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