@@ -431,28 +431,26 @@ PPCTargetLowering::PPCTargetLowering(const PPCTargetMachine &TM,
431
431
// VASTART needs to be custom lowered to use the VarArgsFrameIndex
432
432
setOperationAction(ISD::VASTART , MVT::Other, Custom);
433
433
434
- if (Subtarget.isSVR4ABI()) {
435
- if (isPPC64) {
436
- // VAARG always uses double-word chunks, so promote anything smaller.
437
- setOperationAction(ISD::VAARG, MVT::i1, Promote);
438
- AddPromotedToType (ISD::VAARG, MVT::i1, MVT::i64);
439
- setOperationAction(ISD::VAARG, MVT::i8, Promote);
440
- AddPromotedToType (ISD::VAARG, MVT::i8, MVT::i64);
441
- setOperationAction(ISD::VAARG, MVT::i16, Promote);
442
- AddPromotedToType (ISD::VAARG, MVT::i16, MVT::i64);
443
- setOperationAction(ISD::VAARG, MVT::i32, Promote);
444
- AddPromotedToType (ISD::VAARG, MVT::i32, MVT::i64);
445
- setOperationAction(ISD::VAARG, MVT::Other, Expand);
446
- } else {
447
- // VAARG is custom lowered with the 32-bit SVR4 ABI.
448
- setOperationAction(ISD::VAARG, MVT::Other, Custom);
449
- setOperationAction(ISD::VAARG, MVT::i64, Custom);
450
- }
434
+ if (Subtarget.is64BitELFABI()) {
435
+ // VAARG always uses double-word chunks, so promote anything smaller.
436
+ setOperationAction(ISD::VAARG, MVT::i1, Promote);
437
+ AddPromotedToType(ISD::VAARG, MVT::i1, MVT::i64);
438
+ setOperationAction(ISD::VAARG, MVT::i8, Promote);
439
+ AddPromotedToType(ISD::VAARG, MVT::i8, MVT::i64);
440
+ setOperationAction(ISD::VAARG, MVT::i16, Promote);
441
+ AddPromotedToType(ISD::VAARG, MVT::i16, MVT::i64);
442
+ setOperationAction(ISD::VAARG, MVT::i32, Promote);
443
+ AddPromotedToType(ISD::VAARG, MVT::i32, MVT::i64);
444
+ setOperationAction(ISD::VAARG, MVT::Other, Expand);
445
+ } else if (Subtarget.is32BitELFABI()) {
446
+ // VAARG is custom lowered with the 32-bit SVR4 ABI.
447
+ setOperationAction(ISD::VAARG, MVT::Other, Custom);
448
+ setOperationAction(ISD::VAARG, MVT::i64, Custom);
451
449
} else
452
450
setOperationAction(ISD::VAARG, MVT::Other, Expand);
453
451
454
- if (Subtarget.isSVR4ABI() && !isPPC64)
455
- // VACOPY is custom lowered with the 32-bit SVR4 ABI.
452
+ // VACOPY is custom lowered with the 32-bit SVR4 ABI.
453
+ if (Subtarget.is32BitELFABI())
456
454
setOperationAction(ISD::VACOPY , MVT::Other, Custom);
457
455
else
458
456
setOperationAction(ISD::VACOPY , MVT::Other, Expand);
@@ -2694,7 +2692,7 @@ SDValue PPCTargetLowering::LowerConstantPool(SDValue Op,
2694
2692
2695
2693
// 64-bit SVR4 ABI code is always position-independent.
2696
2694
// The actual address of the GlobalValue is stored in the TOC.
2697
- if (Subtarget.isSVR4ABI() && Subtarget.isPPC64 ()) {
2695
+ if (Subtarget.is64BitELFABI ()) {
2698
2696
setUsesTOCBasePtr(DAG);
2699
2697
SDValue GA = DAG.getTargetConstantPool(C, PtrVT, CP->getAlignment(), 0);
2700
2698
return getTOCEntry(DAG, SDLoc(CP), GA);
@@ -2770,7 +2768,7 @@ SDValue PPCTargetLowering::LowerJumpTable(SDValue Op, SelectionDAG &DAG) const {
2770
2768
2771
2769
// 64-bit SVR4 ABI code is always position-independent.
2772
2770
// The actual address of the GlobalValue is stored in the TOC.
2773
- if (Subtarget.isSVR4ABI() && Subtarget.isPPC64 ()) {
2771
+ if (Subtarget.is64BitELFABI ()) {
2774
2772
setUsesTOCBasePtr(DAG);
2775
2773
SDValue GA = DAG.getTargetJumpTable(JT->getIndex(), PtrVT);
2776
2774
return getTOCEntry(DAG, SDLoc(JT), GA);
@@ -2799,14 +2797,18 @@ SDValue PPCTargetLowering::LowerBlockAddress(SDValue Op,
2799
2797
2800
2798
// 64-bit SVR4 ABI code is always position-independent.
2801
2799
// The actual BlockAddress is stored in the TOC.
2802
- if (Subtarget.isSVR4ABI() &&
2803
- (Subtarget.isPPC64() || isPositionIndependent())) {
2804
- if (Subtarget.isPPC64())
2805
- setUsesTOCBasePtr(DAG);
2800
+ if (Subtarget.is64BitELFABI()) {
2801
+ setUsesTOCBasePtr(DAG);
2806
2802
SDValue GA = DAG.getTargetBlockAddress(BA, PtrVT, BASDN->getOffset());
2807
2803
return getTOCEntry(DAG, SDLoc(BASDN), GA);
2808
2804
}
2809
2805
2806
+ // 32-bit position-independent ELF stores the BlockAddress in the .got.
2807
+ if (Subtarget.is32BitELFABI() && isPositionIndependent())
2808
+ return getTOCEntry(
2809
+ DAG, SDLoc(BASDN),
2810
+ DAG.getTargetBlockAddress(BA, PtrVT, BASDN->getOffset()));
2811
+
2810
2812
unsigned MOHiFlag, MOLoFlag;
2811
2813
bool IsPIC = isPositionIndependent();
2812
2814
getLabelAccessInfo(IsPIC, Subtarget, MOHiFlag, MOLoFlag);
@@ -2921,7 +2923,7 @@ SDValue PPCTargetLowering::LowerGlobalAddress(SDValue Op,
2921
2923
2922
2924
// 64-bit SVR4 ABI & AIX ABI code is always position-independent.
2923
2925
// The actual address of the GlobalValue is stored in the TOC.
2924
- if (( Subtarget.isSVR4ABI() && Subtarget.isPPC64() ) || Subtarget.isAIXABI()) {
2926
+ if (Subtarget.is64BitELFABI( ) || Subtarget.isAIXABI()) {
2925
2927
setUsesTOCBasePtr(DAG);
2926
2928
SDValue GA = DAG.getTargetGlobalAddress(GV, DL, PtrVT, GSDN->getOffset());
2927
2929
return getTOCEntry(DAG, DL, GA);
@@ -3383,17 +3385,17 @@ SDValue PPCTargetLowering::LowerFormalArguments(
3383
3385
SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
3384
3386
const SmallVectorImpl<ISD::InputArg> &Ins, const SDLoc &dl,
3385
3387
SelectionDAG &DAG, SmallVectorImpl<SDValue> &InVals) const {
3386
- if (Subtarget.isSVR4ABI ()) {
3387
- if (Subtarget.isPPC64())
3388
- return LowerFormalArguments_64SVR4(Chain, CallConv, isVarArg, Ins,
3389
- dl, DAG, InVals);
3390
- else
3391
- return LowerFormalArguments_32SVR4(Chain, CallConv, isVarArg, Ins,
3392
- dl, DAG, InVals);
3393
- } else {
3394
- return LowerFormalArguments_Darwin(Chain, CallConv, isVarArg, Ins,
3395
- dl, DAG, InVals);
3396
- }
3388
+ if (Subtarget.is64BitELFABI ())
3389
+ return LowerFormalArguments_64SVR4(Chain, CallConv, isVarArg, Ins, dl, DAG,
3390
+ InVals);
3391
+ else if (Subtarget.is32BitELFABI())
3392
+ return LowerFormalArguments_32SVR4(Chain, CallConv, isVarArg, Ins, dl, DAG,
3393
+ InVals);
3394
+
3395
+ // FIXME: We are using this for both AIX and Darwin. We should add appropriate
3396
+ // AIX testing, and rename it appropriately.
3397
+ return LowerFormalArguments_Darwin(Chain, CallConv, isVarArg, Ins, dl, DAG,
3398
+ InVals);
3397
3399
}
3398
3400
3399
3401
SDValue PPCTargetLowering::LowerFormalArguments_32SVR4(
@@ -4522,7 +4524,7 @@ callsShareTOCBase(const Function *Caller, SDValue Callee,
4522
4524
static bool
4523
4525
needStackSlotPassParameters(const PPCSubtarget &Subtarget,
4524
4526
const SmallVectorImpl<ISD::OutputArg> &Outs) {
4525
- assert(Subtarget.isSVR4ABI() && Subtarget.isPPC64 ());
4527
+ assert(Subtarget.is64BitELFABI ());
4526
4528
4527
4529
const unsigned PtrByteSize = 8;
4528
4530
const unsigned LinkageSize = Subtarget.getFrameLowering()->getLinkageSize();
@@ -4932,7 +4934,7 @@ PrepareCall(SelectionDAG &DAG, SDValue &Callee, SDValue &InFlag, SDValue &Chain,
4932
4934
ImmutableCallSite CS, const PPCSubtarget &Subtarget) {
4933
4935
bool isPPC64 = Subtarget.isPPC64();
4934
4936
bool isSVR4ABI = Subtarget.isSVR4ABI();
4935
- bool isELFv2ABI = Subtarget.isELFv2ABI();
4937
+ bool is64BitELFv1ABI = isPPC64 && isSVR4ABI && ! Subtarget.isELFv2ABI();
4936
4938
bool isAIXABI = Subtarget.isAIXABI();
4937
4939
4938
4940
EVT PtrVT = DAG.getTargetLoweringInfo().getPointerTy(DAG.getDataLayout());
@@ -5003,7 +5005,7 @@ PrepareCall(SelectionDAG &DAG, SDValue &Callee, SDValue &InFlag, SDValue &Chain,
5003
5005
// to do the call, we can't use PPCISD::CALL.
5004
5006
SDValue MTCTROps[] = {Chain, Callee, InFlag};
5005
5007
5006
- if (isSVR4ABI && isPPC64 && !isELFv2ABI ) {
5008
+ if (is64BitELFv1ABI ) {
5007
5009
// Function pointers in the 64-bit SVR4 ABI do not point to the function
5008
5010
// entry point, but to the function descriptor (the function entry point
5009
5011
// address is part of the function descriptor though).
@@ -5091,7 +5093,7 @@ PrepareCall(SelectionDAG &DAG, SDValue &Callee, SDValue &InFlag, SDValue &Chain,
5091
5093
CallOpc = PPCISD::BCTRL;
5092
5094
Callee.setNode(nullptr);
5093
5095
// Add use of X11 (holding environment pointer)
5094
- if (isSVR4ABI && isPPC64 && !isELFv2ABI && !hasNest)
5096
+ if (is64BitELFv1ABI && !hasNest)
5095
5097
Ops.push_back(DAG.getRegister(PPC::X11, PtrVT));
5096
5098
// Add CTR register as callee so a bctr can be emitted later.
5097
5099
if (isTailCall)
@@ -10511,7 +10513,7 @@ PPCTargetLowering::emitEHSjLjSetJmp(MachineInstr &MI,
10511
10513
Register LabelReg = MRI.createVirtualRegister(PtrRC);
10512
10514
Register BufReg = MI.getOperand(1).getReg();
10513
10515
10514
- if (Subtarget.isPPC64() && Subtarget.isSVR4ABI ()) {
10516
+ if (Subtarget.is64BitELFABI ()) {
10515
10517
setUsesTOCBasePtr(*MBB->getParent());
10516
10518
MIB = BuildMI(*thisMBB, MI, DL, TII->get(PPC::STD))
10517
10519
.addReg(PPC::X2)
@@ -10688,7 +10690,7 @@ PPCTargetLowering::EmitInstrWithCustomInserter(MachineInstr &MI,
10688
10690
MachineBasicBlock *BB) const {
10689
10691
if (MI.getOpcode() == TargetOpcode::STACKMAP ||
10690
10692
MI.getOpcode() == TargetOpcode::PATCHPOINT) {
10691
- if (Subtarget.isPPC64() && Subtarget.isSVR4ABI () &&
10693
+ if (Subtarget.is64BitELFABI () &&
10692
10694
MI.getOpcode() == TargetOpcode::PATCHPOINT) {
10693
10695
// Call lowering should have added an r2 operand to indicate a dependence
10694
10696
// on the TOC base pointer value. It can't however, because there is no
@@ -14424,7 +14426,7 @@ unsigned PPCTargetLowering::getRegisterByName(const char* RegName, EVT VT,
14424
14426
14425
14427
bool PPCTargetLowering::isAccessedAsGotIndirect(SDValue GA) const {
14426
14428
// 32-bit SVR4 ABI access everything as got-indirect.
14427
- if (Subtarget.isSVR4ABI() && !Subtarget.isPPC64 ())
14429
+ if (Subtarget.is32BitELFABI ())
14428
14430
return true;
14429
14431
14430
14432
// AIX accesses everything indirectly through the TOC, which is similar to
@@ -15243,7 +15245,7 @@ SDValue PPCTargetLowering::combineMUL(SDNode *N, DAGCombinerInfo &DCI) const {
15243
15245
15244
15246
bool PPCTargetLowering::mayBeEmittedAsTailCall(const CallInst *CI) const {
15245
15247
// Only duplicate to increase tail-calls for the 64bit SysV ABIs.
15246
- if (!Subtarget.isSVR4ABI() || !Subtarget.isPPC64 ())
15248
+ if (!Subtarget.is64BitELFABI ())
15247
15249
return false;
15248
15250
15249
15251
// If not a tail call then no need to proceed.
0 commit comments