[flang-commits] [flang] 0177a95 - [flang][cuda] Fix fir.cuda_kernel_launch assembly with no args (#85987)

via flang-commits flang-commits at lists.llvm.org
Wed Mar 20 12:58:15 PDT 2024


Author: Valentin Clement (バレンタイン クレメン)
Date: 2024-03-20T12:58:11-07:00
New Revision: 0177a9547e588222acaf6d006747b5f7014e6fd8

URL: https://github.com/llvm/llvm-project/commit/0177a9547e588222acaf6d006747b5f7014e6fd8
DIFF: https://github.com/llvm/llvm-project/commit/0177a9547e588222acaf6d006747b5f7014e6fd8.diff

LOG: [flang][cuda] Fix fir.cuda_kernel_launch assembly with no args (#85987)

When the kernel launch has no arguments, the generated parser was
expecting at least a type to be present. Make the last part of the
assemble format optional.
Add a run line to round-trip the output through fir-opt so we make sure
the IR can be parsed and printed correctly.

Added: 
    

Modified: 
    flang/include/flang/Optimizer/Dialect/FIROps.td
    flang/test/Lower/CUDA/cuda-kernel-calls.cuf

Removed: 
    


################################################################################
diff  --git a/flang/include/flang/Optimizer/Dialect/FIROps.td b/flang/include/flang/Optimizer/Dialect/FIROps.td
index 8a7e36e42457f5..b991ec76fdd956 100644
--- a/flang/include/flang/Optimizer/Dialect/FIROps.td
+++ b/flang/include/flang/Optimizer/Dialect/FIROps.td
@@ -2466,7 +2466,7 @@ def fir_CUDAKernelLaunch : fir_Op<"cuda_kernel_launch", [CallOpInterface,
   let assemblyFormat = [{
     $callee `<` `<` `<` $grid_x `,` $grid_y `,` $grid_z `,`$block_x `,`
         $block_y `,` $block_z ( `,` $bytes^ ( `,` $stream^ )? )? `>` `>` `>`
-        `` `(` $args `)` `:` `(` type($args) `)` attr-dict
+        `` `(` $args `)` ( `:` `(` type($args)^ `)` )? attr-dict
   }];
 
   let extraClassDeclaration = [{

diff  --git a/flang/test/Lower/CUDA/cuda-kernel-calls.cuf b/flang/test/Lower/CUDA/cuda-kernel-calls.cuf
index f4327b3261751f..7e28fbb2231a2d 100644
--- a/flang/test/Lower/CUDA/cuda-kernel-calls.cuf
+++ b/flang/test/Lower/CUDA/cuda-kernel-calls.cuf
@@ -1,4 +1,5 @@
 ! RUN: bbc -emit-hlfir -fcuda %s -o - | FileCheck %s
+! RUN: bbc -emit-hlfir -fcuda %s -o - | fir-opt | FileCheck %s
 
 ! Test lowering of CUDA procedure calls.
 


        


More information about the flang-commits mailing list