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 13 mlir::Type Type(nullptr); 14 mlir::Type IndexType = mlir::IndexType::get(&Context); 15 mlir::Type IntegerType = 16 mlir::IntegerType::get(&Context, 3, mlir::IntegerType::Unsigned); 17 mlir::Type FloatType = mlir::Float32Type::get(&Context); 18 mlir::Type MemRefType = mlir::MemRefType::get({4, 5}, FloatType); 19 mlir::Type UnrankedMemRefType = mlir::UnrankedMemRefType::get(IntegerType, 6); 20 mlir::Type VectorType = mlir::VectorType::get({1, 2}, FloatType); 21 mlir::Type TupleType = 22 mlir::TupleType::get(&Context, mlir::TypeRange({IndexType, FloatType})); 23 24 25 mlir::detail::OutOfLineOpResult Result(FloatType, 42); 26 mlir::Value Value(&Result); 27 28 auto UnknownLoc = mlir::UnknownLoc::get(&Context); 29 auto FileLineColLoc = mlir::FileLineColLoc::get(&Context, "file", 7, 8); 30 auto OpaqueLoc = mlir::OpaqueLoc::get<uintptr_t>(9, &Context); 31 auto NameLoc = mlir::NameLoc::get(Identifier); 32 auto CallSiteLoc = mlir::CallSiteLoc::get(FileLineColLoc, OpaqueLoc); 33 auto FusedLoc = mlir::FusedLoc::get(&Context, {FileLineColLoc, NameLoc}); 34 35 mlir::Attribute UnitAttr = mlir::UnitAttr::get(&Context); 36 mlir::Attribute FloatAttr = mlir::FloatAttr::get(FloatType, 1.0); 37 mlir::Attribute IntegerAttr = mlir::IntegerAttr::get(IntegerType, 10); 38 mlir::Attribute TypeAttr = mlir::TypeAttr::get(IndexType); 39 mlir::Attribute ArrayAttr = mlir::ArrayAttr::get(&Context, {UnitAttr}); 40 mlir::Attribute StringAttr = mlir::StringAttr::get(&Context, "foo"); 41 mlir::Attribute ElementsAttr = mlir::DenseElementsAttr::get( 42 VectorType.cast<mlir::ShapedType>(), llvm::ArrayRef<float>{2.0f, 3.0f}); 43 44 int main() { return 0; } 45