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