LLVM
8.0.1
|
#include "ARM.h"
#include "ARMBaseInstrInfo.h"
#include "ARMBasicBlockInfo.h"
#include "ARMMachineFunctionInfo.h"
#include "ARMSubtarget.h"
#include "MCTargetDesc/ARMBaseInfo.h"
#include "Thumb2InstrInfo.h"
#include "Utils/ARMBaseInfo.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineConstantPool.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineJumpTableInfo.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/MC/MCInstrDesc.h"
#include "llvm/Pass.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <iterator>
#include <utility>
#include <vector>
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "arm-cp-islands" |
#define | ARM_CP_ISLANDS_OPT_NAME "ARM constant island placement and branch shortening pass" |
Functions | |
STATISTIC (NumCPEs, "Number of constpool entries") | |
STATISTIC (NumSplit, "Number of uncond branches inserted") | |
STATISTIC (NumCBrFixed, "Number of cond branches fixed") | |
STATISTIC (NumUBrFixed, "Number of uncond branches fixed") | |
STATISTIC (NumTBs, "Number of table branches generated") | |
STATISTIC (NumT2CPShrunk, "Number of Thumb2 constantpool instructions shrunk") | |
STATISTIC (NumT2BrShrunk, "Number of Thumb2 immediate branches shrunk") | |
STATISTIC (NumCBZ, "Number of CBZ / CBNZ formed") | |
STATISTIC (NumJTMoved, "Number of jump table destination blocks moved") | |
STATISTIC (NumJTInserted, "Number of jump table intermediate blocks inserted") | |
static bool | CompareMBBNumbers (const MachineBasicBlock *LHS, const MachineBasicBlock *RHS) |
CompareMBBNumbers - Little predicate function to sort the WaterList by MBB ID. More... | |
static bool | BBIsJumpedOver (MachineBasicBlock *MBB) |
BBIsJumpedOver - Return true of the specified basic block's only predecessor unconditionally branches to its only successor. More... | |
static unsigned | getUnconditionalBrDisp (int Opc) |
getUnconditionalBrDisp - Returns the maximum displacement that can fit in the specific unconditional branch instruction. More... | |
static bool | isSimpleIndexCalc (MachineInstr &I, unsigned EntryReg, unsigned BaseReg) |
static bool | jumpTableFollowsTB (MachineInstr *JTMI, MachineInstr *CPEMI) |
Returns whether CPEMI is the first instruction in the block immediately following JTMI (assumed to be a TBB or TBH terminator). More... | |
static void | RemoveDeadAddBetweenLEAAndJT (MachineInstr *LEAMI, MachineInstr *JumpMI, unsigned &DeadSize) |
static bool | registerDefinedBetween (unsigned Reg, MachineBasicBlock::iterator From, MachineBasicBlock::iterator To, const TargetRegisterInfo *TRI) |
Variables | |
static cl::opt< bool > | AdjustJumpTableBlocks ("arm-adjust-jump-tables", cl::Hidden, cl::init(true), cl::desc("Adjust basic block layout to better use TB[BH]")) |
static cl::opt< unsigned > | CPMaxIteration ("arm-constant-island-max-iteration", cl::Hidden, cl::init(30), cl::desc("The max number of iteration for converge")) |
static cl::opt< bool > | SynthesizeThumb1TBB ("arm-synthesize-thumb-1-tbb", cl::Hidden, cl::init(true), cl::desc("Use compressed jump tables in Thumb-1 by synthesizing an " "equivalent to the TBB/TBH instructions")) |
#define ARM_CP_ISLANDS_OPT_NAME "ARM constant island placement and branch shortening pass" |
Definition at line 61 of file ARMConstantIslandPass.cpp.
Referenced by llvm::createARMConstantIslandPass().
#define DEBUG_TYPE "arm-cp-islands" |
Definition at line 59 of file ARMConstantIslandPass.cpp.
|
static |
BBIsJumpedOver - Return true of the specified basic block's only predecessor unconditionally branches to its only successor.
Definition at line 1093 of file ARMConstantIslandPass.cpp.
References assert(), B, llvm::MachineBasicBlock::back(), llvm::dbgs(), llvm::MachineOperand::getIndex(), llvm::MachineOperand::getMBB(), llvm::MachineBasicBlock::getNumber(), llvm::MachineInstr::getNumOperands(), llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::isCPI(), LLVM_DEBUG, llvm::MachineBasicBlock::pred_begin(), llvm::MachineBasicBlock::pred_size(), llvm::MachineOperand::setIndex(), llvm::MachineBasicBlock::succ_begin(), and llvm::MachineBasicBlock::succ_size().
Referenced by getUnconditionalBrDisp().
|
static |
CompareMBBNumbers - Little predicate function to sort the WaterList by MBB ID.
Definition at line 880 of file ARMConstantIslandPass.cpp.
References llvm::MachineInstrBuilder::add(), llvm::MachineBasicBlock::addSuccessor(), llvm::ARMCC::AL, B, llvm::BuildMI(), llvm::computeBlockSize(), llvm::dbgs(), llvm::MachineBasicBlock::end(), llvm::format(), llvm::MachineBasicBlock::getBasicBlock(), llvm::MachineOperand::getImm(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::MachineBasicBlock::getNumber(), llvm::MachineInstr::getOperand(), llvm::MachineBasicBlock::getParent(), llvm::MachineInstr::getParent(), llvm::SmallSet< T, N, C >::insert(), llvm::MachineBasicBlock::insert(), llvm::BasicBlockInfo::internalKnownBits(), LLVM_DEBUG, llvm::lower_bound(), MI, llvm::BasicBlockInfo::Offset, llvm::OffsetToAlignment(), llvm::BasicBlockInfo::postOffset(), llvm::predOps(), llvm::printMBBReference(), llvm::MachineFunction::RenumberBlocks(), Size, llvm::MachineBasicBlock::splice(), llvm::MachineBasicBlock::transferSuccessors(), and llvm::UnknownPadding().
|
inlinestatic |
getUnconditionalBrDisp - Returns the maximum displacement that can fit in the specific unconditional branch instruction.
Definition at line 1205 of file ARMConstantIslandPass.cpp.
References llvm::ARM_AM::add, llvm::MachineInstrBuilder::add(), llvm::MachineInstrBuilder::addImm(), llvm::MachineInstrBuilder::addMBB(), llvm::MachineInstrBuilder::addReg(), llvm::MachineBasicBlock::addSuccessor(), llvm::ARMCC::AL, llvm::AMDGPU::HSAMD::Kernel::Arg::Key::Align, assert(), B, llvm::MachineBasicBlock::back(), BBHasFallthrough(), BBIsJumpedOver(), llvm::MachineBasicBlock::begin(), llvm::tgtok::Bits, llvm::BuildMI(), llvm::computeBlockSize(), llvm::SmallSet< T, N, C >::count(), llvm::ARMFunctionInfo::createPICLabelUId(), llvm::dbgs(), llvm::MachineBasicBlock::empty(), llvm::MachineBasicBlock::end(), llvm::ARMCC::EQ, llvm::SmallSet< T, N, C >::erase(), llvm::MachineInstr::eraseFromParent(), llvm::find(), llvm::format(), llvm::MachineBasicBlock::getAlignment(), llvm::MachineInstr::getDebugLoc(), llvm::MachineInstr::getDesc(), llvm::MachineOperand::getImm(), llvm::getInstrPredicate(), llvm::ARMBaseInstrInfo::getInstSizeInBytes(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::getITInstrPredicate(), llvm::MachineOperand::getMBB(), llvm::MachineBasicBlock::getNumber(), llvm::MachineInstr::getNumExplicitOperands(), llvm::MachineInstr::getNumOperands(), llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getOperand(), llvm::ARMCC::getOppositeCondition(), llvm::MachineInstr::getParent(), llvm::MachineOperand::getReg(), llvm::SmallSet< T, N, C >::insert(), llvm::BasicBlockInfo::internalKnownBits(), llvm::isARMLowRegister(), llvm::MachineOperand::isCPI(), LLVM_DEBUG, llvm_unreachable, llvm::max(), MI, llvm::ARMII::MO_HI16, llvm::ARMII::MO_LO16, llvm::ARMII::MO_OPTION_MASK, llvm::ARMCC::NE, llvm::BasicBlockInfo::postOffset(), llvm::predOps(), llvm::printMBBReference(), Reg, llvm::MachineBasicBlock::setAlignment(), llvm::MachineInstr::setDesc(), llvm::MachineOperand::setImm(), llvm::MachineOperand::setIndex(), llvm::MachineOperand::setMBB(), Size, llvm::SmallVectorBase::size(), and llvm::UnknownPadding().
|
static |
Definition at line 1934 of file ARMConstantIslandPass.cpp.
References E, llvm::MachineInstr::eraseFromParent(), llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getOperand(), llvm::MachineInstr::getParent(), llvm::MachineOperand::getReg(), I, llvm::MachineOperand::isDef(), llvm::MachineOperand::isKill(), llvm::MachineOperand::isReg(), and llvm::MachineOperand::isUse().
|
static |
Returns whether CPEMI is the first instruction in the block immediately following JTMI (assumed to be a TBB or TBH terminator).
If so, we can switch the first register to PC and usually remove the address calculation that preceded it.
Definition at line 2041 of file ARMConstantIslandPass.cpp.
References llvm::MachineFunction::end(), llvm::ilist_node_impl< OptionsT >::getIterator(), and llvm::MachineInstr::getParent().
Referenced by registerDefinedBetween().
|
static |
Definition at line 2088 of file ARMConstantIslandPass.cpp.
References llvm::MCID::Add, llvm::MachineInstrBuilder::add(), llvm::MachineBasicBlock::addSuccessor(), llvm::ARMCC::AL, llvm::ARMBaseInstrInfo::analyzeBranch(), assert(), B, llvm::BuildMI(), llvm::dbgs(), E, llvm::SmallVectorBase::empty(), llvm::MachineBasicBlock::end(), llvm::MachineInstr::eraseFromParent(), llvm::find_if(), llvm::MachineBasicBlock::front(), llvm::MachineBasicBlock::getBasicBlock(), llvm::MachineInstr::getDebugLoc(), llvm::MachineInstr::getDesc(), llvm::MachineOperand::getImm(), llvm::ARMBaseInstrInfo::getInstSizeInBytes(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::MachineJumpTableInfo::getJumpTables(), llvm::getKillRegState(), llvm::ilist_node_with_parent< NodeTy, ParentTy, Options >::getNextNode(), llvm::MachineBasicBlock::getNumber(), llvm::MCInstrDesc::getNumOperands(), llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getOperand(), llvm::MachineInstr::getParent(), llvm::MachineOperand::getReg(), I, llvm::MachineOperand::isKill(), llvm::MachineInstr::isPredicable(), jumpTableFollowsTB(), LLVM_DEBUG, llvm::SPII::Load, MI, llvm::MachineBasicBlock::moveAfter(), llvm::predOps(), llvm::printMBBReference(), RemoveDeadAddBetweenLEAAndJT(), llvm::MachineJumpTableInfo::ReplaceMBBInJumpTable(), llvm::MachineBasicBlock::replaceSuccessor(), llvm::MachineInstr::setDesc(), llvm::MachineOperand::setIsKill(), llvm::MachineOperand::setReg(), llvm::SmallVectorBase::size(), TRI, and llvm::MachineBasicBlock::updateTerminator().
|
static |
Definition at line 2050 of file ARMConstantIslandPass.cpp.
References llvm::dbgs(), E, llvm::MachineInstr::eraseFromParent(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), I, llvm::MachineOperand::isDef(), llvm::MachineOperand::isReg(), llvm::MachineOperand::isUse(), and LLVM_DEBUG.
Referenced by registerDefinedBetween().
STATISTIC | ( | NumCPEs | , |
"Number of constpool entries" | |||
) |
STATISTIC | ( | NumSplit | , |
"Number of uncond branches inserted" | |||
) |
STATISTIC | ( | NumCBrFixed | , |
"Number of cond branches fixed" | |||
) |
STATISTIC | ( | NumUBrFixed | , |
"Number of uncond branches fixed" | |||
) |
STATISTIC | ( | NumTBs | , |
"Number of table branches generated" | |||
) |
STATISTIC | ( | NumT2CPShrunk | , |
"Number of Thumb2 constantpool instructions shrunk" | |||
) |
STATISTIC | ( | NumT2BrShrunk | , |
"Number of Thumb2 immediate branches shrunk" | |||
) |
STATISTIC | ( | NumCBZ | , |
"Number of CBZ / CBNZ formed" | |||
) |
STATISTIC | ( | NumJTMoved | , |
"Number of jump table destination blocks moved" | |||
) |
STATISTIC | ( | NumJTInserted | , |
"Number of jump table intermediate blocks inserted" | |||
) |
|
static |
|
static |
|
static |