blob: 67a74e04b1d0b70666b947a1fd99513d0877bcab [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,
Jim Grosbach7db8d692011-09-08 22:07:06 +00001103 string opc, string asm, string cstr, list<dag> pattern>
1104 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
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}
Jim Grosbach7db8d692011-09-08 22:07:06 +00001120class T2Ii8s4post<bit P, bit W, bit isLoad, dag oops, dag iops,
1121 InstrItinClass itin, string opc, string asm, string cstr,
1122 list<dag> pattern>
1123 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
Owen Anderson08d4bb02011-08-04 23:18:05 +00001124 pattern> {
1125 bits<4> Rt;
1126 bits<4> Rt2;
Jim Grosbach7db8d692011-09-08 22:07:06 +00001127 bits<4> addr;
Owen Anderson08d4bb02011-08-04 23:18:05 +00001128 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;
Jim Grosbach7db8d692011-09-08 22:07:06 +00001135 let Inst{19-16} = addr;
Owen Anderson08d4bb02011-08-04 23:18:05 +00001136 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
David Goodwinb062c232009-08-06 16:52:47 +00001141class T2sI<dag oops, dag iops, InstrItinClass itin,
1142 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001143 : Thumb2sI<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
Evan Chengd76f0be2009-06-25 02:08:06 +00001144
David Goodwinb062c232009-08-06 16:52:47 +00001145class T2XI<dag oops, dag iops, InstrItinClass itin,
1146 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001147 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001148class T2JTI<dag oops, dag iops, InstrItinClass itin,
1149 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001150 : Thumb2XI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
Evan Cheng431cf562009-06-23 17:48:47 +00001151
Bruno Cardoso Lopes4d4b4902011-01-20 16:58:48 +00001152// Move to/from coprocessor instructions
Jim Grosbachcabb48d2011-07-13 21:17:59 +00001153class T2Cop<bits<4> opc, dag oops, dag iops, string asm, list<dag> pattern>
Jim Grosbachadb29b62011-07-13 21:14:23 +00001154 : T2XI <oops, iops, NoItinerary, asm, pattern>, Requires<[IsThumb2]> {
Jim Grosbachcabb48d2011-07-13 21:17:59 +00001155 let Inst{31-28} = opc;
Bruno Cardoso Lopes4d4b4902011-01-20 16:58:48 +00001156}
1157
Bob Wilson947f04b2010-03-13 01:08:20 +00001158// Two-address instructions
1159class T2XIt<dag oops, dag iops, InstrItinClass itin,
1160 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001161 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, cstr, pattern>;
Evan Cheng83e0d482009-09-28 09:14:39 +00001162
Jim Grosbachc086f682011-09-08 00:39:19 +00001163// T2Ipreldst - Thumb2 pre-indexed load / store instructions.
1164class T2Ipreldst<bit signed, bits<2> opcod, bit load, bit pre,
Johnny Chenc28e6292009-12-15 17:24:14 +00001165 dag oops, dag iops,
1166 AddrMode am, IndexMode im, InstrItinClass itin,
Evan Cheng84c6cda2009-07-02 07:28:31 +00001167 string opc, string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001168 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng84c6cda2009-07-02 07:28:31 +00001169 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001170 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001171 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng84c6cda2009-07-02 07:28:31 +00001172 let Pattern = pattern;
1173 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001174 let DecoderNamespace = "Thumb2";
Jim Grosbachc086f682011-09-08 00:39:19 +00001175
1176 bits<4> Rt;
1177 bits<13> addr;
Johnny Chenc28e6292009-12-15 17:24:14 +00001178 let Inst{31-27} = 0b11111;
1179 let Inst{26-25} = 0b00;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001180 let Inst{24} = signed;
1181 let Inst{23} = 0;
Johnny Chenc28e6292009-12-15 17:24:14 +00001182 let Inst{22-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001183 let Inst{20} = load;
Jim Grosbachc086f682011-09-08 00:39:19 +00001184 let Inst{19-16} = addr{12-9};
1185 let Inst{15-12} = Rt{3-0};
Bill Wendlingb70dc872010-08-31 07:50:46 +00001186 let Inst{11} = 1;
Johnny Chenc28e6292009-12-15 17:24:14 +00001187 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
Bill Wendlingb70dc872010-08-31 07:50:46 +00001188 let Inst{10} = pre; // The P bit.
Jim Grosbachc086f682011-09-08 00:39:19 +00001189 let Inst{9} = addr{8}; // Sign bit
Bill Wendlingb70dc872010-08-31 07:50:46 +00001190 let Inst{8} = 1; // The W bit.
Jim Grosbachc086f682011-09-08 00:39:19 +00001191 let Inst{7-0} = addr{7-0};
1192}
Jim Grosbachc4669ed2010-12-10 20:47:29 +00001193
Jim Grosbachc086f682011-09-08 00:39:19 +00001194// T2Ipostldst - Thumb2 post-indexed load / store instructions.
1195class T2Ipostldst<bit signed, bits<2> opcod, bit load, bit pre,
1196 dag oops, dag iops,
1197 AddrMode am, IndexMode im, InstrItinClass itin,
1198 string opc, string asm, string cstr, list<dag> pattern>
1199 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
1200 let OutOperandList = oops;
1201 let InOperandList = !con(iops, (ins pred:$p));
1202 let AsmString = !strconcat(opc, "${p}", asm);
1203 let Pattern = pattern;
1204 list<Predicate> Predicates = [IsThumb2];
1205 let DecoderNamespace = "Thumb2";
Jim Grosbachc4669ed2010-12-10 20:47:29 +00001206
Owen Andersone22c7322010-11-30 00:14:31 +00001207 bits<4> Rt;
1208 bits<4> Rn;
Jim Grosbach3343da52011-09-08 01:01:32 +00001209 bits<9> offset;
Jim Grosbachc086f682011-09-08 00:39:19 +00001210 let Inst{31-27} = 0b11111;
1211 let Inst{26-25} = 0b00;
1212 let Inst{24} = signed;
1213 let Inst{23} = 0;
1214 let Inst{22-21} = opcod;
1215 let Inst{20} = load;
1216 let Inst{19-16} = Rn;
Owen Andersone22c7322010-11-30 00:14:31 +00001217 let Inst{15-12} = Rt{3-0};
Jim Grosbachc086f682011-09-08 00:39:19 +00001218 let Inst{11} = 1;
1219 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1220 let Inst{10} = pre; // The P bit.
Jim Grosbach3343da52011-09-08 01:01:32 +00001221 let Inst{9} = offset{8}; // Sign bit
Jim Grosbachc086f682011-09-08 00:39:19 +00001222 let Inst{8} = 1; // The W bit.
Jim Grosbach3343da52011-09-08 01:01:32 +00001223 let Inst{7-0} = offset{7-0};
Evan Cheng84c6cda2009-07-02 07:28:31 +00001224}
1225
David Goodwine5b969f2009-07-27 19:59:26 +00001226// Tv5Pat - Same as Pat<>, but requires V5T Thumb mode.
1227class Tv5Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001228 list<Predicate> Predicates = [IsThumb, IsThumb1Only, HasV5T];
David Goodwine5b969f2009-07-27 19:59:26 +00001229}
1230
1231// T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1232class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001233 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
David Goodwine5b969f2009-07-27 19:59:26 +00001234}
Evan Cheng84c6cda2009-07-02 07:28:31 +00001235
Bruno Cardoso Lopes168c9002011-05-03 17:29:22 +00001236// T2v6Pat - Same as Pat<>, but requires V6T2 Thumb2 mode.
1237class T2v6Pat<dag pattern, dag result> : Pat<pattern, result> {
1238 list<Predicate> Predicates = [IsThumb2, HasV6T2];
1239}
1240
Evan Chengeab9ca72009-06-27 02:26:13 +00001241// T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1242class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
Evan Cheng2c450d32009-07-02 06:38:40 +00001243 list<Predicate> Predicates = [IsThumb2];
Evan Cheng431cf562009-06-23 17:48:47 +00001244}
1245
Evan Chengee98fa92008-08-29 06:41:12 +00001246//===----------------------------------------------------------------------===//
1247
Evan Chengac2af2f2008-11-11 02:11:05 +00001248//===----------------------------------------------------------------------===//
1249// ARM VFP Instruction templates.
1250//
1251
David Goodwin81cdd212009-07-10 17:03:29 +00001252// Almost all VFP instructions are predicable.
Owen Anderson651b2302011-07-13 23:22:26 +00001253class VFPI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001254 IndexMode im, Format f, InstrItinClass itin,
1255 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001256 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Jim Grosbach576640f2010-10-12 21:22:40 +00001257 bits<4> p;
1258 let Inst{31-28} = p;
David Goodwin81cdd212009-07-10 17:03:29 +00001259 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001260 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001261 let AsmString = !strconcat(opc, "${p}", asm);
David Goodwin81cdd212009-07-10 17:03:29 +00001262 let Pattern = pattern;
Bill Wendling87240d42010-12-01 21:54:50 +00001263 let PostEncoderMethod = "VFPThumb2PostEncoder";
Owen Andersone0152a72011-08-09 20:55:18 +00001264 let DecoderNamespace = "VFP";
David Goodwin81cdd212009-07-10 17:03:29 +00001265 list<Predicate> Predicates = [HasVFP2];
1266}
1267
1268// Special cases
Owen Anderson651b2302011-07-13 23:22:26 +00001269class VFPXI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001270 IndexMode im, Format f, InstrItinClass itin,
1271 string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001272 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001273 bits<4> p;
1274 let Inst{31-28} = p;
David Goodwin81cdd212009-07-10 17:03:29 +00001275 let OutOperandList = oops;
1276 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001277 let AsmString = asm;
David Goodwin81cdd212009-07-10 17:03:29 +00001278 let Pattern = pattern;
Bill Wendling87240d42010-12-01 21:54:50 +00001279 let PostEncoderMethod = "VFPThumb2PostEncoder";
Owen Andersone0152a72011-08-09 20:55:18 +00001280 let DecoderNamespace = "VFP";
David Goodwin81cdd212009-07-10 17:03:29 +00001281 list<Predicate> Predicates = [HasVFP2];
1282}
1283
David Goodwinb062c232009-08-06 16:52:47 +00001284class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1285 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001286 : VFPI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
Bill Wendling87240d42010-12-01 21:54:50 +00001287 opc, asm, "", pattern> {
1288 let PostEncoderMethod = "VFPThumb2PostEncoder";
1289}
David Goodwin81cdd212009-07-10 17:03:29 +00001290
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001291// ARM VFP addrmode5 loads and stores
1292class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001293 InstrItinClass itin,
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001294 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001295 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001296 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendlingc0024632010-11-04 00:59:42 +00001297 // Instruction operands.
1298 bits<5> Dd;
1299 bits<13> addr;
1300
1301 // Encode instruction operands.
1302 let Inst{23} = addr{8}; // U (add = (U == '1'))
1303 let Inst{22} = Dd{4};
1304 let Inst{19-16} = addr{12-9}; // Rn
1305 let Inst{15-12} = Dd{3-0};
1306 let Inst{7-0} = addr{7-0}; // imm8
1307
Evan Chengac2af2f2008-11-11 02:11:05 +00001308 // TODO: Mark the instructions with the appropriate subtarget info.
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001309 let Inst{27-24} = opcod1;
1310 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001311 let Inst{11-9} = 0b101;
1312 let Inst{8} = 1; // Double precision
Anton Korobeynikov8cce1eb2009-11-02 00:11:06 +00001313
Evan Cheng4a8c43f2011-02-16 00:35:02 +00001314 // Loads & stores operate on both NEON and VFP pipelines.
Jakob Stoklund Olesenb93331f2010-04-05 03:10:20 +00001315 let D = VFPNeonDomain;
Evan Chengac2af2f2008-11-11 02:11:05 +00001316}
1317
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001318class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001319 InstrItinClass itin,
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001320 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001321 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001322 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendlingc0024632010-11-04 00:59:42 +00001323 // Instruction operands.
1324 bits<5> Sd;
1325 bits<13> addr;
1326
1327 // Encode instruction operands.
1328 let Inst{23} = addr{8}; // U (add = (U == '1'))
1329 let Inst{22} = Sd{0};
1330 let Inst{19-16} = addr{12-9}; // Rn
1331 let Inst{15-12} = Sd{4-1};
1332 let Inst{7-0} = addr{7-0}; // imm8
1333
Evan Chengac2af2f2008-11-11 02:11:05 +00001334 // TODO: Mark the instructions with the appropriate subtarget info.
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001335 let Inst{27-24} = opcod1;
1336 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001337 let Inst{11-9} = 0b101;
1338 let Inst{8} = 0; // Single precision
Evan Cheng4a8c43f2011-02-16 00:35:02 +00001339
1340 // Loads & stores operate on both NEON and VFP pipelines.
1341 let D = VFPNeonDomain;
Evan Chengac2af2f2008-11-11 02:11:05 +00001342}
1343
Bob Wilson6b853c32010-09-16 00:31:02 +00001344// VFP Load / store multiple pseudo instructions.
1345class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1346 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001347 : InstARM<AddrMode4, 4, IndexModeNone, Pseudo, VFPNeonDomain,
Bob Wilson6b853c32010-09-16 00:31:02 +00001348 cstr, itin> {
1349 let OutOperandList = oops;
1350 let InOperandList = !con(iops, (ins pred:$p));
1351 let Pattern = pattern;
1352 list<Predicate> Predicates = [HasVFP2];
1353}
1354
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001355// Load / store multiple
Jim Grosbachabcbe242010-09-08 00:25:50 +00001356class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson947f04b2010-03-13 01:08:20 +00001357 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001358 : VFPXI<oops, iops, AddrMode4, 4, im,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001359 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001360 // Instruction operands.
1361 bits<4> Rn;
1362 bits<13> regs;
1363
1364 // Encode instruction operands.
1365 let Inst{19-16} = Rn;
1366 let Inst{22} = regs{12};
1367 let Inst{15-12} = regs{11-8};
1368 let Inst{7-0} = regs{7-0};
1369
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001370 // TODO: Mark the instructions with the appropriate subtarget info.
1371 let Inst{27-25} = 0b110;
Bill Wendling98c29d72010-10-12 22:03:19 +00001372 let Inst{11-9} = 0b101;
1373 let Inst{8} = 1; // Double precision
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001374}
1375
Jim Grosbachabcbe242010-09-08 00:25:50 +00001376class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson947f04b2010-03-13 01:08:20 +00001377 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001378 : VFPXI<oops, iops, AddrMode4, 4, im,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001379 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001380 // Instruction operands.
1381 bits<4> Rn;
1382 bits<13> regs;
1383
1384 // Encode instruction operands.
1385 let Inst{19-16} = Rn;
1386 let Inst{22} = regs{8};
1387 let Inst{15-12} = regs{12-9};
1388 let Inst{7-0} = regs{7-0};
1389
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001390 // TODO: Mark the instructions with the appropriate subtarget info.
1391 let Inst{27-25} = 0b110;
Bill Wendling98c29d72010-10-12 22:03:19 +00001392 let Inst{11-9} = 0b101;
1393 let Inst{8} = 0; // Single precision
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001394}
1395
Evan Chengac2af2f2008-11-11 02:11:05 +00001396// Double precision, unary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001397class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1398 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1399 string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001400 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001401 // Instruction operands.
1402 bits<5> Dd;
1403 bits<5> Dm;
1404
1405 // Encode instruction operands.
1406 let Inst{3-0} = Dm{3-0};
1407 let Inst{5} = Dm{4};
1408 let Inst{15-12} = Dd{3-0};
1409 let Inst{22} = Dd{4};
1410
Johnny Chen34a6afc2010-01-29 23:21:10 +00001411 let Inst{27-23} = opcod1;
1412 let Inst{21-20} = opcod2;
1413 let Inst{19-16} = opcod3;
Bill Wendling98c29d72010-10-12 22:03:19 +00001414 let Inst{11-9} = 0b101;
1415 let Inst{8} = 1; // Double precision
Johnny Chen34a6afc2010-01-29 23:21:10 +00001416 let Inst{7-6} = opcod4;
1417 let Inst{4} = opcod5;
Evan Chengac2af2f2008-11-11 02:11:05 +00001418}
1419
1420// Double precision, binary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001421class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001422 dag iops, InstrItinClass itin, string opc, string asm,
1423 list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001424 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001425 // Instruction operands.
1426 bits<5> Dd;
1427 bits<5> Dn;
1428 bits<5> Dm;
1429
1430 // Encode instruction operands.
1431 let Inst{3-0} = Dm{3-0};
1432 let Inst{5} = Dm{4};
1433 let Inst{19-16} = Dn{3-0};
1434 let Inst{7} = Dn{4};
1435 let Inst{15-12} = Dd{3-0};
1436 let Inst{22} = Dd{4};
1437
Johnny Chen34a6afc2010-01-29 23:21:10 +00001438 let Inst{27-23} = opcod1;
1439 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001440 let Inst{11-9} = 0b101;
1441 let Inst{8} = 1; // Double precision
Bill Wendlingb70dc872010-08-31 07:50:46 +00001442 let Inst{6} = op6;
1443 let Inst{4} = op4;
Evan Chengac2af2f2008-11-11 02:11:05 +00001444}
1445
1446// Single precision, unary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001447class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1448 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1449 string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001450 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001451 // Instruction operands.
1452 bits<5> Sd;
1453 bits<5> Sm;
1454
1455 // Encode instruction operands.
1456 let Inst{3-0} = Sm{4-1};
1457 let Inst{5} = Sm{0};
1458 let Inst{15-12} = Sd{4-1};
1459 let Inst{22} = Sd{0};
1460
Johnny Chen34a6afc2010-01-29 23:21:10 +00001461 let Inst{27-23} = opcod1;
1462 let Inst{21-20} = opcod2;
1463 let Inst{19-16} = opcod3;
Bill Wendling98c29d72010-10-12 22:03:19 +00001464 let Inst{11-9} = 0b101;
1465 let Inst{8} = 0; // Single precision
Johnny Chen34a6afc2010-01-29 23:21:10 +00001466 let Inst{7-6} = opcod4;
1467 let Inst{4} = opcod5;
Evan Chengac2af2f2008-11-11 02:11:05 +00001468}
1469
Bill Wendlingcbb08ca2010-12-01 02:42:55 +00001470// Single precision unary, if no NEON. Same as ASuI except not available if
1471// NEON is enabled.
Johnny Chen34a6afc2010-01-29 23:21:10 +00001472class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1473 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1474 string asm, list<dag> pattern>
1475 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1476 pattern> {
David Goodwin30bf6252009-08-04 20:39:05 +00001477 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1478}
1479
Evan Chengac2af2f2008-11-11 02:11:05 +00001480// Single precision, binary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001481class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1482 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001483 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001484 // Instruction operands.
1485 bits<5> Sd;
1486 bits<5> Sn;
1487 bits<5> Sm;
1488
1489 // Encode instruction operands.
1490 let Inst{3-0} = Sm{4-1};
1491 let Inst{5} = Sm{0};
1492 let Inst{19-16} = Sn{4-1};
1493 let Inst{7} = Sn{0};
1494 let Inst{15-12} = Sd{4-1};
1495 let Inst{22} = Sd{0};
1496
Johnny Chen34a6afc2010-01-29 23:21:10 +00001497 let Inst{27-23} = opcod1;
1498 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001499 let Inst{11-9} = 0b101;
1500 let Inst{8} = 0; // Single precision
Bill Wendlingb70dc872010-08-31 07:50:46 +00001501 let Inst{6} = op6;
1502 let Inst{4} = op4;
Evan Chengac2af2f2008-11-11 02:11:05 +00001503}
1504
Bill Wendlingcbb08ca2010-12-01 02:42:55 +00001505// Single precision binary, if no NEON. Same as ASbI except not available if
1506// NEON is enabled.
Johnny Chen34a6afc2010-01-29 23:21:10 +00001507class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001508 dag iops, InstrItinClass itin, string opc, string asm,
1509 list<dag> pattern>
Johnny Chen34a6afc2010-01-29 23:21:10 +00001510 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
David Goodwin3b9c52c2009-08-04 17:53:06 +00001511 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
Bill Wendling26233432010-11-01 06:00:39 +00001512
1513 // Instruction operands.
1514 bits<5> Sd;
1515 bits<5> Sn;
1516 bits<5> Sm;
1517
1518 // Encode instruction operands.
1519 let Inst{3-0} = Sm{4-1};
1520 let Inst{5} = Sm{0};
1521 let Inst{19-16} = Sn{4-1};
1522 let Inst{7} = Sn{0};
1523 let Inst{15-12} = Sd{4-1};
1524 let Inst{22} = Sd{0};
David Goodwin3b9c52c2009-08-04 17:53:06 +00001525}
1526
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001527// VFP conversion instructions
Johnny Chen34a6afc2010-01-29 23:21:10 +00001528class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1529 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1530 list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001531 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
Johnny Chen34a6afc2010-01-29 23:21:10 +00001532 let Inst{27-23} = opcod1;
1533 let Inst{21-20} = opcod2;
1534 let Inst{19-16} = opcod3;
1535 let Inst{11-8} = opcod4;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001536 let Inst{6} = 1;
Johnny Chen34a6afc2010-01-29 23:21:10 +00001537 let Inst{4} = 0;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001538}
1539
Johnny Chen39640592010-02-11 18:47:03 +00001540// VFP conversion between floating-point and fixed-point
1541class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001542 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1543 list<dag> pattern>
Johnny Chen39640592010-02-11 18:47:03 +00001544 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
1545 // size (fixed-point number): sx == 0 ? 16 : 32
1546 let Inst{7} = op5; // sx
1547}
1548
David Goodwin85b5b022009-08-10 22:17:39 +00001549// VFP conversion instructions, if no NEON
Johnny Chen34a6afc2010-01-29 23:21:10 +00001550class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
David Goodwin85b5b022009-08-10 22:17:39 +00001551 dag oops, dag iops, InstrItinClass itin,
1552 string opc, string asm, list<dag> pattern>
Johnny Chen34a6afc2010-01-29 23:21:10 +00001553 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
1554 pattern> {
David Goodwin85b5b022009-08-10 22:17:39 +00001555 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1556}
1557
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001558class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
David Goodwinb062c232009-08-06 16:52:47 +00001559 InstrItinClass itin,
1560 string opc, string asm, list<dag> pattern>
1561 : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001562 let Inst{27-20} = opcod1;
Evan Cheng38c9a142008-11-11 19:40:26 +00001563 let Inst{11-8} = opcod2;
1564 let Inst{4} = 1;
1565}
1566
David Goodwinb062c232009-08-06 16:52:47 +00001567class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1568 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1569 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
Evan Cheng97ccab82008-11-11 22:46:12 +00001570
Bob Wilson3968c6a2010-03-23 17:23:59 +00001571class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001572 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1573 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001574
David Goodwinb062c232009-08-06 16:52:47 +00001575class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1576 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1577 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001578
David Goodwinb062c232009-08-06 16:52:47 +00001579class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1580 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1581 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
Evan Cheng38c9a142008-11-11 19:40:26 +00001582
Evan Chengac2af2f2008-11-11 02:11:05 +00001583//===----------------------------------------------------------------------===//
1584
Bob Wilson2e076c42009-06-22 23:27:02 +00001585//===----------------------------------------------------------------------===//
1586// ARM NEON Instruction templates.
1587//
Evan Chengee98fa92008-08-29 06:41:12 +00001588
Johnny Chenf833fad2010-03-20 00:17:00 +00001589class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1590 InstrItinClass itin, string opc, string dt, string asm, string cstr,
1591 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001592 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
Evan Cheng738a97a2009-11-23 21:57:23 +00001593 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001594 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001595 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Cheng738a97a2009-11-23 21:57:23 +00001596 let Pattern = pattern;
1597 list<Predicate> Predicates = [HasNEON];
Owen Andersona6201f02011-08-15 23:38:54 +00001598 let DecoderNamespace = "NEON";
Evan Cheng738a97a2009-11-23 21:57:23 +00001599}
1600
1601// Same as NeonI except it does not have a "data type" specifier.
Johnny Chen020023a2010-03-23 20:40:44 +00001602class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1603 InstrItinClass itin, string opc, string asm, string cstr,
1604 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001605 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
Bob Wilson2e076c42009-06-22 23:27:02 +00001606 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001607 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001608 let AsmString = !strconcat(opc, "${p}", "\t", asm);
Bob Wilson2e076c42009-06-22 23:27:02 +00001609 let Pattern = pattern;
1610 list<Predicate> Predicates = [HasNEON];
Owen Andersona6201f02011-08-15 23:38:54 +00001611 let DecoderNamespace = "NEON";
Evan Chengee98fa92008-08-29 06:41:12 +00001612}
1613
Bob Wilson50820a22009-10-07 21:53:04 +00001614class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1615 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001616 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenf833fad2010-03-20 00:17:00 +00001617 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
1618 cstr, pattern> {
Bob Wilsonf731a2d2009-07-08 18:11:30 +00001619 let Inst{31-24} = 0b11110100;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001620 let Inst{23} = op23;
Jim Grosbach68f495c2009-10-20 00:19:08 +00001621 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001622 let Inst{11-8} = op11_8;
1623 let Inst{7-4} = op7_4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001624
Chris Lattner63274cb2010-11-15 05:19:05 +00001625 let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
Owen Andersonc86a5bd2011-08-10 19:01:10 +00001626 let DecoderNamespace = "NEONLoadStore";
Jim Grosbach5876e412010-11-19 22:42:55 +00001627
Owen Andersonad402342010-11-02 00:05:05 +00001628 bits<5> Vd;
Owen Anderson0ebd1fd2010-11-02 23:47:29 +00001629 bits<6> Rn;
1630 bits<4> Rm;
Jim Grosbach5876e412010-11-19 22:42:55 +00001631
Owen Andersonad402342010-11-02 00:05:05 +00001632 let Inst{22} = Vd{4};
1633 let Inst{15-12} = Vd{3-0};
Owen Anderson0ebd1fd2010-11-02 23:47:29 +00001634 let Inst{19-16} = Rn{3-0};
1635 let Inst{3-0} = Rm{3-0};
Bob Wilsonf731a2d2009-07-08 18:11:30 +00001636}
1637
Owen Anderson9f20daf2010-11-02 20:47:39 +00001638class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1639 dag oops, dag iops, InstrItinClass itin,
1640 string opc, string dt, string asm, string cstr, list<dag> pattern>
1641 : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc,
1642 dt, asm, cstr, pattern> {
1643 bits<3> lane;
1644}
1645
Bob Wilson9392b0e2010-08-25 23:27:42 +00001646class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
Owen Anderson651b2302011-07-13 23:22:26 +00001647 : InstARM<AddrMode6, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
Bob Wilson9392b0e2010-08-25 23:27:42 +00001648 itin> {
1649 let OutOperandList = oops;
1650 let InOperandList = !con(iops, (ins pred:$p));
1651 list<Predicate> Predicates = [HasNEON];
1652}
1653
Jim Grosbach233b3a22010-10-06 20:36:55 +00001654class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
1655 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001656 : InstARM<AddrModeNone, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
Bob Wilsonc597fd3b2010-09-13 23:55:10 +00001657 itin> {
1658 let OutOperandList = oops;
1659 let InOperandList = !con(iops, (ins pred:$p));
Jim Grosbach233b3a22010-10-06 20:36:55 +00001660 let Pattern = pattern;
Bob Wilsonc597fd3b2010-09-13 23:55:10 +00001661 list<Predicate> Predicates = [HasNEON];
1662}
1663
Johnny Chenac5024b2010-03-23 16:43:47 +00001664class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001665 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenac5024b2010-03-23 16:43:47 +00001666 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
1667 pattern> {
Evan Cheng738a97a2009-11-23 21:57:23 +00001668 let Inst{31-25} = 0b1111001;
Chris Lattner63274cb2010-11-15 05:19:05 +00001669 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Owen Andersona6201f02011-08-15 23:38:54 +00001670 let DecoderNamespace = "NEONData";
Evan Cheng738a97a2009-11-23 21:57:23 +00001671}
1672
Johnny Chen020023a2010-03-23 20:40:44 +00001673class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001674 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chen020023a2010-03-23 20:40:44 +00001675 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001676 cstr, pattern> {
Bob Wilson2e076c42009-06-22 23:27:02 +00001677 let Inst{31-25} = 0b1111001;
Owen Andersonb538a222010-12-10 22:32:08 +00001678 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Owen Andersona6201f02011-08-15 23:38:54 +00001679 let DecoderNamespace = "NEONData";
Bob Wilson2e076c42009-06-22 23:27:02 +00001680}
1681
1682// NEON "one register and a modified immediate" format.
1683class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
1684 bit op5, bit op4,
David Goodwinb062c232009-08-06 16:52:47 +00001685 dag oops, dag iops, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001686 string opc, string dt, string asm, string cstr,
1687 list<dag> pattern>
Johnny Chen6a643202010-03-23 23:09:14 +00001688 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00001689 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00001690 let Inst{21-19} = op21_19;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001691 let Inst{11-8} = op11_8;
1692 let Inst{7} = op7;
1693 let Inst{6} = op6;
1694 let Inst{5} = op5;
1695 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001696
Owen Anderson284cb362010-10-26 17:40:54 +00001697 // Instruction operands.
1698 bits<5> Vd;
1699 bits<13> SIMM;
Jim Grosbach5876e412010-11-19 22:42:55 +00001700
Owen Anderson284cb362010-10-26 17:40:54 +00001701 let Inst{15-12} = Vd{3-0};
1702 let Inst{22} = Vd{4};
1703 let Inst{24} = SIMM{7};
1704 let Inst{18-16} = SIMM{6-4};
1705 let Inst{3-0} = SIMM{3-0};
Owen Andersone0152a72011-08-09 20:55:18 +00001706 let DecoderMethod = "DecodeNEONModImmInstruction";
Bob Wilson2e076c42009-06-22 23:27:02 +00001707}
1708
1709// NEON 2 vector register format.
1710class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
1711 bits<5> op11_7, bit op6, bit op4,
David Goodwinb062c232009-08-06 16:52:47 +00001712 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001713 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chen9b1f60a2010-03-24 00:57:50 +00001714 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
Evan Cheng738a97a2009-11-23 21:57:23 +00001715 let Inst{24-23} = op24_23;
1716 let Inst{21-20} = op21_20;
1717 let Inst{19-18} = op19_18;
1718 let Inst{17-16} = op17_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001719 let Inst{11-7} = op11_7;
1720 let Inst{6} = op6;
1721 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001722
Owen Anderson24774462010-10-25 18:43:52 +00001723 // Instruction operands.
1724 bits<5> Vd;
1725 bits<5> Vm;
1726
1727 let Inst{15-12} = Vd{3-0};
1728 let Inst{22} = Vd{4};
1729 let Inst{3-0} = Vm{3-0};
1730 let Inst{5} = Vm{4};
Evan Cheng738a97a2009-11-23 21:57:23 +00001731}
1732
1733// Same as N2V except it doesn't have a datatype suffix.
1734class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001735 bits<5> op11_7, bit op6, bit op4,
1736 dag oops, dag iops, InstrItinClass itin,
1737 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chen9b1f60a2010-03-24 00:57:50 +00001738 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
Bob Wilson2e076c42009-06-22 23:27:02 +00001739 let Inst{24-23} = op24_23;
1740 let Inst{21-20} = op21_20;
1741 let Inst{19-18} = op19_18;
1742 let Inst{17-16} = op17_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001743 let Inst{11-7} = op11_7;
1744 let Inst{6} = op6;
1745 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001746
Owen Anderson24774462010-10-25 18:43:52 +00001747 // Instruction operands.
1748 bits<5> Vd;
1749 bits<5> Vm;
1750
1751 let Inst{15-12} = Vd{3-0};
1752 let Inst{22} = Vd{4};
1753 let Inst{3-0} = Vm{3-0};
1754 let Inst{5} = Vm{4};
Bob Wilson2e076c42009-06-22 23:27:02 +00001755}
1756
1757// NEON 2 vector register with immediate.
Bob Wilsonbd3650c2009-10-21 02:15:46 +00001758class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
Johnny Chend82f9002010-03-25 20:39:04 +00001759 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001760 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chend82f9002010-03-25 20:39:04 +00001761 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00001762 let Inst{24} = op24;
1763 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00001764 let Inst{11-8} = op11_8;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001765 let Inst{7} = op7;
1766 let Inst{6} = op6;
1767 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001768
Owen Anderson3665fee2010-10-26 20:56:57 +00001769 // Instruction operands.
1770 bits<5> Vd;
1771 bits<5> Vm;
1772 bits<6> SIMM;
1773
1774 let Inst{15-12} = Vd{3-0};
1775 let Inst{22} = Vd{4};
1776 let Inst{3-0} = Vm{3-0};
1777 let Inst{5} = Vm{4};
1778 let Inst{21-16} = SIMM{5-0};
Bob Wilson2e076c42009-06-22 23:27:02 +00001779}
1780
Bob Wilsoncf603fb2010-03-27 03:56:52 +00001781// NEON 3 vector register format.
Owen Andersonabda3ca2011-03-30 23:45:29 +00001782
Jim Grosbacheca54e42011-05-19 17:34:53 +00001783class N3VCommon<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1784 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
1785 string opc, string dt, string asm, string cstr,
1786 list<dag> pattern>
Johnny Chen2cf04952010-03-26 21:26:28 +00001787 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00001788 let Inst{24} = op24;
1789 let Inst{23} = op23;
Evan Cheng738a97a2009-11-23 21:57:23 +00001790 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001791 let Inst{11-8} = op11_8;
1792 let Inst{6} = op6;
1793 let Inst{4} = op4;
Owen Andersonabda3ca2011-03-30 23:45:29 +00001794}
1795
1796class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
1797 dag oops, dag iops, Format f, InstrItinClass itin,
1798 string opc, string dt, string asm, string cstr, list<dag> pattern>
1799 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
1800 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Jim Grosbach5876e412010-11-19 22:42:55 +00001801
Owen Anderson9e44cf22010-10-21 20:21:49 +00001802 // Instruction operands.
1803 bits<5> Vd;
1804 bits<5> Vn;
1805 bits<5> Vm;
1806
1807 let Inst{15-12} = Vd{3-0};
1808 let Inst{22} = Vd{4};
1809 let Inst{19-16} = Vn{3-0};
1810 let Inst{7} = Vn{4};
1811 let Inst{3-0} = Vm{3-0};
1812 let Inst{5} = Vm{4};
Evan Cheng738a97a2009-11-23 21:57:23 +00001813}
1814
Jim Grosbacheca54e42011-05-19 17:34:53 +00001815class N3VLane32<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1816 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
1817 string opc, string dt, string asm, string cstr,
1818 list<dag> pattern>
Owen Andersonabda3ca2011-03-30 23:45:29 +00001819 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
1820 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1821
1822 // Instruction operands.
1823 bits<5> Vd;
1824 bits<5> Vn;
1825 bits<5> Vm;
1826 bit lane;
1827
1828 let Inst{15-12} = Vd{3-0};
1829 let Inst{22} = Vd{4};
1830 let Inst{19-16} = Vn{3-0};
1831 let Inst{7} = Vn{4};
1832 let Inst{3-0} = Vm{3-0};
1833 let Inst{5} = lane;
1834}
1835
Jim Grosbacheca54e42011-05-19 17:34:53 +00001836class N3VLane16<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1837 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
1838 string opc, string dt, string asm, string cstr,
1839 list<dag> pattern>
Owen Andersonabda3ca2011-03-30 23:45:29 +00001840 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
1841 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1842
1843 // Instruction operands.
1844 bits<5> Vd;
1845 bits<5> Vn;
1846 bits<5> Vm;
1847 bits<2> lane;
1848
1849 let Inst{15-12} = Vd{3-0};
1850 let Inst{22} = Vd{4};
1851 let Inst{19-16} = Vn{3-0};
1852 let Inst{7} = Vn{4};
1853 let Inst{2-0} = Vm{2-0};
1854 let Inst{5} = lane{1};
1855 let Inst{3} = lane{0};
1856}
1857
Johnny Chen8a687232010-03-23 21:35:03 +00001858// Same as N3V except it doesn't have a data type suffix.
Bob Wilson3968c6a2010-03-23 17:23:59 +00001859class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1860 bit op4,
Bob Wilsoncf603fb2010-03-27 03:56:52 +00001861 dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001862 string opc, string asm, string cstr, list<dag> pattern>
Bob Wilsoncf603fb2010-03-27 03:56:52 +00001863 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00001864 let Inst{24} = op24;
1865 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00001866 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001867 let Inst{11-8} = op11_8;
1868 let Inst{6} = op6;
1869 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001870
Owen Andersondff239c2010-10-25 18:28:30 +00001871 // Instruction operands.
1872 bits<5> Vd;
1873 bits<5> Vn;
1874 bits<5> Vm;
1875
1876 let Inst{15-12} = Vd{3-0};
1877 let Inst{22} = Vd{4};
1878 let Inst{19-16} = Vn{3-0};
1879 let Inst{7} = Vn{4};
1880 let Inst{3-0} = Vm{3-0};
1881 let Inst{5} = Vm{4};
Bob Wilson2e076c42009-06-22 23:27:02 +00001882}
1883
1884// NEON VMOVs between scalar and core registers.
1885class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00001886 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001887 string opc, string dt, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001888 : InstARM<AddrModeNone, 4, IndexModeNone, f, NeonDomain,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001889 "", itin> {
Bob Wilson2e076c42009-06-22 23:27:02 +00001890 let Inst{27-20} = opcod1;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001891 let Inst{11-8} = opcod2;
1892 let Inst{6-5} = opcod3;
1893 let Inst{4} = 1;
Johnny Chen8bca1742011-04-06 18:27:46 +00001894 // A8.6.303, A8.6.328, A8.6.329
1895 let Inst{3-0} = 0b0000;
Evan Cheng738a97a2009-11-23 21:57:23 +00001896
1897 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001898 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001899 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Cheng738a97a2009-11-23 21:57:23 +00001900 let Pattern = pattern;
Bob Wilson2e076c42009-06-22 23:27:02 +00001901 list<Predicate> Predicates = [HasNEON];
Jim Grosbach5876e412010-11-19 22:42:55 +00001902
Chris Lattner63274cb2010-11-15 05:19:05 +00001903 let PostEncoderMethod = "NEONThumb2DupPostEncoder";
Owen Andersonc86a5bd2011-08-10 19:01:10 +00001904 let DecoderNamespace = "NEONDup";
Jim Grosbach5876e412010-11-19 22:42:55 +00001905
Owen Andersoned9652f2010-10-27 21:28:09 +00001906 bits<5> V;
1907 bits<4> R;
Owen Anderson40d24a42010-10-27 19:25:54 +00001908 bits<4> p;
Owen Andersoned9652f2010-10-27 21:28:09 +00001909 bits<4> lane;
Jim Grosbach5876e412010-11-19 22:42:55 +00001910
Owen Anderson40d24a42010-10-27 19:25:54 +00001911 let Inst{31-28} = p{3-0};
Owen Andersoned9652f2010-10-27 21:28:09 +00001912 let Inst{7} = V{4};
1913 let Inst{19-16} = V{3-0};
1914 let Inst{15-12} = R{3-0};
Bob Wilson2e076c42009-06-22 23:27:02 +00001915}
1916class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00001917 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001918 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00001919 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001920 opc, dt, asm, pattern>;
Bob Wilson2e076c42009-06-22 23:27:02 +00001921class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00001922 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001923 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00001924 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001925 opc, dt, asm, pattern>;
Bob Wilson2e076c42009-06-22 23:27:02 +00001926class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00001927 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001928 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00001929 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001930 opc, dt, asm, pattern>;
David Goodwin3b9c52c2009-08-04 17:53:06 +00001931
Johnny Chen45ab3f32010-03-25 17:01:27 +00001932// Vector Duplicate Lane (from scalar to all elements)
1933class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
1934 InstrItinClass itin, string opc, string dt, string asm,
1935 list<dag> pattern>
Johnny Chen91d27742010-03-25 21:49:12 +00001936 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
Johnny Chen45ab3f32010-03-25 17:01:27 +00001937 let Inst{24-23} = 0b11;
1938 let Inst{21-20} = 0b11;
1939 let Inst{19-16} = op19_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001940 let Inst{11-7} = 0b11000;
1941 let Inst{6} = op6;
1942 let Inst{4} = 0;
Jim Grosbach5876e412010-11-19 22:42:55 +00001943
Owen Anderson40d24a42010-10-27 19:25:54 +00001944 bits<5> Vd;
1945 bits<5> Vm;
1946 bits<4> lane;
Jim Grosbach5876e412010-11-19 22:42:55 +00001947
Owen Anderson40d24a42010-10-27 19:25:54 +00001948 let Inst{22} = Vd{4};
1949 let Inst{15-12} = Vd{3-0};
1950 let Inst{5} = Vm{4};
1951 let Inst{3-0} = Vm{3-0};
Johnny Chen45ab3f32010-03-25 17:01:27 +00001952}
1953
David Goodwin3b9c52c2009-08-04 17:53:06 +00001954// NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
1955// for single-precision FP.
1956class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
1957 list<Predicate> Predicates = [HasNEON,UseNEONForFP];
1958}