annotate graal/com.oracle.graal.asm/src/com/oracle/graal/asm/Assembler.java @ 14754:164903a50a9a

make ensureUniquePC an abstract method of the base Assembler class
author Erik Eckstein <erik.eckstein@oracle.com>
date Wed, 26 Mar 2014 10:04:37 +0100
parents d1c1f103d42c
children 5a7b82c1514e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
6531
4afe23aa0a00 renamed packages: com.oracle.max.asm... -> com.oracle.graal.asm...
Doug Simon <doug.simon@oracle.com>
parents: 6497
diff changeset
23 package com.oracle.graal.asm;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
7700
627c284671b7 Use java.nio.ByteOrder instead of our own ByteOrder enumeration
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7530
diff changeset
25 import java.nio.*;
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents: 8170
diff changeset
26 import java.util.*;
7700
627c284671b7 Use java.nio.ByteOrder instead of our own ByteOrder enumeration
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7530
diff changeset
27
5510
426c605c9d3c Move cri.ci to api.code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5233
diff changeset
28 import com.oracle.graal.api.code.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
29
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
30 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
31 * The platform-independent base class for the assembler.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
32 */
14032
d1c1f103d42c renamed com.oracle.graal.asm.AbstractAssembler to com.oracle.graal.asm.Assembler
twisti
parents: 14031
diff changeset
33 public abstract class Assembler {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7369
diff changeset
34
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5510
diff changeset
35 public final TargetDescription target;
14031
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
36
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
37 /**
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
38 * Backing code buffer.
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
39 */
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
40 private final Buffer codeBuffer;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
41
14032
d1c1f103d42c renamed com.oracle.graal.asm.AbstractAssembler to com.oracle.graal.asm.Assembler
twisti
parents: 14031
diff changeset
42 public Assembler(TargetDescription target) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
43 this.target = target;
7700
627c284671b7 Use java.nio.ByteOrder instead of our own ByteOrder enumeration
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7530
diff changeset
44 if (target.arch.getByteOrder() == ByteOrder.BIG_ENDIAN) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
45 this.codeBuffer = new Buffer.BigEndian();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
46 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
47 this.codeBuffer = new Buffer.LittleEndian();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
48 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
49 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
50
14031
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
51 /**
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
52 * Returns the current position of the underlying code buffer.
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
53 *
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
54 * @return current position in code buffer
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
55 */
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
56 public int position() {
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
57 return codeBuffer.position();
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
58 }
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
59
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
60 public final void emitByte(int x) {
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
61 codeBuffer.emitByte(x);
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
62 }
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
63
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
64 public final void emitShort(int x) {
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
65 codeBuffer.emitShort(x);
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
66 }
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
67
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
68 public final void emitInt(int x) {
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
69 codeBuffer.emitInt(x);
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
70 }
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
71
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
72 public final void emitLong(long x) {
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
73 codeBuffer.emitLong(x);
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
74 }
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
75
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
76 public final void emitByte(int b, int pos) {
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
77 codeBuffer.emitByte(b, pos);
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
78 }
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
79
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
80 public final void emitShort(int b, int pos) {
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
81 codeBuffer.emitShort(b, pos);
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
82 }
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
83
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
84 public final void emitInt(int b, int pos) {
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
85 codeBuffer.emitInt(b, pos);
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
86 }
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
87
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
88 public final void emitLong(long b, int pos) {
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
89 codeBuffer.emitLong(b, pos);
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
90 }
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
91
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
92 public final int getByte(int pos) {
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
93 return codeBuffer.getByte(pos);
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
94 }
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
95
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
96 public final int getShort(int pos) {
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
97 return codeBuffer.getShort(pos);
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
98 }
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
99
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
100 public final int getInt(int pos) {
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
101 return codeBuffer.getInt(pos);
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
102 }
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
103
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
104 private static final String NEWLINE = System.getProperty("line.separator");
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
105
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
106 /**
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
107 * Some GPU architectures have a text based encoding.
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
108 */
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
109 public final void emitString(String x) {
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
110 emitString0("\t"); // XXX REMOVE ME pretty-printing
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
111 emitString0(x);
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
112 emitString0(NEWLINE);
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
113 }
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
114
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
115 // XXX for pretty-printing
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
116 public final void emitString0(String x) {
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
117 codeBuffer.emitBytes(x.getBytes(), 0, x.length());
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
118 }
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
119
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
120 public void emitString(String s, int pos) {
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
121 codeBuffer.emitBytes(s.getBytes(), pos);
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
122 }
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
123
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
124 /**
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
125 * Closes this assembler. No extra data can be written to this assembler after this call.
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
126 *
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
127 * @param trimmedCopy if {@code true}, then a copy of the underlying byte array up to (but not
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
128 * including) {@code position()} is returned
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
129 * @return the data in this buffer or a trimmed copy if {@code trimmedCopy} is {@code true}
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
130 */
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
131 public byte[] close(boolean trimmedCopy) {
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
132 return codeBuffer.close(trimmedCopy);
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
133 }
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
134
7804
447f9ba1962b Experimental PTX backend. Contribution by Christian Thalinger.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7700
diff changeset
135 public void bind(Label l) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
136 assert !l.isBound() : "can bind label only once";
14031
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
137 l.bind(position());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
138 l.patchInstructions(this);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
139 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
140
4522
cf13124efdd9 Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
141 public abstract void align(int modulus);
cf13124efdd9 Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
142
cf13124efdd9 Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
143 public abstract void jmp(Label l);
cf13124efdd9 Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
144
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
145 protected abstract void patchJumpTarget(int branch, int jumpTarget);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
146
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents: 8170
diff changeset
147 private Map<Label, String> nameMap;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents: 8170
diff changeset
148
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents: 8170
diff changeset
149 /**
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents: 8170
diff changeset
150 * Creates a name for a label.
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents: 8170
diff changeset
151 *
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents: 8170
diff changeset
152 * @param l the label for which a name is being created
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents: 8170
diff changeset
153 * @param id a label identifier that is unique with the scope of this assembler
10820
f8fe0f7ee22a added createLabelName override in AbstractHSAILAssembler; create a common label name in AbstractAssembler
twisti
parents: 10662
diff changeset
154 * @return a label name in the form of "L123"
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents: 8170
diff changeset
155 */
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents: 8170
diff changeset
156 protected String createLabelName(Label l, int id) {
10820
f8fe0f7ee22a added createLabelName override in AbstractHSAILAssembler; create a common label name in AbstractAssembler
twisti
parents: 10662
diff changeset
157 return "L" + id;
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents: 8170
diff changeset
158 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents: 8170
diff changeset
159
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents: 8170
diff changeset
160 /**
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents: 8170
diff changeset
161 * Gets a name for a label, creating it if it does not yet exist. By default, the returned name
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents: 8170
diff changeset
162 * is only unique with the scope of this assembler.
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents: 8170
diff changeset
163 */
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents: 8170
diff changeset
164 public String nameOf(Label l) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents: 8170
diff changeset
165 if (nameMap == null) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents: 8170
diff changeset
166 nameMap = new HashMap<>();
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents: 8170
diff changeset
167 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents: 8170
diff changeset
168 String name = nameMap.get(l);
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents: 8170
diff changeset
169 if (name == null) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents: 8170
diff changeset
170 name = createLabelName(l, nameMap.size());
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents: 8170
diff changeset
171 nameMap.put(l, name);
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents: 8170
diff changeset
172 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents: 8170
diff changeset
173 return name;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents: 8170
diff changeset
174 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents: 8170
diff changeset
175
7839
838293a77af7 Make Address class platform specific.
Roland Schatz <roland.schatz@oracle.com>
parents: 7808
diff changeset
176 /**
13227
1a66453f73db renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents: 10820
diff changeset
177 * This is used by the CompilationResultBuilder to convert a {@link StackSlot} to an
8167
7f57c30575c8 Make AMD64Address a low-level representation for use by the assembler only.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
178 * {@link AbstractAddress}.
7839
838293a77af7 Make Address class platform specific.
Roland Schatz <roland.schatz@oracle.com>
parents: 7808
diff changeset
179 */
8170
537f03d2bdf7 Removed unused parameter from AbstractAssembler.makeAddress().
Roland Schatz <roland.schatz@oracle.com>
parents: 8167
diff changeset
180 public abstract AbstractAddress makeAddress(Register base, int displacement);
7839
838293a77af7 Make Address class platform specific.
Roland Schatz <roland.schatz@oracle.com>
parents: 7808
diff changeset
181
838293a77af7 Make Address class platform specific.
Roland Schatz <roland.schatz@oracle.com>
parents: 7808
diff changeset
182 /**
838293a77af7 Make Address class platform specific.
Roland Schatz <roland.schatz@oracle.com>
parents: 7808
diff changeset
183 * Returns a target specific placeholder address that can be used for code patching.
838293a77af7 Make Address class platform specific.
Roland Schatz <roland.schatz@oracle.com>
parents: 7808
diff changeset
184 */
8167
7f57c30575c8 Make AMD64Address a low-level representation for use by the assembler only.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
185 public abstract AbstractAddress getPlaceholder();
14754
164903a50a9a make ensureUniquePC an abstract method of the base Assembler class
Erik Eckstein <erik.eckstein@oracle.com>
parents: 14032
diff changeset
186
164903a50a9a make ensureUniquePC an abstract method of the base Assembler class
Erik Eckstein <erik.eckstein@oracle.com>
parents: 14032
diff changeset
187 /**
164903a50a9a make ensureUniquePC an abstract method of the base Assembler class
Erik Eckstein <erik.eckstein@oracle.com>
parents: 14032
diff changeset
188 * Emits a NOP instruction to advance the current PC.
164903a50a9a make ensureUniquePC an abstract method of the base Assembler class
Erik Eckstein <erik.eckstein@oracle.com>
parents: 14032
diff changeset
189 */
164903a50a9a make ensureUniquePC an abstract method of the base Assembler class
Erik Eckstein <erik.eckstein@oracle.com>
parents: 14032
diff changeset
190 public abstract void ensureUniquePC();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
191 }