1//===- UBOps.td - UB operations definitions ----------------*- 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#ifndef MLIR_DIALECT_UB_IR_UBOPS_TD 10#define MLIR_DIALECT_UB_IR_UBOPS_TD 11 12include "mlir/Interfaces/SideEffectInterfaces.td" 13include "mlir/IR/AttrTypeBase.td" 14 15include "UBOpsInterfaces.td" 16 17def UB_Dialect : Dialect { 18 let name = "ub"; 19 let cppNamespace = "::mlir::ub"; 20 21 let hasConstantMaterializer = 1; 22 let useDefaultAttributePrinterParser = 1; 23} 24 25// Base class for UB dialect attributes. 26class UB_Attr<string name, string attrMnemonic, list<Trait> traits = []> : 27 AttrDef<UB_Dialect, name, traits> { 28 let mnemonic = attrMnemonic; 29} 30 31// Base class for UB dialect ops. 32class UB_Op<string mnemonic, list<Trait> traits = []> : 33 Op<UB_Dialect, mnemonic, traits>; 34 35def PoisonAttr : UB_Attr<"Poison", "poison", [PoisonAttrInterface]> { 36} 37 38//===----------------------------------------------------------------------===// 39// PoisonOp 40//===----------------------------------------------------------------------===// 41 42def PoisonOp : UB_Op<"poison", [ConstantLike, Pure]> { 43 let summary = "Poisoned constant operation."; 44 let description = [{ 45 The `poison` operation materializes a compile-time poisoned constant value 46 to indicate deferred undefined behavior. 47 `value` attribute is needed to indicate an optional additional poison 48 semantics (e.g. partially poisoned vectors), default value indicates results 49 is fully poisoned. 50 51 Examples: 52 53 ``` 54 // Short form 55 %0 = ub.poison : i32 56 // Long form 57 %1 = ub.poison <#custom_poison_elements_attr> : vector<4xi64> 58 ``` 59 }]; 60 61 let arguments = (ins DefaultValuedAttr<PoisonAttrInterface, "{}">:$value); 62 let results = (outs AnyType:$result); 63 64 let assemblyFormat = "attr-dict (`<` $value^ `>`)? `:` type($result)"; 65 66 let hasFolder = 1; 67} 68 69#endif // MLIR_DIALECT_UB_IR_UBOPS_TD 70