[PATCH] D95029: [CSKY 6/n] Add support branch and symbol series instruction

Renato Golin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 4 09:03:19 PST 2021


rengolin added a comment.

+1 to @myhsu's points, plus a few comments, but otherwise, is looking good.



================
Comment at: llvm/lib/Target/CSKY/MCTargetDesc/CSKYAsmBackend.cpp:52
+         "Invalid kind!");
+  return Infos[Kind];
+}
----------------
What's the probability that `Kind` will be within the range? I'm assuming high, so it would be better if `return Infos[Kind]` was the first thing that checks.

So maybe:
    if (FirstTargetFixupKind <= Kind < FirstLiteralRelocationKind)
      return Infos[Kind]
    else if (Kind < FirstTargetFixupKind)
      return MCAsmBackend::getFixupKindInfo(Kind);
    else
      return MCAsmBackend::getFixupKindInfo(FK_NONE);



================
Comment at: llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCCodeEmitter.h:83
+    const MCOperand &MO = MI.getOperand(Idx);
+    assert(MO.isExpr() && "Unexpected MO type.");
+    MCFixupKind Kind = MCFixupKind(FIXUP);
----------------
Do constant pools and branches really accept any kind of fixup? If not, then maybe an assert on the kinds that work here just to make sure we don't generate bad code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95029



More information about the llvm-commits mailing list