comparison graal/com.oracle.jvmci.code/src/com/oracle/jvmci/code/TargetDescription.java @ 21556:48c1ebd24120

renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
author Doug Simon <doug.simon@oracle.com>
date Wed, 27 May 2015 00:36:16 +0200
parents graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/TargetDescription.java@bd74da0a76f3
children
comparison
equal deleted inserted replaced
21555:d12eaef9af72 21556:48c1ebd24120
1 /*
2 * Copyright (c) 2009, 2014, 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.jvmci.code;
24
25 import com.oracle.jvmci.meta.Kind;
26 import com.oracle.jvmci.meta.PlatformKind;
27 import com.oracle.jvmci.meta.LIRKind;
28 import static com.oracle.jvmci.meta.MetaUtil.*;
29
30 /**
31 * Represents the target machine for a compiler, including the CPU architecture, the size of
32 * pointers and references, alignment of stacks, caches, etc.
33 */
34 public abstract class TargetDescription {
35
36 public final Architecture arch;
37
38 /**
39 * Specifies if this is a multi-processor system.
40 */
41 public final boolean isMP;
42
43 /**
44 * Specifies if this target supports encoding objects inline in the machine code.
45 */
46 public final boolean inlineObjects;
47
48 /**
49 * The machine word size on this target.
50 */
51 public final int wordSize;
52
53 /**
54 * The kind to be used for representing raw pointers and CPU registers.
55 */
56 public final Kind wordKind;
57
58 /**
59 * The stack alignment requirement of the platform. For example, from Appendix D of <a
60 * href="http://www.intel.com/Assets/PDF/manual/248966.pdf">Intel 64 and IA-32 Architectures
61 * Optimization Reference Manual</a>:
62 *
63 * <pre>
64 * "It is important to ensure that the stack frame is aligned to a
65 * 16-byte boundary upon function entry to keep local __m128 data,
66 * parameters, and XMM register spill locations aligned throughout
67 * a function invocation."
68 * </pre>
69 */
70 public final int stackAlignment;
71
72 /**
73 * Maximum constant displacement at which a memory access can no longer be an implicit null
74 * check.
75 */
76 public final int implicitNullCheckLimit;
77
78 public TargetDescription(Architecture arch, boolean isMP, int stackAlignment, int implicitNullCheckLimit, boolean inlineObjects) {
79 this.arch = arch;
80 this.isMP = isMP;
81 this.wordSize = arch.getWordSize();
82 this.wordKind = Kind.fromWordSize(wordSize);
83 this.stackAlignment = stackAlignment;
84 this.implicitNullCheckLimit = implicitNullCheckLimit;
85 this.inlineObjects = inlineObjects;
86 }
87
88 @Override
89 public final int hashCode() {
90 throw new UnsupportedOperationException();
91 }
92
93 @Override
94 public final boolean equals(Object obj) {
95 if (this == obj) {
96 return true;
97 }
98 if (obj instanceof TargetDescription) {
99 TargetDescription that = (TargetDescription) obj;
100 // @formatter:off
101 if (this.implicitNullCheckLimit == that.implicitNullCheckLimit &&
102 this.inlineObjects == that.inlineObjects &&
103 this.isMP == that.isMP &&
104 this.stackAlignment == that.stackAlignment &&
105 this.wordKind.equals(that.wordKind) &&
106 this.wordSize == that.wordSize &&
107 this.arch.equals(that.arch)) {
108 return true;
109 }
110 // @formatter:on
111 }
112 return false;
113 }
114
115 @Override
116 public String toString() {
117 return identityHashCodeString(this);
118 }
119
120 public int getSizeInBytes(PlatformKind kind) {
121 return arch.getSizeInBytes(kind);
122 }
123
124 public LIRKind getLIRKind(Kind javaKind) {
125 switch (javaKind) {
126 case Boolean:
127 case Byte:
128 case Short:
129 case Char:
130 case Int:
131 case Long:
132 case Float:
133 case Double:
134 return LIRKind.value(javaKind);
135 case Object:
136 return LIRKind.reference(javaKind);
137 default:
138 return LIRKind.Illegal;
139 }
140 }
141
142 public abstract ReferenceMap createReferenceMap(boolean hasRegisters, int stackSlotCount);
143 }