comparison graal/GraalCompiler/src/com/sun/c1x/ir/Convert.java @ 2594:092e628ddd5d

changed Constant and Convert, more StoreIndexed changes
author Lukas Stadler <lukas.stadler@jku.at>
date Thu, 05 May 2011 15:43:23 +0200
parents 16b9a8b5ad39
children c3f64b66fc78
comparison
equal deleted inserted replaced
2593:25c278ab287c 2594:092e628ddd5d
20 * or visit www.oracle.com if you need additional information or have any 20 * or visit www.oracle.com if you need additional information or have any
21 * questions. 21 * questions.
22 */ 22 */
23 package com.sun.c1x.ir; 23 package com.sun.c1x.ir;
24 24
25 import com.oracle.graal.graph.*;
25 import com.sun.c1x.debug.*; 26 import com.sun.c1x.debug.*;
26 import com.sun.c1x.util.*; 27 import com.sun.c1x.util.*;
27 import com.sun.cri.bytecode.*; 28 import com.sun.cri.bytecode.*;
28 import com.sun.cri.ci.*; 29 import com.sun.cri.ci.*;
29 30
30 /** 31 /**
31 * The {@code Convert} class represents a conversion between primitive types. 32 * The {@code Convert} class represents a conversion between primitive types.
32 *
33 * @author Ben L. Titzer
34 */ 33 */
35 public final class Convert extends Instruction { 34 public final class Convert extends Instruction {
35
36 private static final int INPUT_COUNT = 1;
37 private static final int INPUT_VALUE = 0;
38
39 private static final int SUCCESSOR_COUNT = 0;
40
41 @Override
42 protected int inputCount() {
43 return super.inputCount() + INPUT_COUNT;
44 }
45
46 @Override
47 protected int successorCount() {
48 return super.successorCount() + SUCCESSOR_COUNT;
49 }
50
51 /**
52 * The instruction which produces the input value to this instruction.
53 */
54 public Value value() {
55 return (Value) inputs().get(super.inputCount() + INPUT_VALUE);
56 }
57
58 public Value setValue(Value n) {
59 return (Value) inputs().set(super.inputCount() + INPUT_VALUE, n);
60 }
36 61
37 /** 62 /**
38 * The opcode for this conversion operation. 63 * The opcode for this conversion operation.
39 */ 64 */
40 public final int opcode; 65 public final int opcode;
41 66
42 Value value;
43
44 /** 67 /**
45 * Constructs a new Convert instance. 68 * Constructs a new Convert instance.
46 * @param opcode the bytecode representing the operation 69 * @param opcode the bytecode representing the operation
47 * @param value the instruction producing the input value 70 * @param value the instruction producing the input value
48 * @param kind the result type of this instruction 71 * @param kind the result type of this instruction
72 * @param graph
49 */ 73 */
50 public Convert(int opcode, Value value, CiKind kind) { 74 public Convert(int opcode, Value value, CiKind kind, Graph graph) {
51 super(kind); 75 super(kind, INPUT_COUNT, SUCCESSOR_COUNT, graph);
52 this.opcode = opcode; 76 this.opcode = opcode;
53 this.value = value; 77 setValue(value);
54 }
55
56 /**
57 * Gets the instruction which produces the input value to this instruction.
58 * @return the input value instruction
59 */
60 public Value value() {
61 return value;
62 }
63
64 @Override
65 public void inputValuesDo(ValueClosure closure) {
66 value = closure.apply(value);
67 } 78 }
68 79
69 @Override 80 @Override
70 public void accept(ValueVisitor v) { 81 public void accept(ValueVisitor v) {
71 v.visitConvert(this); 82 v.visitConvert(this);
72 } 83 }
73 84
74 @Override 85 @Override
75 public int valueNumber() { 86 public int valueNumber() {
76 return Util.hash1(opcode, value); 87 return Util.hash1(opcode, value());
77 } 88 }
78 89
79 @Override 90 @Override
80 public boolean valueEqual(Instruction i) { 91 public boolean valueEqual(Instruction i) {
81 if (i instanceof Convert) { 92 if (i instanceof Convert) {
82 Convert o = (Convert) i; 93 Convert o = (Convert) i;
83 return opcode == o.opcode && value == o.value; 94 return opcode == o.opcode && value() == o.value();
84 } 95 }
85 return false; 96 return false;
86 } 97 }
87 98
88 @Override 99 @Override