mirror of
https://github.com/intel/llvm.git
synced 2026-01-26 03:56:16 +08:00
Remove the wrapping function in SPIR-V (de)serialization
Previously Module and Function are builtinn constructs in MLIR. Due to the structural requirements we must wrap the SPIR-V module inside a Function inside a Module. Now the requirement is lifted and we can remove the wrapping function! :) PiperOrigin-RevId: 264736051
This commit is contained in:
committed by
A. Unique TensorFlower
parent
cc0d337620
commit
748edce6b8
@@ -33,19 +33,6 @@
|
||||
|
||||
using namespace mlir;
|
||||
|
||||
// Adds a one-block function named as `spirv_module` to `module` and returns the
|
||||
// block. The created block will be terminated by `std.return`.
|
||||
Block *createOneBlockFunction(Builder builder, ModuleOp module) {
|
||||
auto fnType = builder.getFunctionType(/*inputs=*/{}, /*results=*/{});
|
||||
auto fn = FuncOp::create(builder.getUnknownLoc(), "spirv_module", fnType);
|
||||
module.push_back(fn);
|
||||
|
||||
auto *block = fn.addEntryBlock();
|
||||
OpBuilder(block).create<ReturnOp>(builder.getUnknownLoc());
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
// Deserializes the SPIR-V binary module stored in the file named as
|
||||
// `inputFilename` and returns a module containing the SPIR-V module.
|
||||
OwningModuleRef deserializeModule(llvm::StringRef inputFilename,
|
||||
@@ -75,15 +62,9 @@ OwningModuleRef deserializeModule(llvm::StringRef inputFilename,
|
||||
if (!spirvModule)
|
||||
return {};
|
||||
|
||||
// TODO(antiagainst): due to the restriction of the current translation
|
||||
// infrastructure, we must return a MLIR module here. So we are wrapping the
|
||||
// converted SPIR-V ModuleOp inside a MLIR module. This should be changed to
|
||||
// return the SPIR-V ModuleOp directly after module and function are migrated
|
||||
// to be general ops.
|
||||
OwningModuleRef module(ModuleOp::create(
|
||||
FileLineColLoc::get(inputFilename, /*line=*/0, /*column=*/0, context)));
|
||||
Block *block = createOneBlockFunction(builder, module.get());
|
||||
block->push_front(spirvModule->getOperation());
|
||||
module->getBody()->push_front(spirvModule->getOperation());
|
||||
|
||||
return module;
|
||||
}
|
||||
|
||||
@@ -40,22 +40,12 @@ LogicalResult serializeModule(ModuleOp module, StringRef outputFilename) {
|
||||
bool done = false;
|
||||
auto result = failure();
|
||||
|
||||
// TODO(antiagainst): we are checking there is only one SPIR-V ModuleOp in
|
||||
// this module and serialize it. This is due to the restriction of the current
|
||||
// translation infrastructure; we must take in a MLIR module here. So we are
|
||||
// wrapping the SPIR-V ModuleOp inside a MLIR module. This should be changed
|
||||
// to take in the SPIR-V ModuleOp directly after module and function are
|
||||
// migrated to be general ops.
|
||||
for (auto fn : module.getOps<FuncOp>()) {
|
||||
fn.walk<spirv::ModuleOp>([&](spirv::ModuleOp spirvModule) {
|
||||
if (done) {
|
||||
spirvModule.emitError("found more than one 'spv.module' op");
|
||||
return;
|
||||
}
|
||||
for (auto spirvModule : module.getOps<spirv::ModuleOp>()) {
|
||||
if (done)
|
||||
return spirvModule.emitError("found more than one 'spv.module' op");
|
||||
|
||||
done = true;
|
||||
result = spirv::serialize(spirvModule, binary);
|
||||
});
|
||||
done = true;
|
||||
result = spirv::serialize(spirvModule, binary);
|
||||
}
|
||||
|
||||
if (failed(result))
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
// RUN: mlir-translate -serialize-spirv %s | mlir-translate -deserialize-spirv | FileCheck %s
|
||||
|
||||
func @foo() {
|
||||
spv.module "Logical" "VulkanKHR" {
|
||||
func @access_chain(%arg0 : !spv.ptr<!spv.array<4x!spv.array<4xf32>>, Function>,
|
||||
%arg1 : i32, %arg2 : i32) {
|
||||
// CHECK: {{%.*}} = spv.AccessChain {{%.*}}[{{%.*}}] : !spv.ptr<!spv.array<4 x !spv.array<4 x f32>>, Function>
|
||||
// CHECK-NEXT: {{%.*}} = spv.AccessChain {{%.*}}[{{%.*}}, {{%.*}}] : !spv.ptr<!spv.array<4 x !spv.array<4 x f32>>, Function>
|
||||
%1 = spv.AccessChain %arg0[%arg1] : !spv.ptr<!spv.array<4x!spv.array<4xf32>>, Function>
|
||||
%2 = spv.AccessChain %arg0[%arg1, %arg2] : !spv.ptr<!spv.array<4x!spv.array<4xf32>>, Function>
|
||||
spv.Return
|
||||
}
|
||||
spv.module "Logical" "VulkanKHR" {
|
||||
func @access_chain(%arg0 : !spv.ptr<!spv.array<4x!spv.array<4xf32>>, Function>,
|
||||
%arg1 : i32, %arg2 : i32) {
|
||||
// CHECK: {{%.*}} = spv.AccessChain {{%.*}}[{{%.*}}] : !spv.ptr<!spv.array<4 x !spv.array<4 x f32>>, Function>
|
||||
// CHECK-NEXT: {{%.*}} = spv.AccessChain {{%.*}}[{{%.*}}, {{%.*}}] : !spv.ptr<!spv.array<4 x !spv.array<4 x f32>>, Function>
|
||||
%1 = spv.AccessChain %arg0[%arg1] : !spv.ptr<!spv.array<4x!spv.array<4xf32>>, Function>
|
||||
%2 = spv.AccessChain %arg0[%arg1, %arg2] : !spv.ptr<!spv.array<4x!spv.array<4xf32>>, Function>
|
||||
spv.Return
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
// RUN: mlir-translate -serialize-spirv %s | mlir-translate -deserialize-spirv | FileCheck %s
|
||||
|
||||
func @spirvmodule() {
|
||||
spv.module "Logical" "VulkanKHR" {
|
||||
func @array_stride(%arg0 : !spv.ptr<!spv.array<4x!spv.array<4xf32 [4]> [128]>, StorageBuffer>,
|
||||
%arg1 : i32, %arg2 : i32) {
|
||||
// CHECK: {{%.*}} = spv.AccessChain {{%.*}}[{{%.*}}, {{%.*}}] : !spv.ptr<!spv.array<4 x !spv.array<4 x f32 [4]> [128]>, StorageBuffer>
|
||||
%2 = spv.AccessChain %arg0[%arg1, %arg2] : !spv.ptr<!spv.array<4x!spv.array<4xf32 [4]> [128]>, StorageBuffer>
|
||||
spv.Return
|
||||
}
|
||||
spv.module "Logical" "VulkanKHR" {
|
||||
func @array_stride(%arg0 : !spv.ptr<!spv.array<4x!spv.array<4xf32 [4]> [128]>, StorageBuffer>,
|
||||
%arg1 : i32, %arg2 : i32) {
|
||||
// CHECK: {{%.*}} = spv.AccessChain {{%.*}}[{{%.*}}, {{%.*}}] : !spv.ptr<!spv.array<4 x !spv.array<4 x f32 [4]> [128]>, StorageBuffer>
|
||||
%2 = spv.AccessChain %arg0[%arg1, %arg2] : !spv.ptr<!spv.array<4x!spv.array<4xf32 [4]> [128]>, StorageBuffer>
|
||||
spv.Return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,127 +1,124 @@
|
||||
// RUN: mlir-translate -serialize-spirv %s | mlir-translate -deserialize-spirv | FileCheck %s
|
||||
|
||||
func @spirv_bin_ops() -> () {
|
||||
spv.module "Logical" "VulkanKHR" {
|
||||
func @fmul(%arg0 : f32, %arg1 : f32) {
|
||||
// CHECK: {{%.*}}= spv.FMul {{%.*}}, {{%.*}} : f32
|
||||
%0 = spv.FMul %arg0, %arg1 : f32
|
||||
spv.Return
|
||||
}
|
||||
func @fadd(%arg0 : vector<4xf32>, %arg1 : vector<4xf32>) {
|
||||
// CHECK: {{%.*}} = spv.FAdd {{%.*}}, {{%.*}} : vector<4xf32>
|
||||
%0 = spv.FAdd %arg0, %arg1 : vector<4xf32>
|
||||
spv.Return
|
||||
}
|
||||
func @fdiv(%arg0 : vector<4xf32>, %arg1 : vector<4xf32>) {
|
||||
// CHECK: {{%.*}} = spv.FDiv {{%.*}}, {{%.*}} : vector<4xf32>
|
||||
%0 = spv.FDiv %arg0, %arg1 : vector<4xf32>
|
||||
spv.Return
|
||||
}
|
||||
func @fmod(%arg0 : vector<4xf32>, %arg1 : vector<4xf32>) {
|
||||
// CHECK: {{%.*}} = spv.FMod {{%.*}}, {{%.*}} : vector<4xf32>
|
||||
%0 = spv.FMod %arg0, %arg1 : vector<4xf32>
|
||||
spv.Return
|
||||
}
|
||||
func @fsub(%arg0 : vector<4xf32>, %arg1 : vector<4xf32>) {
|
||||
// CHECK: {{%.*}} = spv.FSub {{%.*}}, {{%.*}} : vector<4xf32>
|
||||
%0 = spv.FSub %arg0, %arg1 : vector<4xf32>
|
||||
spv.Return
|
||||
}
|
||||
func @frem(%arg0 : vector<4xf32>, %arg1 : vector<4xf32>) {
|
||||
// CHECK: {{%.*}} = spv.FRem {{%.*}}, {{%.*}} : vector<4xf32>
|
||||
%0 = spv.FRem %arg0, %arg1 : vector<4xf32>
|
||||
spv.Return
|
||||
}
|
||||
func @iadd(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) {
|
||||
// CHECK: {{%.*}} = spv.IAdd {{%.*}}, {{%.*}} : vector<4xi32>
|
||||
%0 = spv.IAdd %arg0, %arg1 : vector<4xi32>
|
||||
spv.Return
|
||||
}
|
||||
func @isub(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) {
|
||||
// CHECK: {{%.*}} = spv.ISub {{%.*}}, {{%.*}} : vector<4xi32>
|
||||
%0 = spv.ISub %arg0, %arg1 : vector<4xi32>
|
||||
spv.Return
|
||||
}
|
||||
func @imul(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) {
|
||||
// CHECK: {{%.*}} = spv.IMul {{%.*}}, {{%.*}} : vector<4xi32>
|
||||
%0 = spv.IMul %arg0, %arg1 : vector<4xi32>
|
||||
spv.Return
|
||||
}
|
||||
func @udiv(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) {
|
||||
// CHECK: {{%.*}} = spv.UDiv {{%.*}}, {{%.*}} : vector<4xi32>
|
||||
%0 = spv.UDiv %arg0, %arg1 : vector<4xi32>
|
||||
spv.Return
|
||||
}
|
||||
func @umod(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) {
|
||||
// CHECK: {{%.*}} = spv.UMod {{%.*}}, {{%.*}} : vector<4xi32>
|
||||
%0 = spv.UMod %arg0, %arg1 : vector<4xi32>
|
||||
spv.Return
|
||||
}
|
||||
func @sdiv(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) {
|
||||
// CHECK: {{%.*}} = spv.SDiv {{%.*}}, {{%.*}} : vector<4xi32>
|
||||
%0 = spv.SDiv %arg0, %arg1 : vector<4xi32>
|
||||
spv.Return
|
||||
}
|
||||
func @smod(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) {
|
||||
// CHECK: {{%.*}} = spv.SMod {{%.*}}, {{%.*}} : vector<4xi32>
|
||||
%0 = spv.SMod %arg0, %arg1 : vector<4xi32>
|
||||
spv.Return
|
||||
}
|
||||
func @srem(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) {
|
||||
// CHECK: {{%.*}} = spv.SRem {{%.*}}, {{%.*}} : vector<4xi32>
|
||||
%0 = spv.SRem %arg0, %arg1 : vector<4xi32>
|
||||
spv.Return
|
||||
}
|
||||
func @iequal_scalar(%arg0: i32, %arg1: i32) {
|
||||
// CHECK: {{.*}} = spv.IEqual {{.*}}, {{.*}} : i32
|
||||
%0 = spv.IEqual %arg0, %arg1 : i32
|
||||
spv.Return
|
||||
}
|
||||
func @inotequal_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
|
||||
// CHECK: {{.*}} = spv.INotEqual {{.*}}, {{.*}} : vector<4xi32>
|
||||
%0 = spv.INotEqual %arg0, %arg1 : vector<4xi32>
|
||||
spv.Return
|
||||
}
|
||||
func @sgt_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
|
||||
// CHECK: {{.*}} = spv.SGreaterThan {{.*}}, {{.*}} : vector<4xi32>
|
||||
%0 = spv.SGreaterThan %arg0, %arg1 : vector<4xi32>
|
||||
spv.Return
|
||||
}
|
||||
func @sge_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
|
||||
// CHECK: {{.*}} = spv.SGreaterThanEqual {{.*}}, {{.*}} : vector<4xi32>
|
||||
%0 = spv.SGreaterThanEqual %arg0, %arg1 : vector<4xi32>
|
||||
spv.Return
|
||||
}
|
||||
func @slt_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
|
||||
// CHECK: {{.*}} = spv.SLessThan {{.*}}, {{.*}} : vector<4xi32>
|
||||
%0 = spv.SLessThan %arg0, %arg1 : vector<4xi32>
|
||||
spv.Return
|
||||
}
|
||||
func @slte_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
|
||||
// CHECK: {{.*}} = spv.SLessThanEqual {{.*}}, {{.*}} : vector<4xi32>
|
||||
%0 = spv.SLessThanEqual %arg0, %arg1 : vector<4xi32>
|
||||
spv.Return
|
||||
}
|
||||
func @ugt_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
|
||||
// CHECK: {{.*}} = spv.UGreaterThan {{.*}}, {{.*}} : vector<4xi32>
|
||||
%0 = spv.UGreaterThan %arg0, %arg1 : vector<4xi32>
|
||||
spv.Return
|
||||
}
|
||||
func @ugte_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
|
||||
// CHECK: {{.*}} = spv.UGreaterThanEqual {{.*}}, {{.*}} : vector<4xi32>
|
||||
%0 = spv.UGreaterThanEqual %arg0, %arg1 : vector<4xi32>
|
||||
spv.Return
|
||||
}
|
||||
func @ult_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
|
||||
// CHECK: {{.*}} = spv.ULessThan {{.*}}, {{.*}} : vector<4xi32>
|
||||
%0 = spv.ULessThan %arg0, %arg1 : vector<4xi32>
|
||||
spv.Return
|
||||
}
|
||||
func @ulte_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
|
||||
// CHECK: {{.*}} = spv.ULessThanEqual {{.*}}, {{.*}} : vector<4xi32>
|
||||
%0 = spv.ULessThanEqual %arg0, %arg1 : vector<4xi32>
|
||||
spv.Return
|
||||
}
|
||||
spv.module "Logical" "VulkanKHR" {
|
||||
func @fmul(%arg0 : f32, %arg1 : f32) {
|
||||
// CHECK: {{%.*}}= spv.FMul {{%.*}}, {{%.*}} : f32
|
||||
%0 = spv.FMul %arg0, %arg1 : f32
|
||||
spv.Return
|
||||
}
|
||||
func @fadd(%arg0 : vector<4xf32>, %arg1 : vector<4xf32>) {
|
||||
// CHECK: {{%.*}} = spv.FAdd {{%.*}}, {{%.*}} : vector<4xf32>
|
||||
%0 = spv.FAdd %arg0, %arg1 : vector<4xf32>
|
||||
spv.Return
|
||||
}
|
||||
func @fdiv(%arg0 : vector<4xf32>, %arg1 : vector<4xf32>) {
|
||||
// CHECK: {{%.*}} = spv.FDiv {{%.*}}, {{%.*}} : vector<4xf32>
|
||||
%0 = spv.FDiv %arg0, %arg1 : vector<4xf32>
|
||||
spv.Return
|
||||
}
|
||||
func @fmod(%arg0 : vector<4xf32>, %arg1 : vector<4xf32>) {
|
||||
// CHECK: {{%.*}} = spv.FMod {{%.*}}, {{%.*}} : vector<4xf32>
|
||||
%0 = spv.FMod %arg0, %arg1 : vector<4xf32>
|
||||
spv.Return
|
||||
}
|
||||
func @fsub(%arg0 : vector<4xf32>, %arg1 : vector<4xf32>) {
|
||||
// CHECK: {{%.*}} = spv.FSub {{%.*}}, {{%.*}} : vector<4xf32>
|
||||
%0 = spv.FSub %arg0, %arg1 : vector<4xf32>
|
||||
spv.Return
|
||||
}
|
||||
func @frem(%arg0 : vector<4xf32>, %arg1 : vector<4xf32>) {
|
||||
// CHECK: {{%.*}} = spv.FRem {{%.*}}, {{%.*}} : vector<4xf32>
|
||||
%0 = spv.FRem %arg0, %arg1 : vector<4xf32>
|
||||
spv.Return
|
||||
}
|
||||
func @iadd(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) {
|
||||
// CHECK: {{%.*}} = spv.IAdd {{%.*}}, {{%.*}} : vector<4xi32>
|
||||
%0 = spv.IAdd %arg0, %arg1 : vector<4xi32>
|
||||
spv.Return
|
||||
}
|
||||
func @isub(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) {
|
||||
// CHECK: {{%.*}} = spv.ISub {{%.*}}, {{%.*}} : vector<4xi32>
|
||||
%0 = spv.ISub %arg0, %arg1 : vector<4xi32>
|
||||
spv.Return
|
||||
}
|
||||
func @imul(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) {
|
||||
// CHECK: {{%.*}} = spv.IMul {{%.*}}, {{%.*}} : vector<4xi32>
|
||||
%0 = spv.IMul %arg0, %arg1 : vector<4xi32>
|
||||
spv.Return
|
||||
}
|
||||
func @udiv(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) {
|
||||
// CHECK: {{%.*}} = spv.UDiv {{%.*}}, {{%.*}} : vector<4xi32>
|
||||
%0 = spv.UDiv %arg0, %arg1 : vector<4xi32>
|
||||
spv.Return
|
||||
}
|
||||
func @umod(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) {
|
||||
// CHECK: {{%.*}} = spv.UMod {{%.*}}, {{%.*}} : vector<4xi32>
|
||||
%0 = spv.UMod %arg0, %arg1 : vector<4xi32>
|
||||
spv.Return
|
||||
}
|
||||
func @sdiv(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) {
|
||||
// CHECK: {{%.*}} = spv.SDiv {{%.*}}, {{%.*}} : vector<4xi32>
|
||||
%0 = spv.SDiv %arg0, %arg1 : vector<4xi32>
|
||||
spv.Return
|
||||
}
|
||||
func @smod(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) {
|
||||
// CHECK: {{%.*}} = spv.SMod {{%.*}}, {{%.*}} : vector<4xi32>
|
||||
%0 = spv.SMod %arg0, %arg1 : vector<4xi32>
|
||||
spv.Return
|
||||
}
|
||||
func @srem(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) {
|
||||
// CHECK: {{%.*}} = spv.SRem {{%.*}}, {{%.*}} : vector<4xi32>
|
||||
%0 = spv.SRem %arg0, %arg1 : vector<4xi32>
|
||||
spv.Return
|
||||
}
|
||||
func @iequal_scalar(%arg0: i32, %arg1: i32) {
|
||||
// CHECK: {{.*}} = spv.IEqual {{.*}}, {{.*}} : i32
|
||||
%0 = spv.IEqual %arg0, %arg1 : i32
|
||||
spv.Return
|
||||
}
|
||||
func @inotequal_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
|
||||
// CHECK: {{.*}} = spv.INotEqual {{.*}}, {{.*}} : vector<4xi32>
|
||||
%0 = spv.INotEqual %arg0, %arg1 : vector<4xi32>
|
||||
spv.Return
|
||||
}
|
||||
func @sgt_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
|
||||
// CHECK: {{.*}} = spv.SGreaterThan {{.*}}, {{.*}} : vector<4xi32>
|
||||
%0 = spv.SGreaterThan %arg0, %arg1 : vector<4xi32>
|
||||
spv.Return
|
||||
}
|
||||
func @sge_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
|
||||
// CHECK: {{.*}} = spv.SGreaterThanEqual {{.*}}, {{.*}} : vector<4xi32>
|
||||
%0 = spv.SGreaterThanEqual %arg0, %arg1 : vector<4xi32>
|
||||
spv.Return
|
||||
}
|
||||
func @slt_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
|
||||
// CHECK: {{.*}} = spv.SLessThan {{.*}}, {{.*}} : vector<4xi32>
|
||||
%0 = spv.SLessThan %arg0, %arg1 : vector<4xi32>
|
||||
spv.Return
|
||||
}
|
||||
func @slte_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
|
||||
// CHECK: {{.*}} = spv.SLessThanEqual {{.*}}, {{.*}} : vector<4xi32>
|
||||
%0 = spv.SLessThanEqual %arg0, %arg1 : vector<4xi32>
|
||||
spv.Return
|
||||
}
|
||||
func @ugt_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
|
||||
// CHECK: {{.*}} = spv.UGreaterThan {{.*}}, {{.*}} : vector<4xi32>
|
||||
%0 = spv.UGreaterThan %arg0, %arg1 : vector<4xi32>
|
||||
spv.Return
|
||||
}
|
||||
func @ugte_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
|
||||
// CHECK: {{.*}} = spv.UGreaterThanEqual {{.*}}, {{.*}} : vector<4xi32>
|
||||
%0 = spv.UGreaterThanEqual %arg0, %arg1 : vector<4xi32>
|
||||
spv.Return
|
||||
}
|
||||
func @ult_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
|
||||
// CHECK: {{.*}} = spv.ULessThan {{.*}}, {{.*}} : vector<4xi32>
|
||||
%0 = spv.ULessThan %arg0, %arg1 : vector<4xi32>
|
||||
spv.Return
|
||||
}
|
||||
func @ulte_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
|
||||
// CHECK: {{.*}} = spv.ULessThanEqual {{.*}}, {{.*}} : vector<4xi32>
|
||||
%0 = spv.ULessThanEqual %arg0, %arg1 : vector<4xi32>
|
||||
spv.Return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,171 +1,168 @@
|
||||
// RUN: mlir-translate -serialize-spirv %s | mlir-translate -deserialize-spirv | FileCheck %s
|
||||
|
||||
func @spirv_module() -> () {
|
||||
spv.module "Logical" "GLSL450" {
|
||||
// CHECK-LABEL: @bool_const
|
||||
func @bool_const() -> () {
|
||||
// CHECK: spv.constant true
|
||||
%0 = spv.constant true
|
||||
// CHECK: spv.constant false
|
||||
%1 = spv.constant false
|
||||
spv.module "Logical" "GLSL450" {
|
||||
// CHECK-LABEL: @bool_const
|
||||
func @bool_const() -> () {
|
||||
// CHECK: spv.constant true
|
||||
%0 = spv.constant true
|
||||
// CHECK: spv.constant false
|
||||
%1 = spv.constant false
|
||||
|
||||
%2 = spv.Variable init(%0): !spv.ptr<i1, Function>
|
||||
%3 = spv.Variable init(%1): !spv.ptr<i1, Function>
|
||||
spv.Return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @i32_const
|
||||
func @i32_const() -> () {
|
||||
// CHECK: spv.constant 0 : i32
|
||||
%0 = spv.constant 0 : i32
|
||||
// CHECK: spv.constant 10 : i32
|
||||
%1 = spv.constant 10 : i32
|
||||
// CHECK: spv.constant -5 : i32
|
||||
%2 = spv.constant -5 : i32
|
||||
|
||||
%3 = spv.IAdd %0, %1 : i32
|
||||
%4 = spv.IAdd %2, %3 : i32
|
||||
spv.Return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @i64_const
|
||||
func @i64_const() -> () {
|
||||
// CHECK: spv.constant 4294967296 : i64
|
||||
%0 = spv.constant 4294967296 : i64 // 2^32
|
||||
// CHECK: spv.constant -4294967296 : i64
|
||||
%1 = spv.constant -4294967296 : i64 // -2^32
|
||||
// CHECK: spv.constant 9223372036854775807 : i64
|
||||
%2 = spv.constant 9223372036854775807 : i64 // 2^63 - 1
|
||||
// CHECK: spv.constant -9223372036854775808 : i64
|
||||
%3 = spv.constant -9223372036854775808 : i64 // -2^63
|
||||
|
||||
%4 = spv.IAdd %0, %1 : i64
|
||||
%5 = spv.IAdd %2, %3 : i64
|
||||
spv.Return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @i16_const
|
||||
func @i16_const() -> () {
|
||||
// CHECK: spv.constant -32768 : i16
|
||||
%0 = spv.constant -32768 : i16 // -2^15
|
||||
// CHECK: spv.constant 32767 : i16
|
||||
%1 = spv.constant 32767 : i16 // 2^15 - 1
|
||||
|
||||
%2 = spv.IAdd %0, %1 : i16
|
||||
spv.Return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @float_const
|
||||
func @float_const() -> () {
|
||||
// CHECK: spv.constant 0.000000e+00 : f32
|
||||
%0 = spv.constant 0. : f32
|
||||
// CHECK: spv.constant 1.000000e+00 : f32
|
||||
%1 = spv.constant 1. : f32
|
||||
// CHECK: spv.constant -0.000000e+00 : f32
|
||||
%2 = spv.constant -0. : f32
|
||||
// CHECK: spv.constant -1.000000e+00 : f32
|
||||
%3 = spv.constant -1. : f32
|
||||
// CHECK: spv.constant 7.500000e-01 : f32
|
||||
%4 = spv.constant 0.75 : f32
|
||||
// CHECK: spv.constant -2.500000e-01 : f32
|
||||
%5 = spv.constant -0.25 : f32
|
||||
|
||||
%6 = spv.FAdd %0, %1 : f32
|
||||
%7 = spv.FAdd %2, %3 : f32
|
||||
%8 = spv.FAdd %4, %5 : f32
|
||||
spv.Return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @double_const
|
||||
func @double_const() -> () {
|
||||
// TODO(antiagainst): test range boundary values
|
||||
// CHECK: spv.constant 1.024000e+03 : f64
|
||||
%0 = spv.constant 1024. : f64
|
||||
// CHECK: spv.constant -1.024000e+03 : f64
|
||||
%1 = spv.constant -1024. : f64
|
||||
|
||||
%2 = spv.FAdd %0, %1 : f64
|
||||
spv.Return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @half_const
|
||||
func @half_const() -> () {
|
||||
// CHECK: spv.constant 5.120000e+02 : f16
|
||||
%0 = spv.constant 512. : f16
|
||||
// CHECK: spv.constant -5.120000e+02 : f16
|
||||
%1 = spv.constant -512. : f16
|
||||
|
||||
%2 = spv.FAdd %0, %1 : f16
|
||||
spv.Return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @bool_vector_const
|
||||
func @bool_vector_const() -> () {
|
||||
// CHECK: spv.constant dense<false> : vector<2xi1>
|
||||
%0 = spv.constant dense<false> : vector<2xi1>
|
||||
// CHECK: spv.constant dense<[true, true, true]> : vector<3xi1>
|
||||
%1 = spv.constant dense<true> : vector<3xi1>
|
||||
// CHECK: spv.constant dense<[false, true]> : vector<2xi1>
|
||||
%2 = spv.constant dense<[false, true]> : vector<2xi1>
|
||||
|
||||
%3 = spv.Variable init(%0): !spv.ptr<vector<2xi1>, Function>
|
||||
%4 = spv.Variable init(%1): !spv.ptr<vector<3xi1>, Function>
|
||||
%5 = spv.Variable init(%2): !spv.ptr<vector<2xi1>, Function>
|
||||
spv.Return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @int_vector_const
|
||||
func @int_vector_const() -> () {
|
||||
// CHECK: spv.constant dense<0> : vector<3xi32>
|
||||
%0 = spv.constant dense<0> : vector<3xi32>
|
||||
// CHECK: spv.constant dense<1> : vector<3xi32>
|
||||
%1 = spv.constant dense<1> : vector<3xi32>
|
||||
// CHECK: spv.constant dense<[2, -3, 4]> : vector<3xi32>
|
||||
%2 = spv.constant dense<[2, -3, 4]> : vector<3xi32>
|
||||
|
||||
%3 = spv.IAdd %0, %1 : vector<3xi32>
|
||||
%4 = spv.IAdd %2, %3 : vector<3xi32>
|
||||
spv.Return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @fp_vector_const
|
||||
func @fp_vector_const() -> () {
|
||||
// CHECK: spv.constant dense<0.000000e+00> : vector<4xf32>
|
||||
%0 = spv.constant dense<0.> : vector<4xf32>
|
||||
// CHECK: spv.constant dense<-1.500000e+01> : vector<4xf32>
|
||||
%1 = spv.constant dense<-15.> : vector<4xf32>
|
||||
// CHECK: spv.constant dense<[7.500000e-01, -2.500000e-01, 1.000000e+01, 4.200000e+01]> : vector<4xf32>
|
||||
%2 = spv.constant dense<[0.75, -0.25, 10., 42.]> : vector<4xf32>
|
||||
|
||||
%3 = spv.FAdd %0, %1 : vector<4xf32>
|
||||
%4 = spv.FAdd %2, %3 : vector<4xf32>
|
||||
spv.Return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @array_const
|
||||
func @array_const() -> (!spv.array<2 x vector<2xf32>>) {
|
||||
// CHECK: spv.constant [dense<3.000000e+00> : vector<2xf32>, dense<[4.000000e+00, 5.000000e+00]> : vector<2xf32>] : !spv.array<2 x vector<2xf32>>
|
||||
%0 = spv.constant [dense<3.0> : vector<2xf32>, dense<[4., 5.]> : vector<2xf32>] : !spv.array<2 x vector<2xf32>>
|
||||
|
||||
spv.ReturnValue %0 : !spv.array<2 x vector<2xf32>>
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @ignore_not_used_const
|
||||
func @ignore_not_used_const() -> () {
|
||||
%0 = spv.constant false
|
||||
// CHECK-NEXT: spv.Return
|
||||
spv.Return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @materialize_const_at_each_use
|
||||
func @materialize_const_at_each_use() -> (i32) {
|
||||
// CHECK: %[[USE1:.*]] = spv.constant 42 : i32
|
||||
// CHECK: %[[USE2:.*]] = spv.constant 42 : i32
|
||||
// CHECK: spv.IAdd %[[USE1]], %[[USE2]]
|
||||
%0 = spv.constant 42 : i32
|
||||
%1 = spv.IAdd %0, %0 : i32
|
||||
spv.ReturnValue %1 : i32
|
||||
}
|
||||
%2 = spv.Variable init(%0): !spv.ptr<i1, Function>
|
||||
%3 = spv.Variable init(%1): !spv.ptr<i1, Function>
|
||||
spv.Return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @i32_const
|
||||
func @i32_const() -> () {
|
||||
// CHECK: spv.constant 0 : i32
|
||||
%0 = spv.constant 0 : i32
|
||||
// CHECK: spv.constant 10 : i32
|
||||
%1 = spv.constant 10 : i32
|
||||
// CHECK: spv.constant -5 : i32
|
||||
%2 = spv.constant -5 : i32
|
||||
|
||||
%3 = spv.IAdd %0, %1 : i32
|
||||
%4 = spv.IAdd %2, %3 : i32
|
||||
spv.Return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @i64_const
|
||||
func @i64_const() -> () {
|
||||
// CHECK: spv.constant 4294967296 : i64
|
||||
%0 = spv.constant 4294967296 : i64 // 2^32
|
||||
// CHECK: spv.constant -4294967296 : i64
|
||||
%1 = spv.constant -4294967296 : i64 // -2^32
|
||||
// CHECK: spv.constant 9223372036854775807 : i64
|
||||
%2 = spv.constant 9223372036854775807 : i64 // 2^63 - 1
|
||||
// CHECK: spv.constant -9223372036854775808 : i64
|
||||
%3 = spv.constant -9223372036854775808 : i64 // -2^63
|
||||
|
||||
%4 = spv.IAdd %0, %1 : i64
|
||||
%5 = spv.IAdd %2, %3 : i64
|
||||
spv.Return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @i16_const
|
||||
func @i16_const() -> () {
|
||||
// CHECK: spv.constant -32768 : i16
|
||||
%0 = spv.constant -32768 : i16 // -2^15
|
||||
// CHECK: spv.constant 32767 : i16
|
||||
%1 = spv.constant 32767 : i16 // 2^15 - 1
|
||||
|
||||
%2 = spv.IAdd %0, %1 : i16
|
||||
spv.Return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @float_const
|
||||
func @float_const() -> () {
|
||||
// CHECK: spv.constant 0.000000e+00 : f32
|
||||
%0 = spv.constant 0. : f32
|
||||
// CHECK: spv.constant 1.000000e+00 : f32
|
||||
%1 = spv.constant 1. : f32
|
||||
// CHECK: spv.constant -0.000000e+00 : f32
|
||||
%2 = spv.constant -0. : f32
|
||||
// CHECK: spv.constant -1.000000e+00 : f32
|
||||
%3 = spv.constant -1. : f32
|
||||
// CHECK: spv.constant 7.500000e-01 : f32
|
||||
%4 = spv.constant 0.75 : f32
|
||||
// CHECK: spv.constant -2.500000e-01 : f32
|
||||
%5 = spv.constant -0.25 : f32
|
||||
|
||||
%6 = spv.FAdd %0, %1 : f32
|
||||
%7 = spv.FAdd %2, %3 : f32
|
||||
%8 = spv.FAdd %4, %5 : f32
|
||||
spv.Return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @double_const
|
||||
func @double_const() -> () {
|
||||
// TODO(antiagainst): test range boundary values
|
||||
// CHECK: spv.constant 1.024000e+03 : f64
|
||||
%0 = spv.constant 1024. : f64
|
||||
// CHECK: spv.constant -1.024000e+03 : f64
|
||||
%1 = spv.constant -1024. : f64
|
||||
|
||||
%2 = spv.FAdd %0, %1 : f64
|
||||
spv.Return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @half_const
|
||||
func @half_const() -> () {
|
||||
// CHECK: spv.constant 5.120000e+02 : f16
|
||||
%0 = spv.constant 512. : f16
|
||||
// CHECK: spv.constant -5.120000e+02 : f16
|
||||
%1 = spv.constant -512. : f16
|
||||
|
||||
%2 = spv.FAdd %0, %1 : f16
|
||||
spv.Return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @bool_vector_const
|
||||
func @bool_vector_const() -> () {
|
||||
// CHECK: spv.constant dense<false> : vector<2xi1>
|
||||
%0 = spv.constant dense<false> : vector<2xi1>
|
||||
// CHECK: spv.constant dense<[true, true, true]> : vector<3xi1>
|
||||
%1 = spv.constant dense<true> : vector<3xi1>
|
||||
// CHECK: spv.constant dense<[false, true]> : vector<2xi1>
|
||||
%2 = spv.constant dense<[false, true]> : vector<2xi1>
|
||||
|
||||
%3 = spv.Variable init(%0): !spv.ptr<vector<2xi1>, Function>
|
||||
%4 = spv.Variable init(%1): !spv.ptr<vector<3xi1>, Function>
|
||||
%5 = spv.Variable init(%2): !spv.ptr<vector<2xi1>, Function>
|
||||
spv.Return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @int_vector_const
|
||||
func @int_vector_const() -> () {
|
||||
// CHECK: spv.constant dense<0> : vector<3xi32>
|
||||
%0 = spv.constant dense<0> : vector<3xi32>
|
||||
// CHECK: spv.constant dense<1> : vector<3xi32>
|
||||
%1 = spv.constant dense<1> : vector<3xi32>
|
||||
// CHECK: spv.constant dense<[2, -3, 4]> : vector<3xi32>
|
||||
%2 = spv.constant dense<[2, -3, 4]> : vector<3xi32>
|
||||
|
||||
%3 = spv.IAdd %0, %1 : vector<3xi32>
|
||||
%4 = spv.IAdd %2, %3 : vector<3xi32>
|
||||
spv.Return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @fp_vector_const
|
||||
func @fp_vector_const() -> () {
|
||||
// CHECK: spv.constant dense<0.000000e+00> : vector<4xf32>
|
||||
%0 = spv.constant dense<0.> : vector<4xf32>
|
||||
// CHECK: spv.constant dense<-1.500000e+01> : vector<4xf32>
|
||||
%1 = spv.constant dense<-15.> : vector<4xf32>
|
||||
// CHECK: spv.constant dense<[7.500000e-01, -2.500000e-01, 1.000000e+01, 4.200000e+01]> : vector<4xf32>
|
||||
%2 = spv.constant dense<[0.75, -0.25, 10., 42.]> : vector<4xf32>
|
||||
|
||||
%3 = spv.FAdd %0, %1 : vector<4xf32>
|
||||
%4 = spv.FAdd %2, %3 : vector<4xf32>
|
||||
spv.Return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @array_const
|
||||
func @array_const() -> (!spv.array<2 x vector<2xf32>>) {
|
||||
// CHECK: spv.constant [dense<3.000000e+00> : vector<2xf32>, dense<[4.000000e+00, 5.000000e+00]> : vector<2xf32>] : !spv.array<2 x vector<2xf32>>
|
||||
%0 = spv.constant [dense<3.0> : vector<2xf32>, dense<[4., 5.]> : vector<2xf32>] : !spv.array<2 x vector<2xf32>>
|
||||
|
||||
spv.ReturnValue %0 : !spv.array<2 x vector<2xf32>>
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @ignore_not_used_const
|
||||
func @ignore_not_used_const() -> () {
|
||||
%0 = spv.constant false
|
||||
// CHECK-NEXT: spv.Return
|
||||
spv.Return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @materialize_const_at_each_use
|
||||
func @materialize_const_at_each_use() -> (i32) {
|
||||
// CHECK: %[[USE1:.*]] = spv.constant 42 : i32
|
||||
// CHECK: %[[USE2:.*]] = spv.constant 42 : i32
|
||||
// CHECK: spv.IAdd %[[USE1]], %[[USE2]]
|
||||
%0 = spv.constant 42 : i32
|
||||
%1 = spv.IAdd %0, %0 : i32
|
||||
spv.ReturnValue %1 : i32
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
// RUN: mlir-translate -serialize-spirv %s | mlir-translate -deserialize-spirv | FileCheck %s
|
||||
|
||||
func @spirv_loadstore() -> () {
|
||||
spv.module "Logical" "VulkanKHR" {
|
||||
func @noop() -> () {
|
||||
spv.Return
|
||||
}
|
||||
// CHECK: spv.EntryPoint "GLCompute" @noop
|
||||
// CHECK-NEXT: spv.ExecutionMode @noop "ContractionOff"
|
||||
spv.EntryPoint "GLCompute" @noop
|
||||
spv.ExecutionMode @noop "ContractionOff"
|
||||
spv.module "Logical" "VulkanKHR" {
|
||||
func @noop() -> () {
|
||||
spv.Return
|
||||
}
|
||||
return
|
||||
}
|
||||
// CHECK: spv.EntryPoint "GLCompute" @noop
|
||||
// CHECK-NEXT: spv.ExecutionMode @noop "ContractionOff"
|
||||
spv.EntryPoint "GLCompute" @noop
|
||||
spv.ExecutionMode @noop "ContractionOff"
|
||||
}
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
// RUN: mlir-translate -serialize-spirv %s | mlir-translate -deserialize-spirv | FileCheck %s
|
||||
|
||||
func @spirv_loadstore() -> () {
|
||||
spv.module "Logical" "VulkanKHR" {
|
||||
// CHECK: spv.globalVariable @var2 : !spv.ptr<f32, Input>
|
||||
// CHECK-NEXT: spv.globalVariable @var3 : !spv.ptr<f32, Output>
|
||||
// CHECK-NEXT: func @noop({{%.*}}: !spv.ptr<f32, Input>, {{%.*}}: !spv.ptr<f32, Output>)
|
||||
// CHECK: spv.EntryPoint "GLCompute" @noop, @var2, @var3
|
||||
spv.globalVariable @var2 : !spv.ptr<f32, Input>
|
||||
spv.globalVariable @var3 : !spv.ptr<f32, Output>
|
||||
func @noop(%arg0 : !spv.ptr<f32, Input>, %arg1 : !spv.ptr<f32, Output>) -> () {
|
||||
spv.Return
|
||||
}
|
||||
spv.EntryPoint "GLCompute" @noop, @var2, @var3
|
||||
spv.ExecutionMode @noop "ContractionOff"
|
||||
spv.module "Logical" "VulkanKHR" {
|
||||
// CHECK: spv.globalVariable @var2 : !spv.ptr<f32, Input>
|
||||
// CHECK-NEXT: spv.globalVariable @var3 : !spv.ptr<f32, Output>
|
||||
// CHECK-NEXT: func @noop({{%.*}}: !spv.ptr<f32, Input>, {{%.*}}: !spv.ptr<f32, Output>)
|
||||
// CHECK: spv.EntryPoint "GLCompute" @noop, @var2, @var3
|
||||
spv.globalVariable @var2 : !spv.ptr<f32, Input>
|
||||
spv.globalVariable @var3 : !spv.ptr<f32, Output>
|
||||
func @noop(%arg0 : !spv.ptr<f32, Input>, %arg1 : !spv.ptr<f32, Output>) -> () {
|
||||
spv.Return
|
||||
}
|
||||
return
|
||||
}
|
||||
spv.EntryPoint "GLCompute" @noop, @var2, @var3
|
||||
spv.ExecutionMode @noop "ContractionOff"
|
||||
}
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
// RUN: mlir-translate -serialize-spirv %s | mlir-translate -deserialize-spirv | FileCheck %s
|
||||
|
||||
func @spirv_loadstore() -> () {
|
||||
spv.module "Logical" "VulkanKHR" {
|
||||
func @foo() -> () {
|
||||
spv.Return
|
||||
}
|
||||
spv.EntryPoint "GLCompute" @foo
|
||||
// CHECK: spv.ExecutionMode @foo "LocalSizeHint", 3, 4, 5
|
||||
spv.ExecutionMode @foo "LocalSizeHint", 3, 4, 5
|
||||
spv.module "Logical" "VulkanKHR" {
|
||||
func @foo() -> () {
|
||||
spv.Return
|
||||
}
|
||||
return
|
||||
}
|
||||
spv.EntryPoint "GLCompute" @foo
|
||||
// CHECK: spv.ExecutionMode @foo "LocalSizeHint", 3, 4, 5
|
||||
spv.ExecutionMode @foo "LocalSizeHint", 3, 4, 5
|
||||
}
|
||||
|
||||
@@ -4,13 +4,10 @@
|
||||
// CHECK-NEXT: [[VALUE:%.*]] = spv.Load "Input" [[ARG1]] : f32
|
||||
// CHECK-NEXT: spv.Store "Output" [[ARG2]], [[VALUE]] : f32
|
||||
|
||||
func @spirv_loadstore() -> () {
|
||||
spv.module "Logical" "VulkanKHR" {
|
||||
func @load_store(%arg0 : !spv.ptr<f32, Input>, %arg1 : !spv.ptr<f32, Output>) {
|
||||
%1 = spv.Load "Input" %arg0 : f32
|
||||
spv.Store "Output" %arg1, %1 : f32
|
||||
spv.Return
|
||||
}
|
||||
spv.module "Logical" "VulkanKHR" {
|
||||
func @load_store(%arg0 : !spv.ptr<f32, Input>, %arg1 : !spv.ptr<f32, Output>) {
|
||||
%1 = spv.Load "Input" %arg0 : f32
|
||||
spv.Store "Output" %arg1, %1 : f32
|
||||
spv.Return
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
// RUN: mlir-translate -serialize-spirv %s | mlir-translate -deserialize-spirv | FileCheck %s
|
||||
|
||||
// CHECK-LABEL: func @spirv_module
|
||||
// CHECK: spv.module "Logical" "VulkanKHR" {
|
||||
// CHECK-NEXT: func @foo() {
|
||||
// CHECK-NEXT: spv.Return
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: } attributes {major_version = 1 : i32, minor_version = 0 : i32}
|
||||
|
||||
func @spirv_module() -> () {
|
||||
spv.module "Logical" "VulkanKHR" {
|
||||
func @foo() -> () {
|
||||
spv.Return
|
||||
}
|
||||
spv.module "Logical" "VulkanKHR" {
|
||||
func @foo() -> () {
|
||||
spv.Return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,31 +1,27 @@
|
||||
// RUN: mlir-translate -serialize-spirv %s | mlir-translate -deserialize-spirv | FileCheck %s
|
||||
|
||||
func @spirv_module() -> () {
|
||||
spv.module "Logical" "GLSL450" {
|
||||
// CHECK: spv.specConstant @sc_true = true
|
||||
spv.specConstant @sc_true = true
|
||||
// CHECK: spv.specConstant @sc_false = false
|
||||
spv.specConstant @sc_false = false
|
||||
spv.module "Logical" "GLSL450" {
|
||||
// CHECK: spv.specConstant @sc_true = true
|
||||
spv.specConstant @sc_true = true
|
||||
// CHECK: spv.specConstant @sc_false = false
|
||||
spv.specConstant @sc_false = false
|
||||
|
||||
// CHECK: spv.specConstant @sc_int = -5 : i32
|
||||
spv.specConstant @sc_int = -5 : i32
|
||||
// CHECK: spv.specConstant @sc_int = -5 : i32
|
||||
spv.specConstant @sc_int = -5 : i32
|
||||
|
||||
// CHECK: spv.specConstant @sc_float = 1.000000e+00 : f32
|
||||
spv.specConstant @sc_float = 1. : f32
|
||||
// CHECK: spv.specConstant @sc_float = 1.000000e+00 : f32
|
||||
spv.specConstant @sc_float = 1. : f32
|
||||
|
||||
// CHECK-LABEL: @use
|
||||
func @use() -> (i32) {
|
||||
// We materialize a `spv._reference_of` op at every use of a
|
||||
// specialization constant in the deserializer. So two ops here.
|
||||
// CHECK: %[[USE1:.*]] = spv._reference_of @sc_int : i32
|
||||
// CHECK: %[[USE2:.*]] = spv._reference_of @sc_int : i32
|
||||
// CHECK: spv.IAdd %[[USE1]], %[[USE2]]
|
||||
// CHECK-LABEL: @use
|
||||
func @use() -> (i32) {
|
||||
// We materialize a `spv._reference_of` op at every use of a
|
||||
// specialization constant in the deserializer. So two ops here.
|
||||
// CHECK: %[[USE1:.*]] = spv._reference_of @sc_int : i32
|
||||
// CHECK: %[[USE2:.*]] = spv._reference_of @sc_int : i32
|
||||
// CHECK: spv.IAdd %[[USE1]], %[[USE2]]
|
||||
|
||||
%0 = spv._reference_of @sc_int : i32
|
||||
%1 = spv.IAdd %0, %0 : i32
|
||||
spv.ReturnValue %1 : i32
|
||||
}
|
||||
%0 = spv._reference_of @sc_int : i32
|
||||
%1 = spv.IAdd %0, %0 : i32
|
||||
spv.ReturnValue %1 : i32
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -1,24 +1,21 @@
|
||||
// RUN: mlir-translate -serialize-spirv %s | mlir-translate -deserialize-spirv | FileCheck %s
|
||||
|
||||
func @spirvmodule() -> () {
|
||||
spv.module "Logical" "VulkanKHR" {
|
||||
// CHECK: !spv.ptr<!spv.struct<!spv.array<128 x f32 [4]> [0]>, Input>
|
||||
spv.globalVariable @var0 bind(0, 1) : !spv.ptr<!spv.struct<!spv.array<128 x f32 [4]> [0]>, Input>
|
||||
spv.module "Logical" "VulkanKHR" {
|
||||
// CHECK: !spv.ptr<!spv.struct<!spv.array<128 x f32 [4]> [0]>, Input>
|
||||
spv.globalVariable @var0 bind(0, 1) : !spv.ptr<!spv.struct<!spv.array<128 x f32 [4]> [0]>, Input>
|
||||
|
||||
// CHECK: !spv.ptr<!spv.struct<f32 [0], !spv.struct<f32 [0], !spv.array<16 x f32 [4]> [4]> [4]>, Input>
|
||||
spv.globalVariable @var1 bind(0, 2) : !spv.ptr<!spv.struct<f32 [0], !spv.struct<f32 [0], !spv.array<16 x f32 [4]> [4]> [4]>, Input>
|
||||
// CHECK: !spv.ptr<!spv.struct<f32 [0], !spv.struct<f32 [0], !spv.array<16 x f32 [4]> [4]> [4]>, Input>
|
||||
spv.globalVariable @var1 bind(0, 2) : !spv.ptr<!spv.struct<f32 [0], !spv.struct<f32 [0], !spv.array<16 x f32 [4]> [4]> [4]>, Input>
|
||||
|
||||
// CHECK: !spv.ptr<!spv.struct<f32 [0], i32 [4], f64 [8], i64 [16], f32 [24], i32 [30], f32 [34], i32 [38]>, StorageBuffer>
|
||||
spv.globalVariable @var2 : !spv.ptr<!spv.struct<f32 [0], i32 [4], f64 [8], i64 [16], f32 [24], i32 [30], f32 [34], i32 [38]>, StorageBuffer>
|
||||
// CHECK: !spv.ptr<!spv.struct<f32 [0], i32 [4], f64 [8], i64 [16], f32 [24], i32 [30], f32 [34], i32 [38]>, StorageBuffer>
|
||||
spv.globalVariable @var2 : !spv.ptr<!spv.struct<f32 [0], i32 [4], f64 [8], i64 [16], f32 [24], i32 [30], f32 [34], i32 [38]>, StorageBuffer>
|
||||
|
||||
// CHECK: !spv.ptr<!spv.struct<!spv.array<128 x !spv.struct<!spv.array<128 x f32 [4]> [0]> [4]> [0]>, StorageBuffer>
|
||||
spv.globalVariable @var3 : !spv.ptr<!spv.struct<!spv.array<128 x !spv.struct<!spv.array<128 x f32 [4]> [0]> [4]> [0]>, StorageBuffer>
|
||||
// CHECK: !spv.ptr<!spv.struct<!spv.array<128 x !spv.struct<!spv.array<128 x f32 [4]> [0]> [4]> [0]>, StorageBuffer>
|
||||
spv.globalVariable @var3 : !spv.ptr<!spv.struct<!spv.array<128 x !spv.struct<!spv.array<128 x f32 [4]> [0]> [4]> [0]>, StorageBuffer>
|
||||
|
||||
// CHECK: !spv.ptr<!spv.struct<!spv.array<128 x f32 [4]> [0]>, Input>,
|
||||
// CHECK-SAME: !spv.ptr<!spv.struct<!spv.array<128 x f32 [4]> [0]>, Output>
|
||||
func @kernel_1(%arg0: !spv.ptr<!spv.struct<!spv.array<128 x f32 [4]> [0]>, Input>, %arg1: !spv.ptr<!spv.struct<!spv.array<128 x f32 [4]> [0]>, Output>) -> () {
|
||||
spv.Return
|
||||
}
|
||||
// CHECK: !spv.ptr<!spv.struct<!spv.array<128 x f32 [4]> [0]>, Input>,
|
||||
// CHECK-SAME: !spv.ptr<!spv.struct<!spv.array<128 x f32 [4]> [0]>, Output>
|
||||
func @kernel_1(%arg0: !spv.ptr<!spv.struct<!spv.array<128 x f32 [4]> [0]>, Input>, %arg1: !spv.ptr<!spv.struct<!spv.array<128 x f32 [4]> [0]>, Output>) -> () {
|
||||
spv.Return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,21 +1,17 @@
|
||||
// RUN: mlir-translate -serialize-spirv %s | mlir-translate -deserialize-spirv | FileCheck %s
|
||||
|
||||
func @spirv_terminator() -> () {
|
||||
spv.module "Logical" "GLSL450" {
|
||||
// CHECK-LABEL: @ret
|
||||
func @ret() -> () {
|
||||
// CHECK: spv.Return
|
||||
spv.Return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @ret_val
|
||||
func @ret_val() -> (i32) {
|
||||
%0 = spv.Variable : !spv.ptr<i32, Function>
|
||||
%1 = spv.Load "Function" %0 : i32
|
||||
// CHECK: spv.ReturnValue {{.*}} : i32
|
||||
spv.ReturnValue %1 : i32
|
||||
}
|
||||
spv.module "Logical" "GLSL450" {
|
||||
// CHECK-LABEL: @ret
|
||||
func @ret() -> () {
|
||||
// CHECK: spv.Return
|
||||
spv.Return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @ret_val
|
||||
func @ret_val() -> (i32) {
|
||||
%0 = spv.Variable : !spv.ptr<i32, Function>
|
||||
%1 = spv.Load "Function" %0 : i32
|
||||
// CHECK: spv.ReturnValue {{.*}} : i32
|
||||
spv.ReturnValue %1 : i32
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
// RUN: mlir-translate -serialize-spirv %s | mlir-translate -deserialize-spirv | FileCheck %s
|
||||
|
||||
func @spirv_global_vars() -> () {
|
||||
spv.module "Logical" "VulkanKHR" {
|
||||
spv.globalVariable @globalInvocationID built_in("GlobalInvocationId") : !spv.ptr<vector<3xi32>, Input>
|
||||
func @foo() {
|
||||
// CHECK: %[[ADDR:.*]] = spv._address_of @globalInvocationID : !spv.ptr<vector<3xi32>, Input>
|
||||
%0 = spv._address_of @globalInvocationID : !spv.ptr<vector<3xi32>, Input>
|
||||
%1 = spv.constant 0: i32
|
||||
// CHECK: spv.AccessChain %[[ADDR]]
|
||||
%2 = spv.AccessChain %0[%1] : !spv.ptr<vector<3xi32>, Input>
|
||||
spv.Return
|
||||
}
|
||||
spv.module "Logical" "VulkanKHR" {
|
||||
spv.globalVariable @globalInvocationID built_in("GlobalInvocationId") : !spv.ptr<vector<3xi32>, Input>
|
||||
func @foo() {
|
||||
// CHECK: %[[ADDR:.*]] = spv._address_of @globalInvocationID : !spv.ptr<vector<3xi32>, Input>
|
||||
%0 = spv._address_of @globalInvocationID : !spv.ptr<vector<3xi32>, Input>
|
||||
%1 = spv.constant 0: i32
|
||||
// CHECK: spv.AccessChain %[[ADDR]]
|
||||
%2 = spv.AccessChain %0[%1] : !spv.ptr<vector<3xi32>, Input>
|
||||
spv.Return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
// RUN: mlir-translate -serialize-spirv %s | mlir-translate -deserialize-spirv | FileCheck %s
|
||||
|
||||
// CHECK: spv.globalVariable @var0 bind(1, 0) : !spv.ptr<f32, Input>
|
||||
// CHECK-NEXT: spv.globalVariable @var1 bind(0, 1) : !spv.ptr<f32, Output>
|
||||
// CHECK-NEXT: spv.globalVariable @var2 built_in("GlobalInvocationId") : !spv.ptr<vector<3xi32>, Input>
|
||||
// CHECK-NEXT: spv.globalVariable @var3 built_in("GlobalInvocationId") : !spv.ptr<vector<3xi32>, Input>
|
||||
func @spirv_variables() -> () {
|
||||
spv.module "Logical" "VulkanKHR" {
|
||||
spv.globalVariable @var0 bind(1, 0) : !spv.ptr<f32, Input>
|
||||
spv.globalVariable @var1 bind(0, 1) : !spv.ptr<f32, Output>
|
||||
spv.globalVariable @var2 {built_in = "GlobalInvocationId"} : !spv.ptr<vector<3xi32>, Input>
|
||||
spv.globalVariable @var3 built_in("GlobalInvocationId") : !spv.ptr<vector<3xi32>, Input>
|
||||
}
|
||||
return
|
||||
}
|
||||
// CHECK: spv.globalVariable @var0 bind(1, 0) : !spv.ptr<f32, Input>
|
||||
// CHECK-NEXT: spv.globalVariable @var1 bind(0, 1) : !spv.ptr<f32, Output>
|
||||
// CHECK-NEXT: spv.globalVariable @var2 built_in("GlobalInvocationId") : !spv.ptr<vector<3xi32>, Input>
|
||||
// CHECK-NEXT: spv.globalVariable @var3 built_in("GlobalInvocationId") : !spv.ptr<vector<3xi32>, Input>
|
||||
|
||||
spv.module "Logical" "VulkanKHR" {
|
||||
spv.globalVariable @var0 bind(1, 0) : !spv.ptr<f32, Input>
|
||||
spv.globalVariable @var1 bind(0, 1) : !spv.ptr<f32, Output>
|
||||
spv.globalVariable @var2 {built_in = "GlobalInvocationId"} : !spv.ptr<vector<3xi32>, Input>
|
||||
spv.globalVariable @var3 built_in("GlobalInvocationId") : !spv.ptr<vector<3xi32>, Input>
|
||||
}
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
// RUN: mlir-translate -serialize-spirv %s | mlir-translate -deserialize-spirv | FileCheck %s
|
||||
|
||||
func @spirv_variables() -> () {
|
||||
spv.module "Logical" "VulkanKHR" {
|
||||
// CHECK: spv.globalVariable @var1 : !spv.ptr<f32, Input>
|
||||
// CHECK-NEXT: spv.globalVariable @var2 initializer(@var1) bind(1, 0) : !spv.ptr<f32, Input>
|
||||
spv.globalVariable @var1 : !spv.ptr<f32, Input>
|
||||
spv.globalVariable @var2 initializer(@var1) bind(1, 0) : !spv.ptr<f32, Input>
|
||||
}
|
||||
return
|
||||
}
|
||||
spv.module "Logical" "VulkanKHR" {
|
||||
// CHECK: spv.globalVariable @var1 : !spv.ptr<f32, Input>
|
||||
// CHECK-NEXT: spv.globalVariable @var2 initializer(@var1) bind(1, 0) : !spv.ptr<f32, Input>
|
||||
spv.globalVariable @var1 : !spv.ptr<f32, Input>
|
||||
spv.globalVariable @var2 initializer(@var1) bind(1, 0) : !spv.ptr<f32, Input>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user