From c9d89a40775a055873adf82cfb0ee1cb6bdcb93c Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 25 Jul 2024 15:00:14 -0700 Subject: 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. --- source/slang/slang-lower-to-ir.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'source/slang/slang-lower-to-ir.cpp') 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 : ValVisitorgetValueType(); 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 case LoweredValInfo::Flavor::Ptr: return LoweredValInfo::ptr( builder->emitElementAddress( - context->irBuilder->getPtrType(type), baseVal.val, indexVal)); -- cgit v1.2.3