mirror of
https://github.com/RPCS3/llvm.git
synced 2025-05-23 05:46:05 +00:00

Each Calling convention (CC) defines a static list of registers that should be preserved by a callee function. All other registers should be saved by the caller. Some CCs use additional condition: If the register is used for passing/returning arguments – the caller needs to save it - even if it is part of the Callee Saved Registers (CSR) list. The current LLVM implementation doesn’t support it. It will save a register if it is part of the static CSR list and will not care if the register is passed/returned by the callee. The solution is to dynamically allocate the CSR lists (Only for these CCs). The lists will be updated with actual registers that should be saved by the callee. Since we need the allocated lists to live as long as the function exists, the list should reside inside the Machine Register Info (MRI) which is a property of the Machine Function and managed by it (and has the same life span). The lists should be saved in the MRI and populated upon LowerCall and LowerFormalArguments. The patch will also assist to implement future no_caller_saved_regsiters attribute intended for interrupt handler CC. Differential Revision: https://reviews.llvm.org/D28566 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297715 91177308-0d34-0410-b5e6-96231b3b80d8
32 lines
1.1 KiB
C++
32 lines
1.1 KiB
C++
//===-- X86MachineFunctionInfo.cpp - X86 machine function info ------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "X86MachineFunctionInfo.h"
|
|
#include "X86RegisterInfo.h"
|
|
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
|
#include "llvm/Target/TargetSubtargetInfo.h"
|
|
|
|
using namespace llvm;
|
|
|
|
void X86MachineFunctionInfo::anchor() { }
|
|
|
|
void X86MachineFunctionInfo::setRestoreBasePointer(const MachineFunction *MF) {
|
|
if (!RestoreBasePointerOffset) {
|
|
const X86RegisterInfo *RegInfo = static_cast<const X86RegisterInfo *>(
|
|
MF->getSubtarget().getRegisterInfo());
|
|
unsigned SlotSize = RegInfo->getSlotSize();
|
|
for (const MCPhysReg *CSR = MF->getRegInfo().getCalleeSavedRegs();
|
|
unsigned Reg = *CSR; ++CSR) {
|
|
if (X86::GR64RegClass.contains(Reg) || X86::GR32RegClass.contains(Reg))
|
|
RestoreBasePointerOffset -= SlotSize;
|
|
}
|
|
}
|
|
}
|
|
|