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

moved com.oracle.asm.** to jvmci-util.jar (JBS:GRAAL-53)
author Doug Simon <doug.simon@oracle.com>
date Wed, 03 Jun 2015 18:06:44 +0200
parents graal/com.oracle.graal.asm.sparc/src/com/oracle/graal/asm/sparc/SPARCMacroAssembler.java@5024c80224c7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 */
21708
6df25b1418be moved com.oracle.asm.** to jvmci-util.jar (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21673
diff changeset
23 package com.oracle.jvmci.asm.sparc;
9844
2d1687e63484 SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
24
21708
6df25b1418be moved com.oracle.asm.** to jvmci-util.jar (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21673
diff changeset
25 import static com.oracle.jvmci.asm.sparc.SPARCAssembler.Annul.*;
6df25b1418be moved com.oracle.asm.** to jvmci-util.jar (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21673
diff changeset
26 import static com.oracle.jvmci.asm.sparc.SPARCAssembler.ConditionFlag.*;
21673
5024c80224c7 moved com.oracle.graal.[amd64|sparc] to com.oracle.jvmci.[amd64|sparc] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21556
diff changeset
27 import static com.oracle.jvmci.sparc.SPARC.*;
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
28
19677
7d3afd4356a2 [SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19675
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: 19675
diff changeset
30
21708
6df25b1418be moved com.oracle.asm.** to jvmci-util.jar (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21673
diff changeset
31 import com.oracle.jvmci.asm.*;
6df25b1418be moved com.oracle.asm.** to jvmci-util.jar (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21673
diff changeset
32 import com.oracle.jvmci.code.*;
9844
2d1687e63484 SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
33
2d1687e63484 SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
34 public class SPARCMacroAssembler extends SPARCAssembler {
2d1687e63484 SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
35
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10468
diff changeset
36 /**
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10468
diff changeset
37 * 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
38 * patched.
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10468
diff changeset
39 */
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10468
diff changeset
40 private static final SPARCAddress Placeholder = new SPARCAddress(g0, 0);
19941
4fe66c16e942 [SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19684
diff changeset
41 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: 19684
diff changeset
42 // 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: 19684
diff changeset
43 private int nextFreeScratchRegister = 0;
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10468
diff changeset
44
9844
2d1687e63484 SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
45 public SPARCMacroAssembler(TargetDescription target, RegisterConfig registerConfig) {
2d1687e63484 SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
46 super(target, registerConfig);
2d1687e63484 SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
47 }
2d1687e63484 SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
48
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9949
diff changeset
49 @Override
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9949
diff changeset
50 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
51 while (position() % modulus != 0) {
19677
7d3afd4356a2 [SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19675
diff changeset
52 nop();
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9949
diff changeset
53 }
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9949
diff changeset
54 }
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9949
diff changeset
55
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9949
diff changeset
56 @Override
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9949
diff changeset
57 public void jmp(Label l) {
19675
413ac504d74e [SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 18744
diff changeset
58 bicc(Always, NOT_ANNUL, l);
19677
7d3afd4356a2 [SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19675
diff changeset
59 nop(); // delay slot
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9949
diff changeset
60 }
9844
2d1687e63484 SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
61
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9949
diff changeset
62 @Override
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9949
diff changeset
63 protected final void patchJumpTarget(int branch, int branchTarget) {
19675
413ac504d74e [SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 18744
diff changeset
64 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
65 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
66 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
67 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
68 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
69 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
70 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
71 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
72 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
73 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
74 // 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
75 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
76 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
77 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
78 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
79 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
80 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
81 // 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
82 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
83 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
84 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
85 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
86 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
87 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
88 if (isCBcond) {
20968
d3b276db28b8 [SPARC] Use NOP only between CBcond
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19941
diff changeset
89 assert isSimm10(disp) : String.format("%d: instruction: 0x%x", disp, inst);
19675
413ac504d74e [SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 18744
diff changeset
90 int d10Split = 0;
19677
7d3afd4356a2 [SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19675
diff changeset
91 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: 19675
diff changeset
92 d10Split |= (disp & 0b00_1111_1111) << D10LO_SHIFT;
19675
413ac504d74e [SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 18744
diff changeset
93 setBits = d10Split;
19677
7d3afd4356a2 [SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19675
diff changeset
94 maskBits = D10LO_MASK | D10HI_MASK;
19675
413ac504d74e [SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 18744
diff changeset
95 } 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
96 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
97 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
98 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
99 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
100 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
101 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
102 }
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 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
104 default:
21708
6df25b1418be moved com.oracle.asm.** to jvmci-util.jar (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21673
diff changeset
105 throw new InternalError("Unknown op2 " + op2);
19675
413ac504d74e [SPARC] Simplify branch instructions (No more object allocations), Tidy up SPARCControlFlow and SPARCAssembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 18744
diff changeset
106 }
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 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
108 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
109 emitInt(newInst, branch);
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9949
diff changeset
110 }
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9949
diff changeset
111
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9949
diff changeset
112 @Override
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9949
diff changeset
113 public AbstractAddress makeAddress(Register base, int displacement) {
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10468
diff changeset
114 return new SPARCAddress(base, displacement);
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9949
diff changeset
115 }
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9949
diff changeset
116
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9949
diff changeset
117 @Override
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9949
diff changeset
118 public AbstractAddress getPlaceholder() {
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10468
diff changeset
119 return Placeholder;
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9949
diff changeset
120 }
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9949
diff changeset
121
14754
164903a50a9a make ensureUniquePC an abstract method of the base Assembler class
Erik Eckstein <erik.eckstein@oracle.com>
parents: 14031
diff changeset
122 @Override
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
123 public final void ensureUniquePC() {
19677
7d3afd4356a2 [SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19675
diff changeset
124 nop();
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
125 }
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
126
19684
00d7b0adaf66 [SPARC] Change ld/st ops of SPARC to functions
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19682
diff changeset
127 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: 19682
diff changeset
128 casa(rs1, rs2, rd, Asi.ASI_PRIMARY);
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
129 }
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
130
19684
00d7b0adaf66 [SPARC] Change ld/st ops of SPARC to functions
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19682
diff changeset
131 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: 19682
diff changeset
132 casxa(rs1, rs2, rd, Asi.ASI_PRIMARY);
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
133 }
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
134
19682
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
135 public void clr(Register dst) {
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
136 or(g0, g0, dst);
9845
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9844
diff changeset
137 }
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9844
diff changeset
138
19684
00d7b0adaf66 [SPARC] Change ld/st ops of SPARC to functions
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19682
diff changeset
139 public void clrb(SPARCAddress addr) {
00d7b0adaf66 [SPARC] Change ld/st ops of SPARC to functions
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19682
diff changeset
140 stb(g0, addr);
9845
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9844
diff changeset
141 }
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9844
diff changeset
142
19684
00d7b0adaf66 [SPARC] Change ld/st ops of SPARC to functions
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19682
diff changeset
143 public void clrh(SPARCAddress addr) {
00d7b0adaf66 [SPARC] Change ld/st ops of SPARC to functions
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19682
diff changeset
144 sth(g0, addr);
9845
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9844
diff changeset
145 }
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9844
diff changeset
146
19684
00d7b0adaf66 [SPARC] Change ld/st ops of SPARC to functions
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19682
diff changeset
147 public void clrx(SPARCAddress addr) {
00d7b0adaf66 [SPARC] Change ld/st ops of SPARC to functions
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19682
diff changeset
148 stx(g0, addr);
9844
2d1687e63484 SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
149 }
2d1687e63484 SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
150
19682
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
151 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: 19677
diff changeset
152 subcc(rs1, rs2, g0);
9845
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9844
diff changeset
153 }
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9844
diff changeset
154
19682
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
155 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: 19677
diff changeset
156 subcc(rs1, simm13, g0);
9845
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9844
diff changeset
157 }
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9844
diff changeset
158
19682
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
159 public void dec(Register rd) {
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
160 sub(rd, 1, rd);
9845
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9844
diff changeset
161 }
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9844
diff changeset
162
19682
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
163 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: 19677
diff changeset
164 sub(rd, simm13, rd);
9845
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9844
diff changeset
165 }
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9844
diff changeset
166
19682
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
167 public void jmp(SPARCAddress address) {
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
168 jmpl(address.getBase(), address.getDisplacement(), g0);
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
169 }
9845
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9844
diff changeset
170
19682
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
171 public void jmp(Register rd) {
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
172 jmpl(rd, 0, g0);
9845
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9844
diff changeset
173 }
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9844
diff changeset
174
19682
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
175 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: 19677
diff changeset
176 sub(g0, rs1, rd);
9845
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9844
diff changeset
177 }
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9844
diff changeset
178
19682
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
179 public void neg(Register rd) {
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
180 sub(g0, rd, rd);
9845
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9844
diff changeset
181 }
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9844
diff changeset
182
19682
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
183 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: 19677
diff changeset
184 or(g0, rs, rd);
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9949
diff changeset
185 }
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9949
diff changeset
186
19682
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
187 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: 19677
diff changeset
188 or(g0, simm13, rd);
9844
2d1687e63484 SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
189 }
2d1687e63484 SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
190
19682
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
191 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: 19677
diff changeset
192 xnor(rs1, g0, rd);
9844
2d1687e63484 SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
193 }
2d1687e63484 SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
194
19682
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
195 public void not(Register rd) {
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
196 xnor(rd, g0, rd);
9844
2d1687e63484 SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
197 }
2d1687e63484 SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
198
19682
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
199 public void restoreWindow() {
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
200 restore(g0, g0, g0);
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
201 }
10694
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
202
19682
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
203 public void ret() {
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
204 jmpl(i7, 8, g0);
9845
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9844
diff changeset
205 }
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9844
diff changeset
206
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
207 /**
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
208 * 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
209 */
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
210 public static class Sethix {
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
211
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
212 private static final int INSTRUCTION_SIZE = 7;
9845
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9844
diff changeset
213
10694
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
214 private long value;
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
215 private Register dst;
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
216 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
217 private boolean delayed = false;
19677
7d3afd4356a2 [SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19675
diff changeset
218 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
219
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 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
221 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
222 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
223 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
224 }
10694
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
225
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
226 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
227 this.value = value;
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
228 this.dst = dst;
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
229 this.forceRelocatable = forceRelocatable;
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
230 }
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
231
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
232 public Sethix(long value, Register dst) {
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
233 this(value, dst, false);
10694
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
234 }
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
235
19677
7d3afd4356a2 [SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19675
diff changeset
236 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
237 if (delayed) {
19677
7d3afd4356a2 [SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19675
diff changeset
238 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: 19675
diff changeset
239 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
240 }
19677
7d3afd4356a2 [SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19675
diff changeset
241 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
242 } else {
19677
7d3afd4356a2 [SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19675
diff changeset
243 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
244 }
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
10694
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
247 public void emit(SPARCMacroAssembler masm) {
19677
7d3afd4356a2 [SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19675
diff changeset
248 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: 19675
diff changeset
249 final int lo = (int) (value & ~0);
9845
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9844
diff changeset
250
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
251 // 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
252 final int startPc = masm.position();
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
253
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
254 if (hi == 0 && lo >= 0) {
19677
7d3afd4356a2 [SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19675
diff changeset
255 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: 19675
diff changeset
256 emitInstruction(cb, masm);
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
257 } else if (hi == -1) {
19677
7d3afd4356a2 [SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19675
diff changeset
258 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: 19675
diff changeset
259 emitInstruction(cb, masm);
19682
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
260 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: 19677
diff changeset
261 emitInstruction(cb, masm);
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
262 } else {
19682
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
263 final int shiftcnt;
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
264 final int shiftcnt2;
19677
7d3afd4356a2 [SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19675
diff changeset
265 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: 19675
diff changeset
266 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
267 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
268 // msb 32-bits are now in lsb 32
19682
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
269 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: 19677
diff changeset
270 emitInstruction(cb, masm);
9845
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9844
diff changeset
271 }
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
272 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
273 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
274 // Make room for next 12 bits
19682
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
275 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: 19677
diff changeset
276 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
277 // Or in next 12
19682
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
278 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: 19677
diff changeset
279 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
280 shiftcnt = 0; // We already shifted
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
281 } else {
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
282 shiftcnt = 12;
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
283 }
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
284 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
285 // Make room for last 10 bits
19682
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
286 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: 19677
diff changeset
287 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
288 // Or in next 10
19682
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
289 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: 19677
diff changeset
290 emitInstruction(cb, masm);
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
291 shiftcnt2 = 0;
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
292 } else {
19682
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
293 shiftcnt2 = 10;
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
294 }
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
295 // Shift leaving disp field 0'd
19682
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
296 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: 19677
diff changeset
297 emitInstruction(cb, masm);
9845
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9844
diff changeset
298 } else {
19682
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
299 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: 19677
diff changeset
300 emitInstruction(cb, masm);
9845
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9844
diff changeset
301 }
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
302 }
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
303 // Pad out the instruction sequence so it can be patched later.
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
304 if (forceRelocatable) {
14031
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 11233
diff changeset
305 while (masm.position() < (startPc + (INSTRUCTION_SIZE * 4))) {
19677
7d3afd4356a2 [SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19675
diff changeset
306 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: 19675
diff changeset
307 emitInstruction(cb, masm);
9845
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9844
diff changeset
308 }
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
309 }
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
310 }
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
311
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 public void emitDelayed(SPARCMacroAssembler masm) {
19677
7d3afd4356a2 [SPARC] Remove all object oriented fmt00 instructions (sethi, nop, cbcond) and use simple function calls
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19675
diff changeset
313 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: 19675
diff changeset
314 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
315 }
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
316 }
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 public static class Setx {
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
319
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
320 private long value;
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
321 private Register dst;
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
322 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
323 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
324 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
325 private Sethix sethix;
19682
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
326 private Consumer<SPARCMacroAssembler> delayedAdd;
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
327
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
328 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
329 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
330 this.value = value;
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
331 this.dst = dst;
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
332 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
333 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
334 }
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 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
337 this(value, dst, forceRelocatable, false);
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
338 }
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 public Setx(long value, Register dst) {
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
341 this(value, dst, false);
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
342 }
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 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
345 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
346 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
347 }
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 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
350 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
351 sethix.emit(masm);
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
352 int lo = (int) (value & ~0);
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
353 if (lo10(lo) != 0 || forceRelocatable) {
19682
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
354 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
355 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
356 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
357 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
358 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
359 } 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
360 sethix = null;
19682
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
361 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
362 }
9845
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9844
diff changeset
363 }
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9844
diff changeset
364 }
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
365
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 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
367 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
368 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
369 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
370 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
371 }
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 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
374 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
375 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
376 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
377 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
378 if (delayedAdd != null) {
19682
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
379 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
380 } 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
381 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
382 }
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 }
9845
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9844
diff changeset
385 }
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9844
diff changeset
386
19682
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
387 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: 19677
diff changeset
388 sra(rs, g0, rd);
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
389 }
9845
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9844
diff changeset
390
19682
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
391 public void signx(Register rd) {
f1b4f2613702 [SPARC] Change arithmetic ops of SPARC to functions in assembler
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19677
diff changeset
392 sra(rd, g0, rd);
9845
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9844
diff changeset
393 }
19941
4fe66c16e942 [SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19684
diff changeset
394
4fe66c16e942 [SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19684
diff changeset
395 public ScratchRegister getScratchRegister() {
4fe66c16e942 [SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19684
diff changeset
396 return scratchRegister[nextFreeScratchRegister++];
4fe66c16e942 [SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19684
diff changeset
397 }
4fe66c16e942 [SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19684
diff changeset
398
4fe66c16e942 [SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19684
diff changeset
399 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: 19684
diff changeset
400 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: 19684
diff changeset
401
4fe66c16e942 [SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19684
diff changeset
402 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: 19684
diff changeset
403 super();
4fe66c16e942 [SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19684
diff changeset
404 this.register = register;
4fe66c16e942 [SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19684
diff changeset
405 }
4fe66c16e942 [SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19684
diff changeset
406
4fe66c16e942 [SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19684
diff changeset
407 public Register getRegister() {
4fe66c16e942 [SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19684
diff changeset
408 return register;
4fe66c16e942 [SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19684
diff changeset
409 }
4fe66c16e942 [SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19684
diff changeset
410
4fe66c16e942 [SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19684
diff changeset
411 public void close() {
4fe66c16e942 [SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19684
diff changeset
412 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: 19684
diff changeset
413 nextFreeScratchRegister--;
4fe66c16e942 [SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19684
diff changeset
414 }
4fe66c16e942 [SPARC] (Re)move SPARCScratchRegister into the SPARCMacroAssembler to force usage only during assembly.
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19684
diff changeset
415 }
9844
2d1687e63484 SPARCMacroAssembler and synthetic instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
416 }