< prev index next >
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.aarch64/src/org/graalvm/compiler/core/aarch64/AArch64ArithmeticLIRGenerator.java
Print this page
rev 52889 : 8214023: Update Graal
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, 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.
@@ -23,11 +23,10 @@
package org.graalvm.compiler.core.aarch64;
-import static jdk.vm.ci.aarch64.AArch64.sp;
import static jdk.vm.ci.aarch64.AArch64Kind.DWORD;
import static jdk.vm.ci.aarch64.AArch64Kind.QWORD;
import static org.graalvm.compiler.lir.LIRValueUtil.asJavaConstant;
import static org.graalvm.compiler.lir.LIRValueUtil.isJavaConstant;
import static org.graalvm.compiler.lir.aarch64.AArch64BitManipulationOp.BitManipulationOpCode.BSR;
@@ -53,11 +52,10 @@
import org.graalvm.compiler.lir.aarch64.AArch64SignExtendOp;
import org.graalvm.compiler.lir.aarch64.AArch64Unary;
import org.graalvm.compiler.lir.gen.ArithmeticLIRGenerator;
import jdk.vm.ci.aarch64.AArch64Kind;
-import jdk.vm.ci.code.RegisterValue;
import jdk.vm.ci.meta.AllocatableValue;
import jdk.vm.ci.meta.JavaConstant;
import jdk.vm.ci.meta.PlatformKind;
import jdk.vm.ci.meta.Value;
import jdk.vm.ci.meta.ValueKind;
@@ -132,10 +130,15 @@
public Value emitUMulHigh(Value a, Value b) {
assert isNumericInteger(a.getPlatformKind());
return emitBinary(LIRKind.combine(a, b), AArch64ArithmeticOp.UMULH, true, a, b);
}
+ public Value emitMNeg(Value a, Value b) {
+ assert isNumericInteger(a.getPlatformKind()) && isNumericInteger(b.getPlatformKind());
+ return emitBinary(LIRKind.combine(a, b), AArch64ArithmeticOp.MNEG, true, a, b);
+ }
+
@Override
public Value emitDiv(Value a, Value b, LIRFrameState state) {
return emitBinary(LIRKind.combine(a, b), getOpCode(a, AArch64ArithmeticOp.DIV, AArch64ArithmeticOp.FDIV), false, asAllocatable(a), asAllocatable(b));
}
@@ -199,17 +202,28 @@
Variable result = getLIRGen().newVariable(resultLirKind);
getLIRGen().append(new AArch64FloatConvertOp(op, result, asAllocatable(inputVal)));
return result;
}
- public Value emitAddSubShift(AArch64ArithmeticOp op, Value a, Value b, AArch64MacroAssembler.ShiftType shiftType, int shiftAmount) {
+ public Value emitMAdd(Value a, Value b, Value c) {
+ return emitMultiplyAddSub(AArch64ArithmeticOp.ADD, a, b, c);
+ }
+
+ public Value emitMSub(Value a, Value b, Value c) {
+ return emitMultiplyAddSub(AArch64ArithmeticOp.SUB, a, b, c);
+ }
+
+ private Value emitMultiplyAddSub(AArch64ArithmeticOp op, Value a, Value b, Value c) {
assert isNumericInteger(a.getPlatformKind());
assert isNumericInteger(b.getPlatformKind());
- Variable result = getLIRGen().newVariable(LIRKind.combine(a, b));
+ assert isNumericInteger(c.getPlatformKind());
+
+ Variable result = getLIRGen().newVariable(LIRKind.combine(a, b, c));
AllocatableValue x = moveSp(asAllocatable(a));
AllocatableValue y = moveSp(asAllocatable(b));
- getLIRGen().append(new AArch64ArithmeticOp.AddSubShiftOp(op, result, x, y, shiftType, shiftAmount));
+ AllocatableValue z = moveSp(asAllocatable(c));
+ getLIRGen().append(new AArch64ArithmeticOp.MultiplyAddSubOp(op, result, x, y, z));
return result;
}
private static PlatformKind getFloatConvertResultKind(FloatConvert op) {
switch (op) {
@@ -432,20 +446,12 @@
Variable result = getLIRGen().newVariable(LIRKind.combine(input));
getLIRGen().append(new AArch64ArithmeticOp.UnaryOp(op, result, input));
return result;
}
- /**
- * If val denotes the stackpointer, move it to another location. This is necessary since most
- * ops cannot handle the stackpointer as input or output.
- */
private AllocatableValue moveSp(AllocatableValue val) {
- if (val instanceof RegisterValue && ((RegisterValue) val).getRegister().equals(sp)) {
- assert val.getPlatformKind() == AArch64Kind.QWORD : "Stackpointer must be long";
- return getLIRGen().emitMove(val);
- }
- return val;
+ return getLIRGen().moveSp(val);
}
/**
* Returns the opcode depending on the platform kind of val.
*/
< prev index next >