• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//===-- Mips.td - Describe the Mips Target Machine ---------*- tablegen -*-===//
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// This is the top level entry point for the Mips target.
10//===----------------------------------------------------------------------===//
11
12//===----------------------------------------------------------------------===//
13// Target-independent interfaces
14//===----------------------------------------------------------------------===//
15
16include "llvm/Target/Target.td"
17
18// The overall idea of the PredicateControl class is to chop the Predicates list
19// into subsets that are usually overridden independently. This allows
20// subclasses to partially override the predicates of their superclasses without
21// having to re-add all the existing predicates.
22class PredicateControl {
23  // Predicates for the encoding scheme in use such as HasStdEnc
24  list<Predicate> EncodingPredicates = [];
25  // Predicates for the GPR size such as IsGP64bit
26  list<Predicate> GPRPredicates = [];
27  // Predicates for the PTR size such as IsPTR64bit
28  list<Predicate> PTRPredicates = [];
29  // Predicates for the FGR size and layout such as IsFP64bit
30  list<Predicate> FGRPredicates = [];
31  // Predicates for the instruction group membership such as ISA's.
32  list<Predicate> InsnPredicates = [];
33  // Predicate for the ASE that an instruction belongs to.
34  list<Predicate> ASEPredicate = [];
35  // Predicate for marking the instruction as usable in hard-float mode only.
36  list<Predicate> HardFloatPredicate = [];
37  // Predicates for anything else
38  list<Predicate> AdditionalPredicates = [];
39  list<Predicate> Predicates = !listconcat(EncodingPredicates,
40                                           GPRPredicates,
41                                           PTRPredicates,
42                                           FGRPredicates,
43                                           InsnPredicates,
44                                           HardFloatPredicate,
45                                           ASEPredicate,
46                                           AdditionalPredicates);
47}
48
49// Like Requires<> but for the AdditionalPredicates list
50class AdditionalRequires<list<Predicate> preds> {
51  list<Predicate> AdditionalPredicates = preds;
52}
53
54//===----------------------------------------------------------------------===//
55// Register File, Calling Conv, Instruction Descriptions
56//===----------------------------------------------------------------------===//
57
58include "MipsRegisterInfo.td"
59include "MipsSchedule.td"
60include "MipsInstrInfo.td"
61include "MipsCallingConv.td"
62include "MipsRegisterBanks.td"
63
64// Avoid forward declaration issues.
65include "MipsScheduleP5600.td"
66include "MipsScheduleGeneric.td"
67
68def MipsInstrInfo : InstrInfo;
69
70//===----------------------------------------------------------------------===//
71// Mips Subtarget features                                                    //
72//===----------------------------------------------------------------------===//
73
74def FeatureNoABICalls  : SubtargetFeature<"noabicalls", "NoABICalls", "true",
75                                "Disable SVR4-style position-independent code">;
76def FeaturePTR64Bit    : SubtargetFeature<"ptr64", "IsPTR64bit", "true",
77                                "Pointers are 64-bit wide">;
78def FeatureGP64Bit     : SubtargetFeature<"gp64", "IsGP64bit", "true",
79                                "General Purpose Registers are 64-bit wide">;
80def FeatureFP64Bit     : SubtargetFeature<"fp64", "IsFP64bit", "true",
81                                "Support 64-bit FP registers">;
82def FeatureFPXX        : SubtargetFeature<"fpxx", "IsFPXX", "true",
83                                "Support for FPXX">;
84def FeatureNaN2008     : SubtargetFeature<"nan2008", "IsNaN2008bit", "true",
85                                "IEEE 754-2008 NaN encoding">;
86def FeatureSingleFloat : SubtargetFeature<"single-float", "IsSingleFloat",
87                                "true", "Only supports single precision float">;
88def FeatureSoftFloat   : SubtargetFeature<"soft-float", "IsSoftFloat", "true",
89                                "Does not support floating point instructions">;
90def FeatureNoOddSPReg  : SubtargetFeature<"nooddspreg", "UseOddSPReg", "false",
91                              "Disable odd numbered single-precision "
92                              "registers">;
93def FeatureVFPU        : SubtargetFeature<"vfpu", "HasVFPU",
94                                "true", "Enable vector FPU instructions">;
95def FeatureMips1       : SubtargetFeature<"mips1", "MipsArchVersion", "Mips1",
96                                "Mips I ISA Support [highly experimental]">;
97def FeatureMips2       : SubtargetFeature<"mips2", "MipsArchVersion", "Mips2",
98                                "Mips II ISA Support [highly experimental]",
99                                [FeatureMips1]>;
100def FeatureMips3_32    : SubtargetFeature<"mips3_32", "HasMips3_32", "true",
101                                "Subset of MIPS-III that is also in MIPS32 "
102                                "[highly experimental]">;
103def FeatureMips3_32r2  : SubtargetFeature<"mips3_32r2", "HasMips3_32r2", "true",
104                                "Subset of MIPS-III that is also in MIPS32r2 "
105                                "[highly experimental]">;
106def FeatureMips3       : SubtargetFeature<"mips3", "MipsArchVersion", "Mips3",
107                                "MIPS III ISA Support [highly experimental]",
108                                [FeatureMips2, FeatureMips3_32,
109                                 FeatureMips3_32r2, FeatureGP64Bit,
110                                 FeatureFP64Bit]>;
111def FeatureMips4_32    : SubtargetFeature<"mips4_32", "HasMips4_32", "true",
112                                "Subset of MIPS-IV that is also in MIPS32 "
113                                "[highly experimental]">;
114def FeatureMips4_32r2  : SubtargetFeature<"mips4_32r2", "HasMips4_32r2", "true",
115                                "Subset of MIPS-IV that is also in MIPS32r2 "
116                                "[highly experimental]">;
117def FeatureMips4       : SubtargetFeature<"mips4", "MipsArchVersion",
118                                "Mips4", "MIPS IV ISA Support",
119                                [FeatureMips3, FeatureMips4_32,
120                                 FeatureMips4_32r2]>;
121def FeatureMips5_32r2  : SubtargetFeature<"mips5_32r2", "HasMips5_32r2", "true",
122                                "Subset of MIPS-V that is also in MIPS32r2 "
123                                "[highly experimental]">;
124def FeatureMips5       : SubtargetFeature<"mips5", "MipsArchVersion", "Mips5",
125                                "MIPS V ISA Support [highly experimental]",
126                                [FeatureMips4, FeatureMips5_32r2]>;
127def FeatureMips32      : SubtargetFeature<"mips32", "MipsArchVersion", "Mips32",
128                                "Mips32 ISA Support",
129                                [FeatureMips2, FeatureMips3_32,
130                                 FeatureMips4_32]>;
131def FeatureMips32r2    : SubtargetFeature<"mips32r2", "MipsArchVersion",
132                                "Mips32r2", "Mips32r2 ISA Support",
133                                [FeatureMips3_32r2, FeatureMips4_32r2,
134                                 FeatureMips5_32r2, FeatureMips32]>;
135def FeatureMips32r3    : SubtargetFeature<"mips32r3", "MipsArchVersion",
136                                "Mips32r3", "Mips32r3 ISA Support",
137                                [FeatureMips32r2]>;
138def FeatureMips32r5    : SubtargetFeature<"mips32r5", "MipsArchVersion",
139                                "Mips32r5", "Mips32r5 ISA Support",
140                                [FeatureMips32r3]>;
141def FeatureMips32r6    : SubtargetFeature<"mips32r6", "MipsArchVersion",
142                                "Mips32r6",
143                                "Mips32r6 ISA Support [experimental]",
144                                [FeatureMips32r5, FeatureFP64Bit,
145                                 FeatureNaN2008]>;
146def FeatureMips64      : SubtargetFeature<"mips64", "MipsArchVersion",
147                                "Mips64", "Mips64 ISA Support",
148                                [FeatureMips5, FeatureMips32]>;
149def FeatureMips64r2    : SubtargetFeature<"mips64r2", "MipsArchVersion",
150                                "Mips64r2", "Mips64r2 ISA Support",
151                                [FeatureMips64, FeatureMips32r2]>;
152def FeatureMips64r3    : SubtargetFeature<"mips64r3", "MipsArchVersion",
153                                "Mips64r3", "Mips64r3 ISA Support",
154                                [FeatureMips64r2, FeatureMips32r3]>;
155def FeatureMips64r5    : SubtargetFeature<"mips64r5", "MipsArchVersion",
156                                "Mips64r5", "Mips64r5 ISA Support",
157                                [FeatureMips64r3, FeatureMips32r5]>;
158def FeatureMips64r6    : SubtargetFeature<"mips64r6", "MipsArchVersion",
159                                "Mips64r6",
160                                "Mips64r6 ISA Support [experimental]",
161                                [FeatureMips32r6, FeatureMips64r5,
162                                 FeatureNaN2008]>;
163def FeatureSym32       : SubtargetFeature<"sym32", "HasSym32", "true",
164                                          "Symbols are 32 bit on Mips64">;
165
166def FeatureMips16  : SubtargetFeature<"mips16", "InMips16Mode", "true",
167                                      "Mips16 mode">;
168
169def FeatureDSP : SubtargetFeature<"dsp", "HasDSP", "true", "Mips DSP ASE">;
170def FeatureDSPR2 : SubtargetFeature<"dspr2", "HasDSPR2", "true",
171                                    "Mips DSP-R2 ASE", [FeatureDSP]>;
172def FeatureDSPR3
173    : SubtargetFeature<"dspr3", "HasDSPR3", "true", "Mips DSP-R3 ASE",
174                       [ FeatureDSP, FeatureDSPR2 ]>;
175
176def FeatureMSA : SubtargetFeature<"msa", "HasMSA", "true", "Mips MSA ASE">;
177
178def FeatureEVA : SubtargetFeature<"eva", "HasEVA", "true", "Mips EVA ASE">;
179
180def FeatureCRC : SubtargetFeature<"crc", "HasCRC", "true", "Mips R6 CRC ASE">;
181
182def FeatureVirt : SubtargetFeature<"virt", "HasVirt", "true",
183                                   "Mips Virtualization ASE">;
184
185def FeatureGINV : SubtargetFeature<"ginv", "HasGINV", "true",
186                                   "Mips Global Invalidate ASE">;
187
188def FeatureMicroMips  : SubtargetFeature<"micromips", "InMicroMipsMode", "true",
189                                         "microMips mode">;
190
191def FeatureCnMips     : SubtargetFeature<"cnmips", "HasCnMips",
192                                "true", "Octeon cnMIPS Support",
193                                [FeatureMips64r2]>;
194
195def FeatureUseTCCInDIV : SubtargetFeature<
196                               "use-tcc-in-div",
197                               "UseTCCInDIV", "false",
198                               "Force the assembler to use trapping">;
199
200def FeatureMadd4 : SubtargetFeature<"nomadd4", "DisableMadd4", "true",
201                                    "Disable 4-operand madd.fmt and related instructions">;
202
203def FeatureMT : SubtargetFeature<"mt", "HasMT", "true", "Mips MT ASE">;
204
205def FeatureLongCalls : SubtargetFeature<"long-calls", "UseLongCalls", "true",
206                                        "Disable use of the jal instruction">;
207
208def FeatureUseIndirectJumpsHazard : SubtargetFeature<"use-indirect-jump-hazard",
209                                                    "UseIndirectJumpsHazard",
210                                                    "true", "Use indirect jump"
211                        " guards to prevent certain speculation based attacks">;
212//===----------------------------------------------------------------------===//
213// Mips processors supported.
214//===----------------------------------------------------------------------===//
215
216def ImplP5600 : SubtargetFeature<"p5600", "ProcImpl",
217                                 "MipsSubtarget::CPU::P5600",
218                                 "The P5600 Processor", [FeatureMips32r5]>;
219
220class Proc<string Name, list<SubtargetFeature> Features>
221 : ProcessorModel<Name, MipsGenericModel, Features>;
222
223def : Proc<"mips1", [FeatureMips1]>;
224def : Proc<"mips2", [FeatureMips2]>;
225def : Proc<"mips32", [FeatureMips32]>;
226def : Proc<"mips32r2", [FeatureMips32r2]>;
227def : Proc<"mips32r3", [FeatureMips32r3]>;
228def : Proc<"mips32r5", [FeatureMips32r5]>;
229def : Proc<"mips32r6", [FeatureMips32r6]>;
230
231def : Proc<"mips3", [FeatureMips3]>;
232def : Proc<"mips4", [FeatureMips4]>;
233def : Proc<"mips5", [FeatureMips5]>;
234def : Proc<"mips64", [FeatureMips64]>;
235def : Proc<"mips64r2", [FeatureMips64r2]>;
236def : Proc<"mips64r3", [FeatureMips64r3]>;
237def : Proc<"mips64r5", [FeatureMips64r5]>;
238def : Proc<"mips64r6", [FeatureMips64r6]>;
239def : Proc<"octeon", [FeatureMips64r2, FeatureCnMips]>;
240def : ProcessorModel<"p5600", MipsP5600Model, [ImplP5600]>;
241
242def MipsAsmParser : AsmParser {
243  let ShouldEmitMatchRegisterName = 0;
244}
245
246def MipsAsmParserVariant : AsmParserVariant {
247  int Variant = 0;
248
249  // Recognize hard coded registers.
250  string RegisterPrefix = "$";
251}
252
253def Mips : Target {
254  let InstructionSet = MipsInstrInfo;
255  let AssemblyParsers = [MipsAsmParser];
256  let AssemblyParserVariants = [MipsAsmParserVariant];
257  let AllowRegisterRenaming = 1;
258}
259