blob: ea3fa0a9578e1a283d36fb85b1fce20deec7ff0b [file] [log] [blame]
Jia Liuf54f60f2012-02-28 07:46:26 +00001//===-- Mips.td - Describe the Mips Target Machine ---------*- tablegen -*-===//
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-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 Lopes35e43c42007-06-06 07:42:06 +00007//
Akira Hatanakae2489122011-04-15 21:51:11 +00008//===----------------------------------------------------------------------===//
Bruno Cardoso Lopesf3c55802007-08-18 02:18:07 +00009// This is the top level entry point for the Mips target.
Akira Hatanakae2489122011-04-15 21:51:11 +000010//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000011
Akira Hatanakae2489122011-04-15 21:51:11 +000012//===----------------------------------------------------------------------===//
Bruno Cardoso Lopesf3c55802007-08-18 02:18:07 +000013// Target-independent interfaces
Akira Hatanakae2489122011-04-15 21:51:11 +000014//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000015
Evan Cheng977e7be2008-11-24 07:34:46 +000016include "llvm/Target/Target.td"
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000017
Daniel Sanders3dc2c012014-05-07 10:27:09 +000018// 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 = [];
Daniel Sanders13d72092014-05-07 12:48:37 +000025 // Predicates for the GPR size such as IsGP64bit
26 list<Predicate> GPRPredicates = [];
Simon Dardis4fbf76f2016-06-14 11:29:28 +000027 // Predicates for the PTR size such as IsPTR64bit
28 list<Predicate> PTRPredicates = [];
Daniel Sanders13d72092014-05-07 12:48:37 +000029 // Predicates for the FGR size and layout such as IsFP64bit
30 list<Predicate> FGRPredicates = [];
Daniel Sanders9c1b1be2014-05-07 13:57:22 +000031 // Predicates for the instruction group membership such as ISA's and ASE's
32 list<Predicate> InsnPredicates = [];
Toma Tabacu506cfd02015-05-07 10:29:52 +000033 // Predicate for marking the instruction as usable in hard-float mode only.
34 list<Predicate> HardFloatPredicate = [];
Daniel Sanders3dc2c012014-05-07 10:27:09 +000035 // Predicates for anything else
36 list<Predicate> AdditionalPredicates = [];
37 list<Predicate> Predicates = !listconcat(EncodingPredicates,
Daniel Sanders13d72092014-05-07 12:48:37 +000038 GPRPredicates,
Simon Dardis4fbf76f2016-06-14 11:29:28 +000039 PTRPredicates,
Daniel Sanders13d72092014-05-07 12:48:37 +000040 FGRPredicates,
Daniel Sanders9c1b1be2014-05-07 13:57:22 +000041 InsnPredicates,
Toma Tabacu506cfd02015-05-07 10:29:52 +000042 HardFloatPredicate,
Daniel Sanders3dc2c012014-05-07 10:27:09 +000043 AdditionalPredicates);
44}
45
46// Like Requires<> but for the AdditionalPredicates list
47class AdditionalRequires<list<Predicate> preds> {
48 list<Predicate> AdditionalPredicates = preds;
49}
50
Akira Hatanakae2489122011-04-15 21:51:11 +000051//===----------------------------------------------------------------------===//
Bruno Cardoso Lopesc9c3f492008-07-05 19:05:21 +000052// Register File, Calling Conv, Instruction Descriptions
Akira Hatanakae2489122011-04-15 21:51:11 +000053//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000054
55include "MipsRegisterInfo.td"
Bruno Cardoso Lopesf3c55802007-08-18 02:18:07 +000056include "MipsSchedule.td"
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000057include "MipsInstrInfo.td"
Bruno Cardoso Lopesf3c55802007-08-18 02:18:07 +000058include "MipsCallingConv.td"
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000059
Jakob Stoklund Olesenb93331f2010-04-05 03:10:20 +000060def MipsInstrInfo : InstrInfo;
Bruno Cardoso Lopesf3c55802007-08-18 02:18:07 +000061
Akira Hatanakae2489122011-04-15 21:51:11 +000062//===----------------------------------------------------------------------===//
63// Mips Subtarget features //
64//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000065
Daniel Sandersfeb61302014-08-08 15:47:17 +000066def FeatureNoABICalls : SubtargetFeature<"noabicalls", "NoABICalls", "true",
Toma Tabacu344c1672015-02-27 10:44:02 +000067 "Disable SVR4-style position-independent code">;
Simon Dardis4fbf76f2016-06-14 11:29:28 +000068def FeaturePTR64Bit : SubtargetFeature<"ptr64", "IsPTR64bit", "true",
69 "Pointers are 64-bit wide">;
Bruno Cardoso Lopesbcc21392008-07-09 05:32:22 +000070def FeatureGP64Bit : SubtargetFeature<"gp64", "IsGP64bit", "true",
Toma Tabacu344c1672015-02-27 10:44:02 +000071 "General Purpose Registers are 64-bit wide">;
Bruno Cardoso Lopesbcc21392008-07-09 05:32:22 +000072def FeatureFP64Bit : SubtargetFeature<"fp64", "IsFP64bit", "true",
Toma Tabacu344c1672015-02-27 10:44:02 +000073 "Support 64-bit FP registers">;
Zoran Jovanovic255d00d2014-07-10 15:36:12 +000074def FeatureFPXX : SubtargetFeature<"fpxx", "IsFPXX", "true",
Toma Tabacu344c1672015-02-27 10:44:02 +000075 "Support for FPXX">;
Matheus Almeida0051f2d2014-04-16 15:48:55 +000076def FeatureNaN2008 : SubtargetFeature<"nan2008", "IsNaN2008bit", "true",
Toma Tabacu344c1672015-02-27 10:44:02 +000077 "IEEE 754-2008 NaN encoding">;
Bruno Cardoso Lopesbcc21392008-07-09 05:32:22 +000078def FeatureSingleFloat : SubtargetFeature<"single-float", "IsSingleFloat",
Akira Hatanakae2489122011-04-15 21:51:11 +000079 "true", "Only supports single precision float">;
Toma Tabacu506cfd02015-05-07 10:29:52 +000080def FeatureSoftFloat : SubtargetFeature<"soft-float", "IsSoftFloat", "true",
81 "Does not support floating point instructions">;
Daniel Sanders7e527422014-07-10 13:38:23 +000082def FeatureNoOddSPReg : SubtargetFeature<"nooddspreg", "UseOddSPReg", "false",
83 "Disable odd numbered single-precision "
84 "registers">;
Bruno Cardoso Lopes9c656fe2010-11-08 21:42:32 +000085def FeatureVFPU : SubtargetFeature<"vfpu", "HasVFPU",
Toma Tabacu344c1672015-02-27 10:44:02 +000086 "true", "Enable vector FPU instructions">;
Daniel Sandersd2409532014-05-07 16:25:22 +000087def FeatureMips1 : SubtargetFeature<"mips1", "MipsArchVersion", "Mips1",
88 "Mips I ISA Support [highly experimental]">;
89def FeatureMips2 : SubtargetFeature<"mips2", "MipsArchVersion", "Mips2",
90 "Mips II ISA Support [highly experimental]",
91 [FeatureMips1]>;
Daniel Sandersf2056be2014-05-09 13:02:27 +000092def FeatureMips3_32 : SubtargetFeature<"mips3_32", "HasMips3_32", "true",
93 "Subset of MIPS-III that is also in MIPS32 "
94 "[highly experimental]">;
Daniel Sanders387fc152014-05-13 11:45:36 +000095def FeatureMips3_32r2 : SubtargetFeature<"mips3_32r2", "HasMips3_32r2", "true",
96 "Subset of MIPS-III that is also in MIPS32r2 "
97 "[highly experimental]">;
Daniel Sandersf2056be2014-05-09 13:02:27 +000098def FeatureMips3 : SubtargetFeature<"mips3", "MipsArchVersion", "Mips3",
99 "MIPS III ISA Support [highly experimental]",
100 [FeatureMips2, FeatureMips3_32,
Daniel Sanders387fc152014-05-13 11:45:36 +0000101 FeatureMips3_32r2, FeatureGP64Bit,
102 FeatureFP64Bit]>;
Daniel Sanderse57d8662014-05-09 14:06:17 +0000103def FeatureMips4_32 : SubtargetFeature<"mips4_32", "HasMips4_32", "true",
104 "Subset of MIPS-IV that is also in MIPS32 "
105 "[highly experimental]">;
Daniel Sanders94eda2e2014-05-12 11:56:16 +0000106def FeatureMips4_32r2 : SubtargetFeature<"mips4_32r2", "HasMips4_32r2", "true",
107 "Subset of MIPS-IV that is also in MIPS32r2 "
108 "[highly experimental]">;
Daniel Sandersf2056be2014-05-09 13:02:27 +0000109def FeatureMips4 : SubtargetFeature<"mips4", "MipsArchVersion",
110 "Mips4", "MIPS IV ISA Support",
Daniel Sanderse57d8662014-05-09 14:06:17 +0000111 [FeatureMips3, FeatureMips4_32,
Daniel Sanders94eda2e2014-05-12 11:56:16 +0000112 FeatureMips4_32r2]>;
Daniel Sanders07cdea22014-05-12 12:52:44 +0000113def FeatureMips5_32r2 : SubtargetFeature<"mips5_32r2", "HasMips5_32r2", "true",
114 "Subset of MIPS-V that is also in MIPS32r2 "
115 "[highly experimental]">;
Daniel Sandersf2056be2014-05-09 13:02:27 +0000116def FeatureMips5 : SubtargetFeature<"mips5", "MipsArchVersion", "Mips5",
117 "MIPS V ISA Support [highly experimental]",
Daniel Sanders07cdea22014-05-12 12:52:44 +0000118 [FeatureMips4, FeatureMips5_32r2]>;
Akira Hatanakae2489122011-04-15 21:51:11 +0000119def FeatureMips32 : SubtargetFeature<"mips32", "MipsArchVersion", "Mips32",
120 "Mips32 ISA Support",
Daniel Sandersf2056be2014-05-09 13:02:27 +0000121 [FeatureMips2, FeatureMips3_32,
Daniel Sanders070fd1c2014-05-12 12:41:59 +0000122 FeatureMips4_32]>;
Bruno Cardoso Lopes9c656fe2010-11-08 21:42:32 +0000123def FeatureMips32r2 : SubtargetFeature<"mips32r2", "MipsArchVersion",
124 "Mips32r2", "Mips32r2 ISA Support",
Daniel Sanders387fc152014-05-13 11:45:36 +0000125 [FeatureMips3_32r2, FeatureMips4_32r2,
126 FeatureMips5_32r2, FeatureMips32]>;
Daniel Sanders17793142015-02-18 16:24:50 +0000127def FeatureMips32r3 : SubtargetFeature<"mips32r3", "MipsArchVersion",
128 "Mips32r3", "Mips32r3 ISA Support",
129 [FeatureMips32r2]>;
130def FeatureMips32r5 : SubtargetFeature<"mips32r5", "MipsArchVersion",
131 "Mips32r5", "Mips32r5 ISA Support",
132 [FeatureMips32r3]>;
Daniel Sandersb7f1c6f2014-05-09 09:46:21 +0000133def FeatureMips32r6 : SubtargetFeature<"mips32r6", "MipsArchVersion",
134 "Mips32r6",
135 "Mips32r6 ISA Support [experimental]",
Daniel Sanders17793142015-02-18 16:24:50 +0000136 [FeatureMips32r5, FeatureFP64Bit,
Daniel Sandersb7f1c6f2014-05-09 09:46:21 +0000137 FeatureNaN2008]>;
Akira Hatanaka2b372612011-09-20 20:28:08 +0000138def FeatureMips64 : SubtargetFeature<"mips64", "MipsArchVersion",
139 "Mips64", "Mips64 ISA Support",
Daniel Sanders94eda2e2014-05-12 11:56:16 +0000140 [FeatureMips5, FeatureMips32]>;
Akira Hatanaka2b372612011-09-20 20:28:08 +0000141def FeatureMips64r2 : SubtargetFeature<"mips64r2", "MipsArchVersion",
142 "Mips64r2", "Mips64r2 ISA Support",
143 [FeatureMips64, FeatureMips32r2]>;
Daniel Sanders17793142015-02-18 16:24:50 +0000144def FeatureMips64r3 : SubtargetFeature<"mips64r3", "MipsArchVersion",
145 "Mips64r3", "Mips64r3 ISA Support",
146 [FeatureMips64r2, FeatureMips32r3]>;
147def FeatureMips64r5 : SubtargetFeature<"mips64r5", "MipsArchVersion",
148 "Mips64r5", "Mips64r5 ISA Support",
149 [FeatureMips64r3, FeatureMips32r5]>;
Daniel Sandersb7f1c6f2014-05-09 09:46:21 +0000150def FeatureMips64r6 : SubtargetFeature<"mips64r6", "MipsArchVersion",
151 "Mips64r6",
152 "Mips64r6 ISA Support [experimental]",
Daniel Sanders17793142015-02-18 16:24:50 +0000153 [FeatureMips32r6, FeatureMips64r5,
Daniel Sanders0ac5ec52014-05-12 15:12:45 +0000154 FeatureNaN2008]>;
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +0000155
Akira Hatanaka0faaebf2012-05-16 22:19:56 +0000156def FeatureMips16 : SubtargetFeature<"mips16", "InMips16Mode", "true",
157 "Mips16 mode">;
158
Akira Hatanaka65ce9312012-09-21 23:41:49 +0000159def FeatureDSP : SubtargetFeature<"dsp", "HasDSP", "true", "Mips DSP ASE">;
160def FeatureDSPR2 : SubtargetFeature<"dspr2", "HasDSPR2", "true",
161 "Mips DSP-R2 ASE", [FeatureDSP]>;
Zoran Jovanovic2e386d32015-10-12 16:07:25 +0000162def FeatureDSPR3
163 : SubtargetFeature<"dspr3", "HasDSPR3", "true", "Mips DSP-R3 ASE",
164 [ FeatureDSP, FeatureDSPR2 ]>;
Akira Hatanaka65ce9312012-09-21 23:41:49 +0000165
Jack Carter3a2c2d42013-08-13 20:54:07 +0000166def FeatureMSA : SubtargetFeature<"msa", "HasMSA", "true", "Mips MSA ASE">;
167
Daniel Sanderse4e83a72015-09-15 10:02:16 +0000168def FeatureEVA : SubtargetFeature<"eva", "HasEVA", "true", "Mips EVA ASE">;
169
Jack Carter428a06c2013-02-05 09:30:03 +0000170def FeatureMicroMips : SubtargetFeature<"micromips", "InMicroMipsMode", "true",
171 "microMips mode">;
172
Kai Nacke93fe5e82014-03-20 11:51:58 +0000173def FeatureCnMips : SubtargetFeature<"cnmips", "HasCnMips",
174 "true", "Octeon cnMIPS Support",
175 [FeatureMips64r2]>;
176
Daniel Sanders3ebcaf62015-09-03 12:31:22 +0000177def FeatureUseTCCInDIV : SubtargetFeature<
178 "use-tcc-in-div",
179 "UseTCCInDIV", "false",
180 "Force the assembler to use trapping">;
181
Akira Hatanakae2489122011-04-15 21:51:11 +0000182//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +0000183// Mips processors supported.
Akira Hatanakae2489122011-04-15 21:51:11 +0000184//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +0000185
Daniel Sanders7727e102015-09-28 18:24:08 +0000186def ImplP5600 : SubtargetFeature<"p5600", "ProcImpl",
187 "MipsSubtarget::CPU::P5600",
188 "The P5600 Processor", [FeatureMips32r5]>;
189
Bruno Cardoso Lopesc9c3f492008-07-05 19:05:21 +0000190class Proc<string Name, list<SubtargetFeature> Features>
191 : Processor<Name, MipsGenericItineraries, Features>;
192
Eric Christophera5762812015-01-26 17:33:46 +0000193def : Proc<"mips1", [FeatureMips1]>;
194def : Proc<"mips2", [FeatureMips2]>;
195def : Proc<"mips32", [FeatureMips32]>;
196def : Proc<"mips32r2", [FeatureMips32r2]>;
Daniel Sanders17793142015-02-18 16:24:50 +0000197def : Proc<"mips32r3", [FeatureMips32r3]>;
198def : Proc<"mips32r5", [FeatureMips32r5]>;
Eric Christophera5762812015-01-26 17:33:46 +0000199def : Proc<"mips32r6", [FeatureMips32r6]>;
Daniel Sandersd2409532014-05-07 16:25:22 +0000200
Eric Christophera5762812015-01-26 17:33:46 +0000201def : Proc<"mips3", [FeatureMips3]>;
202def : Proc<"mips4", [FeatureMips4]>;
203def : Proc<"mips5", [FeatureMips5]>;
204def : Proc<"mips64", [FeatureMips64]>;
205def : Proc<"mips64r2", [FeatureMips64r2]>;
Daniel Sanders17793142015-02-18 16:24:50 +0000206def : Proc<"mips64r3", [FeatureMips64r3]>;
207def : Proc<"mips64r5", [FeatureMips64r5]>;
Eric Christophera5762812015-01-26 17:33:46 +0000208def : Proc<"mips64r6", [FeatureMips64r6]>;
Eric Christophera5762812015-01-26 17:33:46 +0000209def : Proc<"octeon", [FeatureMips64r2, FeatureCnMips]>;
Daniel Sanders7727e102015-09-28 18:24:08 +0000210def : ProcessorModel<"p5600", MipsP5600Model, [ImplP5600]>;
Bruno Cardoso Lopes9c656fe2010-11-08 21:42:32 +0000211
Akira Hatanaka7605630c2012-08-17 20:16:42 +0000212def MipsAsmParser : AsmParser {
213 let ShouldEmitMatchRegisterName = 0;
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +0000214}
Akira Hatanaka9c6028f2011-07-07 23:56:50 +0000215
Akira Hatanaka7605630c2012-08-17 20:16:42 +0000216def MipsAsmParserVariant : AsmParserVariant {
217 int Variant = 0;
218
219 // Recognize hard coded registers.
220 string RegisterPrefix = "$";
221}
222
223def Mips : Target {
224 let InstructionSet = MipsInstrInfo;
225 let AssemblyParsers = [MipsAsmParser];
Akira Hatanaka7605630c2012-08-17 20:16:42 +0000226 let AssemblyParserVariants = [MipsAsmParserVariant];
227}