Mercurial > hg > truffle
annotate graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64TestMemoryOp.java @ 19575:b017118b412b
Ensure a canonical ordering of inputs for commutative binary operations
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Wed, 18 Feb 2015 10:36:31 -0800 |
parents | 35ae3e916582 |
children | 8fc336a04d77 |
rev | line source |
---|---|
14707
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
1 /* |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
4 * |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
8 * |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
14 * |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
18 * |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
21 * questions. |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
22 */ |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.lir.amd64; |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
24 |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
25 import static com.oracle.graal.api.code.ValueUtil.*; |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
26 import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
27 |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
28 import com.oracle.graal.api.meta.*; |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
29 import com.oracle.graal.asm.amd64.*; |
15193
96bb07a5d667
Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents:
14931
diff
changeset
|
30 import com.oracle.graal.compiler.common.*; |
14707
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
31 import com.oracle.graal.lir.*; |
14931
d45e8c306349
use MemOp as base class for new memory ops
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14707
diff
changeset
|
32 import com.oracle.graal.lir.amd64.AMD64Move.MemOp; |
14707
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
33 import com.oracle.graal.lir.asm.*; |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
34 |
14931
d45e8c306349
use MemOp as base class for new memory ops
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14707
diff
changeset
|
35 public class AMD64TestMemoryOp extends MemOp { |
14707
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
36 |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
37 @Use({REG, CONST}) protected Value y; |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
38 |
14931
d45e8c306349
use MemOp as base class for new memory ops
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14707
diff
changeset
|
39 public AMD64TestMemoryOp(Kind kind, AMD64AddressValue x, Value y, LIRFrameState state) { |
d45e8c306349
use MemOp as base class for new memory ops
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14707
diff
changeset
|
40 super(kind, x, state); |
14707
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
41 this.y = y; |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
42 this.state = state; |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
43 } |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
44 |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
45 @Override |
14931
d45e8c306349
use MemOp as base class for new memory ops
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14707
diff
changeset
|
46 public void emitMemAccess(CompilationResultBuilder crb, AMD64MacroAssembler masm) { |
14707
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
47 if (isRegister(y)) { |
15977
eff84c561a95
Fix AMD64Assembler.testl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15193
diff
changeset
|
48 switch (kind) { |
14707
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
49 case Int: |
14931
d45e8c306349
use MemOp as base class for new memory ops
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14707
diff
changeset
|
50 masm.testl(asIntReg(y), address.toAddress()); |
14707
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
51 break; |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
52 case Long: |
14931
d45e8c306349
use MemOp as base class for new memory ops
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14707
diff
changeset
|
53 masm.testq(asLongReg(y), address.toAddress()); |
14707
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
54 break; |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
55 default: |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
56 throw GraalInternalError.shouldNotReachHere(); |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
57 } |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
58 } else if (isConstant(y)) { |
15977
eff84c561a95
Fix AMD64Assembler.testl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15193
diff
changeset
|
59 switch (kind) { |
14707
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
60 case Int: |
14931
d45e8c306349
use MemOp as base class for new memory ops
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14707
diff
changeset
|
61 masm.testl(address.toAddress(), crb.asIntConst(y)); |
14707
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
62 break; |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
63 case Long: |
14931
d45e8c306349
use MemOp as base class for new memory ops
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14707
diff
changeset
|
64 masm.testq(address.toAddress(), crb.asIntConst(y)); |
14707
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
65 break; |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
66 default: |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
67 throw GraalInternalError.shouldNotReachHere(); |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
68 } |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
69 } else { |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
70 throw GraalInternalError.shouldNotReachHere(); |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
71 } |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
72 } |
14931
d45e8c306349
use MemOp as base class for new memory ops
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14707
diff
changeset
|
73 |
d45e8c306349
use MemOp as base class for new memory ops
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14707
diff
changeset
|
74 @Override |
17604
35ae3e916582
Make LIRInstruction an interface.
Josef Eisl <josef.eisl@jku.at>
parents:
15977
diff
changeset
|
75 public void verify() { |
14931
d45e8c306349
use MemOp as base class for new memory ops
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14707
diff
changeset
|
76 super.verify(); |
d45e8c306349
use MemOp as base class for new memory ops
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14707
diff
changeset
|
77 assert (kind == Kind.Int || kind == Kind.Long) && kind == y.getKind() : address + " " + y; |
d45e8c306349
use MemOp as base class for new memory ops
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14707
diff
changeset
|
78 } |
14707
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
79 } |