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.cpp76
1 files changed, 76 insertions, 0 deletions
diff --git a/source/slang/ir.cpp b/source/slang/ir.cpp
index 60e983711..6899e1494 100644
--- a/source/slang/ir.cpp
+++ b/source/slang/ir.cpp
@@ -1763,6 +1763,48 @@ namespace Slang
return inst;
}
+ IRInst* IRBuilder::emitExtractExistentialValue(
+ IRType* type,
+ IRInst* existentialValue)
+ {
+ auto inst = createInst<IRInst>(
+ this,
+ kIROp_ExtractExistentialValue,
+ type,
+ 1,
+ &existentialValue);
+ addInst(inst);
+ return inst;
+ }
+
+ IRType* IRBuilder::emitExtractExistentialType(
+ IRInst* existentialValue)
+ {
+ auto type = getTypeKind();
+ auto inst = createInst<IRInst>(
+ this,
+ kIROp_ExtractExistentialType,
+ type,
+ 1,
+ &existentialValue);
+ addInst(inst);
+ return (IRType*) inst;
+ }
+
+ IRInst* IRBuilder::emitExtractExistentialWitnessTable(
+ IRInst* existentialValue)
+ {
+ auto type = getWitnessTableType();
+ auto inst = createInst<IRInst>(
+ this,
+ kIROp_ExtractExistentialWitnessTable,
+ type,
+ 1,
+ &existentialValue);
+ addInst(inst);
+ return inst;
+ }
+
IRInst* IRBuilder::emitSpecializeInst(
IRType* type,
IRInst* genericVal,
@@ -1871,6 +1913,15 @@ namespace Slang
return emitIntrinsicInst(type, kIROp_makeStruct, argCount, args);
}
+ IRInst* IRBuilder::emitMakeExistential(
+ IRType* type,
+ IRInst* value,
+ IRInst* witnessTable)
+ {
+ IRInst* args[] = {value, witnessTable};
+ return emitIntrinsicInst(type, kIROp_MakeExistential, SLANG_COUNT_OF(args), args);
+ }
+
IRModule* IRBuilder::createModule()
{
auto module = new IRModule();
@@ -2035,6 +2086,16 @@ namespace Slang
return structType;
}
+ IRInterfaceType* IRBuilder::createInterfaceType()
+ {
+ IRInterfaceType* interfaceType = createInst<IRInterfaceType>(
+ this,
+ kIROp_InterfaceType,
+ nullptr);
+ addGlobalValue(this, interfaceType);
+ return interfaceType;
+ }
+
IRStructKey* IRBuilder::createStructKey()
{
IRStructKey* structKey = createInst<IRStructKey>(
@@ -5992,6 +6053,18 @@ namespace Slang
return clonedStruct;
}
+
+ IRInterfaceType* cloneInterfaceTypeImpl(
+ IRSpecContextBase* context,
+ IRBuilder* builder,
+ IRInterfaceType* originalInterface,
+ IROriginalValuesForClone const& originalValues)
+ {
+ auto clonedInterface = builder->createInterfaceType();
+ cloneSimpleGlobalValueImpl(context, originalInterface, originalValues, clonedInterface);
+ return clonedInterface;
+ }
+
void cloneGlobalValueWithCodeCommon(
IRSpecContextBase* context,
IRGlobalValueWithCode* clonedValue,
@@ -6431,6 +6504,9 @@ namespace Slang
case kIROp_StructType:
return cloneStructTypeImpl(context, builder, cast<IRStructType>(originalInst), originalValues);
+ case kIROp_InterfaceType:
+ return cloneInterfaceTypeImpl(context, builder, cast<IRInterfaceType>(originalInst), originalValues);
+
case kIROp_Generic:
return cloneGenericImpl(context, builder, cast<IRGeneric>(originalInst), originalValues);