================
@@ -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);
----------------
skc7 wrote:
Both create forms exist in the generated `CIROps.cpp.inc`: the type-omitting
one (`create(OpBuilder&, Location, Attribute)`) infers the fixed
`!cir.metadata` result via `inferReturnTypes`, and the explicit-type one
(`create(OpBuilder&, Location, Type, Attribute)`) is used where a Type is
already in hand. `createMetadataAsValue` uses the former. `materializeConstant`
uses the latter. Both build the same op.
https://github.com/llvm/llvm-project/pull/204190
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits