1 //===-- WebAssemblyRegisterInfo.cpp - WebAssembly Register Information ----===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// \brief This file contains the WebAssembly implementation of the
12 /// TargetRegisterInfo class.
14 //===----------------------------------------------------------------------===//
16 #include "WebAssemblyRegisterInfo.h"
17 #include "MCTargetDesc/WebAssemblyMCTargetDesc.h"
18 #include "WebAssemblyFrameLowering.h"
19 #include "WebAssemblyInstrInfo.h"
20 #include "WebAssemblyMachineFunctionInfo.h"
21 #include "WebAssemblySubtarget.h"
22 #include "llvm/CodeGen/MachineFrameInfo.h"
23 #include "llvm/CodeGen/MachineInstrBuilder.h"
24 #include "llvm/CodeGen/MachineRegisterInfo.h"
25 #include "llvm/IR/Function.h"
26 #include "llvm/Support/raw_ostream.h"
27 #include "llvm/Target/TargetFrameLowering.h"
28 #include "llvm/Target/TargetOptions.h"
31 #define DEBUG_TYPE "wasm-reg-info"
33 #define GET_REGINFO_TARGET_DESC
34 #include "WebAssemblyGenRegisterInfo.inc"
36 WebAssemblyRegisterInfo::WebAssemblyRegisterInfo(const Triple &TT)
37 : WebAssemblyGenRegisterInfo(0), TT(TT) {}
40 WebAssemblyRegisterInfo::getCalleeSavedRegs(const MachineFunction *) const {
41 static const MCPhysReg CalleeSavedRegs[] = {0};
42 return CalleeSavedRegs;
46 WebAssemblyRegisterInfo::getReservedRegs(const MachineFunction &MF) const {
47 BitVector Reserved(getNumRegs());
48 for (auto Reg : {WebAssembly::SP32, WebAssembly::SP64, WebAssembly::FP32,
54 void WebAssemblyRegisterInfo::eliminateFrameIndex(
55 MachineBasicBlock::iterator II, int SPAdj, unsigned FIOperandNum,
56 RegScavenger *RS) const {
57 llvm_unreachable("WebAssemblyRegisterInfo::eliminateFrameIndex"); // FIXME
61 WebAssemblyRegisterInfo::getFrameRegister(const MachineFunction &MF) const {
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()];