src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/alloc/lsra/ssa/SSALinearScanEliminateSpillMovePhase.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/alloc/lsra/ssa

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/alloc/lsra/ssa/SSALinearScanEliminateSpillMovePhase.java

Print this page




   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  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.alloc.lsra.ssa;
  24 
  25 import static org.graalvm.compiler.lir.LIRValueUtil.isStackSlotValue;
  26 import static jdk.vm.ci.code.ValueUtil.isRegister;

  27 
  28 import org.graalvm.compiler.core.common.cfg.AbstractBlockBase;
  29 import org.graalvm.compiler.debug.Debug;
  30 import org.graalvm.compiler.debug.Indent;
  31 import org.graalvm.compiler.lir.LIRInstruction;
  32 import org.graalvm.compiler.lir.StandardOp.LabelOp;
  33 import org.graalvm.compiler.lir.StandardOp.MoveOp;
  34 import org.graalvm.compiler.lir.alloc.lsra.Interval;
  35 import org.graalvm.compiler.lir.alloc.lsra.LinearScan;
  36 import org.graalvm.compiler.lir.alloc.lsra.LinearScanEliminateSpillMovePhase;
  37 
  38 public class SSALinearScanEliminateSpillMovePhase extends LinearScanEliminateSpillMovePhase {
  39 
  40     SSALinearScanEliminateSpillMovePhase(LinearScan allocator) {
  41         super(allocator);
  42     }
  43 
  44     @Override
  45     protected int firstInstructionOfInterest() {
  46         // also look at Labels as they define PHI values
  47         return 0;
  48     }
  49 


  65     private boolean isPhiResolutionMove(AbstractBlockBase<?> block, MoveOp move, Interval toInterval) {
  66         if (!toInterval.isSplitParent()) {
  67             return false;
  68         }
  69         if ((toInterval.from() & 1) == 1) {
  70             // phi intervals start at even positions.
  71             return false;
  72         }
  73         if (block.getSuccessorCount() != 1) {
  74             return false;
  75         }
  76         LIRInstruction op = allocator.instructionForId(toInterval.from());
  77         if (!(op instanceof LabelOp)) {
  78             return false;
  79         }
  80         AbstractBlockBase<?> intStartBlock = allocator.blockForId(toInterval.from());
  81         assert allocator.getLIR().getLIRforBlock(intStartBlock).get(0).equals(op);
  82         if (!block.getSuccessors()[0].equals(intStartBlock)) {
  83             return false;
  84         }
  85         try (Indent indet = Debug.indent()) {
  86             Debug.log("Is a move (%s) to phi interval %s", move, toInterval);

  87         }
  88         return true;
  89     }
  90 }


   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  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.alloc.lsra.ssa;
  24 

  25 import static jdk.vm.ci.code.ValueUtil.isRegister;
  26 import static org.graalvm.compiler.lir.LIRValueUtil.isStackSlotValue;
  27 
  28 import org.graalvm.compiler.core.common.cfg.AbstractBlockBase;
  29 import org.graalvm.compiler.debug.DebugContext;
  30 import org.graalvm.compiler.debug.Indent;
  31 import org.graalvm.compiler.lir.LIRInstruction;
  32 import org.graalvm.compiler.lir.StandardOp.LabelOp;
  33 import org.graalvm.compiler.lir.StandardOp.MoveOp;
  34 import org.graalvm.compiler.lir.alloc.lsra.Interval;
  35 import org.graalvm.compiler.lir.alloc.lsra.LinearScan;
  36 import org.graalvm.compiler.lir.alloc.lsra.LinearScanEliminateSpillMovePhase;
  37 
  38 public class SSALinearScanEliminateSpillMovePhase extends LinearScanEliminateSpillMovePhase {
  39 
  40     SSALinearScanEliminateSpillMovePhase(LinearScan allocator) {
  41         super(allocator);
  42     }
  43 
  44     @Override
  45     protected int firstInstructionOfInterest() {
  46         // also look at Labels as they define PHI values
  47         return 0;
  48     }
  49 


  65     private boolean isPhiResolutionMove(AbstractBlockBase<?> block, MoveOp move, Interval toInterval) {
  66         if (!toInterval.isSplitParent()) {
  67             return false;
  68         }
  69         if ((toInterval.from() & 1) == 1) {
  70             // phi intervals start at even positions.
  71             return false;
  72         }
  73         if (block.getSuccessorCount() != 1) {
  74             return false;
  75         }
  76         LIRInstruction op = allocator.instructionForId(toInterval.from());
  77         if (!(op instanceof LabelOp)) {
  78             return false;
  79         }
  80         AbstractBlockBase<?> intStartBlock = allocator.blockForId(toInterval.from());
  81         assert allocator.getLIR().getLIRforBlock(intStartBlock).get(0).equals(op);
  82         if (!block.getSuccessors()[0].equals(intStartBlock)) {
  83             return false;
  84         }
  85         DebugContext debug = allocator.getDebug();
  86         try (Indent indent = debug.indent()) {
  87             debug.log("Is a move (%s) to phi interval %s", move, toInterval);
  88         }
  89         return true;
  90     }
  91 }
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/alloc/lsra/ssa/SSALinearScanEliminateSpillMovePhase.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File