annotate graal/GraalCompiler/src/com/sun/c1x/ir/Binary.java @ 2852:c6bdec623ef9

Move TypeCHeck to floating nodes, rename Nodes to aboid using an *Op suffix
author Gilles Duboscq <gilles.duboscq@oracle.com>
date Tue, 07 Jun 2011 12:10:27 +0200
parents graal/GraalCompiler/src/com/sun/c1x/ir/Op2.java@caf55daa41dc
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1 /*
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
2 * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
4 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
7 * published by the Free Software Foundation.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
8 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
13 * accompanied this code).
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
14 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
18 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
21 * questions.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
22 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
23 package com.sun.c1x.ir;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
24
2586
421da5f53b5e more Op2 changes
Lukas Stadler <lukas.stadler@jku.at>
parents: 2585
diff changeset
25 import com.oracle.graal.graph.*;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
26 import com.sun.c1x.util.*;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
27 import com.sun.cri.bytecode.*;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
28 import com.sun.cri.ci.*;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
29
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
30 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
31 * The {@code Op2} class is the base of arithmetic and logic operations with two inputs.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
32 */
2852
c6bdec623ef9 Move TypeCHeck to floating nodes, rename Nodes to aboid using an *Op suffix
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2847
diff changeset
33 public abstract class Binary extends FloatingNode {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
34
2585
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
35 private static final int INPUT_COUNT = 2;
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
36 private static final int INPUT_X = 0;
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
37 private static final int INPUT_Y = 1;
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
38
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
39 private static final int SUCCESSOR_COUNT = 0;
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
40
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
41 @Override
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
42 protected int inputCount() {
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
43 return super.inputCount() + INPUT_COUNT;
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
44 }
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
45
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
46 @Override
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
47 protected int successorCount() {
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
48 return super.successorCount() + SUCCESSOR_COUNT;
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
49 }
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
50
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
51 /**
2592
fec99fc30af1 checkstyle fixes, updated AccessArray + subclasses
Lukas Stadler <lukas.stadler@jku.at>
parents: 2587
diff changeset
52 * The first input to this instruction.
2585
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
53 */
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
54 public Value x() {
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
55 return (Value) inputs().get(super.inputCount() + INPUT_X);
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
56 }
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
57
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
58 public Value setX(Value n) {
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
59 return (Value) inputs().set(super.inputCount() + INPUT_X, n);
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
60 }
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
61
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
62 /**
2592
fec99fc30af1 checkstyle fixes, updated AccessArray + subclasses
Lukas Stadler <lukas.stadler@jku.at>
parents: 2587
diff changeset
63 * The second input to this instruction.
2585
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
64 */
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
65 public Value y() {
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
66 return (Value) inputs().get(super.inputCount() + INPUT_Y);
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
67 }
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
68
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
69 public Value setY(Value n) {
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
70 return (Value) inputs().set(super.inputCount() + INPUT_Y, n);
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
71 }
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
72
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
73 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
74 * The opcode of this instruction.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
75 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
76 public final int opcode;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
77
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
78 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
79 * Creates a new Op2 instance.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
80 * @param kind the result type of this instruction
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
81 * @param opcode the bytecode opcode
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
82 * @param x the first input instruction
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
83 * @param y the second input instruction
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
84 */
2852
c6bdec623ef9 Move TypeCHeck to floating nodes, rename Nodes to aboid using an *Op suffix
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2847
diff changeset
85 public Binary(CiKind kind, int opcode, Value x, Value y, int inputCount, int successorCount, Graph graph) {
2587
51ebe5f0516f changed NegateOp, more Op2 changes (generic inputValuesDo impl)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2586
diff changeset
86 super(kind, inputCount + INPUT_COUNT, successorCount + SUCCESSOR_COUNT, graph);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
87 this.opcode = opcode;
2585
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
88 setX(x);
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
89 setY(y);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
90 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
91
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
92 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
93 * Swaps the operands of this instruction. This is only legal for commutative operations.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
94 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
95 public void swapOperands() {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
96 assert Bytecodes.isCommutative(opcode);
2585
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
97 Value t = x();
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
98 setX(y());
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
99 setY(t);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
100 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
101
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
102 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
103 public int valueNumber() {
2585
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
104 return Util.hash2(opcode, x(), y());
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
105 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
106
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
107 @Override
2805
c3f64b66fc78 Towards removing the next pointer from Constant and ArithmeticOp
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2594
diff changeset
108 public boolean valueEqual(Node i) {
2852
c6bdec623ef9 Move TypeCHeck to floating nodes, rename Nodes to aboid using an *Op suffix
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2847
diff changeset
109 if (i instanceof Binary) {
c6bdec623ef9 Move TypeCHeck to floating nodes, rename Nodes to aboid using an *Op suffix
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2847
diff changeset
110 Binary o = (Binary) i;
2585
3e0e65161345 new node layout: Op2
Lukas Stadler <lukas.stadler@jku.at>
parents: 2509
diff changeset
111 return opcode == o.opcode && x() == o.x() && y() == o.y();
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
112 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
113 return false;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
114 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
115 }