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 Signed extends ComparableWord {
026
027    /**
028     * Returns a Signed whose value is {@code (this + val)}.
029     *
030     * @param val value to be added to this Signed.
031     * @return {@code this + val}
032     */
033    Signed add(Signed val);
034
035    /**
036     * Returns a Signed whose value is {@code (this - val)}.
037     *
038     * @param val value to be subtracted from this Signed.
039     * @return {@code this - val}
040     */
041    Signed subtract(Signed val);
042
043    /**
044     * Returns a Signed whose value is {@code (this * val)}.
045     *
046     * @param val value to be multiplied by this Signed.
047     * @return {@code this * val}
048     */
049    Signed multiply(Signed val);
050
051    /**
052     * Returns a Signed whose value is {@code (this / val)}.
053     *
054     * @param val value by which this Signed is to be divided.
055     * @return {@code this / val}
056     */
057    Signed signedDivide(Signed val);
058
059    /**
060     * Returns a Signed whose value is {@code (this % val)}.
061     *
062     * @param val value by which this Signed is to be divided, and the remainder computed.
063     * @return {@code this % val}
064     */
065    Signed signedRemainder(Signed val);
066
067    /**
068     * Returns a Signed whose value is {@code (this << n)}.
069     *
070     * @param n shift distance, in bits.
071     * @return {@code this << n}
072     */
073    Signed shiftLeft(Unsigned n);
074
075    /**
076     * Returns a Signed whose value is {@code (this >> n)}. Sign extension is performed.
077     *
078     * @param n shift distance, in bits.
079     * @return {@code this >> n}
080     */
081    Signed signedShiftRight(Unsigned n);
082
083    /**
084     * Returns a Signed whose value is {@code (this & val)}. (This method returns a negative Signed
085     * if and only if this and val are both negative.)
086     *
087     * @param val value to be AND'ed with this Signed.
088     * @return {@code this & val}
089     */
090    Signed and(Signed val);
091
092    /**
093     * Returns a Signed whose value is {@code (this | val)}. (This method returns a negative Signed
094     * if and only if either this or val is negative.)
095     *
096     * @param val value to be OR'ed with this Signed.
097     * @return {@code this | val}
098     */
099    Signed or(Signed val);
100
101    /**
102     * Returns a Signed whose value is {@code (this ^ val)}. (This method returns a negative Signed
103     * if and only if exactly one of this and val are negative.)
104     *
105     * @param val value to be XOR'ed with this Signed.
106     * @return {@code this ^ val}
107     */
108    Signed xor(Signed val);
109
110    /**
111     * Returns a Signed whose value is {@code (~this)}. (This method returns a negative value if and
112     * only if this Signed is non-negative.)
113     *
114     * @return {@code ~this}
115     */
116    Signed not();
117
118    /**
119     * Compares this Signed with the specified value.
120     *
121     * @param val value to which this Signed is to be compared.
122     * @return {@code this == val}
123     */
124    boolean equal(Signed val);
125
126    /**
127     * Compares this Signed with the specified value.
128     *
129     * @param val value to which this Signed is to be compared.
130     * @return {@code this != val}
131     */
132    boolean notEqual(Signed val);
133
134    /**
135     * Compares this Signed with the specified value.
136     *
137     * @param val value to which this Signed is to be compared.
138     * @return {@code this < val}
139     */
140    boolean lessThan(Signed val);
141
142    /**
143     * Compares this Signed with the specified value.
144     *
145     * @param val value to which this Signed is to be compared.
146     * @return {@code this <= val}
147     */
148    boolean lessOrEqual(Signed val);
149
150    /**
151     * Compares this Signed with the specified value.
152     *
153     * @param val value to which this Signed is to be compared.
154     * @return {@code this > val}
155     */
156    boolean greaterThan(Signed val);
157
158    /**
159     * Compares this Signed with the specified value.
160     *
161     * @param val value to which this Signed is to be compared.
162     * @return {@code this >= val}
163     */
164    boolean greaterOrEqual(Signed val);
165
166    /**
167     * Returns a Signed whose value is {@code (this + val)}.
168     *
169     * @param val value to be added to this Signed.
170     * @return {@code this + val}
171     */
172    Signed add(int val);
173
174    /**
175     * Returns a Signed whose value is {@code (this - val)}.
176     *
177     * @param val value to be subtracted from this Signed.
178     * @return {@code this - val}
179     */
180    Signed subtract(int val);
181
182    /**
183     * Returns a Signed whose value is {@code (this * val)}.
184     *
185     * @param val value to be multiplied by this Signed.
186     * @return {@code this * val}
187     */
188    Signed multiply(int val);
189
190    /**
191     * Returns a Signed whose value is {@code (this / val)}.
192     *
193     * @param val value by which this Signed is to be divided.
194     * @return {@code this / val}
195     */
196    Signed signedDivide(int val);
197
198    /**
199     * Returns a Signed whose value is {@code (this % val)}.
200     *
201     * @param val value by which this Signed is to be divided, and the remainder computed.
202     * @return {@code this % val}
203     */
204    Signed signedRemainder(int val);
205
206    /**
207     * Returns a Signed whose value is {@code (this << n)}.
208     *
209     * @param n shift distance, in bits.
210     * @return {@code this << n}
211     */
212    Signed shiftLeft(int n);
213
214    /**
215     * Returns a Signed whose value is {@code (this >> n)}. Sign extension is performed.
216     *
217     * @param n shift distance, in bits.
218     * @return {@code this >> n}
219     */
220    Signed signedShiftRight(int n);
221
222    /**
223     * Returns a Signed whose value is {@code (this & val)}. (This method returns a negative Signed
224     * if and only if this and val are both negative.)
225     *
226     * @param val value to be AND'ed with this Signed.
227     * @return {@code this & val}
228     */
229    Signed and(int val);
230
231    /**
232     * Returns a Signed whose value is {@code (this | val)}. (This method returns a negative Signed
233     * if and only if either this or val is negative.)
234     *
235     * @param val value to be OR'ed with this Signed.
236     * @return {@code this | val}
237     */
238    Signed or(int val);
239
240    /**
241     * Returns a Signed whose value is {@code (this ^ val)}. (This method returns a negative Signed
242     * if and only if exactly one of this and val are negative.)
243     *
244     * @param val value to be XOR'ed with this Signed.
245     * @return {@code this ^ val}
246     */
247    Signed xor(int val);
248
249    /**
250     * Compares this Signed with the specified value.
251     *
252     * @param val value to which this Signed is to be compared.
253     * @return {@code this == val}
254     */
255    boolean equal(int val);
256
257    /**
258     * Compares this Signed with the specified value.
259     *
260     * @param val value to which this Signed is to be compared.
261     * @return {@code this != val}
262     */
263    boolean notEqual(int val);
264
265    /**
266     * Compares this Signed with the specified value.
267     *
268     * @param val value to which this Signed is to be compared.
269     * @return {@code this < val}
270     */
271    boolean lessThan(int val);
272
273    /**
274     * Compares this Signed with the specified value.
275     *
276     * @param val value to which this Signed is to be compared.
277     * @return {@code this <= val}
278     */
279    boolean lessOrEqual(int val);
280
281    /**
282     * Compares this Signed with the specified value.
283     *
284     * @param val value to which this Signed is to be compared.
285     * @return {@code this > val}
286     */
287    boolean greaterThan(int val);
288
289    /**
290     * Compares this Signed with the specified value.
291     *
292     * @param val value to which this Signed is to be compared.
293     * @return {@code this >= val}
294     */
295    boolean greaterOrEqual(int val);
296}