src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.aarch64/src/org/graalvm/compiler/core/aarch64/AArch64ArithmeticLIRGenerator.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File
hotspot Cdiff src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.aarch64/src/org/graalvm/compiler/core/aarch64/AArch64ArithmeticLIRGenerator.java
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.aarch64/src/org/graalvm/compiler/core/aarch64/AArch64ArithmeticLIRGenerator.java
Print this page
*** 21,37 ****
* questions.
*/
package org.graalvm.compiler.core.aarch64;
- import static org.graalvm.compiler.lir.LIRValueUtil.asJavaConstant;
- import static org.graalvm.compiler.lir.LIRValueUtil.isJavaConstant;
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 org.graalvm.compiler.asm.NumUtil;
import org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler;
import org.graalvm.compiler.core.common.LIRKind;
import org.graalvm.compiler.core.common.calc.FloatConvert;
import org.graalvm.compiler.debug.GraalError;
import org.graalvm.compiler.lir.ConstantValue;
--- 21,40 ----
* questions.
*/
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;
+ import static org.graalvm.compiler.lir.aarch64.AArch64BitManipulationOp.BitManipulationOpCode.CLZ;
+ import static org.graalvm.compiler.lir.aarch64.AArch64BitManipulationOp.BitManipulationOpCode.CTZ;
! import org.graalvm.compiler.core.common.NumUtil;
import org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler;
import org.graalvm.compiler.core.common.LIRKind;
import org.graalvm.compiler.core.common.calc.FloatConvert;
import org.graalvm.compiler.debug.GraalError;
import org.graalvm.compiler.lir.ConstantValue;
*** 39,54 ****
import org.graalvm.compiler.lir.Variable;
import org.graalvm.compiler.lir.aarch64.AArch64AddressValue;
import org.graalvm.compiler.lir.aarch64.AArch64ArithmeticLIRGeneratorTool;
import org.graalvm.compiler.lir.aarch64.AArch64ArithmeticOp;
import org.graalvm.compiler.lir.aarch64.AArch64BitManipulationOp;
- import org.graalvm.compiler.lir.aarch64.AArch64BitManipulationOp.BitManipulationOpCode;
import org.graalvm.compiler.lir.aarch64.AArch64Move.LoadOp;
import org.graalvm.compiler.lir.aarch64.AArch64Move.StoreConstantOp;
import org.graalvm.compiler.lir.aarch64.AArch64Move.StoreOp;
import org.graalvm.compiler.lir.aarch64.AArch64ReinterpretOp;
import org.graalvm.compiler.lir.aarch64.AArch64SignExtendOp;
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;
--- 42,57 ----
import org.graalvm.compiler.lir.Variable;
import org.graalvm.compiler.lir.aarch64.AArch64AddressValue;
import org.graalvm.compiler.lir.aarch64.AArch64ArithmeticLIRGeneratorTool;
import org.graalvm.compiler.lir.aarch64.AArch64ArithmeticOp;
import org.graalvm.compiler.lir.aarch64.AArch64BitManipulationOp;
import org.graalvm.compiler.lir.aarch64.AArch64Move.LoadOp;
import org.graalvm.compiler.lir.aarch64.AArch64Move.StoreConstantOp;
import org.graalvm.compiler.lir.aarch64.AArch64Move.StoreOp;
import org.graalvm.compiler.lir.aarch64.AArch64ReinterpretOp;
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;
*** 89,103 ****
assert !setFlags : "Cannot set flags on floating point arithmetic";
return emitBinary(resultKind, AArch64ArithmeticOp.FSUB, false, a, b);
}
}
@Override
public Value emitMul(Value a, Value b, boolean setFlags) {
! // TODO (das) setFlags handling - should be handled higher up. Ask for ideas at mailing list
! assert !setFlags : "Set flags on multiplication is not supported";
! return emitBinary(LIRKind.combine(a, b), getOpCode(a, AArch64ArithmeticOp.MUL, AArch64ArithmeticOp.FMUL), true, a, b);
}
@Override
public Value emitMulHigh(Value a, Value b) {
assert isNumericInteger(a.getPlatformKind());
--- 92,125 ----
assert !setFlags : "Cannot set flags on floating point arithmetic";
return emitBinary(resultKind, AArch64ArithmeticOp.FSUB, false, a, b);
}
}
+ protected Value emitExtendMemory(boolean isSigned, AArch64Kind memoryKind, int resultBits, AArch64AddressValue address, LIRFrameState state) {
+ // Issue a zero extending load of the proper bit size and set the result to
+ // the proper kind.
+ Variable result = getLIRGen().newVariable(LIRKind.value(resultBits == 32 ? AArch64Kind.DWORD : AArch64Kind.QWORD));
+
+ int targetSize = resultBits <= 32 ? 32 : 64;
+ switch (memoryKind) {
+ case BYTE:
+ case WORD:
+ case DWORD:
+ case QWORD:
+ getLIRGen().append(new AArch64Unary.MemoryOp(isSigned, targetSize,
+ memoryKind.getSizeInBytes() * 8, result, address, state));
+ break;
+ default:
+ throw GraalError.shouldNotReachHere();
+ }
+ return result;
+ }
+
@Override
public Value emitMul(Value a, Value b, boolean setFlags) {
! AArch64ArithmeticOp intOp = setFlags ? AArch64ArithmeticOp.MULVS : AArch64ArithmeticOp.MUL;
! return emitBinary(LIRKind.combine(a, b), getOpCode(a, intOp, AArch64ArithmeticOp.FMUL), true, a, b);
}
@Override
public Value emitMulHigh(Value a, Value b) {
assert isNumericInteger(a.getPlatformKind());
*** 221,231 ****
}
}
@Override
public Value emitZeroExtend(Value inputVal, int fromBits, int toBits) {
! assert fromBits <= toBits && (toBits == 32 || toBits == 64);
if (fromBits == toBits) {
return inputVal;
}
LIRKind resultKind = getResultLirKind(toBits, inputVal);
long mask = NumUtil.getNbitNumberLong(fromBits);
--- 243,253 ----
}
}
@Override
public Value emitZeroExtend(Value inputVal, int fromBits, int toBits) {
! assert fromBits <= toBits && toBits <= 64;
if (fromBits == toBits) {
return inputVal;
}
LIRKind resultKind = getResultLirKind(toBits, inputVal);
long mask = NumUtil.getNbitNumberLong(fromBits);
*** 233,257 ****
return emitBinary(resultKind, AArch64ArithmeticOp.AND, true, inputVal, maskValue);
}
@Override
public Value emitSignExtend(Value inputVal, int fromBits, int toBits) {
! assert fromBits <= toBits && (toBits == 32 || toBits == 64);
if (fromBits == toBits) {
return inputVal;
}
- LIRKind resultKind = getResultLirKind(toBits, inputVal);
Variable result = getLIRGen().newVariable(resultKind);
getLIRGen().append(new AArch64SignExtendOp(result, getLIRGen().asAllocatable(inputVal), fromBits, toBits));
return result;
}
private static LIRKind getResultLirKind(int resultBitSize, Value... inputValues) {
if (resultBitSize == 64) {
return LIRKind.combine(inputValues).changeType(QWORD);
} else {
! assert resultBitSize == 32;
return LIRKind.combine(inputValues).changeType(DWORD);
}
}
protected Variable emitBinary(ValueKind<?> resultKind, AArch64ArithmeticOp op, boolean commutative, Value a, Value b) {
--- 255,290 ----
return emitBinary(resultKind, AArch64ArithmeticOp.AND, true, inputVal, maskValue);
}
@Override
public Value emitSignExtend(Value inputVal, int fromBits, int toBits) {
! LIRKind resultKind = getResultLirKind(toBits, inputVal);
! assert fromBits <= toBits && toBits <= 64;
if (fromBits == toBits) {
return inputVal;
+ } else if (isJavaConstant(inputVal)) {
+ JavaConstant javaConstant = asJavaConstant(inputVal);
+ long constant;
+ if (javaConstant.isNull()) {
+ constant = 0;
+ } else {
+ constant = javaConstant.asLong();
+ }
+ int shiftCount = QWORD.getSizeInBytes() * 8 - fromBits;
+ return new ConstantValue(resultKind, JavaConstant.forLong((constant << shiftCount) >> shiftCount));
}
Variable result = getLIRGen().newVariable(resultKind);
getLIRGen().append(new AArch64SignExtendOp(result, getLIRGen().asAllocatable(inputVal), fromBits, toBits));
return result;
}
private static LIRKind getResultLirKind(int resultBitSize, Value... inputValues) {
if (resultBitSize == 64) {
return LIRKind.combine(inputValues).changeType(QWORD);
} else {
! // FIXME: I have no idea what this assert was ever for
! // assert resultBitSize == 32;
return LIRKind.combine(inputValues).changeType(DWORD);
}
}
protected Variable emitBinary(ValueKind<?> resultKind, AArch64ArithmeticOp op, boolean commutative, Value a, Value b) {
*** 350,390 ****
assert input.getPlatformKind() == AArch64Kind.DOUBLE;
return emitUnary(AArch64ArithmeticOp.SQRT, input);
}
@Override
! public Value emitBitScanForward(Value inputVal) {
! return emitBitManipulation(AArch64BitManipulationOp.BitManipulationOpCode.BSF, inputVal);
}
@Override
public Value emitBitCount(Value operand) {
throw GraalError.unimplemented("AArch64 ISA does not offer way to implement this more efficiently than a simple Java algorithm.");
}
@Override
! public Value emitBitScanReverse(Value inputVal) {
! // TODO (das) old implementation said to use emitCountLeadingZeros instead - need extra node
! // for that though
! return emitBitManipulation(BitManipulationOpCode.BSR, inputVal);
}
@Override
public Value emitCountLeadingZeros(Value value) {
! return emitBitManipulation(BitManipulationOpCode.CLZ, value);
}
@Override
public Value emitCountTrailingZeros(Value value) {
! throw GraalError.unimplemented();
! }
!
! private Variable emitBitManipulation(AArch64BitManipulationOp.BitManipulationOpCode op, Value inputVal) {
! assert isNumericInteger(inputVal.getPlatformKind());
! AllocatableValue input = getLIRGen().asAllocatable(inputVal);
! Variable result = getLIRGen().newVariable(LIRKind.combine(input));
! getLIRGen().append(new AArch64BitManipulationOp(op, result, input));
return result;
}
private Variable emitUnary(AArch64ArithmeticOp op, Value inputVal) {
AllocatableValue input = getLIRGen().asAllocatable(inputVal);
--- 383,419 ----
assert input.getPlatformKind() == AArch64Kind.DOUBLE;
return emitUnary(AArch64ArithmeticOp.SQRT, input);
}
@Override
! public Variable emitBitScanForward(Value value) {
! throw GraalError.unimplemented();
}
@Override
public Value emitBitCount(Value operand) {
throw GraalError.unimplemented("AArch64 ISA does not offer way to implement this more efficiently than a simple Java algorithm.");
}
@Override
! public Value emitBitScanReverse(Value value) {
! Variable result = getLIRGen().newVariable(LIRKind.combine(value).changeType(AArch64Kind.DWORD));
! getLIRGen().append(new AArch64BitManipulationOp(BSR, result, getLIRGen().asAllocatable(value)));
! return result;
}
@Override
public Value emitCountLeadingZeros(Value value) {
! Variable result = getLIRGen().newVariable(LIRKind.combine(value).changeType(AArch64Kind.DWORD));
! getLIRGen().append(new AArch64BitManipulationOp(CLZ, result, getLIRGen().asAllocatable(value)));
! return result;
}
@Override
public Value emitCountTrailingZeros(Value value) {
! Variable result = getLIRGen().newVariable(LIRKind.combine(value).changeType(AArch64Kind.DWORD));
! getLIRGen().append(new AArch64BitManipulationOp(CTZ, result, getLIRGen().asAllocatable(value)));
return result;
}
private Variable emitUnary(AArch64ArithmeticOp op, Value inputVal) {
AllocatableValue input = getLIRGen().asAllocatable(inputVal);
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.aarch64/src/org/graalvm/compiler/core/aarch64/AArch64ArithmeticLIRGenerator.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File