43972
|
1 |
/*
|
52910
|
2 |
* Copyright (c) 2015, 2018, 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.hotspot.amd64;
|
|
26 |
|
|
27 |
import static org.graalvm.compiler.core.common.GraalOptions.GeneratePIC;
|
|
28 |
import static jdk.vm.ci.code.ValueUtil.asRegister;
|
|
29 |
|
|
30 |
import jdk.vm.ci.amd64.AMD64Kind;
|
|
31 |
import jdk.vm.ci.code.Register;
|
|
32 |
import jdk.vm.ci.meta.AllocatableValue;
|
|
33 |
|
|
34 |
import org.graalvm.compiler.asm.amd64.AMD64Address;
|
|
35 |
import org.graalvm.compiler.asm.amd64.AMD64MacroAssembler;
|
|
36 |
import org.graalvm.compiler.debug.GraalError;
|
|
37 |
import org.graalvm.compiler.lir.LIRInstructionClass;
|
|
38 |
import org.graalvm.compiler.lir.amd64.AMD64LIRInstruction;
|
|
39 |
import org.graalvm.compiler.lir.asm.CompilationResultBuilder;
|
|
40 |
|
|
41 |
public final class AMD64HotSpotLoadConfigValueOp extends AMD64LIRInstruction {
|
|
42 |
|
|
43 |
public static final LIRInstructionClass<AMD64HotSpotLoadConfigValueOp> TYPE = LIRInstructionClass.create(AMD64HotSpotLoadConfigValueOp.class);
|
|
44 |
|
|
45 |
@Def({OperandFlag.REG}) protected AllocatableValue result;
|
|
46 |
private final int markId;
|
|
47 |
|
|
48 |
public AMD64HotSpotLoadConfigValueOp(int markId, AllocatableValue result) {
|
|
49 |
super(TYPE);
|
|
50 |
this.result = result;
|
|
51 |
this.markId = markId;
|
|
52 |
}
|
|
53 |
|
|
54 |
@Override
|
|
55 |
public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
|
46344
|
56 |
if (GeneratePIC.getValue(crb.getOptions())) {
|
43972
|
57 |
AMD64Kind kind = (AMD64Kind) result.getPlatformKind();
|
|
58 |
Register reg = asRegister(result);
|
|
59 |
AMD64Address placeholder = masm.getPlaceholder(-1);
|
|
60 |
switch (kind) {
|
|
61 |
case BYTE:
|
|
62 |
masm.movsbl(reg, placeholder);
|
|
63 |
break;
|
|
64 |
case WORD:
|
|
65 |
masm.movswl(reg, placeholder);
|
|
66 |
break;
|
|
67 |
case DWORD:
|
|
68 |
masm.movl(reg, placeholder);
|
|
69 |
break;
|
|
70 |
case QWORD:
|
|
71 |
masm.movq(reg, placeholder);
|
|
72 |
break;
|
|
73 |
default:
|
|
74 |
throw GraalError.unimplemented();
|
|
75 |
}
|
|
76 |
} else {
|
|
77 |
throw GraalError.unimplemented();
|
|
78 |
}
|
|
79 |
crb.recordMark(markId);
|
|
80 |
}
|
|
81 |
|
|
82 |
}
|