gccint: Anchored Addresses
1
1 18.14 Anchored Addresses
1 ========================
1
1 GCC usually addresses every static object as a separate entity. For
1 example, if we have:
1
1 static int a, b, c;
1 int foo (void) { return a + b + c; }
1
1 the code for 'foo' will usually calculate three separate symbolic
1 addresses: those of 'a', 'b' and 'c'. On some targets, it would be
1 better to calculate just one symbolic address and access the three
1 variables relative to it. The equivalent pseudocode would be something
1 like:
1
1 int foo (void)
1 {
1 register int *xr = &x;
1 return xr[&a - &x] + xr[&b - &x] + xr[&c - &x];
1 }
1
1 (which isn't valid C). We refer to shared addresses like 'x' as
1 "section anchors". Their use is controlled by '-fsection-anchors'.
1
1 The hooks below describe the target properties that GCC needs to know
1 in order to make effective use of section anchors. It won't use section
1 anchors at all unless either 'TARGET_MIN_ANCHOR_OFFSET' or
1 'TARGET_MAX_ANCHOR_OFFSET' is set to a nonzero value.
1
1 -- Target Hook: HOST_WIDE_INT TARGET_MIN_ANCHOR_OFFSET
1 The minimum offset that should be applied to a section anchor. On
1 most targets, it should be the smallest offset that can be applied
1 to a base register while still giving a legitimate address for
1 every mode. The default value is 0.
1
1 -- Target Hook: HOST_WIDE_INT TARGET_MAX_ANCHOR_OFFSET
1 Like 'TARGET_MIN_ANCHOR_OFFSET', but the maximum (inclusive) offset
1 that should be applied to section anchors. The default value is 0.
1
1 -- Target Hook: void TARGET_ASM_OUTPUT_ANCHOR (rtx X)
1 Write the assembly code to define section anchor X, which is a
1 'SYMBOL_REF' for which 'SYMBOL_REF_ANCHOR_P (X)' is true. The hook
1 is called with the assembly output position set to the beginning of
1 'SYMBOL_REF_BLOCK (X)'.
1
1 If 'ASM_OUTPUT_DEF' is available, the hook's default definition
1 uses it to define the symbol as '. + SYMBOL_REF_BLOCK_OFFSET (X)'.
1 If 'ASM_OUTPUT_DEF' is not available, the hook's default definition
1 is 'NULL', which disables the use of section anchors altogether.
1
1 -- Target Hook: bool TARGET_USE_ANCHORS_FOR_SYMBOL_P (const_rtx X)
1 Return true if GCC should attempt to use anchors to access
1 'SYMBOL_REF' X. You can assume 'SYMBOL_REF_HAS_BLOCK_INFO_P (X)'
1 and '!SYMBOL_REF_ANCHOR_P (X)'.
1
1 The default version is correct for most targets, but you might need
1 to intercept this hook to handle things like target-specific
1 attributes or target-specific sections.
1