summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDan Bailey <dan@dneg.com>2011-11-03 19:24:46 +0000
committerDan Bailey <dan@dneg.com>2011-11-03 19:24:46 +0000
commite1f38f2ce1221176cc4934a73283cb151e1f940d (patch)
tree6b7b9a3221ea6149b5182b5b00c729a9d0bbae21 /lib
parenta3a2dfd4a2a8265a9a0c962cb776e2e6ba123956 (diff)
downloadllvm-e1f38f2ce1221176cc4934a73283cb151e1f940d.tar.gz
llvm-e1f38f2ce1221176cc4934a73283cb151e1f940d.tar.bz2
llvm-e1f38f2ce1221176cc4934a73283cb151e1f940d.tar.xz
fixed global array handling for ptx to use the correct bit widths
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143640 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Target/PTX/PTXAsmPrinter.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/lib/Target/PTX/PTXAsmPrinter.cpp b/lib/Target/PTX/PTXAsmPrinter.cpp
index b2aa7b27ed..e329d5dcc7 100644
--- a/lib/Target/PTX/PTXAsmPrinter.cpp
+++ b/lib/Target/PTX/PTXAsmPrinter.cpp
@@ -318,11 +318,7 @@ void PTXAsmPrinter::EmitVariableDeclaration(const GlobalVariable *gv) {
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 @@ void PTXAsmPrinter::EmitVariableDeclaration(const GlobalVariable *gv) {
// 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)