SPARCOPFOp.java revision 12657:6ef01bd40ce2
1/*
2 * Copyright (c) 2015, 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.lir.sparc;
24
25import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.REG;
26import static jdk.vm.ci.code.ValueUtil.asRegister;
27
28import org.graalvm.compiler.asm.sparc.SPARCAssembler;
29import org.graalvm.compiler.asm.sparc.SPARCAssembler.Opfs;
30import org.graalvm.compiler.asm.sparc.SPARCMacroAssembler;
31import org.graalvm.compiler.core.common.LIRKind;
32import org.graalvm.compiler.lir.LIRFrameState;
33import org.graalvm.compiler.lir.LIRInstructionClass;
34import org.graalvm.compiler.lir.Opcode;
35import org.graalvm.compiler.lir.asm.CompilationResultBuilder;
36
37import jdk.vm.ci.meta.Value;
38import jdk.vm.ci.sparc.SPARC;
39import jdk.vm.ci.sparc.SPARCKind;
40
41public final class SPARCOPFOp extends SPARCLIRInstruction implements SPARCTailDelayedLIRInstruction {
42    public static final LIRInstructionClass<SPARCOPFOp> TYPE = LIRInstructionClass.create(SPARCOPFOp.class);
43    public static final SizeEstimate SIZE = SizeEstimate.create(1);
44
45    @Opcode protected final Opfs opf;
46    @Use({REG}) protected Value rs1;
47    @Use({REG}) protected Value rs2;
48    @Def({REG}) protected Value rd;
49    @State protected LIRFrameState state;
50
51    public SPARCOPFOp(Opfs opf, Value rs2, Value rd) {
52        this(opf, SPARC.g0.asValue(LIRKind.value(SPARCKind.SINGLE)), rs2, rd);
53    }
54
55    public SPARCOPFOp(Opfs opf, Value rs1, Value rs2, Value rd) {
56        this(opf, rs1, rs2, rd, null);
57    }
58
59    public SPARCOPFOp(Opfs opf, Value rs1, Value rs2, Value rd, LIRFrameState state) {
60        super(TYPE, SIZE);
61        this.opf = opf;
62        this.rs1 = rs1;
63        this.rs2 = rs2;
64        this.rd = rd;
65        this.state = state;
66    }
67
68    @Override
69    protected void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) {
70        getDelayedControlTransfer().emitControlTransfer(crb, masm);
71        if (state != null) {
72            crb.recordImplicitException(masm.position(), state);
73        }
74        SPARCAssembler.OpfOp.emit(masm, opf, asRegister(rs1), asRegister(rs2), asRegister(rd));
75    }
76}
77