Mercurial > hg > truffle
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 |
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 | 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 | 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 | 42 public SPARCAddressValue(PlatformKind kind, AllocatableValue base, int displacement) { |
43 this(kind, base, Value.ILLEGAL, displacement); | |
44 } | |
45 | |
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 | 48 assert isIllegal(index) || displacement == 0; |
10792 | 49 this.base = base; |
50 this.index = index; | |
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 | 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 | 64 if (isLegal(index)) { |
65 return new SPARCAddress(toRegister(base), toRegister(index)); | |
66 } else { | |
67 return new SPARCAddress(toRegister(base), displacement); | |
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 | 71 @Override |
72 public String toString() { | |
73 StringBuilder s = new StringBuilder("["); | |
74 String sep = ""; | |
75 if (isLegal(base)) { | |
76 s.append(base); | |
77 sep = " + "; | |
78 } | |
79 if (isLegal(index)) { | |
80 s.append(sep).append(index); | |
81 sep = " + "; | |
82 } else { | |
83 if (displacement < 0) { | |
84 s.append(" - ").append(-displacement); | |
85 } else if (displacement > 0) { | |
86 s.append(sep).append(displacement); | |
87 } | |
88 } | |
89 s.append("]"); | |
90 return s.toString(); | |
91 } | |
92 | |
93 @Override | |
94 public boolean equals(Object obj) { | |
95 if (obj instanceof SPARCAddressValue) { | |
96 SPARCAddressValue addr = (SPARCAddressValue) obj; | |
97 return getPlatformKind() == addr.getPlatformKind() && displacement == addr.displacement && base.equals(addr.base) && index.equals(addr.index); | |
98 } | |
99 return false; | |
100 } | |
101 | |
102 @Override | |
103 public int hashCode() { | |
104 return base.hashCode() ^ index.hashCode() ^ (displacement << 4) ^ getPlatformKind().hashCode(); | |
105 } | |
9828
5aedcaed6ccf
Initial SPARC control instructions
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
106 } |