[all-commits] [llvm/llvm-project] 2c1176: [RISCV] Make .option arch parser less mind-bending

Jessica Clarke via All-commits all-commits at lists.llvm.org
Tue Jun 6 06:56:39 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2c11768eee3d9301eca52e8756e4088b45108446
      https://github.com/llvm/llvm-project/commit/2c11768eee3d9301eca52e8756e4088b45108446
  Author: Jessica Clarke <jrtc27 at jrtc27.com>
  Date:   2023-06-06 (Tue, 06 Jun 2023)

  Changed paths:
    M llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
    M llvm/test/MC/RISCV/option-invalid.s

  Log Message:
  -----------
  [RISCV] Make .option arch parser less mind-bending

Currently the early-return flow in the infinite loop makes it hard to
find the non-error termination points amongst the sea of errors. Rewrite
it with a more conventional control flow that has a clear loop guard (in
place of one of the early returns) and a break (in place of the other),
and with greater code reuse.

This has a small effect on the errors given for malformed input, as seen
in the affected test, and is probably more helpful as a result. Note
that we also bail early now if parseComma fails, as is standard.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D152192


  Commit: 06e253c10d6cbeb7242810b3cca0440892b0acf0
      https://github.com/llvm/llvm-project/commit/06e253c10d6cbeb7242810b3cca0440892b0acf0
  Author: Jessica Clarke <jrtc27 at jrtc27.com>
  Date:   2023-06-06 (Tue, 06 Jun 2023)

  Changed paths:
    M llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
    M llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
    M llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.h

  Log Message:
  -----------
  [RISCV] Rework .option arch target streamer interface

The current interface requires some rather ugly tracking of state due to
splitting up the calls for each argument. Instead, pack them all into a
single call by passing an ArrayRef. Also clean up the dodgy whitespace
emitted for the directive whilst here; there was a stray space between
the tab and .option, and there was a tab rather than a space after the
first comma for some strange reason.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D152193


Compare: https://github.com/llvm/llvm-project/compare/476e7c49ecb7...06e253c10d6c


More information about the All-commits mailing list