|
| 1 | +// Copyright (c) 2025 Roberto Raggi < [email protected]> |
| 2 | +// |
| 3 | +// Permission is hereby granted, free of charge, to any person obtaining a copy |
| 4 | +// of this software and associated documentation files (the "Software"), to deal |
| 5 | +// in the Software without restriction, including without limitation the rights |
| 6 | +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 7 | +// copies of the Software, and to permit persons to whom the Software is |
| 8 | +// furnished to do so, subject to the following conditions: |
| 9 | +// |
| 10 | +// The above copyright notice and this permission notice shall be included in |
| 11 | +// all copies or substantial portions of the Software. |
| 12 | +// |
| 13 | +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 14 | +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 15 | +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 16 | +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 17 | +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 18 | +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 19 | +// SOFTWARE. |
| 20 | + |
| 21 | +include "mlir/IR/OpBase.td" |
| 22 | +include "mlir/IR/AttrTypeBase.td" |
| 23 | + |
| 24 | +def Cxx_Dialect : Dialect { |
| 25 | + let name = "cxx"; |
| 26 | + let cppNamespace = "mlir::cxx"; |
| 27 | + let useDefaultTypePrinterParser = 1; |
| 28 | + let dependentDialects = [ |
| 29 | + "mlir::func::FuncDialect", |
| 30 | + "mlir::cf::ControlFlowDialect", |
| 31 | + ]; |
| 32 | +} |
| 33 | + |
| 34 | +class Cxx_Type<string name, string typeMnemonic, list<Trait> traits = []> : TypeDef<Cxx_Dialect, name, traits> { |
| 35 | + let mnemonic = typeMnemonic; |
| 36 | +} |
| 37 | + |
| 38 | +class Cxx_Op<string mnemonic, list<Trait> traits = []> : Op<Cxx_Dialect, mnemonic, traits> { |
| 39 | +} |
| 40 | + |
| 41 | +def Cxx_ExprType : Cxx_Type<"Expr", "expr">; |
| 42 | + |
| 43 | +def Cxx_TodoExprOp : Cxx_Op<"todo.expr"> { |
| 44 | + let arguments = (ins StrAttr:$message); |
| 45 | + let results = (outs Cxx_ExprType:$result); |
| 46 | + let assemblyFormat = "$message attr-dict `:` type($result)"; |
| 47 | + let builders = [ |
| 48 | + OpBuilder<(ins "::llvm::StringRef":$message), |
| 49 | + [{ build($_builder, $_state, $_builder.getType<ExprType>(), message); }]>, |
| 50 | + ]; |
| 51 | +} |
| 52 | + |
| 53 | +def Cxx_TodoStmtOp : Cxx_Op<"todo.stmt"> { |
| 54 | + let arguments = (ins StrAttr:$message); |
| 55 | + let results = (outs); |
| 56 | + let assemblyFormat = "$message attr-dict"; |
| 57 | +} |
0 commit comments