blob: b51887d41aaa397c85b1fa1dec8ebce720bcf9f9 [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 Grosbach0a547702011-07-22 17:44:50 +0000177def SetEndAsmOperand : AsmOperandClass {
178 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>
204def shr_imm8 : Operand<i32> {
205 let EncoderMethod = "getShiftRight8Imm";
Owen Andersone0152a72011-08-09 20:55:18 +0000206 let DecoderMethod = "DecodeShiftRight8Imm";
Bill Wendling3b1459b2011-03-01 01:00:59 +0000207}
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000208def shr_imm16 : Operand<i32> {
209 let EncoderMethod = "getShiftRight16Imm";
Owen Andersone0152a72011-08-09 20:55:18 +0000210 let DecoderMethod = "DecodeShiftRight16Imm";
Bill Wendling3b1459b2011-03-01 01:00:59 +0000211}
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000212def shr_imm32 : Operand<i32> {
213 let EncoderMethod = "getShiftRight32Imm";
Owen Andersone0152a72011-08-09 20:55:18 +0000214 let DecoderMethod = "DecodeShiftRight32Imm";
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000215}
216def shr_imm64 : Operand<i32> {
217 let EncoderMethod = "getShiftRight64Imm";
Owen Andersone0152a72011-08-09 20:55:18 +0000218 let DecoderMethod = "DecodeShiftRight64Imm";
Bill Wendling3b1459b2011-03-01 01:00:59 +0000219}
220
Evan Chengcd4cdd12009-07-11 06:43:01 +0000221//===----------------------------------------------------------------------===//
Jim Grosbach6caa5572011-08-22 18:04:24 +0000222// ARM Assembler alias templates.
223//
224class ARMInstAlias<string Asm, dag Result, bit Emit = 0b1>
225 : InstAlias<Asm, Result, Emit>, Requires<[IsARM]>;
226class tInstAlias<string Asm, dag Result, bit Emit = 0b1>
227 : InstAlias<Asm, Result, Emit>, Requires<[IsThumb]>;
228class t2InstAlias<string Asm, dag Result, bit Emit = 0b1>
229 : InstAlias<Asm, Result, Emit>, Requires<[IsThumb2]>;
230
231//===----------------------------------------------------------------------===//
Evan Cheng2d37f192008-08-28 23:39:26 +0000232// ARM Instruction templates.
233//
234
Jim Grosbach6caa5572011-08-22 18:04:24 +0000235
Owen Anderson651b2302011-07-13 23:22:26 +0000236class InstTemplate<AddrMode am, int sz, IndexMode im,
Johnny Chenc28e6292009-12-15 17:24:14 +0000237 Format f, Domain d, string cstr, InstrItinClass itin>
Evan Cheng2d37f192008-08-28 23:39:26 +0000238 : Instruction {
239 let Namespace = "ARM";
240
Evan Cheng2d37f192008-08-28 23:39:26 +0000241 AddrMode AM = am;
Owen Anderson651b2302011-07-13 23:22:26 +0000242 int Size = sz;
Evan Cheng2d37f192008-08-28 23:39:26 +0000243 IndexMode IM = im;
244 bits<2> IndexModeBits = IM.Value;
Evan Cheng2d37f192008-08-28 23:39:26 +0000245 Format F = f;
Bob Wilson69ba1bc2010-03-17 21:13:43 +0000246 bits<6> Form = F.Value;
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000247 Domain D = d;
Evan Cheng81889d012008-11-05 18:35:52 +0000248 bit isUnaryDataProc = 0;
Evan Cheng14965762009-07-08 01:46:35 +0000249 bit canXformTo16Bit = 0;
Jim Grosbach3e941ae2011-08-16 20:45:50 +0000250 // The instruction is a 16-bit flag setting Thumb instruction. Used
251 // by the parser to determine whether to require the 'S' suffix on the
252 // mnemonic (when not in an IT block) or preclude it (when in an IT block).
253 bit thumbArithFlagSetting = 0;
Jim Grosbach5876e412010-11-19 22:42:55 +0000254
Chris Lattner7ff33462010-10-31 19:22:57 +0000255 // If this is a pseudo instruction, mark it isCodeGenOnly.
256 let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
Bob Wilson3968c6a2010-03-23 17:23:59 +0000257
Jim Grosbach30694dc2011-08-15 16:52:24 +0000258 // The layout of TSFlags should be kept in sync with ARMBaseInfo.h.
Jim Grosbache9298992010-10-05 18:14:55 +0000259 let TSFlags{4-0} = AM.Value;
Owen Anderson651b2302011-07-13 23:22:26 +0000260 let TSFlags{6-5} = IndexModeBits;
261 let TSFlags{12-7} = Form;
262 let TSFlags{13} = isUnaryDataProc;
263 let TSFlags{14} = canXformTo16Bit;
264 let TSFlags{17-15} = D.Value;
Jim Grosbach3e941ae2011-08-16 20:45:50 +0000265 let TSFlags{18} = thumbArithFlagSetting;
Jakob Stoklund Olesenb93331f2010-04-05 03:10:20 +0000266
Evan Cheng2d37f192008-08-28 23:39:26 +0000267 let Constraints = cstr;
David Goodwinb062c232009-08-06 16:52:47 +0000268 let Itinerary = itin;
Evan Cheng2d37f192008-08-28 23:39:26 +0000269}
270
Johnny Chenc28e6292009-12-15 17:24:14 +0000271class Encoding {
272 field bits<32> Inst;
273}
274
Owen Anderson651b2302011-07-13 23:22:26 +0000275class InstARM<AddrMode am, int sz, IndexMode im,
Johnny Chenc28e6292009-12-15 17:24:14 +0000276 Format f, Domain d, string cstr, InstrItinClass itin>
Owen Andersonc78e03c2011-07-19 21:06:00 +0000277 : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding {
278 let DecoderNamespace = "ARM";
279}
Johnny Chenc28e6292009-12-15 17:24:14 +0000280
281// This Encoding-less class is used by Thumb1 to specify the encoding bits later
282// on by adding flavors to specific instructions.
Owen Anderson651b2302011-07-13 23:22:26 +0000283class InstThumb<AddrMode am, int sz, IndexMode im,
Johnny Chenc28e6292009-12-15 17:24:14 +0000284 Format f, Domain d, string cstr, InstrItinClass itin>
Owen Andersonc78e03c2011-07-19 21:06:00 +0000285 : InstTemplate<am, sz, im, f, d, cstr, itin> {
286 let DecoderNamespace = "Thumb";
287}
Johnny Chenc28e6292009-12-15 17:24:14 +0000288
Jim Grosbacha74c7ccd2010-11-18 01:38:26 +0000289class PseudoInst<dag oops, dag iops, InstrItinClass itin, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000290 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo,
Jim Grosbach7c301ea2011-07-06 21:35:46 +0000291 GenericDomain, "", itin> {
Evan Cheng2d37f192008-08-28 23:39:26 +0000292 let OutOperandList = oops;
293 let InOperandList = iops;
Evan Cheng2d37f192008-08-28 23:39:26 +0000294 let Pattern = pattern;
Jim Grosbache1756822011-03-10 19:06:39 +0000295 let isCodeGenOnly = 1;
Jim Grosbach7c301ea2011-07-06 21:35:46 +0000296 let isPseudo = 1;
Evan Cheng2d37f192008-08-28 23:39:26 +0000297}
298
Jim Grosbachcfb66202010-11-18 01:15:56 +0000299// PseudoInst that's ARM-mode only.
Owen Anderson651b2302011-07-13 23:22:26 +0000300class ARMPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
Jim Grosbacha74c7ccd2010-11-18 01:38:26 +0000301 list<dag> pattern>
302 : PseudoInst<oops, iops, itin, pattern> {
Owen Anderson651b2302011-07-13 23:22:26 +0000303 let Size = sz;
Jim Grosbachcfb66202010-11-18 01:15:56 +0000304 list<Predicate> Predicates = [IsARM];
305}
306
Jim Grosbach58bc36a2010-11-29 19:32:47 +0000307// PseudoInst that's Thumb-mode only.
Owen Anderson651b2302011-07-13 23:22:26 +0000308class tPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
Jim Grosbach58bc36a2010-11-29 19:32:47 +0000309 list<dag> pattern>
310 : PseudoInst<oops, iops, itin, pattern> {
Owen Anderson651b2302011-07-13 23:22:26 +0000311 let Size = sz;
Jim Grosbach58bc36a2010-11-29 19:32:47 +0000312 list<Predicate> Predicates = [IsThumb];
313}
Jim Grosbachcfb66202010-11-18 01:15:56 +0000314
Jim Grosbachd42257c2010-12-15 18:48:45 +0000315// PseudoInst that's Thumb2-mode only.
Owen Anderson651b2302011-07-13 23:22:26 +0000316class t2PseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
Jim Grosbachd42257c2010-12-15 18:48:45 +0000317 list<dag> pattern>
318 : PseudoInst<oops, iops, itin, pattern> {
Owen Anderson651b2302011-07-13 23:22:26 +0000319 let Size = sz;
Jim Grosbachd42257c2010-12-15 18:48:45 +0000320 list<Predicate> Predicates = [IsThumb2];
321}
Jim Grosbach95dee402011-07-08 17:40:42 +0000322
Owen Anderson651b2302011-07-13 23:22:26 +0000323class ARMPseudoExpand<dag oops, dag iops, int sz,
Jim Grosbach95dee402011-07-08 17:40:42 +0000324 InstrItinClass itin, list<dag> pattern,
325 dag Result>
326 : ARMPseudoInst<oops, iops, sz, itin, pattern>,
327 PseudoInstExpansion<Result>;
328
Owen Anderson651b2302011-07-13 23:22:26 +0000329class tPseudoExpand<dag oops, dag iops, int sz,
Jim Grosbach95dee402011-07-08 17:40:42 +0000330 InstrItinClass itin, list<dag> pattern,
331 dag Result>
332 : tPseudoInst<oops, iops, sz, itin, pattern>,
333 PseudoInstExpansion<Result>;
334
Owen Anderson651b2302011-07-13 23:22:26 +0000335class t2PseudoExpand<dag oops, dag iops, int sz,
Jim Grosbach95dee402011-07-08 17:40:42 +0000336 InstrItinClass itin, list<dag> pattern,
337 dag Result>
338 : t2PseudoInst<oops, iops, sz, itin, pattern>,
339 PseudoInstExpansion<Result>;
340
Evan Cheng2d37f192008-08-28 23:39:26 +0000341// Almost all ARM instructions are predicable.
Owen Anderson651b2302011-07-13 23:22:26 +0000342class I<dag oops, dag iops, AddrMode am, int sz,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000343 IndexMode im, Format f, InstrItinClass itin,
David Goodwinb062c232009-08-06 16:52:47 +0000344 string opc, string asm, string cstr,
Evan Cheng2d37f192008-08-28 23:39:26 +0000345 list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000346 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach5476a272010-10-11 18:51:51 +0000347 bits<4> p;
348 let Inst{31-28} = p;
Evan Cheng2d37f192008-08-28 23:39:26 +0000349 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +0000350 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +0000351 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng2d37f192008-08-28 23:39:26 +0000352 let Pattern = pattern;
353 list<Predicate> Predicates = [IsARM];
354}
Bill Wendlingb70dc872010-08-31 07:50:46 +0000355
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000356// A few are not predicable
Owen Anderson651b2302011-07-13 23:22:26 +0000357class InoP<dag oops, dag iops, AddrMode am, int sz,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000358 IndexMode im, Format f, InstrItinClass itin,
359 string opc, string asm, string cstr,
360 list<dag> pattern>
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000361 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
362 let OutOperandList = oops;
363 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000364 let AsmString = !strconcat(opc, asm);
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000365 let Pattern = pattern;
366 let isPredicable = 0;
367 list<Predicate> Predicates = [IsARM];
368}
Evan Cheng2d37f192008-08-28 23:39:26 +0000369
Bill Wendlingf8dfa462010-08-30 01:47:35 +0000370// Same as I except it can optionally modify CPSR. Note it's modeled as an input
371// operand since by default it's a zero register. It will become an implicit def
372// once it's "flipped".
Owen Anderson651b2302011-07-13 23:22:26 +0000373class sI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000374 IndexMode im, Format f, InstrItinClass itin,
375 string opc, string asm, string cstr,
Evan Cheng2d37f192008-08-28 23:39:26 +0000376 list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000377 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach5476a272010-10-11 18:51:51 +0000378 bits<4> p; // Predicate operand
Jim Grosbachd9d31da2010-10-12 23:00:24 +0000379 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
Jim Grosbach5476a272010-10-11 18:51:51 +0000380 let Inst{31-28} = p;
Jim Grosbachd9d31da2010-10-12 23:00:24 +0000381 let Inst{20} = s;
Jim Grosbach5476a272010-10-11 18:51:51 +0000382
Evan Cheng2d37f192008-08-28 23:39:26 +0000383 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +0000384 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Bob Wilson59351842010-10-15 03:23:44 +0000385 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Cheng2d37f192008-08-28 23:39:26 +0000386 let Pattern = pattern;
387 list<Predicate> Predicates = [IsARM];
388}
389
Evan Chenga2827232008-09-01 07:19:00 +0000390// Special cases
Owen Anderson651b2302011-07-13 23:22:26 +0000391class XI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000392 IndexMode im, Format f, InstrItinClass itin,
393 string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000394 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Evan Chenga2827232008-09-01 07:19:00 +0000395 let OutOperandList = oops;
396 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000397 let AsmString = asm;
Evan Chenga2827232008-09-01 07:19:00 +0000398 let Pattern = pattern;
399 list<Predicate> Predicates = [IsARM];
400}
401
David Goodwinb062c232009-08-06 16:52:47 +0000402class AI<dag oops, dag iops, Format f, InstrItinClass itin,
403 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000404 : I<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000405 opc, asm, "", pattern>;
406class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
407 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000408 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000409 opc, asm, "", pattern>;
410class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng2d37f192008-08-28 23:39:26 +0000411 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000412 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
Evan Cheng49d66522008-11-06 22:15:19 +0000413 asm, "", pattern>;
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000414class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000415 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000416 : InoP<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000417 opc, asm, "", pattern>;
Evan Chengfa558782008-09-01 08:25:56 +0000418
419// Ctrl flow instructions
David Goodwinb062c232009-08-06 16:52:47 +0000420class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
421 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000422 : I<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000423 opc, asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000424 let Inst{27-24} = opcod;
Evan Chengfa558782008-09-01 08:25:56 +0000425}
David Goodwinb062c232009-08-06 16:52:47 +0000426class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
427 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000428 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000429 asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000430 let Inst{27-24} = opcod;
Evan Chengfa558782008-09-01 08:25:56 +0000431}
Evan Chengfa558782008-09-01 08:25:56 +0000432
433// BR_JT instructions
David Goodwinb062c232009-08-06 16:52:47 +0000434class JTI<dag oops, dag iops, InstrItinClass itin,
435 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000436 : XI<oops, iops, AddrModeNone, 0, IndexModeNone, BrMiscFrm, itin,
Evan Cheng7095cd22008-11-07 09:06:08 +0000437 asm, "", pattern>;
Evan Cheng624844b2008-09-01 01:51:14 +0000438
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000439// Atomic load/store instructions
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000440class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
441 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000442 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000443 opc, asm, "", pattern> {
Jim Grosbach4e57b522010-10-29 19:58:57 +0000444 bits<4> Rt;
Jim Grosbachcb311932011-07-26 17:44:46 +0000445 bits<4> addr;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000446 let Inst{27-23} = 0b00011;
447 let Inst{22-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000448 let Inst{20} = 1;
Jim Grosbachcb311932011-07-26 17:44:46 +0000449 let Inst{19-16} = addr;
Jim Grosbach4e57b522010-10-29 19:58:57 +0000450 let Inst{15-12} = Rt;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000451 let Inst{11-0} = 0b111110011111;
452}
453class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
454 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000455 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000456 opc, asm, "", pattern> {
Jim Grosbach4e57b522010-10-29 19:58:57 +0000457 bits<4> Rd;
458 bits<4> Rt;
Bruno Cardoso Lopesf170f8b2011-03-24 21:04:58 +0000459 bits<4> addr;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000460 let Inst{27-23} = 0b00011;
461 let Inst{22-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000462 let Inst{20} = 0;
Bruno Cardoso Lopesf170f8b2011-03-24 21:04:58 +0000463 let Inst{19-16} = addr;
Jim Grosbach4e57b522010-10-29 19:58:57 +0000464 let Inst{15-12} = Rd;
Johnny Chen098bd1b2009-12-11 19:37:26 +0000465 let Inst{11-4} = 0b11111001;
Jim Grosbach4e57b522010-10-29 19:58:57 +0000466 let Inst{3-0} = Rt;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000467}
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000468class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern>
Jim Grosbach15e8d742011-07-26 17:15:11 +0000469 : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, $addr", pattern> {
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000470 bits<4> Rt;
471 bits<4> Rt2;
Jim Grosbach15e8d742011-07-26 17:15:11 +0000472 bits<4> addr;
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000473 let Inst{27-23} = 0b00010;
474 let Inst{22} = b;
475 let Inst{21-20} = 0b00;
Jim Grosbach15e8d742011-07-26 17:15:11 +0000476 let Inst{19-16} = addr;
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000477 let Inst{15-12} = Rt;
478 let Inst{11-4} = 0b00001001;
479 let Inst{3-0} = Rt2;
480}
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000481
Evan Cheng624844b2008-09-01 01:51:14 +0000482// addrmode1 instructions
David Goodwinb062c232009-08-06 16:52:47 +0000483class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
484 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000485 : I<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000486 opc, asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000487 let Inst{24-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000488 let Inst{27-26} = 0b00;
Evan Chengc139c222008-08-29 07:40:52 +0000489}
David Goodwinb062c232009-08-06 16:52:47 +0000490class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
491 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000492 : sI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000493 opc, asm, "", pattern> {
494 let Inst{24-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000495 let Inst{27-26} = 0b00;
David Goodwinb062c232009-08-06 16:52:47 +0000496}
497class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng2d37f192008-08-28 23:39:26 +0000498 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000499 : XI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
Evan Chengc139c222008-08-29 07:40:52 +0000500 asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000501 let Inst{24-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000502 let Inst{27-26} = 0b00;
Evan Chengc139c222008-08-29 07:40:52 +0000503}
Evan Cheng624844b2008-09-01 01:51:14 +0000504
Evan Chengcccca872008-09-01 01:27:33 +0000505// loads
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000506
Jim Grosbach4a22eba2010-11-19 21:07:51 +0000507// LDR/LDRB/STR/STRB/...
508class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am,
Jim Grosbach338de3e2010-10-27 23:12:14 +0000509 Format f, InstrItinClass itin, string opc, string asm,
510 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000511 : I<oops, iops, am, 4, IndexModeNone, f, itin, opc, asm,
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000512 "", pattern> {
513 let Inst{27-25} = op;
514 let Inst{24} = 1; // 24 == P
515 // 23 == U
Jim Grosbach2f790742010-11-13 00:35:48 +0000516 let Inst{22} = isByte;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000517 let Inst{21} = 0; // 21 == W
Jim Grosbach338de3e2010-10-27 23:12:14 +0000518 let Inst{20} = isLd;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000519}
Jim Grosbach2f790742010-11-13 00:35:48 +0000520// Indexed load/stores
521class AI2ldstidx<bit isLd, bit isByte, bit isPre, dag oops, dag iops,
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000522 IndexMode im, Format f, InstrItinClass itin, string opc,
Jim Grosbach2f790742010-11-13 00:35:48 +0000523 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000524 : I<oops, iops, AddrMode2, 4, im, f, itin,
Jim Grosbach2f790742010-11-13 00:35:48 +0000525 opc, asm, cstr, pattern> {
Jim Grosbach38b469e2010-11-15 20:47:07 +0000526 bits<4> Rt;
Jim Grosbach2f790742010-11-13 00:35:48 +0000527 let Inst{27-26} = 0b01;
528 let Inst{24} = isPre; // P bit
529 let Inst{22} = isByte; // B bit
530 let Inst{21} = isPre; // W bit
531 let Inst{20} = isLd; // L bit
Jim Grosbach38b469e2010-11-15 20:47:07 +0000532 let Inst{15-12} = Rt;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000533}
Owen Anderson2aedba62011-07-26 20:54:26 +0000534class AI2stridx_reg<bit isByte, bit isPre, dag oops, dag iops,
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000535 IndexMode im, Format f, InstrItinClass itin, string opc,
536 string asm, string cstr, list<dag> pattern>
537 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
538 pattern> {
539 // AM2 store w/ two operands: (GPR, am2offset)
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000540 // {12} isAdd
541 // {11-0} imm12/Rm
Bruno Cardoso Lopesc2452a62011-03-31 15:54:36 +0000542 bits<14> offset;
543 bits<4> Rn;
Owen Anderson2aedba62011-07-26 20:54:26 +0000544 let Inst{25} = 1;
545 let Inst{23} = offset{12};
546 let Inst{19-16} = Rn;
547 let Inst{11-5} = offset{11-5};
548 let Inst{4} = 0;
549 let Inst{3-0} = offset{3-0};
550}
551
552class AI2stridx_imm<bit isByte, bit isPre, dag oops, dag iops,
553 IndexMode im, Format f, InstrItinClass itin, string opc,
554 string asm, string cstr, list<dag> pattern>
555 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
556 pattern> {
557 // AM2 store w/ two operands: (GPR, am2offset)
558 // {12} isAdd
559 // {11-0} imm12/Rm
560 bits<14> offset;
561 bits<4> Rn;
562 let Inst{25} = 0;
Bruno Cardoso Lopesc2452a62011-03-31 15:54:36 +0000563 let Inst{23} = offset{12};
564 let Inst{19-16} = Rn;
565 let Inst{11-0} = offset{11-0};
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000566}
Owen Anderson2aedba62011-07-26 20:54:26 +0000567
568
Bruno Cardoso Lopesab830502011-03-31 23:26:08 +0000569// FIXME: Merge with the above class when addrmode2 gets used for STR, STRB
570// but for now use this class for STRT and STRBT.
571class AI2stridxT<bit isByte, bit isPre, dag oops, dag iops,
572 IndexMode im, Format f, InstrItinClass itin, string opc,
573 string asm, string cstr, list<dag> pattern>
574 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
575 pattern> {
576 // AM2 store w/ two operands: (GPR, am2offset)
577 // {17-14} Rn
578 // {13} 1 == Rm, 0 == imm12
579 // {12} isAdd
580 // {11-0} imm12/Rm
581 bits<18> addr;
582 let Inst{25} = addr{13};
583 let Inst{23} = addr{12};
584 let Inst{19-16} = addr{17-14};
585 let Inst{11-0} = addr{11-0};
586}
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000587
Evan Cheng624844b2008-09-01 01:51:14 +0000588// addrmode3 instructions
Jim Grosbach76aed402010-11-19 18:16:46 +0000589class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f,
590 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000591 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
Jim Grosbach8e7f8df2010-11-18 00:46:58 +0000592 opc, asm, "", pattern> {
593 bits<14> addr;
594 bits<4> Rt;
595 let Inst{27-25} = 0b000;
596 let Inst{24} = 1; // P bit
597 let Inst{23} = addr{8}; // U bit
598 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
599 let Inst{21} = 0; // W bit
Jim Grosbach76aed402010-11-19 18:16:46 +0000600 let Inst{20} = op20; // L bit
Jim Grosbach8e7f8df2010-11-18 00:46:58 +0000601 let Inst{19-16} = addr{12-9}; // Rn
602 let Inst{15-12} = Rt; // Rt
603 let Inst{11-8} = addr{7-4}; // imm7_4/zero
604 let Inst{7-4} = op;
605 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
Owen Andersone0152a72011-08-09 20:55:18 +0000606
607 let DecoderMethod = "DecodeAddrMode3Instruction";
Jim Grosbach8e7f8df2010-11-18 00:46:58 +0000608}
Evan Cheng169eccc2008-09-01 07:00:14 +0000609
Jim Grosbach2ea19d12011-08-11 20:41:13 +0000610class AI3ldstidx<bits<4> op, bit op20, bit isPre, dag oops, dag iops,
Jim Grosbach003c6e72010-11-19 19:41:26 +0000611 IndexMode im, Format f, InstrItinClass itin, string opc,
612 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000613 : I<oops, iops, AddrMode3, 4, im, f, itin,
Jim Grosbach003c6e72010-11-19 19:41:26 +0000614 opc, asm, cstr, pattern> {
615 bits<4> Rt;
616 let Inst{27-25} = 0b000;
617 let Inst{24} = isPre; // P bit
618 let Inst{21} = isPre; // W bit
619 let Inst{20} = op20; // L bit
620 let Inst{15-12} = Rt; // Rt
621 let Inst{7-4} = op;
622}
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000623
624// FIXME: Merge with the above class when addrmode2 gets used for LDR, LDRB
625// but for now use this class for LDRSBT, LDRHT, LDSHT.
Jim Grosbachd3595712011-08-03 23:50:40 +0000626class AI3ldstidxT<bits<4> op, bit isLoad, dag oops, dag iops,
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000627 IndexMode im, Format f, InstrItinClass itin, string opc,
628 string asm, string cstr, list<dag> pattern>
Jim Grosbachd3595712011-08-03 23:50:40 +0000629 : I<oops, iops, AddrMode3, 4, im, f, itin, opc, asm, cstr, pattern> {
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000630 // {13} 1 == imm8, 0 == Rm
631 // {12-9} Rn
632 // {8} isAdd
633 // {7-4} imm7_4/zero
634 // {3-0} imm3_0/Rm
Jim Grosbachd3595712011-08-03 23:50:40 +0000635 bits<4> addr;
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000636 bits<4> Rt;
637 let Inst{27-25} = 0b000;
Jim Grosbachd3595712011-08-03 23:50:40 +0000638 let Inst{24} = 0; // P bit
639 let Inst{21} = 1;
640 let Inst{20} = isLoad; // L bit
641 let Inst{19-16} = addr; // Rn
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000642 let Inst{15-12} = Rt; // Rt
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000643 let Inst{7-4} = op;
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000644}
645
Evan Cheng169eccc2008-09-01 07:00:14 +0000646// stores
Jim Grosbach09d7bfd2010-11-19 22:14:31 +0000647class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin,
David Goodwinb062c232009-08-06 16:52:47 +0000648 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000649 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000650 opc, asm, "", pattern> {
Jim Grosbach607efcb2010-11-11 01:09:40 +0000651 bits<14> addr;
652 bits<4> Rt;
Evan Cheng5edd90c2009-07-08 22:51:32 +0000653 let Inst{27-25} = 0b000;
Jim Grosbach607efcb2010-11-11 01:09:40 +0000654 let Inst{24} = 1; // P bit
655 let Inst{23} = addr{8}; // U bit
656 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
657 let Inst{21} = 0; // W bit
658 let Inst{20} = 0; // L bit
659 let Inst{19-16} = addr{12-9}; // Rn
660 let Inst{15-12} = Rt; // Rt
661 let Inst{11-8} = addr{7-4}; // imm7_4/zero
Jim Grosbach09d7bfd2010-11-19 22:14:31 +0000662 let Inst{7-4} = op;
Jim Grosbach607efcb2010-11-11 01:09:40 +0000663 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
Owen Anderson60138ea2011-08-12 20:02:50 +0000664 let DecoderMethod = "DecodeAddrMode3Instruction";
Evan Cheng169eccc2008-09-01 07:00:14 +0000665}
Evan Cheng169eccc2008-09-01 07:00:14 +0000666
Evan Cheng624844b2008-09-01 01:51:14 +0000667// addrmode4 instructions
Bill Wendlinge69afc62010-11-13 09:09:38 +0000668class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
669 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000670 : XI<oops, iops, AddrMode4, 4, im, f, itin, asm, cstr, pattern> {
Bill Wendlinge69afc62010-11-13 09:09:38 +0000671 bits<4> p;
672 bits<16> regs;
673 bits<4> Rn;
674 let Inst{31-28} = p;
675 let Inst{27-25} = 0b100;
676 let Inst{22} = 0; // S bit
677 let Inst{19-16} = Rn;
678 let Inst{15-0} = regs;
679}
Evan Cheng2d37f192008-08-28 23:39:26 +0000680
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000681// Unsigned multiply, multiply-accumulate instructions.
David Goodwinb062c232009-08-06 16:52:47 +0000682class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
683 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000684 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000685 opc, asm, "", pattern> {
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000686 let Inst{7-4} = 0b1001;
Evan Cheng2686c8f2008-11-06 01:21:28 +0000687 let Inst{20} = 0; // S bit
Evan Cheng47b546d2008-11-06 08:47:38 +0000688 let Inst{27-21} = opcod;
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000689}
David Goodwinb062c232009-08-06 16:52:47 +0000690class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
691 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000692 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000693 opc, asm, "", pattern> {
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000694 let Inst{7-4} = 0b1001;
Evan Cheng47b546d2008-11-06 08:47:38 +0000695 let Inst{27-21} = opcod;
Evan Cheng2686c8f2008-11-06 01:21:28 +0000696}
697
698// Most significant word multiply
Jim Grosbach22261602010-10-22 17:16:17 +0000699class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
700 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000701 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000702 opc, asm, "", pattern> {
Jim Grosbach22261602010-10-22 17:16:17 +0000703 bits<4> Rd;
704 bits<4> Rn;
705 bits<4> Rm;
706 let Inst{7-4} = opc7_4;
Evan Cheng2686c8f2008-11-06 01:21:28 +0000707 let Inst{20} = 1;
Evan Cheng47b546d2008-11-06 08:47:38 +0000708 let Inst{27-21} = opcod;
Jim Grosbach22261602010-10-22 17:16:17 +0000709 let Inst{19-16} = Rd;
710 let Inst{11-8} = Rm;
711 let Inst{3-0} = Rn;
712}
713// MSW multiple w/ Ra operand
714class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
715 InstrItinClass itin, string opc, string asm, list<dag> pattern>
716 : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> {
717 bits<4> Ra;
718 let Inst{15-12} = Ra;
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000719}
Evan Cheng2d37f192008-08-28 23:39:26 +0000720
Evan Cheng36ae4032008-11-06 03:35:07 +0000721// SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
Jim Grosbach6956a602010-10-22 18:35:16 +0000722class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
Jim Grosbachf98df082010-10-22 17:42:06 +0000723 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000724 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000725 opc, asm, "", pattern> {
Jim Grosbach6956a602010-10-22 18:35:16 +0000726 bits<4> Rn;
727 bits<4> Rm;
Evan Cheng36ae4032008-11-06 03:35:07 +0000728 let Inst{4} = 0;
729 let Inst{7} = 1;
730 let Inst{20} = 0;
Evan Cheng47b546d2008-11-06 08:47:38 +0000731 let Inst{27-21} = opcod;
Jim Grosbachf98df082010-10-22 17:42:06 +0000732 let Inst{6-5} = bit6_5;
Jim Grosbach6956a602010-10-22 18:35:16 +0000733 let Inst{11-8} = Rm;
734 let Inst{3-0} = Rn;
735}
736class AMulxyI<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
737 InstrItinClass itin, string opc, string asm, list<dag> pattern>
738 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
739 bits<4> Rd;
740 let Inst{19-16} = Rd;
741}
742
743// AMulxyI with Ra operand
744class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
745 InstrItinClass itin, string opc, string asm, list<dag> pattern>
746 : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
747 bits<4> Ra;
748 let Inst{15-12} = Ra;
749}
750// SMLAL*
751class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
752 InstrItinClass itin, string opc, string asm, list<dag> pattern>
753 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
754 bits<4> RdLo;
755 bits<4> RdHi;
756 let Inst{19-16} = RdHi;
757 let Inst{15-12} = RdLo;
Evan Cheng36ae4032008-11-06 03:35:07 +0000758}
759
Evan Cheng49d66522008-11-06 22:15:19 +0000760// Extend instructions.
David Goodwinb062c232009-08-06 16:52:47 +0000761class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
762 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000763 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ExtFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000764 opc, asm, "", pattern> {
Jim Grosbach1e7db682010-10-13 19:56:10 +0000765 // All AExtI instructions have Rd and Rm register operands.
766 bits<4> Rd;
767 bits<4> Rm;
768 let Inst{15-12} = Rd;
769 let Inst{3-0} = Rm;
Evan Cheng49d66522008-11-06 22:15:19 +0000770 let Inst{7-4} = 0b0111;
Jim Grosbach1e7db682010-10-13 19:56:10 +0000771 let Inst{9-8} = 0b00;
Evan Cheng49d66522008-11-06 22:15:19 +0000772 let Inst{27-20} = opcod;
773}
774
Evan Cheng98dc53e2008-11-07 01:41:35 +0000775// Misc Arithmetic instructions.
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000776class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
777 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000778 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000779 opc, asm, "", pattern> {
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000780 bits<4> Rd;
781 bits<4> Rm;
Evan Cheng98dc53e2008-11-07 01:41:35 +0000782 let Inst{27-20} = opcod;
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000783 let Inst{19-16} = 0b1111;
784 let Inst{15-12} = Rd;
785 let Inst{11-8} = 0b1111;
786 let Inst{7-4} = opc7_4;
787 let Inst{3-0} = Rm;
788}
789
790// PKH instructions
Jim Grosbach27c1e252011-07-21 17:23:04 +0000791def PKHLSLAsmOperand : AsmOperandClass {
792 let Name = "PKHLSLImm";
793 let ParserMethod = "parsePKHLSLImm";
794}
Jim Grosbacha288b1c2011-07-20 21:40:26 +0000795def pkh_lsl_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 32; }]>{
796 let PrintMethod = "printPKHLSLShiftImm";
Jim Grosbach27c1e252011-07-21 17:23:04 +0000797 let ParserMatchClass = PKHLSLAsmOperand;
798}
799def PKHASRAsmOperand : AsmOperandClass {
800 let Name = "PKHASRImm";
801 let ParserMethod = "parsePKHASRImm";
Jim Grosbacha288b1c2011-07-20 21:40:26 +0000802}
803def pkh_asr_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 32; }]>{
804 let PrintMethod = "printPKHASRShiftImm";
Jim Grosbach27c1e252011-07-21 17:23:04 +0000805 let ParserMatchClass = PKHASRAsmOperand;
Jim Grosbacha288b1c2011-07-20 21:40:26 +0000806}
Jim Grosbach94df3be2011-07-20 20:49:03 +0000807
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000808class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
809 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000810 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000811 opc, asm, "", pattern> {
812 bits<4> Rd;
813 bits<4> Rn;
814 bits<4> Rm;
Jim Grosbacha98f8002011-07-20 20:32:09 +0000815 bits<5> sh;
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000816 let Inst{27-20} = opcod;
817 let Inst{19-16} = Rn;
818 let Inst{15-12} = Rd;
Jim Grosbacha98f8002011-07-20 20:32:09 +0000819 let Inst{11-7} = sh;
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000820 let Inst{6} = tb;
821 let Inst{5-4} = 0b01;
822 let Inst{3-0} = Rm;
Evan Cheng98dc53e2008-11-07 01:41:35 +0000823}
824
Evan Cheng2d37f192008-08-28 23:39:26 +0000825//===----------------------------------------------------------------------===//
826
827// ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
828class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
829 list<Predicate> Predicates = [IsARM];
830}
Bruno Cardoso Lopes168c9002011-05-03 17:29:22 +0000831class ARMV5TPat<dag pattern, dag result> : Pat<pattern, result> {
832 list<Predicate> Predicates = [IsARM, HasV5T];
833}
Evan Cheng2d37f192008-08-28 23:39:26 +0000834class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
835 list<Predicate> Predicates = [IsARM, HasV5TE];
836}
837class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
838 list<Predicate> Predicates = [IsARM, HasV6];
839}
Evan Chengee98fa92008-08-29 06:41:12 +0000840
841//===----------------------------------------------------------------------===//
Evan Chengee98fa92008-08-29 06:41:12 +0000842// Thumb Instruction Format Definitions.
843//
844
Owen Anderson651b2302011-07-13 23:22:26 +0000845class ThumbI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000846 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +0000847 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengcd4cdd12009-07-11 06:43:01 +0000848 let OutOperandList = oops;
849 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000850 let AsmString = asm;
Evan Chengee98fa92008-08-29 06:41:12 +0000851 let Pattern = pattern;
852 list<Predicate> Predicates = [IsThumb];
853}
854
Bill Wendlingcbb08ca2010-12-01 02:42:55 +0000855// TI - Thumb instruction.
David Goodwinb062c232009-08-06 16:52:47 +0000856class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000857 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
Evan Chengee98fa92008-08-29 06:41:12 +0000858
Evan Cheng7cc6aca2009-08-04 23:47:55 +0000859// Two-address instructions
Bob Wilson3968c6a2010-03-23 17:23:59 +0000860class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
861 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000862 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "$lhs = $dst",
Bob Wilson3968c6a2010-03-23 17:23:59 +0000863 pattern>;
Evan Cheng7cc6aca2009-08-04 23:47:55 +0000864
Johnny Chenc28e6292009-12-15 17:24:14 +0000865// tBL, tBX 32-bit instructions
866class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000867 dag oops, dag iops, InstrItinClass itin, string asm,
868 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000869 : ThumbI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000870 Encoding {
Johnny Chenc28e6292009-12-15 17:24:14 +0000871 let Inst{31-27} = opcod1;
872 let Inst{15-14} = opcod2;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000873 let Inst{12} = opcod3;
Johnny Chenc28e6292009-12-15 17:24:14 +0000874}
Evan Chengee98fa92008-08-29 06:41:12 +0000875
876// BR_JT instructions
Bob Wilson3968c6a2010-03-23 17:23:59 +0000877class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
878 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000879 : ThumbI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
Evan Chengee98fa92008-08-29 06:41:12 +0000880
Evan Chengbec1dba892009-06-23 19:38:13 +0000881// Thumb1 only
Owen Anderson651b2302011-07-13 23:22:26 +0000882class Thumb1I<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000883 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +0000884 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengcd4cdd12009-07-11 06:43:01 +0000885 let OutOperandList = oops;
886 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000887 let AsmString = asm;
Evan Chengbec1dba892009-06-23 19:38:13 +0000888 let Pattern = pattern;
Jim Grosbachfddf36d2010-11-01 17:08:58 +0000889 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Chengbec1dba892009-06-23 19:38:13 +0000890}
891
David Goodwinb062c232009-08-06 16:52:47 +0000892class T1I<dag oops, dag iops, InstrItinClass itin,
893 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000894 : Thumb1I<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +0000895class T1Ix2<dag oops, dag iops, InstrItinClass itin,
896 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000897 : Thumb1I<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
Evan Chengbec1dba892009-06-23 19:38:13 +0000898
899// Two-address instructions
David Goodwinb062c232009-08-06 16:52:47 +0000900class T1It<dag oops, dag iops, InstrItinClass itin,
Bob Wilson947f04b2010-03-13 01:08:20 +0000901 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000902 : Thumb1I<oops, iops, AddrModeNone, 2, itin,
Bob Wilson947f04b2010-03-13 01:08:20 +0000903 asm, cstr, pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +0000904
905// Thumb1 instruction that can either be predicated or set CPSR.
Owen Anderson651b2302011-07-13 23:22:26 +0000906class Thumb1sI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000907 InstrItinClass itin,
Evan Chengcd4cdd12009-07-11 06:43:01 +0000908 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +0000909 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Chris Lattnerfb2ceed2010-03-18 21:06:54 +0000910 let OutOperandList = !con(oops, (outs s_cc_out:$s));
911 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +0000912 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Chengcd4cdd12009-07-11 06:43:01 +0000913 let Pattern = pattern;
Jim Grosbach3e941ae2011-08-16 20:45:50 +0000914 let thumbArithFlagSetting = 1;
Jim Grosbachfddf36d2010-11-01 17:08:58 +0000915 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Owen Anderson91a8f9b2011-08-16 23:45:44 +0000916 let DecoderNamespace = "ThumbSBit";
Evan Chengcd4cdd12009-07-11 06:43:01 +0000917}
918
David Goodwinb062c232009-08-06 16:52:47 +0000919class T1sI<dag oops, dag iops, InstrItinClass itin,
920 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000921 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +0000922
923// Two-address instructions
David Goodwinb062c232009-08-06 16:52:47 +0000924class T1sIt<dag oops, dag iops, InstrItinClass itin,
925 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000926 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm,
Bill Wendling05632cb2010-11-30 23:54:45 +0000927 "$Rn = $Rdn", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +0000928
929// Thumb1 instruction that can be predicated.
Owen Anderson651b2302011-07-13 23:22:26 +0000930class Thumb1pI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000931 InstrItinClass itin,
Evan Chengcd4cdd12009-07-11 06:43:01 +0000932 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +0000933 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengcd4cdd12009-07-11 06:43:01 +0000934 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +0000935 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +0000936 let AsmString = !strconcat(opc, "${p}", asm);
Evan Chengcd4cdd12009-07-11 06:43:01 +0000937 let Pattern = pattern;
Jim Grosbachfddf36d2010-11-01 17:08:58 +0000938 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Chengcd4cdd12009-07-11 06:43:01 +0000939}
940
David Goodwinb062c232009-08-06 16:52:47 +0000941class T1pI<dag oops, dag iops, InstrItinClass itin,
942 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000943 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +0000944
945// Two-address instructions
David Goodwinb062c232009-08-06 16:52:47 +0000946class T1pIt<dag oops, dag iops, InstrItinClass itin,
947 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000948 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm,
Bill Wendling7c646b92010-12-01 01:32:02 +0000949 "$Rn = $Rdn", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +0000950
Bob Wilson3968c6a2010-03-23 17:23:59 +0000951class T1pIs<dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +0000952 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000953 : Thumb1pI<oops, iops, AddrModeT1_s, 2, itin, opc, asm, "", pattern>;
Evan Chengbec1dba892009-06-23 19:38:13 +0000954
Johnny Chen466231a2009-12-16 02:32:54 +0000955class Encoding16 : Encoding {
956 let Inst{31-16} = 0x0000;
957}
958
Johnny Chenc28e6292009-12-15 17:24:14 +0000959// A6.2 16-bit Thumb instruction encoding
Johnny Chen466231a2009-12-16 02:32:54 +0000960class T1Encoding<bits<6> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +0000961 let Inst{15-10} = opcode;
962}
963
964// A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
Johnny Chen466231a2009-12-16 02:32:54 +0000965class T1General<bits<5> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +0000966 let Inst{15-14} = 0b00;
967 let Inst{13-9} = opcode;
968}
969
970// A6.2.2 Data-processing encoding.
Johnny Chen466231a2009-12-16 02:32:54 +0000971class T1DataProcessing<bits<4> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +0000972 let Inst{15-10} = 0b010000;
973 let Inst{9-6} = opcode;
974}
975
976// A6.2.3 Special data instructions and branch and exchange encoding.
Johnny Chen466231a2009-12-16 02:32:54 +0000977class T1Special<bits<4> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +0000978 let Inst{15-10} = 0b010001;
Bill Wendling345b48f2010-11-17 00:45:23 +0000979 let Inst{9-6} = opcode;
Johnny Chenc28e6292009-12-15 17:24:14 +0000980}
981
982// A6.2.4 Load/store single data item encoding.
Johnny Chen466231a2009-12-16 02:32:54 +0000983class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +0000984 let Inst{15-12} = opA;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000985 let Inst{11-9} = opB;
Johnny Chenc28e6292009-12-15 17:24:14 +0000986}
Bill Wendlingb70dc872010-08-31 07:50:46 +0000987class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative
Johnny Chenc28e6292009-12-15 17:24:14 +0000988
Eric Christopher9b67db82011-05-27 03:50:53 +0000989class T1BranchCond<bits<4> opcode> : Encoding16 {
990 let Inst{15-12} = opcode;
991}
992
Bill Wendlinga9e3df72010-11-30 22:57:21 +0000993// Helper classes to encode Thumb1 loads and stores. For immediates, the
Bill Wendling05632cb2010-11-30 23:54:45 +0000994// following bits are used for "opA" (see A6.2.4):
Jim Grosbachc4669ed2010-12-10 20:47:29 +0000995//
Bill Wendlinga9e3df72010-11-30 22:57:21 +0000996// 0b0110 => Immediate, 4 bytes
997// 0b1000 => Immediate, 2 bytes
998// 0b0111 => Immediate, 1 byte
Bill Wendlingc25545a2010-12-01 01:38:08 +0000999class T1pILdStEncode<bits<3> opcode, dag oops, dag iops, AddrMode am,
1000 InstrItinClass itin, string opc, string asm,
1001 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001002 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
Bill Wendling5c51fcd2010-11-30 23:16:25 +00001003 T1LoadStore<0b0101, opcode> {
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001004 bits<3> Rt;
1005 bits<8> addr;
1006 let Inst{8-6} = addr{5-3}; // Rm
1007 let Inst{5-3} = addr{2-0}; // Rn
1008 let Inst{2-0} = Rt;
1009}
Bill Wendlingc25545a2010-12-01 01:38:08 +00001010class T1pILdStEncodeImm<bits<4> opA, bit opB, dag oops, dag iops, AddrMode am,
1011 InstrItinClass itin, string opc, string asm,
1012 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001013 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
Bill Wendling5c51fcd2010-11-30 23:16:25 +00001014 T1LoadStore<opA, {opB,?,?}> {
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001015 bits<3> Rt;
1016 bits<8> addr;
1017 let Inst{10-6} = addr{7-3}; // imm5
1018 let Inst{5-3} = addr{2-0}; // Rn
1019 let Inst{2-0} = Rt;
1020}
1021
Johnny Chenc28e6292009-12-15 17:24:14 +00001022// A6.2.5 Miscellaneous 16-bit instructions encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001023class T1Misc<bits<7> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001024 let Inst{15-12} = 0b1011;
1025 let Inst{11-5} = opcode;
1026}
1027
Evan Chengd76f0be2009-06-25 02:08:06 +00001028// Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
Owen Anderson651b2302011-07-13 23:22:26 +00001029class Thumb2I<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001030 InstrItinClass itin,
Evan Chengd76f0be2009-06-25 02:08:06 +00001031 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001032 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengd76f0be2009-06-25 02:08:06 +00001033 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001034 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001035 let AsmString = !strconcat(opc, "${p}", asm);
Evan Chengd76f0be2009-06-25 02:08:06 +00001036 let Pattern = pattern;
Evan Cheng2c450d32009-07-02 06:38:40 +00001037 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001038 let DecoderNamespace = "Thumb2";
Evan Chengd76f0be2009-06-25 02:08:06 +00001039}
1040
Bill Wendlingb70dc872010-08-31 07:50:46 +00001041// Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
1042// input operand since by default it's a zero register. It will become an
1043// implicit def once it's "flipped".
Jim Grosbachb9386552010-10-13 23:12:26 +00001044//
Evan Chengd76f0be2009-06-25 02:08:06 +00001045// FIXME: This uses unified syntax so {s} comes before {p}. We should make it
1046// more consistent.
Owen Anderson651b2302011-07-13 23:22:26 +00001047class Thumb2sI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001048 InstrItinClass itin,
Evan Chengd76f0be2009-06-25 02:08:06 +00001049 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001050 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Owen Andersoncf096a42010-12-07 20:50:15 +00001051 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
1052 let Inst{20} = s;
1053
Evan Chengd76f0be2009-06-25 02:08:06 +00001054 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001055 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Chris Lattner04c342e2010-10-06 00:05:18 +00001056 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Chengd76f0be2009-06-25 02:08:06 +00001057 let Pattern = pattern;
Evan Cheng2c450d32009-07-02 06:38:40 +00001058 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001059 let DecoderNamespace = "Thumb2";
Evan Chengd76f0be2009-06-25 02:08:06 +00001060}
1061
1062// Special cases
Owen Anderson651b2302011-07-13 23:22:26 +00001063class Thumb2XI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001064 InstrItinClass itin,
Evan Chengd76f0be2009-06-25 02:08:06 +00001065 string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001066 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengd76f0be2009-06-25 02:08:06 +00001067 let OutOperandList = oops;
1068 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001069 let AsmString = asm;
Evan Cheng431cf562009-06-23 17:48:47 +00001070 let Pattern = pattern;
Evan Cheng2c450d32009-07-02 06:38:40 +00001071 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001072 let DecoderNamespace = "Thumb2";
Evan Cheng431cf562009-06-23 17:48:47 +00001073}
1074
Owen Anderson651b2302011-07-13 23:22:26 +00001075class ThumbXI<dag oops, dag iops, AddrMode am, int sz,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001076 InstrItinClass itin,
1077 string asm, string cstr, list<dag> pattern>
Jim Grosbach36d4dec2009-12-01 18:10:36 +00001078 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1079 let OutOperandList = oops;
1080 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001081 let AsmString = asm;
Jim Grosbach36d4dec2009-12-01 18:10:36 +00001082 let Pattern = pattern;
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001083 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001084 let DecoderNamespace = "Thumb";
Jim Grosbach36d4dec2009-12-01 18:10:36 +00001085}
1086
David Goodwinb062c232009-08-06 16:52:47 +00001087class T2I<dag oops, dag iops, InstrItinClass itin,
1088 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001089 : Thumb2I<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001090class T2Ii12<dag oops, dag iops, InstrItinClass itin,
1091 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001092 : Thumb2I<oops, iops, AddrModeT2_i12, 4, itin, opc, asm, "",pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001093class T2Ii8<dag oops, dag iops, InstrItinClass itin,
1094 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001095 : Thumb2I<oops, iops, AddrModeT2_i8, 4, itin, opc, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001096class T2Iso<dag oops, dag iops, InstrItinClass itin,
1097 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001098 : Thumb2I<oops, iops, AddrModeT2_so, 4, itin, opc, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001099class T2Ipc<dag oops, dag iops, InstrItinClass itin,
1100 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001101 : Thumb2I<oops, iops, AddrModeT2_pc, 4, itin, opc, asm, "", pattern>;
Jim Grosbach95bd6b72010-12-10 20:51:35 +00001102class T2Ii8s4<bit P, bit W, bit isLoad, dag oops, dag iops, InstrItinClass itin,
David Goodwinb062c232009-08-06 16:52:47 +00001103 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001104 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, "",
Johnny Chenc28e6292009-12-15 17:24:14 +00001105 pattern> {
Owen Anderson943fb602010-12-01 19:18:46 +00001106 bits<4> Rt;
1107 bits<4> Rt2;
1108 bits<13> addr;
Jim Grosbach95bd6b72010-12-10 20:51:35 +00001109 let Inst{31-25} = 0b1110100;
1110 let Inst{24} = P;
1111 let Inst{23} = addr{8};
1112 let Inst{22} = 1;
1113 let Inst{21} = W;
1114 let Inst{20} = isLoad;
1115 let Inst{19-16} = addr{12-9};
Owen Anderson943fb602010-12-01 19:18:46 +00001116 let Inst{15-12} = Rt{3-0};
1117 let Inst{11-8} = Rt2{3-0};
Owen Anderson943fb602010-12-01 19:18:46 +00001118 let Inst{7-0} = addr{7-0};
Johnny Chenc28e6292009-12-15 17:24:14 +00001119}
Evan Chengd76f0be2009-06-25 02:08:06 +00001120
Owen Anderson08d4bb02011-08-04 23:18:05 +00001121class T2Ii8s4Tied<bit P, bit W, bit isLoad, dag oops, dag iops, InstrItinClass itin,
1122 string opc, string asm, list<dag> pattern>
1123 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, "$base = $wb",
1124 pattern> {
1125 bits<4> Rt;
1126 bits<4> Rt2;
1127 bits<4> base;
1128 bits<9> imm;
1129 let Inst{31-25} = 0b1110100;
1130 let Inst{24} = P;
1131 let Inst{23} = imm{8};
1132 let Inst{22} = 1;
1133 let Inst{21} = W;
1134 let Inst{20} = isLoad;
1135 let Inst{19-16} = base{3-0};
1136 let Inst{15-12} = Rt{3-0};
1137 let Inst{11-8} = Rt2{3-0};
1138 let Inst{7-0} = imm{7-0};
1139}
1140
1141
David Goodwinb062c232009-08-06 16:52:47 +00001142class T2sI<dag oops, dag iops, InstrItinClass itin,
1143 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001144 : Thumb2sI<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
Evan Chengd76f0be2009-06-25 02:08:06 +00001145
David Goodwinb062c232009-08-06 16:52:47 +00001146class T2XI<dag oops, dag iops, InstrItinClass itin,
1147 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001148 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001149class T2JTI<dag oops, dag iops, InstrItinClass itin,
1150 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001151 : Thumb2XI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
Evan Cheng431cf562009-06-23 17:48:47 +00001152
Bruno Cardoso Lopes4d4b4902011-01-20 16:58:48 +00001153// Move to/from coprocessor instructions
Jim Grosbachcabb48d2011-07-13 21:17:59 +00001154class T2Cop<bits<4> opc, dag oops, dag iops, string asm, list<dag> pattern>
Jim Grosbachadb29b62011-07-13 21:14:23 +00001155 : T2XI <oops, iops, NoItinerary, asm, pattern>, Requires<[IsThumb2]> {
Jim Grosbachcabb48d2011-07-13 21:17:59 +00001156 let Inst{31-28} = opc;
Bruno Cardoso Lopes4d4b4902011-01-20 16:58:48 +00001157}
1158
Bob Wilson947f04b2010-03-13 01:08:20 +00001159// Two-address instructions
1160class T2XIt<dag oops, dag iops, InstrItinClass itin,
1161 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001162 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, cstr, pattern>;
Evan Cheng83e0d482009-09-28 09:14:39 +00001163
Jim Grosbachc086f682011-09-08 00:39:19 +00001164// T2Ipreldst - Thumb2 pre-indexed load / store instructions.
1165class T2Ipreldst<bit signed, bits<2> opcod, bit load, bit pre,
Johnny Chenc28e6292009-12-15 17:24:14 +00001166 dag oops, dag iops,
1167 AddrMode am, IndexMode im, InstrItinClass itin,
Evan Cheng84c6cda2009-07-02 07:28:31 +00001168 string opc, string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001169 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng84c6cda2009-07-02 07:28:31 +00001170 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001171 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001172 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng84c6cda2009-07-02 07:28:31 +00001173 let Pattern = pattern;
1174 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001175 let DecoderNamespace = "Thumb2";
Jim Grosbachc086f682011-09-08 00:39:19 +00001176
1177 bits<4> Rt;
1178 bits<13> addr;
Johnny Chenc28e6292009-12-15 17:24:14 +00001179 let Inst{31-27} = 0b11111;
1180 let Inst{26-25} = 0b00;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001181 let Inst{24} = signed;
1182 let Inst{23} = 0;
Johnny Chenc28e6292009-12-15 17:24:14 +00001183 let Inst{22-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001184 let Inst{20} = load;
Jim Grosbachc086f682011-09-08 00:39:19 +00001185 let Inst{19-16} = addr{12-9};
1186 let Inst{15-12} = Rt{3-0};
Bill Wendlingb70dc872010-08-31 07:50:46 +00001187 let Inst{11} = 1;
Johnny Chenc28e6292009-12-15 17:24:14 +00001188 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
Bill Wendlingb70dc872010-08-31 07:50:46 +00001189 let Inst{10} = pre; // The P bit.
Jim Grosbachc086f682011-09-08 00:39:19 +00001190 let Inst{9} = addr{8}; // Sign bit
Bill Wendlingb70dc872010-08-31 07:50:46 +00001191 let Inst{8} = 1; // The W bit.
Jim Grosbachc086f682011-09-08 00:39:19 +00001192 let Inst{7-0} = addr{7-0};
1193}
Jim Grosbachc4669ed2010-12-10 20:47:29 +00001194
Jim Grosbachc086f682011-09-08 00:39:19 +00001195// T2Ipostldst - Thumb2 post-indexed load / store instructions.
1196class T2Ipostldst<bit signed, bits<2> opcod, bit load, bit pre,
1197 dag oops, dag iops,
1198 AddrMode am, IndexMode im, InstrItinClass itin,
1199 string opc, string asm, string cstr, list<dag> pattern>
1200 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
1201 let OutOperandList = oops;
1202 let InOperandList = !con(iops, (ins pred:$p));
1203 let AsmString = !strconcat(opc, "${p}", asm);
1204 let Pattern = pattern;
1205 list<Predicate> Predicates = [IsThumb2];
1206 let DecoderNamespace = "Thumb2";
Jim Grosbachc4669ed2010-12-10 20:47:29 +00001207
Owen Andersone22c7322010-11-30 00:14:31 +00001208 bits<4> Rt;
1209 bits<4> Rn;
Jim Grosbachc086f682011-09-08 00:39:19 +00001210 bits<9> addr;
1211 let Inst{31-27} = 0b11111;
1212 let Inst{26-25} = 0b00;
1213 let Inst{24} = signed;
1214 let Inst{23} = 0;
1215 let Inst{22-21} = opcod;
1216 let Inst{20} = load;
1217 let Inst{19-16} = Rn;
Owen Andersone22c7322010-11-30 00:14:31 +00001218 let Inst{15-12} = Rt{3-0};
Jim Grosbachc086f682011-09-08 00:39:19 +00001219 let Inst{11} = 1;
1220 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1221 let Inst{10} = pre; // The P bit.
1222 let Inst{9} = addr{8}; // Sign bit
1223 let Inst{8} = 1; // The W bit.
1224 let Inst{7-0} = addr{7-0};
Evan Cheng84c6cda2009-07-02 07:28:31 +00001225}
1226
David Goodwine5b969f2009-07-27 19:59:26 +00001227// Tv5Pat - Same as Pat<>, but requires V5T Thumb mode.
1228class Tv5Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001229 list<Predicate> Predicates = [IsThumb, IsThumb1Only, HasV5T];
David Goodwine5b969f2009-07-27 19:59:26 +00001230}
1231
1232// T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1233class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001234 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
David Goodwine5b969f2009-07-27 19:59:26 +00001235}
Evan Cheng84c6cda2009-07-02 07:28:31 +00001236
Bruno Cardoso Lopes168c9002011-05-03 17:29:22 +00001237// T2v6Pat - Same as Pat<>, but requires V6T2 Thumb2 mode.
1238class T2v6Pat<dag pattern, dag result> : Pat<pattern, result> {
1239 list<Predicate> Predicates = [IsThumb2, HasV6T2];
1240}
1241
Evan Chengeab9ca72009-06-27 02:26:13 +00001242// T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1243class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
Evan Cheng2c450d32009-07-02 06:38:40 +00001244 list<Predicate> Predicates = [IsThumb2];
Evan Cheng431cf562009-06-23 17:48:47 +00001245}
1246
Evan Chengee98fa92008-08-29 06:41:12 +00001247//===----------------------------------------------------------------------===//
1248
Evan Chengac2af2f2008-11-11 02:11:05 +00001249//===----------------------------------------------------------------------===//
1250// ARM VFP Instruction templates.
1251//
1252
David Goodwin81cdd212009-07-10 17:03:29 +00001253// Almost all VFP instructions are predicable.
Owen Anderson651b2302011-07-13 23:22:26 +00001254class VFPI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001255 IndexMode im, Format f, InstrItinClass itin,
1256 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001257 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Jim Grosbach576640f2010-10-12 21:22:40 +00001258 bits<4> p;
1259 let Inst{31-28} = p;
David Goodwin81cdd212009-07-10 17:03:29 +00001260 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001261 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001262 let AsmString = !strconcat(opc, "${p}", asm);
David Goodwin81cdd212009-07-10 17:03:29 +00001263 let Pattern = pattern;
Bill Wendling87240d42010-12-01 21:54:50 +00001264 let PostEncoderMethod = "VFPThumb2PostEncoder";
Owen Andersone0152a72011-08-09 20:55:18 +00001265 let DecoderNamespace = "VFP";
David Goodwin81cdd212009-07-10 17:03:29 +00001266 list<Predicate> Predicates = [HasVFP2];
1267}
1268
1269// Special cases
Owen Anderson651b2302011-07-13 23:22:26 +00001270class VFPXI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001271 IndexMode im, Format f, InstrItinClass itin,
1272 string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001273 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001274 bits<4> p;
1275 let Inst{31-28} = p;
David Goodwin81cdd212009-07-10 17:03:29 +00001276 let OutOperandList = oops;
1277 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001278 let AsmString = asm;
David Goodwin81cdd212009-07-10 17:03:29 +00001279 let Pattern = pattern;
Bill Wendling87240d42010-12-01 21:54:50 +00001280 let PostEncoderMethod = "VFPThumb2PostEncoder";
Owen Andersone0152a72011-08-09 20:55:18 +00001281 let DecoderNamespace = "VFP";
David Goodwin81cdd212009-07-10 17:03:29 +00001282 list<Predicate> Predicates = [HasVFP2];
1283}
1284
David Goodwinb062c232009-08-06 16:52:47 +00001285class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1286 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001287 : VFPI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
Bill Wendling87240d42010-12-01 21:54:50 +00001288 opc, asm, "", pattern> {
1289 let PostEncoderMethod = "VFPThumb2PostEncoder";
1290}
David Goodwin81cdd212009-07-10 17:03:29 +00001291
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001292// ARM VFP addrmode5 loads and stores
1293class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001294 InstrItinClass itin,
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001295 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001296 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001297 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendlingc0024632010-11-04 00:59:42 +00001298 // Instruction operands.
1299 bits<5> Dd;
1300 bits<13> addr;
1301
1302 // Encode instruction operands.
1303 let Inst{23} = addr{8}; // U (add = (U == '1'))
1304 let Inst{22} = Dd{4};
1305 let Inst{19-16} = addr{12-9}; // Rn
1306 let Inst{15-12} = Dd{3-0};
1307 let Inst{7-0} = addr{7-0}; // imm8
1308
Evan Chengac2af2f2008-11-11 02:11:05 +00001309 // TODO: Mark the instructions with the appropriate subtarget info.
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001310 let Inst{27-24} = opcod1;
1311 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001312 let Inst{11-9} = 0b101;
1313 let Inst{8} = 1; // Double precision
Anton Korobeynikov8cce1eb2009-11-02 00:11:06 +00001314
Evan Cheng4a8c43f2011-02-16 00:35:02 +00001315 // Loads & stores operate on both NEON and VFP pipelines.
Jakob Stoklund Olesenb93331f2010-04-05 03:10:20 +00001316 let D = VFPNeonDomain;
Evan Chengac2af2f2008-11-11 02:11:05 +00001317}
1318
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001319class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001320 InstrItinClass itin,
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001321 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001322 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001323 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendlingc0024632010-11-04 00:59:42 +00001324 // Instruction operands.
1325 bits<5> Sd;
1326 bits<13> addr;
1327
1328 // Encode instruction operands.
1329 let Inst{23} = addr{8}; // U (add = (U == '1'))
1330 let Inst{22} = Sd{0};
1331 let Inst{19-16} = addr{12-9}; // Rn
1332 let Inst{15-12} = Sd{4-1};
1333 let Inst{7-0} = addr{7-0}; // imm8
1334
Evan Chengac2af2f2008-11-11 02:11:05 +00001335 // TODO: Mark the instructions with the appropriate subtarget info.
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001336 let Inst{27-24} = opcod1;
1337 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001338 let Inst{11-9} = 0b101;
1339 let Inst{8} = 0; // Single precision
Evan Cheng4a8c43f2011-02-16 00:35:02 +00001340
1341 // Loads & stores operate on both NEON and VFP pipelines.
1342 let D = VFPNeonDomain;
Evan Chengac2af2f2008-11-11 02:11:05 +00001343}
1344
Bob Wilson6b853c32010-09-16 00:31:02 +00001345// VFP Load / store multiple pseudo instructions.
1346class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1347 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001348 : InstARM<AddrMode4, 4, IndexModeNone, Pseudo, VFPNeonDomain,
Bob Wilson6b853c32010-09-16 00:31:02 +00001349 cstr, itin> {
1350 let OutOperandList = oops;
1351 let InOperandList = !con(iops, (ins pred:$p));
1352 let Pattern = pattern;
1353 list<Predicate> Predicates = [HasVFP2];
1354}
1355
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001356// Load / store multiple
Jim Grosbachabcbe242010-09-08 00:25:50 +00001357class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson947f04b2010-03-13 01:08:20 +00001358 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001359 : VFPXI<oops, iops, AddrMode4, 4, im,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001360 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001361 // Instruction operands.
1362 bits<4> Rn;
1363 bits<13> regs;
1364
1365 // Encode instruction operands.
1366 let Inst{19-16} = Rn;
1367 let Inst{22} = regs{12};
1368 let Inst{15-12} = regs{11-8};
1369 let Inst{7-0} = regs{7-0};
1370
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001371 // TODO: Mark the instructions with the appropriate subtarget info.
1372 let Inst{27-25} = 0b110;
Bill Wendling98c29d72010-10-12 22:03:19 +00001373 let Inst{11-9} = 0b101;
1374 let Inst{8} = 1; // Double precision
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001375}
1376
Jim Grosbachabcbe242010-09-08 00:25:50 +00001377class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson947f04b2010-03-13 01:08:20 +00001378 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001379 : VFPXI<oops, iops, AddrMode4, 4, im,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001380 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001381 // Instruction operands.
1382 bits<4> Rn;
1383 bits<13> regs;
1384
1385 // Encode instruction operands.
1386 let Inst{19-16} = Rn;
1387 let Inst{22} = regs{8};
1388 let Inst{15-12} = regs{12-9};
1389 let Inst{7-0} = regs{7-0};
1390
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001391 // TODO: Mark the instructions with the appropriate subtarget info.
1392 let Inst{27-25} = 0b110;
Bill Wendling98c29d72010-10-12 22:03:19 +00001393 let Inst{11-9} = 0b101;
1394 let Inst{8} = 0; // Single precision
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001395}
1396
Evan Chengac2af2f2008-11-11 02:11:05 +00001397// Double precision, unary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001398class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1399 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1400 string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001401 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001402 // Instruction operands.
1403 bits<5> Dd;
1404 bits<5> Dm;
1405
1406 // Encode instruction operands.
1407 let Inst{3-0} = Dm{3-0};
1408 let Inst{5} = Dm{4};
1409 let Inst{15-12} = Dd{3-0};
1410 let Inst{22} = Dd{4};
1411
Johnny Chen34a6afc2010-01-29 23:21:10 +00001412 let Inst{27-23} = opcod1;
1413 let Inst{21-20} = opcod2;
1414 let Inst{19-16} = opcod3;
Bill Wendling98c29d72010-10-12 22:03:19 +00001415 let Inst{11-9} = 0b101;
1416 let Inst{8} = 1; // Double precision
Johnny Chen34a6afc2010-01-29 23:21:10 +00001417 let Inst{7-6} = opcod4;
1418 let Inst{4} = opcod5;
Evan Chengac2af2f2008-11-11 02:11:05 +00001419}
1420
1421// Double precision, binary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001422class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001423 dag iops, InstrItinClass itin, string opc, string asm,
1424 list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001425 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001426 // Instruction operands.
1427 bits<5> Dd;
1428 bits<5> Dn;
1429 bits<5> Dm;
1430
1431 // Encode instruction operands.
1432 let Inst{3-0} = Dm{3-0};
1433 let Inst{5} = Dm{4};
1434 let Inst{19-16} = Dn{3-0};
1435 let Inst{7} = Dn{4};
1436 let Inst{15-12} = Dd{3-0};
1437 let Inst{22} = Dd{4};
1438
Johnny Chen34a6afc2010-01-29 23:21:10 +00001439 let Inst{27-23} = opcod1;
1440 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001441 let Inst{11-9} = 0b101;
1442 let Inst{8} = 1; // Double precision
Bill Wendlingb70dc872010-08-31 07:50:46 +00001443 let Inst{6} = op6;
1444 let Inst{4} = op4;
Evan Chengac2af2f2008-11-11 02:11:05 +00001445}
1446
1447// Single precision, unary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001448class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1449 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1450 string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001451 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001452 // Instruction operands.
1453 bits<5> Sd;
1454 bits<5> Sm;
1455
1456 // Encode instruction operands.
1457 let Inst{3-0} = Sm{4-1};
1458 let Inst{5} = Sm{0};
1459 let Inst{15-12} = Sd{4-1};
1460 let Inst{22} = Sd{0};
1461
Johnny Chen34a6afc2010-01-29 23:21:10 +00001462 let Inst{27-23} = opcod1;
1463 let Inst{21-20} = opcod2;
1464 let Inst{19-16} = opcod3;
Bill Wendling98c29d72010-10-12 22:03:19 +00001465 let Inst{11-9} = 0b101;
1466 let Inst{8} = 0; // Single precision
Johnny Chen34a6afc2010-01-29 23:21:10 +00001467 let Inst{7-6} = opcod4;
1468 let Inst{4} = opcod5;
Evan Chengac2af2f2008-11-11 02:11:05 +00001469}
1470
Bill Wendlingcbb08ca2010-12-01 02:42:55 +00001471// Single precision unary, if no NEON. Same as ASuI except not available if
1472// NEON is enabled.
Johnny Chen34a6afc2010-01-29 23:21:10 +00001473class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1474 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1475 string asm, list<dag> pattern>
1476 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1477 pattern> {
David Goodwin30bf6252009-08-04 20:39:05 +00001478 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1479}
1480
Evan Chengac2af2f2008-11-11 02:11:05 +00001481// Single precision, binary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001482class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1483 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001484 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001485 // Instruction operands.
1486 bits<5> Sd;
1487 bits<5> Sn;
1488 bits<5> Sm;
1489
1490 // Encode instruction operands.
1491 let Inst{3-0} = Sm{4-1};
1492 let Inst{5} = Sm{0};
1493 let Inst{19-16} = Sn{4-1};
1494 let Inst{7} = Sn{0};
1495 let Inst{15-12} = Sd{4-1};
1496 let Inst{22} = Sd{0};
1497
Johnny Chen34a6afc2010-01-29 23:21:10 +00001498 let Inst{27-23} = opcod1;
1499 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001500 let Inst{11-9} = 0b101;
1501 let Inst{8} = 0; // Single precision
Bill Wendlingb70dc872010-08-31 07:50:46 +00001502 let Inst{6} = op6;
1503 let Inst{4} = op4;
Evan Chengac2af2f2008-11-11 02:11:05 +00001504}
1505
Bill Wendlingcbb08ca2010-12-01 02:42:55 +00001506// Single precision binary, if no NEON. Same as ASbI except not available if
1507// NEON is enabled.
Johnny Chen34a6afc2010-01-29 23:21:10 +00001508class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001509 dag iops, InstrItinClass itin, string opc, string asm,
1510 list<dag> pattern>
Johnny Chen34a6afc2010-01-29 23:21:10 +00001511 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
David Goodwin3b9c52c2009-08-04 17:53:06 +00001512 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
Bill Wendling26233432010-11-01 06:00:39 +00001513
1514 // Instruction operands.
1515 bits<5> Sd;
1516 bits<5> Sn;
1517 bits<5> Sm;
1518
1519 // Encode instruction operands.
1520 let Inst{3-0} = Sm{4-1};
1521 let Inst{5} = Sm{0};
1522 let Inst{19-16} = Sn{4-1};
1523 let Inst{7} = Sn{0};
1524 let Inst{15-12} = Sd{4-1};
1525 let Inst{22} = Sd{0};
David Goodwin3b9c52c2009-08-04 17:53:06 +00001526}
1527
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001528// VFP conversion instructions
Johnny Chen34a6afc2010-01-29 23:21:10 +00001529class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1530 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1531 list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001532 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
Johnny Chen34a6afc2010-01-29 23:21:10 +00001533 let Inst{27-23} = opcod1;
1534 let Inst{21-20} = opcod2;
1535 let Inst{19-16} = opcod3;
1536 let Inst{11-8} = opcod4;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001537 let Inst{6} = 1;
Johnny Chen34a6afc2010-01-29 23:21:10 +00001538 let Inst{4} = 0;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001539}
1540
Johnny Chen39640592010-02-11 18:47:03 +00001541// VFP conversion between floating-point and fixed-point
1542class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001543 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1544 list<dag> pattern>
Johnny Chen39640592010-02-11 18:47:03 +00001545 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
1546 // size (fixed-point number): sx == 0 ? 16 : 32
1547 let Inst{7} = op5; // sx
1548}
1549
David Goodwin85b5b022009-08-10 22:17:39 +00001550// VFP conversion instructions, if no NEON
Johnny Chen34a6afc2010-01-29 23:21:10 +00001551class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
David Goodwin85b5b022009-08-10 22:17:39 +00001552 dag oops, dag iops, InstrItinClass itin,
1553 string opc, string asm, list<dag> pattern>
Johnny Chen34a6afc2010-01-29 23:21:10 +00001554 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
1555 pattern> {
David Goodwin85b5b022009-08-10 22:17:39 +00001556 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1557}
1558
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001559class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
David Goodwinb062c232009-08-06 16:52:47 +00001560 InstrItinClass itin,
1561 string opc, string asm, list<dag> pattern>
1562 : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001563 let Inst{27-20} = opcod1;
Evan Cheng38c9a142008-11-11 19:40:26 +00001564 let Inst{11-8} = opcod2;
1565 let Inst{4} = 1;
1566}
1567
David Goodwinb062c232009-08-06 16:52:47 +00001568class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1569 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1570 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
Evan Cheng97ccab82008-11-11 22:46:12 +00001571
Bob Wilson3968c6a2010-03-23 17:23:59 +00001572class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001573 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1574 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001575
David Goodwinb062c232009-08-06 16:52:47 +00001576class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1577 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1578 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001579
David Goodwinb062c232009-08-06 16:52:47 +00001580class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1581 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1582 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
Evan Cheng38c9a142008-11-11 19:40:26 +00001583
Evan Chengac2af2f2008-11-11 02:11:05 +00001584//===----------------------------------------------------------------------===//
1585
Bob Wilson2e076c42009-06-22 23:27:02 +00001586//===----------------------------------------------------------------------===//
1587// ARM NEON Instruction templates.
1588//
Evan Chengee98fa92008-08-29 06:41:12 +00001589
Johnny Chenf833fad2010-03-20 00:17:00 +00001590class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1591 InstrItinClass itin, string opc, string dt, string asm, string cstr,
1592 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001593 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
Evan Cheng738a97a2009-11-23 21:57:23 +00001594 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001595 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001596 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Cheng738a97a2009-11-23 21:57:23 +00001597 let Pattern = pattern;
1598 list<Predicate> Predicates = [HasNEON];
Owen Andersona6201f02011-08-15 23:38:54 +00001599 let DecoderNamespace = "NEON";
Evan Cheng738a97a2009-11-23 21:57:23 +00001600}
1601
1602// Same as NeonI except it does not have a "data type" specifier.
Johnny Chen020023a2010-03-23 20:40:44 +00001603class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1604 InstrItinClass itin, string opc, string asm, string cstr,
1605 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001606 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
Bob Wilson2e076c42009-06-22 23:27:02 +00001607 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001608 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001609 let AsmString = !strconcat(opc, "${p}", "\t", asm);
Bob Wilson2e076c42009-06-22 23:27:02 +00001610 let Pattern = pattern;
1611 list<Predicate> Predicates = [HasNEON];
Owen Andersona6201f02011-08-15 23:38:54 +00001612 let DecoderNamespace = "NEON";
Evan Chengee98fa92008-08-29 06:41:12 +00001613}
1614
Bob Wilson50820a22009-10-07 21:53:04 +00001615class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1616 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001617 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenf833fad2010-03-20 00:17:00 +00001618 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
1619 cstr, pattern> {
Bob Wilsonf731a2d2009-07-08 18:11:30 +00001620 let Inst{31-24} = 0b11110100;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001621 let Inst{23} = op23;
Jim Grosbach68f495c2009-10-20 00:19:08 +00001622 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001623 let Inst{11-8} = op11_8;
1624 let Inst{7-4} = op7_4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001625
Chris Lattner63274cb2010-11-15 05:19:05 +00001626 let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
Owen Andersonc86a5bd2011-08-10 19:01:10 +00001627 let DecoderNamespace = "NEONLoadStore";
Jim Grosbach5876e412010-11-19 22:42:55 +00001628
Owen Andersonad402342010-11-02 00:05:05 +00001629 bits<5> Vd;
Owen Anderson0ebd1fd2010-11-02 23:47:29 +00001630 bits<6> Rn;
1631 bits<4> Rm;
Jim Grosbach5876e412010-11-19 22:42:55 +00001632
Owen Andersonad402342010-11-02 00:05:05 +00001633 let Inst{22} = Vd{4};
1634 let Inst{15-12} = Vd{3-0};
Owen Anderson0ebd1fd2010-11-02 23:47:29 +00001635 let Inst{19-16} = Rn{3-0};
1636 let Inst{3-0} = Rm{3-0};
Bob Wilsonf731a2d2009-07-08 18:11:30 +00001637}
1638
Owen Anderson9f20daf2010-11-02 20:47:39 +00001639class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1640 dag oops, dag iops, InstrItinClass itin,
1641 string opc, string dt, string asm, string cstr, list<dag> pattern>
1642 : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc,
1643 dt, asm, cstr, pattern> {
1644 bits<3> lane;
1645}
1646
Bob Wilson9392b0e2010-08-25 23:27:42 +00001647class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
Owen Anderson651b2302011-07-13 23:22:26 +00001648 : InstARM<AddrMode6, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
Bob Wilson9392b0e2010-08-25 23:27:42 +00001649 itin> {
1650 let OutOperandList = oops;
1651 let InOperandList = !con(iops, (ins pred:$p));
1652 list<Predicate> Predicates = [HasNEON];
1653}
1654
Jim Grosbach233b3a22010-10-06 20:36:55 +00001655class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
1656 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001657 : InstARM<AddrModeNone, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
Bob Wilsonc597fd3b2010-09-13 23:55:10 +00001658 itin> {
1659 let OutOperandList = oops;
1660 let InOperandList = !con(iops, (ins pred:$p));
Jim Grosbach233b3a22010-10-06 20:36:55 +00001661 let Pattern = pattern;
Bob Wilsonc597fd3b2010-09-13 23:55:10 +00001662 list<Predicate> Predicates = [HasNEON];
1663}
1664
Johnny Chenac5024b2010-03-23 16:43:47 +00001665class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001666 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenac5024b2010-03-23 16:43:47 +00001667 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
1668 pattern> {
Evan Cheng738a97a2009-11-23 21:57:23 +00001669 let Inst{31-25} = 0b1111001;
Chris Lattner63274cb2010-11-15 05:19:05 +00001670 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Owen Andersona6201f02011-08-15 23:38:54 +00001671 let DecoderNamespace = "NEONData";
Evan Cheng738a97a2009-11-23 21:57:23 +00001672}
1673
Johnny Chen020023a2010-03-23 20:40:44 +00001674class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001675 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chen020023a2010-03-23 20:40:44 +00001676 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001677 cstr, pattern> {
Bob Wilson2e076c42009-06-22 23:27:02 +00001678 let Inst{31-25} = 0b1111001;
Owen Andersonb538a222010-12-10 22:32:08 +00001679 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Owen Andersona6201f02011-08-15 23:38:54 +00001680 let DecoderNamespace = "NEONData";
Bob Wilson2e076c42009-06-22 23:27:02 +00001681}
1682
1683// NEON "one register and a modified immediate" format.
1684class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
1685 bit op5, bit op4,
David Goodwinb062c232009-08-06 16:52:47 +00001686 dag oops, dag iops, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001687 string opc, string dt, string asm, string cstr,
1688 list<dag> pattern>
Johnny Chen6a643202010-03-23 23:09:14 +00001689 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00001690 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00001691 let Inst{21-19} = op21_19;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001692 let Inst{11-8} = op11_8;
1693 let Inst{7} = op7;
1694 let Inst{6} = op6;
1695 let Inst{5} = op5;
1696 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001697
Owen Anderson284cb362010-10-26 17:40:54 +00001698 // Instruction operands.
1699 bits<5> Vd;
1700 bits<13> SIMM;
Jim Grosbach5876e412010-11-19 22:42:55 +00001701
Owen Anderson284cb362010-10-26 17:40:54 +00001702 let Inst{15-12} = Vd{3-0};
1703 let Inst{22} = Vd{4};
1704 let Inst{24} = SIMM{7};
1705 let Inst{18-16} = SIMM{6-4};
1706 let Inst{3-0} = SIMM{3-0};
Owen Andersone0152a72011-08-09 20:55:18 +00001707 let DecoderMethod = "DecodeNEONModImmInstruction";
Bob Wilson2e076c42009-06-22 23:27:02 +00001708}
1709
1710// NEON 2 vector register format.
1711class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
1712 bits<5> op11_7, bit op6, bit op4,
David Goodwinb062c232009-08-06 16:52:47 +00001713 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001714 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chen9b1f60a2010-03-24 00:57:50 +00001715 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
Evan Cheng738a97a2009-11-23 21:57:23 +00001716 let Inst{24-23} = op24_23;
1717 let Inst{21-20} = op21_20;
1718 let Inst{19-18} = op19_18;
1719 let Inst{17-16} = op17_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001720 let Inst{11-7} = op11_7;
1721 let Inst{6} = op6;
1722 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001723
Owen Anderson24774462010-10-25 18:43:52 +00001724 // Instruction operands.
1725 bits<5> Vd;
1726 bits<5> Vm;
1727
1728 let Inst{15-12} = Vd{3-0};
1729 let Inst{22} = Vd{4};
1730 let Inst{3-0} = Vm{3-0};
1731 let Inst{5} = Vm{4};
Evan Cheng738a97a2009-11-23 21:57:23 +00001732}
1733
1734// Same as N2V except it doesn't have a datatype suffix.
1735class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001736 bits<5> op11_7, bit op6, bit op4,
1737 dag oops, dag iops, InstrItinClass itin,
1738 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chen9b1f60a2010-03-24 00:57:50 +00001739 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
Bob Wilson2e076c42009-06-22 23:27:02 +00001740 let Inst{24-23} = op24_23;
1741 let Inst{21-20} = op21_20;
1742 let Inst{19-18} = op19_18;
1743 let Inst{17-16} = op17_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001744 let Inst{11-7} = op11_7;
1745 let Inst{6} = op6;
1746 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001747
Owen Anderson24774462010-10-25 18:43:52 +00001748 // Instruction operands.
1749 bits<5> Vd;
1750 bits<5> Vm;
1751
1752 let Inst{15-12} = Vd{3-0};
1753 let Inst{22} = Vd{4};
1754 let Inst{3-0} = Vm{3-0};
1755 let Inst{5} = Vm{4};
Bob Wilson2e076c42009-06-22 23:27:02 +00001756}
1757
1758// NEON 2 vector register with immediate.
Bob Wilsonbd3650c2009-10-21 02:15:46 +00001759class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
Johnny Chend82f9002010-03-25 20:39:04 +00001760 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001761 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chend82f9002010-03-25 20:39:04 +00001762 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00001763 let Inst{24} = op24;
1764 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00001765 let Inst{11-8} = op11_8;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001766 let Inst{7} = op7;
1767 let Inst{6} = op6;
1768 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001769
Owen Anderson3665fee2010-10-26 20:56:57 +00001770 // Instruction operands.
1771 bits<5> Vd;
1772 bits<5> Vm;
1773 bits<6> SIMM;
1774
1775 let Inst{15-12} = Vd{3-0};
1776 let Inst{22} = Vd{4};
1777 let Inst{3-0} = Vm{3-0};
1778 let Inst{5} = Vm{4};
1779 let Inst{21-16} = SIMM{5-0};
Bob Wilson2e076c42009-06-22 23:27:02 +00001780}
1781
Bob Wilsoncf603fb2010-03-27 03:56:52 +00001782// NEON 3 vector register format.
Owen Andersonabda3ca2011-03-30 23:45:29 +00001783
Jim Grosbacheca54e42011-05-19 17:34:53 +00001784class N3VCommon<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1785 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
1786 string opc, string dt, string asm, string cstr,
1787 list<dag> pattern>
Johnny Chen2cf04952010-03-26 21:26:28 +00001788 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00001789 let Inst{24} = op24;
1790 let Inst{23} = op23;
Evan Cheng738a97a2009-11-23 21:57:23 +00001791 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001792 let Inst{11-8} = op11_8;
1793 let Inst{6} = op6;
1794 let Inst{4} = op4;
Owen Andersonabda3ca2011-03-30 23:45:29 +00001795}
1796
1797class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
1798 dag oops, dag iops, Format f, InstrItinClass itin,
1799 string opc, string dt, string asm, string cstr, list<dag> pattern>
1800 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
1801 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Jim Grosbach5876e412010-11-19 22:42:55 +00001802
Owen Anderson9e44cf22010-10-21 20:21:49 +00001803 // Instruction operands.
1804 bits<5> Vd;
1805 bits<5> Vn;
1806 bits<5> Vm;
1807
1808 let Inst{15-12} = Vd{3-0};
1809 let Inst{22} = Vd{4};
1810 let Inst{19-16} = Vn{3-0};
1811 let Inst{7} = Vn{4};
1812 let Inst{3-0} = Vm{3-0};
1813 let Inst{5} = Vm{4};
Evan Cheng738a97a2009-11-23 21:57:23 +00001814}
1815
Jim Grosbacheca54e42011-05-19 17:34:53 +00001816class N3VLane32<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1817 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
1818 string opc, string dt, string asm, string cstr,
1819 list<dag> pattern>
Owen Andersonabda3ca2011-03-30 23:45:29 +00001820 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
1821 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1822
1823 // Instruction operands.
1824 bits<5> Vd;
1825 bits<5> Vn;
1826 bits<5> Vm;
1827 bit lane;
1828
1829 let Inst{15-12} = Vd{3-0};
1830 let Inst{22} = Vd{4};
1831 let Inst{19-16} = Vn{3-0};
1832 let Inst{7} = Vn{4};
1833 let Inst{3-0} = Vm{3-0};
1834 let Inst{5} = lane;
1835}
1836
Jim Grosbacheca54e42011-05-19 17:34:53 +00001837class N3VLane16<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1838 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
1839 string opc, string dt, string asm, string cstr,
1840 list<dag> pattern>
Owen Andersonabda3ca2011-03-30 23:45:29 +00001841 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
1842 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1843
1844 // Instruction operands.
1845 bits<5> Vd;
1846 bits<5> Vn;
1847 bits<5> Vm;
1848 bits<2> lane;
1849
1850 let Inst{15-12} = Vd{3-0};
1851 let Inst{22} = Vd{4};
1852 let Inst{19-16} = Vn{3-0};
1853 let Inst{7} = Vn{4};
1854 let Inst{2-0} = Vm{2-0};
1855 let Inst{5} = lane{1};
1856 let Inst{3} = lane{0};
1857}
1858
Johnny Chen8a687232010-03-23 21:35:03 +00001859// Same as N3V except it doesn't have a data type suffix.
Bob Wilson3968c6a2010-03-23 17:23:59 +00001860class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1861 bit op4,
Bob Wilsoncf603fb2010-03-27 03:56:52 +00001862 dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001863 string opc, string asm, string cstr, list<dag> pattern>
Bob Wilsoncf603fb2010-03-27 03:56:52 +00001864 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00001865 let Inst{24} = op24;
1866 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00001867 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001868 let Inst{11-8} = op11_8;
1869 let Inst{6} = op6;
1870 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001871
Owen Andersondff239c2010-10-25 18:28:30 +00001872 // Instruction operands.
1873 bits<5> Vd;
1874 bits<5> Vn;
1875 bits<5> Vm;
1876
1877 let Inst{15-12} = Vd{3-0};
1878 let Inst{22} = Vd{4};
1879 let Inst{19-16} = Vn{3-0};
1880 let Inst{7} = Vn{4};
1881 let Inst{3-0} = Vm{3-0};
1882 let Inst{5} = Vm{4};
Bob Wilson2e076c42009-06-22 23:27:02 +00001883}
1884
1885// NEON VMOVs between scalar and core registers.
1886class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00001887 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001888 string opc, string dt, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001889 : InstARM<AddrModeNone, 4, IndexModeNone, f, NeonDomain,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001890 "", itin> {
Bob Wilson2e076c42009-06-22 23:27:02 +00001891 let Inst{27-20} = opcod1;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001892 let Inst{11-8} = opcod2;
1893 let Inst{6-5} = opcod3;
1894 let Inst{4} = 1;
Johnny Chen8bca1742011-04-06 18:27:46 +00001895 // A8.6.303, A8.6.328, A8.6.329
1896 let Inst{3-0} = 0b0000;
Evan Cheng738a97a2009-11-23 21:57:23 +00001897
1898 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001899 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001900 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Cheng738a97a2009-11-23 21:57:23 +00001901 let Pattern = pattern;
Bob Wilson2e076c42009-06-22 23:27:02 +00001902 list<Predicate> Predicates = [HasNEON];
Jim Grosbach5876e412010-11-19 22:42:55 +00001903
Chris Lattner63274cb2010-11-15 05:19:05 +00001904 let PostEncoderMethod = "NEONThumb2DupPostEncoder";
Owen Andersonc86a5bd2011-08-10 19:01:10 +00001905 let DecoderNamespace = "NEONDup";
Jim Grosbach5876e412010-11-19 22:42:55 +00001906
Owen Andersoned9652f2010-10-27 21:28:09 +00001907 bits<5> V;
1908 bits<4> R;
Owen Anderson40d24a42010-10-27 19:25:54 +00001909 bits<4> p;
Owen Andersoned9652f2010-10-27 21:28:09 +00001910 bits<4> lane;
Jim Grosbach5876e412010-11-19 22:42:55 +00001911
Owen Anderson40d24a42010-10-27 19:25:54 +00001912 let Inst{31-28} = p{3-0};
Owen Andersoned9652f2010-10-27 21:28:09 +00001913 let Inst{7} = V{4};
1914 let Inst{19-16} = V{3-0};
1915 let Inst{15-12} = R{3-0};
Bob Wilson2e076c42009-06-22 23:27:02 +00001916}
1917class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00001918 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001919 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00001920 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001921 opc, dt, asm, pattern>;
Bob Wilson2e076c42009-06-22 23:27:02 +00001922class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00001923 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001924 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00001925 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001926 opc, dt, asm, pattern>;
Bob Wilson2e076c42009-06-22 23:27:02 +00001927class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00001928 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001929 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00001930 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001931 opc, dt, asm, pattern>;
David Goodwin3b9c52c2009-08-04 17:53:06 +00001932
Johnny Chen45ab3f32010-03-25 17:01:27 +00001933// Vector Duplicate Lane (from scalar to all elements)
1934class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
1935 InstrItinClass itin, string opc, string dt, string asm,
1936 list<dag> pattern>
Johnny Chen91d27742010-03-25 21:49:12 +00001937 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
Johnny Chen45ab3f32010-03-25 17:01:27 +00001938 let Inst{24-23} = 0b11;
1939 let Inst{21-20} = 0b11;
1940 let Inst{19-16} = op19_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001941 let Inst{11-7} = 0b11000;
1942 let Inst{6} = op6;
1943 let Inst{4} = 0;
Jim Grosbach5876e412010-11-19 22:42:55 +00001944
Owen Anderson40d24a42010-10-27 19:25:54 +00001945 bits<5> Vd;
1946 bits<5> Vm;
1947 bits<4> lane;
Jim Grosbach5876e412010-11-19 22:42:55 +00001948
Owen Anderson40d24a42010-10-27 19:25:54 +00001949 let Inst{22} = Vd{4};
1950 let Inst{15-12} = Vd{3-0};
1951 let Inst{5} = Vm{4};
1952 let Inst{3-0} = Vm{3-0};
Johnny Chen45ab3f32010-03-25 17:01:27 +00001953}
1954
David Goodwin3b9c52c2009-08-04 17:53:06 +00001955// NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
1956// for single-precision FP.
1957class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
1958 list<Predicate> Predicates = [HasNEON,UseNEONForFP];
1959}