[clang] [CIR][SYCL] Implement SYCLUniqueStableNameExpr codegen (PR #231209)

Konstantinos Parasyris via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 13 08:05:22 PDT 2026


================
@@ -1828,6 +1824,24 @@ mlir::Value ScalarExprEmitter::emitCompoundAssign(
   return emitLoadOfLValue(lhs, e->getExprLoc());
 }
 
+mlir::Value
+ScalarExprEmitter::VisitSYCLUniqueStableNameExpr(SYCLUniqueStableNameExpr *e) {
+  ASTContext &context = cgf.getContext();
+  mlir::Location loc = cgf.getLoc(e->getSourceRange());
+  cir::GlobalOp globalConstStr =
+      cgf.cgm.createGlobalString(loc, e->ComputeName(context), "__usn_str");
+
+  // Unlike LLVM IR, CIR pointers are typed, so the bitcast and the address
+  // space cast are emitted as separate operations when both are needed.
+  mlir::Value addr = builder.createGetGlobal(loc, globalConstStr);
+  auto exprTy = mlir::cast<cir::PointerType>(convertType(e->getType()));
+  auto addrTy = mlir::cast<cir::PointerType>(addr.getType());
+  if (addrTy.getAddrSpace() != exprTy.getAddrSpace())
+    addr = cgf.performAddrSpaceCast(
+        addr, builder.getPointerTo(addrTy.getPointee(), exprTy.getAddrSpace()));
+  return builder.createBitcast(loc, addr, exprTy);
----------------
koparasy wrote:

I guess there are quite some places that do this "dance". We should have a separate PR that cleans up all of those. Thnx!

https://github.com/llvm/llvm-project/pull/231209


More information about the cfe-commits mailing list