LLVM: lib/Target/X86/X86FlagsCopyLowering.cpp File Reference (original) (raw)

Lowers COPY nodes of EFLAGS by directly extracting and preserving individual flag bits. More...

Go to the source code of this file.

Macros
#define PASS_KEY "x86-flags-copy-lowering"
#define DEBUG_TYPE PASS_KEY
#define FROM_TO(A, B)
#define CASE(A)
Enumerations
enum EFLAGSClobber { NoClobber, EvitableClobber, InevitableClobber }
Functions
STATISTIC (NumCopiesEliminated, "Number of copies of EFLAGS eliminated")
STATISTIC (NumSetCCsInserted, "Number of setCC instructions inserted")
STATISTIC (NumTestsInserted, "Number of test instructions inserted")
STATISTIC (NumAddsInserted, "Number of adds instructions inserted")
STATISTIC (NumNFsConvertedTo, "Number of NF instructions converted to")
INITIALIZE_PASS_BEGIN (X86FlagsCopyLoweringPass, DEBUG_TYPE, "X86 EFLAGS copy lowering", false, false) INITIALIZE_PASS_END(X86FlagsCopyLoweringPass
static bool isArithmeticOp (unsigned Opc)
static MachineBasicBlock & splitBlock (MachineBasicBlock &MBB, MachineInstr &SplitI, const X86InstrInfo &TII)
static EFLAGSClobber getClobberType (const MachineInstr &MI)
static X86::CondCode getImplicitCondFromMI (unsigned Opc)
static unsigned getOpcodeWithCC (unsigned Opc, X86::CondCode CC)

Lowers COPY nodes of EFLAGS by directly extracting and preserving individual flag bits.

We have to do this by carefully analyzing and rewriting the usage of the copied EFLAGS register because there is no general way to rematerialize the entire EFLAGS register safely and efficiently. Using popf both forces dynamic stack adjustment and can create correctness issues due to IF, TF, and other non-status flags being overwritten. Using sequences involving SAHF don't work on all x86 processors and are often quite slow compared to directly testing a single status preserved in its own GPR.

Definition in file X86FlagsCopyLowering.cpp.

CASE

Value:

case X86::CMOVB_##A: \

case X86::CMOVE_##A: \

case X86::CMOVP_##A: \

case X86::CMOVBE_##A: \

case X86::CMOVNB_##A: \

case X86::CMOVNE_##A: \

case X86::CMOVNP_##A: \

case X86::CMOVNBE_##A: \

return (CC == X86::COND_E) ? X86::CMOVE_##A : X86::CMOVNE_##A;

static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")

DEBUG_TYPE

#define DEBUG_TYPE PASS_KEY

FROM_TO

Value:

case X86::CMOV##A##_Fp32: \

case X86::CMOV##A##_Fp64: \

case X86::CMOV##A##_Fp80: \

return X86::COND_##B;

static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")

PASS_KEY

#define PASS_KEY "x86-flags-copy-lowering"

EFLAGSClobber

getClobberType()

getImplicitCondFromMI()

getOpcodeWithCC()

INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( X86FlagsCopyLoweringPass ,
DEBUG_TYPE ,
"X86 EFLAGS copy lowering" ,
false ,
false )

isArithmeticOp()

splitBlock()

Definition at line 139 of file X86FlagsCopyLowering.cpp.

References assert(), llvm::X86::COND_INVALID, llvm::X86::getCondFromBranch(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::MachineOperand::getMBB(), llvm::MachineInstr::getOperand(), llvm::MachineInstr::getParent(), llvm::MachineInstr::isBranch(), MBB, MI, and TII.

STATISTIC() [1/5]

STATISTIC ( NumAddsInserted ,
"Number of adds instructions inserted" )

STATISTIC() [2/5]

STATISTIC ( NumCopiesEliminated ,
"Number of copies of EFLAGS eliminated" )

STATISTIC() [3/5]

STATISTIC ( NumNFsConvertedTo ,
"Number of NF instructions converted to" )

STATISTIC() [4/5]

STATISTIC ( NumSetCCsInserted ,
"Number of setCC instructions inserted" )

STATISTIC() [5/5]

DEBUG_TYPE

false

lowering

X86EnableAPXForRelocation