[PATCH] D117975: [JITLink][RISCV] fix the extractBits behavior and add R_RISCV_JAL relocation.

Siwei Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 23 07:21:39 PST 2022


fourdim updated this revision to Diff 402319.
fourdim added a comment.

address the comments and include the recent commits.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117975/new/

https://reviews.llvm.org/D117975

Files:
  llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp
  llvm/test/ExecutionEngine/JITLink/RISCV/ELF_jal.s


Index: llvm/test/ExecutionEngine/JITLink/RISCV/ELF_jal.s
===================================================================
--- llvm/test/ExecutionEngine/JITLink/RISCV/ELF_jal.s
+++ llvm/test/ExecutionEngine/JITLink/RISCV/ELF_jal.s
@@ -27,7 +27,7 @@
 
 # Test R_RISCV_JAL
 
-# jitlink-check: decode_operand(test_jal, 1)[19:0] = (external_func - test_jal)[31:12]
+# jitlink-check: decode_operand(test_jal, 1)[31:12] = (external_func - test_jal)[31:12]
   .globl  test_jal
   .p2align  1
   .type  test_jal, at function
Index: llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp
===================================================================
--- llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp
+++ llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp
@@ -227,11 +227,10 @@
       if (AlignmentIssue) {
         return AlignmentIssue;
       }
-      uint32_t Hi = Value >> 12;
-      uint32_t Imm20 = extractBits(Hi, 20, 1) << 31;
-      uint32_t Imm10_1 = extractBits(Hi, 1, 10) << 21;
-      uint32_t Imm11 = extractBits(Hi, 11, 1) << 20;
-      uint32_t Imm19_12 = extractBits(Hi, 12, 8) << 12;
+      uint32_t Imm20 = extractBits(Value, 20, 1) << 31;
+      uint32_t Imm10_1 = extractBits(Value, 1, 10) << 21;
+      uint32_t Imm11 = extractBits(Value, 11, 1) << 20;
+      uint32_t Imm19_12 = extractBits(Value, 12, 8) << 12;
       uint32_t RawInstr = *(little32_t *)FixupPtr;
       *(little32_t *)FixupPtr = RawInstr | Imm20 | Imm10_1 | Imm11 | Imm19_12;
       break;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117975.402319.patch
Type: text/x-patch
Size: 1466 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220123/458030fc/attachment.bin>


More information about the llvm-commits mailing list