annotate graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCCall.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 35ae3e916582
children 96ab2078eeaf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
1 /*
19526
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17604
diff changeset
2 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
4 *
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
7 * published by the Free Software Foundation.
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
8 *
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
13 * accompanied this code).
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
14 *
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
18 *
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
21 * questions.
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
22 */
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
23 package com.oracle.graal.lir.sparc;
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
24
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
25 import static com.oracle.graal.api.code.ValueUtil.*;
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
26 import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
27 import static com.oracle.graal.sparc.SPARC.*;
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
28
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
29 import com.oracle.graal.api.code.*;
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
30 import com.oracle.graal.api.meta.*;
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
31 import com.oracle.graal.asm.sparc.*;
14991
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14031
diff changeset
32 import com.oracle.graal.asm.sparc.SPARCAssembler.Call;
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14031
diff changeset
33 import com.oracle.graal.asm.sparc.SPARCAssembler.Jmpl;
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14031
diff changeset
34 import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Jmp;
17119
60844c15ab27 [SPARC] Add nop again otherwise the information on pc is not unique
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17118
diff changeset
35 import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Nop;
14991
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14031
diff changeset
36 import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Sethix;
17177
805a26002dc7 [SPARC] Implement stuffing of delay slots in branches and calls. Optimized the cmove for integer and fp ops
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17119
diff changeset
37 import com.oracle.graal.compiler.common.*;
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
38 import com.oracle.graal.lir.*;
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
39 import com.oracle.graal.lir.asm.*;
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
40
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
41 public class SPARCCall {
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
42
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
43 public abstract static class CallOp extends SPARCLIRInstruction {
19526
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17604
diff changeset
44 public static final LIRInstructionClass<CallOp> TYPE = LIRInstructionClass.create(CallOp.class);
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
45
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
46 @Def({REG, ILLEGAL}) protected Value result;
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
47 @Use({REG, STACK}) protected Value[] parameters;
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
48 @Temp protected Value[] temps;
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
49 @State protected LIRFrameState state;
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
50
19526
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17604
diff changeset
51 protected CallOp(LIRInstructionClass<? extends CallOp> c, Value result, Value[] parameters, Value[] temps, LIRFrameState state) {
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17604
diff changeset
52 super(c);
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
53 this.result = result;
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
54 this.parameters = parameters;
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
55 this.state = state;
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
56 this.temps = temps;
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
57 assert temps != null;
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
58 }
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
59
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
60 @Override
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
61 public boolean destroysCallerSavedRegisters() {
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
62 return true;
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
63 }
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
64 }
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
65
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
66 public abstract static class MethodCallOp extends CallOp {
19526
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17604
diff changeset
67 public static final LIRInstructionClass<MethodCallOp> TYPE = LIRInstructionClass.create(MethodCallOp.class);
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
68
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
69 protected final ResolvedJavaMethod callTarget;
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
70
19526
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17604
diff changeset
71 protected MethodCallOp(LIRInstructionClass<? extends MethodCallOp> c, ResolvedJavaMethod callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState state) {
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17604
diff changeset
72 super(c, result, parameters, temps, state);
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
73 this.callTarget = callTarget;
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
74 }
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
75
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
76 }
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
77
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
78 @Opcode("CALL_DIRECT")
19526
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17604
diff changeset
79 public abstract static class DirectCallOp extends MethodCallOp /*
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17604
diff changeset
80 * implements
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17604
diff changeset
81 * SPARCDelayedControlTransfer
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17604
diff changeset
82 */{
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17604
diff changeset
83 public static final LIRInstructionClass<DirectCallOp> TYPE = LIRInstructionClass.create(DirectCallOp.class);
17177
805a26002dc7 [SPARC] Implement stuffing of delay slots in branches and calls. Optimized the cmove for integer and fp ops
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17119
diff changeset
84 private boolean emitted = false;
805a26002dc7 [SPARC] Implement stuffing of delay slots in branches and calls. Optimized the cmove for integer and fp ops
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17119
diff changeset
85 private int before = -1;
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
86
19526
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17604
diff changeset
87 public DirectCallOp(LIRInstructionClass<? extends DirectCallOp> c, ResolvedJavaMethod callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState state) {
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17604
diff changeset
88 super(c, callTarget, result, parameters, temps, state);
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
89 }
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
90
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
91 @Override
19526
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17604
diff changeset
92 public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) {
17177
805a26002dc7 [SPARC] Implement stuffing of delay slots in branches and calls. Optimized the cmove for integer and fp ops
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17119
diff changeset
93 if (!emitted) {
805a26002dc7 [SPARC] Implement stuffing of delay slots in branches and calls. Optimized the cmove for integer and fp ops
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17119
diff changeset
94 emitCallPrefixCode(crb, masm);
805a26002dc7 [SPARC] Implement stuffing of delay slots in branches and calls. Optimized the cmove for integer and fp ops
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17119
diff changeset
95 directCall(crb, masm, callTarget, null, true, state);
805a26002dc7 [SPARC] Implement stuffing of delay slots in branches and calls. Optimized the cmove for integer and fp ops
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17119
diff changeset
96 } else {
805a26002dc7 [SPARC] Implement stuffing of delay slots in branches and calls. Optimized the cmove for integer and fp ops
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17119
diff changeset
97 int after = masm.position();
805a26002dc7 [SPARC] Implement stuffing of delay slots in branches and calls. Optimized the cmove for integer and fp ops
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17119
diff changeset
98 if (after - before == 4) {
805a26002dc7 [SPARC] Implement stuffing of delay slots in branches and calls. Optimized the cmove for integer and fp ops
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17119
diff changeset
99 new Nop().emit(masm);
805a26002dc7 [SPARC] Implement stuffing of delay slots in branches and calls. Optimized the cmove for integer and fp ops
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17119
diff changeset
100 } else if (after - before == 8) {
805a26002dc7 [SPARC] Implement stuffing of delay slots in branches and calls. Optimized the cmove for integer and fp ops
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17119
diff changeset
101 // everything is fine;
805a26002dc7 [SPARC] Implement stuffing of delay slots in branches and calls. Optimized the cmove for integer and fp ops
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17119
diff changeset
102 } else {
805a26002dc7 [SPARC] Implement stuffing of delay slots in branches and calls. Optimized the cmove for integer and fp ops
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17119
diff changeset
103 GraalInternalError.shouldNotReachHere("" + (after - before));
805a26002dc7 [SPARC] Implement stuffing of delay slots in branches and calls. Optimized the cmove for integer and fp ops
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17119
diff changeset
104 }
805a26002dc7 [SPARC] Implement stuffing of delay slots in branches and calls. Optimized the cmove for integer and fp ops
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17119
diff changeset
105 after = masm.position();
805a26002dc7 [SPARC] Implement stuffing of delay slots in branches and calls. Optimized the cmove for integer and fp ops
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17119
diff changeset
106 crb.recordDirectCall(before, after, callTarget, state);
805a26002dc7 [SPARC] Implement stuffing of delay slots in branches and calls. Optimized the cmove for integer and fp ops
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17119
diff changeset
107 crb.recordExceptionHandlers(after, state);
805a26002dc7 [SPARC] Implement stuffing of delay slots in branches and calls. Optimized the cmove for integer and fp ops
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17119
diff changeset
108 masm.ensureUniquePC();
805a26002dc7 [SPARC] Implement stuffing of delay slots in branches and calls. Optimized the cmove for integer and fp ops
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17119
diff changeset
109 }
805a26002dc7 [SPARC] Implement stuffing of delay slots in branches and calls. Optimized the cmove for integer and fp ops
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17119
diff changeset
110 }
805a26002dc7 [SPARC] Implement stuffing of delay slots in branches and calls. Optimized the cmove for integer and fp ops
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17119
diff changeset
111
805a26002dc7 [SPARC] Implement stuffing of delay slots in branches and calls. Optimized the cmove for integer and fp ops
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17119
diff changeset
112 @SuppressWarnings("unused")
805a26002dc7 [SPARC] Implement stuffing of delay slots in branches and calls. Optimized the cmove for integer and fp ops
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17119
diff changeset
113 public void emitCallPrefixCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) {
805a26002dc7 [SPARC] Implement stuffing of delay slots in branches and calls. Optimized the cmove for integer and fp ops
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17119
diff changeset
114 //
805a26002dc7 [SPARC] Implement stuffing of delay slots in branches and calls. Optimized the cmove for integer and fp ops
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17119
diff changeset
115 }
805a26002dc7 [SPARC] Implement stuffing of delay slots in branches and calls. Optimized the cmove for integer and fp ops
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17119
diff changeset
116
17206
2d401b9ca70d [SPARC] Improve the lookup for delayable candidates, renaming interfaces/methods
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17177
diff changeset
117 public void emitControlTransfer(CompilationResultBuilder crb, SPARCMacroAssembler masm) {
17177
805a26002dc7 [SPARC] Implement stuffing of delay slots in branches and calls. Optimized the cmove for integer and fp ops
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17119
diff changeset
118 assert !emitted;
805a26002dc7 [SPARC] Implement stuffing of delay slots in branches and calls. Optimized the cmove for integer and fp ops
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17119
diff changeset
119 emitCallPrefixCode(crb, masm);
805a26002dc7 [SPARC] Implement stuffing of delay slots in branches and calls. Optimized the cmove for integer and fp ops
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17119
diff changeset
120 before = masm.position();
805a26002dc7 [SPARC] Implement stuffing of delay slots in branches and calls. Optimized the cmove for integer and fp ops
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17119
diff changeset
121 new Call(0).emit(masm);
805a26002dc7 [SPARC] Implement stuffing of delay slots in branches and calls. Optimized the cmove for integer and fp ops
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17119
diff changeset
122 emitted = true;
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
123 }
17207
5a7b82c1514e [SPARC] Add functionality to be able to do assembly in two passes (knowing offsets of forward branches)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17206
diff changeset
124
5a7b82c1514e [SPARC] Add functionality to be able to do assembly in two passes (knowing offsets of forward branches)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17206
diff changeset
125 public void resetState() {
5a7b82c1514e [SPARC] Add functionality to be able to do assembly in two passes (knowing offsets of forward branches)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17206
diff changeset
126 emitted = false;
5a7b82c1514e [SPARC] Add functionality to be able to do assembly in two passes (knowing offsets of forward branches)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17206
diff changeset
127 before = -1;
5a7b82c1514e [SPARC] Add functionality to be able to do assembly in two passes (knowing offsets of forward branches)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17206
diff changeset
128 }
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
129 }
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
130
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
131 @Opcode("CALL_INDIRECT")
19526
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17604
diff changeset
132 public abstract static class IndirectCallOp extends MethodCallOp {
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17604
diff changeset
133 public static final LIRInstructionClass<IndirectCallOp> TYPE = LIRInstructionClass.create(IndirectCallOp.class);
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
134
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
135 @Use({REG}) protected Value targetAddress;
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
136
19526
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17604
diff changeset
137 protected IndirectCallOp(LIRInstructionClass<? extends IndirectCallOp> c, ResolvedJavaMethod callTarget, Value result, Value[] parameters, Value[] temps, Value targetAddress,
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17604
diff changeset
138 LIRFrameState state) {
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17604
diff changeset
139 super(c, callTarget, result, parameters, temps, state);
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
140 this.targetAddress = targetAddress;
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
141 }
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
142
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
143 @Override
13227
1a66453f73db renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents: 11233
diff changeset
144 public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) {
1a66453f73db renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents: 11233
diff changeset
145 indirectCall(crb, masm, asRegister(targetAddress), callTarget, state);
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
146 }
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
147
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
148 @Override
17604
35ae3e916582 Make LIRInstruction an interface.
Josef Eisl <josef.eisl@jku.at>
parents: 17207
diff changeset
149 public void verify() {
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
150 super.verify();
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
151 assert isRegister(targetAddress) : "The current register allocator cannot handle variables to be used at call sites, it must be in a fixed register for now";
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
152 }
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
153 }
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
154
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
155 public abstract static class ForeignCallOp extends CallOp {
19526
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17604
diff changeset
156 public static final LIRInstructionClass<ForeignCallOp> TYPE = LIRInstructionClass.create(ForeignCallOp.class);
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
157
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
158 protected final ForeignCallLinkage callTarget;
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
159
19526
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17604
diff changeset
160 public ForeignCallOp(LIRInstructionClass<? extends ForeignCallOp> c, ForeignCallLinkage callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState state) {
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17604
diff changeset
161 super(c, result, parameters, temps, state);
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
162 this.callTarget = callTarget;
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
163 }
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
164
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
165 @Override
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
166 public boolean destroysCallerSavedRegisters() {
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
167 return callTarget.destroysRegisters();
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
168 }
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
169 }
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
170
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
171 @Opcode("NEAR_FOREIGN_CALL")
19526
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17604
diff changeset
172 public static final class DirectNearForeignCallOp extends ForeignCallOp {
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17604
diff changeset
173 public static final LIRInstructionClass<DirectNearForeignCallOp> TYPE = LIRInstructionClass.create(DirectNearForeignCallOp.class);
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
174
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
175 public DirectNearForeignCallOp(ForeignCallLinkage linkage, Value result, Value[] parameters, Value[] temps, LIRFrameState state) {
19526
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17604
diff changeset
176 super(TYPE, linkage, result, parameters, temps, state);
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
177 }
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
178
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
179 @Override
13227
1a66453f73db renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents: 11233
diff changeset
180 public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) {
1a66453f73db renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents: 11233
diff changeset
181 directCall(crb, masm, callTarget, null, false, state);
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
182 }
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
183 }
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
184
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
185 @Opcode("FAR_FOREIGN_CALL")
19526
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17604
diff changeset
186 public static final class DirectFarForeignCallOp extends ForeignCallOp {
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17604
diff changeset
187 public static final LIRInstructionClass<DirectFarForeignCallOp> TYPE = LIRInstructionClass.create(DirectFarForeignCallOp.class);
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
188
10871
c3b09d69dfde SPARC: fixes and more implementation; can now allocate objects
twisti
parents: 10854
diff changeset
189 public DirectFarForeignCallOp(ForeignCallLinkage callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState state) {
19526
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17604
diff changeset
190 super(TYPE, callTarget, result, parameters, temps, state);
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
191 }
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
192
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
193 @Override
13227
1a66453f73db renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents: 11233
diff changeset
194 public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) {
1a66453f73db renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents: 11233
diff changeset
195 directCall(crb, masm, callTarget, o7, false, state);
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
196 }
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
197 }
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
198
13227
1a66453f73db renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents: 11233
diff changeset
199 public static void directCall(CompilationResultBuilder crb, SPARCMacroAssembler masm, InvokeTarget callTarget, Register scratch, boolean align, LIRFrameState info) {
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
200 if (align) {
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
201 // We don't need alignment on SPARC.
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
202 }
14031
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
203 int before = masm.position();
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
204 if (scratch != null) {
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10686
diff changeset
205 // offset might not fit a 30-bit displacement, generate an
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10686
diff changeset
206 // indirect call with a 64-bit immediate
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10686
diff changeset
207 new Sethix(0L, scratch, true).emit(masm);
10871
c3b09d69dfde SPARC: fixes and more implementation; can now allocate objects
twisti
parents: 10854
diff changeset
208 new Jmpl(scratch, 0, o7).emit(masm);
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10686
diff changeset
209 } else {
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10686
diff changeset
210 new Call(0).emit(masm);
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
211 }
17119
60844c15ab27 [SPARC] Add nop again otherwise the information on pc is not unique
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17118
diff changeset
212 new Nop().emit(masm); // delay slot
14031
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
213 int after = masm.position();
13227
1a66453f73db renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents: 11233
diff changeset
214 crb.recordDirectCall(before, after, callTarget, info);
1a66453f73db renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents: 11233
diff changeset
215 crb.recordExceptionHandlers(after, info);
17119
60844c15ab27 [SPARC] Add nop again otherwise the information on pc is not unique
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17118
diff changeset
216 masm.ensureUniquePC();
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
217 }
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
218
13227
1a66453f73db renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents: 11233
diff changeset
219 public static void indirectJmp(CompilationResultBuilder crb, SPARCMacroAssembler masm, Register dst, InvokeTarget target) {
14031
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
220 int before = masm.position();
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10686
diff changeset
221 new Sethix(0L, dst, true).emit(masm);
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10686
diff changeset
222 new Jmp(new SPARCAddress(dst, 0)).emit(masm);
17119
60844c15ab27 [SPARC] Add nop again otherwise the information on pc is not unique
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17118
diff changeset
223 new Nop().emit(masm); // delay slot
14031
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
224 int after = masm.position();
13227
1a66453f73db renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents: 11233
diff changeset
225 crb.recordIndirectCall(before, after, target, null);
17119
60844c15ab27 [SPARC] Add nop again otherwise the information on pc is not unique
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17118
diff changeset
226 masm.ensureUniquePC();
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
227 }
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
228
13227
1a66453f73db renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents: 11233
diff changeset
229 public static void indirectCall(CompilationResultBuilder crb, SPARCMacroAssembler masm, Register dst, InvokeTarget callTarget, LIRFrameState info) {
14031
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
230 int before = masm.position();
10871
c3b09d69dfde SPARC: fixes and more implementation; can now allocate objects
twisti
parents: 10854
diff changeset
231 new Jmpl(dst, 0, o7).emit(masm);
17119
60844c15ab27 [SPARC] Add nop again otherwise the information on pc is not unique
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17118
diff changeset
232 new Nop().emit(masm); // delay slot
14031
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13227
diff changeset
233 int after = masm.position();
13227
1a66453f73db renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents: 11233
diff changeset
234 crb.recordIndirectCall(before, after, callTarget, info);
1a66453f73db renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents: 11233
diff changeset
235 crb.recordExceptionHandlers(after, info);
17119
60844c15ab27 [SPARC] Add nop again otherwise the information on pc is not unique
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 17118
diff changeset
236 masm.ensureUniquePC();
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
237 }
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents:
diff changeset
238 }