• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//===-- SystemZOperands.td - SystemZ instruction operands ----*- tblgen-*--===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10//===----------------------------------------------------------------------===//
11// Class definitions
12//===----------------------------------------------------------------------===//
13
14class ImmediateAsmOperand<string name>
15  : AsmOperandClass {
16  let Name = name;
17  let RenderMethod = "addImmOperands";
18}
19class ImmediateTLSAsmOperand<string name>
20  : AsmOperandClass {
21  let Name = name;
22  let RenderMethod = "addImmTLSOperands";
23}
24
25// Constructs both a DAG pattern and instruction operand for an immediate
26// of type VT.  PRED returns true if a node is acceptable and XFORM returns
27// the operand value associated with the node.  ASMOP is the name of the
28// associated asm operand, and also forms the basis of the asm print method.
29class Immediate<ValueType vt, code pred, SDNodeXForm xform, string asmop>
30  : PatLeaf<(vt imm), pred, xform>, Operand<vt> {
31  let PrintMethod = "print"##asmop##"Operand";
32  let DecoderMethod = "decode"##asmop##"Operand";
33  let ParserMatchClass = !cast<AsmOperandClass>(asmop);
34}
35
36// Constructs an asm operand for a PC-relative address.  SIZE says how
37// many bits there are.
38class PCRelAsmOperand<string size> : ImmediateAsmOperand<"PCRel"##size> {
39  let PredicateMethod = "isImm";
40  let ParserMethod = "parsePCRel"##size;
41}
42class PCRelTLSAsmOperand<string size>
43  : ImmediateTLSAsmOperand<"PCRelTLS"##size> {
44  let PredicateMethod = "isImmTLS";
45  let ParserMethod = "parsePCRelTLS"##size;
46}
47
48// Constructs an operand for a PC-relative address with address type VT.
49// ASMOP is the associated asm operand.
50class PCRelOperand<ValueType vt, AsmOperandClass asmop> : Operand<vt> {
51  let PrintMethod = "printPCRelOperand";
52  let ParserMatchClass = asmop;
53}
54class PCRelTLSOperand<ValueType vt, AsmOperandClass asmop> : Operand<vt> {
55  let PrintMethod = "printPCRelTLSOperand";
56  let ParserMatchClass = asmop;
57}
58
59// Constructs both a DAG pattern and instruction operand for a PC-relative
60// address with address size VT.  SELF is the name of the operand and
61// ASMOP is the associated asm operand.
62class PCRelAddress<ValueType vt, string self, AsmOperandClass asmop>
63  : ComplexPattern<vt, 1, "selectPCRelAddress",
64                   [z_pcrel_wrapper, z_pcrel_offset]>,
65    PCRelOperand<vt, asmop> {
66  let MIOperandInfo = (ops !cast<Operand>(self));
67}
68
69// Constructs an AsmOperandClass for addressing mode FORMAT, treating the
70// registers as having BITSIZE bits and displacements as having DISPSIZE bits.
71// LENGTH is "LenN" for addresses with an N-bit length field, otherwise it
72// is "".
73class AddressAsmOperand<string format, string bitsize, string dispsize,
74                        string length = "">
75  : AsmOperandClass {
76  let Name = format##bitsize##"Disp"##dispsize##length;
77  let ParserMethod = "parse"##format##bitsize;
78  let RenderMethod = "add"##format##"Operands";
79}
80
81// Constructs an instruction operand for an addressing mode.  FORMAT,
82// BITSIZE, DISPSIZE and LENGTH are the parameters to an associated
83// AddressAsmOperand.  OPERANDS is a list of individual operands
84// (base register, displacement, etc.).
85class AddressOperand<string bitsize, string dispsize, string length,
86                     string format, dag operands>
87  : Operand<!cast<ValueType>("i"##bitsize)> {
88  let PrintMethod = "print"##format##"Operand";
89  let EncoderMethod = "get"##format##dispsize##length##"Encoding";
90  let DecoderMethod =
91    "decode"##format##bitsize##"Disp"##dispsize##length##"Operand";
92  let MIOperandInfo = operands;
93  let ParserMatchClass =
94    !cast<AddressAsmOperand>(format##bitsize##"Disp"##dispsize##length);
95}
96
97// Constructs both a DAG pattern and instruction operand for an addressing mode.
98// FORMAT, BITSIZE, DISPSIZE and LENGTH are the parameters to an associated
99// AddressAsmOperand.  OPERANDS is a list of NUMOPS individual operands
100// (base register, displacement, etc.).  SELTYPE is the type of the memory
101// operand for selection purposes; sometimes we want different selection
102// choices for the same underlying addressing mode.  SUFFIX is similarly
103// a suffix appended to the displacement for selection purposes;
104// e.g. we want to reject small 20-bit displacements if a 12-bit form
105// also exists, but we want to accept them otherwise.
106class AddressingMode<string seltype, string bitsize, string dispsize,
107                     string suffix, string length, int numops, string format,
108                     dag operands>
109  : ComplexPattern<!cast<ValueType>("i"##bitsize), numops,
110                   "select"##seltype##dispsize##suffix##length,
111                   [add, sub, or, frameindex, z_adjdynalloc]>,
112    AddressOperand<bitsize, dispsize, length, format, operands>;
113
114// An addressing mode with a base and displacement but no index.
115class BDMode<string type, string bitsize, string dispsize, string suffix>
116  : AddressingMode<type, bitsize, dispsize, suffix, "", 2, "BDAddr",
117                   (ops !cast<RegisterOperand>("ADDR"##bitsize),
118                        !cast<Operand>("disp"##dispsize##"imm"##bitsize))>;
119
120// An addressing mode with a base, displacement and index.
121class BDXMode<string type, string bitsize, string dispsize, string suffix>
122  : AddressingMode<type, bitsize, dispsize, suffix, "", 3, "BDXAddr",
123                   (ops !cast<RegisterOperand>("ADDR"##bitsize),
124                        !cast<Operand>("disp"##dispsize##"imm"##bitsize),
125                        !cast<RegisterOperand>("ADDR"##bitsize))>;
126
127// A BDMode paired with an immediate length operand of LENSIZE bits.
128class BDLMode<string type, string bitsize, string dispsize, string suffix,
129              string lensize>
130  : AddressingMode<type, bitsize, dispsize, suffix, "Len"##lensize, 3,
131                   "BDLAddr",
132                   (ops !cast<RegisterOperand>("ADDR"##bitsize),
133                        !cast<Operand>("disp"##dispsize##"imm"##bitsize),
134                        !cast<Operand>("imm"##bitsize))>;
135
136// A BDMode paired with a register length operand.
137class BDRMode<string type, string bitsize, string dispsize, string suffix>
138  : AddressingMode<type, bitsize, dispsize, suffix, "", 3, "BDRAddr",
139                   (ops !cast<RegisterOperand>("ADDR"##bitsize),
140                        !cast<Operand>("disp"##dispsize##"imm"##bitsize),
141                        !cast<RegisterOperand>("GR"##bitsize))>;
142
143// An addressing mode with a base, displacement and a vector index.
144class BDVMode<string bitsize, string dispsize>
145  : AddressOperand<bitsize, dispsize, "", "BDVAddr",
146                   (ops !cast<RegisterOperand>("ADDR"##bitsize),
147                        !cast<Operand>("disp"##dispsize##"imm"##bitsize),
148                        !cast<RegisterOperand>("VR128"))>;
149
150//===----------------------------------------------------------------------===//
151// Extracting immediate operands from nodes
152// These all create MVT::i64 nodes to ensure the value is not sign-extended
153// when converted from an SDNode to a MachineOperand later on.
154//===----------------------------------------------------------------------===//
155
156// Bits 0-15 (counting from the lsb).
157def LL16 : SDNodeXForm<imm, [{
158  uint64_t Value = N->getZExtValue() & 0x000000000000FFFFULL;
159  return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64);
160}]>;
161
162// Bits 16-31 (counting from the lsb).
163def LH16 : SDNodeXForm<imm, [{
164  uint64_t Value = (N->getZExtValue() & 0x00000000FFFF0000ULL) >> 16;
165  return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64);
166}]>;
167
168// Bits 32-47 (counting from the lsb).
169def HL16 : SDNodeXForm<imm, [{
170  uint64_t Value = (N->getZExtValue() & 0x0000FFFF00000000ULL) >> 32;
171  return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64);
172}]>;
173
174// Bits 48-63 (counting from the lsb).
175def HH16 : SDNodeXForm<imm, [{
176  uint64_t Value = (N->getZExtValue() & 0xFFFF000000000000ULL) >> 48;
177  return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64);
178}]>;
179
180// Low 32 bits.
181def LF32 : SDNodeXForm<imm, [{
182  uint64_t Value = N->getZExtValue() & 0x00000000FFFFFFFFULL;
183  return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64);
184}]>;
185
186// High 32 bits.
187def HF32 : SDNodeXForm<imm, [{
188  uint64_t Value = N->getZExtValue() >> 32;
189  return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64);
190}]>;
191
192// Truncate an immediate to a 8-bit signed quantity.
193def SIMM8 : SDNodeXForm<imm, [{
194  return CurDAG->getTargetConstant(int8_t(N->getZExtValue()), SDLoc(N),
195                                   MVT::i64);
196}]>;
197
198// Truncate an immediate to a 8-bit unsigned quantity.
199def UIMM8 : SDNodeXForm<imm, [{
200  return CurDAG->getTargetConstant(uint8_t(N->getZExtValue()), SDLoc(N),
201                                   MVT::i64);
202}]>;
203
204// Truncate an immediate to a 8-bit unsigned quantity and mask off low bit.
205def UIMM8EVEN : SDNodeXForm<imm, [{
206  return CurDAG->getTargetConstant(N->getZExtValue() & 0xfe, SDLoc(N),
207                                   MVT::i64);
208}]>;
209
210// Truncate an immediate to a 12-bit unsigned quantity.
211def UIMM12 : SDNodeXForm<imm, [{
212  return CurDAG->getTargetConstant(N->getZExtValue() & 0xfff, SDLoc(N),
213                                   MVT::i64);
214}]>;
215
216// Truncate an immediate to a 16-bit signed quantity.
217def SIMM16 : SDNodeXForm<imm, [{
218  return CurDAG->getTargetConstant(int16_t(N->getZExtValue()), SDLoc(N),
219                                   MVT::i64);
220}]>;
221
222// Negate and then truncate an immediate to a 16-bit signed quantity.
223def NEGSIMM16 : SDNodeXForm<imm, [{
224  return CurDAG->getTargetConstant(int16_t(-N->getZExtValue()), SDLoc(N),
225                                   MVT::i64);
226}]>;
227
228// Truncate an immediate to a 16-bit unsigned quantity.
229def UIMM16 : SDNodeXForm<imm, [{
230  return CurDAG->getTargetConstant(uint16_t(N->getZExtValue()), SDLoc(N),
231                                   MVT::i64);
232}]>;
233
234// Truncate an immediate to a 32-bit signed quantity.
235def SIMM32 : SDNodeXForm<imm, [{
236  return CurDAG->getTargetConstant(int32_t(N->getZExtValue()), SDLoc(N),
237                                   MVT::i64);
238}]>;
239
240// Negate and then truncate an immediate to a 32-bit unsigned quantity.
241def NEGSIMM32 : SDNodeXForm<imm, [{
242  return CurDAG->getTargetConstant(int32_t(-N->getZExtValue()), SDLoc(N),
243                                   MVT::i64);
244}]>;
245
246// Truncate an immediate to a 32-bit unsigned quantity.
247def UIMM32 : SDNodeXForm<imm, [{
248  return CurDAG->getTargetConstant(uint32_t(N->getZExtValue()), SDLoc(N),
249                                   MVT::i64);
250}]>;
251
252// Negate and then truncate an immediate to a 32-bit unsigned quantity.
253def NEGUIMM32 : SDNodeXForm<imm, [{
254  return CurDAG->getTargetConstant(uint32_t(-N->getZExtValue()), SDLoc(N),
255                                   MVT::i64);
256}]>;
257
258// Truncate an immediate to a 48-bit unsigned quantity.
259def UIMM48 : SDNodeXForm<imm, [{
260  return CurDAG->getTargetConstant(uint64_t(N->getZExtValue()) & 0xffffffffffff,
261                                   SDLoc(N), MVT::i64);
262}]>;
263
264//===----------------------------------------------------------------------===//
265// Immediate asm operands.
266//===----------------------------------------------------------------------===//
267
268def U1Imm  : ImmediateAsmOperand<"U1Imm">;
269def U2Imm  : ImmediateAsmOperand<"U2Imm">;
270def U3Imm  : ImmediateAsmOperand<"U3Imm">;
271def U4Imm  : ImmediateAsmOperand<"U4Imm">;
272def U6Imm  : ImmediateAsmOperand<"U6Imm">;
273def S8Imm  : ImmediateAsmOperand<"S8Imm">;
274def U8Imm  : ImmediateAsmOperand<"U8Imm">;
275def U12Imm : ImmediateAsmOperand<"U12Imm">;
276def S16Imm : ImmediateAsmOperand<"S16Imm">;
277def U16Imm : ImmediateAsmOperand<"U16Imm">;
278def S32Imm : ImmediateAsmOperand<"S32Imm">;
279def U32Imm : ImmediateAsmOperand<"U32Imm">;
280def U48Imm : ImmediateAsmOperand<"U48Imm">;
281
282//===----------------------------------------------------------------------===//
283// i32 immediates
284//===----------------------------------------------------------------------===//
285
286// Immediates for the lower and upper 16 bits of an i32, with the other
287// bits of the i32 being zero.
288def imm32ll16 : Immediate<i32, [{
289  return SystemZ::isImmLL(N->getZExtValue());
290}], LL16, "U16Imm">;
291
292def imm32lh16 : Immediate<i32, [{
293  return SystemZ::isImmLH(N->getZExtValue());
294}], LH16, "U16Imm">;
295
296// Immediates for the lower and upper 16 bits of an i32, with the other
297// bits of the i32 being one.
298def imm32ll16c : Immediate<i32, [{
299  return SystemZ::isImmLL(uint32_t(~N->getZExtValue()));
300}], LL16, "U16Imm">;
301
302def imm32lh16c : Immediate<i32, [{
303  return SystemZ::isImmLH(uint32_t(~N->getZExtValue()));
304}], LH16, "U16Imm">;
305
306// Short immediates
307def imm32zx1 : Immediate<i32, [{
308  return isUInt<1>(N->getZExtValue());
309}], NOOP_SDNodeXForm, "U1Imm">;
310
311def imm32zx2 : Immediate<i32, [{
312  return isUInt<2>(N->getZExtValue());
313}], NOOP_SDNodeXForm, "U2Imm">;
314
315def imm32zx3 : Immediate<i32, [{
316  return isUInt<3>(N->getZExtValue());
317}], NOOP_SDNodeXForm, "U3Imm">;
318
319def imm32zx4 : Immediate<i32, [{
320  return isUInt<4>(N->getZExtValue());
321}], NOOP_SDNodeXForm, "U4Imm">;
322
323// Note: this enforces an even value during code generation only.
324// When used from the assembler, any 4-bit value is allowed.
325def imm32zx4even : Immediate<i32, [{
326  return isUInt<4>(N->getZExtValue());
327}], UIMM8EVEN, "U4Imm">;
328
329def imm32zx6 : Immediate<i32, [{
330  return isUInt<6>(N->getZExtValue());
331}], NOOP_SDNodeXForm, "U6Imm">;
332
333def imm32sx8 : Immediate<i32, [{
334  return isInt<8>(N->getSExtValue());
335}], SIMM8, "S8Imm">;
336
337def imm32zx8 : Immediate<i32, [{
338  return isUInt<8>(N->getZExtValue());
339}], UIMM8, "U8Imm">;
340
341def imm32zx8trunc : Immediate<i32, [{}], UIMM8, "U8Imm">;
342
343def imm32zx12 : Immediate<i32, [{
344  return isUInt<12>(N->getZExtValue());
345}], UIMM12, "U12Imm">;
346
347def imm32sx16 : Immediate<i32, [{
348  return isInt<16>(N->getSExtValue());
349}], SIMM16, "S16Imm">;
350
351def imm32sx16n : Immediate<i32, [{
352  return isInt<16>(-N->getSExtValue());
353}], NEGSIMM16, "S16Imm">;
354
355def imm32zx16 : Immediate<i32, [{
356  return isUInt<16>(N->getZExtValue());
357}], UIMM16, "U16Imm">;
358
359def imm32sx16trunc : Immediate<i32, [{}], SIMM16, "S16Imm">;
360def imm32zx16trunc : Immediate<i32, [{}], UIMM16, "U16Imm">;
361
362// Full 32-bit immediates.  we need both signed and unsigned versions
363// because the assembler is picky.  E.g. AFI requires signed operands
364// while NILF requires unsigned ones.
365def simm32 : Immediate<i32, [{}], SIMM32, "S32Imm">;
366def uimm32 : Immediate<i32, [{}], UIMM32, "U32Imm">;
367
368def simm32n : Immediate<i32, [{
369  return isInt<32>(-N->getSExtValue());
370}], NEGSIMM32, "S32Imm">;
371
372def imm32 : ImmLeaf<i32, [{}]>;
373
374//===----------------------------------------------------------------------===//
375// 64-bit immediates
376//===----------------------------------------------------------------------===//
377
378// Immediates for 16-bit chunks of an i64, with the other bits of the
379// i32 being zero.
380def imm64ll16 : Immediate<i64, [{
381  return SystemZ::isImmLL(N->getZExtValue());
382}], LL16, "U16Imm">;
383
384def imm64lh16 : Immediate<i64, [{
385  return SystemZ::isImmLH(N->getZExtValue());
386}], LH16, "U16Imm">;
387
388def imm64hl16 : Immediate<i64, [{
389  return SystemZ::isImmHL(N->getZExtValue());
390}], HL16, "U16Imm">;
391
392def imm64hh16 : Immediate<i64, [{
393  return SystemZ::isImmHH(N->getZExtValue());
394}], HH16, "U16Imm">;
395
396// Immediates for 16-bit chunks of an i64, with the other bits of the
397// i32 being one.
398def imm64ll16c : Immediate<i64, [{
399  return SystemZ::isImmLL(uint64_t(~N->getZExtValue()));
400}], LL16, "U16Imm">;
401
402def imm64lh16c : Immediate<i64, [{
403  return SystemZ::isImmLH(uint64_t(~N->getZExtValue()));
404}], LH16, "U16Imm">;
405
406def imm64hl16c : Immediate<i64, [{
407  return SystemZ::isImmHL(uint64_t(~N->getZExtValue()));
408}], HL16, "U16Imm">;
409
410def imm64hh16c : Immediate<i64, [{
411  return SystemZ::isImmHH(uint64_t(~N->getZExtValue()));
412}], HH16, "U16Imm">;
413
414// Immediates for the lower and upper 32 bits of an i64, with the other
415// bits of the i32 being zero.
416def imm64lf32 : Immediate<i64, [{
417  return SystemZ::isImmLF(N->getZExtValue());
418}], LF32, "U32Imm">;
419
420def imm64hf32 : Immediate<i64, [{
421  return SystemZ::isImmHF(N->getZExtValue());
422}], HF32, "U32Imm">;
423
424// Immediates for the lower and upper 32 bits of an i64, with the other
425// bits of the i32 being one.
426def imm64lf32c : Immediate<i64, [{
427  return SystemZ::isImmLF(uint64_t(~N->getZExtValue()));
428}], LF32, "U32Imm">;
429
430def imm64hf32c : Immediate<i64, [{
431  return SystemZ::isImmHF(uint64_t(~N->getZExtValue()));
432}], HF32, "U32Imm">;
433
434// Short immediates.
435def imm64sx8 : Immediate<i64, [{
436  return isInt<8>(N->getSExtValue());
437}], SIMM8, "S8Imm">;
438
439def imm64zx8 : Immediate<i64, [{
440  return isUInt<8>(N->getSExtValue());
441}], UIMM8, "U8Imm">;
442
443def imm64sx16 : Immediate<i64, [{
444  return isInt<16>(N->getSExtValue());
445}], SIMM16, "S16Imm">;
446
447def imm64sx16n : Immediate<i64, [{
448  return isInt<16>(-N->getSExtValue());
449}], NEGSIMM16, "S16Imm">;
450
451def imm64zx16 : Immediate<i64, [{
452  return isUInt<16>(N->getZExtValue());
453}], UIMM16, "U16Imm">;
454
455def imm64sx32 : Immediate<i64, [{
456  return isInt<32>(N->getSExtValue());
457}], SIMM32, "S32Imm">;
458
459def imm64sx32n : Immediate<i64, [{
460  return isInt<32>(-N->getSExtValue());
461}], NEGSIMM32, "S32Imm">;
462
463def imm64zx32 : Immediate<i64, [{
464  return isUInt<32>(N->getZExtValue());
465}], UIMM32, "U32Imm">;
466
467def imm64zx32n : Immediate<i64, [{
468  return isUInt<32>(-N->getSExtValue());
469}], NEGUIMM32, "U32Imm">;
470
471def imm64zx48 : Immediate<i64, [{
472  return isUInt<64>(N->getZExtValue());
473}], UIMM48, "U48Imm">;
474
475def imm64 : ImmLeaf<i64, [{}]>, Operand<i64>;
476
477//===----------------------------------------------------------------------===//
478// Floating-point immediates
479//===----------------------------------------------------------------------===//
480
481// Floating-point zero.
482def fpimm0 : PatLeaf<(fpimm), [{ return N->isExactlyValue(+0.0); }]>;
483
484// Floating point negative zero.
485def fpimmneg0 : PatLeaf<(fpimm), [{ return N->isExactlyValue(-0.0); }]>;
486
487//===----------------------------------------------------------------------===//
488// Symbolic address operands
489//===----------------------------------------------------------------------===//
490
491// PC-relative asm operands.
492def PCRel12 : PCRelAsmOperand<"12">;
493def PCRel16 : PCRelAsmOperand<"16">;
494def PCRel24 : PCRelAsmOperand<"24">;
495def PCRel32 : PCRelAsmOperand<"32">;
496def PCRelTLS16 : PCRelTLSAsmOperand<"16">;
497def PCRelTLS32 : PCRelTLSAsmOperand<"32">;
498
499// PC-relative offsets of a basic block.  The offset is sign-extended
500// and multiplied by 2.
501def brtarget16 : PCRelOperand<OtherVT, PCRel16> {
502  let EncoderMethod = "getPC16DBLEncoding";
503  let DecoderMethod = "decodePC16DBLBranchOperand";
504}
505def brtarget32 : PCRelOperand<OtherVT, PCRel32> {
506  let EncoderMethod = "getPC32DBLEncoding";
507  let DecoderMethod = "decodePC32DBLBranchOperand";
508}
509
510// Variants of brtarget for use with branch prediction preload.
511def brtarget12bpp : PCRelOperand<OtherVT, PCRel12> {
512  let EncoderMethod = "getPC12DBLBPPEncoding";
513  let DecoderMethod = "decodePC12DBLBranchOperand";
514}
515def brtarget16bpp : PCRelOperand<OtherVT, PCRel16> {
516  let EncoderMethod = "getPC16DBLBPPEncoding";
517  let DecoderMethod = "decodePC16DBLBranchOperand";
518}
519def brtarget24bpp : PCRelOperand<OtherVT, PCRel24> {
520  let EncoderMethod = "getPC24DBLBPPEncoding";
521  let DecoderMethod = "decodePC24DBLBranchOperand";
522}
523
524// Variants of brtarget16/32 with an optional additional TLS symbol.
525// These are used to annotate calls to __tls_get_offset.
526def tlssym : Operand<i64> { }
527def brtarget16tls : PCRelTLSOperand<OtherVT, PCRelTLS16> {
528  let MIOperandInfo = (ops brtarget16:$func, tlssym:$sym);
529  let EncoderMethod = "getPC16DBLTLSEncoding";
530  let DecoderMethod = "decodePC16DBLBranchOperand";
531}
532def brtarget32tls : PCRelTLSOperand<OtherVT, PCRelTLS32> {
533  let MIOperandInfo = (ops brtarget32:$func, tlssym:$sym);
534  let EncoderMethod = "getPC32DBLTLSEncoding";
535  let DecoderMethod = "decodePC32DBLBranchOperand";
536}
537
538// A PC-relative offset of a global value.  The offset is sign-extended
539// and multiplied by 2.
540def pcrel32 : PCRelAddress<i64, "pcrel32", PCRel32> {
541  let EncoderMethod = "getPC32DBLEncoding";
542  let DecoderMethod = "decodePC32DBLOperand";
543}
544
545//===----------------------------------------------------------------------===//
546// Addressing modes
547//===----------------------------------------------------------------------===//
548
549// 12-bit displacement operands.
550def disp12imm32 : Operand<i32>;
551def disp12imm64 : Operand<i64>;
552
553// 20-bit displacement operands.
554def disp20imm32 : Operand<i32>;
555def disp20imm64 : Operand<i64>;
556
557def BDAddr32Disp12      : AddressAsmOperand<"BDAddr",   "32", "12">;
558def BDAddr32Disp20      : AddressAsmOperand<"BDAddr",   "32", "20">;
559def BDAddr64Disp12      : AddressAsmOperand<"BDAddr",   "64", "12">;
560def BDAddr64Disp20      : AddressAsmOperand<"BDAddr",   "64", "20">;
561def BDXAddr64Disp12     : AddressAsmOperand<"BDXAddr",  "64", "12">;
562def BDXAddr64Disp20     : AddressAsmOperand<"BDXAddr",  "64", "20">;
563def BDLAddr64Disp12Len4 : AddressAsmOperand<"BDLAddr",  "64", "12", "Len4">;
564def BDLAddr64Disp12Len8 : AddressAsmOperand<"BDLAddr",  "64", "12", "Len8">;
565def BDRAddr64Disp12     : AddressAsmOperand<"BDRAddr",  "64", "12">;
566def BDVAddr64Disp12     : AddressAsmOperand<"BDVAddr",  "64", "12">;
567
568// DAG patterns and operands for addressing modes.  Each mode has
569// the form <type><range><group>[<len>] where:
570//
571// <type> is one of:
572//   shift    : base + displacement (32-bit)
573//   bdaddr   : base + displacement
574//   mviaddr  : like bdaddr, but reject cases with a natural index
575//   bdxaddr  : base + displacement + index
576//   laaddr   : like bdxaddr, but used for Load Address operations
577//   dynalloc : base + displacement + index + ADJDYNALLOC
578//   bdladdr  : base + displacement with a length field
579//   bdvaddr  : base + displacement with a vector index
580//
581// <range> is one of:
582//   12       : the displacement is an unsigned 12-bit value
583//   20       : the displacement is a signed 20-bit value
584//
585// <group> is one of:
586//   pair     : used when there is an equivalent instruction with the opposite
587//              range value (12 or 20)
588//   only     : used when there is no equivalent instruction with the opposite
589//              range value
590//
591// <len> is one of:
592//
593//   <empty>  : there is no length field
594//   len8     : the length field is 8 bits, with a range of [1, 0x100].
595def shift12only       : BDMode <"BDAddr",   "32", "12", "Only">;
596def shift20only       : BDMode <"BDAddr",   "32", "20", "Only">;
597def bdaddr12only      : BDMode <"BDAddr",   "64", "12", "Only">;
598def bdaddr12pair      : BDMode <"BDAddr",   "64", "12", "Pair">;
599def bdaddr20only      : BDMode <"BDAddr",   "64", "20", "Only">;
600def bdaddr20pair      : BDMode <"BDAddr",   "64", "20", "Pair">;
601def mviaddr12pair     : BDMode <"MVIAddr",  "64", "12", "Pair">;
602def mviaddr20pair     : BDMode <"MVIAddr",  "64", "20", "Pair">;
603def bdxaddr12only     : BDXMode<"BDXAddr",  "64", "12", "Only">;
604def bdxaddr12pair     : BDXMode<"BDXAddr",  "64", "12", "Pair">;
605def bdxaddr20only     : BDXMode<"BDXAddr",  "64", "20", "Only">;
606def bdxaddr20only128  : BDXMode<"BDXAddr",  "64", "20", "Only128">;
607def bdxaddr20pair     : BDXMode<"BDXAddr",  "64", "20", "Pair">;
608def dynalloc12only    : BDXMode<"DynAlloc", "64", "12", "Only">;
609def laaddr12pair      : BDXMode<"LAAddr",   "64", "12", "Pair">;
610def laaddr20pair      : BDXMode<"LAAddr",   "64", "20", "Pair">;
611def bdladdr12onlylen4 : BDLMode<"BDLAddr",  "64", "12", "Only", "4">;
612def bdladdr12onlylen8 : BDLMode<"BDLAddr",  "64", "12", "Only", "8">;
613def bdraddr12only     : BDRMode<"BDRAddr",  "64", "12", "Only">;
614def bdvaddr12only     : BDVMode<            "64", "12">;
615
616//===----------------------------------------------------------------------===//
617// Miscellaneous
618//===----------------------------------------------------------------------===//
619
620// A 4-bit condition-code mask.
621def cond4 : PatLeaf<(i32 imm), [{ return (N->getZExtValue() < 16); }]>,
622            Operand<i32> {
623  let PrintMethod = "printCond4Operand";
624}
625