[clang] [CIR] Add metadata type, attributes and metadata_as_value op. (PR #204190)

Rana Pratap Reddy via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 19 00:14:11 PDT 2026


================
@@ -464,6 +464,21 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
     return cir::ConstantOp::create(*this, loc, cir::ZeroAttr::get(ty));
   }
 
+  //===--------------------------------------------------------------------===//
+  // Metadata creation helpers
+  //===--------------------------------------------------------------------===//
+  cir::MDStringAttr getMDStringAttr(llvm::StringRef str) {
+    return cir::MDStringAttr::get(getContext(), getStringAttr(str));
+  }
+
+  cir::MDNodeAttr getMDNodeAttr(llvm::ArrayRef<mlir::Attribute> operands) {
+    return cir::MDNodeAttr::get(getContext(), operands);
+  }
+
+  mlir::Value createMetadataAsValue(mlir::Location loc, mlir::Attribute md) {
+    return cir::MetadataAsValueOp::create(*this, loc, md);
----------------
ranapratap55 wrote:

This omits the result type, but the other cir::MetadataAsValueOp::create() in CIRDialect.cpp passes it explicitly.

Could you confirm generated .inc for a MetadataAsValueOp::build overload that omits the result type?

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


More information about the cfe-commits mailing list