001/* 002 * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. 003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 004 * 005 * This code is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU General Public License version 2 only, as 007 * published by the Free Software Foundation. 008 * 009 * This code is distributed in the hope that it will be useful, but WITHOUT 010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 011 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 012 * version 2 for more details (a copy is included in the LICENSE file that 013 * accompanied this code). 014 * 015 * You should have received a copy of the GNU General Public License version 016 * 2 along with this work; if not, write to the Free Software Foundation, 017 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 018 * 019 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 020 * or visit www.oracle.com if you need additional information or have any 021 * questions. 022 */ 023package com.oracle.graal.word; 024 025public interface Unsigned extends ComparableWord { 026 027 /** 028 * Returns a Unsigned whose value is {@code (this + val)}. 029 * 030 * @param val value to be added to this Unsigned. 031 * @return {@code this + val} 032 */ 033 Unsigned add(Unsigned val); 034 035 /** 036 * Returns a Unsigned whose value is {@code (this - val)}. 037 * 038 * @param val value to be subtracted from this Unsigned. 039 * @return {@code this - val} 040 */ 041 Unsigned subtract(Unsigned val); 042 043 /** 044 * Returns a Unsigned whose value is {@code (this * val)}. 045 * 046 * @param val value to be multiplied by this Unsigned. 047 * @return {@code this * val} 048 */ 049 Unsigned multiply(Unsigned val); 050 051 /** 052 * Returns a Unsigned whose value is {@code (this / val)}. 053 * 054 * @param val value by which this Unsigned is to be divided. 055 * @return {@code this / val} 056 */ 057 Unsigned unsignedDivide(Unsigned val); 058 059 /** 060 * Returns a Unsigned whose value is {@code (this % val)}. 061 * 062 * @param val value by which this Unsigned is to be divided, and the remainder computed. 063 * @return {@code this % val} 064 */ 065 Unsigned unsignedRemainder(Unsigned val); 066 067 /** 068 * Returns a Unsigned whose value is {@code (this << n)}. 069 * 070 * @param n shift distance, in bits. 071 * @return {@code this << n} 072 */ 073 Unsigned shiftLeft(Unsigned n); 074 075 /** 076 * Returns a Unsigned whose value is {@code (this >>> n)}. No sign extension is performed. 077 * 078 * @param n shift distance, in bits. 079 * @return {@code this >> n} 080 */ 081 Unsigned unsignedShiftRight(Unsigned n); 082 083 /** 084 * Returns a Unsigned whose value is {@code (this & val)}. 085 * 086 * @param val value to be AND'ed with this Unsigned. 087 * @return {@code this & val} 088 */ 089 Unsigned and(Unsigned val); 090 091 /** 092 * Returns a Unsigned whose value is {@code (this | val)}. 093 * 094 * @param val value to be OR'ed with this Unsigned. 095 * @return {@code this | val} 096 */ 097 Unsigned or(Unsigned val); 098 099 /** 100 * Returns a Unsigned whose value is {@code (this ^ val)}. 101 * 102 * @param val value to be XOR'ed with this Unsigned. 103 * @return {@code this ^ val} 104 */ 105 Unsigned xor(Unsigned val); 106 107 /** 108 * Returns a Unsigned whose value is {@code (~this)}. 109 * 110 * @return {@code ~this} 111 */ 112 Unsigned not(); 113 114 /** 115 * Compares this Unsigned with the specified value. 116 * 117 * @param val value to which this Unsigned is to be compared. 118 * @return {@code this == val} 119 */ 120 boolean equal(Unsigned val); 121 122 /** 123 * Compares this Unsigned with the specified value. 124 * 125 * @param val value to which this Unsigned is to be compared. 126 * @return {@code this != val} 127 */ 128 boolean notEqual(Unsigned val); 129 130 /** 131 * Compares this Unsigned with the specified value. 132 * 133 * @param val value to which this Unsigned is to be compared. 134 * @return {@code this < val} 135 */ 136 boolean belowThan(Unsigned val); 137 138 /** 139 * Compares this Unsigned with the specified value. 140 * 141 * @param val value to which this Unsigned is to be compared. 142 * @return {@code this <= val} 143 */ 144 boolean belowOrEqual(Unsigned val); 145 146 /** 147 * Compares this Unsigned with the specified value. 148 * 149 * @param val value to which this Unsigned is to be compared. 150 * @return {@code this > val} 151 */ 152 boolean aboveThan(Unsigned val); 153 154 /** 155 * Compares this Unsigned with the specified value. 156 * 157 * @param val value to which this Unsigned is to be compared. 158 * @return {@code this >= val} 159 */ 160 boolean aboveOrEqual(Unsigned val); 161 162 /** 163 * Returns a Unsigned whose value is {@code (this + val)}. 164 * <p> 165 * Note that the right operand is a signed value, while the operation is performed unsigned. 166 * Therefore, the result is only well-defined for positive right operands. 167 * 168 * @param val value to be added to this Unsigned. 169 * @return {@code this + val} 170 */ 171 Unsigned add(int val); 172 173 /** 174 * Returns a Unsigned whose value is {@code (this - val)}. 175 * <p> 176 * Note that the right operand is a signed value, while the operation is performed unsigned. 177 * Therefore, the result is only well-defined for positive right operands. 178 * 179 * @param val value to be subtracted from this Unsigned. 180 * @return {@code this - val} 181 */ 182 Unsigned subtract(int val); 183 184 /** 185 * Returns a Unsigned whose value is {@code (this * val)}. 186 * <p> 187 * Note that the right operand is a signed value, while the operation is performed unsigned. 188 * Therefore, the result is only well-defined for positive right operands. 189 * 190 * @param val value to be multiplied by this Unsigned. 191 * @return {@code this * val} 192 */ 193 Unsigned multiply(int val); 194 195 /** 196 * Returns a Unsigned whose value is {@code (this / val)}. 197 * <p> 198 * Note that the right operand is a signed value, while the operation is performed unsigned. 199 * Therefore, the result is only well-defined for positive right operands. 200 * 201 * @param val value by which this Unsigned is to be divided. 202 * @return {@code this / val} 203 */ 204 Unsigned unsignedDivide(int val); 205 206 /** 207 * Returns a Unsigned whose value is {@code (this % val)}. 208 * <p> 209 * Note that the right operand is a signed value, while the operation is performed unsigned. 210 * Therefore, the result is only well-defined for positive right operands. 211 * 212 * @param val value by which this Unsigned is to be divided, and the remainder computed. 213 * @return {@code this % val} 214 */ 215 Unsigned unsignedRemainder(int val); 216 217 /** 218 * Returns a Unsigned whose value is {@code (this << n)}. 219 * <p> 220 * Note that the right operand is a signed value, while the operation is performed unsigned. 221 * Therefore, the result is only well-defined for positive right operands. 222 * 223 * @param n shift distance, in bits. 224 * @return {@code this << n} 225 */ 226 Unsigned shiftLeft(int n); 227 228 /** 229 * Returns a Unsigned whose value is {@code (this >>> n)}. No sign extension is performed. 230 * <p> 231 * Note that the right operand is a signed value, while the operation is performed unsigned. 232 * Therefore, the result is only well-defined for positive right operands. 233 * 234 * @param n shift distance, in bits. 235 * @return {@code this >> n} 236 */ 237 Unsigned unsignedShiftRight(int n); 238 239 /** 240 * Returns a Unsigned whose value is {@code (this & val)}. 241 * <p> 242 * Note that the right operand is a signed value, while the operation is performed unsigned. 243 * Therefore, the result is only well-defined for positive right operands. 244 * 245 * @param val value to be AND'ed with this Unsigned. 246 * @return {@code this & val} 247 */ 248 Unsigned and(int val); 249 250 /** 251 * Returns a Unsigned whose value is {@code (this | val)}. 252 * <p> 253 * Note that the right operand is a signed value, while the operation is performed unsigned. 254 * Therefore, the result is only well-defined for positive right operands. 255 * 256 * @param val value to be OR'ed with this Unsigned. 257 * @return {@code this | val} 258 */ 259 Unsigned or(int val); 260 261 /** 262 * Returns a Unsigned whose value is {@code (this ^ val)}. 263 * <p> 264 * Note that the right operand is a signed value, while the operation is performed unsigned. 265 * Therefore, the result is only well-defined for positive right operands. 266 * 267 * @param val value to be XOR'ed with this Unsigned. 268 * @return {@code this ^ val} 269 */ 270 Unsigned xor(int val); 271 272 /** 273 * Compares this Unsigned with the specified value. 274 * <p> 275 * Note that the right operand is a signed value, while the operation is performed unsigned. 276 * Therefore, the result is only well-defined for positive right operands. 277 * 278 * @param val value to which this Unsigned is to be compared. 279 * @return {@code this == val} 280 */ 281 boolean equal(int val); 282 283 /** 284 * Compares this Unsigned with the specified value. 285 * <p> 286 * Note that the right operand is a signed value, while the operation is performed unsigned. 287 * Therefore, the result is only well-defined for positive right operands. 288 * 289 * @param val value to which this Unsigned is to be compared. 290 * @return {@code this != val} 291 */ 292 boolean notEqual(int val); 293 294 /** 295 * Compares this Unsigned with the specified value. 296 * <p> 297 * Note that the right operand is a signed value, while the operation is performed unsigned. 298 * Therefore, the result is only well-defined for positive right operands. 299 * 300 * @param val value to which this Unsigned is to be compared. 301 * @return {@code this < val} 302 */ 303 boolean belowThan(int val); 304 305 /** 306 * Compares this Unsigned with the specified value. 307 * <p> 308 * Note that the right operand is a signed value, while the operation is performed unsigned. 309 * Therefore, the result is only well-defined for positive right operands. 310 * 311 * @param val value to which this Unsigned is to be compared. 312 * @return {@code this <= val} 313 */ 314 boolean belowOrEqual(int val); 315 316 /** 317 * Compares this Unsigned with the specified value. 318 * <p> 319 * Note that the right operand is a signed value, while the operation is performed unsigned. 320 * Therefore, the result is only well-defined for positive right operands. 321 * 322 * @param val value to which this Unsigned is to be compared. 323 * @return {@code this > val} 324 */ 325 boolean aboveThan(int val); 326 327 /** 328 * Compares this Unsigned with the specified value. 329 * <p> 330 * Note that the right operand is a signed value, while the operation is performed unsigned. 331 * Therefore, the result is only well-defined for positive right operands. 332 * 333 * @param val value to which this Unsigned is to be compared. 334 * @return {@code this >= val} 335 */ 336 boolean aboveOrEqual(int val); 337}