LLVM 24.0.0git
ARMConstantIslandPass.cpp File Reference
#include "ARM.h"
#include "ARMBaseInstrInfo.h"
#include "ARMBasicBlockInfo.h"
#include "ARMMachineFunctionInfo.h"
#include "ARMSubtarget.h"
#include "MCTargetDesc/ARMBaseInfo.h"
#include "MVETailPredUtils.h"
#include "Thumb2InstrInfo.h"
#include "Utils/ARMBaseInfo.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/CodeGen/LivePhysRegs.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/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/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <iterator>
#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")
 STATISTIC (NumLEInserted, "Number of LE backwards branches inserted")
static bool AlignBlocks (MachineFunction *MF, const ARMSubtarget *STI)
static bool CompareMBBNumbers (const MachineBasicBlock *LHS, const MachineBasicBlock *RHS)
 CompareMBBNumbers - Little predicate function to sort the WaterList by MBB ID.
static bool BBIsJumpedOver (MachineBasicBlock *MBB)
 BBIsJumpedOver - Return true of the specified basic block's only predecessor unconditionally branches to its only successor.
static unsigned getUnconditionalBrDisp (int Opc)
 getUnconditionalBrDisp - Returns the maximum displacement that can fit in the specific unconditional branch instruction.
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).
static void RemoveDeadAddBetweenLEAAndJT (MachineInstr *LEAMI, MachineInstr *JumpMI, unsigned &DeadSize)

Macro Definition Documentation

◆ ARM_CP_ISLANDS_OPT_NAME

#define ARM_CP_ISLANDS_OPT_NAME    "ARM constant island placement and branch shortening pass"

Definition at line 59 of file ARMConstantIslandPass.cpp.

◆ DEBUG_TYPE

#define DEBUG_TYPE   "arm-cp-islands"

Definition at line 57 of file ARMConstantIslandPass.cpp.

Function Documentation

◆ AlignBlocks()

◆ BBIsJumpedOver()

bool BBIsJumpedOver ( MachineBasicBlock * MBB)
static

BBIsJumpedOver - Return true of the specified basic block's only predecessor unconditionally branches to its only successor.

Definition at line 1164 of file ARMConstantIslandPass.cpp.

References llvm::MachineOperand::getMBB(), llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getOperand(), MBB, and Pred.

◆ CompareMBBNumbers()

bool CompareMBBNumbers ( const MachineBasicBlock * LHS,
const MachineBasicBlock * RHS )
static

CompareMBBNumbers - Little predicate function to sort the WaterList by MBB ID.

Definition at line 938 of file ARMConstantIslandPass.cpp.

References LHS, and RHS.

◆ getUnconditionalBrDisp()

unsigned getUnconditionalBrDisp ( int Opc)
inlinestatic

getUnconditionalBrDisp - Returns the maximum displacement that can fit in the specific unconditional branch instruction.

Definition at line 1254 of file ARMConstantIslandPass.cpp.

References Opc.

◆ isSimpleIndexCalc()

bool isSimpleIndexCalc ( MachineInstr & I,
unsigned EntryReg,
unsigned BaseReg )
static

Definition at line 2053 of file ARMConstantIslandPass.cpp.

References I.

◆ jumpTableFollowsTB()

bool jumpTableFollowsTB ( MachineInstr * JTMI,
MachineInstr * CPEMI )
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 2158 of file ARMConstantIslandPass.cpp.

References llvm::MachineFunction::end(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::MachineInstr::getParent(), and MBB.

◆ RemoveDeadAddBetweenLEAAndJT()

void RemoveDeadAddBetweenLEAAndJT ( MachineInstr * LEAMI,
MachineInstr * JumpMI,
unsigned & DeadSize )
static

◆ STATISTIC() [1/11]

STATISTIC ( NumCBrFixed ,
"Number of cond branches fixed"  )

◆ STATISTIC() [2/11]

STATISTIC ( NumCBZ ,
"Number of CBZ / CBNZ formed"  )

◆ STATISTIC() [3/11]

STATISTIC ( NumCPEs ,
"Number of constpool entries"  )

◆ STATISTIC() [4/11]

STATISTIC ( NumJTInserted ,
"Number of jump table intermediate blocks inserted"  )

◆ STATISTIC() [5/11]

STATISTIC ( NumJTMoved ,
"Number of jump table destination blocks moved"  )

◆ STATISTIC() [6/11]

STATISTIC ( NumLEInserted ,
"Number of LE backwards branches inserted"  )

References MI, and llvm::neg().

◆ STATISTIC() [7/11]

STATISTIC ( NumSplit ,
"Number of uncond branches inserted"  )

◆ STATISTIC() [8/11]

STATISTIC ( NumT2BrShrunk ,
"Number of Thumb2 immediate branches shrunk"  )

◆ STATISTIC() [9/11]

STATISTIC ( NumT2CPShrunk ,
"Number of Thumb2 constantpool instructions shrunk"  )

◆ STATISTIC() [10/11]

STATISTIC ( NumTBs ,
"Number of table branches generated"  )

◆ STATISTIC() [11/11]

STATISTIC ( NumUBrFixed ,
"Number of uncond branches fixed"  )