use of org.graalvm.compiler.core.common.LIRKind in project graal by oracle.
the class AArch64ArithmeticLIRGenerator method emitFloatConvert.
@Override
public Value emitFloatConvert(FloatConvert op, Value inputVal) {
PlatformKind resultPlatformKind = getFloatConvertResultKind(op);
LIRKind resultLirKind = LIRKind.combine(inputVal).changeType(resultPlatformKind);
Variable result = getLIRGen().newVariable(resultLirKind);
getLIRGen().append(new AArch64FloatConvertOp(op, result, getLIRGen().asAllocatable(inputVal)));
return result;
}
use of org.graalvm.compiler.core.common.LIRKind 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.core.common.LIRKind in project graal by oracle.
the class SubstrateReferenceMapBuilder method addLiveValue.
@Override
public void addLiveValue(Value value) {
if (ValueUtil.isStackSlot(value)) {
StackSlot stackSlot = ValueUtil.asStackSlot(value);
int offset = stackSlot.getOffset(totalFrameSize);
assert referenceMap.debugMarkStackSlot(offset, stackSlot);
LIRKind kind = (LIRKind) value.getValueKind();
if (!kind.isValue()) {
if (kind.isUnknownReference()) {
throw JVMCIError.shouldNotReachHere("unknown reference alive across safepoint");
} else if (kind.isDerivedReference()) {
throw JVMCIError.shouldNotReachHere("derived references not supported yet on Substrate VM");
} else {
int bytes = bytesPerElement(kind);
int mapSlotSize = SubstrateReferenceMap.getSlotSizeInBytes();
assert bytes % mapSlotSize == 0;
assert offset % mapSlotSize == 0;
for (int i = 0; i < kind.getPlatformKind().getVectorLength(); i++) {
if (kind.isReference(i)) {
boolean compressed = kind.isCompressedReference(i);
referenceMap.markReferenceAtIndex((offset + i * bytes) / mapSlotSize, compressed);
}
}
}
}
} else if (ValueUtil.isRegister(value)) {
assert referenceMap.debugMarkRegister(ValueUtil.asRegister(value).number, value);
} else {
throw VMError.shouldNotReachHere(value.toString());
}
}
use of org.graalvm.compiler.core.common.LIRKind in project graal by oracle.
the class SaveCalleeSaveRegisters method saveAtEntry.
private static RegisterMap<Variable> saveAtEntry(LIR lir, LIRGeneratorTool lirGen, LIRGenerationResult lirGenRes, RegisterArray calleeSaveRegisters, Architecture arch) {
AbstractBlockBase<?> startBlock = lir.getControlFlowGraph().getStartBlock();
ArrayList<LIRInstruction> instructions = lir.getLIRforBlock(startBlock);
int insertionIndex = 1;
LIRInsertionBuffer buffer = new LIRInsertionBuffer();
buffer.init(instructions);
StandardOp.LabelOp entry = (StandardOp.LabelOp) instructions.get(insertionIndex - 1);
RegisterValue[] savedRegisterValues = new RegisterValue[calleeSaveRegisters.size()];
int savedRegisterValueIndex = 0;
RegisterMap<Variable> saveMap = new RegisterMap<>(arch);
for (Register register : calleeSaveRegisters) {
PlatformKind registerPlatformKind = arch.getLargestStorableKind(register.getRegisterCategory());
LIRKind lirKind = LIRKind.value(registerPlatformKind);
RegisterValue registerValue = register.asValue(lirKind);
Variable saveVariable = lirGen.newVariable(lirKind);
LIRInstruction save = lirGen.getSpillMoveFactory().createMove(saveVariable, registerValue);
buffer.append(insertionIndex, save);
save.setComment(lirGenRes, "SaveCalleeSavedRegisters: saveAtEntry");
saveMap.put(register, saveVariable);
savedRegisterValues[savedRegisterValueIndex++] = registerValue;
}
entry.addIncomingValues(savedRegisterValues);
buffer.finish();
return saveMap;
}
use of org.graalvm.compiler.core.common.LIRKind in project graal by oracle.
the class NodeLIRBuilder method getExactPhiKind.
protected LIRKind getExactPhiKind(PhiNode phi) {
LIRKind derivedKind = gen.toRegisterKind(gen.getLIRKind(phi.stamp(NodeView.DEFAULT)));
/* Collect reference information. */
for (int i = 0; i < phi.valueCount() && !derivedKind.isUnknownReference(); i++) {
ValueNode node = phi.valueAt(i);
Value value = getOperand(node);
// get ValueKind for input
final LIRKind valueKind;
if (value != null) {
valueKind = value.getValueKind(LIRKind.class);
} else {
assert isPhiInputFromBackedge(phi, i) : String.format("Input %s to phi node %s is not yet available although it is not coming from a loop back edge", node, phi);
LIRKind kind = gen.getLIRKind(node.stamp(NodeView.DEFAULT));
valueKind = gen.toRegisterKind(kind);
}
/* Merge the reference information of the derived kind and the input. */
derivedKind = LIRKind.mergeReferenceInformation(derivedKind, valueKind);
}
return derivedKind;
}
Aggregations