src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/gen/PhiResolver.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/gen

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/gen/PhiResolver.java

Print this page




  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 package org.graalvm.compiler.lir.gen;
  24 
  25 import static org.graalvm.compiler.lir.LIRValueUtil.isVariable;
  26 import static jdk.vm.ci.code.ValueUtil.isIllegal;
  27 import static jdk.vm.ci.code.ValueUtil.isLegal;
  28 import static jdk.vm.ci.meta.Value.ILLEGAL;
  29 
  30 import java.util.ArrayList;
  31 import java.util.HashMap;
  32 import java.util.List;
  33 
  34 import org.graalvm.compiler.core.common.CollectionsFactory;
  35 import org.graalvm.compiler.core.common.cfg.AbstractBlockBase;
  36 import org.graalvm.compiler.lir.LIRInsertionBuffer;
  37 import org.graalvm.compiler.lir.LIRInstruction;
  38 import org.graalvm.compiler.lir.gen.LIRGeneratorTool.MoveFactory;


  39 
  40 import jdk.vm.ci.meta.AllocatableValue;
  41 import jdk.vm.ci.meta.Value;
  42 
  43 /**
  44  * Converts phi instructions into moves.
  45  *
  46  * Resolves cycles:
  47  *
  48  * <pre>
  49  *
  50  *  r1 := r2  becomes  temp := r1
  51  *  r2 := r1           r1 := r2
  52  *                     r2 := temp
  53  * </pre>
  54  *
  55  * and orders moves:
  56  *
  57  * <pre>
  58  *  r2 := r3  becomes  r1 := r2


 113     }
 114 
 115     private final LIRGeneratorTool gen;
 116     private final MoveFactory moveFactory;
 117     private final LIRInsertionBuffer buffer;
 118     private final int insertBefore;
 119 
 120     /**
 121      * The operand loop header phi for the operand currently being process in {@link #dispose()}.
 122      */
 123     private PhiResolverNode loop;
 124 
 125     private Value temp;
 126 
 127     private final ArrayList<PhiResolverNode> variableOperands = new ArrayList<>(3);
 128     private final ArrayList<PhiResolverNode> otherOperands = new ArrayList<>(3);
 129 
 130     /**
 131      * Maps operands to nodes.
 132      */
 133     private final HashMap<Value, PhiResolverNode> operandToNodeMap = CollectionsFactory.newMap();
 134 
 135     public static PhiResolver create(LIRGeneratorTool gen) {
 136         AbstractBlockBase<?> block = gen.getCurrentBlock();
 137         assert block != null;
 138         List<LIRInstruction> instructions = gen.getResult().getLIR().getLIRforBlock(block);
 139 
 140         return new PhiResolver(gen, new LIRInsertionBuffer(), instructions, instructions.size());
 141     }
 142 
 143     public static PhiResolver create(LIRGeneratorTool gen, LIRInsertionBuffer buffer, List<LIRInstruction> instructions, int insertBefore) {
 144         return new PhiResolver(gen, buffer, instructions, insertBefore);
 145     }
 146 
 147     protected PhiResolver(LIRGeneratorTool gen, LIRInsertionBuffer buffer, List<LIRInstruction> instructions, int insertBefore) {
 148         this.gen = gen;
 149         moveFactory = gen.getSpillMoveFactory();
 150         temp = ILLEGAL;
 151 
 152         this.buffer = buffer;
 153         this.buffer.init(instructions);
 154         this.insertBefore = insertBefore;
 155 
 156     }
 157 
 158     public void dispose() {




  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 package org.graalvm.compiler.lir.gen;
  24 
  25 import static org.graalvm.compiler.lir.LIRValueUtil.isVariable;
  26 import static jdk.vm.ci.code.ValueUtil.isIllegal;
  27 import static jdk.vm.ci.code.ValueUtil.isLegal;
  28 import static jdk.vm.ci.meta.Value.ILLEGAL;
  29 
  30 import java.util.ArrayList;

  31 import java.util.List;
  32 

  33 import org.graalvm.compiler.core.common.cfg.AbstractBlockBase;
  34 import org.graalvm.compiler.lir.LIRInsertionBuffer;
  35 import org.graalvm.compiler.lir.LIRInstruction;
  36 import org.graalvm.compiler.lir.gen.LIRGeneratorTool.MoveFactory;
  37 import org.graalvm.util.Equivalence;
  38 import org.graalvm.util.EconomicMap;
  39 
  40 import jdk.vm.ci.meta.AllocatableValue;
  41 import jdk.vm.ci.meta.Value;
  42 
  43 /**
  44  * Converts phi instructions into moves.
  45  *
  46  * Resolves cycles:
  47  *
  48  * <pre>
  49  *
  50  *  r1 := r2  becomes  temp := r1
  51  *  r2 := r1           r1 := r2
  52  *                     r2 := temp
  53  * </pre>
  54  *
  55  * and orders moves:
  56  *
  57  * <pre>
  58  *  r2 := r3  becomes  r1 := r2


 113     }
 114 
 115     private final LIRGeneratorTool gen;
 116     private final MoveFactory moveFactory;
 117     private final LIRInsertionBuffer buffer;
 118     private final int insertBefore;
 119 
 120     /**
 121      * The operand loop header phi for the operand currently being process in {@link #dispose()}.
 122      */
 123     private PhiResolverNode loop;
 124 
 125     private Value temp;
 126 
 127     private final ArrayList<PhiResolverNode> variableOperands = new ArrayList<>(3);
 128     private final ArrayList<PhiResolverNode> otherOperands = new ArrayList<>(3);
 129 
 130     /**
 131      * Maps operands to nodes.
 132      */
 133     private final EconomicMap<Value, PhiResolverNode> operandToNodeMap = EconomicMap.create(Equivalence.DEFAULT);
 134 
 135     public static PhiResolver create(LIRGeneratorTool gen) {
 136         AbstractBlockBase<?> block = gen.getCurrentBlock();
 137         assert block != null;
 138         ArrayList<LIRInstruction> instructions = gen.getResult().getLIR().getLIRforBlock(block);
 139 
 140         return new PhiResolver(gen, new LIRInsertionBuffer(), instructions, instructions.size());
 141     }
 142 
 143     public static PhiResolver create(LIRGeneratorTool gen, LIRInsertionBuffer buffer, List<LIRInstruction> instructions, int insertBefore) {
 144         return new PhiResolver(gen, buffer, instructions, insertBefore);
 145     }
 146 
 147     protected PhiResolver(LIRGeneratorTool gen, LIRInsertionBuffer buffer, List<LIRInstruction> instructions, int insertBefore) {
 148         this.gen = gen;
 149         moveFactory = gen.getSpillMoveFactory();
 150         temp = ILLEGAL;
 151 
 152         this.buffer = buffer;
 153         this.buffer.init(instructions);
 154         this.insertBefore = insertBefore;
 155 
 156     }
 157 
 158     public void dispose() {


src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/gen/PhiResolver.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File