mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 04:40:38 +00:00
MachineFunction: Slight refactoring; NFC
Slight cleanup/refactor in preparation for upcoming commit. llvm-svn: 320882
This commit is contained in:
parent
8ea9ca15b9
commit
79f7444667
@ -223,7 +223,7 @@ struct LandingPadInfo {
|
||||
};
|
||||
|
||||
class MachineFunction {
|
||||
const Function *Fn;
|
||||
const Function &F;
|
||||
const TargetMachine &Target;
|
||||
const TargetSubtargetInfo *STI;
|
||||
MCContext &Ctx;
|
||||
@ -359,8 +359,9 @@ public:
|
||||
using VariableDbgInfoMapTy = SmallVector<VariableDbgInfo, 4>;
|
||||
VariableDbgInfoMapTy VariableDbgInfos;
|
||||
|
||||
MachineFunction(const Function *Fn, const TargetMachine &TM,
|
||||
unsigned FunctionNum, MachineModuleInfo &MMI);
|
||||
MachineFunction(const Function &F, const TargetMachine &TM,
|
||||
const TargetSubtargetInfo &STI, unsigned FunctionNum,
|
||||
MachineModuleInfo &MMI);
|
||||
MachineFunction(const MachineFunction &) = delete;
|
||||
MachineFunction &operator=(const MachineFunction &) = delete;
|
||||
~MachineFunction();
|
||||
@ -380,7 +381,7 @@ public:
|
||||
const DataLayout &getDataLayout() const;
|
||||
|
||||
/// getFunction - Return the LLVM function that this machine code represents
|
||||
const Function *getFunction() const { return Fn; }
|
||||
const Function *getFunction() const { return &F; }
|
||||
|
||||
/// getName - Return the name of the corresponding LLVM function.
|
||||
StringRef getName() const;
|
||||
|
@ -119,16 +119,16 @@ void ilist_alloc_traits<MachineBasicBlock>::deleteNode(MachineBasicBlock *MBB) {
|
||||
}
|
||||
|
||||
static inline unsigned getFnStackAlignment(const TargetSubtargetInfo *STI,
|
||||
const Function *Fn) {
|
||||
if (Fn->hasFnAttribute(Attribute::StackAlignment))
|
||||
return Fn->getFnStackAlignment();
|
||||
const Function &F) {
|
||||
if (F.hasFnAttribute(Attribute::StackAlignment))
|
||||
return F.getFnStackAlignment();
|
||||
return STI->getFrameLowering()->getStackAlignment();
|
||||
}
|
||||
|
||||
MachineFunction::MachineFunction(const Function *F, const TargetMachine &TM,
|
||||
MachineFunction::MachineFunction(const Function &F, const TargetMachine &Target,
|
||||
const TargetSubtargetInfo &STI,
|
||||
unsigned FunctionNum, MachineModuleInfo &mmi)
|
||||
: Fn(F), Target(TM), STI(TM.getSubtargetImpl(*F)), Ctx(mmi.getContext()),
|
||||
MMI(mmi) {
|
||||
: F(F), Target(Target), STI(&STI), Ctx(mmi.getContext()), MMI(mmi) {
|
||||
FunctionNumber = FunctionNum;
|
||||
init();
|
||||
}
|
||||
@ -146,21 +146,21 @@ void MachineFunction::init() {
|
||||
// We can realign the stack if the target supports it and the user hasn't
|
||||
// explicitly asked us not to.
|
||||
bool CanRealignSP = STI->getFrameLowering()->isStackRealignable() &&
|
||||
!Fn->hasFnAttribute("no-realign-stack");
|
||||
!F.hasFnAttribute("no-realign-stack");
|
||||
FrameInfo = new (Allocator) MachineFrameInfo(
|
||||
getFnStackAlignment(STI, Fn), /*StackRealignable=*/CanRealignSP,
|
||||
getFnStackAlignment(STI, F), /*StackRealignable=*/CanRealignSP,
|
||||
/*ForceRealign=*/CanRealignSP &&
|
||||
Fn->hasFnAttribute(Attribute::StackAlignment));
|
||||
F.hasFnAttribute(Attribute::StackAlignment));
|
||||
|
||||
if (Fn->hasFnAttribute(Attribute::StackAlignment))
|
||||
FrameInfo->ensureMaxAlignment(Fn->getFnStackAlignment());
|
||||
if (F.hasFnAttribute(Attribute::StackAlignment))
|
||||
FrameInfo->ensureMaxAlignment(F.getFnStackAlignment());
|
||||
|
||||
ConstantPool = new (Allocator) MachineConstantPool(getDataLayout());
|
||||
Alignment = STI->getTargetLowering()->getMinFunctionAlignment();
|
||||
|
||||
// FIXME: Shouldn't use pref alignment if explicit alignment is set on Fn.
|
||||
// FIXME: Shouldn't use pref alignment if explicit alignment is set on F.
|
||||
// FIXME: Use Function::optForSize().
|
||||
if (!Fn->hasFnAttribute(Attribute::OptimizeForSize))
|
||||
if (!F.hasFnAttribute(Attribute::OptimizeForSize))
|
||||
Alignment = std::max(Alignment,
|
||||
STI->getTargetLowering()->getPrefFunctionAlignment());
|
||||
|
||||
@ -170,7 +170,7 @@ void MachineFunction::init() {
|
||||
JumpTableInfo = nullptr;
|
||||
|
||||
if (isFuncletEHPersonality(classifyEHPersonality(
|
||||
Fn->hasPersonalityFn() ? Fn->getPersonalityFn() : nullptr))) {
|
||||
F.hasPersonalityFn() ? F.getPersonalityFn() : nullptr))) {
|
||||
WinEHInfo = new (Allocator) WinEHFuncInfo();
|
||||
}
|
||||
|
||||
@ -228,7 +228,7 @@ void MachineFunction::clear() {
|
||||
}
|
||||
|
||||
const DataLayout &MachineFunction::getDataLayout() const {
|
||||
return Fn->getParent()->getDataLayout();
|
||||
return F.getParent()->getDataLayout();
|
||||
}
|
||||
|
||||
/// Get the JumpTableInfo for this function.
|
||||
|
@ -276,7 +276,8 @@ MachineModuleInfo::getOrCreateMachineFunction(const Function &F) {
|
||||
MachineFunction *MF;
|
||||
if (I.second) {
|
||||
// No pre-existing machine function, create a new one.
|
||||
MF = new MachineFunction(&F, TM, NextFnNum++, *this);
|
||||
const TargetSubtargetInfo &STI = *TM.getSubtargetImpl(F);
|
||||
MF = new MachineFunction(F, TM, STI, NextFnNum++, *this);
|
||||
// Update the set entry.
|
||||
I.first->second.reset(MF);
|
||||
} else {
|
||||
|
@ -91,8 +91,9 @@ std::unique_ptr<MachineFunction> createMachineFunction() {
|
||||
auto TM = createTargetMachine();
|
||||
unsigned FunctionNum = 42;
|
||||
MachineModuleInfo MMI(TM.get());
|
||||
const TargetSubtargetInfo &STI = *TM->getSubtargetImpl(*F);
|
||||
|
||||
return llvm::make_unique<MachineFunction>(F, *TM, FunctionNum, MMI);
|
||||
return llvm::make_unique<MachineFunction>(*F, *TM, STI, FunctionNum, MMI);
|
||||
}
|
||||
|
||||
// This test makes sure that MachineInstr::isIdenticalTo handles Defs correctly
|
||||
|
Loading…
Reference in New Issue
Block a user