|
19 | 19 | #include "clang/CIR/Dialect/IR/FPEnv.h" |
20 | 20 | #include "clang/CIR/MissingFeatures.h" |
21 | 21 |
|
| 22 | +#include "mlir/Dialect/Ptr/IR/MemorySpaceInterfaces.h" |
22 | 23 | #include "mlir/IR/Attributes.h" |
23 | 24 | #include "mlir/IR/Builders.h" |
24 | 25 | #include "mlir/IR/BuiltinAttributes.h" |
25 | 26 | #include "mlir/IR/BuiltinOps.h" |
26 | 27 | #include "mlir/IR/BuiltinTypes.h" |
27 | 28 | #include "mlir/IR/Location.h" |
28 | 29 | #include "mlir/IR/Types.h" |
| 30 | +#include "mlir/Support/LLVM.h" |
29 | 31 | #include "llvm/ADT/APSInt.h" |
30 | 32 | #include "llvm/ADT/ArrayRef.h" |
31 | 33 | #include "llvm/ADT/FloatingPointMode.h" |
@@ -107,34 +109,30 @@ class CIRBaseBuilderTy : public mlir::OpBuilder { |
107 | 109 | } |
108 | 110 |
|
109 | 111 | /// Create a pointer type with an address space attribute. |
110 | | - /// Either a cir::ClangAddressSpaceAttr or cir::TargetAddressSpaceAttr is |
111 | | - /// expected. |
112 | | - cir::PointerType getPointerTo(mlir::Type ty, mlir::Attribute addrSpaceAttr) { |
113 | | - if (!addrSpaceAttr) |
| 112 | + cir::PointerType |
| 113 | + getPointerTo(mlir::Type ty, mlir::ptr::MemorySpaceAttrInterface memorySpace) { |
| 114 | + if (!memorySpace) |
114 | 115 | return cir::PointerType::get(ty); |
115 | | - |
116 | | - assert((mlir::isa<cir::ClangAddressSpaceAttr>(addrSpaceAttr) || |
117 | | - mlir::isa<cir::TargetAddressSpaceAttr>(addrSpaceAttr)) && |
118 | | - "expected address space attribute"); |
119 | | - |
120 | | - return cir::PointerType::get(ty, addrSpaceAttr); |
| 116 | + return cir::PointerType::get(ty, memorySpace); |
121 | 117 | } |
122 | 118 |
|
123 | 119 | cir::PointerType getPointerTo(mlir::Type ty, clang::LangAS langAS) { |
124 | 120 | if (langAS == clang::LangAS::Default) |
125 | 121 | return getPointerTo(ty); |
126 | 122 |
|
127 | | - mlir::Attribute addrSpaceAttr = |
| 123 | + mlir::ptr::MemorySpaceAttrInterface addrSpaceAttr = |
128 | 124 | cir::toCIRClangAddressSpaceAttr(getContext(), langAS); |
| 125 | + // Convert to MemorySpaceAttrInterface for the interface overload |
129 | 126 | return getPointerTo(ty, addrSpaceAttr); |
130 | 127 | } |
131 | 128 |
|
132 | 129 | cir::PointerType getVoidPtrTy(clang::LangAS langAS = clang::LangAS::Default) { |
133 | 130 | return getPointerTo(cir::VoidType::get(getContext()), langAS); |
134 | 131 | } |
135 | 132 |
|
136 | | - cir::PointerType getVoidPtrTy(mlir::Attribute addrSpaceAttr) { |
137 | | - return getPointerTo(cir::VoidType::get(getContext()), addrSpaceAttr); |
| 133 | + cir::PointerType |
| 134 | + getVoidPtrTy(mlir::ptr::MemorySpaceAttrInterface memorySpace) { |
| 135 | + return getPointerTo(cir::VoidType::get(getContext()), memorySpace); |
138 | 136 | } |
139 | 137 |
|
140 | 138 | cir::MethodAttr getMethodAttr(cir::MethodType ty, cir::FuncOp methodFuncOp) { |
@@ -432,7 +430,8 @@ class CIRBaseBuilderTy : public mlir::OpBuilder { |
432 | 430 | mlir::Value createGetGlobal(mlir::Location loc, cir::GlobalOp global, |
433 | 431 | bool threadLocal = false) { |
434 | 432 | return cir::GetGlobalOp::create( |
435 | | - *this, loc, getPointerTo(global.getSymType(), global.getAddrSpace()), |
| 433 | + *this, loc, |
| 434 | + getPointerTo(global.getSymType(), global.getAddrSpaceAttr()), |
436 | 435 | global.getName(), threadLocal); |
437 | 436 | } |
438 | 437 |
|
|
0 commit comments