[Mlir-commits] [mlir] EmitC: Add emitc.global and emitc.get_global (#145) (PR #88701)
Simon Camphausen
llvmlistbot at llvm.org
Mon Apr 22 06:21:24 PDT 2024
================
@@ -1384,6 +1403,30 @@ LogicalResult CppEmitter::emitVariableDeclaration(OpResult result,
return success();
}
+LogicalResult CppEmitter::emitGlobalVariable(GlobalOp op) {
+ if (op.getExternSpecifier())
+ os << "extern ";
+ else if (op.getStaticSpecifier())
+ os << "static ";
+ if (op.getConstSpecifier())
+ os << "const ";
+
+ if (failed(emitVariableDeclaration(op->getLoc(), op.getType(),
+ op.getSymName()))) {
+ return failure();
+ }
+
+ std::optional<Attribute> initialValue = op.getInitialValue();
+ if (initialValue && !isa<UnitAttr>(*initialValue)) {
----------------
simon-camp wrote:
```suggestion
if (initialValue) {
```
https://github.com/llvm/llvm-project/pull/88701
More information about the Mlir-commits
mailing list