LLVM  8.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();
59  return MipsABIInfo::N32();
60  assert(Options.getABIName().empty() && "Unknown ABI option for MIPS");
61 
62  if (TT.isMIPS64())
63  return MipsABIInfo::N64();
64  return MipsABIInfo::O32();
65 }
66 
67 unsigned MipsABIInfo::GetStackPtr() const {
68  return ArePtrs64bit() ? Mips::SP_64 : Mips::SP;
69 }
70 
71 unsigned MipsABIInfo::GetFramePtr() const {
72  return ArePtrs64bit() ? Mips::FP_64 : Mips::FP;
73 }
74 
75 unsigned MipsABIInfo::GetBasePtr() const {
76  return ArePtrs64bit() ? Mips::S7_64 : Mips::S7;
77 }
78 
79 unsigned MipsABIInfo::GetGlobalPtr() const {
80  return ArePtrs64bit() ? Mips::GP_64 : Mips::GP;
81 }
82 
83 unsigned MipsABIInfo::GetNullPtr() const {
84  return ArePtrs64bit() ? Mips::ZERO_64 : Mips::ZERO;
85 }
86 
87 unsigned MipsABIInfo::GetZeroReg() const {
88  return AreGprs64bit() ? Mips::ZERO_64 : Mips::ZERO;
89 }
90 
91 unsigned MipsABIInfo::GetPtrAdduOp() const {
92  return ArePtrs64bit() ? Mips::DADDu : Mips::ADDu;
93 }
94 
95 unsigned MipsABIInfo::GetPtrAddiuOp() const {
96  return ArePtrs64bit() ? Mips::DADDiu : Mips::ADDiu;
97 }
98 
99 unsigned MipsABIInfo::GetPtrSubuOp() const {
100  return ArePtrs64bit() ? Mips::DSUBu : Mips::SUBu;
101 }
102 
103 unsigned MipsABIInfo::GetPtrAndOp() const {
104  return ArePtrs64bit() ? Mips::AND64 : Mips::AND;
105 }
106 
107 unsigned MipsABIInfo::GetGPRMoveOp() const {
108  return ArePtrs64bit() ? Mips::OR64 : Mips::OR;
109 }
110 
111 unsigned MipsABIInfo::GetEhDataReg(unsigned I) const {
112  static const unsigned EhDataReg[] = {
113  Mips::A0, Mips::A1, Mips::A2, Mips::A3
114  };
115  static const unsigned EhDataReg64[] = {
116  Mips::A0_64, Mips::A1_64, Mips::A2_64, Mips::A3_64
117  };
118 
119  return IsN64() ? EhDataReg64[I] : EhDataReg[I];
120 }
121 
unsigned GetPtrAdduOp() const
Definition: MipsABIInfo.cpp:91
bool isMIPS64() const
Tests whether the target is MIPS 64-bit (little and big endian).
Definition: Triple.h:670
Fast - This calling convention attempts to make calls as fast as possible (e.g.
Definition: CallingConv.h:43
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:79
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
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:95
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
EnvironmentType getEnvironment() const
getEnvironment - Get the parsed environment type of this triple.
Definition: Triple.h:304
unsigned GetPtrSubuOp() const
Definition: MipsABIInfo.cpp:99
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:75
#define I(x, y, z)
Definition: MD5.cpp:58
unsigned GetZeroReg() const
Definition: MipsABIInfo.cpp:87
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:67
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
unsigned GetNullPtr() const
Definition: MipsABIInfo.cpp:83
static MipsABIInfo N64()
Definition: MipsABIInfo.h:37
unsigned GetFramePtr() const
Definition: MipsABIInfo.cpp:71