comparison graal/GraalCompiler/src/com/sun/c1x/lir/LIROp2.java @ 2509:16b9a8b5ad39

Renamings Runtime=>GraalRuntime and Compiler=>GraalCompiler
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Wed, 27 Apr 2011 11:50:44 +0200
parents graal/Compiler/src/com/sun/c1x/lir/LIROp2.java@9ec15d6914ca
children
comparison
equal deleted inserted replaced
2508:fea94949e0a2 2509:16b9a8b5ad39
1 /*
2 * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23 package com.sun.c1x.lir;
24
25 import com.sun.c1x.ir.*;
26 import com.sun.cri.ci.*;
27
28 /**
29 * The {@code LIROp2} class represents a LIR instruction that performs an operation on two operands.
30 *
31 * @author Marcelo Cintra
32 * @author Thomas Wuerthinger
33 * @author Ben L. Titzer
34 */
35 public class LIROp2 extends LIRInstruction {
36
37 final Condition condition;
38
39 /**
40 * Constructs a new LIROp2 instruction.
41 *
42 * @param opcode the instruction's opcode
43 * @param condition the instruction's condition
44 * @param opr1 the first input operand
45 * @param opr2 the second input operand
46 * @param info the object holding information needed to emit debug information
47 */
48 public LIROp2(LIROpcode opcode, Condition condition, CiValue opr1, CiValue opr2, LIRDebugInfo info) {
49 super(opcode, CiValue.IllegalValue, info, false, 0, 0, opr1, opr2);
50 this.condition = condition;
51 assert opcode == LIROpcode.Cmp : "Instruction opcode should be of type LIROpcode.Cmp";
52 }
53
54 /**
55 * Constructs a new LIROp2 instruction.
56 *
57 * @param opcode the instruction's opcode
58 * @param condition the instruction's condition
59 * @param opr1 the first input operand
60 * @param opr2 the second input operand
61 * @param result the operand that holds the result of this instruction
62 */
63 public LIROp2(LIROpcode opcode, Condition condition, CiValue opr1, CiValue opr2, CiValue result) {
64 super(opcode, result, null, false, 0, 0, opr1, opr2);
65 this.condition = condition;
66 assert opcode == LIROpcode.Cmove : "Instruction opcode should be of type LIROpcode.Cmove";
67 }
68
69 /**
70 * Constructs a new LIROp2 instruction.
71 *
72 * @param opcode the instruction's opcode
73 * @param opr1 the first input operand
74 * @param opr2 the second input operand
75 * @param result the operand that holds the result of this instruction
76 * @param info the object holding information needed to emit debug information
77 * @param kind the kind of this instruction
78 */
79 public LIROp2(LIROpcode opcode, CiValue opr1, CiValue opr2, CiValue result, LIRDebugInfo info, CiKind kind, boolean hasCall) {
80 super(opcode, result, info, hasCall, 0, 0, opr1, opr2);
81 this.condition = null;
82 assert opcode != LIROpcode.Cmp && isInRange(opcode, LIROpcode.BeginOp2, LIROpcode.EndOp2) : "The " + opcode + " is not a valid LIROp2 opcode";
83 }
84
85 /**
86 * Constructs a new LIROp2 instruction.
87 *
88 * @param opcode the instruction's opcode
89 * @param opr1 the instruction's first operand
90 * @param opr2 the instruction's second operand
91 * @param result the operand that holds the result of this instruction
92 * @param info the object holding information needed to emit debug information
93 */
94 public LIROp2(LIROpcode opcode, CiValue opr1, CiValue opr2, CiValue result, LIRDebugInfo info) {
95 this(opcode, opr1, opr2, result, info, CiKind.Illegal, false);
96 }
97
98 /**
99 * Constructs a new LIROp2 instruction.
100 *
101 * @param opcode the instruction's opcode
102 * @param opr1 the instruction's first operand
103 * @param opr2 the instruction's second operand
104 * @param result the operand that holds the result of this instruction
105 */
106 public LIROp2(LIROpcode opcode, CiValue opr1, CiValue opr2, CiValue result) {
107 this(opcode, opr1, opr2, result, (LIRDebugInfo) null);
108 }
109
110 /**
111 * Constructs a new LIROp2 instruction.
112 *
113 * @param opcode the instruction's opcode
114 * @param opr1 the first input operand
115 * @param opr2 the second input operand
116 * @param result the operand that holds the result of this instruction
117 * @param tmp the temporary operand used by this instruction
118 */
119 public LIROp2(LIROpcode opcode, CiValue opr1, CiValue opr2, CiValue result, CiValue tmp) {
120 super(opcode, result, null, false, 0, 1, opr1, opr2, tmp);
121 this.condition = null;
122 assert opcode != LIROpcode.Cmp && isInRange(opcode, LIROpcode.BeginOp2, LIROpcode.EndOp2) : "The " + opcode + " is not a valid LIROp2 opcode";
123 }
124
125 /**
126 * Gets the first input operand.
127 *
128 * @return opr1 the first input operand
129 */
130 public CiValue operand1() {
131 return operand(0);
132 }
133
134 /**
135 * Gets the second input operand.
136 *
137 * @return opr2 the second input operand
138 */
139 public CiValue operand2() {
140 return operand(1);
141 }
142
143 /**
144 * Gets the temporary operand of this instruction.
145 *
146 * @return tmp the temporary operand of this instruction
147 *
148 */
149 public CiValue tmp() {
150 return operand(2);
151 }
152
153 /**
154 * Gets the condition of this instruction, if it is a Cmp or Cmove LIR instruction.
155 *
156 * @return condition the condition of this instruction
157 */
158 public Condition condition() {
159 assert code == LIROpcode.Cmp || code == LIROpcode.Cmove : "Field access only valid for cmp and cmove";
160 return condition;
161 }
162
163 /**
164 * Emit target assembly code for this instruction.
165 *
166 * @param masm the target assembler
167 */
168 @Override
169 public void emitCode(LIRAssembler masm) {
170 masm.emitOp2(this);
171 }
172
173 /**
174 * Prints this instruction.
175 */
176 @Override
177 public String operationString(OperandFormatter operandFmt) {
178 if (code == LIROpcode.Cmove) {
179 return condition.toString() + " " + super.operationString(operandFmt);
180 }
181 return super.operationString(operandFmt);
182 }
183 }
184