-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dialects: Add LLVM InlineAsm op (#2203)
This PR adds the LLVM InlineAsm op, which allows to bake in inline assembly from within MLIR. There's an additional attribute to select the inline assembly dialect (not dialect in context of MLIR, choices are AT&T or Intel). I just implemented this as an `IntegerAttr`.
- Loading branch information
1 parent
8d74fbf
commit 0be2ab3
Showing
3 changed files
with
87 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// RUN: XDSL_ROUNDTRIP | ||
|
||
%0 = "test.op"() : () -> i32 | ||
%1 = "test.op"() : () -> i32 | ||
"llvm.inline_asm"(%0, %1) <{asm_string = "csrw $0, $1", constraints = "i, r"}> {has_side_effect} : (i32, i32) -> () | ||
|
||
%2 = "test.op"() : () -> vector<8xf32> | ||
%3 = "test.op"() : () -> vector<8xf32> | ||
%4 = "llvm.inline_asm"(%2, %3) <{asm_dialect = 1 : i64, asm_string = "vaddps $0, $1, $2", constraints = "=x,x,x"}> : (vector<8xf32>, vector<8xf32>) -> vector<8xf32> | ||
|
||
// CHECK: %0 = "test.op"() : () -> i32 | ||
// CHECK-NEXT: 1 = "test.op"() : () -> i32 | ||
// CHECK-NEXT: "llvm.inline_asm"(%0, %1) <{"asm_string" = "csrw $0, $1", "constraints" = "i, r"}> {"has_side_effect"} : (i32, i32) -> () | ||
// CHECK-NEXT: %2 = "test.op"() : () -> vector<8xf32> | ||
// CHECK-NEXT: %3 = "test.op"() : () -> vector<8xf32> | ||
// CHECK-NEXT: %4 = "llvm.inline_asm"(%2, %3) <{"asm_dialect" = 1 : i64, "asm_string" = "vaddps $0, $1, $2", "constraints" = "=x,x,x"}> : (vector<8xf32>, vector<8xf32>) -> vector<8xf32> |
16 changes: 16 additions & 0 deletions
16
tests/filecheck/mlir-conversion/with-mlir/dialects/llvm/inline_asm.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/// RUN: mlir-opt %s --mlir-print-op-generic | xdsl-opt --print-op-generic | filecheck %s | ||
|
||
%0 = "test.op"() : () -> i32 | ||
%1 = "test.op"() : () -> i32 | ||
"llvm.inline_asm"(%0, %1) <{asm_string = "csrw $0, $1", constraints = "i, r"}> {has_side_effect} : (i32, i32) -> () | ||
|
||
%2 = "test.op"() : () -> vector<8xf32> | ||
%3 = "test.op"() : () -> vector<8xf32> | ||
%4 = "llvm.inline_asm"(%2, %3) <{asm_dialect = 1 : i64, asm_string = "vaddps $0, $1, $2", constraints = "=x,x,x"}> : (vector<8xf32>, vector<8xf32>) -> vector<8xf32> | ||
|
||
// CHECK: %0 = "test.op"() : () -> i32 | ||
// CHECK-NEXT: 1 = "test.op"() : () -> i32 | ||
// CHECK-NEXT: "llvm.inline_asm"(%0, %1) <{"asm_string" = "csrw $0, $1", "constraints" = "i, r"}> {"has_side_effect"} : (i32, i32) -> () | ||
// CHECK-NEXT: %2 = "test.op"() : () -> vector<8xf32> | ||
// CHECK-NEXT: %3 = "test.op"() : () -> vector<8xf32> | ||
// CHECK-NEXT: %4 = "llvm.inline_asm"(%2, %3) <{"asm_dialect" = 1 : i64, "asm_string" = "vaddps $0, $1, $2", "constraints" = "=x,x,x"}> : (vector<8xf32>, vector<8xf32>) -> vector<8xf32> |
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