1 /* |
1 /* |
2 * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
33 import org.graalvm.compiler.asm.amd64.AMD64Address; |
33 import org.graalvm.compiler.asm.amd64.AMD64Address; |
34 import org.graalvm.compiler.asm.amd64.AMD64Assembler.VexRRIOp; |
34 import org.graalvm.compiler.asm.amd64.AMD64Assembler.VexRRIOp; |
35 import org.graalvm.compiler.asm.amd64.AMD64Assembler.VexRVMOp; |
35 import org.graalvm.compiler.asm.amd64.AMD64Assembler.VexRVMOp; |
36 import org.graalvm.compiler.asm.amd64.AMD64MacroAssembler; |
36 import org.graalvm.compiler.asm.amd64.AMD64MacroAssembler; |
37 import org.graalvm.compiler.asm.amd64.AVXKind; |
37 import org.graalvm.compiler.asm.amd64.AVXKind; |
|
38 import org.graalvm.compiler.lir.ConstantValue; |
38 import org.graalvm.compiler.lir.LIRFrameState; |
39 import org.graalvm.compiler.lir.LIRFrameState; |
39 import org.graalvm.compiler.lir.LIRInstructionClass; |
40 import org.graalvm.compiler.lir.LIRInstructionClass; |
40 import org.graalvm.compiler.lir.Opcode; |
41 import org.graalvm.compiler.lir.Opcode; |
41 import org.graalvm.compiler.lir.amd64.AMD64AddressValue; |
42 import org.graalvm.compiler.lir.amd64.AMD64AddressValue; |
42 import org.graalvm.compiler.lir.amd64.AMD64LIRInstruction; |
43 import org.graalvm.compiler.lir.amd64.AMD64LIRInstruction; |
43 import org.graalvm.compiler.lir.asm.CompilationResultBuilder; |
44 import org.graalvm.compiler.lir.asm.CompilationResultBuilder; |
44 |
45 |
|
46 import jdk.vm.ci.amd64.AMD64Kind; |
45 import jdk.vm.ci.meta.AllocatableValue; |
47 import jdk.vm.ci.meta.AllocatableValue; |
46 |
48 |
47 public class AMD64VectorBinary { |
49 public class AMD64VectorBinary { |
48 |
50 |
49 public static final class AVXBinaryOp extends AMD64LIRInstruction { |
51 public static final class AVXBinaryOp extends AMD64LIRInstruction { |
100 public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { |
102 public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { |
101 opcode.emit(masm, size, asRegister(result), asRegister(x), y); |
103 opcode.emit(masm, size, asRegister(result), asRegister(x), y); |
102 } |
104 } |
103 } |
105 } |
104 |
106 |
|
107 public static final class AVXBinaryConstFloatOp extends AMD64LIRInstruction { |
|
108 |
|
109 public static final LIRInstructionClass<AVXBinaryConstFloatOp> TYPE = LIRInstructionClass.create(AVXBinaryConstFloatOp.class); |
|
110 |
|
111 @Opcode private final VexRVMOp opcode; |
|
112 private final AVXKind.AVXSize size; |
|
113 |
|
114 @Def({REG}) protected AllocatableValue result; |
|
115 @Use({REG}) protected AllocatableValue x; |
|
116 protected ConstantValue y; |
|
117 |
|
118 public AVXBinaryConstFloatOp(VexRVMOp opcode, AVXKind.AVXSize size, AllocatableValue result, AllocatableValue x, ConstantValue y) { |
|
119 super(TYPE); |
|
120 assert y.getPlatformKind() == AMD64Kind.SINGLE || y.getPlatformKind() == AMD64Kind.DOUBLE; |
|
121 this.opcode = opcode; |
|
122 this.size = size; |
|
123 this.result = result; |
|
124 this.x = x; |
|
125 this.y = y; |
|
126 } |
|
127 |
|
128 @Override |
|
129 public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { |
|
130 if (y.getPlatformKind() == AMD64Kind.SINGLE) { |
|
131 opcode.emit(masm, size, asRegister(result), asRegister(x), (AMD64Address) crb.asFloatConstRef(y.getJavaConstant())); |
|
132 } else { |
|
133 assert y.getPlatformKind() == AMD64Kind.DOUBLE; |
|
134 opcode.emit(masm, size, asRegister(result), asRegister(x), (AMD64Address) crb.asDoubleConstRef(y.getJavaConstant())); |
|
135 } |
|
136 } |
|
137 } |
|
138 |
105 public static final class AVXBinaryMemoryOp extends AMD64LIRInstruction { |
139 public static final class AVXBinaryMemoryOp extends AMD64LIRInstruction { |
106 public static final LIRInstructionClass<AVXBinaryMemoryOp> TYPE = LIRInstructionClass.create(AVXBinaryMemoryOp.class); |
140 public static final LIRInstructionClass<AVXBinaryMemoryOp> TYPE = LIRInstructionClass.create(AVXBinaryMemoryOp.class); |
107 |
141 |
108 @Opcode private final VexRVMOp opcode; |
142 @Opcode private final VexRVMOp opcode; |
109 private final AVXKind.AVXSize size; |
143 private final AVXKind.AVXSize size; |