blob: 7b83ea8535ae6afbd8f904f00e98b4dde9a62240 [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//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +00006//
Akira Hatanakae2489122011-04-15 21:51:11 +00007//===----------------------------------------------------------------------===//
Bruno Cardoso Lopesf3c55802007-08-18 02:18:07 +00008// This is the top level entry point for the Mips target.
Akira Hatanakae2489122011-04-15 21:51:11 +00009//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000010
Akira Hatanakae2489122011-04-15 21:51:11 +000011//===----------------------------------------------------------------------===//
Bruno Cardoso Lopesf3c55802007-08-18 02:18:07 +000012// Target-independent interfaces
Akira Hatanakae2489122011-04-15 21:51:11 +000013//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000014
Evan Cheng977e7be2008-11-24 07:34:46 +000015include "llvm/Target/Target.td"
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000016
Daniel Sanders3dc2c012014-05-07 10:27:09 +000017// The overall idea of the PredicateControl class is to chop the Predicates list
18// into subsets that are usually overridden independently. This allows
19// subclasses to partially override the predicates of their superclasses without
20// having to re-add all the existing predicates.
21class PredicateControl {
22 // Predicates for the encoding scheme in use such as HasStdEnc
23 list<Predicate> EncodingPredicates = [];
Daniel Sanders13d72092014-05-07 12:48:37 +000024 // Predicates for the GPR size such as IsGP64bit
25 list<Predicate> GPRPredicates = [];
Simon Dardis4fbf76f2016-06-14 11:29:28 +000026 // Predicates for the PTR size such as IsPTR64bit
27 list<Predicate> PTRPredicates = [];
Daniel Sanders13d72092014-05-07 12:48:37 +000028 // Predicates for the FGR size and layout such as IsFP64bit
29 list<Predicate> FGRPredicates = [];
Simon Dardis1f0fe562018-03-12 13:16:12 +000030 // Predicates for the instruction group membership such as ISA's.
Daniel Sanders9c1b1be2014-05-07 13:57:22 +000031 list<Predicate> InsnPredicates = [];
Simon Dardis1f0fe562018-03-12 13:16:12 +000032 // Predicate for the ASE that an instruction belongs to.
33 list<Predicate> ASEPredicate = [];
Toma Tabacu506cfd02015-05-07 10:29:52 +000034 // Predicate for marking the instruction as usable in hard-float mode only.
35 list<Predicate> HardFloatPredicate = [];
Daniel Sanders3dc2c012014-05-07 10:27:09 +000036 // Predicates for anything else
37 list<Predicate> AdditionalPredicates = [];
38 list<Predicate> Predicates = !listconcat(EncodingPredicates,
Daniel Sanders13d72092014-05-07 12:48:37 +000039 GPRPredicates,
Simon Dardis4fbf76f2016-06-14 11:29:28 +000040 PTRPredicates,
Daniel Sanders13d72092014-05-07 12:48:37 +000041 FGRPredicates,
Daniel Sanders9c1b1be2014-05-07 13:57:22 +000042 InsnPredicates,
Toma Tabacu506cfd02015-05-07 10:29:52 +000043 HardFloatPredicate,
Simon Dardis1f0fe562018-03-12 13:16:12 +000044 ASEPredicate,
Daniel Sanders3dc2c012014-05-07 10:27:09 +000045 AdditionalPredicates);
46}
47
48// Like Requires<> but for the AdditionalPredicates list
49class AdditionalRequires<list<Predicate> preds> {
50 list<Predicate> AdditionalPredicates = preds;
51}
52
Akira Hatanakae2489122011-04-15 21:51:11 +000053//===----------------------------------------------------------------------===//
Bruno Cardoso Lopesc9c3f492008-07-05 19:05:21 +000054// Register File, Calling Conv, Instruction Descriptions
Akira Hatanakae2489122011-04-15 21:51:11 +000055//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000056
57include "MipsRegisterInfo.td"
Bruno Cardoso Lopesf3c55802007-08-18 02:18:07 +000058include "MipsSchedule.td"
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000059include "MipsInstrInfo.td"
Bruno Cardoso Lopesf3c55802007-08-18 02:18:07 +000060include "MipsCallingConv.td"
Petar Jovanovic366857a2018-04-11 15:12:32 +000061include "MipsRegisterBanks.td"
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000062
Simon Dardis6c3591d2016-08-02 10:32:00 +000063// Avoid forward declaration issues.
64include "MipsScheduleP5600.td"
Simon Dardisbd271542016-09-01 14:53:53 +000065include "MipsScheduleGeneric.td"
Simon Dardis6c3591d2016-08-02 10:32:00 +000066
Jakob Stoklund Olesenb93331f2010-04-05 03:10:20 +000067def MipsInstrInfo : InstrInfo;
Bruno Cardoso Lopesf3c55802007-08-18 02:18:07 +000068
Akira Hatanakae2489122011-04-15 21:51:11 +000069//===----------------------------------------------------------------------===//
70// Mips Subtarget features //
71//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000072
Daniel Sandersfeb61302014-08-08 15:47:17 +000073def FeatureNoABICalls : SubtargetFeature<"noabicalls", "NoABICalls", "true",
Toma Tabacu344c1672015-02-27 10:44:02 +000074 "Disable SVR4-style position-independent code">;
Simon Dardis4fbf76f2016-06-14 11:29:28 +000075def FeaturePTR64Bit : SubtargetFeature<"ptr64", "IsPTR64bit", "true",
76 "Pointers are 64-bit wide">;
Bruno Cardoso Lopesbcc21392008-07-09 05:32:22 +000077def FeatureGP64Bit : SubtargetFeature<"gp64", "IsGP64bit", "true",
Toma Tabacu344c1672015-02-27 10:44:02 +000078 "General Purpose Registers are 64-bit wide">;
Bruno Cardoso Lopesbcc21392008-07-09 05:32:22 +000079def FeatureFP64Bit : SubtargetFeature<"fp64", "IsFP64bit", "true",
Toma Tabacu344c1672015-02-27 10:44:02 +000080 "Support 64-bit FP registers">;
Zoran Jovanovic255d00d2014-07-10 15:36:12 +000081def FeatureFPXX : SubtargetFeature<"fpxx", "IsFPXX", "true",
Toma Tabacu344c1672015-02-27 10:44:02 +000082 "Support for FPXX">;
Matheus Almeida0051f2d2014-04-16 15:48:55 +000083def FeatureNaN2008 : SubtargetFeature<"nan2008", "IsNaN2008bit", "true",
Toma Tabacu344c1672015-02-27 10:44:02 +000084 "IEEE 754-2008 NaN encoding">;
Aleksandar Beserminji6c5dfcb2019-01-28 14:59:30 +000085def FeatureAbs2008 : SubtargetFeature<"abs2008", "Abs2008", "true",
86 "Disable IEEE 754-2008 abs.fmt mode">;
Bruno Cardoso Lopesbcc21392008-07-09 05:32:22 +000087def FeatureSingleFloat : SubtargetFeature<"single-float", "IsSingleFloat",
Akira Hatanakae2489122011-04-15 21:51:11 +000088 "true", "Only supports single precision float">;
Toma Tabacu506cfd02015-05-07 10:29:52 +000089def FeatureSoftFloat : SubtargetFeature<"soft-float", "IsSoftFloat", "true",
90 "Does not support floating point instructions">;
Daniel Sanders7e527422014-07-10 13:38:23 +000091def FeatureNoOddSPReg : SubtargetFeature<"nooddspreg", "UseOddSPReg", "false",
92 "Disable odd numbered single-precision "
93 "registers">;
Bruno Cardoso Lopes9c656fe2010-11-08 21:42:32 +000094def FeatureVFPU : SubtargetFeature<"vfpu", "HasVFPU",
Toma Tabacu344c1672015-02-27 10:44:02 +000095 "true", "Enable vector FPU instructions">;
Daniel Sandersd2409532014-05-07 16:25:22 +000096def FeatureMips1 : SubtargetFeature<"mips1", "MipsArchVersion", "Mips1",
97 "Mips I ISA Support [highly experimental]">;
98def FeatureMips2 : SubtargetFeature<"mips2", "MipsArchVersion", "Mips2",
99 "Mips II ISA Support [highly experimental]",
100 [FeatureMips1]>;
Daniel Sandersf2056be2014-05-09 13:02:27 +0000101def FeatureMips3_32 : SubtargetFeature<"mips3_32", "HasMips3_32", "true",
102 "Subset of MIPS-III that is also in MIPS32 "
103 "[highly experimental]">;
Daniel Sanders387fc152014-05-13 11:45:36 +0000104def FeatureMips3_32r2 : SubtargetFeature<"mips3_32r2", "HasMips3_32r2", "true",
105 "Subset of MIPS-III that is also in MIPS32r2 "
106 "[highly experimental]">;
Daniel Sandersf2056be2014-05-09 13:02:27 +0000107def FeatureMips3 : SubtargetFeature<"mips3", "MipsArchVersion", "Mips3",
108 "MIPS III ISA Support [highly experimental]",
109 [FeatureMips2, FeatureMips3_32,
Daniel Sanders387fc152014-05-13 11:45:36 +0000110 FeatureMips3_32r2, FeatureGP64Bit,
111 FeatureFP64Bit]>;
Daniel Sanderse57d8662014-05-09 14:06:17 +0000112def FeatureMips4_32 : SubtargetFeature<"mips4_32", "HasMips4_32", "true",
113 "Subset of MIPS-IV that is also in MIPS32 "
114 "[highly experimental]">;
Daniel Sanders94eda2e2014-05-12 11:56:16 +0000115def FeatureMips4_32r2 : SubtargetFeature<"mips4_32r2", "HasMips4_32r2", "true",
116 "Subset of MIPS-IV that is also in MIPS32r2 "
117 "[highly experimental]">;
Daniel Sandersf2056be2014-05-09 13:02:27 +0000118def FeatureMips4 : SubtargetFeature<"mips4", "MipsArchVersion",
119 "Mips4", "MIPS IV ISA Support",
Daniel Sanderse57d8662014-05-09 14:06:17 +0000120 [FeatureMips3, FeatureMips4_32,
Daniel Sanders94eda2e2014-05-12 11:56:16 +0000121 FeatureMips4_32r2]>;
Daniel Sanders07cdea22014-05-12 12:52:44 +0000122def FeatureMips5_32r2 : SubtargetFeature<"mips5_32r2", "HasMips5_32r2", "true",
123 "Subset of MIPS-V that is also in MIPS32r2 "
124 "[highly experimental]">;
Daniel Sandersf2056be2014-05-09 13:02:27 +0000125def FeatureMips5 : SubtargetFeature<"mips5", "MipsArchVersion", "Mips5",
126 "MIPS V ISA Support [highly experimental]",
Daniel Sanders07cdea22014-05-12 12:52:44 +0000127 [FeatureMips4, FeatureMips5_32r2]>;
Akira Hatanakae2489122011-04-15 21:51:11 +0000128def FeatureMips32 : SubtargetFeature<"mips32", "MipsArchVersion", "Mips32",
129 "Mips32 ISA Support",
Daniel Sandersf2056be2014-05-09 13:02:27 +0000130 [FeatureMips2, FeatureMips3_32,
Daniel Sanders070fd1c2014-05-12 12:41:59 +0000131 FeatureMips4_32]>;
Bruno Cardoso Lopes9c656fe2010-11-08 21:42:32 +0000132def FeatureMips32r2 : SubtargetFeature<"mips32r2", "MipsArchVersion",
133 "Mips32r2", "Mips32r2 ISA Support",
Daniel Sanders387fc152014-05-13 11:45:36 +0000134 [FeatureMips3_32r2, FeatureMips4_32r2,
135 FeatureMips5_32r2, FeatureMips32]>;
Daniel Sanders17793142015-02-18 16:24:50 +0000136def FeatureMips32r3 : SubtargetFeature<"mips32r3", "MipsArchVersion",
137 "Mips32r3", "Mips32r3 ISA Support",
138 [FeatureMips32r2]>;
139def FeatureMips32r5 : SubtargetFeature<"mips32r5", "MipsArchVersion",
140 "Mips32r5", "Mips32r5 ISA Support",
141 [FeatureMips32r3]>;
Daniel Sandersb7f1c6f2014-05-09 09:46:21 +0000142def FeatureMips32r6 : SubtargetFeature<"mips32r6", "MipsArchVersion",
143 "Mips32r6",
144 "Mips32r6 ISA Support [experimental]",
Daniel Sanders17793142015-02-18 16:24:50 +0000145 [FeatureMips32r5, FeatureFP64Bit,
Aleksandar Beserminji6c5dfcb2019-01-28 14:59:30 +0000146 FeatureNaN2008, FeatureAbs2008]>;
Akira Hatanaka2b372612011-09-20 20:28:08 +0000147def FeatureMips64 : SubtargetFeature<"mips64", "MipsArchVersion",
148 "Mips64", "Mips64 ISA Support",
Daniel Sanders94eda2e2014-05-12 11:56:16 +0000149 [FeatureMips5, FeatureMips32]>;
Akira Hatanaka2b372612011-09-20 20:28:08 +0000150def FeatureMips64r2 : SubtargetFeature<"mips64r2", "MipsArchVersion",
151 "Mips64r2", "Mips64r2 ISA Support",
152 [FeatureMips64, FeatureMips32r2]>;
Daniel Sanders17793142015-02-18 16:24:50 +0000153def FeatureMips64r3 : SubtargetFeature<"mips64r3", "MipsArchVersion",
154 "Mips64r3", "Mips64r3 ISA Support",
155 [FeatureMips64r2, FeatureMips32r3]>;
156def FeatureMips64r5 : SubtargetFeature<"mips64r5", "MipsArchVersion",
157 "Mips64r5", "Mips64r5 ISA Support",
158 [FeatureMips64r3, FeatureMips32r5]>;
Daniel Sandersb7f1c6f2014-05-09 09:46:21 +0000159def FeatureMips64r6 : SubtargetFeature<"mips64r6", "MipsArchVersion",
160 "Mips64r6",
161 "Mips64r6 ISA Support [experimental]",
Daniel Sanders17793142015-02-18 16:24:50 +0000162 [FeatureMips32r6, FeatureMips64r5,
Aleksandar Beserminji6c5dfcb2019-01-28 14:59:30 +0000163 FeatureNaN2008, FeatureAbs2008]>;
Simon Dardisca74dd72017-01-27 11:36:52 +0000164def FeatureSym32 : SubtargetFeature<"sym32", "HasSym32", "true",
165 "Symbols are 32 bit on Mips64">;
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +0000166
Akira Hatanaka0faaebf2012-05-16 22:19:56 +0000167def FeatureMips16 : SubtargetFeature<"mips16", "InMips16Mode", "true",
168 "Mips16 mode">;
169
Akira Hatanaka65ce9312012-09-21 23:41:49 +0000170def FeatureDSP : SubtargetFeature<"dsp", "HasDSP", "true", "Mips DSP ASE">;
171def FeatureDSPR2 : SubtargetFeature<"dspr2", "HasDSPR2", "true",
172 "Mips DSP-R2 ASE", [FeatureDSP]>;
Zoran Jovanovic2e386d32015-10-12 16:07:25 +0000173def FeatureDSPR3
174 : SubtargetFeature<"dspr3", "HasDSPR3", "true", "Mips DSP-R3 ASE",
175 [ FeatureDSP, FeatureDSPR2 ]>;
Akira Hatanaka65ce9312012-09-21 23:41:49 +0000176
Jack Carter3a2c2d42013-08-13 20:54:07 +0000177def FeatureMSA : SubtargetFeature<"msa", "HasMSA", "true", "Mips MSA ASE">;
178
Daniel Sanderse4e83a72015-09-15 10:02:16 +0000179def FeatureEVA : SubtargetFeature<"eva", "HasEVA", "true", "Mips EVA ASE">;
180
Petar Jovanovic3408caf2018-03-14 14:13:31 +0000181def FeatureCRC : SubtargetFeature<"crc", "HasCRC", "true", "Mips R6 CRC ASE">;
182
Petar Jovanovicd4349f32018-04-27 09:12:08 +0000183def FeatureVirt : SubtargetFeature<"virt", "HasVirt", "true",
184 "Mips Virtualization ASE">;
185
Petar Jovanovicdaf51692018-05-17 16:30:32 +0000186def FeatureGINV : SubtargetFeature<"ginv", "HasGINV", "true",
187 "Mips Global Invalidate ASE">;
188
Jack Carter428a06c2013-02-05 09:30:03 +0000189def FeatureMicroMips : SubtargetFeature<"micromips", "InMicroMipsMode", "true",
190 "microMips mode">;
191
Kai Nacke93fe5e82014-03-20 11:51:58 +0000192def FeatureCnMips : SubtargetFeature<"cnmips", "HasCnMips",
193 "true", "Octeon cnMIPS Support",
194 [FeatureMips64r2]>;
195
Daniel Sanders3ebcaf62015-09-03 12:31:22 +0000196def FeatureUseTCCInDIV : SubtargetFeature<
197 "use-tcc-in-div",
198 "UseTCCInDIV", "false",
199 "Force the assembler to use trapping">;
200
Petar Jovanovic64fb7a82017-06-06 15:33:01 +0000201def FeatureMadd4 : SubtargetFeature<"nomadd4", "DisableMadd4", "true",
202 "Disable 4-operand madd.fmt and related instructions">;
203
Simon Dardisae719c52017-07-11 18:03:20 +0000204def FeatureMT : SubtargetFeature<"mt", "HasMT", "true", "Mips MT ASE">;
205
Simon Atanasyanf217c7b2017-07-15 07:14:25 +0000206def FeatureLongCalls : SubtargetFeature<"long-calls", "UseLongCalls", "true",
207 "Disable use of the jal instruction">;
208
Simon Dardis7bc8ad52018-02-21 00:06:53 +0000209def FeatureUseIndirectJumpsHazard : SubtargetFeature<"use-indirect-jump-hazard",
210 "UseIndirectJumpsHazard",
211 "true", "Use indirect jump"
212 " guards to prevent certain speculation based attacks">;
Akira Hatanakae2489122011-04-15 21:51:11 +0000213//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +0000214// Mips processors supported.
Akira Hatanakae2489122011-04-15 21:51:11 +0000215//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +0000216
Daniel Sanders7727e102015-09-28 18:24:08 +0000217def ImplP5600 : SubtargetFeature<"p5600", "ProcImpl",
218 "MipsSubtarget::CPU::P5600",
219 "The P5600 Processor", [FeatureMips32r5]>;
220
Bruno Cardoso Lopesc9c3f492008-07-05 19:05:21 +0000221class Proc<string Name, list<SubtargetFeature> Features>
Simon Dardisbd271542016-09-01 14:53:53 +0000222 : ProcessorModel<Name, MipsGenericModel, Features>;
Bruno Cardoso Lopesc9c3f492008-07-05 19:05:21 +0000223
Eric Christophera5762812015-01-26 17:33:46 +0000224def : Proc<"mips1", [FeatureMips1]>;
225def : Proc<"mips2", [FeatureMips2]>;
226def : Proc<"mips32", [FeatureMips32]>;
227def : Proc<"mips32r2", [FeatureMips32r2]>;
Daniel Sanders17793142015-02-18 16:24:50 +0000228def : Proc<"mips32r3", [FeatureMips32r3]>;
229def : Proc<"mips32r5", [FeatureMips32r5]>;
Eric Christophera5762812015-01-26 17:33:46 +0000230def : Proc<"mips32r6", [FeatureMips32r6]>;
Daniel Sandersd2409532014-05-07 16:25:22 +0000231
Eric Christophera5762812015-01-26 17:33:46 +0000232def : Proc<"mips3", [FeatureMips3]>;
233def : Proc<"mips4", [FeatureMips4]>;
234def : Proc<"mips5", [FeatureMips5]>;
235def : Proc<"mips64", [FeatureMips64]>;
236def : Proc<"mips64r2", [FeatureMips64r2]>;
Daniel Sanders17793142015-02-18 16:24:50 +0000237def : Proc<"mips64r3", [FeatureMips64r3]>;
238def : Proc<"mips64r5", [FeatureMips64r5]>;
Eric Christophera5762812015-01-26 17:33:46 +0000239def : Proc<"mips64r6", [FeatureMips64r6]>;
Eric Christophera5762812015-01-26 17:33:46 +0000240def : Proc<"octeon", [FeatureMips64r2, FeatureCnMips]>;
Daniel Sanders7727e102015-09-28 18:24:08 +0000241def : ProcessorModel<"p5600", MipsP5600Model, [ImplP5600]>;
Bruno Cardoso Lopes9c656fe2010-11-08 21:42:32 +0000242
Akira Hatanaka7605630c2012-08-17 20:16:42 +0000243def MipsAsmParser : AsmParser {
244 let ShouldEmitMatchRegisterName = 0;
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +0000245}
Akira Hatanaka9c6028f2011-07-07 23:56:50 +0000246
Akira Hatanaka7605630c2012-08-17 20:16:42 +0000247def MipsAsmParserVariant : AsmParserVariant {
248 int Variant = 0;
249
250 // Recognize hard coded registers.
251 string RegisterPrefix = "$";
252}
253
254def Mips : Target {
255 let InstructionSet = MipsInstrInfo;
256 let AssemblyParsers = [MipsAsmParser];
Akira Hatanaka7605630c2012-08-17 20:16:42 +0000257 let AssemblyParserVariants = [MipsAsmParserVariant];
Geoff Berryf8bf2ec2018-02-23 18:25:08 +0000258 let AllowRegisterRenaming = 1;
Akira Hatanaka7605630c2012-08-17 20:16:42 +0000259}