Skip to content

Commit

Permalink
AArch64: Add FarBranch support for BranchOp.
Browse files Browse the repository at this point in the history
  • Loading branch information
teshull committed Sep 18, 2023
1 parent 3fe6122 commit 2d6f1e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2015,6 +2015,9 @@ protected void patchJumpTarget(int patchPos, int jumpTarget) {
final int extraInformation = PatchLabelKind.decodeExtraInformation(instruction);
switch (type) {
case BRANCH_CONDITIONALLY:
if (!NumUtil.isSignedNbit(21, pcRelativeOffset)) {
throw new BranchTargetOutOfBoundsException(true, "Branch target %d out of bounds", pcRelativeOffset);
}
ConditionFlag condition = ConditionFlag.fromEncoding(extraInformation);
super.b(condition, pcRelativeOffset, patchPos);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ public BranchOp(AArch64Assembler.ConditionFlag condition, LabelRef trueDestinati
@Override
protected void emitBranch(CompilationResultBuilder crb, AArch64MacroAssembler masm, LabelRef target, boolean negate) {
AArch64Assembler.ConditionFlag finalCond = negate ? condition.negate() : condition;
masm.branchConditionally(finalCond, target.label());
Consumer<Label> originalBranch = l -> masm.branchConditionally(finalCond, l);
Consumer<Label> negatedBranch = l -> masm.branchConditionally(finalCond.negate(), l);
emitBranchOrFarBranch(crb, masm, this, 21, target.label(), originalBranch, negatedBranch);
}
}

Expand Down

0 comments on commit 2d6f1e3

Please sign in to comment.