AMD64HotSpotLoadAddressOp.java revision 12651:6ef01bd40ce2
1/*
2 * Copyright (c) 2015, 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 */
23package org.graalvm.compiler.hotspot.amd64;
24
25import static jdk.vm.ci.code.ValueUtil.asRegister;
26import jdk.vm.ci.amd64.AMD64Kind;
27import jdk.vm.ci.meta.AllocatableValue;
28import jdk.vm.ci.meta.Constant;
29
30import org.graalvm.compiler.asm.amd64.AMD64MacroAssembler;
31import org.graalvm.compiler.debug.GraalError;
32import org.graalvm.compiler.lir.LIRInstructionClass;
33import org.graalvm.compiler.lir.amd64.AMD64LIRInstruction;
34import org.graalvm.compiler.lir.asm.CompilationResultBuilder;
35
36public final class AMD64HotSpotLoadAddressOp extends AMD64LIRInstruction {
37
38    public static final LIRInstructionClass<AMD64HotSpotLoadAddressOp> TYPE = LIRInstructionClass.create(AMD64HotSpotLoadAddressOp.class);
39
40    @Def({OperandFlag.REG}) protected AllocatableValue result;
41    private final Constant constant;
42    private final Object note;
43
44    public AMD64HotSpotLoadAddressOp(AllocatableValue result, Constant constant, Object note) {
45        super(TYPE);
46        this.result = result;
47        this.constant = constant;
48        this.note = note;
49    }
50
51    @Override
52    public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
53        crb.recordInlineDataInCodeWithNote(constant, note);
54        AMD64Kind kind = (AMD64Kind) result.getPlatformKind();
55        switch (kind) {
56            case DWORD:
57                masm.movl(asRegister(result), masm.getPlaceholder(-1));
58                break;
59            case QWORD:
60                masm.movq(asRegister(result), masm.getPlaceholder(-1));
61                break;
62            default:
63                throw GraalError.shouldNotReachHere("unexpected kind: " + kind);
64        }
65    }
66
67}
68