comparison graal/com.oracle.max.cri/src/com/sun/cri/ci/CiValueUtil.java @ 4183:9e0c1b4cfef5

Move all isXxx and asXxx out of CiValue and into their own util class.
author Christian Wimmer <Christian.Wimmer@Oracle.com>
date Mon, 02 Jan 2012 17:39:20 -0800
parents
children
comparison
equal deleted inserted replaced
4182:de7b3e7ae528 4183:9e0c1b4cfef5
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 package com.sun.cri.ci;
24
25 public class CiValueUtil {
26 public static boolean isIllegal(CiValue value) {
27 assert value != null;
28 return value == CiValue.IllegalValue;
29 }
30
31 public static boolean isLegal(CiValue value) {
32 return !isIllegal(value);
33 }
34
35 public static boolean isVirtualObject(CiValue value) {
36 assert value != null;
37 return value instanceof CiVirtualObject;
38 }
39
40
41 public static boolean isVariable(CiValue value) {
42 assert value != null;
43 return value instanceof CiVariable;
44 }
45
46 public static CiVariable asVariable(CiValue value) {
47 assert value != null;
48 return (CiVariable) value;
49 }
50
51
52 public static boolean isConstant(CiValue value) {
53 assert value != null;
54 return value instanceof CiConstant;
55 }
56
57
58 public static boolean isStackSlot(CiValue value) {
59 assert value != null;
60 return value instanceof CiStackSlot;
61 }
62
63 public static CiStackSlot asStackSlot(CiValue value) {
64 assert value != null;
65 return (CiStackSlot) value;
66 }
67
68
69 public static boolean isRegister(CiValue value) {
70 assert value != null;
71 return value instanceof CiRegisterValue;
72 }
73
74 public static CiRegister asRegister(CiValue value) {
75 assert value != null;
76 return ((CiRegisterValue) value).reg;
77 }
78
79 public static CiRegister asIntReg(CiValue value) {
80 assert value.kind == CiKind.Int || value.kind == CiKind.Jsr;
81 return asRegister(value);
82 }
83
84 public static CiRegister asLongReg(CiValue value) {
85 assert value.kind == CiKind.Long : value.kind;
86 return asRegister(value);
87 }
88
89 public static CiRegister asObjectReg(CiValue value) {
90 assert value.kind == CiKind.Object;
91 return asRegister(value);
92 }
93
94 public static CiRegister asFloatReg(CiValue value) {
95 assert value.kind == CiKind.Float;
96 return asRegister(value);
97 }
98
99 public static CiRegister asDoubleReg(CiValue value) {
100 assert value.kind == CiKind.Double;
101 return asRegister(value);
102 }
103 }