forked from OSchip/llvm-project
Reduce the amount of state in the lowering code and drop old pattern ISel functions
llvm-svn: 30881
This commit is contained in:
parent
08edf332ed
commit
fa8cbfd8e8
|
@ -193,17 +193,33 @@ private:
|
||||||
/// GOT address into a register.
|
/// GOT address into a register.
|
||||||
///
|
///
|
||||||
SDOperand AlphaDAGToDAGISel::getGlobalBaseReg() {
|
SDOperand AlphaDAGToDAGISel::getGlobalBaseReg() {
|
||||||
|
MachineFunction* MF = BB->getParent();
|
||||||
|
unsigned GP = 0;
|
||||||
|
for(MachineFunction::livein_iterator ii = MF->livein_begin(),
|
||||||
|
ee = MF->livein_end(); ii != ee; ++ii)
|
||||||
|
if (ii->first == Alpha::R29) {
|
||||||
|
GP = ii->second;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
assert(GP && "GOT PTR not in liveins");
|
||||||
return CurDAG->getCopyFromReg(CurDAG->getEntryNode(),
|
return CurDAG->getCopyFromReg(CurDAG->getEntryNode(),
|
||||||
AlphaLowering.getVRegGP(),
|
GP, MVT::i64);
|
||||||
MVT::i64);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getRASaveReg - Grab the return address
|
/// getRASaveReg - Grab the return address
|
||||||
///
|
///
|
||||||
SDOperand AlphaDAGToDAGISel::getGlobalRetAddr() {
|
SDOperand AlphaDAGToDAGISel::getGlobalRetAddr() {
|
||||||
|
MachineFunction* MF = BB->getParent();
|
||||||
|
unsigned RA = 0;
|
||||||
|
for(MachineFunction::livein_iterator ii = MF->livein_begin(),
|
||||||
|
ee = MF->livein_end(); ii != ee; ++ii)
|
||||||
|
if (ii->first == Alpha::R26) {
|
||||||
|
RA = ii->second;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
assert(RA && "RA PTR not in liveins");
|
||||||
return CurDAG->getCopyFromReg(CurDAG->getEntryNode(),
|
return CurDAG->getCopyFromReg(CurDAG->getEntryNode(),
|
||||||
AlphaLowering.getVRegRA(),
|
RA, MVT::i64);
|
||||||
MVT::i64);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// InstructionSelectBasicBlock - This callback is invoked by
|
/// InstructionSelectBasicBlock - This callback is invoked by
|
||||||
|
|
|
@ -201,17 +201,15 @@ static SDOperand LowerJumpTable(SDOperand Op, SelectionDAG &DAG) {
|
||||||
|
|
||||||
static SDOperand LowerFORMAL_ARGUMENTS(SDOperand Op, SelectionDAG &DAG,
|
static SDOperand LowerFORMAL_ARGUMENTS(SDOperand Op, SelectionDAG &DAG,
|
||||||
int &VarArgsBase,
|
int &VarArgsBase,
|
||||||
int &VarArgsOffset,
|
int &VarArgsOffset) {
|
||||||
unsigned int &GP,
|
|
||||||
unsigned int &RA) {
|
|
||||||
MachineFunction &MF = DAG.getMachineFunction();
|
MachineFunction &MF = DAG.getMachineFunction();
|
||||||
MachineFrameInfo *MFI = MF.getFrameInfo();
|
MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||||
SSARegMap *RegMap = MF.getSSARegMap();
|
SSARegMap *RegMap = MF.getSSARegMap();
|
||||||
std::vector<SDOperand> ArgValues;
|
std::vector<SDOperand> ArgValues;
|
||||||
SDOperand Root = Op.getOperand(0);
|
SDOperand Root = Op.getOperand(0);
|
||||||
|
|
||||||
GP = AddLiveIn(MF, Alpha::R29, &Alpha::GPRCRegClass);
|
AddLiveIn(MF, Alpha::R29, &Alpha::GPRCRegClass); //GP
|
||||||
RA = AddLiveIn(MF, Alpha::R26, &Alpha::GPRCRegClass);
|
AddLiveIn(MF, Alpha::R26, &Alpha::GPRCRegClass); //RA
|
||||||
|
|
||||||
unsigned args_int[] = {
|
unsigned args_int[] = {
|
||||||
Alpha::R16, Alpha::R17, Alpha::R18, Alpha::R19, Alpha::R20, Alpha::R21};
|
Alpha::R16, Alpha::R17, Alpha::R18, Alpha::R19, Alpha::R20, Alpha::R21};
|
||||||
|
@ -291,7 +289,7 @@ static SDOperand LowerFORMAL_ARGUMENTS(SDOperand Op, SelectionDAG &DAG,
|
||||||
return DAG.getNode(ISD::MERGE_VALUES, RetVT, &ArgValues[0], ArgValues.size());
|
return DAG.getNode(ISD::MERGE_VALUES, RetVT, &ArgValues[0], ArgValues.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDOperand LowerRET(SDOperand Op, SelectionDAG &DAG, unsigned int RA) {
|
static SDOperand LowerRET(SDOperand Op, SelectionDAG &DAG) {
|
||||||
SDOperand Copy = DAG.getCopyToReg(Op.getOperand(0), Alpha::R26,
|
SDOperand Copy = DAG.getCopyToReg(Op.getOperand(0), Alpha::R26,
|
||||||
DAG.getNode(AlphaISD::GlobalRetAddr,
|
DAG.getNode(AlphaISD::GlobalRetAddr,
|
||||||
MVT::i64),
|
MVT::i64),
|
||||||
|
@ -386,15 +384,6 @@ AlphaTargetLowering::LowerCallTo(SDOperand Chain,
|
||||||
return std::make_pair(RetVal, Chain);
|
return std::make_pair(RetVal, Chain);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlphaTargetLowering::restoreGP(MachineBasicBlock* BB)
|
|
||||||
{
|
|
||||||
BuildMI(BB, Alpha::BIS, 2, Alpha::R29).addReg(GP).addReg(GP);
|
|
||||||
}
|
|
||||||
void AlphaTargetLowering::restoreRA(MachineBasicBlock* BB)
|
|
||||||
{
|
|
||||||
BuildMI(BB, Alpha::BIS, 2, Alpha::R26).addReg(RA).addReg(RA);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int getUID()
|
static int getUID()
|
||||||
{
|
{
|
||||||
static int id = 0;
|
static int id = 0;
|
||||||
|
@ -408,9 +397,9 @@ SDOperand AlphaTargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) {
|
||||||
default: assert(0 && "Wasn't expecting to be able to lower this!");
|
default: assert(0 && "Wasn't expecting to be able to lower this!");
|
||||||
case ISD::FORMAL_ARGUMENTS: return LowerFORMAL_ARGUMENTS(Op, DAG,
|
case ISD::FORMAL_ARGUMENTS: return LowerFORMAL_ARGUMENTS(Op, DAG,
|
||||||
VarArgsBase,
|
VarArgsBase,
|
||||||
VarArgsOffset,
|
VarArgsOffset);
|
||||||
GP, RA);
|
|
||||||
case ISD::RET: return LowerRET(Op,DAG, getVRegRA());
|
case ISD::RET: return LowerRET(Op,DAG);
|
||||||
case ISD::JumpTable: return LowerJumpTable(Op, DAG);
|
case ISD::JumpTable: return LowerJumpTable(Op, DAG);
|
||||||
|
|
||||||
case ISD::SINT_TO_FP: {
|
case ISD::SINT_TO_FP: {
|
||||||
|
|
|
@ -54,8 +54,6 @@ namespace llvm {
|
||||||
class AlphaTargetLowering : public TargetLowering {
|
class AlphaTargetLowering : public TargetLowering {
|
||||||
int VarArgsOffset; // What is the offset to the first vaarg
|
int VarArgsOffset; // What is the offset to the first vaarg
|
||||||
int VarArgsBase; // What is the base FrameIndex
|
int VarArgsBase; // What is the base FrameIndex
|
||||||
unsigned GP; //GOT vreg
|
|
||||||
unsigned RA; //Return Address
|
|
||||||
bool useITOF;
|
bool useITOF;
|
||||||
public:
|
public:
|
||||||
AlphaTargetLowering(TargetMachine &TM);
|
AlphaTargetLowering(TargetMachine &TM);
|
||||||
|
@ -81,10 +79,6 @@ namespace llvm {
|
||||||
getRegClassForInlineAsmConstraint(const std::string &Constraint,
|
getRegClassForInlineAsmConstraint(const std::string &Constraint,
|
||||||
MVT::ValueType VT) const;
|
MVT::ValueType VT) const;
|
||||||
|
|
||||||
void restoreGP(MachineBasicBlock* BB);
|
|
||||||
void restoreRA(MachineBasicBlock* BB);
|
|
||||||
unsigned getVRegGP() { return GP; }
|
|
||||||
unsigned getVRegRA() { return RA; }
|
|
||||||
bool hasITOF() { return useITOF; }
|
bool hasITOF() { return useITOF; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue