52 return value instanceof ConstantValue; 53 } 54 55 public static ConstantValue asConstantValue(Value value) { 56 assert value != null; 57 return (ConstantValue) value; 58 } 59 60 public static Constant asConstant(Value value) { 61 return asConstantValue(value).getConstant(); 62 } 63 64 public static boolean isJavaConstant(Value value) { 65 return isConstantValue(value) && asConstantValue(value).isJavaConstant(); 66 } 67 68 public static JavaConstant asJavaConstant(Value value) { 69 return asConstantValue(value).getJavaConstant(); 70 } 71 72 public static boolean isStackSlotValue(Value value) { 73 assert value != null; 74 return value instanceof StackSlot || value instanceof VirtualStackSlot; 75 } 76 77 public static boolean isVirtualStackSlot(Value value) { 78 assert value != null; 79 return value instanceof VirtualStackSlot; 80 } 81 82 public static VirtualStackSlot asVirtualStackSlot(Value value) { 83 assert value != null; 84 return (VirtualStackSlot) value; 85 } 86 87 public static boolean sameRegister(Value v1, Value v2) { 88 return isRegister(v1) && isRegister(v2) && asRegister(v1).equals(asRegister(v2)); 89 } 90 91 public static boolean sameRegister(Value v1, Value v2, Value v3) { | 52 return value instanceof ConstantValue; 53 } 54 55 public static ConstantValue asConstantValue(Value value) { 56 assert value != null; 57 return (ConstantValue) value; 58 } 59 60 public static Constant asConstant(Value value) { 61 return asConstantValue(value).getConstant(); 62 } 63 64 public static boolean isJavaConstant(Value value) { 65 return isConstantValue(value) && asConstantValue(value).isJavaConstant(); 66 } 67 68 public static JavaConstant asJavaConstant(Value value) { 69 return asConstantValue(value).getJavaConstant(); 70 } 71 72 public static boolean isIntConstant(Value value, long expected) { 73 if (isJavaConstant(value)) { 74 JavaConstant javaConstant = asJavaConstant(value); 75 if (javaConstant != null && javaConstant.getJavaKind().isNumericInteger()) { 76 return javaConstant.asLong() == expected; 77 } 78 } 79 return false; 80 } 81 82 public static boolean isStackSlotValue(Value value) { 83 assert value != null; 84 return value instanceof StackSlot || value instanceof VirtualStackSlot; 85 } 86 87 public static boolean isVirtualStackSlot(Value value) { 88 assert value != null; 89 return value instanceof VirtualStackSlot; 90 } 91 92 public static VirtualStackSlot asVirtualStackSlot(Value value) { 93 assert value != null; 94 return (VirtualStackSlot) value; 95 } 96 97 public static boolean sameRegister(Value v1, Value v2) { 98 return isRegister(v1) && isRegister(v2) && asRegister(v1).equals(asRegister(v2)); 99 } 100 101 public static boolean sameRegister(Value v1, Value v2, Value v3) { |