comparison graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCImmediateAddressValue.java @ 21785:06cd28cccc64

[SPARC] Create SPARC specific address nodes.
author Roland Schatz <roland.schatz@oracle.com>
date Mon, 08 Jun 2015 19:19:51 +0200
parents graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCAddressValue.java@d915361cc3a1
children
comparison
equal deleted inserted replaced
21784:f4e1d958f1c3 21785:06cd28cccc64
1 /*
2 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23 package com.oracle.graal.lir.sparc;
24
25 import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
26 import static com.oracle.jvmci.code.ValueUtil.*;
27
28 import java.util.*;
29
30 import com.oracle.graal.asm.sparc.*;
31 import com.oracle.graal.lir.*;
32 import com.oracle.graal.lir.LIRInstruction.OperandFlag;
33 import com.oracle.graal.lir.LIRInstruction.OperandMode;
34 import com.oracle.jvmci.meta.*;
35
36 public final class SPARCImmediateAddressValue extends SPARCAddressValue {
37
38 @Component({REG}) protected AllocatableValue base;
39 protected final int displacement;
40
41 private static final EnumSet<OperandFlag> flags = EnumSet.of(OperandFlag.REG);
42
43 public SPARCImmediateAddressValue(LIRKind kind, AllocatableValue base, int displacement) {
44 super(kind);
45 assert SPARCAssembler.isSimm13(displacement);
46 this.base = base;
47 this.displacement = displacement;
48 }
49
50 @Override
51 public CompositeValue forEachComponent(LIRInstruction inst, OperandMode mode, InstructionValueProcedure proc) {
52 AllocatableValue newBase = (AllocatableValue) proc.doValue(inst, base, mode, flags);
53 if (!base.identityEquals(newBase)) {
54 return new SPARCImmediateAddressValue(getLIRKind(), newBase, displacement);
55 }
56 return this;
57 }
58
59 @Override
60 protected void forEachComponent(LIRInstruction inst, OperandMode mode, InstructionValueConsumer proc) {
61 proc.visitValue(inst, base, mode, flags);
62 }
63
64 @Override
65 public SPARCAddress toAddress() {
66 return new SPARCAddress(asRegister(base), displacement);
67 }
68
69 @Override
70 public boolean isValidImplicitNullCheckFor(Value value, int implicitNullCheckLimit) {
71 return value.equals(base) && displacement >= 0 && displacement < implicitNullCheckLimit;
72 }
73
74 @Override
75 public String toString() {
76 StringBuilder s = new StringBuilder("[");
77 String sep = "";
78 if (isLegal(base)) {
79 s.append(base);
80 sep = " + ";
81 }
82 if (displacement < 0) {
83 s.append(" - ").append(-displacement);
84 } else if (displacement > 0) {
85 s.append(sep).append(displacement);
86 }
87 s.append("]");
88 return s.toString();
89 }
90
91 @Override
92 public boolean equals(Object obj) {
93 if (obj instanceof SPARCImmediateAddressValue) {
94 SPARCImmediateAddressValue addr = (SPARCImmediateAddressValue) obj;
95 return getLIRKind().equals(addr.getLIRKind()) && displacement == addr.displacement && base.equals(addr.base);
96 }
97 return false;
98 }
99
100 @Override
101 public int hashCode() {
102 return base.hashCode() ^ (displacement << 4) ^ getLIRKind().hashCode();
103 }
104 }