annotate graal/com.oracle.jvmci.asm.sparc/src/com/oracle/jvmci/asm/sparc/SPARCAddress.java @ 21708:6df25b1418be

moved com.oracle.asm.** to jvmci-util.jar (JBS:GRAAL-53)
author Doug Simon <doug.simon@oracle.com>
date Wed, 03 Jun 2015 18:06:44 +0200
parents graal/com.oracle.graal.asm.sparc/src/com/oracle/graal/asm/sparc/SPARCAddress.java@5024c80224c7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9825
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
1 /*
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
4 *
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
8 *
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
13 * accompanied this code).
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
14 *
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
18 *
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
21 * questions.
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
22 */
21708
6df25b1418be moved com.oracle.asm.** to jvmci-util.jar (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21673
diff changeset
23 package com.oracle.jvmci.asm.sparc;
21673
5024c80224c7 moved com.oracle.graal.[amd64|sparc] to com.oracle.jvmci.[amd64|sparc] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21556
diff changeset
24
5024c80224c7 moved com.oracle.graal.[amd64|sparc] to com.oracle.jvmci.[amd64|sparc] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21556
diff changeset
25 import static com.oracle.jvmci.sparc.SPARC.*;
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 9831
diff changeset
26
21708
6df25b1418be moved com.oracle.asm.** to jvmci-util.jar (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21673
diff changeset
27 import com.oracle.jvmci.code.*;
21673
5024c80224c7 moved com.oracle.graal.[amd64|sparc] to com.oracle.jvmci.[amd64|sparc] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21556
diff changeset
28 import com.oracle.jvmci.sparc.*;
9825
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
29
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
30 public class SPARCAddress extends AbstractAddress {
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
31
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
32 private final Register base;
10694
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
33 private final Register index;
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
34 private final int displacement;
9825
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
35
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
36 /**
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
37 * Creates an {@link SPARCAddress} with given base register, no scaling and a given
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
38 * displacement.
15345
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15193
diff changeset
39 *
9825
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
40 * @param base the base register
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
41 * @param displacement the displacement
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
42 */
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
43 public SPARCAddress(Register base, int displacement) {
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9825
diff changeset
44 this.base = base;
10694
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
45 this.index = Register.None;
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9825
diff changeset
46 this.displacement = displacement;
9825
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
47 }
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
48
10694
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
49 /**
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
50 * Creates an {@link SPARCAddress} with given base register, no scaling and a given index.
15345
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15193
diff changeset
51 *
10694
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
52 * @param base the base register
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
53 * @param index the index register
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
54 */
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
55 public SPARCAddress(Register base, Register index) {
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
56 this.base = base;
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
57 this.index = index;
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
58 this.displacement = 0;
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
59 }
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
60
9825
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
61 @Override
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
62 public String toString() {
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
63 StringBuilder s = new StringBuilder();
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
64 s.append("[");
10694
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
65 String sep = "";
9825
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
66 if (!getBase().equals(Register.None)) {
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
67 s.append(getBase());
10694
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
68 sep = " + ";
9825
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
69 }
10694
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
70 if (!getIndex().equals(Register.None)) {
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
71 s.append(sep).append(getIndex());
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
72 sep = " + ";
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
73 } else {
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
74 if (getDisplacement() < 0) {
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
75 s.append(" - ").append(-getDisplacement());
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
76 } else if (getDisplacement() > 0) {
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
77 s.append(sep).append(getDisplacement());
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
78 }
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
79 }
9825
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
80 s.append("]");
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
81 return s.toString();
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
82 }
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
83
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
84 /**
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
85 * @return Base register that defines the start of the address computation. If not present, is
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
86 * denoted by {@link Register#None}.
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
87 */
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
88 public Register getBase() {
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
89 return base;
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
90 }
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
91
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
92 /**
10694
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
93 * @return Index register, the value of which is added to {@link #getBase}. If not present, is
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
94 * denoted by {@link Register#None}.
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
95 */
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
96 public Register getIndex() {
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
97 return index;
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
98 }
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
99
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
100 /**
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
101 * @return true if this address has an index register
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
102 */
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
103 public boolean hasIndex() {
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
104 return !getIndex().equals(Register.None);
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
105 }
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
106
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
107 /**
10871
c3b09d69dfde SPARC: fixes and more implementation; can now allocate objects
twisti
parents: 10694
diff changeset
108 * This method adds the stack-bias to the displacement if the base register is either
c3b09d69dfde SPARC: fixes and more implementation; can now allocate objects
twisti
parents: 10694
diff changeset
109 * {@link SPARC#sp} or {@link SPARC#fp}.
15345
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15193
diff changeset
110 *
9825
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
111 * @return Optional additive displacement.
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
112 */
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
113 public int getDisplacement() {
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
114 if (hasIndex()) {
21708
6df25b1418be moved com.oracle.asm.** to jvmci-util.jar (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21673
diff changeset
115 throw new InternalError("address has index register");
10694
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
116 }
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 9831
diff changeset
117 // TODO Should we also hide the register save area size here?
11803
eb2def6529bc HSAIL, SPARC: fix some occurrences of object identity, using equals() instead
Bernhard Urban <bernhard.urban@jku.at>
parents: 11233
diff changeset
118 if (getBase().equals(sp) || getBase().equals(fp)) {
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 9831
diff changeset
119 return displacement + STACK_BIAS;
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 9831
diff changeset
120 }
9825
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
121 return displacement;
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
122 }
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
123 }