gccint: Named Address Spaces
1
1 18.29 Adding support for named address spaces
1 =============================================
1
1 The draft technical report of the ISO/IEC JTC1 S22 WG14 N1275 standards
1 committee, 'Programming Languages - C - Extensions to support embedded
1 processors', specifies a syntax for embedded processors to specify
1 alternate address spaces. You can configure a GCC port to support
1 section 5.1 of the draft report to add support for address spaces other
1 than the default address space. These address spaces are new keywords
1 that are similar to the 'volatile' and 'const' type attributes.
1
1 Pointers to named address spaces can have a different size than
1 pointers to the generic address space.
1
1 For example, the SPU port uses the '__ea' address space to refer to
1 memory in the host processor, rather than memory local to the SPU
1 processor. Access to memory in the '__ea' address space involves
1 issuing DMA operations to move data between the host processor and the
1 local processor memory address space. Pointers in the '__ea' address
1 space are either 32 bits or 64 bits based on the '-mea32' or '-mea64'
1 switches (native SPU pointers are always 32 bits).
1
1 Internally, address spaces are represented as a small integer in the
1 range 0 to 15 with address space 0 being reserved for the generic
1 address space.
1
1 To register a named address space qualifier keyword with the C front
1 end, the target may call the 'c_register_addr_space' routine. For
1 example, the SPU port uses the following to declare '__ea' as the
1 keyword for named address space #1:
1 #define ADDR_SPACE_EA 1
1 c_register_addr_space ("__ea", ADDR_SPACE_EA);
1
1 -- Target Hook: scalar_int_mode TARGET_ADDR_SPACE_POINTER_MODE
1 (addr_space_t ADDRESS_SPACE)
1 Define this to return the machine mode to use for pointers to
1 ADDRESS_SPACE if the target supports named address spaces. The
1 default version of this hook returns 'ptr_mode'.
1
1 -- Target Hook: scalar_int_mode TARGET_ADDR_SPACE_ADDRESS_MODE
1 (addr_space_t ADDRESS_SPACE)
1 Define this to return the machine mode to use for addresses in
1 ADDRESS_SPACE if the target supports named address spaces. The
1 default version of this hook returns 'Pmode'.
1
1 -- Target Hook: bool TARGET_ADDR_SPACE_VALID_POINTER_MODE
1 (scalar_int_mode MODE, addr_space_t AS)
1 Define this to return nonzero if the port can handle pointers with
1 machine mode MODE to address space AS. This target hook is the
1 same as the 'TARGET_VALID_POINTER_MODE' target hook, except that it
1 includes explicit named address space support. The default version
1 of this hook returns true for the modes returned by either the
1 'TARGET_ADDR_SPACE_POINTER_MODE' or
1 'TARGET_ADDR_SPACE_ADDRESS_MODE' target hooks for the given address
1 space.
1
1 -- Target Hook: bool TARGET_ADDR_SPACE_LEGITIMATE_ADDRESS_P
1 (machine_mode MODE, rtx EXP, bool STRICT, addr_space_t AS)
1 Define this to return true if EXP is a valid address for mode MODE
1 in the named address space AS. The STRICT parameter says whether
1 strict addressing is in effect after reload has finished. This
1 target hook is the same as the 'TARGET_LEGITIMATE_ADDRESS_P' target
1 hook, except that it includes explicit named address space support.
1
1 -- Target Hook: rtx TARGET_ADDR_SPACE_LEGITIMIZE_ADDRESS (rtx X, rtx
1 OLDX, machine_mode MODE, addr_space_t AS)
1 Define this to modify an invalid address X to be a valid address
1 with mode MODE in the named address space AS. This target hook is
1 the same as the 'TARGET_LEGITIMIZE_ADDRESS' target hook, except
1 that it includes explicit named address space support.
1
1 -- Target Hook: bool TARGET_ADDR_SPACE_SUBSET_P (addr_space_t SUBSET,
1 addr_space_t SUPERSET)
1 Define this to return whether the SUBSET named address space is
1 contained within the SUPERSET named address space. Pointers to a
1 named address space that is a subset of another named address space
1 will be converted automatically without a cast if used together in
1 arithmetic operations. Pointers to a superset address space can be
1 converted to pointers to a subset address space via explicit casts.
1
1 -- Target Hook: bool TARGET_ADDR_SPACE_ZERO_ADDRESS_VALID (addr_space_t
1 AS)
1 Define this to modify the default handling of address 0 for the
1 address space. Return true if 0 should be considered a valid
1 address.
1
1 -- Target Hook: rtx TARGET_ADDR_SPACE_CONVERT (rtx OP, tree FROM_TYPE,
1 tree TO_TYPE)
1 Define this to convert the pointer expression represented by the
1 RTL OP with type FROM_TYPE that points to a named address space to
1 a new pointer expression with type TO_TYPE that points to a
1 different named address space. When this hook it called, it is
1 guaranteed that one of the two address spaces is a subset of the
1 other, as determined by the 'TARGET_ADDR_SPACE_SUBSET_P' target
1 hook.
1
1 -- Target Hook: int TARGET_ADDR_SPACE_DEBUG (addr_space_t AS)
1 Define this to define how the address space is encoded in dwarf.
1 The result is the value to be used with 'DW_AT_address_class'.
1
1 -- Target Hook: void TARGET_ADDR_SPACE_DIAGNOSE_USAGE (addr_space_t AS,
1 location_t LOC)
1 Define this hook if the availability of an address space depends on
1 command line options and some diagnostics should be printed when
1 the address space is used. This hook is called during parsing and
1 allows to emit a better diagnostic compared to the case where the
1 address space was not registered with 'c_register_addr_space'. AS
1 is the address space as registered with 'c_register_addr_space'.
1 LOC is the location of the address space qualifier token. The
1 default implementation does nothing.
1