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 */ 013package org.jikesrvm.compilers.opt.lir2mir.ppc_32; 014 015import static org.jikesrvm.compilers.opt.ir.Operators.*; 016import static org.jikesrvm.compilers.opt.lir2mir.ppc_32.BURS_Definitions.*; 017 018import org.jikesrvm.*; 019import org.jikesrvm.compilers.opt.*; 020import org.jikesrvm.compilers.opt.depgraph.DepGraphNode; 021import org.jikesrvm.compilers.opt.ir.*; 022import org.jikesrvm.compilers.opt.ir.operand.*; 023import org.jikesrvm.compilers.opt.ir.operand.ppc.*; 024import org.jikesrvm.compilers.opt.lir2mir.AbstractBURS_TreeNode; 025 026import org.vmmagic.pragma.Inline; 027 028/** 029 * An BURS_TreeNode is a node in a binary tree that is fed 030 * as input to BURS. 031 * <p> 032 * Machine-generated, do not edit! If you need to make changes 033 * to this file, edit BURS_TreeNode.template. 034 * 035 * @see org.jikesrvm.compilers.opt.lir2mir.BURS 036 * @see BURS_STATE 037 */ 038public class BURS_TreeNode extends AbstractBURS_TreeNode { 039 040 /** 041 * Constructor for interior node. 042 * 043 * @param n corresponding node from the dependence graph 044 */ 045 public BURS_TreeNode(DepGraphNode n) { 046 super(n); 047 } 048 049 /** 050 * Constructor for leaf/auxiliary node. 051 * 052 * @param opcode the opcode to use for the node 053 */ 054 public BURS_TreeNode(char opcode) { 055 super(opcode); 056 } 057 058/**** remainder will be inserted by the BURS generator *********/ 059 060// program generated file, do not edit 061 062 // cost for each non-terminal 063 private char cost_stm; 064 private char cost_r; 065 private char cost_czr; 066 private char cost_rs; 067 private char cost_rz; 068 private char cost_rp; 069 private char cost_any; 070 private char cost_boolcmp; 071 072 // rule for each non-terminal 073 private int word0; 074 // stm; word:0 offset:0, bits:7, 91 rules); 075 // r; word:0 offset:7, bits:7, 125 rules); 076 // czr; word:0 offset:14, bits:2, 2 rules); 077 // rs; word:0 offset:16, bits:5, 17 rules); 078 // rz; word:0 offset:21, bits:3, 5 rules); 079 // rp; word:0 offset:24, bits:4, 15 rules); 080 // any; word:0 offset:28, bits:3, 6 rules); 081 private int word1; 082 // boolcmp; word:1 offset:0, bits:4, 8 rules); 083 084 public final char getCost(int goalNT) { 085 switch(goalNT) { 086 case stm_NT: return cost_stm; 087 case r_NT: return cost_r; 088 case czr_NT: return cost_czr; 089 case rs_NT: return cost_rs; 090 case rz_NT: return cost_rz; 091 case rp_NT: return cost_rp; 092 case any_NT: return cost_any; 093 default: return cost_boolcmp; 094 } 095 } 096 097 public final void setCost(int goalNT, char cost) { 098 switch(goalNT) { 099 case stm_NT: cost_stm = cost; break; 100 case r_NT: cost_r = cost; break; 101 case czr_NT: cost_czr = cost; break; 102 case rs_NT: cost_rs = cost; break; 103 case rz_NT: cost_rz = cost; break; 104 case rp_NT: cost_rp = cost; break; 105 case any_NT: cost_any = cost; break; 106 default: cost_boolcmp = cost; break; 107 } 108 } 109 110 @Override 111 public final void initCost() { 112 cost_stm = 113 cost_r = 114 cost_czr = 115 cost_rs = 116 cost_rz = 117 cost_rp = 118 cost_any = 119 cost_boolcmp = 120 0x7fff; 121 word0 = 0; 122 word1 = 0; 123 124 } 125 126 @Override 127 public final void writePacked(int word, int mask, int shiftedValue) { 128 129 switch(word) { 130 case 0: word0 = (word0 & mask) | shiftedValue; break; 131 case 1: word1 = (word1 & mask) | shiftedValue; break; 132 133 default: OptimizingCompilerException.UNREACHABLE(); 134 } 135 136 } 137 138 @Override 139 public final int readPacked(int word, int shift, int mask) { 140 141 switch(word) { 142 case 0: return (word0 >>> shift) & mask; 143 case 1: return (word1 >>> shift) & mask; 144 145 default: OptimizingCompilerException.UNREACHABLE(); return -1; 146 } 147 148 } 149 150 /** 151 * Get the BURS rule number associated with this tree node for a given non-terminal 152 * 153 * @param goalNT the non-terminal we want to know the rule for (e.g. stm_NT) 154 * @return the rule number 155 */ 156 @Inline 157 public final int rule(int goalNT) { 158 int stateNT; 159 switch(goalNT) { 160 case stm_NT: 161 stateNT = readPacked(0, 0, 0x7F); 162 break; 163 case r_NT: 164 stateNT = readPacked(0, 7, 0x7F); 165 break; 166 case czr_NT: 167 stateNT = readPacked(0, 14, 0x3); 168 break; 169 case rs_NT: 170 stateNT = readPacked(0, 16, 0x1F); 171 break; 172 case rz_NT: 173 stateNT = readPacked(0, 21, 0x7); 174 break; 175 case rp_NT: 176 stateNT = readPacked(0, 24, 0xF); 177 break; 178 case any_NT: 179 stateNT = readPacked(0, 28, 0x7); 180 break; 181 default: // boolcmp_NT 182 stateNT = readPacked(1, 0, 0xF); 183 break; 184 } 185 return BURS_STATE.decode(goalNT, stateNT); 186 } 187} 188