comparison graal/com.oracle.max.graal.lir/src/com/oracle/max/graal/lir/Variable.java @ 4525:681e969888a7

Separate LIR and new register allocator into separate projects
author Christian Wimmer <Christian.Wimmer@Oracle.com>
date Wed, 08 Feb 2012 19:25:29 -0800
parents graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/Variable.java@430b5db3e6f8
children
comparison
equal deleted inserted replaced
4524:dcc8f5c6f394 4525:681e969888a7
1 /*
2 * Copyright (c) 2010, 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.oracle.max.graal.lir;
24
25 import com.oracle.max.cri.ci.*;
26
27 /**
28 * Represents a value that is yet to be bound to a machine location (such as
29 * a {@link CiRegisterValue} or {@link CiStackSlot}) by a register allocator.
30 */
31 public final class Variable extends CiValue {
32 private static final long serialVersionUID = 4507578431686109809L;
33
34 /**
35 * The identifier of the variable. This is a non-zero index in a contiguous 0-based name space.
36 */
37 public final int index;
38
39 /**
40 * The type of register that this variable needs to get assigned.
41 */
42 public final CiRegister.RegisterFlag flag;
43
44 /**
45 * Creates a new variable.
46 * @param kind
47 * @param index
48 */
49 public Variable(CiKind kind, int index, CiRegister.RegisterFlag flag) {
50 super(kind);
51 assert kind == kind.stackKind() : "Variables can be only created for stack kinds";
52 assert index >= 0;
53 this.index = index;
54 this.flag = flag;
55 }
56
57 @Override
58 public int hashCode() {
59 return (index << 4) | kind.ordinal();
60 }
61
62 @Override
63 public String toString() {
64 return "v" + index + kindSuffix();
65 }
66 }