[llvm] r200325 - [NVPTX] Fix emitting aggregate parameters

Gautam Chakrabarti gchakrabarti at nvidia.com
Tue Jan 28 10:35:29 PST 2014


Author: gchakrabarti
Date: Tue Jan 28 12:35:29 2014
New Revision: 200325

URL: http://llvm.org/viewvc/llvm-project?rev=200325&view=rev
Log:
[NVPTX] Fix emitting aggregate parameters

The code was missing the case for aggregate parameters and
hence was emitting them as .b0 type. Also fixed a couple
of comments.


Added:
    llvm/trunk/test/CodeGen/NVPTX/aggr-param.ll
Modified:
    llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp

Modified: llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp?rev=200325&r1=200324&r2=200325&view=diff
==============================================================================
--- llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp Tue Jan 28 12:35:29 2014
@@ -1522,8 +1522,8 @@ void NVPTXAsmPrinter::emitFunctionParamL
     }
 
     if (PAL.hasAttribute(paramIndex + 1, Attribute::ByVal) == false) {
-      if (Ty->isVectorTy()) {
-        // Just print .param .b8 .align <a> .param[size];
+      if (Ty->isAggregateType() || Ty->isVectorTy()) {
+        // Just print .param .align <a> .b8 .param[size];
         // <a> = PAL.getparamalignment
         // size = typeallocsize of element type
         unsigned align = PAL.getParamAlignment(paramIndex + 1);
@@ -1603,7 +1603,7 @@ void NVPTXAsmPrinter::emitFunctionParamL
     Type *ETy = PTy->getElementType();
 
     if (isABI || isKernelFunc) {
-      // Just print .param .b8 .align <a> .param[size];
+      // Just print .param .align <a> .b8 .param[size];
       // <a> = PAL.getparamalignment
       // size = typeallocsize of element type
       unsigned align = PAL.getParamAlignment(paramIndex + 1);

Added: llvm/trunk/test/CodeGen/NVPTX/aggr-param.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/NVPTX/aggr-param.ll?rev=200325&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/NVPTX/aggr-param.ll (added)
+++ llvm/trunk/test/CodeGen/NVPTX/aggr-param.ll Tue Jan 28 12:35:29 2014
@@ -0,0 +1,20 @@
+; RUN: llc < %s -march=nvptx -mcpu=sm_20 | FileCheck %s
+
+; Make sure aggregate param types get emitted properly.
+
+%struct.float4 = type { float, float, float, float }
+
+; CHECK: .visible .func bar
+; CHECK:   .param .align 4 .b8 bar_param_0[16]
+define void @bar(%struct.float4 %f) {
+entry:
+  ret void
+}
+
+; CHECK: .visible .func foo
+; CHECK:   .param .align 4 .b8 foo_param_0[20]
+define void @foo([5 x i32] %f) {
+entry:
+  ret void
+}
+





More information about the llvm-commits mailing list