1 //===---- MipsABIInfo.h - Information about MIPS ABI's --------------------===//
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 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSABIINFO_H
11 #define LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSABIINFO_H
13 #include "llvm/ADT/ArrayRef.h"
14 #include "llvm/ADT/Triple.h"
15 #include "llvm/IR/CallingConv.h"
16 #include "llvm/MC/MCRegisterInfo.h"
20 class MCTargetOptions;
22 class TargetRegisterClass;
26 enum class ABI { Unknown, O32, N32, N64, EABI };
32 MipsABIInfo(ABI ThisABI) : ThisABI(ThisABI) {}
34 static MipsABIInfo Unknown() { return MipsABIInfo(ABI::Unknown); }
35 static MipsABIInfo O32() { return MipsABIInfo(ABI::O32); }
36 static MipsABIInfo N32() { return MipsABIInfo(ABI::N32); }
37 static MipsABIInfo N64() { return MipsABIInfo(ABI::N64); }
38 static MipsABIInfo EABI() { return MipsABIInfo(ABI::EABI); }
39 static MipsABIInfo computeTargetABI(Triple TT, StringRef CPU,
40 const MCTargetOptions &Options);
42 bool IsKnown() const { return ThisABI != ABI::Unknown; }
43 bool IsO32() const { return ThisABI == ABI::O32; }
44 bool IsN32() const { return ThisABI == ABI::N32; }
45 bool IsN64() const { return ThisABI == ABI::N64; }
46 bool IsEABI() const { return ThisABI == ABI::EABI; }
47 ABI GetEnumValue() const { return ThisABI; }
49 /// The registers to use for byval arguments.
50 const ArrayRef<MCPhysReg> GetByValArgRegs() const;
52 /// The registers to use for the variable argument list.
53 const ArrayRef<MCPhysReg> GetVarArgRegs() const;
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;
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();
66 unsigned GetStackPtr() const;
67 unsigned GetFramePtr() const;
68 unsigned GetNullPtr() const;
69 unsigned GetPtrAdduOp() const;
70 unsigned GetPtrAddiuOp() const;
71 inline bool ArePtrs64bit() const { return IsN64(); }
73 unsigned GetEhDataReg(unsigned I) const;