use of org.graalvm.compiler.core.common.LIRKind in project graal by oracle.
the class AMD64ArithmeticLIRGenerator method emitMul.
@Override
public Variable emitMul(Value a, Value b, boolean setFlags) {
LIRKind resultKind = LIRKind.combine(a, b);
TargetDescription target = getLIRGen().target();
boolean isAvx = ((AMD64) target.arch).getFeatures().contains(CPUFeature.AVX);
switch((AMD64Kind) a.getPlatformKind()) {
case DWORD:
return emitIMUL(DWORD, a, b);
case QWORD:
return emitIMUL(QWORD, a, b);
case SINGLE:
if (isAvx) {
return emitBinary(resultKind, AVXOp.MUL, SS, true, a, b);
} else {
return emitBinary(resultKind, SSEOp.MUL, SS, true, a, b);
}
case DOUBLE:
if (isAvx) {
return emitBinary(resultKind, AVXOp.MUL, SD, true, a, b);
} else {
return emitBinary(resultKind, SSEOp.MUL, SD, true, a, b);
}
default:
throw GraalError.shouldNotReachHere();
}
}
use of org.graalvm.compiler.core.common.LIRKind in project graal by oracle.
the class AMD64ArithmeticLIRGenerator method emitXor.
@Override
public Variable emitXor(Value a, Value b) {
LIRKind resultKind = LIRKind.combine(a, b);
TargetDescription target = getLIRGen().target();
boolean isAvx = ((AMD64) target.arch).getFeatures().contains(CPUFeature.AVX);
switch((AMD64Kind) a.getPlatformKind()) {
case DWORD:
return emitBinary(resultKind, XOR, DWORD, true, a, b, false);
case QWORD:
return emitBinary(resultKind, XOR, QWORD, true, a, b, false);
case SINGLE:
if (isAvx) {
return emitBinary(resultKind, AVXOp.XOR, PS, true, a, b);
} else {
return emitBinary(resultKind, SSEOp.XOR, PS, true, a, b);
}
case DOUBLE:
if (isAvx) {
return emitBinary(resultKind, AVXOp.XOR, PD, true, a, b);
} else {
return emitBinary(resultKind, SSEOp.XOR, PD, true, a, b);
}
default:
throw GraalError.shouldNotReachHere();
}
}
use of org.graalvm.compiler.core.common.LIRKind in project graal by oracle.
the class AArch64AddressNode method generate.
@Override
public void generate(NodeLIRBuilderTool gen) {
LIRGeneratorTool tool = gen.getLIRGeneratorTool();
AllocatableValue baseValue = base == null ? Value.ILLEGAL : tool.asAllocatable(gen.operand(base));
AllocatableValue indexValue = index == null ? Value.ILLEGAL : tool.asAllocatable(gen.operand(index));
AllocatableValue baseReference = LIRKind.derivedBaseFromValue(baseValue);
AllocatableValue indexReference;
if (index == null) {
indexReference = null;
} else if (addressingMode.equals(AddressingMode.IMMEDIATE_UNSCALED)) {
indexReference = LIRKind.derivedBaseFromValue(indexValue);
} else {
if (LIRKind.isValue(indexValue.getValueKind())) {
indexReference = null;
} else {
indexReference = Value.ILLEGAL;
}
}
LIRKind kind = LIRKind.combineDerived(tool.getLIRKind(stamp(NodeView.DEFAULT)), baseReference, indexReference);
gen.setResult(this, new AArch64AddressValue(kind, baseValue, indexValue, (int) displacement, scaleFactor, addressingMode));
}
use of org.graalvm.compiler.core.common.LIRKind in project graal by oracle.
the class AArch64ArithmeticLIRGenerator method emitNarrow.
@Override
public Value emitNarrow(Value inputVal, int bits) {
if (inputVal.getPlatformKind() == AArch64Kind.QWORD && bits <= 32) {
LIRKind resultKind = getResultLirKind(bits, inputVal);
long mask = NumUtil.getNbitNumberLong(bits);
Value maskValue = new ConstantValue(resultKind, JavaConstant.forLong(mask));
return emitBinary(resultKind, AArch64ArithmeticOp.AND, true, inputVal, maskValue);
} else {
return inputVal;
}
}
use of org.graalvm.compiler.core.common.LIRKind in project graal by oracle.
the class AArch64ArithmeticLIRGenerator method emitSignExtend.
@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;
}
Aggregations