001 /* 002 * This file is part of the Jikes RVM project (http://jikesrvm.org). 003 * 004 * This file is licensed to You under the Eclipse Public License (EPL); 005 * You may not use this file except in compliance with the License. You 006 * may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/eclipse-1.0.php 009 * 010 * See the COPYRIGHT.txt file distributed with this work for information 011 * regarding copyright ownership. 012 */ 013 package org.jikesrvm.compilers.opt.instrsched; 014 015 import org.jikesrvm.compilers.opt.ir.Instruction; 016 017 /** 018 * Object containing scheduling information 019 * Used by the scheduler 020 */ 021 final class SchedulingInfo { 022 int alt; 023 int time; 024 int etime; 025 int cp; 026 027 /** 028 * For internal use only. Clients should 029 * invoke {@link #createInfo(Instruction)}. 030 */ 031 private SchedulingInfo() { 032 alt = -1; 033 time = -1; 034 etime = -1; 035 cp = -1; 036 } 037 038 /** 039 * Initializes scheduling information for instruction. 040 * 041 * @param i instruction 042 */ 043 public static void createInfo(Instruction i) { 044 i.scratchObject = new SchedulingInfo(); 045 } 046 047 /** 048 * Removes scheduling information from instruction. 049 * 050 * @param i instruction 051 */ 052 public static void removeInfo(Instruction i) { 053 i.scratchObject = null; 054 } 055 056 /** 057 * Returns scheduling information for instruction. 058 * 059 * @param i instruction 060 * @return scheduling info for instruction 061 */ 062 public static SchedulingInfo getInfo(Instruction i) { 063 return (SchedulingInfo) i.scratchObject; 064 } 065 066 /** 067 * Adds scheduling information to instruction. 068 * 069 * @param i instruction 070 * @param alt scheduling alternative 071 * @param time scheduling time 072 */ 073 public static void setInfo(Instruction i, int alt, int time) { 074 SchedulingInfo si = getInfo(i); 075 si.alt = alt; 076 si.time = time; 077 } 078 079 /** 080 * Clears scheduling information of instruction. 081 * 082 * @param i instruction 083 */ 084 public static void resetInfo(Instruction i) { 085 setInfo(i, -1, -1); 086 } 087 088 /** 089 * Checks whether instruction is scheduled. 090 * 091 * @param i instruction 092 * @return true if instruction is scheduled, false otherwise 093 */ 094 public static boolean isScheduled(Instruction i) { 095 return getInfo(i).alt != -1; 096 } 097 098 /** 099 * Returns scheduling alternative for instruction. 100 * 101 * @param i instruction 102 * @return scheduling alternative for instruction 103 */ 104 public static int getAlt(Instruction i) { 105 return getInfo(i).alt; 106 } 107 108 /** 109 * Returns scheduling time for instruction. 110 * 111 * @param i instruction 112 * @return scheduling time for instruction 113 */ 114 public static int getTime(Instruction i) { 115 return getInfo(i).time; 116 } 117 118 /** 119 * Returns earliest scheduling time for instruction. 120 * 121 * @param i instruction 122 * @return earliest scheduling time for instruction 123 */ 124 public static int getEarliestTime(Instruction i) { 125 return getInfo(i).etime; 126 } 127 128 /** 129 * Sets earliest scheduling time for instruction. 130 * 131 * @param i instruction 132 * @param etime earliest scheduling time for instruction 133 */ 134 public static void setEarliestTime(Instruction i, int etime) { 135 getInfo(i).etime = etime; 136 } 137 138 /** 139 * Returns critical path length for instruction. 140 * 141 * @param i instruction 142 * @return critical path length for instruction 143 */ 144 public static int getCriticalPath(Instruction i) { 145 return getInfo(i).cp; 146 } 147 148 /** 149 * Sets critical path length for instruction. 150 * 151 * @param i instruction 152 * @param cp critical path length for instruction 153 */ 154 public static void setCriticalPath(Instruction i, int cp) { 155 getInfo(i).cp = cp; 156 } 157 158 /** 159 * Returns a string representation of scheduling info. 160 * 161 * @return string representation of scheduling info 162 */ 163 @Override 164 public String toString() { 165 return "time=" + time + "; alt=" + alt + "; eTime=" + etime + "; cp=" + cp; 166 } 167 }