use of org.graalvm.compiler.core.common.LIRKind in project graal by oracle.
the class JVMCIInfopointErrorTest method testInvalidShortDerivedOop.
@Test(expected = Error.class)
public void testInvalidShortDerivedOop() {
test((tool, state, safepoint) -> {
Variable baseOop = tool.newVariable(LIRKind.fromJavaKind(tool.target().arch, JavaKind.Object));
tool.append(new ValueDef(baseOop));
PlatformKind kind = tool.target().arch.getPlatformKind(JavaKind.Short);
LIRKind lirKind = LIRKind.derivedReference(kind, baseOop, false);
Variable var = tool.newVariable(lirKind);
tool.append(new ValueDef(var));
safepoint.accept(state);
tool.append(new ValueUse(var));
});
}
use of org.graalvm.compiler.core.common.LIRKind in project graal by oracle.
the class SPARCHotSpotLIRGenerator method emitCompress.
@Override
public Value emitCompress(Value pointer, CompressEncoding encoding, boolean nonNull) {
LIRKind inputKind = pointer.getValueKind(LIRKind.class);
assert inputKind.getPlatformKind() == XWORD : inputKind;
if (inputKind.isReference(0)) {
// oop
Variable result = newVariable(LIRKind.compressedReference(WORD));
append(new SPARCHotSpotMove.CompressPointer(result, asAllocatable(pointer), getProviders().getRegisters().getHeapBaseRegister().asValue(), encoding, nonNull));
return result;
} else {
// metaspace pointer
Variable result = newVariable(LIRKind.value(WORD));
AllocatableValue base = Value.ILLEGAL;
if (encoding.hasBase()) {
base = emitLoadConstant(LIRKind.value(XWORD), JavaConstant.forLong(encoding.getBase()));
}
append(new SPARCHotSpotMove.CompressPointer(result, asAllocatable(pointer), base, encoding, nonNull));
return result;
}
}
use of org.graalvm.compiler.core.common.LIRKind in project graal by oracle.
the class SPARCArithmeticLIRGenerator method emitShr.
@Override
public Variable emitShr(Value a, Value b) {
SPARCKind aKind = (SPARCKind) a.getPlatformKind();
LIRKind resultKind = LIRKind.combine(a, b).changeType(aKind);
Op3s op;
switch(aKind) {
case WORD:
op = Op3s.Sra;
break;
case XWORD:
op = Op3s.Srax;
break;
default:
throw GraalError.shouldNotReachHere();
}
return emitBinary(resultKind, op, a, b);
}
use of org.graalvm.compiler.core.common.LIRKind 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.core.common.LIRKind in project graal by oracle.
the class SPARCArithmeticLIRGenerator method emitShl.
@Override
public Variable emitShl(Value a, Value b) {
SPARCKind aKind = (SPARCKind) a.getPlatformKind();
LIRKind resultKind = LIRKind.combine(a, b).changeType(aKind);
Op3s op;
switch(aKind) {
case WORD:
op = Op3s.Sll;
break;
case XWORD:
op = Op3s.Sllx;
break;
default:
throw GraalError.shouldNotReachHere(String.format("Unsupported kind %s", aKind));
}
return emitBinary(resultKind, op, a, b);
}
Aggregations