summaryrefslogtreecommitdiff
path: root/source/slang/slang-lower-to-ir.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-07-25 15:00:14 -0700
committerGitHub <noreply@github.com>2024-07-25 15:00:14 -0700
commitc9d89a40775a055873adf82cfb0ee1cb6bdcb93c (patch)
tree2438f353e87b30febe966ca23976793637c018d2 /source/slang/slang-lower-to-ir.cpp
parent1343ab79fcd0ff9e5ffebbcf95414e51ab19e9cd (diff)
Overhaul IR lowering of pointer types. (#4710)
* Overhaul IR lowering of pointer types. * Propagate address space in IRBuilder. * Fixup. * Fix. * Fix. * Change how Ptr type is printed to text. * Fix.
Diffstat (limited to 'source/slang/slang-lower-to-ir.cpp')
-rw-r--r--source/slang/slang-lower-to-ir.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp
index d3770753c..74aa0a0ee 100644
--- a/source/slang/slang-lower-to-ir.cpp
+++ b/source/slang/slang-lower-to-ir.cpp
@@ -1855,8 +1855,16 @@ struct ValLoweringVisitor : ValVisitor<ValLoweringVisitor, LoweredValInfo, Lower
auto astValueType = type->getValueType();
IRType* irValueType = lowerType(context, astValueType);
-
- return getBuilder()->getPtrType(irValueType);
+ IRInst* addrSpace = nullptr;
+ if (auto astAddrSpace = type->getAddressSpace())
+ {
+ addrSpace = getSimpleVal(context, lowerVal(context, astAddrSpace));
+ }
+ else
+ {
+ addrSpace = getBuilder()->getIntValue(getBuilder()->getUInt64Type(), (IRIntegerValue)AddressSpace::Generic);
+ }
+ return getBuilder()->getPtrType(kIROp_PtrType, irValueType, addrSpace);
}
IRType* visitDeclRefType(DeclRefType* type)
@@ -3138,7 +3146,7 @@ void _lowerFuncDeclBaseTypeInfo(
irParamType = builder->getInOutType(irParamType);
break;
case kParameterDirection_Ref:
- irParamType = builder->getRefType(irParamType);
+ irParamType = builder->getRefType(irParamType, AddressSpace::Generic);
break;
case kParameterDirection_ConstRef:
irParamType = builder->getConstRefType(irParamType);
@@ -4972,7 +4980,6 @@ struct ExprLoweringVisitorBase : public ExprVisitor<Derived, LoweredValInfo>
case LoweredValInfo::Flavor::Ptr:
return LoweredValInfo::ptr(
builder->emitElementAddress(
- context->irBuilder->getPtrType(type),
baseVal.val,
indexVal));