1 /*
2 * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2017, Red Hat Inc. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
53 @NodeInfo
54 public class AArch64ReadNode extends ReadNode {
55 public static final NodeClass<AArch64ReadNode> TYPE = NodeClass.create(AArch64ReadNode.class);
56 private final IntegerStamp accessStamp;
57 private final boolean isSigned;
58
59 public AArch64ReadNode(AddressNode address, LocationIdentity location, Stamp stamp, GuardingNode guard, BarrierType barrierType, boolean nullCheck,
60 FrameState stateBefore, IntegerStamp accessStamp, boolean isSigned) {
61 super(TYPE, address, location, stamp, guard, barrierType, nullCheck, stateBefore);
62 this.accessStamp = accessStamp;
63 this.isSigned = isSigned;
64 }
65
66 @Override
67 public void generate(NodeLIRBuilderTool gen) {
68 AArch64LIRGenerator lirgen = (AArch64LIRGenerator) gen.getLIRGeneratorTool();
69 AArch64ArithmeticLIRGenerator arithgen = (AArch64ArithmeticLIRGenerator) lirgen.getArithmetic();
70 AArch64Kind readKind = (AArch64Kind) lirgen.getLIRKind(accessStamp).getPlatformKind();
71 int resultBits = ((IntegerStamp) stamp(NodeView.DEFAULT)).getBits();
72 gen.setResult(this, arithgen.emitExtendMemory(isSigned, readKind, resultBits, (AArch64AddressValue) gen.operand(getAddress()), gen.state(this)));
73 }
74
75 /**
76 * replace a ReadNode with an AArch64-specific variant which knows how to merge a downstream
77 * zero or sign extend into the read operation.
78 *
79 * @param readNode
80 */
81 public static void replace(ReadNode readNode) {
82 assert readNode.getUsageCount() == 1;
83 assert readNode.usages().first() instanceof ZeroExtendNode || readNode.usages().first() instanceof SignExtendNode;
84
85 ValueNode usage = (ValueNode) readNode.usages().first();
86 boolean isSigned = usage instanceof SignExtendNode;
87 IntegerStamp accessStamp = ((IntegerStamp) readNode.getAccessStamp());
88
89 AddressNode address = readNode.getAddress();
90 LocationIdentity location = readNode.getLocationIdentity();
91 Stamp stamp = usage.stamp(NodeView.DEFAULT);
92 GuardingNode guard = readNode.getGuard();
|
1 /*
2 * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2017, Red Hat Inc. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
53 @NodeInfo
54 public class AArch64ReadNode extends ReadNode {
55 public static final NodeClass<AArch64ReadNode> TYPE = NodeClass.create(AArch64ReadNode.class);
56 private final IntegerStamp accessStamp;
57 private final boolean isSigned;
58
59 public AArch64ReadNode(AddressNode address, LocationIdentity location, Stamp stamp, GuardingNode guard, BarrierType barrierType, boolean nullCheck,
60 FrameState stateBefore, IntegerStamp accessStamp, boolean isSigned) {
61 super(TYPE, address, location, stamp, guard, barrierType, nullCheck, stateBefore);
62 this.accessStamp = accessStamp;
63 this.isSigned = isSigned;
64 }
65
66 @Override
67 public void generate(NodeLIRBuilderTool gen) {
68 AArch64LIRGenerator lirgen = (AArch64LIRGenerator) gen.getLIRGeneratorTool();
69 AArch64ArithmeticLIRGenerator arithgen = (AArch64ArithmeticLIRGenerator) lirgen.getArithmetic();
70 AArch64Kind readKind = (AArch64Kind) lirgen.getLIRKind(accessStamp).getPlatformKind();
71 int resultBits = ((IntegerStamp) stamp(NodeView.DEFAULT)).getBits();
72 gen.setResult(this, arithgen.emitExtendMemory(isSigned, readKind, resultBits, (AArch64AddressValue) gen.operand(getAddress()), gen.state(this)));
73 }
74
75 @Override
76 public Stamp getAccessStamp() {
77 return accessStamp;
78 }
79
80 /**
81 * replace a ReadNode with an AArch64-specific variant which knows how to merge a downstream
82 * zero or sign extend into the read operation.
83 *
84 * @param readNode
85 */
86 public static void replace(ReadNode readNode) {
87 assert readNode.getUsageCount() == 1;
88 assert readNode.usages().first() instanceof ZeroExtendNode || readNode.usages().first() instanceof SignExtendNode;
89
90 ValueNode usage = (ValueNode) readNode.usages().first();
91 boolean isSigned = usage instanceof SignExtendNode;
92 IntegerStamp accessStamp = ((IntegerStamp) readNode.getAccessStamp());
93
94 AddressNode address = readNode.getAddress();
95 LocationIdentity location = readNode.getLocationIdentity();
96 Stamp stamp = usage.stamp(NodeView.DEFAULT);
97 GuardingNode guard = readNode.getGuard();
|