Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64AddressLowering.java @ 22604:b00cc0475f31
Update jvmci import: Refactoring: Rename Kind to JavaKind.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Tue, 08 Sep 2015 19:57:39 +0200 |
parents | 0e095e2c24e2 |
children | ed489bbcccbb |
rev | line source |
---|---|
21784
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
1 /* |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
4 * |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
8 * |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
14 * |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
18 * |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
21 * questions. |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
22 */ |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
23 |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
24 package com.oracle.graal.compiler.amd64; |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
25 |
22054 | 26 import jdk.internal.jvmci.code.*; |
27 import jdk.internal.jvmci.meta.*; | |
28 | |
21784
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
29 import com.oracle.graal.asm.*; |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
30 import com.oracle.graal.asm.amd64.AMD64Address.Scale; |
21787
2766fee1809a
Use the fact that a range checked array index is not negative to avoid sign-extension of the index register.
Roland Schatz <roland.schatz@oracle.com>
parents:
21784
diff
changeset
|
31 import com.oracle.graal.compiler.common.type.*; |
21784
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
32 import com.oracle.graal.nodes.*; |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
33 import com.oracle.graal.nodes.calc.*; |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
34 import com.oracle.graal.nodes.memory.address.*; |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
35 import com.oracle.graal.phases.common.AddressLoweringPhase.AddressLowering; |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
36 |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
37 public class AMD64AddressLowering extends AddressLowering { |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
38 |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
39 private final CodeCacheProvider codeCache; |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
40 |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
41 public AMD64AddressLowering(CodeCacheProvider codeCache) { |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
42 this.codeCache = codeCache; |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
43 } |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
44 |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
45 @Override |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
46 public AddressNode lower(ValueNode address) { |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
47 return lower(address, null); |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
48 } |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
49 |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
50 @Override |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
51 public AddressNode lower(ValueNode base, ValueNode offset) { |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
52 AMD64AddressNode ret = new AMD64AddressNode(base, offset); |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
53 boolean changed; |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
54 do { |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
55 changed = improve(ret); |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
56 } while (changed); |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
57 return base.graph().unique(ret); |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
58 } |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
59 |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
60 protected boolean improve(AMD64AddressNode ret) { |
21787
2766fee1809a
Use the fact that a range checked array index is not negative to avoid sign-extension of the index register.
Roland Schatz <roland.schatz@oracle.com>
parents:
21784
diff
changeset
|
61 ValueNode newBase = improveInput(ret, ret.getBase(), 0); |
21784
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
62 if (newBase != ret.getBase()) { |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
63 ret.setBase(newBase); |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
64 return true; |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
65 } |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
66 |
21787
2766fee1809a
Use the fact that a range checked array index is not negative to avoid sign-extension of the index register.
Roland Schatz <roland.schatz@oracle.com>
parents:
21784
diff
changeset
|
67 ValueNode newIdx = improveInput(ret, ret.getIndex(), ret.getScale().log2); |
21784
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
68 if (newIdx != ret.getIndex()) { |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
69 ret.setIndex(newIdx); |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
70 return true; |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
71 } |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
72 |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
73 if (ret.getIndex() instanceof LeftShiftNode) { |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
74 LeftShiftNode shift = (LeftShiftNode) ret.getIndex(); |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
75 if (shift.getY().isConstant()) { |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
76 int amount = ret.getScale().log2 + shift.getY().asJavaConstant().asInt(); |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
77 Scale scale = Scale.fromShift(amount); |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
78 if (scale != null) { |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
79 ret.setIndex(shift.getX()); |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
80 ret.setScale(scale); |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
81 return true; |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
82 } |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
83 } |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
84 } |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
85 |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
86 if (ret.getScale() == Scale.Times1) { |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
87 if (ret.getBase() == null || ret.getIndex() == null) { |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
88 if (ret.getBase() instanceof AddNode) { |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
89 AddNode add = (AddNode) ret.getBase(); |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
90 ret.setBase(add.getX()); |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
91 ret.setIndex(add.getY()); |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
92 return true; |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
93 } else if (ret.getIndex() instanceof AddNode) { |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
94 AddNode add = (AddNode) ret.getIndex(); |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
95 ret.setBase(add.getX()); |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
96 ret.setIndex(add.getY()); |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
97 return true; |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
98 } |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
99 } |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
100 |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
101 if (ret.getBase() instanceof LeftShiftNode && !(ret.getIndex() instanceof LeftShiftNode)) { |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
102 ValueNode tmp = ret.getBase(); |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
103 ret.setBase(ret.getIndex()); |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
104 ret.setIndex(tmp); |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
105 return true; |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
106 } |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
107 } |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
108 |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
109 return false; |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
110 } |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
111 |
21787
2766fee1809a
Use the fact that a range checked array index is not negative to avoid sign-extension of the index register.
Roland Schatz <roland.schatz@oracle.com>
parents:
21784
diff
changeset
|
112 private ValueNode improveInput(AMD64AddressNode address, ValueNode node, int shift) { |
21784
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
113 if (node == null) { |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
114 return null; |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
115 } |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
116 |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
117 if (node.isConstant()) { |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
118 return improveConstDisp(address, node, node.asJavaConstant(), null, shift); |
21787
2766fee1809a
Use the fact that a range checked array index is not negative to avoid sign-extension of the index register.
Roland Schatz <roland.schatz@oracle.com>
parents:
21784
diff
changeset
|
119 } else { |
2766fee1809a
Use the fact that a range checked array index is not negative to avoid sign-extension of the index register.
Roland Schatz <roland.schatz@oracle.com>
parents:
21784
diff
changeset
|
120 if (node.stamp() instanceof IntegerStamp && ((IntegerStamp) node.stamp()).getBits() == 64) { |
2766fee1809a
Use the fact that a range checked array index is not negative to avoid sign-extension of the index register.
Roland Schatz <roland.schatz@oracle.com>
parents:
21784
diff
changeset
|
121 if (node instanceof ZeroExtendNode) { |
2766fee1809a
Use the fact that a range checked array index is not negative to avoid sign-extension of the index register.
Roland Schatz <roland.schatz@oracle.com>
parents:
21784
diff
changeset
|
122 if (((ZeroExtendNode) node).getInputBits() == 32) { |
2766fee1809a
Use the fact that a range checked array index is not negative to avoid sign-extension of the index register.
Roland Schatz <roland.schatz@oracle.com>
parents:
21784
diff
changeset
|
123 /* |
2766fee1809a
Use the fact that a range checked array index is not negative to avoid sign-extension of the index register.
Roland Schatz <roland.schatz@oracle.com>
parents:
21784
diff
changeset
|
124 * We can just swallow a zero-extend from 32 bit to 64 bit because the upper |
2766fee1809a
Use the fact that a range checked array index is not negative to avoid sign-extension of the index register.
Roland Schatz <roland.schatz@oracle.com>
parents:
21784
diff
changeset
|
125 * half of the register will always be zero. |
2766fee1809a
Use the fact that a range checked array index is not negative to avoid sign-extension of the index register.
Roland Schatz <roland.schatz@oracle.com>
parents:
21784
diff
changeset
|
126 */ |
2766fee1809a
Use the fact that a range checked array index is not negative to avoid sign-extension of the index register.
Roland Schatz <roland.schatz@oracle.com>
parents:
21784
diff
changeset
|
127 return ((ZeroExtendNode) node).getValue(); |
2766fee1809a
Use the fact that a range checked array index is not negative to avoid sign-extension of the index register.
Roland Schatz <roland.schatz@oracle.com>
parents:
21784
diff
changeset
|
128 } |
2766fee1809a
Use the fact that a range checked array index is not negative to avoid sign-extension of the index register.
Roland Schatz <roland.schatz@oracle.com>
parents:
21784
diff
changeset
|
129 } else if (node instanceof AddNode) { |
2766fee1809a
Use the fact that a range checked array index is not negative to avoid sign-extension of the index register.
Roland Schatz <roland.schatz@oracle.com>
parents:
21784
diff
changeset
|
130 AddNode add = (AddNode) node; |
2766fee1809a
Use the fact that a range checked array index is not negative to avoid sign-extension of the index register.
Roland Schatz <roland.schatz@oracle.com>
parents:
21784
diff
changeset
|
131 if (add.getX().isConstant()) { |
2766fee1809a
Use the fact that a range checked array index is not negative to avoid sign-extension of the index register.
Roland Schatz <roland.schatz@oracle.com>
parents:
21784
diff
changeset
|
132 return improveConstDisp(address, node, add.getX().asJavaConstant(), add.getY(), shift); |
2766fee1809a
Use the fact that a range checked array index is not negative to avoid sign-extension of the index register.
Roland Schatz <roland.schatz@oracle.com>
parents:
21784
diff
changeset
|
133 } else if (add.getY().isConstant()) { |
2766fee1809a
Use the fact that a range checked array index is not negative to avoid sign-extension of the index register.
Roland Schatz <roland.schatz@oracle.com>
parents:
21784
diff
changeset
|
134 return improveConstDisp(address, node, add.getY().asJavaConstant(), add.getX(), shift); |
2766fee1809a
Use the fact that a range checked array index is not negative to avoid sign-extension of the index register.
Roland Schatz <roland.schatz@oracle.com>
parents:
21784
diff
changeset
|
135 } |
2766fee1809a
Use the fact that a range checked array index is not negative to avoid sign-extension of the index register.
Roland Schatz <roland.schatz@oracle.com>
parents:
21784
diff
changeset
|
136 } |
21784
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
137 } |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
138 } |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
139 |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
140 return node; |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
141 } |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
142 |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
143 private ValueNode improveConstDisp(AMD64AddressNode address, ValueNode original, JavaConstant c, ValueNode other, int shift) { |
22604
b00cc0475f31
Update jvmci import: Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22054
diff
changeset
|
144 if (c.getJavaKind().isNumericInteger() && !codeCache.needsDataPatch(c)) { |
21784
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
145 long disp = address.getDisplacement(); |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
146 disp += c.asLong() << shift; |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
147 if (NumUtil.isInt(disp)) { |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
148 address.setDisplacement((int) disp); |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
149 return other; |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
150 } |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
151 } |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
152 return original; |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
153 } |
f4e1d958f1c3
[AMD64] Create AMD64 specific address nodes.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
154 } |