src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir.amd64/src/org/graalvm/compiler/lir/amd64/vector/AMD64VectorClearOp.java
author dlong
Thu, 14 Nov 2019 12:21:00 -0800
changeset 59095 03fbcd06b4c0
parent 51436 091c0d22e735
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
/*
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
     2
 * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
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
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
    27
import static jdk.vm.ci.code.ValueUtil.asRegister;
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
    28
import static org.graalvm.compiler.asm.amd64.AMD64Assembler.VexRVMOp.VPXOR;
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
    29
import static org.graalvm.compiler.asm.amd64.AMD64Assembler.VexRVMOp.VXORPD;
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
    30
import static org.graalvm.compiler.asm.amd64.AMD64Assembler.VexRVMOp.VXORPS;
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    31
import static org.graalvm.compiler.asm.amd64.AVXKind.AVXSize.XMM;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    32
import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.REG;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    33
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
    34
import org.graalvm.compiler.asm.amd64.AMD64MacroAssembler;
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
    35
import org.graalvm.compiler.asm.amd64.AVXKind;
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    36
import org.graalvm.compiler.lir.LIRInstruction;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    37
import org.graalvm.compiler.lir.LIRInstructionClass;
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
    38
import org.graalvm.compiler.lir.amd64.AMD64LIRInstruction;
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    39
import org.graalvm.compiler.lir.asm.CompilationResultBuilder;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    40
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    41
import jdk.vm.ci.amd64.AMD64Kind;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    42
import jdk.vm.ci.code.Register;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    43
import jdk.vm.ci.meta.AllocatableValue;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    44
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
    45
public class AMD64VectorClearOp extends AMD64LIRInstruction {
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    46
    public static final LIRInstructionClass<AMD64VectorClearOp> TYPE = LIRInstructionClass.create(AMD64VectorClearOp.class);
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    47
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    48
    protected @LIRInstruction.Def({REG}) AllocatableValue result;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    49
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    50
    public AMD64VectorClearOp(AllocatableValue result) {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    51
        this(TYPE, result);
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    52
    }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    53
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    54
    protected AMD64VectorClearOp(LIRInstructionClass<? extends AMD64VectorClearOp> c, AllocatableValue result) {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    55
        super(c);
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    56
        this.result = result;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    57
    }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    58
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    59
    @Override
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
    60
    public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    61
        AMD64Kind kind = (AMD64Kind) result.getPlatformKind();
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    62
        Register register = asRegister(result);
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    63
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    64
        switch (kind.getScalar()) {
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    65
            case SINGLE:
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
    66
                VXORPS.emit(masm, AVXKind.getRegisterSize(kind), register, register, register);
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    67
                break;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    68
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    69
            case DOUBLE:
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
    70
                VXORPD.emit(masm, AVXKind.getRegisterSize(kind), register, register, register);
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    71
                break;
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    72
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    73
            default:
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    74
                // on AVX1, YMM VPXOR is not supported - still it is possible to clear the whole YMM
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    75
                // register as the upper 128-bit are implicitly cleared by the AVX1 instruction.
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50858
diff changeset
    76
                VPXOR.emit(masm, XMM, register, register, register);
50609
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    77
        }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    78
    }
bf414874c28f 8204231: Update Graal
dlong
parents:
diff changeset
    79
}