[PATCH] D116678: [3/4][RISCV][MC] Teach MCInstrAnalysis::evaluateBranch to determine the target of an auipc+jalr
Alex Bradbury via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 9 05:20:20 PST 2022
asb updated this revision to Diff 398429.
asb added a comment.
Rebase.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D116678/new/
https://reviews.llvm.org/D116678
Files:
llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp
llvm/test/tools/llvm-objdump/ELF/RISCV/branches.s
Index: llvm/test/tools/llvm-objdump/ELF/RISCV/branches.s
===================================================================
--- llvm/test/tools/llvm-objdump/ELF/RISCV/branches.s
+++ llvm/test/tools/llvm-objdump/ELF/RISCV/branches.s
@@ -57,11 +57,11 @@
c.j bar
# CHECK: auipc ra, 0
-# CHECK: jalr ra, 16(ra){{$}}
+# CHECK: jalr ra, 16(ra) <foo+0x58>
call .Llocal
# CHECK: auipc ra, 0
-# CHECK: jalr ra, 16(ra){{$}}
+# CHECK: jalr ra, 16(ra) <bar>
call bar
.Llocal:
Index: llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp
===================================================================
--- llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp
+++ llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp
@@ -142,6 +142,14 @@
return true;
}
+ if (Inst.getOpcode() == RISCV::JALR && PreviousInst.hasValue() &&
+ PreviousInst->getOpcode() == RISCV::AUIPC &&
+ PreviousInst->getOperand(0).getReg() == Inst.getOperand(1).getReg()) {
+ Target = Addr + Inst.getOperand(2).getImm() +
+ PreviousInst->getOperand(1).getImm() - 4;
+ return true;
+ }
+
return false;
}
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116678.398429.patch
Type: text/x-patch
Size: 1154 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220109/dcfdeb0e/attachment.bin>
More information about the llvm-commits
mailing list