< prev index next >
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.amd64/src/org/graalvm/compiler/core/amd64/AMD64ArithmeticLIRGenerator.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
@@ -78,17 +78,10 @@
import static org.graalvm.compiler.lir.LIRValueUtil.asJavaConstant;
import static org.graalvm.compiler.lir.LIRValueUtil.isConstantValue;
import static org.graalvm.compiler.lir.LIRValueUtil.isJavaConstant;
import static org.graalvm.compiler.lir.amd64.AMD64Arithmetic.DREM;
import static org.graalvm.compiler.lir.amd64.AMD64Arithmetic.FREM;
-import static org.graalvm.compiler.lir.amd64.AMD64MathIntrinsicBinaryOp.BinaryIntrinsicOpcode.POW;
-import static org.graalvm.compiler.lir.amd64.AMD64MathIntrinsicUnaryOp.UnaryIntrinsicOpcode.COS;
-import static org.graalvm.compiler.lir.amd64.AMD64MathIntrinsicUnaryOp.UnaryIntrinsicOpcode.EXP;
-import static org.graalvm.compiler.lir.amd64.AMD64MathIntrinsicUnaryOp.UnaryIntrinsicOpcode.LOG;
-import static org.graalvm.compiler.lir.amd64.AMD64MathIntrinsicUnaryOp.UnaryIntrinsicOpcode.LOG10;
-import static org.graalvm.compiler.lir.amd64.AMD64MathIntrinsicUnaryOp.UnaryIntrinsicOpcode.SIN;
-import static org.graalvm.compiler.lir.amd64.AMD64MathIntrinsicUnaryOp.UnaryIntrinsicOpcode.TAN;
import org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64BinaryArithmetic;
import org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64MIOp;
import org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64MOp;
import org.graalvm.compiler.asm.amd64.AMD64Assembler.AMD64MROp;
@@ -114,22 +107,26 @@
import org.graalvm.compiler.lir.amd64.AMD64Arithmetic.FPDivRemOp;
import org.graalvm.compiler.lir.amd64.AMD64ArithmeticLIRGeneratorTool;
import org.graalvm.compiler.lir.amd64.AMD64Binary;
import org.graalvm.compiler.lir.amd64.AMD64BinaryConsumer;
import org.graalvm.compiler.lir.amd64.AMD64ClearRegisterOp;
-import org.graalvm.compiler.lir.amd64.AMD64MathIntrinsicBinaryOp;
-import org.graalvm.compiler.lir.amd64.AMD64MathIntrinsicUnaryOp;
+import org.graalvm.compiler.lir.amd64.AMD64MathCosOp;
+import org.graalvm.compiler.lir.amd64.AMD64MathExpOp;
+import org.graalvm.compiler.lir.amd64.AMD64MathLog10Op;
+import org.graalvm.compiler.lir.amd64.AMD64MathLogOp;
+import org.graalvm.compiler.lir.amd64.AMD64MathPowOp;
+import org.graalvm.compiler.lir.amd64.AMD64MathSinOp;
+import org.graalvm.compiler.lir.amd64.AMD64MathTanOp;
import org.graalvm.compiler.lir.amd64.AMD64Move;
import org.graalvm.compiler.lir.amd64.AMD64MulDivOp;
import org.graalvm.compiler.lir.amd64.AMD64ShiftOp;
import org.graalvm.compiler.lir.amd64.AMD64SignExtendOp;
import org.graalvm.compiler.lir.amd64.AMD64Unary;
import org.graalvm.compiler.lir.amd64.vector.AMD64VectorBinary;
import org.graalvm.compiler.lir.amd64.vector.AMD64VectorBinary.AVXBinaryOp;
import org.graalvm.compiler.lir.amd64.vector.AMD64VectorUnary;
import org.graalvm.compiler.lir.gen.ArithmeticLIRGenerator;
-import org.graalvm.compiler.lir.gen.LIRGenerator;
import jdk.vm.ci.amd64.AMD64;
import jdk.vm.ci.amd64.AMD64.CPUFeature;
import jdk.vm.ci.amd64.AMD64Kind;
import jdk.vm.ci.code.CodeUtil;
@@ -150,45 +147,15 @@
*/
public class AMD64ArithmeticLIRGenerator extends ArithmeticLIRGenerator implements AMD64ArithmeticLIRGeneratorTool {
private static final RegisterValue RCX_I = AMD64.rcx.asValue(LIRKind.value(AMD64Kind.DWORD));
- public AMD64ArithmeticLIRGenerator(AllocatableValue nullRegisterValue, Maths maths) {
+ public AMD64ArithmeticLIRGenerator(AllocatableValue nullRegisterValue) {
this.nullRegisterValue = nullRegisterValue;
- this.maths = maths == null ? new Maths() {
- } : maths;
}
private final AllocatableValue nullRegisterValue;
- private final Maths maths;
-
- /**
- * Interface for emitting LIR for selected {@link Math} routines. A {@code null} return value
- * for any method in this interface means the caller must emit the LIR itself.
- */
- public interface Maths {
-
- @SuppressWarnings("unused")
- default Variable emitLog(LIRGenerator gen, Value input, boolean base10) {
- return null;
- }
-
- @SuppressWarnings("unused")
- default Variable emitCos(LIRGenerator gen, Value input) {
- return null;
- }
-
- @SuppressWarnings("unused")
- default Variable emitSin(LIRGenerator gen, Value input) {
- return null;
- }
-
- @SuppressWarnings("unused")
- default Variable emitTan(LIRGenerator gen, Value input) {
- return null;
- }
- }
@Override
public Variable emitNegate(Value inputVal) {
AllocatableValue input = asAllocatable(inputVal);
Variable result = getLIRGen().newVariable(LIRKind.combine(input));
@@ -779,10 +746,11 @@
default:
throw GraalError.shouldNotReachHere();
}
}
+ @Override
public Variable emitRor(Value a, Value b) {
switch ((AMD64Kind) a.getPlatformKind()) {
case DWORD:
return emitShift(ROR, DWORD, a, b);
case QWORD:
@@ -1101,69 +1069,40 @@
return result;
}
@Override
public Value emitMathLog(Value input, boolean base10) {
- LIRGenerator gen = getLIRGen();
- Variable result = maths.emitLog(gen, input, base10);
- if (result == null) {
- result = gen.newVariable(LIRKind.combine(input));
- AllocatableValue stackSlot = gen.getResult().getFrameMapBuilder().allocateSpillSlot(LIRKind.value(AMD64Kind.QWORD));
- gen.append(new AMD64MathIntrinsicUnaryOp(getAMD64LIRGen(), base10 ? LOG10 : LOG, result, asAllocatable(input), stackSlot));
+ if (base10) {
+ return new AMD64MathLog10Op().emitLIRWrapper(getLIRGen(), input);
+ } else {
+ return new AMD64MathLogOp().emitLIRWrapper(getLIRGen(), input);
}
- return result;
}
@Override
public Value emitMathCos(Value input) {
- LIRGenerator gen = getLIRGen();
- Variable result = maths.emitCos(gen, input);
- if (result == null) {
- result = gen.newVariable(LIRKind.combine(input));
- AllocatableValue stackSlot = gen.getResult().getFrameMapBuilder().allocateSpillSlot(LIRKind.value(AMD64Kind.QWORD));
- gen.append(new AMD64MathIntrinsicUnaryOp(getAMD64LIRGen(), COS, result, asAllocatable(input), stackSlot));
- }
- return result;
+ return new AMD64MathCosOp().emitLIRWrapper(getLIRGen(), input);
}
@Override
public Value emitMathSin(Value input) {
- LIRGenerator gen = getLIRGen();
- Variable result = maths.emitSin(gen, input);
- if (result == null) {
- result = gen.newVariable(LIRKind.combine(input));
- AllocatableValue stackSlot = gen.getResult().getFrameMapBuilder().allocateSpillSlot(LIRKind.value(AMD64Kind.QWORD));
- gen.append(new AMD64MathIntrinsicUnaryOp(getAMD64LIRGen(), SIN, result, asAllocatable(input), stackSlot));
- }
- return result;
+ return new AMD64MathSinOp().emitLIRWrapper(getLIRGen(), input);
}
@Override
public Value emitMathTan(Value input) {
- LIRGenerator gen = getLIRGen();
- Variable result = maths.emitTan(gen, input);
- if (result == null) {
- result = gen.newVariable(LIRKind.combine(input));
- AllocatableValue stackSlot = gen.getResult().getFrameMapBuilder().allocateSpillSlot(LIRKind.value(AMD64Kind.QWORD));
- gen.append(new AMD64MathIntrinsicUnaryOp(getAMD64LIRGen(), TAN, result, asAllocatable(input), stackSlot));
- }
- return result;
+ return new AMD64MathTanOp().emitLIRWrapper(getLIRGen(), input);
}
@Override
public Value emitMathExp(Value input) {
- Variable result = getLIRGen().newVariable(LIRKind.combine(input));
- AllocatableValue stackSlot = getLIRGen().getResult().getFrameMapBuilder().allocateSpillSlot(LIRKind.value(AMD64Kind.QWORD));
- getLIRGen().append(new AMD64MathIntrinsicUnaryOp(getAMD64LIRGen(), EXP, result, asAllocatable(input), stackSlot));
- return result;
+ return new AMD64MathExpOp().emitLIRWrapper(getLIRGen(), input);
}
@Override
- public Value emitMathPow(Value input1, Value input2) {
- Variable result = getLIRGen().newVariable(LIRKind.combine(input1));
- getLIRGen().append(new AMD64MathIntrinsicBinaryOp(getAMD64LIRGen(), POW, result, asAllocatable(input1), asAllocatable(input2)));
- return result;
+ public Value emitMathPow(Value x, Value y) {
+ return new AMD64MathPowOp().emitLIRWrapper(getLIRGen(), x, y);
}
protected AMD64LIRGenerator getAMD64LIRGen() {
return (AMD64LIRGenerator) getLIRGen();
}
< prev index next >