X86MachineFunctionInfo.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. #include "X86MachineFunctionInfo.h"
  9. #include "X86RegisterInfo.h"
  10. #include "llvm/CodeGen/MachineRegisterInfo.h"
  11. #include "llvm/CodeGen/TargetSubtargetInfo.h"
  12. using namespace llvm;
  13. MachineFunctionInfo *X86MachineFunctionInfo::clone(
  14. BumpPtrAllocator &Allocator, MachineFunction &DestMF,
  15. const DenseMap<MachineBasicBlock *, MachineBasicBlock *> &Src2DstMBB)
  16. const {
  17. return DestMF.cloneInfo<X86MachineFunctionInfo>(*this);
  18. }
  19. void X86MachineFunctionInfo::anchor() { }
  20. void X86MachineFunctionInfo::setRestoreBasePointer(const MachineFunction *MF) {
  21. if (!RestoreBasePointerOffset) {
  22. const X86RegisterInfo *RegInfo = static_cast<const X86RegisterInfo *>(
  23. MF->getSubtarget().getRegisterInfo());
  24. unsigned SlotSize = RegInfo->getSlotSize();
  25. for (const MCPhysReg *CSR = MF->getRegInfo().getCalleeSavedRegs();
  26. unsigned Reg = *CSR; ++CSR) {
  27. if (X86::GR64RegClass.contains(Reg) || X86::GR32RegClass.contains(Reg))
  28. RestoreBasePointerOffset -= SlotSize;
  29. }
  30. }
  31. }