Mercurial > hg > truffle
annotate graal/com.oracle.graal.asm.sparc/src/com/oracle/graal/asm/sparc/SPARCMacroAssembler.java @ 21543:93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 25 May 2015 23:30:34 +0200 |
parents | d3b276db28b8 |
children | 48c1ebd24120 |
rev | line source |
---|---|
9844
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
1 /* |
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
4 * |
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
8 * |
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
14 * |
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
18 * |
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
21 * questions. |
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
22 */ |
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.asm.sparc; |
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
24 |
19668
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
25 import static com.oracle.graal.asm.sparc.SPARCAssembler.Annul.*; |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
26 import static com.oracle.graal.asm.sparc.SPARCAssembler.ConditionFlag.*; |
10459 | 27 import static com.oracle.graal.sparc.SPARC.*; |
9846
91a1041ec905
SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents:
9845
diff
changeset
|
28 |
19670
7d3afd4356a2
[SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19668
diff
changeset
|
29 import java.util.function.*; |
7d3afd4356a2
[SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19668
diff
changeset
|
30 |
9844
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
31 import com.oracle.graal.api.code.*; |
10459 | 32 import com.oracle.graal.asm.*; |
21543
93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
20968
diff
changeset
|
33 import com.oracle.jvmci.common.*; |
9844
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
34 |
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
35 public class SPARCMacroAssembler extends SPARCAssembler { |
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
36 |
10686
73122b5edf6a
SPARC: Can compile simple methods and do static calls.
twisti
parents:
10468
diff
changeset
|
37 /** |
73122b5edf6a
SPARC: Can compile simple methods and do static calls.
twisti
parents:
10468
diff
changeset
|
38 * A sentinel value used as a place holder in an instruction stream for an address that will be |
73122b5edf6a
SPARC: Can compile simple methods and do static calls.
twisti
parents:
10468
diff
changeset
|
39 * patched. |
73122b5edf6a
SPARC: Can compile simple methods and do static calls.
twisti
parents:
10468
diff
changeset
|
40 */ |
73122b5edf6a
SPARC: Can compile simple methods and do static calls.
twisti
parents:
10468
diff
changeset
|
41 private static final SPARCAddress Placeholder = new SPARCAddress(g0, 0); |
19937
4fe66c16e942
[SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19677
diff
changeset
|
42 private final ScratchRegister[] scratchRegister = new ScratchRegister[]{new ScratchRegister(g1), new ScratchRegister(g3)}; |
4fe66c16e942
[SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19677
diff
changeset
|
43 // Points to the next free scratch register |
4fe66c16e942
[SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19677
diff
changeset
|
44 private int nextFreeScratchRegister = 0; |
10686
73122b5edf6a
SPARC: Can compile simple methods and do static calls.
twisti
parents:
10468
diff
changeset
|
45 |
9844
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
46 public SPARCMacroAssembler(TargetDescription target, RegisterConfig registerConfig) { |
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
47 super(target, registerConfig); |
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
48 } |
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
49 |
10459 | 50 @Override |
51 public void align(int modulus) { | |
17120
832c8c93c949
[SPARC] Now doing alignment bytewise and not instruction-wise (nop in AMD64 has one byte, nop in SPARC four bytes)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
17089
diff
changeset
|
52 while (position() % modulus != 0) { |
19670
7d3afd4356a2
[SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19668
diff
changeset
|
53 nop(); |
10459 | 54 } |
55 } | |
56 | |
57 @Override | |
58 public void jmp(Label l) { | |
19668
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
59 bicc(Always, NOT_ANNUL, l); |
19670
7d3afd4356a2
[SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19668
diff
changeset
|
60 nop(); // delay slot |
10459 | 61 } |
9844
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
62 |
10459 | 63 @Override |
64 protected final void patchJumpTarget(int branch, int branchTarget) { | |
19668
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
65 final int disp = (branchTarget - branch) / 4; |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
66 final int inst = getInt(branch); |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
67 Op2s op2 = Op2s.byValue((inst & OP2_MASK) >> OP2_SHIFT); |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
68 int maskBits; |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
69 int setBits; |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
70 switch (op2) { |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
71 case Br: |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
72 case Fb: |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
73 case Sethi: |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
74 case Illtrap: |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
75 // Disp 22 in the lower 22 bits |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
76 assert isSimm(disp, 22); |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
77 setBits = disp << DISP22_SHIFT; |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
78 maskBits = DISP22_MASK; |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
79 break; |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
80 case Fbp: |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
81 case Bp: |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
82 // Disp 19 in the lower 19 bits |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
83 assert isSimm(disp, 19); |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
84 setBits = disp << DISP19_SHIFT; |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
85 maskBits = DISP19_MASK; |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
86 break; |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
87 case Bpr: |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
88 boolean isCBcond = (inst & CBCOND_MASK) != 0; |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
89 if (isCBcond) { |
20968
d3b276db28b8
[SPARC] Use NOP only between CBcond
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19937
diff
changeset
|
90 assert isSimm10(disp) : String.format("%d: instruction: 0x%x", disp, inst); |
19668
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
91 int d10Split = 0; |
19670
7d3afd4356a2
[SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19668
diff
changeset
|
92 d10Split |= (disp & 0b11_0000_0000) << D10HI_SHIFT - 8; |
7d3afd4356a2
[SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19668
diff
changeset
|
93 d10Split |= (disp & 0b00_1111_1111) << D10LO_SHIFT; |
19668
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
94 setBits = d10Split; |
19670
7d3afd4356a2
[SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19668
diff
changeset
|
95 maskBits = D10LO_MASK | D10HI_MASK; |
19668
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
96 } else { |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
97 assert isSimm(disp, 16); |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
98 int d16Split = 0; |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
99 d16Split |= (disp & 0b1100_0000_0000_0000) << D16HI_SHIFT - 14; |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
100 d16Split |= (disp & 0b0011_1111_1111_1111) << D16LO_SHIFT; |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
101 setBits = d16Split; |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
102 maskBits = D16HI_MASK | D16LO_MASK; |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
103 } |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
104 break; |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
105 default: |
21543
93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
20968
diff
changeset
|
106 throw JVMCIError.shouldNotReachHere("Unknown op2 " + op2); |
19668
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
107 } |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
108 int newInst = ~maskBits & inst; |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
109 newInst |= setBits; |
413ac504d74e
[SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18744
diff
changeset
|
110 emitInt(newInst, branch); |
10459 | 111 } |
112 | |
113 @Override | |
114 public AbstractAddress makeAddress(Register base, int displacement) { | |
10686
73122b5edf6a
SPARC: Can compile simple methods and do static calls.
twisti
parents:
10468
diff
changeset
|
115 return new SPARCAddress(base, displacement); |
10459 | 116 } |
117 | |
118 @Override | |
119 public AbstractAddress getPlaceholder() { | |
10686
73122b5edf6a
SPARC: Can compile simple methods and do static calls.
twisti
parents:
10468
diff
changeset
|
120 return Placeholder; |
10459 | 121 } |
122 | |
14754
164903a50a9a
make ensureUniquePC an abstract method of the base Assembler class
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14031
diff
changeset
|
123 @Override |
11233 | 124 public final void ensureUniquePC() { |
19670
7d3afd4356a2
[SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19668
diff
changeset
|
125 nop(); |
11233 | 126 } |
127 | |
19677
00d7b0adaf66
[SPARC] Change ld/st ops of SPARC to functions
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19675
diff
changeset
|
128 public void cas(Register rs1, Register rs2, Register rd) { |
00d7b0adaf66
[SPARC] Change ld/st ops of SPARC to functions
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19675
diff
changeset
|
129 casa(rs1, rs2, rd, Asi.ASI_PRIMARY); |
10792 | 130 } |
131 | |
19677
00d7b0adaf66
[SPARC] Change ld/st ops of SPARC to functions
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19675
diff
changeset
|
132 public void casx(Register rs1, Register rs2, Register rd) { |
00d7b0adaf66
[SPARC] Change ld/st ops of SPARC to functions
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19675
diff
changeset
|
133 casxa(rs1, rs2, rd, Asi.ASI_PRIMARY); |
10792 | 134 } |
135 | |
19675
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
136 public void clr(Register dst) { |
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
137 or(g0, g0, dst); |
9845
204e8f3209e9
SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents:
9844
diff
changeset
|
138 } |
204e8f3209e9
SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents:
9844
diff
changeset
|
139 |
19677
00d7b0adaf66
[SPARC] Change ld/st ops of SPARC to functions
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19675
diff
changeset
|
140 public void clrb(SPARCAddress addr) { |
00d7b0adaf66
[SPARC] Change ld/st ops of SPARC to functions
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19675
diff
changeset
|
141 stb(g0, addr); |
9845
204e8f3209e9
SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents:
9844
diff
changeset
|
142 } |
204e8f3209e9
SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents:
9844
diff
changeset
|
143 |
19677
00d7b0adaf66
[SPARC] Change ld/st ops of SPARC to functions
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19675
diff
changeset
|
144 public void clrh(SPARCAddress addr) { |
00d7b0adaf66
[SPARC] Change ld/st ops of SPARC to functions
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19675
diff
changeset
|
145 sth(g0, addr); |
9845
204e8f3209e9
SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents:
9844
diff
changeset
|
146 } |
204e8f3209e9
SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents:
9844
diff
changeset
|
147 |
19677
00d7b0adaf66
[SPARC] Change ld/st ops of SPARC to functions
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19675
diff
changeset
|
148 public void clrx(SPARCAddress addr) { |
00d7b0adaf66
[SPARC] Change ld/st ops of SPARC to functions
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19675
diff
changeset
|
149 stx(g0, addr); |
9844
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
150 } |
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
151 |
19675
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
152 public void cmp(Register rs1, Register rs2) { |
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
153 subcc(rs1, rs2, g0); |
9845
204e8f3209e9
SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents:
9844
diff
changeset
|
154 } |
204e8f3209e9
SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents:
9844
diff
changeset
|
155 |
19675
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
156 public void cmp(Register rs1, int simm13) { |
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
157 subcc(rs1, simm13, g0); |
9845
204e8f3209e9
SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents:
9844
diff
changeset
|
158 } |
204e8f3209e9
SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents:
9844
diff
changeset
|
159 |
19675
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
160 public void dec(Register rd) { |
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
161 sub(rd, 1, rd); |
9845
204e8f3209e9
SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents:
9844
diff
changeset
|
162 } |
204e8f3209e9
SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents:
9844
diff
changeset
|
163 |
19675
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
164 public void dec(int simm13, Register rd) { |
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
165 sub(rd, simm13, rd); |
9845
204e8f3209e9
SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents:
9844
diff
changeset
|
166 } |
204e8f3209e9
SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents:
9844
diff
changeset
|
167 |
19675
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
168 public void jmp(SPARCAddress address) { |
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
169 jmpl(address.getBase(), address.getDisplacement(), g0); |
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
170 } |
9845
204e8f3209e9
SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents:
9844
diff
changeset
|
171 |
19675
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
172 public void jmp(Register rd) { |
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
173 jmpl(rd, 0, g0); |
9845
204e8f3209e9
SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents:
9844
diff
changeset
|
174 } |
204e8f3209e9
SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents:
9844
diff
changeset
|
175 |
19675
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
176 public void neg(Register rs1, Register rd) { |
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
177 sub(g0, rs1, rd); |
9845
204e8f3209e9
SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents:
9844
diff
changeset
|
178 } |
204e8f3209e9
SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents:
9844
diff
changeset
|
179 |
19675
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
180 public void neg(Register rd) { |
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
181 sub(g0, rd, rd); |
9845
204e8f3209e9
SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents:
9844
diff
changeset
|
182 } |
204e8f3209e9
SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents:
9844
diff
changeset
|
183 |
19675
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
184 public void mov(Register rs, Register rd) { |
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
185 or(g0, rs, rd); |
10459 | 186 } |
187 | |
19675
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
188 public void mov(int simm13, Register rd) { |
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
189 or(g0, simm13, rd); |
9844
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
190 } |
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
191 |
19675
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
192 public void not(Register rs1, Register rd) { |
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
193 xnor(rs1, g0, rd); |
9844
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
194 } |
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
195 |
19675
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
196 public void not(Register rd) { |
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
197 xnor(rd, g0, rd); |
9844
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
198 } |
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
199 |
19675
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
200 public void restoreWindow() { |
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
201 restore(g0, g0, g0); |
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
202 } |
10694
31266ceb86ef
SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents:
10686
diff
changeset
|
203 |
19675
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
204 public void ret() { |
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
205 jmpl(i7, 8, g0); |
9845
204e8f3209e9
SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents:
9844
diff
changeset
|
206 } |
204e8f3209e9
SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents:
9844
diff
changeset
|
207 |
10854
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
208 /** |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
209 * This instruction is like sethi but for 64-bit values. |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
210 */ |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
211 public static class Sethix { |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
212 |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
213 private static final int INSTRUCTION_SIZE = 7; |
9845
204e8f3209e9
SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents:
9844
diff
changeset
|
214 |
10694
31266ceb86ef
SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents:
10686
diff
changeset
|
215 private long value; |
31266ceb86ef
SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents:
10686
diff
changeset
|
216 private Register dst; |
10792 | 217 private boolean forceRelocatable; |
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:
17144
diff
changeset
|
218 private boolean delayed = false; |
19670
7d3afd4356a2
[SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19668
diff
changeset
|
219 private Consumer<SPARCAssembler> delayedInstructionEmitter; |
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:
17144
diff
changeset
|
220 |
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:
17144
diff
changeset
|
221 public Sethix(long value, Register dst, boolean forceRelocatable, boolean delayed) { |
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:
17144
diff
changeset
|
222 this(value, dst, forceRelocatable); |
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:
17144
diff
changeset
|
223 assert !(forceRelocatable && delayed) : "Relocatable sethix cannot be delayed"; |
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:
17144
diff
changeset
|
224 this.delayed = delayed; |
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:
17144
diff
changeset
|
225 } |
10694
31266ceb86ef
SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents:
10686
diff
changeset
|
226 |
10854
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
227 public Sethix(long value, Register dst, boolean forceRelocatable) { |
10694
31266ceb86ef
SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents:
10686
diff
changeset
|
228 this.value = value; |
31266ceb86ef
SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents:
10686
diff
changeset
|
229 this.dst = dst; |
10792 | 230 this.forceRelocatable = forceRelocatable; |
231 } | |
232 | |
10854
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
233 public Sethix(long value, Register dst) { |
10792 | 234 this(value, dst, false); |
10694
31266ceb86ef
SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents:
10686
diff
changeset
|
235 } |
31266ceb86ef
SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents:
10686
diff
changeset
|
236 |
19670
7d3afd4356a2
[SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19668
diff
changeset
|
237 private void emitInstruction(Consumer<SPARCAssembler> cb, 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:
17144
diff
changeset
|
238 if (delayed) { |
19670
7d3afd4356a2
[SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19668
diff
changeset
|
239 if (this.delayedInstructionEmitter != null) { |
7d3afd4356a2
[SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19668
diff
changeset
|
240 delayedInstructionEmitter.accept(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:
17144
diff
changeset
|
241 } |
19670
7d3afd4356a2
[SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19668
diff
changeset
|
242 delayedInstructionEmitter = cb; |
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:
17144
diff
changeset
|
243 } else { |
19670
7d3afd4356a2
[SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19668
diff
changeset
|
244 cb.accept(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:
17144
diff
changeset
|
245 } |
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:
17144
diff
changeset
|
246 } |
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:
17144
diff
changeset
|
247 |
10694
31266ceb86ef
SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents:
10686
diff
changeset
|
248 public void emit(SPARCMacroAssembler masm) { |
19670
7d3afd4356a2
[SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19668
diff
changeset
|
249 final int hi = (int) (value >> 32); |
7d3afd4356a2
[SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19668
diff
changeset
|
250 final int lo = (int) (value & ~0); |
9845
204e8f3209e9
SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents:
9844
diff
changeset
|
251 |
10792 | 252 // This is the same logic as MacroAssembler::internal_set. |
14031
390c4b742890
made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents:
11233
diff
changeset
|
253 final int startPc = masm.position(); |
10792 | 254 |
255 if (hi == 0 && lo >= 0) { | |
19670
7d3afd4356a2
[SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19668
diff
changeset
|
256 Consumer<SPARCAssembler> cb = eMasm -> eMasm.sethi(hi22(lo), dst); |
7d3afd4356a2
[SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19668
diff
changeset
|
257 emitInstruction(cb, masm); |
10792 | 258 } else if (hi == -1) { |
19670
7d3afd4356a2
[SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19668
diff
changeset
|
259 Consumer<SPARCAssembler> cb = eMasm -> eMasm.sethi(hi22(~lo), dst); |
7d3afd4356a2
[SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19668
diff
changeset
|
260 emitInstruction(cb, masm); |
19675
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
261 cb = eMasm -> eMasm.xor(dst, ~lo10(~0), dst); |
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
262 emitInstruction(cb, masm); |
10792 | 263 } else { |
19675
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
264 final int shiftcnt; |
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
265 final int shiftcnt2; |
19670
7d3afd4356a2
[SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19668
diff
changeset
|
266 Consumer<SPARCAssembler> cb = eMasm -> eMasm.sethi(hi22(hi), dst); |
7d3afd4356a2
[SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19668
diff
changeset
|
267 emitInstruction(cb, 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:
17144
diff
changeset
|
268 if ((hi & 0x3ff) != 0) { // Any bits? |
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:
17144
diff
changeset
|
269 // msb 32-bits are now in lsb 32 |
19675
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
270 cb = eMasm -> eMasm.or(dst, hi & 0x3ff, dst); |
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
271 emitInstruction(cb, masm); |
9845
204e8f3209e9
SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents:
9844
diff
changeset
|
272 } |
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:
17144
diff
changeset
|
273 if ((lo & 0xFFFFFC00) != 0) { // done? |
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:
17144
diff
changeset
|
274 if (((lo >> 20) & 0xfff) != 0) { // Any bits set? |
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:
17144
diff
changeset
|
275 // Make room for next 12 bits |
19675
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
276 cb = eMasm -> eMasm.sllx(dst, 12, dst); |
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
277 emitInstruction(cb, 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:
17144
diff
changeset
|
278 // Or in next 12 |
19675
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
279 cb = eMasm -> eMasm.or(dst, (lo >> 20) & 0xfff, dst); |
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
280 emitInstruction(cb, 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:
17144
diff
changeset
|
281 shiftcnt = 0; // We already shifted |
10792 | 282 } else { |
283 shiftcnt = 12; | |
284 } | |
285 if (((lo >> 10) & 0x3ff) != 0) { | |
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:
17144
diff
changeset
|
286 // Make room for last 10 bits |
19675
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
287 cb = eMasm -> eMasm.sllx(dst, shiftcnt + 10, dst); |
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
288 emitInstruction(cb, 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:
17144
diff
changeset
|
289 // Or in next 10 |
19675
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
290 cb = eMasm -> eMasm.or(dst, (lo >> 10) & 0x3ff, dst); |
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
291 emitInstruction(cb, masm); |
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
292 shiftcnt2 = 0; |
10792 | 293 } else { |
19675
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
294 shiftcnt2 = 10; |
10792 | 295 } |
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:
17144
diff
changeset
|
296 // Shift leaving disp field 0'd |
19675
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
297 cb = eMasm -> eMasm.sllx(dst, shiftcnt2 + 10, dst); |
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
298 emitInstruction(cb, masm); |
9845
204e8f3209e9
SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents:
9844
diff
changeset
|
299 } else { |
19675
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
300 cb = eMasm -> eMasm.sllx(dst, 32, dst); |
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
301 emitInstruction(cb, masm); |
9845
204e8f3209e9
SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents:
9844
diff
changeset
|
302 } |
10792 | 303 } |
304 // Pad out the instruction sequence so it can be patched later. | |
305 if (forceRelocatable) { | |
14031
390c4b742890
made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents:
11233
diff
changeset
|
306 while (masm.position() < (startPc + (INSTRUCTION_SIZE * 4))) { |
19670
7d3afd4356a2
[SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19668
diff
changeset
|
307 Consumer<SPARCAssembler> cb = eMasm -> eMasm.nop(); |
7d3afd4356a2
[SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19668
diff
changeset
|
308 emitInstruction(cb, masm); |
9845
204e8f3209e9
SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents:
9844
diff
changeset
|
309 } |
10792 | 310 } |
10854
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
311 } |
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:
17144
diff
changeset
|
312 |
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:
17144
diff
changeset
|
313 public void emitDelayed(SPARCMacroAssembler masm) { |
19670
7d3afd4356a2
[SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19668
diff
changeset
|
314 assert delayedInstructionEmitter != null; |
7d3afd4356a2
[SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19668
diff
changeset
|
315 delayedInstructionEmitter.accept(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:
17144
diff
changeset
|
316 } |
10854
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
317 } |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
318 |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
319 public static class Setx { |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
320 |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
321 private long value; |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
322 private Register dst; |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
323 private boolean forceRelocatable; |
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:
17144
diff
changeset
|
324 private boolean delayed = 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:
17144
diff
changeset
|
325 private boolean delayedFirstEmitted = 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:
17144
diff
changeset
|
326 private Sethix sethix; |
19675
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
327 private Consumer<SPARCMacroAssembler> delayedAdd; |
10854
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
328 |
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:
17144
diff
changeset
|
329 public Setx(long value, Register dst, boolean forceRelocatable, boolean delayed) { |
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:
17144
diff
changeset
|
330 assert !(forceRelocatable && delayed) : "Cannot use relocatable setx as delayable"; |
10854
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
331 this.value = value; |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
332 this.dst = dst; |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
333 this.forceRelocatable = forceRelocatable; |
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:
17144
diff
changeset
|
334 this.delayed = delayed; |
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:
17144
diff
changeset
|
335 } |
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:
17144
diff
changeset
|
336 |
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:
17144
diff
changeset
|
337 public Setx(long value, Register dst, boolean forceRelocatable) { |
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:
17144
diff
changeset
|
338 this(value, dst, forceRelocatable, false); |
10854
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
339 } |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
340 |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
341 public Setx(long value, Register dst) { |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
342 this(value, dst, false); |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
343 } |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
344 |
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
345 public void emit(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:
17144
diff
changeset
|
346 assert !delayed; |
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:
17144
diff
changeset
|
347 doEmit(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:
17144
diff
changeset
|
348 } |
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:
17144
diff
changeset
|
349 |
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:
17144
diff
changeset
|
350 private void doEmit(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:
17144
diff
changeset
|
351 sethix = new Sethix(value, dst, forceRelocatable, delayed); |
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:
17144
diff
changeset
|
352 sethix.emit(masm); |
10854
e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
twisti
parents:
10792
diff
changeset
|
353 int lo = (int) (value & ~0); |
10792 | 354 if (lo10(lo) != 0 || forceRelocatable) { |
19675
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
355 Consumer<SPARCMacroAssembler> add = eMasm -> eMasm.add(dst, lo10(lo), dst); |
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:
17144
diff
changeset
|
356 if (delayed) { |
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:
17144
diff
changeset
|
357 sethix.emitDelayed(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:
17144
diff
changeset
|
358 sethix = null; |
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:
17144
diff
changeset
|
359 delayedAdd = add; |
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:
17144
diff
changeset
|
360 } 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:
17144
diff
changeset
|
361 sethix = null; |
19675
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
362 add.accept(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:
17144
diff
changeset
|
363 } |
9845
204e8f3209e9
SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents:
9844
diff
changeset
|
364 } |
204e8f3209e9
SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents:
9844
diff
changeset
|
365 } |
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:
17144
diff
changeset
|
366 |
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:
17144
diff
changeset
|
367 public void emitFirstPartOfDelayed(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:
17144
diff
changeset
|
368 assert !forceRelocatable : "Cannot use delayed mode with relocatable setx"; |
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:
17144
diff
changeset
|
369 assert delayed : "Can only be used in delayed mode"; |
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:
17144
diff
changeset
|
370 doEmit(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:
17144
diff
changeset
|
371 delayedFirstEmitted = true; |
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:
17144
diff
changeset
|
372 } |
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:
17144
diff
changeset
|
373 |
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:
17144
diff
changeset
|
374 public void emitSecondPartOfDelayed(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:
17144
diff
changeset
|
375 assert !forceRelocatable : "Cannot use delayed mode with relocatable setx"; |
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:
17144
diff
changeset
|
376 assert delayed : "Can only be used in delayed mode"; |
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:
17144
diff
changeset
|
377 assert delayedFirstEmitted : "First part has not been emitted so far."; |
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:
17144
diff
changeset
|
378 assert delayedAdd == null && sethix != null || delayedAdd != null && sethix == null : "Either add or sethix must be set"; |
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:
17144
diff
changeset
|
379 if (delayedAdd != null) { |
19675
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
380 delayedAdd.accept(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:
17144
diff
changeset
|
381 } 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:
17144
diff
changeset
|
382 sethix.emitDelayed(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:
17144
diff
changeset
|
383 } |
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:
17144
diff
changeset
|
384 |
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:
17144
diff
changeset
|
385 } |
9845
204e8f3209e9
SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents:
9844
diff
changeset
|
386 } |
204e8f3209e9
SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents:
9844
diff
changeset
|
387 |
19675
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
388 public void signx(Register rs, Register rd) { |
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
389 sra(rs, g0, rd); |
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
390 } |
9845
204e8f3209e9
SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents:
9844
diff
changeset
|
391 |
19675
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
392 public void signx(Register rd) { |
f1b4f2613702
[SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19670
diff
changeset
|
393 sra(rd, g0, rd); |
9845
204e8f3209e9
SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents:
9844
diff
changeset
|
394 } |
19937
4fe66c16e942
[SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19677
diff
changeset
|
395 |
4fe66c16e942
[SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19677
diff
changeset
|
396 public ScratchRegister getScratchRegister() { |
4fe66c16e942
[SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19677
diff
changeset
|
397 return scratchRegister[nextFreeScratchRegister++]; |
4fe66c16e942
[SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19677
diff
changeset
|
398 } |
4fe66c16e942
[SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19677
diff
changeset
|
399 |
4fe66c16e942
[SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19677
diff
changeset
|
400 public class ScratchRegister implements AutoCloseable { |
4fe66c16e942
[SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19677
diff
changeset
|
401 private final Register register; |
4fe66c16e942
[SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19677
diff
changeset
|
402 |
4fe66c16e942
[SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19677
diff
changeset
|
403 public ScratchRegister(Register register) { |
4fe66c16e942
[SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19677
diff
changeset
|
404 super(); |
4fe66c16e942
[SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19677
diff
changeset
|
405 this.register = register; |
4fe66c16e942
[SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19677
diff
changeset
|
406 } |
4fe66c16e942
[SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19677
diff
changeset
|
407 |
4fe66c16e942
[SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19677
diff
changeset
|
408 public Register getRegister() { |
4fe66c16e942
[SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19677
diff
changeset
|
409 return register; |
4fe66c16e942
[SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19677
diff
changeset
|
410 } |
4fe66c16e942
[SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19677
diff
changeset
|
411 |
4fe66c16e942
[SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19677
diff
changeset
|
412 public void close() { |
4fe66c16e942
[SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19677
diff
changeset
|
413 assert nextFreeScratchRegister > 0 : "Close called too often"; |
4fe66c16e942
[SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19677
diff
changeset
|
414 nextFreeScratchRegister--; |
4fe66c16e942
[SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19677
diff
changeset
|
415 } |
4fe66c16e942
[SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
19677
diff
changeset
|
416 } |
9844
2d1687e63484
SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
417 } |