comparison graal/Compiler/src/com/sun/c1x/ir/StorePointer.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, 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.c1x.ir;
24
25 import com.sun.c1x.debug.*;
26 import com.sun.c1x.value.*;
27 import com.sun.cri.ci.*;
28
29 /**
30 * The {@code StorePointer} instruction represents a write of a pointer.
31 * This instruction is part of the HIR support for low-level operations, such as safepoints,
32 * stack banging, etc, and does not correspond to a Java operation.
33 *
34 * @author Ben L. Titzer
35 * @author Doug Simon
36 */
37 public final class StorePointer extends PointerOp {
38
39 Value value;
40
41 /**
42 * Creates an instruction for a pointer store. If {@code displacement != null}, the effective of the address of the store is
43 * computed as the pointer plus a byte displacement plus a scaled index. Otherwise, the effective address is computed as the
44 * pointer plus a byte offset.
45 * @param dataKind the kind of value at the address accessed by the pointer operation
46 * @param pointer the value producing the pointer
47 * @param displacement the value producing the displacement. This may be {@code null}.
48 * @param offsetOrIndex the value producing the scaled-index or the byte offset depending on whether {@code displacement} is {@code null}
49 * @param value the value to write to the pointer
50 * @param stateBefore the state before
51 * @param isVolatile {@code true} if the access is volatile
52 */
53 public StorePointer(int opcode, CiKind dataKind, Value pointer, Value displacement, Value offsetOrIndex, Value value, FrameState stateBefore, boolean isVolatile) {
54 super(CiKind.Void, dataKind, opcode, pointer, displacement, offsetOrIndex, stateBefore, isVolatile);
55 this.value = value;
56 setFlag(Flag.LiveStore);
57 }
58
59 @Override
60 public void accept(ValueVisitor v) {
61 v.visitStorePointer(this);
62 }
63
64 public Value value() {
65 return value;
66 }
67
68 @Override
69 public void inputValuesDo(ValueClosure closure) {
70 super.inputValuesDo(closure);
71 value = closure.apply(value);
72 }
73
74 @Override
75 public void print(LogStream out) {
76 out.print("*(").print(pointer);
77 if (displacement() == null) {
78 out.print(" + ").print(offset());
79 } else {
80 out.print(" + ").print(displacement()).print(" + (").print(index()).print(" * sizeOf(" + dataKind.name() + "))");
81 }
82 out.print(") := ").print(value());
83 }
84
85 }