[llvm] [RISCV] Implement Statepoint and Patchpoint lowering to call instructions (PR #77337)
Pengcheng Wang via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 9 06:07:28 PDT 2024
================
@@ -152,8 +153,40 @@ void RISCVAsmPrinter::LowerPATCHPOINT(MCStreamer &OutStreamer, StackMaps &SM,
PatchPointOpers Opers(&MI);
+ const MachineOperand &CalleeMO = Opers.getCallTarget();
unsigned EncodedBytes = 0;
+ if (CalleeMO.isImm()) {
+ uint64_t CallTarget = CalleeMO.getImm();
+ if (CallTarget) {
+ assert((CallTarget & 0xFFFF'FFFF'FFFF) == CallTarget &&
+ "High 16 bits of call target should be zero.");
+ // Materialize the jump address:
+ SmallVector<MCInst, 8> Seq;
+ RISCVMatInt::generateMCInstSeq(CallTarget, *STI, RISCV::X1, Seq);
+ for (MCInst &Inst : Seq) {
+ MCInst CInst;
+ bool compressed = RISCVRVC::compress(CInst, Inst, *STI);
+ EmitToStreamer(OutStreamer, Inst);
----------------
wangpc-pp wrote:
I have created a PR (#88120) so that we don't have to call `RISCVRVC::compress` twice.
And after that, you can write:
```
bool Compressed = EmitToStreamer(OutStreamer, Inst);
EncodedBytes += Compressed ? 2 : 4;
```
https://github.com/llvm/llvm-project/pull/77337
More information about the llvm-commits
mailing list