[Mlir-commits] [mlir] [MLIR] emitc: Add emitc translation unit op (PR #123298)
Simon Camphausen
llvmlistbot at llvm.org
Fri Jan 17 01:33:20 PST 2025
================
@@ -56,6 +57,54 @@ def IntegerIndexOrOpaqueType : Type<CPred<"emitc::isIntegerIndexOrOpaqueType($_s
"integer, index or opaque type supported by EmitC">;
def FloatIntegerIndexOrOpaqueType : AnyTypeOf<[EmitCFloatType, IntegerIndexOrOpaqueType]>;
+def EmitC_TranslationUnitOp
+ : EmitC_Op<"tu", [IsolatedFromAbove, NoRegionArguments, SymbolTable,
+ OpAsmOpInterface]#GraphRegionNoTerminator.traits> {
+ let summary = "A translation unit container operation";
+ let description = [{
+ A `tu` represents a translation unit that can be emitted
+ into a single C++ file.
+
+ `mlir-translate` emits only the translation unit selected via
+ the `-translation-unit-id=id` flag. By default, no translation units are
+ emitted.
+
+ Example:
+
+ ```mlir
+ emitc.tu "main" {
+ emitc.func @func_one() {
+ emitc.return
+ }
+ }
+ ```
+ }];
+
+ let arguments = (ins Builtin_StringAttr:$id);
+ let regions = (region SizedRegion<1>:$bodyRegion);
+
+ let assemblyFormat = "$id attr-dict-with-keyword $bodyRegion";
+ let builders = [OpBuilder<(ins CArg<"StringRef">:$id)>];
+ let extraClassDeclaration = [{
+ /// Construct a module from the given location with an optional name.
----------------
simon-camp wrote:
```suggestion
/// Construct a translation_unit from the given location with the given name.
```
https://github.com/llvm/llvm-project/pull/123298
More information about the Mlir-commits
mailing list