diff options
| -rw-r--r-- | mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h | 2 | ||||
| -rw-r--r-- | mlir/test/Conversion/GPUToSPIRV/load-store.mlir (renamed from mlir/test/Conversion/GPUToSPIRV/load_store.mlir) | 0 | ||||
| -rw-r--r-- | mlir/test/Conversion/StandardToSPIRV/std-to-spirv.mlir (renamed from mlir/test/Conversion/StandardToSPIRV/op_conversion.mlir) | 82 |
3 files changed, 50 insertions, 34 deletions
diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h b/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h index 56182aedac8..417d0e1bb72 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h @@ -15,7 +15,7 @@ // limitations under the License. // ============================================================================= // -// Defines, utilities and base classes to use while targeting SPIR-V dialect. +// Defines utilities to use while targeting SPIR-V dialect. // //===----------------------------------------------------------------------===// diff --git a/mlir/test/Conversion/GPUToSPIRV/load_store.mlir b/mlir/test/Conversion/GPUToSPIRV/load-store.mlir index daa975becaf..daa975becaf 100644 --- a/mlir/test/Conversion/GPUToSPIRV/load_store.mlir +++ b/mlir/test/Conversion/GPUToSPIRV/load-store.mlir diff --git a/mlir/test/Conversion/StandardToSPIRV/op_conversion.mlir b/mlir/test/Conversion/StandardToSPIRV/std-to-spirv.mlir index d0effdd3fe4..3e1b4420b1b 100644 --- a/mlir/test/Conversion/StandardToSPIRV/op_conversion.mlir +++ b/mlir/test/Conversion/StandardToSPIRV/std-to-spirv.mlir @@ -1,5 +1,18 @@ // RUN: mlir-opt -convert-std-to-spirv %s -o - | FileCheck %s +//===----------------------------------------------------------------------===// +// std binary arithmetic ops +//===----------------------------------------------------------------------===// + +// CHECK-LABEL: @add_sub +func @add_sub(%arg0 : i32, %arg1 : i32) { + // CHECK: spv.IAdd + %0 = addi %arg0, %arg1 : i32 + // CHECK: spv.ISub + %1 = subi %arg0, %arg1 : i32 + return +} + // CHECK-LABEL: @fmul_scalar func @fmul_scalar(%arg: f32) -> f32 { // CHECK: spv.FMul @@ -44,23 +57,21 @@ func @fmul_tensor(%arg: tensor<4xf32>) -> tensor<4xf32> { return %0 : tensor<4xf32> } -// CHECK-LABEL: @constval -func @constval() { - // CHECK: spv.constant true - %0 = constant true - // CHECK: spv.constant 42 : i64 - %1 = constant 42 - // CHECK: spv.constant {{[0-9]*\.[0-9]*e?-?[0-9]*}} : f32 - %2 = constant 0.5 : f32 - // CHECK: spv.constant dense<[2, 3]> : vector<2xi32> - %3 = constant dense<[2, 3]> : vector<2xi32> - // CHECK: spv.constant 1 : i32 - %4 = constant 1 : index +// CHECK-LABEL: @div_rem +func @div_rem(%arg0 : i32, %arg1 : i32) { + // CHECK: spv.SDiv + %0 = divis %arg0, %arg1 : i32 + // CHECK: spv.SMod + %1 = remis %arg0, %arg1 : i32 return } -// CHECK-LABEL: @cmpiop -func @cmpiop(%arg0 : i32, %arg1 : i32) { +//===----------------------------------------------------------------------===// +// std.cmpi +//===----------------------------------------------------------------------===// + +// CHECK-LABEL: @cmpi +func @cmpi(%arg0 : i32, %arg1 : i32) { // CHECK: spv.IEqual %0 = cmpi "eq", %arg0, %arg1 : i32 // CHECK: spv.INotEqual @@ -76,28 +87,33 @@ func @cmpiop(%arg0 : i32, %arg1 : i32) { return } -// CHECK-LABEL: @select -func @selectOp(%arg0 : i32, %arg1 : i32) { - %0 = cmpi "sle", %arg0, %arg1 : i32 - // CHECK: spv.Select - %1 = select %0, %arg0, %arg1 : i32 - return -} +//===----------------------------------------------------------------------===// +// std.constant +//===----------------------------------------------------------------------===// -// CHECK-LABEL: @div_rem -func @div_rem(%arg0 : i32, %arg1 : i32) { - // CHECK: spv.SDiv - %0 = divis %arg0, %arg1 : i32 - // CHECK: spv.SMod - %1 = remis %arg0, %arg1 : i32 +// CHECK-LABEL: @constant +func @constant() { + // CHECK: spv.constant true + %0 = constant true + // CHECK: spv.constant 42 : i64 + %1 = constant 42 + // CHECK: spv.constant {{[0-9]*\.[0-9]*e?-?[0-9]*}} : f32 + %2 = constant 0.5 : f32 + // CHECK: spv.constant dense<[2, 3]> : vector<2xi32> + %3 = constant dense<[2, 3]> : vector<2xi32> + // CHECK: spv.constant 1 : i32 + %4 = constant 1 : index return } -// CHECK-LABEL: @add_sub -func @add_sub(%arg0 : i32, %arg1 : i32) { - // CHECK: spv.IAdd - %0 = addi %arg0, %arg1 : i32 - // CHECK: spv.ISub - %1 = subi %arg0, %arg1 : i32 +//===----------------------------------------------------------------------===// +// std.select +//===----------------------------------------------------------------------===// + +// CHECK-LABEL: @select +func @select(%arg0 : i32, %arg1 : i32) { + %0 = cmpi "sle", %arg0, %arg1 : i32 + // CHECK: spv.Select + %1 = select %0, %arg0, %arg1 : i32 return } |

