Go to the documentation of this file.
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");
63 return "AArch64 Compress Jump Tables";
70 "AArch64 compress jump tables pass",
false,
false)
82 Size +=
TII->getInstSizeInBytes(
MI);
87 bool AArch64CompressJumpTables::scanFunction() {
94 unsigned AlignedOffset;
95 if (Alignment ==
Align(1))
98 AlignedOffset =
alignTo(Offset, Alignment);
108 bool AArch64CompressJumpTables::compressJumpTable(
MachineInstr &
MI,
110 if (
MI.getOpcode() != AArch64::JumpTableDest32)
113 int JTIdx =
MI.getOperand(4).getIndex();
114 auto &JTInfo = *MF->getJumpTableInfo();
124 for (
auto *Block :
JT.MBBs) {
125 int BlockOffset = BlockInfo[
Block->getNumber()];
126 assert(BlockOffset % 4 == 0 &&
"misaligned basic block");
128 MaxOffset =
std::max(MaxOffset, BlockOffset);
129 if (BlockOffset <= MinOffset) {
130 MinOffset = BlockOffset;
134 assert(MinBlock &&
"Failed to find minimum offset block");
138 if (!isInt<21>(MinOffset - Offset)) {
143 int Span = MaxOffset - MinOffset;
147 MI.setDesc(
TII->get(AArch64::JumpTableDest8));
152 AFI->setJumpTableEntryInfo(JTIdx, 2, MinBlock->
getSymbol());
153 MI.setDesc(
TII->get(AArch64::JumpTableDest16));
162 bool AArch64CompressJumpTables::runOnMachineFunction(
MachineFunction &MFIn) {
163 bool Changed =
false;
167 TII =
ST.getInstrInfo();
169 if (
ST.force32BitJumpTables() && !MF->getFunction().hasMinSize())
178 Changed |= compressJumpTable(
MI, Offset);
187 return new AArch64CompressJumpTables();
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
This is an optimization pass for GlobalISel generic memory operations.
static const int BlockSize
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
unsigned getNumBlockIDs() const
getNumBlockIDs - Return the number of MBB ID's allocated.
void initializeAArch64CompressJumpTablesPass(PassRegistry &)
Properties which a MachineFunction may have at a given point in time.
Expected< ExpressionValue > max(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
@ INLINEASM
INLINEASM - Represents an inline asm block.
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
TargetInstrInfo - Interface to description of machine instruction set.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
FunctionPass * createAArch64CompressJumpTablesPass()
const HexagonInstrInfo * TII
MachineFunctionProperties & set(Property P)
STATISTIC(NumFunctions, "Total number of functions")
This struct is a compact representation of a valid (non-zero power of two) alignment.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
constexpr bool isUInt< 16 >(uint64_t x)
Representation of each machine instruction.
AArch64FunctionInfo - This class is derived from MachineFunctionInfo and contains private AArch64-spe...
Align getAlignment() const
Return alignment of the basic block.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
constexpr bool isUInt< 8 >(uint64_t x)
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
Expected< ExpressionValue > min(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
StringRef - Represent a constant reference to a string, i.e.
INITIALIZE_PASS(AArch64CompressJumpTables, DEBUG_TYPE, "AArch64 compress jump tables pass", false, false) Optional< int > AArch64CompressJumpTables
@ INLINEASM_BR
INLINEASM_BR - Branching version of inline asm. Used by asm-goto.
MachineJumpTableEntry - One jump table in the jump table info.
void setJumpTableEntryInfo(int Idx, unsigned Size, MCSymbol *PCRelSym)
FunctionPass class - This class is used to implement most global optimizations.