1//===- EmitCAttributes.td - EmitC attributes ---------------*- tablegen -*-===// 2// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6// 7//===----------------------------------------------------------------------===// 8// 9// Defines the MLIR EmitC attributes. 10// 11//===----------------------------------------------------------------------===// 12 13#ifndef MLIR_DIALECT_EMITC_IR_EMITCATTRIBUTES 14#define MLIR_DIALECT_EMITC_IR_EMITCATTRIBUTES 15 16include "mlir/IR/AttrTypeBase.td" 17include "mlir/IR/BuiltinAttributeInterfaces.td" 18include "mlir/IR/EnumAttr.td" 19include "mlir/Dialect/EmitC/IR/EmitCBase.td" 20 21//===----------------------------------------------------------------------===// 22// EmitC attribute definitions 23//===----------------------------------------------------------------------===// 24 25class EmitC_Attr<string name, string attrMnemonic, list<Trait> traits = []> 26 : AttrDef<EmitC_Dialect, name, traits> { 27 let mnemonic = attrMnemonic; 28} 29 30def EmitC_CmpPredicateAttr : I64EnumAttr< 31 "CmpPredicate", "", 32 [ 33 I64EnumAttrCase<"eq", 0>, 34 I64EnumAttrCase<"ne", 1>, 35 I64EnumAttrCase<"lt", 2>, 36 I64EnumAttrCase<"le", 3>, 37 I64EnumAttrCase<"gt", 4>, 38 I64EnumAttrCase<"ge", 5>, 39 I64EnumAttrCase<"three_way", 6>, 40 ]> { 41 let cppNamespace = "::mlir::emitc"; 42} 43 44def EmitC_OpaqueAttr : EmitC_Attr<"Opaque", "opaque"> { 45 let summary = "An opaque attribute"; 46 47 let description = [{ 48 An opaque attribute of which the value gets emitted as is. 49 50 Example: 51 52 ```mlir 53 #emitc.opaque<""> 54 #emitc.opaque<"NULL"> 55 #emitc.opaque<"nullptr"> 56 ``` 57 }]; 58 59 let parameters = (ins StringRefParameter<"the opaque value">:$value); 60 let assemblyFormat = "`<` $value `>`"; 61} 62 63def EmitC_OpaqueOrTypedAttr : AnyAttrOf<[EmitC_OpaqueAttr, TypedAttrInterface]>; 64 65#endif // MLIR_DIALECT_EMITC_IR_EMITCATTRIBUTES 66