src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir.amd64/src/org/graalvm/compiler/lir/amd64/vector/AMD64VectorMove.java
author dlong
Thu, 14 Nov 2019 12:21:00 -0800
changeset 59095 03fbcd06b4c0
parent 58877 aec7bf35d6f5
permissions -rw-r--r--
8233841: Update Graal Reviewed-by: kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
     1
/*
58299
6df94ce3ab2f 8229201: Update Graal
dlong
parents: 51436
diff changeset
     2
 * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
     4
 *
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
     7
 * published by the Free Software Foundation.
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
     8
 *
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    13
 * accompanied this code).
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    14
 *
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    18
 *
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    21
 * questions.
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    22
 */
50858
2d3e99a72541 8205824: Update Graal
never
parents: 50609
diff changeset
    23
2d3e99a72541 8205824: Update Graal
never
parents: 50609
diff changeset
    24
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    25
package org.graalvm.compiler.lir.amd64.vector;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    26
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    27
import static jdk.vm.ci.code.ValueUtil.asRegister;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    28
import static jdk.vm.ci.code.ValueUtil.isRegister;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    29
import static jdk.vm.ci.code.ValueUtil.isStackSlot;
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
    30
import static org.graalvm.compiler.asm.amd64.AMD64Assembler.VexMoveOp.VMOVD;
58299
6df94ce3ab2f 8229201: Update Graal
dlong
parents: 51436
diff changeset
    31
import static org.graalvm.compiler.asm.amd64.AMD64Assembler.VexMoveOp.VMOVDQU32;
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
    32
import static org.graalvm.compiler.asm.amd64.AMD64Assembler.VexMoveOp.VMOVQ;
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
    33
import static org.graalvm.compiler.asm.amd64.AMD64Assembler.VexMoveOp.VMOVSD;
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
    34
import static org.graalvm.compiler.asm.amd64.AMD64Assembler.VexMoveOp.VMOVSS;
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
    35
import static org.graalvm.compiler.asm.amd64.AMD64Assembler.VexMoveOp.VMOVUPD;
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
    36
import static org.graalvm.compiler.asm.amd64.AMD64Assembler.VexMoveOp.VMOVUPS;
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
    37
import static org.graalvm.compiler.asm.amd64.AMD64Assembler.VexRVMOp.VXORPD;
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    38
import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.COMPOSITE;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    39
import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.HINT;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    40
import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.REG;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    41
import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.STACK;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    42
import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.UNINITIALIZED;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    43
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    44
import org.graalvm.compiler.asm.amd64.AMD64Address;
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
    45
import org.graalvm.compiler.asm.amd64.AMD64Assembler.VexMoveOp;
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    46
import org.graalvm.compiler.asm.amd64.AMD64MacroAssembler;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    47
import org.graalvm.compiler.asm.amd64.AVXKind;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    48
import org.graalvm.compiler.asm.amd64.AVXKind.AVXSize;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    49
import org.graalvm.compiler.debug.GraalError;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    50
import org.graalvm.compiler.lir.LIRFrameState;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    51
import org.graalvm.compiler.lir.LIRInstructionClass;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    52
import org.graalvm.compiler.lir.Opcode;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    53
import org.graalvm.compiler.lir.StandardOp.LoadConstantOp;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    54
import org.graalvm.compiler.lir.StandardOp.ValueMoveOp;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    55
import org.graalvm.compiler.lir.amd64.AMD64AddressValue;
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
    56
import org.graalvm.compiler.lir.amd64.AMD64LIRInstruction;
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    57
import org.graalvm.compiler.lir.amd64.AMD64Move;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    58
import org.graalvm.compiler.lir.amd64.AMD64RestoreRegistersOp;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    59
import org.graalvm.compiler.lir.amd64.AMD64SaveRegistersOp;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    60
import org.graalvm.compiler.lir.asm.CompilationResultBuilder;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    61
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    62
import jdk.vm.ci.amd64.AMD64Kind;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    63
import jdk.vm.ci.code.Register;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    64
import jdk.vm.ci.code.RegisterValue;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    65
import jdk.vm.ci.code.StackSlot;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    66
import jdk.vm.ci.meta.AllocatableValue;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    67
import jdk.vm.ci.meta.Constant;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    68
import jdk.vm.ci.meta.JavaConstant;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    69
import jdk.vm.ci.meta.Value;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    70
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    71
public class AMD64VectorMove {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    72
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    73
    @Opcode("VMOVE")
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
    74
    public static final class MoveToRegOp extends AMD64LIRInstruction implements ValueMoveOp {
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    75
        public static final LIRInstructionClass<MoveToRegOp> TYPE = LIRInstructionClass.create(MoveToRegOp.class);
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    76
58877
aec7bf35d6f5 8233273: Update Graal
dlong
parents: 58299
diff changeset
    77
        @Def({REG, STACK, HINT}) protected AllocatableValue result;
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    78
        @Use({REG, STACK}) protected AllocatableValue input;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    79
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    80
        public MoveToRegOp(AllocatableValue result, AllocatableValue input) {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    81
            super(TYPE);
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    82
            this.result = result;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    83
            this.input = input;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    84
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    85
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    86
        @Override
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
    87
        public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
    88
            move(crb, masm, result, input);
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    89
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    90
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    91
        @Override
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    92
        public AllocatableValue getInput() {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    93
            return input;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    94
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    95
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    96
        @Override
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    97
        public AllocatableValue getResult() {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    98
            return result;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    99
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   100
    }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   101
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   102
    @Opcode("VMOVE")
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
   103
    public static final class MoveFromRegOp extends AMD64LIRInstruction implements ValueMoveOp {
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   104
        public static final LIRInstructionClass<MoveFromRegOp> TYPE = LIRInstructionClass.create(MoveFromRegOp.class);
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   105
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   106
        @Def({REG, STACK}) protected AllocatableValue result;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   107
        @Use({REG, HINT}) protected AllocatableValue input;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   108
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   109
        public MoveFromRegOp(AllocatableValue result, AllocatableValue input) {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   110
            super(TYPE);
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   111
            this.result = result;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   112
            this.input = input;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   113
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   114
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   115
        @Override
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
   116
        public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
   117
            move(crb, masm, result, input);
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   118
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   119
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   120
        @Override
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   121
        public AllocatableValue getInput() {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   122
            return input;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   123
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   124
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   125
        @Override
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   126
        public AllocatableValue getResult() {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   127
            return result;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   128
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   129
    }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   130
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   131
    @Opcode("VMOVE")
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
   132
    public static class MoveFromConstOp extends AMD64LIRInstruction implements LoadConstantOp {
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   133
        public static final LIRInstructionClass<MoveFromConstOp> TYPE = LIRInstructionClass.create(MoveFromConstOp.class);
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   134
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   135
        @Def({REG, STACK}) protected AllocatableValue result;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   136
        private final JavaConstant input;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   137
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   138
        public MoveFromConstOp(AllocatableValue result, JavaConstant input) {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   139
            super(TYPE);
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   140
            this.result = result;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   141
            this.input = input;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   142
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   143
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   144
        @Override
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
   145
        public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   146
            if (isRegister(result)) {
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
   147
                const2reg(crb, masm, (RegisterValue) result, input);
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   148
            } else {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   149
                assert isStackSlot(result);
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
   150
                AMD64Move.const2stack(crb, masm, result, input);
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   151
            }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   152
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   153
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   154
        @Override
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   155
        public Constant getConstant() {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   156
            return input;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   157
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   158
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   159
        @Override
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   160
        public AllocatableValue getResult() {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   161
            return result;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   162
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   163
    }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   164
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   165
    @Opcode("VSTACKMOVE")
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
   166
    public static final class StackMoveOp extends AMD64LIRInstruction implements ValueMoveOp {
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   167
        public static final LIRInstructionClass<StackMoveOp> TYPE = LIRInstructionClass.create(StackMoveOp.class);
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   168
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   169
        @Def({STACK}) protected AllocatableValue result;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   170
        @Use({STACK, HINT}) protected AllocatableValue input;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   171
        @Alive({STACK, UNINITIALIZED}) private AllocatableValue backupSlot;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   172
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   173
        private Register scratch;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   174
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   175
        public StackMoveOp(AllocatableValue result, AllocatableValue input, Register scratch, AllocatableValue backupSlot) {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   176
            super(TYPE);
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   177
            this.result = result;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   178
            this.input = input;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   179
            this.backupSlot = backupSlot;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   180
            this.scratch = scratch;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   181
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   182
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   183
        @Override
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   184
        public AllocatableValue getInput() {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   185
            return input;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   186
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   187
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   188
        @Override
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   189
        public AllocatableValue getResult() {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   190
            return result;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   191
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   192
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   193
        @Override
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
   194
        public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   195
            // backup scratch register
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   196
            move(crb, masm, backupSlot, scratch.asValue(backupSlot.getValueKind()));
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   197
            // move stack slot
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   198
            move(crb, masm, scratch.asValue(getInput().getValueKind()), getInput());
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   199
            move(crb, masm, getResult(), scratch.asValue(getResult().getValueKind()));
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   200
            // restore scratch register
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   201
            move(crb, masm, scratch.asValue(backupSlot.getValueKind()), backupSlot);
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   202
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   203
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   204
    }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   205
59095
03fbcd06b4c0 8233841: Update Graal
dlong
parents: 58877
diff changeset
   206
    public abstract static class VectorMemOp extends AMD64VectorInstruction {
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   207
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   208
        protected final VexMoveOp op;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   209
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   210
        @Use({COMPOSITE}) protected AMD64AddressValue address;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   211
        @State protected LIRFrameState state;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   212
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   213
        protected VectorMemOp(LIRInstructionClass<? extends VectorMemOp> c, AVXSize size, VexMoveOp op, AMD64AddressValue address, LIRFrameState state) {
59095
03fbcd06b4c0 8233841: Update Graal
dlong
parents: 58877
diff changeset
   214
            super(c, size);
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   215
            this.op = op;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   216
            this.address = address;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   217
            this.state = state;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   218
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   219
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
   220
        protected abstract void emitMemAccess(AMD64MacroAssembler masm);
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   221
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   222
        @Override
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
   223
        public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   224
            if (state != null) {
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
   225
                crb.recordImplicitException(masm.position(), state);
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   226
            }
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
   227
            emitMemAccess(masm);
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   228
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   229
    }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   230
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   231
    public static final class VectorLoadOp extends VectorMemOp {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   232
        public static final LIRInstructionClass<VectorLoadOp> TYPE = LIRInstructionClass.create(VectorLoadOp.class);
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   233
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   234
        @Def({REG}) protected AllocatableValue result;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   235
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   236
        public VectorLoadOp(AVXSize size, VexMoveOp op, AllocatableValue result, AMD64AddressValue address, LIRFrameState state) {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   237
            super(TYPE, size, op, address, state);
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   238
            this.result = result;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   239
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   240
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   241
        @Override
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
   242
        public void emitMemAccess(AMD64MacroAssembler masm) {
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
   243
            op.emit(masm, size, asRegister(result), address.toAddress());
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   244
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   245
    }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   246
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   247
    public static class VectorStoreOp extends VectorMemOp {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   248
        public static final LIRInstructionClass<VectorStoreOp> TYPE = LIRInstructionClass.create(VectorStoreOp.class);
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   249
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   250
        @Use({REG}) protected AllocatableValue input;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   251
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   252
        public VectorStoreOp(AVXSize size, VexMoveOp op, AMD64AddressValue address, AllocatableValue input, LIRFrameState state) {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   253
            super(TYPE, size, op, address, state);
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   254
            this.input = input;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   255
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   256
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   257
        @Override
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
   258
        public void emitMemAccess(AMD64MacroAssembler masm) {
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
   259
            op.emit(masm, size, address.toAddress(), asRegister(input));
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   260
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   261
    }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   262
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   263
    @Opcode("SAVE_REGISTER")
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   264
    public static class SaveRegistersOp extends AMD64SaveRegistersOp {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   265
        public static final LIRInstructionClass<SaveRegistersOp> TYPE = LIRInstructionClass.create(SaveRegistersOp.class);
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   266
58299
6df94ce3ab2f 8229201: Update Graal
dlong
parents: 51436
diff changeset
   267
        public SaveRegistersOp(Register[] savedRegisters, AllocatableValue[] slots) {
6df94ce3ab2f 8229201: Update Graal
dlong
parents: 51436
diff changeset
   268
            super(TYPE, savedRegisters, slots);
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   269
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   270
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   271
        @Override
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   272
        protected void saveRegister(CompilationResultBuilder crb, AMD64MacroAssembler masm, StackSlot result, Register register) {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   273
            AMD64Kind kind = (AMD64Kind) result.getPlatformKind();
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   274
            if (kind.isXMM()) {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   275
                VexMoveOp op;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   276
                if (kind.getVectorLength() > 1) {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   277
                    op = getVectorMoveOp(kind.getScalar());
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   278
                } else {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   279
                    op = getScalarMoveOp(kind);
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   280
                }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   281
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   282
                AMD64Address addr = (AMD64Address) crb.asAddress(result);
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
   283
                op.emit(masm, AVXKind.getRegisterSize(kind), addr, register);
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   284
            } else {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   285
                super.saveRegister(crb, masm, result, register);
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   286
            }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   287
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   288
    }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   289
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   290
    @Opcode("RESTORE_REGISTER")
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   291
    public static final class RestoreRegistersOp extends AMD64RestoreRegistersOp {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   292
        public static final LIRInstructionClass<RestoreRegistersOp> TYPE = LIRInstructionClass.create(RestoreRegistersOp.class);
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   293
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   294
        public RestoreRegistersOp(AllocatableValue[] source, AMD64SaveRegistersOp save) {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   295
            super(TYPE, source, save);
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   296
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   297
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   298
        @Override
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   299
        protected void restoreRegister(CompilationResultBuilder crb, AMD64MacroAssembler masm, Register register, StackSlot input) {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   300
            AMD64Kind kind = (AMD64Kind) input.getPlatformKind();
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   301
            if (kind.isXMM()) {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   302
                VexMoveOp op;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   303
                if (kind.getVectorLength() > 1) {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   304
                    op = getVectorMoveOp(kind.getScalar());
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   305
                } else {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   306
                    op = getScalarMoveOp(kind);
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   307
                }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   308
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   309
                AMD64Address addr = (AMD64Address) crb.asAddress(input);
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
   310
                op.emit(masm, AVXKind.getRegisterSize(kind), register, addr);
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   311
            } else {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   312
                super.restoreRegister(crb, masm, register, input);
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   313
            }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   314
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   315
    }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   316
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   317
    private static VexMoveOp getScalarMoveOp(AMD64Kind kind) {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   318
        switch (kind) {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   319
            case SINGLE:
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   320
                return VMOVSS;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   321
            case DOUBLE:
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   322
                return VMOVSD;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   323
            default:
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   324
                throw GraalError.shouldNotReachHere();
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   325
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   326
    }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   327
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   328
    private static VexMoveOp getVectorMoveOp(AMD64Kind kind) {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   329
        switch (kind) {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   330
            case SINGLE:
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   331
                return VMOVUPS;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   332
            case DOUBLE:
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   333
                return VMOVUPD;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   334
            default:
58299
6df94ce3ab2f 8229201: Update Graal
dlong
parents: 51436
diff changeset
   335
                return VMOVDQU32;
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   336
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   337
    }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   338
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   339
    private static VexMoveOp getVectorMemMoveOp(AMD64Kind kind) {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   340
        switch (AVXKind.getDataSize(kind)) {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   341
            case DWORD:
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   342
                return VMOVD;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   343
            case QWORD:
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   344
                return VMOVQ;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   345
            default:
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   346
                return getVectorMoveOp(kind.getScalar());
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   347
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   348
    }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   349
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
   350
    private static void move(CompilationResultBuilder crb, AMD64MacroAssembler masm, AllocatableValue result, Value input) {
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   351
        VexMoveOp op;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   352
        AVXSize size;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   353
        AMD64Kind kind = (AMD64Kind) result.getPlatformKind();
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   354
        if (kind.getVectorLength() > 1) {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   355
            size = AVXKind.getRegisterSize(kind);
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   356
            if (isRegister(input) && isRegister(result)) {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   357
                op = getVectorMoveOp(kind.getScalar());
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   358
            } else {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   359
                op = getVectorMemMoveOp(kind);
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   360
            }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   361
        } else {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   362
            size = AVXSize.XMM;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   363
            if (isRegister(input) && isRegister(result)) {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   364
                op = getVectorMoveOp(kind);
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   365
            } else {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   366
                op = getScalarMoveOp(kind);
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   367
            }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   368
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   369
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   370
        if (isRegister(input)) {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   371
            if (isRegister(result)) {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   372
                if (!asRegister(input).equals(asRegister(result))) {
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
   373
                    op.emit(masm, size, asRegister(result), asRegister(input));
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   374
                }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   375
            } else {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   376
                assert isStackSlot(result);
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
   377
                op.emit(masm, size, (AMD64Address) crb.asAddress(result), asRegister(input));
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   378
            }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   379
        } else {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   380
            assert isStackSlot(input) && isRegister(result);
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
   381
            op.emit(masm, size, asRegister(result), (AMD64Address) crb.asAddress(input));
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   382
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   383
    }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   384
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
   385
    private static void const2reg(CompilationResultBuilder crb, AMD64MacroAssembler masm, RegisterValue result, JavaConstant input) {
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   386
        if (input.isDefaultForKind()) {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   387
            AMD64Kind kind = (AMD64Kind) result.getPlatformKind();
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   388
            Register register = result.getRegister();
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
   389
            VXORPD.emit(masm, AVXKind.getRegisterSize(kind), register, register, register);
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   390
            return;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   391
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   392
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   393
        AMD64Address address;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   394
        switch (input.getJavaKind()) {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   395
            case Float:
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   396
                address = (AMD64Address) crb.asFloatConstRef(input);
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   397
                break;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   398
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   399
            case Double:
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   400
                address = (AMD64Address) crb.asDoubleConstRef(input);
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   401
                break;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   402
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   403
            default:
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   404
                throw GraalError.shouldNotReachHere();
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   405
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   406
        VexMoveOp op = getScalarMoveOp((AMD64Kind) result.getPlatformKind());
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
   407
        op.emit(masm, AVXSize.XMM, asRegister(result), address);
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   408
    }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   409
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
   410
    public static final class AVXMoveToIntOp extends AMD64LIRInstruction {
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   411
        public static final LIRInstructionClass<AVXMoveToIntOp> TYPE = LIRInstructionClass.create(AVXMoveToIntOp.class);
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   412
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   413
        @Opcode private final VexMoveOp opcode;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   414
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   415
        @Def({REG, STACK}) protected AllocatableValue result;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   416
        @Use({REG}) protected AllocatableValue input;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   417
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   418
        public AVXMoveToIntOp(VexMoveOp opcode, AllocatableValue result, AllocatableValue input) {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   419
            super(TYPE);
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   420
            this.opcode = opcode;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   421
            this.result = result;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   422
            this.input = input;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   423
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   424
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   425
        @Override
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
   426
        public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   427
            if (isRegister(result)) {
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
   428
                opcode.emitReverse(masm, AVXSize.XMM, asRegister(result), asRegister(input));
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   429
            } else {
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
   430
                opcode.emit(masm, AVXSize.XMM, (AMD64Address) crb.asAddress(result), asRegister(input));
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   431
            }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   432
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   433
    }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
   434
}