Mercurial > hg > truffle
comparison graal/com.oracle.max.asmdis/src/com/sun/max/asm/ppc/CRF.java @ 3733:e233f5660da4
Added Java files from Maxine project.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sat, 17 Dec 2011 19:59:18 +0100 |
parents | |
children | bc8527f3071c |
comparison
equal
deleted
inserted
replaced
3732:3e2e8b8abdaf | 3733:e233f5660da4 |
---|---|
1 /* | |
2 * Copyright (c) 2007, 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.sun.max.asm.ppc; | |
24 | |
25 import com.sun.max.asm.*; | |
26 import com.sun.max.util.*; | |
27 | |
28 /** | |
29 * The constants denoting the eight 4-bit fields into which the 32-bit Condition Register | |
30 * is logically partitioned. | |
31 */ | |
32 public enum CRF implements EnumerableArgument<CRF> { | |
33 | |
34 CR0, CR1, CR2, CR3, CR4, CR5, CR6, CR7; | |
35 | |
36 /** | |
37 * Determines if a mask of bits only selects one of the 8 condition register fields. | |
38 */ | |
39 public static boolean isExactlyOneCRFSelected(int mask) { | |
40 return (mask & (mask - 1)) == 0 && mask > 0 && mask <= 128; | |
41 } | |
42 | |
43 public int value() { | |
44 return ordinal(); | |
45 } | |
46 | |
47 public long asLong() { | |
48 return value(); | |
49 } | |
50 | |
51 public String externalValue() { | |
52 return Integer.toString(ordinal()); | |
53 } | |
54 | |
55 public String disassembledValue() { | |
56 return externalValue(); | |
57 } | |
58 | |
59 public Enumerator<CRF> enumerator() { | |
60 return ENUMERATOR; | |
61 } | |
62 | |
63 public CRF exampleValue() { | |
64 return CR0; | |
65 } | |
66 | |
67 /** | |
68 * Given the index of a bit within this 4-bit field, returns the index of the same bit | |
69 * in the 32-bit Condition Register. | |
70 * | |
71 * @throws IllegalArgumentException if n is not between 0 and 3 inclusive | |
72 */ | |
73 public int bitFor(int n) { | |
74 if (n < 0 || n > 3) { | |
75 throw new IllegalArgumentException("bit specifier must be between 0 and 3"); | |
76 } | |
77 return ordinal() * 4 + n; | |
78 } | |
79 | |
80 /** | |
81 * @return the index of the bit within the 32-bit Condition Register corresponding to the <i>less than</i> bit in this Condition Register field | |
82 */ | |
83 public int lt() { | |
84 return bitFor(LT); | |
85 } | |
86 | |
87 /** | |
88 * @return the index of the bit within the 32-bit Condition Register corresponding to the <i>greater than</i> bit in this Condition Register field | |
89 */ | |
90 public int gt() { | |
91 return bitFor(GT); | |
92 } | |
93 | |
94 /** | |
95 * @return the index of the bit within the 32-bit Condition Register corresponding to the <i>equal</i> bit in this Condition Register field | |
96 */ | |
97 public int eq() { | |
98 return bitFor(EQ); | |
99 } | |
100 | |
101 /** | |
102 * @return the index of the bit within the 32-bit Condition Register corresponding to the <i>summary overflow</i> bit in this Condition Register field | |
103 */ | |
104 public int so() { | |
105 return bitFor(SO); | |
106 } | |
107 | |
108 /** | |
109 * @return the index of the bit within the 32-bit Condition Register corresponding to the <i>unordered (after floating-point comparison)</i> bit in this Condition Register field | |
110 */ | |
111 public int un() { | |
112 return bitFor(UN); | |
113 } | |
114 | |
115 /** | |
116 * Index of the bit in a 4-bit Condition Register field indicating a <i>less than</i> condition. | |
117 */ | |
118 public static final int LT = 0; | |
119 | |
120 /** | |
121 * Index of the bit in a 4-bit Condition Register field indicating a <i>greater than</i> condition. | |
122 */ | |
123 public static final int GT = 1; | |
124 | |
125 /** | |
126 * Index of the bit in a 4-bit Condition Register field indicating an <i>equal</i> condition. | |
127 */ | |
128 public static final int EQ = 2; | |
129 | |
130 /** | |
131 * Index of the bit in a 4-bit Condition Register field indicating a <i>summary overflow</i> condition. | |
132 */ | |
133 public static final int SO = 3; | |
134 | |
135 /** | |
136 * Index of the bit in a 4-bit Condition Register field indicating an <i>unordered (after floating-point comparison)</i> condition. | |
137 */ | |
138 public static final int UN = 3; | |
139 | |
140 public static final Enumerator<CRF> ENUMERATOR = new Enumerator<CRF>(CRF.class); | |
141 | |
142 } |