Skip to content

Commit

Permalink
hl: Clean up tablegen code style.
Browse files Browse the repository at this point in the history
  • Loading branch information
xlauko committed May 31, 2024
1 parent 831a7f2 commit e9360d0
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 18 deletions.
7 changes: 6 additions & 1 deletion include/vast/Dialect/HighLevel/HighLevelAttributes.td
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class NameAttr<string name, string attr_mnemonic>
: HighLevel_Attr< name, attr_mnemonic >
{
let parameters = (ins "::mlir::StringAttr":$name);

let builders = [
AttrBuilderWithInferredContext<(ins "::mlir::StringAttr":$name), [{
return get(name.getContext(), name);
Expand Down Expand Up @@ -52,6 +53,7 @@ def ReturnsTwiceAttr : HighLevel_Attr< "ReturnsTwice", "returns_twice" >;

def AsmLabelAttr : HighLevel_Attr< "AsmLabel", "asm" > {
let parameters = (ins "::mlir::StringAttr":$label, "bool":$isLiteral);

let builders = [
AttrBuilderWithInferredContext<(ins "::mlir::StringAttr":$label, "bool":$literal), [{
return get(label.getContext(), label, literal);
Expand All @@ -66,6 +68,7 @@ def AsmLabelAttr : HighLevel_Attr< "AsmLabel", "asm" > {

def ModeAttr : HighLevel_Attr< "Mode", "mode" > {
let parameters = (ins "::mlir::StringAttr":$mode);

let builders = [
AttrBuilderWithInferredContext<(ins "::mlir::StringAttr":$mode), [{
return get(mode.getContext(), mode);
Expand All @@ -80,6 +83,7 @@ def ModeAttr : HighLevel_Attr< "Mode", "mode" > {

def BuiltinAttr : HighLevel_Attr< "Builtin", "builtin" > {
let parameters = (ins "unsigned":$ID);

let assemblyFormat = "`<` $ID `>`";
}

Expand All @@ -98,7 +102,8 @@ def AllocSizeAttr : HighLevel_Attr< "AllocSize", "alloc_size" > {
def DeprecatedAttr : HighLevel_Attr< "Deprecated", "deprecated" > {
let parameters = (ins
"::mlir::StringAttr":$message,
"::mlir::StringAttr":$fixit);
"::mlir::StringAttr":$fixit
);

let builders = [
AttrBuilder<(ins "::mlir::StringRef":$msg, "::mlir::StringRef":$fix), [{
Expand Down
50 changes: 33 additions & 17 deletions include/vast/Dialect/HighLevel/HighLevelOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -468,16 +468,23 @@ def ConstantOp
def InitializedConstantOp : HighLevel_Op< "const.init", [ConstantLike, Pure] >
, Results< (outs AnyType:$result) >
{
let summary = "VAST value constant";
let description = [{ VAST value constant witch requires region initialization }];
let summary = "VAST constant with non-trivial initialization";
let description = [{
InitializedConstantOp is used to represent a constant with non-trivial
initialization. The initialization is represented by a region that
represents initialization expression.
}];

let regions = (region ValueRegion:$init);

let skipDefaultBuilders = 1;
let builders = [
OpBuilder<(ins
"Type":$type,
"builder_callback":$initbuilder
)>
];

let assemblyFormat = [{ attr-dict `:` type($result) `=` $init }];
}

Expand All @@ -490,18 +497,24 @@ def UnreachableOp : HighLevel_Op<"unreachable", [Terminator]> {
def CompoundLiteralOp : HighLevel_Op< "compound_literal" >
, Results< (outs AnyType:$result) >
{
let summary = "VAST operation for building compound literals.";
let description = [{ Creates a compound literal that represents an unnamed object
and is initialzied by initializer-list.}];
let summary = "VAST compound literals operation";
let description = [{
Creates a compound literal that represents an unnamed object and is
initialzied by initializer-list.

Is used to represetnt `clang::CompoundLiteralExpr`.
}];

let regions = (region ValueRegion:$init);

let skipDefaultBuilders = 1;
let builders = [
OpBuilder<(ins
"Type":$type,
"builder_callback":$initbuilder
)>
];

let assemblyFormat = [{ attr-dict `:` type($result) `=` $init }];
}

Expand Down Expand Up @@ -763,12 +776,12 @@ class StandardArithBinOp< string mnemonic, list< Trait > traits = [] >
class FloatArithBinOp< string mnemonic, list< Trait > traits = [] >
: ArithBinOp< mnemonic, traits >
{
let hasVerifier = 1;
let extraClassDefinition = [{
let hasVerifier = 1;
let extraClassDefinition = [{
logical_result $cppClass::verify() {
return verify_float_arith_op(this->getOperation());
return verify_float_arith_op(this->getOperation());
}
}];
}];
}

def AddIOp : ArithBinOp< "add", [Commutative, IsAdditive< "lhs", "rhs", "result" >] >;
Expand Down Expand Up @@ -1288,8 +1301,8 @@ def IdentKind : IdentKindList< "IdentKind", "ident kind", [

def PredefinedExpr
: HighLevel_Op< "predefined.expr" >
, Arguments<(ins AnyType:$value, IdentKind:$kind)>
, Results<(outs AnyType:$result)>
, Arguments<(ins AnyType:$value, IdentKind:$kind)>
, Results<(outs AnyType:$result)>
{
let summary = "VAT predefined expr ( such as __func__ )";
let description = [{ VAT predefined expr ( such as __func__ ) }];
Expand All @@ -1299,8 +1312,8 @@ def PredefinedExpr

def ExtensionOp
: HighLevel_Op< "gnu.extension" >
, Arguments<(ins AnyType:$value)>
, Results<(outs AnyType:$result)>
, Arguments<(ins AnyType:$value)>
, Results<(outs AnyType:$result)>
{
let summary = "VAST extension (__extension__) keyword";
let description = [{ VAST op corresponding to GNU __extension__ keyword. }];
Expand Down Expand Up @@ -1332,11 +1345,12 @@ def AsmOp
)>
{
let summary = "VAST operation for inline assembly";
let description = [{ VAST operation mirroring the GCCAsmStmt in clang AST. It prints
a name for every operand (either its id or user-supplied string).}];
let description = [{
VAST operation mirroring the GCCAsmStmt in clang AST. It prints a name for
every operand (either its id or user-supplied string).
}];

let skipDefaultBuilders = 1;

let builders = [
OpBuilder< (ins
"mlir::StringAttr":$asm_template,
Expand All @@ -1353,7 +1367,9 @@ def AsmOp
) >
];

let assemblyFormat = [{attr-dict $asm_template `(`($output_names $asm_outputs^ `:` $output_constraints)? `)` `(` (`ins` `:`$input_names $asm_inputs^ `:` $input_constraints)? `)` `(`( $clobbers^)?`)` `(`( $labels^)?`)` `:` functional-type(operands, results)}];
let assemblyFormat = [{
attr-dict $asm_template `(`($output_names $asm_outputs^ `:` $output_constraints)? `)` `(` (`ins` `:`$input_names $asm_inputs^ `:` $input_constraints)? `)` `(`( $clobbers^)?`)` `(`( $labels^)?`)` `:` functional-type(operands, results)
}];
}

def VAArgExpr
Expand Down

0 comments on commit e9360d0

Please sign in to comment.