Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gccjit] add more operations #6

Merged
merged 5 commits into from
Oct 24, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
more
SchrodingerZhu committed Oct 24, 2024
commit 8eec254e14846ac02d8bac1b15936da34ad04c34
55 changes: 48 additions & 7 deletions include/mlir-gccjit/IR/GCCJITOps.td
Original file line number Diff line number Diff line change
@@ -291,9 +291,11 @@ def LocalOp : GCCJIT_Op<"local", [ParentOneOf<["FuncOp"]>]> {
);
let results = (outs GCCJIT_LValueType:$var);
let assemblyFormat = [{
(`reg` `(` $reg_name^ `)`)?
(`align` `(` $alignment^ `)`)?
(`tls_model` `(` $tls_model^ `)`)?
oilist (
`reg` `(` $reg_name `)` |
`align` `(` $alignment `)` |
`tls_model` `(` $tls_model `)`
)
`:` type($var) attr-dict
}];
}
@@ -363,12 +365,12 @@ def SizeOfOp : GCCJIT_Op<"sizeof", [Pure]> {
}];
}

def ArrayOp : GCCJIT_Op<"array"> {
def NewArrayOp : GCCJIT_Op<"new_array"> {
let summary = "Construct an array";
let description = [{
The "array" operation constructs an array from a list of elements.
```mlir
%array = gccjit.array !gccjit.array<i32, 3> [%1, %2, %3]
%array = gccjit.new_array !gccjit.array<i32, 3> [%1, %2, %3]
```
}];
let arguments = (ins Variadic<AnyType>:$elements);
@@ -378,12 +380,51 @@ def ArrayOp : GCCJIT_Op<"array"> {
}];
}

def VectorOp : GCCJIT_Op<"vector"> {
def NewStructOp : GCCJIT_Op<"new_struct"> {
let summary = "Construct a struct";
let description = [{
The "struct" operation constructs a struct from a list of elements.
Each value has to have the same unqualified type as the field it is applied to.
```mlir
%struct = gccjit.new_struct [0, 1] [%1, %2] : (!i32, !i32) -> !gccjit.struct<(!i32, !i32)>
```
}];
let arguments = (ins
DenseI32ArrayAttr:$indices,
Variadic<AnyType>:$elements
);
// TODO: Add support for struct type.
let results = (outs AnyType:$result);
let assemblyFormat = [{
$indices `[` $elements `]` `:` functional-type(operands, results) attr-dict
}];
}

def NewUnionOp : GCCJIT_Op<"new_union"> {
let summary = "Construct a union";
let description = [{
The "union" operation constructs a union from a list of elements.
Each value has to have the same unqualified type as the field it is applied to.
```mlir
%union = gccjit.new_union %1 at 0 : !i32, !gccjit.union<(!i32)>
```
}];
let arguments = (ins
AnyType:$element,
IndexAttr:$index
);
let results = (outs AnyType:$result);
let assemblyFormat = [{
$element `at` $index `:` type($element) `,` type($result) attr-dict
}];
}

def NewVectorOp : GCCJIT_Op<"new_vector"> {
let summary = "Construct a vector";
let description = [{
The "vector" operation constructs a vector from a list of elements.
```mlir
%vector = gccjit.vector !gccjit.vector<i32, 4> [%1, %2, %3, %4]
%vector = gccjit.new_vector !gccjit.vector<i32, 4> [%1, %2, %3, %4]
```
}];
let arguments = (ins Variadic<AnyType>:$elements);