Mercurial > hg > truffle
comparison graal/com.oracle.max.cri/src/com/oracle/max/cri/util/UnsignedMath.java @ 4198:8c9c0e1eaab1
More restructuring of cri; moved bytecodes ingo compiler.graphbuilder.* package
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Tue, 03 Jan 2012 16:24:22 +0100 |
parents | graal/com.oracle.max.cri/src/com/oracle/max/cri/intrinsics/UnsignedMath.java@e233f5660da4 |
children | 4d7175cf3526 |
comparison
equal
deleted
inserted
replaced
4197:b765172082ac | 4198:8c9c0e1eaab1 |
---|---|
1 /* | |
2 * Copyright (c) 2011, 2011, 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 package com.oracle.max.cri.util; | |
24 | |
25 /** | |
26 * {@link INTRINSIC} method definitions for unsigned comparisons. | |
27 * All methods have correct, but slow, standard Java implementations so that | |
28 * they can be used with compilers not supporting the intrinsics. | |
29 */ | |
30 public class UnsignedMath { | |
31 private static final long MASK = 0xffffffffL; | |
32 | |
33 /** | |
34 * Unsigned comparison aboveThan for two numbers. | |
35 */ | |
36 public static boolean aboveThan(int a, int b) { | |
37 return (a & MASK) > (b & MASK); | |
38 } | |
39 | |
40 /** | |
41 * Unsigned comparison aboveOrEqual for two numbers. | |
42 */ | |
43 public static boolean aboveOrEqual(int a, int b) { | |
44 return (a & MASK) >= (b & MASK); | |
45 } | |
46 | |
47 /** | |
48 * Unsigned comparison belowThan for two numbers. | |
49 */ | |
50 public static boolean belowThan(int a, int b) { | |
51 return (a & MASK) < (b & MASK); | |
52 } | |
53 | |
54 /** | |
55 * Unsigned comparison belowOrEqual for two numbers. | |
56 */ | |
57 public static boolean belowOrEqual(int a, int b) { | |
58 return (a & MASK) <= (b & MASK); | |
59 } | |
60 | |
61 /** | |
62 * Unsigned comparison aboveThan for two numbers. | |
63 */ | |
64 public static boolean aboveThan(long a, long b) { | |
65 return (a > b) ^ ((a < 0) != (b < 0)); | |
66 } | |
67 | |
68 /** | |
69 * Unsigned comparison aboveOrEqual for two numbers. | |
70 */ | |
71 public static boolean aboveOrEqual(long a, long b) { | |
72 return (a >= b) ^ ((a < 0) != (b < 0)); | |
73 } | |
74 | |
75 /** | |
76 * Unsigned comparison belowThan for two numbers. | |
77 */ | |
78 public static boolean belowThan(long a, long b) { | |
79 return (a < b) ^ ((a < 0) != (b < 0)); | |
80 } | |
81 | |
82 /** | |
83 * Unsigned comparison belowOrEqual for two numbers. | |
84 */ | |
85 public static boolean belowOrEqual(long a, long b) { | |
86 return (a <= b) ^ ((a < 0) != (b < 0)); | |
87 } | |
88 } | |
89 |