Mercurial > hg > truffle
annotate graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java @ 19001:5a79fa76b489
Run eclipse format.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Wed, 28 Jan 2015 04:05:07 +0100 |
parents | 3faa4f98d5c8 |
children | cd49455040c1 |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16092
diff
changeset
|
2 * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
23 |
6532
0c6030872cd0
renamed package: com.oracle.graal.compiler.target.amd64 -> com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6531
diff
changeset
|
24 package com.oracle.graal.compiler.amd64; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
25 |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5546
diff
changeset
|
26 import static com.oracle.graal.api.code.ValueUtil.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
27 import static com.oracle.graal.lir.amd64.AMD64Arithmetic.*; |
7861
c6d003891de0
Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7839
diff
changeset
|
28 import static com.oracle.graal.lir.amd64.AMD64BitManipulationOp.IntrinsicOpcode.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
29 import static com.oracle.graal.lir.amd64.AMD64Compare.*; |
7280
f368ec89e231
added intrinsifications for Integer.bitCount() and Long.bitCount()
Doug Simon <doug.simon@oracle.com>
parents:
7144
diff
changeset
|
30 import static com.oracle.graal.lir.amd64.AMD64MathIntrinsicOp.IntrinsicOpcode.*; |
4323
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4314
diff
changeset
|
31 |
6580
d56d600819fe
moved AMD64 into its own (new) project: com.oracle.graal.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
32 import com.oracle.graal.amd64.*; |
5510
426c605c9d3c
Move cri.ci to api.code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5507
diff
changeset
|
33 import com.oracle.graal.api.code.*; |
5507
dc71b06d09f8
Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5506
diff
changeset
|
34 import com.oracle.graal.api.meta.*; |
6531
4afe23aa0a00
renamed packages: com.oracle.max.asm... -> com.oracle.graal.asm...
Doug Simon <doug.simon@oracle.com>
parents:
6525
diff
changeset
|
35 import com.oracle.graal.asm.*; |
8167
7f57c30575c8
Make AMD64Address a low-level representation for use by the assembler only.
Roland Schatz <roland.schatz@oracle.com>
parents:
8166
diff
changeset
|
36 import com.oracle.graal.asm.amd64.AMD64Address.Scale; |
6675
6eb83c6eb177
change LIRGenerator to take StructuredGraph instead of Graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
6580
diff
changeset
|
37 import com.oracle.graal.asm.amd64.AMD64Assembler.ConditionFlag; |
15193
96bb07a5d667
Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents:
14998
diff
changeset
|
38 import com.oracle.graal.compiler.common.*; |
15200
97eed257999b
Move Condition to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
15193
diff
changeset
|
39 import com.oracle.graal.compiler.common.calc.*; |
18358
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
18300
diff
changeset
|
40 import com.oracle.graal.compiler.common.spi.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
41 import com.oracle.graal.lir.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
42 import com.oracle.graal.lir.StandardOp.JumpOp; |
7919
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
43 import com.oracle.graal.lir.amd64.*; |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
44 import com.oracle.graal.lir.amd64.AMD64Arithmetic.BinaryCommutative; |
14707
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
45 import com.oracle.graal.lir.amd64.AMD64Arithmetic.BinaryMemory; |
7919
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
46 import com.oracle.graal.lir.amd64.AMD64Arithmetic.BinaryRegConst; |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
47 import com.oracle.graal.lir.amd64.AMD64Arithmetic.BinaryRegReg; |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
48 import com.oracle.graal.lir.amd64.AMD64Arithmetic.BinaryRegStack; |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
49 import com.oracle.graal.lir.amd64.AMD64Arithmetic.BinaryRegStackConst; |
7861
c6d003891de0
Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7839
diff
changeset
|
50 import com.oracle.graal.lir.amd64.AMD64Arithmetic.DivRemOp; |
9581
d84ea522800e
replaced arithmetic_[fd]rem stubs with inline compiled code (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9431
diff
changeset
|
51 import com.oracle.graal.lir.amd64.AMD64Arithmetic.FPDivRemOp; |
17196
189479d72dc8
Move bit manipulation methods to CodeUtil class.
Roland Schatz <roland.schatz@oracle.com>
parents:
16346
diff
changeset
|
52 import com.oracle.graal.lir.amd64.AMD64Arithmetic.MulHighOp; |
7910
748cb57f53cb
Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7909
diff
changeset
|
53 import com.oracle.graal.lir.amd64.AMD64Arithmetic.Unary1Op; |
14707
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
54 import com.oracle.graal.lir.amd64.AMD64Arithmetic.Unary2MemoryOp; |
7910
748cb57f53cb
Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7909
diff
changeset
|
55 import com.oracle.graal.lir.amd64.AMD64Arithmetic.Unary2Op; |
15278
3ef4196cf8e5
use movl instead of andl for L2I
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15261
diff
changeset
|
56 import com.oracle.graal.lir.amd64.AMD64Arithmetic.Unary2RegOp; |
14707
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
57 import com.oracle.graal.lir.amd64.AMD64Compare.CompareMemoryOp; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
58 import com.oracle.graal.lir.amd64.AMD64Compare.CompareOp; |
5798
2585af1e26ac
implemented non-XIR lowering of invokes (todo: inline virtual dispatch and null checking of receivers)
Doug Simon <doug.simon@oracle.com>
parents:
5775
diff
changeset
|
59 import com.oracle.graal.lir.amd64.AMD64ControlFlow.BranchOp; |
2585af1e26ac
implemented non-XIR lowering of invokes (todo: inline virtual dispatch and null checking of receivers)
Doug Simon <doug.simon@oracle.com>
parents:
5775
diff
changeset
|
60 import com.oracle.graal.lir.amd64.AMD64ControlFlow.CondMoveOp; |
2585af1e26ac
implemented non-XIR lowering of invokes (todo: inline virtual dispatch and null checking of receivers)
Doug Simon <doug.simon@oracle.com>
parents:
5775
diff
changeset
|
61 import com.oracle.graal.lir.amd64.AMD64ControlFlow.FloatBranchOp; |
2585af1e26ac
implemented non-XIR lowering of invokes (todo: inline virtual dispatch and null checking of receivers)
Doug Simon <doug.simon@oracle.com>
parents:
5775
diff
changeset
|
62 import com.oracle.graal.lir.amd64.AMD64ControlFlow.FloatCondMoveOp; |
2585af1e26ac
implemented non-XIR lowering of invokes (todo: inline virtual dispatch and null checking of receivers)
Doug Simon <doug.simon@oracle.com>
parents:
5775
diff
changeset
|
63 import com.oracle.graal.lir.amd64.AMD64ControlFlow.ReturnOp; |
13294
29907e69ae8d
rework of switch generation: move code into platform independent SwitchStrategy, add boolean switch strategy
Lukas Stadler <lukas.stadler@jku.at>
parents:
13268
diff
changeset
|
64 import com.oracle.graal.lir.amd64.AMD64ControlFlow.StrategySwitchOp; |
5798
2585af1e26ac
implemented non-XIR lowering of invokes (todo: inline virtual dispatch and null checking of receivers)
Doug Simon <doug.simon@oracle.com>
parents:
5775
diff
changeset
|
65 import com.oracle.graal.lir.amd64.AMD64ControlFlow.TableSwitchOp; |
14859 | 66 import com.oracle.graal.lir.amd64.AMD64Move.LeaDataOp; |
14121
0ddb3b3665bd
Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents:
14061
diff
changeset
|
67 import com.oracle.graal.lir.amd64.AMD64Move.LeaOp; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
68 import com.oracle.graal.lir.amd64.AMD64Move.MembarOp; |
14121
0ddb3b3665bd
Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents:
14061
diff
changeset
|
69 import com.oracle.graal.lir.amd64.AMD64Move.MoveFromRegOp; |
0ddb3b3665bd
Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents:
14061
diff
changeset
|
70 import com.oracle.graal.lir.amd64.AMD64Move.MoveToRegOp; |
7882
124b28240347
Separate STACK and ADDR nodes in LIR.
Roland Schatz <roland.schatz@oracle.com>
parents:
7880
diff
changeset
|
71 import com.oracle.graal.lir.amd64.AMD64Move.StackLeaOp; |
14859 | 72 import com.oracle.graal.lir.amd64.AMD64Move.ZeroExtendLoadOp; |
15292
a38d791982e1
Move LIRGenerationResult* to graal.lir.
Josef Eisl <josef.eisl@jku.at>
parents:
15278
diff
changeset
|
73 import com.oracle.graal.lir.gen.*; |
6525
2c913b643422
rename packages in graal.phases to match project name
Doug Simon <doug.simon@oracle.com>
parents:
6521
diff
changeset
|
74 import com.oracle.graal.phases.util.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
75 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
76 /** |
6496
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6493
diff
changeset
|
77 * This class implements the AMD64 specific portion of the LIR generator. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
78 */ |
5247
62bbfd78c703
removed mechanism for lowering ExceptionObjectNode via substitution; only LIR lowering by the runtime is now supported
Doug Simon <doug.simon@oracle.com>
parents:
5233
diff
changeset
|
79 public abstract class AMD64LIRGenerator extends LIRGenerator { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
80 |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16092
diff
changeset
|
81 private static final RegisterValue RCX_I = AMD64.rcx.asValue(LIRKind.value(Kind.Int)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
82 |
14121
0ddb3b3665bd
Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents:
14061
diff
changeset
|
83 private class AMD64SpillMoveFactory implements LIR.SpillMoveFactory { |
0ddb3b3665bd
Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents:
14061
diff
changeset
|
84 |
0ddb3b3665bd
Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents:
14061
diff
changeset
|
85 @Override |
0ddb3b3665bd
Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents:
14061
diff
changeset
|
86 public LIRInstruction createMove(AllocatableValue result, Value input) { |
0ddb3b3665bd
Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents:
14061
diff
changeset
|
87 return AMD64LIRGenerator.this.createMove(result, input); |
0ddb3b3665bd
Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents:
14061
diff
changeset
|
88 } |
0ddb3b3665bd
Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents:
14061
diff
changeset
|
89 } |
0ddb3b3665bd
Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents:
14061
diff
changeset
|
90 |
18358
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
18300
diff
changeset
|
91 public AMD64LIRGenerator(LIRKindTool lirKindTool, Providers providers, CallingConvention cc, LIRGenerationResult lirGenRes) { |
2dc0d4dcb709
Separate stamp for metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
18300
diff
changeset
|
92 super(lirKindTool, providers, cc, lirGenRes); |
14809
73774616a6b3
Decoupled LIRGenerator and LIRGenerationResult.
Josef Eisl <josef.eisl@jku.at>
parents:
14796
diff
changeset
|
93 lirGenRes.getLIR().setSpillMoveFactory(new AMD64SpillMoveFactory()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
94 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
95 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
96 @Override |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
17314
diff
changeset
|
97 public boolean canInlineConstant(JavaConstant c) { |
6329
92bc58dc5b5e
More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5798
diff
changeset
|
98 switch (c.getKind()) { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
99 case Long: |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12363
diff
changeset
|
100 return NumUtil.isInt(c.asLong()) && !getCodeCache().needsDataPatch(c); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
101 case Object: |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
102 return c.isNull(); |
17305
8dcb64d6e987
Backed out changeset: 00dd7b3c5aea ("float and double constants cannot be inlined")
Lukas Stadler <lukas.stadler@oracle.com>
parents:
17266
diff
changeset
|
103 default: |
17266
00dd7b3c5aea
float and double constants cannot be inlined
Lukas Stadler <lukas.stadler@oracle.com>
parents:
17196
diff
changeset
|
104 return true; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
105 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
106 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
107 |
18935
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18843
diff
changeset
|
108 /** |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18843
diff
changeset
|
109 * Checks whether the supplied constant can be used without loading it into a register for store |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18843
diff
changeset
|
110 * operations, i.e., on the right hand side of a memory access. |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18843
diff
changeset
|
111 * |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18843
diff
changeset
|
112 * @param c The constant to check. |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18843
diff
changeset
|
113 * @return True if the constant can be used directly, false if the constant needs to be in a |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18843
diff
changeset
|
114 * register. |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18843
diff
changeset
|
115 */ |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18843
diff
changeset
|
116 protected boolean canStoreConstant(JavaConstant c) { |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18843
diff
changeset
|
117 // there is no immediate move of 64-bit constants on Intel |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18843
diff
changeset
|
118 switch (c.getKind()) { |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18843
diff
changeset
|
119 case Long: |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18843
diff
changeset
|
120 return Util.isInt(c.asLong()) && !getCodeCache().needsDataPatch(c); |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18843
diff
changeset
|
121 case Double: |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18843
diff
changeset
|
122 return false; |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18843
diff
changeset
|
123 case Object: |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18843
diff
changeset
|
124 return c.isNull(); |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18843
diff
changeset
|
125 default: |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18843
diff
changeset
|
126 return true; |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18843
diff
changeset
|
127 } |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18843
diff
changeset
|
128 } |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18843
diff
changeset
|
129 |
14121
0ddb3b3665bd
Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents:
14061
diff
changeset
|
130 protected AMD64LIRInstruction createMove(AllocatableValue dst, Value src) { |
0ddb3b3665bd
Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents:
14061
diff
changeset
|
131 if (src instanceof AMD64AddressValue) { |
0ddb3b3665bd
Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents:
14061
diff
changeset
|
132 return new LeaOp(dst, (AMD64AddressValue) src); |
18436
59e65d3aa2fc
Use StackSlotValue where appropriate.
Josef Eisl <josef.eisl@jku.at>
parents:
18425
diff
changeset
|
133 } else if (isRegister(src) || isStackSlotValue(dst)) { |
14945
b14cb2d9253d
Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
14931
diff
changeset
|
134 return new MoveFromRegOp(dst.getKind(), dst, src); |
14121
0ddb3b3665bd
Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents:
14061
diff
changeset
|
135 } else { |
14945
b14cb2d9253d
Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
14931
diff
changeset
|
136 return new MoveToRegOp(dst.getKind(), dst, src); |
14121
0ddb3b3665bd
Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents:
14061
diff
changeset
|
137 } |
0ddb3b3665bd
Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents:
14061
diff
changeset
|
138 } |
0ddb3b3665bd
Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents:
14061
diff
changeset
|
139 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
140 @Override |
9296
1342574c4f7d
Move targets can only be AllocatableValues.
Roland Schatz <roland.schatz@oracle.com>
parents:
9294
diff
changeset
|
141 public void emitMove(AllocatableValue dst, Value src) { |
14121
0ddb3b3665bd
Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents:
14061
diff
changeset
|
142 append(createMove(dst, src)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
143 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
144 |
14859 | 145 public void emitData(AllocatableValue dst, byte[] data) { |
146 append(new LeaDataOp(dst, data)); | |
147 } | |
148 | |
9298
9ee5f3bfa755
Restructure load/store/lea LIR instructions.
Roland Schatz <roland.schatz@oracle.com>
parents:
9297
diff
changeset
|
149 @Override |
9ee5f3bfa755
Restructure load/store/lea LIR instructions.
Roland Schatz <roland.schatz@oracle.com>
parents:
9297
diff
changeset
|
150 public AMD64AddressValue emitAddress(Value base, long displacement, Value index, int scale) { |
8166
d2733c9b3d0e
Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents:
8144
diff
changeset
|
151 AllocatableValue baseRegister; |
9204
589e140a7f1c
Allow locations to have long displacements.
Roland Schatz <roland.schatz@oracle.com>
parents:
9003
diff
changeset
|
152 long finalDisp = displacement; |
7861
c6d003891de0
Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7839
diff
changeset
|
153 if (isConstant(base)) { |
c6d003891de0
Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7839
diff
changeset
|
154 if (asConstant(base).isNull()) { |
9294
899295127bc4
Get rid of the distinction between UNUSED and ILLEGAL value.
Roland Schatz <roland.schatz@oracle.com>
parents:
9293
diff
changeset
|
155 baseRegister = Value.ILLEGAL; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12363
diff
changeset
|
156 } else if (asConstant(base).getKind() != Kind.Object && !getCodeCache().needsDataPatch(asConstant(base))) { |
9204
589e140a7f1c
Allow locations to have long displacements.
Roland Schatz <roland.schatz@oracle.com>
parents:
9003
diff
changeset
|
157 finalDisp += asConstant(base).asLong(); |
9294
899295127bc4
Get rid of the distinction between UNUSED and ILLEGAL value.
Roland Schatz <roland.schatz@oracle.com>
parents:
9293
diff
changeset
|
158 baseRegister = Value.ILLEGAL; |
8166
d2733c9b3d0e
Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents:
8144
diff
changeset
|
159 } else { |
d2733c9b3d0e
Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents:
8144
diff
changeset
|
160 baseRegister = load(base); |
7861
c6d003891de0
Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7839
diff
changeset
|
161 } |
8166
d2733c9b3d0e
Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents:
8144
diff
changeset
|
162 } else { |
d2733c9b3d0e
Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents:
8144
diff
changeset
|
163 baseRegister = asAllocatable(base); |
7861
c6d003891de0
Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7839
diff
changeset
|
164 } |
c6d003891de0
Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7839
diff
changeset
|
165 |
8166
d2733c9b3d0e
Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents:
8144
diff
changeset
|
166 AllocatableValue indexRegister; |
d2733c9b3d0e
Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents:
8144
diff
changeset
|
167 Scale scaleEnum; |
9638
c455c86138ba
Value: more occurrences of object equality replaced
Bernhard Urban <bernhard.urban@jku.at>
parents:
9613
diff
changeset
|
168 if (!index.equals(Value.ILLEGAL) && scale != 0) { |
8166
d2733c9b3d0e
Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents:
8144
diff
changeset
|
169 scaleEnum = Scale.fromInt(scale); |
7861
c6d003891de0
Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7839
diff
changeset
|
170 if (isConstant(index)) { |
9204
589e140a7f1c
Allow locations to have long displacements.
Roland Schatz <roland.schatz@oracle.com>
parents:
9003
diff
changeset
|
171 finalDisp += asConstant(index).asLong() * scale; |
9294
899295127bc4
Get rid of the distinction between UNUSED and ILLEGAL value.
Roland Schatz <roland.schatz@oracle.com>
parents:
9293
diff
changeset
|
172 indexRegister = Value.ILLEGAL; |
13134
6217f601e65d
Allow addresses with an arbitrary scale value; fix handling of unsigned int-to-long conversion
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12695
diff
changeset
|
173 |
6217f601e65d
Allow addresses with an arbitrary scale value; fix handling of unsigned int-to-long conversion
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12695
diff
changeset
|
174 } else if (scaleEnum == null) { |
6217f601e65d
Allow addresses with an arbitrary scale value; fix handling of unsigned int-to-long conversion
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12695
diff
changeset
|
175 /* Scale value that architecture cannot handle, so scale manually. */ |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
176 Value longIndex = index.getKind() == Kind.Long ? index : emitSignExtend(index, 32, 64); |
13134
6217f601e65d
Allow addresses with an arbitrary scale value; fix handling of unsigned int-to-long conversion
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12695
diff
changeset
|
177 if (CodeUtil.isPowerOf2(scale)) { |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
17314
diff
changeset
|
178 indexRegister = emitShl(longIndex, JavaConstant.forLong(CodeUtil.log2(scale))); |
13134
6217f601e65d
Allow addresses with an arbitrary scale value; fix handling of unsigned int-to-long conversion
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12695
diff
changeset
|
179 } else { |
18843
5e80dd2f1783
Extend emitMul, emitAdd and emitSub in ArithmeticLIRGenerator for explicitly requesting to set the flags register. (In AMD64 flags are set implicitly, but on SPARC it is not)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18436
diff
changeset
|
180 indexRegister = emitMul(longIndex, JavaConstant.forLong(scale), false); |
13134
6217f601e65d
Allow addresses with an arbitrary scale value; fix handling of unsigned int-to-long conversion
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12695
diff
changeset
|
181 } |
6217f601e65d
Allow addresses with an arbitrary scale value; fix handling of unsigned int-to-long conversion
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12695
diff
changeset
|
182 scaleEnum = Scale.Times1; |
6217f601e65d
Allow addresses with an arbitrary scale value; fix handling of unsigned int-to-long conversion
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12695
diff
changeset
|
183 |
8166
d2733c9b3d0e
Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents:
8144
diff
changeset
|
184 } else { |
d2733c9b3d0e
Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents:
8144
diff
changeset
|
185 indexRegister = asAllocatable(index); |
7861
c6d003891de0
Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7839
diff
changeset
|
186 } |
c6d003891de0
Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7839
diff
changeset
|
187 } else { |
9294
899295127bc4
Get rid of the distinction between UNUSED and ILLEGAL value.
Roland Schatz <roland.schatz@oracle.com>
parents:
9293
diff
changeset
|
188 indexRegister = Value.ILLEGAL; |
8166
d2733c9b3d0e
Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents:
8144
diff
changeset
|
189 scaleEnum = Scale.Times1; |
7861
c6d003891de0
Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7839
diff
changeset
|
190 } |
c6d003891de0
Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7839
diff
changeset
|
191 |
9204
589e140a7f1c
Allow locations to have long displacements.
Roland Schatz <roland.schatz@oracle.com>
parents:
9003
diff
changeset
|
192 int displacementInt; |
589e140a7f1c
Allow locations to have long displacements.
Roland Schatz <roland.schatz@oracle.com>
parents:
9003
diff
changeset
|
193 if (NumUtil.isInt(finalDisp)) { |
589e140a7f1c
Allow locations to have long displacements.
Roland Schatz <roland.schatz@oracle.com>
parents:
9003
diff
changeset
|
194 displacementInt = (int) finalDisp; |
589e140a7f1c
Allow locations to have long displacements.
Roland Schatz <roland.schatz@oracle.com>
parents:
9003
diff
changeset
|
195 } else { |
589e140a7f1c
Allow locations to have long displacements.
Roland Schatz <roland.schatz@oracle.com>
parents:
9003
diff
changeset
|
196 displacementInt = 0; |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
17314
diff
changeset
|
197 AllocatableValue displacementRegister = load(JavaConstant.forLong(finalDisp)); |
9638
c455c86138ba
Value: more occurrences of object equality replaced
Bernhard Urban <bernhard.urban@jku.at>
parents:
9613
diff
changeset
|
198 if (baseRegister.equals(Value.ILLEGAL)) { |
9204
589e140a7f1c
Allow locations to have long displacements.
Roland Schatz <roland.schatz@oracle.com>
parents:
9003
diff
changeset
|
199 baseRegister = displacementRegister; |
10086 | 200 } else if (indexRegister.equals(Value.ILLEGAL)) { |
9204
589e140a7f1c
Allow locations to have long displacements.
Roland Schatz <roland.schatz@oracle.com>
parents:
9003
diff
changeset
|
201 indexRegister = displacementRegister; |
589e140a7f1c
Allow locations to have long displacements.
Roland Schatz <roland.schatz@oracle.com>
parents:
9003
diff
changeset
|
202 scaleEnum = Scale.Times1; |
589e140a7f1c
Allow locations to have long displacements.
Roland Schatz <roland.schatz@oracle.com>
parents:
9003
diff
changeset
|
203 } else { |
18843
5e80dd2f1783
Extend emitMul, emitAdd and emitSub in ArithmeticLIRGenerator for explicitly requesting to set the flags register. (In AMD64 flags are set implicitly, but on SPARC it is not)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18436
diff
changeset
|
204 baseRegister = emitAdd(baseRegister, displacementRegister, false); |
9204
589e140a7f1c
Allow locations to have long displacements.
Roland Schatz <roland.schatz@oracle.com>
parents:
9003
diff
changeset
|
205 } |
589e140a7f1c
Allow locations to have long displacements.
Roland Schatz <roland.schatz@oracle.com>
parents:
9003
diff
changeset
|
206 } |
589e140a7f1c
Allow locations to have long displacements.
Roland Schatz <roland.schatz@oracle.com>
parents:
9003
diff
changeset
|
207 |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16092
diff
changeset
|
208 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
|
209 return new AMD64AddressValue(resultKind, baseRegister, indexRegister, scaleEnum, displacementInt); |
7861
c6d003891de0
Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7839
diff
changeset
|
210 } |
c6d003891de0
Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7839
diff
changeset
|
211 |
14841
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
14826
diff
changeset
|
212 public AMD64AddressValue asAddressValue(Value address) { |
9298
9ee5f3bfa755
Restructure load/store/lea LIR instructions.
Roland Schatz <roland.schatz@oracle.com>
parents:
9297
diff
changeset
|
213 if (address instanceof AMD64AddressValue) { |
9ee5f3bfa755
Restructure load/store/lea LIR instructions.
Roland Schatz <roland.schatz@oracle.com>
parents:
9297
diff
changeset
|
214 return (AMD64AddressValue) address; |
9ee5f3bfa755
Restructure load/store/lea LIR instructions.
Roland Schatz <roland.schatz@oracle.com>
parents:
9297
diff
changeset
|
215 } else { |
9ee5f3bfa755
Restructure load/store/lea LIR instructions.
Roland Schatz <roland.schatz@oracle.com>
parents:
9297
diff
changeset
|
216 return emitAddress(address, 0, Value.ILLEGAL, 0); |
9ee5f3bfa755
Restructure load/store/lea LIR instructions.
Roland Schatz <roland.schatz@oracle.com>
parents:
9297
diff
changeset
|
217 } |
9ee5f3bfa755
Restructure load/store/lea LIR instructions.
Roland Schatz <roland.schatz@oracle.com>
parents:
9297
diff
changeset
|
218 } |
9ee5f3bfa755
Restructure load/store/lea LIR instructions.
Roland Schatz <roland.schatz@oracle.com>
parents:
9297
diff
changeset
|
219 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
220 @Override |
18425
b856446ff7e0
Introduce StackSlotValue and VirtualStackSlot.
Josef Eisl <josef.eisl@jku.at>
parents:
18415
diff
changeset
|
221 public Variable emitAddress(StackSlotValue address) { |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16092
diff
changeset
|
222 Variable result = newVariable(LIRKind.value(target().wordKind)); |
7882
124b28240347
Separate STACK and ADDR nodes in LIR.
Roland Schatz <roland.schatz@oracle.com>
parents:
7880
diff
changeset
|
223 append(new StackLeaOp(result, address)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
224 return result; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
225 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
226 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
227 @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
|
228 public void emitJump(LabelRef label) { |
13294
29907e69ae8d
rework of switch generation: move code into platform independent SwitchStrategy, add boolean switch strategy
Lukas Stadler <lukas.stadler@jku.at>
parents:
13268
diff
changeset
|
229 assert label != null; |
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
|
230 append(new JumpOp(label)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
231 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
232 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
233 @Override |
14962
e4a5b8904695
Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14949
diff
changeset
|
234 public void emitCompareBranch(PlatformKind cmpKind, Value left, Value right, Condition cond, boolean unorderedIsTrue, LabelRef trueLabel, LabelRef falseLabel, double trueLabelProbability) { |
16104
4dd2cedc7f57
Revert using LIRKind.reference(Kind.Int) instead of hotspot specific NarrowOop kind (part of c0b8d395368b).
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
235 boolean mirrored = emitCompare(cmpKind, left, right); |
5406
ae759e820ce7
AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents:
5402
diff
changeset
|
236 Condition finalCondition = mirrored ? cond.mirror() : cond; |
15910
79a0d9065849
Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15909
diff
changeset
|
237 if (cmpKind == Kind.Float || cmpKind == Kind.Double) { |
79a0d9065849
Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15909
diff
changeset
|
238 append(new FloatBranchOp(finalCondition, unorderedIsTrue, trueLabel, falseLabel, trueLabelProbability)); |
79a0d9065849
Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15909
diff
changeset
|
239 } else { |
79a0d9065849
Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15909
diff
changeset
|
240 append(new BranchOp(finalCondition, trueLabel, falseLabel, trueLabelProbability)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
241 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
242 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
243 |
15370
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
244 public void emitCompareBranchMemory(Kind cmpKind, Value left, AMD64AddressValue right, LIRFrameState state, Condition cond, boolean unorderedIsTrue, LabelRef trueLabel, LabelRef falseLabel, |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
245 double trueLabelProbability) { |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
246 boolean mirrored = emitCompareMemory(cmpKind, left, right, state); |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
247 Condition finalCondition = mirrored ? cond.mirror() : cond; |
15910
79a0d9065849
Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15909
diff
changeset
|
248 if (cmpKind == Kind.Float || cmpKind == Kind.Double) { |
79a0d9065849
Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15909
diff
changeset
|
249 append(new FloatBranchOp(finalCondition, unorderedIsTrue, trueLabel, falseLabel, trueLabelProbability)); |
79a0d9065849
Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15909
diff
changeset
|
250 } else { |
79a0d9065849
Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15909
diff
changeset
|
251 append(new BranchOp(finalCondition, trueLabel, falseLabel, trueLabelProbability)); |
15370
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
252 } |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
253 } |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
254 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
255 @Override |
18843
5e80dd2f1783
Extend emitMul, emitAdd and emitSub in ArithmeticLIRGenerator for explicitly requesting to set the flags register. (In AMD64 flags are set implicitly, but on SPARC it is not)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18436
diff
changeset
|
256 public void emitOverflowCheckBranch(LabelRef overflow, LabelRef noOverflow, LIRKind cmpLIRKind, double overflowProbability) { |
13908
8f3cd93813f1
Use branch probability for emitting conditional jump.
Roland Schatz <roland.schatz@oracle.com>
parents:
13907
diff
changeset
|
257 append(new BranchOp(ConditionFlag.Overflow, overflow, noOverflow, overflowProbability)); |
8210
c64ecb1ef1a9
Create LIRGenerator.emitOverflowCheckBranch in preparation for emitDeoptimizeOnOverflow removal
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8209
diff
changeset
|
258 } |
c64ecb1ef1a9
Create LIRGenerator.emitOverflowCheckBranch in preparation for emitDeoptimizeOnOverflow removal
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8209
diff
changeset
|
259 |
c64ecb1ef1a9
Create LIRGenerator.emitOverflowCheckBranch in preparation for emitDeoptimizeOnOverflow removal
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8209
diff
changeset
|
260 @Override |
13908
8f3cd93813f1
Use branch probability for emitting conditional jump.
Roland Schatz <roland.schatz@oracle.com>
parents:
13907
diff
changeset
|
261 public void emitIntegerTestBranch(Value left, Value right, LabelRef trueDestination, LabelRef falseDestination, double trueDestinationProbability) { |
7725
301cff1a99d1
backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents:
7660
diff
changeset
|
262 emitIntegerTest(left, right); |
13908
8f3cd93813f1
Use branch probability for emitting conditional jump.
Roland Schatz <roland.schatz@oracle.com>
parents:
13907
diff
changeset
|
263 append(new BranchOp(Condition.EQ, trueDestination, falseDestination, trueDestinationProbability)); |
7725
301cff1a99d1
backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents:
7660
diff
changeset
|
264 } |
301cff1a99d1
backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents:
7660
diff
changeset
|
265 |
301cff1a99d1
backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents:
7660
diff
changeset
|
266 @Override |
14962
e4a5b8904695
Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14949
diff
changeset
|
267 public Variable emitConditionalMove(PlatformKind cmpKind, Value left, Value right, Condition cond, boolean unorderedIsTrue, Value trueValue, Value falseValue) { |
16104
4dd2cedc7f57
Revert using LIRKind.reference(Kind.Int) instead of hotspot specific NarrowOop kind (part of c0b8d395368b).
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
268 boolean mirrored = emitCompare(cmpKind, left, right); |
5406
ae759e820ce7
AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents:
5402
diff
changeset
|
269 Condition finalCondition = mirrored ? cond.mirror() : cond; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
270 |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16092
diff
changeset
|
271 Variable result = newVariable(trueValue.getLIRKind()); |
15910
79a0d9065849
Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15909
diff
changeset
|
272 if (cmpKind == Kind.Float || cmpKind == Kind.Double) { |
79a0d9065849
Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15909
diff
changeset
|
273 append(new FloatCondMoveOp(result, finalCondition, unorderedIsTrue, load(trueValue), load(falseValue))); |
79a0d9065849
Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15909
diff
changeset
|
274 } else { |
79a0d9065849
Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15909
diff
changeset
|
275 append(new CondMoveOp(result, finalCondition, load(trueValue), loadNonConst(falseValue))); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
276 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
277 return result; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
278 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
279 |
7725
301cff1a99d1
backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents:
7660
diff
changeset
|
280 @Override |
301cff1a99d1
backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents:
7660
diff
changeset
|
281 public Variable emitIntegerTestMove(Value left, Value right, Value trueValue, Value falseValue) { |
301cff1a99d1
backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents:
7660
diff
changeset
|
282 emitIntegerTest(left, right); |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16092
diff
changeset
|
283 Variable result = newVariable(trueValue.getLIRKind()); |
7725
301cff1a99d1
backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents:
7660
diff
changeset
|
284 append(new CondMoveOp(result, Condition.EQ, load(trueValue), loadNonConst(falseValue))); |
301cff1a99d1
backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents:
7660
diff
changeset
|
285 return result; |
301cff1a99d1
backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents:
7660
diff
changeset
|
286 } |
301cff1a99d1
backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents:
7660
diff
changeset
|
287 |
301cff1a99d1
backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents:
7660
diff
changeset
|
288 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
|
289 assert a.getKind().isNumericInteger(); |
7725
301cff1a99d1
backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents:
7660
diff
changeset
|
290 if (LIRValueUtil.isVariable(b)) { |
301cff1a99d1
backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents:
7660
diff
changeset
|
291 append(new AMD64TestOp(load(b), loadNonConst(a))); |
301cff1a99d1
backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents:
7660
diff
changeset
|
292 } else { |
301cff1a99d1
backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents:
7660
diff
changeset
|
293 append(new AMD64TestOp(load(a), loadNonConst(b))); |
301cff1a99d1
backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents:
7660
diff
changeset
|
294 } |
301cff1a99d1
backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents:
7660
diff
changeset
|
295 } |
301cff1a99d1
backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents:
7660
diff
changeset
|
296 |
16104
4dd2cedc7f57
Revert using LIRKind.reference(Kind.Int) instead of hotspot specific NarrowOop kind (part of c0b8d395368b).
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
297 protected void emitCompareOp(PlatformKind cmpKind, Variable left, Value right) { |
4dd2cedc7f57
Revert using LIRKind.reference(Kind.Int) instead of hotspot specific NarrowOop kind (part of c0b8d395368b).
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
298 switch ((Kind) cmpKind) { |
14962
e4a5b8904695
Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14949
diff
changeset
|
299 case Byte: |
e4a5b8904695
Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14949
diff
changeset
|
300 case Boolean: |
e4a5b8904695
Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14949
diff
changeset
|
301 append(new CompareOp(BCMP, left, right)); |
e4a5b8904695
Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14949
diff
changeset
|
302 break; |
e4a5b8904695
Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14949
diff
changeset
|
303 case Short: |
e4a5b8904695
Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14949
diff
changeset
|
304 case Char: |
e4a5b8904695
Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14949
diff
changeset
|
305 append(new CompareOp(SCMP, left, right)); |
e4a5b8904695
Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14949
diff
changeset
|
306 break; |
13251
3a8a4042229f
Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents:
13212
diff
changeset
|
307 case Int: |
3a8a4042229f
Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents:
13212
diff
changeset
|
308 append(new CompareOp(ICMP, left, right)); |
3a8a4042229f
Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents:
13212
diff
changeset
|
309 break; |
3a8a4042229f
Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents:
13212
diff
changeset
|
310 case Long: |
3a8a4042229f
Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents:
13212
diff
changeset
|
311 append(new CompareOp(LCMP, left, right)); |
3a8a4042229f
Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents:
13212
diff
changeset
|
312 break; |
3a8a4042229f
Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents:
13212
diff
changeset
|
313 case Object: |
3a8a4042229f
Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents:
13212
diff
changeset
|
314 append(new CompareOp(ACMP, left, right)); |
3a8a4042229f
Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents:
13212
diff
changeset
|
315 break; |
3a8a4042229f
Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents:
13212
diff
changeset
|
316 case Float: |
3a8a4042229f
Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents:
13212
diff
changeset
|
317 append(new CompareOp(FCMP, left, right)); |
3a8a4042229f
Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents:
13212
diff
changeset
|
318 break; |
3a8a4042229f
Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents:
13212
diff
changeset
|
319 case Double: |
3a8a4042229f
Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents:
13212
diff
changeset
|
320 append(new CompareOp(DCMP, left, right)); |
3a8a4042229f
Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents:
13212
diff
changeset
|
321 break; |
3a8a4042229f
Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents:
13212
diff
changeset
|
322 default: |
3a8a4042229f
Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents:
13212
diff
changeset
|
323 throw GraalInternalError.shouldNotReachHere(); |
3a8a4042229f
Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents:
13212
diff
changeset
|
324 } |
3a8a4042229f
Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents:
13212
diff
changeset
|
325 } |
3a8a4042229f
Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents:
13212
diff
changeset
|
326 |
15370
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
327 /** |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
328 * This method emits the compare against memory instruction, and may reorder the operands. It |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
329 * returns true if it did so. |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
330 * |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
331 * @param b the right operand of the comparison |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
332 * @return true if the left and right operands were switched, false otherwise |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
333 */ |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
334 private boolean emitCompareMemory(Kind cmpKind, Value a, AMD64AddressValue b, LIRFrameState state) { |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
335 boolean mirrored; |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
336 if (LIRValueUtil.isVariable(a)) { |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
337 Variable left = load(a); |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
338 emitCompareRegMemoryOp(cmpKind, left, b, state); |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
339 mirrored = false; |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
340 } else { |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
17314
diff
changeset
|
341 emitCompareMemoryConOp(cmpKind, b, (JavaConstant) a, state); |
15370
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
342 mirrored = true; |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
343 } |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
344 return mirrored; |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
345 } |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
346 |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
17314
diff
changeset
|
347 protected void emitCompareMemoryConOp(Kind kind, AMD64AddressValue address, JavaConstant value, LIRFrameState state) { |
14962
e4a5b8904695
Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14949
diff
changeset
|
348 assert kind.getStackKind() == value.getKind().getStackKind(); |
14707
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
349 switch (kind) { |
14962
e4a5b8904695
Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14949
diff
changeset
|
350 case Byte: |
e4a5b8904695
Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14949
diff
changeset
|
351 case Boolean: |
e4a5b8904695
Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14949
diff
changeset
|
352 append(new CompareMemoryOp(BCMP, kind, address, value, state)); |
e4a5b8904695
Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14949
diff
changeset
|
353 break; |
e4a5b8904695
Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14949
diff
changeset
|
354 case Short: |
e4a5b8904695
Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14949
diff
changeset
|
355 case Char: |
e4a5b8904695
Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14949
diff
changeset
|
356 append(new CompareMemoryOp(SCMP, kind, address, value, state)); |
e4a5b8904695
Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14949
diff
changeset
|
357 break; |
14707
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
358 case Int: |
14931
d45e8c306349
use MemOp as base class for new memory ops
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14859
diff
changeset
|
359 append(new CompareMemoryOp(ICMP, kind, address, value, state)); |
14707
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
360 break; |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
361 case Long: |
14931
d45e8c306349
use MemOp as base class for new memory ops
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14859
diff
changeset
|
362 append(new CompareMemoryOp(LCMP, kind, address, value, state)); |
14707
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
363 break; |
15910
79a0d9065849
Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15909
diff
changeset
|
364 case Object: |
79a0d9065849
Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15909
diff
changeset
|
365 assert value.isNull(); |
79a0d9065849
Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15909
diff
changeset
|
366 append(new CompareMemoryOp(ACMP, kind, address, value, state)); |
79a0d9065849
Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15909
diff
changeset
|
367 break; |
14707
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
368 default: |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
369 throw GraalInternalError.shouldNotReachHere(); |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
370 } |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
371 } |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
372 |
14931
d45e8c306349
use MemOp as base class for new memory ops
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14859
diff
changeset
|
373 protected void emitCompareRegMemoryOp(Kind kind, Value value, AMD64AddressValue address, LIRFrameState state) { |
d45e8c306349
use MemOp as base class for new memory ops
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14859
diff
changeset
|
374 AMD64Compare opcode = null; |
14707
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
375 switch (kind) { |
14962
e4a5b8904695
Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14949
diff
changeset
|
376 case Byte: |
e4a5b8904695
Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14949
diff
changeset
|
377 case Boolean: |
e4a5b8904695
Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14949
diff
changeset
|
378 opcode = BCMP; |
e4a5b8904695
Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14949
diff
changeset
|
379 break; |
e4a5b8904695
Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14949
diff
changeset
|
380 case Short: |
e4a5b8904695
Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14949
diff
changeset
|
381 case Char: |
e4a5b8904695
Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14949
diff
changeset
|
382 opcode = SCMP; |
e4a5b8904695
Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14949
diff
changeset
|
383 break; |
14707
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
384 case Int: |
14931
d45e8c306349
use MemOp as base class for new memory ops
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14859
diff
changeset
|
385 opcode = ICMP; |
14707
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
386 break; |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
387 case Long: |
14931
d45e8c306349
use MemOp as base class for new memory ops
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14859
diff
changeset
|
388 opcode = LCMP; |
14707
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
389 break; |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
390 case Object: |
14931
d45e8c306349
use MemOp as base class for new memory ops
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14859
diff
changeset
|
391 opcode = ACMP; |
14707
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
392 break; |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
393 case Float: |
14931
d45e8c306349
use MemOp as base class for new memory ops
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14859
diff
changeset
|
394 opcode = FCMP; |
14707
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
395 break; |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
396 case Double: |
14931
d45e8c306349
use MemOp as base class for new memory ops
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14859
diff
changeset
|
397 opcode = DCMP; |
14707
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
398 break; |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
399 default: |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
400 throw GraalInternalError.shouldNotReachHere(); |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
401 } |
14931
d45e8c306349
use MemOp as base class for new memory ops
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14859
diff
changeset
|
402 append(new CompareMemoryOp(opcode, kind, address, value, state)); |
14707
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
403 } |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
404 |
5406
ae759e820ce7
AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents:
5402
diff
changeset
|
405 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
406 * This method emits the compare instruction, and may reorder the operands. It returns true if |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
407 * it did so. |
14850 | 408 * |
5406
ae759e820ce7
AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents:
5402
diff
changeset
|
409 * @param a the left operand of the comparison |
ae759e820ce7
AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents:
5402
diff
changeset
|
410 * @param b the right operand of the comparison |
ae759e820ce7
AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents:
5402
diff
changeset
|
411 * @return true if the left and right operands were switched, false otherwise |
ae759e820ce7
AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents:
5402
diff
changeset
|
412 */ |
16104
4dd2cedc7f57
Revert using LIRKind.reference(Kind.Int) instead of hotspot specific NarrowOop kind (part of c0b8d395368b).
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
413 private boolean emitCompare(PlatformKind cmpKind, Value a, Value b) { |
5406
ae759e820ce7
AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents:
5402
diff
changeset
|
414 Variable left; |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
415 Value right; |
5406
ae759e820ce7
AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents:
5402
diff
changeset
|
416 boolean mirrored; |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5546
diff
changeset
|
417 if (LIRValueUtil.isVariable(b)) { |
5406
ae759e820ce7
AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents:
5402
diff
changeset
|
418 left = load(b); |
ae759e820ce7
AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents:
5402
diff
changeset
|
419 right = loadNonConst(a); |
ae759e820ce7
AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents:
5402
diff
changeset
|
420 mirrored = true; |
ae759e820ce7
AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents:
5402
diff
changeset
|
421 } else { |
ae759e820ce7
AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents:
5402
diff
changeset
|
422 left = load(a); |
ae759e820ce7
AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents:
5402
diff
changeset
|
423 right = loadNonConst(b); |
ae759e820ce7
AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents:
5402
diff
changeset
|
424 mirrored = false; |
ae759e820ce7
AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents:
5402
diff
changeset
|
425 } |
14962
e4a5b8904695
Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14949
diff
changeset
|
426 emitCompareOp(cmpKind, left, right); |
5406
ae759e820ce7
AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents:
5402
diff
changeset
|
427 return mirrored; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
428 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
429 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
430 @Override |
7910
748cb57f53cb
Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7909
diff
changeset
|
431 public Variable emitNegate(Value inputVal) { |
748cb57f53cb
Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7909
diff
changeset
|
432 AllocatableValue input = asAllocatable(inputVal); |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
433 Variable result = newVariable(LIRKind.derive(input)); |
6329
92bc58dc5b5e
More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5798
diff
changeset
|
434 switch (input.getKind()) { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
435 case Int: |
7910
748cb57f53cb
Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7909
diff
changeset
|
436 append(new Unary1Op(INEG, result, input)); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
437 break; |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
438 case Long: |
7910
748cb57f53cb
Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7909
diff
changeset
|
439 append(new Unary1Op(LNEG, result, input)); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
440 break; |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
441 case Float: |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
17314
diff
changeset
|
442 append(new BinaryRegConst(FXOR, result, input, JavaConstant.forFloat(Float.intBitsToFloat(0x80000000)))); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
443 break; |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
444 case Double: |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
17314
diff
changeset
|
445 append(new BinaryRegConst(DXOR, result, input, JavaConstant.forDouble(Double.longBitsToDouble(0x8000000000000000L)))); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
446 break; |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
447 default: |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
448 throw GraalInternalError.shouldNotReachHere(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
449 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
450 return result; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
451 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
452 |
11355
01269a181628
add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents:
11290
diff
changeset
|
453 @Override |
01269a181628
add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents:
11290
diff
changeset
|
454 public Variable emitNot(Value inputVal) { |
01269a181628
add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents:
11290
diff
changeset
|
455 AllocatableValue input = asAllocatable(inputVal); |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
456 Variable result = newVariable(LIRKind.derive(input)); |
11355
01269a181628
add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents:
11290
diff
changeset
|
457 switch (input.getKind()) { |
01269a181628
add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents:
11290
diff
changeset
|
458 case Int: |
01269a181628
add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents:
11290
diff
changeset
|
459 append(new Unary1Op(INOT, result, input)); |
01269a181628
add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents:
11290
diff
changeset
|
460 break; |
01269a181628
add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents:
11290
diff
changeset
|
461 case Long: |
01269a181628
add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents:
11290
diff
changeset
|
462 append(new Unary1Op(LNOT, result, input)); |
01269a181628
add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents:
11290
diff
changeset
|
463 break; |
01269a181628
add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents:
11290
diff
changeset
|
464 default: |
01269a181628
add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents:
11290
diff
changeset
|
465 throw GraalInternalError.shouldNotReachHere(); |
01269a181628
add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents:
11290
diff
changeset
|
466 } |
01269a181628
add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents:
11290
diff
changeset
|
467 return result; |
01269a181628
add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents:
11290
diff
changeset
|
468 } |
01269a181628
add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents:
11290
diff
changeset
|
469 |
7919
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
470 private Variable emitBinary(AMD64Arithmetic op, boolean commutative, Value a, Value b) { |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
471 if (isConstant(b)) { |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
472 return emitBinaryConst(op, commutative, asAllocatable(a), asConstant(b)); |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
473 } else if (commutative && isConstant(a)) { |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
474 return emitBinaryConst(op, commutative, asAllocatable(b), asConstant(a)); |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
475 } else { |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
476 return emitBinaryVar(op, commutative, asAllocatable(a), asAllocatable(b)); |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
477 } |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
478 } |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
479 |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
17314
diff
changeset
|
480 private Variable emitBinaryConst(AMD64Arithmetic op, boolean commutative, AllocatableValue a, JavaConstant b) { |
7919
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
481 switch (op) { |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
482 case IADD: |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
483 case LADD: |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
484 case ISUB: |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
485 case LSUB: |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
486 case IAND: |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
487 case LAND: |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
488 case IOR: |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
489 case LOR: |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
490 case IXOR: |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
491 case LXOR: |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
492 if (NumUtil.isInt(b.asLong())) { |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
493 Variable result = newVariable(LIRKind.derive(a, b)); |
7919
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
494 append(new BinaryRegConst(op, result, a, b)); |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
495 return result; |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
496 } |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
497 break; |
7919
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
498 |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
499 case IMUL: |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
500 case LMUL: |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
501 if (NumUtil.isInt(b.asLong())) { |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
502 Variable result = newVariable(LIRKind.derive(a, b)); |
7919
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
503 append(new BinaryRegStackConst(op, result, a, b)); |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
504 return result; |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
505 } |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
506 break; |
7919
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
507 } |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
508 |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
509 return emitBinaryVar(op, commutative, a, asAllocatable(b)); |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
510 } |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
511 |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
512 private Variable emitBinaryVar(AMD64Arithmetic op, boolean commutative, AllocatableValue a, AllocatableValue b) { |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
513 Variable result = newVariable(LIRKind.derive(a, b)); |
7919
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
514 if (commutative) { |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
515 append(new BinaryCommutative(op, result, a, b)); |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
516 } else { |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
517 append(new BinaryRegStack(op, result, a, b)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
518 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
519 return result; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
520 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
521 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
522 @Override |
18843
5e80dd2f1783
Extend emitMul, emitAdd and emitSub in ArithmeticLIRGenerator for explicitly requesting to set the flags register. (In AMD64 flags are set implicitly, but on SPARC it is not)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18436
diff
changeset
|
523 public Variable emitAdd(Value a, Value b, boolean setFlags) { |
10428
6188764e66af
Use stack kind to determine instruction in AMD64LIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
10086
diff
changeset
|
524 switch (a.getKind().getStackKind()) { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
525 case Int: |
7919
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
526 return emitBinary(IADD, true, a, b); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
527 case Long: |
7919
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
528 return emitBinary(LADD, true, a, b); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
529 case Float: |
7919
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
530 return emitBinary(FADD, true, a, b); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
531 case Double: |
7919
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
532 return emitBinary(DADD, true, a, b); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
533 default: |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
534 throw GraalInternalError.shouldNotReachHere(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
535 } |
7919
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
536 } |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
537 |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
538 @Override |
18843
5e80dd2f1783
Extend emitMul, emitAdd and emitSub in ArithmeticLIRGenerator for explicitly requesting to set the flags register. (In AMD64 flags are set implicitly, but on SPARC it is not)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18436
diff
changeset
|
539 public Variable emitSub(Value a, Value b, boolean setFlags) { |
10428
6188764e66af
Use stack kind to determine instruction in AMD64LIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
10086
diff
changeset
|
540 switch (a.getKind().getStackKind()) { |
7919
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
541 case Int: |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
542 return emitBinary(ISUB, false, a, b); |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
543 case Long: |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
544 return emitBinary(LSUB, false, a, b); |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
545 case Float: |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
546 return emitBinary(FSUB, false, a, b); |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
547 case Double: |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
548 return emitBinary(DSUB, false, a, b); |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
549 default: |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
550 throw GraalInternalError.shouldNotReachHere(); |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
551 } |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
552 } |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
553 |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
554 @Override |
18843
5e80dd2f1783
Extend emitMul, emitAdd and emitSub in ArithmeticLIRGenerator for explicitly requesting to set the flags register. (In AMD64 flags are set implicitly, but on SPARC it is not)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18436
diff
changeset
|
555 public Variable emitMul(Value a, Value b, boolean setFlags) { |
10428
6188764e66af
Use stack kind to determine instruction in AMD64LIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
10086
diff
changeset
|
556 switch (a.getKind().getStackKind()) { |
7919
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
557 case Int: |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
558 return emitBinary(IMUL, true, a, b); |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
559 case Long: |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
560 return emitBinary(LMUL, true, a, b); |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
561 case Float: |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
562 return emitBinary(FMUL, true, a, b); |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
563 case Double: |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
564 return emitBinary(DMUL, true, a, b); |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
565 default: |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
566 throw GraalInternalError.shouldNotReachHere(); |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
567 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
568 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
569 |
15691
6a13c422fca4
API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
15522
diff
changeset
|
570 private Value emitMulHigh(AMD64Arithmetic opcode, Value a, Value b) { |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
571 MulHighOp mulHigh = new MulHighOp(opcode, LIRKind.derive(a, b), asAllocatable(b)); |
15691
6a13c422fca4
API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
15522
diff
changeset
|
572 emitMove(mulHigh.x, a); |
6a13c422fca4
API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
15522
diff
changeset
|
573 append(mulHigh); |
6a13c422fca4
API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
15522
diff
changeset
|
574 return emitMove(mulHigh.highResult); |
6a13c422fca4
API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
15522
diff
changeset
|
575 } |
6a13c422fca4
API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
15522
diff
changeset
|
576 |
6a13c422fca4
API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
15522
diff
changeset
|
577 @Override |
6a13c422fca4
API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
15522
diff
changeset
|
578 public Value emitMulHigh(Value a, Value b) { |
6a13c422fca4
API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
15522
diff
changeset
|
579 switch (a.getKind().getStackKind()) { |
6a13c422fca4
API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
15522
diff
changeset
|
580 case Int: |
6a13c422fca4
API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
15522
diff
changeset
|
581 return emitMulHigh(IMUL, a, b); |
6a13c422fca4
API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
15522
diff
changeset
|
582 case Long: |
6a13c422fca4
API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
15522
diff
changeset
|
583 return emitMulHigh(LMUL, a, b); |
6a13c422fca4
API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
15522
diff
changeset
|
584 default: |
6a13c422fca4
API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
15522
diff
changeset
|
585 throw GraalInternalError.shouldNotReachHere(); |
6a13c422fca4
API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
15522
diff
changeset
|
586 } |
6a13c422fca4
API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
15522
diff
changeset
|
587 } |
6a13c422fca4
API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
15522
diff
changeset
|
588 |
6a13c422fca4
API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
15522
diff
changeset
|
589 @Override |
6a13c422fca4
API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
15522
diff
changeset
|
590 public Value emitUMulHigh(Value a, Value b) { |
6a13c422fca4
API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
15522
diff
changeset
|
591 switch (a.getKind().getStackKind()) { |
6a13c422fca4
API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
15522
diff
changeset
|
592 case Int: |
6a13c422fca4
API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
15522
diff
changeset
|
593 return emitMulHigh(IUMUL, a, b); |
6a13c422fca4
API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
15522
diff
changeset
|
594 case Long: |
6a13c422fca4
API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
15522
diff
changeset
|
595 return emitMulHigh(LUMUL, a, b); |
6a13c422fca4
API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
15522
diff
changeset
|
596 default: |
6a13c422fca4
API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
15522
diff
changeset
|
597 throw GraalInternalError.shouldNotReachHere(); |
6a13c422fca4
API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
15522
diff
changeset
|
598 } |
6a13c422fca4
API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
15522
diff
changeset
|
599 } |
6a13c422fca4
API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents:
15522
diff
changeset
|
600 |
15522
589c3627fab8
special cases for addresses involving compressed references
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15370
diff
changeset
|
601 public Value emitBinaryMemory(AMD64Arithmetic op, Kind kind, AllocatableValue a, AMD64AddressValue location, LIRFrameState state) { |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
602 Variable result = newVariable(LIRKind.derive(a)); |
14707
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
603 append(new BinaryMemory(op, kind, result, a, location, state)); |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
604 return result; |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
605 } |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
606 |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
607 protected Value emitConvert2MemoryOp(PlatformKind kind, AMD64Arithmetic op, AMD64AddressValue address, LIRFrameState state) { |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16092
diff
changeset
|
608 Variable result = newVariable(LIRKind.value(kind)); |
14931
d45e8c306349
use MemOp as base class for new memory ops
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14859
diff
changeset
|
609 append(new Unary2MemoryOp(op, result, (Kind) null, address, state)); |
14707
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
610 return result; |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
611 } |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
612 |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
613 protected Value emitZeroExtendMemory(Kind memoryKind, int resultBits, AMD64AddressValue address, LIRFrameState state) { |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
614 // Issue a zero extending load of the proper bit size and set the result to |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
615 // the proper kind. |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16092
diff
changeset
|
616 Variable result = newVariable(LIRKind.value(resultBits == 32 ? Kind.Int : Kind.Long)); |
14859 | 617 append(new ZeroExtendLoadOp(memoryKind, result, address, state)); |
14707
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
618 return result; |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
619 } |
6ce6c4ccba8f
initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14633
diff
changeset
|
620 |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
621 private DivRemOp emitDivRem(AMD64Arithmetic op, Value a, Value b, LIRFrameState state) { |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16092
diff
changeset
|
622 AllocatableValue rax = AMD64.rax.asValue(a.getLIRKind()); |
7920
2e3e4b691835
Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents:
7919
diff
changeset
|
623 emitMove(rax, a); |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
624 DivRemOp ret = new DivRemOp(op, rax, asAllocatable(b), state); |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
625 append(ret); |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
626 return ret; |
7920
2e3e4b691835
Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents:
7919
diff
changeset
|
627 } |
2e3e4b691835
Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents:
7919
diff
changeset
|
628 |
15301
468b2428c403
Change DeoptimizingNode and Access to LIRFrameState in *LIRGenerator*.
Josef Eisl <josef.eisl@jku.at>
parents:
15297
diff
changeset
|
629 public Value[] emitIntegerDivRem(Value a, Value b, LIRFrameState state) { |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
630 DivRemOp op; |
10428
6188764e66af
Use stack kind to determine instruction in AMD64LIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
10086
diff
changeset
|
631 switch (a.getKind().getStackKind()) { |
7380
3207ee96b659
Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7328
diff
changeset
|
632 case Int: |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
633 op = emitDivRem(IDIVREM, a, b, state); |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
634 break; |
7380
3207ee96b659
Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7328
diff
changeset
|
635 case Long: |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
636 op = emitDivRem(LDIVREM, a, b, state); |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
637 break; |
7380
3207ee96b659
Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7328
diff
changeset
|
638 default: |
3207ee96b659
Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7328
diff
changeset
|
639 throw GraalInternalError.shouldNotReachHere(); |
3207ee96b659
Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7328
diff
changeset
|
640 } |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
641 return new Value[]{emitMove(op.divResult), emitMove(op.remResult)}; |
7380
3207ee96b659
Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7328
diff
changeset
|
642 } |
3207ee96b659
Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7328
diff
changeset
|
643 |
3207ee96b659
Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7328
diff
changeset
|
644 @Override |
15301
468b2428c403
Change DeoptimizingNode and Access to LIRFrameState in *LIRGenerator*.
Josef Eisl <josef.eisl@jku.at>
parents:
15297
diff
changeset
|
645 public Value emitDiv(Value a, Value b, LIRFrameState state) { |
10428
6188764e66af
Use stack kind to determine instruction in AMD64LIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
10086
diff
changeset
|
646 switch (a.getKind().getStackKind()) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
647 case Int: |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
648 DivRemOp op = emitDivRem(IDIV, a, b, state); |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
649 return emitMove(op.divResult); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
650 case Long: |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
651 DivRemOp lop = emitDivRem(LDIV, a, b, state); |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
652 return emitMove(lop.divResult); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
653 case Float: { |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
654 Variable result = newVariable(LIRKind.derive(a, b)); |
7919
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
655 append(new BinaryRegStack(FDIV, result, asAllocatable(a), asAllocatable(b))); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
656 return result; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
657 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
658 case Double: { |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
659 Variable result = newVariable(LIRKind.derive(a, b)); |
7919
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
660 append(new BinaryRegStack(DDIV, result, asAllocatable(a), asAllocatable(b))); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
661 return result; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
662 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
663 default: |
4524
dcc8f5c6f394
Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4522
diff
changeset
|
664 throw GraalInternalError.shouldNotReachHere(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
665 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
666 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
667 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
668 @Override |
15301
468b2428c403
Change DeoptimizingNode and Access to LIRFrameState in *LIRGenerator*.
Josef Eisl <josef.eisl@jku.at>
parents:
15297
diff
changeset
|
669 public Value emitRem(Value a, Value b, LIRFrameState state) { |
10428
6188764e66af
Use stack kind to determine instruction in AMD64LIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
10086
diff
changeset
|
670 switch (a.getKind().getStackKind()) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
671 case Int: |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
672 DivRemOp op = emitDivRem(IREM, a, b, state); |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
673 return emitMove(op.remResult); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
674 case Long: |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
675 DivRemOp lop = emitDivRem(LREM, a, b, state); |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
676 return emitMove(lop.remResult); |
6521
2a0c9f20baa1
consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
6496
diff
changeset
|
677 case Float: { |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
678 Variable result = newVariable(LIRKind.derive(a, b)); |
9581
d84ea522800e
replaced arithmetic_[fd]rem stubs with inline compiled code (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9431
diff
changeset
|
679 append(new FPDivRemOp(FREM, result, load(a), load(b))); |
d84ea522800e
replaced arithmetic_[fd]rem stubs with inline compiled code (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9431
diff
changeset
|
680 return result; |
6521
2a0c9f20baa1
consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
6496
diff
changeset
|
681 } |
2a0c9f20baa1
consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
6496
diff
changeset
|
682 case Double: { |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
683 Variable result = newVariable(LIRKind.derive(a, b)); |
9581
d84ea522800e
replaced arithmetic_[fd]rem stubs with inline compiled code (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9431
diff
changeset
|
684 append(new FPDivRemOp(DREM, result, load(a), load(b))); |
d84ea522800e
replaced arithmetic_[fd]rem stubs with inline compiled code (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9431
diff
changeset
|
685 return result; |
6521
2a0c9f20baa1
consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
6496
diff
changeset
|
686 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
687 default: |
4524
dcc8f5c6f394
Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4522
diff
changeset
|
688 throw GraalInternalError.shouldNotReachHere(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
689 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
690 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
691 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
692 @Override |
15301
468b2428c403
Change DeoptimizingNode and Access to LIRFrameState in *LIRGenerator*.
Josef Eisl <josef.eisl@jku.at>
parents:
15297
diff
changeset
|
693 public Variable emitUDiv(Value a, Value b, LIRFrameState state) { |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
694 DivRemOp op; |
10428
6188764e66af
Use stack kind to determine instruction in AMD64LIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
10086
diff
changeset
|
695 switch (a.getKind().getStackKind()) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
696 case Int: |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
697 op = emitDivRem(IUDIV, a, b, state); |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
698 break; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
699 case Long: |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
700 op = emitDivRem(LUDIV, a, b, state); |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
701 break; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
702 default: |
4524
dcc8f5c6f394
Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4522
diff
changeset
|
703 throw GraalInternalError.shouldNotReachHere(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
704 } |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
705 return emitMove(op.divResult); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
706 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
707 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
708 @Override |
15301
468b2428c403
Change DeoptimizingNode and Access to LIRFrameState in *LIRGenerator*.
Josef Eisl <josef.eisl@jku.at>
parents:
15297
diff
changeset
|
709 public Variable emitURem(Value a, Value b, LIRFrameState state) { |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
710 DivRemOp op; |
10428
6188764e66af
Use stack kind to determine instruction in AMD64LIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
10086
diff
changeset
|
711 switch (a.getKind().getStackKind()) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
712 case Int: |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
713 op = emitDivRem(IUREM, a, b, state); |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
714 break; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
715 case Long: |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
716 op = emitDivRem(LUREM, a, b, state); |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
717 break; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
718 default: |
4524
dcc8f5c6f394
Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4522
diff
changeset
|
719 throw GraalInternalError.shouldNotReachHere(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
720 } |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
721 return emitMove(op.remResult); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
722 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
723 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
724 @Override |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
725 public Variable emitAnd(Value a, Value b) { |
10428
6188764e66af
Use stack kind to determine instruction in AMD64LIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
10086
diff
changeset
|
726 switch (a.getKind().getStackKind()) { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
727 case Int: |
7919
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
728 return emitBinary(IAND, true, a, b); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
729 case Long: |
7919
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
730 return emitBinary(LAND, true, a, b); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
731 default: |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
732 throw GraalInternalError.shouldNotReachHere(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
733 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
734 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
735 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
736 @Override |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
737 public Variable emitOr(Value a, Value b) { |
10428
6188764e66af
Use stack kind to determine instruction in AMD64LIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
10086
diff
changeset
|
738 switch (a.getKind().getStackKind()) { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
739 case Int: |
7919
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
740 return emitBinary(IOR, true, a, b); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
741 case Long: |
7919
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
742 return emitBinary(LOR, true, a, b); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
743 default: |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
744 throw GraalInternalError.shouldNotReachHere(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
745 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
746 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
747 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
748 @Override |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
749 public Variable emitXor(Value a, Value b) { |
10428
6188764e66af
Use stack kind to determine instruction in AMD64LIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
10086
diff
changeset
|
750 switch (a.getKind().getStackKind()) { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
751 case Int: |
7919
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
752 return emitBinary(IXOR, true, a, b); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
753 case Long: |
7919
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
754 return emitBinary(LXOR, true, a, b); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
755 default: |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
756 throw GraalInternalError.shouldNotReachHere(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
757 } |
7919
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
758 } |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
759 |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
760 private Variable emitShift(AMD64Arithmetic op, Value a, Value b) { |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
761 Variable result = newVariable(LIRKind.derive(a, b).changeType(a.getPlatformKind())); |
7919
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
762 AllocatableValue input = asAllocatable(a); |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
763 if (isConstant(b)) { |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
764 append(new BinaryRegConst(op, result, input, asConstant(b))); |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
765 } else { |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
766 emitMove(RCX_I, b); |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
767 append(new BinaryRegReg(op, result, input, RCX_I)); |
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
768 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
769 return result; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
770 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
771 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
772 @Override |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
773 public Variable emitShl(Value a, Value b) { |
10428
6188764e66af
Use stack kind to determine instruction in AMD64LIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
10086
diff
changeset
|
774 switch (a.getKind().getStackKind()) { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
775 case Int: |
7919
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
776 return emitShift(ISHL, a, b); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
777 case Long: |
7919
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
778 return emitShift(LSHL, a, b); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
779 default: |
7919
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
780 throw GraalInternalError.shouldNotReachHere(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
781 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
782 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
783 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
784 @Override |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
785 public Variable emitShr(Value a, Value b) { |
10428
6188764e66af
Use stack kind to determine instruction in AMD64LIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
10086
diff
changeset
|
786 switch (a.getKind().getStackKind()) { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
787 case Int: |
7919
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
788 return emitShift(ISHR, a, b); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
789 case Long: |
7919
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
790 return emitShift(LSHR, a, b); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
791 default: |
7919
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
792 throw GraalInternalError.shouldNotReachHere(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
793 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
794 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
795 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
796 @Override |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
797 public Variable emitUShr(Value a, Value b) { |
10428
6188764e66af
Use stack kind to determine instruction in AMD64LIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
10086
diff
changeset
|
798 switch (a.getKind().getStackKind()) { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
799 case Int: |
7919
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
800 return emitShift(IUSHR, a, b); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
801 case Long: |
7919
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
802 return emitShift(LUSHR, a, b); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
803 default: |
7919
0ae70d44ec9a
Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
7910
diff
changeset
|
804 throw GraalInternalError.shouldNotReachHere(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
805 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
806 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
807 |
15370
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
808 public Variable emitRol(Value a, Value b) { |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
809 switch (a.getKind().getStackKind()) { |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
810 case Int: |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
811 return emitShift(IROL, a, b); |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
812 case Long: |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
813 return emitShift(LROL, a, b); |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
814 default: |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
815 throw GraalInternalError.shouldNotReachHere(); |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
816 } |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
817 } |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
818 |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
819 public Variable emitRor(Value a, Value b) { |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
820 switch (a.getKind().getStackKind()) { |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
821 case Int: |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
822 return emitShift(IROR, a, b); |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
823 case Long: |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
824 return emitShift(LROR, a, b); |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
825 default: |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
826 throw GraalInternalError.shouldNotReachHere(); |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
827 } |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
828 } |
319deee16746
add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15301
diff
changeset
|
829 |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16092
diff
changeset
|
830 private AllocatableValue emitConvert2RegOp(LIRKind kind, AMD64Arithmetic op, AllocatableValue input) { |
12656
9334392ed279
Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
12604
diff
changeset
|
831 Variable result = newVariable(kind); |
15278
3ef4196cf8e5
use movl instead of andl for L2I
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15261
diff
changeset
|
832 append(new Unary2RegOp(op, result, input)); |
12656
9334392ed279
Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
12604
diff
changeset
|
833 return result; |
9334392ed279
Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
12604
diff
changeset
|
834 } |
9334392ed279
Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
12604
diff
changeset
|
835 |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16092
diff
changeset
|
836 private AllocatableValue emitConvert2Op(LIRKind kind, AMD64Arithmetic op, AllocatableValue input) { |
12656
9334392ed279
Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
12604
diff
changeset
|
837 Variable result = newVariable(kind); |
9334392ed279
Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
12604
diff
changeset
|
838 append(new Unary2Op(op, result, input)); |
9334392ed279
Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
12604
diff
changeset
|
839 return result; |
9334392ed279
Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
12604
diff
changeset
|
840 } |
9334392ed279
Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
12604
diff
changeset
|
841 |
14003
0c38906450a0
Make conversion from Stamp to PlatformKind extensible by backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14001
diff
changeset
|
842 @Override |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16092
diff
changeset
|
843 public Value emitReinterpret(LIRKind to, Value inputVal) { |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16092
diff
changeset
|
844 LIRKind from = inputVal.getLIRKind(); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16092
diff
changeset
|
845 if (to.equals(from)) { |
14009
384d7fc0e27b
Ignore reinterpret in backend if the new Stamp has the same PlatformKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
846 return inputVal; |
384d7fc0e27b
Ignore reinterpret in backend if the new Stamp has the same PlatformKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
847 } |
384d7fc0e27b
Ignore reinterpret in backend if the new Stamp has the same PlatformKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
14003
diff
changeset
|
848 |
12656
9334392ed279
Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
12604
diff
changeset
|
849 AllocatableValue input = asAllocatable(inputVal); |
13134
6217f601e65d
Allow addresses with an arbitrary scale value; fix handling of unsigned int-to-long conversion
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12695
diff
changeset
|
850 /* |
6217f601e65d
Allow addresses with an arbitrary scale value; fix handling of unsigned int-to-long conversion
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12695
diff
changeset
|
851 * Conversions between integer to floating point types require moves between CPU and FPU |
6217f601e65d
Allow addresses with an arbitrary scale value; fix handling of unsigned int-to-long conversion
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12695
diff
changeset
|
852 * registers. |
6217f601e65d
Allow addresses with an arbitrary scale value; fix handling of unsigned int-to-long conversion
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12695
diff
changeset
|
853 */ |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16092
diff
changeset
|
854 Kind fromKind = (Kind) from.getPlatformKind(); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16092
diff
changeset
|
855 switch ((Kind) to.getPlatformKind()) { |
12656
9334392ed279
Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
12604
diff
changeset
|
856 case Int: |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16092
diff
changeset
|
857 switch (fromKind) { |
12656
9334392ed279
Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
12604
diff
changeset
|
858 case Float: |
9334392ed279
Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
12604
diff
changeset
|
859 return emitConvert2Op(to, MOV_F2I, input); |
9334392ed279
Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
12604
diff
changeset
|
860 } |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7380
diff
changeset
|
861 break; |
12656
9334392ed279
Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
12604
diff
changeset
|
862 case Long: |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16092
diff
changeset
|
863 switch (fromKind) { |
12656
9334392ed279
Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
12604
diff
changeset
|
864 case Double: |
9334392ed279
Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
12604
diff
changeset
|
865 return emitConvert2Op(to, MOV_D2L, input); |
9334392ed279
Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
12604
diff
changeset
|
866 } |
9334392ed279
Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
12604
diff
changeset
|
867 break; |
9334392ed279
Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
12604
diff
changeset
|
868 case Float: |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16092
diff
changeset
|
869 switch (fromKind) { |
12656
9334392ed279
Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
12604
diff
changeset
|
870 case Int: |
9334392ed279
Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
12604
diff
changeset
|
871 return emitConvert2Op(to, MOV_I2F, input); |
9334392ed279
Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
12604
diff
changeset
|
872 } |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7280
diff
changeset
|
873 break; |
12656
9334392ed279
Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
12604
diff
changeset
|
874 case Double: |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16092
diff
changeset
|
875 switch (fromKind) { |
12656
9334392ed279
Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
12604
diff
changeset
|
876 case Long: |
9334392ed279
Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
12604
diff
changeset
|
877 return emitConvert2Op(to, MOV_L2D, input); |
9334392ed279
Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
12604
diff
changeset
|
878 } |
9334392ed279
Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
12604
diff
changeset
|
879 break; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
880 } |
13134
6217f601e65d
Allow addresses with an arbitrary scale value; fix handling of unsigned int-to-long conversion
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12695
diff
changeset
|
881 throw GraalInternalError.shouldNotReachHere(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
882 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
883 |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
884 public Value emitFloatConvert(FloatConvert op, Value inputVal) { |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
885 AllocatableValue input = asAllocatable(inputVal); |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
886 switch (op) { |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
887 case D2F: |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
888 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:
13999
diff
changeset
|
889 case D2I: |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
890 return emitConvert2Op(LIRKind.derive(inputVal).changeType(Kind.Int), D2I, input); |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
891 case D2L: |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
892 return emitConvert2Op(LIRKind.derive(inputVal).changeType(Kind.Long), D2L, input); |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
893 case F2D: |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
894 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:
13999
diff
changeset
|
895 case F2I: |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
896 return emitConvert2Op(LIRKind.derive(inputVal).changeType(Kind.Int), F2I, input); |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
897 case F2L: |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
898 return emitConvert2Op(LIRKind.derive(inputVal).changeType(Kind.Long), F2L, input); |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
899 case I2D: |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
900 return emitConvert2Op(LIRKind.derive(inputVal).changeType(Kind.Double), I2D, input); |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
901 case I2F: |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
902 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:
13999
diff
changeset
|
903 case L2D: |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
904 return emitConvert2Op(LIRKind.derive(inputVal).changeType(Kind.Double), L2D, input); |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
905 case L2F: |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
906 return emitConvert2Op(LIRKind.derive(inputVal).changeType(Kind.Float), L2F, input); |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
907 default: |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
908 throw GraalInternalError.shouldNotReachHere(); |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
909 } |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
910 } |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
911 |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
912 @Override |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
913 public Value emitNarrow(Value inputVal, int bits) { |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
914 if (inputVal.getKind() == Kind.Long && bits <= 32) { |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
915 // TODO make it possible to reinterpret Long as Int in LIR without move |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
916 return emitConvert2RegOp(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:
13999
diff
changeset
|
917 } else { |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
918 return inputVal; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
919 } |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
920 } |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
921 |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
922 @Override |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
923 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:
13999
diff
changeset
|
924 assert fromBits <= toBits && toBits <= 64; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
925 if (fromBits == toBits) { |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
926 return inputVal; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
927 } else if (toBits > 32) { |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
928 // sign extend to 64 bits |
14001
79114edb5130
Explicit x2L instructions in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14000
diff
changeset
|
929 switch (fromBits) { |
79114edb5130
Explicit x2L instructions in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14000
diff
changeset
|
930 case 8: |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
931 return emitConvert2Op(LIRKind.derive(inputVal).changeType(Kind.Long), B2L, asAllocatable(inputVal)); |
14001
79114edb5130
Explicit x2L instructions in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14000
diff
changeset
|
932 case 16: |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
933 return emitConvert2Op(LIRKind.derive(inputVal).changeType(Kind.Long), S2L, asAllocatable(inputVal)); |
14001
79114edb5130
Explicit x2L instructions in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14000
diff
changeset
|
934 case 32: |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
935 return emitConvert2Op(LIRKind.derive(inputVal).changeType(Kind.Long), I2L, asAllocatable(inputVal)); |
14001
79114edb5130
Explicit x2L instructions in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14000
diff
changeset
|
936 default: |
79114edb5130
Explicit x2L instructions in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
14000
diff
changeset
|
937 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:
13999
diff
changeset
|
938 } |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
939 } else { |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
940 // 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:
13999
diff
changeset
|
941 switch (fromBits) { |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
942 case 8: |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
943 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:
13999
diff
changeset
|
944 case 16: |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
945 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:
13999
diff
changeset
|
946 case 32: |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
947 return inputVal; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
948 default: |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
949 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:
13999
diff
changeset
|
950 } |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
951 } |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
952 } |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
953 |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
954 @Override |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
955 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:
13999
diff
changeset
|
956 assert fromBits <= toBits && toBits <= 64; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
957 if (fromBits == toBits) { |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
958 return inputVal; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
959 } else if (fromBits > 32) { |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
960 assert inputVal.getKind() == Kind.Long; |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
961 Variable result = newVariable(LIRKind.derive(inputVal).changeType(Kind.Long)); |
17196
189479d72dc8
Move bit manipulation methods to CodeUtil class.
Roland Schatz <roland.schatz@oracle.com>
parents:
16346
diff
changeset
|
962 long mask = CodeUtil.mask(fromBits); |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
17314
diff
changeset
|
963 append(new BinaryRegConst(AMD64Arithmetic.LAND, result, asAllocatable(inputVal), JavaConstant.forLong(mask))); |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
964 return result; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
965 } else { |
14998
1c1818fb5ad1
Fix wrong assertion.
Roland Schatz <roland.schatz@oracle.com>
parents:
14962
diff
changeset
|
966 assert inputVal.getKind().getStackKind() == Kind.Int; |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
967 Variable result = newVariable(LIRKind.derive(inputVal).changeType(Kind.Int)); |
17196
189479d72dc8
Move bit manipulation methods to CodeUtil class.
Roland Schatz <roland.schatz@oracle.com>
parents:
16346
diff
changeset
|
968 int mask = (int) CodeUtil.mask(fromBits); |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
17314
diff
changeset
|
969 append(new BinaryRegConst(AMD64Arithmetic.IAND, result, asAllocatable(inputVal), JavaConstant.forInt(mask))); |
14000
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
970 if (toBits > 32) { |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
971 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:
13999
diff
changeset
|
972 emitMove(longResult, result); |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
973 return longResult; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
974 } else { |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
975 return result; |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
976 } |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
977 } |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
978 } |
958c99d0790c
Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents:
13999
diff
changeset
|
979 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
980 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
981 public void emitMembar(int barriers) { |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12363
diff
changeset
|
982 int necessaryBarriers = target().arch.requiredBarriers(barriers); |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12363
diff
changeset
|
983 if (target().isMP && necessaryBarriers != 0) { |
4323
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4314
diff
changeset
|
984 append(new MembarOp(necessaryBarriers)); |
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4314
diff
changeset
|
985 } |
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4314
diff
changeset
|
986 } |
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4314
diff
changeset
|
987 |
13837
ed3a1471e133
Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
13559
diff
changeset
|
988 public abstract void emitCCall(long address, CallingConvention nativeCallingConvention, Value[] args, int numberOfFloatingPointArguments); |
ed3a1471e133
Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
13559
diff
changeset
|
989 |
4323
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4314
diff
changeset
|
990 @Override |
18976
3faa4f98d5c8
renamed LIRGenerator.emitForeignCall to emitForeignCallOp to avoid confusion
Doug Simon <doug.simon@oracle.com>
parents:
18935
diff
changeset
|
991 protected void emitForeignCallOp(ForeignCallLinkage linkage, Value result, Value[] arguments, Value[] temps, LIRFrameState info) { |
9742
cff1e11941c0
moved temporaries from CallingConvention to ForeignCallLinkage
Doug Simon <doug.simon@oracle.com>
parents:
9739
diff
changeset
|
992 long maxOffset = linkage.getMaxCallTargetOffset(); |
8333
e9c6fc513719
Remove last usages of scratch register. Separate runtime calls from normal method calls in LIR.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8293
diff
changeset
|
993 if (maxOffset != (int) maxOffset) { |
13212
eb03a7335eb0
Use fixed instead of virtual register for target in far foreign call, since the register allocator does not support virtual registers to be used at call sites.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13134
diff
changeset
|
994 append(new AMD64Call.DirectFarForeignCallOp(linkage, result, arguments, temps, info)); |
4323
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4314
diff
changeset
|
995 } else { |
9744
8342b10b9cc3
rename: *RuntimeCallOp -> *ForeignCallOp
Doug Simon <doug.simon@oracle.com>
parents:
9742
diff
changeset
|
996 append(new AMD64Call.DirectNearForeignCallOp(linkage, result, arguments, temps, info)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
997 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
998 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
999 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1000 @Override |
16092
51ba6c521922
Refactor LIRGeneratorTool methods.
Roland Schatz <roland.schatz@oracle.com>
parents:
15947
diff
changeset
|
1001 public Value emitBitCount(Value value) { |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
1002 Variable result = newVariable(LIRKind.derive(value).changeType(Kind.Int)); |
7280
f368ec89e231
added intrinsifications for Integer.bitCount() and Long.bitCount()
Doug Simon <doug.simon@oracle.com>
parents:
7144
diff
changeset
|
1003 if (value.getKind().getStackKind() == Kind.Int) { |
7909
afb56ecdb083
Fix usage and operand flags of AMD64BitManipulationOp.
Roland Schatz <roland.schatz@oracle.com>
parents:
7884
diff
changeset
|
1004 append(new AMD64BitManipulationOp(IPOPCNT, result, asAllocatable(value))); |
7280
f368ec89e231
added intrinsifications for Integer.bitCount() and Long.bitCount()
Doug Simon <doug.simon@oracle.com>
parents:
7144
diff
changeset
|
1005 } else { |
7909
afb56ecdb083
Fix usage and operand flags of AMD64BitManipulationOp.
Roland Schatz <roland.schatz@oracle.com>
parents:
7884
diff
changeset
|
1006 append(new AMD64BitManipulationOp(LPOPCNT, result, asAllocatable(value))); |
7280
f368ec89e231
added intrinsifications for Integer.bitCount() and Long.bitCount()
Doug Simon <doug.simon@oracle.com>
parents:
7144
diff
changeset
|
1007 } |
16092
51ba6c521922
Refactor LIRGeneratorTool methods.
Roland Schatz <roland.schatz@oracle.com>
parents:
15947
diff
changeset
|
1008 return result; |
7280
f368ec89e231
added intrinsifications for Integer.bitCount() and Long.bitCount()
Doug Simon <doug.simon@oracle.com>
parents:
7144
diff
changeset
|
1009 } |
f368ec89e231
added intrinsifications for Integer.bitCount() and Long.bitCount()
Doug Simon <doug.simon@oracle.com>
parents:
7144
diff
changeset
|
1010 |
f368ec89e231
added intrinsifications for Integer.bitCount() and Long.bitCount()
Doug Simon <doug.simon@oracle.com>
parents:
7144
diff
changeset
|
1011 @Override |
16092
51ba6c521922
Refactor LIRGeneratorTool methods.
Roland Schatz <roland.schatz@oracle.com>
parents:
15947
diff
changeset
|
1012 public Value emitBitScanForward(Value value) { |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
1013 Variable result = newVariable(LIRKind.derive(value).changeType(Kind.Int)); |
7909
afb56ecdb083
Fix usage and operand flags of AMD64BitManipulationOp.
Roland Schatz <roland.schatz@oracle.com>
parents:
7884
diff
changeset
|
1014 append(new AMD64BitManipulationOp(BSF, result, asAllocatable(value))); |
16092
51ba6c521922
Refactor LIRGeneratorTool methods.
Roland Schatz <roland.schatz@oracle.com>
parents:
15947
diff
changeset
|
1015 return result; |
6496
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6493
diff
changeset
|
1016 } |
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6493
diff
changeset
|
1017 |
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6493
diff
changeset
|
1018 @Override |
16092
51ba6c521922
Refactor LIRGeneratorTool methods.
Roland Schatz <roland.schatz@oracle.com>
parents:
15947
diff
changeset
|
1019 public Value emitBitScanReverse(Value value) { |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
1020 Variable result = newVariable(LIRKind.derive(value).changeType(Kind.Int)); |
7098
e23980f4a890
Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7074
diff
changeset
|
1021 if (value.getKind().getStackKind() == Kind.Int) { |
7909
afb56ecdb083
Fix usage and operand flags of AMD64BitManipulationOp.
Roland Schatz <roland.schatz@oracle.com>
parents:
7884
diff
changeset
|
1022 append(new AMD64BitManipulationOp(IBSR, result, asAllocatable(value))); |
6496
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6493
diff
changeset
|
1023 } else { |
7909
afb56ecdb083
Fix usage and operand flags of AMD64BitManipulationOp.
Roland Schatz <roland.schatz@oracle.com>
parents:
7884
diff
changeset
|
1024 append(new AMD64BitManipulationOp(LBSR, result, asAllocatable(value))); |
6496
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6493
diff
changeset
|
1025 } |
16092
51ba6c521922
Refactor LIRGeneratorTool methods.
Roland Schatz <roland.schatz@oracle.com>
parents:
15947
diff
changeset
|
1026 return result; |
6496
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6493
diff
changeset
|
1027 } |
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6493
diff
changeset
|
1028 |
18415
6dc4f0be9a70
Add support of lzcnt and tzcnt
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
18358
diff
changeset
|
1029 public Value emitCountLeadingZeros(Value value) { |
6dc4f0be9a70
Add support of lzcnt and tzcnt
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
18358
diff
changeset
|
1030 Variable result = newVariable(LIRKind.derive(value).changeType(Kind.Int)); |
6dc4f0be9a70
Add support of lzcnt and tzcnt
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
18358
diff
changeset
|
1031 if (value.getKind().getStackKind() == Kind.Int) { |
6dc4f0be9a70
Add support of lzcnt and tzcnt
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
18358
diff
changeset
|
1032 append(new AMD64BitManipulationOp(ILZCNT, result, asAllocatable(value))); |
6dc4f0be9a70
Add support of lzcnt and tzcnt
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
18358
diff
changeset
|
1033 } else { |
6dc4f0be9a70
Add support of lzcnt and tzcnt
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
18358
diff
changeset
|
1034 append(new AMD64BitManipulationOp(LLZCNT, result, asAllocatable(value))); |
6dc4f0be9a70
Add support of lzcnt and tzcnt
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
18358
diff
changeset
|
1035 } |
6dc4f0be9a70
Add support of lzcnt and tzcnt
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
18358
diff
changeset
|
1036 return result; |
6dc4f0be9a70
Add support of lzcnt and tzcnt
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
18358
diff
changeset
|
1037 } |
6dc4f0be9a70
Add support of lzcnt and tzcnt
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
18358
diff
changeset
|
1038 |
6dc4f0be9a70
Add support of lzcnt and tzcnt
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
18358
diff
changeset
|
1039 public Value emitCountTrailingZeros(Value value) { |
6dc4f0be9a70
Add support of lzcnt and tzcnt
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
18358
diff
changeset
|
1040 Variable result = newVariable(LIRKind.derive(value).changeType(Kind.Int)); |
6dc4f0be9a70
Add support of lzcnt and tzcnt
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
18358
diff
changeset
|
1041 if (value.getKind().getStackKind() == Kind.Int) { |
6dc4f0be9a70
Add support of lzcnt and tzcnt
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
18358
diff
changeset
|
1042 append(new AMD64BitManipulationOp(ITZCNT, result, asAllocatable(value))); |
6dc4f0be9a70
Add support of lzcnt and tzcnt
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
18358
diff
changeset
|
1043 } else { |
6dc4f0be9a70
Add support of lzcnt and tzcnt
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
18358
diff
changeset
|
1044 append(new AMD64BitManipulationOp(LTZCNT, result, asAllocatable(value))); |
6dc4f0be9a70
Add support of lzcnt and tzcnt
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
18358
diff
changeset
|
1045 } |
6dc4f0be9a70
Add support of lzcnt and tzcnt
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
18358
diff
changeset
|
1046 return result; |
6dc4f0be9a70
Add support of lzcnt and tzcnt
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
18358
diff
changeset
|
1047 } |
6dc4f0be9a70
Add support of lzcnt and tzcnt
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
18358
diff
changeset
|
1048 |
6496
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6493
diff
changeset
|
1049 @Override |
11290
686d6d99352c
Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
11289
diff
changeset
|
1050 public Value emitMathAbs(Value input) { |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
1051 Variable result = newVariable(LIRKind.derive(input)); |
18300
9734f97bddfe
Intrinsify Math.abs(float).
Roland Schatz <roland.schatz@oracle.com>
parents:
18187
diff
changeset
|
1052 switch (input.getKind()) { |
9734f97bddfe
Intrinsify Math.abs(float).
Roland Schatz <roland.schatz@oracle.com>
parents:
18187
diff
changeset
|
1053 case Float: |
9734f97bddfe
Intrinsify Math.abs(float).
Roland Schatz <roland.schatz@oracle.com>
parents:
18187
diff
changeset
|
1054 append(new BinaryRegConst(FAND, result, asAllocatable(input), JavaConstant.forFloat(Float.intBitsToFloat(0x7FFFFFFF)))); |
9734f97bddfe
Intrinsify Math.abs(float).
Roland Schatz <roland.schatz@oracle.com>
parents:
18187
diff
changeset
|
1055 break; |
9734f97bddfe
Intrinsify Math.abs(float).
Roland Schatz <roland.schatz@oracle.com>
parents:
18187
diff
changeset
|
1056 case Double: |
9734f97bddfe
Intrinsify Math.abs(float).
Roland Schatz <roland.schatz@oracle.com>
parents:
18187
diff
changeset
|
1057 append(new BinaryRegConst(DAND, result, asAllocatable(input), JavaConstant.forDouble(Double.longBitsToDouble(0x7FFFFFFFFFFFFFFFL)))); |
9734f97bddfe
Intrinsify Math.abs(float).
Roland Schatz <roland.schatz@oracle.com>
parents:
18187
diff
changeset
|
1058 break; |
9734f97bddfe
Intrinsify Math.abs(float).
Roland Schatz <roland.schatz@oracle.com>
parents:
18187
diff
changeset
|
1059 default: |
9734f97bddfe
Intrinsify Math.abs(float).
Roland Schatz <roland.schatz@oracle.com>
parents:
18187
diff
changeset
|
1060 throw GraalInternalError.shouldNotReachHere(); |
9734f97bddfe
Intrinsify Math.abs(float).
Roland Schatz <roland.schatz@oracle.com>
parents:
18187
diff
changeset
|
1061 } |
11290
686d6d99352c
Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
11289
diff
changeset
|
1062 return result; |
6496
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6493
diff
changeset
|
1063 } |
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6493
diff
changeset
|
1064 |
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6493
diff
changeset
|
1065 @Override |
11290
686d6d99352c
Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
11289
diff
changeset
|
1066 public Value emitMathSqrt(Value input) { |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
1067 Variable result = newVariable(LIRKind.derive(input)); |
11290
686d6d99352c
Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
11289
diff
changeset
|
1068 append(new Unary2Op(SQRT, result, asAllocatable(input))); |
686d6d99352c
Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
11289
diff
changeset
|
1069 return result; |
6496
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6493
diff
changeset
|
1070 } |
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6493
diff
changeset
|
1071 |
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6493
diff
changeset
|
1072 @Override |
11290
686d6d99352c
Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
11289
diff
changeset
|
1073 public Value emitMathLog(Value input, boolean base10) { |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
1074 Variable result = newVariable(LIRKind.derive(input)); |
11290
686d6d99352c
Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
11289
diff
changeset
|
1075 append(new AMD64MathIntrinsicOp(base10 ? LOG10 : LOG, result, asAllocatable(input))); |
686d6d99352c
Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
11289
diff
changeset
|
1076 return result; |
6496
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6493
diff
changeset
|
1077 } |
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6493
diff
changeset
|
1078 |
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6493
diff
changeset
|
1079 @Override |
11290
686d6d99352c
Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
11289
diff
changeset
|
1080 public Value emitMathCos(Value input) { |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
1081 Variable result = newVariable(LIRKind.derive(input)); |
11290
686d6d99352c
Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
11289
diff
changeset
|
1082 append(new AMD64MathIntrinsicOp(COS, result, asAllocatable(input))); |
686d6d99352c
Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
11289
diff
changeset
|
1083 return result; |
6496
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6493
diff
changeset
|
1084 } |
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6493
diff
changeset
|
1085 |
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6493
diff
changeset
|
1086 @Override |
11290
686d6d99352c
Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
11289
diff
changeset
|
1087 public Value emitMathSin(Value input) { |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
1088 Variable result = newVariable(LIRKind.derive(input)); |
11290
686d6d99352c
Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
11289
diff
changeset
|
1089 append(new AMD64MathIntrinsicOp(SIN, result, asAllocatable(input))); |
686d6d99352c
Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
11289
diff
changeset
|
1090 return result; |
6496
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6493
diff
changeset
|
1091 } |
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6493
diff
changeset
|
1092 |
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6493
diff
changeset
|
1093 @Override |
11290
686d6d99352c
Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
11289
diff
changeset
|
1094 public Value emitMathTan(Value input) { |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
1095 Variable result = newVariable(LIRKind.derive(input)); |
11290
686d6d99352c
Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
11289
diff
changeset
|
1096 append(new AMD64MathIntrinsicOp(TAN, result, asAllocatable(input))); |
686d6d99352c
Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
11289
diff
changeset
|
1097 return result; |
6496
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6493
diff
changeset
|
1098 } |
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6493
diff
changeset
|
1099 |
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6493
diff
changeset
|
1100 @Override |
16092
51ba6c521922
Refactor LIRGeneratorTool methods.
Roland Schatz <roland.schatz@oracle.com>
parents:
15947
diff
changeset
|
1101 public Value emitByteSwap(Value input) { |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
1102 Variable result = newVariable(LIRKind.derive(input)); |
6496
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6493
diff
changeset
|
1103 append(new AMD64ByteSwapOp(result, input)); |
16092
51ba6c521922
Refactor LIRGeneratorTool methods.
Roland Schatz <roland.schatz@oracle.com>
parents:
15947
diff
changeset
|
1104 return result; |
6496
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6493
diff
changeset
|
1105 } |
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6493
diff
changeset
|
1106 |
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6493
diff
changeset
|
1107 @Override |
16092
51ba6c521922
Refactor LIRGeneratorTool methods.
Roland Schatz <roland.schatz@oracle.com>
parents:
15947
diff
changeset
|
1108 public Value emitArrayEquals(Kind kind, Value array1, Value array2, Value length) { |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16092
diff
changeset
|
1109 Variable result = newVariable(LIRKind.value(Kind.Int)); |
13973 | 1110 append(new AMD64ArrayEqualsOp(this, kind, result, array1, array2, asAllocatable(length))); |
16092
51ba6c521922
Refactor LIRGeneratorTool methods.
Roland Schatz <roland.schatz@oracle.com>
parents:
15947
diff
changeset
|
1111 return result; |
13541 | 1112 } |
1113 | |
1114 @Override | |
14841
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
14826
diff
changeset
|
1115 public void emitReturn(Value input) { |
14949
b65036798097
Remove visitReturn from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents:
14945
diff
changeset
|
1116 AllocatableValue operand = Value.ILLEGAL; |
b65036798097
Remove visitReturn from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents:
14945
diff
changeset
|
1117 if (input != null) { |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16092
diff
changeset
|
1118 operand = resultOperandFor(input.getLIRKind()); |
14949
b65036798097
Remove visitReturn from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents:
14945
diff
changeset
|
1119 emitMove(operand, input); |
b65036798097
Remove visitReturn from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents:
14945
diff
changeset
|
1120 } |
b65036798097
Remove visitReturn from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents:
14945
diff
changeset
|
1121 append(new ReturnOp(operand)); |
4323
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4314
diff
changeset
|
1122 } |
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4314
diff
changeset
|
1123 |
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4314
diff
changeset
|
1124 @Override |
15297
3a6151ed5a25
Move LIRGenerator to graal.lir (errors).
Josef Eisl <josef.eisl@jku.at>
parents:
15294
diff
changeset
|
1125 public void emitStrategySwitch(SwitchStrategy strategy, Variable key, LabelRef[] keyTargets, LabelRef defaultTarget) { |
13302
094f4ee93977
some javadoc for switch strategies
Lukas Stadler <lukas.stadler@jku.at>
parents:
13294
diff
changeset
|
1126 // a temp is needed for loading object constants |
13294
29907e69ae8d
rework of switch generation: move code into platform independent SwitchStrategy, add boolean switch strategy
Lukas Stadler <lukas.stadler@jku.at>
parents:
13268
diff
changeset
|
1127 boolean needsTemp = key.getKind() == Kind.Object; |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16092
diff
changeset
|
1128 append(new StrategySwitchOp(strategy, keyTargets, defaultTarget, key, needsTemp ? newVariable(key.getLIRKind()) : Value.ILLEGAL)); |
5698
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5667
diff
changeset
|
1129 } |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5667
diff
changeset
|
1130 |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5667
diff
changeset
|
1131 @Override |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5667
diff
changeset
|
1132 protected void emitTableSwitch(int lowKey, LabelRef defaultTarget, LabelRef[] targets, Value key) { |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16092
diff
changeset
|
1133 append(new TableSwitchOp(lowKey, defaultTarget, targets, key, newVariable(LIRKind.value(target().wordKind)), newVariable(key.getLIRKind()))); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1134 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1135 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1136 } |