Mercurial > hg > graal-jvmci-8
comparison graal/Compiler/src/com/sun/c1x/lir/LIROp1.java @ 2507:9ec15d6914ca
Pull over of compiler from maxine repository.
author | Thomas Wuerthinger <thomas@wuerthinger.net> |
---|---|
date | Wed, 27 Apr 2011 11:43:22 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2506:4a3bf8a5bf41 | 2507:9ec15d6914ca |
---|---|
1 /* | |
2 * Copyright (c) 2009, 2010, 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.util.*; | |
26 import com.sun.cri.ci.*; | |
27 | |
28 /** | |
29 * The {@code LIROp1} class definition. The LIROp1 instruction has only one input operand. | |
30 * | |
31 * @author Marcelo Cintra | |
32 */ | |
33 public class LIROp1 extends LIRInstruction { | |
34 | |
35 public enum LIRMoveKind { | |
36 Normal, Volatile, Unaligned | |
37 } | |
38 | |
39 public final CiKind kind; // the operand type | |
40 public final LIRMoveKind moveKind; // flag that indicate the kind of move | |
41 | |
42 /** | |
43 * Constructs a new LIROp1 instruction. | |
44 * | |
45 * @param opcode the instruction's opcode | |
46 * @param opr the first input operand | |
47 * @param result the operand that holds the result of this instruction | |
48 * @param kind the kind of this instruction | |
49 * @param info the object holding information needed to emit debug information | |
50 */ | |
51 public LIROp1(LIROpcode opcode, CiValue opr, CiValue result, CiKind kind, LIRDebugInfo info) { | |
52 super(opcode, result, info, false, 0, 0, opr); | |
53 this.kind = kind; | |
54 this.moveKind = LIRMoveKind.Normal; | |
55 assert isInRange(opcode, LIROpcode.BeginOp1, LIROpcode.EndOp1) : "The " + opcode + " is not a valid LIROp1 opcode"; | |
56 } | |
57 | |
58 /** | |
59 * Constructs a new LIROp1 instruction. | |
60 * | |
61 * @param opcode the instruction's opcode | |
62 * @param opr the first input operand | |
63 * @param result the operand that holds the result of this instruction | |
64 * @param kind the kind of this instruction | |
65 */ | |
66 public LIROp1(LIROpcode opcode, CiValue opr, CiValue result, CiKind kind) { | |
67 this(opcode, opr, result, kind, null); | |
68 } | |
69 | |
70 /** | |
71 * Constructs a new LIROp1 instruction. | |
72 * | |
73 * @param opcode the instruction's opcode | |
74 * @param opr the first input operand | |
75 * @param result the operand that holds the result of this instruction | |
76 */ | |
77 public LIROp1(LIROpcode opcode, CiValue opr, CiValue result) { | |
78 this(opcode, opr, result, CiKind.Illegal); | |
79 } | |
80 | |
81 /** | |
82 * Constructs a new LIROp1 instruction. | |
83 * | |
84 * @param opcode the instruction's opcode | |
85 * @param opr the first input operand | |
86 */ | |
87 public LIROp1(LIROpcode opcode, CiValue opr) { | |
88 this(opcode, opr, CiValue.IllegalValue); | |
89 } | |
90 | |
91 /** | |
92 * Constructs a new LIROp1 instruction. | |
93 * | |
94 * @param moveKind the kind of move the instruction represents | |
95 * @param operand the single input operand | |
96 * @param result the operand that holds the result of this instruction | |
97 * @param kind the kind of this instruction | |
98 * @param info the object holding information needed to emit debug information | |
99 */ | |
100 public LIROp1(LIRMoveKind moveKind, CiValue operand, CiValue result, CiKind kind, LIRDebugInfo info) { | |
101 super(LIROpcode.Move, result, info, false, 0, 0, operand); | |
102 this.kind = kind; | |
103 this.moveKind = moveKind; | |
104 } | |
105 | |
106 /** | |
107 * Constructs a new LIROp1 instruction. | |
108 * | |
109 * @param opcode the instruction's opcode | |
110 * @param opr the first input operand | |
111 * @param info the object holding information needed to emit debug information | |
112 */ | |
113 public LIROp1(LIROpcode opcode, CiValue opr, LIRDebugInfo info) { | |
114 super(opcode, CiValue.IllegalValue, info, false, 0, 0, opr); | |
115 this.kind = CiKind.Illegal; | |
116 this.moveKind = LIRMoveKind.Normal; | |
117 assert isInRange(opcode, LIROpcode.BeginOp1, LIROpcode.EndOp1) : "The " + opcode + " is not a valid LIROp1 opcode"; | |
118 } | |
119 | |
120 /** | |
121 * Gets the input operand of this instruction. | |
122 * | |
123 * @return opr the input operand. | |
124 */ | |
125 public CiValue operand() { | |
126 return operand(0); | |
127 } | |
128 | |
129 /** | |
130 * Gets the kind of move of this instruction. | |
131 * | |
132 * @return flags the constant that represents the move kind. | |
133 */ | |
134 public LIRMoveKind moveKind() { | |
135 assert code == LIROpcode.Move : "The opcode must be of type LIROpcode.Move in LIROp1"; | |
136 return moveKind; | |
137 } | |
138 | |
139 @Override | |
140 public void emitCode(LIRAssembler masm) { | |
141 masm.emitOp1(this); | |
142 } | |
143 | |
144 @Override | |
145 public String name() { | |
146 if (code == LIROpcode.Move) { | |
147 switch (moveKind()) { | |
148 case Normal: | |
149 return "move"; | |
150 case Unaligned: | |
151 return "unaligned move"; | |
152 case Volatile: | |
153 return "volatile_move"; | |
154 default: | |
155 throw Util.shouldNotReachHere(); | |
156 } | |
157 } else { | |
158 return super.name(); | |
159 } | |
160 } | |
161 | |
162 @Override | |
163 public boolean verify() { | |
164 switch (code) { | |
165 case Move: | |
166 assert (operand().isLegal()) && (result().isLegal()) : "Operand and result must be valid in a LIROp1 move instruction."; | |
167 break; | |
168 case NullCheck: | |
169 assert operand().isVariableOrRegister() : "Operand must be a register in a LIROp1 null check instruction."; | |
170 break; | |
171 case Return: | |
172 assert operand().isVariableOrRegister() || operand().isIllegal() : "Operand must be (register | illegal) in a LIROp1 return instruction."; | |
173 break; | |
174 } | |
175 return true; | |
176 } | |
177 } |