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 Trap 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 Trap extends InstructionFormat { 022 /** 023 * InstructionFormat identification method for Trap. 024 * @param i an instruction 025 * @return <code>true</code> if the InstructionFormat of the argument 026 * instruction is Trap 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 Trap. 034 * @param o an instruction 035 * @return <code>true</code> if the InstructionFormat of the argument 036 * operator is Trap or <code>false</code> 037 * if it is not. 038 */ 039 public static boolean conforms(Operator o) { 040 return o.format == Trap_format; 041 } 042 043 /** 044 * Get the operand called GuardResult 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 GuardResult 049 */ 050 public static RegisterOperand getGuardResult(Instruction i) { 051 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Trap"); 052 return (RegisterOperand) i.getOperand(0); 053 } 054 /** 055 * Get the operand called GuardResult 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 GuardResult 060 */ 061 public static RegisterOperand getClearGuardResult(Instruction i) { 062 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Trap"); 063 return (RegisterOperand) i.getClearOperand(0); 064 } 065 /** 066 * Set the operand called GuardResult 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 GuardResult the operand to store 072 */ 073 public static void setGuardResult(Instruction i, RegisterOperand GuardResult) { 074 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Trap"); 075 i.putOperand(0, GuardResult); 076 } 077 /** 078 * Return the index of the operand called GuardResult 079 * in the argument instruction. 080 * @param i the instruction to access. 081 * @return the index of the operand called GuardResult 082 * in the argument instruction 083 */ 084 public static int indexOfGuardResult(Instruction i) { 085 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Trap"); 086 return 0; 087 } 088 /** 089 * Does the argument instruction have a non-null 090 * operand named GuardResult? 091 * @param i the instruction to access. 092 * @return <code>true</code> if the instruction has an non-null 093 * operand named GuardResult or <code>false</code> 094 * if it does not. 095 */ 096 public static boolean hasGuardResult(Instruction i) { 097 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Trap"); 098 return i.getOperand(0) != null; 099 } 100 101 /** 102 * Get the operand called TCode 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 TCode 107 */ 108 public static TrapCodeOperand getTCode(Instruction i) { 109 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Trap"); 110 return (TrapCodeOperand) i.getOperand(1); 111 } 112 /** 113 * Get the operand called TCode 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 TCode 118 */ 119 public static TrapCodeOperand getClearTCode(Instruction i) { 120 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Trap"); 121 return (TrapCodeOperand) i.getClearOperand(1); 122 } 123 /** 124 * Set the operand called TCode 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 TCode the operand to store 130 */ 131 public static void setTCode(Instruction i, TrapCodeOperand TCode) { 132 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Trap"); 133 i.putOperand(1, TCode); 134 } 135 /** 136 * Return the index of the operand called TCode 137 * in the argument instruction. 138 * @param i the instruction to access. 139 * @return the index of the operand called TCode 140 * in the argument instruction 141 */ 142 public static int indexOfTCode(Instruction i) { 143 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Trap"); 144 return 1; 145 } 146 /** 147 * Does the argument instruction have a non-null 148 * operand named TCode? 149 * @param i the instruction to access. 150 * @return <code>true</code> if the instruction has an non-null 151 * operand named TCode or <code>false</code> 152 * if it does not. 153 */ 154 public static boolean hasTCode(Instruction i) { 155 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Trap"); 156 return i.getOperand(1) != null; 157 } 158 159 160 /** 161 * Create an instruction of the Trap instruction format. 162 * @param o the instruction's operator 163 * @param GuardResult the instruction's GuardResult operand 164 * @param TCode the instruction's TCode operand 165 * @return the newly created Trap instruction 166 */ 167 public static Instruction create(Operator o 168 , RegisterOperand GuardResult 169 , TrapCodeOperand TCode 170 ) 171 { 172 if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "Trap"); 173 Instruction i = Instruction.create(o, 5); 174 i.putOperand(0, GuardResult); 175 i.putOperand(1, TCode); 176 return i; 177 } 178 179 /** 180 * Mutate the argument instruction into an instruction of the 181 * Trap instruction format having the specified 182 * operator and operands. 183 * @param i the instruction to mutate 184 * @param o the instruction's operator 185 * @param GuardResult the instruction's GuardResult operand 186 * @param TCode the instruction's TCode operand 187 * @return the mutated instruction 188 */ 189 public static Instruction mutate(Instruction i, Operator o 190 , RegisterOperand GuardResult 191 , TrapCodeOperand TCode 192 ) 193 { 194 if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "Trap"); 195 i.changeOperatorTo(o); 196 i.putOperand(0, GuardResult); 197 i.putOperand(1, TCode); 198 return i; 199 } 200} 201