-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This custom-parsed op and attribute make it relatively easy to systematically change an `arith.constant` op to `mod_arith`: ``` arith.constant 17 : i32 --> mod_arith.constant 17 : !mod_arith.mod_arith<234 : i32> ``` - comment on getValue nightmare - mod_arith.mod_arith -> mod_arith.int
- Loading branch information
Showing
17 changed files
with
198 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef LIB_DIALECT_MODARITH_IR_MODARITHATTRIBUTES_H_ | ||
#define LIB_DIALECT_MODARITH_IR_MODARITHATTRIBUTES_H_ | ||
|
||
#include "lib/Dialect/ModArith/IR/ModArithDialect.h" | ||
#include "lib/Dialect/ModArith/IR/ModArithTypes.h" | ||
|
||
#define GET_ATTRDEF_CLASSES | ||
#include "lib/Dialect/ModArith/IR/ModArithAttributes.h.inc" | ||
|
||
#endif // LIB_DIALECT_MODARITH_IR_MODARITHATTRIBUTES_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#ifndef LIB_DIALECT_MODARITH_IR_MODARITHATTRS_TD_ | ||
#define LIB_DIALECT_MODARITH_IR_MODARITHATTRS_TD_ | ||
|
||
include "lib/Dialect/ModArith/IR/ModArithDialect.td" | ||
include "lib/Dialect/ModArith/IR/ModArithTypes.td" | ||
include "mlir/IR/BuiltinAttributes.td" | ||
|
||
|
||
class ModArith_Attr<string name, string attrMnemonic, list<Trait> traits = []> | ||
: AttrDef<ModArith_Dialect, name, traits> { | ||
let mnemonic = attrMnemonic; | ||
} | ||
|
||
|
||
def ModArith_ModArithAttr : ModArith_Attr< | ||
"ModArith", "int", [TypedAttrInterface]> { | ||
let summary = "a typed mod_arith attribute"; | ||
let description = [{ | ||
Example: | ||
|
||
```mlir | ||
#attr = 123:i32 | ||
#attr_verbose = #mod_arith.int<123:i32> | ||
``` | ||
}]; | ||
let parameters = (ins "::mlir::heir::mod_arith::ModArithType":$type, "mlir::IntegerAttr":$value); | ||
let assemblyFormat = "$value `:` $type"; | ||
let builders = [ | ||
AttrBuilderWithInferredContext<(ins "ModArithType":$type, | ||
"const int64_t":$value), [{ | ||
return $_get( | ||
type.getContext(), | ||
type, | ||
IntegerAttr::get(type.getModulus().getType(), value)); | ||
}]> | ||
]; | ||
let extraClassDeclaration = [{ | ||
using ValueType = ::mlir::Attribute; | ||
}]; | ||
} | ||
|
||
|
||
#endif // LIB_DIALECT_MODARITH_IR_MODARITHATTRS_TD_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/Dialect/ModArith/Conversions/mod_arith_to_arith/mod-arith-to-arith.mlir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.