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