blob: 0c10b01b6c7050183bf53f2f6f2e773aa9906ce2 [file] [log] [blame]
Bill Wendlingcbb08ca2010-12-01 02:42:55 +00001//===- ARMInstrFormats.td - ARM Instruction Formats ----------*- tablegen -*-=//
Bob Wilson3968c6a2010-03-23 17:23:59 +00002//
Evan Cheng2d37f192008-08-28 23:39:26 +00003// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Bob Wilson3968c6a2010-03-23 17:23:59 +00007//
Evan Cheng2d37f192008-08-28 23:39:26 +00008//===----------------------------------------------------------------------===//
9
10//===----------------------------------------------------------------------===//
11//
12// ARM Instruction Format Definitions.
13//
14
15// Format specifies the encoding used by the instruction. This is part of the
16// ad-hoc solution used to emit machine instruction encodings by our machine
17// code emitter.
Bob Wilson69ba1bc2010-03-17 21:13:43 +000018class Format<bits<6> val> {
19 bits<6> Value = val;
Evan Cheng2d37f192008-08-28 23:39:26 +000020}
21
Evan Chengfabdcce2008-11-13 23:36:57 +000022def Pseudo : Format<0>;
23def MulFrm : Format<1>;
24def BrFrm : Format<2>;
25def BrMiscFrm : Format<3>;
Evan Cheng2d37f192008-08-28 23:39:26 +000026
Evan Chengfabdcce2008-11-13 23:36:57 +000027def DPFrm : Format<4>;
Owen Anderson04912702011-07-21 23:38:37 +000028def DPSoRegRegFrm : Format<5>;
Evan Cheng2d37f192008-08-28 23:39:26 +000029
Evan Chengfabdcce2008-11-13 23:36:57 +000030def LdFrm : Format<6>;
31def StFrm : Format<7>;
32def LdMiscFrm : Format<8>;
33def StMiscFrm : Format<9>;
34def LdStMulFrm : Format<10>;
Evan Cheng2d37f192008-08-28 23:39:26 +000035
Johnny Chen0dab68f2010-03-19 17:39:00 +000036def LdStExFrm : Format<11>;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +000037
Johnny Chen0dab68f2010-03-19 17:39:00 +000038def ArithMiscFrm : Format<12>;
Bob Wilson96649842010-08-11 00:01:18 +000039def SatFrm : Format<13>;
40def ExtFrm : Format<14>;
Evan Cheng8cbbcb12008-11-11 21:48:44 +000041
Bob Wilson96649842010-08-11 00:01:18 +000042def VFPUnaryFrm : Format<15>;
43def VFPBinaryFrm : Format<16>;
44def VFPConv1Frm : Format<17>;
45def VFPConv2Frm : Format<18>;
46def VFPConv3Frm : Format<19>;
47def VFPConv4Frm : Format<20>;
48def VFPConv5Frm : Format<21>;
49def VFPLdStFrm : Format<22>;
50def VFPLdStMulFrm : Format<23>;
51def VFPMiscFrm : Format<24>;
Evan Cheng8cbbcb12008-11-11 21:48:44 +000052
Bob Wilson96649842010-08-11 00:01:18 +000053def ThumbFrm : Format<25>;
54def MiscFrm : Format<26>;
Evan Cheng2d37f192008-08-28 23:39:26 +000055
Bob Wilson96649842010-08-11 00:01:18 +000056def NGetLnFrm : Format<27>;
57def NSetLnFrm : Format<28>;
58def NDupFrm : Format<29>;
59def NLdStFrm : Format<30>;
60def N1RegModImmFrm: Format<31>;
61def N2RegFrm : Format<32>;
62def NVCVTFrm : Format<33>;
63def NVDupLnFrm : Format<34>;
64def N2RegVShLFrm : Format<35>;
65def N2RegVShRFrm : Format<36>;
66def N3RegFrm : Format<37>;
67def N3RegVShFrm : Format<38>;
68def NVExtFrm : Format<39>;
69def NVMulSLFrm : Format<40>;
70def NVTBLFrm : Format<41>;
Owen Anderson04912702011-07-21 23:38:37 +000071def DPSoRegImmFrm : Format<42>;
Johnny Chenf833fad2010-03-20 00:17:00 +000072
Evan Cheng14965762009-07-08 01:46:35 +000073// Misc flags.
74
Bill Wendlingcbb08ca2010-12-01 02:42:55 +000075// The instruction has an Rn register operand.
Evan Cheng14965762009-07-08 01:46:35 +000076// UnaryDP - Indicates this is a unary data processing instruction, i.e.
77// it doesn't have a Rn operand.
78class UnaryDP { bit isUnaryDataProc = 1; }
79
80// Xform16Bit - Indicates this Thumb2 instruction may be transformed into
81// a 16-bit Thumb instruction if certain conditions are met.
82class Xform16Bit { bit canXformTo16Bit = 1; }
Evan Cheng2d37f192008-08-28 23:39:26 +000083
Evan Cheng2d37f192008-08-28 23:39:26 +000084//===----------------------------------------------------------------------===//
Bob Wilsona4d86b62010-03-18 23:57:57 +000085// ARM Instruction flags. These need to match ARMBaseInstrInfo.h.
Evan Chengb23b50d2009-06-29 07:51:04 +000086//
87
Jim Grosbachec86bac2011-01-18 19:59:19 +000088// FIXME: Once the JIT is MC-ized, these can go away.
Evan Chengb23b50d2009-06-29 07:51:04 +000089// Addressing mode.
Jim Grosbache9298992010-10-05 18:14:55 +000090class AddrMode<bits<5> val> {
91 bits<5> Value = val;
Evan Chengb23b50d2009-06-29 07:51:04 +000092}
Bill Wendlingb70dc872010-08-31 07:50:46 +000093def AddrModeNone : AddrMode<0>;
94def AddrMode1 : AddrMode<1>;
95def AddrMode2 : AddrMode<2>;
96def AddrMode3 : AddrMode<3>;
97def AddrMode4 : AddrMode<4>;
98def AddrMode5 : AddrMode<5>;
99def AddrMode6 : AddrMode<6>;
100def AddrModeT1_1 : AddrMode<7>;
101def AddrModeT1_2 : AddrMode<8>;
102def AddrModeT1_4 : AddrMode<9>;
103def AddrModeT1_s : AddrMode<10>;
104def AddrModeT2_i12 : AddrMode<11>;
105def AddrModeT2_i8 : AddrMode<12>;
106def AddrModeT2_so : AddrMode<13>;
107def AddrModeT2_pc : AddrMode<14>;
Bob Wilsondeb35af2009-07-01 23:16:05 +0000108def AddrModeT2_i8s4 : AddrMode<15>;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000109def AddrMode_i12 : AddrMode<16>;
Evan Chengb23b50d2009-06-29 07:51:04 +0000110
Evan Chengb23b50d2009-06-29 07:51:04 +0000111// Load / store index mode.
112class IndexMode<bits<2> val> {
113 bits<2> Value = val;
114}
115def IndexModeNone : IndexMode<0>;
116def IndexModePre : IndexMode<1>;
117def IndexModePost : IndexMode<2>;
Bob Wilsonf1e8f7f2010-03-13 07:34:35 +0000118def IndexModeUpd : IndexMode<3>;
Evan Chengb23b50d2009-06-29 07:51:04 +0000119
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000120// Instruction execution domain.
Evan Cheng04ad35b2011-02-22 19:53:14 +0000121class Domain<bits<3> val> {
122 bits<3> Value = val;
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000123}
124def GenericDomain : Domain<0>;
125def VFPDomain : Domain<1>; // Instructions in VFP domain only
126def NeonDomain : Domain<2>; // Instructions in Neon domain only
127def VFPNeonDomain : Domain<3>; // Instructions in both VFP & Neon domains
Evan Cheng97e64282011-02-23 02:35:33 +0000128def VFPNeonA8Domain : Domain<5>; // Instructions in VFP & Neon under A8
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000129
Evan Chengb23b50d2009-06-29 07:51:04 +0000130//===----------------------------------------------------------------------===//
Evan Chengcd4cdd12009-07-11 06:43:01 +0000131// ARM special operands.
132//
133
Bruno Cardoso Lopes90d1dfe2011-02-14 13:09:44 +0000134// ARM imod and iflag operands, used only by the CPS instruction.
135def imod_op : Operand<i32> {
136 let PrintMethod = "printCPSIMod";
137}
138
Jim Grosbacheeaab222011-07-25 20:38:18 +0000139def ProcIFlagsOperand : AsmOperandClass {
140 let Name = "ProcIFlags";
141 let ParserMethod = "parseProcIFlagsOperand";
142}
Bruno Cardoso Lopes90d1dfe2011-02-14 13:09:44 +0000143def iflags_op : Operand<i32> {
144 let PrintMethod = "printCPSIFlag";
145 let ParserMatchClass = ProcIFlagsOperand;
146}
147
Evan Chengcd4cdd12009-07-11 06:43:01 +0000148// ARM Predicate operand. Default to 14 = always (AL). Second part is CC
149// register whose default is 0 (no register).
Jim Grosbacheeaab222011-07-25 20:38:18 +0000150def CondCodeOperand : AsmOperandClass { let Name = "CondCode"; }
Jim Grosbachf86cd372011-08-19 20:46:54 +0000151def pred : PredicateOperand<OtherVT, (ops i32imm, i32imm),
Evan Chengcd4cdd12009-07-11 06:43:01 +0000152 (ops (i32 14), (i32 zero_reg))> {
153 let PrintMethod = "printPredicateOperand";
Daniel Dunbard8042b72010-08-11 06:36:53 +0000154 let ParserMatchClass = CondCodeOperand;
Jim Grosbachdbb60f92011-08-19 20:30:19 +0000155 let DecoderMethod = "DecodePredicateOperand";
Evan Chengcd4cdd12009-07-11 06:43:01 +0000156}
157
158// Conditional code result for instructions whose 's' bit is set, e.g. subs.
Jim Grosbacheeaab222011-07-25 20:38:18 +0000159def CCOutOperand : AsmOperandClass { let Name = "CCOut"; }
Evan Chengcd4cdd12009-07-11 06:43:01 +0000160def cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 zero_reg))> {
Chris Lattner63274cb2010-11-15 05:19:05 +0000161 let EncoderMethod = "getCCOutOpValue";
Evan Chengcd4cdd12009-07-11 06:43:01 +0000162 let PrintMethod = "printSBitModifierOperand";
Jim Grosbach0bfb4d52010-12-06 18:21:12 +0000163 let ParserMatchClass = CCOutOperand;
Jim Grosbach9c920492011-08-19 19:41:46 +0000164 let DecoderMethod = "DecodeCCOutOperand";
Evan Chengcd4cdd12009-07-11 06:43:01 +0000165}
166
167// Same as cc_out except it defaults to setting CPSR.
168def s_cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 CPSR))> {
Chris Lattner63274cb2010-11-15 05:19:05 +0000169 let EncoderMethod = "getCCOutOpValue";
Evan Chengcd4cdd12009-07-11 06:43:01 +0000170 let PrintMethod = "printSBitModifierOperand";
Jim Grosbach0bfb4d52010-12-06 18:21:12 +0000171 let ParserMatchClass = CCOutOperand;
Jim Grosbach9c920492011-08-19 19:41:46 +0000172 let DecoderMethod = "DecodeCCOutOperand";
Evan Chengcd4cdd12009-07-11 06:43:01 +0000173}
174
Johnny Chen9a3e2392010-03-10 18:59:38 +0000175// ARM special operands for disassembly only.
176//
Jim Grosbach3a3d8e82011-11-12 00:58:43 +0000177def SetEndAsmOperand : ImmAsmOperand {
Jim Grosbach0a547702011-07-22 17:44:50 +0000178 let Name = "SetEndImm";
179 let ParserMethod = "parseSetEndImm";
180}
Jim Grosbach7e72ec62010-10-13 21:00:04 +0000181def setend_op : Operand<i32> {
182 let PrintMethod = "printSetendOperand";
Jim Grosbach0a547702011-07-22 17:44:50 +0000183 let ParserMatchClass = SetEndAsmOperand;
Jim Grosbach7e72ec62010-10-13 21:00:04 +0000184}
Johnny Chen9a3e2392010-03-10 18:59:38 +0000185
Jim Grosbacheeaab222011-07-25 20:38:18 +0000186def MSRMaskOperand : AsmOperandClass {
187 let Name = "MSRMask";
188 let ParserMethod = "parseMSRMaskOperand";
189}
Johnny Chen9a3e2392010-03-10 18:59:38 +0000190def msr_mask : Operand<i32> {
191 let PrintMethod = "printMSRMaskOperand";
Owen Anderson60663402011-08-11 20:21:46 +0000192 let DecoderMethod = "DecodeMSRMask";
Bruno Cardoso Lopes9cd43972011-02-18 19:45:59 +0000193 let ParserMatchClass = MSRMaskOperand;
Johnny Chen9a3e2392010-03-10 18:59:38 +0000194}
195
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000196// Shift Right Immediate - A shift right immediate is encoded differently from
197// other shift immediates. The imm6 field is encoded like so:
Bill Wendling3b1459b2011-03-01 01:00:59 +0000198//
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000199// Offset Encoding
200// 8 imm6<5:3> = '001', 8 - <imm> is encoded in imm6<2:0>
201// 16 imm6<5:4> = '01', 16 - <imm> is encoded in imm6<3:0>
202// 32 imm6<5> = '1', 32 - <imm> is encoded in imm6<4:0>
203// 64 64 - <imm> is encoded in imm6<5:0>
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000204def shr_imm8_asm_operand : ImmAsmOperand { let Name = "ShrImm8"; }
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000205def shr_imm8 : Operand<i32> {
206 let EncoderMethod = "getShiftRight8Imm";
Owen Andersone0152a72011-08-09 20:55:18 +0000207 let DecoderMethod = "DecodeShiftRight8Imm";
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000208 let ParserMatchClass = shr_imm8_asm_operand;
Bill Wendling3b1459b2011-03-01 01:00:59 +0000209}
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000210def shr_imm16_asm_operand : ImmAsmOperand { let Name = "ShrImm16"; }
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000211def shr_imm16 : Operand<i32> {
212 let EncoderMethod = "getShiftRight16Imm";
Owen Andersone0152a72011-08-09 20:55:18 +0000213 let DecoderMethod = "DecodeShiftRight16Imm";
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000214 let ParserMatchClass = shr_imm16_asm_operand;
Bill Wendling3b1459b2011-03-01 01:00:59 +0000215}
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000216def shr_imm32_asm_operand : ImmAsmOperand { let Name = "ShrImm32"; }
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000217def shr_imm32 : Operand<i32> {
218 let EncoderMethod = "getShiftRight32Imm";
Owen Andersone0152a72011-08-09 20:55:18 +0000219 let DecoderMethod = "DecodeShiftRight32Imm";
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000220 let ParserMatchClass = shr_imm32_asm_operand;
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000221}
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000222def shr_imm64_asm_operand : ImmAsmOperand { let Name = "ShrImm64"; }
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000223def shr_imm64 : Operand<i32> {
224 let EncoderMethod = "getShiftRight64Imm";
Owen Andersone0152a72011-08-09 20:55:18 +0000225 let DecoderMethod = "DecodeShiftRight64Imm";
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000226 let ParserMatchClass = shr_imm64_asm_operand;
Bill Wendling3b1459b2011-03-01 01:00:59 +0000227}
228
Evan Chengcd4cdd12009-07-11 06:43:01 +0000229//===----------------------------------------------------------------------===//
Jim Grosbach6caa5572011-08-22 18:04:24 +0000230// ARM Assembler alias templates.
231//
232class ARMInstAlias<string Asm, dag Result, bit Emit = 0b1>
233 : InstAlias<Asm, Result, Emit>, Requires<[IsARM]>;
234class tInstAlias<string Asm, dag Result, bit Emit = 0b1>
235 : InstAlias<Asm, Result, Emit>, Requires<[IsThumb]>;
236class t2InstAlias<string Asm, dag Result, bit Emit = 0b1>
237 : InstAlias<Asm, Result, Emit>, Requires<[IsThumb2]>;
Jim Grosbach4ab23b52011-10-03 21:12:43 +0000238class VFP2InstAlias<string Asm, dag Result, bit Emit = 0b1>
239 : InstAlias<Asm, Result, Emit>, Requires<[HasVFP2]>;
240class VFP3InstAlias<string Asm, dag Result, bit Emit = 0b1>
241 : InstAlias<Asm, Result, Emit>, Requires<[HasVFP3]>;
Jim Grosbach0a978ef2011-12-05 19:55:46 +0000242class NEONInstAlias<string Asm, dag Result, bit Emit = 0b1>
243 : InstAlias<Asm, Result, Emit>, Requires<[HasNEON]>;
Jim Grosbach6caa5572011-08-22 18:04:24 +0000244
Jim Grosbach9227f392011-12-13 20:08:32 +0000245
246class VFP2MnemonicAlias<string src, string dst> : MnemonicAlias<src, dst>,
247 Requires<[HasVFP2]>;
248class NEONMnemonicAlias<string src, string dst> : MnemonicAlias<src, dst>,
249 Requires<[HasNEON]>;
250
Jim Grosbach6caa5572011-08-22 18:04:24 +0000251//===----------------------------------------------------------------------===//
Evan Cheng2d37f192008-08-28 23:39:26 +0000252// ARM Instruction templates.
253//
254
Jim Grosbach6caa5572011-08-22 18:04:24 +0000255
Owen Anderson651b2302011-07-13 23:22:26 +0000256class InstTemplate<AddrMode am, int sz, IndexMode im,
Johnny Chenc28e6292009-12-15 17:24:14 +0000257 Format f, Domain d, string cstr, InstrItinClass itin>
Evan Cheng2d37f192008-08-28 23:39:26 +0000258 : Instruction {
259 let Namespace = "ARM";
260
Evan Cheng2d37f192008-08-28 23:39:26 +0000261 AddrMode AM = am;
Owen Anderson651b2302011-07-13 23:22:26 +0000262 int Size = sz;
Evan Cheng2d37f192008-08-28 23:39:26 +0000263 IndexMode IM = im;
264 bits<2> IndexModeBits = IM.Value;
Evan Cheng2d37f192008-08-28 23:39:26 +0000265 Format F = f;
Bob Wilson69ba1bc2010-03-17 21:13:43 +0000266 bits<6> Form = F.Value;
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000267 Domain D = d;
Evan Cheng81889d012008-11-05 18:35:52 +0000268 bit isUnaryDataProc = 0;
Evan Cheng14965762009-07-08 01:46:35 +0000269 bit canXformTo16Bit = 0;
Jim Grosbach3e941ae2011-08-16 20:45:50 +0000270 // The instruction is a 16-bit flag setting Thumb instruction. Used
271 // by the parser to determine whether to require the 'S' suffix on the
272 // mnemonic (when not in an IT block) or preclude it (when in an IT block).
273 bit thumbArithFlagSetting = 0;
Jim Grosbach5876e412010-11-19 22:42:55 +0000274
Chris Lattner7ff33462010-10-31 19:22:57 +0000275 // If this is a pseudo instruction, mark it isCodeGenOnly.
276 let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
Bob Wilson3968c6a2010-03-23 17:23:59 +0000277
Jim Grosbach30694dc2011-08-15 16:52:24 +0000278 // The layout of TSFlags should be kept in sync with ARMBaseInfo.h.
Jim Grosbache9298992010-10-05 18:14:55 +0000279 let TSFlags{4-0} = AM.Value;
Owen Anderson651b2302011-07-13 23:22:26 +0000280 let TSFlags{6-5} = IndexModeBits;
281 let TSFlags{12-7} = Form;
282 let TSFlags{13} = isUnaryDataProc;
283 let TSFlags{14} = canXformTo16Bit;
284 let TSFlags{17-15} = D.Value;
Jim Grosbach3e941ae2011-08-16 20:45:50 +0000285 let TSFlags{18} = thumbArithFlagSetting;
Jakob Stoklund Olesenb93331f2010-04-05 03:10:20 +0000286
Evan Cheng2d37f192008-08-28 23:39:26 +0000287 let Constraints = cstr;
David Goodwinb062c232009-08-06 16:52:47 +0000288 let Itinerary = itin;
Evan Cheng2d37f192008-08-28 23:39:26 +0000289}
290
Johnny Chenc28e6292009-12-15 17:24:14 +0000291class Encoding {
292 field bits<32> Inst;
293}
294
Owen Anderson651b2302011-07-13 23:22:26 +0000295class InstARM<AddrMode am, int sz, IndexMode im,
Johnny Chenc28e6292009-12-15 17:24:14 +0000296 Format f, Domain d, string cstr, InstrItinClass itin>
Owen Andersonc78e03c2011-07-19 21:06:00 +0000297 : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding {
298 let DecoderNamespace = "ARM";
299}
Johnny Chenc28e6292009-12-15 17:24:14 +0000300
301// This Encoding-less class is used by Thumb1 to specify the encoding bits later
302// on by adding flavors to specific instructions.
Owen Anderson651b2302011-07-13 23:22:26 +0000303class InstThumb<AddrMode am, int sz, IndexMode im,
Johnny Chenc28e6292009-12-15 17:24:14 +0000304 Format f, Domain d, string cstr, InstrItinClass itin>
Owen Andersonc78e03c2011-07-19 21:06:00 +0000305 : InstTemplate<am, sz, im, f, d, cstr, itin> {
306 let DecoderNamespace = "Thumb";
307}
Johnny Chenc28e6292009-12-15 17:24:14 +0000308
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000309// Pseudo-instructions for alternate assembly syntax (never used by codegen).
310// These are aliases that require C++ handling to convert to the target
311// instruction, while InstAliases can be handled directly by tblgen.
Jim Grosbach61db5a52011-11-10 16:44:55 +0000312class AsmPseudoInst<string asm, dag iops>
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000313 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo, GenericDomain,
314 "", NoItinerary> {
Jim Grosbach61db5a52011-11-10 16:44:55 +0000315 let OutOperandList = (outs);
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000316 let InOperandList = iops;
317 let Pattern = [];
318 let isCodeGenOnly = 0; // So we get asm matcher for it.
Jim Grosbach61db5a52011-11-10 16:44:55 +0000319 let AsmString = asm;
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000320 let isPseudo = 1;
321}
322
Jim Grosbach61db5a52011-11-10 16:44:55 +0000323class ARMAsmPseudo<string asm, dag iops> : AsmPseudoInst<asm, iops>,
324 Requires<[IsARM]>;
325class tAsmPseudo<string asm, dag iops> : AsmPseudoInst<asm, iops>,
326 Requires<[IsThumb]>;
327class t2AsmPseudo<string asm, dag iops> : AsmPseudoInst<asm, iops>,
328 Requires<[IsThumb2]>;
329class VFP2AsmPseudo<string asm, dag iops> : AsmPseudoInst<asm, iops>,
330 Requires<[HasVFP2]>;
331class NEONAsmPseudo<string asm, dag iops> : AsmPseudoInst<asm, iops>,
332 Requires<[HasNEON]>;
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000333
334// Pseudo instructions for the code generator.
Jim Grosbacha74c7ccd2010-11-18 01:38:26 +0000335class PseudoInst<dag oops, dag iops, InstrItinClass itin, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000336 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo,
Jim Grosbach7c301ea2011-07-06 21:35:46 +0000337 GenericDomain, "", itin> {
Evan Cheng2d37f192008-08-28 23:39:26 +0000338 let OutOperandList = oops;
339 let InOperandList = iops;
Evan Cheng2d37f192008-08-28 23:39:26 +0000340 let Pattern = pattern;
Jim Grosbache1756822011-03-10 19:06:39 +0000341 let isCodeGenOnly = 1;
Jim Grosbach7c301ea2011-07-06 21:35:46 +0000342 let isPseudo = 1;
Evan Cheng2d37f192008-08-28 23:39:26 +0000343}
344
Jim Grosbachcfb66202010-11-18 01:15:56 +0000345// PseudoInst that's ARM-mode only.
Owen Anderson651b2302011-07-13 23:22:26 +0000346class ARMPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
Jim Grosbacha74c7ccd2010-11-18 01:38:26 +0000347 list<dag> pattern>
348 : PseudoInst<oops, iops, itin, pattern> {
Owen Anderson651b2302011-07-13 23:22:26 +0000349 let Size = sz;
Jim Grosbachcfb66202010-11-18 01:15:56 +0000350 list<Predicate> Predicates = [IsARM];
351}
352
Jim Grosbach58bc36a2010-11-29 19:32:47 +0000353// PseudoInst that's Thumb-mode only.
Owen Anderson651b2302011-07-13 23:22:26 +0000354class tPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
Jim Grosbach58bc36a2010-11-29 19:32:47 +0000355 list<dag> pattern>
356 : PseudoInst<oops, iops, itin, pattern> {
Owen Anderson651b2302011-07-13 23:22:26 +0000357 let Size = sz;
Jim Grosbach58bc36a2010-11-29 19:32:47 +0000358 list<Predicate> Predicates = [IsThumb];
359}
Jim Grosbachcfb66202010-11-18 01:15:56 +0000360
Jim Grosbachd42257c2010-12-15 18:48:45 +0000361// PseudoInst that's Thumb2-mode only.
Owen Anderson651b2302011-07-13 23:22:26 +0000362class t2PseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
Jim Grosbachd42257c2010-12-15 18:48:45 +0000363 list<dag> pattern>
364 : PseudoInst<oops, iops, itin, pattern> {
Owen Anderson651b2302011-07-13 23:22:26 +0000365 let Size = sz;
Jim Grosbachd42257c2010-12-15 18:48:45 +0000366 list<Predicate> Predicates = [IsThumb2];
367}
Jim Grosbach95dee402011-07-08 17:40:42 +0000368
Owen Anderson651b2302011-07-13 23:22:26 +0000369class ARMPseudoExpand<dag oops, dag iops, int sz,
Jim Grosbach95dee402011-07-08 17:40:42 +0000370 InstrItinClass itin, list<dag> pattern,
371 dag Result>
372 : ARMPseudoInst<oops, iops, sz, itin, pattern>,
373 PseudoInstExpansion<Result>;
374
Owen Anderson651b2302011-07-13 23:22:26 +0000375class tPseudoExpand<dag oops, dag iops, int sz,
Jim Grosbach95dee402011-07-08 17:40:42 +0000376 InstrItinClass itin, list<dag> pattern,
377 dag Result>
378 : tPseudoInst<oops, iops, sz, itin, pattern>,
379 PseudoInstExpansion<Result>;
380
Owen Anderson651b2302011-07-13 23:22:26 +0000381class t2PseudoExpand<dag oops, dag iops, int sz,
Jim Grosbach95dee402011-07-08 17:40:42 +0000382 InstrItinClass itin, list<dag> pattern,
383 dag Result>
384 : t2PseudoInst<oops, iops, sz, itin, pattern>,
385 PseudoInstExpansion<Result>;
386
Evan Cheng2d37f192008-08-28 23:39:26 +0000387// Almost all ARM instructions are predicable.
Owen Anderson651b2302011-07-13 23:22:26 +0000388class I<dag oops, dag iops, AddrMode am, int sz,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000389 IndexMode im, Format f, InstrItinClass itin,
David Goodwinb062c232009-08-06 16:52:47 +0000390 string opc, string asm, string cstr,
Evan Cheng2d37f192008-08-28 23:39:26 +0000391 list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000392 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach5476a272010-10-11 18:51:51 +0000393 bits<4> p;
394 let Inst{31-28} = p;
Evan Cheng2d37f192008-08-28 23:39:26 +0000395 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +0000396 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +0000397 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng2d37f192008-08-28 23:39:26 +0000398 let Pattern = pattern;
399 list<Predicate> Predicates = [IsARM];
400}
Bill Wendlingb70dc872010-08-31 07:50:46 +0000401
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000402// A few are not predicable
Owen Anderson651b2302011-07-13 23:22:26 +0000403class InoP<dag oops, dag iops, AddrMode am, int sz,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000404 IndexMode im, Format f, InstrItinClass itin,
405 string opc, string asm, string cstr,
406 list<dag> pattern>
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000407 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
408 let OutOperandList = oops;
409 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000410 let AsmString = !strconcat(opc, asm);
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000411 let Pattern = pattern;
412 let isPredicable = 0;
413 list<Predicate> Predicates = [IsARM];
414}
Evan Cheng2d37f192008-08-28 23:39:26 +0000415
Bill Wendlingf8dfa462010-08-30 01:47:35 +0000416// Same as I except it can optionally modify CPSR. Note it's modeled as an input
417// operand since by default it's a zero register. It will become an implicit def
418// once it's "flipped".
Owen Anderson651b2302011-07-13 23:22:26 +0000419class sI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000420 IndexMode im, Format f, InstrItinClass itin,
421 string opc, string asm, string cstr,
Evan Cheng2d37f192008-08-28 23:39:26 +0000422 list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000423 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach5476a272010-10-11 18:51:51 +0000424 bits<4> p; // Predicate operand
Jim Grosbachd9d31da2010-10-12 23:00:24 +0000425 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
Jim Grosbach5476a272010-10-11 18:51:51 +0000426 let Inst{31-28} = p;
Jim Grosbachd9d31da2010-10-12 23:00:24 +0000427 let Inst{20} = s;
Jim Grosbach5476a272010-10-11 18:51:51 +0000428
Evan Cheng2d37f192008-08-28 23:39:26 +0000429 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +0000430 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Bob Wilson59351842010-10-15 03:23:44 +0000431 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Cheng2d37f192008-08-28 23:39:26 +0000432 let Pattern = pattern;
433 list<Predicate> Predicates = [IsARM];
434}
435
Evan Chenga2827232008-09-01 07:19:00 +0000436// Special cases
Owen Anderson651b2302011-07-13 23:22:26 +0000437class XI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000438 IndexMode im, Format f, InstrItinClass itin,
439 string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000440 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Evan Chenga2827232008-09-01 07:19:00 +0000441 let OutOperandList = oops;
442 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000443 let AsmString = asm;
Evan Chenga2827232008-09-01 07:19:00 +0000444 let Pattern = pattern;
445 list<Predicate> Predicates = [IsARM];
446}
447
David Goodwinb062c232009-08-06 16:52:47 +0000448class AI<dag oops, dag iops, Format f, InstrItinClass itin,
449 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000450 : I<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000451 opc, asm, "", pattern>;
452class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
453 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000454 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000455 opc, asm, "", pattern>;
456class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng2d37f192008-08-28 23:39:26 +0000457 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000458 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
Evan Cheng49d66522008-11-06 22:15:19 +0000459 asm, "", pattern>;
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000460class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000461 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000462 : InoP<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000463 opc, asm, "", pattern>;
Evan Chengfa558782008-09-01 08:25:56 +0000464
465// Ctrl flow instructions
David Goodwinb062c232009-08-06 16:52:47 +0000466class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
467 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000468 : I<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000469 opc, asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000470 let Inst{27-24} = opcod;
Evan Chengfa558782008-09-01 08:25:56 +0000471}
David Goodwinb062c232009-08-06 16:52:47 +0000472class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
473 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000474 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000475 asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000476 let Inst{27-24} = opcod;
Evan Chengfa558782008-09-01 08:25:56 +0000477}
Evan Chengfa558782008-09-01 08:25:56 +0000478
479// BR_JT instructions
David Goodwinb062c232009-08-06 16:52:47 +0000480class JTI<dag oops, dag iops, InstrItinClass itin,
481 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000482 : XI<oops, iops, AddrModeNone, 0, IndexModeNone, BrMiscFrm, itin,
Evan Cheng7095cd22008-11-07 09:06:08 +0000483 asm, "", pattern>;
Evan Cheng624844b2008-09-01 01:51:14 +0000484
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000485// Atomic load/store instructions
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000486class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
487 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000488 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000489 opc, asm, "", pattern> {
Jim Grosbach4e57b522010-10-29 19:58:57 +0000490 bits<4> Rt;
Jim Grosbachcb311932011-07-26 17:44:46 +0000491 bits<4> addr;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000492 let Inst{27-23} = 0b00011;
493 let Inst{22-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000494 let Inst{20} = 1;
Jim Grosbachcb311932011-07-26 17:44:46 +0000495 let Inst{19-16} = addr;
Jim Grosbach4e57b522010-10-29 19:58:57 +0000496 let Inst{15-12} = Rt;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000497 let Inst{11-0} = 0b111110011111;
498}
499class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
500 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000501 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000502 opc, asm, "", pattern> {
Jim Grosbach4e57b522010-10-29 19:58:57 +0000503 bits<4> Rd;
504 bits<4> Rt;
Bruno Cardoso Lopesf170f8b2011-03-24 21:04:58 +0000505 bits<4> addr;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000506 let Inst{27-23} = 0b00011;
507 let Inst{22-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000508 let Inst{20} = 0;
Bruno Cardoso Lopesf170f8b2011-03-24 21:04:58 +0000509 let Inst{19-16} = addr;
Jim Grosbach4e57b522010-10-29 19:58:57 +0000510 let Inst{15-12} = Rd;
Johnny Chen098bd1b2009-12-11 19:37:26 +0000511 let Inst{11-4} = 0b11111001;
Jim Grosbach4e57b522010-10-29 19:58:57 +0000512 let Inst{3-0} = Rt;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000513}
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000514class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern>
Jim Grosbach15e8d742011-07-26 17:15:11 +0000515 : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, $addr", pattern> {
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000516 bits<4> Rt;
517 bits<4> Rt2;
Jim Grosbach15e8d742011-07-26 17:15:11 +0000518 bits<4> addr;
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000519 let Inst{27-23} = 0b00010;
520 let Inst{22} = b;
521 let Inst{21-20} = 0b00;
Jim Grosbach15e8d742011-07-26 17:15:11 +0000522 let Inst{19-16} = addr;
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000523 let Inst{15-12} = Rt;
524 let Inst{11-4} = 0b00001001;
525 let Inst{3-0} = Rt2;
Owen Andersondde461c2011-10-28 18:02:13 +0000526
527 let DecoderMethod = "DecodeSwap";
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000528}
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000529
Evan Cheng624844b2008-09-01 01:51:14 +0000530// addrmode1 instructions
David Goodwinb062c232009-08-06 16:52:47 +0000531class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
532 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000533 : I<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000534 opc, asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000535 let Inst{24-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000536 let Inst{27-26} = 0b00;
Evan Chengc139c222008-08-29 07:40:52 +0000537}
David Goodwinb062c232009-08-06 16:52:47 +0000538class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
539 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000540 : sI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000541 opc, asm, "", pattern> {
542 let Inst{24-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000543 let Inst{27-26} = 0b00;
David Goodwinb062c232009-08-06 16:52:47 +0000544}
545class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng2d37f192008-08-28 23:39:26 +0000546 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000547 : XI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
Evan Chengc139c222008-08-29 07:40:52 +0000548 asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000549 let Inst{24-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000550 let Inst{27-26} = 0b00;
Evan Chengc139c222008-08-29 07:40:52 +0000551}
Evan Cheng624844b2008-09-01 01:51:14 +0000552
Evan Chengcccca872008-09-01 01:27:33 +0000553// loads
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000554
Jim Grosbach4a22eba2010-11-19 21:07:51 +0000555// LDR/LDRB/STR/STRB/...
556class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am,
Jim Grosbach338de3e2010-10-27 23:12:14 +0000557 Format f, InstrItinClass itin, string opc, string asm,
558 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000559 : I<oops, iops, am, 4, IndexModeNone, f, itin, opc, asm,
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000560 "", pattern> {
561 let Inst{27-25} = op;
562 let Inst{24} = 1; // 24 == P
563 // 23 == U
Jim Grosbach2f790742010-11-13 00:35:48 +0000564 let Inst{22} = isByte;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000565 let Inst{21} = 0; // 21 == W
Jim Grosbach338de3e2010-10-27 23:12:14 +0000566 let Inst{20} = isLd;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000567}
Jim Grosbach2f790742010-11-13 00:35:48 +0000568// Indexed load/stores
569class AI2ldstidx<bit isLd, bit isByte, bit isPre, dag oops, dag iops,
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000570 IndexMode im, Format f, InstrItinClass itin, string opc,
Jim Grosbach2f790742010-11-13 00:35:48 +0000571 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000572 : I<oops, iops, AddrMode2, 4, im, f, itin,
Jim Grosbach2f790742010-11-13 00:35:48 +0000573 opc, asm, cstr, pattern> {
Jim Grosbach38b469e2010-11-15 20:47:07 +0000574 bits<4> Rt;
Jim Grosbach2f790742010-11-13 00:35:48 +0000575 let Inst{27-26} = 0b01;
576 let Inst{24} = isPre; // P bit
577 let Inst{22} = isByte; // B bit
578 let Inst{21} = isPre; // W bit
579 let Inst{20} = isLd; // L bit
Jim Grosbach38b469e2010-11-15 20:47:07 +0000580 let Inst{15-12} = Rt;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000581}
Owen Anderson2aedba62011-07-26 20:54:26 +0000582class AI2stridx_reg<bit isByte, bit isPre, dag oops, dag iops,
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000583 IndexMode im, Format f, InstrItinClass itin, string opc,
584 string asm, string cstr, list<dag> pattern>
585 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
586 pattern> {
587 // AM2 store w/ two operands: (GPR, am2offset)
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000588 // {12} isAdd
589 // {11-0} imm12/Rm
Bruno Cardoso Lopesc2452a62011-03-31 15:54:36 +0000590 bits<14> offset;
591 bits<4> Rn;
Owen Anderson2aedba62011-07-26 20:54:26 +0000592 let Inst{25} = 1;
593 let Inst{23} = offset{12};
594 let Inst{19-16} = Rn;
595 let Inst{11-5} = offset{11-5};
596 let Inst{4} = 0;
597 let Inst{3-0} = offset{3-0};
598}
599
600class AI2stridx_imm<bit isByte, bit isPre, dag oops, dag iops,
601 IndexMode im, Format f, InstrItinClass itin, string opc,
602 string asm, string cstr, list<dag> pattern>
603 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
604 pattern> {
605 // AM2 store w/ two operands: (GPR, am2offset)
606 // {12} isAdd
607 // {11-0} imm12/Rm
608 bits<14> offset;
609 bits<4> Rn;
610 let Inst{25} = 0;
Bruno Cardoso Lopesc2452a62011-03-31 15:54:36 +0000611 let Inst{23} = offset{12};
612 let Inst{19-16} = Rn;
613 let Inst{11-0} = offset{11-0};
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000614}
Owen Anderson2aedba62011-07-26 20:54:26 +0000615
616
Bruno Cardoso Lopesab830502011-03-31 23:26:08 +0000617// FIXME: Merge with the above class when addrmode2 gets used for STR, STRB
618// but for now use this class for STRT and STRBT.
619class AI2stridxT<bit isByte, bit isPre, dag oops, dag iops,
620 IndexMode im, Format f, InstrItinClass itin, string opc,
621 string asm, string cstr, list<dag> pattern>
622 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
623 pattern> {
624 // AM2 store w/ two operands: (GPR, am2offset)
625 // {17-14} Rn
626 // {13} 1 == Rm, 0 == imm12
627 // {12} isAdd
628 // {11-0} imm12/Rm
629 bits<18> addr;
630 let Inst{25} = addr{13};
631 let Inst{23} = addr{12};
632 let Inst{19-16} = addr{17-14};
633 let Inst{11-0} = addr{11-0};
634}
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000635
Evan Cheng624844b2008-09-01 01:51:14 +0000636// addrmode3 instructions
Jim Grosbach76aed402010-11-19 18:16:46 +0000637class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f,
638 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000639 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
Jim Grosbach8e7f8df2010-11-18 00:46:58 +0000640 opc, asm, "", pattern> {
641 bits<14> addr;
642 bits<4> Rt;
643 let Inst{27-25} = 0b000;
644 let Inst{24} = 1; // P bit
645 let Inst{23} = addr{8}; // U bit
646 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
647 let Inst{21} = 0; // W bit
Jim Grosbach76aed402010-11-19 18:16:46 +0000648 let Inst{20} = op20; // L bit
Jim Grosbach8e7f8df2010-11-18 00:46:58 +0000649 let Inst{19-16} = addr{12-9}; // Rn
650 let Inst{15-12} = Rt; // Rt
651 let Inst{11-8} = addr{7-4}; // imm7_4/zero
652 let Inst{7-4} = op;
653 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
Owen Andersone0152a72011-08-09 20:55:18 +0000654
655 let DecoderMethod = "DecodeAddrMode3Instruction";
Jim Grosbach8e7f8df2010-11-18 00:46:58 +0000656}
Evan Cheng169eccc2008-09-01 07:00:14 +0000657
Jim Grosbach2ea19d12011-08-11 20:41:13 +0000658class AI3ldstidx<bits<4> op, bit op20, bit isPre, dag oops, dag iops,
Jim Grosbach003c6e72010-11-19 19:41:26 +0000659 IndexMode im, Format f, InstrItinClass itin, string opc,
660 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000661 : I<oops, iops, AddrMode3, 4, im, f, itin,
Jim Grosbach003c6e72010-11-19 19:41:26 +0000662 opc, asm, cstr, pattern> {
663 bits<4> Rt;
664 let Inst{27-25} = 0b000;
665 let Inst{24} = isPre; // P bit
666 let Inst{21} = isPre; // W bit
667 let Inst{20} = op20; // L bit
668 let Inst{15-12} = Rt; // Rt
669 let Inst{7-4} = op;
670}
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000671
672// FIXME: Merge with the above class when addrmode2 gets used for LDR, LDRB
673// but for now use this class for LDRSBT, LDRHT, LDSHT.
Jim Grosbachd3595712011-08-03 23:50:40 +0000674class AI3ldstidxT<bits<4> op, bit isLoad, dag oops, dag iops,
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000675 IndexMode im, Format f, InstrItinClass itin, string opc,
676 string asm, string cstr, list<dag> pattern>
Jim Grosbachd3595712011-08-03 23:50:40 +0000677 : I<oops, iops, AddrMode3, 4, im, f, itin, opc, asm, cstr, pattern> {
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000678 // {13} 1 == imm8, 0 == Rm
679 // {12-9} Rn
680 // {8} isAdd
681 // {7-4} imm7_4/zero
682 // {3-0} imm3_0/Rm
Jim Grosbachd3595712011-08-03 23:50:40 +0000683 bits<4> addr;
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000684 bits<4> Rt;
685 let Inst{27-25} = 0b000;
Jim Grosbachd3595712011-08-03 23:50:40 +0000686 let Inst{24} = 0; // P bit
687 let Inst{21} = 1;
688 let Inst{20} = isLoad; // L bit
689 let Inst{19-16} = addr; // Rn
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000690 let Inst{15-12} = Rt; // Rt
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000691 let Inst{7-4} = op;
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000692}
693
Evan Cheng169eccc2008-09-01 07:00:14 +0000694// stores
Jim Grosbach09d7bfd2010-11-19 22:14:31 +0000695class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin,
David Goodwinb062c232009-08-06 16:52:47 +0000696 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000697 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000698 opc, asm, "", pattern> {
Jim Grosbach607efcb2010-11-11 01:09:40 +0000699 bits<14> addr;
700 bits<4> Rt;
Evan Cheng5edd90c2009-07-08 22:51:32 +0000701 let Inst{27-25} = 0b000;
Jim Grosbach607efcb2010-11-11 01:09:40 +0000702 let Inst{24} = 1; // P bit
703 let Inst{23} = addr{8}; // U bit
704 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
705 let Inst{21} = 0; // W bit
706 let Inst{20} = 0; // L bit
707 let Inst{19-16} = addr{12-9}; // Rn
708 let Inst{15-12} = Rt; // Rt
709 let Inst{11-8} = addr{7-4}; // imm7_4/zero
Jim Grosbach09d7bfd2010-11-19 22:14:31 +0000710 let Inst{7-4} = op;
Jim Grosbach607efcb2010-11-11 01:09:40 +0000711 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
Owen Anderson60138ea2011-08-12 20:02:50 +0000712 let DecoderMethod = "DecodeAddrMode3Instruction";
Evan Cheng169eccc2008-09-01 07:00:14 +0000713}
Evan Cheng169eccc2008-09-01 07:00:14 +0000714
Evan Cheng624844b2008-09-01 01:51:14 +0000715// addrmode4 instructions
Bill Wendlinge69afc62010-11-13 09:09:38 +0000716class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
717 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000718 : XI<oops, iops, AddrMode4, 4, im, f, itin, asm, cstr, pattern> {
Bill Wendlinge69afc62010-11-13 09:09:38 +0000719 bits<4> p;
720 bits<16> regs;
721 bits<4> Rn;
722 let Inst{31-28} = p;
723 let Inst{27-25} = 0b100;
724 let Inst{22} = 0; // S bit
725 let Inst{19-16} = Rn;
726 let Inst{15-0} = regs;
727}
Evan Cheng2d37f192008-08-28 23:39:26 +0000728
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000729// Unsigned multiply, multiply-accumulate instructions.
David Goodwinb062c232009-08-06 16:52:47 +0000730class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
731 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000732 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000733 opc, asm, "", pattern> {
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000734 let Inst{7-4} = 0b1001;
Evan Cheng2686c8f2008-11-06 01:21:28 +0000735 let Inst{20} = 0; // S bit
Evan Cheng47b546d2008-11-06 08:47:38 +0000736 let Inst{27-21} = opcod;
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000737}
David Goodwinb062c232009-08-06 16:52:47 +0000738class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
739 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000740 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000741 opc, asm, "", pattern> {
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000742 let Inst{7-4} = 0b1001;
Evan Cheng47b546d2008-11-06 08:47:38 +0000743 let Inst{27-21} = opcod;
Evan Cheng2686c8f2008-11-06 01:21:28 +0000744}
745
746// Most significant word multiply
Jim Grosbach22261602010-10-22 17:16:17 +0000747class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
748 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000749 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000750 opc, asm, "", pattern> {
Jim Grosbach22261602010-10-22 17:16:17 +0000751 bits<4> Rd;
752 bits<4> Rn;
753 bits<4> Rm;
754 let Inst{7-4} = opc7_4;
Evan Cheng2686c8f2008-11-06 01:21:28 +0000755 let Inst{20} = 1;
Evan Cheng47b546d2008-11-06 08:47:38 +0000756 let Inst{27-21} = opcod;
Jim Grosbach22261602010-10-22 17:16:17 +0000757 let Inst{19-16} = Rd;
758 let Inst{11-8} = Rm;
759 let Inst{3-0} = Rn;
760}
761// MSW multiple w/ Ra operand
762class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
763 InstrItinClass itin, string opc, string asm, list<dag> pattern>
764 : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> {
765 bits<4> Ra;
766 let Inst{15-12} = Ra;
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000767}
Evan Cheng2d37f192008-08-28 23:39:26 +0000768
Evan Cheng36ae4032008-11-06 03:35:07 +0000769// SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
Jim Grosbach6956a602010-10-22 18:35:16 +0000770class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
Jim Grosbachf98df082010-10-22 17:42:06 +0000771 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000772 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000773 opc, asm, "", pattern> {
Jim Grosbach6956a602010-10-22 18:35:16 +0000774 bits<4> Rn;
775 bits<4> Rm;
Evan Cheng36ae4032008-11-06 03:35:07 +0000776 let Inst{4} = 0;
777 let Inst{7} = 1;
778 let Inst{20} = 0;
Evan Cheng47b546d2008-11-06 08:47:38 +0000779 let Inst{27-21} = opcod;
Jim Grosbachf98df082010-10-22 17:42:06 +0000780 let Inst{6-5} = bit6_5;
Jim Grosbach6956a602010-10-22 18:35:16 +0000781 let Inst{11-8} = Rm;
782 let Inst{3-0} = Rn;
783}
784class AMulxyI<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
785 InstrItinClass itin, string opc, string asm, list<dag> pattern>
786 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
787 bits<4> Rd;
788 let Inst{19-16} = Rd;
789}
790
791// AMulxyI with Ra operand
792class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
793 InstrItinClass itin, string opc, string asm, list<dag> pattern>
794 : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
795 bits<4> Ra;
796 let Inst{15-12} = Ra;
797}
798// SMLAL*
799class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
800 InstrItinClass itin, string opc, string asm, list<dag> pattern>
801 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
802 bits<4> RdLo;
803 bits<4> RdHi;
804 let Inst{19-16} = RdHi;
805 let Inst{15-12} = RdLo;
Evan Cheng36ae4032008-11-06 03:35:07 +0000806}
807
Evan Cheng49d66522008-11-06 22:15:19 +0000808// Extend instructions.
David Goodwinb062c232009-08-06 16:52:47 +0000809class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
810 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000811 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ExtFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000812 opc, asm, "", pattern> {
Jim Grosbach1e7db682010-10-13 19:56:10 +0000813 // All AExtI instructions have Rd and Rm register operands.
814 bits<4> Rd;
815 bits<4> Rm;
816 let Inst{15-12} = Rd;
817 let Inst{3-0} = Rm;
Evan Cheng49d66522008-11-06 22:15:19 +0000818 let Inst{7-4} = 0b0111;
Jim Grosbach1e7db682010-10-13 19:56:10 +0000819 let Inst{9-8} = 0b00;
Evan Cheng49d66522008-11-06 22:15:19 +0000820 let Inst{27-20} = opcod;
821}
822
Evan Cheng98dc53e2008-11-07 01:41:35 +0000823// Misc Arithmetic instructions.
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000824class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
825 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000826 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000827 opc, asm, "", pattern> {
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000828 bits<4> Rd;
829 bits<4> Rm;
Evan Cheng98dc53e2008-11-07 01:41:35 +0000830 let Inst{27-20} = opcod;
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000831 let Inst{19-16} = 0b1111;
832 let Inst{15-12} = Rd;
833 let Inst{11-8} = 0b1111;
834 let Inst{7-4} = opc7_4;
835 let Inst{3-0} = Rm;
836}
837
838// PKH instructions
Jim Grosbach3a3d8e82011-11-12 00:58:43 +0000839def PKHLSLAsmOperand : ImmAsmOperand {
Jim Grosbach27c1e252011-07-21 17:23:04 +0000840 let Name = "PKHLSLImm";
841 let ParserMethod = "parsePKHLSLImm";
842}
Jim Grosbacha288b1c2011-07-20 21:40:26 +0000843def pkh_lsl_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 32; }]>{
844 let PrintMethod = "printPKHLSLShiftImm";
Jim Grosbach27c1e252011-07-21 17:23:04 +0000845 let ParserMatchClass = PKHLSLAsmOperand;
846}
847def PKHASRAsmOperand : AsmOperandClass {
848 let Name = "PKHASRImm";
849 let ParserMethod = "parsePKHASRImm";
Jim Grosbacha288b1c2011-07-20 21:40:26 +0000850}
851def pkh_asr_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 32; }]>{
852 let PrintMethod = "printPKHASRShiftImm";
Jim Grosbach27c1e252011-07-21 17:23:04 +0000853 let ParserMatchClass = PKHASRAsmOperand;
Jim Grosbacha288b1c2011-07-20 21:40:26 +0000854}
Jim Grosbach94df3be2011-07-20 20:49:03 +0000855
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000856class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
857 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000858 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000859 opc, asm, "", pattern> {
860 bits<4> Rd;
861 bits<4> Rn;
862 bits<4> Rm;
Jim Grosbacha98f8002011-07-20 20:32:09 +0000863 bits<5> sh;
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000864 let Inst{27-20} = opcod;
865 let Inst{19-16} = Rn;
866 let Inst{15-12} = Rd;
Jim Grosbacha98f8002011-07-20 20:32:09 +0000867 let Inst{11-7} = sh;
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000868 let Inst{6} = tb;
869 let Inst{5-4} = 0b01;
870 let Inst{3-0} = Rm;
Evan Cheng98dc53e2008-11-07 01:41:35 +0000871}
872
Evan Cheng2d37f192008-08-28 23:39:26 +0000873//===----------------------------------------------------------------------===//
874
875// ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
876class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
877 list<Predicate> Predicates = [IsARM];
878}
Bruno Cardoso Lopes168c9002011-05-03 17:29:22 +0000879class ARMV5TPat<dag pattern, dag result> : Pat<pattern, result> {
880 list<Predicate> Predicates = [IsARM, HasV5T];
881}
Evan Cheng2d37f192008-08-28 23:39:26 +0000882class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
883 list<Predicate> Predicates = [IsARM, HasV5TE];
884}
885class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
886 list<Predicate> Predicates = [IsARM, HasV6];
887}
Evan Chengee98fa92008-08-29 06:41:12 +0000888
889//===----------------------------------------------------------------------===//
Evan Chengee98fa92008-08-29 06:41:12 +0000890// Thumb Instruction Format Definitions.
891//
892
Owen Anderson651b2302011-07-13 23:22:26 +0000893class ThumbI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000894 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +0000895 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengcd4cdd12009-07-11 06:43:01 +0000896 let OutOperandList = oops;
897 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000898 let AsmString = asm;
Evan Chengee98fa92008-08-29 06:41:12 +0000899 let Pattern = pattern;
900 list<Predicate> Predicates = [IsThumb];
901}
902
Bill Wendlingcbb08ca2010-12-01 02:42:55 +0000903// TI - Thumb instruction.
David Goodwinb062c232009-08-06 16:52:47 +0000904class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000905 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
Evan Chengee98fa92008-08-29 06:41:12 +0000906
Evan Cheng7cc6aca2009-08-04 23:47:55 +0000907// Two-address instructions
Bob Wilson3968c6a2010-03-23 17:23:59 +0000908class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
909 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000910 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "$lhs = $dst",
Bob Wilson3968c6a2010-03-23 17:23:59 +0000911 pattern>;
Evan Cheng7cc6aca2009-08-04 23:47:55 +0000912
Johnny Chenc28e6292009-12-15 17:24:14 +0000913// tBL, tBX 32-bit instructions
914class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000915 dag oops, dag iops, InstrItinClass itin, string asm,
916 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000917 : ThumbI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000918 Encoding {
Johnny Chenc28e6292009-12-15 17:24:14 +0000919 let Inst{31-27} = opcod1;
920 let Inst{15-14} = opcod2;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000921 let Inst{12} = opcod3;
Johnny Chenc28e6292009-12-15 17:24:14 +0000922}
Evan Chengee98fa92008-08-29 06:41:12 +0000923
924// BR_JT instructions
Bob Wilson3968c6a2010-03-23 17:23:59 +0000925class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
926 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000927 : ThumbI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
Evan Chengee98fa92008-08-29 06:41:12 +0000928
Evan Chengbec1dba892009-06-23 19:38:13 +0000929// Thumb1 only
Owen Anderson651b2302011-07-13 23:22:26 +0000930class Thumb1I<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000931 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +0000932 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengcd4cdd12009-07-11 06:43:01 +0000933 let OutOperandList = oops;
934 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000935 let AsmString = asm;
Evan Chengbec1dba892009-06-23 19:38:13 +0000936 let Pattern = pattern;
Jim Grosbachfddf36d2010-11-01 17:08:58 +0000937 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Chengbec1dba892009-06-23 19:38:13 +0000938}
939
David Goodwinb062c232009-08-06 16:52:47 +0000940class T1I<dag oops, dag iops, InstrItinClass itin,
941 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000942 : Thumb1I<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +0000943class T1Ix2<dag oops, dag iops, InstrItinClass itin,
944 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000945 : Thumb1I<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
Evan Chengbec1dba892009-06-23 19:38:13 +0000946
947// Two-address instructions
David Goodwinb062c232009-08-06 16:52:47 +0000948class T1It<dag oops, dag iops, InstrItinClass itin,
Bob Wilson947f04b2010-03-13 01:08:20 +0000949 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000950 : Thumb1I<oops, iops, AddrModeNone, 2, itin,
Bob Wilson947f04b2010-03-13 01:08:20 +0000951 asm, cstr, pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +0000952
953// Thumb1 instruction that can either be predicated or set CPSR.
Owen Anderson651b2302011-07-13 23:22:26 +0000954class Thumb1sI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000955 InstrItinClass itin,
Evan Chengcd4cdd12009-07-11 06:43:01 +0000956 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +0000957 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Chris Lattnerfb2ceed2010-03-18 21:06:54 +0000958 let OutOperandList = !con(oops, (outs s_cc_out:$s));
959 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +0000960 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Chengcd4cdd12009-07-11 06:43:01 +0000961 let Pattern = pattern;
Jim Grosbach3e941ae2011-08-16 20:45:50 +0000962 let thumbArithFlagSetting = 1;
Jim Grosbachfddf36d2010-11-01 17:08:58 +0000963 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Owen Anderson91a8f9b2011-08-16 23:45:44 +0000964 let DecoderNamespace = "ThumbSBit";
Evan Chengcd4cdd12009-07-11 06:43:01 +0000965}
966
David Goodwinb062c232009-08-06 16:52:47 +0000967class T1sI<dag oops, dag iops, InstrItinClass itin,
968 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000969 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +0000970
971// Two-address instructions
David Goodwinb062c232009-08-06 16:52:47 +0000972class T1sIt<dag oops, dag iops, InstrItinClass itin,
973 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000974 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm,
Bill Wendling05632cb2010-11-30 23:54:45 +0000975 "$Rn = $Rdn", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +0000976
977// Thumb1 instruction that can be predicated.
Owen Anderson651b2302011-07-13 23:22:26 +0000978class Thumb1pI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000979 InstrItinClass itin,
Evan Chengcd4cdd12009-07-11 06:43:01 +0000980 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +0000981 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengcd4cdd12009-07-11 06:43:01 +0000982 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +0000983 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +0000984 let AsmString = !strconcat(opc, "${p}", asm);
Evan Chengcd4cdd12009-07-11 06:43:01 +0000985 let Pattern = pattern;
Jim Grosbachfddf36d2010-11-01 17:08:58 +0000986 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Chengcd4cdd12009-07-11 06:43:01 +0000987}
988
David Goodwinb062c232009-08-06 16:52:47 +0000989class T1pI<dag oops, dag iops, InstrItinClass itin,
990 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000991 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +0000992
993// Two-address instructions
David Goodwinb062c232009-08-06 16:52:47 +0000994class T1pIt<dag oops, dag iops, InstrItinClass itin,
995 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000996 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm,
Bill Wendling7c646b92010-12-01 01:32:02 +0000997 "$Rn = $Rdn", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +0000998
Bob Wilson3968c6a2010-03-23 17:23:59 +0000999class T1pIs<dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001000 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001001 : Thumb1pI<oops, iops, AddrModeT1_s, 2, itin, opc, asm, "", pattern>;
Evan Chengbec1dba892009-06-23 19:38:13 +00001002
Johnny Chen466231a2009-12-16 02:32:54 +00001003class Encoding16 : Encoding {
1004 let Inst{31-16} = 0x0000;
1005}
1006
Johnny Chenc28e6292009-12-15 17:24:14 +00001007// A6.2 16-bit Thumb instruction encoding
Johnny Chen466231a2009-12-16 02:32:54 +00001008class T1Encoding<bits<6> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001009 let Inst{15-10} = opcode;
1010}
1011
1012// A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001013class T1General<bits<5> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001014 let Inst{15-14} = 0b00;
1015 let Inst{13-9} = opcode;
1016}
1017
1018// A6.2.2 Data-processing encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001019class T1DataProcessing<bits<4> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001020 let Inst{15-10} = 0b010000;
1021 let Inst{9-6} = opcode;
1022}
1023
1024// A6.2.3 Special data instructions and branch and exchange encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001025class T1Special<bits<4> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001026 let Inst{15-10} = 0b010001;
Bill Wendling345b48f2010-11-17 00:45:23 +00001027 let Inst{9-6} = opcode;
Johnny Chenc28e6292009-12-15 17:24:14 +00001028}
1029
1030// A6.2.4 Load/store single data item encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001031class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001032 let Inst{15-12} = opA;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001033 let Inst{11-9} = opB;
Johnny Chenc28e6292009-12-15 17:24:14 +00001034}
Bill Wendlingb70dc872010-08-31 07:50:46 +00001035class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative
Johnny Chenc28e6292009-12-15 17:24:14 +00001036
Eric Christopher9b67db82011-05-27 03:50:53 +00001037class T1BranchCond<bits<4> opcode> : Encoding16 {
1038 let Inst{15-12} = opcode;
1039}
1040
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001041// Helper classes to encode Thumb1 loads and stores. For immediates, the
Bill Wendling05632cb2010-11-30 23:54:45 +00001042// following bits are used for "opA" (see A6.2.4):
Jim Grosbachc4669ed2010-12-10 20:47:29 +00001043//
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001044// 0b0110 => Immediate, 4 bytes
1045// 0b1000 => Immediate, 2 bytes
1046// 0b0111 => Immediate, 1 byte
Bill Wendlingc25545a2010-12-01 01:38:08 +00001047class T1pILdStEncode<bits<3> opcode, dag oops, dag iops, AddrMode am,
1048 InstrItinClass itin, string opc, string asm,
1049 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001050 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
Bill Wendling5c51fcd2010-11-30 23:16:25 +00001051 T1LoadStore<0b0101, opcode> {
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001052 bits<3> Rt;
1053 bits<8> addr;
1054 let Inst{8-6} = addr{5-3}; // Rm
1055 let Inst{5-3} = addr{2-0}; // Rn
1056 let Inst{2-0} = Rt;
1057}
Bill Wendlingc25545a2010-12-01 01:38:08 +00001058class T1pILdStEncodeImm<bits<4> opA, bit opB, dag oops, dag iops, AddrMode am,
1059 InstrItinClass itin, string opc, string asm,
1060 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001061 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
Bill Wendling5c51fcd2010-11-30 23:16:25 +00001062 T1LoadStore<opA, {opB,?,?}> {
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001063 bits<3> Rt;
1064 bits<8> addr;
1065 let Inst{10-6} = addr{7-3}; // imm5
1066 let Inst{5-3} = addr{2-0}; // Rn
1067 let Inst{2-0} = Rt;
1068}
1069
Johnny Chenc28e6292009-12-15 17:24:14 +00001070// A6.2.5 Miscellaneous 16-bit instructions encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001071class T1Misc<bits<7> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001072 let Inst{15-12} = 0b1011;
1073 let Inst{11-5} = opcode;
1074}
1075
Evan Chengd76f0be2009-06-25 02:08:06 +00001076// Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
Owen Anderson651b2302011-07-13 23:22:26 +00001077class Thumb2I<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001078 InstrItinClass itin,
Evan Chengd76f0be2009-06-25 02:08:06 +00001079 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001080 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengd76f0be2009-06-25 02:08:06 +00001081 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001082 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001083 let AsmString = !strconcat(opc, "${p}", asm);
Evan Chengd76f0be2009-06-25 02:08:06 +00001084 let Pattern = pattern;
Evan Cheng2c450d32009-07-02 06:38:40 +00001085 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001086 let DecoderNamespace = "Thumb2";
Evan Chengd76f0be2009-06-25 02:08:06 +00001087}
1088
Bill Wendlingb70dc872010-08-31 07:50:46 +00001089// Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
1090// input operand since by default it's a zero register. It will become an
1091// implicit def once it's "flipped".
Jim Grosbachb9386552010-10-13 23:12:26 +00001092//
Evan Chengd76f0be2009-06-25 02:08:06 +00001093// FIXME: This uses unified syntax so {s} comes before {p}. We should make it
1094// more consistent.
Owen Anderson651b2302011-07-13 23:22:26 +00001095class Thumb2sI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001096 InstrItinClass itin,
Evan Chengd76f0be2009-06-25 02:08:06 +00001097 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001098 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Owen Andersoncf096a42010-12-07 20:50:15 +00001099 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
1100 let Inst{20} = s;
1101
Evan Chengd76f0be2009-06-25 02:08:06 +00001102 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001103 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Chris Lattner04c342e2010-10-06 00:05:18 +00001104 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Chengd76f0be2009-06-25 02:08:06 +00001105 let Pattern = pattern;
Evan Cheng2c450d32009-07-02 06:38:40 +00001106 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001107 let DecoderNamespace = "Thumb2";
Evan Chengd76f0be2009-06-25 02:08:06 +00001108}
1109
1110// Special cases
Owen Anderson651b2302011-07-13 23:22:26 +00001111class Thumb2XI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001112 InstrItinClass itin,
Evan Chengd76f0be2009-06-25 02:08:06 +00001113 string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001114 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengd76f0be2009-06-25 02:08:06 +00001115 let OutOperandList = oops;
1116 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001117 let AsmString = asm;
Evan Cheng431cf562009-06-23 17:48:47 +00001118 let Pattern = pattern;
Evan Cheng2c450d32009-07-02 06:38:40 +00001119 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001120 let DecoderNamespace = "Thumb2";
Evan Cheng431cf562009-06-23 17:48:47 +00001121}
1122
Owen Anderson651b2302011-07-13 23:22:26 +00001123class ThumbXI<dag oops, dag iops, AddrMode am, int sz,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001124 InstrItinClass itin,
1125 string asm, string cstr, list<dag> pattern>
Jim Grosbach36d4dec2009-12-01 18:10:36 +00001126 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1127 let OutOperandList = oops;
1128 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001129 let AsmString = asm;
Jim Grosbach36d4dec2009-12-01 18:10:36 +00001130 let Pattern = pattern;
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001131 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001132 let DecoderNamespace = "Thumb";
Jim Grosbach36d4dec2009-12-01 18:10:36 +00001133}
1134
David Goodwinb062c232009-08-06 16:52:47 +00001135class T2I<dag oops, dag iops, InstrItinClass itin,
1136 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001137 : Thumb2I<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001138class T2Ii12<dag oops, dag iops, InstrItinClass itin,
1139 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001140 : Thumb2I<oops, iops, AddrModeT2_i12, 4, itin, opc, asm, "",pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001141class T2Ii8<dag oops, dag iops, InstrItinClass itin,
1142 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001143 : Thumb2I<oops, iops, AddrModeT2_i8, 4, itin, opc, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001144class T2Iso<dag oops, dag iops, InstrItinClass itin,
1145 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001146 : Thumb2I<oops, iops, AddrModeT2_so, 4, itin, opc, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001147class T2Ipc<dag oops, dag iops, InstrItinClass itin,
1148 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001149 : Thumb2I<oops, iops, AddrModeT2_pc, 4, itin, opc, asm, "", pattern>;
Jim Grosbach95bd6b72010-12-10 20:51:35 +00001150class T2Ii8s4<bit P, bit W, bit isLoad, dag oops, dag iops, InstrItinClass itin,
Jim Grosbach7db8d692011-09-08 22:07:06 +00001151 string opc, string asm, string cstr, list<dag> pattern>
1152 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
Johnny Chenc28e6292009-12-15 17:24:14 +00001153 pattern> {
Owen Anderson943fb602010-12-01 19:18:46 +00001154 bits<4> Rt;
1155 bits<4> Rt2;
1156 bits<13> addr;
Jim Grosbach95bd6b72010-12-10 20:51:35 +00001157 let Inst{31-25} = 0b1110100;
1158 let Inst{24} = P;
1159 let Inst{23} = addr{8};
1160 let Inst{22} = 1;
1161 let Inst{21} = W;
1162 let Inst{20} = isLoad;
1163 let Inst{19-16} = addr{12-9};
Owen Anderson943fb602010-12-01 19:18:46 +00001164 let Inst{15-12} = Rt{3-0};
1165 let Inst{11-8} = Rt2{3-0};
Owen Anderson943fb602010-12-01 19:18:46 +00001166 let Inst{7-0} = addr{7-0};
Johnny Chenc28e6292009-12-15 17:24:14 +00001167}
Jim Grosbach7db8d692011-09-08 22:07:06 +00001168class T2Ii8s4post<bit P, bit W, bit isLoad, dag oops, dag iops,
1169 InstrItinClass itin, string opc, string asm, string cstr,
1170 list<dag> pattern>
1171 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
Owen Anderson08d4bb02011-08-04 23:18:05 +00001172 pattern> {
1173 bits<4> Rt;
1174 bits<4> Rt2;
Jim Grosbach7db8d692011-09-08 22:07:06 +00001175 bits<4> addr;
Owen Anderson08d4bb02011-08-04 23:18:05 +00001176 bits<9> imm;
1177 let Inst{31-25} = 0b1110100;
1178 let Inst{24} = P;
1179 let Inst{23} = imm{8};
1180 let Inst{22} = 1;
1181 let Inst{21} = W;
1182 let Inst{20} = isLoad;
Jim Grosbach7db8d692011-09-08 22:07:06 +00001183 let Inst{19-16} = addr;
Owen Anderson08d4bb02011-08-04 23:18:05 +00001184 let Inst{15-12} = Rt{3-0};
1185 let Inst{11-8} = Rt2{3-0};
1186 let Inst{7-0} = imm{7-0};
1187}
1188
David Goodwinb062c232009-08-06 16:52:47 +00001189class T2sI<dag oops, dag iops, InstrItinClass itin,
1190 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001191 : Thumb2sI<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
Evan Chengd76f0be2009-06-25 02:08:06 +00001192
David Goodwinb062c232009-08-06 16:52:47 +00001193class T2XI<dag oops, dag iops, InstrItinClass itin,
1194 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001195 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001196class T2JTI<dag oops, dag iops, InstrItinClass itin,
1197 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001198 : Thumb2XI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
Evan Cheng431cf562009-06-23 17:48:47 +00001199
Bruno Cardoso Lopes4d4b4902011-01-20 16:58:48 +00001200// Move to/from coprocessor instructions
Jim Grosbachcabb48d2011-07-13 21:17:59 +00001201class T2Cop<bits<4> opc, dag oops, dag iops, string asm, list<dag> pattern>
Jim Grosbachadb29b62011-07-13 21:14:23 +00001202 : T2XI <oops, iops, NoItinerary, asm, pattern>, Requires<[IsThumb2]> {
Jim Grosbachcabb48d2011-07-13 21:17:59 +00001203 let Inst{31-28} = opc;
Bruno Cardoso Lopes4d4b4902011-01-20 16:58:48 +00001204}
1205
Bob Wilson947f04b2010-03-13 01:08:20 +00001206// Two-address instructions
1207class T2XIt<dag oops, dag iops, InstrItinClass itin,
1208 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001209 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, cstr, pattern>;
Evan Cheng83e0d482009-09-28 09:14:39 +00001210
Jim Grosbachc086f682011-09-08 00:39:19 +00001211// T2Ipreldst - Thumb2 pre-indexed load / store instructions.
1212class T2Ipreldst<bit signed, bits<2> opcod, bit load, bit pre,
Johnny Chenc28e6292009-12-15 17:24:14 +00001213 dag oops, dag iops,
1214 AddrMode am, IndexMode im, InstrItinClass itin,
Evan Cheng84c6cda2009-07-02 07:28:31 +00001215 string opc, string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001216 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng84c6cda2009-07-02 07:28:31 +00001217 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001218 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001219 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng84c6cda2009-07-02 07:28:31 +00001220 let Pattern = pattern;
1221 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001222 let DecoderNamespace = "Thumb2";
Jim Grosbachc086f682011-09-08 00:39:19 +00001223
1224 bits<4> Rt;
1225 bits<13> addr;
Johnny Chenc28e6292009-12-15 17:24:14 +00001226 let Inst{31-27} = 0b11111;
1227 let Inst{26-25} = 0b00;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001228 let Inst{24} = signed;
1229 let Inst{23} = 0;
Johnny Chenc28e6292009-12-15 17:24:14 +00001230 let Inst{22-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001231 let Inst{20} = load;
Jim Grosbachc086f682011-09-08 00:39:19 +00001232 let Inst{19-16} = addr{12-9};
1233 let Inst{15-12} = Rt{3-0};
Bill Wendlingb70dc872010-08-31 07:50:46 +00001234 let Inst{11} = 1;
Johnny Chenc28e6292009-12-15 17:24:14 +00001235 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
Bill Wendlingb70dc872010-08-31 07:50:46 +00001236 let Inst{10} = pre; // The P bit.
Jim Grosbachc086f682011-09-08 00:39:19 +00001237 let Inst{9} = addr{8}; // Sign bit
Bill Wendlingb70dc872010-08-31 07:50:46 +00001238 let Inst{8} = 1; // The W bit.
Jim Grosbachc086f682011-09-08 00:39:19 +00001239 let Inst{7-0} = addr{7-0};
Owen Andersona9ebf6f2011-09-12 18:56:30 +00001240
1241 let DecoderMethod = "DecodeT2LdStPre";
Jim Grosbachc086f682011-09-08 00:39:19 +00001242}
Jim Grosbachc4669ed2010-12-10 20:47:29 +00001243
Jim Grosbachc086f682011-09-08 00:39:19 +00001244// T2Ipostldst - Thumb2 post-indexed load / store instructions.
1245class T2Ipostldst<bit signed, bits<2> opcod, bit load, bit pre,
1246 dag oops, dag iops,
1247 AddrMode am, IndexMode im, InstrItinClass itin,
1248 string opc, string asm, string cstr, list<dag> pattern>
1249 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
1250 let OutOperandList = oops;
1251 let InOperandList = !con(iops, (ins pred:$p));
1252 let AsmString = !strconcat(opc, "${p}", asm);
1253 let Pattern = pattern;
1254 list<Predicate> Predicates = [IsThumb2];
1255 let DecoderNamespace = "Thumb2";
Jim Grosbachc4669ed2010-12-10 20:47:29 +00001256
Owen Andersone22c7322010-11-30 00:14:31 +00001257 bits<4> Rt;
1258 bits<4> Rn;
Jim Grosbach3343da52011-09-08 01:01:32 +00001259 bits<9> offset;
Jim Grosbachc086f682011-09-08 00:39:19 +00001260 let Inst{31-27} = 0b11111;
1261 let Inst{26-25} = 0b00;
1262 let Inst{24} = signed;
1263 let Inst{23} = 0;
1264 let Inst{22-21} = opcod;
1265 let Inst{20} = load;
1266 let Inst{19-16} = Rn;
Owen Andersone22c7322010-11-30 00:14:31 +00001267 let Inst{15-12} = Rt{3-0};
Jim Grosbachc086f682011-09-08 00:39:19 +00001268 let Inst{11} = 1;
1269 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1270 let Inst{10} = pre; // The P bit.
Jim Grosbach3343da52011-09-08 01:01:32 +00001271 let Inst{9} = offset{8}; // Sign bit
Jim Grosbachc086f682011-09-08 00:39:19 +00001272 let Inst{8} = 1; // The W bit.
Jim Grosbach3343da52011-09-08 01:01:32 +00001273 let Inst{7-0} = offset{7-0};
Owen Andersona9ebf6f2011-09-12 18:56:30 +00001274
1275 let DecoderMethod = "DecodeT2LdStPre";
Evan Cheng84c6cda2009-07-02 07:28:31 +00001276}
1277
David Goodwine5b969f2009-07-27 19:59:26 +00001278// Tv5Pat - Same as Pat<>, but requires V5T Thumb mode.
1279class Tv5Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001280 list<Predicate> Predicates = [IsThumb, IsThumb1Only, HasV5T];
David Goodwine5b969f2009-07-27 19:59:26 +00001281}
1282
1283// T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1284class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001285 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
David Goodwine5b969f2009-07-27 19:59:26 +00001286}
Evan Cheng84c6cda2009-07-02 07:28:31 +00001287
Bruno Cardoso Lopes168c9002011-05-03 17:29:22 +00001288// T2v6Pat - Same as Pat<>, but requires V6T2 Thumb2 mode.
1289class T2v6Pat<dag pattern, dag result> : Pat<pattern, result> {
1290 list<Predicate> Predicates = [IsThumb2, HasV6T2];
1291}
1292
Evan Chengeab9ca72009-06-27 02:26:13 +00001293// T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1294class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
Evan Cheng2c450d32009-07-02 06:38:40 +00001295 list<Predicate> Predicates = [IsThumb2];
Evan Cheng431cf562009-06-23 17:48:47 +00001296}
1297
Evan Chengee98fa92008-08-29 06:41:12 +00001298//===----------------------------------------------------------------------===//
1299
Evan Chengac2af2f2008-11-11 02:11:05 +00001300//===----------------------------------------------------------------------===//
1301// ARM VFP Instruction templates.
1302//
1303
David Goodwin81cdd212009-07-10 17:03:29 +00001304// Almost all VFP instructions are predicable.
Owen Anderson651b2302011-07-13 23:22:26 +00001305class VFPI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001306 IndexMode im, Format f, InstrItinClass itin,
1307 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001308 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Jim Grosbach576640f2010-10-12 21:22:40 +00001309 bits<4> p;
1310 let Inst{31-28} = p;
David Goodwin81cdd212009-07-10 17:03:29 +00001311 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001312 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001313 let AsmString = !strconcat(opc, "${p}", asm);
David Goodwin81cdd212009-07-10 17:03:29 +00001314 let Pattern = pattern;
Bill Wendling87240d42010-12-01 21:54:50 +00001315 let PostEncoderMethod = "VFPThumb2PostEncoder";
Owen Andersone0152a72011-08-09 20:55:18 +00001316 let DecoderNamespace = "VFP";
David Goodwin81cdd212009-07-10 17:03:29 +00001317 list<Predicate> Predicates = [HasVFP2];
1318}
1319
1320// Special cases
Owen Anderson651b2302011-07-13 23:22:26 +00001321class VFPXI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001322 IndexMode im, Format f, InstrItinClass itin,
1323 string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001324 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001325 bits<4> p;
1326 let Inst{31-28} = p;
David Goodwin81cdd212009-07-10 17:03:29 +00001327 let OutOperandList = oops;
1328 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001329 let AsmString = asm;
David Goodwin81cdd212009-07-10 17:03:29 +00001330 let Pattern = pattern;
Bill Wendling87240d42010-12-01 21:54:50 +00001331 let PostEncoderMethod = "VFPThumb2PostEncoder";
Owen Andersone0152a72011-08-09 20:55:18 +00001332 let DecoderNamespace = "VFP";
David Goodwin81cdd212009-07-10 17:03:29 +00001333 list<Predicate> Predicates = [HasVFP2];
1334}
1335
David Goodwinb062c232009-08-06 16:52:47 +00001336class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1337 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001338 : VFPI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
Bill Wendling87240d42010-12-01 21:54:50 +00001339 opc, asm, "", pattern> {
1340 let PostEncoderMethod = "VFPThumb2PostEncoder";
1341}
David Goodwin81cdd212009-07-10 17:03:29 +00001342
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001343// ARM VFP addrmode5 loads and stores
1344class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001345 InstrItinClass itin,
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001346 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001347 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001348 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendlingc0024632010-11-04 00:59:42 +00001349 // Instruction operands.
1350 bits<5> Dd;
1351 bits<13> addr;
1352
1353 // Encode instruction operands.
1354 let Inst{23} = addr{8}; // U (add = (U == '1'))
1355 let Inst{22} = Dd{4};
1356 let Inst{19-16} = addr{12-9}; // Rn
1357 let Inst{15-12} = Dd{3-0};
1358 let Inst{7-0} = addr{7-0}; // imm8
1359
Evan Chengac2af2f2008-11-11 02:11:05 +00001360 // TODO: Mark the instructions with the appropriate subtarget info.
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001361 let Inst{27-24} = opcod1;
1362 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001363 let Inst{11-9} = 0b101;
1364 let Inst{8} = 1; // Double precision
Anton Korobeynikov8cce1eb2009-11-02 00:11:06 +00001365
Evan Cheng4a8c43f2011-02-16 00:35:02 +00001366 // Loads & stores operate on both NEON and VFP pipelines.
Jakob Stoklund Olesenb93331f2010-04-05 03:10:20 +00001367 let D = VFPNeonDomain;
Evan Chengac2af2f2008-11-11 02:11:05 +00001368}
1369
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001370class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001371 InstrItinClass itin,
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001372 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001373 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001374 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendlingc0024632010-11-04 00:59:42 +00001375 // Instruction operands.
1376 bits<5> Sd;
1377 bits<13> addr;
1378
1379 // Encode instruction operands.
1380 let Inst{23} = addr{8}; // U (add = (U == '1'))
1381 let Inst{22} = Sd{0};
1382 let Inst{19-16} = addr{12-9}; // Rn
1383 let Inst{15-12} = Sd{4-1};
1384 let Inst{7-0} = addr{7-0}; // imm8
1385
Evan Chengac2af2f2008-11-11 02:11:05 +00001386 // TODO: Mark the instructions with the appropriate subtarget info.
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001387 let Inst{27-24} = opcod1;
1388 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001389 let Inst{11-9} = 0b101;
1390 let Inst{8} = 0; // Single precision
Evan Cheng4a8c43f2011-02-16 00:35:02 +00001391
1392 // Loads & stores operate on both NEON and VFP pipelines.
1393 let D = VFPNeonDomain;
Evan Chengac2af2f2008-11-11 02:11:05 +00001394}
1395
Bob Wilson6b853c32010-09-16 00:31:02 +00001396// VFP Load / store multiple pseudo instructions.
1397class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1398 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001399 : InstARM<AddrMode4, 4, IndexModeNone, Pseudo, VFPNeonDomain,
Bob Wilson6b853c32010-09-16 00:31:02 +00001400 cstr, itin> {
1401 let OutOperandList = oops;
1402 let InOperandList = !con(iops, (ins pred:$p));
1403 let Pattern = pattern;
1404 list<Predicate> Predicates = [HasVFP2];
1405}
1406
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001407// Load / store multiple
Jim Grosbachabcbe242010-09-08 00:25:50 +00001408class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson947f04b2010-03-13 01:08:20 +00001409 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001410 : VFPXI<oops, iops, AddrMode4, 4, im,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001411 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001412 // Instruction operands.
1413 bits<4> Rn;
1414 bits<13> regs;
1415
1416 // Encode instruction operands.
1417 let Inst{19-16} = Rn;
1418 let Inst{22} = regs{12};
1419 let Inst{15-12} = regs{11-8};
1420 let Inst{7-0} = regs{7-0};
1421
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001422 // TODO: Mark the instructions with the appropriate subtarget info.
1423 let Inst{27-25} = 0b110;
Bill Wendling98c29d72010-10-12 22:03:19 +00001424 let Inst{11-9} = 0b101;
1425 let Inst{8} = 1; // Double precision
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001426}
1427
Jim Grosbachabcbe242010-09-08 00:25:50 +00001428class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson947f04b2010-03-13 01:08:20 +00001429 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001430 : VFPXI<oops, iops, AddrMode4, 4, im,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001431 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001432 // Instruction operands.
1433 bits<4> Rn;
1434 bits<13> regs;
1435
1436 // Encode instruction operands.
1437 let Inst{19-16} = Rn;
1438 let Inst{22} = regs{8};
1439 let Inst{15-12} = regs{12-9};
1440 let Inst{7-0} = regs{7-0};
1441
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001442 // TODO: Mark the instructions with the appropriate subtarget info.
1443 let Inst{27-25} = 0b110;
Bill Wendling98c29d72010-10-12 22:03:19 +00001444 let Inst{11-9} = 0b101;
1445 let Inst{8} = 0; // Single precision
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001446}
1447
Evan Chengac2af2f2008-11-11 02:11:05 +00001448// Double precision, unary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001449class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1450 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1451 string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001452 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001453 // Instruction operands.
1454 bits<5> Dd;
1455 bits<5> Dm;
1456
1457 // Encode instruction operands.
1458 let Inst{3-0} = Dm{3-0};
1459 let Inst{5} = Dm{4};
1460 let Inst{15-12} = Dd{3-0};
1461 let Inst{22} = Dd{4};
1462
Johnny Chen34a6afc2010-01-29 23:21:10 +00001463 let Inst{27-23} = opcod1;
1464 let Inst{21-20} = opcod2;
1465 let Inst{19-16} = opcod3;
Bill Wendling98c29d72010-10-12 22:03:19 +00001466 let Inst{11-9} = 0b101;
1467 let Inst{8} = 1; // Double precision
Johnny Chen34a6afc2010-01-29 23:21:10 +00001468 let Inst{7-6} = opcod4;
1469 let Inst{4} = opcod5;
Evan Chengac2af2f2008-11-11 02:11:05 +00001470}
1471
1472// Double precision, binary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001473class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001474 dag iops, InstrItinClass itin, string opc, string asm,
1475 list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001476 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001477 // Instruction operands.
1478 bits<5> Dd;
1479 bits<5> Dn;
1480 bits<5> Dm;
1481
1482 // Encode instruction operands.
1483 let Inst{3-0} = Dm{3-0};
1484 let Inst{5} = Dm{4};
1485 let Inst{19-16} = Dn{3-0};
1486 let Inst{7} = Dn{4};
1487 let Inst{15-12} = Dd{3-0};
1488 let Inst{22} = Dd{4};
1489
Johnny Chen34a6afc2010-01-29 23:21:10 +00001490 let Inst{27-23} = opcod1;
1491 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001492 let Inst{11-9} = 0b101;
1493 let Inst{8} = 1; // Double precision
Bill Wendlingb70dc872010-08-31 07:50:46 +00001494 let Inst{6} = op6;
1495 let Inst{4} = op4;
Evan Chengac2af2f2008-11-11 02:11:05 +00001496}
1497
1498// Single precision, unary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001499class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1500 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1501 string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001502 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001503 // Instruction operands.
1504 bits<5> Sd;
1505 bits<5> Sm;
1506
1507 // Encode instruction operands.
1508 let Inst{3-0} = Sm{4-1};
1509 let Inst{5} = Sm{0};
1510 let Inst{15-12} = Sd{4-1};
1511 let Inst{22} = Sd{0};
1512
Johnny Chen34a6afc2010-01-29 23:21:10 +00001513 let Inst{27-23} = opcod1;
1514 let Inst{21-20} = opcod2;
1515 let Inst{19-16} = opcod3;
Bill Wendling98c29d72010-10-12 22:03:19 +00001516 let Inst{11-9} = 0b101;
1517 let Inst{8} = 0; // Single precision
Johnny Chen34a6afc2010-01-29 23:21:10 +00001518 let Inst{7-6} = opcod4;
1519 let Inst{4} = opcod5;
Evan Chengac2af2f2008-11-11 02:11:05 +00001520}
1521
Bill Wendlingcbb08ca2010-12-01 02:42:55 +00001522// Single precision unary, if no NEON. Same as ASuI except not available if
1523// NEON is enabled.
Johnny Chen34a6afc2010-01-29 23:21:10 +00001524class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1525 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1526 string asm, list<dag> pattern>
1527 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1528 pattern> {
David Goodwin30bf6252009-08-04 20:39:05 +00001529 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1530}
1531
Evan Chengac2af2f2008-11-11 02:11:05 +00001532// Single precision, binary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001533class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1534 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001535 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001536 // Instruction operands.
1537 bits<5> Sd;
1538 bits<5> Sn;
1539 bits<5> Sm;
1540
1541 // Encode instruction operands.
1542 let Inst{3-0} = Sm{4-1};
1543 let Inst{5} = Sm{0};
1544 let Inst{19-16} = Sn{4-1};
1545 let Inst{7} = Sn{0};
1546 let Inst{15-12} = Sd{4-1};
1547 let Inst{22} = Sd{0};
1548
Johnny Chen34a6afc2010-01-29 23:21:10 +00001549 let Inst{27-23} = opcod1;
1550 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001551 let Inst{11-9} = 0b101;
1552 let Inst{8} = 0; // Single precision
Bill Wendlingb70dc872010-08-31 07:50:46 +00001553 let Inst{6} = op6;
1554 let Inst{4} = op4;
Evan Chengac2af2f2008-11-11 02:11:05 +00001555}
1556
Bill Wendlingcbb08ca2010-12-01 02:42:55 +00001557// Single precision binary, if no NEON. Same as ASbI except not available if
1558// NEON is enabled.
Johnny Chen34a6afc2010-01-29 23:21:10 +00001559class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001560 dag iops, InstrItinClass itin, string opc, string asm,
1561 list<dag> pattern>
Johnny Chen34a6afc2010-01-29 23:21:10 +00001562 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
David Goodwin3b9c52c2009-08-04 17:53:06 +00001563 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
Bill Wendling26233432010-11-01 06:00:39 +00001564
1565 // Instruction operands.
1566 bits<5> Sd;
1567 bits<5> Sn;
1568 bits<5> Sm;
1569
1570 // Encode instruction operands.
1571 let Inst{3-0} = Sm{4-1};
1572 let Inst{5} = Sm{0};
1573 let Inst{19-16} = Sn{4-1};
1574 let Inst{7} = Sn{0};
1575 let Inst{15-12} = Sd{4-1};
1576 let Inst{22} = Sd{0};
David Goodwin3b9c52c2009-08-04 17:53:06 +00001577}
1578
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001579// VFP conversion instructions
Johnny Chen34a6afc2010-01-29 23:21:10 +00001580class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1581 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1582 list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001583 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
Johnny Chen34a6afc2010-01-29 23:21:10 +00001584 let Inst{27-23} = opcod1;
1585 let Inst{21-20} = opcod2;
1586 let Inst{19-16} = opcod3;
1587 let Inst{11-8} = opcod4;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001588 let Inst{6} = 1;
Johnny Chen34a6afc2010-01-29 23:21:10 +00001589 let Inst{4} = 0;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001590}
1591
Johnny Chen39640592010-02-11 18:47:03 +00001592// VFP conversion between floating-point and fixed-point
1593class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001594 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1595 list<dag> pattern>
Johnny Chen39640592010-02-11 18:47:03 +00001596 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
Jim Grosbachf0d25112011-12-22 19:55:21 +00001597 bits<5> fbits;
Johnny Chen39640592010-02-11 18:47:03 +00001598 // size (fixed-point number): sx == 0 ? 16 : 32
1599 let Inst{7} = op5; // sx
Jim Grosbachf0d25112011-12-22 19:55:21 +00001600 let Inst{5} = fbits{0};
1601 let Inst{3-0} = fbits{4-1};
Johnny Chen39640592010-02-11 18:47:03 +00001602}
1603
David Goodwin85b5b022009-08-10 22:17:39 +00001604// VFP conversion instructions, if no NEON
Johnny Chen34a6afc2010-01-29 23:21:10 +00001605class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
David Goodwin85b5b022009-08-10 22:17:39 +00001606 dag oops, dag iops, InstrItinClass itin,
1607 string opc, string asm, list<dag> pattern>
Johnny Chen34a6afc2010-01-29 23:21:10 +00001608 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
1609 pattern> {
David Goodwin85b5b022009-08-10 22:17:39 +00001610 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1611}
1612
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001613class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
David Goodwinb062c232009-08-06 16:52:47 +00001614 InstrItinClass itin,
1615 string opc, string asm, list<dag> pattern>
1616 : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001617 let Inst{27-20} = opcod1;
Evan Cheng38c9a142008-11-11 19:40:26 +00001618 let Inst{11-8} = opcod2;
1619 let Inst{4} = 1;
1620}
1621
David Goodwinb062c232009-08-06 16:52:47 +00001622class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1623 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1624 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
Evan Cheng97ccab82008-11-11 22:46:12 +00001625
Bob Wilson3968c6a2010-03-23 17:23:59 +00001626class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001627 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1628 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001629
David Goodwinb062c232009-08-06 16:52:47 +00001630class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1631 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1632 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001633
David Goodwinb062c232009-08-06 16:52:47 +00001634class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1635 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1636 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
Evan Cheng38c9a142008-11-11 19:40:26 +00001637
Evan Chengac2af2f2008-11-11 02:11:05 +00001638//===----------------------------------------------------------------------===//
1639
Bob Wilson2e076c42009-06-22 23:27:02 +00001640//===----------------------------------------------------------------------===//
1641// ARM NEON Instruction templates.
1642//
Evan Chengee98fa92008-08-29 06:41:12 +00001643
Johnny Chenf833fad2010-03-20 00:17:00 +00001644class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1645 InstrItinClass itin, string opc, string dt, string asm, string cstr,
1646 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001647 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
Evan Cheng738a97a2009-11-23 21:57:23 +00001648 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001649 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001650 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Cheng738a97a2009-11-23 21:57:23 +00001651 let Pattern = pattern;
1652 list<Predicate> Predicates = [HasNEON];
Owen Andersona6201f02011-08-15 23:38:54 +00001653 let DecoderNamespace = "NEON";
Evan Cheng738a97a2009-11-23 21:57:23 +00001654}
1655
1656// Same as NeonI except it does not have a "data type" specifier.
Johnny Chen020023a2010-03-23 20:40:44 +00001657class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1658 InstrItinClass itin, string opc, string asm, string cstr,
1659 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001660 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
Bob Wilson2e076c42009-06-22 23:27:02 +00001661 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001662 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001663 let AsmString = !strconcat(opc, "${p}", "\t", asm);
Bob Wilson2e076c42009-06-22 23:27:02 +00001664 let Pattern = pattern;
1665 list<Predicate> Predicates = [HasNEON];
Owen Andersona6201f02011-08-15 23:38:54 +00001666 let DecoderNamespace = "NEON";
Evan Chengee98fa92008-08-29 06:41:12 +00001667}
1668
Bob Wilson50820a22009-10-07 21:53:04 +00001669class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1670 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001671 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenf833fad2010-03-20 00:17:00 +00001672 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
1673 cstr, pattern> {
Bob Wilsonf731a2d2009-07-08 18:11:30 +00001674 let Inst{31-24} = 0b11110100;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001675 let Inst{23} = op23;
Jim Grosbach68f495c2009-10-20 00:19:08 +00001676 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001677 let Inst{11-8} = op11_8;
1678 let Inst{7-4} = op7_4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001679
Chris Lattner63274cb2010-11-15 05:19:05 +00001680 let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
Owen Andersonc86a5bd2011-08-10 19:01:10 +00001681 let DecoderNamespace = "NEONLoadStore";
Jim Grosbach5876e412010-11-19 22:42:55 +00001682
Owen Andersonad402342010-11-02 00:05:05 +00001683 bits<5> Vd;
Owen Anderson0ebd1fd2010-11-02 23:47:29 +00001684 bits<6> Rn;
1685 bits<4> Rm;
Jim Grosbach5876e412010-11-19 22:42:55 +00001686
Owen Andersonad402342010-11-02 00:05:05 +00001687 let Inst{22} = Vd{4};
1688 let Inst{15-12} = Vd{3-0};
Owen Anderson0ebd1fd2010-11-02 23:47:29 +00001689 let Inst{19-16} = Rn{3-0};
1690 let Inst{3-0} = Rm{3-0};
Bob Wilsonf731a2d2009-07-08 18:11:30 +00001691}
1692
Owen Anderson9f20daf2010-11-02 20:47:39 +00001693class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1694 dag oops, dag iops, InstrItinClass itin,
1695 string opc, string dt, string asm, string cstr, list<dag> pattern>
1696 : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc,
1697 dt, asm, cstr, pattern> {
1698 bits<3> lane;
1699}
1700
Bob Wilson9392b0e2010-08-25 23:27:42 +00001701class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
Owen Anderson651b2302011-07-13 23:22:26 +00001702 : InstARM<AddrMode6, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
Bob Wilson9392b0e2010-08-25 23:27:42 +00001703 itin> {
1704 let OutOperandList = oops;
1705 let InOperandList = !con(iops, (ins pred:$p));
1706 list<Predicate> Predicates = [HasNEON];
1707}
1708
Jim Grosbach233b3a22010-10-06 20:36:55 +00001709class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
1710 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001711 : InstARM<AddrModeNone, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
Bob Wilsonc597fd3b2010-09-13 23:55:10 +00001712 itin> {
1713 let OutOperandList = oops;
1714 let InOperandList = !con(iops, (ins pred:$p));
Jim Grosbach233b3a22010-10-06 20:36:55 +00001715 let Pattern = pattern;
Bob Wilsonc597fd3b2010-09-13 23:55:10 +00001716 list<Predicate> Predicates = [HasNEON];
1717}
1718
Johnny Chenac5024b2010-03-23 16:43:47 +00001719class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001720 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenac5024b2010-03-23 16:43:47 +00001721 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
1722 pattern> {
Evan Cheng738a97a2009-11-23 21:57:23 +00001723 let Inst{31-25} = 0b1111001;
Chris Lattner63274cb2010-11-15 05:19:05 +00001724 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Owen Andersona6201f02011-08-15 23:38:54 +00001725 let DecoderNamespace = "NEONData";
Evan Cheng738a97a2009-11-23 21:57:23 +00001726}
1727
Johnny Chen020023a2010-03-23 20:40:44 +00001728class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001729 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chen020023a2010-03-23 20:40:44 +00001730 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001731 cstr, pattern> {
Bob Wilson2e076c42009-06-22 23:27:02 +00001732 let Inst{31-25} = 0b1111001;
Owen Andersonb538a222010-12-10 22:32:08 +00001733 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Owen Andersona6201f02011-08-15 23:38:54 +00001734 let DecoderNamespace = "NEONData";
Bob Wilson2e076c42009-06-22 23:27:02 +00001735}
1736
1737// NEON "one register and a modified immediate" format.
1738class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
1739 bit op5, bit op4,
David Goodwinb062c232009-08-06 16:52:47 +00001740 dag oops, dag iops, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001741 string opc, string dt, string asm, string cstr,
1742 list<dag> pattern>
Johnny Chen6a643202010-03-23 23:09:14 +00001743 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00001744 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00001745 let Inst{21-19} = op21_19;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001746 let Inst{11-8} = op11_8;
1747 let Inst{7} = op7;
1748 let Inst{6} = op6;
1749 let Inst{5} = op5;
1750 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001751
Owen Anderson284cb362010-10-26 17:40:54 +00001752 // Instruction operands.
1753 bits<5> Vd;
1754 bits<13> SIMM;
Jim Grosbach5876e412010-11-19 22:42:55 +00001755
Owen Anderson284cb362010-10-26 17:40:54 +00001756 let Inst{15-12} = Vd{3-0};
1757 let Inst{22} = Vd{4};
1758 let Inst{24} = SIMM{7};
1759 let Inst{18-16} = SIMM{6-4};
1760 let Inst{3-0} = SIMM{3-0};
Owen Andersone0152a72011-08-09 20:55:18 +00001761 let DecoderMethod = "DecodeNEONModImmInstruction";
Bob Wilson2e076c42009-06-22 23:27:02 +00001762}
1763
1764// NEON 2 vector register format.
1765class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
1766 bits<5> op11_7, bit op6, bit op4,
David Goodwinb062c232009-08-06 16:52:47 +00001767 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001768 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chen9b1f60a2010-03-24 00:57:50 +00001769 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
Evan Cheng738a97a2009-11-23 21:57:23 +00001770 let Inst{24-23} = op24_23;
1771 let Inst{21-20} = op21_20;
1772 let Inst{19-18} = op19_18;
1773 let Inst{17-16} = op17_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001774 let Inst{11-7} = op11_7;
1775 let Inst{6} = op6;
1776 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001777
Owen Anderson24774462010-10-25 18:43:52 +00001778 // Instruction operands.
1779 bits<5> Vd;
1780 bits<5> Vm;
1781
1782 let Inst{15-12} = Vd{3-0};
1783 let Inst{22} = Vd{4};
1784 let Inst{3-0} = Vm{3-0};
1785 let Inst{5} = Vm{4};
Evan Cheng738a97a2009-11-23 21:57:23 +00001786}
1787
1788// Same as N2V except it doesn't have a datatype suffix.
1789class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001790 bits<5> op11_7, bit op6, bit op4,
1791 dag oops, dag iops, InstrItinClass itin,
1792 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chen9b1f60a2010-03-24 00:57:50 +00001793 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
Bob Wilson2e076c42009-06-22 23:27:02 +00001794 let Inst{24-23} = op24_23;
1795 let Inst{21-20} = op21_20;
1796 let Inst{19-18} = op19_18;
1797 let Inst{17-16} = op17_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001798 let Inst{11-7} = op11_7;
1799 let Inst{6} = op6;
1800 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001801
Owen Anderson24774462010-10-25 18:43:52 +00001802 // Instruction operands.
1803 bits<5> Vd;
1804 bits<5> Vm;
1805
1806 let Inst{15-12} = Vd{3-0};
1807 let Inst{22} = Vd{4};
1808 let Inst{3-0} = Vm{3-0};
1809 let Inst{5} = Vm{4};
Bob Wilson2e076c42009-06-22 23:27:02 +00001810}
1811
1812// NEON 2 vector register with immediate.
Bob Wilsonbd3650c2009-10-21 02:15:46 +00001813class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
Johnny Chend82f9002010-03-25 20:39:04 +00001814 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001815 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chend82f9002010-03-25 20:39:04 +00001816 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00001817 let Inst{24} = op24;
1818 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00001819 let Inst{11-8} = op11_8;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001820 let Inst{7} = op7;
1821 let Inst{6} = op6;
1822 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001823
Owen Anderson3665fee2010-10-26 20:56:57 +00001824 // Instruction operands.
1825 bits<5> Vd;
1826 bits<5> Vm;
1827 bits<6> SIMM;
1828
1829 let Inst{15-12} = Vd{3-0};
1830 let Inst{22} = Vd{4};
1831 let Inst{3-0} = Vm{3-0};
1832 let Inst{5} = Vm{4};
1833 let Inst{21-16} = SIMM{5-0};
Bob Wilson2e076c42009-06-22 23:27:02 +00001834}
1835
Bob Wilsoncf603fb2010-03-27 03:56:52 +00001836// NEON 3 vector register format.
Owen Andersonabda3ca2011-03-30 23:45:29 +00001837
Jim Grosbacheca54e42011-05-19 17:34:53 +00001838class N3VCommon<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1839 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
1840 string opc, string dt, string asm, string cstr,
1841 list<dag> pattern>
Johnny Chen2cf04952010-03-26 21:26:28 +00001842 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00001843 let Inst{24} = op24;
1844 let Inst{23} = op23;
Evan Cheng738a97a2009-11-23 21:57:23 +00001845 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001846 let Inst{11-8} = op11_8;
1847 let Inst{6} = op6;
1848 let Inst{4} = op4;
Owen Andersonabda3ca2011-03-30 23:45:29 +00001849}
1850
1851class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
1852 dag oops, dag iops, Format f, InstrItinClass itin,
1853 string opc, string dt, string asm, string cstr, list<dag> pattern>
1854 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
1855 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Jim Grosbach5876e412010-11-19 22:42:55 +00001856
Owen Anderson9e44cf22010-10-21 20:21:49 +00001857 // Instruction operands.
1858 bits<5> Vd;
1859 bits<5> Vn;
1860 bits<5> Vm;
1861
1862 let Inst{15-12} = Vd{3-0};
1863 let Inst{22} = Vd{4};
1864 let Inst{19-16} = Vn{3-0};
1865 let Inst{7} = Vn{4};
1866 let Inst{3-0} = Vm{3-0};
1867 let Inst{5} = Vm{4};
Evan Cheng738a97a2009-11-23 21:57:23 +00001868}
1869
Jim Grosbacheca54e42011-05-19 17:34:53 +00001870class N3VLane32<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1871 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
1872 string opc, string dt, string asm, string cstr,
1873 list<dag> pattern>
Owen Andersonabda3ca2011-03-30 23:45:29 +00001874 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
1875 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1876
1877 // Instruction operands.
1878 bits<5> Vd;
1879 bits<5> Vn;
1880 bits<5> Vm;
1881 bit lane;
1882
1883 let Inst{15-12} = Vd{3-0};
1884 let Inst{22} = Vd{4};
1885 let Inst{19-16} = Vn{3-0};
1886 let Inst{7} = Vn{4};
1887 let Inst{3-0} = Vm{3-0};
1888 let Inst{5} = lane;
1889}
1890
Jim Grosbacheca54e42011-05-19 17:34:53 +00001891class N3VLane16<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1892 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
1893 string opc, string dt, string asm, string cstr,
1894 list<dag> pattern>
Owen Andersonabda3ca2011-03-30 23:45:29 +00001895 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
1896 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1897
1898 // Instruction operands.
1899 bits<5> Vd;
1900 bits<5> Vn;
1901 bits<5> Vm;
1902 bits<2> lane;
1903
1904 let Inst{15-12} = Vd{3-0};
1905 let Inst{22} = Vd{4};
1906 let Inst{19-16} = Vn{3-0};
1907 let Inst{7} = Vn{4};
1908 let Inst{2-0} = Vm{2-0};
1909 let Inst{5} = lane{1};
1910 let Inst{3} = lane{0};
1911}
1912
Johnny Chen8a687232010-03-23 21:35:03 +00001913// Same as N3V except it doesn't have a data type suffix.
Bob Wilson3968c6a2010-03-23 17:23:59 +00001914class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1915 bit op4,
Bob Wilsoncf603fb2010-03-27 03:56:52 +00001916 dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001917 string opc, string asm, string cstr, list<dag> pattern>
Bob Wilsoncf603fb2010-03-27 03:56:52 +00001918 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00001919 let Inst{24} = op24;
1920 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00001921 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001922 let Inst{11-8} = op11_8;
1923 let Inst{6} = op6;
1924 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001925
Owen Andersondff239c2010-10-25 18:28:30 +00001926 // Instruction operands.
1927 bits<5> Vd;
1928 bits<5> Vn;
1929 bits<5> Vm;
1930
1931 let Inst{15-12} = Vd{3-0};
1932 let Inst{22} = Vd{4};
1933 let Inst{19-16} = Vn{3-0};
1934 let Inst{7} = Vn{4};
1935 let Inst{3-0} = Vm{3-0};
1936 let Inst{5} = Vm{4};
Bob Wilson2e076c42009-06-22 23:27:02 +00001937}
1938
1939// NEON VMOVs between scalar and core registers.
1940class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00001941 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001942 string opc, string dt, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001943 : InstARM<AddrModeNone, 4, IndexModeNone, f, NeonDomain,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001944 "", itin> {
Bob Wilson2e076c42009-06-22 23:27:02 +00001945 let Inst{27-20} = opcod1;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001946 let Inst{11-8} = opcod2;
1947 let Inst{6-5} = opcod3;
1948 let Inst{4} = 1;
Johnny Chen8bca1742011-04-06 18:27:46 +00001949 // A8.6.303, A8.6.328, A8.6.329
1950 let Inst{3-0} = 0b0000;
Evan Cheng738a97a2009-11-23 21:57:23 +00001951
1952 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001953 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001954 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Cheng738a97a2009-11-23 21:57:23 +00001955 let Pattern = pattern;
Bob Wilson2e076c42009-06-22 23:27:02 +00001956 list<Predicate> Predicates = [HasNEON];
Jim Grosbach5876e412010-11-19 22:42:55 +00001957
Chris Lattner63274cb2010-11-15 05:19:05 +00001958 let PostEncoderMethod = "NEONThumb2DupPostEncoder";
Owen Andersonc86a5bd2011-08-10 19:01:10 +00001959 let DecoderNamespace = "NEONDup";
Jim Grosbach5876e412010-11-19 22:42:55 +00001960
Owen Andersoned9652f2010-10-27 21:28:09 +00001961 bits<5> V;
1962 bits<4> R;
Owen Anderson40d24a42010-10-27 19:25:54 +00001963 bits<4> p;
Owen Andersoned9652f2010-10-27 21:28:09 +00001964 bits<4> lane;
Jim Grosbach5876e412010-11-19 22:42:55 +00001965
Owen Anderson40d24a42010-10-27 19:25:54 +00001966 let Inst{31-28} = p{3-0};
Owen Andersoned9652f2010-10-27 21:28:09 +00001967 let Inst{7} = V{4};
1968 let Inst{19-16} = V{3-0};
1969 let Inst{15-12} = R{3-0};
Bob Wilson2e076c42009-06-22 23:27:02 +00001970}
1971class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00001972 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001973 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00001974 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001975 opc, dt, asm, pattern>;
Bob Wilson2e076c42009-06-22 23:27:02 +00001976class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00001977 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001978 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00001979 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001980 opc, dt, asm, pattern>;
Bob Wilson2e076c42009-06-22 23:27:02 +00001981class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00001982 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001983 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00001984 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001985 opc, dt, asm, pattern>;
David Goodwin3b9c52c2009-08-04 17:53:06 +00001986
Johnny Chen45ab3f32010-03-25 17:01:27 +00001987// Vector Duplicate Lane (from scalar to all elements)
1988class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
1989 InstrItinClass itin, string opc, string dt, string asm,
1990 list<dag> pattern>
Johnny Chen91d27742010-03-25 21:49:12 +00001991 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
Johnny Chen45ab3f32010-03-25 17:01:27 +00001992 let Inst{24-23} = 0b11;
1993 let Inst{21-20} = 0b11;
1994 let Inst{19-16} = op19_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001995 let Inst{11-7} = 0b11000;
1996 let Inst{6} = op6;
1997 let Inst{4} = 0;
Jim Grosbach5876e412010-11-19 22:42:55 +00001998
Owen Anderson40d24a42010-10-27 19:25:54 +00001999 bits<5> Vd;
2000 bits<5> Vm;
Jim Grosbach5876e412010-11-19 22:42:55 +00002001
Owen Anderson40d24a42010-10-27 19:25:54 +00002002 let Inst{22} = Vd{4};
2003 let Inst{15-12} = Vd{3-0};
2004 let Inst{5} = Vm{4};
2005 let Inst{3-0} = Vm{3-0};
Johnny Chen45ab3f32010-03-25 17:01:27 +00002006}
2007
David Goodwin3b9c52c2009-08-04 17:53:06 +00002008// NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
2009// for single-precision FP.
2010class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
2011 list<Predicate> Predicates = [HasNEON,UseNEONForFP];
2012}
Jim Grosbach7996b152011-11-14 22:28:39 +00002013
2014// VFP/NEON Instruction aliases for type suffices.
2015class VFPDataTypeInstAlias<string opc, string dt, string asm, dag Result> :
Jim Grosbachfdf9e152011-12-05 20:29:59 +00002016 InstAlias<!strconcat(opc, dt, "\t", asm), Result>, Requires<[HasVFP2]>;
Jim Grosbach2cf294a2011-12-07 01:50:36 +00002017
Jim Grosbach3d6c0e02011-11-14 23:11:19 +00002018multiclass VFPDTAnyInstAlias<string opc, string asm, dag Result> {
Jim Grosbach2cf294a2011-12-07 01:50:36 +00002019 def : VFPDataTypeInstAlias<opc, ".8", asm, Result>;
2020 def : VFPDataTypeInstAlias<opc, ".16", asm, Result>;
2021 def : VFPDataTypeInstAlias<opc, ".32", asm, Result>;
2022 def : VFPDataTypeInstAlias<opc, ".64", asm, Result>;
Jim Grosbache7dcbc82011-12-02 18:52:30 +00002023}
2024
Jim Grosbach681db342012-01-24 17:23:29 +00002025multiclass NEONDTAnyInstAlias<string opc, string asm, dag Result> {
2026 let Predicates = [HasNEON] in {
2027 def : VFPDataTypeInstAlias<opc, ".8", asm, Result>;
2028 def : VFPDataTypeInstAlias<opc, ".16", asm, Result>;
2029 def : VFPDataTypeInstAlias<opc, ".32", asm, Result>;
2030 def : VFPDataTypeInstAlias<opc, ".64", asm, Result>;
2031}
2032}
2033
Jim Grosbache7dcbc82011-12-02 18:52:30 +00002034// The same alias classes using AsmPseudo instead, for the more complex
2035// stuff in NEON that InstAlias can't quite handle.
2036// Note that we can't use anonymous defm references here like we can
2037// above, as we care about the ultimate instruction enum names generated, unlike
2038// for instalias defs.
2039class NEONDataTypeAsmPseudoInst<string opc, string dt, string asm, dag iops> :
Jim Grosbachdda976b2011-12-02 22:01:52 +00002040 AsmPseudoInst<!strconcat(opc, dt, "\t", asm), iops>, Requires<[HasNEON]>;
Jim Grosbach585ce302011-12-07 01:17:58 +00002041
2042// Data type suffix token aliases. Implements Table A7-3 in the ARM ARM.
2043def : TokenAlias<".s8", ".i8">;
2044def : TokenAlias<".u8", ".i8">;
2045def : TokenAlias<".s16", ".i16">;
2046def : TokenAlias<".u16", ".i16">;
2047def : TokenAlias<".s32", ".i32">;
2048def : TokenAlias<".u32", ".i32">;
Jim Grosbach2cf294a2011-12-07 01:50:36 +00002049def : TokenAlias<".s64", ".i64">;
2050def : TokenAlias<".u64", ".i64">;
Jim Grosbach585ce302011-12-07 01:17:58 +00002051
2052def : TokenAlias<".i8", ".8">;
2053def : TokenAlias<".i16", ".16">;
2054def : TokenAlias<".i32", ".32">;
Jim Grosbach2cf294a2011-12-07 01:50:36 +00002055def : TokenAlias<".i64", ".64">;
Jim Grosbach585ce302011-12-07 01:17:58 +00002056
2057def : TokenAlias<".p8", ".8">;
2058def : TokenAlias<".p16", ".16">;
2059
2060def : TokenAlias<".f32", ".32">;
2061def : TokenAlias<".f64", ".64">;
2062def : TokenAlias<".f", ".f32">;
2063def : TokenAlias<".d", ".f64">;