================
@@ -120,6 +120,31 @@ class NVPTXTargetCIRGenInfo : public TargetCIRGenInfo {
mlir::Type getCUDADeviceBuiltinTextureDeviceType() const override {
return cir::CUDADeviceTextureType::get(&getABIInfo().cgt.getMLIRContext());
}
+
+ // A null pointer in the local address space is materialized via an address
+ // space cast from null in the generic address space, so that it converts
+ // back to a generic null pointer.
+ mlir::Value getNullPointer(CIRGenModule &cgm, cir::PointerType ptrTy,
+ QualType qt, mlir::Location loc) const override {
+ CIRGenBuilderTy &builder = cgm.getBuilder();
+ // The local address space is either a language address space or an
+ // explicit target address space at this point.
+ mlir::ptr::MemorySpaceAttrInterface addrSpace = ptrTy.getAddrSpace();
+ auto targetAS =
+ mlir::dyn_cast_if_present<cir::TargetAddressSpaceAttr>(addrSpace);
+ bool isLocal =
+ cir::isMatchingAddressSpace(addrSpace, LangAS::opencl_local) ||
+ (targetAS &&
+ targetAS.getValue() ==
+ cgm.getASTContext().getTargetAddressSpace(LangAS::opencl_local));
----------------
Qi-Ye-079 wrote:
In SYCL, besides the common `address_space(N)` attribute, it has its own
standard address space attribute:
```
int __attribtue__((address_space(3))) *p; // explicit address space number
int [[clang::sycl_local]] *p; // language address space; standard and
portable SYCL attribute
```
So to make it work for SYCL, we need to check both, as programmers can use any
of the 2 flavors.
Lines 136 and 137-139 can have different results when the programmer specifies
conflicting address spaces using the 2 flavors at the same time on a single
variable, like `int [[clang::sycl_global]] __attribtue__((address_space(3)))
*p`. But we don't need to handle this here because Sema check will simply
reject it with `error: multiple address spaces specified for type` error.
https://github.com/llvm/llvm-project/pull/237387
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits