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.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 */
022public 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  SSAOptions(boolean scalarsOnly, boolean backwards, boolean insertUsePhis, java.util.Set<Object> heapTypes) {
120    this.scalarsOnly = scalarsOnly;
121    this.backwards = backwards;
122    this.insertUsePhis = insertUsePhis;
123    this.heapTypes = heapTypes;
124    this.insertPEIDeps = false;
125    this.excludeGuards = false;
126    scalarValid = false;
127    heapValid = false;
128  }
129
130  /**
131   * default configuration: just perform forward scalar SSA
132   */
133  SSAOptions() {
134    this.scalarsOnly = true;
135    this.backwards = false;
136    this.insertUsePhis = false;
137    this.heapTypes = null;
138    this.insertPEIDeps = false;
139    this.excludeGuards = false;
140    scalarValid = false;
141    heapValid = false;
142  }
143
144  /**
145   * Given a desired set of SSA Options, does this set of SSA Options
146   * describe enough information to satisfy the desire?
147   *
148   * @param d the desired SSA options
149   * @return whether this set of options satisfies the desired set
150   */
151  boolean satisfies(SSAOptions d) {
152    // 1. At a minimum , scalars must be valid
153    if (!scalarValid) {
154      return false;
155    }
156    // 2. OK, scalar SSA is valid.  Is this enough?
157    if (d.getScalarsOnly()) {
158      return true;
159    }
160    // 3. OK, we desire more than scalars.  So now, at least
161    //    Heap SSA must be valid
162    if (!heapValid) {
163      return false;
164    }
165    // 4. OK, Heap Array SSA is valid.  Do we have the correct
166    //    backwards, usePhis, and heapTypes??
167    if (backwards != d.getBackwards()) {
168      return false;
169    }
170    if (insertUsePhis != d.getInsertUsePhis()) {
171      return false;
172    }
173    if (insertPEIDeps != d.getInsertPEIDeps()) {
174      return false;
175    }
176    if (excludeGuards != d.getExcludeGuards()) {
177      return false;
178    }
179    if (heapTypes != d.getHeapTypes()) {
180      return false;
181    }
182    // Got this far.  SUCCESS!!
183    return true;
184  }
185}
186
187
188