• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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(3, mlir::IntegerType::Unsigned, &Context);
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(mlir::TypeRange({IndexType, FloatType}), &Context);
25 
26 auto UnknownLoc = mlir::UnknownLoc::get(&Context);
27 auto FileLineColLoc = mlir::FileLineColLoc::get("file", 7, 8, &Context);
28 auto OpaqueLoc = mlir::OpaqueLoc::get<uintptr_t>(9, &Context);
29 auto NameLoc = mlir::NameLoc::get(Identifier, &Context);
30 auto CallSiteLoc = mlir::CallSiteLoc::get(FileLineColLoc, OpaqueLoc);
31 auto FusedLoc = mlir::FusedLoc::get({FileLineColLoc, NameLoc}, &Context);
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({UnitAttr}, &Context);
38 mlir::Attribute StringAttr = mlir::StringAttr::get("foo", &Context);
39 mlir::Attribute ElementsAttr = mlir::DenseElementsAttr::get(
40     VectorType.cast<mlir::ShapedType>(), llvm::ArrayRef<float>{2.0f, 3.0f});
41 
main()42 int main() { return 0; }
43