[MLIR][SPIRVToLLVM] Added module name conversion
authorGeorge Mitenkov <georgemitenk0v@gmail.com>
Sat, 7 Nov 2020 09:27:03 +0000 (12:27 +0300)
committerGeorge Mitenkov <georgemitenk0v@gmail.com>
Sat, 7 Nov 2020 09:27:44 +0000 (12:27 +0300)
Since SPIR-V module has an optional name, this patch
makes a change to pass it to `ModuleOp` during conversion.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D90904

mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp
mlir/test/Conversion/SPIRVToLLVM/module-ops-to-llvm.mlir

index db6a247..571e85c 100644 (file)
@@ -1269,7 +1269,8 @@ public:
   matchAndRewrite(spirv::ModuleOp spvModuleOp, ArrayRef<Value> operands,
                   ConversionPatternRewriter &rewriter) const override {
 
-    auto newModuleOp = rewriter.create<ModuleOp>(spvModuleOp.getLoc());
+    auto newModuleOp =
+        rewriter.create<ModuleOp>(spvModuleOp.getLoc(), spvModuleOp.getName());
     rewriter.inlineRegionBefore(spvModuleOp.body(), newModuleOp.getBody());
 
     // Remove the terminator block that was automatically added by builder
index b8169a1..a2dbd19 100644 (file)
@@ -7,6 +7,9 @@
 // CHECK: module
 spv.module Logical GLSL450 {}
 
+// CHECK: module @foo
+spv.module @foo Logical GLSL450 {}
+
 // CHECK: module
 spv.module Logical GLSL450 requires #spv.vce<v1.0, [Shader], [SPV_KHR_16bit_storage]> {}