mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
Add MI-Sched support for x86 macro fusion.
This is an awful implementation of the target hook. But we don't have abstractions yet for common machine ops, and I don't see any quick way to make it table-driven. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184664 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -4647,6 +4647,167 @@ bool X86InstrInfo::shouldScheduleLoadsNear(SDNode *Load1, SDNode *Load2,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool X86InstrInfo::shouldScheduleAdjacent(MachineInstr* First,
|
||||
MachineInstr *Second) const {
|
||||
// Check if this processor supports macro-fusion. Since this is a minor
|
||||
// heuristic, we haven't specifically reserved a feature. hasAVX is a decent
|
||||
// proxy for SandyBridge+.
|
||||
if (!TM.getSubtarget<X86Subtarget>().hasAVX())
|
||||
return false;
|
||||
|
||||
enum {
|
||||
FuseTest,
|
||||
FuseCmp,
|
||||
FuseInc
|
||||
} FuseKind;
|
||||
|
||||
switch(Second->getOpcode()) {
|
||||
default:
|
||||
return false;
|
||||
case X86::JE_4:
|
||||
case X86::JNE_4:
|
||||
case X86::JL_4:
|
||||
case X86::JLE_4:
|
||||
case X86::JG_4:
|
||||
case X86::JGE_4:
|
||||
FuseKind = FuseInc;
|
||||
break;
|
||||
case X86::JB_4:
|
||||
case X86::JBE_4:
|
||||
case X86::JA_4:
|
||||
case X86::JAE_4:
|
||||
FuseKind = FuseCmp;
|
||||
break;
|
||||
case X86::JS_4:
|
||||
case X86::JNS_4:
|
||||
case X86::JP_4:
|
||||
case X86::JNP_4:
|
||||
case X86::JO_4:
|
||||
case X86::JNO_4:
|
||||
FuseKind = FuseTest;
|
||||
break;
|
||||
}
|
||||
switch (First->getOpcode()) {
|
||||
default:
|
||||
return false;
|
||||
case X86::TEST8rr:
|
||||
case X86::TEST16rr:
|
||||
case X86::TEST32rr:
|
||||
case X86::TEST64rr:
|
||||
case X86::TEST8ri:
|
||||
case X86::TEST16ri:
|
||||
case X86::TEST32ri:
|
||||
case X86::TEST32i32:
|
||||
case X86::TEST64i32:
|
||||
case X86::TEST64ri32:
|
||||
case X86::TEST8rm:
|
||||
case X86::TEST16rm:
|
||||
case X86::TEST32rm:
|
||||
case X86::TEST64rm:
|
||||
case X86::AND16i16:
|
||||
case X86::AND16ri:
|
||||
case X86::AND16ri8:
|
||||
case X86::AND16rm:
|
||||
case X86::AND16rr:
|
||||
case X86::AND32i32:
|
||||
case X86::AND32ri:
|
||||
case X86::AND32ri8:
|
||||
case X86::AND32rm:
|
||||
case X86::AND32rr:
|
||||
case X86::AND64i32:
|
||||
case X86::AND64ri32:
|
||||
case X86::AND64ri8:
|
||||
case X86::AND64rm:
|
||||
case X86::AND64rr:
|
||||
case X86::AND8i8:
|
||||
case X86::AND8ri:
|
||||
case X86::AND8rm:
|
||||
case X86::AND8rr:
|
||||
return true;
|
||||
case X86::CMP16i16:
|
||||
case X86::CMP16ri:
|
||||
case X86::CMP16ri8:
|
||||
case X86::CMP16rm:
|
||||
case X86::CMP16rr:
|
||||
case X86::CMP32i32:
|
||||
case X86::CMP32ri:
|
||||
case X86::CMP32ri8:
|
||||
case X86::CMP32rm:
|
||||
case X86::CMP32rr:
|
||||
case X86::CMP64i32:
|
||||
case X86::CMP64ri32:
|
||||
case X86::CMP64ri8:
|
||||
case X86::CMP64rm:
|
||||
case X86::CMP64rr:
|
||||
case X86::CMP8i8:
|
||||
case X86::CMP8ri:
|
||||
case X86::CMP8rm:
|
||||
case X86::CMP8rr:
|
||||
case X86::ADD16i16:
|
||||
case X86::ADD16ri:
|
||||
case X86::ADD16ri8:
|
||||
case X86::ADD16ri8_DB:
|
||||
case X86::ADD16ri_DB:
|
||||
case X86::ADD16rm:
|
||||
case X86::ADD16rr:
|
||||
case X86::ADD16rr_DB:
|
||||
case X86::ADD32i32:
|
||||
case X86::ADD32ri:
|
||||
case X86::ADD32ri8:
|
||||
case X86::ADD32ri8_DB:
|
||||
case X86::ADD32ri_DB:
|
||||
case X86::ADD32rm:
|
||||
case X86::ADD32rr:
|
||||
case X86::ADD32rr_DB:
|
||||
case X86::ADD64i32:
|
||||
case X86::ADD64ri32:
|
||||
case X86::ADD64ri32_DB:
|
||||
case X86::ADD64ri8:
|
||||
case X86::ADD64ri8_DB:
|
||||
case X86::ADD64rm:
|
||||
case X86::ADD64rr:
|
||||
case X86::ADD64rr_DB:
|
||||
case X86::ADD8i8:
|
||||
case X86::ADD8mi:
|
||||
case X86::ADD8mr:
|
||||
case X86::ADD8ri:
|
||||
case X86::ADD8rm:
|
||||
case X86::ADD8rr:
|
||||
case X86::SUB16i16:
|
||||
case X86::SUB16ri:
|
||||
case X86::SUB16ri8:
|
||||
case X86::SUB16rm:
|
||||
case X86::SUB16rr:
|
||||
case X86::SUB32i32:
|
||||
case X86::SUB32ri:
|
||||
case X86::SUB32ri8:
|
||||
case X86::SUB32rm:
|
||||
case X86::SUB32rr:
|
||||
case X86::SUB64i32:
|
||||
case X86::SUB64ri32:
|
||||
case X86::SUB64ri8:
|
||||
case X86::SUB64rm:
|
||||
case X86::SUB64rr:
|
||||
case X86::SUB8i8:
|
||||
case X86::SUB8ri:
|
||||
case X86::SUB8rm:
|
||||
case X86::SUB8rr:
|
||||
return FuseKind == FuseCmp || FuseKind == FuseInc;
|
||||
case X86::INC16r:
|
||||
case X86::INC32r:
|
||||
case X86::INC64_16r:
|
||||
case X86::INC64_32r:
|
||||
case X86::INC64r:
|
||||
case X86::INC8r:
|
||||
case X86::DEC16r:
|
||||
case X86::DEC32r:
|
||||
case X86::DEC64_16r:
|
||||
case X86::DEC64_32r:
|
||||
case X86::DEC64r:
|
||||
case X86::DEC8r:
|
||||
return FuseKind == FuseInc;
|
||||
}
|
||||
}
|
||||
|
||||
bool X86InstrInfo::
|
||||
ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const {
|
||||
|
Reference in New Issue
Block a user