Mercurial > hg > graal-compiler
comparison graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Architecture.java @ 6582:cc32ce37eddc
deleted Architecture.twoOperandMode() and encapsulated all public fields in Architecture with getters
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 25 Oct 2012 20:08:32 +0200 |
parents | 2a456986716b |
children | 5e3d1a68664e |
comparison
equal
deleted
inserted
replaced
6581:2a456986716b | 6582:cc32ce37eddc |
---|---|
43 | 43 |
44 /** | 44 /** |
45 * The number of bits required in a bit map covering all the registers that may store references. | 45 * The number of bits required in a bit map covering all the registers that may store references. |
46 * The bit position of a register in the map is the register's {@linkplain Register#number number}. | 46 * The bit position of a register in the map is the register's {@linkplain Register#number number}. |
47 */ | 47 */ |
48 public final int registerReferenceMapBitCount; | 48 private final int registerReferenceMapBitCount; |
49 | 49 |
50 /** | 50 /** |
51 * Represents the natural size of words (typically registers and pointers) of this architecture, in bytes. | 51 * Represents the natural size of words (typically registers and pointers) of this architecture, in bytes. |
52 */ | 52 */ |
53 public final int wordSize; | 53 private final int wordSize; |
54 | 54 |
55 /** | 55 /** |
56 * The name of this architecture (e.g. "AMD64", "SPARCv9"). | 56 * The name of this architecture (e.g. "AMD64", "SPARCv9"). |
57 */ | 57 */ |
58 public final String name; | 58 private final String name; |
59 | 59 |
60 /** | 60 /** |
61 * Array of all available registers on this architecture. The index of each register in this | 61 * Array of all available registers on this architecture. The index of each register in this |
62 * array is equal to its {@linkplain Register#number number}. | 62 * array is equal to its {@linkplain Register#number number}. |
63 */ | 63 */ |
64 public final Register[] registers; | 64 private final Register[] registers; |
65 | |
66 /** | |
67 * Map of all registers keyed by their {@linkplain Register#name names}. | |
68 */ | |
69 public final HashMap<String, Register> registersByName; | |
70 | 65 |
71 /** | 66 /** |
72 * The byte ordering can be either little or big endian. | 67 * The byte ordering can be either little or big endian. |
73 */ | 68 */ |
74 public final ByteOrder byteOrder; | 69 private final ByteOrder byteOrder; |
75 | 70 |
76 /** | 71 /** |
77 * Mask of the barrier constants denoting the barriers that | 72 * Mask of the barrier constants denoting the barriers that |
78 * are not required to be explicitly inserted under this architecture. | 73 * are not required to be explicitly inserted under this architecture. |
79 */ | 74 */ |
80 public final int implicitMemoryBarriers; | 75 private final int implicitMemoryBarriers; |
81 | |
82 /** | |
83 * Determines the barriers in a given barrier mask that are explicitly required on this architecture. | |
84 * | |
85 * @param barriers a mask of the barrier constants | |
86 * @return the value of {@code barriers} minus the barriers unnecessary on this architecture | |
87 */ | |
88 public final int requiredBarriers(int barriers) { | |
89 return barriers & ~implicitMemoryBarriers; | |
90 } | |
91 | 76 |
92 /** | 77 /** |
93 * Offset in bytes from the beginning of a call instruction to the displacement. | 78 * Offset in bytes from the beginning of a call instruction to the displacement. |
94 */ | 79 */ |
95 public final int machineCodeCallDisplacementOffset; | 80 private final int machineCodeCallDisplacementOffset; |
96 | 81 |
97 /** | 82 /** |
98 * The size of the return address pushed to the stack by a call instruction. | 83 * The size of the return address pushed to the stack by a call instruction. |
99 * A value of 0 denotes that call linkage uses registers instead (e.g. SPARC). | 84 * A value of 0 denotes that call linkage uses registers instead (e.g. SPARC). |
100 */ | 85 */ |
101 public final int returnAddressSize; | 86 private final int returnAddressSize; |
102 | 87 |
103 private final EnumMap<RegisterFlag, Register[]> registersByTypeAndEncoding; | 88 private final EnumMap<RegisterFlag, Register[]> registersByTypeAndEncoding; |
104 | 89 |
105 /** | 90 /** |
106 * Gets the register for a given {@linkplain Register#encoding encoding} and type. | 91 * Gets the register for a given {@linkplain Register#encoding encoding} and type. |
131 this.implicitMemoryBarriers = implicitMemoryBarriers; | 116 this.implicitMemoryBarriers = implicitMemoryBarriers; |
132 this.machineCodeCallDisplacementOffset = nativeCallDisplacementOffset; | 117 this.machineCodeCallDisplacementOffset = nativeCallDisplacementOffset; |
133 this.registerReferenceMapBitCount = registerReferenceMapBitCount; | 118 this.registerReferenceMapBitCount = registerReferenceMapBitCount; |
134 this.returnAddressSize = returnAddressSize; | 119 this.returnAddressSize = returnAddressSize; |
135 | 120 |
136 registersByName = new HashMap<>(registers.length); | |
137 for (Register register : registers) { | |
138 registersByName.put(register.name, register); | |
139 assert registers[register.number] == register; | |
140 } | |
141 | |
142 registersByTypeAndEncoding = new EnumMap<>(RegisterFlag.class); | 121 registersByTypeAndEncoding = new EnumMap<>(RegisterFlag.class); |
143 EnumMap<RegisterFlag, Register[]> categorizedRegs = Register.categorize(registers); | 122 EnumMap<RegisterFlag, Register[]> categorizedRegs = Register.categorize(registers); |
144 for (RegisterFlag type : RegisterFlag.values()) { | 123 for (RegisterFlag type : RegisterFlag.values()) { |
145 Register[] regs = categorizedRegs.get(type); | 124 Register[] regs = categorizedRegs.get(type); |
146 int max = Register.maxRegisterEncoding(regs); | 125 int max = Register.maxRegisterEncoding(regs); |
156 * Converts this architecture to a string. | 135 * Converts this architecture to a string. |
157 * @return the string representation of this architecture | 136 * @return the string representation of this architecture |
158 */ | 137 */ |
159 @Override | 138 @Override |
160 public final String toString() { | 139 public final String toString() { |
161 return name.toLowerCase(); | 140 return getName().toLowerCase(); |
162 } | 141 } |
163 | 142 |
164 /** | 143 public int getRegisterReferenceMapBitCount() { |
165 * Checks whether this is a 32-bit architecture. | 144 return registerReferenceMapBitCount; |
166 * @return {@code true} if this architecture is 32-bit | 145 } |
167 */ | 146 |
168 public final boolean is32bit() { | 147 /** |
169 return wordSize == 4; | 148 * Gets the natural size of words (typically registers and pointers) of this architecture, in bytes. |
170 } | 149 */ |
171 | 150 public int getWordSize() { |
172 /** | 151 return wordSize; |
173 * Checks whether this is a 64-bit architecture. | 152 } |
174 * @return {@code true} if this architecture is 64-bit | 153 |
175 */ | 154 /** |
176 public final boolean is64bit() { | 155 * Gets the name of this architecture. |
177 return wordSize == 8; | 156 */ |
178 } | 157 public String getName() { |
179 | 158 return name; |
180 /** | 159 } |
181 * Checks whether this architecture's normal arithmetic instructions use a two-operand form | 160 |
182 * (e.g. x86 which overwrites one operand register with the result when adding). | 161 /** |
183 * @return {@code true} if this architecture uses two-operand mode | 162 * Gets an array of all available registers on this architecture. The index of each register in this |
184 */ | 163 * array is equal to its {@linkplain Register#number number}. |
185 public abstract boolean twoOperandMode(); | 164 */ |
165 public Register[] getRegisters() { | |
166 return registers.clone(); | |
167 } | |
168 | |
169 public ByteOrder getByteOrder() { | |
170 return byteOrder; | |
171 } | |
172 | |
173 /** | |
174 * Gets a mask of the barrier constants denoting the barriers that | |
175 * are not required to be explicitly inserted under this architecture. | |
176 */ | |
177 public int getImplicitMemoryBarriers() { | |
178 return implicitMemoryBarriers; | |
179 } | |
180 | |
181 /** | |
182 * Gets the size of the return address pushed to the stack by a call instruction. | |
183 * A value of 0 denotes that call linkage uses registers instead. | |
184 */ | |
185 public int getReturnAddressSize() { | |
186 return returnAddressSize; | |
187 } | |
188 | |
189 /** | |
190 * Gets the offset in bytes from the beginning of a call instruction to the displacement. | |
191 */ | |
192 public int getMachineCodeCallDisplacementOffset() { | |
193 return machineCodeCallDisplacementOffset; | |
194 } | |
195 | |
196 /** | |
197 * Determines the barriers in a given barrier mask that are explicitly required on this architecture. | |
198 * | |
199 * @param barriers a mask of the barrier constants | |
200 * @return the value of {@code barriers} minus the barriers unnecessary on this architecture | |
201 */ | |
202 public final int requiredBarriers(int barriers) { | |
203 return barriers & ~implicitMemoryBarriers; | |
204 } | |
186 } | 205 } |