[PATCH] D43157: [RISCV] Properly evaluate VK_RISCV_PCREL_LO

Chih-Mao Chen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 13 22:24:18 PDT 2018


PkmX added inline comments.
Herald added subscribers: rkruppe, the_o, brucehoult, MartinMosbeck, rogfer01, mgrang, edward-jones, zzheng.


================
Comment at: lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp:42
+                             const MCValue &Target) override {
+    if (Fixup.getKind() == RISCV::fixup_riscv_pcrel_lo12_i) {
+      const MCExpr *T = cast<RISCVMCExpr>(Fixup.getValue())->getPCRelHiExpr();
----------------
This should also check for `lo12_s`.


================
Comment at: lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp:42
+                             const MCValue &Target) override {
+    if (Fixup.getKind() == RISCV::fixup_riscv_pcrel_lo12_i) {
+      const MCExpr *T = cast<RISCVMCExpr>(Fixup.getValue())->getPCRelHiExpr();
----------------
PkmX wrote:
> This should also check for `lo12_s`.
Cast to `unsigned` to silence the warning about mismatching `enum` type.


================
Comment at: lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.cpp:60
+  for (const MCFixup &F : DF->getFixups()) {
+    if (F.getKind() != RISCV::fixup_riscv_pcrel_hi20)
+      continue;
----------------
Cast to `unsigned` to silence the warning about mismatching `enum` type.


================
Comment at: test/MC/RISCV/fixups.s:31
+# CHECK-INSTR: auipc t1, 0
+addi t1, t1, %pcrel_lo(1b)
+# CHECK-FIXUP: fixup A - offset: 0, value: %pcrel_lo(.Ltmp0), kind: fixup_riscv_pcrel_lo12_i
----------------
Need a test case for S-type.


================
Comment at: test/MC/RISCV/pcrel-hilo.s:14
+# CHECK-INSTR: auipc t1, 0
+addi t1, t1, %pcrel_lo(1b)
+# CHECK-FIXUP: fixup A - offset: 0, value: %pcrel_lo(.Ltmp0), kind: fixup_riscv_pcrel_lo12_i
----------------
Need a test case for S-type.


https://reviews.llvm.org/D43157





More information about the llvm-commits mailing list