LLVM 24.0.0git
MipsABIInfo.h
Go to the documentation of this file.
1//===---- MipsABIInfo.h - Information about MIPS ABI's --------------------===//
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
9#ifndef LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSABIINFO_H
10#define LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSABIINFO_H
11
12#include "llvm/IR/CallingConv.h"
15
16namespace llvm {
17
18template <typename T> class ArrayRef;
19class StringRef;
20
22public:
23 enum class ABI { Unknown, O32, N32, N64, P32 };
24
25protected:
27
28public:
30
32 static MipsABIInfo O32() { return MipsABIInfo(ABI::O32); }
33 static MipsABIInfo N32() { return MipsABIInfo(ABI::N32); }
34 static MipsABIInfo N64() { return MipsABIInfo(ABI::N64); }
35 static MipsABIInfo P32() { return MipsABIInfo(ABI::P32); }
36 static MipsABIInfo computeTargetABI(const Triple &TT, StringRef ABIName);
37
38 bool IsKnown() const { return ThisABI != ABI::Unknown; }
39 bool IsO32() const { return ThisABI == ABI::O32; }
40 bool IsN32() const { return ThisABI == ABI::N32; }
41 bool IsN64() const { return ThisABI == ABI::N64; }
42 bool IsP32() const { return ThisABI == ABI::P32; }
43 ABI GetEnumValue() const { return ThisABI; }
44
45 /// Register naming convention for this ABI.
46 unsigned getRegAltNameIndex() const;
47
48 /// Integer argument registers in calling-convention order.
49 ArrayRef<MCPhysReg> getArgRegs(bool Is64Bit) const;
50
51 /// ABI register accessors default to the ABI's GPR width. Use the *RegPtr
52 /// variants for pointer-sized values; N32 has 32-bit pointers and 64-bit
53 /// GPRs.
54 MCRegister getArgReg(unsigned I, bool Is64Bit) const;
55 MCRegister getArgReg(unsigned I) const {
56 return getArgReg(I, AreGprs64bit());
57 }
58 MCRegister getArgRegPtr(unsigned I) const {
59 return getArgReg(I, ArePtrs64bit());
60 }
61 /// I is the suffix in tI (NABI has t0-t3 and t8-t9).
62 MCRegister getTempReg(unsigned I, bool Is64Bit) const;
63 MCRegister getTempReg(unsigned I) const {
64 return getTempReg(I, AreGprs64bit());
65 }
66 MCRegister getTempRegPtr(unsigned I) const {
67 return getTempReg(I, ArePtrs64bit());
68 }
69 MCRegister getSavedReg(unsigned I, bool Is64Bit) const;
70 MCRegister getSavedReg(unsigned I) const {
71 return getSavedReg(I, AreGprs64bit());
72 }
73 MCRegister getSavedRegPtr(unsigned I) const {
74 return getSavedReg(I, ArePtrs64bit());
75 }
76 /// Integer return-value registers.
77 MCRegister getReturnReg(unsigned I, bool Is64Bit) const;
78 MCRegister getReturnReg(unsigned I) const {
79 return getReturnReg(I, AreGprs64bit());
80 }
81 MCRegister getReturnRegPtr(unsigned I) const {
82 return getReturnReg(I, ArePtrs64bit());
83 }
84
85 /// The registers to use for byval arguments.
87
88 /// The registers to use for the variable argument list.
89 ArrayRef<MCPhysReg> getVarArgRegs(bool isGP64bit) const;
90
91 /// Obtain the size of the area allocated by the callee for arguments.
92 /// CallingConv::FastCall affects the value for O32.
94
95 /// Ordering of ABI's
96 /// MipsGenSubtargetInfo.inc will use this to resolve conflicts when given
97 /// multiple ABI options.
98 bool operator<(const MipsABIInfo Other) const {
99 return ThisABI < Other.GetEnumValue();
100 }
101
102 unsigned GetStackPtr() const;
103 unsigned GetFramePtr() const;
104 unsigned GetBasePtr() const;
105 unsigned GetGlobalPtr() const;
106 unsigned GetNullPtr() const;
107 unsigned GetZeroReg() const;
108 unsigned GetPtrAdduOp() const;
109 unsigned GetPtrAddiuOp() const;
110 unsigned GetPtrSubuOp() const;
111 unsigned GetPtrAndOp() const;
112 unsigned GetGPRMoveOp() const;
113 inline bool ArePtrs64bit() const { return IsN64(); }
114 inline bool AreGprs64bit() const { return IsN32() || IsN64(); }
115
116 unsigned GetEhDataReg(unsigned I) const;
117};
118}
119
120#endif
#define I(x, y, z)
Definition MD5.cpp:57
RISCVCC::CondCode CC
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
Wrapper class representing physical registers and target specific virtual registers.
Definition MCRegister.h:42
MCRegister getArgReg(unsigned I) const
Definition MipsABIInfo.h:55
bool AreGprs64bit() const
bool IsN64() const
Definition MipsABIInfo.h:41
unsigned GetGlobalPtr() const
ABI GetEnumValue() const
Definition MipsABIInfo.h:43
static MipsABIInfo O32()
Definition MipsABIInfo.h:32
MipsABIInfo(ABI ThisABI)
Definition MipsABIInfo.h:29
unsigned GetEhDataReg(unsigned I) const
bool ArePtrs64bit() const
unsigned GetGPRMoveOp() const
MCRegister getArgReg(unsigned I, bool Is64Bit) const
ABI register accessors default to the ABI's GPR width.
static MipsABIInfo P32()
Definition MipsABIInfo.h:35
unsigned GetStackPtr() const
MCRegister getSavedReg(unsigned I) const
Definition MipsABIInfo.h:70
static MipsABIInfo N32()
Definition MipsABIInfo.h:33
MCRegister getTempReg(unsigned I) const
Definition MipsABIInfo.h:63
unsigned GetZeroReg() const
unsigned GetCalleeAllocdArgSizeInBytes(CallingConv::ID CC) const
Obtain the size of the area allocated by the callee for arguments.
static MipsABIInfo N64()
Definition MipsABIInfo.h:34
bool operator<(const MipsABIInfo Other) const
Ordering of ABI's MipsGenSubtargetInfo.inc will use this to resolve conflicts when given multiple ABI...
Definition MipsABIInfo.h:98
unsigned GetPtrAddiuOp() const
unsigned GetPtrAndOp() const
unsigned GetFramePtr() const
unsigned getRegAltNameIndex() const
Register naming convention for this ABI.
static MipsABIInfo computeTargetABI(const Triple &TT, StringRef ABIName)
static MipsABIInfo Unknown()
Definition MipsABIInfo.h:31
MCRegister getReturnReg(unsigned I) const
Definition MipsABIInfo.h:78
ArrayRef< MCPhysReg > GetByValArgRegs() const
The registers to use for byval arguments.
unsigned GetNullPtr() const
ArrayRef< MCPhysReg > getVarArgRegs(bool isGP64bit) const
The registers to use for the variable argument list.
unsigned GetPtrAdduOp() const
bool IsKnown() const
Definition MipsABIInfo.h:38
bool IsN32() const
Definition MipsABIInfo.h:40
MCRegister getReturnReg(unsigned I, bool Is64Bit) const
Integer return-value registers.
MCRegister getSavedReg(unsigned I, bool Is64Bit) const
unsigned GetBasePtr() const
unsigned GetPtrSubuOp() const
MCRegister getSavedRegPtr(unsigned I) const
Definition MipsABIInfo.h:73
MCRegister getTempRegPtr(unsigned I) const
Definition MipsABIInfo.h:66
bool IsO32() const
Definition MipsABIInfo.h:39
bool IsP32() const
Definition MipsABIInfo.h:42
MCRegister getReturnRegPtr(unsigned I) const
Definition MipsABIInfo.h:81
MCRegister getTempReg(unsigned I, bool Is64Bit) const
I is the suffix in tI (NABI has t0-t3 and t8-t9).
ArrayRef< MCPhysReg > getArgRegs(bool Is64Bit) const
Integer argument registers in calling-convention order.
MCRegister getArgRegPtr(unsigned I) const
Definition MipsABIInfo.h:58
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:48
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
This is an optimization pass for GlobalISel generic memory operations.
@ Other
Any other memory.
Definition ModRef.h:68