28 #define DEBUG_TYPE "aarch64-jump-tables" 30 STATISTIC(NumJT8,
"Number of jump-tables with 1-byte entries");
31 STATISTIC(NumJT16,
"Number of jump-tables with 2-byte entries");
32 STATISTIC(NumJT32,
"Number of jump-tables with 4-byte entries");
58 return "AArch64 Compress Jump Tables";
65 "AArch64 compress jump tables pass",
false,
false)
74 void AArch64CompressJumpTables::scanFunction() {
80 BlockInfo[MBB.getNumber()] =
Offset;
85 bool AArch64CompressJumpTables::compressJumpTable(
MachineInstr &
MI,
87 if (MI.
getOpcode() != AArch64::JumpTableDest32)
98 int MaxOffset = std::numeric_limits<int>::min(),
101 for (
auto Block : JT.
MBBs) {
102 int BlockOffset = BlockInfo[Block->getNumber()];
103 assert(BlockOffset % 4 == 0 &&
"misaligned basic block");
105 MaxOffset =
std::max(MaxOffset, BlockOffset);
106 if (BlockOffset <= MinOffset) {
107 MinOffset = BlockOffset;
114 if (!isInt<21>(MinOffset - Offset)) {
119 int Span = MaxOffset - MinOffset;
123 MI.
setDesc(TII->
get(AArch64::JumpTableDest8));
127 AFI->setJumpTableEntryInfo(JTIdx, 2, MinBlock->
getSymbol());
128 MI.
setDesc(TII->
get(AArch64::JumpTableDest16));
137 bool AArch64CompressJumpTables::runOnMachineFunction(
MachineFunction &MFIn) {
138 bool Changed =
false;
142 TII =
ST.getInstrInfo();
150 int Offset = BlockInfo[MBB.getNumber()];
152 Changed |= compressJumpTable(MI, Offset);
153 Offset += TII->getInstSizeInBytes(MI);
161 return new AArch64CompressJumpTables();
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
AArch64FunctionInfo - This class is derived from MachineFunctionInfo and contains private AArch64-spe...
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
This class represents lattice values for constants.
unsigned getNumBlockIDs() const
getNumBlockIDs - Return the number of MBB ID's allocated.
STATISTIC(NumFunctions, "Total number of functions")
void computeBlockSize(MachineFunction *MF, MachineBasicBlock *MBB, BasicBlockInfo &BBI)
virtual unsigned getInstSizeInBytes(const MachineInstr &MI) const
Returns the size in bytes of the specified MachineInstr, or ~0U when this function is not implemented...
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const HexagonInstrInfo * TII
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
TargetInstrInfo - Interface to description of machine instruction set.
constexpr bool isUInt< 8 >(uint64_t x)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
void setJumpTableEntryInfo(int Idx, unsigned Size, MCSymbol *PCRelSym)
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
FunctionPass class - This class is used to implement most global optimizations.
std::vector< MachineBasicBlock * > MBBs
MBBs - The vector of basic blocks from which to create the jump table.
INITIALIZE_PASS(AArch64CompressJumpTables, DEBUG_TYPE, "AArch64 compress jump tables pass", false, false) int AArch64CompressJumpTables
void setDesc(const MCInstrDesc &tid)
Replace the instruction descriptor (thus opcode) of the current instruction with a new one...
const Function & getFunction() const
Return the LLVM function that this machine code represents.
MachineJumpTableEntry - One jump table in the jump table info.
MachineFunctionProperties & set(Property P)
Representation of each machine instruction.
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
bool optForMinSize() const
Optimize this function for minimum size (-Oz).
constexpr bool isUInt< 16 >(uint64_t x)
void initializeAArch64CompressJumpTablesPass(PassRegistry &)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringRef - Represent a constant reference to a string, i.e.
const MachineJumpTableInfo * getJumpTableInfo() const
getJumpTableInfo - Return the jump table info object for the current function.
const MachineOperand & getOperand(unsigned i) const
Properties which a MachineFunction may have at a given point in time.
FunctionPass * createAArch64CompressJumpTablesPass()