[llvm-commits] [llvm] r143640 - in /llvm/trunk: lib/Target/PTX/PTXAsmPrinter.cpp test/CodeGen/PTX/ld.ll test/CodeGen/PTX/st.ll
Dan Bailey
dan at dneg.com
Thu Nov 3 12:24:46 PDT 2011
Author: drb
Date: Thu Nov 3 14:24:46 2011
New Revision: 143640
URL: http://llvm.org/viewvc/llvm-project?rev=143640&view=rev
Log:
fixed global array handling for ptx to use the correct bit widths
Modified:
llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp
llvm/trunk/test/CodeGen/PTX/ld.ll
llvm/trunk/test/CodeGen/PTX/st.ll
Modified: llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp?rev=143640&r1=143639&r2=143640&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp Thu Nov 3 14:24:46 2011
@@ -318,11 +318,7 @@
if (PointerType::classof(gv->getType())) {
PointerType* pointerTy = dyn_cast<PointerType>(gv->getType());
Type* elementTy = pointerTy->getElementType();
-
- decl += ".b8 ";
- decl += gvsym->getName();
- decl += "[";
-
+
if (elementTy->isArrayTy())
{
assert(elementTy->isArrayTy() && "Only pointers to arrays are supported");
@@ -343,15 +339,24 @@
// FIXME: isPrimitiveType() == false for i16?
assert(elementTy->isSingleValueType() &&
"Non-primitive types are not handled");
+
+ // Find the size of the element in bits
+ unsigned elementSize = elementTy->getPrimitiveSizeInBits();
- // Compute the size of the array, in bytes.
- uint64_t arraySize = (elementTy->getPrimitiveSizeInBits() >> 3)
- * numElements;
-
- decl += utostr(arraySize);
+ decl += ".b";
+ decl += utostr(elementSize);
+ decl += " ";
+ decl += gvsym->getName();
+ decl += "[";
+ decl += utostr(numElements);
+ decl += "]";
+ }
+ else
+ {
+ decl += ".b8 ";
+ decl += gvsym->getName();
+ decl += "[]";
}
-
- decl += "]";
// handle string constants (assume ConstantArray means string)
Modified: llvm/trunk/test/CodeGen/PTX/ld.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PTX/ld.ll?rev=143640&r1=143639&r2=143640&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/PTX/ld.ll (original)
+++ llvm/trunk/test/CodeGen/PTX/ld.ll Thu Nov 3 14:24:46 2011
@@ -1,48 +1,48 @@
; RUN: llc < %s -march=ptx32 | FileCheck %s
-;CHECK: .extern .global .b8 array_i16[20];
+;CHECK: .extern .global .b16 array_i16[10];
@array_i16 = external global [10 x i16]
-;CHECK: .extern .const .b8 array_constant_i16[20];
+;CHECK: .extern .const .b16 array_constant_i16[10];
@array_constant_i16 = external addrspace(1) constant [10 x i16]
-;CHECK: .extern .shared .b8 array_shared_i16[20];
+;CHECK: .extern .shared .b16 array_shared_i16[10];
@array_shared_i16 = external addrspace(4) global [10 x i16]
-;CHECK: .extern .global .b8 array_i32[40];
+;CHECK: .extern .global .b32 array_i32[10];
@array_i32 = external global [10 x i32]
-;CHECK: .extern .const .b8 array_constant_i32[40];
+;CHECK: .extern .const .b32 array_constant_i32[10];
@array_constant_i32 = external addrspace(1) constant [10 x i32]
-;CHECK: .extern .shared .b8 array_shared_i32[40];
+;CHECK: .extern .shared .b32 array_shared_i32[10];
@array_shared_i32 = external addrspace(4) global [10 x i32]
-;CHECK: .extern .global .b8 array_i64[80];
+;CHECK: .extern .global .b64 array_i64[10];
@array_i64 = external global [10 x i64]
-;CHECK: .extern .const .b8 array_constant_i64[80];
+;CHECK: .extern .const .b64 array_constant_i64[10];
@array_constant_i64 = external addrspace(1) constant [10 x i64]
-;CHECK: .extern .shared .b8 array_shared_i64[80];
+;CHECK: .extern .shared .b64 array_shared_i64[10];
@array_shared_i64 = external addrspace(4) global [10 x i64]
-;CHECK: .extern .global .b8 array_float[40];
+;CHECK: .extern .global .b32 array_float[10];
@array_float = external global [10 x float]
-;CHECK: .extern .const .b8 array_constant_float[40];
+;CHECK: .extern .const .b32 array_constant_float[10];
@array_constant_float = external addrspace(1) constant [10 x float]
-;CHECK: .extern .shared .b8 array_shared_float[40];
+;CHECK: .extern .shared .b32 array_shared_float[10];
@array_shared_float = external addrspace(4) global [10 x float]
-;CHECK: .extern .global .b8 array_double[80];
+;CHECK: .extern .global .b64 array_double[10];
@array_double = external global [10 x double]
-;CHECK: .extern .const .b8 array_constant_double[80];
+;CHECK: .extern .const .b64 array_constant_double[10];
@array_constant_double = external addrspace(1) constant [10 x double]
-;CHECK: .extern .shared .b8 array_shared_double[80];
+;CHECK: .extern .shared .b64 array_shared_double[10];
@array_shared_double = external addrspace(4) global [10 x double]
Modified: llvm/trunk/test/CodeGen/PTX/st.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PTX/st.ll?rev=143640&r1=143639&r2=143640&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/PTX/st.ll (original)
+++ llvm/trunk/test/CodeGen/PTX/st.ll Thu Nov 3 14:24:46 2011
@@ -1,48 +1,48 @@
; RUN: llc < %s -march=ptx32 | FileCheck %s
-;CHECK: .extern .global .b8 array_i16[20];
+;CHECK: .extern .global .b16 array_i16[10];
@array_i16 = external global [10 x i16]
-;CHECK: .extern .const .b8 array_constant_i16[20];
+;CHECK: .extern .const .b16 array_constant_i16[10];
@array_constant_i16 = external addrspace(1) constant [10 x i16]
-;CHECK: .extern .shared .b8 array_shared_i16[20];
+;CHECK: .extern .shared .b16 array_shared_i16[10];
@array_shared_i16 = external addrspace(4) global [10 x i16]
-;CHECK: .extern .global .b8 array_i32[40];
+;CHECK: .extern .global .b32 array_i32[10];
@array_i32 = external global [10 x i32]
-;CHECK: .extern .const .b8 array_constant_i32[40];
+;CHECK: .extern .const .b32 array_constant_i32[10];
@array_constant_i32 = external addrspace(1) constant [10 x i32]
-;CHECK: .extern .shared .b8 array_shared_i32[40];
+;CHECK: .extern .shared .b32 array_shared_i32[10];
@array_shared_i32 = external addrspace(4) global [10 x i32]
-;CHECK: .extern .global .b8 array_i64[80];
+;CHECK: .extern .global .b64 array_i64[10];
@array_i64 = external global [10 x i64]
-;CHECK: .extern .const .b8 array_constant_i64[80];
+;CHECK: .extern .const .b64 array_constant_i64[10];
@array_constant_i64 = external addrspace(1) constant [10 x i64]
-;CHECK: .extern .shared .b8 array_shared_i64[80];
+;CHECK: .extern .shared .b64 array_shared_i64[10];
@array_shared_i64 = external addrspace(4) global [10 x i64]
-;CHECK: .extern .global .b8 array_float[40];
+;CHECK: .extern .global .b32 array_float[10];
@array_float = external global [10 x float]
-;CHECK: .extern .const .b8 array_constant_float[40];
+;CHECK: .extern .const .b32 array_constant_float[10];
@array_constant_float = external addrspace(1) constant [10 x float]
-;CHECK: .extern .shared .b8 array_shared_float[40];
+;CHECK: .extern .shared .b32 array_shared_float[10];
@array_shared_float = external addrspace(4) global [10 x float]
-;CHECK: .extern .global .b8 array_double[80];
+;CHECK: .extern .global .b64 array_double[10];
@array_double = external global [10 x double]
-;CHECK: .extern .const .b8 array_constant_double[80];
+;CHECK: .extern .const .b64 array_constant_double[10];
@array_constant_double = external addrspace(1) constant [10 x double]
-;CHECK: .extern .shared .b8 array_shared_double[80];
+;CHECK: .extern .shared .b64 array_shared_double[10];
@array_shared_double = external addrspace(4) global [10 x double]
More information about the llvm-commits
mailing list