annotate graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCAddressValue.java @ 13367:413040ab993e

remove some usages of HashSet
author Bernhard Urban <bernhard.urban@jku.at>
date Tue, 17 Dec 2013 16:00:57 +0100
parents 5a9d68c3a7d7
children 64dcb92ee75a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
1 /*
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
4 *
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
8 *
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
13 * accompanied this code).
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
14 *
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
18 *
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
21 * questions.
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
22 */
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
23 package com.oracle.graal.lir.sparc;
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
24
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
25 import static com.oracle.graal.api.code.ValueUtil.*;
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
26 import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
27
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
28 import com.oracle.graal.api.code.*;
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
29 import com.oracle.graal.api.meta.*;
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
30 import com.oracle.graal.asm.sparc.*;
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
31 import com.oracle.graal.lir.*;
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
32 import com.oracle.graal.lir.LIRInstruction.*;
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
33
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
34 public class SPARCAddressValue extends CompositeValue {
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
35
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
36 private static final long serialVersionUID = -3583286416638228207L;
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
37
10481
29e9a5d18c70 Clean up.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9831
diff changeset
38 @Component({REG, OperandFlag.ILLEGAL}) protected AllocatableValue base;
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
39 @Component({REG, OperandFlag.ILLEGAL}) protected AllocatableValue index;
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
40 protected final int displacement;
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
41
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
42 public SPARCAddressValue(PlatformKind kind, AllocatableValue base, int displacement) {
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
43 this(kind, base, Value.ILLEGAL, displacement);
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
44 }
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
45
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
46 public SPARCAddressValue(PlatformKind kind, AllocatableValue base, AllocatableValue index, int displacement) {
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
47 super(kind);
11233
5a9d68c3a7d7 SPARC: a lot of fixes and more
twisti
parents: 10792
diff changeset
48 assert isIllegal(index) || displacement == 0;
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
49 this.base = base;
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
50 this.index = index;
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
51 this.displacement = displacement;
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
52 }
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
53
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
54 private static Register toRegister(AllocatableValue value) {
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
55 if (isIllegal(value)) {
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
56 return Register.None;
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
57 } else {
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
58 RegisterValue reg = (RegisterValue) value;
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
59 return reg.getRegister();
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
60 }
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
61 }
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
62
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
63 public SPARCAddress toAddress() {
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
64 if (isLegal(index)) {
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
65 return new SPARCAddress(toRegister(base), toRegister(index));
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
66 } else {
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
67 return new SPARCAddress(toRegister(base), displacement);
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
68 }
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
69 }
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
70
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
71 @Override
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
72 public String toString() {
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
73 StringBuilder s = new StringBuilder("[");
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
74 String sep = "";
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
75 if (isLegal(base)) {
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
76 s.append(base);
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
77 sep = " + ";
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
78 }
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
79 if (isLegal(index)) {
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
80 s.append(sep).append(index);
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
81 sep = " + ";
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
82 } else {
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
83 if (displacement < 0) {
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
84 s.append(" - ").append(-displacement);
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
85 } else if (displacement > 0) {
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
86 s.append(sep).append(displacement);
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
87 }
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
88 }
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
89 s.append("]");
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
90 return s.toString();
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
91 }
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
92
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
93 @Override
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
94 public boolean equals(Object obj) {
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
95 if (obj instanceof SPARCAddressValue) {
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
96 SPARCAddressValue addr = (SPARCAddressValue) obj;
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
97 return getPlatformKind() == addr.getPlatformKind() && displacement == addr.displacement && base.equals(addr.base) && index.equals(addr.index);
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
98 }
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
99 return false;
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
100 }
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
101
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
102 @Override
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
103 public int hashCode() {
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
104 return base.hashCode() ^ index.hashCode() ^ (displacement << 4) ^ getPlatformKind().hashCode();
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10481
diff changeset
105 }
9828
5aedcaed6ccf Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff changeset
106 }