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.ssa; 014 015 /** 016 * This module defines parameters to the SSA construction process. 017 * This is used to pass information between compiler phases. 018 * <p> 019 * IMPORTANT: Phases that change the SSA state MUST update the SSA 020 * actual options held by the IR object. 021 */ 022 public class SSAOptions { 023 /* 024 * options for SSA construction 025 */ 026 /** construct SSA only for scalars? */ 027 private boolean scalarsOnly; 028 /** construct Heap SSA for backwards analysis? */ 029 private boolean backwards; 030 /** constuct Heap SSA with uPhi functions? */ 031 private boolean insertUsePhis; 032 /** constuct Heap SSA with PEI deps? */ 033 private boolean insertPEIDeps; 034 /** ignore guards (validation regs) ? */ 035 private boolean excludeGuards; 036 /** restrict Heap SSA to this set of types? */ 037 private java.util.Set<Object> heapTypes; 038 /** is Heap SSA info valid? */ 039 private boolean heapValid; 040 /** is Scalar SSA info valid? */ 041 private boolean scalarValid; 042 /** abort all ssa passes? */ 043 private boolean abort; 044 045 final boolean getAbort() { 046 return abort; 047 } 048 049 final void setAbort(boolean b) { 050 abort = b; 051 } 052 053 final boolean getScalarsOnly() { 054 return scalarsOnly; 055 } 056 057 final boolean getBackwards() { 058 return backwards; 059 } 060 061 final boolean getInsertUsePhis() { 062 return insertUsePhis; 063 } 064 065 final boolean getInsertPEIDeps() { 066 return insertPEIDeps; 067 } 068 069 final boolean getExcludeGuards() { 070 return excludeGuards; 071 } 072 073 final java.util.Set<Object> getHeapTypes() { 074 return heapTypes; 075 } 076 077 public final boolean getHeapValid() { 078 return heapValid; 079 } 080 081 public final boolean getScalarValid() { 082 return scalarValid; 083 } 084 085 final void setScalarsOnly(boolean b) { 086 scalarsOnly = b; 087 } 088 089 final void setBackwards(boolean b) { 090 backwards = b; 091 } 092 093 final void setInsertUsePhis(boolean b) { 094 insertUsePhis = b; 095 } 096 097 final void setExcludeGuards(boolean b) { 098 excludeGuards = b; 099 } 100 101 final void setInsertPEIDeps(boolean b) { 102 insertPEIDeps = b; 103 } 104 105 final void setHeapTypes(java.util.Set<Object> s) { 106 heapTypes = s; 107 } 108 109 // CAUTION: only Enter and LeaveSSA should use the following. 110 // Don't use these unless you know what you're doing. 111 final void setHeapValid(boolean b) { 112 heapValid = b; 113 } 114 115 final void setScalarValid(boolean b) { 116 scalarValid = b; 117 } 118 119 /** 120 * Set up instructions for an form of heap Array SSA, or turn it 121 * off 122 */ 123 SSAOptions(boolean scalarsOnly, boolean backwards, boolean insertUsePhis, java.util.Set<Object> heapTypes) { 124 this.scalarsOnly = scalarsOnly; 125 this.backwards = backwards; 126 this.insertUsePhis = insertUsePhis; 127 this.heapTypes = heapTypes; 128 this.insertPEIDeps = false; 129 this.excludeGuards = false; 130 scalarValid = false; 131 heapValid = false; 132 } 133 134 /** 135 * default configuration: just perform forward scalar SSA 136 */ 137 SSAOptions() { 138 this.scalarsOnly = true; 139 this.backwards = false; 140 this.insertUsePhis = false; 141 this.heapTypes = null; 142 this.insertPEIDeps = false; 143 this.excludeGuards = false; 144 scalarValid = false; 145 heapValid = false; 146 } 147 148 /** 149 * Given a desired set of SSA Options, does this set of SSA Options 150 * describe enough information to satisfy the desire? 151 * 152 * @param d the desired SSA options 153 */ 154 boolean satisfies(SSAOptions d) { 155 // 1. At a minimum , scalars must be valid 156 if (!scalarValid) { 157 return false; 158 } 159 // 2. OK, scalar SSA is valid. Is this enough? 160 if (d.getScalarsOnly()) { 161 return true; 162 } 163 // 3. OK, we desire more than scalars. So now, at least 164 // Heap SSA must be valid 165 if (!heapValid) { 166 return false; 167 } 168 // 4. OK, Heap Array SSA is valid. Do we have the correct 169 // backwards, usePhis, and heapTypes?? 170 if (backwards != d.getBackwards()) { 171 return false; 172 } 173 if (insertUsePhis != d.getInsertUsePhis()) { 174 return false; 175 } 176 if (insertPEIDeps != d.getInsertPEIDeps()) { 177 return false; 178 } 179 if (excludeGuards != d.getExcludeGuards()) { 180 return false; 181 } 182 if (heapTypes != d.getHeapTypes()) { 183 return false; 184 } 185 // Got this far. SUCCESS!! 186 return true; 187 } 188 } 189 190 191