Skip to content

Commit

Permalink
RISC-V: make USE_LOAD_ADDRESS_MACRO easier to understand
Browse files Browse the repository at this point in the history
The current macro has several && and || making it really hard to understand
the first time.

Signed-off-by: Vineet Gupta <[email protected]>

gcc/ChangeLog:

	* config/riscv/riscv.h (LOCAL_SYM_P): New.
	(USE_LOAD_ADDRESS_MACRO): Simplify by calling LOCAL_SYM_P.
  • Loading branch information
Vineet Gupta authored and kito-cheng committed Sep 23, 2022
1 parent b2fe02b commit 7d4df63
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions gcc/config/riscv/riscv.h
Original file line number Diff line number Diff line change
Expand Up @@ -749,18 +749,19 @@ typedef struct {
#define CASE_VECTOR_MODE SImode
#define CASE_VECTOR_PC_RELATIVE (riscv_cmodel != CM_MEDLOW)

#define LOCAL_SYM_P(sym) \
((SYMBOL_REF_P (sym) && SYMBOL_REF_LOCAL_P (sym)) \
|| ((GET_CODE (sym) == CONST) \
&& SYMBOL_REF_P (XEXP (XEXP (sym, 0),0)) \
&& SYMBOL_REF_LOCAL_P (XEXP (XEXP (sym, 0),0))))

/* The load-address macro is used for PC-relative addressing of symbols
that bind locally. Don't use it for symbols that should be addressed
via the GOT. Also, avoid it for CM_MEDLOW, where LUI addressing
currently results in more opportunities for linker relaxation. */
#define USE_LOAD_ADDRESS_MACRO(sym) \
(!TARGET_EXPLICIT_RELOCS && \
((flag_pic \
&& ((SYMBOL_REF_P (sym) && SYMBOL_REF_LOCAL_P (sym)) \
|| ((GET_CODE (sym) == CONST) \
&& SYMBOL_REF_P (XEXP (XEXP (sym, 0),0)) \
&& SYMBOL_REF_LOCAL_P (XEXP (XEXP (sym, 0),0))))) \
|| riscv_cmodel == CM_MEDANY))
((flag_pic && LOCAL_SYM_P (sym)) || riscv_cmodel == CM_MEDANY))

/* Define this as 1 if `char' should by default be signed; else as 0. */
#define DEFAULT_SIGNED_CHAR 0
Expand Down

0 comments on commit 7d4df63

Please sign in to comment.