LLVM
8.0.1
|
Lowers COPY nodes of EFLAGS by directly extracting and preserving individual flag bits. More...
#include "X86.h"
#include "X86InstrBuilder.h"
#include "X86InstrInfo.h"
#include "X86Subtarget.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/PostOrderIterator.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/SparseBitVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineConstantPool.h"
#include "llvm/CodeGen/MachineDominators.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/MachineSSAUpdater.h"
#include "llvm/CodeGen/TargetInstrInfo.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/CodeGen/TargetSchedule.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/MC/MCSchedule.h"
#include "llvm/Pass.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
#include <iterator>
#include <utility>
Go to the source code of this file.
Namespaces | |
llvm | |
This class represents lattice values for constants. | |
Macros | |
#define | PASS_KEY "x86-flags-copy-lowering" |
#define | DEBUG_TYPE PASS_KEY |
#define | LLVM_EXPAND_INSTR_SIZES(MNEMONIC, SUFFIX) |
#define | LLVM_EXPAND_ADC_SBB_INSTR(MNEMONIC) |
Enumerations | |
enum | FlagArithMnemonic |
An enumeration of the arithmetic instruction mnemonics which have interesting flag semantics. More... | |
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") | |
void | llvm::initializeX86FlagsCopyLoweringPassPass (PassRegistry &) |
INITIALIZE_PASS_BEGIN (X86FlagsCopyLoweringPass, DEBUG_TYPE, "X86 EFLAGS copy lowering", false, false) INITIALIZE_PASS_END(X86FlagsCopyLoweringPass | |
static FlagArithMnemonic | getMnemonicFromOpcode (unsigned Opcode) |
static MachineBasicBlock & | splitBlock (MachineBasicBlock &MBB, MachineInstr &SplitI, const X86InstrInfo &TII) |
Variables | |
DEBUG_TYPE | |
X86 EFLAGS copy | lowering |
X86 EFLAGS copy | false |
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.
#define DEBUG_TYPE PASS_KEY |
Definition at line 67 of file X86FlagsCopyLowering.cpp.
#define LLVM_EXPAND_ADC_SBB_INSTR | ( | MNEMONIC | ) |
Referenced by getMnemonicFromOpcode().
#define LLVM_EXPAND_INSTR_SIZES | ( | MNEMONIC, | |
SUFFIX | |||
) |
Referenced by getMnemonicFromOpcode().
#define PASS_KEY "x86-flags-copy-lowering" |
Definition at line 66 of file X86FlagsCopyLowering.cpp.
|
strong |
An enumeration of the arithmetic instruction mnemonics which have interesting flag semantics.
We can map instruction opcodes into these mnemonics to make it easy to dispatch with specific functionality.
Definition at line 166 of file X86FlagsCopyLowering.cpp.
|
static |
Definition at line 176 of file X86FlagsCopyLowering.cpp.
References llvm::AArch64ISD::ADC, LLVM_EXPAND_ADC_SBB_INSTR, LLVM_EXPAND_INSTR_SIZES, r1(), llvm::report_fatal_error(), and llvm::X86ISD::SBB.
INITIALIZE_PASS_BEGIN | ( | X86FlagsCopyLoweringPass | , |
DEBUG_TYPE | , | ||
"X86 EFLAGS copy lowering" | , | ||
false | , | ||
false | |||
) |
|
static |
Definition at line 246 of file X86FlagsCopyLowering.cpp.
References llvm::any_of(), assert(), llvm::MachineFunction::begin(), llvm::X86::COND_INVALID, Copies, llvm::MachineBasicBlock::copySuccessor(), llvm::MachineFunction::CreateMachineBasicBlock(), llvm::MachineOperand::CreateMBB(), llvm::dbgs(), llvm::MachineBasicBlock::end(), llvm::MachineFunction::end(), llvm::X86::getCondFromBranchOpc(), llvm::MachineBasicBlock::getFallThrough(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::MachineOperand::getMBB(), llvm::MachineFunction::getName(), llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getOperand(), llvm::MachineBasicBlock::getParent(), llvm::MachineInstr::getParent(), llvm::MachineOperand::getReg(), llvm::MachineFunction::getRegInfo(), llvm::MachineFunction::getSubtarget(), llvm::MachineFunction::insert(), llvm::MachineBasicBlock::instr_end(), llvm::MachineInstr::isBranch(), llvm::MachineOperand::isMBB(), llvm::MachineOperand::isReg(), llvm::MachineBasicBlock::isSuccessor(), LLVM_DEBUG, llvm::make_scope_exit(), MI, MRI, llvm::MachineBasicBlock::normalizeSuccProbs(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::MachineBasicBlock::replaceSuccessor(), llvm::report_fatal_error(), llvm::MachineOperand::setMBB(), SI, llvm::MachineBasicBlock::splice(), llvm::MachineBasicBlock::succ_begin(), llvm::MachineBasicBlock::succ_end(), llvm::MachineBasicBlock::successors(), TII, and TRI.
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" | |||
) |
DEBUG_TYPE |
Definition at line 146 of file X86FlagsCopyLowering.cpp.
X86 EFLAGS copy false |
Definition at line 146 of file X86FlagsCopyLowering.cpp.
X86 EFLAGS copy lowering |
Definition at line 146 of file X86FlagsCopyLowering.cpp.