annotate graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java @ 17266:00dd7b3c5aea

float and double constants cannot be inlined
author Lukas Stadler <lukas.stadler@oracle.com>
date Tue, 30 Sep 2014 11:08:10 +0200
parents 189479d72dc8
children 8dcb64d6e987
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
40 import com.oracle.graal.lir.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
41 import com.oracle.graal.lir.StandardOp.JumpOp;
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
42 import com.oracle.graal.lir.amd64.*;
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
43 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
44 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
45 import com.oracle.graal.lir.amd64.AMD64Arithmetic.BinaryRegConst;
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
46 import com.oracle.graal.lir.amd64.AMD64Arithmetic.BinaryRegReg;
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
47 import com.oracle.graal.lir.amd64.AMD64Arithmetic.BinaryRegStack;
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
48 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
49 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
50 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
51 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
52 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
53 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
54 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
55 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
56 import com.oracle.graal.lir.amd64.AMD64Compare.CompareMemoryOp;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
57 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
58 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
59 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
60 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
61 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
62 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
63 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
64 import com.oracle.graal.lir.amd64.AMD64ControlFlow.TableSwitchOp;
14859
4f5c312d676e Fix merge regressions.
Josef Eisl <josef.eisl@jku.at>
parents: 14850
diff changeset
65 import com.oracle.graal.lir.amd64.AMD64Move.LeaDataOp;
14121
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
66 import com.oracle.graal.lir.amd64.AMD64Move.LeaOp;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
67 import com.oracle.graal.lir.amd64.AMD64Move.MembarOp;
14121
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
68 import com.oracle.graal.lir.amd64.AMD64Move.MoveFromRegOp;
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
69 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
70 import com.oracle.graal.lir.amd64.AMD64Move.StackLeaOp;
14859
4f5c312d676e Fix merge regressions.
Josef Eisl <josef.eisl@jku.at>
parents: 14850
diff changeset
71 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
72 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
73 import com.oracle.graal.phases.util.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
74
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
75 /**
6496
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
76 * 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
77 */
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
78 public abstract class AMD64LIRGenerator extends LIRGenerator {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
79
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16092
diff changeset
80 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
81
14121
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
82 private class AMD64SpillMoveFactory implements LIR.SpillMoveFactory {
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
83
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
84 @Override
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
85 public LIRInstruction createMove(AllocatableValue result, Value input) {
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
86 return AMD64LIRGenerator.this.createMove(result, input);
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
87 }
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
14842
f2e61bf2a2d8 Removed nodeOperands from LIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14841
diff changeset
90 public AMD64LIRGenerator(Providers providers, CallingConvention cc, LIRGenerationResult lirGenRes) {
f2e61bf2a2d8 Removed nodeOperands from LIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14841
diff changeset
91 super(providers, cc, lirGenRes);
14809
73774616a6b3 Decoupled LIRGenerator and LIRGenerationResult.
Josef Eisl <josef.eisl@jku.at>
parents: 14796
diff changeset
92 lirGenRes.getLIR().setSpillMoveFactory(new AMD64SpillMoveFactory());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
93 }
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 @Override
15947
3eedf7a653ea Remove unused oop compression code from backends.
Roland Schatz <roland.schatz@oracle.com>
parents: 15910
diff changeset
96 public boolean canStoreConstant(Constant c) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
97 // there is no immediate move of 64-bit constants on Intel
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 Util.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 Double:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
102 return false;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
103 case Object:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
104 return c.isNull();
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
105 default:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
106 return true;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
107 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
108 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
109
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
110 @Override
5538
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5510
diff changeset
111 public boolean canInlineConstant(Constant c) {
6329
92bc58dc5b5e More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5798
diff changeset
112 switch (c.getKind()) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
113 case Long:
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
114 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
115 case Object:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
116 return c.isNull();
17266
00dd7b3c5aea float and double constants cannot be inlined
Lukas Stadler <lukas.stadler@oracle.com>
parents: 17196
diff changeset
117 case Boolean:
00dd7b3c5aea float and double constants cannot be inlined
Lukas Stadler <lukas.stadler@oracle.com>
parents: 17196
diff changeset
118 case Byte:
00dd7b3c5aea float and double constants cannot be inlined
Lukas Stadler <lukas.stadler@oracle.com>
parents: 17196
diff changeset
119 case Char:
00dd7b3c5aea float and double constants cannot be inlined
Lukas Stadler <lukas.stadler@oracle.com>
parents: 17196
diff changeset
120 case Int:
00dd7b3c5aea float and double constants cannot be inlined
Lukas Stadler <lukas.stadler@oracle.com>
parents: 17196
diff changeset
121 case Short:
00dd7b3c5aea float and double constants cannot be inlined
Lukas Stadler <lukas.stadler@oracle.com>
parents: 17196
diff changeset
122 case Illegal:
00dd7b3c5aea float and double constants cannot be inlined
Lukas Stadler <lukas.stadler@oracle.com>
parents: 17196
diff changeset
123 return true;
00dd7b3c5aea float and double constants cannot be inlined
Lukas Stadler <lukas.stadler@oracle.com>
parents: 17196
diff changeset
124 case Double:
00dd7b3c5aea float and double constants cannot be inlined
Lukas Stadler <lukas.stadler@oracle.com>
parents: 17196
diff changeset
125 case Float:
00dd7b3c5aea float and double constants cannot be inlined
Lukas Stadler <lukas.stadler@oracle.com>
parents: 17196
diff changeset
126 return false;
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
127 default:
17266
00dd7b3c5aea float and double constants cannot be inlined
Lukas Stadler <lukas.stadler@oracle.com>
parents: 17196
diff changeset
128 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
129 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
130 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
131
4314
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
132 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
133 public Variable emitMove(Value input) {
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16092
diff changeset
134 Variable result = newVariable(input.getLIRKind());
7883
cc9b45598a4f Change argument order to be consistent with the rest of the backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7882
diff changeset
135 emitMove(result, input);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
136 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
137 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
138
14121
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
139 protected AMD64LIRInstruction createMove(AllocatableValue dst, Value src) {
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
140 if (src instanceof AMD64AddressValue) {
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
141 return new LeaOp(dst, (AMD64AddressValue) src);
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
142 } else if (isRegister(src) || isStackSlot(dst)) {
14945
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14931
diff changeset
143 return new MoveFromRegOp(dst.getKind(), dst, src);
14121
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
144 } else {
14945
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14931
diff changeset
145 return new MoveToRegOp(dst.getKind(), dst, src);
14121
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
146 }
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
147 }
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
148
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
149 @Override
9296
1342574c4f7d Move targets can only be AllocatableValues.
Roland Schatz <roland.schatz@oracle.com>
parents: 9294
diff changeset
150 public void emitMove(AllocatableValue dst, Value src) {
14121
0ddb3b3665bd Backed out changeset: 38c881305352
Roland Schatz <roland.schatz@oracle.com>
parents: 14061
diff changeset
151 append(createMove(dst, src));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
152 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
153
14859
4f5c312d676e Fix merge regressions.
Josef Eisl <josef.eisl@jku.at>
parents: 14850
diff changeset
154 public void emitData(AllocatableValue dst, byte[] data) {
4f5c312d676e Fix merge regressions.
Josef Eisl <josef.eisl@jku.at>
parents: 14850
diff changeset
155 append(new LeaDataOp(dst, data));
4f5c312d676e Fix merge regressions.
Josef Eisl <josef.eisl@jku.at>
parents: 14850
diff changeset
156 }
4f5c312d676e Fix merge regressions.
Josef Eisl <josef.eisl@jku.at>
parents: 14850
diff changeset
157
9298
9ee5f3bfa755 Restructure load/store/lea LIR instructions.
Roland Schatz <roland.schatz@oracle.com>
parents: 9297
diff changeset
158 @Override
9ee5f3bfa755 Restructure load/store/lea LIR instructions.
Roland Schatz <roland.schatz@oracle.com>
parents: 9297
diff changeset
159 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
160 AllocatableValue baseRegister;
9204
589e140a7f1c Allow locations to have long displacements.
Roland Schatz <roland.schatz@oracle.com>
parents: 9003
diff changeset
161 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
162 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
163 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
164 baseRegister = Value.ILLEGAL;
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
165 } 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
166 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
167 baseRegister = Value.ILLEGAL;
8166
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
168 } else {
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
169 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
170 }
8166
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
171 } else {
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
172 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
173 }
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
174
8166
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
175 AllocatableValue indexRegister;
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
176 Scale scaleEnum;
9638
c455c86138ba Value: more occurrences of object equality replaced
Bernhard Urban <bernhard.urban@jku.at>
parents: 9613
diff changeset
177 if (!index.equals(Value.ILLEGAL) && scale != 0) {
8166
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
178 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
179 if (isConstant(index)) {
9204
589e140a7f1c Allow locations to have long displacements.
Roland Schatz <roland.schatz@oracle.com>
parents: 9003
diff changeset
180 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
181 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
182
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 } 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
184 /* 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
185 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
186 if (CodeUtil.isPowerOf2(scale)) {
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
187 indexRegister = emitShl(longIndex, Constant.forLong(CodeUtil.log2(scale)));
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
188 } else {
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
189 indexRegister = emitMul(longIndex, Constant.forLong(scale));
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
190 }
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
191 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
192
8166
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
193 } else {
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
194 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
195 }
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
196 } else {
9294
899295127bc4 Get rid of the distinction between UNUSED and ILLEGAL value.
Roland Schatz <roland.schatz@oracle.com>
parents: 9293
diff changeset
197 indexRegister = Value.ILLEGAL;
8166
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
198 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
199 }
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
200
9204
589e140a7f1c Allow locations to have long displacements.
Roland Schatz <roland.schatz@oracle.com>
parents: 9003
diff changeset
201 int displacementInt;
589e140a7f1c Allow locations to have long displacements.
Roland Schatz <roland.schatz@oracle.com>
parents: 9003
diff changeset
202 if (NumUtil.isInt(finalDisp)) {
589e140a7f1c Allow locations to have long displacements.
Roland Schatz <roland.schatz@oracle.com>
parents: 9003
diff changeset
203 displacementInt = (int) finalDisp;
589e140a7f1c Allow locations to have long displacements.
Roland Schatz <roland.schatz@oracle.com>
parents: 9003
diff changeset
204 } else {
589e140a7f1c Allow locations to have long displacements.
Roland Schatz <roland.schatz@oracle.com>
parents: 9003
diff changeset
205 displacementInt = 0;
589e140a7f1c Allow locations to have long displacements.
Roland Schatz <roland.schatz@oracle.com>
parents: 9003
diff changeset
206 AllocatableValue displacementRegister = load(Constant.forLong(finalDisp));
9638
c455c86138ba Value: more occurrences of object equality replaced
Bernhard Urban <bernhard.urban@jku.at>
parents: 9613
diff changeset
207 if (baseRegister.equals(Value.ILLEGAL)) {
9204
589e140a7f1c Allow locations to have long displacements.
Roland Schatz <roland.schatz@oracle.com>
parents: 9003
diff changeset
208 baseRegister = displacementRegister;
10086
e0fb8a213650 fix == on Value
Mick Jordan <mick.jordan@oracle.com>
parents: 9896
diff changeset
209 } else if (indexRegister.equals(Value.ILLEGAL)) {
9204
589e140a7f1c Allow locations to have long displacements.
Roland Schatz <roland.schatz@oracle.com>
parents: 9003
diff changeset
210 indexRegister = displacementRegister;
589e140a7f1c Allow locations to have long displacements.
Roland Schatz <roland.schatz@oracle.com>
parents: 9003
diff changeset
211 scaleEnum = Scale.Times1;
589e140a7f1c Allow locations to have long displacements.
Roland Schatz <roland.schatz@oracle.com>
parents: 9003
diff changeset
212 } else {
589e140a7f1c Allow locations to have long displacements.
Roland Schatz <roland.schatz@oracle.com>
parents: 9003
diff changeset
213 baseRegister = emitAdd(baseRegister, displacementRegister);
589e140a7f1c Allow locations to have long displacements.
Roland Schatz <roland.schatz@oracle.com>
parents: 9003
diff changeset
214 }
589e140a7f1c Allow locations to have long displacements.
Roland Schatz <roland.schatz@oracle.com>
parents: 9003
diff changeset
215 }
589e140a7f1c Allow locations to have long displacements.
Roland Schatz <roland.schatz@oracle.com>
parents: 9003
diff changeset
216
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16092
diff changeset
217 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
218 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
219 }
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
220
14841
47e4d2e01c6e Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents: 14826
diff changeset
221 public AMD64AddressValue asAddressValue(Value address) {
9298
9ee5f3bfa755 Restructure load/store/lea LIR instructions.
Roland Schatz <roland.schatz@oracle.com>
parents: 9297
diff changeset
222 if (address instanceof AMD64AddressValue) {
9ee5f3bfa755 Restructure load/store/lea LIR instructions.
Roland Schatz <roland.schatz@oracle.com>
parents: 9297
diff changeset
223 return (AMD64AddressValue) address;
9ee5f3bfa755 Restructure load/store/lea LIR instructions.
Roland Schatz <roland.schatz@oracle.com>
parents: 9297
diff changeset
224 } else {
9ee5f3bfa755 Restructure load/store/lea LIR instructions.
Roland Schatz <roland.schatz@oracle.com>
parents: 9297
diff changeset
225 return emitAddress(address, 0, Value.ILLEGAL, 0);
9ee5f3bfa755 Restructure load/store/lea LIR instructions.
Roland Schatz <roland.schatz@oracle.com>
parents: 9297
diff changeset
226 }
9ee5f3bfa755 Restructure load/store/lea LIR instructions.
Roland Schatz <roland.schatz@oracle.com>
parents: 9297
diff changeset
227 }
9ee5f3bfa755 Restructure load/store/lea LIR instructions.
Roland Schatz <roland.schatz@oracle.com>
parents: 9297
diff changeset
228
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
229 @Override
9298
9ee5f3bfa755 Restructure load/store/lea LIR instructions.
Roland Schatz <roland.schatz@oracle.com>
parents: 9297
diff changeset
230 public Variable emitAddress(StackSlot address) {
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16092
diff changeset
231 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
232 append(new StackLeaOp(result, address));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
233 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
234 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
235
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
236 @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
237 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
238 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
239 append(new JumpOp(label));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
240 }
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 @Override
14962
e4a5b8904695 Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14949
diff changeset
243 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
244 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
245 Condition finalCondition = mirrored ? cond.mirror() : cond;
15910
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15909
diff changeset
246 if (cmpKind == Kind.Float || cmpKind == Kind.Double) {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15909
diff changeset
247 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
248 } else {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15909
diff changeset
249 append(new BranchOp(finalCondition, trueLabel, falseLabel, trueLabelProbability));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
250 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
251 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
252
15370
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15301
diff changeset
253 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
254 double trueLabelProbability) {
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15301
diff changeset
255 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
256 Condition finalCondition = mirrored ? cond.mirror() : cond;
15910
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15909
diff changeset
257 if (cmpKind == Kind.Float || cmpKind == Kind.Double) {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15909
diff changeset
258 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
259 } else {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15909
diff changeset
260 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
261 }
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15301
diff changeset
262 }
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15301
diff changeset
263
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
264 @Override
13908
8f3cd93813f1 Use branch probability for emitting conditional jump.
Roland Schatz <roland.schatz@oracle.com>
parents: 13907
diff changeset
265 public void emitOverflowCheckBranch(LabelRef overflow, LabelRef noOverflow, double overflowProbability) {
8f3cd93813f1 Use branch probability for emitting conditional jump.
Roland Schatz <roland.schatz@oracle.com>
parents: 13907
diff changeset
266 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
267 }
c64ecb1ef1a9 Create LIRGenerator.emitOverflowCheckBranch in preparation for emitDeoptimizeOnOverflow removal
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8209
diff changeset
268
c64ecb1ef1a9 Create LIRGenerator.emitOverflowCheckBranch in preparation for emitDeoptimizeOnOverflow removal
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8209
diff changeset
269 @Override
13908
8f3cd93813f1 Use branch probability for emitting conditional jump.
Roland Schatz <roland.schatz@oracle.com>
parents: 13907
diff changeset
270 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
271 emitIntegerTest(left, right);
13908
8f3cd93813f1 Use branch probability for emitting conditional jump.
Roland Schatz <roland.schatz@oracle.com>
parents: 13907
diff changeset
272 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
273 }
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
274
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
275 @Override
14962
e4a5b8904695 Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14949
diff changeset
276 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
277 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
278 Condition finalCondition = mirrored ? cond.mirror() : cond;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
279
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16092
diff changeset
280 Variable result = newVariable(trueValue.getLIRKind());
15910
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15909
diff changeset
281 if (cmpKind == Kind.Float || cmpKind == Kind.Double) {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15909
diff changeset
282 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
283 } else {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15909
diff changeset
284 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
285 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
286 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
287 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
288
7725
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
289 @Override
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
290 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
291 emitIntegerTest(left, right);
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16092
diff changeset
292 Variable result = newVariable(trueValue.getLIRKind());
7725
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
293 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
294 return result;
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
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
297 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
298 assert a.getKind().isNumericInteger();
7725
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
299 if (LIRValueUtil.isVariable(b)) {
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
300 append(new AMD64TestOp(load(b), loadNonConst(a)));
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
301 } else {
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
302 append(new AMD64TestOp(load(a), loadNonConst(b)));
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
303 }
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
304 }
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
305
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
306 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
307 switch ((Kind) cmpKind) {
14962
e4a5b8904695 Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14949
diff changeset
308 case Byte:
e4a5b8904695 Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14949
diff changeset
309 case Boolean:
e4a5b8904695 Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14949
diff changeset
310 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
311 break;
e4a5b8904695 Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14949
diff changeset
312 case Short:
e4a5b8904695 Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14949
diff changeset
313 case Char:
e4a5b8904695 Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14949
diff changeset
314 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
315 break;
13251
3a8a4042229f Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents: 13212
diff changeset
316 case Int:
3a8a4042229f Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents: 13212
diff changeset
317 append(new CompareOp(ICMP, 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 Long:
3a8a4042229f Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents: 13212
diff changeset
320 append(new CompareOp(LCMP, 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 case Object:
3a8a4042229f Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents: 13212
diff changeset
323 append(new CompareOp(ACMP, left, right));
3a8a4042229f Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents: 13212
diff changeset
324 break;
3a8a4042229f Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents: 13212
diff changeset
325 case Float:
3a8a4042229f Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents: 13212
diff changeset
326 append(new CompareOp(FCMP, left, right));
3a8a4042229f Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents: 13212
diff changeset
327 break;
3a8a4042229f Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents: 13212
diff changeset
328 case Double:
3a8a4042229f Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents: 13212
diff changeset
329 append(new CompareOp(DCMP, left, right));
3a8a4042229f Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents: 13212
diff changeset
330 break;
3a8a4042229f Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents: 13212
diff changeset
331 default:
3a8a4042229f Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents: 13212
diff changeset
332 throw GraalInternalError.shouldNotReachHere();
3a8a4042229f Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents: 13212
diff changeset
333 }
3a8a4042229f Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents: 13212
diff changeset
334 }
3a8a4042229f Refactor emission of compare op.
Roland Schatz <roland.schatz@oracle.com>
parents: 13212
diff changeset
335
15370
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15301
diff changeset
336 /**
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15301
diff changeset
337 * 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
338 * 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
339 *
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15301
diff changeset
340 * @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
341 * @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
342 */
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15301
diff changeset
343 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
344 boolean mirrored;
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15301
diff changeset
345 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
346 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
347 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
348 mirrored = false;
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15301
diff changeset
349 } else {
15910
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15909
diff changeset
350 emitCompareMemoryConOp(cmpKind, b, (Constant) 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
351 mirrored = true;
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15301
diff changeset
352 }
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15301
diff changeset
353 return mirrored;
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15301
diff changeset
354 }
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15301
diff changeset
355
15910
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15909
diff changeset
356 protected void emitCompareMemoryConOp(Kind kind, AMD64AddressValue address, Constant value, LIRFrameState state) {
14962
e4a5b8904695 Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14949
diff changeset
357 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
358 switch (kind) {
14962
e4a5b8904695 Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14949
diff changeset
359 case Byte:
e4a5b8904695 Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14949
diff changeset
360 case Boolean:
e4a5b8904695 Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14949
diff changeset
361 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
362 break;
e4a5b8904695 Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14949
diff changeset
363 case Short:
e4a5b8904695 Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14949
diff changeset
364 case Char:
e4a5b8904695 Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14949
diff changeset
365 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
366 break;
14707
6ce6c4ccba8f initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
367 case Int:
14931
d45e8c306349 use MemOp as base class for new memory ops
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14859
diff changeset
368 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
369 break;
6ce6c4ccba8f initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
370 case Long:
14931
d45e8c306349 use MemOp as base class for new memory ops
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14859
diff changeset
371 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
372 break;
15910
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15909
diff changeset
373 case Object:
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15909
diff changeset
374 assert value.isNull();
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15909
diff changeset
375 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
376 break;
14707
6ce6c4ccba8f initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
377 default:
6ce6c4ccba8f initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
378 throw GraalInternalError.shouldNotReachHere();
6ce6c4ccba8f initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
379 }
6ce6c4ccba8f initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
380 }
6ce6c4ccba8f initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
381
14931
d45e8c306349 use MemOp as base class for new memory ops
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14859
diff changeset
382 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
383 AMD64Compare opcode = null;
14707
6ce6c4ccba8f initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
384 switch (kind) {
14962
e4a5b8904695 Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14949
diff changeset
385 case Byte:
e4a5b8904695 Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14949
diff changeset
386 case Boolean:
e4a5b8904695 Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14949
diff changeset
387 opcode = BCMP;
e4a5b8904695 Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14949
diff changeset
388 break;
e4a5b8904695 Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14949
diff changeset
389 case Short:
e4a5b8904695 Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14949
diff changeset
390 case Char:
e4a5b8904695 Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14949
diff changeset
391 opcode = SCMP;
e4a5b8904695 Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14949
diff changeset
392 break;
14707
6ce6c4ccba8f initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
393 case Int:
14931
d45e8c306349 use MemOp as base class for new memory ops
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14859
diff changeset
394 opcode = ICMP;
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 Long:
14931
d45e8c306349 use MemOp as base class for new memory ops
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14859
diff changeset
397 opcode = LCMP;
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 case Object:
14931
d45e8c306349 use MemOp as base class for new memory ops
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14859
diff changeset
400 opcode = ACMP;
14707
6ce6c4ccba8f initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
401 break;
6ce6c4ccba8f initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
402 case Float:
14931
d45e8c306349 use MemOp as base class for new memory ops
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14859
diff changeset
403 opcode = FCMP;
14707
6ce6c4ccba8f initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
404 break;
6ce6c4ccba8f initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
405 case Double:
14931
d45e8c306349 use MemOp as base class for new memory ops
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14859
diff changeset
406 opcode = DCMP;
14707
6ce6c4ccba8f initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
407 break;
6ce6c4ccba8f initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
408 default:
6ce6c4ccba8f initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
409 throw GraalInternalError.shouldNotReachHere();
6ce6c4ccba8f initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
410 }
14931
d45e8c306349 use MemOp as base class for new memory ops
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14859
diff changeset
411 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
412 }
6ce6c4ccba8f initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
413
5406
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
414 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
415 * 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
416 * it did so.
14850
Josef Eisl <josef.eisl@jku.at>
parents: 14842 14747
diff changeset
417 *
5406
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
418 * @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
419 * @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
420 * @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
421 */
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
422 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
423 Variable left;
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
424 Value right;
5406
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
425 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
426 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
427 left = load(b);
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
428 right = loadNonConst(a);
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
429 mirrored = true;
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
430 } else {
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
431 left = load(a);
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
432 right = loadNonConst(b);
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
433 mirrored = false;
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
434 }
14962
e4a5b8904695 Support for short and byte compare in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14949
diff changeset
435 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
436 return mirrored;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
437 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
438
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
439 @Override
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
440 public Variable emitNegate(Value inputVal) {
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
441 AllocatableValue input = asAllocatable(inputVal);
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
442 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
443 switch (input.getKind()) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
444 case Int:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
445 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
446 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
447 case Long:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
448 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
449 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
450 case Float:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
451 append(new BinaryRegConst(FXOR, result, input, Constant.forFloat(Float.intBitsToFloat(0x80000000))));
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
452 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
453 case Double:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
454 append(new BinaryRegConst(DXOR, result, input, Constant.forDouble(Double.longBitsToDouble(0x8000000000000000L))));
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
455 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
456 default:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
457 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
458 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
459 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
460 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
461
11355
01269a181628 add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 11290
diff changeset
462 @Override
01269a181628 add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 11290
diff changeset
463 public Variable emitNot(Value inputVal) {
01269a181628 add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 11290
diff changeset
464 AllocatableValue input = asAllocatable(inputVal);
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
465 Variable result = newVariable(LIRKind.derive(input));
11355
01269a181628 add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 11290
diff changeset
466 switch (input.getKind()) {
01269a181628 add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 11290
diff changeset
467 case Int:
01269a181628 add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 11290
diff changeset
468 append(new Unary1Op(INOT, result, input));
01269a181628 add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 11290
diff changeset
469 break;
01269a181628 add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 11290
diff changeset
470 case Long:
01269a181628 add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 11290
diff changeset
471 append(new Unary1Op(LNOT, result, input));
01269a181628 add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 11290
diff changeset
472 break;
01269a181628 add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 11290
diff changeset
473 default:
01269a181628 add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 11290
diff changeset
474 throw GraalInternalError.shouldNotReachHere();
01269a181628 add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 11290
diff changeset
475 }
01269a181628 add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 11290
diff changeset
476 return result;
01269a181628 add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 11290
diff changeset
477 }
01269a181628 add bitwise "not" operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 11290
diff changeset
478
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
479 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
480 if (isConstant(b)) {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
481 return emitBinaryConst(op, commutative, asAllocatable(a), asConstant(b));
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
482 } else if (commutative && isConstant(a)) {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
483 return emitBinaryConst(op, commutative, asAllocatable(b), asConstant(a));
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
484 } else {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
485 return emitBinaryVar(op, commutative, asAllocatable(a), asAllocatable(b));
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
486 }
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
487 }
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
488
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
489 private Variable emitBinaryConst(AMD64Arithmetic op, boolean commutative, AllocatableValue a, Constant b) {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
490 switch (op) {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
491 case IADD:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
492 case LADD:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
493 case ISUB:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
494 case LSUB:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
495 case IAND:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
496 case LAND:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
497 case IOR:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
498 case LOR:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
499 case IXOR:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
500 case LXOR:
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 BinaryRegConst(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 case IMUL:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
509 case LMUL:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
510 if (NumUtil.isInt(b.asLong())) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
511 Variable result = newVariable(LIRKind.derive(a, b));
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
512 append(new BinaryRegStackConst(op, result, a, b));
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
513 return result;
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
514 }
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
515 break;
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
516 }
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
517
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
518 return emitBinaryVar(op, commutative, a, asAllocatable(b));
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
519 }
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
520
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
521 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
522 Variable result = newVariable(LIRKind.derive(a, b));
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
523 if (commutative) {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
524 append(new BinaryCommutative(op, result, a, b));
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
525 } else {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
526 append(new BinaryRegStack(op, result, a, b));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
527 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
528 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
529 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
530
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
531 @Override
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
532 public Variable emitAdd(Value a, Value b) {
10428
6188764e66af Use stack kind to determine instruction in AMD64LIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 10086
diff changeset
533 switch (a.getKind().getStackKind()) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
534 case Int:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
535 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
536 case Long:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
537 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
538 case Float:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
539 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
540 case Double:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
541 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
542 default:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
543 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
544 }
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
545 }
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
546
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
547 @Override
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
548 public Variable emitSub(Value a, Value b) {
10428
6188764e66af Use stack kind to determine instruction in AMD64LIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 10086
diff changeset
549 switch (a.getKind().getStackKind()) {
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
550 case Int:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
551 return emitBinary(ISUB, false, a, b);
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
552 case Long:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
553 return emitBinary(LSUB, false, a, b);
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
554 case Float:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
555 return emitBinary(FSUB, false, a, b);
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
556 case Double:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
557 return emitBinary(DSUB, false, a, b);
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
558 default:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
559 throw GraalInternalError.shouldNotReachHere();
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
560 }
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
561 }
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
562
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
563 @Override
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
564 public Variable emitMul(Value a, Value b) {
10428
6188764e66af Use stack kind to determine instruction in AMD64LIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 10086
diff changeset
565 switch (a.getKind().getStackKind()) {
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
566 case Int:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
567 return emitBinary(IMUL, true, a, b);
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
568 case Long:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
569 return emitBinary(LMUL, true, a, b);
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
570 case Float:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
571 return emitBinary(FMUL, true, a, b);
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
572 case Double:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
573 return emitBinary(DMUL, true, a, b);
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
574 default:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
575 throw GraalInternalError.shouldNotReachHere();
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
576 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
577 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
578
15691
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15522
diff changeset
579 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
580 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
581 emitMove(mulHigh.x, a);
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15522
diff changeset
582 append(mulHigh);
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15522
diff changeset
583 return emitMove(mulHigh.highResult);
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15522
diff changeset
584 }
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15522
diff changeset
585
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15522
diff changeset
586 @Override
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15522
diff changeset
587 public Value emitMulHigh(Value a, Value b) {
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15522
diff changeset
588 switch (a.getKind().getStackKind()) {
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15522
diff changeset
589 case Int:
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15522
diff changeset
590 return emitMulHigh(IMUL, a, b);
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15522
diff changeset
591 case Long:
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15522
diff changeset
592 return emitMulHigh(LMUL, a, b);
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15522
diff changeset
593 default:
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15522
diff changeset
594 throw GraalInternalError.shouldNotReachHere();
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15522
diff changeset
595 }
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15522
diff changeset
596 }
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15522
diff changeset
597
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15522
diff changeset
598 @Override
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15522
diff changeset
599 public Value emitUMulHigh(Value a, Value b) {
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15522
diff changeset
600 switch (a.getKind().getStackKind()) {
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15522
diff changeset
601 case Int:
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15522
diff changeset
602 return emitMulHigh(IUMUL, a, b);
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15522
diff changeset
603 case Long:
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15522
diff changeset
604 return emitMulHigh(LUMUL, a, b);
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15522
diff changeset
605 default:
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15522
diff changeset
606 throw GraalInternalError.shouldNotReachHere();
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15522
diff changeset
607 }
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15522
diff changeset
608 }
6a13c422fca4 API for high word multiplication.
Roland Schatz <roland.schatz@oracle.com>
parents: 15522
diff changeset
609
15522
589c3627fab8 special cases for addresses involving compressed references
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15370
diff changeset
610 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
611 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
612 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
613 return result;
6ce6c4ccba8f initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
614 }
6ce6c4ccba8f initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
615
6ce6c4ccba8f initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
616 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
617 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
618 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
619 return result;
6ce6c4ccba8f initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
620 }
6ce6c4ccba8f initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
621
6ce6c4ccba8f initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
622 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
623 // 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
624 // the proper kind.
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16092
diff changeset
625 Variable result = newVariable(LIRKind.value(resultBits == 32 ? Kind.Int : Kind.Long));
14859
4f5c312d676e Fix merge regressions.
Josef Eisl <josef.eisl@jku.at>
parents: 14850
diff changeset
626 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
627 return result;
6ce6c4ccba8f initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
628 }
6ce6c4ccba8f initial support for memory arithmetic on x86
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14633
diff changeset
629
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
630 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
631 AllocatableValue rax = AMD64.rax.asValue(a.getLIRKind());
7920
2e3e4b691835 Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7919
diff changeset
632 emitMove(rax, a);
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
633 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
634 append(ret);
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
635 return ret;
7920
2e3e4b691835 Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7919
diff changeset
636 }
2e3e4b691835 Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7919
diff changeset
637
15301
468b2428c403 Change DeoptimizingNode and Access to LIRFrameState in *LIRGenerator*.
Josef Eisl <josef.eisl@jku.at>
parents: 15297
diff changeset
638 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
639 DivRemOp op;
10428
6188764e66af Use stack kind to determine instruction in AMD64LIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 10086
diff changeset
640 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
641 case Int:
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
642 op = emitDivRem(IDIVREM, a, b, state);
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
643 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
644 case Long:
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
645 op = emitDivRem(LDIVREM, a, b, state);
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
646 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
647 default:
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
648 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
649 }
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
650 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
651 }
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
652
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
653 @Override
15301
468b2428c403 Change DeoptimizingNode and Access to LIRFrameState in *LIRGenerator*.
Josef Eisl <josef.eisl@jku.at>
parents: 15297
diff changeset
654 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
655 switch (a.getKind().getStackKind()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
656 case Int:
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
657 DivRemOp op = emitDivRem(IDIV, a, b, state);
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
658 return emitMove(op.divResult);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
659 case Long:
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
660 DivRemOp lop = emitDivRem(LDIV, a, b, state);
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
661 return emitMove(lop.divResult);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
662 case Float: {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
663 Variable result = newVariable(LIRKind.derive(a, b));
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
664 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
665 return result;
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 case Double: {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
668 Variable result = newVariable(LIRKind.derive(a, b));
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
669 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
670 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
671 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
672 default:
4524
dcc8f5c6f394 Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4522
diff changeset
673 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
674 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
675 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
676
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
677 @Override
15301
468b2428c403 Change DeoptimizingNode and Access to LIRFrameState in *LIRGenerator*.
Josef Eisl <josef.eisl@jku.at>
parents: 15297
diff changeset
678 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
679 switch (a.getKind().getStackKind()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
680 case Int:
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
681 DivRemOp op = emitDivRem(IREM, a, b, state);
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
682 return emitMove(op.remResult);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
683 case Long:
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
684 DivRemOp lop = emitDivRem(LREM, a, b, state);
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
685 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
686 case Float: {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
687 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
688 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
689 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
690 }
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
691 case Double: {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
692 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
693 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
694 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
695 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
696 default:
4524
dcc8f5c6f394 Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4522
diff changeset
697 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
698 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
699 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
700
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
701 @Override
15301
468b2428c403 Change DeoptimizingNode and Access to LIRFrameState in *LIRGenerator*.
Josef Eisl <josef.eisl@jku.at>
parents: 15297
diff changeset
702 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
703 DivRemOp op;
10428
6188764e66af Use stack kind to determine instruction in AMD64LIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 10086
diff changeset
704 switch (a.getKind().getStackKind()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
705 case Int:
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
706 op = emitDivRem(IUDIV, a, b, state);
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
707 break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
708 case Long:
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
709 op = emitDivRem(LUDIV, a, b, state);
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
710 break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
711 default:
4524
dcc8f5c6f394 Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4522
diff changeset
712 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
713 }
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
714 return emitMove(op.divResult);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
715 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
716
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
717 @Override
15301
468b2428c403 Change DeoptimizingNode and Access to LIRFrameState in *LIRGenerator*.
Josef Eisl <josef.eisl@jku.at>
parents: 15297
diff changeset
718 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
719 DivRemOp op;
10428
6188764e66af Use stack kind to determine instruction in AMD64LIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 10086
diff changeset
720 switch (a.getKind().getStackKind()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
721 case Int:
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
722 op = emitDivRem(IUREM, a, b, state);
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
723 break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
724 case Long:
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
725 op = emitDivRem(LUREM, a, b, state);
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
726 break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
727 default:
4524
dcc8f5c6f394 Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4522
diff changeset
728 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
729 }
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
730 return emitMove(op.remResult);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
731 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
732
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
733 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
734 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
735 switch (a.getKind().getStackKind()) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
736 case Int:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
737 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
738 case Long:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
739 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
740 default:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
741 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
742 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
743 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
744
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
745 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
746 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
747 switch (a.getKind().getStackKind()) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
748 case Int:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
749 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
750 case Long:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
751 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
752 default:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
753 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
754 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
755 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
756
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
757 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
758 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
759 switch (a.getKind().getStackKind()) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
760 case Int:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
761 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
762 case Long:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
763 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
764 default:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
765 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
766 }
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
767 }
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
768
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
769 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
770 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
771 AllocatableValue input = asAllocatable(a);
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
772 if (isConstant(b)) {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
773 append(new BinaryRegConst(op, result, input, asConstant(b)));
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
774 } else {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
775 emitMove(RCX_I, b);
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
776 append(new BinaryRegReg(op, result, input, RCX_I));
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
777 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
778 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
779 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
780
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
781 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
782 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
783 switch (a.getKind().getStackKind()) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
784 case Int:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
785 return emitShift(ISHL, a, b);
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
786 case Long:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
787 return emitShift(LSHL, a, b);
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
788 default:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
789 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
790 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
791 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
792
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
793 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
794 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
795 switch (a.getKind().getStackKind()) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
796 case Int:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
797 return emitShift(ISHR, a, b);
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
798 case Long:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
799 return emitShift(LSHR, a, b);
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
800 default:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
801 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
802 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
803 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
804
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
805 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
806 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
807 switch (a.getKind().getStackKind()) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
808 case Int:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
809 return emitShift(IUSHR, a, b);
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
810 case Long:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
811 return emitShift(LUSHR, a, b);
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
812 default:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
813 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
814 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
815 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
816
15370
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15301
diff changeset
817 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
818 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
819 case Int:
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15301
diff changeset
820 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
821 case Long:
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(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
823 default:
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15301
diff changeset
824 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
825 }
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15301
diff changeset
826 }
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 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
829 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
830 case Int:
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15301
diff changeset
831 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
832 case Long:
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15301
diff changeset
833 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
834 default:
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15301
diff changeset
835 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
836 }
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15301
diff changeset
837 }
319deee16746 add support for matching multiple HIR nodes when lowering to LIR
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15301
diff changeset
838
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16092
diff changeset
839 private AllocatableValue emitConvert2RegOp(LIRKind kind, AMD64Arithmetic op, AllocatableValue input) {
12656
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12604
diff changeset
840 Variable result = newVariable(kind);
15278
3ef4196cf8e5 use movl instead of andl for L2I
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15261
diff changeset
841 append(new Unary2RegOp(op, result, input));
12656
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12604
diff changeset
842 return result;
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12604
diff changeset
843 }
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12604
diff changeset
844
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16092
diff changeset
845 private AllocatableValue emitConvert2Op(LIRKind kind, AMD64Arithmetic op, AllocatableValue input) {
12656
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12604
diff changeset
846 Variable result = newVariable(kind);
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12604
diff changeset
847 append(new Unary2Op(op, result, input));
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12604
diff changeset
848 return result;
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12604
diff changeset
849 }
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12604
diff changeset
850
14003
0c38906450a0 Make conversion from Stamp to PlatformKind extensible by backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14001
diff changeset
851 @Override
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16092
diff changeset
852 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
853 LIRKind from = inputVal.getLIRKind();
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16092
diff changeset
854 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
855 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
856 }
384d7fc0e27b Ignore reinterpret in backend if the new Stamp has the same PlatformKind.
Roland Schatz <roland.schatz@oracle.com>
parents: 14003
diff changeset
857
12656
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12604
diff changeset
858 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
859 /*
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
860 * 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
861 * 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
862 */
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16092
diff changeset
863 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
864 switch ((Kind) to.getPlatformKind()) {
12656
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12604
diff changeset
865 case Int:
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16092
diff changeset
866 switch (fromKind) {
12656
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12604
diff changeset
867 case Float:
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12604
diff changeset
868 return emitConvert2Op(to, MOV_F2I, input);
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12604
diff changeset
869 }
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
870 break;
12656
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12604
diff changeset
871 case Long:
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16092
diff changeset
872 switch (fromKind) {
12656
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12604
diff changeset
873 case Double:
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12604
diff changeset
874 return emitConvert2Op(to, MOV_D2L, input);
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12604
diff changeset
875 }
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12604
diff changeset
876 break;
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12604
diff changeset
877 case Float:
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16092
diff changeset
878 switch (fromKind) {
12656
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12604
diff changeset
879 case Int:
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12604
diff changeset
880 return emitConvert2Op(to, MOV_I2F, input);
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12604
diff changeset
881 }
7300
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7280
diff changeset
882 break;
12656
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12604
diff changeset
883 case Double:
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16092
diff changeset
884 switch (fromKind) {
12656
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12604
diff changeset
885 case Long:
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12604
diff changeset
886 return emitConvert2Op(to, MOV_L2D, input);
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12604
diff changeset
887 }
9334392ed279 Refactor ConvertNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 12604
diff changeset
888 break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
889 }
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
890 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
891 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
892
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
893 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
894 AllocatableValue input = asAllocatable(inputVal);
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
895 switch (op) {
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
896 case D2F:
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
897 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
898 case D2I:
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
899 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
900 case D2L:
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
901 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
902 case F2D:
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
903 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
904 case F2I:
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
905 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
906 case F2L:
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
907 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
908 case I2D:
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
909 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
910 case I2F:
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
911 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
912 case L2D:
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
913 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
914 case L2F:
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
915 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
916 default:
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
917 throw GraalInternalError.shouldNotReachHere();
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
918 }
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 @Override
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
922 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
923 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
924 // 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
925 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
926 } else {
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
927 return inputVal;
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
928 }
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
929 }
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
930
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
931 @Override
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
932 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
933 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
934 if (fromBits == toBits) {
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
935 return inputVal;
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
936 } else if (toBits > 32) {
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
937 // sign extend to 64 bits
14001
79114edb5130 Explicit x2L instructions in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14000
diff changeset
938 switch (fromBits) {
79114edb5130 Explicit x2L instructions in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14000
diff changeset
939 case 8:
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
940 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
941 case 16:
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
942 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
943 case 32:
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
944 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
945 default:
79114edb5130 Explicit x2L instructions in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 14000
diff changeset
946 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
947 }
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
948 } else {
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
949 // 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
950 switch (fromBits) {
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
951 case 8:
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
952 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
953 case 16:
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
954 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
955 case 32:
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
956 return inputVal;
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
957 default:
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
958 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
959 }
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
960 }
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
961 }
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
962
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
963 @Override
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
964 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
965 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
966 if (fromBits == toBits) {
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
967 return inputVal;
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
968 } else if (fromBits > 32) {
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
969 assert inputVal.getKind() == Kind.Long;
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
970 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
971 long mask = CodeUtil.mask(fromBits);
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
972 append(new BinaryRegConst(AMD64Arithmetic.LAND, result, asAllocatable(inputVal), Constant.forLong(mask)));
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
973 return result;
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
974 } else {
14998
1c1818fb5ad1 Fix wrong assertion.
Roland Schatz <roland.schatz@oracle.com>
parents: 14962
diff changeset
975 assert inputVal.getKind().getStackKind() == Kind.Int;
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
976 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
977 int mask = (int) CodeUtil.mask(fromBits);
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
978 append(new BinaryRegConst(AMD64Arithmetic.IAND, result, asAllocatable(inputVal), Constant.forInt(mask)));
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
979 if (toBits > 32) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
980 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
981 emitMove(longResult, result);
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
982 return longResult;
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
983 } else {
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
984 return result;
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
985 }
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
986 }
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
987 }
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
988
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
989 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
990 public void emitMembar(int barriers) {
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
991 int necessaryBarriers = target().arch.requiredBarriers(barriers);
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
992 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
993 append(new MembarOp(necessaryBarriers));
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
994 }
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
995 }
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
996
13837
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 13559
diff changeset
997 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
998
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
999 @Override
9742
cff1e11941c0 moved temporaries from CallingConvention to ForeignCallLinkage
Doug Simon <doug.simon@oracle.com>
parents: 9739
diff changeset
1000 protected void emitForeignCall(ForeignCallLinkage linkage, Value result, Value[] arguments, Value[] temps, LIRFrameState info) {
cff1e11941c0 moved temporaries from CallingConvention to ForeignCallLinkage
Doug Simon <doug.simon@oracle.com>
parents: 9739
diff changeset
1001 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
1002 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
1003 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
1004 } else {
9744
8342b10b9cc3 rename: *RuntimeCallOp -> *ForeignCallOp
Doug Simon <doug.simon@oracle.com>
parents: 9742
diff changeset
1005 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
1006 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1007 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1008
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1009 @Override
16092
51ba6c521922 Refactor LIRGeneratorTool methods.
Roland Schatz <roland.schatz@oracle.com>
parents: 15947
diff changeset
1010 public Value emitBitCount(Value value) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
1011 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
1012 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
1013 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
1014 } else {
7909
afb56ecdb083 Fix usage and operand flags of AMD64BitManipulationOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7884
diff changeset
1015 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
1016 }
16092
51ba6c521922 Refactor LIRGeneratorTool methods.
Roland Schatz <roland.schatz@oracle.com>
parents: 15947
diff changeset
1017 return result;
7280
f368ec89e231 added intrinsifications for Integer.bitCount() and Long.bitCount()
Doug Simon <doug.simon@oracle.com>
parents: 7144
diff changeset
1018 }
f368ec89e231 added intrinsifications for Integer.bitCount() and Long.bitCount()
Doug Simon <doug.simon@oracle.com>
parents: 7144
diff changeset
1019
f368ec89e231 added intrinsifications for Integer.bitCount() and Long.bitCount()
Doug Simon <doug.simon@oracle.com>
parents: 7144
diff changeset
1020 @Override
16092
51ba6c521922 Refactor LIRGeneratorTool methods.
Roland Schatz <roland.schatz@oracle.com>
parents: 15947
diff changeset
1021 public Value emitBitScanForward(Value value) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
1022 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
1023 append(new AMD64BitManipulationOp(BSF, result, asAllocatable(value)));
16092
51ba6c521922 Refactor LIRGeneratorTool methods.
Roland Schatz <roland.schatz@oracle.com>
parents: 15947
diff changeset
1024 return result;
6496
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
1025 }
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
1026
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
1027 @Override
16092
51ba6c521922 Refactor LIRGeneratorTool methods.
Roland Schatz <roland.schatz@oracle.com>
parents: 15947
diff changeset
1028 public Value emitBitScanReverse(Value value) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
1029 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
1030 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
1031 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
1032 } else {
7909
afb56ecdb083 Fix usage and operand flags of AMD64BitManipulationOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7884
diff changeset
1033 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
1034 }
16092
51ba6c521922 Refactor LIRGeneratorTool methods.
Roland Schatz <roland.schatz@oracle.com>
parents: 15947
diff changeset
1035 return result;
6496
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
1036 }
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
1037
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
1038 @Override
11290
686d6d99352c Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 11289
diff changeset
1039 public Value emitMathAbs(Value input) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
1040 Variable result = newVariable(LIRKind.derive(input));
11290
686d6d99352c Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 11289
diff changeset
1041 append(new BinaryRegConst(DAND, result, asAllocatable(input), Constant.forDouble(Double.longBitsToDouble(0x7FFFFFFFFFFFFFFFL))));
686d6d99352c Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 11289
diff changeset
1042 return result;
6496
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
1043 }
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
1044
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
1045 @Override
11290
686d6d99352c Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 11289
diff changeset
1046 public Value emitMathSqrt(Value input) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
1047 Variable result = newVariable(LIRKind.derive(input));
11290
686d6d99352c Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 11289
diff changeset
1048 append(new Unary2Op(SQRT, result, asAllocatable(input)));
686d6d99352c Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 11289
diff changeset
1049 return result;
6496
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
1050 }
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
1051
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
1052 @Override
11290
686d6d99352c Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 11289
diff changeset
1053 public Value emitMathLog(Value input, boolean base10) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
1054 Variable result = newVariable(LIRKind.derive(input));
11290
686d6d99352c Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 11289
diff changeset
1055 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
1056 return result;
6496
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
1057 }
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
1058
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
1059 @Override
11290
686d6d99352c Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 11289
diff changeset
1060 public Value emitMathCos(Value input) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
1061 Variable result = newVariable(LIRKind.derive(input));
11290
686d6d99352c Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 11289
diff changeset
1062 append(new AMD64MathIntrinsicOp(COS, result, asAllocatable(input)));
686d6d99352c Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 11289
diff changeset
1063 return result;
6496
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
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
1066 @Override
11290
686d6d99352c Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 11289
diff changeset
1067 public Value emitMathSin(Value input) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
1068 Variable result = newVariable(LIRKind.derive(input));
11290
686d6d99352c Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 11289
diff changeset
1069 append(new AMD64MathIntrinsicOp(SIN, result, asAllocatable(input)));
686d6d99352c Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 11289
diff changeset
1070 return result;
6496
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
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
1073 @Override
11290
686d6d99352c Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 11289
diff changeset
1074 public Value emitMathTan(Value input) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
1075 Variable result = newVariable(LIRKind.derive(input));
11290
686d6d99352c Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 11289
diff changeset
1076 append(new AMD64MathIntrinsicOp(TAN, result, asAllocatable(input)));
686d6d99352c Move MathIntrinsic operations to ArithmeticLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents: 11289
diff changeset
1077 return result;
6496
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
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
1080 @Override
16092
51ba6c521922 Refactor LIRGeneratorTool methods.
Roland Schatz <roland.schatz@oracle.com>
parents: 15947
diff changeset
1081 public Value emitByteSwap(Value input) {
16346
bbf051d717f5 Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
1082 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
1083 append(new AMD64ByteSwapOp(result, input));
16092
51ba6c521922 Refactor LIRGeneratorTool methods.
Roland Schatz <roland.schatz@oracle.com>
parents: 15947
diff changeset
1084 return result;
6496
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
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
1087 @Override
16092
51ba6c521922 Refactor LIRGeneratorTool methods.
Roland Schatz <roland.schatz@oracle.com>
parents: 15947
diff changeset
1088 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
1089 Variable result = newVariable(LIRKind.value(Kind.Int));
13973
faa6fda7ee36 added Arrays.equals substitutions
twisti
parents: 13908
diff changeset
1090 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
1091 return result;
13541
63bb635911ab String.equals method substitution
twisti
parents: 13520
diff changeset
1092 }
63bb635911ab String.equals method substitution
twisti
parents: 13520
diff changeset
1093
63bb635911ab String.equals method substitution
twisti
parents: 13520
diff changeset
1094 @Override
14841
47e4d2e01c6e Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents: 14826
diff changeset
1095 public void emitReturn(Value input) {
14949
b65036798097 Remove visitReturn from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 14945
diff changeset
1096 AllocatableValue operand = Value.ILLEGAL;
b65036798097 Remove visitReturn from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 14945
diff changeset
1097 if (input != null) {
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16092
diff changeset
1098 operand = resultOperandFor(input.getLIRKind());
14949
b65036798097 Remove visitReturn from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 14945
diff changeset
1099 emitMove(operand, input);
b65036798097 Remove visitReturn from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 14945
diff changeset
1100 }
b65036798097 Remove visitReturn from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 14945
diff changeset
1101 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
1102 }
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
1103
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
1104 @Override
15297
3a6151ed5a25 Move LIRGenerator to graal.lir (errors).
Josef Eisl <josef.eisl@jku.at>
parents: 15294
diff changeset
1105 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
1106 // 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
1107 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
1108 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
1109 }
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5667
diff changeset
1110
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5667
diff changeset
1111 @Override
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5667
diff changeset
1112 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
1113 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
1114 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1115
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1116 }