Jia Liu | bb481f8 | 2012-02-28 07:46:26 +0000 | [diff] [blame] | 1 | //===-- MipsSubtarget.h - Define Subtarget for the Mips ---------*- C++ -*-===// |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 7 | // |
Akira Hatanaka | 4552c9a | 2011-04-15 21:51:11 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 9 | // |
Evan Cheng | 5b1b4489 | 2011-07-01 21:01:15 +0000 | [diff] [blame] | 10 | // This file declares the Mips specific subclass of TargetSubtargetInfo. |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 11 | // |
Akira Hatanaka | 4552c9a | 2011-04-15 21:51:11 +0000 | [diff] [blame] | 12 | //===----------------------------------------------------------------------===// |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 13 | |
| 14 | #ifndef MIPSSUBTARGET_H |
| 15 | #define MIPSSUBTARGET_H |
| 16 | |
Jack Carter | c91cbb9 | 2013-01-18 21:20:38 +0000 | [diff] [blame] | 17 | #include "MCTargetDesc/MipsReginfo.h" |
Evan Cheng | ab8be96 | 2011-06-29 01:14:12 +0000 | [diff] [blame] | 18 | #include "llvm/MC/MCInstrItineraries.h" |
Reed Kotler | a430cb6 | 2013-04-09 19:46:01 +0000 | [diff] [blame] | 19 | #include "llvm/Support/ErrorHandling.h" |
Chandler Carruth | a1514e2 | 2012-12-04 07:12:27 +0000 | [diff] [blame] | 20 | #include "llvm/Target/TargetSubtargetInfo.h" |
Reed Kotler | a430cb6 | 2013-04-09 19:46:01 +0000 | [diff] [blame] | 21 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 22 | #include <string> |
| 23 | |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 24 | #define GET_SUBTARGETINFO_HEADER |
Evan Cheng | 385e930 | 2011-07-01 22:36:09 +0000 | [diff] [blame] | 25 | #include "MipsGenSubtargetInfo.inc" |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 26 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 27 | namespace llvm { |
Evan Cheng | 0ddff1b | 2011-07-07 07:07:08 +0000 | [diff] [blame] | 28 | class StringRef; |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 29 | |
Reed Kotler | a430cb6 | 2013-04-09 19:46:01 +0000 | [diff] [blame] | 30 | class MipsTargetMachine; |
| 31 | |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 32 | class MipsSubtarget : public MipsGenSubtargetInfo { |
David Blaikie | 2d24e2a | 2011-12-20 02:50:00 +0000 | [diff] [blame] | 33 | virtual void anchor(); |
Bruno Cardoso Lopes | 13d1b7b | 2007-08-18 01:52:27 +0000 | [diff] [blame] | 34 | |
Bruno Cardoso Lopes | 43d526d | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 35 | public: |
Akira Hatanaka | 0b7b6a0 | 2011-09-14 17:22:51 +0000 | [diff] [blame] | 36 | // NOTE: O64 will not be supported. |
Bruno Cardoso Lopes | 43d526d | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 37 | enum MipsABIEnum { |
Akira Hatanaka | 8c1b4bf | 2011-09-21 02:45:29 +0000 | [diff] [blame] | 38 | UnknownABI, O32, N32, N64, EABI |
Bruno Cardoso Lopes | 81092dc | 2011-03-04 17:51:39 +0000 | [diff] [blame] | 39 | }; |
Bruno Cardoso Lopes | 43d526d | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 40 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 41 | protected: |
Bruno Cardoso Lopes | 13d1b7b | 2007-08-18 01:52:27 +0000 | [diff] [blame] | 42 | |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 43 | enum MipsArchEnum { |
Akira Hatanaka | 1daa5be | 2011-09-20 20:28:08 +0000 | [diff] [blame] | 44 | Mips32, Mips32r2, Mips64, Mips64r2 |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 45 | }; |
| 46 | |
Bruno Cardoso Lopes | 81092dc | 2011-03-04 17:51:39 +0000 | [diff] [blame] | 47 | // Mips architecture version |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 48 | MipsArchEnum MipsArchVersion; |
| 49 | |
Bruno Cardoso Lopes | 81092dc | 2011-03-04 17:51:39 +0000 | [diff] [blame] | 50 | // Mips supported ABIs |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 51 | MipsABIEnum MipsABI; |
| 52 | |
| 53 | // IsLittle - The target is Little Endian |
Bruno Cardoso Lopes | d2947ee | 2008-06-04 01:45:25 +0000 | [diff] [blame] | 54 | bool IsLittle; |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 55 | |
| 56 | // IsSingleFloat - The target only supports single precision float |
| 57 | // point operations. This enable the target to use all 32 32-bit |
Bruno Cardoso Lopes | 7b76da1 | 2008-07-09 04:45:36 +0000 | [diff] [blame] | 58 | // floating point registers instead of only using even ones. |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 59 | bool IsSingleFloat; |
| 60 | |
Bruno Cardoso Lopes | 7b76da1 | 2008-07-09 04:45:36 +0000 | [diff] [blame] | 61 | // IsFP64bit - The target processor has 64-bit floating point registers. |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 62 | bool IsFP64bit; |
| 63 | |
| 64 | // IsFP64bit - General-purpose registers are 64 bits wide |
| 65 | bool IsGP64bit; |
| 66 | |
Bruno Cardoso Lopes | 7728f7e | 2008-07-09 05:32:22 +0000 | [diff] [blame] | 67 | // HasVFPU - Processor has a vector floating point unit. |
| 68 | bool HasVFPU; |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 69 | |
Bruno Cardoso Lopes | 43d526d | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 70 | // isLinux - Target system is Linux. Is false we consider ELFOS for now. |
| 71 | bool IsLinux; |
| 72 | |
Akira Hatanaka | e7338cd | 2012-08-22 03:18:13 +0000 | [diff] [blame] | 73 | // UseSmallSection - Small section is used. |
| 74 | bool UseSmallSection; |
| 75 | |
Bruno Cardoso Lopes | d3a680d | 2008-07-30 17:01:06 +0000 | [diff] [blame] | 76 | /// Features related to the presence of specific instructions. |
Bruno Cardoso Lopes | 81092dc | 2011-03-04 17:51:39 +0000 | [diff] [blame] | 77 | |
Bruno Cardoso Lopes | d3a680d | 2008-07-30 17:01:06 +0000 | [diff] [blame] | 78 | // HasSEInReg - SEB and SEH (signext in register) instructions. |
| 79 | bool HasSEInReg; |
| 80 | |
| 81 | // HasCondMov - Conditional mov (MOVZ, MOVN) instructions. |
| 82 | bool HasCondMov; |
| 83 | |
Bruno Cardoso Lopes | d3a680d | 2008-07-30 17:01:06 +0000 | [diff] [blame] | 84 | // HasSwap - Byte and half swap instructions. |
| 85 | bool HasSwap; |
| 86 | |
| 87 | // HasBitCount - Count leading '1' and '0' bits. |
| 88 | bool HasBitCount; |
| 89 | |
Akira Hatanaka | 0301bc5 | 2012-11-15 21:17:13 +0000 | [diff] [blame] | 90 | // HasFPIdx -- Floating point indexed load/store instructions. |
| 91 | bool HasFPIdx; |
| 92 | |
Akira Hatanaka | 66e19c3 | 2012-05-16 22:19:56 +0000 | [diff] [blame] | 93 | // InMips16 -- can process Mips16 instructions |
| 94 | bool InMips16Mode; |
| 95 | |
Reed Kotler | a430cb6 | 2013-04-09 19:46:01 +0000 | [diff] [blame] | 96 | // PreviousInMips16 -- the function we just processed was in Mips 16 Mode |
| 97 | bool PreviousInMips16Mode; |
| 98 | |
Jack Carter | 7304702 | 2013-02-05 09:30:03 +0000 | [diff] [blame] | 99 | // InMicroMips -- can process MicroMips instructions |
| 100 | bool InMicroMipsMode; |
| 101 | |
Akira Hatanaka | a9adbf6 | 2012-09-21 23:41:49 +0000 | [diff] [blame] | 102 | // HasDSP, HasDSPR2 -- supports DSP ASE. |
| 103 | bool HasDSP, HasDSPR2; |
| 104 | |
Reed Kotler | a430cb6 | 2013-04-09 19:46:01 +0000 | [diff] [blame] | 105 | // Allow mixed Mips16 and Mips32 in one source file |
| 106 | bool AllowMixed16_32; |
| 107 | |
Bruno Cardoso Lopes | 13d1b7b | 2007-08-18 01:52:27 +0000 | [diff] [blame] | 108 | InstrItineraryData InstrItins; |
| 109 | |
Jack Carter | c91cbb9 | 2013-01-18 21:20:38 +0000 | [diff] [blame] | 110 | // The instance to the register info section object |
| 111 | MipsReginfo MRI; |
| 112 | |
Jack Carter | dba1430 | 2013-01-30 02:16:36 +0000 | [diff] [blame] | 113 | // Relocation Model |
| 114 | Reloc::Model RM; |
| 115 | |
Reed Kotler | a430cb6 | 2013-04-09 19:46:01 +0000 | [diff] [blame] | 116 | // We can override the determination of whether we are in mips16 mode |
| 117 | // as from the command line |
| 118 | enum {NoOverride, Mips16Override, NoMips16Override} OverrideMode; |
| 119 | |
| 120 | MipsTargetMachine *TM; |
| 121 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 122 | public: |
Akira Hatanaka | 81a424b | 2012-03-28 00:24:17 +0000 | [diff] [blame] | 123 | virtual bool enablePostRAScheduler(CodeGenOpt::Level OptLevel, |
| 124 | AntiDepBreakMode& Mode, |
| 125 | RegClassVector& CriticalPathRCs) const; |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 126 | |
| 127 | /// Only O32 and EABI supported right now. |
| 128 | bool isABI_EABI() const { return MipsABI == EABI; } |
Akira Hatanaka | 1daa5be | 2011-09-20 20:28:08 +0000 | [diff] [blame] | 129 | bool isABI_N64() const { return MipsABI == N64; } |
| 130 | bool isABI_N32() const { return MipsABI == N32; } |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 131 | bool isABI_O32() const { return MipsABI == O32; } |
Bruno Cardoso Lopes | 43d526d | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 132 | unsigned getTargetABI() const { return MipsABI; } |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 133 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 134 | /// This constructor initializes the data members to match that |
Daniel Dunbar | 3be0340 | 2009-08-02 22:11:08 +0000 | [diff] [blame] | 135 | /// of the specified triple. |
Evan Cheng | 276365d | 2011-06-30 01:53:36 +0000 | [diff] [blame] | 136 | MipsSubtarget(const std::string &TT, const std::string &CPU, |
Reed Kotler | a430cb6 | 2013-04-09 19:46:01 +0000 | [diff] [blame] | 137 | const std::string &FS, bool little, Reloc::Model RM, |
| 138 | MipsTargetMachine *TM); |
Bruno Cardoso Lopes | 81092dc | 2011-03-04 17:51:39 +0000 | [diff] [blame] | 139 | |
| 140 | /// ParseSubtargetFeatures - Parses features string setting specified |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 141 | /// subtarget options. Definition of function is auto generated by tblgen. |
Evan Cheng | 0ddff1b | 2011-07-07 07:07:08 +0000 | [diff] [blame] | 142 | void ParseSubtargetFeatures(StringRef CPU, StringRef FS); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 143 | |
Akira Hatanaka | 5663344 | 2011-09-20 23:53:09 +0000 | [diff] [blame] | 144 | bool hasMips32() const { return MipsArchVersion >= Mips32; } |
| 145 | bool hasMips32r2() const { return MipsArchVersion == Mips32r2 || |
Akira Hatanaka | 1daa5be | 2011-09-20 20:28:08 +0000 | [diff] [blame] | 146 | MipsArchVersion == Mips64r2; } |
Akira Hatanaka | 50fa74e | 2011-09-21 02:24:25 +0000 | [diff] [blame] | 147 | bool hasMips64() const { return MipsArchVersion >= Mips64; } |
| 148 | bool hasMips64r2() const { return MipsArchVersion == Mips64r2; } |
Bruno Cardoso Lopes | d2947ee | 2008-06-04 01:45:25 +0000 | [diff] [blame] | 149 | |
Bruno Cardoso Lopes | d2947ee | 2008-06-04 01:45:25 +0000 | [diff] [blame] | 150 | bool isLittle() const { return IsLittle; } |
Douglas Gregor | cabdd74 | 2009-12-19 07:05:23 +0000 | [diff] [blame] | 151 | bool isFP64bit() const { return IsFP64bit; } |
| 152 | bool isGP64bit() const { return IsGP64bit; } |
| 153 | bool isGP32bit() const { return !IsGP64bit; } |
| 154 | bool isSingleFloat() const { return IsSingleFloat; } |
| 155 | bool isNotSingleFloat() const { return !IsSingleFloat; } |
| 156 | bool hasVFPU() const { return HasVFPU; } |
Reed Kotler | a430cb6 | 2013-04-09 19:46:01 +0000 | [diff] [blame] | 157 | bool inMips16Mode() const { |
| 158 | switch (OverrideMode) { |
| 159 | case NoOverride: |
| 160 | return InMips16Mode; |
| 161 | case Mips16Override: |
| 162 | return true; |
| 163 | case NoMips16Override: |
| 164 | return false; |
| 165 | } |
| 166 | llvm_unreachable("Unexpected mode"); |
| 167 | } |
| 168 | bool inMips16ModeDefault() { |
| 169 | return InMips16Mode; |
| 170 | } |
Jack Carter | 7304702 | 2013-02-05 09:30:03 +0000 | [diff] [blame] | 171 | bool inMicroMipsMode() const { return InMicroMipsMode; } |
Akira Hatanaka | a9adbf6 | 2012-09-21 23:41:49 +0000 | [diff] [blame] | 172 | bool hasDSP() const { return HasDSP; } |
| 173 | bool hasDSPR2() const { return HasDSPR2; } |
Douglas Gregor | cabdd74 | 2009-12-19 07:05:23 +0000 | [diff] [blame] | 174 | bool isLinux() const { return IsLinux; } |
Akira Hatanaka | e7338cd | 2012-08-22 03:18:13 +0000 | [diff] [blame] | 175 | bool useSmallSection() const { return UseSmallSection; } |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 176 | |
Akira Hatanaka | 18f3c78 | 2012-05-22 03:10:09 +0000 | [diff] [blame] | 177 | bool hasStandardEncoding() const { return !inMips16Mode(); } |
| 178 | |
Bruno Cardoso Lopes | d3a680d | 2008-07-30 17:01:06 +0000 | [diff] [blame] | 179 | /// Features related to the presence of specific instructions. |
Douglas Gregor | cabdd74 | 2009-12-19 07:05:23 +0000 | [diff] [blame] | 180 | bool hasSEInReg() const { return HasSEInReg; } |
| 181 | bool hasCondMov() const { return HasCondMov; } |
Douglas Gregor | cabdd74 | 2009-12-19 07:05:23 +0000 | [diff] [blame] | 182 | bool hasSwap() const { return HasSwap; } |
| 183 | bool hasBitCount() const { return HasBitCount; } |
Akira Hatanaka | 0301bc5 | 2012-11-15 21:17:13 +0000 | [diff] [blame] | 184 | bool hasFPIdx() const { return HasFPIdx; } |
Jack Carter | c91cbb9 | 2013-01-18 21:20:38 +0000 | [diff] [blame] | 185 | |
Reed Kotler | a430cb6 | 2013-04-09 19:46:01 +0000 | [diff] [blame] | 186 | bool allowMixed16_32() const { return AllowMixed16_32;}; |
| 187 | |
Jack Carter | c91cbb9 | 2013-01-18 21:20:38 +0000 | [diff] [blame] | 188 | // Grab MipsRegInfo object |
| 189 | const MipsReginfo &getMReginfo() const { return MRI; } |
Jack Carter | dba1430 | 2013-01-30 02:16:36 +0000 | [diff] [blame] | 190 | |
| 191 | // Grab relocation model |
| 192 | Reloc::Model getRelocationModel() const {return RM;} |
Reed Kotler | a430cb6 | 2013-04-09 19:46:01 +0000 | [diff] [blame] | 193 | |
| 194 | /// \brief Reset the subtarget for the Mips target. |
| 195 | void resetSubtarget(MachineFunction *MF); |
| 196 | |
| 197 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 198 | }; |
| 199 | } // End llvm namespace |
| 200 | |
| 201 | #endif |