001 002/* 003 * THIS FILE IS MACHINE_GENERATED. DO NOT EDIT. 004 * See InstructionFormats.template, CommonOperands.dat, 005 * OperatorList.dat, etc. 006 */ 007 008package org.jikesrvm.compilers.opt.ir; 009 010import org.jikesrvm.Configuration; 011import org.jikesrvm.VM; 012import org.jikesrvm.compilers.opt.ir.operand.*; 013 014/** 015 * InstructionFormats that have a GuardResult (which is RegisterOperand) 016 */ 017public final class GuardResultCarrier extends InstructionFormat { 018 019 /** 020 * Performs table lookup 021 * @param index the index to lookup 022 * @return the index into the instruction operands that carries the GuardResult 023 * or -1 if not carried 024 */ 025 public static int lookup(int index) { 026 if (VM.BuildForIA32) { 027 return org.jikesrvm.compilers.opt.ir.ia32.GuardResultCarrierLookup.lookup(index); 028 } else { 029 if (VM.VerifyAssertions) VM._assert(VM.BuildForPowerPC); 030 return org.jikesrvm.compilers.opt.ir.ppc.GuardResultCarrierLookup.lookup(index); 031 } 032 } 033 034 /** 035 * Does the instruction belong to an instruction format that 036 * has an operand called GuardResult? 037 * @param i the instruction to test 038 * @return <code>true</code> if the instruction's instruction 039 * format has an operand called GuardResult and 040 * <code>false</code> if it does not. 041 */ 042 public static boolean conforms(Instruction i) { 043 return conforms(i.operator()); 044 } 045 /** 046 * Does the operator belong to an instruction format that 047 * has an operand called GuardResult? 048 * @param o the operator to test 049 * @return <code>true</code> if the instruction's instruction 050 * format has an operand called GuardResult and 051 * <code>false</code> if it does not. 052 */ 053 public static boolean conforms(Operator o) { 054 return lookup(o.format) != -1; 055 } 056 057 /** 058 * Get the operand called GuardResult from the 059 * argument instruction. Note that the returned operand 060 * will still point to its containing instruction. 061 * @param i the instruction to fetch the operand from 062 * @return the operand called GuardResult 063 */ 064 public static RegisterOperand getGuardResult(Instruction i) { 065 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "GuardResultCarrier"); 066 int index = lookup(i.operator().format); 067 return (RegisterOperand) i.getOperand(index); 068 } 069 /** 070 * Get the operand called GuardResult from the argument 071 * instruction clearing its instruction pointer. The returned 072 * operand will not point to any containing instruction. 073 * @param i the instruction to fetch the operand from 074 * @return the operand called GuardResult 075 */ 076 public static RegisterOperand getClearGuardResult(Instruction i) { 077 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "GuardResultCarrier"); 078 int index = lookup(i.operator().format); 079 return (RegisterOperand) i.getClearOperand(index); 080 } 081 /** 082 * Set the operand called GuardResult in the argument 083 * instruction to the argument operand. The operand will 084 * now point to the argument instruction as its containing 085 * instruction. 086 * @param i the instruction in which to store the operand 087 * @param op the operand to store 088 */ 089 public static void setGuardResult(Instruction i, RegisterOperand op) { 090 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "GuardResultCarrier"); 091 int index = lookup(i.operator().format); 092 i.putOperand(index, op); 093 } 094 /** 095 * Return the index of the operand called GuardResult 096 * in the argument instruction. 097 * @param i the instruction to access. 098 * @return the index of the operand called GuardResult 099 * in the argument instruction 100 */ 101 public static int indexOfGuardResult(Instruction i) { 102 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "GuardResultCarrier"); 103 return lookup(i.operator().format); 104 } 105 /** 106 * Does the argument instruction have a non-null 107 * operand named GuardResult? 108 * @param i the instruction to access. 109 * @return <code>true</code> if the instruction has an non-null 110 * operand named GuardResult or <code>false</code> 111 * if it does not. 112 */ 113 public static boolean hasGuardResult(Instruction i) { 114 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "GuardResultCarrier"); 115 int index = lookup(i.operator().format); 116 return i.getOperand(index) != null; 117 } 118} 119