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.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp
index 19d3ce59a..46d6d445d 100644
--- a/source/slang/slang-ir.cpp
+++ b/source/slang/slang-ir.cpp
@@ -2203,15 +2203,24 @@ namespace Slang
return static_cast<IRStringLit*>(_findOrEmitConstant(keyInst));
}
- IRPtrLit* IRBuilder::getPtrValue(void* value)
+ IRPtrLit* IRBuilder::_getPtrValue(void* data)
{
- IRType* type = getPtrType(getVoidType());
+ auto type = getPtrType(getVoidType());
+ IRConstant keyInst;
+ memset(&keyInst, 0, sizeof(keyInst));
+ keyInst.m_op = kIROp_PtrLit;
+ keyInst.typeUse.usedValue = type;
+ keyInst.value.ptrVal = data;
+ return (IRPtrLit*)_findOrEmitConstant(keyInst);
+ }
+ IRPtrLit* IRBuilder::getNullPtrValue(IRType* type)
+ {
IRConstant keyInst;
memset(&keyInst, 0, sizeof(keyInst));
keyInst.m_op = kIROp_PtrLit;
keyInst.typeUse.usedValue = type;
- keyInst.value.ptrVal = value;
+ keyInst.value.ptrVal = nullptr;
return (IRPtrLit*) _findOrEmitConstant(keyInst);
}
@@ -4589,6 +4598,9 @@ namespace Slang
switch (managedPtrType->getOp())
{
case kIROp_InterfaceType:
+ return emitIntrinsicInst(
+ getPtrType(getNativePtrType((IRType*)managedPtrType)), kIROp_GetManagedPtrWriteRef, 1, &ptrToManagedPtr);
+ break;
case kIROp_ComPtrType:
return emitIntrinsicInst(
getPtrType(getNativePtrType((IRType*)managedPtrType->getOperand(0))), kIROp_GetManagedPtrWriteRef, 1, &ptrToManagedPtr);
@@ -4651,7 +4663,7 @@ namespace Slang
void IRBuilder::addHighLevelDeclDecoration(IRInst* inst, Decl* decl)
{
- auto ptrConst = getPtrValue(decl);
+ auto ptrConst = _getPtrValue(decl);
addDecoration(inst, kIROp_HighLevelDeclDecoration, ptrConst);
}
@@ -6193,6 +6205,7 @@ namespace Slang
case kIROp_PackAnyValue:
case kIROp_UnpackAnyValue:
case kIROp_Reinterpret:
+ case kIROp_GetNativePtr:
return false;
}
}