annotate graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/PrimitiveStamp.java @ 18482:b8a622c3e99f

Move raw memory access operations to a separate interface.
author Roland Schatz <roland.schatz@oracle.com>
date Thu, 20 Nov 2014 17:00:19 +0100
parents a3a2359ac88e
children 48c1ebd24120
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
1 /*
18359
a3a2359ac88e Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents: 17197
diff changeset
2 * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved.
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
4 *
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
8 *
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
13 * accompanied this code).
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
14 *
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
18 *
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
21 * questions.
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
22 */
16314
f57cf459f5d3 [SPARC] Adding deoptimization handler foreign call
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15198
diff changeset
23 package com.oracle.graal.compiler.common.type;
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
24
18359
a3a2359ac88e Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents: 17197
diff changeset
25 import com.oracle.graal.api.meta.*;
a3a2359ac88e Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents: 17197
diff changeset
26
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
27 /**
16314
f57cf459f5d3 [SPARC] Adding deoptimization handler foreign call
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 15198
diff changeset
28 * Type describing primitive values.
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
29 */
17197
ec35bb4eccb8 Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 16330
diff changeset
30 public abstract class PrimitiveStamp extends ArithmeticStamp {
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
31
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
32 private final int bits;
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
33
17197
ec35bb4eccb8 Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 16330
diff changeset
34 protected PrimitiveStamp(int bits, ArithmeticOpTable ops) {
ec35bb4eccb8 Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 16330
diff changeset
35 super(ops);
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
36 this.bits = bits;
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
37 }
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
38
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
39 /**
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
40 * The width in bits of the value described by this stamp.
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
41 */
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
42 public int getBits() {
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
43 return bits;
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
44 }
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
45
14000
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
46 public static int getBits(Stamp stamp) {
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
47 if (stamp instanceof PrimitiveStamp) {
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
48 return ((PrimitiveStamp) stamp).getBits();
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
49 } else {
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
50 return 0;
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
51 }
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
52 }
958c99d0790c Split convert node into separate nodes for different conversions.
Roland Schatz <roland.schatz@oracle.com>
parents: 13999
diff changeset
53
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
54 @Override
18482
b8a622c3e99f Move raw memory access operations to a separate interface.
Roland Schatz <roland.schatz@oracle.com>
parents: 18359
diff changeset
55 public Constant readConstant(MemoryAccessProvider provider, Constant base, long displacement) {
b8a622c3e99f Move raw memory access operations to a separate interface.
Roland Schatz <roland.schatz@oracle.com>
parents: 18359
diff changeset
56 return provider.readPrimitiveConstant(getStackKind(), base, displacement, getBits());
18359
a3a2359ac88e Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents: 17197
diff changeset
57 }
a3a2359ac88e Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents: 17197
diff changeset
58
a3a2359ac88e Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents: 17197
diff changeset
59 @Override
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
60 public int hashCode() {
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
61 final int prime = 31;
17197
ec35bb4eccb8 Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 16330
diff changeset
62 int result = super.hashCode();
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
63 result = prime * result + bits;
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
64 return result;
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
65 }
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
66
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
67 @Override
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
68 public boolean equals(Object obj) {
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
69 if (this == obj) {
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
70 return true;
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
71 }
17197
ec35bb4eccb8 Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 16330
diff changeset
72 if (!(obj instanceof PrimitiveStamp)) {
ec35bb4eccb8 Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 16330
diff changeset
73 return false;
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
74 }
17197
ec35bb4eccb8 Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 16330
diff changeset
75 PrimitiveStamp other = (PrimitiveStamp) obj;
ec35bb4eccb8 Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 16330
diff changeset
76 if (bits != other.bits) {
ec35bb4eccb8 Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 16330
diff changeset
77 return false;
ec35bb4eccb8 Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 16330
diff changeset
78 }
ec35bb4eccb8 Add support for other data types to integer arithmetic nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 16330
diff changeset
79 return super.equals(obj);
13999
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
80 }
f2b300c6e621 Refactor Stamp hierarchy.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
81 }