mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-22 04:22:57 +02:00
dad2c9ed8c
The key idea is to lower COPY nodes populating EFLAGS by scanning the uses of EFLAGS and introducing dedicated code to preserve the necessary state in a GPR. In the vast majority of cases, these uses are cmovCC and jCC instructions. For such cases, we can very easily save and restore the necessary information by simply inserting a setCC into a GPR where the original flags are live, and then testing that GPR directly to feed the cmov or conditional branch. However, things are a bit more tricky if arithmetic is using the flags. This patch handles the vast majority of cases that seem to come up in practice: adc, adcx, adox, rcl, and rcr; all without taking advantage of partially preserved EFLAGS as LLVM doesn't currently model that at all. There are a large number of operations that techinaclly observe EFLAGS currently but shouldn't in this case -- they typically are using DF. Currently, they will not be handled by this approach. However, I have never seen this issue come up in practice. It is already pretty rare to have these patterns come up in practical code with LLVM. I had to resort to writing MIR tests to cover most of the logic in this pass already. I suspect even with its current amount of coverage of arithmetic users of EFLAGS it will be a significant improvement over the current use of pushf/popf. It will also produce substantially faster code in most of the common patterns. This patch also removes all of the old lowering for EFLAGS copies, and the hack that forced us to use a frame pointer when EFLAGS copies were found anywhere in a function so that the dynamic stack adjustment wasn't a problem. None of this is needed as we now lower all of these copies directly in MI and without require stack adjustments. Lots of thanks to Reid who came up with several aspects of this approach, and Craig who helped me work out a couple of things tripping me up while working on this. Differential Revision: https://reviews.llvm.org/D45146 llvm-svn: 329657
76 lines
2.1 KiB
CMake
76 lines
2.1 KiB
CMake
set(LLVM_TARGET_DEFINITIONS X86.td)
|
|
|
|
tablegen(LLVM X86GenAsmMatcher.inc -gen-asm-matcher)
|
|
tablegen(LLVM X86GenAsmWriter.inc -gen-asm-writer)
|
|
tablegen(LLVM X86GenAsmWriter1.inc -gen-asm-writer -asmwriternum=1)
|
|
tablegen(LLVM X86GenCallingConv.inc -gen-callingconv)
|
|
tablegen(LLVM X86GenDAGISel.inc -gen-dag-isel)
|
|
tablegen(LLVM X86GenDisassemblerTables.inc -gen-disassembler)
|
|
tablegen(LLVM X86GenEVEX2VEXTables.inc -gen-x86-EVEX2VEX-tables)
|
|
tablegen(LLVM X86GenFastISel.inc -gen-fast-isel)
|
|
tablegen(LLVM X86GenGlobalISel.inc -gen-global-isel)
|
|
tablegen(LLVM X86GenInstrInfo.inc -gen-instr-info)
|
|
tablegen(LLVM X86GenRegisterBank.inc -gen-register-bank)
|
|
tablegen(LLVM X86GenRegisterInfo.inc -gen-register-info)
|
|
tablegen(LLVM X86GenSubtargetInfo.inc -gen-subtarget)
|
|
|
|
if (X86_GEN_FOLD_TABLES)
|
|
tablegen(LLVM X86GenFoldTables.inc -gen-x86-fold-tables)
|
|
endif()
|
|
|
|
add_public_tablegen_target(X86CommonTableGen)
|
|
|
|
set(sources
|
|
ShadowCallStack.cpp
|
|
X86AsmPrinter.cpp
|
|
X86CallFrameOptimization.cpp
|
|
X86CallingConv.cpp
|
|
X86CallLowering.cpp
|
|
X86CmovConversion.cpp
|
|
X86DomainReassignment.cpp
|
|
X86ExpandPseudo.cpp
|
|
X86FastISel.cpp
|
|
X86FixupBWInsts.cpp
|
|
X86FixupLEAs.cpp
|
|
X86AvoidStoreForwardingBlocks.cpp
|
|
X86FixupSetCC.cpp
|
|
X86FlagsCopyLowering.cpp
|
|
X86FloatingPoint.cpp
|
|
X86FrameLowering.cpp
|
|
X86InstructionSelector.cpp
|
|
X86ISelDAGToDAG.cpp
|
|
X86ISelLowering.cpp
|
|
X86IndirectBranchTracking.cpp
|
|
X86InterleavedAccess.cpp
|
|
X86InstrFMA3Info.cpp
|
|
X86InstrInfo.cpp
|
|
X86EvexToVex.cpp
|
|
X86LegalizerInfo.cpp
|
|
X86MCInstLower.cpp
|
|
X86MachineFunctionInfo.cpp
|
|
X86MacroFusion.cpp
|
|
X86OptimizeLEAs.cpp
|
|
X86PadShortFunction.cpp
|
|
X86RegisterBankInfo.cpp
|
|
X86RegisterInfo.cpp
|
|
X86RetpolineThunks.cpp
|
|
X86SelectionDAGInfo.cpp
|
|
X86ShuffleDecodeConstantPool.cpp
|
|
X86Subtarget.cpp
|
|
X86TargetMachine.cpp
|
|
X86TargetObjectFile.cpp
|
|
X86TargetTransformInfo.cpp
|
|
X86VZeroUpper.cpp
|
|
X86WinAllocaExpander.cpp
|
|
X86WinEHState.cpp
|
|
)
|
|
|
|
add_llvm_target(X86CodeGen ${sources})
|
|
|
|
add_subdirectory(AsmParser)
|
|
add_subdirectory(Disassembler)
|
|
add_subdirectory(InstPrinter)
|
|
add_subdirectory(MCTargetDesc)
|
|
add_subdirectory(TargetInfo)
|
|
add_subdirectory(Utils)
|