1//===-- X86MachineFunctionInfo.cpp - X86 machine function info ------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "X86MachineFunctionInfo.h"
10#include "X86RegisterInfo.h"
11#include "llvm/CodeGen/MachineRegisterInfo.h"
12#include "llvm/CodeGen/TargetSubtargetInfo.h"
13
14using namespace llvm;
15
16yaml::X86MachineFunctionInfo::X86MachineFunctionInfo(
17 const llvm::X86MachineFunctionInfo &MFI)
18 : AMXProgModel(MFI.getAMXProgModel()) {}
19
20void yaml::X86MachineFunctionInfo::mappingImpl(yaml::IO &YamlIO) {
21 MappingTraits<X86MachineFunctionInfo>::mapping(YamlIO, MFI&: *this);
22}
23
24MachineFunctionInfo *X86MachineFunctionInfo::clone(
25 BumpPtrAllocator &Allocator, MachineFunction &DestMF,
26 const DenseMap<MachineBasicBlock *, MachineBasicBlock *> &Src2DstMBB)
27 const {
28 return DestMF.cloneInfo<X86MachineFunctionInfo>(Old: *this);
29}
30
31void X86MachineFunctionInfo::initializeBaseYamlFields(
32 const yaml::X86MachineFunctionInfo &YamlMFI) {
33 AMXProgModel = YamlMFI.AMXProgModel;
34}
35
36void X86MachineFunctionInfo::anchor() { }
37
38void X86MachineFunctionInfo::setRestoreBasePointer(const MachineFunction *MF) {
39 if (!RestoreBasePointerOffset) {
40 const X86RegisterInfo *RegInfo = static_cast<const X86RegisterInfo *>(
41 MF->getSubtarget().getRegisterInfo());
42 unsigned SlotSize = RegInfo->getSlotSize();
43 for (const MCPhysReg *CSR = MF->getRegInfo().getCalleeSavedRegs();
44 unsigned Reg = *CSR; ++CSR) {
45 if (X86::GR64RegClass.contains(Reg) || X86::GR32RegClass.contains(Reg))
46 RestoreBasePointerOffset -= SlotSize;
47 }
48 }
49}
50
51