diff options
| author | Justin Lebar <jlebar@google.com> | 2017-01-18 00:29:53 +0000 |
|---|---|---|
| committer | Justin Lebar <jlebar@google.com> | 2017-01-18 00:29:53 +0000 |
| commit | 1cf6bf4989d70ac0f405fe5c3d9e1a2aab7adb41 (patch) | |
| tree | fc8ac94d2509786ce8295f2f14c5c645fbfe4a6d /llvm/lib | |
| parent | 58e8142f0edbdce5a1641e0c9208d0a6aad508c0 (diff) | |
| download | bcm5719-llvm-1cf6bf4989d70ac0f405fe5c3d9e1a2aab7adb41.tar.gz bcm5719-llvm-1cf6bf4989d70ac0f405fe5c3d9e1a2aab7adb41.zip | |
[NVPTX] Support global variables of integer type larger than i64.
Reviewers: tra, majnemer
Subscribers: llvm-commits, jholewinski
Differential Revision: https://reviews.llvm.org/D28825
llvm-svn: 292316
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp index fa4b389cdb2..b9473514e5e 100644 --- a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp @@ -1230,7 +1230,8 @@ void NVPTXAsmPrinter::printModuleLevelGV(const GlobalVariable *GVar, else O << " .align " << GVar->getAlignment(); - if (ETy->isFloatingPointTy() || ETy->isIntegerTy() || ETy->isPointerTy()) { + if (ETy->isFloatingPointTy() || ETy->isPointerTy() || + (ETy->isIntegerTy() && ETy->getScalarSizeInBits() <= 64)) { O << " ."; // Special case: ABI requires that we use .u8 for predicates if (ETy->isIntegerTy(1)) @@ -1271,6 +1272,7 @@ void NVPTXAsmPrinter::printModuleLevelGV(const GlobalVariable *GVar, // targets that support these high level field accesses. Structs, arrays // and vectors are lowered into arrays of bytes. switch (ETy->getTypeID()) { + case Type::IntegerTyID: // Integers larger than 64 bits case Type::StructTyID: case Type::ArrayTyID: case Type::VectorTyID: @@ -1994,6 +1996,17 @@ void NVPTXAsmPrinter::bufferAggregateConstant(const Constant *CPV, const DataLayout &DL = getDataLayout(); int Bytes; + // Integers of arbitrary width + if (const ConstantInt *CI = dyn_cast<ConstantInt>(CPV)) { + APInt Val = CI->getValue(); + for (unsigned I = 0, E = DL.getTypeAllocSize(CPV->getType()); I < E; ++I) { + uint8_t Byte = Val.getLoBits(8).getZExtValue(); + aggBuffer->addBytes(&Byte, 1, 1); + Val = Val.lshr(8); + } + return; + } + // Old constants if (isa<ConstantArray>(CPV) || isa<ConstantVector>(CPV)) { if (CPV->getNumOperands()) |

