annotate graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java @ 16932:4d77f938aa02

[SPARC] Exclude AMD64 tests from SPARC testrun, always use tmp register when using StrategySwitch, using registerSaver in EnterUnpackStackFrame, LeaveCurrentStackframe, adding guarantee to load offsets when doing load reg+imm13 when the imm value does not fit in 13 bit, assertions for scratch register usage (tmp/def)
author Stefan Anzinger <stefan.anzinger@gmail.com>
date Tue, 19 Aug 2014 09:21:29 -0700
parents 5c8a0b322d15
children f011bf910f34
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7740
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
13541
63bb635911ab String.equals method substitution
twisti
parents: 13520
diff changeset
2 * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
7740
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
23
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24 package com.oracle.graal.compiler.sparc;
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
25
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9825
diff changeset
26 import static com.oracle.graal.api.code.ValueUtil.*;
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10470
diff changeset
27 import static com.oracle.graal.lir.sparc.SPARCArithmetic.*;
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
28 import static com.oracle.graal.lir.sparc.SPARCBitManipulationOp.IntrinsicOpcode.*;
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10470
diff changeset
29 import static com.oracle.graal.lir.sparc.SPARCCompare.*;
15345
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15301
diff changeset
30 import static com.oracle.graal.lir.sparc.SPARCControlFlow.*;
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
31 import static com.oracle.graal.lir.sparc.SPARCMathIntrinsicOp.IntrinsicOpcode.*;
15345
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15301
diff changeset
32 import static com.oracle.graal.lir.sparc.SPARCMove.*;
9814
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9739
diff changeset
33
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10470
diff changeset
34 import com.oracle.graal.api.code.*;
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
35 import com.oracle.graal.api.meta.*;
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
36 import com.oracle.graal.asm.*;
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 10077
diff changeset
37 import com.oracle.graal.asm.sparc.*;
16926
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
38 import com.oracle.graal.asm.sparc.SPARCAssembler.*;
15193
96bb07a5d667 Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents: 14962
diff changeset
39 import com.oracle.graal.compiler.common.*;
15200
97eed257999b Move Condition to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15193
diff changeset
40 import com.oracle.graal.compiler.common.calc.*;
15261
882f4cb7cfcf Move Stamps to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15200
diff changeset
41 import com.oracle.graal.compiler.common.type.*;
9845
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9843
diff changeset
42 import com.oracle.graal.lir.*;
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10470
diff changeset
43 import com.oracle.graal.lir.StandardOp.JumpOp;
15292
a38d791982e1 Move LIRGenerationResult* to graal.lir.
Josef Eisl <josef.eisl@jku.at>
parents: 15261
diff changeset
44 import com.oracle.graal.lir.gen.*;
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10470
diff changeset
45 import com.oracle.graal.lir.sparc.*;
12363
78e5badf4b8e moved lookupForeignCall() from CodeCacheProvider to ForeignCallsProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11959
diff changeset
46 import com.oracle.graal.phases.util.*;
7740
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
47
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
48 /**
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
49 * This class implements the SPARC specific portion of the LIR generator.
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
50 */
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10470
diff changeset
51 public abstract class SPARCLIRGenerator extends LIRGenerator {
7740
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
52
14121
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
53 private class SPARCSpillMoveFactory implements LIR.SpillMoveFactory {
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
54
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
55 @Override
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
56 public LIRInstruction createMove(AllocatableValue result, Value input) {
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
57 return SPARCLIRGenerator.this.createMove(result, input);
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
58 }
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
59 }
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
60
14847
c132602c640e Apply LIRGenerator refactoring to SPARC backend.
Josef Eisl <josef.eisl@jku.at>
parents: 14820
diff changeset
61 public SPARCLIRGenerator(Providers providers, CallingConvention cc, LIRGenerationResult lirGenRes) {
c132602c640e Apply LIRGenerator refactoring to SPARC backend.
Josef Eisl <josef.eisl@jku.at>
parents: 14820
diff changeset
62 super(providers, cc, lirGenRes);
14809
73774616a6b3 Decoupled LIRGenerator and LIRGenerationResult.
Josef Eisl <josef.eisl@jku.at>
parents: 14796
diff changeset
63 lirGenRes.getLIR().setSpillMoveFactory(new SPARCSpillMoveFactory());
9814
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9739
diff changeset
64 }
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9739
diff changeset
65
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9739
diff changeset
66 @Override
15947
3eedf7a653ea Remove unused oop compression code from backends.
Roland Schatz <roland.schatz@oracle.com>
parents: 15691
diff changeset
67 public boolean canStoreConstant(Constant c) {
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
68 // SPARC can only store integer null constants (via g0)
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
69 switch (c.getKind()) {
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
70 case Float:
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
71 case Double:
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
72 return false;
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
73 default:
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
74 return c.isDefaultForKind();
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
75 }
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
76 }
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
77
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
78 @Override
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
79 public boolean canInlineConstant(Constant c) {
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
80 switch (c.getKind()) {
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
81 case Int:
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
82 return SPARCAssembler.isSimm13(c.asInt()) && !getCodeCache().needsDataPatch(c);
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
83 case Long:
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
84 return SPARCAssembler.isSimm13(c.asLong()) && !getCodeCache().needsDataPatch(c);
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
85 case Object:
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
86 return c.isNull();
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
87 default:
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
88 return false;
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
89 }
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
90 }
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
91
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
92 @Override
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
93 public Variable emitMove(Value input) {
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16092
diff changeset
94 Variable result = newVariable(input.getLIRKind());
9814
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9739
diff changeset
95 emitMove(result, input);
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9739
diff changeset
96 return result;
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9739
diff changeset
97 }
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9739
diff changeset
98
14121
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
99 protected SPARCLIRInstruction createMove(AllocatableValue dst, Value src) {
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
100 if (src instanceof SPARCAddressValue) {
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
101 return new LoadAddressOp(dst, (SPARCAddressValue) src);
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
102 } else if (isRegister(src) || isStackSlot(dst)) {
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
103 return new MoveFromRegOp(dst, src);
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
104 } else {
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
105 return new MoveToRegOp(dst, src);
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
106 }
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
107 }
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
108
9814
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9739
diff changeset
109 @Override
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9739
diff changeset
110 public void emitMove(AllocatableValue dst, Value src) {
14121
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
111 append(createMove(dst, src));
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
112 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
113
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
114 @Override
14735
c5ee41cf9823 replaced RawDataValue with LIRGeneratorTool.emitData(); accept only ASCII strings in log and VM error messages
Doug Simon <doug.simon@oracle.com>
parents: 14633
diff changeset
115 public void emitData(AllocatableValue dst, byte[] data) {
15345
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15301
diff changeset
116 append(new LoadDataAddressOp(dst, data));
14735
c5ee41cf9823 replaced RawDataValue with LIRGeneratorTool.emitData(); accept only ASCII strings in log and VM error messages
Doug Simon <doug.simon@oracle.com>
parents: 14633
diff changeset
117 }
c5ee41cf9823 replaced RawDataValue with LIRGeneratorTool.emitData(); accept only ASCII strings in log and VM error messages
Doug Simon <doug.simon@oracle.com>
parents: 14633
diff changeset
118
c5ee41cf9823 replaced RawDataValue with LIRGeneratorTool.emitData(); accept only ASCII strings in log and VM error messages
Doug Simon <doug.simon@oracle.com>
parents: 14633
diff changeset
119 @Override
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
120 public SPARCAddressValue emitAddress(Value base, long displacement, Value index, int scale) {
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
121 AllocatableValue baseRegister;
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
122 long finalDisp = displacement;
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
123 if (isConstant(base)) {
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
124 if (asConstant(base).isNull()) {
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
125 baseRegister = Value.ILLEGAL;
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
126 } else if (asConstant(base).getKind() != Kind.Object) {
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
127 finalDisp += asConstant(base).asLong();
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
128 baseRegister = Value.ILLEGAL;
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
129 } else {
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
130 baseRegister = load(base);
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
131 }
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
132 } else {
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
133 baseRegister = asAllocatable(base);
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
134 }
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
135
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
136 AllocatableValue indexRegister;
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
137 if (!index.equals(Value.ILLEGAL) && scale != 0) {
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
138 if (isConstant(index)) {
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
139 finalDisp += asConstant(index).asLong() * scale;
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
140 indexRegister = Value.ILLEGAL;
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
141 } else {
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
142 if (scale != 1) {
15345
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15301
diff changeset
143 Value longIndex = index.getKind() == Kind.Long ? index : emitSignExtend(index, 32, 64);
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
144 if (CodeUtil.isPowerOf2(scale)) {
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
145 indexRegister = emitShl(longIndex, Constant.forLong(CodeUtil.log2(scale)));
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
146 } else {
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
147 indexRegister = emitMul(longIndex, Constant.forLong(scale));
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
148 }
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
149 } else {
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
150 indexRegister = asAllocatable(index);
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
151 }
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
152
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
153 // if (baseRegister.equals(Value.ILLEGAL)) {
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
154 // baseRegister = asAllocatable(indexRegister);
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
155 // } else {
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
156 // Variable newBase = newVariable(Kind.Long);
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
157 // emitMove(newBase, baseRegister);
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
158 // baseRegister = newBase;
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
159 // baseRegister = emitAdd(baseRegister, indexRegister);
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
160 // }
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
161 }
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
162 } else {
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
163 indexRegister = Value.ILLEGAL;
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
164 }
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
165
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
166 int displacementInt;
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
167
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
168 // If we don't have an index register we can use a displacement, otherwise load the
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
169 // displacement into a register and add it to the base.
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
170 if (indexRegister.equals(Value.ILLEGAL)) {
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
171 displacementInt = (int) finalDisp;
15345
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15301
diff changeset
172 assert SPARCAssembler.isSimm13(displacementInt) : displacementInt;
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
173 } else {
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
174 displacementInt = 0;
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
175 if (baseRegister.equals(Value.ILLEGAL)) {
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
176 baseRegister = load(Constant.forLong(finalDisp));
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
177 } else {
15345
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15301
diff changeset
178 if (finalDisp == 0) {
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15301
diff changeset
179 // Nothing to do. Just use the base register.
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15301
diff changeset
180 } else {
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16092
diff changeset
181 Variable longBaseRegister = newVariable(LIRKind.derivedReference(Kind.Long));
15345
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15301
diff changeset
182 emitMove(longBaseRegister, baseRegister);
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15301
diff changeset
183 baseRegister = emitAdd(longBaseRegister, Constant.forLong(finalDisp));
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15301
diff changeset
184 }
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
185 }
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
186 }
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
187
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16092
diff changeset
188 LIRKind resultKind = getAddressKind(base, displacement, index);
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16092
diff changeset
189 return new SPARCAddressValue(resultKind, baseRegister, indexRegister, displacementInt);
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
190 }
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
191
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
192 protected SPARCAddressValue asAddressValue(Value address) {
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
193 if (address instanceof SPARCAddressValue) {
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
194 return (SPARCAddressValue) address;
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
195 } else {
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
196 return emitAddress(address, 0, Value.ILLEGAL, 0);
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
197 }
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
198 }
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
199
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
200 @Override
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
201 public Value emitAddress(StackSlot address) {
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16092
diff changeset
202 Variable result = newVariable(LIRKind.value(target().wordKind));
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
203 append(new StackLoadAddressOp(result, address));
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
204 return result;
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
205 }
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
206
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
207 @Override
14847
c132602c640e Apply LIRGenerator refactoring to SPARC backend.
Josef Eisl <josef.eisl@jku.at>
parents: 14820
diff changeset
208 public void emitReturn(Value input) {
14949
b65036798097 Remove visitReturn from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 14850
diff changeset
209 AllocatableValue operand = Value.ILLEGAL;
b65036798097 Remove visitReturn from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 14850
diff changeset
210 if (input != null) {
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16092
diff changeset
211 operand = resultOperandFor(input.getLIRKind());
14949
b65036798097 Remove visitReturn from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 14850
diff changeset
212 emitMove(operand, input);
b65036798097 Remove visitReturn from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 14850
diff changeset
213 }
b65036798097 Remove visitReturn from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 14850
diff changeset
214 append(new ReturnOp(operand));
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
215 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
216
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
217 @Override
8293
ae7e78091f03 Cleanup branching and jumps in LIRGenerator: JumpOp/BranchOp do not need a state. In emitBranch, emitNullCheckBranch, emitCompareBranch, emitOverflowCheckBranch and emitIntegerTestBranch both targets are always provided.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8292
diff changeset
218 public void emitJump(LabelRef label) {
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9825
diff changeset
219 append(new JumpOp(label));
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
220 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
221
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
222 @Override
14962
e4a5b8904695 Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14949
diff changeset
223 public void emitCompareBranch(PlatformKind cmpKind, Value left, Value right, Condition cond, boolean unorderedIsTrue, LabelRef trueDestination, LabelRef falseDestination,
e4a5b8904695 Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14949
diff changeset
224 double trueDestinationProbability) {
16664
62f295bdea36 [SPARC] Fixing compare of short/char with constants, using half of single float registers as of now, otherwise it would overlap with double registers
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16659
diff changeset
225 boolean mirrored = emitCompare(cmpKind, left, right);
10694
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
226 Condition finalCondition = mirrored ? cond.mirror() : cond;
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
227 Kind kind = left.getKind().getStackKind();
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
228 switch (kind) {
9831
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9829
diff changeset
229 case Int:
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9829
diff changeset
230 case Long:
10694
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
231 case Object:
13268
68b964b6dc8e introduced BlockEndOp interface and require that every LIR block is terminated by such an operation
Doug Simon <doug.simon@oracle.com>
parents: 12695
diff changeset
232 append(new BranchOp(finalCondition, trueDestination, falseDestination, kind));
9831
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9829
diff changeset
233 break;
16524
a08a58d0736b [SPARC] Emit compareAndSwap for AtomicInteger and AtomicLong, Removing o7 register from usable ones, as this register is always overwritten, when using Call or JumpAndLink instructions in SPARC, even callee does not overwrite explicitly, implicit exception is defined when doing integer division, parameter constraint narrowed to only register on Unary2Op, Fix SPARCTestOp, as it did a compare instead of an and with condition codes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16520
diff changeset
234 case Float:
16520
9a07bf8467a6 [SPARC] Implement floatingpoint branch instructions, removing math substitutions for SPARC; fixing problems with constants in debug info (Big/Little Endian problems)
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16519
diff changeset
235 case Double:
16926
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
236 append(new BranchOp(finalCondition, trueDestination, falseDestination, kind));
16520
9a07bf8467a6 [SPARC] Implement floatingpoint branch instructions, removing math substitutions for SPARC; fixing problems with constants in debug info (Big/Little Endian problems)
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16519
diff changeset
237 break;
9825
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9817
diff changeset
238 default:
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9817
diff changeset
239 throw GraalInternalError.shouldNotReachHere("" + left.getKind());
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9817
diff changeset
240 }
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
241 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
242
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
243 @Override
13908
8f3cd93813f1 Use branch probability for emitting conditional jump.
Roland Schatz <roland.schatz@oracle.com>
parents: 13907
diff changeset
244 public void emitOverflowCheckBranch(LabelRef overflow, LabelRef noOverflow, double overflowProbability) {
16926
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
245 append(new BranchOp(ConditionFlag.CarrySet, overflow, noOverflow, Kind.Long));
9845
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9843
diff changeset
246 // append(new BranchOp(negated ? ConditionFlag.NoOverflow : ConditionFlag.Overflow, label));
16926
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
247 // throw GraalInternalError.unimplemented();
8210
c64ecb1ef1a9 Create LIRGenerator.emitOverflowCheckBranch in preparation for emitDeoptimizeOnOverflow removal
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8127
diff changeset
248 }
c64ecb1ef1a9 Create LIRGenerator.emitOverflowCheckBranch in preparation for emitDeoptimizeOnOverflow removal
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8127
diff changeset
249
c64ecb1ef1a9 Create LIRGenerator.emitOverflowCheckBranch in preparation for emitDeoptimizeOnOverflow removal
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8127
diff changeset
250 @Override
13908
8f3cd93813f1 Use branch probability for emitting conditional jump.
Roland Schatz <roland.schatz@oracle.com>
parents: 13907
diff changeset
251 public void emitIntegerTestBranch(Value left, Value right, LabelRef trueDestination, LabelRef falseDestination, double trueDestinationProbability) {
9845
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9843
diff changeset
252 emitIntegerTest(left, right);
13907
6fc05ad86490 Remove unused 'negated' arguments.
Roland Schatz <roland.schatz@oracle.com>
parents: 13641
diff changeset
253 append(new BranchOp(Condition.EQ, trueDestination, falseDestination, left.getKind().getStackKind()));
9845
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9843
diff changeset
254 }
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9843
diff changeset
255
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9843
diff changeset
256 private void emitIntegerTest(Value a, Value b) {
12695
4aec62c32a82 Helper functions for identifying numeric kinds.
Roland Schatz <roland.schatz@oracle.com>
parents: 12656
diff changeset
257 assert a.getKind().isNumericInteger();
9845
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9843
diff changeset
258 if (LIRValueUtil.isVariable(b)) {
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9843
diff changeset
259 append(new SPARCTestOp(load(b), loadNonConst(a)));
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9843
diff changeset
260 } else {
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9843
diff changeset
261 append(new SPARCTestOp(load(a), loadNonConst(b)));
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9843
diff changeset
262 }
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9843
diff changeset
263 }
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9843
diff changeset
264
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9843
diff changeset
265 @Override
14962
e4a5b8904695 Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14949
diff changeset
266 public Variable emitConditionalMove(PlatformKind cmpKind, Value left, Value right, Condition cond, boolean unorderedIsTrue, Value trueValue, Value falseValue) {
16664
62f295bdea36 [SPARC] Fixing compare of short/char with constants, using half of single float registers as of now, otherwise it would overlap with double registers
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16659
diff changeset
267 boolean mirrored = emitCompare(cmpKind, left, right);
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
268 Condition finalCondition = mirrored ? cond.mirror() : cond;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
269
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16092
diff changeset
270 Variable result = newVariable(trueValue.getLIRKind());
15345
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15301
diff changeset
271 Kind kind = left.getKind().getStackKind();
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15301
diff changeset
272 switch (kind) {
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
273 case Int:
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
274 case Long:
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
275 case Object:
15345
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15301
diff changeset
276 append(new CondMoveOp(kind, result, finalCondition, load(trueValue), loadNonConst(falseValue)));
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
277 break;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
278 case Float:
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
279 case Double:
15345
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15301
diff changeset
280 append(new FloatCondMoveOp(kind, result, finalCondition, unorderedIsTrue, load(trueValue), load(falseValue)));
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
281 break;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
282 default:
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
283 throw GraalInternalError.shouldNotReachHere("" + left.getKind());
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
284 }
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
285 return result;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
286 }
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
287
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
288 /**
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
289 * This method emits the compare instruction, and may reorder the operands. It returns true if
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
290 * it did so.
14949
b65036798097 Remove visitReturn from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 14850
diff changeset
291 *
16664
62f295bdea36 [SPARC] Fixing compare of short/char with constants, using half of single float registers as of now, otherwise it would overlap with double registers
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16659
diff changeset
292 * @param cmpKind Kind how a and b have to be compared
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
293 * @param a the left operand of the comparison
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
294 * @param b the right operand of the comparison
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
295 * @return true if the left and right operands were switched, false otherwise
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
296 */
16664
62f295bdea36 [SPARC] Fixing compare of short/char with constants, using half of single float registers as of now, otherwise it would overlap with double registers
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16659
diff changeset
297 protected boolean emitCompare(PlatformKind cmpKind, Value a, Value b) {
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
298 Variable left;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
299 Value right;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
300 boolean mirrored;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
301 if (LIRValueUtil.isVariable(b)) {
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
302 left = load(b);
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
303 right = loadNonConst(a);
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
304 mirrored = true;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
305 } else {
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
306 left = load(a);
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
307 right = loadNonConst(b);
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
308 mirrored = false;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
309 }
16664
62f295bdea36 [SPARC] Fixing compare of short/char with constants, using half of single float registers as of now, otherwise it would overlap with double registers
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16659
diff changeset
310 switch ((Kind) cmpKind) {
62f295bdea36 [SPARC] Fixing compare of short/char with constants, using half of single float registers as of now, otherwise it would overlap with double registers
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16659
diff changeset
311 case Short:
62f295bdea36 [SPARC] Fixing compare of short/char with constants, using half of single float registers as of now, otherwise it would overlap with double registers
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16659
diff changeset
312 case Char:
62f295bdea36 [SPARC] Fixing compare of short/char with constants, using half of single float registers as of now, otherwise it would overlap with double registers
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16659
diff changeset
313 append(new CompareOp(ICMP, emitZeroExtend(left, 16, 32), emitZeroExtend(right, 16, 32)));
62f295bdea36 [SPARC] Fixing compare of short/char with constants, using half of single float registers as of now, otherwise it would overlap with double registers
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16659
diff changeset
314 break;
62f295bdea36 [SPARC] Fixing compare of short/char with constants, using half of single float registers as of now, otherwise it would overlap with double registers
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16659
diff changeset
315 case Byte:
62f295bdea36 [SPARC] Fixing compare of short/char with constants, using half of single float registers as of now, otherwise it would overlap with double registers
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16659
diff changeset
316 append(new CompareOp(ICMP, emitZeroExtend(left, 8, 32), emitZeroExtend(right, 8, 32)));
62f295bdea36 [SPARC] Fixing compare of short/char with constants, using half of single float registers as of now, otherwise it would overlap with double registers
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16659
diff changeset
317 break;
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
318 case Int:
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
319 append(new CompareOp(ICMP, left, right));
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
320 break;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
321 case Long:
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
322 append(new CompareOp(LCMP, left, right));
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
323 break;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
324 case Object:
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
325 append(new CompareOp(ACMP, left, right));
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
326 break;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
327 case Float:
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
328 append(new CompareOp(FCMP, left, right));
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
329 break;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
330 case Double:
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
331 append(new CompareOp(DCMP, left, right));
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
332 break;
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
333 default:
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
334 throw GraalInternalError.shouldNotReachHere();
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
335 }
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
336 return mirrored;
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
337 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
338
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
339 @Override
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
340 public Variable emitIntegerTestMove(Value left, Value right, Value trueValue, Value falseValue) {
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
341 emitIntegerTest(left, right);
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16092
diff changeset
342 Variable result = newVariable(trueValue.getLIRKind());
15345
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15301
diff changeset
343 Kind kind = left.getKind().getStackKind();
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15301
diff changeset
344 append(new CondMoveOp(kind, result, Condition.EQ, load(trueValue), loadNonConst(falseValue)));
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
345 return result;
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
346 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
347
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
348 @Override
9739
4cd4926ec683 rename: RuntimeCallTarget -> ForeignCallLinkage
Doug Simon <doug.simon@oracle.com>
parents: 9613
diff changeset
349 protected void emitForeignCall(ForeignCallLinkage linkage, Value result, Value[] arguments, Value[] temps, LIRFrameState info) {
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
350 long maxOffset = linkage.getMaxCallTargetOffset();
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
351 if (SPARCAssembler.isWordDisp30(maxOffset)) {
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
352 append(new SPARCCall.DirectNearForeignCallOp(linkage, result, arguments, temps, info));
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
353 } else {
10871
c3b09d69dfde SPARC: fixes and more implementation; can now allocate objects
twisti
parents: 10854
diff changeset
354 append(new SPARCCall.DirectFarForeignCallOp(linkage, result, arguments, temps, info));
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10850
diff changeset
355 }
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
356 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
357
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
358 @Override
15297
3a6151ed5a25 Move LIRGenerator to graal.lir (errors).
Josef Eisl <josef.eisl@jku.at>
parents: 15294
diff changeset
359 public void emitStrategySwitch(SwitchStrategy strategy, Variable key, LabelRef[] keyTargets, LabelRef defaultTarget) {
16932
4d77f938aa02 [SPARC] Exclude AMD64 tests from SPARC testrun, always use tmp register when using StrategySwitch, using registerSaver in EnterUnpackStackFrame, LeaveCurrentStackframe, adding guarantee to load offsets when doing load reg+imm13 when the imm value does not fit in 13 bit, assertions for scratch register usage (tmp/def)
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16926
diff changeset
360 append(new StrategySwitchOp(strategy, keyTargets, defaultTarget, key, newVariable(key.getLIRKind())));
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
361 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
362
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
363 @Override
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
364 protected void emitTableSwitch(int lowKey, LabelRef defaultTarget, LabelRef[] targets, Value key) {
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9825
diff changeset
365 // Making a copy of the switch value is necessary because jump table destroys the input
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9825
diff changeset
366 // value
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents: 9825
diff changeset
367 Variable tmp = emitMove(key);
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16092
diff changeset
368 append(new TableSwitchOp(lowKey, defaultTarget, targets, tmp, newVariable(LIRKind.value(target().wordKind))));
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
369 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
370
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
371 @Override
16092
51ba6c521922 Refactor LIRGeneratorTool methods.
Roland Schatz <roland.schatz@oracle.com>
parents: 15947
diff changeset
372 public Value emitBitCount(Value operand) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
373 Variable result = newVariable(LIRKind.derive(operand).changeType(Kind.Int));
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
374 if (operand.getKind().getStackKind() == Kind.Int) {
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
375 append(new SPARCBitManipulationOp(IPOPCNT, result, asAllocatable(operand), this));
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
376 } else {
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
377 append(new SPARCBitManipulationOp(LPOPCNT, result, asAllocatable(operand), this));
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
378 }
16092
51ba6c521922 Refactor LIRGeneratorTool methods.
Roland Schatz <roland.schatz@oracle.com>
parents: 15947
diff changeset
379 return result;
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
380 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
381
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
382 @Override
16092
51ba6c521922 Refactor LIRGeneratorTool methods.
Roland Schatz <roland.schatz@oracle.com>
parents: 15947
diff changeset
383 public Value emitBitScanForward(Value operand) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
384 Variable result = newVariable(LIRKind.derive(operand).changeType(Kind.Int));
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
385 append(new SPARCBitManipulationOp(BSF, result, asAllocatable(operand), this));
16092
51ba6c521922 Refactor LIRGeneratorTool methods.
Roland Schatz <roland.schatz@oracle.com>
parents: 15947
diff changeset
386 return result;
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
387 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
388
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
389 @Override
16092
51ba6c521922 Refactor LIRGeneratorTool methods.
Roland Schatz <roland.schatz@oracle.com>
parents: 15947
diff changeset
390 public Value emitBitScanReverse(Value operand) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
391 Variable result = newVariable(LIRKind.derive(operand).changeType(Kind.Int));
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
392 if (operand.getKind().getStackKind() == Kind.Int) {
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
393 append(new SPARCBitManipulationOp(IBSR, result, asAllocatable(operand), this));
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
394 } else {
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
395 append(new SPARCBitManipulationOp(LBSR, result, asAllocatable(operand), this));
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
396 }
16092
51ba6c521922 Refactor LIRGeneratorTool methods.
Roland Schatz <roland.schatz@oracle.com>
parents: 15947
diff changeset
397 return result;
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
398 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
399
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
400 @Override
11290
686d6d99352c Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 11289
diff changeset
401 public Value emitMathAbs(Value input) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
402 Variable result = newVariable(LIRKind.derive(input));
16518
3eb13b910134 [SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16429
diff changeset
403 append(new BinaryRegConst(DAND, result, asAllocatable(input), Constant.forDouble(Double.longBitsToDouble(0x7FFFFFFFFFFFFFFFL)), null));
11290
686d6d99352c Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 11289
diff changeset
404 return result;
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
405 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
406
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
407 @Override
11290
686d6d99352c Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 11289
diff changeset
408 public Value emitMathSqrt(Value input) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
409 Variable result = newVariable(LIRKind.derive(input));
11290
686d6d99352c Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 11289
diff changeset
410 append(new SPARCMathIntrinsicOp(SQRT, result, asAllocatable(input)));
686d6d99352c Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 11289
diff changeset
411 return result;
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
412 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
413
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
414 @Override
11290
686d6d99352c Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 11289
diff changeset
415 public Value emitMathLog(Value input, boolean base10) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
416 Variable result = newVariable(LIRKind.derive(input));
11290
686d6d99352c Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 11289
diff changeset
417 append(new SPARCMathIntrinsicOp(LOG, result, asAllocatable(input)));
686d6d99352c Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 11289
diff changeset
418 return result;
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
419 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
420
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
421 @Override
11290
686d6d99352c Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 11289
diff changeset
422 public Value emitMathCos(Value input) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
423 Variable result = newVariable(LIRKind.derive(input));
11290
686d6d99352c Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 11289
diff changeset
424 append(new SPARCMathIntrinsicOp(COS, result, asAllocatable(input)));
686d6d99352c Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 11289
diff changeset
425 return result;
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
426 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
427
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
428 @Override
11290
686d6d99352c Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 11289
diff changeset
429 public Value emitMathSin(Value input) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
430 Variable result = newVariable(LIRKind.derive(input));
11290
686d6d99352c Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 11289
diff changeset
431 append(new SPARCMathIntrinsicOp(SIN, result, asAllocatable(input)));
686d6d99352c Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 11289
diff changeset
432 return result;
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
433 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
434
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
435 @Override
11290
686d6d99352c Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 11289
diff changeset
436 public Value emitMathTan(Value input) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
437 Variable result = newVariable(LIRKind.derive(input));
11290
686d6d99352c Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 11289
diff changeset
438 append(new SPARCMathIntrinsicOp(TAN, result, asAllocatable(input)));
686d6d99352c Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 11289
diff changeset
439 return result;
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
440 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
441
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
442 @Override
16092
51ba6c521922 Refactor LIRGeneratorTool methods.
Roland Schatz <roland.schatz@oracle.com>
parents: 15947
diff changeset
443 public Value emitByteSwap(Value input) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
444 Variable result = newVariable(LIRKind.derive(input));
16518
3eb13b910134 [SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16429
diff changeset
445 append(new SPARCByteSwapOp(this, result, input));
16092
51ba6c521922 Refactor LIRGeneratorTool methods.
Roland Schatz <roland.schatz@oracle.com>
parents: 15947
diff changeset
446 return result;
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
447 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
448
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
449 @Override
16092
51ba6c521922 Refactor LIRGeneratorTool methods.
Roland Schatz <roland.schatz@oracle.com>
parents: 15947
diff changeset
450 public Value emitArrayEquals(Kind kind, Value array1, Value array2, Value length) {
13541
63bb635911ab String.equals method substitution
twisti
parents: 13520
diff changeset
451 // TODO Auto-generated method stub
63bb635911ab String.equals method substitution
twisti
parents: 13520
diff changeset
452 throw GraalInternalError.unimplemented();
63bb635911ab String.equals method substitution
twisti
parents: 13520
diff changeset
453 }
63bb635911ab String.equals method substitution
twisti
parents: 13520
diff changeset
454
63bb635911ab String.equals method substitution
twisti
parents: 13520
diff changeset
455 @Override
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
456 public Value emitNegate(Value input) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
457 Variable result = newVariable(LIRKind.derive(input));
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
458 switch (input.getKind().getStackKind()) {
16319
a4bd33d52985 Fixing tests with number conversions, float and double handling. Introducing new VIS3 instructions. Adding testcases.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16315
diff changeset
459 case Long:
16926
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
460 append(new Unary2Op(LNEG, result, load(input)));
16319
a4bd33d52985 Fixing tests with number conversions, float and double handling. Introducing new VIS3 instructions. Adding testcases.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16315
diff changeset
461 break;
9825
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9817
diff changeset
462 case Int:
16926
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
463 append(new Unary2Op(INEG, result, load(input)));
9825
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9817
diff changeset
464 break;
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9817
diff changeset
465 case Float:
16926
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
466 append(new Unary2Op(FNEG, result, load(input)));
9825
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9817
diff changeset
467 break;
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9817
diff changeset
468 case Double:
16926
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
469 append(new Unary2Op(DNEG, result, load(input)));
9825
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9817
diff changeset
470 break;
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9817
diff changeset
471 default:
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9817
diff changeset
472 throw GraalInternalError.shouldNotReachHere();
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9817
diff changeset
473 }
81d5d8089cda SPARC float arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9817
diff changeset
474 return result;
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
475 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
476
11355
01269a181628 add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 11290
diff changeset
477 @Override
01269a181628 add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 11290
diff changeset
478 public Value emitNot(Value input) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
479 Variable result = newVariable(LIRKind.derive(input));
11355
01269a181628 add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 11290
diff changeset
480 switch (input.getKind().getStackKind()) {
01269a181628 add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 11290
diff changeset
481 case Int:
16926
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
482 append(new Unary2Op(INOT, result, load(input)));
11355
01269a181628 add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 11290
diff changeset
483 break;
01269a181628 add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 11290
diff changeset
484 case Long:
16926
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
485 append(new Unary2Op(LNOT, result, load(input)));
11355
01269a181628 add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 11290
diff changeset
486 break;
01269a181628 add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 11290
diff changeset
487 default:
01269a181628 add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 11290
diff changeset
488 throw GraalInternalError.shouldNotReachHere();
01269a181628 add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 11290
diff changeset
489 }
01269a181628 add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 11290
diff changeset
490 return result;
01269a181628 add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 11290
diff changeset
491 }
01269a181628 add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 11290
diff changeset
492
16518
3eb13b910134 [SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16429
diff changeset
493 private Variable emitBinary(SPARCArithmetic op, boolean commutative, Value a, Value b, LIRFrameState state) {
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
494 if (isConstant(b)) {
16518
3eb13b910134 [SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16429
diff changeset
495 return emitBinaryConst(op, commutative, asAllocatable(a), asConstant(b), state);
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
496 } else if (commutative && isConstant(a)) {
16518
3eb13b910134 [SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16429
diff changeset
497 return emitBinaryConst(op, commutative, asAllocatable(b), asConstant(a), state);
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
498 } else {
16518
3eb13b910134 [SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16429
diff changeset
499 return emitBinaryVar(op, commutative, asAllocatable(a), asAllocatable(b), state);
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
500 }
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
501 }
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
502
16518
3eb13b910134 [SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16429
diff changeset
503 private Variable emitBinaryConst(SPARCArithmetic op, boolean commutative, AllocatableValue a, Constant b, LIRFrameState state) {
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
504 switch (op) {
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
505 case IADD:
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
506 case LADD:
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
507 case ISUB:
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
508 case LSUB:
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
509 case IAND:
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
510 case LAND:
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
511 case IOR:
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
512 case LOR:
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
513 case IXOR:
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
514 case LXOR:
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
515 case IMUL:
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
516 case LMUL:
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
517 if (NumUtil.isInt(b.asLong())) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
518 Variable result = newVariable(LIRKind.derive(a, b));
16518
3eb13b910134 [SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16429
diff changeset
519 append(new BinaryRegConst(op, result, a, b, state));
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
520 return result;
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
521 }
9814
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9739
diff changeset
522 break;
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
523 }
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
524
16518
3eb13b910134 [SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16429
diff changeset
525 return emitBinaryVar(op, commutative, a, asAllocatable(b), state);
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
526 }
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
527
16518
3eb13b910134 [SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16429
diff changeset
528 private Variable emitBinaryVar(SPARCArithmetic op, boolean commutative, AllocatableValue a, AllocatableValue b, LIRFrameState state) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
529 Variable result = newVariable(LIRKind.derive(a, b));
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
530 if (commutative) {
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
531 append(new BinaryCommutative(op, result, a, b));
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
532 } else {
16519
2b91702c4e69 [SPARC] Fixing IntegerBits
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16518
diff changeset
533 append(new BinaryRegReg(op, result, a, b, state));
9814
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9739
diff changeset
534 }
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9739
diff changeset
535 return result;
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
536 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
537
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
538 @Override
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
539 public Variable emitAdd(Value a, Value b) {
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
540 switch (a.getKind().getStackKind()) {
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
541 case Int:
16518
3eb13b910134 [SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16429
diff changeset
542 return emitBinary(IADD, true, a, b, null);
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
543 case Long:
16518
3eb13b910134 [SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16429
diff changeset
544 return emitBinary(LADD, true, a, b, null);
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
545 case Float:
16518
3eb13b910134 [SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16429
diff changeset
546 return emitBinary(FADD, true, a, b, null);
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
547 case Double:
16518
3eb13b910134 [SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16429
diff changeset
548 return emitBinary(DADD, true, a, b, null);
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
549 default:
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
550 throw GraalInternalError.shouldNotReachHere();
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
551 }
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
552 }
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
553
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
554 @Override
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
555 public Variable emitSub(Value a, Value b) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
556 Variable result = newVariable(LIRKind.derive(a, b));
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
557 switch (a.getKind().getStackKind()) {
9817
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
558 case Int:
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
559 append(new Op2Stack(ISUB, result, a, loadNonConst(b)));
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
560 break;
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
561 case Long:
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
562 append(new Op2Stack(LSUB, result, a, loadNonConst(b)));
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
563 break;
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
564 case Float:
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
565 append(new Op2Stack(FSUB, result, a, loadNonConst(b)));
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
566 break;
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
567 case Double:
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
568 append(new Op2Stack(DSUB, result, a, loadNonConst(b)));
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
569 break;
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
570 default:
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
571 throw GraalInternalError.shouldNotReachHere("missing: " + a.getKind());
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
572 }
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
573 return result;
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
574 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
575
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
576 @Override
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
577 public Variable emitMul(Value a, Value b) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
578 Variable result = newVariable(LIRKind.derive(a, b));
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
579 switch (a.getKind().getStackKind()) {
9817
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
580 case Int:
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
581 append(new BinaryRegReg(IMUL, result, a, loadNonConst(b)));
9817
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
582 break;
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
583 case Long:
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
584 append(new BinaryRegReg(LMUL, result, a, loadNonConst(b)));
9817
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
585 break;
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
586 case Float:
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
587 append(new Op2Stack(FMUL, result, a, loadNonConst(b)));
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
588 break;
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
589 case Double:
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
590 append(new Op2Stack(DMUL, result, a, loadNonConst(b)));
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
591 break;
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
592 default:
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
593 throw GraalInternalError.shouldNotReachHere("missing: " + a.getKind());
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
594 }
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
595 return result;
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
596 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
597
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
598 @Override
15691
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15345
diff changeset
599 public Value emitMulHigh(Value a, Value b) {
16926
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
600 switch (a.getKind().getStackKind()) {
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
601 case Int:
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
602 return emitMulHigh(IMUL, a, b);
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
603 case Long:
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
604 return emitMulHigh(LMUL, a, b);
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
605 default:
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
606 throw GraalInternalError.shouldNotReachHere();
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
607 }
15691
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15345
diff changeset
608 }
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15345
diff changeset
609
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15345
diff changeset
610 @Override
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15345
diff changeset
611 public Value emitUMulHigh(Value a, Value b) {
16926
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
612 switch (a.getKind().getStackKind()) {
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
613 case Int:
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
614 return emitMulHigh(IUMUL, a, b);
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
615 case Long:
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
616 return emitMulHigh(LUMUL, a, b);
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
617 default:
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
618 throw GraalInternalError.shouldNotReachHere();
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
619 }
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
620 }
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
621
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
622 private Value emitMulHigh(SPARCArithmetic opcode, Value a, Value b) {
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
623 Variable result = newVariable(LIRKind.derive(a, b));
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
624 MulHighOp mulHigh = new MulHighOp(opcode, load(a), load(b), result, newVariable(LIRKind.derive(a, b)));
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
625 append(mulHigh);
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
626 return result;
15691
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15345
diff changeset
627 }
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15345
diff changeset
628
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15345
diff changeset
629 @Override
15301
468b2428c403 Change DeoptimizingNode and Access to LIRFrameState in *LIRGenerator*.
Josef Eisl <josef.eisl@jku.at>
parents: 15297
diff changeset
630 public Value emitDiv(Value a, Value b, LIRFrameState state) {
16518
3eb13b910134 [SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16429
diff changeset
631 SPARCArithmetic op = null;
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
632 switch (a.getKind().getStackKind()) {
9817
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
633 case Int:
16518
3eb13b910134 [SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16429
diff changeset
634 op = IDIV;
9817
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
635 break;
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
636 case Long:
16518
3eb13b910134 [SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16429
diff changeset
637 op = LDIV;
9817
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
638 break;
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
639 case Float:
16518
3eb13b910134 [SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16429
diff changeset
640 op = FDIV;
9817
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
641 break;
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
642 case Double:
16518
3eb13b910134 [SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16429
diff changeset
643 op = DDIV;
9817
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
644 break;
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
645 default:
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
646 throw GraalInternalError.shouldNotReachHere("missing: " + a.getKind());
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
647 }
16518
3eb13b910134 [SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16429
diff changeset
648 return emitBinary(op, false, a, b, state);
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
649 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
650
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
651 @Override
15301
468b2428c403 Change DeoptimizingNode and Access to LIRFrameState in *LIRGenerator*.
Josef Eisl <josef.eisl@jku.at>
parents: 15297
diff changeset
652 public Value emitRem(Value a, Value b, LIRFrameState state) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
653 Variable result = newVariable(LIRKind.derive(a, b));
16321
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
654 Variable q = null;
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
655 switch (a.getKind().getStackKind()) {
9817
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
656 case Int:
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
657 append(new RemOp(IREM, result, a, loadNonConst(b), state, this));
9817
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
658 break;
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
659 case Long:
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
660 append(new RemOp(LREM, result, a, loadNonConst(b), state, this));
9817
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
661 break;
16321
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
662 case Float:
16327
5f01f7c48d40 Merge with 5cdcb94a7cf7d9782107cc582f3e4b50000d5d1f
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16326 16094
diff changeset
663 q = newVariable(LIRKind.value(Kind.Float));
16321
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
664 append(new Op2Stack(FDIV, q, a, b));
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
665 append(new Unary2Op(F2I, q, q));
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
666 append(new Unary2Op(I2F, q, q));
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
667 append(new Op2Stack(FMUL, q, q, b));
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
668 append(new Op2Stack(FSUB, result, a, q));
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
669 break;
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
670 case Double:
16327
5f01f7c48d40 Merge with 5cdcb94a7cf7d9782107cc582f3e4b50000d5d1f
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16326 16094
diff changeset
671 q = newVariable(LIRKind.value(Kind.Double));
16321
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
672 append(new Op2Stack(DDIV, q, a, b));
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
673 append(new Unary2Op(D2L, q, q));
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
674 append(new Unary2Op(L2D, q, q));
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
675 append(new Op2Stack(DMUL, q, q, b));
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
676 append(new Op2Stack(DSUB, result, a, q));
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
677 break;
9817
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
678 default:
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
679 throw GraalInternalError.shouldNotReachHere("missing: " + a.getKind());
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
680 }
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
681 return result;
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
682 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
683
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
684 @Override
16659
b377d9e85bc6 [SPARC] Fist implementation of unsigned arithmethic (Still to improve)
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16524
diff changeset
685 public Value emitURem(Value a, Value b, LIRFrameState state) {
b377d9e85bc6 [SPARC] Fist implementation of unsigned arithmethic (Still to improve)
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16524
diff changeset
686 Variable result = newVariable(LIRKind.derive(a, b));
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
687 switch (a.getKind().getStackKind()) {
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
688 case Int:
16926
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
689 append(new RemOp(IUREM, result, load(a), load(b), state, this));
16659
b377d9e85bc6 [SPARC] Fist implementation of unsigned arithmethic (Still to improve)
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16524
diff changeset
690 break;
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
691 case Long:
16926
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
692 append(new RemOp(LUREM, result, load(a), loadNonConst(b), state, this));
16659
b377d9e85bc6 [SPARC] Fist implementation of unsigned arithmethic (Still to improve)
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16524
diff changeset
693 break;
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
694 default:
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
695 throw GraalInternalError.shouldNotReachHere();
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
696 }
16659
b377d9e85bc6 [SPARC] Fist implementation of unsigned arithmethic (Still to improve)
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16524
diff changeset
697 return result;
b377d9e85bc6 [SPARC] Fist implementation of unsigned arithmethic (Still to improve)
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16524
diff changeset
698
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
699 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
700
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
701 @Override
16659
b377d9e85bc6 [SPARC] Fist implementation of unsigned arithmethic (Still to improve)
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16524
diff changeset
702 public Value emitUDiv(Value a, Value b, LIRFrameState state) {
b377d9e85bc6 [SPARC] Fist implementation of unsigned arithmethic (Still to improve)
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16524
diff changeset
703 SPARCArithmetic op;
16926
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
704 Value actualA = a;
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
705 Value actualB = b;
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
706 switch (a.getKind().getStackKind()) {
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
707 case Int:
16659
b377d9e85bc6 [SPARC] Fist implementation of unsigned arithmethic (Still to improve)
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16524
diff changeset
708 op = IUDIV;
16926
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
709 actualA = emitZeroExtend(actualA, 32, 64);
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
710 actualB = emitZeroExtend(actualB, 32, 64);
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
711 case Long:
16659
b377d9e85bc6 [SPARC] Fist implementation of unsigned arithmethic (Still to improve)
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16524
diff changeset
712 op = LUDIV;
b377d9e85bc6 [SPARC] Fist implementation of unsigned arithmethic (Still to improve)
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16524
diff changeset
713 break;
9846
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
714 default:
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
715 throw GraalInternalError.shouldNotReachHere();
91a1041ec905 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops
Morris Meyer <morris.meyer@oracle.com>
parents: 9845
diff changeset
716 }
16926
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
717 return emitBinary(op, false, actualA, actualB, state);
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
718 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
719
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
720 @Override
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
721 public Variable emitAnd(Value a, Value b) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
722 Variable result = newVariable(LIRKind.derive(a, b));
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
723 switch (a.getKind().getStackKind()) {
9829
04911dff1c66 SPARC logic and shift operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
724 case Int:
04911dff1c66 SPARC logic and shift operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
725 append(new Op2Stack(IAND, result, a, loadNonConst(b)));
04911dff1c66 SPARC logic and shift operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
726 break;
04911dff1c66 SPARC logic and shift operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
727 case Long:
04911dff1c66 SPARC logic and shift operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
728 append(new Op2Stack(LAND, result, a, loadNonConst(b)));
04911dff1c66 SPARC logic and shift operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
729 break;
04911dff1c66 SPARC logic and shift operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
730
04911dff1c66 SPARC logic and shift operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
731 default:
04911dff1c66 SPARC logic and shift operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
732 throw GraalInternalError.shouldNotReachHere("missing: " + a.getKind());
04911dff1c66 SPARC logic and shift operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
733 }
04911dff1c66 SPARC logic and shift operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
734 return result;
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
735 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
736
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
737 @Override
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
738 public Variable emitOr(Value a, Value b) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
739 Variable result = newVariable(LIRKind.derive(a, b));
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
740 switch (a.getKind().getStackKind()) {
9829
04911dff1c66 SPARC logic and shift operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
741 case Int:
04911dff1c66 SPARC logic and shift operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
742 append(new Op2Stack(IOR, result, a, loadNonConst(b)));
04911dff1c66 SPARC logic and shift operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
743 break;
04911dff1c66 SPARC logic and shift operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
744 case Long:
04911dff1c66 SPARC logic and shift operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
745 append(new Op2Stack(LOR, result, a, loadNonConst(b)));
04911dff1c66 SPARC logic and shift operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
746 break;
04911dff1c66 SPARC logic and shift operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
747 default:
04911dff1c66 SPARC logic and shift operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
748 throw GraalInternalError.shouldNotReachHere("missing: " + a.getKind());
04911dff1c66 SPARC logic and shift operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
749 }
04911dff1c66 SPARC logic and shift operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
750 return result;
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
751 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
752
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
753 @Override
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
754 public Variable emitXor(Value a, Value b) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
755 Variable result = newVariable(LIRKind.derive(a, b));
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
756 switch (a.getKind().getStackKind()) {
9829
04911dff1c66 SPARC logic and shift operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
757 case Int:
04911dff1c66 SPARC logic and shift operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
758 append(new Op2Stack(IXOR, result, a, loadNonConst(b)));
04911dff1c66 SPARC logic and shift operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
759 break;
04911dff1c66 SPARC logic and shift operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
760 case Long:
04911dff1c66 SPARC logic and shift operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
761 append(new Op2Stack(LXOR, result, a, loadNonConst(b)));
04911dff1c66 SPARC logic and shift operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
762 break;
04911dff1c66 SPARC logic and shift operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
763 default:
04911dff1c66 SPARC logic and shift operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
764 throw GraalInternalError.shouldNotReachHere();
04911dff1c66 SPARC logic and shift operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
765 }
04911dff1c66 SPARC logic and shift operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9828
diff changeset
766 return result;
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
767 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
768
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
769 private Variable emitShift(SPARCArithmetic op, Value a, Value b) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
770 Variable result = newVariable(LIRKind.derive(a, b).changeType(a.getPlatformKind()));
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
771 AllocatableValue input = asAllocatable(a);
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
772 if (isConstant(b)) {
16518
3eb13b910134 [SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16429
diff changeset
773 append(new BinaryRegConst(op, result, input, asConstant(b), null));
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
774 } else {
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
775 append(new BinaryRegReg(op, result, input, b));
9817
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
776 }
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
777 return result;
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
778 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
779
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
780 @Override
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
781 public Variable emitShl(Value a, Value b) {
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
782 switch (a.getKind().getStackKind()) {
9817
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
783 case Int:
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
784 return emitShift(ISHL, a, b);
9817
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
785 case Long:
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
786 return emitShift(LSHL, a, b);
9817
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
787 default:
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
788 throw GraalInternalError.shouldNotReachHere();
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
789 }
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
790 }
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
791
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
792 @Override
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
793 public Variable emitShr(Value a, Value b) {
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
794 switch (a.getKind().getStackKind()) {
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
795 case Int:
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
796 return emitShift(ISHR, a, b);
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
797 case Long:
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
798 return emitShift(LSHR, a, b);
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
799 default:
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
800 throw GraalInternalError.shouldNotReachHere();
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
801 }
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
802 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
803
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
804 @Override
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
805 public Variable emitUShr(Value a, Value b) {
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
806 switch (a.getKind().getStackKind()) {
9817
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
807 case Int:
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
808 return emitShift(IUSHR, a, b);
9817
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
809 case Long:
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10871
diff changeset
810 return emitShift(LUSHR, a, b);
9817
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
811 default:
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
812 throw GraalInternalError.shouldNotReachHere();
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
813 }
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
814 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
815
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16092
diff changeset
816 private AllocatableValue emitConvertMove(LIRKind kind, AllocatableValue input) {
12656
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
817 Variable result = newVariable(kind);
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
818 emitMove(result, input);
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
819 return result;
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
820 }
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
821
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16092
diff changeset
822 private AllocatableValue emitConvert2Op(LIRKind kind, SPARCArithmetic op, AllocatableValue input) {
12656
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
823 Variable result = newVariable(kind);
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
824 append(new Unary2Op(op, result, input));
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
825 return result;
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
826 }
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
827
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
828 @Override
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
829 public Value emitFloatConvert(FloatConvert op, Value inputVal) {
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
830 AllocatableValue input = asAllocatable(inputVal);
16321
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
831 Kind fromRegisterKind = null;
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
832 Kind toRegisterKind = null;
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
833 SPARCArithmetic conversionInstruction = null;
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
834 switch (op) {
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
835 case D2F:
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
836 return emitConvert2Op(LIRKind.derive(inputVal).changeType(Kind.Float), D2F, input);
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
837 case D2I:
16321
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
838 fromRegisterKind = Kind.Double;
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
839 toRegisterKind = Kind.Int;
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
840 conversionInstruction = D2I;
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
841 break;
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
842 case F2L:
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
843 Variable v = newVariable(LIRKind.derive(inputVal).changeType(Kind.Double));
16321
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
844 emitMove(v, input);
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
845 input = v;
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
846 case D2L:
16321
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
847 fromRegisterKind = Kind.Double;
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
848 toRegisterKind = Kind.Long;
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
849 conversionInstruction = D2L;
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
850 break;
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
851 case F2D:
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
852 return emitConvert2Op(LIRKind.derive(inputVal).changeType(Kind.Double), F2D, input);
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
853 case F2I:
16321
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
854 fromRegisterKind = Kind.Float;
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
855 toRegisterKind = Kind.Int;
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
856 conversionInstruction = F2I;
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
857 break;
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
858 case I2D:
16429
3943a1a46a53 [SPARC] Fixing i2d and l2f and handling of implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16346
diff changeset
859 // Implemented in two steps, as this consists of sign extension and then move the
3943a1a46a53 [SPARC] Fixing i2d and l2f and handling of implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16346
diff changeset
860 // bits over to the double register and then convert to double, in fact this does
3943a1a46a53 [SPARC] Fixing i2d and l2f and handling of implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16346
diff changeset
861 // not generate any overhead in generated code
3943a1a46a53 [SPARC] Fixing i2d and l2f and handling of implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16346
diff changeset
862 {
3943a1a46a53 [SPARC] Fixing i2d and l2f and handling of implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16346
diff changeset
863 AllocatableValue tmp = emitConvert2Op(LIRKind.derive(inputVal).changeType(Kind.Long), I2L, input);
3943a1a46a53 [SPARC] Fixing i2d and l2f and handling of implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16346
diff changeset
864 return emitConvert2Op(LIRKind.derive(inputVal).changeType(Kind.Double), L2D, tmp);
3943a1a46a53 [SPARC] Fixing i2d and l2f and handling of implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16346
diff changeset
865 }
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
866 case I2F:
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
867 return emitConvert2Op(LIRKind.derive(inputVal).changeType(Kind.Float), I2F, input);
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
868 case L2D:
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
869 return emitConvert2Op(LIRKind.derive(inputVal).changeType(Kind.Double), L2D, input);
16429
3943a1a46a53 [SPARC] Fixing i2d and l2f and handling of implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16346
diff changeset
870 case L2F: {
3943a1a46a53 [SPARC] Fixing i2d and l2f and handling of implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16346
diff changeset
871 AllocatableValue tmp = emitConvert2Op(LIRKind.derive(inputVal).changeType(Kind.Double), L2D, input);
3943a1a46a53 [SPARC] Fixing i2d and l2f and handling of implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16346
diff changeset
872 return emitConvert2Op(LIRKind.derive(inputVal).changeType(Kind.Float), D2F, tmp);
3943a1a46a53 [SPARC] Fixing i2d and l2f and handling of implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16346
diff changeset
873 }
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
874 default:
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
875 throw GraalInternalError.shouldNotReachHere();
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
876 }
16321
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
877 if (fromRegisterKind != null) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
878 AllocatableValue var = newVariable(LIRKind.derive(inputVal).changeType(toRegisterKind));
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
879 emitMove(var, emitConvert2Op(LIRKind.derive(inputVal).changeType(fromRegisterKind), conversionInstruction, input));
16321
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
880 return var;
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
881 } else {
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
882 throw GraalInternalError.shouldNotReachHere();
fac4af29aeb8 [SPARC] Fixing lots of float and double issues.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16319
diff changeset
883 }
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
884 }
12656
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
885
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
886 @Override
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
887 public Value emitNarrow(Value inputVal, int bits) {
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
888 if (inputVal.getKind() == Kind.Long && bits <= 32) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
889 return emitConvert2Op(LIRKind.derive(inputVal).changeType(Kind.Int), L2I, asAllocatable(inputVal));
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
890 } else {
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
891 return inputVal;
12656
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
892 }
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
893 }
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
894
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
895 @Override
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
896 public Value emitSignExtend(Value inputVal, int fromBits, int toBits) {
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
897 assert fromBits <= toBits && toBits <= 64;
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
898 if (fromBits == toBits) {
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
899 return inputVal;
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
900 } else if (toBits > 32) {
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
901 // sign extend to 64 bits
15345
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15301
diff changeset
902 switch (fromBits) {
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15301
diff changeset
903 case 8:
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
904 return emitConvert2Op(LIRKind.derive(inputVal).changeType(Kind.Long), B2L, asAllocatable(inputVal));
15345
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15301
diff changeset
905 case 16:
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
906 return emitConvert2Op(LIRKind.derive(inputVal).changeType(Kind.Long), S2L, asAllocatable(inputVal));
15345
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15301
diff changeset
907 case 32:
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
908 return emitConvert2Op(LIRKind.derive(inputVal).changeType(Kind.Long), I2L, asAllocatable(inputVal));
15345
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15301
diff changeset
909 default:
109d6c7c40b5 implement SPARC uncommon trap stub
twisti
parents: 15301
diff changeset
910 throw GraalInternalError.unimplemented("unsupported sign extension (" + fromBits + " bit -> " + toBits + " bit)");
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
911 }
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
912 } else {
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
913 // sign extend to 32 bits (smaller values are internally represented as 32 bit values)
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
914 switch (fromBits) {
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
915 case 8:
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
916 return emitConvert2Op(LIRKind.derive(inputVal).changeType(Kind.Int), B2I, asAllocatable(inputVal));
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
917 case 16:
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
918 return emitConvert2Op(LIRKind.derive(inputVal).changeType(Kind.Int), S2I, asAllocatable(inputVal));
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
919 case 32:
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
920 return inputVal;
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
921 default:
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
922 throw GraalInternalError.unimplemented("unsupported sign extension (" + fromBits + " bit -> " + toBits + " bit)");
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
923 }
12656
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
924 }
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
925 }
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
926
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
927 @Override
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
928 public Value emitZeroExtend(Value inputVal, int fromBits, int toBits) {
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
929 assert fromBits <= toBits && toBits <= 64;
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
930 if (fromBits == toBits) {
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
931 return inputVal;
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
932 } else if (fromBits > 32) {
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
933 assert inputVal.getKind() == Kind.Long;
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
934 Variable result = newVariable(LIRKind.derive(inputVal).changeType(Kind.Long));
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
935 long mask = IntegerStamp.defaultMask(fromBits);
16518
3eb13b910134 [SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16429
diff changeset
936 append(new BinaryRegConst(SPARCArithmetic.LAND, result, asAllocatable(inputVal), Constant.forLong(mask), null));
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
937 return result;
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
938 } else {
16932
4d77f938aa02 [SPARC] Exclude AMD64 tests from SPARC testrun, always use tmp register when using StrategySwitch, using registerSaver in EnterUnpackStackFrame, LeaveCurrentStackframe, adding guarantee to load offsets when doing load reg+imm13 when the imm value does not fit in 13 bit, assertions for scratch register usage (tmp/def)
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16926
diff changeset
939 assert inputVal.getKind() == Kind.Int || inputVal.getKind() == Kind.Short || inputVal.getKind() == Kind.Byte || inputVal.getKind() == Kind.Char : inputVal.getKind();
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
940 Variable result = newVariable(LIRKind.derive(inputVal).changeType(Kind.Int));
16664
62f295bdea36 [SPARC] Fixing compare of short/char with constants, using half of single float registers as of now, otherwise it would overlap with double registers
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16659
diff changeset
941 long mask = IntegerStamp.defaultMask(fromBits);
16926
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
942 Constant constant = Constant.forInt((int) mask);
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
943 if (fromBits == 32) {
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
944 append(new ShiftOp(IUSHR, result, inputVal, Constant.forInt(0)));
5c8a0b322d15 [SPARC] Implement unsigned arithmethic, fix CAS, unary operations on stack and various other fixes
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16664
diff changeset
945 } else if (canInlineConstant(constant)) {
16518
3eb13b910134 [SPARC] Fixing LongBits tests and some implicit exceptions
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16429
diff changeset
946 append(new BinaryRegConst(SPARCArithmetic.IAND, result, asAllocatable(inputVal), constant, null));
16315
b955d649fca8 Fixing BC_i2f, BC_i2c, BC_fadd
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16313
diff changeset
947 } else {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
948 Variable maskVar = newVariable(LIRKind.derive(inputVal).changeType(Kind.Int));
16315
b955d649fca8 Fixing BC_i2f, BC_i2c, BC_fadd
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16313
diff changeset
949 emitMove(maskVar, constant);
16664
62f295bdea36 [SPARC] Fixing compare of short/char with constants, using half of single float registers as of now, otherwise it would overlap with double registers
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16659
diff changeset
950 append(new BinaryRegReg(IAND, result, maskVar, asAllocatable(inputVal)));
16315
b955d649fca8 Fixing BC_i2f, BC_i2c, BC_fadd
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16313
diff changeset
951 }
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
952 if (toBits > 32) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16327
diff changeset
953 Variable longResult = newVariable(LIRKind.derive(inputVal).changeType(Kind.Long));
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
954 emitMove(longResult, result);
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
955 return longResult;
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
956 } else {
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
957 return result;
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
958 }
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13973
diff changeset
959 }
12656
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
960 }
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
961
14003
0c38906450a0 Make conversion from Stamp to PlatformKind extensible by backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14000
diff changeset
962 @Override
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16092
diff changeset
963 public AllocatableValue emitReinterpret(LIRKind to, Value inputVal) {
12656
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
964 Kind from = inputVal.getKind();
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
965 AllocatableValue input = asAllocatable(inputVal);
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
966
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
967 // These cases require a move between CPU and FPU registers:
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16092
diff changeset
968 switch ((Kind) to.getPlatformKind()) {
12656
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
969 case Int:
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
970 switch (from) {
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
971 case Float:
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
972 case Double:
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
973 return emitConvert2Op(to, MOV_F2I, input);
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
974 }
9817
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
975 break;
12656
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
976 case Long:
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
977 switch (from) {
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
978 case Float:
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
979 case Double:
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
980 return emitConvert2Op(to, MOV_D2L, input);
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
981 }
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
982 break;
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
983 case Float:
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
984 switch (from) {
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
985 case Int:
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
986 case Long:
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
987 return emitConvert2Op(to, MOV_I2F, input);
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
988 }
9817
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
989 break;
12656
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
990 case Double:
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
991 switch (from) {
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
992 case Int:
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
993 case Long:
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
994 return emitConvert2Op(to, MOV_L2D, input);
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
995 }
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
996 break;
9817
26960d32552c SPARC integer arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9816
diff changeset
997 }
12656
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
998
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
999 // Otherwise, just emit an ordinary move instruction.
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
1000 // Instructions that move or generate 32-bit register values also set the upper 32
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
1001 // bits of the register to zero.
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
1002 // Consequently, there is no need for a special zero-extension move.
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12503
diff changeset
1003 return emitConvertMove(to, input);
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
1004 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
1005
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
1006 @Override
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
1007 public void emitMembar(int barriers) {
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
1008 int necessaryBarriers = target().arch.requiredBarriers(barriers);
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
1009 if (target().isMP && necessaryBarriers != 0) {
9845
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9843
diff changeset
1010 append(new MembarOp(necessaryBarriers));
204e8f3209e9 SPARCMacroAssembler synthetic instructions and SPARCTestOp
Morris Meyer <morris.meyer@oracle.com>
parents: 9843
diff changeset
1011 }
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
1012 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
1013
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
1014 @Override
15301
468b2428c403 Change DeoptimizingNode and Access to LIRFrameState in *LIRGenerator*.
Josef Eisl <josef.eisl@jku.at>
parents: 15297
diff changeset
1015 public void emitDeoptimize(Value actionAndReason, Value speculation, LIRFrameState state) {
9831
705aca4ebf2f SPARC array, load / store and compare operations
Morris Meyer <morris.meyer@oracle.com>
parents: 9829
diff changeset
1016 append(new ReturnOp(Value.ILLEGAL));
7743
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
1017 }
7732a91e5f6d Added more skeleton code to SPARC projects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7740
diff changeset
1018
7740
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1019 }