| 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 | |
| Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 14 | #ifndef LLVM_LIB_TARGET_MIPS_MIPSSUBTARGET_H |
| 15 | #define LLVM_LIB_TARGET_MIPS_MIPSSUBTARGET_H |
| Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 16 | |
| Chandler Carruth | d990388 | 2015-01-14 11:23:27 +0000 | [diff] [blame] | 17 | #include "MCTargetDesc/MipsABIInfo.h" |
| Eric Christopher | daa9dbb | 2014-07-03 00:10:24 +0000 | [diff] [blame] | 18 | #include "MipsFrameLowering.h" |
| 19 | #include "MipsISelLowering.h" |
| 20 | #include "MipsInstrInfo.h" |
| Benjamin Kramer | f9172fd4 | 2016-01-27 16:32:26 +0000 | [diff] [blame] | 21 | #include "llvm/CodeGen/SelectionDAGTargetInfo.h" |
| David Blaikie | b3bde2e | 2017-11-17 01:07:10 +0000 | [diff] [blame] | 22 | #include "llvm/CodeGen/TargetSubtargetInfo.h" |
| Petar Jovanovic | fac93e2 | 2018-02-23 11:06:40 +0000 | [diff] [blame] | 23 | #include "llvm/CodeGen/GlobalISel/CallLowering.h" |
| 24 | #include "llvm/CodeGen/GlobalISel/LegalizerInfo.h" |
| 25 | #include "llvm/CodeGen/GlobalISel/RegisterBankInfo.h" |
| 26 | #include "llvm/CodeGen/GlobalISel/InstructionSelector.h" |
| Eric Christopher | 5f9fd21 | 2014-07-02 21:29:23 +0000 | [diff] [blame] | 27 | #include "llvm/IR/DataLayout.h" |
| Evan Cheng | 8264e27 | 2011-06-29 01:14:12 +0000 | [diff] [blame] | 28 | #include "llvm/MC/MCInstrItineraries.h" |
| Reed Kotler | 1595f36 | 2013-04-09 19:46:01 +0000 | [diff] [blame] | 29 | #include "llvm/Support/ErrorHandling.h" |
| Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 30 | #include <string> |
| 31 | |
| Evan Cheng | 54b68e3 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 32 | #define GET_SUBTARGETINFO_HEADER |
| Evan Cheng | c9c090d | 2011-07-01 22:36:09 +0000 | [diff] [blame] | 33 | #include "MipsGenSubtargetInfo.inc" |
| Evan Cheng | 54b68e3 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 34 | |
| Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 35 | namespace llvm { |
| Evan Cheng | 1a72add6 | 2011-07-07 07:07:08 +0000 | [diff] [blame] | 36 | class StringRef; |
| Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 37 | |
| Reed Kotler | 1595f36 | 2013-04-09 19:46:01 +0000 | [diff] [blame] | 38 | class MipsTargetMachine; |
| 39 | |
| Evan Cheng | 54b68e3 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 40 | class MipsSubtarget : public MipsGenSubtargetInfo { |
| David Blaikie | a379b181 | 2011-12-20 02:50:00 +0000 | [diff] [blame] | 41 | virtual void anchor(); |
| Bruno Cardoso Lopes | 87beec9 | 2007-08-18 01:52:27 +0000 | [diff] [blame] | 42 | |
| Daniel Sanders | b7f1c6f | 2014-05-09 09:46:21 +0000 | [diff] [blame] | 43 | enum MipsArchEnum { |
| Vasileios Kalintiris | b2dd15f | 2014-11-11 11:43:55 +0000 | [diff] [blame] | 44 | MipsDefault, |
| Daniel Sanders | 1779314 | 2015-02-18 16:24:50 +0000 | [diff] [blame] | 45 | Mips1, Mips2, Mips32, Mips32r2, Mips32r3, Mips32r5, Mips32r6, Mips32Max, |
| 46 | Mips3, Mips4, Mips5, Mips64, Mips64r2, Mips64r3, Mips64r5, Mips64r6 |
| Daniel Sanders | b7f1c6f | 2014-05-09 09:46:21 +0000 | [diff] [blame] | 47 | }; |
| Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 48 | |
| Daniel Sanders | 7727e10 | 2015-09-28 18:24:08 +0000 | [diff] [blame] | 49 | enum class CPU { P5600 }; |
| 50 | |
| Petar Jovanovic | 29aced1 | 2018-01-22 16:43:30 +0000 | [diff] [blame] | 51 | // Used to avoid printing dsp warnings multiple times. |
| 52 | static bool DspWarningPrinted; |
| 53 | |
| 54 | // Used to avoid printing msa warnings multiple times. |
| 55 | static bool MSAWarningPrinted; |
| 56 | |
| Bruno Cardoso Lopes | ed874ef | 2011-03-04 17:51:39 +0000 | [diff] [blame] | 57 | // Mips architecture version |
| Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 58 | MipsArchEnum MipsArchVersion; |
| 59 | |
| Daniel Sanders | 7727e10 | 2015-09-28 18:24:08 +0000 | [diff] [blame] | 60 | // Processor implementation (unused but required to exist by |
| 61 | // tablegen-erated code). |
| 62 | CPU ProcImpl; |
| 63 | |
| Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 64 | // IsLittle - The target is Little Endian |
| Bruno Cardoso Lopes | 326a037 | 2008-06-04 01:45:25 +0000 | [diff] [blame] | 65 | bool IsLittle; |
| Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 66 | |
| Toma Tabacu | 506cfd0 | 2015-05-07 10:29:52 +0000 | [diff] [blame] | 67 | // IsSoftFloat - The target does not support any floating point instructions. |
| 68 | bool IsSoftFloat; |
| 69 | |
| Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 70 | // IsSingleFloat - The target only supports single precision float |
| 71 | // 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] | 72 | // floating point registers instead of only using even ones. |
| Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 73 | bool IsSingleFloat; |
| 74 | |
| Zoran Jovanovic | 255d00d | 2014-07-10 15:36:12 +0000 | [diff] [blame] | 75 | // IsFPXX - MIPS O32 modeless ABI. |
| 76 | bool IsFPXX; |
| 77 | |
| Daniel Sanders | feb6130 | 2014-08-08 15:47:17 +0000 | [diff] [blame] | 78 | // NoABICalls - Disable SVR4-style position-independent code. |
| 79 | bool NoABICalls; |
| Daniel Sanders | 35837ac | 2014-08-08 10:01:29 +0000 | [diff] [blame] | 80 | |
| Bruno Cardoso Lopes | 7ceec57 | 2008-07-09 04:45:36 +0000 | [diff] [blame] | 81 | // IsFP64bit - The target processor has 64-bit floating point registers. |
| Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 82 | bool IsFP64bit; |
| 83 | |
| Daniel Sanders | 7e52742 | 2014-07-10 13:38:23 +0000 | [diff] [blame] | 84 | /// Are odd single-precision registers permitted? |
| 85 | /// This corresponds to -modd-spreg and -mno-odd-spreg |
| 86 | bool UseOddSPReg; |
| 87 | |
| Matheus Almeida | 0051f2d | 2014-04-16 15:48:55 +0000 | [diff] [blame] | 88 | // IsNan2008 - IEEE 754-2008 NaN encoding. |
| 89 | bool IsNaN2008bit; |
| 90 | |
| Simon Dardis | 24ca9da | 2017-06-15 16:28:28 +0000 | [diff] [blame] | 91 | // IsGP64bit - General-purpose registers are 64 bits wide |
| Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 92 | bool IsGP64bit; |
| 93 | |
| Simon Dardis | 4fbf76f | 2016-06-14 11:29:28 +0000 | [diff] [blame] | 94 | // IsPTR64bit - Pointers are 64 bit wide |
| 95 | bool IsPTR64bit; |
| 96 | |
| Bruno Cardoso Lopes | bcc2139 | 2008-07-09 05:32:22 +0000 | [diff] [blame] | 97 | // HasVFPU - Processor has a vector floating point unit. |
| 98 | bool HasVFPU; |
| Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 99 | |
| Kai Nacke | 93fe5e8 | 2014-03-20 11:51:58 +0000 | [diff] [blame] | 100 | // CPU supports cnMIPS (Cavium Networks Octeon CPU). |
| 101 | bool HasCnMips; |
| 102 | |
| Bruno Cardoso Lopes | 80ab8f9 | 2008-07-14 14:42:54 +0000 | [diff] [blame] | 103 | // isLinux - Target system is Linux. Is false we consider ELFOS for now. |
| 104 | bool IsLinux; |
| 105 | |
| Akira Hatanaka | ad49502 | 2012-08-22 03:18:13 +0000 | [diff] [blame] | 106 | // UseSmallSection - Small section is used. |
| 107 | bool UseSmallSection; |
| 108 | |
| Bruno Cardoso Lopes | f714e25 | 2008-07-30 17:01:06 +0000 | [diff] [blame] | 109 | /// Features related to the presence of specific instructions. |
| Bruno Cardoso Lopes | ed874ef | 2011-03-04 17:51:39 +0000 | [diff] [blame] | 110 | |
| Daniel Sanders | f2056be | 2014-05-09 13:02:27 +0000 | [diff] [blame] | 111 | // HasMips3_32 - The subset of MIPS-III instructions added to MIPS32 |
| 112 | bool HasMips3_32; |
| 113 | |
| Daniel Sanders | 387fc15 | 2014-05-13 11:45:36 +0000 | [diff] [blame] | 114 | // HasMips3_32r2 - The subset of MIPS-III instructions added to MIPS32r2 |
| 115 | bool HasMips3_32r2; |
| 116 | |
| Daniel Sanders | 94eda2e | 2014-05-12 11:56:16 +0000 | [diff] [blame] | 117 | // HasMips4_32 - Has the subset of MIPS-IV present in MIPS32 |
| Daniel Sanders | e57d866 | 2014-05-09 14:06:17 +0000 | [diff] [blame] | 118 | bool HasMips4_32; |
| 119 | |
| Daniel Sanders | 94eda2e | 2014-05-12 11:56:16 +0000 | [diff] [blame] | 120 | // HasMips4_32r2 - Has the subset of MIPS-IV present in MIPS32r2 |
| 121 | bool HasMips4_32r2; |
| 122 | |
| Daniel Sanders | 07cdea2 | 2014-05-12 12:52:44 +0000 | [diff] [blame] | 123 | // HasMips5_32r2 - Has the subset of MIPS-V present in MIPS32r2 |
| 124 | bool HasMips5_32r2; |
| 125 | |
| Akira Hatanaka | 0faaebf | 2012-05-16 22:19:56 +0000 | [diff] [blame] | 126 | // InMips16 -- can process Mips16 instructions |
| 127 | bool InMips16Mode; |
| 128 | |
| Reed Kotler | 783c794 | 2013-05-10 22:25:39 +0000 | [diff] [blame] | 129 | // Mips16 hard float |
| 130 | bool InMips16HardFloat; |
| 131 | |
| Jack Carter | 428a06c | 2013-02-05 09:30:03 +0000 | [diff] [blame] | 132 | // InMicroMips -- can process MicroMips instructions |
| 133 | bool InMicroMipsMode; |
| 134 | |
| Zoran Jovanovic | 2e386d3 | 2015-10-12 16:07:25 +0000 | [diff] [blame] | 135 | // HasDSP, HasDSPR2, HasDSPR3 -- supports DSP ASE. |
| 136 | bool HasDSP, HasDSPR2, HasDSPR3; |
| Akira Hatanaka | 65ce931 | 2012-09-21 23:41:49 +0000 | [diff] [blame] | 137 | |
| Reed Kotler | 1595f36 | 2013-04-09 19:46:01 +0000 | [diff] [blame] | 138 | // Allow mixed Mips16 and Mips32 in one source file |
| 139 | bool AllowMixed16_32; |
| 140 | |
| Reed Kotler | fe94cc3 | 2013-04-10 16:58:04 +0000 | [diff] [blame] | 141 | // Optimize for space by compiling all functions as Mips 16 unless |
| 142 | // it needs floating point. Functions needing floating point are |
| 143 | // compiled as Mips32 |
| 144 | bool Os16; |
| 145 | |
| Jack Carter | 3a2c2d4 | 2013-08-13 20:54:07 +0000 | [diff] [blame] | 146 | // HasMSA -- supports MSA ASE. |
| 147 | bool HasMSA; |
| 148 | |
| Daniel Sanders | 3ebcaf6 | 2015-09-03 12:31:22 +0000 | [diff] [blame] | 149 | // UseTCCInDIV -- Enables the use of trapping in the assembler. |
| 150 | bool UseTCCInDIV; |
| 151 | |
| Simon Dardis | ca74dd7 | 2017-01-27 11:36:52 +0000 | [diff] [blame] | 152 | // Sym32 -- On Mips64 symbols are 32 bits. |
| 153 | bool HasSym32; |
| 154 | |
| Daniel Sanders | e4e83a7 | 2015-09-15 10:02:16 +0000 | [diff] [blame] | 155 | // HasEVA -- supports EVA ASE. |
| 156 | bool HasEVA; |
| Stefan Maksimovic | add20f8 | 2017-06-09 07:57:05 +0000 | [diff] [blame] | 157 | |
| Petar Jovanovic | 64fb7a8 | 2017-06-06 15:33:01 +0000 | [diff] [blame] | 158 | // nomadd4 - disables generation of 4-operand madd.s, madd.d and |
| 159 | // related instructions. |
| 160 | bool DisableMadd4; |
| Daniel Sanders | e4e83a7 | 2015-09-15 10:02:16 +0000 | [diff] [blame] | 161 | |
| Simon Dardis | ae719c5 | 2017-07-11 18:03:20 +0000 | [diff] [blame] | 162 | // HasMT -- support MT ASE. |
| 163 | bool HasMT; |
| 164 | |
| Petar Jovanovic | 3408caf | 2018-03-14 14:13:31 +0000 | [diff] [blame] | 165 | // HasCRC -- supports R6 CRC ASE |
| 166 | bool HasCRC; |
| 167 | |
| Petar Jovanovic | d4349f3 | 2018-04-27 09:12:08 +0000 | [diff] [blame^] | 168 | // HasVirt -- supports Virtualization ASE |
| 169 | bool HasVirt; |
| 170 | |
| Simon Dardis | 7bc8ad5 | 2018-02-21 00:06:53 +0000 | [diff] [blame] | 171 | // Use hazard variants of the jump register instructions for indirect |
| 172 | // function calls and jump tables. |
| 173 | bool UseIndirectJumpsHazard; |
| 174 | |
| Simon Atanasyan | f217c7b | 2017-07-15 07:14:25 +0000 | [diff] [blame] | 175 | // Disable use of the `jal` instruction. |
| 176 | bool UseLongCalls = false; |
| 177 | |
| John Baldwin | 1255b16 | 2017-08-14 21:49:38 +0000 | [diff] [blame] | 178 | /// The minimum alignment known to hold of the stack frame on |
| 179 | /// entry to the function and which must be maintained by every function. |
| 180 | unsigned stackAlignment; |
| 181 | |
| 182 | /// The overridden stack alignment. |
| 183 | unsigned StackAlignOverride; |
| 184 | |
| Bruno Cardoso Lopes | 87beec9 | 2007-08-18 01:52:27 +0000 | [diff] [blame] | 185 | InstrItineraryData InstrItins; |
| 186 | |
| Reed Kotler | 1595f36 | 2013-04-09 19:46:01 +0000 | [diff] [blame] | 187 | // We can override the determination of whether we are in mips16 mode |
| 188 | // as from the command line |
| 189 | enum {NoOverride, Mips16Override, NoMips16Override} OverrideMode; |
| 190 | |
| Eric Christopher | 9072428 | 2015-01-08 18:18:57 +0000 | [diff] [blame] | 191 | const MipsTargetMachine &TM; |
| Reed Kotler | 1595f36 | 2013-04-09 19:46:01 +0000 | [diff] [blame] | 192 | |
| Petar Jovanovic | 9725016 | 2014-02-05 17:19:30 +0000 | [diff] [blame] | 193 | Triple TargetTriple; |
| Eric Christopher | 1f51ddd | 2014-07-02 00:54:12 +0000 | [diff] [blame] | 194 | |
| Benjamin Kramer | f9172fd4 | 2016-01-27 16:32:26 +0000 | [diff] [blame] | 195 | const SelectionDAGTargetInfo TSInfo; |
| Eric Christopher | daa9dbb | 2014-07-03 00:10:24 +0000 | [diff] [blame] | 196 | std::unique_ptr<const MipsInstrInfo> InstrInfo; |
| 197 | std::unique_ptr<const MipsFrameLowering> FrameLowering; |
| 198 | std::unique_ptr<const MipsTargetLowering> TLInfo; |
| Eric Christopher | 5f9fd21 | 2014-07-02 21:29:23 +0000 | [diff] [blame] | 199 | |
| Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 200 | public: |
| Rafael Espindola | b30e66b | 2016-06-28 14:33:28 +0000 | [diff] [blame] | 201 | bool isPositionIndependent() const; |
| Sanjay Patel | a2f658d | 2014-07-15 22:39:58 +0000 | [diff] [blame] | 202 | /// This overrides the PostRAScheduler bit in the SchedModel for each CPU. |
| Matthias Braun | 39a2afc | 2015-06-13 03:42:16 +0000 | [diff] [blame] | 203 | bool enablePostRAScheduler() const override; |
| Sanjay Patel | a2f658d | 2014-07-15 22:39:58 +0000 | [diff] [blame] | 204 | void getCriticalPathRCs(RegClassVector &CriticalPathRCs) const override; |
| 205 | CodeGenOpt::Level getOptLevelToEnablePostRAScheduler() const override; |
| Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 206 | |
| Eric Christopher | a576281 | 2015-01-26 17:33:46 +0000 | [diff] [blame] | 207 | bool isABI_N64() const; |
| 208 | bool isABI_N32() const; |
| 209 | bool isABI_O32() const; |
| 210 | const MipsABIInfo &getABI() const; |
| Sasa Stankovic | b976fee | 2014-07-14 09:40:29 +0000 | [diff] [blame] | 211 | bool isABI_FPXX() const { return isABI_O32() && IsFPXX; } |
| Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 212 | |
| Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 213 | /// This constructor initializes the data members to match that |
| Daniel Dunbar | 31b44e8 | 2009-08-02 22:11:08 +0000 | [diff] [blame] | 214 | /// of the specified triple. |
| Simon Atanasyan | 039b02ec | 2017-05-23 15:00:26 +0000 | [diff] [blame] | 215 | MipsSubtarget(const Triple &TT, StringRef CPU, StringRef FS, bool little, |
| John Baldwin | 1255b16 | 2017-08-14 21:49:38 +0000 | [diff] [blame] | 216 | const MipsTargetMachine &TM, unsigned StackAlignOverride); |
| Bruno Cardoso Lopes | ed874ef | 2011-03-04 17:51:39 +0000 | [diff] [blame] | 217 | |
| 218 | /// ParseSubtargetFeatures - Parses features string setting specified |
| Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 219 | /// subtarget options. Definition of function is auto generated by tblgen. |
| Evan Cheng | 1a72add6 | 2011-07-07 07:07:08 +0000 | [diff] [blame] | 220 | void ParseSubtargetFeatures(StringRef CPU, StringRef FS); |
| Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 221 | |
| Vladimir Medic | fb8a2a9 | 2014-07-08 08:59:22 +0000 | [diff] [blame] | 222 | bool hasMips1() const { return MipsArchVersion >= Mips1; } |
| Daniel Sanders | d39320c | 2014-05-08 12:40:48 +0000 | [diff] [blame] | 223 | bool hasMips2() const { return MipsArchVersion >= Mips2; } |
| Daniel Sanders | f2056be | 2014-05-09 13:02:27 +0000 | [diff] [blame] | 224 | bool hasMips3() const { return MipsArchVersion >= Mips3; } |
| Vladimir Medic | fb8a2a9 | 2014-07-08 08:59:22 +0000 | [diff] [blame] | 225 | bool hasMips4() const { return MipsArchVersion >= Mips4; } |
| 226 | bool hasMips5() const { return MipsArchVersion >= Mips5; } |
| Daniel Sanders | e57d866 | 2014-05-09 14:06:17 +0000 | [diff] [blame] | 227 | bool hasMips4_32() const { return HasMips4_32; } |
| Daniel Sanders | 94eda2e | 2014-05-12 11:56:16 +0000 | [diff] [blame] | 228 | bool hasMips4_32r2() const { return HasMips4_32r2; } |
| Daniel Sanders | 0046311 | 2014-06-16 13:18:59 +0000 | [diff] [blame] | 229 | bool hasMips32() const { |
| Daniel Sanders | e67d27f | 2015-02-04 15:18:11 +0000 | [diff] [blame] | 230 | return (MipsArchVersion >= Mips32 && MipsArchVersion < Mips32Max) || |
| 231 | hasMips64(); |
| Daniel Sanders | 0046311 | 2014-06-16 13:18:59 +0000 | [diff] [blame] | 232 | } |
| Daniel Sanders | 1f6f0f4 | 2014-06-12 11:55:58 +0000 | [diff] [blame] | 233 | bool hasMips32r2() const { |
| Daniel Sanders | e67d27f | 2015-02-04 15:18:11 +0000 | [diff] [blame] | 234 | return (MipsArchVersion >= Mips32r2 && MipsArchVersion < Mips32Max) || |
| 235 | hasMips64r2(); |
| Daniel Sanders | 1f6f0f4 | 2014-06-12 11:55:58 +0000 | [diff] [blame] | 236 | } |
| Daniel Sanders | 1779314 | 2015-02-18 16:24:50 +0000 | [diff] [blame] | 237 | bool hasMips32r3() const { |
| 238 | return (MipsArchVersion >= Mips32r3 && MipsArchVersion < Mips32Max) || |
| 239 | hasMips64r2(); |
| 240 | } |
| 241 | bool hasMips32r5() const { |
| 242 | return (MipsArchVersion >= Mips32r5 && MipsArchVersion < Mips32Max) || |
| Vasileios Kalintiris | 974d409 | 2015-07-20 12:28:56 +0000 | [diff] [blame] | 243 | hasMips64r5(); |
| Daniel Sanders | 1779314 | 2015-02-18 16:24:50 +0000 | [diff] [blame] | 244 | } |
| Daniel Sanders | 1f6f0f4 | 2014-06-12 11:55:58 +0000 | [diff] [blame] | 245 | bool hasMips32r6() const { |
| Daniel Sanders | e67d27f | 2015-02-04 15:18:11 +0000 | [diff] [blame] | 246 | return (MipsArchVersion >= Mips32r6 && MipsArchVersion < Mips32Max) || |
| 247 | hasMips64r6(); |
| Daniel Sanders | 1f6f0f4 | 2014-06-12 11:55:58 +0000 | [diff] [blame] | 248 | } |
| Akira Hatanaka | 6e506eb | 2011-09-21 02:24:25 +0000 | [diff] [blame] | 249 | bool hasMips64() const { return MipsArchVersion >= Mips64; } |
| Daniel Sanders | e67d27f | 2015-02-04 15:18:11 +0000 | [diff] [blame] | 250 | bool hasMips64r2() const { return MipsArchVersion >= Mips64r2; } |
| Daniel Sanders | 1779314 | 2015-02-18 16:24:50 +0000 | [diff] [blame] | 251 | bool hasMips64r3() const { return MipsArchVersion >= Mips64r3; } |
| 252 | bool hasMips64r5() const { return MipsArchVersion >= Mips64r5; } |
| Daniel Sanders | e67d27f | 2015-02-04 15:18:11 +0000 | [diff] [blame] | 253 | bool hasMips64r6() const { return MipsArchVersion >= Mips64r6; } |
| Bruno Cardoso Lopes | 326a037 | 2008-06-04 01:45:25 +0000 | [diff] [blame] | 254 | |
| Kai Nacke | 93fe5e8 | 2014-03-20 11:51:58 +0000 | [diff] [blame] | 255 | bool hasCnMips() const { return HasCnMips; } |
| 256 | |
| Bruno Cardoso Lopes | 326a037 | 2008-06-04 01:45:25 +0000 | [diff] [blame] | 257 | bool isLittle() const { return IsLittle; } |
| Daniel Sanders | feb6130 | 2014-08-08 15:47:17 +0000 | [diff] [blame] | 258 | bool isABICalls() const { return !NoABICalls; } |
| Zoran Jovanovic | 255d00d | 2014-07-10 15:36:12 +0000 | [diff] [blame] | 259 | bool isFPXX() const { return IsFPXX; } |
| Douglas Gregor | 740ab38 | 2009-12-19 07:05:23 +0000 | [diff] [blame] | 260 | bool isFP64bit() const { return IsFP64bit; } |
| Daniel Sanders | 7e52742 | 2014-07-10 13:38:23 +0000 | [diff] [blame] | 261 | bool useOddSPReg() const { return UseOddSPReg; } |
| Sasa Stankovic | f4a9e3b | 2014-07-29 14:39:24 +0000 | [diff] [blame] | 262 | bool noOddSPReg() const { return !UseOddSPReg; } |
| Matheus Almeida | 0051f2d | 2014-04-16 15:48:55 +0000 | [diff] [blame] | 263 | bool isNaN2008() const { return IsNaN2008bit; } |
| Douglas Gregor | 740ab38 | 2009-12-19 07:05:23 +0000 | [diff] [blame] | 264 | bool isGP64bit() const { return IsGP64bit; } |
| 265 | bool isGP32bit() const { return !IsGP64bit; } |
| Daniel Sanders | 2b746bc | 2014-09-09 12:11:16 +0000 | [diff] [blame] | 266 | unsigned getGPRSizeInBytes() const { return isGP64bit() ? 8 : 4; } |
| Simon Dardis | 4fbf76f | 2016-06-14 11:29:28 +0000 | [diff] [blame] | 267 | bool isPTR64bit() const { return IsPTR64bit; } |
| 268 | bool isPTR32bit() const { return !IsPTR64bit; } |
| Simon Dardis | ca74dd7 | 2017-01-27 11:36:52 +0000 | [diff] [blame] | 269 | bool hasSym32() const { |
| 270 | return (HasSym32 && isABI_N64()) || isABI_N32() || isABI_O32(); |
| 271 | } |
| Douglas Gregor | 740ab38 | 2009-12-19 07:05:23 +0000 | [diff] [blame] | 272 | bool isSingleFloat() const { return IsSingleFloat; } |
| Sagar Thakur | ec65792 | 2017-02-15 10:48:11 +0000 | [diff] [blame] | 273 | bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); } |
| Douglas Gregor | 740ab38 | 2009-12-19 07:05:23 +0000 | [diff] [blame] | 274 | bool hasVFPU() const { return HasVFPU; } |
| Eric Christopher | 4e7d1e7 | 2014-07-18 23:41:32 +0000 | [diff] [blame] | 275 | bool inMips16Mode() const { return InMips16Mode; } |
| Reed Kotler | 783c794 | 2013-05-10 22:25:39 +0000 | [diff] [blame] | 276 | bool inMips16ModeDefault() const { |
| Reed Kotler | 1595f36 | 2013-04-09 19:46:01 +0000 | [diff] [blame] | 277 | return InMips16Mode; |
| 278 | } |
| Eric Christopher | 7394e23 | 2014-07-18 00:08:50 +0000 | [diff] [blame] | 279 | // Hard float for mips16 means essentially to compile as soft float |
| 280 | // but to use a runtime library for soft float that is written with |
| 281 | // native mips32 floating point instructions (those runtime routines |
| 282 | // run in mips32 hard float mode). |
| Reed Kotler | 783c794 | 2013-05-10 22:25:39 +0000 | [diff] [blame] | 283 | bool inMips16HardFloat() const { |
| 284 | return inMips16Mode() && InMips16HardFloat; |
| 285 | } |
| Jack Carter | 428a06c | 2013-02-05 09:30:03 +0000 | [diff] [blame] | 286 | bool inMicroMipsMode() const { return InMicroMipsMode; } |
| Jozef Kolek | c22555d | 2015-04-20 12:23:06 +0000 | [diff] [blame] | 287 | bool inMicroMips32r6Mode() const { return InMicroMipsMode && hasMips32r6(); } |
| Akira Hatanaka | 65ce931 | 2012-09-21 23:41:49 +0000 | [diff] [blame] | 288 | bool hasDSP() const { return HasDSP; } |
| 289 | bool hasDSPR2() const { return HasDSPR2; } |
| Zoran Jovanovic | 2e386d3 | 2015-10-12 16:07:25 +0000 | [diff] [blame] | 290 | bool hasDSPR3() const { return HasDSPR3; } |
| Jack Carter | 3a2c2d4 | 2013-08-13 20:54:07 +0000 | [diff] [blame] | 291 | bool hasMSA() const { return HasMSA; } |
| Petar Jovanovic | 64fb7a8 | 2017-06-06 15:33:01 +0000 | [diff] [blame] | 292 | bool disableMadd4() const { return DisableMadd4; } |
| Daniel Sanders | e4e83a7 | 2015-09-15 10:02:16 +0000 | [diff] [blame] | 293 | bool hasEVA() const { return HasEVA; } |
| Simon Dardis | ae719c5 | 2017-07-11 18:03:20 +0000 | [diff] [blame] | 294 | bool hasMT() const { return HasMT; } |
| Petar Jovanovic | 3408caf | 2018-03-14 14:13:31 +0000 | [diff] [blame] | 295 | bool hasCRC() const { return HasCRC; } |
| Petar Jovanovic | d4349f3 | 2018-04-27 09:12:08 +0000 | [diff] [blame^] | 296 | bool hasVirt() const { return HasVirt; } |
| Simon Dardis | 7bc8ad5 | 2018-02-21 00:06:53 +0000 | [diff] [blame] | 297 | bool useIndirectJumpsHazard() const { |
| 298 | return UseIndirectJumpsHazard && hasMips32r2(); |
| 299 | } |
| Akira Hatanaka | ad49502 | 2012-08-22 03:18:13 +0000 | [diff] [blame] | 300 | bool useSmallSection() const { return UseSmallSection; } |
| Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 301 | |
| Akira Hatanaka | cdf4fd8 | 2012-05-22 03:10:09 +0000 | [diff] [blame] | 302 | bool hasStandardEncoding() const { return !inMips16Mode(); } |
| 303 | |
| Eric Christopher | 54966eb | 2015-05-07 23:10:23 +0000 | [diff] [blame] | 304 | bool useSoftFloat() const { return IsSoftFloat; } |
| Reed Kotler | c03807a | 2013-08-30 19:40:56 +0000 | [diff] [blame] | 305 | |
| Simon Atanasyan | f217c7b | 2017-07-15 07:14:25 +0000 | [diff] [blame] | 306 | bool useLongCalls() const { return UseLongCalls; } |
| 307 | |
| Akira Hatanaka | a8a05be | 2013-10-07 19:06:57 +0000 | [diff] [blame] | 308 | bool enableLongBranchPass() const { |
| 309 | return hasStandardEncoding() || allowMixed16_32(); |
| 310 | } |
| 311 | |
| Bruno Cardoso Lopes | f714e25 | 2008-07-30 17:01:06 +0000 | [diff] [blame] | 312 | /// Features related to the presence of specific instructions. |
| Akira Hatanaka | 4a3836b | 2013-10-09 23:36:17 +0000 | [diff] [blame] | 313 | bool hasExtractInsert() const { return !inMips16Mode() && hasMips32r2(); } |
| Sasa Stankovic | b976fee | 2014-07-14 09:40:29 +0000 | [diff] [blame] | 314 | bool hasMTHC1() const { return hasMips32r2(); } |
| Jack Carter | c1b17ed | 2013-01-18 21:20:38 +0000 | [diff] [blame] | 315 | |
| Reed Kotler | 783c794 | 2013-05-10 22:25:39 +0000 | [diff] [blame] | 316 | bool allowMixed16_32() const { return inMips16ModeDefault() | |
| Toma Tabacu | f476200 | 2015-01-16 10:45:15 +0000 | [diff] [blame] | 317 | AllowMixed16_32; } |
| Reed Kotler | 1595f36 | 2013-04-09 19:46:01 +0000 | [diff] [blame] | 318 | |
| Toma Tabacu | f476200 | 2015-01-16 10:45:15 +0000 | [diff] [blame] | 319 | bool os16() const { return Os16; } |
| Reed Kotler | fe94cc3 | 2013-04-10 16:58:04 +0000 | [diff] [blame] | 320 | |
| Petar Jovanovic | 9725016 | 2014-02-05 17:19:30 +0000 | [diff] [blame] | 321 | bool isTargetNaCl() const { return TargetTriple.isOSNaCl(); } |
| 322 | |
| Sagar Thakur | ec65792 | 2017-02-15 10:48:11 +0000 | [diff] [blame] | 323 | bool isXRaySupported() const override { return true; } |
| 324 | |
| Daniel Sanders | 82cd99a | 2014-04-16 14:38:27 +0000 | [diff] [blame] | 325 | // for now constant islands are on for the whole compilation unit but we only |
| 326 | // really use them if in addition we are in mips16 mode |
| 327 | static bool useConstantIslands(); |
| Akira Hatanaka | 6b2d841 | 2013-10-29 19:29:03 +0000 | [diff] [blame] | 328 | |
| John Baldwin | 1255b16 | 2017-08-14 21:49:38 +0000 | [diff] [blame] | 329 | unsigned getStackAlignment() const { return stackAlignment; } |
| Akira Hatanaka | 6b2d841 | 2013-10-29 19:29:03 +0000 | [diff] [blame] | 330 | |
| Jack Carter | 7f37810 | 2013-01-30 02:16:36 +0000 | [diff] [blame] | 331 | // Grab relocation model |
| Eric Christopher | f74faf4 | 2014-07-18 22:34:20 +0000 | [diff] [blame] | 332 | Reloc::Model getRelocationModel() const; |
| Reed Kotler | 1595f36 | 2013-04-09 19:46:01 +0000 | [diff] [blame] | 333 | |
| Eric Christopher | daa9dbb | 2014-07-03 00:10:24 +0000 | [diff] [blame] | 334 | MipsSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS, |
| Eric Christopher | 9072428 | 2015-01-08 18:18:57 +0000 | [diff] [blame] | 335 | const TargetMachine &TM); |
| Eric Christopher | 5b336a2 | 2014-07-02 01:14:43 +0000 | [diff] [blame] | 336 | |
| Daniel Sanders | ac27263 | 2014-05-23 13:18:02 +0000 | [diff] [blame] | 337 | /// Does the system support unaligned memory access. |
| 338 | /// |
| 339 | /// MIPS32r6/MIPS64r6 require full unaligned access support but does not |
| 340 | /// specify which component of the system provides it. Hardware, software, and |
| 341 | /// hybrid implementations are all valid. |
| 342 | bool systemSupportsUnalignedAccess() const { return hasMips32r6(); } |
| Eric Christopher | 1f51ddd | 2014-07-02 00:54:12 +0000 | [diff] [blame] | 343 | |
| Eric Christopher | daa9dbb | 2014-07-03 00:10:24 +0000 | [diff] [blame] | 344 | // Set helper classes |
| 345 | void setHelperClassesMips16(); |
| 346 | void setHelperClassesMipsSE(); |
| 347 | |
| Benjamin Kramer | f9172fd4 | 2016-01-27 16:32:26 +0000 | [diff] [blame] | 348 | const SelectionDAGTargetInfo *getSelectionDAGInfo() const override { |
| Eric Christopher | d913448 | 2014-08-04 21:25:23 +0000 | [diff] [blame] | 349 | return &TSInfo; |
| 350 | } |
| Eric Christopher | d913448 | 2014-08-04 21:25:23 +0000 | [diff] [blame] | 351 | const MipsInstrInfo *getInstrInfo() const override { return InstrInfo.get(); } |
| 352 | const TargetFrameLowering *getFrameLowering() const override { |
| Eric Christopher | daa9dbb | 2014-07-03 00:10:24 +0000 | [diff] [blame] | 353 | return FrameLowering.get(); |
| 354 | } |
| Eric Christopher | d913448 | 2014-08-04 21:25:23 +0000 | [diff] [blame] | 355 | const MipsRegisterInfo *getRegisterInfo() const override { |
| Eric Christopher | daa9dbb | 2014-07-03 00:10:24 +0000 | [diff] [blame] | 356 | return &InstrInfo->getRegisterInfo(); |
| 357 | } |
| Eric Christopher | d913448 | 2014-08-04 21:25:23 +0000 | [diff] [blame] | 358 | const MipsTargetLowering *getTargetLowering() const override { |
| 359 | return TLInfo.get(); |
| 360 | } |
| 361 | const InstrItineraryData *getInstrItineraryData() const override { |
| 362 | return &InstrItins; |
| 363 | } |
| Petar Jovanovic | fac93e2 | 2018-02-23 11:06:40 +0000 | [diff] [blame] | 364 | |
| 365 | protected: |
| 366 | // GlobalISel related APIs. |
| 367 | std::unique_ptr<CallLowering> CallLoweringInfo; |
| 368 | std::unique_ptr<LegalizerInfo> Legalizer; |
| 369 | std::unique_ptr<RegisterBankInfo> RegBankInfo; |
| 370 | std::unique_ptr<InstructionSelector> InstSelector; |
| 371 | |
| 372 | public: |
| 373 | const CallLowering *getCallLowering() const override; |
| 374 | const LegalizerInfo *getLegalizerInfo() const override; |
| 375 | const RegisterBankInfo *getRegBankInfo() const override; |
| 376 | const InstructionSelector *getInstructionSelector() const override; |
| Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 377 | }; |
| Alexander Kornienko | f00654e | 2015-06-23 09:49:53 +0000 | [diff] [blame] | 378 | } // End llvm namespace |
| Bruno Cardoso Lopes | 35e43c4 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 379 | |
| 380 | #endif |