Mercurial > hg > truffle
comparison graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Arithmetic.java @ 19526:8fc336a04d77
Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Fri, 20 Feb 2015 22:22:55 +0100 |
parents | 437894ecd7c5 |
children | 89c729e9e0a4 |
comparison
equal
deleted
inserted
replaced
19525:35481bcb5882 | 19526:8fc336a04d77 |
---|---|
61 // @formatter:on | 61 // @formatter:on |
62 | 62 |
63 /** | 63 /** |
64 * Unary operation with separate source and destination operand. | 64 * Unary operation with separate source and destination operand. |
65 */ | 65 */ |
66 public static class Unary2Op extends AMD64LIRInstruction { | 66 public static final class Unary2Op extends AMD64LIRInstruction { |
67 | 67 |
68 public static final LIRInstructionClass<Unary2Op> TYPE = LIRInstructionClass.create(Unary2Op.class); | |
68 @Opcode private final AMD64Arithmetic opcode; | 69 @Opcode private final AMD64Arithmetic opcode; |
69 @Def({REG}) protected AllocatableValue result; | 70 @Def({REG}) protected AllocatableValue result; |
70 @Use({REG, STACK}) protected AllocatableValue x; | 71 @Use({REG, STACK}) protected AllocatableValue x; |
71 | 72 |
72 public Unary2Op(AMD64Arithmetic opcode, AllocatableValue result, AllocatableValue x) { | 73 public Unary2Op(AMD64Arithmetic opcode, AllocatableValue result, AllocatableValue x) { |
74 super(TYPE); | |
73 this.opcode = opcode; | 75 this.opcode = opcode; |
74 this.result = result; | 76 this.result = result; |
75 this.x = x; | 77 this.x = x; |
76 } | 78 } |
77 | 79 |
82 } | 84 } |
83 | 85 |
84 /** | 86 /** |
85 * Unary operation with separate source and destination operand but register only. | 87 * Unary operation with separate source and destination operand but register only. |
86 */ | 88 */ |
87 public static class Unary2RegOp extends AMD64LIRInstruction { | 89 public static final class Unary2RegOp extends AMD64LIRInstruction { |
90 public static final LIRInstructionClass<Unary2RegOp> TYPE = LIRInstructionClass.create(Unary2RegOp.class); | |
88 | 91 |
89 @Opcode private final AMD64Arithmetic opcode; | 92 @Opcode private final AMD64Arithmetic opcode; |
90 @Def({REG}) protected AllocatableValue result; | 93 @Def({REG}) protected AllocatableValue result; |
91 @Use({REG}) protected AllocatableValue x; | 94 @Use({REG}) protected AllocatableValue x; |
92 | 95 |
93 public Unary2RegOp(AMD64Arithmetic opcode, AllocatableValue result, AllocatableValue x) { | 96 public Unary2RegOp(AMD64Arithmetic opcode, AllocatableValue result, AllocatableValue x) { |
97 super(TYPE); | |
94 this.opcode = opcode; | 98 this.opcode = opcode; |
95 this.result = result; | 99 this.result = result; |
96 this.x = x; | 100 this.x = x; |
97 } | 101 } |
98 | 102 |
104 | 108 |
105 /** | 109 /** |
106 * Unary operation with single operand for source and destination. | 110 * Unary operation with single operand for source and destination. |
107 */ | 111 */ |
108 public static class Unary1Op extends AMD64LIRInstruction { | 112 public static class Unary1Op extends AMD64LIRInstruction { |
113 public static final LIRInstructionClass<Unary1Op> TYPE = LIRInstructionClass.create(Unary1Op.class); | |
109 | 114 |
110 @Opcode private final AMD64Arithmetic opcode; | 115 @Opcode private final AMD64Arithmetic opcode; |
111 @Def({REG, HINT}) protected AllocatableValue result; | 116 @Def({REG, HINT}) protected AllocatableValue result; |
112 @Use({REG, STACK}) protected AllocatableValue x; | 117 @Use({REG, STACK}) protected AllocatableValue x; |
113 | 118 |
114 public Unary1Op(AMD64Arithmetic opcode, AllocatableValue result, AllocatableValue x) { | 119 public Unary1Op(AMD64Arithmetic opcode, AllocatableValue result, AllocatableValue x) { |
120 super(TYPE); | |
115 this.opcode = opcode; | 121 this.opcode = opcode; |
116 this.result = result; | 122 this.result = result; |
117 this.x = x; | 123 this.x = x; |
118 } | 124 } |
119 | 125 |
125 } | 131 } |
126 | 132 |
127 /** | 133 /** |
128 * Unary operation with separate memory source and destination operand. | 134 * Unary operation with separate memory source and destination operand. |
129 */ | 135 */ |
130 public static class Unary2MemoryOp extends MemOp { | 136 public static final class Unary2MemoryOp extends MemOp { |
137 public static final LIRInstructionClass<Unary2MemoryOp> TYPE = LIRInstructionClass.create(Unary2MemoryOp.class); | |
131 | 138 |
132 @Opcode private final AMD64Arithmetic opcode; | 139 @Opcode private final AMD64Arithmetic opcode; |
133 @Def({REG}) protected AllocatableValue result; | 140 @Def({REG}) protected AllocatableValue result; |
134 | 141 |
135 public Unary2MemoryOp(AMD64Arithmetic opcode, AllocatableValue result, Kind kind, AMD64AddressValue address, LIRFrameState state) { | 142 public Unary2MemoryOp(AMD64Arithmetic opcode, AllocatableValue result, Kind kind, AMD64AddressValue address, LIRFrameState state) { |
136 super(kind, address, state); | 143 super(TYPE, kind, address, state); |
137 this.opcode = opcode; | 144 this.opcode = opcode; |
138 this.result = result; | 145 this.result = result; |
139 } | 146 } |
140 | 147 |
141 @Override | 148 @Override |
147 /** | 154 /** |
148 * Binary operation with two operands. The first source operand is combined with the | 155 * Binary operation with two operands. The first source operand is combined with the |
149 * destination. The second source operand may be a stack slot. | 156 * destination. The second source operand may be a stack slot. |
150 */ | 157 */ |
151 public static class BinaryRegStack extends AMD64LIRInstruction { | 158 public static class BinaryRegStack extends AMD64LIRInstruction { |
159 public static final LIRInstructionClass<BinaryRegStack> TYPE = LIRInstructionClass.create(BinaryRegStack.class); | |
152 | 160 |
153 @Opcode private final AMD64Arithmetic opcode; | 161 @Opcode private final AMD64Arithmetic opcode; |
154 @Def({REG, HINT}) protected AllocatableValue result; | 162 @Def({REG, HINT}) protected AllocatableValue result; |
155 @Use({REG, STACK}) protected AllocatableValue x; | 163 @Use({REG, STACK}) protected AllocatableValue x; |
156 @Alive({REG, STACK}) protected AllocatableValue y; | 164 @Alive({REG, STACK}) protected AllocatableValue y; |
157 | 165 |
158 public BinaryRegStack(AMD64Arithmetic opcode, AllocatableValue result, AllocatableValue x, AllocatableValue y) { | 166 public BinaryRegStack(AMD64Arithmetic opcode, AllocatableValue result, AllocatableValue x, AllocatableValue y) { |
167 super(TYPE); | |
159 this.opcode = opcode; | 168 this.opcode = opcode; |
160 this.result = result; | 169 this.result = result; |
161 this.x = x; | 170 this.x = x; |
162 this.y = y; | 171 this.y = y; |
163 } | 172 } |
178 | 187 |
179 /** | 188 /** |
180 * Binary operation with two operands. The first source operand is combined with the | 189 * Binary operation with two operands. The first source operand is combined with the |
181 * destination. The second source operand may be a stack slot. | 190 * destination. The second source operand may be a stack slot. |
182 */ | 191 */ |
183 public static class BinaryMemory extends AMD64LIRInstruction { | 192 public static final class BinaryMemory extends AMD64LIRInstruction { |
193 public static final LIRInstructionClass<BinaryMemory> TYPE = LIRInstructionClass.create(BinaryMemory.class); | |
184 | 194 |
185 @Opcode private final AMD64Arithmetic opcode; | 195 @Opcode private final AMD64Arithmetic opcode; |
186 @Def({REG, HINT}) protected AllocatableValue result; | 196 @Def({REG, HINT}) protected AllocatableValue result; |
187 @Use({REG}) protected AllocatableValue x; | 197 @Use({REG}) protected AllocatableValue x; |
188 protected final Kind kind; | 198 protected final Kind kind; |
189 @Alive({COMPOSITE}) protected AMD64AddressValue location; | 199 @Alive({COMPOSITE}) protected AMD64AddressValue location; |
190 @State protected LIRFrameState state; | 200 @State protected LIRFrameState state; |
191 | 201 |
192 public BinaryMemory(AMD64Arithmetic opcode, Kind kind, AllocatableValue result, AllocatableValue x, AMD64AddressValue location, LIRFrameState state) { | 202 public BinaryMemory(AMD64Arithmetic opcode, Kind kind, AllocatableValue result, AllocatableValue x, AMD64AddressValue location, LIRFrameState state) { |
203 super(TYPE); | |
193 this.opcode = opcode; | 204 this.opcode = opcode; |
194 this.result = result; | 205 this.result = result; |
195 this.x = x; | 206 this.x = x; |
196 this.location = location; | 207 this.location = location; |
197 this.kind = kind; | 208 this.kind = kind; |
217 | 228 |
218 /** | 229 /** |
219 * Binary operation with two operands. The first source operand is combined with the | 230 * Binary operation with two operands. The first source operand is combined with the |
220 * destination. The second source operand must be a register. | 231 * destination. The second source operand must be a register. |
221 */ | 232 */ |
222 public static class BinaryRegReg extends AMD64LIRInstruction { | 233 public static final class BinaryRegReg extends AMD64LIRInstruction { |
234 public static final LIRInstructionClass<BinaryRegReg> TYPE = LIRInstructionClass.create(BinaryRegReg.class); | |
223 | 235 |
224 @Opcode private final AMD64Arithmetic opcode; | 236 @Opcode private final AMD64Arithmetic opcode; |
225 @Def({REG, HINT}) protected AllocatableValue result; | 237 @Def({REG, HINT}) protected AllocatableValue result; |
226 @Use({REG, STACK}) protected AllocatableValue x; | 238 @Use({REG, STACK}) protected AllocatableValue x; |
227 @Alive({REG}) protected AllocatableValue y; | 239 @Alive({REG}) protected AllocatableValue y; |
228 | 240 |
229 public BinaryRegReg(AMD64Arithmetic opcode, AllocatableValue result, AllocatableValue x, AllocatableValue y) { | 241 public BinaryRegReg(AMD64Arithmetic opcode, AllocatableValue result, AllocatableValue x, AllocatableValue y) { |
242 super(TYPE); | |
230 this.opcode = opcode; | 243 this.opcode = opcode; |
231 this.result = result; | 244 this.result = result; |
232 this.x = x; | 245 this.x = x; |
233 this.y = y; | 246 this.y = y; |
234 } | 247 } |
248 } | 261 } |
249 | 262 |
250 /** | 263 /** |
251 * Binary operation with single source/destination operand and one constant. | 264 * Binary operation with single source/destination operand and one constant. |
252 */ | 265 */ |
253 public static class BinaryRegConst extends AMD64LIRInstruction { | 266 public static final class BinaryRegConst extends AMD64LIRInstruction { |
267 public static final LIRInstructionClass<BinaryRegConst> TYPE = LIRInstructionClass.create(BinaryRegConst.class); | |
254 | 268 |
255 @Opcode private final AMD64Arithmetic opcode; | 269 @Opcode private final AMD64Arithmetic opcode; |
256 @Def({REG, HINT}) protected AllocatableValue result; | 270 @Def({REG, HINT}) protected AllocatableValue result; |
257 @Use({REG, STACK}) protected AllocatableValue x; | 271 @Use({REG, STACK}) protected AllocatableValue x; |
258 protected JavaConstant y; | 272 protected JavaConstant y; |
259 | 273 |
260 public BinaryRegConst(AMD64Arithmetic opcode, AllocatableValue result, AllocatableValue x, JavaConstant y) { | 274 public BinaryRegConst(AMD64Arithmetic opcode, AllocatableValue result, AllocatableValue x, JavaConstant y) { |
275 super(TYPE); | |
261 this.opcode = opcode; | 276 this.opcode = opcode; |
262 this.result = result; | 277 this.result = result; |
263 this.x = x; | 278 this.x = x; |
264 this.y = y; | 279 this.y = y; |
265 } | 280 } |
279 | 294 |
280 /** | 295 /** |
281 * Commutative binary operation with two operands. One of the operands is combined with the | 296 * Commutative binary operation with two operands. One of the operands is combined with the |
282 * result. | 297 * result. |
283 */ | 298 */ |
284 public static class BinaryCommutative extends AMD64LIRInstruction { | 299 public static final class BinaryCommutative extends AMD64LIRInstruction { |
300 public static final LIRInstructionClass<BinaryCommutative> TYPE = LIRInstructionClass.create(BinaryCommutative.class); | |
285 | 301 |
286 @Opcode private final AMD64Arithmetic opcode; | 302 @Opcode private final AMD64Arithmetic opcode; |
287 @Def({REG, HINT}) protected AllocatableValue result; | 303 @Def({REG, HINT}) protected AllocatableValue result; |
288 @Use({REG, STACK}) protected AllocatableValue x; | 304 @Use({REG, STACK}) protected AllocatableValue x; |
289 @Use({REG, STACK}) protected AllocatableValue y; | 305 @Use({REG, STACK}) protected AllocatableValue y; |
290 | 306 |
291 public BinaryCommutative(AMD64Arithmetic opcode, AllocatableValue result, AllocatableValue x, AllocatableValue y) { | 307 public BinaryCommutative(AMD64Arithmetic opcode, AllocatableValue result, AllocatableValue x, AllocatableValue y) { |
308 super(TYPE); | |
292 this.opcode = opcode; | 309 this.opcode = opcode; |
293 this.result = result; | 310 this.result = result; |
294 this.x = x; | 311 this.x = x; |
295 this.y = y; | 312 this.y = y; |
296 } | 313 } |
313 } | 330 } |
314 | 331 |
315 /** | 332 /** |
316 * Binary operation with separate source and destination and one constant operand. | 333 * Binary operation with separate source and destination and one constant operand. |
317 */ | 334 */ |
318 public static class BinaryRegStackConst extends AMD64LIRInstruction { | 335 public static final class BinaryRegStackConst extends AMD64LIRInstruction { |
336 public static final LIRInstructionClass<BinaryRegStackConst> TYPE = LIRInstructionClass.create(BinaryRegStackConst.class); | |
319 | 337 |
320 @Opcode private final AMD64Arithmetic opcode; | 338 @Opcode private final AMD64Arithmetic opcode; |
321 @Def({REG}) protected AllocatableValue result; | 339 @Def({REG}) protected AllocatableValue result; |
322 @Use({REG, STACK}) protected AllocatableValue x; | 340 @Use({REG, STACK}) protected AllocatableValue x; |
323 protected JavaConstant y; | 341 protected JavaConstant y; |
324 | 342 |
325 public BinaryRegStackConst(AMD64Arithmetic opcode, AllocatableValue result, AllocatableValue x, JavaConstant y) { | 343 public BinaryRegStackConst(AMD64Arithmetic opcode, AllocatableValue result, AllocatableValue x, JavaConstant y) { |
344 super(TYPE); | |
326 this.opcode = opcode; | 345 this.opcode = opcode; |
327 this.result = result; | 346 this.result = result; |
328 this.x = x; | 347 this.x = x; |
329 this.y = y; | 348 this.y = y; |
330 } | 349 } |
362 super.verify(); | 381 super.verify(); |
363 verifyKind(opcode, result, x, y); | 382 verifyKind(opcode, result, x, y); |
364 } | 383 } |
365 } | 384 } |
366 | 385 |
367 public static class MulHighOp extends AMD64LIRInstruction { | 386 public static final class MulHighOp extends AMD64LIRInstruction { |
387 public static final LIRInstructionClass<MulHighOp> TYPE = LIRInstructionClass.create(MulHighOp.class); | |
368 | 388 |
369 @Opcode private final AMD64Arithmetic opcode; | 389 @Opcode private final AMD64Arithmetic opcode; |
370 @Def({REG}) public AllocatableValue lowResult; | 390 @Def({REG}) public AllocatableValue lowResult; |
371 @Def({REG}) public AllocatableValue highResult; | 391 @Def({REG}) public AllocatableValue highResult; |
372 @Use({REG}) public AllocatableValue x; | 392 @Use({REG}) public AllocatableValue x; |
373 @Use({REG, STACK}) public AllocatableValue y; | 393 @Use({REG, STACK}) public AllocatableValue y; |
374 | 394 |
375 public MulHighOp(AMD64Arithmetic opcode, LIRKind kind, AllocatableValue y) { | 395 public MulHighOp(AMD64Arithmetic opcode, LIRKind kind, AllocatableValue y) { |
396 super(TYPE); | |
376 this.opcode = opcode; | 397 this.opcode = opcode; |
377 this.x = AMD64.rax.asValue(kind); | 398 this.x = AMD64.rax.asValue(kind); |
378 this.y = y; | 399 this.y = y; |
379 this.lowResult = AMD64.rax.asValue(kind); | 400 this.lowResult = AMD64.rax.asValue(kind); |
380 this.highResult = AMD64.rdx.asValue(kind); | 401 this.highResult = AMD64.rdx.asValue(kind); |
418 } | 439 } |
419 } | 440 } |
420 } | 441 } |
421 } | 442 } |
422 | 443 |
423 public static class DivRemOp extends AMD64LIRInstruction { | 444 public static final class DivRemOp extends AMD64LIRInstruction { |
445 public static final LIRInstructionClass<DivRemOp> TYPE = LIRInstructionClass.create(DivRemOp.class); | |
424 | 446 |
425 @Opcode private final AMD64Arithmetic opcode; | 447 @Opcode private final AMD64Arithmetic opcode; |
426 @Def public AllocatableValue divResult; | 448 @Def public AllocatableValue divResult; |
427 @Def public AllocatableValue remResult; | 449 @Def public AllocatableValue remResult; |
428 @Use protected AllocatableValue x; | 450 @Use protected AllocatableValue x; |
429 @Alive protected AllocatableValue y; | 451 @Alive protected AllocatableValue y; |
430 @State protected LIRFrameState state; | 452 @State protected LIRFrameState state; |
431 | 453 |
432 public DivRemOp(AMD64Arithmetic opcode, AllocatableValue x, AllocatableValue y, LIRFrameState state) { | 454 public DivRemOp(AMD64Arithmetic opcode, AllocatableValue x, AllocatableValue y, LIRFrameState state) { |
455 super(TYPE); | |
433 this.opcode = opcode; | 456 this.opcode = opcode; |
434 this.divResult = AMD64.rax.asValue(LIRKind.derive(x, y)); | 457 this.divResult = AMD64.rax.asValue(LIRKind.derive(x, y)); |
435 this.remResult = AMD64.rdx.asValue(LIRKind.derive(x, y)); | 458 this.remResult = AMD64.rdx.asValue(LIRKind.derive(x, y)); |
436 this.x = x; | 459 this.x = x; |
437 this.y = y; | 460 this.y = y; |
454 verifyKind(opcode, remResult, x, y); | 477 verifyKind(opcode, remResult, x, y); |
455 } | 478 } |
456 } | 479 } |
457 | 480 |
458 public static class FPDivRemOp extends AMD64LIRInstruction { | 481 public static class FPDivRemOp extends AMD64LIRInstruction { |
482 public static final LIRInstructionClass<FPDivRemOp> TYPE = LIRInstructionClass.create(FPDivRemOp.class); | |
459 | 483 |
460 @Opcode private final AMD64Arithmetic opcode; | 484 @Opcode private final AMD64Arithmetic opcode; |
461 @Def protected AllocatableValue result; | 485 @Def protected AllocatableValue result; |
462 @Use protected AllocatableValue x; | 486 @Use protected AllocatableValue x; |
463 @Use protected AllocatableValue y; | 487 @Use protected AllocatableValue y; |
464 @Temp protected AllocatableValue raxTemp; | 488 @Temp protected AllocatableValue raxTemp; |
465 | 489 |
466 public FPDivRemOp(AMD64Arithmetic opcode, AllocatableValue result, AllocatableValue x, AllocatableValue y) { | 490 public FPDivRemOp(AMD64Arithmetic opcode, AllocatableValue result, AllocatableValue x, AllocatableValue y) { |
491 super(TYPE); | |
467 this.opcode = opcode; | 492 this.opcode = opcode; |
468 this.result = result; | 493 this.result = result; |
469 this.raxTemp = AMD64.rax.asValue(LIRKind.value(Kind.Int)); | 494 this.raxTemp = AMD64.rax.asValue(LIRKind.value(Kind.Int)); |
470 this.x = x; | 495 this.x = x; |
471 this.y = y; | 496 this.y = y; |