let parser = "return parseGlobalOp(parser, result);";
- let printer = [{
- if (linkName().hasValue())
- p << ' ' << linkName().getValue();
- p << ' ';
- p.printAttributeWithoutType((*this)->getAttr(symbolAttrName()));
- if (auto val = getValueOrNull())
- p << '(' << val << ')';
- if (constantAttr())
- p << " constant";
- p << " : ";
- p.printType(getType());
- if (hasInitializationBody())
- p.printRegion((*this)->getRegion(0), /*printEntryBlockArgs=*/false,
- /*printBlockTerminators=*/true);
- }];
+ let printer = "::print(p, *this);";
let skipDefaultBuilders = 1;
let builders = [
let extraClassDeclaration = [{
static constexpr llvm::StringRef symbolAttrName() { return "symref"; }
+ static constexpr llvm::StringRef getConstantAttrName() {
+ return "constant";
+ }
static constexpr llvm::StringRef linkageAttrName() { return "linkName"; }
/// The printable type of the global
return mlir::success();
}
+static void print(mlir::OpAsmPrinter &p, fir::GlobalOp &op) {
+ if (op.linkName().hasValue())
+ p << ' ' << op.linkName().getValue();
+ p << ' ';
+ p.printAttributeWithoutType(
+ op.getOperation()->getAttr(fir::GlobalOp::symbolAttrName()));
+ if (auto val = op.getValueOrNull())
+ p << '(' << val << ')';
+ if (op.getOperation()->getAttr(fir::GlobalOp::getConstantAttrName()))
+ p << " constant";
+ p << " : ";
+ p.printType(op.getType());
+ if (op.hasInitializationBody())
+ p.printRegion(op.getOperation()->getRegion(0),
+ /*printEntryBlockArgs=*/false,
+ /*printBlockTerminators=*/true);
+}
+
void fir::GlobalOp::appendInitialValue(mlir::Operation *op) {
getBlock().getOperations().push_back(op);
}