The ratified A extension supports '.aq', '.rl' and '.aqrl' as memory ordering suffixes. Let's emit them in case we get a '%A' conversion specifier for riscv_print_operand().
As '%A' was already used for a similar, but restricted, purpose (only '.aq' was emitted so far), this does not require any other changes. gcc/ PR 100265 * config/riscv/riscv.c (riscv_memmodel_needs_amo_acquire): Remove function. * config/riscv/riscv.c (riscv_print_amo_memory_ordering_suffix): Add function to emit AMO memory ordering suffixes. * config/riscv/riscv.c (riscv_print_operand): Call riscv_print_amo_memory_ordering_suffix() instead of riscv_memmodel_needs_amo_acquire(). --- gcc/config/riscv/riscv.cc | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index 1a130f1fe3b..983a567c69c 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -3574,24 +3574,26 @@ riscv_print_operand_reloc (FILE *file, rtx op, bool hi_reloc) fputc (')', file); } -/* Return true if the .AQ suffix should be added to an AMO to implement the - acquire portion of memory model MODEL. */ +/* Print the memory ordering suffix for AMOs. */ -static bool -riscv_memmodel_needs_amo_acquire (const enum memmodel model) +static void +riscv_print_amo_memory_ordering_suffix (FILE *file, const enum memmodel model) { switch (model) { - case MEMMODEL_ACQ_REL: - case MEMMODEL_SEQ_CST: - case MEMMODEL_ACQUIRE: + case MEMMODEL_RELAXED: + break; case MEMMODEL_CONSUME: - return true; - + case MEMMODEL_ACQUIRE: + fputs (".aq", file); + break; case MEMMODEL_RELEASE: - case MEMMODEL_RELAXED: - return false; - + fputs (".rl", file); + break; + case MEMMODEL_ACQ_REL: + case MEMMODEL_SEQ_CST: + fputs (".aqrl", file); + break; default: gcc_unreachable (); } @@ -3658,8 +3660,7 @@ riscv_print_operand (FILE *file, rtx op, int letter) break; case 'A': - if (riscv_memmodel_needs_amo_acquire (model)) - fputs (".aq", file); + riscv_print_amo_memory_ordering_suffix (file, model); break; case 'F': -- 2.35.3