Make HexagonISelLowering not dependent upon a HexagonTargetMachine,

but a normal TargetMachine and remove a few cached uses.

llvm-svn: 211821
This commit is contained in:
Eric Christopher 2014-06-27 00:13:52 +00:00
parent 6e9bcd1528
commit dbe1cb0d59
2 changed files with 25 additions and 21 deletions

View File

@ -463,9 +463,10 @@ HexagonTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
SmallVector<std::pair<unsigned, SDValue>, 16> RegsToPass; SmallVector<std::pair<unsigned, SDValue>, 16> RegsToPass;
SmallVector<SDValue, 8> MemOpChains; SmallVector<SDValue, 8> MemOpChains;
const HexagonRegisterInfo *QRI = static_cast<const HexagonRegisterInfo *>(
DAG.getTarget().getRegisterInfo());
SDValue StackPtr = SDValue StackPtr =
DAG.getCopyFromReg(Chain, dl, TM.getRegisterInfo()->getStackRegister(), DAG.getCopyFromReg(Chain, dl, QRI->getStackRegister(), getPointerTy());
getPointerTy());
// Walk the register/memloc assignments, inserting copies/loads. // Walk the register/memloc assignments, inserting copies/loads.
for (unsigned i = 0, e = ArgLocs.size(); i != e; ++i) { for (unsigned i = 0, e = ArgLocs.size(); i != e; ++i) {
@ -720,7 +721,10 @@ SDValue HexagonTargetLowering::LowerINLINEASM(SDValue Op,
cast<RegisterSDNode>(Node->getOperand(i))->getReg(); cast<RegisterSDNode>(Node->getOperand(i))->getReg();
// Check it to be lr // Check it to be lr
if (Reg == TM.getRegisterInfo()->getRARegister()) { const HexagonRegisterInfo *QRI =
static_cast<const HexagonRegisterInfo *>(
DAG.getTarget().getRegisterInfo());
if (Reg == QRI->getRARegister()) {
FuncInfo->setHasClobberLR(true); FuncInfo->setHasClobberLR(true);
break; break;
} }
@ -812,9 +816,9 @@ HexagonTargetLowering::LowerDYNAMIC_STACKALLOC(SDValue Op,
// The Sub result contains the new stack start address, so it // The Sub result contains the new stack start address, so it
// must be placed in the stack pointer register. // must be placed in the stack pointer register.
SDValue CopyChain = DAG.getCopyToReg(Chain, dl, const HexagonRegisterInfo *QRI = static_cast<const HexagonRegisterInfo *>(
TM.getRegisterInfo()->getStackRegister(), DAG.getTarget().getRegisterInfo());
Sub); SDValue CopyChain = DAG.getCopyToReg(Chain, dl, QRI->getStackRegister(), Sub);
SDValue Ops[2] = { ArgAdjust, CopyChain }; SDValue Ops[2] = { ArgAdjust, CopyChain };
return DAG.getMergeValues(Ops, dl); return DAG.getMergeValues(Ops, dl);
@ -960,7 +964,7 @@ HexagonTargetLowering::LowerConstantPool(SDValue Op, SelectionDAG &DAG) const {
SDValue SDValue
HexagonTargetLowering::LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const { HexagonTargetLowering::LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const {
const TargetRegisterInfo *TRI = TM.getRegisterInfo(); const TargetRegisterInfo *TRI = DAG.getTarget().getRegisterInfo();
MachineFunction &MF = DAG.getMachineFunction(); MachineFunction &MF = DAG.getMachineFunction();
MachineFrameInfo *MFI = MF.getFrameInfo(); MachineFrameInfo *MFI = MF.getFrameInfo();
MFI->setReturnAddressIsTaken(true); MFI->setReturnAddressIsTaken(true);
@ -986,7 +990,8 @@ HexagonTargetLowering::LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const {
SDValue SDValue
HexagonTargetLowering::LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const { HexagonTargetLowering::LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const {
const HexagonRegisterInfo *TRI = TM.getRegisterInfo(); const HexagonRegisterInfo *TRI =
static_cast<const HexagonRegisterInfo *>(DAG.getTarget().getRegisterInfo());
MachineFrameInfo *MFI = DAG.getMachineFunction().getFrameInfo(); MachineFrameInfo *MFI = DAG.getMachineFunction().getFrameInfo();
MFI->setFrameAddressIsTaken(true); MFI->setFrameAddressIsTaken(true);
@ -1038,18 +1043,17 @@ HexagonTargetLowering::LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const {
// TargetLowering Implementation // TargetLowering Implementation
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
HexagonTargetLowering::HexagonTargetLowering( HexagonTargetLowering::HexagonTargetLowering(const TargetMachine &targetmachine)
HexagonTargetMachine &targetmachine)
: TargetLowering(targetmachine, new HexagonTargetObjectFile()), : TargetLowering(targetmachine, new HexagonTargetObjectFile()),
TM(targetmachine) { TM(targetmachine) {
const HexagonRegisterInfo *QRI = TM.getRegisterInfo(); const HexagonSubtarget &Subtarget = TM.getSubtarget<HexagonSubtarget>();
// Set up the register classes. // Set up the register classes.
addRegisterClass(MVT::i32, &Hexagon::IntRegsRegClass); addRegisterClass(MVT::i32, &Hexagon::IntRegsRegClass);
addRegisterClass(MVT::i64, &Hexagon::DoubleRegsRegClass); addRegisterClass(MVT::i64, &Hexagon::DoubleRegsRegClass);
if (QRI->Subtarget.hasV5TOps()) { if (Subtarget.hasV5TOps()) {
addRegisterClass(MVT::f32, &Hexagon::IntRegsRegClass); addRegisterClass(MVT::f32, &Hexagon::IntRegsRegClass);
addRegisterClass(MVT::f64, &Hexagon::DoubleRegsRegClass); addRegisterClass(MVT::f64, &Hexagon::DoubleRegsRegClass);
} }
@ -1111,7 +1115,7 @@ HexagonTargetLowering::HexagonTargetLowering(
setOperationAction(ISD::FSIN, MVT::f32, Expand); setOperationAction(ISD::FSIN, MVT::f32, Expand);
setOperationAction(ISD::FSIN, MVT::f64, Expand); setOperationAction(ISD::FSIN, MVT::f64, Expand);
if (QRI->Subtarget.hasV5TOps()) { if (Subtarget.hasV5TOps()) {
// Hexagon V5 Support. // Hexagon V5 Support.
setOperationAction(ISD::FADD, MVT::f32, Legal); setOperationAction(ISD::FADD, MVT::f32, Legal);
setOperationAction(ISD::FADD, MVT::f64, Legal); setOperationAction(ISD::FADD, MVT::f64, Legal);
@ -1330,7 +1334,7 @@ HexagonTargetLowering::HexagonTargetLowering(
setOperationAction(ISD::SELECT_CC, MVT::i32, Expand); setOperationAction(ISD::SELECT_CC, MVT::i32, Expand);
setOperationAction(ISD::SELECT_CC, MVT::i64, Expand); setOperationAction(ISD::SELECT_CC, MVT::i64, Expand);
if (QRI->Subtarget.hasV5TOps()) { if (Subtarget.hasV5TOps()) {
// We need to make the operation type of SELECT node to be Custom, // We need to make the operation type of SELECT node to be Custom,
// such that we don't go into the infinite loop of // such that we don't go into the infinite loop of
@ -1425,7 +1429,7 @@ HexagonTargetLowering::HexagonTargetLowering(
setOperationAction(ISD::EH_RETURN, MVT::Other, Custom); setOperationAction(ISD::EH_RETURN, MVT::Other, Custom);
if (TM.getSubtargetImpl()->isSubtargetV2()) { if (Subtarget.isSubtargetV2()) {
setExceptionPointerRegister(Hexagon::R20); setExceptionPointerRegister(Hexagon::R20);
setExceptionSelectorRegister(Hexagon::R21); setExceptionSelectorRegister(Hexagon::R21);
} else { } else {
@ -1449,8 +1453,9 @@ HexagonTargetLowering::HexagonTargetLowering(
setMinFunctionAlignment(2); setMinFunctionAlignment(2);
// Needed for DYNAMIC_STACKALLOC expansion. // Needed for DYNAMIC_STACKALLOC expansion.
unsigned StackRegister = TM.getRegisterInfo()->getStackRegister(); const HexagonRegisterInfo *QRI =
setStackPointerRegisterToSaveRestore(StackRegister); static_cast<const HexagonRegisterInfo *>(TM.getRegisterInfo());
setStackPointerRegisterToSaveRestore(QRI->getStackRegister());
setSchedulingPreference(Sched::VLIW); setSchedulingPreference(Sched::VLIW);
} }
@ -1618,8 +1623,7 @@ HexagonTargetLowering::getRegForInlineAsmConstraint(const
/// specified FP immediate natively. If false, the legalizer will /// specified FP immediate natively. If false, the legalizer will
/// materialize the FP immediate as a load from a constant pool. /// materialize the FP immediate as a load from a constant pool.
bool HexagonTargetLowering::isFPImmLegal(const APFloat &Imm, EVT VT) const { bool HexagonTargetLowering::isFPImmLegal(const APFloat &Imm, EVT VT) const {
const HexagonRegisterInfo* QRI = TM.getRegisterInfo(); return TM.getSubtarget<HexagonSubtarget>().hasV5TOps();
return QRI->Subtarget.hasV5TOps();
} }
/// isLegalAddressingMode - Return true if the addressing mode represented by /// isLegalAddressingMode - Return true if the addressing mode represented by

View File

@ -74,8 +74,8 @@ namespace llvm {
unsigned& RetSize) const; unsigned& RetSize) const;
public: public:
HexagonTargetMachine &TM; const TargetMachine &TM;
explicit HexagonTargetLowering(HexagonTargetMachine &targetmachine); explicit HexagonTargetLowering(const TargetMachine &targetmachine);
/// IsEligibleForTailCallOptimization - Check whether the call is eligible /// IsEligibleForTailCallOptimization - Check whether the call is eligible
/// for tail call optimization. Targets which want to do tail call /// for tail call optimization. Targets which want to do tail call