LLVM  7.0.0svn
MipsABIInfo.cpp
Go to the documentation of this file.
1 //===---- MipsABIInfo.cpp - Information about MIPS ABI's ------------------===//
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 #include "MipsABIInfo.h"
11 #include "MipsRegisterInfo.h"
12 #include "llvm/ADT/StringRef.h"
13 #include "llvm/ADT/StringSwitch.h"
15 
16 using namespace llvm;
17 
18 namespace {
19 static const MCPhysReg O32IntRegs[4] = {Mips::A0, Mips::A1, Mips::A2, Mips::A3};
20 
21 static const MCPhysReg Mips64IntRegs[8] = {
22  Mips::A0_64, Mips::A1_64, Mips::A2_64, Mips::A3_64,
23  Mips::T0_64, Mips::T1_64, Mips::T2_64, Mips::T3_64};
24 }
25 
27  if (IsO32())
28  return makeArrayRef(O32IntRegs);
29  if (IsN32() || IsN64())
30  return makeArrayRef(Mips64IntRegs);
31  llvm_unreachable("Unhandled ABI");
32 }
33 
35  if (IsO32())
36  return makeArrayRef(O32IntRegs);
37  if (IsN32() || IsN64())
38  return makeArrayRef(Mips64IntRegs);
39  llvm_unreachable("Unhandled ABI");
40 }
41 
43  if (IsO32())
44  return CC != CallingConv::Fast ? 16 : 0;
45  if (IsN32() || IsN64())
46  return 0;
47  llvm_unreachable("Unhandled ABI");
48 }
49 
51  const MCTargetOptions &Options) {
52  if (Options.getABIName().startswith("o32"))
53  return MipsABIInfo::O32();
54  if (Options.getABIName().startswith("n32"))
55  return MipsABIInfo::N32();
56  if (Options.getABIName().startswith("n64"))
57  return MipsABIInfo::N64();
58  assert(Options.getABIName().empty() && "Unknown ABI option for MIPS");
59 
60  if (TT.getArch() == Triple::mips64 || TT.getArch() == Triple::mips64el)
61  return MipsABIInfo::N64();
62  return MipsABIInfo::O32();
63 }
64 
65 unsigned MipsABIInfo::GetStackPtr() const {
66  return ArePtrs64bit() ? Mips::SP_64 : Mips::SP;
67 }
68 
69 unsigned MipsABIInfo::GetFramePtr() const {
70  return ArePtrs64bit() ? Mips::FP_64 : Mips::FP;
71 }
72 
73 unsigned MipsABIInfo::GetBasePtr() const {
74  return ArePtrs64bit() ? Mips::S7_64 : Mips::S7;
75 }
76 
77 unsigned MipsABIInfo::GetGlobalPtr() const {
78  return ArePtrs64bit() ? Mips::GP_64 : Mips::GP;
79 }
80 
81 unsigned MipsABIInfo::GetNullPtr() const {
82  return ArePtrs64bit() ? Mips::ZERO_64 : Mips::ZERO;
83 }
84 
85 unsigned MipsABIInfo::GetZeroReg() const {
86  return AreGprs64bit() ? Mips::ZERO_64 : Mips::ZERO;
87 }
88 
89 unsigned MipsABIInfo::GetPtrAdduOp() const {
90  return ArePtrs64bit() ? Mips::DADDu : Mips::ADDu;
91 }
92 
93 unsigned MipsABIInfo::GetPtrAddiuOp() const {
94  return ArePtrs64bit() ? Mips::DADDiu : Mips::ADDiu;
95 }
96 
97 unsigned MipsABIInfo::GetPtrSubuOp() const {
98  return ArePtrs64bit() ? Mips::DSUBu : Mips::SUBu;
99 }
100 
101 unsigned MipsABIInfo::GetPtrAndOp() const {
102  return ArePtrs64bit() ? Mips::AND64 : Mips::AND;
103 }
104 
105 unsigned MipsABIInfo::GetGPRMoveOp() const {
106  return ArePtrs64bit() ? Mips::OR64 : Mips::OR;
107 }
108 
109 unsigned MipsABIInfo::GetEhDataReg(unsigned I) const {
110  static const unsigned EhDataReg[] = {
111  Mips::A0, Mips::A1, Mips::A2, Mips::A3
112  };
113  static const unsigned EhDataReg64[] = {
114  Mips::A0_64, Mips::A1_64, Mips::A2_64, Mips::A3_64
115  };
116 
117  return IsN64() ? EhDataReg64[I] : EhDataReg[I];
118 }
119 
unsigned GetPtrAdduOp() const
Definition: MipsABIInfo.cpp:89
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
bool ArePtrs64bit() const
Definition: MipsABIInfo.h:75
unsigned GetEhDataReg(unsigned I) const
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:451
unsigned GetCalleeAllocdArgSizeInBytes(CallingConv::ID CC) const
Obtain the size of the area allocated by the callee for arguments.
Definition: MipsABIInfo.cpp:42
bool IsN32() const
Definition: MipsABIInfo.h:43
unsigned GetGlobalPtr() const
Definition: MipsABIInfo.cpp:77
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
Definition: StringRef.h:267
bool IsN64() const
Definition: MipsABIInfo.h:44
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
Definition: Triple.h:283
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:133
ArrayRef< MCPhysReg > GetByValArgRegs() const
The registers to use for byval arguments.
Definition: MipsABIInfo.cpp:26
unsigned GetPtrAndOp() const
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
unsigned GetPtrAddiuOp() const
Definition: MipsABIInfo.cpp:93
static MipsABIInfo O32()
Definition: MipsABIInfo.h:35
static ManagedStatic< OptionRegistry > OR
Definition: Options.cpp:31
bool IsO32() const
Definition: MipsABIInfo.h:42
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
bool AreGprs64bit() const
Definition: MipsABIInfo.h:76
unsigned GetPtrSubuOp() const
Definition: MipsABIInfo.cpp:97
Fast - This calling convention attempts to make calls as fast as possible (e.g.
Definition: CallingConv.h:43
ArrayRef< MCPhysReg > GetVarArgRegs() const
The registers to use for the variable argument list.
Definition: MipsABIInfo.cpp:34
StringRef getABIName() const
getABIName - If this returns a non-empty string this represents the textual name of the ABI that we w...
Bitwise operators - logical and, logical or, logical xor.
Definition: ISDOpcodes.h:363
unsigned GetBasePtr() const
Definition: MipsABIInfo.cpp:73
#define I(x, y, z)
Definition: MD5.cpp:58
unsigned GetZeroReg() const
Definition: MipsABIInfo.cpp:85
unsigned GetGPRMoveOp() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static MipsABIInfo computeTargetABI(const Triple &TT, StringRef CPU, const MCTargetOptions &Options)
Definition: MipsABIInfo.cpp:50
static MipsABIInfo N32()
Definition: MipsABIInfo.h:36
unsigned GetStackPtr() const
Definition: MipsABIInfo.cpp:65
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
unsigned GetNullPtr() const
Definition: MipsABIInfo.cpp:81
static MipsABIInfo N64()
Definition: MipsABIInfo.h:37
unsigned GetFramePtr() const
Definition: MipsABIInfo.cpp:69