summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-ir.cpp')
-rw-r--r--source/slang/slang-ir.cpp63
1 files changed, 62 insertions, 1 deletions
diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp
index c66f0d555..fd7cbe408 100644
--- a/source/slang/slang-ir.cpp
+++ b/source/slang/slang-ir.cpp
@@ -2587,7 +2587,7 @@ namespace Slang
IRAnyValueType* IRBuilder::getAnyValueType(IRIntegerValue size)
{
return (IRAnyValueType*)getType(kIROp_AnyValueType,
- getIntValue(getIntType(), size));
+ getIntValue(getUIntType(), size));
}
IRAnyValueType* IRBuilder::getAnyValueType(IRInst* size)
@@ -2624,6 +2624,11 @@ namespace Slang
return (IRResultType*)getType(kIROp_ResultType, 2, operands);
}
+ IROptionalType* IRBuilder::getOptionalType(IRType* valueType)
+ {
+ return (IROptionalType*)getType(kIROp_OptionalType, valueType);
+ }
+
IRBasicBlockType* IRBuilder::getBasicBlockType()
{
return (IRBasicBlockType*)getType(kIROp_BasicBlockType);
@@ -2971,6 +2976,11 @@ namespace Slang
return inst;
}
+ IRInst* IRBuilder::emitReinterpret(IRInst* type, IRInst* value)
+ {
+ return emitIntrinsicInst((IRType*)type, kIROp_Reinterpret, 1, &value);
+ }
+
IRLiveRangeStart* IRBuilder::emitLiveRangeStart(IRInst* referenced)
{
// This instruction doesn't produce any result,
@@ -3323,6 +3333,42 @@ namespace Slang
&result);
}
+ IRInst* IRBuilder::emitOptionalHasValue(IRInst* optValue)
+ {
+ return emitIntrinsicInst(
+ getBoolType(),
+ kIROp_OptionalHasValue,
+ 1,
+ &optValue);
+ }
+
+ IRInst* IRBuilder::emitGetOptionalValue(IRInst* optValue)
+ {
+ return emitIntrinsicInst(
+ cast<IROptionalType>(optValue->getDataType())->getValueType(),
+ kIROp_GetOptionalValue,
+ 1,
+ &optValue);
+ }
+
+ IRInst* IRBuilder::emitMakeOptionalValue(IRInst* optType, IRInst* value)
+ {
+ return emitIntrinsicInst(
+ (IRType*)optType,
+ kIROp_MakeOptionalValue,
+ 1,
+ &value);
+ }
+
+ IRInst* IRBuilder::emitMakeOptionalNone(IRInst* optType, IRInst* defaultValue)
+ {
+ return emitIntrinsicInst(
+ (IRType*)optType,
+ kIROp_MakeOptionalNone,
+ 1,
+ &defaultValue);
+ }
+
IRInst* IRBuilder::emitMakeVector(
IRType* type,
UInt argCount,
@@ -3819,6 +3865,14 @@ namespace Slang
return inst;
}
+ IRInst* IRBuilder::emitIsType(IRInst* value, IRInst* witness, IRInst* typeOperand, IRInst* targetWitness)
+ {
+ IRInst* args[] = { value, witness, typeOperand, targetWitness };
+ auto inst = createInst<IRIsType>(this, kIROp_IsType, getBoolType(), SLANG_COUNT_OF(args), args);
+ addInst(inst);
+ return inst;
+ }
+
IRInst* IRBuilder::emitFieldExtract(
IRType* type,
IRInst* base,
@@ -6079,6 +6133,10 @@ namespace Slang
case kIROp_GetResultError:
case kIROp_GetResultValue:
case kIROp_IsResultError:
+ case kIROp_MakeOptionalValue:
+ case kIROp_MakeOptionalNone:
+ case kIROp_OptionalHasValue:
+ case kIROp_GetOptionalValue:
case kIROp_Load: // We are ignoring the possibility of loads from bad addresses, or `volatile` loads
case kIROp_ImageSubscript:
case kIROp_FieldExtract:
@@ -6118,6 +6176,9 @@ namespace Slang
case kIROp_WrapExistential:
case kIROp_BitCast:
case kIROp_AllocObj:
+ case kIROp_PackAnyValue:
+ case kIROp_UnpackAnyValue:
+ case kIROp_Reinterpret:
return false;
}
}