Mercurial > hg > graal-jvmci-8
comparison graal/Compiler/src/com/sun/c1x/ir/UnsafeRawOp.java @ 2507:9ec15d6914ca
Pull over of compiler from maxine repository.
author | Thomas Wuerthinger <thomas@wuerthinger.net> |
---|---|
date | Wed, 27 Apr 2011 11:43:22 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2506:4a3bf8a5bf41 | 2507:9ec15d6914ca |
---|---|
1 /* | |
2 * Copyright (c) 2009, 2010, 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.c1x.ir; | |
24 | |
25 import com.sun.cri.ci.*; | |
26 | |
27 /** | |
28 * The {@code UnsafeRawOp} class is the base class of all unsafe raw operations. | |
29 * | |
30 * @author Ben L. Titzer | |
31 */ | |
32 public abstract class UnsafeRawOp extends UnsafeOp { | |
33 | |
34 Value base; | |
35 Value index; | |
36 int log2Scale; | |
37 | |
38 /** | |
39 * Creates a new UnsafeRawOp instruction. | |
40 * @param opKind the kind of the operation | |
41 * @param addr the instruction generating the base address (a long) | |
42 * @param isStore {@code true} if this operation is a store | |
43 */ | |
44 public UnsafeRawOp(CiKind opKind, Value addr, boolean isStore) { | |
45 super(opKind, isStore); | |
46 assert addr == null || addr.kind == CiKind.Long; | |
47 base = addr; | |
48 } | |
49 | |
50 /** | |
51 * Creates a new UnsafeRawOp instruction. | |
52 * @param opKind the kind of the operation | |
53 * @param addr the instruction generating the base address (a long) | |
54 * @param index the instruction generating the index | |
55 * @param log2scale the log base 2 of the scaling factor | |
56 * @param isStore {@code true} if this operation is a store | |
57 */ | |
58 public UnsafeRawOp(CiKind opKind, Value addr, Value index, int log2scale, boolean isStore) { | |
59 this(opKind, addr, isStore); | |
60 this.base = addr; | |
61 this.index = index; | |
62 this.log2Scale = log2scale; | |
63 } | |
64 | |
65 /** | |
66 * Gets the instruction generating the base address for this operation. | |
67 * @return the instruction generating the base | |
68 */ | |
69 public Value base() { | |
70 return base; | |
71 } | |
72 | |
73 /** | |
74 * Gets the instruction generating the index for this operation. | |
75 * @return the instruction generating the index | |
76 */ | |
77 public Value index() { | |
78 return index; | |
79 } | |
80 | |
81 /** | |
82 * Checks whether this instruction has an index. | |
83 * @return {@code true} if this instruction has an index | |
84 */ | |
85 public boolean hasIndex() { | |
86 return index != null; | |
87 } | |
88 | |
89 /** | |
90 * Gets the log base 2 of the scaling factor for the index of this instruction. | |
91 * @return the log base 2 of the scaling factor | |
92 */ | |
93 public int log2Scale() { | |
94 return log2Scale; | |
95 } | |
96 | |
97 /** | |
98 * Sets the instruction that generates the base address for this instruction. | |
99 * @param base the instruction generating the base address | |
100 */ | |
101 public void setBase(Value base) { | |
102 this.base = base; | |
103 } | |
104 | |
105 /** | |
106 * Sets the instruction generating the base address for this instruction. | |
107 * @param index the instruction generating the index | |
108 */ | |
109 public void setIndex(Value index) { | |
110 this.index = index; | |
111 } | |
112 | |
113 /** | |
114 * Sets the scaling factor for the index of this instruction. | |
115 * @param log2scale the log base 2 of the scaling factor for this instruction | |
116 */ | |
117 public void setLog2Scale(int log2scale) { | |
118 this.log2Scale = log2scale; | |
119 } | |
120 | |
121 /** | |
122 * Iterates over the input values to this instruction. | |
123 * @param closure the closure to apply | |
124 */ | |
125 @Override | |
126 public void inputValuesDo(ValueClosure closure) { | |
127 super.inputValuesDo(closure); | |
128 base = closure.apply(base); | |
129 if (index != null) { | |
130 index = closure.apply(index); | |
131 } | |
132 } | |
133 } |