1 #include "mlir/IR/BuiltinAttributes.h" 2 #include "mlir/IR/BuiltinTypes.h" 3 #include "mlir/IR/Identifier.h" 4 #include "mlir/IR/Location.h" 5 #include "mlir/IR/MLIRContext.h" 6 #include "mlir/IR/OperationSupport.h" 7 8 mlir::MLIRContext Context; 9 10 auto Identifier = mlir::Identifier::get("foo", &Context); 11 mlir::OperationName OperationName("FooOp", &Context); 12 mlir::Value Value({reinterpret_cast<void *>(0x8), 13 mlir::Value::Kind::TrailingOpResult}); 14 15 mlir::Type Type(nullptr); 16 mlir::Type IndexType = mlir::IndexType::get(&Context); 17 mlir::Type IntegerType = 18 mlir::IntegerType::get(&Context, 3, mlir::IntegerType::Unsigned); 19 mlir::Type FloatType = mlir::Float32Type::get(&Context); 20 mlir::Type MemRefType = mlir::MemRefType::get({4, 5}, FloatType); 21 mlir::Type UnrankedMemRefType = mlir::UnrankedMemRefType::get(IntegerType, 6); 22 mlir::Type VectorType = mlir::VectorType::get({1, 2}, FloatType); 23 mlir::Type TupleType = 24 mlir::TupleType::get(&Context, mlir::TypeRange({IndexType, FloatType})); 25 26 auto UnknownLoc = mlir::UnknownLoc::get(&Context); 27 auto FileLineColLoc = mlir::FileLineColLoc::get(&Context, "file", 7, 8); 28 auto OpaqueLoc = mlir::OpaqueLoc::get<uintptr_t>(9, &Context); 29 auto NameLoc = mlir::NameLoc::get(Identifier); 30 auto CallSiteLoc = mlir::CallSiteLoc::get(FileLineColLoc, OpaqueLoc); 31 auto FusedLoc = mlir::FusedLoc::get(&Context, {FileLineColLoc, NameLoc}); 32 33 mlir::Attribute UnitAttr = mlir::UnitAttr::get(&Context); 34 mlir::Attribute FloatAttr = mlir::FloatAttr::get(FloatType, 1.0); 35 mlir::Attribute IntegerAttr = mlir::IntegerAttr::get(IntegerType, 10); 36 mlir::Attribute TypeAttr = mlir::TypeAttr::get(IndexType); 37 mlir::Attribute ArrayAttr = mlir::ArrayAttr::get(&Context, {UnitAttr}); 38 mlir::Attribute StringAttr = mlir::StringAttr::get(&Context, "foo"); 39 mlir::Attribute ElementsAttr = mlir::DenseElementsAttr::get( 40 VectorType.cast<mlir::ShapedType>(), llvm::ArrayRef<float>{2.0f, 3.0f}); 41 42 int main() { return 0; } 43