diff options
| author | Hanhan Wang <hanchung@google.com> | 2019-11-12 18:58:36 -0800 |
|---|---|---|
| committer | A. Unique TensorFlower <gardener@tensorflow.org> | 2019-11-12 18:59:15 -0800 |
| commit | 85d7fb3324a6442e865c87ea766992ab096f8859 (patch) | |
| tree | 6881e629ceaa3acf9c97a62d3454489dad302973 /mlir/test/Dialect/SPIRV/Serialization | |
| parent | 2be53603e9296e86ae6ef529c37053e198560f60 (diff) | |
| download | bcm5719-llvm-85d7fb3324a6442e865c87ea766992ab096f8859.tar.gz bcm5719-llvm-85d7fb3324a6442e865c87ea766992ab096f8859.zip | |
Make VariableOp instructions be in the first block in the function.
Since VariableOp is serialized during processBlock, we add two more fields,
`functionHeader` and `functionBody`, to collect instructions for a function.
After all the blocks have been processed, we append them to the `functions`.
Also, fix a bug in processGlobalVariableOp. The global variables should be
encoded into `typesGlobalValues`.
PiperOrigin-RevId: 280105366
Diffstat (limited to 'mlir/test/Dialect/SPIRV/Serialization')
| -rw-r--r-- | mlir/test/Dialect/SPIRV/Serialization/constant.mlir | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/mlir/test/Dialect/SPIRV/Serialization/constant.mlir b/mlir/test/Dialect/SPIRV/Serialization/constant.mlir index acfa40a06cd..953120946db 100644 --- a/mlir/test/Dialect/SPIRV/Serialization/constant.mlir +++ b/mlir/test/Dialect/SPIRV/Serialization/constant.mlir @@ -165,4 +165,17 @@ spv.module "Logical" "GLSL450" { %1 = spv.IAdd %0, %0 : i32 spv.ReturnValue %1 : i32 } + + // CHECK-LABEL: @const_variable + func @const_variable(%arg0 : i32, %arg1 : i32) -> () { + // CHECK: %[[CONST:.*]] = spv.constant 5 : i32 + // CHECK: spv.Variable init(%[[CONST]]) : !spv.ptr<i32, Function> + // CHECK: spv.IAdd %arg0, %arg1 + %0 = spv.IAdd %arg0, %arg1 : i32 + %1 = spv.constant 5 : i32 + %2 = spv.Variable init(%1) : !spv.ptr<i32, Function> + %3 = spv.Load "Function" %2 : i32 + %4 = spv.IAdd %0, %3 : i32 + spv.Return + } } |

