Skip to content

Commit 3527e24

Browse files
mofeingPangoraw
andauthored
Refactor and clean IR module (#62)
* Reimplement `Context` * Reimplement `Dialect` * Reimplement `Location` * Reimplement `Value` * Reimplement `Block` * Move `BlockIterator` * Refactor `first_op` * Refactor `mlirIsNull` calls in `Block` * Reimplement `Region` * Reimplement `Module` * Fix namespaces in `Location` * Refactor `Type` to `Core.Type` to avoid import * Remove unused arg name from `iterator(::BlockIterator)` * Fix namespace calls under `API` * Refactor constructors * Refactor `Context` code * Refactor `Dialect` code * Fix typo in exported symbol * Fix typo in returned value in `enable_multithreading!` * Document some code * Refactor code * Reimplement `Operation` * Remove commented code * Export symbols from `IR` * Reimplement `TypeID` * Move iterators to new file * Fix missing module name in function calls * Remove `MLIRType` from tblgen generator * Refactor `MLIRType` from brutus example * Remove duplicate `get_or_load_dialect!` method * Fix missing module name in symbol refs * Refactor `MLIRType` in tests * Add `Identifier` * Add `SymbolTable` * Implement `IntegerSet` * Add `AffineExpr` type * Throw message on assert fail in `AffineExpr` constructor * Add `AffineMap` type * Fix `Context` kwargs * Import `@affinemap` macro from #35 Co-authored-by: Paul Berg <[email protected]> * Fix `@affinemap` * Implement `LogicalResult` * Fix typo in `move_after!` * Add `rmfromparent!` for `Operation` * Reimplement `Type` * Reorder includes * Fix `Type` clash in `LogicalResult` * Reimplement `Attribute` * Refactor `MLIRType` to `IR.Type` in dialect bindings * Fix `mlir*IsNull` calls `mlir*IsNull` are only defined in headers (no symbol in libs), so binding is generated but fails to look for the symbol * Apply suggestion from @Pangoraw Co-authored-by: Paul Berg <[email protected]> * Apply suggestion from @Pangoraw Co-authored-by: Paul Berg <[email protected]> * Apply suggestion by @Pangoraw Co-authored-by: Paul Berg <[email protected]> * Fix typos * Fix ambiguity * Fix typos * Remove redundant exports * Fix type value retrieval of `Attribute` for integers * Apply suggestion by @Pangoraw * Refactor `@affinemap` * Remove invalid assert in `@affinemap` * Fix extra namespace inside macro * Fix `mlir_str` macro * Fix `verifyall` * Rename `next_in_region` to `next` * Add `OpOperand` type (LLVM 16) * Fix `mlirOpPrintingFlagsEnableDebugInfo` on LLVM 15,16 * Add `@llvmversioned` macro utility * Add Float8 types * Add support for `DenseArray` attributes * Remove `isopaquelements` on LLVM 16 * Fix typos in `OpOperand` * Fix namespace in `DenseArrayAttribute` * Refactor `operandsegmentsizes` * Fix import in Julia 1.10 * Fix max versioning in `@llvmversioned` * Fix `DenseElementsAttribute` docstrings * Fix docstring warning in methods with `@llvmversioned` * Fix docstring of `type` * Fix `mlirIsNull` calls * Fix `LogicalResult` methods `mlirLogicalResult*` functions in the C-API are header-only * Fix `LogicalResult` calls in pass infrastructure * Update Brutus example * Comment `mlirOperationWriteBytecode` * Use signless integer types in MLIR for `<:Signed` types in Julia * Fix `Bool` to MLIR conversion * Fix tests * Update docs * Fix 0-indexing of dims and symbol expressions in `@affinemap` * Refactor `PassManager`,`OpPassManager` * Add `ExecutionEngine` * Fix docstring of `Type(Complex{T})` * Refactor `TensorType` constructor * Refactor `push_argument!` * Apply suggestion by @Pangoraw Co-authored-by: Paul Berg <[email protected]> * Refactor `create_operation` * Fix `push_arguent!` * Try fix `load_all_available_dialects` call in Julia 1.9 --------- Co-authored-by: Paul Berg <[email protected]>
1 parent 8267af4 commit 3527e24

File tree

149 files changed

+18904
-16195
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

149 files changed

+18904
-16195
lines changed

deps/tblgen/jl-generators.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ bool emitOpTableDefs(const llvm::RecordKeeper &recordKeeper,
170170
const char *moduleTemplate;
171171
if (disableModuleWrap)
172172
{
173-
moduleTemplate = R"(import ...IR: NamedAttribute, MLIRType, Value, Location, Block, Region, Attribute, create_operation, context, IndexType
173+
moduleTemplate = R"(import ...IR: IR, NamedAttribute, Value, Location, Block, Region, Attribute, create_operation, context, IndexType
174174
import ..Dialects: namedattribute, operandsegmentsizes
175175
import ...API
176176
@@ -181,7 +181,7 @@ import ...API
181181
{
182182
moduleTemplate = R"(module {0}
183183
184-
import ...IR: NamedAttribute, MLIRType, Value, Location, Block, Region, Attribute, create_operation, context, IndexType
184+
import ...IR: NamedAttribute, Value, Location, Block, Region, Attribute, create_operation, context, IndexType
185185
import ..Dialects: namedattribute, operandsegmentsizes
186186
import ...API
187187
@@ -196,7 +196,7 @@ function {0}({1}location=Location())
196196
{2}
197197
end
198198
)"; // 0: functionname, 1: functionarguments, 2: functionbody
199-
const char *functionbodytemplate = R"(results = MLIRType[{0}]
199+
const char *functionbodytemplate = R"(results = IR.Type[{0}]
200200
operands = Value[{1}]
201201
owned_regions = Region[{2}]
202202
successors = Block[{3}]
@@ -321,7 +321,7 @@ end
321321
resultname = "result_" + std::to_string(i);
322322
}
323323
resultname = sanitizeName(resultname);
324-
std::string type = "MLIRType";
324+
std::string type = "IR.Type";
325325

326326
bool optional = named_result.isOptional() || inferrable;
327327
bool variadic = named_result.isVariadic();

docs/make.jl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,28 @@ makedocs(;
4040
pages = [
4141
"Home" => "index.md",
4242
"Examples" => examples,
43+
"IR" => [
44+
"AffineExpr" => "IR/affineexpr.md",
45+
"AffineMap" => "IR/affinemap.md",
46+
"Attribute" => "IR/attribute.md",
47+
"Block" => "IR/block.md",
48+
"Context" => "IR/context.md",
49+
"Dialect" => "IR/dialect.md",
50+
"Identifier" => "IR/identifier.md",
51+
"IntegerSet" => "IR/integerset.md",
52+
"Iterators" => "IR/iterators.md",
53+
"Location" => "IR/location.md",
54+
"LogicalResult" => "IR/logicalresult.md",
55+
"Module" => "IR/module.md",
56+
"Operation" => "IR/operation.md",
57+
# TODO `OpOperand` for LLVM >=16
58+
"Pass Infrastucture" => "IR/pass.md",
59+
"Region" => "IR/region.md",
60+
"SymbolTable" => "IR/symboltable.md",
61+
"Type" => "IR/type.md",
62+
"TypeID" => "IR/typeid.md",
63+
"Value" => "IR/value.md",
64+
],
4365
"Dialects" => [
4466
"15" => [
4567
"`affine`" => "dialects/affine.md",

docs/src/IR/affineexpr.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Affine Expressions
2+
3+
```@autodocs
4+
Modules = [MLIR.IR]
5+
Pages = ["IR/AffineExpr.jl"]
6+
```

docs/src/IR/affinemap.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Affine Map
2+
3+
```@autodocs
4+
Modules = [MLIR.IR]
5+
Pages = ["IR/AffineMap.jl"]
6+
```

docs/src/IR/attribute.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Attribute
2+
3+
```@autodocs
4+
Modules = [MLIR.IR]
5+
Pages = ["IR/Attribute.jl"]
6+
```

docs/src/IR/block.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Block
2+
3+
```@autodocs
4+
Modules = [MLIR.IR]
5+
Pages = ["IR/Block.jl"]
6+
```

docs/src/IR/context.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Context
2+
3+
```@autodocs
4+
Modules = [MLIR.IR]
5+
Pages = ["IR/Context.jl"]
6+
```

docs/src/IR/dialect.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Dialect
2+
3+
```@autodocs
4+
Modules = [MLIR.IR]
5+
Pages = ["IR/Dialect.jl"]
6+
```

docs/src/IR/identifier.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Identifier
2+
3+
```@autodocs
4+
Modules = [MLIR.IR]
5+
Pages = ["IR/Identifier.jl"]
6+
```

docs/src/IR/integerset.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Integer Set
2+
3+
```@autodocs
4+
Modules = [MLIR.IR]
5+
Pages = ["IR/IntegerSet.jl"]
6+
```

0 commit comments

Comments
 (0)