LLVM 20.0.0git
|
#include "ARMFrameLowering.h"
#include "ARMBaseInstrInfo.h"
#include "ARMBaseRegisterInfo.h"
#include "ARMConstantPoolValue.h"
#include "ARMMachineFunctionInfo.h"
#include "ARMSubtarget.h"
#include "MCTargetDesc/ARMAddressingModes.h"
#include "MCTargetDesc/ARMBaseInfo.h"
#include "Utils/ARMBaseInfo.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineConstantPool.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineJumpTableInfo.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/RegisterScavenging.h"
#include "llvm/CodeGen/TargetInstrInfo.h"
#include "llvm/CodeGen/TargetOpcodes.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/CallingConv.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/IR/Function.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCDwarf.h"
#include "llvm/MC/MCInstrDesc.h"
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <iterator>
#include <utility>
#include <vector>
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "arm-frame-lowering" |
Enumerations | |
enum class | SpillArea { GPRCS1 , GPRCS2 , DPRCS1 , DPRCS2 , GPRCS3 , FPCXT } |
Variables | |
static cl::opt< bool > | SpillAlignedNEONRegs ("align-neon-spills", cl::Hidden, cl::init(true), cl::desc("Align ARM NEON spills in prolog and epilog")) |
static const uint64_t | kSplitStackAvailable = 256 |
#define DEBUG_TYPE "arm-frame-lowering" |
Definition at line 163 of file ARMFrameLowering.cpp.
|
strong |
Enumerator | |
---|---|
GPRCS1 | |
GPRCS2 | |
DPRCS1 | |
DPRCS2 | |
GPRCS3 | |
FPCXT |
Definition at line 175 of file ARMFrameLowering.cpp.
Get the minimum constant for ARM that is greater than or equal to the argument.
In ARM, constants can have any value that can be produced by rotating an 8-bit value to the right by an even number of bits within a 32-bit word.
Definition at line 3102 of file ARMFrameLowering.cpp.
Referenced by llvm::ARMFrameLowering::adjustForSegmentedStacks().
|
static |
Definition at line 2393 of file ARMFrameLowering.cpp.
References contains(), llvm::TargetFrameLowering::getFrameIndexReference(), llvm::MachineFunction::getInfo(), llvm::MachineFunction::getSubtarget(), llvm::ARMFunctionInfo::isThumb1OnlyFunction(), MBB, and MI.
Referenced by llvm::ARMFrameLowering::determineCalleeSaves().
|
static |
Definition at line 2324 of file ARMFrameLowering.cpp.
References llvm::ARMBaseRegisterInfo::canRealignStack(), llvm::TargetSubtargetInfo::getFrameLowering(), llvm::MachineFunction::getFunction(), llvm::MachineFunction::getInfo(), llvm::TargetSubtargetInfo::getRegisterInfo(), llvm::TargetFrameLowering::getStackAlign(), llvm::MachineFunction::getSubtarget(), llvm::Function::hasFnAttribute(), llvm::BitVector::set(), SpillAlignedNEONRegs, and llvm::BitVector::test().
Referenced by llvm::ARMFrameLowering::determineCalleeSaves().
|
static |
Emit aligned reload instructions for NumAlignedDPRCS2Regs D-registers starting from d8.
These instructions are assumed to execute while the stack is still aligned, unlike the code inserted by emitPopInst.
Definition at line 2014 of file ARMFrameLowering.cpp.
References llvm::MachineInstrBuilder::add(), llvm::MachineInstrBuilder::addFrameIndex(), llvm::MachineInstrBuilder::addImm(), llvm::MachineInstrBuilder::addReg(), llvm::MachineInstr::addRegisterKilled(), llvm::ARMCC::AL, assert(), llvm::BuildMI(), llvm::condCodeOp(), llvm::RegState::Define, DL, llvm::MachineBasicBlock::end(), llvm::MachineFunction::getInfo(), llvm::TargetSubtargetInfo::getInstrInfo(), llvm::MachineBasicBlock::getParent(), llvm::MachineFunction::getSubtarget(), I, llvm::RegState::ImplicitDefine, isThumb(), llvm::ARMFunctionInfo::isThumb1OnlyFunction(), llvm::ARMFunctionInfo::isThumbFunction(), llvm::RegState::Kill, MBB, MI, llvm::predOps(), TII, and TRI.
Referenced by llvm::ARMFrameLowering::restoreCalleeSavedRegisters().
|
static |
Emit aligned spill instructions for NumAlignedDPRCS2Regs D-registers starting from d8.
Also insert stack realignment code and leave the stack pointer pointing to the d8 spill slot.
Definition at line 1841 of file ARMFrameLowering.cpp.
References llvm::MachineInstrBuilder::add(), llvm::MachineInstrBuilder::addImm(), llvm::MachineBasicBlock::addLiveIn(), llvm::MachineInstrBuilder::addReg(), llvm::MachineInstr::addRegisterKilled(), llvm::ARMCC::AL, assert(), llvm::BuildMI(), llvm::condCodeOp(), DL, emitAligningInstructions(), llvm::MachineBasicBlock::end(), llvm::MachineFunction::getFrameInfo(), llvm::MachineFunction::getInfo(), llvm::TargetSubtargetInfo::getInstrInfo(), llvm::MachineFrameInfo::getMaxAlign(), llvm::MachineBasicBlock::getParent(), llvm::MachineFunction::getSubtarget(), I, llvm::RegState::ImplicitKill, isThumb(), llvm::ARMFunctionInfo::isThumb1OnlyFunction(), llvm::ARMFunctionInfo::isThumbFunction(), llvm::RegState::Kill, MBB, MI, llvm::predOps(), llvm::MachineFrameInfo::setObjectAlignment(), llvm::ARMFunctionInfo::setShouldRestoreSPFromFP(), TII, and TRI.
Referenced by llvm::ARMFrameLowering::spillCalleeSavedRegisters().
|
static |
Emit an instruction sequence that will align the address in register Reg by zero-ing out the lower bits.
For versions of the architecture that support Neon, this must be done in a single instruction, since skipAlignedDPRCS2Spills assumes it is done in a single instruction. That function only gets called when optimizing spilling of D registers on a core with the Neon instruction set present.
Definition at line 799 of file ARMFrameLowering.cpp.
References llvm::MachineInstrBuilder::add(), llvm::MachineInstrBuilder::addImm(), llvm::MachineInstrBuilder::addReg(), llvm::ARMCC::AL, assert(), llvm::BuildMI(), llvm::condCodeOp(), DL, llvm::ARM_AM::getSORegOpc(), llvm::MachineFunction::getSubtarget(), llvm::ARMFunctionInfo::isThumb1OnlyFunction(), llvm::ARMFunctionInfo::isThumbFunction(), llvm::RegState::Kill, llvm::Log2(), llvm::ARM_AM::lsl, llvm::ARM_AM::lsr, MBB, MBBI, llvm::predOps(), TII, and llvm::Align::value().
Referenced by emitAlignedDPRCS2Spills(), and llvm::ARMFrameLowering::emitPrologue().
|
static |
Definition at line 671 of file ARMFrameLowering.cpp.
References llvm::emitARMRegPlusImmediate(), llvm::emitT2RegPlusImmediate(), MBB, MBBI, and TII.
Referenced by llvm::ARMFrameLowering::emitPrologue(), and emitSPUpdate().
|
static |
Definition at line 684 of file ARMFrameLowering.cpp.
References emitRegPlusImmediate(), MBB, MBBI, and TII.
Referenced by llvm::ARMFrameLowering::emitEpilogue(), and llvm::ARMFrameLowering::emitPrologue().
|
static |
Definition at line 2221 of file ARMFrameLowering.cpp.
References llvm::MachineFunction::getConstantPool(), llvm::MachineConstantPool::getConstants(), llvm::MachineFunction::getJumpTableInfo(), llvm::MachineJumpTableInfo::getJumpTables(), MBB, MI, and TII.
Referenced by llvm::ARMFrameLowering::determineCalleeSaves(), and llvm::CSKYFrameLowering::determineCalleeSaves().
|
static |
estimateRSStackSizeLimit - Look at each instruction that references stack frames and return the stack size limit beyond which some of these instructions will require a scratch register during their expansion later.
Definition at line 2239 of file ARMFrameLowering.cpp.
References llvm::ARMII::AddrMode2, llvm::ARMII::AddrMode3, llvm::ARMII::AddrMode4, llvm::ARMII::AddrMode5, llvm::ARMII::AddrMode5FP16, llvm::ARMII::AddrMode6, llvm::ARMII::AddrMode_i12, llvm::ARMII::AddrModeMask, llvm::ARMII::AddrModeT2_i12, llvm::ARMII::AddrModeT2_i7, llvm::ARMII::AddrModeT2_i7s2, llvm::ARMII::AddrModeT2_i7s4, llvm::ARMII::AddrModeT2_i8neg, llvm::ARMII::AddrModeT2_i8s4, llvm::ARMII::AddrModeT2_ldrex, llvm::TargetRegisterClass::contains(), llvm::MachineFunction::getInfo(), llvm::TargetSubtargetInfo::getInstrInfo(), llvm::TargetSubtargetInfo::getRegisterInfo(), llvm::MachineFunction::getSubtarget(), llvm::TargetFrameLowering::hasFP(), llvm::ARMFunctionInfo::hasStackFrame(), llvm_unreachable, MBB, MI, TII, and TRI.
|
static |
Definition at line 388 of file ARMFrameLowering.cpp.
References llvm::MachineBasicBlock::end(), llvm::ARMFunctionInfo::getArgumentStackToRestore(), llvm::MachineOperand::getImm(), llvm::MachineFunction::getInfo(), llvm::MachineBasicBlock::getLastNonDebugInstr(), MBB, and MBBI.
|
static |
We need the offset of the frame pointer relative to other MachineFrameInfo offsets which are encoded relative to SP at function begin.
See also emitPrologue() for how the FP is set up. Unfortunately we cannot determine this value in determineCalleeSaves() yet as assignCalleeSavedSpillSlots() hasn't run at this point. Instead we use this to produce a conservative estimate that we check in an assert() later.
Definition at line 865 of file ARMFrameLowering.cpp.
References llvm::ARMFunctionInfo::getArgRegsSaveSize(), llvm::ARMSubtarget::getPushPopSplitVariation(), llvm::ARMFunctionInfo::isCmseNSEntryFunction(), llvm::ARMFunctionInfo::isThumb1OnlyFunction(), llvm::ARMSubtarget::SplitR11AAPCSSignRA, and llvm::ARMSubtarget::SplitR11WindowsSEH.
Referenced by llvm::ARMFrameLowering::determineCalleeSaves(), and llvm::ARMFrameLowering::emitPrologue().
SpillArea getSpillArea | ( | Register | Reg, |
ARMSubtarget::PushPopSplitVariation | Variation, | ||
unsigned | NumAlignedDPRCS2Regs, | ||
const ARMBaseRegisterInfo * | RegInfo | ||
) |
Get the spill area that Reg should be saved into in the prologue.
Definition at line 185 of file ARMFrameLowering.cpp.
References llvm::ARM::D16, llvm::dbgs(), DPRCS1, DPRCS2, FPCXT, GPRCS1, GPRCS2, GPRCS3, llvm_unreachable, llvm::printReg(), llvm::ARMSubtarget::SplitR11AAPCSSignRA, llvm::ARMSubtarget::SplitR11WindowsSEH, and llvm::ARMSubtarget::SplitR7.
Referenced by llvm::ARMFrameLowering::emitPrologue(), llvm::ARMFrameLowering::restoreCalleeSavedRegisters(), and llvm::ARMFrameLowering::spillCalleeSavedRegisters().
|
static |
Definition at line 641 of file ARMFrameLowering.cpp.
References llvm::MachineBasicBlock::begin(), MBB, and MBBI.
Referenced by llvm::ARMFrameLowering::emitEpilogue().
|
static |
Definition at line 427 of file ARMFrameLowering.cpp.
References llvm::MachineInstrBuilder::add(), llvm::MachineInstrBuilder::addImm(), llvm::BuildMI(), DL, llvm::drop_begin(), llvm::MachineBasicBlock::erase(), llvm::First, llvm::MachineInstr::FrameDestroy, llvm::MachineInstr::FrameSetup, llvm::MachineBasicBlock::getParent(), llvm::MachineOperand::getReg(), llvm::ARMSubtarget::getRegisterInfo(), llvm::MachineFunction::getSubtarget(), llvm::MachineBasicBlock::insertAfter(), llvm::MachineOperand::isImplicit(), llvm::MachineOperand::isReg(), llvm::Last, llvm_unreachable, MBB, MBBI, llvm::MachineInstr::NoMerge, llvm::report_fatal_error(), llvm::MachineInstrBuilder::setMIFlags(), llvm::t1CondCodeOp(), and TII.
Referenced by insertSEHRange().
|
static |
Definition at line 647 of file ARMFrameLowering.cpp.
References llvm::MachineBasicBlock::begin(), End, insertSEH(), llvm::isSEHInstruction(), MBB, MI, and TII.
Referenced by llvm::ARMFrameLowering::emitEpilogue(), and llvm::ARMFrameLowering::emitPrologue().
|
static |
Definition at line 419 of file ARMFrameLowering.cpp.
References F, llvm::MachineFunction::getFunction(), llvm::TargetMachine::getMCAsmInfo(), llvm::MachineFunction::getTarget(), and llvm::MCAsmInfo::usesWindowsCFI().
|
static |
Definition at line 694 of file ARMFrameLowering.cpp.
References llvm::count(), llvm_unreachable, MI, and RegSize.
Referenced by llvm::ARMFrameLowering::emitPrologue().
|
static |
Skip past the code inserted by emitAlignedDPRCS2Spills, and return an iterator to the following instruction.
Definition at line 1984 of file ARMFrameLowering.cpp.
Referenced by llvm::ARMFrameLowering::emitPrologue().
|
static |
Definition at line 719 of file ARMFrameLowering.cpp.
References F, llvm::MachineFunction::getFrameInfo(), llvm::MachineFunction::getFunction(), and llvm::MachineFrameInfo::getStackProtectorIndex().
Referenced by llvm::ARMFrameLowering::determineCalleeSaves(), and llvm::ARMFrameLowering::emitPrologue().
Definition at line 3129 of file ARMFrameLowering.cpp.
Referenced by llvm::ARMFrameLowering::adjustForSegmentedStacks(), and llvm::X86FrameLowering::adjustForSegmentedStacks().
|
static |
Referenced by checkNumAlignedDPRCS2Regs().