001
002/*
003 * THIS FILE IS MACHINE_GENERATED. DO NOT EDIT.
004 * See InstructionFormats.template, InstructionFormatList.dat,
005 * OperatorList.dat, etc.
006 */
007
008package org.jikesrvm.compilers.opt.ir;
009
010import org.jikesrvm.Configuration;
011import org.jikesrvm.compilers.opt.ir.operand.*;
012
013/**
014 * The Attempt InstructionFormat class.
015 *
016 * The header comment for {@link Instruction} contains
017 * an explanation of the role of InstructionFormats in the
018 * opt compiler's IR.
019 */
020@SuppressWarnings("unused")  // Machine generated code is never 100% clean
021public final class Attempt extends InstructionFormat {
022  /**
023   * InstructionFormat identification method for Attempt.
024   * @param i an instruction
025   * @return <code>true</code> if the InstructionFormat of the argument
026   *         instruction is Attempt or <code>false</code>
027   *         if it is not.
028   */
029  public static boolean conforms(Instruction i) {
030    return conforms(i.operator());
031  }
032  /**
033   * InstructionFormat identification method for Attempt.
034   * @param o an instruction
035   * @return <code>true</code> if the InstructionFormat of the argument
036   *         operator is Attempt or <code>false</code>
037   *         if it is not.
038   */
039  public static boolean conforms(Operator o) {
040    return o.format == Attempt_format;
041  }
042
043  /**
044   * Get the operand called Result from the
045   * argument instruction. Note that the returned operand
046   * will still point to its containing instruction.
047   * @param i the instruction to fetch the operand from
048   * @return the operand called Result
049   */
050  public static RegisterOperand getResult(Instruction i) {
051    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Attempt");
052    return (RegisterOperand) i.getOperand(0);
053  }
054  /**
055   * Get the operand called Result from the argument
056   * instruction clearing its instruction pointer. The returned
057   * operand will not point to any containing instruction.
058   * @param i the instruction to fetch the operand from
059   * @return the operand called Result
060   */
061  public static RegisterOperand getClearResult(Instruction i) {
062    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Attempt");
063    return (RegisterOperand) i.getClearOperand(0);
064  }
065  /**
066   * Set the operand called Result in the argument
067   * instruction to the argument operand. The operand will
068   * now point to the argument instruction as its containing
069   * instruction.
070   * @param i the instruction in which to store the operand
071   * @param Result the operand to store
072   */
073  public static void setResult(Instruction i, RegisterOperand Result) {
074    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Attempt");
075    i.putOperand(0, Result);
076  }
077  /**
078   * Return the index of the operand called Result
079   * in the argument instruction.
080   * @param i the instruction to access.
081   * @return the index of the operand called Result
082   *         in the argument instruction
083   */
084  public static int indexOfResult(Instruction i) {
085    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Attempt");
086    return 0;
087  }
088  /**
089   * Does the argument instruction have a non-null
090   * operand named Result?
091   * @param i the instruction to access.
092   * @return <code>true</code> if the instruction has an non-null
093   *         operand named Result or <code>false</code>
094   *         if it does not.
095   */
096  public static boolean hasResult(Instruction i) {
097    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Attempt");
098    return i.getOperand(0) != null;
099  }
100
101  /**
102   * Get the operand called Address from the
103   * argument instruction. Note that the returned operand
104   * will still point to its containing instruction.
105   * @param i the instruction to fetch the operand from
106   * @return the operand called Address
107   */
108  public static Operand getAddress(Instruction i) {
109    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Attempt");
110    return (Operand) i.getOperand(1);
111  }
112  /**
113   * Get the operand called Address from the argument
114   * instruction clearing its instruction pointer. The returned
115   * operand will not point to any containing instruction.
116   * @param i the instruction to fetch the operand from
117   * @return the operand called Address
118   */
119  public static Operand getClearAddress(Instruction i) {
120    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Attempt");
121    return (Operand) i.getClearOperand(1);
122  }
123  /**
124   * Set the operand called Address in the argument
125   * instruction to the argument operand. The operand will
126   * now point to the argument instruction as its containing
127   * instruction.
128   * @param i the instruction in which to store the operand
129   * @param Address the operand to store
130   */
131  public static void setAddress(Instruction i, Operand Address) {
132    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Attempt");
133    i.putOperand(1, Address);
134  }
135  /**
136   * Return the index of the operand called Address
137   * in the argument instruction.
138   * @param i the instruction to access.
139   * @return the index of the operand called Address
140   *         in the argument instruction
141   */
142  public static int indexOfAddress(Instruction i) {
143    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Attempt");
144    return 1;
145  }
146  /**
147   * Does the argument instruction have a non-null
148   * operand named Address?
149   * @param i the instruction to access.
150   * @return <code>true</code> if the instruction has an non-null
151   *         operand named Address or <code>false</code>
152   *         if it does not.
153   */
154  public static boolean hasAddress(Instruction i) {
155    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Attempt");
156    return i.getOperand(1) != null;
157  }
158
159  /**
160   * Get the operand called Offset from the
161   * argument instruction. Note that the returned operand
162   * will still point to its containing instruction.
163   * @param i the instruction to fetch the operand from
164   * @return the operand called Offset
165   */
166  public static Operand getOffset(Instruction i) {
167    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Attempt");
168    return (Operand) i.getOperand(2);
169  }
170  /**
171   * Get the operand called Offset from the argument
172   * instruction clearing its instruction pointer. The returned
173   * operand will not point to any containing instruction.
174   * @param i the instruction to fetch the operand from
175   * @return the operand called Offset
176   */
177  public static Operand getClearOffset(Instruction i) {
178    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Attempt");
179    return (Operand) i.getClearOperand(2);
180  }
181  /**
182   * Set the operand called Offset in the argument
183   * instruction to the argument operand. The operand will
184   * now point to the argument instruction as its containing
185   * instruction.
186   * @param i the instruction in which to store the operand
187   * @param Offset the operand to store
188   */
189  public static void setOffset(Instruction i, Operand Offset) {
190    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Attempt");
191    i.putOperand(2, Offset);
192  }
193  /**
194   * Return the index of the operand called Offset
195   * in the argument instruction.
196   * @param i the instruction to access.
197   * @return the index of the operand called Offset
198   *         in the argument instruction
199   */
200  public static int indexOfOffset(Instruction i) {
201    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Attempt");
202    return 2;
203  }
204  /**
205   * Does the argument instruction have a non-null
206   * operand named Offset?
207   * @param i the instruction to access.
208   * @return <code>true</code> if the instruction has an non-null
209   *         operand named Offset or <code>false</code>
210   *         if it does not.
211   */
212  public static boolean hasOffset(Instruction i) {
213    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Attempt");
214    return i.getOperand(2) != null;
215  }
216
217  /**
218   * Get the operand called OldValue from the
219   * argument instruction. Note that the returned operand
220   * will still point to its containing instruction.
221   * @param i the instruction to fetch the operand from
222   * @return the operand called OldValue
223   */
224  public static Operand getOldValue(Instruction i) {
225    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Attempt");
226    return (Operand) i.getOperand(3);
227  }
228  /**
229   * Get the operand called OldValue from the argument
230   * instruction clearing its instruction pointer. The returned
231   * operand will not point to any containing instruction.
232   * @param i the instruction to fetch the operand from
233   * @return the operand called OldValue
234   */
235  public static Operand getClearOldValue(Instruction i) {
236    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Attempt");
237    return (Operand) i.getClearOperand(3);
238  }
239  /**
240   * Set the operand called OldValue in the argument
241   * instruction to the argument operand. The operand will
242   * now point to the argument instruction as its containing
243   * instruction.
244   * @param i the instruction in which to store the operand
245   * @param OldValue the operand to store
246   */
247  public static void setOldValue(Instruction i, Operand OldValue) {
248    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Attempt");
249    i.putOperand(3, OldValue);
250  }
251  /**
252   * Return the index of the operand called OldValue
253   * in the argument instruction.
254   * @param i the instruction to access.
255   * @return the index of the operand called OldValue
256   *         in the argument instruction
257   */
258  public static int indexOfOldValue(Instruction i) {
259    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Attempt");
260    return 3;
261  }
262  /**
263   * Does the argument instruction have a non-null
264   * operand named OldValue?
265   * @param i the instruction to access.
266   * @return <code>true</code> if the instruction has an non-null
267   *         operand named OldValue or <code>false</code>
268   *         if it does not.
269   */
270  public static boolean hasOldValue(Instruction i) {
271    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Attempt");
272    return i.getOperand(3) != null;
273  }
274
275  /**
276   * Get the operand called NewValue from the
277   * argument instruction. Note that the returned operand
278   * will still point to its containing instruction.
279   * @param i the instruction to fetch the operand from
280   * @return the operand called NewValue
281   */
282  public static Operand getNewValue(Instruction i) {
283    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Attempt");
284    return (Operand) i.getOperand(4);
285  }
286  /**
287   * Get the operand called NewValue from the argument
288   * instruction clearing its instruction pointer. The returned
289   * operand will not point to any containing instruction.
290   * @param i the instruction to fetch the operand from
291   * @return the operand called NewValue
292   */
293  public static Operand getClearNewValue(Instruction i) {
294    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Attempt");
295    return (Operand) i.getClearOperand(4);
296  }
297  /**
298   * Set the operand called NewValue in the argument
299   * instruction to the argument operand. The operand will
300   * now point to the argument instruction as its containing
301   * instruction.
302   * @param i the instruction in which to store the operand
303   * @param NewValue the operand to store
304   */
305  public static void setNewValue(Instruction i, Operand NewValue) {
306    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Attempt");
307    i.putOperand(4, NewValue);
308  }
309  /**
310   * Return the index of the operand called NewValue
311   * in the argument instruction.
312   * @param i the instruction to access.
313   * @return the index of the operand called NewValue
314   *         in the argument instruction
315   */
316  public static int indexOfNewValue(Instruction i) {
317    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Attempt");
318    return 4;
319  }
320  /**
321   * Does the argument instruction have a non-null
322   * operand named NewValue?
323   * @param i the instruction to access.
324   * @return <code>true</code> if the instruction has an non-null
325   *         operand named NewValue or <code>false</code>
326   *         if it does not.
327   */
328  public static boolean hasNewValue(Instruction i) {
329    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Attempt");
330    return i.getOperand(4) != null;
331  }
332
333  /**
334   * Get the operand called Location from the
335   * argument instruction. Note that the returned operand
336   * will still point to its containing instruction.
337   * @param i the instruction to fetch the operand from
338   * @return the operand called Location
339   */
340  public static LocationOperand getLocation(Instruction i) {
341    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Attempt");
342    return (LocationOperand) i.getOperand(5);
343  }
344  /**
345   * Get the operand called Location from the argument
346   * instruction clearing its instruction pointer. The returned
347   * operand will not point to any containing instruction.
348   * @param i the instruction to fetch the operand from
349   * @return the operand called Location
350   */
351  public static LocationOperand getClearLocation(Instruction i) {
352    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Attempt");
353    return (LocationOperand) i.getClearOperand(5);
354  }
355  /**
356   * Set the operand called Location in the argument
357   * instruction to the argument operand. The operand will
358   * now point to the argument instruction as its containing
359   * instruction.
360   * @param i the instruction in which to store the operand
361   * @param Location the operand to store
362   */
363  public static void setLocation(Instruction i, LocationOperand Location) {
364    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Attempt");
365    i.putOperand(5, Location);
366  }
367  /**
368   * Return the index of the operand called Location
369   * in the argument instruction.
370   * @param i the instruction to access.
371   * @return the index of the operand called Location
372   *         in the argument instruction
373   */
374  public static int indexOfLocation(Instruction i) {
375    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Attempt");
376    return 5;
377  }
378  /**
379   * Does the argument instruction have a non-null
380   * operand named Location?
381   * @param i the instruction to access.
382   * @return <code>true</code> if the instruction has an non-null
383   *         operand named Location or <code>false</code>
384   *         if it does not.
385   */
386  public static boolean hasLocation(Instruction i) {
387    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Attempt");
388    return i.getOperand(5) != null;
389  }
390
391  /**
392   * Get the operand called Guard from the
393   * argument instruction. Note that the returned operand
394   * will still point to its containing instruction.
395   * @param i the instruction to fetch the operand from
396   * @return the operand called Guard
397   */
398  public static Operand getGuard(Instruction i) {
399    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Attempt");
400    return (Operand) i.getOperand(6);
401  }
402  /**
403   * Get the operand called Guard from the argument
404   * instruction clearing its instruction pointer. The returned
405   * operand will not point to any containing instruction.
406   * @param i the instruction to fetch the operand from
407   * @return the operand called Guard
408   */
409  public static Operand getClearGuard(Instruction i) {
410    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Attempt");
411    return (Operand) i.getClearOperand(6);
412  }
413  /**
414   * Set the operand called Guard in the argument
415   * instruction to the argument operand. The operand will
416   * now point to the argument instruction as its containing
417   * instruction.
418   * @param i the instruction in which to store the operand
419   * @param Guard the operand to store
420   */
421  public static void setGuard(Instruction i, Operand Guard) {
422    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Attempt");
423    i.putOperand(6, Guard);
424  }
425  /**
426   * Return the index of the operand called Guard
427   * in the argument instruction.
428   * @param i the instruction to access.
429   * @return the index of the operand called Guard
430   *         in the argument instruction
431   */
432  public static int indexOfGuard(Instruction i) {
433    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Attempt");
434    return 6;
435  }
436  /**
437   * Does the argument instruction have a non-null
438   * operand named Guard?
439   * @param i the instruction to access.
440   * @return <code>true</code> if the instruction has an non-null
441   *         operand named Guard or <code>false</code>
442   *         if it does not.
443   */
444  public static boolean hasGuard(Instruction i) {
445    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Attempt");
446    return i.getOperand(6) != null;
447  }
448
449
450  /**
451   * Create an instruction of the Attempt instruction format.
452   * @param o the instruction's operator
453   * @param Result the instruction's Result operand
454   * @param Address the instruction's Address operand
455   * @param Offset the instruction's Offset operand
456   * @param OldValue the instruction's OldValue operand
457   * @param NewValue the instruction's NewValue operand
458   * @param Location the instruction's Location operand
459   * @param Guard the instruction's Guard operand
460   * @return the newly created Attempt instruction
461   */
462  public static Instruction create(Operator o
463                   , RegisterOperand Result
464                   , Operand Address
465                   , Operand Offset
466                   , Operand OldValue
467                   , Operand NewValue
468                   , LocationOperand Location
469                   , Operand Guard
470                )
471  {
472    if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "Attempt");
473    Instruction i = Instruction.create(o, 7);
474    i.putOperand(0, Result);
475    i.putOperand(1, Address);
476    i.putOperand(2, Offset);
477    i.putOperand(3, OldValue);
478    i.putOperand(4, NewValue);
479    i.putOperand(5, Location);
480    i.putOperand(6, Guard);
481    return i;
482  }
483
484  /**
485   * Mutate the argument instruction into an instruction of the
486   * Attempt instruction format having the specified
487   * operator and operands.
488   * @param i the instruction to mutate
489   * @param o the instruction's operator
490   * @param Result the instruction's Result operand
491   * @param Address the instruction's Address operand
492   * @param Offset the instruction's Offset operand
493   * @param OldValue the instruction's OldValue operand
494   * @param NewValue the instruction's NewValue operand
495   * @param Location the instruction's Location operand
496   * @param Guard the instruction's Guard operand
497   * @return the mutated instruction
498   */
499  public static Instruction mutate(Instruction i, Operator o
500                   , RegisterOperand Result
501                   , Operand Address
502                   , Operand Offset
503                   , Operand OldValue
504                   , Operand NewValue
505                   , LocationOperand Location
506                   , Operand Guard
507                )
508  {
509    if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "Attempt");
510    i.resizeNumberOfOperands(7);
511
512    i.changeOperatorTo(o);
513    i.putOperand(0, Result);
514    i.putOperand(1, Address);
515    i.putOperand(2, Offset);
516    i.putOperand(3, OldValue);
517    i.putOperand(4, NewValue);
518    i.putOperand(5, Location);
519    i.putOperand(6, Guard);
520    return i;
521  }
522  /**
523   * Create an instruction of the Attempt instruction format.
524   * @param o the instruction's operator
525   * @param Result the instruction's Result operand
526   * @param Address the instruction's Address operand
527   * @param Offset the instruction's Offset operand
528   * @param OldValue the instruction's OldValue operand
529   * @param NewValue the instruction's NewValue operand
530   * @param Location the instruction's Location operand
531   * @return the newly created Attempt instruction
532   */
533  public static Instruction create(Operator o
534                   , RegisterOperand Result
535                   , Operand Address
536                   , Operand Offset
537                   , Operand OldValue
538                   , Operand NewValue
539                   , LocationOperand Location
540                )
541  {
542    if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "Attempt");
543    Instruction i = Instruction.create(o, 7);
544    i.putOperand(0, Result);
545    i.putOperand(1, Address);
546    i.putOperand(2, Offset);
547    i.putOperand(3, OldValue);
548    i.putOperand(4, NewValue);
549    i.putOperand(5, Location);
550    return i;
551  }
552
553  /**
554   * Mutate the argument instruction into an instruction of the
555   * Attempt instruction format having the specified
556   * operator and operands.
557   * @param i the instruction to mutate
558   * @param o the instruction's operator
559   * @param Result the instruction's Result operand
560   * @param Address the instruction's Address operand
561   * @param Offset the instruction's Offset operand
562   * @param OldValue the instruction's OldValue operand
563   * @param NewValue the instruction's NewValue operand
564   * @param Location the instruction's Location operand
565   * @return the mutated instruction
566   */
567  public static Instruction mutate(Instruction i, Operator o
568                   , RegisterOperand Result
569                   , Operand Address
570                   , Operand Offset
571                   , Operand OldValue
572                   , Operand NewValue
573                   , LocationOperand Location
574                )
575  {
576    if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "Attempt");
577    i.resizeNumberOfOperands(7);
578
579    i.changeOperatorTo(o);
580    i.putOperand(0, Result);
581    i.putOperand(1, Address);
582    i.putOperand(2, Offset);
583    i.putOperand(3, OldValue);
584    i.putOperand(4, NewValue);
585    i.putOperand(5, Location);
586    i.putOperand(6, null);
587    return i;
588  }
589}
590