annotate graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCControlFlow.java @ 12503:d7f8dd4fe876

minor reformatting based on 'mx eclipseformat'
author Doug Simon <doug.simon@oracle.com>
date Mon, 21 Oct 2013 18:10:32 +0200
parents 23ccaa863eda
children 1a66453f73db
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9816
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
1 /*
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
4 *
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
8 *
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
13 * accompanied this code).
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
14 *
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
18 *
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
21 * questions.
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
22 */
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
23 package com.oracle.graal.lir.sparc;
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
24
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
25 import static com.oracle.graal.api.code.ValueUtil.*;
9816
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
26 import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
27
9856
fbeda9df497d implemented workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=409824
Doug Simon <doug.simon@oracle.com>
parents: 9846
diff changeset
28 import com.oracle.graal.api.code.CompilationResult.JumpTable;
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
29 import com.oracle.graal.api.code.*;
9816
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
30 import com.oracle.graal.api.meta.*;
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
31 import com.oracle.graal.asm.*;
9816
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
32 import com.oracle.graal.asm.sparc.*;
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9856
diff changeset
33 import com.oracle.graal.asm.sparc.SPARCAssembler.*;
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
34 import com.oracle.graal.graph.*;
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
35 import com.oracle.graal.lir.*;
9856
fbeda9df497d implemented workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=409824
Doug Simon <doug.simon@oracle.com>
parents: 9846
diff changeset
36 import com.oracle.graal.lir.StandardOp.FallThroughOp;
9816
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
37 import com.oracle.graal.lir.asm.*;
9856
fbeda9df497d implemented workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=409824
Doug Simon <doug.simon@oracle.com>
parents: 9846
diff changeset
38 import com.oracle.graal.nodes.calc.*;
9816
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
39
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9856
diff changeset
40 import static com.oracle.graal.asm.sparc.SPARCMacroAssembler.*;
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9856
diff changeset
41
9816
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
42 public class SPARCControlFlow {
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
43
9831
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
44 public static class BranchOp extends SPARCLIRInstruction implements StandardOp.BranchOp {
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
45
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
46 protected Condition condition;
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
47 protected LabelRef destination;
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
48 protected final Kind kind;
9831
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
49
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
50 public BranchOp(Condition condition, LabelRef destination, Kind kind) {
9831
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
51 this.condition = condition;
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
52 this.destination = destination;
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
53 this.kind = kind;
9831
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
54 }
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
55
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
56 @Override
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10468
diff changeset
57 public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) {
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
58 assert kind == Kind.Int || kind == Kind.Long || kind == Kind.Object;
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
59 CC cc = kind == Kind.Int ? CC.Icc : CC.Xcc;
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9856
diff changeset
60 switch (condition) {
10694
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
61 case EQ:
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
62 new Bpe(cc, destination.label()).emit(masm);
10694
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
63 break;
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
64 case NE:
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
65 new Bpne(cc, destination.label()).emit(masm);
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
66 break;
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
67 case BT:
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
68 new Bplu(cc, destination.label()).emit(masm);
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
69 break;
10871
c3b09d69dfde SPARC: fixes and more implementation; can now allocate objects
twisti
parents: 10854
diff changeset
70 case LT:
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
71 new Bpl(cc, destination.label()).emit(masm);
10871
c3b09d69dfde SPARC: fixes and more implementation; can now allocate objects
twisti
parents: 10854
diff changeset
72 break;
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
73 case BE:
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
74 new Bpleu(cc, destination.label()).emit(masm);
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
75 break;
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
76 case LE:
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
77 new Bple(cc, destination.label()).emit(masm);
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
78 break;
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
79 case GE:
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
80 new Bpge(cc, destination.label()).emit(masm);
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
81 break;
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
82 case AE:
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
83 new Bpgeu(cc, destination.label()).emit(masm);
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
84 break;
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9856
diff changeset
85 case GT:
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
86 new Bpg(cc, destination.label()).emit(masm);
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9856
diff changeset
87 break;
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
88 case AT:
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
89 new Bpgu(cc, destination.label()).emit(masm);
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
90 break;
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9856
diff changeset
91 default:
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9856
diff changeset
92 throw GraalInternalError.shouldNotReachHere();
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9856
diff changeset
93 }
10468
cfbe4f978116 SPARC assembler enhancements and more fixes
twisti
parents: 10467
diff changeset
94 new Nop().emit(masm); // delay slot
9831
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
95 }
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
96
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
97 @Override
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
98 public LabelRef destination() {
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
99 return destination;
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
100 }
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
101
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
102 @Override
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
103 public void negate(LabelRef newDestination) {
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
104 destination = newDestination;
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
105 condition = condition.negate();
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
106 }
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
107 }
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
108
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
109 @Opcode("CMOVE")
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
110 public static class CondMoveOp extends SPARCLIRInstruction {
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
111
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
112 @Def({REG, HINT}) protected Value result;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
113 @Alive({REG}) protected Value trueValue;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
114 @Use({REG, STACK, CONST}) protected Value falseValue;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
115
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
116 private final ConditionFlag condition;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
117
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
118 public CondMoveOp(Variable result, Condition condition, Variable trueValue, Value falseValue) {
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
119 this.result = result;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
120 this.condition = intCond(condition);
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
121 this.trueValue = trueValue;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
122 this.falseValue = falseValue;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
123 }
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
124
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
125 @Override
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10468
diff changeset
126 public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) {
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
127 cmove(tasm, masm, result, false, condition, false, trueValue, falseValue);
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
128 }
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
129 }
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
130
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
131 @Opcode("CMOVE")
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
132 public static class FloatCondMoveOp extends SPARCLIRInstruction {
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
133
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
134 @Def({REG}) protected Value result;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
135 @Alive({REG}) protected Value trueValue;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
136 @Alive({REG}) protected Value falseValue;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
137 private final ConditionFlag condition;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
138 private final boolean unorderedIsTrue;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
139
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
140 public FloatCondMoveOp(Variable result, Condition condition, boolean unorderedIsTrue, Variable trueValue, Variable falseValue) {
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
141 this.result = result;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
142 this.condition = floatCond(condition);
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
143 this.unorderedIsTrue = unorderedIsTrue;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
144 this.trueValue = trueValue;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
145 this.falseValue = falseValue;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
146 }
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
147
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
148 @Override
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10468
diff changeset
149 public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) {
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
150 cmove(tasm, masm, result, true, condition, unorderedIsTrue, trueValue, falseValue);
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
151 }
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
152 }
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
153
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10468
diff changeset
154 private static void cmove(TargetMethodAssembler tasm, SPARCMacroAssembler masm, Value result, boolean isFloat, ConditionFlag condition, boolean unorderedIsTrue, Value trueValue, Value falseValue) {
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
155 // check that we don't overwrite an input operand before it is used.
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
156 assert !result.equals(trueValue);
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
157
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
158 SPARCMove.move(tasm, masm, result, falseValue);
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
159 cmove(tasm, masm, result, condition, trueValue);
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
160
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
161 if (isFloat) {
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
162 if (unorderedIsTrue && !trueOnUnordered(condition)) {
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
163 // cmove(tasm, masm, result, ConditionFlag.Parity, trueValue);
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
164 throw GraalInternalError.unimplemented();
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
165 } else if (!unorderedIsTrue && trueOnUnordered(condition)) {
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
166 // cmove(tasm, masm, result, ConditionFlag.Parity, falseValue);
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
167 throw GraalInternalError.unimplemented();
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
168 }
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
169 }
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
170 }
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
171
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10468
diff changeset
172 private static void cmove(TargetMethodAssembler tasm, SPARCMacroAssembler masm, Value result, ConditionFlag cond, Value other) {
10468
cfbe4f978116 SPARC assembler enhancements and more fixes
twisti
parents: 10467
diff changeset
173 if (!isRegister(other)) {
cfbe4f978116 SPARC assembler enhancements and more fixes
twisti
parents: 10467
diff changeset
174 SPARCMove.move(tasm, masm, result, other);
cfbe4f978116 SPARC assembler enhancements and more fixes
twisti
parents: 10467
diff changeset
175 throw new InternalError("result should be scratch");
cfbe4f978116 SPARC assembler enhancements and more fixes
twisti
parents: 10467
diff changeset
176 }
cfbe4f978116 SPARC assembler enhancements and more fixes
twisti
parents: 10467
diff changeset
177 assert !asRegister(other).equals(asRegister(result)) : "other already overwritten by previous move";
cfbe4f978116 SPARC assembler enhancements and more fixes
twisti
parents: 10467
diff changeset
178 switch (other.getKind()) {
cfbe4f978116 SPARC assembler enhancements and more fixes
twisti
parents: 10467
diff changeset
179 case Int:
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
180 // XXX CC depends on compare
10468
cfbe4f978116 SPARC assembler enhancements and more fixes
twisti
parents: 10467
diff changeset
181 new Movcc(cond, CC.Icc, asRegister(other), asRegister(result)).emit(masm);
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
182 break;
10468
cfbe4f978116 SPARC assembler enhancements and more fixes
twisti
parents: 10467
diff changeset
183 case Long:
cfbe4f978116 SPARC assembler enhancements and more fixes
twisti
parents: 10467
diff changeset
184 default:
cfbe4f978116 SPARC assembler enhancements and more fixes
twisti
parents: 10467
diff changeset
185 throw GraalInternalError.shouldNotReachHere();
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
186 }
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
187 }
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
188
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
189 private static ConditionFlag intCond(Condition cond) {
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
190 switch (cond) {
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
191 case EQ:
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
192 return ConditionFlag.Equal;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
193 case NE:
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
194 return ConditionFlag.NotEqual;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
195 case LT:
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
196 return ConditionFlag.Less;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
197 case LE:
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
198 return ConditionFlag.LessEqual;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
199 case GE:
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
200 return ConditionFlag.GreaterEqual;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
201 case GT:
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
202 return ConditionFlag.Greater;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
203 case BE:
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
204 case AE:
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
205 case AT:
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
206 case BT:
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
207 default:
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
208 throw GraalInternalError.shouldNotReachHere();
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
209 }
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
210 }
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
211
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
212 private static ConditionFlag floatCond(Condition cond) {
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
213 switch (cond) {
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
214 case EQ:
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
215 return ConditionFlag.Equal;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
216 case NE:
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
217 return ConditionFlag.NotEqual;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
218 case LT:
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
219 case LE:
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
220 case GE:
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
221 case GT:
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
222 default:
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
223 throw GraalInternalError.shouldNotReachHere();
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
224 }
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
225 }
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
226
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
227 private static boolean trueOnUnordered(ConditionFlag condition) {
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
228 switch (condition) {
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
229 case NotEqual:
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
230 case Less:
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
231 return false;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
232 case Equal:
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
233 case GreaterEqual:
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
234 return true;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
235 default:
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
236 throw GraalInternalError.shouldNotReachHere();
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
237 }
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
238 }
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
239
9816
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
240 public static class ReturnOp extends SPARCLIRInstruction {
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
241
9831
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
242 @Use({REG, ILLEGAL}) protected Value x;
9816
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
243
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
244 public ReturnOp(Value x) {
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
245 this.x = x;
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
246 }
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
247
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
248 @Override
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10468
diff changeset
249 public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) {
11760
ce0b00597980 made safepoint-on-return use specialized HotSpot runtime support for such safepoints (which have no debug info attached)
Doug Simon <doug.simon@oracle.com>
parents: 11233
diff changeset
250 emitCodeHelper(tasm, masm);
ce0b00597980 made safepoint-on-return use specialized HotSpot runtime support for such safepoints (which have no debug info attached)
Doug Simon <doug.simon@oracle.com>
parents: 11233
diff changeset
251 }
ce0b00597980 made safepoint-on-return use specialized HotSpot runtime support for such safepoints (which have no debug info attached)
Doug Simon <doug.simon@oracle.com>
parents: 11233
diff changeset
252
ce0b00597980 made safepoint-on-return use specialized HotSpot runtime support for such safepoints (which have no debug info attached)
Doug Simon <doug.simon@oracle.com>
parents: 11233
diff changeset
253 public static void emitCodeHelper(TargetMethodAssembler tasm, SPARCMacroAssembler masm) {
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9856
diff changeset
254 new Ret().emit(masm);
11760
ce0b00597980 made safepoint-on-return use specialized HotSpot runtime support for such safepoints (which have no debug info attached)
Doug Simon <doug.simon@oracle.com>
parents: 11233
diff changeset
255 // On SPARC we always leave the frame (in the delay slot).
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9856
diff changeset
256 tasm.frameContext.leave(tasm);
9816
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
257 }
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
258 }
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
259
9831
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
260 public static class SequentialSwitchOp extends SPARCLIRInstruction implements FallThroughOp {
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
261
9831
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
262 @Use({CONST}) protected Constant[] keyConstants;
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
263 private final LabelRef[] keyTargets;
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
264 private LabelRef defaultTarget;
9831
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
265 @Alive({REG}) protected Value key;
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
266 @Temp({REG, ILLEGAL}) protected Value scratch;
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
267
9831
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
268 public SequentialSwitchOp(Constant[] keyConstants, LabelRef[] keyTargets, LabelRef defaultTarget, Value key, Value scratch) {
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
269 assert keyConstants.length == keyTargets.length;
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
270 this.keyConstants = keyConstants;
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
271 this.keyTargets = keyTargets;
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
272 this.defaultTarget = defaultTarget;
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
273 this.key = key;
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
274 this.scratch = scratch;
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
275 }
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
276
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
277 @Override
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10468
diff changeset
278 public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) {
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
279 if (key.getKind() == Kind.Int) {
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
280 Register intKey = asIntReg(key);
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
281 for (int i = 0; i < keyConstants.length; i++) {
11959
23ccaa863eda made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11760
diff changeset
282 if (tasm.codeCache.needsDataPatch(keyConstants[i])) {
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
283 tasm.recordDataReferenceInCode(keyConstants[i], 0, true);
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
284 }
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
285 long lc = keyConstants[i].asLong();
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
286 assert NumUtil.isInt(lc);
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9856
diff changeset
287 new Cmp(intKey, (int) lc).emit(masm);
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
288 new Bpe(CC.Icc, keyTargets[i].label()).emit(masm);
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
289 new Nop().emit(masm); // delay slot
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
290 }
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
291 } else if (key.getKind() == Kind.Long) {
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
292 Register longKey = asLongReg(key);
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
293 Register temp = asLongReg(scratch);
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
294 for (int i = 0; i < keyConstants.length; i++) {
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
295 SPARCMove.move(tasm, masm, temp.asValue(Kind.Long), keyConstants[i]);
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
296 new Cmp(longKey, temp).emit(masm);
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
297 new Bpe(CC.Xcc, keyTargets[i].label()).emit(masm);
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
298 new Nop().emit(masm); // delay slot
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
299 }
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
300 } else if (key.getKind() == Kind.Object) {
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
301 Register objectKey = asObjectReg(key);
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
302 Register temp = asObjectReg(scratch);
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
303 for (int i = 0; i < keyConstants.length; i++) {
9831
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
304 SPARCMove.move(tasm, masm, temp.asValue(Kind.Object), keyConstants[i]);
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
305 new Cmp(objectKey, temp).emit(masm);
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9856
diff changeset
306 new Bpe(CC.Ptrcc, keyTargets[i].label()).emit(masm);
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
307 new Nop().emit(masm); // delay slot
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
308 }
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
309 } else {
9831
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
310 throw new GraalInternalError("sequential switch only supported for int, long and object");
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
311 }
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
312 if (defaultTarget != null) {
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
313 masm.jmp(defaultTarget.label());
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
314 } else {
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
315 new Illtrap(0).emit(masm);
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
316 }
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
317 }
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
318
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
319 @Override
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
320 public LabelRef fallThroughTarget() {
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
321 return defaultTarget;
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
322 }
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
323
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
324 @Override
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
325 public void setFallThroughTarget(LabelRef target) {
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
326 defaultTarget = target;
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
327 }
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
328 }
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
329
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
330 public static class SwitchRangesOp extends SPARCLIRInstruction implements FallThroughOp {
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
331
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
332 private final LabelRef[] keyTargets;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
333 private LabelRef defaultTarget;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
334 private final int[] lowKeys;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
335 private final int[] highKeys;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
336 @Alive protected Value key;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
337
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
338 public SwitchRangesOp(int[] lowKeys, int[] highKeys, LabelRef[] keyTargets, LabelRef defaultTarget, Value key) {
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
339 this.lowKeys = lowKeys;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
340 this.highKeys = highKeys;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
341 this.keyTargets = keyTargets;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
342 this.defaultTarget = defaultTarget;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
343 this.key = key;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
344 }
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
345
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
346 @Override
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10468
diff changeset
347 public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) {
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
348 assert isSorted(lowKeys) && isSorted(highKeys);
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
349
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
350 Label actualDefaultTarget = defaultTarget == null ? new Label() : defaultTarget.label();
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
351 int prevHighKey = 0;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
352 boolean skipLowCheck = false;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
353 for (int i = 0; i < lowKeys.length; i++) {
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
354 int lowKey = lowKeys[i];
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
355 int highKey = highKeys[i];
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
356 if (lowKey == highKey) {
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
357 // masm.cmpl(asIntReg(key), lowKey);
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
358 // masm.jcc(ConditionFlag.Equal, keyTargets[i].label());
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
359 skipLowCheck = false;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
360 } else {
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
361 if (!skipLowCheck || (prevHighKey + 1) != lowKey) {
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
362 // masm.cmpl(asIntReg(key), lowKey);
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
363 // masm.jcc(ConditionFlag.Less, actualDefaultTarget);
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
364 }
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
365 // masm.cmpl(asIntReg(key), highKey);
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
366 // masm.jcc(ConditionFlag.LessEqual, keyTargets[i].label());
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
367 skipLowCheck = true;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
368 }
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
369 prevHighKey = highKey;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
370 }
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
371 if (defaultTarget != null) {
10468
cfbe4f978116 SPARC assembler enhancements and more fixes
twisti
parents: 10467
diff changeset
372 new Bpa(defaultTarget.label()).emit(masm);
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
373 } else {
10468
cfbe4f978116 SPARC assembler enhancements and more fixes
twisti
parents: 10467
diff changeset
374 masm.bind(actualDefaultTarget);
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
375 // masm.hlt();
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
376 }
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
377 throw GraalInternalError.unimplemented();
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
378 }
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
379
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
380 @Override
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
381 protected void verify() {
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
382 super.verify();
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
383 assert lowKeys.length == keyTargets.length;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
384 assert highKeys.length == keyTargets.length;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
385 assert key.getKind() == Kind.Int;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
386 }
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
387
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
388 @Override
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
389 public LabelRef fallThroughTarget() {
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
390 return defaultTarget;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
391 }
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
392
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
393 @Override
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
394 public void setFallThroughTarget(LabelRef target) {
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
395 defaultTarget = target;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
396 }
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
397
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
398 private static boolean isSorted(int[] values) {
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
399 for (int i = 1; i < values.length; i++) {
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
400 if (values[i - 1] >= values[i]) {
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
401 return false;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
402 }
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
403 }
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
404 return true;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
405 }
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
406 }
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9831
diff changeset
407
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
408 public static class TableSwitchOp extends SPARCLIRInstruction {
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
409
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
410 private final int lowKey;
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
411 private final LabelRef defaultTarget;
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
412 private final LabelRef[] targets;
9831
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
413 @Alive protected Value index;
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
414 @Temp protected Value scratch;
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
415
9831
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
416 public TableSwitchOp(final int lowKey, final LabelRef defaultTarget, final LabelRef[] targets, Variable index, Variable scratch) {
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
417 this.lowKey = lowKey;
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
418 this.defaultTarget = defaultTarget;
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
419 this.targets = targets;
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
420 this.index = index;
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
421 this.scratch = scratch;
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
422 }
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
423
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
424 @Override
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10468
diff changeset
425 public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) {
9831
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
426 tableswitch(tasm, masm, lowKey, defaultTarget, targets, asIntReg(index), asLongReg(scratch));
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
427 }
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
428 }
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
429
9831
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
430 private static void tableswitch(TargetMethodAssembler tasm, SPARCAssembler masm, int lowKey, LabelRef defaultTarget, LabelRef[] targets, Register value, Register scratch) {
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
431 Buffer buf = masm.codeBuffer;
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
432 // Compare index against jump table bounds
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
433 int highKey = lowKey + targets.length - 1;
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
434 if (lowKey != 0) {
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
435 // subtract the low value from the switch value
10468
cfbe4f978116 SPARC assembler enhancements and more fixes
twisti
parents: 10467
diff changeset
436 new Sub(value, lowKey, value).emit(masm);
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
437 // masm.setp_gt_s32(value, highKey - lowKey);
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
438 } else {
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
439 // masm.setp_gt_s32(value, highKey);
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
440 }
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
441
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
442 // Jump to default target if index is not within the jump table
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
443 if (defaultTarget != null) {
10468
cfbe4f978116 SPARC assembler enhancements and more fixes
twisti
parents: 10467
diff changeset
444 new Bpgu(CC.Icc, defaultTarget.label()).emit(masm);
cfbe4f978116 SPARC assembler enhancements and more fixes
twisti
parents: 10467
diff changeset
445 new Nop().emit(masm); // delay slot
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
446 }
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
447
10468
cfbe4f978116 SPARC assembler enhancements and more fixes
twisti
parents: 10467
diff changeset
448 // Load jump table entry into scratch and jump to it
12503
d7f8dd4fe876 minor reformatting based on 'mx eclipseformat'
Doug Simon <doug.simon@oracle.com>
parents: 11959
diff changeset
449 // masm.movslq(value, new AMD64Address(scratch, value, Scale.Times4, 0));
d7f8dd4fe876 minor reformatting based on 'mx eclipseformat'
Doug Simon <doug.simon@oracle.com>
parents: 11959
diff changeset
450 // masm.addq(scratch, value);
10468
cfbe4f978116 SPARC assembler enhancements and more fixes
twisti
parents: 10467
diff changeset
451 new Jmp(new SPARCAddress(scratch, 0)).emit(masm);
cfbe4f978116 SPARC assembler enhancements and more fixes
twisti
parents: 10467
diff changeset
452 new Nop().emit(masm); // delay slot
cfbe4f978116 SPARC assembler enhancements and more fixes
twisti
parents: 10467
diff changeset
453
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
454 // address of jump table
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
455 int tablePos = buf.position();
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
456
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
457 JumpTable jt = new JumpTable(tablePos, lowKey, highKey, 4);
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
458 tasm.compilationResult.addAnnotation(jt);
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
459
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
460 // SPARC: unimp: tableswitch extract
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
461 throw GraalInternalError.unimplemented();
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
462 }
9816
4e9854086532 Initial SPARC compilation test
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
463 }