comparison graal/com.oracle.max.cri/src/com/sun/cri/ci/CiValue.java @ 4183:9e0c1b4cfef5

Move all isXxx and asXxx out of CiValue and into their own util class.
author Christian Wimmer <Christian.Wimmer@Oracle.com>
date Mon, 02 Jan 2012 17:39:20 -0800
parents de7b3e7ae528
children
comparison
equal deleted inserted replaced
4182:de7b3e7ae528 4183:9e0c1b4cfef5
34 public static CiValue IllegalValue = new CiValue(CiKind.Illegal) { 34 public static CiValue IllegalValue = new CiValue(CiKind.Illegal) {
35 @Override 35 @Override
36 public String toString() { 36 public String toString() {
37 return "-"; 37 return "-";
38 } 38 }
39 @Override
40 public CiRegister asRegister() {
41 return CiRegister.None;
42 }
43 }; 39 };
44 40
45 /** 41 /**
46 * The kind of this value. 42 * The kind of this value.
47 */ 43 */
53 */ 49 */
54 protected CiValue(CiKind kind) { 50 protected CiValue(CiKind kind) {
55 this.kind = kind; 51 this.kind = kind;
56 } 52 }
57 53
58 public final boolean isVariableOrRegister() {
59 return this instanceof CiVariable || this instanceof CiRegisterValue;
60 }
61
62 public CiRegister asRegister() {
63 throw new InternalError("Not a register: " + this);
64 }
65
66 public final boolean isIllegal() {
67 return this == IllegalValue;
68 }
69
70 public final boolean isLegal() {
71 return this != IllegalValue;
72 }
73
74 /** 54 /**
75 * Determines if this value represents a slot on a stack. These values are created 55 * String representation of the kind, which should be the end of all {@link #toString()} implementation of subclasses.
76 * by the register allocator for spill slots. They are also used to model method
77 * parameters passed on the stack according to a specific calling convention.
78 */ 56 */
79 public final boolean isStackSlot() {
80 return this instanceof CiStackSlot;
81 }
82
83 public final boolean isRegister() {
84 return this instanceof CiRegisterValue;
85 }
86
87 public final boolean isVariable() {
88 return this instanceof CiVariable;
89 }
90
91 public final boolean isAddress() {
92 return this instanceof CiAddress;
93 }
94
95 public final boolean isConstant() {
96 return this instanceof CiConstant;
97 }
98
99 @Override
100 public abstract String toString();
101
102 protected final String kindSuffix() { 57 protected final String kindSuffix() {
103 return "|" + kind.typeChar; 58 return "|" + kind.typeChar;
104 } 59 }
105
106 public final boolean isConstant0() {
107 return isConstant() && ((CiConstant) this).asInt() == 0;
108 }
109 } 60 }