@@ -259,7 +259,7 @@ void NVPTXAsmPrinter::printReturnValStr(const Function *F, raw_ostream &O) {
259
259
return ;
260
260
O << " (" ;
261
261
262
- auto PrintScalarParam = [&](unsigned Size) {
262
+ auto PrintScalarRetVal = [&](unsigned Size) {
263
263
O << " .param .b" << promoteScalarArgumentSize (Size) << " func_retval0" ;
264
264
};
265
265
if (shouldPassAsArray (Ty)) {
@@ -269,11 +269,11 @@ void NVPTXAsmPrinter::printReturnValStr(const Function *F, raw_ostream &O) {
269
269
O << " .param .align " << RetAlignment.value () << " .b8 func_retval0["
270
270
<< TotalSize << " ]" ;
271
271
} else if (Ty->isFloatingPointTy ()) {
272
- PrintScalarParam (Ty->getPrimitiveSizeInBits ());
272
+ PrintScalarRetVal (Ty->getPrimitiveSizeInBits ());
273
273
} else if (auto *ITy = dyn_cast<IntegerType>(Ty)) {
274
- PrintScalarParam (ITy->getBitWidth ());
274
+ PrintScalarRetVal (ITy->getBitWidth ());
275
275
} else if (isa<PointerType>(Ty)) {
276
- PrintScalarParam (TLI->getPointerTy (DL).getSizeInBits ());
276
+ PrintScalarRetVal (TLI->getPointerTy (DL).getSizeInBits ());
277
277
} else
278
278
llvm_unreachable (" Unknown return type" );
279
279
O << " ) " ;
@@ -1674,24 +1674,24 @@ void NVPTXAsmPrinter::bufferAggregateConstant(const Constant *CPV,
1674
1674
AggBuffer *aggBuffer) {
1675
1675
const DataLayout &DL = getDataLayout ();
1676
1676
1677
- auto BufferConstant = [& ](APInt Val) {
1678
- for (unsigned I = 0 , E = DL. getTypeAllocSize (CPV-> getType ()); I < E; ++I ) {
1677
+ auto BufferConstant = [](APInt Val, AggBuffer *Buffer ) {
1678
+ for (unsigned _ : llvm::seq (Val. getBitWidth () / 8 ) ) {
1679
1679
uint8_t Byte = Val.getLoBits (8 ).getZExtValue ();
1680
- aggBuffer ->addBytes (&Byte, 1 , 1 );
1680
+ Buffer ->addBytes (&Byte, 1 , 1 );
1681
1681
Val.lshrInPlace (8 );
1682
1682
}
1683
1683
};
1684
1684
1685
1685
// Integers of arbitrary width
1686
1686
if (const ConstantInt *CI = dyn_cast<ConstantInt>(CPV)) {
1687
- BufferConstant (CI->getValue ());
1687
+ BufferConstant (CI->getValue (), aggBuffer );
1688
1688
return ;
1689
1689
}
1690
1690
1691
1691
// f128
1692
1692
if (const ConstantFP *CFP = dyn_cast<ConstantFP>(CPV)) {
1693
1693
if (CFP->getType ()->isFP128Ty ()) {
1694
- BufferConstant (CFP->getValueAPF ().bitcastToAPInt ());
1694
+ BufferConstant (CFP->getValueAPF ().bitcastToAPInt (), aggBuffer );
1695
1695
return ;
1696
1696
}
1697
1697
}
@@ -1705,7 +1705,7 @@ void NVPTXAsmPrinter::bufferAggregateConstant(const Constant *CPV,
1705
1705
1706
1706
if (const auto *CDS = dyn_cast<ConstantDataSequential>(CPV)) {
1707
1707
if (CDS->getNumElements ())
1708
- for (unsigned i = 0 ; i < CDS->getNumElements (); ++i )
1708
+ for (unsigned i : llvm::seq ( CDS->getNumElements ()) )
1709
1709
bufferLEByte (cast<Constant>(CDS->getElementAsConstant (i)), 0 ,
1710
1710
aggBuffer);
1711
1711
return ;
@@ -1714,15 +1714,12 @@ void NVPTXAsmPrinter::bufferAggregateConstant(const Constant *CPV,
1714
1714
if (isa<ConstantStruct>(CPV)) {
1715
1715
if (CPV->getNumOperands ()) {
1716
1716
StructType *ST = cast<StructType>(CPV->getType ());
1717
- for (unsigned i = 0 , e = CPV->getNumOperands (); i != e; ++i) {
1718
- int Bytes;
1719
- if (i == (e - 1 ))
1720
- Bytes = DL.getStructLayout (ST)->getElementOffset (0 ) +
1721
- DL.getTypeAllocSize (ST) -
1722
- DL.getStructLayout (ST)->getElementOffset (i);
1723
- else
1724
- Bytes = DL.getStructLayout (ST)->getElementOffset (i + 1 ) -
1725
- DL.getStructLayout (ST)->getElementOffset (i);
1717
+ for (unsigned i : llvm::seq (CPV->getNumOperands ())) {
1718
+ int EndOffset = (i + 1 == CPV->getNumOperands ())
1719
+ ? DL.getStructLayout (ST)->getElementOffset (0 ) +
1720
+ DL.getTypeAllocSize (ST)
1721
+ : DL.getStructLayout (ST)->getElementOffset (i + 1 );
1722
+ int Bytes = EndOffset - DL.getStructLayout (ST)->getElementOffset (i);
1726
1723
bufferLEByte (cast<Constant>(CPV->getOperand (i)), Bytes, aggBuffer);
1727
1724
}
1728
1725
}
0 commit comments