001 /*
002 * This file is part of the Jikes RVM project (http://jikesrvm.org).
003 *
004 * This file is licensed to You under the Eclipse Public License (EPL);
005 * You may not use this file except in compliance with the License. You
006 * may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/eclipse-1.0.php
009 *
010 * See the COPYRIGHT.txt file distributed with this work for information
011 * regarding copyright ownership.
012 */
013 package org.vmmagic.unboxed;
014
015 import org.vmmagic.Unboxed;
016 import org.vmmagic.pragma.RawStorage;
017
018 /**
019 * A generic pointer-sized integer. Can be converted to/from other pointer-sized types, and
020 * provides shifting and masking operations.
021 */
022 @Unboxed
023 @RawStorage(lengthInWords = true, length = 1)
024 public final class Word {
025
026 /**
027 * Convert an int to a word. On 64-bit machines, sign-extend the high order bit.
028 *
029 * @param val
030 * @return A word instance whose value is val, sign-extended on 64 bit machines
031 */
032 public static Word fromIntSignExtend(int val) {
033 return null;
034 }
035
036 /**
037 * Convert an int to a word. On 64-bit machines, zero-extend the high order bit.
038 *
039 * @param val
040 * @return A word instance whose value is val, zero-extended on 64 bit machines
041 */
042 public static Word fromIntZeroExtend(int val) {
043 return null;
044 }
045
046 /**
047 * Convert a long to a word. On 64-bit this is a no-op, on 32-bit the long is truncated.
048 *
049 * @param val
050 * @return A word instance whose value is val on 32 bit machine this truncates the upper 32 bits.
051 */
052 public static Word fromLong(long val) {
053 return null;
054 }
055
056 /**
057 * The Word constant 0.
058 * Equivalent to Word.fromIntSignExtend(0), but more readable.
059 *
060 * @return the Word constant 0.
061 */
062 public static Word zero() {
063 return null;
064 }
065
066 /**
067 * The Word constant 1.
068 * Equivalent to Word.fromIntSignExtend(1), but more readable.
069 *
070 * @return the Word constant 1.
071 */
072 public static Word one() {
073 return null;
074 }
075
076 /**
077 * The maximum representable Word value. Words are unsigned, so this is
078 * a word full of 1s, 32/64-bit safe.
079 *
080 * @return the maximum representable Word value
081 */
082 public static Word max() {
083 return null;
084 }
085
086 /**
087 * Type-cast to an int, truncating on 64-bit platforms.
088 *
089 * @return an int, with the same value as the word on 32 bit platforms; truncates on 64 bit platforms.
090 */
091 public int toInt() {
092 return 0;
093 }
094
095 /**
096 * Type-cast to a long, zero-extending on a 32-bit platform.
097 * @return a long, with the same value as the word (zero extends on 32 bit platforms).
098 */
099 public long toLong() {
100 return 0L;
101 }
102
103 /** Type-cast to an address. */
104 public Address toAddress() {
105 return null;
106 }
107
108 /** Type-cast to an offset */
109 public Offset toOffset() {
110 return null;
111 }
112
113 /** Type-cast to an extent */
114 public Extent toExtent() {
115 return null;
116 }
117
118 /**
119 * Add two words
120 *
121 * @param w2
122 * @return The word whose value is this+w2
123 */
124 public Word plus(Word w2) {
125 return null;
126 }
127
128 /**
129 * Add an offset to a word
130 * @param w2
131 * @return The word whose value is this+w2
132 */
133 public Word plus(Offset w2) {
134 return null;
135 }
136
137 /**
138 * Add an extent to a word
139 * @param w2
140 * @return The word whose value is this+w2
141 */
142 public Word plus(Extent w2) {
143 return null;
144 }
145
146 /**
147 * Subtract two words
148 * @param w2
149 * @return The word whose value is this-w2
150 */
151 public Word minus(Word w2) {
152 return null;
153 }
154
155 /**
156 * Subtract an offset from a word
157 * @param w2
158 * @return The word whose value is this-w2
159 */
160 public Word minus(Offset w2) {
161 return null;
162 }
163
164 /**
165 * Subtract an extent from a word.
166 * @param w2
167 * @return The word whose value is this-w2
168 */
169 public Word minus(Extent w2) {
170 return null;
171 }
172
173 /**
174 * Test for zero. Equivalent to .EQ(Word.zero())
175 * @return return true if this is equal to Word.zero(), false otherwise
176 */
177 public boolean isZero() {
178 return false;
179 }
180
181 /**
182 * Test for zero. Equivalent to .EQ(Word.max())
183 * @return true if this is equal to Word.max(), false otherwise
184 */
185 public boolean isMax() {
186 return false;
187 }
188
189 /**
190 * Less-than comparison
191 * @param addr2
192 * @return true if this <code>Word</code> instance is <i>less than</i> <code>addr2</code>
193 */
194 public boolean LT(Word addr2) {
195 return false;
196 }
197
198 /**
199 * Less-than or equal comparison
200 * @param w2
201 * @return true if this <code>Word</code> instance is <i>less than or equal to</i> <code>w2</code>
202 */
203 public boolean LE(Word w2) {
204 return false;
205 }
206
207 /**
208 * Greater-than comparison
209 * @param w2
210 * @return true if this <code>Word</code> instance is <i>greater than</i> <code>w2</code>
211 */
212 public boolean GT(Word w2) {
213 return false;
214 }
215
216 /**
217 * Greater-than or equal comparison
218 * @param w2
219 * @return true if this <code>Word</code> instance is <i>greater than or equal to</i> <code>w2</code>
220 */
221 public boolean GE(Word w2) {
222 return false;
223 }
224
225 /**
226 * Equality comparison
227 * @param w2
228 * @return true if this <code>Word</code> instance is <i>equal to</i> <code>w2</code>
229 */
230 public boolean EQ(Word w2) {
231 return false;
232 }
233
234 /**
235 * Not-equal comparison
236 * @param w2
237 * @return true if this <code>Word</code> instance is <i>not equal to</i> <code>w2</code>
238 */
239 public boolean NE(Word w2) {
240 return false;
241 }
242
243 /**
244 * Bit-wise and of two words.
245 * @param w2
246 * @return The word whose value is the bitwise and of this and w2
247 */
248 public Word and(Word w2) {
249 return null;
250 }
251
252 /**
253 * Bit-wise or of two words.
254 * @param w2
255 * @return The word whose value is the bitwise not of this and w2
256 */
257 public Word or(Word w2) {
258 return null;
259 }
260
261 /**
262 * Bit-wise complement of a word.
263 * @return the bitwise complement of this
264 */
265 public Word not() {
266 return null;
267 }
268
269 /**
270 * Bit-wise exclusive or of two words.
271 * @param w2
272 * @return The word whose value is the bitwise xor of this and w2
273 */
274 public Word xor(Word w2) {
275 return null;
276 }
277
278 /**
279 * Left-shift a word. Shifts of a size greater than the Word are undefined and
280 * have an architecture and compiler specific behaviour. On Intel the shift
281 * amount ignores the most significant bits, for example for a 32bit Word 1
282 * << 32 == 1, the result will be 0 on PowerPC. Shifts may or may not be
283 * combined by the compiler, this yields differing behaviour, for example for a
284 * 32bit Word 1 <<32 may or may not equal 1 << 16 << 16.
285 *
286 * @param amt the amount to shift by
287 * @return new Word shifted by the given amount
288 */
289 public Word lsh(int amt) {
290 return null;
291 }
292
293 /**
294 * Logical right-shift a word. Shifts of a size greater than the Word are undefined and
295 * have an architecture and compiler specific behaviour see also {@link #lsh(int)}.
296 *
297 * @param amt the amount to shift by
298 * @return new Word shifted by the given amount
299 */
300 public Word rshl(int amt) {
301 return null;
302 }
303
304 /**
305 * Arithmetic right-shift a word. Shifts of a size greater than the Word are undefined and
306 * have an architecture and compiler specific behaviour see also {@link #lsh(int)}.
307 * Arithmetic right-shift a word. Equivalent to the integer <code>>></code> operator
308 *
309 * @param amt the amount to shift by
310 * @return new Word shifted by the given amount
311 */
312 public Word rsha(int amt) {
313 return null;
314 }
315 }
316