Jia Liu | f54f60f | 2012-02-28 07:46:26 +0000 | [diff] [blame] | 1 | //===-- MipsSubtarget.h - Define Subtarget for the Mips ---------*- C++ -*-===// |
Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | f3ebc3f | 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 | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 7 | // |
Akira Hatanaka | e248912 | 2011-04-15 21:51:11 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 9 | // |
Evan Cheng | 0d639a2 | 2011-07-01 21:01:15 +0000 | [diff] [blame] | 10 | // This file declares the Mips specific subclass of TargetSubtargetInfo. |
Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 11 | // |
Akira Hatanaka | e248912 | 2011-04-15 21:51:11 +0000 | [diff] [blame] | 12 | //===----------------------------------------------------------------------===// |
Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 13 | |
| 14 | #ifndef MIPSSUBTARGET_H |
| 15 | #define MIPSSUBTARGET_H |
| 16 | |
Eric Christopher | daa9dbb | 2014-07-03 00:10:24 +0000 | [diff] [blame] | 17 | #include "MipsFrameLowering.h" |
| 18 | #include "MipsISelLowering.h" |
| 19 | #include "MipsInstrInfo.h" |
Eric Christopher | b9fd9ed | 2014-08-07 22:02:54 +0000 | [diff] [blame] | 20 | #include "MipsJITInfo.h" |
Eric Christopher | 5f9fd21 | 2014-07-02 21:29:23 +0000 | [diff] [blame] | 21 | #include "MipsSelectionDAGInfo.h" |
| 22 | #include "llvm/IR/DataLayout.h" |
Evan Cheng | 8264e27 | 2011-06-29 01:14:12 +0000 | [diff] [blame] | 23 | #include "llvm/MC/MCInstrItineraries.h" |
Reed Kotler | 1595f36 | 2013-04-09 19:46:01 +0000 | [diff] [blame] | 24 | #include "llvm/Support/ErrorHandling.h" |
Chandler Carruth | 802d755 | 2012-12-04 07:12:27 +0000 | [diff] [blame] | 25 | #include "llvm/Target/TargetSubtargetInfo.h" |
Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 26 | #include <string> |
| 27 | |
Evan Cheng | 54b68e3 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 28 | #define GET_SUBTARGETINFO_HEADER |
Evan Cheng | c9c090d | 2011-07-01 22:36:09 +0000 | [diff] [blame] | 29 | #include "MipsGenSubtargetInfo.inc" |
Evan Cheng | 54b68e3 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 30 | |
Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 31 | namespace llvm { |
Evan Cheng | 1a72add6 | 2011-07-07 07:07:08 +0000 | [diff] [blame] | 32 | class StringRef; |
Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 33 | |
Reed Kotler | 1595f36 | 2013-04-09 19:46:01 +0000 | [diff] [blame] | 34 | class MipsTargetMachine; |
| 35 | |
Evan Cheng | 54b68e3 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 36 | class MipsSubtarget : public MipsGenSubtargetInfo { |
David Blaikie | a379b181 | 2011-12-20 02:50:00 +0000 | [diff] [blame] | 37 | virtual void anchor(); |
Bruno Cardoso Lopes | 87beec9 | 2007-08-18 01:52:27 +0000 | [diff] [blame] | 38 | |
Bruno Cardoso Lopes | 80ab8f9 | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 39 | public: |
Akira Hatanaka | 3efff6c | 2011-09-14 17:22:51 +0000 | [diff] [blame] | 40 | // NOTE: O64 will not be supported. |
Bruno Cardoso Lopes | 80ab8f9 | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 41 | enum MipsABIEnum { |
Akira Hatanaka | 6de4d12 | 2011-09-21 02:45:29 +0000 | [diff] [blame] | 42 | UnknownABI, O32, N32, N64, EABI |
Bruno Cardoso Lopes | ed874ef | 2011-03-04 17:51:39 +0000 | [diff] [blame] | 43 | }; |
Bruno Cardoso Lopes | 80ab8f9 | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 44 | |
Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 45 | protected: |
Daniel Sanders | b7f1c6f | 2014-05-09 09:46:21 +0000 | [diff] [blame] | 46 | enum MipsArchEnum { |
| 47 | Mips1, Mips2, Mips32, Mips32r2, Mips32r6, Mips3, Mips4, Mips5, Mips64, |
| 48 | Mips64r2, Mips64r6 |
| 49 | }; |
Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 50 | |
Bruno Cardoso Lopes | ed874ef | 2011-03-04 17:51:39 +0000 | [diff] [blame] | 51 | // Mips architecture version |
Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 52 | MipsArchEnum MipsArchVersion; |
| 53 | |
Bruno Cardoso Lopes | ed874ef | 2011-03-04 17:51:39 +0000 | [diff] [blame] | 54 | // Mips supported ABIs |
Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 55 | MipsABIEnum MipsABI; |
| 56 | |
| 57 | // IsLittle - The target is Little Endian |
Bruno Cardoso Lopes | 326a037 | 2008-06-04 01:45:25 +0000 | [diff] [blame] | 58 | bool IsLittle; |
Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 59 | |
| 60 | // IsSingleFloat - The target only supports single precision float |
| 61 | // point operations. This enable the target to use all 32 32-bit |
Bruno Cardoso Lopes | 7ceec57 | 2008-07-09 04:45:36 +0000 | [diff] [blame] | 62 | // floating point registers instead of only using even ones. |
Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 63 | bool IsSingleFloat; |
| 64 | |
Zoran Jovanovic | 255d00d | 2014-07-10 15:36:12 +0000 | [diff] [blame] | 65 | // IsFPXX - MIPS O32 modeless ABI. |
| 66 | bool IsFPXX; |
| 67 | |
Daniel Sanders | feb6130 | 2014-08-08 15:47:17 +0000 | [diff] [blame] | 68 | // NoABICalls - Disable SVR4-style position-independent code. |
| 69 | bool NoABICalls; |
Daniel Sanders | 35837ac | 2014-08-08 10:01:29 +0000 | [diff] [blame] | 70 | |
Bruno Cardoso Lopes | 7ceec57 | 2008-07-09 04:45:36 +0000 | [diff] [blame] | 71 | // IsFP64bit - The target processor has 64-bit floating point registers. |
Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 72 | bool IsFP64bit; |
| 73 | |
Daniel Sanders | 7e52742 | 2014-07-10 13:38:23 +0000 | [diff] [blame] | 74 | /// Are odd single-precision registers permitted? |
| 75 | /// This corresponds to -modd-spreg and -mno-odd-spreg |
| 76 | bool UseOddSPReg; |
| 77 | |
Matheus Almeida | 0051f2d | 2014-04-16 15:48:55 +0000 | [diff] [blame] | 78 | // IsNan2008 - IEEE 754-2008 NaN encoding. |
| 79 | bool IsNaN2008bit; |
| 80 | |
Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 81 | // IsFP64bit - General-purpose registers are 64 bits wide |
| 82 | bool IsGP64bit; |
| 83 | |
Bruno Cardoso Lopes | bcc2139 | 2008-07-09 05:32:22 +0000 | [diff] [blame] | 84 | // HasVFPU - Processor has a vector floating point unit. |
| 85 | bool HasVFPU; |
Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 86 | |
Kai Nacke | 93fe5e8 | 2014-03-20 11:51:58 +0000 | [diff] [blame] | 87 | // CPU supports cnMIPS (Cavium Networks Octeon CPU). |
| 88 | bool HasCnMips; |
| 89 | |
Bruno Cardoso Lopes | 80ab8f9 | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 90 | // isLinux - Target system is Linux. Is false we consider ELFOS for now. |
| 91 | bool IsLinux; |
| 92 | |
Akira Hatanaka | ad49502 | 2012-08-22 03:18:13 +0000 | [diff] [blame] | 93 | // UseSmallSection - Small section is used. |
| 94 | bool UseSmallSection; |
| 95 | |
Bruno Cardoso Lopes | f714e25 | 2008-07-30 17:01:06 +0000 | [diff] [blame] | 96 | /// Features related to the presence of specific instructions. |
Bruno Cardoso Lopes | ed874ef | 2011-03-04 17:51:39 +0000 | [diff] [blame] | 97 | |
Daniel Sanders | f2056be | 2014-05-09 13:02:27 +0000 | [diff] [blame] | 98 | // HasMips3_32 - The subset of MIPS-III instructions added to MIPS32 |
| 99 | bool HasMips3_32; |
| 100 | |
Daniel Sanders | 387fc15 | 2014-05-13 11:45:36 +0000 | [diff] [blame] | 101 | // HasMips3_32r2 - The subset of MIPS-III instructions added to MIPS32r2 |
| 102 | bool HasMips3_32r2; |
| 103 | |
Daniel Sanders | 94eda2e | 2014-05-12 11:56:16 +0000 | [diff] [blame] | 104 | // HasMips4_32 - Has the subset of MIPS-IV present in MIPS32 |
Daniel Sanders | e57d866 | 2014-05-09 14:06:17 +0000 | [diff] [blame] | 105 | bool HasMips4_32; |
| 106 | |
Daniel Sanders | 94eda2e | 2014-05-12 11:56:16 +0000 | [diff] [blame] | 107 | // HasMips4_32r2 - Has the subset of MIPS-IV present in MIPS32r2 |
| 108 | bool HasMips4_32r2; |
| 109 | |
Daniel Sanders | 07cdea2 | 2014-05-12 12:52:44 +0000 | [diff] [blame] | 110 | // HasMips5_32r2 - Has the subset of MIPS-V present in MIPS32r2 |
| 111 | bool HasMips5_32r2; |
| 112 | |
Akira Hatanaka | 0faaebf | 2012-05-16 22:19:56 +0000 | [diff] [blame] | 113 | // InMips16 -- can process Mips16 instructions |
| 114 | bool InMips16Mode; |
| 115 | |
Reed Kotler | 783c794 | 2013-05-10 22:25:39 +0000 | [diff] [blame] | 116 | // Mips16 hard float |
| 117 | bool InMips16HardFloat; |
| 118 | |
Reed Kotler | 1595f36 | 2013-04-09 19:46:01 +0000 | [diff] [blame] | 119 | // PreviousInMips16 -- the function we just processed was in Mips 16 Mode |
| 120 | bool PreviousInMips16Mode; |
| 121 | |
Jack Carter | 428a06c | 2013-02-05 09:30:03 +0000 | [diff] [blame] | 122 | // InMicroMips -- can process MicroMips instructions |
| 123 | bool InMicroMipsMode; |
| 124 | |
Akira Hatanaka | 65ce931 | 2012-09-21 23:41:49 +0000 | [diff] [blame] | 125 | // HasDSP, HasDSPR2 -- supports DSP ASE. |
| 126 | bool HasDSP, HasDSPR2; |
| 127 | |
Reed Kotler | 1595f36 | 2013-04-09 19:46:01 +0000 | [diff] [blame] | 128 | // Allow mixed Mips16 and Mips32 in one source file |
| 129 | bool AllowMixed16_32; |
| 130 | |
Reed Kotler | fe94cc3 | 2013-04-10 16:58:04 +0000 | [diff] [blame] | 131 | // Optimize for space by compiling all functions as Mips 16 unless |
| 132 | // it needs floating point. Functions needing floating point are |
| 133 | // compiled as Mips32 |
| 134 | bool Os16; |
| 135 | |
Jack Carter | 3a2c2d4 | 2013-08-13 20:54:07 +0000 | [diff] [blame] | 136 | // HasMSA -- supports MSA ASE. |
| 137 | bool HasMSA; |
| 138 | |
Bruno Cardoso Lopes | 87beec9 | 2007-08-18 01:52:27 +0000 | [diff] [blame] | 139 | InstrItineraryData InstrItins; |
| 140 | |
Reed Kotler | 1595f36 | 2013-04-09 19:46:01 +0000 | [diff] [blame] | 141 | // We can override the determination of whether we are in mips16 mode |
| 142 | // as from the command line |
| 143 | enum {NoOverride, Mips16Override, NoMips16Override} OverrideMode; |
| 144 | |
| 145 | MipsTargetMachine *TM; |
| 146 | |
Petar Jovanovic | 9725016 | 2014-02-05 17:19:30 +0000 | [diff] [blame] | 147 | Triple TargetTriple; |
Eric Christopher | 1f51ddd | 2014-07-02 00:54:12 +0000 | [diff] [blame] | 148 | |
Eric Christopher | 5f9fd21 | 2014-07-02 21:29:23 +0000 | [diff] [blame] | 149 | const DataLayout DL; // Calculates type size & alignment |
| 150 | const MipsSelectionDAGInfo TSInfo; |
Eric Christopher | b9fd9ed | 2014-08-07 22:02:54 +0000 | [diff] [blame] | 151 | MipsJITInfo JITInfo; |
Eric Christopher | daa9dbb | 2014-07-03 00:10:24 +0000 | [diff] [blame] | 152 | std::unique_ptr<const MipsInstrInfo> InstrInfo; |
| 153 | std::unique_ptr<const MipsFrameLowering> FrameLowering; |
| 154 | std::unique_ptr<const MipsTargetLowering> TLInfo; |
Eric Christopher | 5f9fd21 | 2014-07-02 21:29:23 +0000 | [diff] [blame] | 155 | |
Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 156 | public: |
Sanjay Patel | a2f658d | 2014-07-15 22:39:58 +0000 | [diff] [blame] | 157 | /// This overrides the PostRAScheduler bit in the SchedModel for each CPU. |
| 158 | bool enablePostMachineScheduler() const override; |
| 159 | void getCriticalPathRCs(RegClassVector &CriticalPathRCs) const override; |
| 160 | CodeGenOpt::Level getOptLevelToEnablePostRAScheduler() const override; |
Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 161 | |
| 162 | /// Only O32 and EABI supported right now. |
| 163 | bool isABI_EABI() const { return MipsABI == EABI; } |
Akira Hatanaka | 2b37261 | 2011-09-20 20:28:08 +0000 | [diff] [blame] | 164 | bool isABI_N64() const { return MipsABI == N64; } |
| 165 | bool isABI_N32() const { return MipsABI == N32; } |
Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 166 | bool isABI_O32() const { return MipsABI == O32; } |
Sasa Stankovic | b976fee | 2014-07-14 09:40:29 +0000 | [diff] [blame] | 167 | bool isABI_FPXX() const { return isABI_O32() && IsFPXX; } |
Bruno Cardoso Lopes | 80ab8f9 | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 168 | unsigned getTargetABI() const { return MipsABI; } |
Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 169 | |
Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 170 | /// This constructor initializes the data members to match that |
Daniel Dunbar | 31b44e8 | 2009-08-02 22:11:08 +0000 | [diff] [blame] | 171 | /// of the specified triple. |
Evan Cheng | fe6e405 | 2011-06-30 01:53:36 +0000 | [diff] [blame] | 172 | MipsSubtarget(const std::string &TT, const std::string &CPU, |
Eric Christopher | f74faf4 | 2014-07-18 22:34:20 +0000 | [diff] [blame] | 173 | const std::string &FS, bool little, MipsTargetMachine *TM); |
Bruno Cardoso Lopes | ed874ef | 2011-03-04 17:51:39 +0000 | [diff] [blame] | 174 | |
| 175 | /// ParseSubtargetFeatures - Parses features string setting specified |
Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 176 | /// subtarget options. Definition of function is auto generated by tblgen. |
Evan Cheng | 1a72add6 | 2011-07-07 07:07:08 +0000 | [diff] [blame] | 177 | void ParseSubtargetFeatures(StringRef CPU, StringRef FS); |
Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 178 | |
Vladimir Medic | fb8a2a9 | 2014-07-08 08:59:22 +0000 | [diff] [blame] | 179 | bool hasMips1() const { return MipsArchVersion >= Mips1; } |
Daniel Sanders | d39320c | 2014-05-08 12:40:48 +0000 | [diff] [blame] | 180 | bool hasMips2() const { return MipsArchVersion >= Mips2; } |
Daniel Sanders | f2056be | 2014-05-09 13:02:27 +0000 | [diff] [blame] | 181 | bool hasMips3() const { return MipsArchVersion >= Mips3; } |
Vladimir Medic | fb8a2a9 | 2014-07-08 08:59:22 +0000 | [diff] [blame] | 182 | bool hasMips4() const { return MipsArchVersion >= Mips4; } |
| 183 | bool hasMips5() const { return MipsArchVersion >= Mips5; } |
Daniel Sanders | e57d866 | 2014-05-09 14:06:17 +0000 | [diff] [blame] | 184 | bool hasMips4_32() const { return HasMips4_32; } |
Daniel Sanders | 94eda2e | 2014-05-12 11:56:16 +0000 | [diff] [blame] | 185 | bool hasMips4_32r2() const { return HasMips4_32r2; } |
Daniel Sanders | 0046311 | 2014-06-16 13:18:59 +0000 | [diff] [blame] | 186 | bool hasMips32() const { |
| 187 | return MipsArchVersion >= Mips32 && MipsArchVersion != Mips3 && |
| 188 | MipsArchVersion != Mips4 && MipsArchVersion != Mips5; |
| 189 | } |
Daniel Sanders | 1f6f0f4 | 2014-06-12 11:55:58 +0000 | [diff] [blame] | 190 | bool hasMips32r2() const { |
| 191 | return MipsArchVersion == Mips32r2 || MipsArchVersion == Mips32r6 || |
Daniel Sanders | 6a803f6 | 2014-06-16 13:13:03 +0000 | [diff] [blame] | 192 | MipsArchVersion == Mips64r2 || MipsArchVersion == Mips64r6; |
Daniel Sanders | 1f6f0f4 | 2014-06-12 11:55:58 +0000 | [diff] [blame] | 193 | } |
| 194 | bool hasMips32r6() const { |
| 195 | return MipsArchVersion == Mips32r6 || MipsArchVersion == Mips64r6; |
| 196 | } |
Akira Hatanaka | 6e506eb | 2011-09-21 02:24:25 +0000 | [diff] [blame] | 197 | bool hasMips64() const { return MipsArchVersion >= Mips64; } |
Daniel Sanders | 1f6f0f4 | 2014-06-12 11:55:58 +0000 | [diff] [blame] | 198 | bool hasMips64r2() const { |
| 199 | return MipsArchVersion == Mips64r2 || MipsArchVersion == Mips64r6; |
| 200 | } |
Daniel Sanders | b7f1c6f | 2014-05-09 09:46:21 +0000 | [diff] [blame] | 201 | bool hasMips64r6() const { return MipsArchVersion == Mips64r6; } |
Bruno Cardoso Lopes | 326a037 | 2008-06-04 01:45:25 +0000 | [diff] [blame] | 202 | |
Kai Nacke | 93fe5e8 | 2014-03-20 11:51:58 +0000 | [diff] [blame] | 203 | bool hasCnMips() const { return HasCnMips; } |
| 204 | |
Bruno Cardoso Lopes | 326a037 | 2008-06-04 01:45:25 +0000 | [diff] [blame] | 205 | bool isLittle() const { return IsLittle; } |
Daniel Sanders | feb6130 | 2014-08-08 15:47:17 +0000 | [diff] [blame] | 206 | bool isABICalls() const { return !NoABICalls; } |
Zoran Jovanovic | 255d00d | 2014-07-10 15:36:12 +0000 | [diff] [blame] | 207 | bool isFPXX() const { return IsFPXX; } |
Douglas Gregor | 740ab38 | 2009-12-19 07:05:23 +0000 | [diff] [blame] | 208 | bool isFP64bit() const { return IsFP64bit; } |
Daniel Sanders | 7e52742 | 2014-07-10 13:38:23 +0000 | [diff] [blame] | 209 | bool useOddSPReg() const { return UseOddSPReg; } |
Sasa Stankovic | f4a9e3b | 2014-07-29 14:39:24 +0000 | [diff] [blame] | 210 | bool noOddSPReg() const { return !UseOddSPReg; } |
Matheus Almeida | 0051f2d | 2014-04-16 15:48:55 +0000 | [diff] [blame] | 211 | bool isNaN2008() const { return IsNaN2008bit; } |
Akira Hatanaka | bfb6624 | 2013-08-20 23:38:40 +0000 | [diff] [blame] | 212 | bool isNotFP64bit() const { return !IsFP64bit; } |
Douglas Gregor | 740ab38 | 2009-12-19 07:05:23 +0000 | [diff] [blame] | 213 | bool isGP64bit() const { return IsGP64bit; } |
| 214 | bool isGP32bit() const { return !IsGP64bit; } |
| 215 | bool isSingleFloat() const { return IsSingleFloat; } |
| 216 | bool isNotSingleFloat() const { return !IsSingleFloat; } |
| 217 | bool hasVFPU() const { return HasVFPU; } |
Eric Christopher | 4e7d1e7 | 2014-07-18 23:41:32 +0000 | [diff] [blame] | 218 | bool inMips16Mode() const { return InMips16Mode; } |
Reed Kotler | 783c794 | 2013-05-10 22:25:39 +0000 | [diff] [blame] | 219 | bool inMips16ModeDefault() const { |
Reed Kotler | 1595f36 | 2013-04-09 19:46:01 +0000 | [diff] [blame] | 220 | return InMips16Mode; |
| 221 | } |
Eric Christopher | 7394e23 | 2014-07-18 00:08:50 +0000 | [diff] [blame] | 222 | // Hard float for mips16 means essentially to compile as soft float |
| 223 | // but to use a runtime library for soft float that is written with |
| 224 | // native mips32 floating point instructions (those runtime routines |
| 225 | // run in mips32 hard float mode). |
Reed Kotler | 783c794 | 2013-05-10 22:25:39 +0000 | [diff] [blame] | 226 | bool inMips16HardFloat() const { |
| 227 | return inMips16Mode() && InMips16HardFloat; |
| 228 | } |
Jack Carter | 428a06c | 2013-02-05 09:30:03 +0000 | [diff] [blame] | 229 | bool inMicroMipsMode() const { return InMicroMipsMode; } |
Akira Hatanaka | 65ce931 | 2012-09-21 23:41:49 +0000 | [diff] [blame] | 230 | bool hasDSP() const { return HasDSP; } |
| 231 | bool hasDSPR2() const { return HasDSPR2; } |
Jack Carter | 3a2c2d4 | 2013-08-13 20:54:07 +0000 | [diff] [blame] | 232 | bool hasMSA() const { return HasMSA; } |
Douglas Gregor | 740ab38 | 2009-12-19 07:05:23 +0000 | [diff] [blame] | 233 | bool isLinux() const { return IsLinux; } |
Akira Hatanaka | ad49502 | 2012-08-22 03:18:13 +0000 | [diff] [blame] | 234 | bool useSmallSection() const { return UseSmallSection; } |
Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 235 | |
Akira Hatanaka | cdf4fd8 | 2012-05-22 03:10:09 +0000 | [diff] [blame] | 236 | bool hasStandardEncoding() const { return !inMips16Mode(); } |
| 237 | |
Eric Christopher | 7394e23 | 2014-07-18 00:08:50 +0000 | [diff] [blame] | 238 | bool abiUsesSoftFloat() const; |
Reed Kotler | c03807a | 2013-08-30 19:40:56 +0000 | [diff] [blame] | 239 | |
Akira Hatanaka | a8a05be | 2013-10-07 19:06:57 +0000 | [diff] [blame] | 240 | bool enableLongBranchPass() const { |
| 241 | return hasStandardEncoding() || allowMixed16_32(); |
| 242 | } |
| 243 | |
Bruno Cardoso Lopes | f714e25 | 2008-07-30 17:01:06 +0000 | [diff] [blame] | 244 | /// Features related to the presence of specific instructions. |
Akira Hatanaka | 4a3836b | 2013-10-09 23:36:17 +0000 | [diff] [blame] | 245 | bool hasExtractInsert() const { return !inMips16Mode() && hasMips32r2(); } |
Sasa Stankovic | b976fee | 2014-07-14 09:40:29 +0000 | [diff] [blame] | 246 | bool hasMTHC1() const { return hasMips32r2(); } |
Jack Carter | c1b17ed | 2013-01-18 21:20:38 +0000 | [diff] [blame] | 247 | |
Reed Kotler | 783c794 | 2013-05-10 22:25:39 +0000 | [diff] [blame] | 248 | bool allowMixed16_32() const { return inMips16ModeDefault() | |
| 249 | AllowMixed16_32;} |
Reed Kotler | 1595f36 | 2013-04-09 19:46:01 +0000 | [diff] [blame] | 250 | |
Reed Kotler | fe94cc3 | 2013-04-10 16:58:04 +0000 | [diff] [blame] | 251 | bool os16() const { return Os16;}; |
| 252 | |
Petar Jovanovic | 9725016 | 2014-02-05 17:19:30 +0000 | [diff] [blame] | 253 | bool isTargetNaCl() const { return TargetTriple.isOSNaCl(); } |
Sasa Stankovic | 4c80bda | 2014-02-07 17:16:40 +0000 | [diff] [blame] | 254 | bool isNotTargetNaCl() const { return !TargetTriple.isOSNaCl(); } |
Petar Jovanovic | 9725016 | 2014-02-05 17:19:30 +0000 | [diff] [blame] | 255 | |
Daniel Sanders | 82cd99a | 2014-04-16 14:38:27 +0000 | [diff] [blame] | 256 | // for now constant islands are on for the whole compilation unit but we only |
| 257 | // really use them if in addition we are in mips16 mode |
| 258 | static bool useConstantIslands(); |
Akira Hatanaka | 6b2d841 | 2013-10-29 19:29:03 +0000 | [diff] [blame] | 259 | |
Akira Hatanaka | 8f1caeb | 2013-11-11 21:49:03 +0000 | [diff] [blame] | 260 | unsigned stackAlignment() const { return hasMips64() ? 16 : 8; } |
Akira Hatanaka | 6b2d841 | 2013-10-29 19:29:03 +0000 | [diff] [blame] | 261 | |
Jack Carter | 7f37810 | 2013-01-30 02:16:36 +0000 | [diff] [blame] | 262 | // Grab relocation model |
Eric Christopher | f74faf4 | 2014-07-18 22:34:20 +0000 | [diff] [blame] | 263 | Reloc::Model getRelocationModel() const; |
Reed Kotler | 1595f36 | 2013-04-09 19:46:01 +0000 | [diff] [blame] | 264 | |
Eric Christopher | daa9dbb | 2014-07-03 00:10:24 +0000 | [diff] [blame] | 265 | MipsSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS, |
| 266 | const TargetMachine *TM); |
Eric Christopher | 5b336a2 | 2014-07-02 01:14:43 +0000 | [diff] [blame] | 267 | |
Daniel Sanders | ac27263 | 2014-05-23 13:18:02 +0000 | [diff] [blame] | 268 | /// Does the system support unaligned memory access. |
| 269 | /// |
| 270 | /// MIPS32r6/MIPS64r6 require full unaligned access support but does not |
| 271 | /// specify which component of the system provides it. Hardware, software, and |
| 272 | /// hybrid implementations are all valid. |
| 273 | bool systemSupportsUnalignedAccess() const { return hasMips32r6(); } |
Eric Christopher | 1f51ddd | 2014-07-02 00:54:12 +0000 | [diff] [blame] | 274 | |
Eric Christopher | daa9dbb | 2014-07-03 00:10:24 +0000 | [diff] [blame] | 275 | // Set helper classes |
| 276 | void setHelperClassesMips16(); |
| 277 | void setHelperClassesMipsSE(); |
| 278 | |
Eric Christopher | b9fd9ed | 2014-08-07 22:02:54 +0000 | [diff] [blame] | 279 | MipsJITInfo *getJITInfo() override { return &JITInfo; } |
Eric Christopher | d913448 | 2014-08-04 21:25:23 +0000 | [diff] [blame] | 280 | const MipsSelectionDAGInfo *getSelectionDAGInfo() const override { |
| 281 | return &TSInfo; |
| 282 | } |
| 283 | const DataLayout *getDataLayout() const override { return &DL; } |
| 284 | const MipsInstrInfo *getInstrInfo() const override { return InstrInfo.get(); } |
| 285 | const TargetFrameLowering *getFrameLowering() const override { |
Eric Christopher | daa9dbb | 2014-07-03 00:10:24 +0000 | [diff] [blame] | 286 | return FrameLowering.get(); |
| 287 | } |
Eric Christopher | d913448 | 2014-08-04 21:25:23 +0000 | [diff] [blame] | 288 | const MipsRegisterInfo *getRegisterInfo() const override { |
Eric Christopher | daa9dbb | 2014-07-03 00:10:24 +0000 | [diff] [blame] | 289 | return &InstrInfo->getRegisterInfo(); |
| 290 | } |
Eric Christopher | d913448 | 2014-08-04 21:25:23 +0000 | [diff] [blame] | 291 | const MipsTargetLowering *getTargetLowering() const override { |
| 292 | return TLInfo.get(); |
| 293 | } |
| 294 | const InstrItineraryData *getInstrItineraryData() const override { |
| 295 | return &InstrItins; |
| 296 | } |
Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 297 | }; |
| 298 | } // End llvm namespace |
| 299 | |
| 300 | #endif |