blob: 63cde8d66894c5eac5378189333634eb92b22cce [file] [log] [blame]
Jia Liubb481f82012-02-28 07:46:26 +00001//===-- MipsSubtarget.h - Define Subtarget for the Mips ---------*- C++ -*-===//
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +00007//
Akira Hatanaka4552c9a2011-04-15 21:51:11 +00008//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +00009//
Evan Cheng5b1b44892011-07-01 21:01:15 +000010// This file declares the Mips specific subclass of TargetSubtargetInfo.
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000011//
Akira Hatanaka4552c9a2011-04-15 21:51:11 +000012//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000013
14#ifndef MIPSSUBTARGET_H
15#define MIPSSUBTARGET_H
16
Jack Carterc91cbb92013-01-18 21:20:38 +000017#include "MCTargetDesc/MipsReginfo.h"
Evan Chengab8be962011-06-29 01:14:12 +000018#include "llvm/MC/MCInstrItineraries.h"
Chandler Carrutha1514e22012-12-04 07:12:27 +000019#include "llvm/Target/TargetSubtargetInfo.h"
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000020#include <string>
21
Evan Cheng94214702011-07-01 20:45:01 +000022#define GET_SUBTARGETINFO_HEADER
Evan Cheng385e9302011-07-01 22:36:09 +000023#include "MipsGenSubtargetInfo.inc"
Evan Cheng94214702011-07-01 20:45:01 +000024
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000025namespace llvm {
Evan Cheng0ddff1b2011-07-07 07:07:08 +000026class StringRef;
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000027
Evan Cheng94214702011-07-01 20:45:01 +000028class MipsSubtarget : public MipsGenSubtargetInfo {
David Blaikie2d24e2a2011-12-20 02:50:00 +000029 virtual void anchor();
Bruno Cardoso Lopes13d1b7b2007-08-18 01:52:27 +000030
Bruno Cardoso Lopes43d526d2008-07-14 14:42:54 +000031public:
Akira Hatanaka0b7b6a02011-09-14 17:22:51 +000032 // NOTE: O64 will not be supported.
Bruno Cardoso Lopes43d526d2008-07-14 14:42:54 +000033 enum MipsABIEnum {
Akira Hatanaka8c1b4bf2011-09-21 02:45:29 +000034 UnknownABI, O32, N32, N64, EABI
Bruno Cardoso Lopes81092dc2011-03-04 17:51:39 +000035 };
Bruno Cardoso Lopes43d526d2008-07-14 14:42:54 +000036
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000037protected:
Bruno Cardoso Lopes13d1b7b2007-08-18 01:52:27 +000038
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000039 enum MipsArchEnum {
Akira Hatanaka1daa5be2011-09-20 20:28:08 +000040 Mips32, Mips32r2, Mips64, Mips64r2
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000041 };
42
Bruno Cardoso Lopes81092dc2011-03-04 17:51:39 +000043 // Mips architecture version
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000044 MipsArchEnum MipsArchVersion;
45
Bruno Cardoso Lopes81092dc2011-03-04 17:51:39 +000046 // Mips supported ABIs
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000047 MipsABIEnum MipsABI;
48
49 // IsLittle - The target is Little Endian
Bruno Cardoso Lopesd2947ee2008-06-04 01:45:25 +000050 bool IsLittle;
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000051
52 // IsSingleFloat - The target only supports single precision float
53 // point operations. This enable the target to use all 32 32-bit
Bruno Cardoso Lopes7b76da12008-07-09 04:45:36 +000054 // floating point registers instead of only using even ones.
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000055 bool IsSingleFloat;
56
Bruno Cardoso Lopes7b76da12008-07-09 04:45:36 +000057 // IsFP64bit - The target processor has 64-bit floating point registers.
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000058 bool IsFP64bit;
59
60 // IsFP64bit - General-purpose registers are 64 bits wide
61 bool IsGP64bit;
62
Bruno Cardoso Lopes7728f7e2008-07-09 05:32:22 +000063 // HasVFPU - Processor has a vector floating point unit.
64 bool HasVFPU;
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000065
Bruno Cardoso Lopes43d526d2008-07-14 14:42:54 +000066 // isLinux - Target system is Linux. Is false we consider ELFOS for now.
67 bool IsLinux;
68
Akira Hatanakae7338cd2012-08-22 03:18:13 +000069 // UseSmallSection - Small section is used.
70 bool UseSmallSection;
71
Bruno Cardoso Lopesd3a680d2008-07-30 17:01:06 +000072 /// Features related to the presence of specific instructions.
Bruno Cardoso Lopes81092dc2011-03-04 17:51:39 +000073
Bruno Cardoso Lopesd3a680d2008-07-30 17:01:06 +000074 // HasSEInReg - SEB and SEH (signext in register) instructions.
75 bool HasSEInReg;
76
77 // HasCondMov - Conditional mov (MOVZ, MOVN) instructions.
78 bool HasCondMov;
79
Bruno Cardoso Lopesd3a680d2008-07-30 17:01:06 +000080 // HasSwap - Byte and half swap instructions.
81 bool HasSwap;
82
83 // HasBitCount - Count leading '1' and '0' bits.
84 bool HasBitCount;
85
Akira Hatanaka0301bc52012-11-15 21:17:13 +000086 // HasFPIdx -- Floating point indexed load/store instructions.
87 bool HasFPIdx;
88
Akira Hatanaka66e19c32012-05-16 22:19:56 +000089 // InMips16 -- can process Mips16 instructions
90 bool InMips16Mode;
91
Akira Hatanakaa9adbf62012-09-21 23:41:49 +000092 // HasDSP, HasDSPR2 -- supports DSP ASE.
93 bool HasDSP, HasDSPR2;
94
Akira Hatanakabb2e1b52012-08-16 03:48:05 +000095 // IsAndroid -- target is android
96 bool IsAndroid;
97
Bruno Cardoso Lopes13d1b7b2007-08-18 01:52:27 +000098 InstrItineraryData InstrItins;
99
Jack Carterc91cbb92013-01-18 21:20:38 +0000100 // The instance to the register info section object
101 MipsReginfo MRI;
102
Jack Carterdba14302013-01-30 02:16:36 +0000103 // Relocation Model
104 Reloc::Model RM;
105
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +0000106public:
Akira Hatanaka81a424b2012-03-28 00:24:17 +0000107 virtual bool enablePostRAScheduler(CodeGenOpt::Level OptLevel,
108 AntiDepBreakMode& Mode,
109 RegClassVector& CriticalPathRCs) const;
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +0000110
111 /// Only O32 and EABI supported right now.
112 bool isABI_EABI() const { return MipsABI == EABI; }
Akira Hatanaka1daa5be2011-09-20 20:28:08 +0000113 bool isABI_N64() const { return MipsABI == N64; }
114 bool isABI_N32() const { return MipsABI == N32; }
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +0000115 bool isABI_O32() const { return MipsABI == O32; }
Bruno Cardoso Lopes43d526d2008-07-14 14:42:54 +0000116 unsigned getTargetABI() const { return MipsABI; }
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +0000117
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +0000118 /// This constructor initializes the data members to match that
Daniel Dunbar3be03402009-08-02 22:11:08 +0000119 /// of the specified triple.
Evan Cheng276365d2011-06-30 01:53:36 +0000120 MipsSubtarget(const std::string &TT, const std::string &CPU,
Akira Hatanakae7338cd2012-08-22 03:18:13 +0000121 const std::string &FS, bool little, Reloc::Model RM);
Bruno Cardoso Lopes81092dc2011-03-04 17:51:39 +0000122
123 /// ParseSubtargetFeatures - Parses features string setting specified
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +0000124 /// subtarget options. Definition of function is auto generated by tblgen.
Evan Cheng0ddff1b2011-07-07 07:07:08 +0000125 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +0000126
Akira Hatanaka56633442011-09-20 23:53:09 +0000127 bool hasMips32() const { return MipsArchVersion >= Mips32; }
128 bool hasMips32r2() const { return MipsArchVersion == Mips32r2 ||
Akira Hatanaka1daa5be2011-09-20 20:28:08 +0000129 MipsArchVersion == Mips64r2; }
Akira Hatanaka50fa74e2011-09-21 02:24:25 +0000130 bool hasMips64() const { return MipsArchVersion >= Mips64; }
131 bool hasMips64r2() const { return MipsArchVersion == Mips64r2; }
Bruno Cardoso Lopesd2947ee2008-06-04 01:45:25 +0000132
Bruno Cardoso Lopesd2947ee2008-06-04 01:45:25 +0000133 bool isLittle() const { return IsLittle; }
Douglas Gregorcabdd742009-12-19 07:05:23 +0000134 bool isFP64bit() const { return IsFP64bit; }
135 bool isGP64bit() const { return IsGP64bit; }
136 bool isGP32bit() const { return !IsGP64bit; }
137 bool isSingleFloat() const { return IsSingleFloat; }
138 bool isNotSingleFloat() const { return !IsSingleFloat; }
139 bool hasVFPU() const { return HasVFPU; }
Akira Hatanaka66e19c32012-05-16 22:19:56 +0000140 bool inMips16Mode() const { return InMips16Mode; }
Akira Hatanakaa9adbf62012-09-21 23:41:49 +0000141 bool hasDSP() const { return HasDSP; }
142 bool hasDSPR2() const { return HasDSPR2; }
Akira Hatanakabb2e1b52012-08-16 03:48:05 +0000143 bool isAndroid() const { return IsAndroid; }
Douglas Gregorcabdd742009-12-19 07:05:23 +0000144 bool isLinux() const { return IsLinux; }
Akira Hatanakae7338cd2012-08-22 03:18:13 +0000145 bool useSmallSection() const { return UseSmallSection; }
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +0000146
Akira Hatanaka18f3c782012-05-22 03:10:09 +0000147 bool hasStandardEncoding() const { return !inMips16Mode(); }
148
Bruno Cardoso Lopesd3a680d2008-07-30 17:01:06 +0000149 /// Features related to the presence of specific instructions.
Douglas Gregorcabdd742009-12-19 07:05:23 +0000150 bool hasSEInReg() const { return HasSEInReg; }
151 bool hasCondMov() const { return HasCondMov; }
Douglas Gregorcabdd742009-12-19 07:05:23 +0000152 bool hasSwap() const { return HasSwap; }
153 bool hasBitCount() const { return HasBitCount; }
Akira Hatanaka0301bc52012-11-15 21:17:13 +0000154 bool hasFPIdx() const { return HasFPIdx; }
Jack Carterc91cbb92013-01-18 21:20:38 +0000155
156 // Grab MipsRegInfo object
157 const MipsReginfo &getMReginfo() const { return MRI; }
Jack Carterdba14302013-01-30 02:16:36 +0000158
159 // Grab relocation model
160 Reloc::Model getRelocationModel() const {return RM;}
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +0000161};
162} // End llvm namespace
163
164#endif