LLVM  3.7.0
WebAssemblyRegisterInfo.cpp
Go to the documentation of this file.
1 //===-- WebAssemblyRegisterInfo.cpp - WebAssembly Register Information ----===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// \file
11 /// \brief This file contains the WebAssembly implementation of the
12 /// TargetRegisterInfo class.
13 ///
14 //===----------------------------------------------------------------------===//
15 
19 #include "WebAssemblyInstrInfo.h"
21 #include "WebAssemblySubtarget.h"
25 #include "llvm/IR/Function.h"
29 using namespace llvm;
30 
31 #define DEBUG_TYPE "wasm-reg-info"
32 
33 #define GET_REGINFO_TARGET_DESC
34 #include "WebAssemblyGenRegisterInfo.inc"
35 
37  : WebAssemblyGenRegisterInfo(0), TT(TT) {}
38 
39 const MCPhysReg *
41  static const MCPhysReg CalleeSavedRegs[] = {0};
42  return CalleeSavedRegs;
43 }
44 
47  BitVector Reserved(getNumRegs());
48  for (auto Reg : {WebAssembly::SP32, WebAssembly::SP64, WebAssembly::FP32,
49  WebAssembly::FP64})
50  Reserved.set(Reg);
51  return Reserved;
52 }
53 
55  MachineBasicBlock::iterator II, int SPAdj, unsigned FIOperandNum,
56  RegScavenger *RS) const {
57  llvm_unreachable("WebAssemblyRegisterInfo::eliminateFrameIndex"); // FIXME
58 }
59 
60 unsigned
62  static const unsigned Regs[2][2] = {
63  /* !isArch64Bit isArch64Bit */
64  /* !hasFP */ {WebAssembly::SP32, WebAssembly::SP64},
65  /* hasFP */ {WebAssembly::FP32, WebAssembly::FP64}};
66  const WebAssemblyFrameLowering *TFI = getFrameLowering(MF);
67  return Regs[TFI->hasFP(MF)][TT.isArch64Bit()];
68 }
69 
71  return !MF.getFunction()->hasFnAttribute("no-realign-stack");
72 }
73 
74 // FIXME: share this with other backends with identical implementation?
76  const MachineFunction &MF) const {
77  const MachineFrameInfo *MFI = MF.getFrameInfo();
78  const WebAssemblyFrameLowering *TFI = getFrameLowering(MF);
79  const Function *F = MF.getFunction();
80  unsigned StackAlign = TFI->getStackAlignment();
81  bool requiresRealignment =
82  ((MFI->getMaxAlignment() > StackAlign) ||
85 
86  return requiresRealignment && canRealignStack(MF);
87 }
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
BitVector & set()
Definition: BitVector.h:218
Alignment of stack for function (3 bits) stored as log2 of alignment with +1 bias 0 means unaligned (...
Definition: Attributes.h:106
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
F(f)
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
bool hasFP(const MachineFunction &MF) const override
Return true if the specified function should have a dedicated frame pointer register.
bool hasAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return true if the attribute exists at the given index.
Definition: Attributes.cpp:956
void eliminateFrameIndex(MachineBasicBlock::iterator MI, int SPAdj, unsigned FIOperandNum, RegScavenger *RS=nullptr) const override
unsigned getMaxAlignment() const
Return the alignment in bytes that this function must be aligned to, which is greater than the defaul...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:98
Reg
All possible values of the reg field in the ModR/M byte.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
bool isArch64Bit() const
Test whether the architecture is 64-bit.
Definition: Triple.cpp:1046
BitVector getReservedRegs(const MachineFunction &MF) const override
bundle_iterator< MachineInstr, instr_iterator > iterator
const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const override
This file provides WebAssembly-specific target descriptions.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
This file contains the WebAssembly implementation of the WebAssemblyRegisterInfo class.
This file declares the WebAssembly-specific subclass of TargetSubtarget.
This file contains the WebAssembly implementation of the TargetInstrInfo class.
MachineFrameInfo * getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
unsigned getFrameRegister(const MachineFunction &MF) const override
AttributeSet getAttributes() const
Return the attribute list for this Function.
Definition: Function.h:181
This class implements WebAssembly-specific bits of TargetFrameLowering class.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
Definition: Function.h:217
This file declares WebAssembly-specific per-machine-function information.
bool needsStackRealignment(const MachineFunction &MF) const override
bool canRealignStack(const MachineFunction &MF) const