mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-27 13:30:05 +00:00
Reset the subtarget for DAGToDAG on every iteration of runOnMachineFunction.
This required updating the generated functions and TD file accordingly to be pointers rather than const references. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209375 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
162180cba5
commit
58d9172bb4
@ -86,7 +86,7 @@ class PPCFastISel final : public FastISel {
|
||||
const TargetMachine &TM;
|
||||
const TargetInstrInfo &TII;
|
||||
const TargetLowering &TLI;
|
||||
const PPCSubtarget &PPCSubTarget;
|
||||
const PPCSubtarget *PPCSubTarget;
|
||||
LLVMContext *Context;
|
||||
|
||||
public:
|
||||
@ -96,9 +96,7 @@ class PPCFastISel final : public FastISel {
|
||||
TM(FuncInfo.MF->getTarget()),
|
||||
TII(*TM.getInstrInfo()),
|
||||
TLI(*TM.getTargetLowering()),
|
||||
PPCSubTarget(
|
||||
*((static_cast<const PPCTargetMachine *>(&TM))->getSubtargetImpl())
|
||||
),
|
||||
PPCSubTarget(&TM.getSubtarget<PPCSubtarget>()),
|
||||
Context(&FuncInfo.Fn->getContext()) { }
|
||||
|
||||
// Backend specific FastISel code.
|
||||
@ -740,7 +738,7 @@ bool PPCFastISel::PPCEmitCmp(const Value *SrcValue1, const Value *SrcValue2,
|
||||
return false;
|
||||
MVT SrcVT = SrcEVT.getSimpleVT();
|
||||
|
||||
if (SrcVT == MVT::i1 && PPCSubTarget.useCRBits())
|
||||
if (SrcVT == MVT::i1 && PPCSubTarget->useCRBits())
|
||||
return false;
|
||||
|
||||
// See if operand 2 is an immediate encodeable in the compare.
|
||||
@ -901,7 +899,7 @@ unsigned PPCFastISel::PPCMoveToFPReg(MVT SrcVT, unsigned SrcReg,
|
||||
if (!IsSigned) {
|
||||
LoadOpc = PPC::LFIWZX;
|
||||
Addr.Offset = 4;
|
||||
} else if (PPCSubTarget.hasLFIWAX()) {
|
||||
} else if (PPCSubTarget->hasLFIWAX()) {
|
||||
LoadOpc = PPC::LFIWAX;
|
||||
Addr.Offset = 4;
|
||||
}
|
||||
@ -942,7 +940,7 @@ bool PPCFastISel::SelectIToFP(const Instruction *I, bool IsSigned) {
|
||||
|
||||
// We can only lower an unsigned convert if we have the newer
|
||||
// floating-point conversion operations.
|
||||
if (!IsSigned && !PPCSubTarget.hasFPCVT())
|
||||
if (!IsSigned && !PPCSubTarget->hasFPCVT())
|
||||
return false;
|
||||
|
||||
// FIXME: For now we require the newer floating-point conversion operations
|
||||
@ -950,7 +948,7 @@ bool PPCFastISel::SelectIToFP(const Instruction *I, bool IsSigned) {
|
||||
// to single-precision float. Otherwise we have to generate a lot of
|
||||
// fiddly code to avoid double rounding. If necessary, the fiddly code
|
||||
// can be found in PPCTargetLowering::LowerINT_TO_FP().
|
||||
if (DstVT == MVT::f32 && !PPCSubTarget.hasFPCVT())
|
||||
if (DstVT == MVT::f32 && !PPCSubTarget->hasFPCVT())
|
||||
return false;
|
||||
|
||||
// Extend the input if necessary.
|
||||
@ -1065,7 +1063,7 @@ bool PPCFastISel::SelectFPToI(const Instruction *I, bool IsSigned) {
|
||||
if (IsSigned)
|
||||
Opc = PPC::FCTIWZ;
|
||||
else
|
||||
Opc = PPCSubTarget.hasFPCVT() ? PPC::FCTIWUZ : PPC::FCTIDZ;
|
||||
Opc = PPCSubTarget->hasFPCVT() ? PPC::FCTIWUZ : PPC::FCTIDZ;
|
||||
else
|
||||
Opc = IsSigned ? PPC::FCTIDZ : PPC::FCTIDUZ;
|
||||
|
||||
@ -2002,7 +2000,7 @@ unsigned PPCFastISel::PPCMaterialize64BitInt(int64_t Imm,
|
||||
unsigned PPCFastISel::PPCMaterializeInt(const Constant *C, MVT VT) {
|
||||
// If we're using CR bit registers for i1 values, handle that as a special
|
||||
// case first.
|
||||
if (VT == MVT::i1 && PPCSubTarget.useCRBits()) {
|
||||
if (VT == MVT::i1 && PPCSubTarget->useCRBits()) {
|
||||
const ConstantInt *CI = cast<ConstantInt>(C);
|
||||
unsigned ImmReg = createResultReg(&PPC::CRBITRCRegClass);
|
||||
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
|
||||
@ -2176,7 +2174,7 @@ unsigned PPCFastISel::FastEmit_i(MVT Ty, MVT VT, unsigned Opc, uint64_t Imm) {
|
||||
|
||||
// If we're using CR bit registers for i1 values, handle that as a special
|
||||
// case first.
|
||||
if (VT == MVT::i1 && PPCSubTarget.useCRBits()) {
|
||||
if (VT == MVT::i1 && PPCSubTarget->useCRBits()) {
|
||||
unsigned ImmReg = createResultReg(&PPC::CRBITRCRegClass);
|
||||
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
|
||||
TII.get(Imm == 0 ? PPC::CRUNSET : PPC::CRSET), ImmReg);
|
||||
|
@ -51,23 +51,25 @@ namespace {
|
||||
///
|
||||
class PPCDAGToDAGISel : public SelectionDAGISel {
|
||||
const PPCTargetMachine &TM;
|
||||
const PPCTargetLowering &PPCLowering;
|
||||
const PPCSubtarget &PPCSubTarget;
|
||||
const PPCTargetLowering *PPCLowering;
|
||||
const PPCSubtarget *PPCSubTarget;
|
||||
unsigned GlobalBaseReg;
|
||||
public:
|
||||
explicit PPCDAGToDAGISel(PPCTargetMachine &tm)
|
||||
: SelectionDAGISel(tm), TM(tm),
|
||||
PPCLowering(*TM.getTargetLowering()),
|
||||
PPCSubTarget(*TM.getSubtargetImpl()) {
|
||||
PPCLowering(TM.getTargetLowering()),
|
||||
PPCSubTarget(TM.getSubtargetImpl()) {
|
||||
initializePPCDAGToDAGISelPass(*PassRegistry::getPassRegistry());
|
||||
}
|
||||
|
||||
bool runOnMachineFunction(MachineFunction &MF) override {
|
||||
// Make sure we re-emit a set of the global base reg if necessary
|
||||
GlobalBaseReg = 0;
|
||||
PPCLowering = TM.getTargetLowering();
|
||||
PPCSubTarget = TM.getSubtargetImpl();
|
||||
SelectionDAGISel::runOnMachineFunction(MF);
|
||||
|
||||
if (!PPCSubTarget.isSVR4ABI())
|
||||
if (!PPCSubTarget->isSVR4ABI())
|
||||
InsertVRSaveCode(MF);
|
||||
|
||||
return true;
|
||||
@ -89,7 +91,7 @@ namespace {
|
||||
|
||||
/// getSmallIPtrImm - Return a target constant of pointer type.
|
||||
inline SDValue getSmallIPtrImm(unsigned Imm) {
|
||||
return CurDAG->getTargetConstant(Imm, PPCLowering.getPointerTy());
|
||||
return CurDAG->getTargetConstant(Imm, PPCLowering->getPointerTy());
|
||||
}
|
||||
|
||||
/// isRunOfOnes - Returns true iff Val consists of one contiguous run of 1s
|
||||
@ -122,7 +124,7 @@ namespace {
|
||||
/// a base register plus a signed 16-bit displacement [r+imm].
|
||||
bool SelectAddrImm(SDValue N, SDValue &Disp,
|
||||
SDValue &Base) {
|
||||
return PPCLowering.SelectAddressRegImm(N, Disp, Base, *CurDAG, false);
|
||||
return PPCLowering->SelectAddressRegImm(N, Disp, Base, *CurDAG, false);
|
||||
}
|
||||
|
||||
/// SelectAddrImmOffs - Return true if the operand is valid for a preinc
|
||||
@ -142,20 +144,20 @@ namespace {
|
||||
/// represented as an indexed [r+r] operation. Returns false if it can
|
||||
/// be represented by [r+imm], which are preferred.
|
||||
bool SelectAddrIdx(SDValue N, SDValue &Base, SDValue &Index) {
|
||||
return PPCLowering.SelectAddressRegReg(N, Base, Index, *CurDAG);
|
||||
return PPCLowering->SelectAddressRegReg(N, Base, Index, *CurDAG);
|
||||
}
|
||||
|
||||
/// SelectAddrIdxOnly - Given the specified addressed, force it to be
|
||||
/// represented as an indexed [r+r] operation.
|
||||
bool SelectAddrIdxOnly(SDValue N, SDValue &Base, SDValue &Index) {
|
||||
return PPCLowering.SelectAddressRegRegOnly(N, Base, Index, *CurDAG);
|
||||
return PPCLowering->SelectAddressRegRegOnly(N, Base, Index, *CurDAG);
|
||||
}
|
||||
|
||||
/// SelectAddrImmX4 - Returns true if the address N can be represented by
|
||||
/// a base register plus a signed 16-bit displacement that is a multiple of 4.
|
||||
/// Suitable for use by STD and friends.
|
||||
bool SelectAddrImmX4(SDValue N, SDValue &Disp, SDValue &Base) {
|
||||
return PPCLowering.SelectAddressRegImm(N, Disp, Base, *CurDAG, true);
|
||||
return PPCLowering->SelectAddressRegImm(N, Disp, Base, *CurDAG, true);
|
||||
}
|
||||
|
||||
// Select an address into a single register.
|
||||
@ -272,7 +274,7 @@ SDNode *PPCDAGToDAGISel::getGlobalBaseReg() {
|
||||
MachineBasicBlock::iterator MBBI = FirstMBB.begin();
|
||||
DebugLoc dl;
|
||||
|
||||
if (PPCLowering.getPointerTy() == MVT::i32) {
|
||||
if (PPCLowering->getPointerTy() == MVT::i32) {
|
||||
GlobalBaseReg = RegInfo->createVirtualRegister(&PPC::GPRC_NOR0RegClass);
|
||||
BuildMI(FirstMBB, MBBI, dl, TII.get(PPC::MovePCtoLR));
|
||||
BuildMI(FirstMBB, MBBI, dl, TII.get(PPC::MFLR), GlobalBaseReg);
|
||||
@ -283,7 +285,7 @@ SDNode *PPCDAGToDAGISel::getGlobalBaseReg() {
|
||||
}
|
||||
}
|
||||
return CurDAG->getRegister(GlobalBaseReg,
|
||||
PPCLowering.getPointerTy()).getNode();
|
||||
PPCLowering->getPointerTy()).getNode();
|
||||
}
|
||||
|
||||
/// isIntS16Immediate - This method tests to see if the node is either a 32-bit
|
||||
@ -580,7 +582,7 @@ SDValue PPCDAGToDAGISel::SelectCC(SDValue LHS, SDValue RHS,
|
||||
Opc = PPC::FCMPUS;
|
||||
} else {
|
||||
assert(LHS.getValueType() == MVT::f64 && "Unknown vt!");
|
||||
Opc = PPCSubTarget.hasVSX() ? PPC::XSCMPUDP : PPC::FCMPUD;
|
||||
Opc = PPCSubTarget->hasVSX() ? PPC::XSCMPUDP : PPC::FCMPUD;
|
||||
}
|
||||
return SDValue(CurDAG->getMachineNode(Opc, dl, MVT::i32, LHS, RHS), 0);
|
||||
}
|
||||
@ -746,7 +748,7 @@ SDNode *PPCDAGToDAGISel::SelectSETCC(SDNode *N) {
|
||||
EVT PtrVT = CurDAG->getTargetLoweringInfo().getPointerTy();
|
||||
bool isPPC64 = (PtrVT == MVT::i64);
|
||||
|
||||
if (!PPCSubTarget.useCRBits() &&
|
||||
if (!PPCSubTarget->useCRBits() &&
|
||||
isInt32Immediate(N->getOperand(1), Imm)) {
|
||||
// We can codegen setcc op, imm very efficiently compared to a brcond.
|
||||
// Check for those cases here.
|
||||
@ -828,7 +830,7 @@ SDNode *PPCDAGToDAGISel::SelectSETCC(SDNode *N) {
|
||||
if (LHS.getValueType().isVector()) {
|
||||
EVT VecVT = LHS.getValueType();
|
||||
MVT::SimpleValueType VT = VecVT.getSimpleVT().SimpleTy;
|
||||
unsigned int VCmpInst = getVCmpInst(VT, CC, PPCSubTarget.hasVSX());
|
||||
unsigned int VCmpInst = getVCmpInst(VT, CC, PPCSubTarget->hasVSX());
|
||||
|
||||
switch (CC) {
|
||||
case ISD::SETEQ:
|
||||
@ -839,7 +841,7 @@ SDNode *PPCDAGToDAGISel::SelectSETCC(SDNode *N) {
|
||||
case ISD::SETONE:
|
||||
case ISD::SETUNE: {
|
||||
SDValue VCmp(CurDAG->getMachineNode(VCmpInst, dl, VecVT, LHS, RHS), 0);
|
||||
return CurDAG->SelectNodeTo(N, PPCSubTarget.hasVSX() ? PPC::XXLNOR :
|
||||
return CurDAG->SelectNodeTo(N, PPCSubTarget->hasVSX() ? PPC::XXLNOR :
|
||||
PPC::VNOR,
|
||||
VecVT, VCmp, VCmp);
|
||||
}
|
||||
@ -861,9 +863,9 @@ SDNode *PPCDAGToDAGISel::SelectSETCC(SDNode *N) {
|
||||
return CurDAG->SelectNodeTo(N, VCmpInst, VecVT, LHS, RHS);
|
||||
} else {
|
||||
SDValue VCmpGT(CurDAG->getMachineNode(VCmpInst, dl, VecVT, LHS, RHS), 0);
|
||||
unsigned int VCmpEQInst = getVCmpEQInst(VT, PPCSubTarget.hasVSX());
|
||||
unsigned int VCmpEQInst = getVCmpEQInst(VT, PPCSubTarget->hasVSX());
|
||||
SDValue VCmpEQ(CurDAG->getMachineNode(VCmpEQInst, dl, VecVT, LHS, RHS), 0);
|
||||
return CurDAG->SelectNodeTo(N, PPCSubTarget.hasVSX() ? PPC::XXLOR :
|
||||
return CurDAG->SelectNodeTo(N, PPCSubTarget->hasVSX() ? PPC::XXLOR :
|
||||
PPC::VOR,
|
||||
VecVT, VCmpGT, VCmpEQ);
|
||||
}
|
||||
@ -872,9 +874,9 @@ SDNode *PPCDAGToDAGISel::SelectSETCC(SDNode *N) {
|
||||
case ISD::SETOLE:
|
||||
case ISD::SETULE: {
|
||||
SDValue VCmpLE(CurDAG->getMachineNode(VCmpInst, dl, VecVT, RHS, LHS), 0);
|
||||
unsigned int VCmpEQInst = getVCmpEQInst(VT, PPCSubTarget.hasVSX());
|
||||
unsigned int VCmpEQInst = getVCmpEQInst(VT, PPCSubTarget->hasVSX());
|
||||
SDValue VCmpEQ(CurDAG->getMachineNode(VCmpEQInst, dl, VecVT, LHS, RHS), 0);
|
||||
return CurDAG->SelectNodeTo(N, PPCSubTarget.hasVSX() ? PPC::XXLOR :
|
||||
return CurDAG->SelectNodeTo(N, PPCSubTarget->hasVSX() ? PPC::XXLOR :
|
||||
PPC::VOR,
|
||||
VecVT, VCmpLE, VCmpEQ);
|
||||
}
|
||||
@ -883,7 +885,7 @@ SDNode *PPCDAGToDAGISel::SelectSETCC(SDNode *N) {
|
||||
}
|
||||
}
|
||||
|
||||
if (PPCSubTarget.useCRBits())
|
||||
if (PPCSubTarget->useCRBits())
|
||||
return nullptr;
|
||||
|
||||
bool Inv;
|
||||
@ -1101,7 +1103,7 @@ SDNode *PPCDAGToDAGISel::Select(SDNode *N) {
|
||||
SDValue Base = LD->getBasePtr();
|
||||
SDValue Ops[] = { Offset, Base, Chain };
|
||||
return CurDAG->getMachineNode(Opcode, dl, LD->getValueType(0),
|
||||
PPCLowering.getPointerTy(),
|
||||
PPCLowering->getPointerTy(),
|
||||
MVT::Other, Ops);
|
||||
} else {
|
||||
unsigned Opcode;
|
||||
@ -1136,7 +1138,7 @@ SDNode *PPCDAGToDAGISel::Select(SDNode *N) {
|
||||
SDValue Base = LD->getBasePtr();
|
||||
SDValue Ops[] = { Base, Offset, Chain };
|
||||
return CurDAG->getMachineNode(Opcode, dl, LD->getValueType(0),
|
||||
PPCLowering.getPointerTy(),
|
||||
PPCLowering->getPointerTy(),
|
||||
MVT::Other, Ops);
|
||||
}
|
||||
}
|
||||
@ -1267,7 +1269,7 @@ SDNode *PPCDAGToDAGISel::Select(SDNode *N) {
|
||||
bool isPPC64 = (PtrVT == MVT::i64);
|
||||
|
||||
// If this is a select of i1 operands, we'll pattern match it.
|
||||
if (PPCSubTarget.useCRBits() &&
|
||||
if (PPCSubTarget->useCRBits() &&
|
||||
N->getOperand(0).getValueType() == MVT::i1)
|
||||
break;
|
||||
|
||||
@ -1338,14 +1340,14 @@ SDNode *PPCDAGToDAGISel::Select(SDNode *N) {
|
||||
return CurDAG->SelectNodeTo(N, SelectCCOp, N->getValueType(0), Ops);
|
||||
}
|
||||
case ISD::VSELECT:
|
||||
if (PPCSubTarget.hasVSX()) {
|
||||
if (PPCSubTarget->hasVSX()) {
|
||||
SDValue Ops[] = { N->getOperand(2), N->getOperand(1), N->getOperand(0) };
|
||||
return CurDAG->SelectNodeTo(N, PPC::XXSEL, N->getValueType(0), Ops);
|
||||
}
|
||||
|
||||
break;
|
||||
case ISD::VECTOR_SHUFFLE:
|
||||
if (PPCSubTarget.hasVSX() && (N->getValueType(0) == MVT::v2f64 ||
|
||||
if (PPCSubTarget->hasVSX() && (N->getValueType(0) == MVT::v2f64 ||
|
||||
N->getValueType(0) == MVT::v2i64)) {
|
||||
ShuffleVectorSDNode *SVN = cast<ShuffleVectorSDNode>(N);
|
||||
|
||||
@ -1383,7 +1385,7 @@ SDNode *PPCDAGToDAGISel::Select(SDNode *N) {
|
||||
break;
|
||||
case PPCISD::BDNZ:
|
||||
case PPCISD::BDZ: {
|
||||
bool IsPPC64 = PPCSubTarget.isPPC64();
|
||||
bool IsPPC64 = PPCSubTarget->isPPC64();
|
||||
SDValue Ops[] = { N->getOperand(1), N->getOperand(0) };
|
||||
return CurDAG->SelectNodeTo(N, N->getOpcode() == PPCISD::BDNZ ?
|
||||
(IsPPC64 ? PPC::BDNZ8 : PPC::BDNZ) :
|
||||
@ -1443,7 +1445,7 @@ SDNode *PPCDAGToDAGISel::Select(SDNode *N) {
|
||||
return CurDAG->SelectNodeTo(N, Reg, MVT::Other, Chain);
|
||||
}
|
||||
case PPCISD::TOC_ENTRY: {
|
||||
assert (PPCSubTarget.isPPC64() && "Only supported for 64-bit ABI");
|
||||
assert (PPCSubTarget->isPPC64() && "Only supported for 64-bit ABI");
|
||||
|
||||
// For medium and large code model, we generate two instructions as
|
||||
// described below. Otherwise we allow SelectCodeCommon to handle this,
|
||||
@ -1583,7 +1585,7 @@ void PPCDAGToDAGISel::PostprocessISelDAG() {
|
||||
// containing zero.
|
||||
bool PPCDAGToDAGISel::AllUsersSelectZero(SDNode *N) {
|
||||
// If we're not using isel, then this does not matter.
|
||||
if (!PPCSubTarget.hasISEL())
|
||||
if (!PPCSubTarget->hasISEL())
|
||||
return false;
|
||||
|
||||
for (SDNode::use_iterator UI = N->use_begin(), UE = N->use_end();
|
||||
@ -2045,7 +2047,7 @@ void PPCDAGToDAGISel::PeepholeCROps() {
|
||||
|
||||
void PPCDAGToDAGISel::PeepholePPC64() {
|
||||
// These optimizations are currently supported only for 64-bit SVR4.
|
||||
if (PPCSubTarget.isDarwin() || !PPCSubTarget.isPPC64())
|
||||
if (PPCSubTarget->isDarwin() || !PPCSubTarget->isPPC64())
|
||||
return;
|
||||
|
||||
SelectionDAG::allnodes_iterator Position(CurDAG->getRoot().getNode());
|
||||
|
@ -223,7 +223,7 @@ class VX2_Int_Ty2<bits<11> xo, string opc, Intrinsic IntID, ValueType OutTy,
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Instruction Definitions.
|
||||
|
||||
def HasAltivec : Predicate<"PPCSubTarget.hasAltivec()">;
|
||||
def HasAltivec : Predicate<"PPCSubTarget->hasAltivec()">;
|
||||
let Predicates = [HasAltivec] in {
|
||||
|
||||
let isCodeGenOnly = 1 in {
|
||||
|
@ -610,10 +610,10 @@ def iaddroff : ComplexPattern<iPTR, 1, "SelectAddrImmOffs", [], []>;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// PowerPC Instruction Predicate Definitions.
|
||||
def In32BitMode : Predicate<"!PPCSubTarget.isPPC64()">;
|
||||
def In64BitMode : Predicate<"PPCSubTarget.isPPC64()">;
|
||||
def IsBookE : Predicate<"PPCSubTarget.isBookE()">;
|
||||
def IsNotBookE : Predicate<"!PPCSubTarget.isBookE()">;
|
||||
def In32BitMode : Predicate<"!PPCSubTarget->isPPC64()">;
|
||||
def In64BitMode : Predicate<"PPCSubTarget->isPPC64()">;
|
||||
def IsBookE : Predicate<"PPCSubTarget->isBookE()">;
|
||||
def IsNotBookE : Predicate<"!PPCSubTarget->isBookE()">;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// PowerPC Multiclass Definitions.
|
||||
|
@ -39,7 +39,7 @@ multiclass XX3Form_Rcr<bits<6> opcode, bits<7> xo, dag OOL, dag IOL,
|
||||
}
|
||||
}
|
||||
|
||||
def HasVSX : Predicate<"PPCSubTarget.hasVSX()">;
|
||||
def HasVSX : Predicate<"PPCSubTarget->hasVSX()">;
|
||||
let Predicates = [HasVSX] in {
|
||||
let AddedComplexity = 400 in { // Prefer VSX patterns over non-VSX patterns.
|
||||
let neverHasSideEffects = 1 in { // VSX instructions don't have side effects.
|
||||
|
Loading…
Reference in New Issue
Block a user