================
@@ -54,10 +54,41 @@ class CommonSPIRTargetCIRGenInfo : public TargetCIRGenInfo {
       ft = getABIInfo().cgt.getASTContext().adjustFunctionType(
           ft, ft->getExtInfo().withCallingConv(CC_DeviceKernel));
   }
+
+  mlir::Value getNullPointer(CIRGenModule &cgm, cir::PointerType ptrTy,
+                             QualType qt, mlir::Location loc) const override;
 };
 
 } // namespace
 
+// The bit pattern of null in non-generic AS is unspecified for SPIR(-V), so
+// materialize it via an address space cast from null in generic AS.
+mlir::Value
+CommonSPIRTargetCIRGenInfo::getNullPointer(CIRGenModule &cgm,
+                                           cir::PointerType ptrTy, QualType qt,
+                                           mlir::Location loc) const {
+  LangAS as = qt->getUnqualifiedDesugaredType()->isNullPtrType()
+                  ? LangAS::Default
+                  : qt->getPointeeType().getAddressSpace();
+  unsigned asAsInt = static_cast<unsigned>(as);
+  unsigned firstTargetASAsInt =
+      static_cast<unsigned>(LangAS::FirstTargetAddressSpace);
+  unsigned codeSectionINTELAS = firstTargetASAsInt + 9;
----------------
steffenlarsen wrote:

At least the `constexpr` tells a more of a story. Thanks!

https://github.com/llvm/llvm-project/pull/228559
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to