Re: [PATCH 04/27] [AARCH64] Add PTR_REG, PTR_LOG_SIZE, and PTR_SIZE. Use it in LDST_PCREL and LDST_GLOBAL.

From: Andreas Schwab
Date: Tue Jun 21 2016 - 04:46:25 EST


Yury Norov <ynorov@xxxxxxxxxxxxxxxxxx> writes:

> diff --git a/sysdeps/aarch64/sysdep.h b/sysdeps/aarch64/sysdep.h
> index 4cb028f..f2ea821 100644
> --- a/sysdeps/aarch64/sysdep.h
> +++ b/sysdeps/aarch64/sysdep.h
> @@ -23,10 +23,16 @@
>
> #ifdef __LP64__
> #define AARCH64_R(NAME) R_AARCH64_ ## NAME
> +#define PTR_REG(n) x##n
> +#define PTR_LOG_SIZE 3
> #else
> #define AARCH64_R(NAME) R_AARCH64_P32_ ## NAME
> +#define PTR_REG(n) w##n
> +#define PTR_LOG_SIZE 2
> #endif
>
> +#define PTR_SIZE (1<<PTR_LOG_SIZE)
> +
> #ifdef __ASSEMBLER__
>
> /* Syntactic details of assembler. */
> @@ -87,16 +93,18 @@
> # define L(name) .L##name
> #endif
>
> -/* Load or store to/from a pc-relative EXPR into/from R, using T. */
> -#define LDST_PCREL(OP, R, T, EXPR) \
> - adrp T, EXPR; \
> - OP R, [T, #:lo12:EXPR];\
> -
> -/* Load or store to/from a got-relative EXPR into/from R, using T. */
> -#define LDST_GLOBAL(OP, R, T, EXPR) \
> - adrp T, :got:EXPR; \
> - ldr T, [T, #:got_lo12:EXPR];\
> - OP R, [T];
> +/* Load or store to/from a pc-relative EXPR into/from R, using T.
> + Note R and T are register numbers and not register names. */
> +#define LDST_PCREL(OP, R, T, EXPR) \
> + adrp x##T, EXPR; \
> + OP PTR_REG (R), [x##T, #:lo12:EXPR]; \
> +
> +/* Load or store to/from a got-relative EXPR into/from R, using T.
> + Note R and T are register numbers and not register names. */
> +#define LDST_GLOBAL(OP, R, T, EXPR) \
> + adrp x##T, :got:EXPR; \
> + ldr PTR_REG (T), [x##T, #:got_lo12:EXPR]; \
> + OP x##R, [x##T];

I think this needs to be PTR_REG(x).

Andreas.

--
Andreas Schwab, SUSE Labs, schwab@xxxxxxx
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."