@@ -343,61 +343,32 @@ void NVPTXAsmPrinter::printReturnValStr(const Function *F, raw_ostream &O) {
343
343
const auto *TLI = cast<NVPTXTargetLowering>(STI.getTargetLowering ());
344
344
345
345
Type *Ty = F->getReturnType ();
346
-
347
- bool isABI = (STI.getSmVersion () >= 20 );
348
-
349
346
if (Ty->getTypeID () == Type::VoidTyID)
350
347
return ;
351
348
O << " (" ;
352
349
353
- if (isABI) {
354
- if ((Ty->isFloatingPointTy () || Ty->isIntegerTy ()) &&
355
- !ShouldPassAsArray (Ty)) {
356
- unsigned size = 0 ;
357
- if (auto *ITy = dyn_cast<IntegerType>(Ty)) {
358
- size = ITy->getBitWidth ();
359
- } else {
360
- assert (Ty->isFloatingPointTy () && " Floating point type expected here" );
361
- size = Ty->getPrimitiveSizeInBits ();
362
- }
363
- size = promoteScalarArgumentSize (size);
364
- O << " .param .b" << size << " func_retval0" ;
365
- } else if (isa<PointerType>(Ty)) {
366
- O << " .param .b" << TLI->getPointerTy (DL).getSizeInBits ()
367
- << " func_retval0" ;
368
- } else if (ShouldPassAsArray (Ty)) {
369
- unsigned totalsz = DL.getTypeAllocSize (Ty);
370
- Align RetAlignment = TLI->getFunctionArgumentAlignment (
371
- F, Ty, AttributeList::ReturnIndex, DL);
372
- O << " .param .align " << RetAlignment.value () << " .b8 func_retval0["
373
- << totalsz << " ]" ;
374
- } else
375
- llvm_unreachable (" Unknown return type" );
376
- } else {
377
- SmallVector<EVT, 16 > vtparts;
378
- ComputeValueVTs (*TLI, DL, Ty, vtparts);
379
- unsigned idx = 0 ;
380
- for (unsigned i = 0 , e = vtparts.size (); i != e; ++i) {
381
- unsigned elems = 1 ;
382
- EVT elemtype = vtparts[i];
383
- if (vtparts[i].isVector ()) {
384
- elems = vtparts[i].getVectorNumElements ();
385
- elemtype = vtparts[i].getVectorElementType ();
386
- }
387
-
388
- for (unsigned j = 0 , je = elems; j != je; ++j) {
389
- unsigned sz = elemtype.getSizeInBits ();
390
- if (elemtype.isInteger ())
391
- sz = promoteScalarArgumentSize (sz);
392
- O << " .reg .b" << sz << " func_retval" << idx;
393
- if (j < je - 1 )
394
- O << " , " ;
395
- ++idx;
396
- }
397
- if (i < e - 1 )
398
- O << " , " ;
350
+ if ((Ty->isFloatingPointTy () || Ty->isIntegerTy ()) &&
351
+ !ShouldPassAsArray (Ty)) {
352
+ unsigned size = 0 ;
353
+ if (auto *ITy = dyn_cast<IntegerType>(Ty)) {
354
+ size = ITy->getBitWidth ();
355
+ } else {
356
+ assert (Ty->isFloatingPointTy () && " Floating point type expected here" );
357
+ size = Ty->getPrimitiveSizeInBits ();
399
358
}
400
- }
359
+ size = promoteScalarArgumentSize (size);
360
+ O << " .param .b" << size << " func_retval0" ;
361
+ } else if (isa<PointerType>(Ty)) {
362
+ O << " .param .b" << TLI->getPointerTy (DL).getSizeInBits ()
363
+ << " func_retval0" ;
364
+ } else if (ShouldPassAsArray (Ty)) {
365
+ unsigned totalsz = DL.getTypeAllocSize (Ty);
366
+ Align RetAlignment = TLI->getFunctionArgumentAlignment (
367
+ F, Ty, AttributeList::ReturnIndex, DL);
368
+ O << " .param .align " << RetAlignment.value () << " .b8 func_retval0["
369
+ << totalsz << " ]" ;
370
+ } else
371
+ llvm_unreachable (" Unknown return type" );
401
372
O << " ) " ;
402
373
}
403
374
@@ -1513,7 +1484,6 @@ void NVPTXAsmPrinter::emitFunctionParamList(const Function *F, raw_ostream &O) {
1513
1484
unsigned paramIndex = 0 ;
1514
1485
bool first = true ;
1515
1486
bool isKernelFunc = isKernelFunction (*F);
1516
- bool isABI = (STI.getSmVersion () >= 20 );
1517
1487
1518
1488
if (F->arg_empty () && !F->isVarArg ()) {
1519
1489
O << " ()" ;
@@ -1646,10 +1616,7 @@ void NVPTXAsmPrinter::emitFunctionParamList(const Function *F, raw_ostream &O) {
1646
1616
sz = PTySizeInBits;
1647
1617
} else
1648
1618
sz = Ty->getPrimitiveSizeInBits ();
1649
- if (isABI)
1650
- O << " \t .param .b" << sz << " " ;
1651
- else
1652
- O << " \t .reg .b" << sz << " " ;
1619
+ O << " \t .param .b" << sz << " " ;
1653
1620
O << TLI->getParamName (F, paramIndex);
1654
1621
continue ;
1655
1622
}
@@ -1658,53 +1625,20 @@ void NVPTXAsmPrinter::emitFunctionParamList(const Function *F, raw_ostream &O) {
1658
1625
Type *ETy = PAL.getParamByValType (paramIndex);
1659
1626
assert (ETy && " Param should have byval type" );
1660
1627
1661
- if (isABI || isKernelFunc) {
1662
- // Just print .param .align <a> .b8 .param[size];
1663
- // <a> = optimal alignment for the element type; always multiple of
1664
- // PAL.getParamAlignment
1665
- // size = typeallocsize of element type
1666
- Align OptimalAlign =
1667
- isKernelFunc
1668
- ? getOptimalAlignForParam (ETy)
1669
- : TLI->getFunctionByValParamAlign (
1670
- F, ETy, PAL.getParamAlignment (paramIndex).valueOrOne (), DL);
1671
-
1672
- unsigned sz = DL.getTypeAllocSize (ETy);
1673
- O << " \t .param .align " << OptimalAlign.value () << " .b8 " ;
1674
- O << TLI->getParamName (F, paramIndex);
1675
- O << " [" << sz << " ]" ;
1676
- continue ;
1677
- } else {
1678
- // Split the ETy into constituent parts and
1679
- // print .param .b<size> <name> for each part.
1680
- // Further, if a part is vector, print the above for
1681
- // each vector element.
1682
- SmallVector<EVT, 16 > vtparts;
1683
- ComputeValueVTs (*TLI, DL, ETy, vtparts);
1684
- for (unsigned i = 0 , e = vtparts.size (); i != e; ++i) {
1685
- unsigned elems = 1 ;
1686
- EVT elemtype = vtparts[i];
1687
- if (vtparts[i].isVector ()) {
1688
- elems = vtparts[i].getVectorNumElements ();
1689
- elemtype = vtparts[i].getVectorElementType ();
1690
- }
1691
-
1692
- for (unsigned j = 0 , je = elems; j != je; ++j) {
1693
- unsigned sz = elemtype.getSizeInBits ();
1694
- if (elemtype.isInteger ())
1695
- sz = promoteScalarArgumentSize (sz);
1696
- O << " \t .reg .b" << sz << " " ;
1697
- O << TLI->getParamName (F, paramIndex);
1698
- if (j < je - 1 )
1699
- O << " ,\n " ;
1700
- ++paramIndex;
1701
- }
1702
- if (i < e - 1 )
1703
- O << " ,\n " ;
1704
- }
1705
- --paramIndex;
1706
- continue ;
1707
- }
1628
+ // Print .param .align <a> .b8 .param[size];
1629
+ // <a> = optimal alignment for the element type; always multiple of
1630
+ // PAL.getParamAlignment
1631
+ // size = typeallocsize of element type
1632
+ Align OptimalAlign =
1633
+ isKernelFunc
1634
+ ? getOptimalAlignForParam (ETy)
1635
+ : TLI->getFunctionByValParamAlign (
1636
+ F, ETy, PAL.getParamAlignment (paramIndex).valueOrOne (), DL);
1637
+
1638
+ unsigned sz = DL.getTypeAllocSize (ETy);
1639
+ O << " \t .param .align " << OptimalAlign.value () << " .b8 " ;
1640
+ O << TLI->getParamName (F, paramIndex);
1641
+ O << " [" << sz << " ]" ;
1708
1642
}
1709
1643
1710
1644
if (F->isVarArg ()) {
0 commit comments