mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-24 22:24:54 +00:00
Change SPU register re-interpretations from OR to COPY_TO_REGCLASS instruction.
This cleans up after the mess r108567 left in the CellSPU backend. ORCvt-instruction were used to reinterpret registers, and the ORs were then removed by isMoveInstr(). This patch now removes 350 instrucions of format: or $3, $3, $3 (from the 52 testcases in CodeGen/CellSPU). One case of a nonexistant or is checked for. Some moves of the form 'ori $., $., 0' and 'ai $., $., 0' still remain. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114074 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -357,6 +357,9 @@ namespace {
|
||||
assert(II && "No InstrInfo?");
|
||||
return new SPUHazardRecognizer(*II);
|
||||
}
|
||||
|
||||
private:
|
||||
SDValue getRC( MVT );
|
||||
|
||||
// Include the pieces autogenerated from the target description.
|
||||
#include "SPUGenDAGISel.inc"
|
||||
@@ -619,6 +622,29 @@ SPUDAGToDAGISel::SelectXFormAddr(SDNode *Op, SDValue N, SDValue &Base,
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
Utility function to use with COPY_TO_REGCLASS instructions. Returns a SDValue
|
||||
to be used as the last parameter of a
|
||||
CurDAG->getMachineNode(COPY_TO_REGCLASS,..., ) function call
|
||||
\arg VT the value type for which we want a register class
|
||||
*/
|
||||
SDValue SPUDAGToDAGISel::getRC( MVT VT ) {
|
||||
switch( VT.SimpleTy ) {
|
||||
case MVT::i32:
|
||||
return CurDAG->getTargetConstant(SPU::R32CRegClass.getID(), MVT::i32);
|
||||
break;
|
||||
case MVT::i64:
|
||||
return CurDAG->getTargetConstant(SPU::R64CRegClass.getID(), MVT::i32);
|
||||
break;
|
||||
case MVT::v2i64:
|
||||
return CurDAG->getTargetConstant(SPU::VECREGRegClass.getID(), MVT::i32);
|
||||
break;
|
||||
default:
|
||||
assert( false && "add a new case here" );
|
||||
}
|
||||
return SDValue();
|
||||
}
|
||||
|
||||
//! Convert the operand from a target-independent to a target-specific node
|
||||
/*!
|
||||
*/
|
||||
@@ -773,8 +799,8 @@ SPUDAGToDAGISel::Select(SDNode *N) {
|
||||
|
||||
if (shift_amt >= 32) {
|
||||
SDNode *hi32 =
|
||||
CurDAG->getMachineNode(SPU::ORr32_r64, dl, OpVT,
|
||||
Op0.getOperand(0));
|
||||
CurDAG->getMachineNode(TargetOpcode::COPY_TO_REGCLASS, dl, OpVT,
|
||||
Op0.getOperand(0), getRC(MVT::i32));
|
||||
|
||||
shift_amt -= 32;
|
||||
if (shift_amt > 0) {
|
||||
@@ -941,7 +967,8 @@ SPUDAGToDAGISel::SelectSHLi64(SDNode *N, EVT OpVT) {
|
||||
SDValue SelMaskVal;
|
||||
DebugLoc dl = N->getDebugLoc();
|
||||
|
||||
VecOp0 = CurDAG->getMachineNode(SPU::ORv2i64_i64, dl, VecVT, Op0);
|
||||
VecOp0 = CurDAG->getMachineNode(TargetOpcode::COPY_TO_REGCLASS, dl, VecVT,
|
||||
Op0, getRC(MVT::v2i64) );
|
||||
SelMaskVal = CurDAG->getTargetConstant(0xff00ULL, MVT::i16);
|
||||
SelMask = CurDAG->getMachineNode(SPU::FSMBIv2i64, dl, VecVT, SelMaskVal);
|
||||
ZeroFill = CurDAG->getMachineNode(SPU::ILv2i64, dl, VecVT,
|
||||
@@ -985,7 +1012,8 @@ SPUDAGToDAGISel::SelectSHLi64(SDNode *N, EVT OpVT) {
|
||||
SDValue(Shift, 0), SDValue(Bits, 0));
|
||||
}
|
||||
|
||||
return CurDAG->getMachineNode(SPU::ORi64_v2i64, dl, OpVT, SDValue(Shift, 0));
|
||||
return CurDAG->getMachineNode(TargetOpcode::COPY_TO_REGCLASS, dl,
|
||||
OpVT, SDValue(Shift, 0), getRC(MVT::i64));
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1006,7 +1034,8 @@ SPUDAGToDAGISel::SelectSRLi64(SDNode *N, EVT OpVT) {
|
||||
SDNode *VecOp0, *Shift = 0;
|
||||
DebugLoc dl = N->getDebugLoc();
|
||||
|
||||
VecOp0 = CurDAG->getMachineNode(SPU::ORv2i64_i64, dl, VecVT, Op0);
|
||||
VecOp0 = CurDAG->getMachineNode(TargetOpcode::COPY_TO_REGCLASS, dl, VecVT,
|
||||
Op0, getRC(MVT::v2i64) );
|
||||
|
||||
if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(ShiftAmt)) {
|
||||
unsigned bytes = unsigned(CN->getZExtValue()) >> 3;
|
||||
@@ -1052,7 +1081,8 @@ SPUDAGToDAGISel::SelectSRLi64(SDNode *N, EVT OpVT) {
|
||||
SDValue(Shift, 0), SDValue(Bits, 0));
|
||||
}
|
||||
|
||||
return CurDAG->getMachineNode(SPU::ORi64_v2i64, dl, OpVT, SDValue(Shift, 0));
|
||||
return CurDAG->getMachineNode(TargetOpcode::COPY_TO_REGCLASS, dl,
|
||||
OpVT, SDValue(Shift, 0), getRC(MVT::i64));
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1073,14 +1103,16 @@ SPUDAGToDAGISel::SelectSRAi64(SDNode *N, EVT OpVT) {
|
||||
DebugLoc dl = N->getDebugLoc();
|
||||
|
||||
SDNode *VecOp0 =
|
||||
CurDAG->getMachineNode(SPU::ORv2i64_i64, dl, VecVT, N->getOperand(0));
|
||||
CurDAG->getMachineNode(TargetOpcode::COPY_TO_REGCLASS, dl,
|
||||
VecVT, N->getOperand(0), getRC(MVT::v2i64));
|
||||
|
||||
SDValue SignRotAmt = CurDAG->getTargetConstant(31, ShiftAmtVT);
|
||||
SDNode *SignRot =
|
||||
CurDAG->getMachineNode(SPU::ROTMAIv2i64_i32, dl, MVT::v2i64,
|
||||
SDValue(VecOp0, 0), SignRotAmt);
|
||||
SDNode *UpperHalfSign =
|
||||
CurDAG->getMachineNode(SPU::ORi32_v4i32, dl, MVT::i32, SDValue(SignRot, 0));
|
||||
CurDAG->getMachineNode(TargetOpcode::COPY_TO_REGCLASS, dl,
|
||||
MVT::i32, SDValue(SignRot, 0), getRC(MVT::i32));
|
||||
|
||||
SDNode *UpperHalfSignMask =
|
||||
CurDAG->getMachineNode(SPU::FSM64r32, dl, VecVT, SDValue(UpperHalfSign, 0));
|
||||
@@ -1127,7 +1159,8 @@ SPUDAGToDAGISel::SelectSRAi64(SDNode *N, EVT OpVT) {
|
||||
SDValue(Shift, 0), SDValue(NegShift, 0));
|
||||
}
|
||||
|
||||
return CurDAG->getMachineNode(SPU::ORi64_v2i64, dl, OpVT, SDValue(Shift, 0));
|
||||
return CurDAG->getMachineNode(TargetOpcode::COPY_TO_REGCLASS, dl,
|
||||
OpVT, SDValue(Shift, 0), getRC(MVT::i64));
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1154,8 +1187,9 @@ SDNode *SPUDAGToDAGISel::SelectI64Constant(uint64_t Value64, EVT OpVT,
|
||||
SDValue Op0 = i64vec.getOperand(0);
|
||||
|
||||
ReplaceUses(i64vec, Op0);
|
||||
return CurDAG->getMachineNode(SPU::ORi64_v2i64, dl, OpVT,
|
||||
SDValue(emitBuildVector(Op0.getNode()), 0));
|
||||
return CurDAG->getMachineNode(TargetOpcode::COPY_TO_REGCLASS, dl, OpVT,
|
||||
SDValue(emitBuildVector(Op0.getNode()), 0),
|
||||
getRC(MVT::i64));
|
||||
} else if (i64vec.getOpcode() == SPUISD::SHUFB) {
|
||||
SDValue lhs = i64vec.getOperand(0);
|
||||
SDValue rhs = i64vec.getOperand(1);
|
||||
@@ -1196,10 +1230,12 @@ SDNode *SPUDAGToDAGISel::SelectI64Constant(uint64_t Value64, EVT OpVT,
|
||||
SDNode *SN = SelectCode(Dummy.getValue().getNode());
|
||||
if (SN == 0) SN = Dummy.getValue().getNode();
|
||||
|
||||
return CurDAG->getMachineNode(SPU::ORi64_v2i64, dl, OpVT, SDValue(SN, 0));
|
||||
return CurDAG->getMachineNode(TargetOpcode::COPY_TO_REGCLASS, dl,
|
||||
OpVT, SDValue(SN, 0), getRC(MVT::i64));
|
||||
} else if (i64vec.getOpcode() == ISD::BUILD_VECTOR) {
|
||||
return CurDAG->getMachineNode(SPU::ORi64_v2i64, dl, OpVT,
|
||||
SDValue(emitBuildVector(i64vec.getNode()), 0));
|
||||
return CurDAG->getMachineNode(TargetOpcode::COPY_TO_REGCLASS, dl, OpVT,
|
||||
SDValue(emitBuildVector(i64vec.getNode()), 0),
|
||||
getRC(MVT::i64));
|
||||
} else {
|
||||
report_fatal_error("SPUDAGToDAGISel::SelectI64Constant: Unhandled i64vec"
|
||||
"condition");
|
||||
|
Reference in New Issue
Block a user