use of org.graalvm.compiler.asm.sparc.SPARCAssembler.ControlTransferOp in project graal by oracle.
the class SPARCAssemblerTest method doTestControlTransferOp.
/**
* Assembles the control transfer op and then verifies the expected disp value against the disp
* field provided by the disassembler.
*/
public void doTestControlTransferOp(Consumer<Label> opCreator, int minDisp, int maxDisp) {
Label lBack = new Label();
Label lForward = new Label();
masm.bind(lBack);
for (int i = 0; i < -minDisp; i++) {
masm.nop();
}
int backPos = masm.position();
opCreator.accept(lBack);
// Nop required to separate the two control transfer instructions
masm.nop();
int forwardPos = masm.position();
opCreator.accept(lForward);
for (int i = 0; i < maxDisp - 1; i++) {
masm.nop();
}
masm.bind(lForward);
int condBack = masm.getInt(backPos);
SPARCOp backOp = SPARCAssembler.getSPARCOp(condBack);
int dispBack = ((ControlTransferOp) backOp).getDisp(condBack);
Assert.assertEquals(minDisp, dispBack);
int condFwd = masm.getInt(forwardPos);
SPARCOp fwdOp = SPARCAssembler.getSPARCOp(condFwd);
int dispFwd = ((ControlTransferOp) fwdOp).getDisp(condFwd);
Assert.assertEquals(maxDisp, dispFwd);
}
Aggregations