use of org.graalvm.compiler.lir.Variable in project graal by oracle.
the class SPARCArithmeticLIRGenerator method emitUnary.
private Variable emitUnary(Op3s op3, Value input) {
Variable result = getLIRGen().newVariable(LIRKind.combine(input));
getLIRGen().append(SPARCOP3Op.newUnary(op3, getLIRGen().loadSimm13(input), result));
return result;
}
use of org.graalvm.compiler.lir.Variable in project graal by oracle.
the class SPARCArithmeticLIRGenerator method emitStore.
@Override
public void emitStore(ValueKind<?> kind, Value address, Value inputVal, LIRFrameState state) {
SPARCAddressValue storeAddress = getLIRGen().asAddressValue(address);
if (isJavaConstant(inputVal)) {
JavaConstant c = asJavaConstant(inputVal);
if (c.isDefaultForKind()) {
getLIRGen().append(new StoreConstantOp(kind.getPlatformKind(), storeAddress, c, state));
return;
}
}
Variable input = getLIRGen().load(inputVal);
getLIRGen().append(new StoreOp(kind.getPlatformKind(), storeAddress, input, state));
}
use of org.graalvm.compiler.lir.Variable in project graal by oracle.
the class SPARCArithmeticLIRGenerator method emitSignExtend.
@Override
public Value emitSignExtend(Value inputVal, int fromBits, int toBits) {
assert fromBits <= toBits && toBits <= XWORD.getSizeInBits();
LIRKind shiftKind = LIRKind.value(WORD);
LIRKind resultKind = LIRKind.combine(inputVal).changeType(toBits > 32 ? XWORD : WORD);
int shiftCount = XWORD.getSizeInBits() - fromBits;
if (fromBits == toBits) {
return inputVal;
} else if (isJavaConstant(inputVal)) {
JavaConstant javaConstant = asJavaConstant(inputVal);
long constant;
if (javaConstant.isNull()) {
constant = 0;
} else {
constant = javaConstant.asLong();
}
return new ConstantValue(resultKind, JavaConstant.forLong((constant << shiftCount) >> shiftCount));
} else {
AllocatableValue inputAllocatable = getLIRGen().asAllocatable(inputVal);
Variable result = getLIRGen().newVariable(resultKind);
if (fromBits == WORD.getSizeInBits() && toBits == XWORD.getSizeInBits()) {
getLIRGen().append(new SPARCOP3Op(Sra, inputAllocatable, g0.asValue(LIRKind.value(WORD)), result));
} else {
Variable tmp = getLIRGen().newVariable(resultKind.changeType(XWORD));
getLIRGen().append(new SPARCOP3Op(Sllx, inputAllocatable, new ConstantValue(shiftKind, JavaConstant.forInt(shiftCount)), tmp));
getLIRGen().append(new SPARCOP3Op(Srax, tmp, new ConstantValue(shiftKind, JavaConstant.forInt(shiftCount)), result));
}
return result;
}
}
use of org.graalvm.compiler.lir.Variable in project graal by oracle.
the class SPARCArithmeticLIRGenerator method emitUnary.
private Variable emitUnary(Opfs opf, Value inputValue) {
Variable result = getLIRGen().newVariable(LIRKind.combine(inputValue));
getLIRGen().append(new SPARCOPFOp(opf, g0.asValue(), getLIRGen().asAllocatable(inputValue), result));
return result;
}
use of org.graalvm.compiler.lir.Variable in project graal by oracle.
the class SPARCArithmeticLIRGenerator method emitZeroExtend.
@Override
public Value emitZeroExtend(Value inputValue, int fromBits, int toBits) {
assert fromBits <= toBits && toBits <= 64;
if (fromBits == toBits) {
return inputValue;
}
Variable result = getLIRGen().newVariable(LIRKind.combine(inputValue).changeType(toBits > WORD.getSizeInBits() ? XWORD : WORD));
AllocatableValue inputAllocatable = getLIRGen().asAllocatable(inputValue);
if (fromBits == 32) {
getLIRGen().append(new SPARCOP3Op(Srl, inputAllocatable, g0.asValue(), result));
} else {
Value mask = getLIRGen().emitConstant(LIRKind.value(XWORD), forLong(mask(fromBits)));
getLIRGen().append(new SPARCOP3Op(And, inputAllocatable, mask, result));
}
return result;
}
Aggregations