Skip to content

Commit e4c9cf0

Browse files
author
Jingyue Wu
committedDec 17, 2014
[NVPTX] Fix bugs related to isSingleValueType
Summary: With isSingleValueType starting to treat vector types as single-value types, code that uses this interface needs to be updated. Test Plan: vector-global.ll nvcl-param-align.ll Reviewers: jholewinski Reviewed By: jholewinski Subscribers: llvm-commits, meheff, eliben, jholewinski Differential Revision: http://reviews.llvm.org/D6573 llvm-svn: 224440
1 parent 0e60abc commit e4c9cf0

File tree

3 files changed

+27
-13
lines changed

3 files changed

+27
-13
lines changed
 

Diff for: ‎llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp

+2-13
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,7 @@ void NVPTXAsmPrinter::printModuleLevelGV(const GlobalVariable *GVar,
11281128
else
11291129
O << " .align " << GVar->getAlignment();
11301130

1131-
if (ETy->isSingleValueType()) {
1131+
if (ETy->isFloatingPointTy() || ETy->isIntegerTy() || ETy->isPointerTy()) {
11321132
O << " .";
11331133
// Special case: ABI requires that we use .u8 for predicates
11341134
if (ETy->isIntegerTy(1))
@@ -1310,7 +1310,7 @@ void NVPTXAsmPrinter::emitPTXGlobalVariable(const GlobalVariable *GVar,
13101310
else
13111311
O << " .align " << GVar->getAlignment();
13121312

1313-
if (ETy->isSingleValueType()) {
1313+
if (ETy->isFloatingPointTy() || ETy->isIntegerTy() || ETy->isPointerTy()) {
13141314
O << " .";
13151315
O << getPTXFundamentalTypeStr(ETy);
13161316
O << " ";
@@ -1349,17 +1349,6 @@ static unsigned int getOpenCLAlignment(const DataLayout *TD, Type *Ty) {
13491349
if (ATy)
13501350
return getOpenCLAlignment(TD, ATy->getElementType());
13511351

1352-
const VectorType *VTy = dyn_cast<VectorType>(Ty);
1353-
if (VTy) {
1354-
Type *ETy = VTy->getElementType();
1355-
unsigned int numE = VTy->getNumElements();
1356-
unsigned int alignE = TD->getPrefTypeAlignment(ETy);
1357-
if (numE == 3)
1358-
return 4 * alignE;
1359-
else
1360-
return numE * alignE;
1361-
}
1362-
13631352
const StructType *STy = dyn_cast<StructType>(Ty);
13641353
if (STy) {
13651354
unsigned int alignStruct = 1;

Diff for: ‎llvm/test/CodeGen/NVPTX/nvcl-param-align.ll

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
; RUN: llc < %s -march=nvptx -mcpu=sm_20 | FileCheck %s
2+
3+
target triple = "nvptx-unknown-nvcl"
4+
5+
; CHECK-LABEL: .entry foo(
6+
define void @foo(i64 %img, i64 %sampler, <5 x float>* %v) {
7+
; The parameter alignment should be the next power of 2 of 5xsizeof(float),
8+
; which is 32.
9+
; CHECK: .param .u32 .ptr .align 32 foo_param_2
10+
ret void
11+
}
12+
13+
!nvvm.annotations = !{!1, !2, !3}
14+
!1 = !{void (i64, i64, <5 x float>*)* @foo, !"kernel", i32 1}
15+
!2 = !{void (i64, i64, <5 x float>*)* @foo, !"rdoimage", i32 0}
16+
!3 = !{void (i64, i64, <5 x float>*)* @foo, !"sampler", i32 1}

Diff for: ‎llvm/test/CodeGen/NVPTX/vector-global.ll

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
; RUN: llc < %s -march=nvptx64 -mcpu=sm_20 | FileCheck %s
2+
3+
target datalayout = "e-i64:64-v16:16-v32:32-n16:32:64"
4+
target triple = "nvptx64-nvidia-cuda"
5+
6+
@g1 = external global <4 x i32> ; external global variable
7+
; CHECK: .extern .global .align 16 .b8 g1[16];
8+
@g2 = global <4 x i32> zeroinitializer ; module-level global variable
9+
; CHECK: .visible .global .align 16 .b8 g2[16];

0 commit comments

Comments
 (0)