mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-05 13:26:55 +00:00
ARM: use litpools for normal i32 imms when compiling minsize.
With constant-sharing, litpool loads consume 4 + N*2 bytes of code, but movw/movt pairs consume 8*N. This means litpools are better than movw/movt even with just one use. Other materialisation strategies can still be better though, so the logic is a little odd. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199891 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -2472,19 +2472,21 @@ SDNode *ARMDAGToDAGISel::Select(SDNode *N) {
|
||||
case ISD::Constant: {
|
||||
unsigned Val = cast<ConstantSDNode>(N)->getZExtValue();
|
||||
bool UseCP = true;
|
||||
if (Subtarget->hasThumb2())
|
||||
if (Subtarget->useMovt())
|
||||
// Thumb2-aware targets have the MOVT instruction, so all immediates can
|
||||
// be done with MOV + MOVT, at worst.
|
||||
UseCP = 0;
|
||||
UseCP = false;
|
||||
else {
|
||||
if (Subtarget->isThumb()) {
|
||||
UseCP = (Val > 255 && // MOV
|
||||
~Val > 255 && // MOV + MVN
|
||||
!ARM_AM::isThumbImmShiftedVal(Val)); // MOV + LSL
|
||||
UseCP = (Val > 255 && // MOV
|
||||
~Val > 255 && // MOV + MVN
|
||||
!ARM_AM::isThumbImmShiftedVal(Val) && // MOV + LSL
|
||||
!(Subtarget->hasV6T2Ops() && Val <= 0xffff)); // MOVW
|
||||
} else
|
||||
UseCP = (ARM_AM::getSOImmVal(Val) == -1 && // MOV
|
||||
ARM_AM::getSOImmVal(~Val) == -1 && // MVN
|
||||
!ARM_AM::isSOImmTwoPartVal(Val)); // two instrs.
|
||||
UseCP = (ARM_AM::getSOImmVal(Val) == -1 && // MOV
|
||||
ARM_AM::getSOImmVal(~Val) == -1 && // MVN
|
||||
!ARM_AM::isSOImmTwoPartVal(Val) && // two instrs.
|
||||
!(Subtarget->hasV6T2Ops() && Val <= 0xffff)); // MOVW
|
||||
}
|
||||
|
||||
if (UseCP) {
|
||||
@@ -2494,7 +2496,7 @@ SDNode *ARMDAGToDAGISel::Select(SDNode *N) {
|
||||
getTargetLowering()->getPointerTy());
|
||||
|
||||
SDNode *ResNode;
|
||||
if (Subtarget->isThumb1Only()) {
|
||||
if (Subtarget->isThumb()) {
|
||||
SDValue Pred = getAL(CurDAG);
|
||||
SDValue PredReg = CurDAG->getRegister(0, MVT::i32);
|
||||
SDValue Ops[] = { CPIdx, Pred, PredReg, CurDAG->getEntryNode() };
|
||||
|
@@ -593,7 +593,7 @@ def so_imm2part : PatLeaf<(imm), [{
|
||||
/// arm_i32imm - True for +V6T2, or true only if so_imm2part is true.
|
||||
///
|
||||
def arm_i32imm : PatLeaf<(imm), [{
|
||||
if (Subtarget->hasV6T2Ops())
|
||||
if (Subtarget->useMovt())
|
||||
return true;
|
||||
return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
|
||||
}]>;
|
||||
|
@@ -3781,7 +3781,7 @@ def t2SUBS_PC_LR : T2I <(outs), (ins imm0_255:$imm), NoItinerary,
|
||||
let isReMaterializable = 1, isMoveImm = 1 in
|
||||
def t2MOVi32imm : PseudoInst<(outs rGPR:$dst), (ins i32imm:$src), IIC_iMOVix2,
|
||||
[(set rGPR:$dst, (i32 imm:$src))]>,
|
||||
Requires<[IsThumb, HasV6T2]>;
|
||||
Requires<[IsThumb, UseMovt]>;
|
||||
|
||||
// Pseudo instruction that combines movw + movt + add pc (if pic).
|
||||
// It also makes it possible to rematerialize the instructions.
|
||||
|
Reference in New Issue
Block a user