1 /* 2 * Copyright (c) 2012, 2012, 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 24 25 package jdk.internal.vm.compiler.word; 26 27 /** 28 * Represents a signed word-sized value. 29 * 30 * @since 1.0 31 */ 32 public interface SignedWord extends ComparableWord { 33 34 /** 35 * Returns a Signed whose value is {@code (this + val)}. 36 * 37 * @param val value to be added to this Signed. 38 * @return {@code this + val} 39 * 40 * @since 1.0 41 */ 42 SignedWord add(SignedWord val); 43 44 /** 45 * Returns a Signed whose value is {@code (this - val)}. 46 * 47 * @param val value to be subtracted from this Signed. 48 * @return {@code this - val} 49 * 50 * @since 1.0 51 */ 52 SignedWord subtract(SignedWord val); 53 54 /** 55 * Returns a Signed whose value is {@code (this * val)}. 56 * 57 * @param val value to be multiplied by this Signed. 58 * @return {@code this * val} 59 * 60 * @since 1.0 61 */ 62 SignedWord multiply(SignedWord val); 63 64 /** 65 * Returns a Signed whose value is {@code (this / val)}. 66 * 67 * @param val value by which this Signed is to be divided. 68 * @return {@code this / val} 69 * 70 * @since 1.0 71 */ 72 SignedWord signedDivide(SignedWord val); 73 74 /** 75 * Returns a Signed whose value is {@code (this % val)}. 76 * 77 * @param val value by which this Signed is to be divided, and the remainder computed. 78 * @return {@code this % val} 79 * 80 * @since 1.0 81 */ 82 SignedWord signedRemainder(SignedWord val); 83 84 /** 85 * Returns a Signed whose value is {@code (this << n)}. 86 * 87 * @param n shift distance, in bits. 88 * @return {@code this << n} 89 * 90 * @since 1.0 91 */ 92 SignedWord shiftLeft(UnsignedWord n); 93 94 /** 95 * Returns a Signed whose value is {@code (this >> n)}. Sign extension is performed. 96 * 97 * @param n shift distance, in bits. 98 * @return {@code this >> n} 99 * 100 * @since 1.0 101 */ 102 SignedWord signedShiftRight(UnsignedWord n); 103 104 /** 105 * Returns a Signed whose value is {@code (this & val)}. (This method returns a negative Signed 106 * if and only if this and val are both negative.) 107 * 108 * @param val value to be AND'ed with this Signed. 109 * @return {@code this & val} 110 * 111 * @since 1.0 112 */ 113 SignedWord and(SignedWord val); 114 115 /** 116 * Returns a Signed whose value is {@code (this | val)}. (This method returns a negative Signed 117 * if and only if either this or val is negative.) 118 * 119 * @param val value to be OR'ed with this Signed. 120 * @return {@code this | val} 121 * 122 * @since 1.0 123 */ 124 SignedWord or(SignedWord val); 125 126 /** 127 * Returns a Signed whose value is {@code (this ^ val)}. (This method returns a negative Signed 128 * if and only if exactly one of this and val are negative.) 129 * 130 * @param val value to be XOR'ed with this Signed. 131 * @return {@code this ^ val} 132 * 133 * @since 1.0 134 */ 135 SignedWord xor(SignedWord val); 136 137 /** 138 * Returns a Signed whose value is {@code (~this)}. (This method returns a negative value if and 139 * only if this Signed is non-negative.) 140 * 141 * @return {@code ~this} 142 * 143 * @since 1.0 144 */ 145 SignedWord not(); 146 147 /** 148 * Compares this Signed with the specified value. 149 * 150 * @param val value to which this Signed is to be compared. 151 * @return {@code this == val} 152 * 153 * @since 1.0 154 */ 155 boolean equal(SignedWord val); 156 157 /** 158 * Compares this Signed with the specified value. 159 * 160 * @param val value to which this Signed is to be compared. 161 * @return {@code this != val} 162 * 163 * @since 1.0 164 */ 165 boolean notEqual(SignedWord val); 166 167 /** 168 * Compares this Signed with the specified value. 169 * 170 * @param val value to which this Signed is to be compared. 171 * @return {@code this < val} 172 * 173 * @since 1.0 174 */ 175 boolean lessThan(SignedWord val); 176 177 /** 178 * Compares this Signed with the specified value. 179 * 180 * @param val value to which this Signed is to be compared. 181 * @return {@code this <= val} 182 * 183 * @since 1.0 184 */ 185 boolean lessOrEqual(SignedWord val); 186 187 /** 188 * Compares this Signed with the specified value. 189 * 190 * @param val value to which this Signed is to be compared. 191 * @return {@code this > val} 192 * 193 * @since 1.0 194 */ 195 boolean greaterThan(SignedWord val); 196 197 /** 198 * Compares this Signed with the specified value. 199 * 200 * @param val value to which this Signed is to be compared. 201 * @return {@code this >= val} 202 * 203 * @since 1.0 204 */ 205 boolean greaterOrEqual(SignedWord val); 206 207 /** 208 * Returns a Signed whose value is {@code (this + val)}. 209 * 210 * @param val value to be added to this Signed. 211 * @return {@code this + val} 212 * 213 * @since 1.0 214 */ 215 SignedWord add(int val); 216 217 /** 218 * Returns a Signed whose value is {@code (this - val)}. 219 * 220 * @param val value to be subtracted from this Signed. 221 * @return {@code this - val} 222 * 223 * @since 1.0 224 */ 225 SignedWord subtract(int val); 226 227 /** 228 * Returns a Signed whose value is {@code (this * val)}. 229 * 230 * @param val value to be multiplied by this Signed. 231 * @return {@code this * val} 232 * 233 * @since 1.0 234 */ 235 SignedWord multiply(int val); 236 237 /** 238 * Returns a Signed whose value is {@code (this / val)}. 239 * 240 * @param val value by which this Signed is to be divided. 241 * @return {@code this / val} 242 * 243 * @since 1.0 244 */ 245 SignedWord signedDivide(int val); 246 247 /** 248 * Returns a Signed whose value is {@code (this % val)}. 249 * 250 * @param val value by which this Signed is to be divided, and the remainder computed. 251 * @return {@code this % val} 252 * 253 * @since 1.0 254 */ 255 SignedWord signedRemainder(int val); 256 257 /** 258 * Returns a Signed whose value is {@code (this << n)}. 259 * 260 * @param n shift distance, in bits. 261 * @return {@code this << n} 262 * 263 * @since 1.0 264 */ 265 SignedWord shiftLeft(int n); 266 267 /** 268 * Returns a Signed whose value is {@code (this >> n)}. Sign extension is performed. 269 * 270 * @param n shift distance, in bits. 271 * @return {@code this >> n} 272 * 273 * @since 1.0 274 */ 275 SignedWord signedShiftRight(int n); 276 277 /** 278 * Returns a Signed whose value is {@code (this & val)}. (This method returns a negative Signed 279 * if and only if this and val are both negative.) 280 * 281 * @param val value to be AND'ed with this Signed. 282 * @return {@code this & val} 283 * 284 * @since 1.0 285 */ 286 SignedWord and(int val); 287 288 /** 289 * Returns a Signed whose value is {@code (this | val)}. (This method returns a negative Signed 290 * if and only if either this or val is negative.) 291 * 292 * @param val value to be OR'ed with this Signed. 293 * @return {@code this | val} 294 * 295 * @since 1.0 296 */ 297 SignedWord or(int val); 298 299 /** 300 * Returns a Signed whose value is {@code (this ^ val)}. (This method returns a negative Signed 301 * if and only if exactly one of this and val are negative.) 302 * 303 * @param val value to be XOR'ed with this Signed. 304 * @return {@code this ^ val} 305 * 306 * @since 1.0 307 */ 308 SignedWord xor(int val); 309 310 /** 311 * Compares this Signed with the specified value. 312 * 313 * @param val value to which this Signed is to be compared. 314 * @return {@code this == val} 315 * 316 * @since 1.0 317 */ 318 boolean equal(int val); 319 320 /** 321 * Compares this Signed with the specified value. 322 * 323 * @param val value to which this Signed is to be compared. 324 * @return {@code this != val} 325 * 326 * @since 1.0 327 */ 328 boolean notEqual(int val); 329 330 /** 331 * Compares this Signed with the specified value. 332 * 333 * @param val value to which this Signed is to be compared. 334 * @return {@code this < val} 335 * 336 * @since 1.0 337 */ 338 boolean lessThan(int val); 339 340 /** 341 * Compares this Signed with the specified value. 342 * 343 * @param val value to which this Signed is to be compared. 344 * @return {@code this <= val} 345 * 346 * @since 1.0 347 */ 348 boolean lessOrEqual(int val); 349 350 /** 351 * Compares this Signed with the specified value. 352 * 353 * @param val value to which this Signed is to be compared. 354 * @return {@code this > val} 355 * 356 * @since 1.0 357 */ 358 boolean greaterThan(int val); 359 360 /** 361 * Compares this Signed with the specified value. 362 * 363 * @param val value to which this Signed is to be compared. 364 * @return {@code this >= val} 365 * 366 * @since 1.0 367 */ 368 boolean greaterOrEqual(int val); 369 }