MoveType.java revision 12651:6ef01bd40ce2
198514Sluigi/* 298514Sluigi * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. 398514Sluigi * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 498514Sluigi * 598514Sluigi * This code is free software; you can redistribute it and/or modify it 698514Sluigi * under the terms of the GNU General Public License version 2 only, as 798514Sluigi * published by the Free Software Foundation. 898514Sluigi * 998514Sluigi * This code is distributed in the hope that it will be useful, but WITHOUT 1098514Sluigi * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1198514Sluigi * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1298514Sluigi * version 2 for more details (a copy is included in the LICENSE file that 1398514Sluigi * accompanied this code). 1498514Sluigi * 1598514Sluigi * You should have received a copy of the GNU General Public License version 1698514Sluigi * 2 along with this work; if not, write to the Free Software Foundation, 1798514Sluigi * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1898514Sluigi * 1998514Sluigi * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2098514Sluigi * or visit www.oracle.com if you need additional information or have any 2198514Sluigi * questions. 2298514Sluigi */ 2398514Sluigipackage org.graalvm.compiler.lir.profiling; 2498514Sluigi 2598514Sluigiimport static jdk.vm.ci.code.ValueUtil.isRegister; 2698514Sluigiimport static jdk.vm.ci.code.ValueUtil.isStackSlot; 2798514Sluigi 2898514Sluigiimport org.graalvm.compiler.debug.GraalError; 2998514Sluigiimport org.graalvm.compiler.lir.StandardOp.LoadConstantOp; 3098514Sluigiimport org.graalvm.compiler.lir.StandardOp.MoveOp; 3198514Sluigiimport org.graalvm.compiler.lir.StandardOp.ValueMoveOp; 3298514Sluigi 3398514Sluigiimport jdk.vm.ci.meta.AllocatableValue; 3498514Sluigiimport jdk.vm.ci.meta.Value; 3598514Sluigi 3698514Sluigienum MoveType { 3798514Sluigi REG2REG("Reg", "Reg"), 3898514Sluigi STACK2REG("Reg", "Stack"), 39 CONST2REG("Reg", "Const"), 40 REG2STACK("Stack", "Reg"), 41 CONST2STACK("Stack", "Const"), 42 STACK2STACK("Stack", "Stack"); 43 44 private final String name; 45 46 MoveType(String dst, String src) { 47 this.name = src + '2' + dst; 48 } 49 50 @Override 51 public String toString() { 52 return name; 53 } 54 55 public static MoveType get(MoveOp move) { 56 AllocatableValue dst = move.getResult(); 57 Value src = null; 58 if (move instanceof LoadConstantOp) { 59 if (isRegister(dst)) { 60 return CONST2REG; 61 } else if (isStackSlot(dst)) { 62 return CONST2STACK; 63 } 64 } else if (move instanceof ValueMoveOp) { 65 src = ((ValueMoveOp) move).getInput(); 66 if (isRegister(dst)) { 67 if (isRegister(src)) { 68 return REG2REG; 69 } else if (isStackSlot(src)) { 70 return STACK2REG; 71 } 72 } else if (isStackSlot(dst)) { 73 if (isRegister(src)) { 74 return REG2STACK; 75 } else if (isStackSlot(src)) { 76 return STACK2STACK; 77 } 78 } 79 } 80 throw GraalError.shouldNotReachHere(String.format("Unrecognized Move: %s dst=%s, src=%s", move, dst, src)); 81 } 82} 83