Rename TargetSubtarget to TargetSubtargetInfo for consistency.
[oota-llvm.git] / lib / Target / Mips / MipsSubtarget.h
1 //=====-- MipsSubtarget.h - Define Subtarget for the Mips -----*- C++ -*--====//
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 // This file declares the Mips specific subclass of TargetSubtargetInfo.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef MIPSSUBTARGET_H
15 #define MIPSSUBTARGET_H
16
17 #include "llvm/Target/TargetSubtargetInfo.h"
18 #include "llvm/MC/MCInstrItineraries.h"
19 #include <string>
20
21 #define GET_SUBTARGETINFO_HEADER
22 #include "MipsGenSubtarget.inc"
23
24 namespace llvm {
25
26 class MipsSubtarget : public MipsGenSubtargetInfo {
27
28 public:
29   enum MipsABIEnum {
30     O32, O64, N32, N64, EABI
31   };
32
33 protected:
34
35   enum MipsArchEnum {
36     Mips1, Mips2, Mips3, Mips4, Mips32, Mips32r2
37   };
38
39   // Mips architecture version
40   MipsArchEnum MipsArchVersion;
41
42   // Mips supported ABIs
43   MipsABIEnum MipsABI;
44
45   // IsLittle - The target is Little Endian
46   bool IsLittle;
47
48   // IsSingleFloat - The target only supports single precision float
49   // point operations. This enable the target to use all 32 32-bit
50   // floating point registers instead of only using even ones.
51   bool IsSingleFloat;
52
53   // IsFP64bit - The target processor has 64-bit floating point registers.
54   bool IsFP64bit;
55
56   // IsFP64bit - General-purpose registers are 64 bits wide
57   bool IsGP64bit;
58
59   // HasVFPU - Processor has a vector floating point unit.
60   bool HasVFPU;
61
62   // isLinux - Target system is Linux. Is false we consider ELFOS for now.
63   bool IsLinux;
64
65   /// Features related to the presence of specific instructions.
66
67   // HasSEInReg - SEB and SEH (signext in register) instructions.
68   bool HasSEInReg;
69
70   // HasCondMov - Conditional mov (MOVZ, MOVN) instructions.
71   bool HasCondMov;
72
73   // HasMulDivAdd - Multiply add and sub (MADD, MADDu, MSUB, MSUBu)
74   // instructions.
75   bool HasMulDivAdd;
76
77   // HasMinMax - MIN and MAX instructions.
78   bool HasMinMax;
79
80   // HasSwap - Byte and half swap instructions.
81   bool HasSwap;
82
83   // HasBitCount - Count leading '1' and '0' bits.
84   bool HasBitCount;
85
86   InstrItineraryData InstrItins;
87
88 public:
89
90   /// Only O32 and EABI supported right now.
91   bool isABI_EABI() const { return MipsABI == EABI; }
92   bool isABI_O32() const { return MipsABI == O32; }
93   unsigned getTargetABI() const { return MipsABI; }
94
95   /// This constructor initializes the data members to match that
96   /// of the specified triple.
97   MipsSubtarget(const std::string &TT, const std::string &CPU,
98                 const std::string &FS, bool little);
99
100   /// ParseSubtargetFeatures - Parses features string setting specified
101   /// subtarget options.  Definition of function is auto generated by tblgen.
102   void ParseSubtargetFeatures(const std::string &FS, const std::string &CPU);
103
104   bool isMips1() const { return MipsArchVersion == Mips1; }
105   bool isMips32() const { return MipsArchVersion >= Mips32; }
106   bool isMips32r2() const { return MipsArchVersion == Mips32r2; }
107
108   bool isLittle() const { return IsLittle; }
109   bool isFP64bit() const { return IsFP64bit; }
110   bool isGP64bit() const { return IsGP64bit; }
111   bool isGP32bit() const { return !IsGP64bit; }
112   bool isSingleFloat() const { return IsSingleFloat; }
113   bool isNotSingleFloat() const { return !IsSingleFloat; }
114   bool hasVFPU() const { return HasVFPU; }
115   bool isLinux() const { return IsLinux; }
116
117   /// Features related to the presence of specific instructions.
118   bool hasSEInReg()   const { return HasSEInReg; }
119   bool hasCondMov()   const { return HasCondMov; }
120   bool hasMulDivAdd() const { return HasMulDivAdd; }
121   bool hasMinMax()    const { return HasMinMax; }
122   bool hasSwap()      const { return HasSwap; }
123   bool hasBitCount()  const { return HasBitCount; }
124 };
125 } // End llvm namespace
126
127 #endif