43972
|
1 |
/*
|
58299
|
2 |
* Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
|
43972
|
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 |
*/
|
50858
|
23 |
|
|
24 |
|
43972
|
25 |
package org.graalvm.compiler.replacements.nodes;
|
|
26 |
|
46393
|
27 |
import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_2;
|
|
28 |
import static org.graalvm.compiler.nodeinfo.NodeSize.SIZE_1;
|
|
29 |
|
43972
|
30 |
import org.graalvm.compiler.core.common.type.StampFactory;
|
|
31 |
import org.graalvm.compiler.graph.NodeClass;
|
|
32 |
import org.graalvm.compiler.nodeinfo.NodeInfo;
|
|
33 |
import org.graalvm.compiler.nodeinfo.Verbosity;
|
|
34 |
import org.graalvm.compiler.nodes.FixedWithNextNode;
|
|
35 |
import org.graalvm.compiler.nodes.ValueNode;
|
|
36 |
import org.graalvm.compiler.nodes.spi.LIRLowerable;
|
|
37 |
import org.graalvm.compiler.nodes.spi.NodeLIRBuilderTool;
|
|
38 |
|
|
39 |
import jdk.vm.ci.code.Register;
|
|
40 |
import jdk.vm.ci.meta.Value;
|
|
41 |
|
|
42 |
/**
|
|
43 |
* Changes the value of a specific register.
|
|
44 |
*/
|
46393
|
45 |
@NodeInfo(nameTemplate = "WriteRegister %{p#register}", cycles = CYCLES_2, size = SIZE_1)
|
43972
|
46 |
public final class WriteRegisterNode extends FixedWithNextNode implements LIRLowerable {
|
|
47 |
|
|
48 |
public static final NodeClass<WriteRegisterNode> TYPE = NodeClass.create(WriteRegisterNode.class);
|
|
49 |
/**
|
|
50 |
* The fixed register to access.
|
|
51 |
*/
|
|
52 |
protected final Register register;
|
|
53 |
|
|
54 |
/**
|
|
55 |
* The new value assigned to the register.
|
|
56 |
*/
|
|
57 |
@Input ValueNode value;
|
|
58 |
|
|
59 |
public WriteRegisterNode(Register register, ValueNode value) {
|
|
60 |
super(TYPE, StampFactory.forVoid());
|
|
61 |
this.register = register;
|
|
62 |
this.value = value;
|
|
63 |
}
|
|
64 |
|
|
65 |
@Override
|
|
66 |
public void generate(NodeLIRBuilderTool generator) {
|
|
67 |
Value val = generator.operand(value);
|
57537
|
68 |
generator.getLIRGeneratorTool().emitWriteRegister(register, val, val.getValueKind());
|
43972
|
69 |
}
|
|
70 |
|
|
71 |
@Override
|
|
72 |
public String toString(Verbosity verbosity) {
|
|
73 |
if (verbosity == Verbosity.Name) {
|
|
74 |
return super.toString(Verbosity.Name) + "%" + register;
|
|
75 |
} else {
|
|
76 |
return super.toString(verbosity);
|
|
77 |
}
|
|
78 |
}
|
|
79 |
}
|