diff options
| author | Yong He <yonghe@outlook.com> | 2024-07-25 15:00:14 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-25 15:00:14 -0700 |
| commit | c9d89a40775a055873adf82cfb0ee1cb6bdcb93c (patch) | |
| tree | 2438f353e87b30febe966ca23976793637c018d2 /source/slang/slang-ast-builder.cpp | |
| parent | 1343ab79fcd0ff9e5ffebbcf95414e51ab19e9cd (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-ast-builder.cpp')
| -rw-r--r-- | source/slang/slang-ast-builder.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/source/slang/slang-ast-builder.cpp b/source/slang/slang-ast-builder.cpp index a672c1b7e..ce4c32c3a 100644 --- a/source/slang/slang-ast-builder.cpp +++ b/source/slang/slang-ast-builder.cpp @@ -290,9 +290,9 @@ Type* ASTBuilder::getSpecializedBuiltinType(ArrayView<Val*> genericArgs, const c return rsType; } -PtrType* ASTBuilder::getPtrType(Type* valueType) +PtrType* ASTBuilder::getPtrType(Type* valueType, AddressSpace addrSpace) { - return dynamicCast<PtrType>(getPtrType(valueType, "PtrType")); + return dynamicCast<PtrType>(getPtrType(valueType, addrSpace, "PtrType")); } // Construct the type `Out<valueType>` @@ -306,9 +306,9 @@ InOutType* ASTBuilder::getInOutType(Type* valueType) return dynamicCast<InOutType>(getPtrType(valueType, "InOutType")); } -RefType* ASTBuilder::getRefType(Type* valueType) +RefType* ASTBuilder::getRefType(Type* valueType, AddressSpace addrSpace) { - return dynamicCast<RefType>(getPtrType(valueType, "RefType")); + return dynamicCast<RefType>(getPtrType(valueType, addrSpace, "RefType")); } ConstRefType* ASTBuilder::getConstRefType(Type* valueType) @@ -327,6 +327,12 @@ PtrTypeBase* ASTBuilder::getPtrType(Type* valueType, char const* ptrTypeName) return as<PtrTypeBase>(getSpecializedBuiltinType(valueType, ptrTypeName)); } +PtrTypeBase* ASTBuilder::getPtrType(Type* valueType, AddressSpace addrSpace, char const* ptrTypeName) +{ + Val* args[] = { valueType, getIntVal(getUInt64Type(), (IntegerLiteralValue)addrSpace) }; + return as<PtrTypeBase>(getSpecializedBuiltinType(makeArrayView(args), ptrTypeName)); +} + ArrayExpressionType* ASTBuilder::getArrayType(Type* elementType, IntVal* elementCount) { if (!elementCount) |
