summaryrefslogtreecommitdiffstats
path: root/source/slang/ir.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/ir.cpp')
-rw-r--r--source/slang/ir.cpp64
1 files changed, 64 insertions, 0 deletions
diff --git a/source/slang/ir.cpp b/source/slang/ir.cpp
index 48716bd87..8f33034b7 100644
--- a/source/slang/ir.cpp
+++ b/source/slang/ir.cpp
@@ -1731,6 +1731,18 @@ namespace Slang
operands);
}
+ IRType* IRBuilder::getTaggedUnionType(
+ UInt caseCount,
+ IRType* const* caseTypes)
+ {
+ return (IRType*) findOrEmitHoistableInst(
+ this,
+ getTypeKind(),
+ kIROp_TaggedUnionType,
+ caseCount,
+ (IRInst* const*) caseTypes);
+ }
+
void IRBuilder::setDataType(IRInst* inst, IRType* dataType)
{
if (auto oldRateQualifiedType = as<IRRateQualifiedType>(inst->getFullType()))
@@ -2684,6 +2696,50 @@ namespace Slang
return inst;
}
+ IRInst* IRBuilder::emitExtractTaggedUnionTag(
+ IRInst* val)
+ {
+ auto inst = createInst<IRInst>(
+ this,
+ kIROp_ExtractTaggedUnionTag,
+ getBasicType(BaseType::UInt),
+ val);
+ addInst(inst);
+ return inst;
+ }
+
+ IRInst* IRBuilder::emitExtractTaggedUnionPayload(
+ IRType* type,
+ IRInst* val,
+ IRInst* tag)
+ {
+ auto inst = createInst<IRInst>(
+ this,
+ kIROp_ExtractTaggedUnionPayload,
+ type,
+ val,
+ tag);
+ addInst(inst);
+ return inst;
+ }
+
+ IRInst* IRBuilder::emitBitCast(
+ IRType* type,
+ IRInst* val)
+ {
+ auto inst = createInst<IRInst>(
+ this,
+ kIROp_BitCast,
+ type,
+ val);
+ addInst(inst);
+ return inst;
+ }
+
+ //
+ // Decorations
+ //
+
IRDecoration* IRBuilder::addDecoration(IRInst* value, IROp op, IRInst* const* operands, Int operandCount)
{
auto decoration = createInstWithTrailingArgs<IRDecoration>(
@@ -3796,6 +3852,14 @@ namespace Slang
}
}
+ void IRInst::transferDecorationsTo(IRInst* target)
+ {
+ while( auto decoration = getFirstDecoration() )
+ {
+ decoration->removeFromParent();
+ decoration->insertAtStart(target);
+ }
+ }
bool IRInst::mightHaveSideEffects()
{