use of org.graalvm.compiler.lir.amd64.AMD64AddressValue in project graal by oracle.
the class AMD64NodeMatchRules method emitReinterpretMemory.
private Value emitReinterpretMemory(LIRKind to, Access access) {
AMD64AddressValue address = (AMD64AddressValue) operand(access.getAddress());
LIRFrameState state = getState(access);
return getArithmeticLIRGenerator().emitLoad(to, address, state);
}
use of org.graalvm.compiler.lir.amd64.AMD64AddressValue in project graal by oracle.
the class AMD64NodeMatchRules method emitCompareBranchMemory.
protected ComplexMatchResult emitCompareBranchMemory(IfNode ifNode, CompareNode compare, ValueNode value, LIRLowerableAccess access) {
Condition cond = compare.condition().asCondition();
AMD64Kind kind = getMemoryKind(access);
// For assertion checking
boolean matchedAsConstant = false;
if (value.isConstant()) {
JavaConstant constant = value.asJavaConstant();
if (constant != null) {
if (kind == AMD64Kind.QWORD && !constant.getJavaKind().isObject() && !NumUtil.isInt(constant.asLong())) {
// Only imm32 as long
return null;
}
// A QWORD that can be encoded as int can be embedded as a constant
matchedAsConstant = kind == AMD64Kind.QWORD && !constant.getJavaKind().isObject() && NumUtil.isInt(constant.asLong());
}
if (kind == AMD64Kind.DWORD) {
// Any DWORD value should be embeddable as a constant
matchedAsConstant = true;
}
if (kind.isXMM()) {
ifNode.getDebug().log("Skipping constant compares for float kinds");
return null;
}
}
boolean matchedAsConstantFinal = matchedAsConstant;
/*
* emitCompareBranchMemory expects the memory on the right, so mirror the condition if
* that's not true. It might be mirrored again the actual compare is emitted but that's ok.
*/
Condition finalCondition = GraphUtil.unproxify(compare.getX()) == access ? cond.mirror() : cond;
return new ComplexMatchResult() {
@Override
public Value evaluate(NodeLIRBuilder builder) {
LabelRef trueLabel = getLIRBlock(ifNode.trueSuccessor());
LabelRef falseLabel = getLIRBlock(ifNode.falseSuccessor());
boolean unorderedIsTrue = compare.unorderedIsTrue();
double trueLabelProbability = ifNode.probability(ifNode.trueSuccessor());
Value other = operand(value);
/*
* Check that patterns which were matched as a constant actually end up seeing a
* constant in the LIR.
*/
assert !matchedAsConstantFinal || !LIRValueUtil.isVariable(other) : "expected constant value " + value;
AMD64AddressValue address = (AMD64AddressValue) operand(access.getAddress());
getLIRGeneratorTool().emitCompareBranchMemory(kind, other, address, getState(access), finalCondition, unorderedIsTrue, trueLabel, falseLabel, trueLabelProbability);
return null;
}
};
}
use of org.graalvm.compiler.lir.amd64.AMD64AddressValue in project graal by oracle.
the class AMD64AddressNode 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 (scale.equals(Scale.Times1)) {
indexReference = LIRKind.derivedBaseFromValue(indexValue);
} else {
if (LIRKind.isValue(indexValue)) {
indexReference = null;
} else {
indexReference = Value.ILLEGAL;
}
}
LIRKind kind = LIRKind.combineDerived(tool.getLIRKind(stamp(NodeView.DEFAULT)), baseReference, indexReference);
gen.setResult(this, new AMD64AddressValue(kind, baseValue, indexValue, scale, displacement));
}
use of org.graalvm.compiler.lir.amd64.AMD64AddressValue in project graal by oracle.
the class AMD64HotSpotLIRGenerator method moveValueToThread.
private void moveValueToThread(Value v, int offset) {
LIRKind wordKind = LIRKind.value(target().arch.getWordKind());
RegisterValue thread = getProviders().getRegisters().getThreadRegister().asValue(wordKind);
AMD64AddressValue address = new AMD64AddressValue(wordKind, thread, offset);
arithmeticLIRGen.emitStore(v.getValueKind(), address, v, null);
}
use of org.graalvm.compiler.lir.amd64.AMD64AddressValue in project graal by oracle.
the class AMD64HotSpotLIRGenerator method emitNullCheck.
@Override
public void emitNullCheck(Value address, LIRFrameState state) {
if (address.getValueKind().getPlatformKind() == getLIRKindTool().getNarrowOopKind().getPlatformKind()) {
CompressEncoding encoding = config.getOopEncoding();
Value uncompressed;
if (encoding.getShift() <= 3) {
LIRKind wordKind = LIRKind.unknownReference(target().arch.getWordKind());
uncompressed = new AMD64AddressValue(wordKind, getProviders().getRegisters().getHeapBaseRegister().asValue(wordKind), asAllocatable(address), Scale.fromInt(1 << encoding.getShift()), 0);
} else {
uncompressed = emitUncompress(address, encoding, false);
}
append(new AMD64Move.NullCheckOp(asAddressValue(uncompressed), state));
return;
}
super.emitNullCheck(address, state);
}
Aggregations