1 //===---- MipsABIInfo.h - 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 #ifndef LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSABIINFO_H
11 #define LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSABIINFO_H
12 
13 #include "llvm/ADT/ArrayRef.h"
14 #include "llvm/ADT/Triple.h"
15 #include "llvm/IR/CallingConv.h"
16 #include "llvm/MC/MCRegisterInfo.h"
17 
18 namespace llvm {
19 
20 class MCTargetOptions;
21 class StringRef;
22 class TargetRegisterClass;
23 
24 class MipsABIInfo {
25 public:
26   enum class ABI { Unknown, O32, N32, N64, EABI };
27 
28 protected:
29   ABI ThisABI;
30 
31 public:
MipsABIInfo(ABI ThisABI)32   MipsABIInfo(ABI ThisABI) : ThisABI(ThisABI) {}
33 
Unknown()34   static MipsABIInfo Unknown() { return MipsABIInfo(ABI::Unknown); }
O32()35   static MipsABIInfo O32() { return MipsABIInfo(ABI::O32); }
N32()36   static MipsABIInfo N32() { return MipsABIInfo(ABI::N32); }
N64()37   static MipsABIInfo N64() { return MipsABIInfo(ABI::N64); }
EABI()38   static MipsABIInfo EABI() { return MipsABIInfo(ABI::EABI); }
39   static MipsABIInfo computeTargetABI(const Triple &TT, StringRef CPU,
40                                       const MCTargetOptions &Options);
41 
IsKnown()42   bool IsKnown() const { return ThisABI != ABI::Unknown; }
IsO32()43   bool IsO32() const { return ThisABI == ABI::O32; }
IsN32()44   bool IsN32() const { return ThisABI == ABI::N32; }
IsN64()45   bool IsN64() const { return ThisABI == ABI::N64; }
IsEABI()46   bool IsEABI() const { return ThisABI == ABI::EABI; }
GetEnumValue()47   ABI GetEnumValue() const { return ThisABI; }
48 
49   /// The registers to use for byval arguments.
50   ArrayRef<MCPhysReg> GetByValArgRegs() const;
51 
52   /// The registers to use for the variable argument list.
53   ArrayRef<MCPhysReg> GetVarArgRegs() const;
54 
55   /// Obtain the size of the area allocated by the callee for arguments.
56   /// CallingConv::FastCall affects the value for O32.
57   unsigned GetCalleeAllocdArgSizeInBytes(CallingConv::ID CC) const;
58 
59   /// Ordering of ABI's
60   /// MipsGenSubtargetInfo.inc will use this to resolve conflicts when given
61   /// multiple ABI options.
62   bool operator<(const MipsABIInfo Other) const {
63     return ThisABI < Other.GetEnumValue();
64   }
65 
66   unsigned GetStackPtr() const;
67   unsigned GetFramePtr() const;
68   unsigned GetBasePtr() const;
69   unsigned GetNullPtr() const;
70   unsigned GetZeroReg() const;
71   unsigned GetPtrAdduOp() const;
72   unsigned GetPtrAddiuOp() const;
73   unsigned GetGPRMoveOp() const;
ArePtrs64bit()74   inline bool ArePtrs64bit() const { return IsN64(); }
AreGprs64bit()75   inline bool AreGprs64bit() const { return IsN32() || IsN64(); }
76 
77   unsigned GetEhDataReg(unsigned I) const;
78 };
79 }
80 
81 #endif
82