]> gcc.gnu.org Git - gcc.git/commit
riscv: Simplify output of MEM addresses
authorChristoph Müllner <christoph.muellner@vrull.eu>
Thu, 27 Apr 2023 06:53:29 +0000 (08:53 +0200)
committerKito Cheng <kito.cheng@sifive.com>
Wed, 12 Jul 2023 08:07:12 +0000 (16:07 +0800)
commitb621883620b127caf20e88e59fa73e666960013e
tree0a449d4cfa0c50d0503303b5ea832d4f9d5e5998
parent208e10bf8a90f49aa40152ab7fcebe8cd7c5d31a
riscv: Simplify output of MEM addresses

We have the following situation for MEM RTX objects:
* TARGET_PRINT_OPERAND expands to riscv_print_operand()
* This falls into the default case (unknown or on letter) of the outer
  switch-case-block and the MEM case of the inner switch-case-block and
  calls output_address() in final.cc with XEXP (op, 0) (the address)
* This calls targetm.asm_out.print_operand_address() which is
  riscv_print_operand_address()
* riscv_print_operand_address() is targeting the address of a MEM RTX
* riscv_print_operand_address() calls riscv_print_operand() for the offset
  and directly prints the register if the address is classified as ADDRESS_REG
* This falls into the default case (unknown or on letter) of the outer
  switch-case-block and the default case of the inner switch-case-block and
  calls output_addr_const().

However, since we know that offset must be a CONST_INT (which will be
followed by a '(<reg>)' string), there is no need to call
riscv_print_operand() for the offset.
Instead we can take the shortcut and use output_addr_const().

This change also brings the code in riscv_print_operand_address()
in line with the other cases, where output_addr_const() is used
to print offsets.

Tested with GCC regression test suite and SPEC intrate.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_print_operand_address): Use
output_addr_const rather than riscv_print_operand.
gcc/config/riscv/riscv.cc
This page took 0.064026 seconds and 6 git commands to generate.