Mercurial > hg > graal-compiler
annotate graal/com.oracle.jvmci.asm.sparc/src/com/oracle/jvmci/asm/sparc/SPARCAddress.java @ 21711:1c41d00e6b2f
moved com.oracle.graal.bytecode to JVMCI namespace (JBS:GRAAL-53)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 03 Jun 2015 21:42:01 +0200 |
parents | 6df25b1418be |
children |
rev | line source |
---|---|
9825 | 1 /* |
2 * Copyright (c) 2013, 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 */ | |
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 | 29 |
30 public class SPARCAddress extends AbstractAddress { | |
31 | |
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 | 35 |
36 /** | |
37 * Creates an {@link SPARCAddress} with given base register, no scaling and a given | |
38 * displacement. | |
15345 | 39 * |
9825 | 40 * @param base the base register |
41 * @param displacement the displacement | |
42 */ | |
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 | 47 } |
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 | 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 | 61 @Override |
62 public String toString() { | |
63 StringBuilder s = new StringBuilder(); | |
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 | 66 if (!getBase().equals(Register.None)) { |
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 | 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 | 80 s.append("]"); |
81 return s.toString(); | |
82 } | |
83 | |
84 /** | |
85 * @return Base register that defines the start of the address computation. If not present, is | |
86 * denoted by {@link Register#None}. | |
87 */ | |
88 public Register getBase() { | |
89 return base; | |
90 } | |
91 | |
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 | 101 * @return true if this address has an index register |
102 */ | |
103 public boolean hasIndex() { | |
104 return !getIndex().equals(Register.None); | |
105 } | |
106 | |
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 | 110 * |
9825 | 111 * @return Optional additive displacement. |
112 */ | |
113 public int getDisplacement() { | |
11233 | 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 | 121 return displacement; |
122 } | |
123 } |