GCC Middle and Back End API Reference
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "rtl.h"
#include "tree.h"
#include "flags.h"
#include "function.h"
#include "expr.h"
#include "hard-reg-set.h"
#include "regs.h"
#include "output.h"
#include "diagnostic-core.h"
#include "hashtab.h"
#include "ggc.h"
#include "langhooks.h"
#include "tm_p.h"
#include "debug.h"
#include "target.h"
#include "common/common-target.h"
#include "targhooks.h"
#include "cgraph.h"
#include "pointer-set.h"
#include "asan.h"
#include "basic-block.h"
#include "gt-varasm.h"
Data Structures | |
struct | addr_const |
struct | rtx_constant_pool |
struct | constant_descriptor_rtx |
struct | oc_outer_state |
struct | oc_local_state |
struct | tm_alias_pair |
Macros | |
#define | n_deferred_constants (crtl->varasm.deferred_constants) |
#define | IN_NAMED_SECTION(DECL) |
#define | CONSTANT_POOL_BEFORE_FUNCTION 1 |
#define | TLS_SECTION_ASM_FLAG 'T' |
Typedefs | |
typedef struct tm_alias_pair | tm_alias_pair |
#define CONSTANT_POOL_BEFORE_FUNCTION 1 |
CONSTANT_POOL_BEFORE_FUNCTION may be defined as an expression with a nonzero value if the constant pool should be output before the start of the function, or a zero value if the pool should output after the end of the function. The default is to put it before the start.
#define IN_NAMED_SECTION | ( | DECL | ) |
Return a nonzero value if DECL has a section attribute.
#define n_deferred_constants (crtl->varasm.deferred_constants) |
Referenced by force_const_mem().
#define TLS_SECTION_ASM_FLAG 'T' |
typedef struct tm_alias_pair tm_alias_pair |
void align_variable | ( | ) |
Compute the alignment of variable specified by DECL. DONT_OUTPUT_DATA is from assemble_variable.
In the case for initialing an array whose length isn't specified, where we have not yet been able to do the layout, figure out the proper alignment now.
Some object file formats have a maximum alignment which they support. In particular, a.out format supports a maximum alignment of 4.
On some machines, it is good to increase alignment sometimes. But as DECL_ALIGN is used both for actually emitting the variable and for code accessing the variable as guaranteed alignment, we can only increase the alignment if it is a performance optimization if the references to it must bind to the current definition.
Reset the alignment in case we have made it tighter, so we can benefit from it in get_pointer_alignment.
References BITS_PER_WORD, DECL_ALIGN, decl_binds_to_current_def_p(), DECL_INITIAL, DECL_THREAD_LOCAL_P, DECL_USER_ALIGN, error_mark_node, TREE_PUBLIC, and TREE_TYPE.
|
static |
|
static |
Subroutine of output_constructor, used for computing the size of arrays of unspecified length. VAL must be a CONSTRUCTOR of an array type with an unspecified upper bound.
This code used to attempt to handle string constants that are not arrays of single-bytes, but nothing else does, so there's no point in doing it here.
Compute the total number of array elements.
Multiply by the array element unit size to find number of bytes.
void assemble_addr_to_section | ( | ) |
Write the address of the entity given by SYMBOL to SEC.
void assemble_alias | ( | ) |
Emit an assembler directive to make the symbol for DECL an alias to the symbol for TARGET.
Allow aliases to aliases.
If the target has already been emitted, we don't have to queue the alias. This saves a tad of memory.
void assemble_align | ( | ) |
Assemble an alignment pseudo op for an ALIGN-bit boundary.
References ASM_OUTPUT_LABEL, and symtab_node_base::decl.
void assemble_asm | ( | ) |
Output a string of literal assembler code for an `asm' keyword used between functions.
References DECL_RTL, ggc_strdup, targetm, XEXP, and XSTR.
|
static |
Subroutine of output_constant_def_contents. Output the definition of constant EXP, which is pointed to by label LABEL. ALIGN is the constant's alignment in bits.
Do any machine/system dependent processing of the constant.
Output the value of EXP.
void assemble_end_function | ( | ) |
Output assembler code associated with defining the size of the function. DECL describes the function. NAME is the function's name.
Output labels for end of hot/cold text sections (to be used by debug info.)
void assemble_external | ( | ) |
Output something to declare an external symbol to the assembler, and qualifiers such as weakness. (Most assemblers don't need extern declaration, so we normally output nothing.) Do nothing if DECL is not external.
Make sure that the ASM_OUT_FILE is open. If it's not, we should not be calling this function.
In a perfect world, the following condition would be true. Sadly, the Java and Go front ends emit assembly *from the front end*, bypassing the call graph. See PR52739. Fix before GCC 4.8.
We want to output annotation for weak and external symbols at very last to check if they are references or not.
TREE_STATIC is a weird and abused creature which is not generally the right test for whether an entity has been locally emitted, inlined or otherwise not-really-extern, but for declarations that can be weak, it happens to be match.
void assemble_external_libcall | ( | ) |
Similar, for calling a library function FUN.
Declare library function name external when first used, if nec.
bool assemble_integer | ( | ) |
Assemble the integer constant X into an object of SIZE bytes. ALIGN is the alignment of the integer in bits. Return 1 if we were able to output the constant, otherwise 0. We must be able to output the constant, if FORCE is nonzero.
See if the target hook can handle this kind of object.
If the object is a multi-byte one, try splitting it up. Split it into words it if is multi-word, otherwise split it into bytes.
If we've printed some of it, but not all of it, there's no going back now.
References const_hash_1(), VECTOR_CST_ELT, and VECTOR_CST_NELTS.
void assemble_integer_with_op | ( | ) |
Use directive OP to assemble an integer object X. Print OP at the start of the line, followed immediately by the value of X.
References TREE_CODE.
void assemble_label | ( | ) |
Assemble a label named NAME.
void assemble_name | ( | ) |
Like assemble_name_raw, but should be used when NAME might refer to an entity that is also represented as a tree (like a function or variable). If NAME does refer to such an entity, that entity will be marked as referenced.
void assemble_name_raw | ( | ) |
Output to FILE (an assembly file) a reference to NAME. If NAME starts with a *, the rest of NAME is output verbatim. Otherwise NAME is transformed in a target-specific way (usually by the addition of an underscore).
References BITS_PER_UNIT, GET_CODE, GET_MODE, GET_MODE_CLASS, and MIN.
|
static |
Assemble DECL given that it belongs in SECTION_NOSWITCH section SECT. NAME is the name of DECL's SYMBOL_REF.
Don't allocate zero bytes of common, since that means "undefined external" in the linker.
Round size up to multiple of BIGGEST_ALIGNMENT bits so that each uninitialized object starts on such a boundary.
void assemble_real | ( | ) |
This is hairy. We have a quantity of known size. real_to_target will put it into an array of <em>host</em> longs, 32 bits per element (even if long is more than 32 bits). We need to determine the number of array elements that are occupied (nelts) and the number of <em>target</em> min-addressable units that will be occupied in the object file (nunits). We cannot assume that 32 divides the mode's bitsize (size * BITS_PER_UNIT) evenly. size * BITS_PER_UNIT is used here to make sure that padding bits (which might appear at either end of the value; real_to_target will include the padding bits in its output array) are included.
Put out the first word with the specified alignment.
Subsequent words need only 32-bit alignment.
Referenced by const_desc_rtx_eq(), and initializer_constant_valid_p_1().
void assemble_start_function | ( | ) |
Output assembler code for the constant pool of a function and associated with defining the name of the function. DECL describes the function. NAME is the function's name. For the constant pool, we use the current constant pool data.
The following code does not need preprocessing in the assembler.
Make sure the not and cold text (code) sections are properly aligned. This is necessary here in the case where the function has both hot and cold sections, because we don't want to re-set the alignment when the section switch happens mid-function.
When the function starts with a cold section, we need to explicitly align the hot section and write out the hot section label. But if the current function is a thunk, we do not have a CFG.
Switch to the correct text section for the start of the function.
Tell assembler to move to target machine's alignment for functions.
Handle a user-specified function alignment. Note that we still need to align to DECL_ALIGN, as above, because ASM_OUTPUT_MAX_SKIP_ALIGN might not do any alignment at all.
Make function name accessible from other files, if appropriate.
Do any machine/system dependent processing of the function name.
Standard thing is just output label for the function.
rtx assemble_static_space | ( | ) |
Allocate SIZE bytes writable static space with a gensym name and return an RTX to refer to its address.
Round size up to multiple of BIGGEST_ALIGNMENT bits so that each uninitialized object starts on such a boundary.
Variable `rounded' might or might not be used in ASM_OUTPUT_LOCAL.
References assemble_integer(), BITS_PER_UNIT, CEIL, GEN_INT, GET_MODE_SIZE, MIN, min_align(), and real_to_target().
void assemble_string | ( | ) |
Assemble a string constant with the specified C string as contents.
If the string is very long, split it up.
References assemble_zeros(), DECL_INITIAL, DECL_SIZE_UNIT, error_mark_node, get_variable_align(), initializer_zerop(), output_constant(), and tree_low_cst().
rtx assemble_trampoline_template | ( | void | ) |
Assemble the static constant template for function entry trampolines.
By default, put trampoline templates in read-only data section.
Write the assembler code to define one.
Record the rtl to refer to it.
void assemble_variable | ( | tree | decl, |
int | top_level, | ||
int | at_end, | ||
int | dont_output_data | ||
) |
Assemble everything that is needed for a variable or function declaration. Not used for automatic variables, and not used for function definitions. Should not be called for variables of incomplete structure type.
TOP_LEVEL is nonzero if this variable has file scope. AT_END is nonzero if this is the special handling, at end of compilation, to define things that have had only tentative definitions. DONT_OUTPUT_DATA if nonzero means don't actually output the initial value (that will be done by the caller).
This function is supposed to handle VARIABLES. Ensure we have one.
Emulated TLS had better not get this far.
Normally no need to say anything here for external references, since assemble_external is called by the language-specific code when a declaration is first seen.
Do nothing for global register variables.
If type was incomplete when the variable was declared, see if it is complete now.
Still incomplete => don't allocate it; treat the tentative defn (which is what it must have been) as an `extern' reference.
The first declaration of a variable that comes through this function decides whether it is global (in C, has external linkage) or local (in C, has internal linkage). So do nothing more if this function has already run.
Make sure targetm.encode_section_info is invoked before we set ASM_WRITTEN.
Do no output if -fsyntax-only.
If this symbol belongs to the tree constant pool, output the constant if it hasn't already been written.
Compute the alignment of this data.
First make the assembler name(s) global if appropriate.
Output any data that we will need to use the address of.
dbxout.c needs to know this.
If the decl is part of an object_block, make sure that the decl has been positioned within its block, but do not write out its definition yet. output_object_blocks will do that later.
The following bit of code ensures that vtable_map variables are not only in the comdat section, but that each variable has its own unique comdat name. If this code is removed, the variables end up in the same section with a single comdat name. FIXME: resolve_unique_section needs to deal better with decls with both DECL_SECTION_NAME and DECL_ONE_ONLY. Once that is fixed, this if-else statement can be replaced with a single call to "switch_to_section (sect)".
|
static |
A subroutine of assemble_variable. Output the label and contents of DECL, whose address is a SYMBOL_REF with name NAME. DONT_OUTPUT_DATA is as for assemble_variable.
Do any machine/system dependent processing of the object.
Standard thing is just output label for the object.
Output the actual data.
Leave space for it.
void assemble_vtv_preinit_initializer | ( | ) |
Given a function declaration (FN_DECL), this function assembles the function into the .preinit_array section.
References SYMBOL_REF_USED, and targetm.
void assemble_zeros | ( | ) |
Assemble code to leave SIZE bytes of zeros.
Do no output if -fsyntax-only.
bool bss_initializer_p | ( | ) |
Return true if DECL's initializer is suitable for a BSS section.
Leave constant zeroes in .rodata so they can be shared.
|
staticread |
Subroutine of output_constant_def: No constant equal to EXP is known to have been output. Make a constant descriptor to enter EXP in the hash table. Assign the label number and construct RTL to refer to the constant's location in memory. Caller is responsible for updating the hash table.
Create a string containing the label name, in LABEL.
Construct the VAR_DECL associated with the constant.
We don't set the RTL yet as this would cause varpool to assume that the variable is referenced. Moreover, it would just be dropped in LTO mode. Instead we set the flag that will be recognized in make_decl_rtl.
??? CONSTANT_ALIGNMENT hasn't been updated for vector types on most architectures so use DATA_ALIGNMENT as well, except for strings.
Now construct the SYMBOL_REF and the MEM.
We cannot share RTX'es in pool entries. Mark this piece of RTL as required for unsharing.
Set flags or add text to the name to record information, such as that it is a local symbol. If the name is changed, the macro ASM_OUTPUT_LABELREF will have to know how to strip this information. This call might invalidate our local variable SYMBOL; we can't use it afterward.
Referenced by get_constant_size().
enum section_category categorize_decl_for_section | ( | ) |
or !flag_merge_constants
Here the reloc_rw_mask is not testing whether the section should be read-only or not, but whether the dynamic link will have to do something. If so, we wish to segregate the data in order to minimize cache misses inside the dynamic linker.
C and C++ don't allow different variables to share the same location. -fmerge-all-constants allows even that (at the expense of not conforming).
There are no read-only thread-local sections.
Note that this would be *just* SECCAT_BSS, except that there's no concept of a read-only thread-local-data section.
If the target uses small data sections, select it.
|
static |
Make sure block symbol SYMBOL is in block BLOCK.
Referenced by decode_addr_const().
|
static |
Compare t1 and t2, and return 1 only if they are known to result in the same bit pattern on output.
Integer constants are the same only if the same width of type.
Real constants are the same only if the same width of type.
Fixed constants are the same only if the same width of type.
For arrays, check that the sizes all match.
For record and union constructors, require exact type equality.
Check that each value is the same...
... and that they apply to the same fields!
References compute_reloc_for_constant(), and targetm.
int compute_reloc_for_constant | ( | ) |
Determine what kind of relocations EXP may need.
Go inside any operations that get_inner_reference can handle and see if what's inside is a constant: no need to do anything here for addresses of variables or functions.
The difference of two local labels is computable at link time.
References initializer_constant_valid_p_1(), NULL_TREE, and TYPE_MODE.
|
static |
References targetm.
|
static |
Like compute_reloc_for_constant, except for an RTX. The return value is a mask for which bit 1 indicates a global relocation, and bit 0 indicates a local relocation.
|
static |
|
static |
Wrapper of compare_constant, for the htab interface.
|
static |
|
static |
Compute a hash code for a constant expression.
|
static |
|
static |
Hash and compare functions for const_rtx_htab.
References crtl.
|
static |
Referenced by assemble_integer(), default_assemble_integer(), and get_constant_size().
|
static |
Either set P and LEN to the address and len of something to hash and exit the switch or return a value.
Don't hash the address of the SYMBOL_REF; only use the offset and the symbol name.
A language specific constant. Just hash the code.
Compute hashing function.
|
static |
Compute a hash value for X, which should be a constant.
References targetm.
|
static |
This is the worker function for const_rtx_hash, called via for_each_rtx.
htab_t constant_pool_htab | ( | void | ) |
Constant pool accessor function.
bool constructor_static_from_elts_p | ( | ) |
Whether a constructor CTOR is a valid static constant initializer if all its elements are. This used to be internal to initializer_constant_valid_p and has been exposed to let other functions like categorize_ctor_elements evaluate the property while walking a constructor for other purposes.
|
static |
|
static |
Return 1 if type TYPE contains any pointers.
I'm not sure whether OFFSET_TYPE needs this treatment, so I'll play safe and return 1.
For a type that has fields, see if the fields have pointers.
An array type contains pointers if its element type does.
References ASM_OUTPUT_LABEL.
|
static |
Make a copy of the whole tree structure for a constant. This handles the same types of nodes that compare_constant handles.
For ADDR_EXPR, we do not want to copy the decl whose address is requested. We do want to copy constants though.
References targetm.
|
static |
Create a symbol with label LABEL and place it at byte offset OFFSET in BLOCK. OFFSET can be negative if the symbol's offset is not yet known. LABEL must be a garbage-collected string.
Create the extended SYMBOL_REF.
Initialize the normal SYMBOL_REF fields.
Initialize the block_symbol stuff.
References DECL_P, DECL_SECTION_NAME, gcc_assert, and TREE_STRING_POINTER.
|
staticread |
Create and return a new rtx constant pool.
section* current_function_section | ( | void | ) |
Return the section for the current function, take IN_COLD_SECTION_P into account.
void decide_function_section | ( | ) |
If not using flag_reorder_blocks_and_partition, decide early whether the current function goes into the cold section, so that targets can use current_function_section during RTL expansion. DECL describes the function.
We will decide in assemble_start_function.
Calls to function_section rely on first_function_block_is_cold being accurate.
References globalize_decl(), maybe_assemble_visibility(), and notice_global_symbol().
bool decl_binds_to_current_def_p | ( | ) |
Return true when references to DECL must bind to current definition in final executable.
The condition is usually equivalent to whether the function binds to the current module (shared library or executable), that is to binds_local_p. We use this fact to avoid need for another target hook and implement the logic using binds_local_p and just special cases where decl_binds_to_current_def_p is stronger than binds_local_p. In particular the weak definitions (that can be overwritten at linktime by other definition from different object file) and when resolution info is available we simply use the knowledge passed to us by linker plugin.
When resolution is available, just use it.
Otherwise we have to assume the worst for DECL_WEAK (hidden weaks binds locally but still can be overwritten), DECL_COMMON (can be merged with a non-common definition somewhere in the same module) or DECL_EXTERNAL. This rely on fact that binds_local_p behave as decl_replaceable_p for all other declaration types.
enum tls_model decl_default_tls_model | ( | ) |
Local dynamic is inefficient when we're not combining the parts of the address.
bool decl_readonly_section | ( | ) |
|
static |
Referenced by make_decl_one_only().
|
static |
bool decl_replaceable_p | ( | ) |
A replaceable function or variable is one which may be replaced at link-time with an entirely different definition, provided that the replacement has the same type. For example, functions declared with attribute((weak)) on most systems are replaceable.
COMDAT functions are not replaceable, since all definitions of the function must be equivalent. It is important that COMDAT functions not be treated as replaceable so that use of C++ template instantiations is not penalized.
void declare_weak | ( | ) |
Declare DECL to be a weak symbol.
References cgraph_get_node(), symtab_node_base::definition, tm_alias_pair::from, and tm_alias_pair::to.
|
static |
|
static |
References compare_constant(), FIXED_VALUES_IDENTICAL, int_size_in_bytes(), REAL_VALUES_IDENTICAL, TREE_CODE, TREE_FIXED_CST, TREE_IMAGPART, tree_int_cst_equal(), TREE_REAL_CST, TREE_REALPART, TREE_STRING_LENGTH, TREE_STRING_POINTER, TREE_TYPE, TYPE_MODE, TYPE_PRECISION, VECTOR_CST_ELT, and VECTOR_CST_NELTS.
int decode_reg_name | ( | ) |
References DECL_INITIAL.
int decode_reg_name_and_count | ( | ) |
Decode an `asm' spec for a declaration as a register name. Return the register number, or -1 if nothing specified, or -2 if the ASMSPEC is not `cc' or `memory' and is not recognized, or -3 if ASMSPEC is `cc' and is not recognized, or -4 if ASMSPEC is `memory' and is not recognized. Accept an exact spelling or a decimal number. Prefixes such as % are optional.
Presume just one register is clobbered.
Get rid of confusing prefixes.
Allow a decimal number as a "register name".
void default_asm_declare_constant_name | ( | FILE * | file, |
const char * | name, | ||
const_tree | exp, | ||
HOST_WIDE_INT | size | ||
) |
The default implementation of ASM_DECLARE_CONSTANT_NAME.
void default_asm_output_ident_directive | ( | ) |
Default TARGET_ASM_OUTPUT_IDENT hook.
This is a bit of a cheat. The real default is a no-op, but this hook is the default for all targets with a .ident directive.
If we are still in the front end, do not write out the string to asm_out_file. Instead, add a fake top-level asm statement. This allows the front ends to use this hook without actually writing to asm_out_file, to handle #ident or Pragma Ident.
void default_asm_output_source_filename | ( | ) |
The default hook for TARGET_ASM_OUTPUT_SOURCE_FILENAME.
The default implementation of the asm_out.integer target hook.
Avoid GAS bugs for large values. Specifically negative values whose absolute value fits in a bfd_vma, but not in a bfd_signed_vma.
References const_hash_1(), fixed_hash(), real_hash(), TREE_FIXED_CST_PTR, TREE_IMAGPART, TREE_INT_CST, TREE_REAL_CST_PTR, TREE_REALPART, TREE_STRING_LENGTH, and TREE_STRING_POINTER.
void default_assemble_visibility | ( | tree | decl, |
int | vis | ||
) |
Emit an assembler directive to set symbol for DECL visibility to the visibility type VIS, which must not be VISIBILITY_DEFAULT.
bool default_binds_local_p | ( | ) |
Assume ELF-ish defaults, since that's pretty much the most liberal wrt cross-module name binding.
References assemble_zeros(), CONSTANT_POOL_ADDRESS_P, and SYMBOL_REF_BLOCK_OFFSET.
bool default_binds_local_p_1 | ( | ) |
With resolution file in hands, take look into resolutions. We can't just return true for resolved_locally symbols, because dynamic linking might overwrite symbols in shared libraries.
A non-decl is an entry in the constant pool.
Weakrefs may not bind locally, even though the weakref itself is always static and therefore local. Similarly, the resolver for ifunc functions might resolve to a non-local function. FIXME: We can resolve the weakref case more curefuly by looking at the weakref alias.
Static variables are always local.
A variable is local if the user has said explicitly that it will be.
Variables defined outside this object might not be local.
If defined in this object and visibility is not default, must be local.
Default visibility weak data can be overridden by a strong symbol in another module and so are not local.
If PIC, then assume that any global name can be overridden by symbols resolved from other modules.
Uninitialized COMMON variable may be unified with symbols resolved from other modules.
Otherwise we're left with initialized (or non-common) global data which is of necessity defined locally.
section* default_clone_table_section | ( | void | ) |
Provide a default for the tm_clone_table section.
void default_coff_asm_named_section | ( | const char * | name, |
unsigned int | flags, | ||
tree | decl | ||
) |
void default_elf_asm_named_section | ( | const char * | name, |
unsigned int | flags, | ||
tree | decl | ||
) |
If we have already declared this section, we can use an abbreviated form to switch back to it – unless this section is part of a COMDAT groups, in which case GAS requires the full declaration every time.
On platforms that use "@" as the assembly comment character, use "%" instead.
void default_elf_asm_output_external | ( | FILE * | file, |
tree | decl, | ||
const char * | name | ||
) |
Emit text to declare externally defined symbols. It is needed to properly support non-default visibility.
We output the name if and only if TREE_SYMBOL_REFERENCED is set in order to avoid putting out names that are never really used.
void default_elf_fini_array_asm_out_destructor | ( | ) |
Use .fini_array section for destructors.
void default_elf_init_array_asm_out_constructor | ( | ) |
Use .init_array section for constructors.
section* default_elf_select_rtx_section | ( | enum machine_mode | mode, |
rtx | x, | ||
unsigned HOST_WIDE_INT | align | ||
) |
??? Handle small data here somehow.
References constant_descriptor_rtx::align, GET_MODE_SIZE, constant_descriptor_rtx::mode, and SYMBOL_REF_CONSTANT.
section* default_elf_select_section | ( | tree | decl, |
int | reloc, | ||
unsigned HOST_WIDE_INT | align | ||
) |
Select a section based on the above categorization.
We're not supposed to be called on FUNCTION_DECLs.
References decl_binds_to_current_def_p(), DECL_COMDAT, DECL_P, gcc_assert, and TREE_PUBLIC.
void default_emit_except_table_label | ( | ) |
Default function to output a label to divide up the exception table. The default is to do nothing. A target that needs/wants to divide up the table must provide it's own function to do this.
void default_emit_unwind_label | ( | FILE * | stream, |
tree | decl, | ||
int | for_eh, | ||
int | empty | ||
) |
Default function to output a label for unwind information. The default is to do nothing. A target that needs nonlocal labels for unwind information must provide its own function to do this.
void default_encode_section_info | ( | ) |
Set the generally applicable flags on the SYMBOL_REF for EXP.
Careful not to prod global register variables.
??? Why is DECL_EXTERNAL ever set for non-PUBLIC names? Without being PUBLIC, the thing *must* be defined in this translation unit. Prevent this buglet from being propagated into rtl code as well.
void default_file_start | ( | void | ) |
This is the default behavior at the beginning of a file. It's controlled by two other target-hook toggles.
section* default_function_rodata_section | ( | ) |
Return the read-only data section associated with function DECL.
For .gnu.linkonce.t.foo we want to use .gnu.linkonce.r.foo.
For .text.foo we want to use .rodata.foo.
section* default_function_section | ( | tree | decl, |
enum node_frequency | freq, | ||
bool | startup, | ||
bool | exit | ||
) |
Choose named function section based on its frequency.
Startup code should go to startup subsection unless it is unlikely executed (this happens especially with function splitting where we can split away unnecessary parts of static constructors.
Similarly for exit.
Group cold functions together, similarly for hot code.
References cgraph_get_node(), DECL_ALIGN, DECL_SECTION_NAME, get_named_section(), hot_function_section(), NODE_FREQUENCY_NORMAL, NODE_FREQUENCY_UNLIKELY_EXECUTED, NULL, NULL_TREE, cgraph_node::only_called_at_exit, cgraph_node::only_called_at_startup, and targetm.
void default_generate_internal_label | ( | char * | buf, |
const char * | prefix, | ||
unsigned long | labelno | ||
) |
This is how to output an internal numbered label where PREFIX is the class of label and LABELNO is the number within the class.
void default_globalize_decl_name | ( | ) |
Default function to output code that will globalize a label. A target must define GLOBAL_ASM_OP or provide its own function to globalize a label. Default function to output code that will globalize a declaration.
void default_internal_label | ( | FILE * | stream, |
const char * | prefix, | ||
unsigned long | labelno | ||
) |
void default_named_section_asm_out_constructor | ( | ) |
void default_named_section_asm_out_destructor | ( | ) |
References crtl, and ggc_strdup.
section* default_no_function_rodata_section | ( | ) |
Return the read-only data section associated with function DECL for targets where that section should be always the single readonly data section.
void default_no_named_section | ( | const char * | name, |
unsigned int | flags, | ||
tree | decl | ||
) |
Output assembly to switch to section NAME with attribute FLAGS. Four variants for common object file formats.
Some object formats don't support named sections at all. The front-end should already have flagged this as an error.
References targetm.
void default_pe_asm_named_section | ( | const char * | name, |
unsigned int | flags, | ||
tree | decl | ||
) |
Functions may have been compiled at various levels of optimization so we can't use `same_size' here. Instead, have the linker pick one.
unsigned int default_section_type_flags | ( | ) |
Select a set of attributes for section NAME based on the properties of DECL and whether or not RELOC indicates that DECL's initializer might contain runtime relocations.
We make the section read-only and executable for a function decl, read-only for a const data decl, and writable for a non-const data decl.
These three sections have special ELF types. They are neither SHT_PROGBITS nor SHT_NOBITS, so when changing sections we don't want to print a section type ( or ). If someone is silly enough to emit code or TLS variables to one of these sections, then don't handle them specially.
References GET_CODE, and SYMBOL_REF_LOCAL_P.
section* default_select_rtx_section | ( | enum machine_mode | mode, |
rtx | x, | ||
unsigned HOST_WIDE_INT | align | ||
) |
References gcc_assert, offset, and SYMBOL_REF_BLOCK.
section* default_select_section | ( | tree | decl, |
int | reloc, | ||
unsigned HOST_WIDE_INT | align | ||
) |
The lame default section selector.
References resolution_local_p(), resolution_to_local_definition_p(), and varpool_get_node().
const char* default_strip_name_encoding | ( | ) |
By default, we do nothing for encode_section_info, so we need not do anything but discard the '*' marker.
References GET_MODE_BITSIZE, HOST_WIDE_INT, ptr_mode, and targetm.
void default_unique_section | ( | ) |
Construct a unique section name based on the decl name and the categorization performed above.
We only need to use .gnu.linkonce if we don't have COMDAT groups.
If we're using one_only, then there needs to be a .gnu.linkonce prefix to the section name.
References alloca, and ASM_OUTPUT_INTERNAL_LABEL.
bool default_use_anchors_for_symbol_p | ( | ) |
The default implementation of TARGET_USE_ANCHORS_FOR_SYMBOL_P.
Don't use anchors for mergeable sections. The linker might move the objects around.
Don't use anchors for small data sections. The small data register acts as an anchor for such sections.
Don't use section anchors for decls that might be defined or usurped by other modules.
Don't use section anchors for decls that will be placed in a small data section.
??? Ideally, this check would be redundant with the SECTION_SMALL one above. The problem is that we only use SECTION_SMALL for sections that should be marked as small in the section directive.
void do_assemble_alias | ( | ) |
Output the assembler code for a define (equate) using ASM_OUTPUT_DEF or ASM_OUTPUT_DEF_FROM_DECLS. The function defines the symbol whose tree node is DECL to have the value of the tree node TARGET.
Emulated TLS had better not get this var.
We must force creation of DECL_RTL for debug info generation, even though we don't use it here.
References targetm.
|
static |
Dump the actual pairs to the .tm_clone_table section.
The function ipa_tm_create_version() marks the clone as needed if the original function was needed. But we also mark the clone as needed if we ever called the clone indirectly through TM_GETTMCLONE. If neither of these are true, we didn't generate a clone, and we didn't call it indirectly... no sense keeping it in the clone table.
This covers the case where we have optimized the original function away, and only access the transactional clone.
|
static |
Helper function for finish_tm_clone_pairs. Dump a hash table entry into a VEC in INFO.
int elf_record_gcc_switches | ( | ) |
This function provides a possible implementation of the TARGET_ASM_RECORD_GCC_SWITCHES target hook for ELF targets. When triggered by -frecord-gcc-switches it creates a new mergeable, string section in the assembler output file called TARGET_ASM_RECORD_GCC_SWITCHES_SECTION which contains the switches in ASCII format.
FIXME: This code does not correctly handle double quote characters that appear inside strings, (it strips them rather than preserving them). FIXME: ASM_OUTPUT_ASCII, as defined in config/elfos.h will not emit NUL characters - instead it treats them as sub-string separators. Since we want to emit NUL strings terminators into the object file we have to use ASM_OUTPUT_SKIP.
Distinguish between invocations where name is NULL.
The return value is currently ignored by the caller, but must be 0. For -fverbose-asm the return value would be the number of characters emitted into the assembler file.
|
static |
A noswitch_section_callback for bss_noswitch_section. A noswitch_section_callback for comm_section.
References error(), and TREE_ASM_WRITTEN.
|
static |
A noswitch_section_callback for lcomm_section.
References DECL_EXTERNAL, DECL_RTL, DECL_RTL_SET_P, DECL_SIZE, DECL_THREAD_LOCAL_P, gcc_assert, gcc_checking_assert, layout_decl(), REG_P, targetm, TREE_ASM_WRITTEN, and TREE_CODE.
|
static |
A noswitch_section_callback for tls_comm_section.
References error().
void file_end_indicate_exec_stack | ( | void | ) |
void file_end_indicate_split_stack | ( | void | ) |
Emit a special section directive to indicate that this object file was compiled with -fsplit-stack. This is used to let the linker detect calls between split-stack code and non-split-stack code, so that it can modify the split-stack code to allocate a sufficiently large stack. We emit another special section if there are any functions in this file which have the no_split_stack attribute, to prevent the linker from warning about being unable to convert the functions if they call non-split-stack code.
|
static |
Fiven an assembly name, find the decl it is associated with.
void finish_tm_clone_pairs | ( | void | ) |
We need a determenistic order for the .tm_clone_table, otherwise we will get bootstrap comparison failures, so dump the hash table to a vector, sort it, and dump the vector.
Dump the hashtable to a vector.
Sort it.
Dump it.
Referenced by emit_debug_global_declarations().
rtx force_const_mem | ( | ) |
Given a constant rtx X, make (or find) a memory constant for its value and return a MEM rtx to refer to it in memory.
If we're not allowed to drop X into the constant pool, don't.
Record that this function has used a constant pool entry.
Decide which pool to use.
Lookup the value in the hashtable.
If the constant was already present, return its memory.
Otherwise, create a new descriptor.
Align the location counter as required by EXP's data type.
Create a string containing the label name, in LABEL.
Construct the SYMBOL_REF. Make sure to mark it as belonging to the constants pool.
Construct the MEM.
If we're dropping a label to the constant pool, make sure we don't delete it.
References n_deferred_constants, and output_constant_def_contents().
section* function_section | ( | ) |
Return the section for function DECL.
If DECL is NULL_TREE, return the text section. We can be passed NULL_TREE under some circumstances by dbxout.c at least.
Handle cases where function splitting code decides to put function entry point into unlikely executed section despite the fact that the function itself is not cold (i.e. it is called rarely but contains a hot loop that is better to live in hot subsection for the code locality).
|
static |
Return the section for function DECL.
If DECL is NULL_TREE, return the text section. We can be passed NULL_TREE under some circumstances by dbxout.c at least.
If FORCE_COLD is true, return cold function section ignoring the frequency info of cgraph_node.
|
staticread |
Return the block into which object_block DECL should be placed.
The object must be defined in this translation unit.
There's no point using object blocks for something that is isolated by definition.
We can only calculate block offsets if the decl has a known constant size.
Find out which section should contain DECL. We cannot put it into an object block if it requires a standalone definition.
References targetm.
|
staticread |
Return the object_block structure for section SECT. Create a new structure if we haven't created one already. Return null if SECT itself is null.
section* get_cdtor_priority_section | ( | ) |
Return the numbered .ctors.N (if CONSTRUCTOR_P) or .dtors.N (if not) section for PRIORITY.
??? This only works reliably with the GNU linker.
Invert the numbering so the linker puts us in the proper order; constructors are run from right to left, and the linker sorts in increasing order.
References cgraph_get_node(), and NODE_FREQUENCY_UNLIKELY_EXECUTED.
|
static |
Return the section into which constant EXP should be placed.
|
static |
Return the size of constant EXP in bytes.
References build_constant_desc(), const_desc_htab, const_hash_1(), exp(), constant_descriptor_tree::hash, and constant_descriptor_tree::value.
section* get_named_section | ( | ) |
Return a section with a particular name and with whatever SECTION_* flags section_type_flags deems appropriate. The name of the section is taken from NAME if nonnull, otherwise it is taken from DECL's DECL_SECTION_NAME. DECL is the decl associated with the section (see the section comment for details) and RELOC is as for section_type_flags.
References ASM_OUTPUT_LABEL, BITS_PER_UNIT, floor_log2(), and switch_to_section().
section* get_named_text_section | ( | tree | decl, |
const char * | text_section_name, | ||
const char * | named_section_suffix | ||
) |
Return section for TEXT_SECTION_NAME if DECL or DECL_SECTION_NAME (DECL) is NULL.
When DECL_SECTION_NAME is non-NULL and it is implicit section and NAMED_SECTION_SUFFIX is non-NULL, then produce section called concatenate the name with NAMED_SECTION_SUFFIX. Otherwise produce "TEXT_SECTION_NAME.IMPLICIT_NAME".
Do not try to split gnu_linkonce functions. This gets somewhat slipperly.
References DECL_HAS_IMPLICIT_SECTION_NAME_P, DECL_SECTION_NAME, get_named_text_section(), NODE_FREQUENCY_HOT, NODE_FREQUENCY_UNLIKELY_EXECUTED, and NULL.
Referenced by get_named_text_section().
|
static |
Return a SECTION_NOSWITCH section with the given fields.
rtx get_pool_constant | ( | ) |
Given a constant pool SYMBOL_REF, return the corresponding constant.
References TREE_CODE.
rtx get_pool_constant_mark | ( | ) |
Given a constant pool SYMBOL_REF, return the corresponding constant and whether it has been output or not.
enum machine_mode get_pool_mode | ( | ) |
Similar, return the mode.
int get_pool_size | ( | void | ) |
Return the size of the constant pool.
section* get_section | ( | ) |
Return the named section structure associated with NAME. Create a new section with the given fields if no such structure exists.
It is fine if one of the section flags is SECTION_WRITE | SECTION_RELRO and the other has none of these flags (i.e. read-only) in named sections and either the section hasn't been declared yet or has been declared as writable. In that case just make sure the resulting flags are SECTION_WRITE | SECTION_RELRO, ie. writable only because of relocations.
Sanity check user variables for flag changes.
Make sure we don't error about one section multiple times.
References section::common, section_common::flags, object_block::sect, SECTION_RELRO, and SECTION_WRITE.
rtx get_section_anchor | ( | struct object_block * | block, |
HOST_WIDE_INT | offset, | ||
enum tls_model | model | ||
) |
Return the anchor that should be used to address byte offset OFFSET from the first object in BLOCK. MODEL is the TLS model used to access it.
Work out the anchor's offset. Use an offset of 0 for the first anchor so that we don't pessimize the case where we take the address of a variable at the beginning of the block. This is particularly useful when a block has only one variable assigned to it. We try to place anchors RANGE bytes apart, so there can then be anchors at +/-RANGE, +/-2 * RANGE, and so on, up to the limits of a ptr_mode offset. With some target settings, the lowest such anchor might be out of range for the lowest ptr_mode offset; likewise the highest anchor for the highest offset. Use anchors at the extreme ends of the ptr_mode range in such cases. All arithmetic uses unsigned integers in order to avoid signed overflow.
Do a binary search to see if there's already an anchor we can use. Set BEGIN to the new anchor's index if not.
Create a new anchor with a unique label.
Insert it at index BEGIN.
tree get_tm_clone_pair | ( | ) |
section* get_unnamed_section | ( | unsigned int | flags, |
void(*)(const void *) | callback, | ||
const void * | data | ||
) |
Return a new unnamed section with the given fields.
|
static |
Return DECL_ALIGN (decl), possibly increased for optimization purposes beyond what align_variable returned.
For user aligned vars or static vars align_variable already did everything.
For decls that bind to the current definition, align_variable did also everything, except for not assuming ABI required alignment of TLS variables. For other vars, increase the alignment here as an optimization.
On some machines, it is good to increase alignment sometimes.
References targetm.
Referenced by assemble_string().
section* get_variable_section | ( | ) |
Return the section into which the given VAR_DECL or CONST_DECL should be placed. PREFER_NOSWITCH_P is true if a noswitch section should be used wherever possible.
If the decl has been given an explicit section name, or it resides in a non-generic address space, then it isn't common, and shouldn't be handled as such.
References gcc_assert, SYMBOL_REF_BLOCK, and SYMBOL_REF_BLOCK_OFFSET.
|
static |
Referenced by decide_function_section().
|
static |
Emit the assembly bits to indicate that DECL is globally visible.
References DECL_COMDAT_GROUP.
|
static |
Return a hash value for section SECT.
References unnamed_section::common, section_common::flags, object_block::sect, SECTION_UNNAMED, and section::unnamed.
bool have_global_bss_p | ( | void | ) |
Return true if the target supports some form of global BSS, either through bss_noswitch_section, or by selecting a BSS section in TARGET_ASM_SELECT_SECTION.
References MEM_P.
|
static |
Return the hot section for function DECL. Return text_section for null DECLs.
References DECL_ASSEMBLER_NAME, DECL_ONE_ONLY, get_named_section(), IDENTIFIER_POINTER, NULL, and targetm.
Referenced by default_function_section().
void init_varasm_once | ( | void | ) |
In varasm.c
void init_varasm_status | ( | void | ) |
Initialize constant pool hashing for a new function.
References CONSTANT_POOL_ADDRESS_P, GET_CODE, and NULL_RTX.
Referenced by blocks_nreverse().
bool initializer_constant_valid_for_bitfield_p | ( | ) |
Return true if VALUE is a valid constant-valued expression for use in initializing a static bit-field; one that can be an element of a "constant" initializer.
For bitfields we support integer constants or possibly nested aggregates of such.
tree initializer_constant_valid_p | ( | ) |
Return nonzero if VALUE is a valid constant-valued expression for use in initializing a static variable; one that can be an element of a "constant" initializer.
Return null_pointer_node if the value is absolute; if it is relocatable, return the variable that determines the relocation. We assume that VALUE has been folded as much as possible; therefore, we do not need to check for such things as arithmetic-combinations of integers.
Referenced by compute_reloc_for_constant(), mark_constant_pool(), and output_addressed_constants().
|
static |
Helper function of initializer_constant_valid_p. Return nonzero if VALUE is a valid constant-valued expression for use in initializing a static variable; one that can be an element of a "constant" initializer.
Return null_pointer_node if the value is absolute; if it is relocatable, return the variable that determines the relocation. We assume that VALUE has been folded as much as possible; therefore, we do not need to check for such things as arithmetic-combinations of integers.
Use CACHE (pointer to 2 tree values) for caching if non-NULL.
For a non-absolute relocation, there is no single variable that can be "the variable that determines the relocation."
"&(*a).f" is like unto pointer arithmetic. If "a" turns out to be a constant, this is old-skool offsetof-like nonsense.
Taking the address of a nested function involves a trampoline, unless we don't need or want one.
"&{...}" requires a temporary to hold the constructed object.
Allow view-conversions from aggregate to non-aggregate type only if the bit pattern is fully preserved afterwards; otherwise, the RTL expander won't be able to apply a subsequent transformation to the underlying constructor.
Allow all other kinds of view-conversion.
Allow conversions between pointer types, floating-point types, and offset types.
Allow length-preserving conversions between integer types.
Allow conversions between other integer types only if explicit value.
Allow (int) &foo provided int is as wide as a pointer.
Likewise conversions from int to pointers, but also allow conversions from 0.
Allow conversions to struct or union types if the value inside is okay.
Any valid floating-point constants will have been folded by now; with -frounding-math we hit this with addition of two constants.
If either term is absolute, use the other term's relocation.
Support narrowing pointer differences.
Support narrowing pointer differences.
Win if second argument is absolute.
Win if both arguments have the same relocation. Then the value is absolute.
Since GCC guarantees that string constants are unique in the generated code, a subtraction between two copies of the same constant string is absolute.
Support narrowing differences.
Support narrowing differences.
References assemble_integer(), assemble_real(), assemble_string(), assemble_zeros(), build1, build_int_cst_wide(), CONSTRUCTOR_ELTS, CONVERT_EXPR_P, error(), expand_expr(), EXPAND_INITIALIZER, gcc_assert, gcc_unreachable, GET_MODE_ALIGNMENT, GET_MODE_SIZE, int_size_in_bytes(), MIN, min_align(), NULL, NULL_RTX, output_constant(), output_constructor(), POINTER_TYPE_P, targetm, TREE_CODE, TREE_IMAGPART, TREE_INT_CST_HIGH, TREE_INT_CST_LOW, tree_low_cst(), TREE_OPERAND, TREE_REAL_CST, TREE_REALPART, TREE_STRING_LENGTH, TREE_STRING_POINTER, TREE_TYPE, TYPE_ADDR_SPACE, TYPE_MODE, vec_safe_is_empty(), VECTOR_CST_ELT, and VECTOR_CST_NELTS.
const char* integer_asm_op | ( | ) |
Return the assembler directive for creating a given kind of integer object. SIZE is the number of bytes in the object and ALIGNED_P indicates whether it is known to be aligned. Return NULL if the assembly dialect has no such directive.
The returned string should be printed at the start of a new line and be followed immediately by the object's initial value.
rtx lookup_constant_def | ( | ) |
Look up EXP in the table of constant descriptors. Return the rtl if it has been emitted, else null.
rtx make_debug_expr_from_rtl | ( | ) |
Create a DEBUG_EXPR_DECL / DEBUG_EXPR pair from RTL expression EXP.
void make_decl_one_only | ( | ) |
Set up DECL as a public symbol that can be defined in multiple translation units without generating a linker error.
References categorize_decl_for_section(), and decl_readonly_section_1().
void make_decl_rtl | ( | ) |
Create the DECL_RTL for a VAR_DECL or FUNCTION_DECL. DECL should have static storage duration. In other words, it should not be an automatic variable, including PARM_DECLs.
There is, however, one exception: this function handles variables explicitly placed in a particular register by the user.
This is never called for PARM_DECL nodes.
Check that we are not being given an automatic variable.
A weak alias has TREE_PUBLIC set but not the other bits.
And that we were not given a type or a label.
For a duplicate declaration, we can be called twice on the same DECL node. Don't discard the RTL already made.
If the old RTL had the wrong mode, fix the mode.
??? Another way to do this would be to maintain a hashed table of such critters. Instead of adding stuff to a DECL to give certain attributes to it, we could use an external hash map from DECL to set of attributes.
Let the target reassign the RTL if it wants. This is necessary, for example, when one machine specific decl attribute overrides another.
If the symbol has a SYMBOL_REF_BLOCK field, update it based on the new decl information.
If this variable belongs to the global constant pool, retrieve the pre-computed RTL or recompute it in LTO mode.
First detect errors in declaring global registers.
Now handle properly declared static register variables.
If the user specified one of the eliminables registers here, e.g., FRAME_POINTER_REGNUM, we don't want to get this variable confused with that register and be eliminated. This usage is somewhat suspect...
Make this register global, so not usable for anything else.
As a register variable, it has no section.
Now handle ordinary static variables and functions (in memory). Also handle vars declared register invalidly.
Specifying a section attribute on a variable forces it into a non-.bss section, and thus it cannot be common.
FIXME: In general this code should not be necessary because visibility pass is doing the same work. But notice_global_symbol is called early and it needs to make DECL_RTL to get the name. we take care of recomputing the DECL_RTL after visibility is changed.
Variables can't be both common and weak.
Optionally set flags or add text to the name to record information such as that it is a function name. If the name is changed, the macro ASM_OUTPUT_LABELREF will have to know how to strip this information.
rtx make_decl_rtl_for_debug | ( | ) |
Like make_decl_rtl, but inhibit creation of new alias sets when calling make_decl_rtl. Also, reset DECL_RTL before returning the rtl.
Kludge alert! Somewhere down the call chain, make_decl_rtl will call new_alias_set. If running with -fcompare-debug, sometimes we do not want to create alias sets that will throw the alias numbers off in the comparison dumps. So... clearing flag_strict_aliasing will keep new_alias_set() from creating a new set.
Reset DECL_RTL back, as various parts of the compiler expects DECL_RTL set meaning it is actually going to be output.
References DECL_COMMON, DECL_EXTERNAL, DECL_INITIAL, DECL_NAME, DECL_ONE_ONLY, DECL_RTL, DECL_WEAK, error_mark_node, first_global_object_name, MEM_P, TREE_CODE, TREE_PUBLIC, and weak_global_object_name.
|
static |
Given a SYMBOL_REF CURRENT_RTX, mark it and all constants it refers to as used. Emit referenced deferred strings. This function can be used with for_each_rtx to mark all SYMBOL_REFs in an rtx.
|
static |
Look through the instructions for this function, and mark all the entries in POOL which are actually being used. Emit deferred constants which have indeed been used.
References CONSTRUCTOR_ELTS, FOR_EACH_CONSTRUCTOR_VALUE, initializer_constant_valid_p_1(), NULL, and TREE_TYPE.
|
static |
Look through appropriate parts of INSN, marking all entries in the constant pool which are actually being used. Entries that are only referenced by other constants are also marked as used. Emit deferred strings that are used.
Insns may appear inside a SEQUENCE. Only check the patterns of insns, not any notes that may be attached. We don't want to mark a constant just because it happens to appear in a REG_EQUIV note.
void mark_decl_referenced | ( | ) |
Set the symbol_referenced flag for DECL and notify callgraph.
Extern inline functions don't become needed when referenced. If we know a method will be emitted in other TU and no new functions can be marked reachable, just use the external definition.
C++ frontend use mark_decl_references to force COMDAT variables to be output that might appear dead otherwise.
else do nothing - we can get various sorts of CST nodes here, which do not need to be marked.
References asm_int_op::di, asm_int_op::hi, NULL, asm_int_op::si, targetm, and asm_int_op::ti.
void mark_referenced | ( | ) |
Set the symbol_referenced flag for ID.
References targetm.
|
static |
Referenced by output_constructor_bitfield().
|
static |
Mark DECL as weak.
int maybe_assemble_visibility | ( | ) |
A helper function to call assemble_visibility when needed for a decl.
References SECCAT_BSS, SECCAT_RODATA, SECCAT_SBSS, SECCAT_SDATA, SECCAT_SRODATA, and targetm.
|
static |
Subroutine of output_constant_def: Decide whether or not we need to output the constant DESC now, and if so, do it.
Already output; don't do it again.
We can always defer constants as long as the context allows doing so.
Increment n_deferred_constants if it exists. It needs to be at least as large as the number of constants actually referred to by the function. If it's too small we'll stop looking too early and fail to emit constants; if it's too large we'll only look through the entire function when we could have stopped earlier.
void merge_weak | ( | ) |
Merge weak status between NEWDECL and OLDDECL.
We put the NEWDECL on the weak_decls list at some point and OLDDECL as well. Keep just OLDDECL on the list.
NEWDECL is weak, but OLDDECL is not. If we already output the OLDDECL, we're in trouble; we can't go back and make it weak. This should never happen in unit-at-a-time compilation.
If we've already generated rtl referencing OLDDECL, we may have done so in a way that will not function properly with a weak symbol. Again in unit-at-a-time this should be impossible.
We put the NEWDECL on the weak_decls list at some point. Replace it with the OLDDECL.
We may not find the entry on the list. If NEWDECL is a weak alias, then we will have already called globalize_decl to remove the entry; in that case, we do not need to do anything.
Make the OLDDECL weak; it's OLDDECL that we'll be keeping.
OLDDECL was weak, but NEWDECL was not explicitly marked as weak. Just update NEWDECL to indicate that it's weak too.
References htab_create_ggc, NULL, tree_map_eq, and tree_map_hash().
section* mergeable_constant_section | ( | enum machine_mode | mode, |
unsigned HOST_WIDE_INT | align, | ||
unsigned int | flags | ||
) |
Return the section to use for constant merging.
References reg_names, and strip_reg_name().
|
static |
Return the section to use for string merging.
Check for embedded NUL characters.
References alloca, GET_MODE_BITSIZE, get_section(), NULL, readonly_data_section, SECTION_MERGE, and targetm.
|
static |
Referenced by assemble_static_space(), and initializer_constant_valid_p_1().
|
inlinestatic |
A and B are either alignments or offsets. Return the minimum alignment that may be assumed after adding the two together.
|
static |
A subroutine of initializer_constant_valid_p. VALUE is a MINUS_EXPR, PLUS_EXPR or POINTER_PLUS_EXPR. This looks for cases of VALUE which are valid when ENDTYPE is an integer of any size; in particular, this does not accept a pointer minus a constant. This returns null_pointer_node if the VALUE is an absolute constant which can be used to initialize a static variable. Otherwise it returns NULL.
Like STRIP_NOPS except allow the operand mode to widen. This works around a feature of fold that simplifies (int)(p1 - p2) to ((int)p1 - (int)p2) under the theory that the narrower operation is cheaper.
Both initializers must be known.
Support differences between labels.
Referenced by output_addressed_constants().
void notice_global_symbol | ( | ) |
DECL is an object (either VAR_DECL or FUNCTION_DECL) which is going to be output to assembler. Set first_global_object_name and weak_global_object_name as appropriate.
We win when global object is found, but it is useful to know about weak symbol as well so we can produce nicer unique names.
|
static |
Helper routines for maintaining object_block_htab.
|
static |
|
static |
|
static |
Find all the constants whose addresses are referenced inside of EXP, and make sure assembler code with a label has been output for each one. Indicate whether an ADDR_EXPR has been encountered.
Go inside any operations that get_inner_reference can handle and see if what's inside is a constant: no need to do anything here for addresses of variables or functions.
If we have an initialized CONST_DECL, retrieve the initializer.
Fall through.
References initializer_constant_valid_p_1(), narrowing_initializer_constant_valid_p(), null_pointer_node, NULL_TREE, and TREE_OPERAND.
void output_constant | ( | ) |
Output assembler code for constant EXP, with no label. This includes the pseudo-op such as ".int" or ".byte", and a newline. Assumes output_addressed_constants has been done on EXP already.
Generate exactly SIZE bytes of assembler data, padding at the end with zeros if necessary. SIZE must always be specified.
SIZE is important for structure constructors, since trailing members may have been omitted from the constructor. It is also important for initialization of arrays from string constants since the full length of the string constant might not be wanted. It is also needed for initialization of unions, where the initializer's type is just one member, and that may not be as long as the union.
There a case in which we would fail to output exactly SIZE bytes: for a structure constructor that wants to produce more than SIZE bytes. But such constructors will never be generated for any possible input.
ALIGN is the alignment of the data in bits.
See if we're trying to initialize a pointer in a non-default mode to the address of some declaration somewhere. If the target says the mode is valid for pointers, assume the target has a way of resolving it.
Peel off any intermediate conversions-to-pointer for valid pointer modes.
If what we're left with is the address of something, we can convert the address to the final type and output it that way.
Likewise for constant ints.
Eliminate any conversions since we'll be outputting the underlying constant.
Make sure eliminating the conversion is really a no-op, except with VIEW_CONVERT_EXPRs to allow for wild Ada unchecked conversions and union types to allow for Ada unchecked unions.
Keep the conversion.
Allow a constructor with no elements for any data type. This means to fill the space with zeros.
Now output the underlying data. If we've handling the padding, return. Otherwise, break and ensure SIZE is the size written.
References assemble_integer(), assemble_zeros(), oc_outer_state::bit_offset, BITS_PER_UNIT, oc_outer_state::byte, oc_local_state::byte, oc_local_state::byte_buffer_in_use, DECL_NAME, DECL_SIZE, error(), oc_local_state::field, gcc_assert, GEN_INT, HOST_BITS_PER_DOUBLE_INT, HOST_BITS_PER_WIDE_INT, oc_local_state::index, int_bit_position(), integer_zero_node, oc_local_state::last_relative_index, MIN, oc_local_state::min_index, NULL_TREE, output_constructor(), shift, oc_local_state::total_bytes, TREE_CODE, TREE_INT_CST_HIGH, TREE_INT_CST_LOW, tree_low_cst(), TREE_OPERAND, TREE_TYPE, oc_local_state::type, TYPE_SIZE, and oc_local_state::val.
rtx output_constant_def | ( | ) |
Return an rtx representing a reference to constant data in memory for the constant expression EXP.
If assembler code for such a constant has already been output, return an rtx to refer to it. Otherwise, output such a constant in memory and generate an rtx for it.
If DEFER is nonzero, this constant can be deferred and output only if referenced in the function after all optimizations.
`const_desc_table' records which constants already have label strings.
Look up EXP in the table of constant descriptors. If we didn't find it, create a new one.
References shift.
|
static |
Referenced by force_const_mem().
|
static |
We must output the constant data referred to by SYMBOL; do so.
Make sure any other constants whose addresses appear in EXP are assigned label numbers.
We are no longer deferring this constant.
If the constant is part of an object block, make sure that the decl has been positioned within its block, but do not write out its definition yet. output_object_blocks will do that later.
References simplify_rtx().
|
static |
Mark all constants that are used in the current function, then write out the function's private constant pool.
It is possible for gcc to call force_const_mem and then to later discard the instructions which refer to the constant. In such a case we do not need to output the constant.
References DECL_STATIC_CHAIN, null_pointer_node, NULL_TREE, staticp(), TREE_CODE, TREE_CONSTANT, TREE_NO_TRAMPOLINE, and TREE_OPERAND.
|
static |
Worker function for output_constant_pool. Emit constant DESC, giving it ALIGN bits of alignment.
See if X is a LABEL_REF (or a CONST referring to a LABEL_REF) whose CODE_LABEL has been deleted. This can occur if a jump table is eliminated by optimization. If so, write a constant of zero instead. Note that this can also happen by turning the CODE_LABEL into a NOTE.
??? This seems completely and utterly wrong. Certainly it's not true for NOTE_INSN_DELETED_LABEL, but I disbelieve proper functioning even with INSN_DELETED_P and friends.
FALLTHRU
Output the label.
Output the data.
Make sure all constants in SECTION_MERGE and not SECTION_STRINGS sections have proper size.
|
static |
Worker function for output_constant_pool_1. Emit assembly for X in MODE with known alignment ALIGN.
|
static |
Write all the constants in POOL.
If the constant is part of an object_block, make sure that the constant has been positioned within its block, but do not write out its definition yet. output_object_blocks will do that later.
References NULL_TREE.
|
static |
Subroutine of output_constant, used for CONSTRUCTORs (aggregate constants). Generate at least SIZE bytes, padding if necessary. OUTER designates the caller output state of relevance in recursive invocations.
Setup our local state to communicate with helpers.
As CE goes through the elements of the constant, FIELD goes through the structure fields if the constant is a structure. If the constant is a union, we override this by getting the field from the TREE_LIST element. But the constant could also be an array. Then FIELD is zero. There is always a maximum of one element in the chain LINK for unions (even if the initializer in a source program incorrectly contains more one).
The element in a union constructor specifies the proper field or index.
Eliminate the marker that makes a cast not be an lvalue.
Output the current element, using the appropriate helper ...
For an array slice not part of an outer bitfield.
For a field that is neither a true bitfield nor part of an outer one, known to be at least byte aligned and multiple-of-bytes long.
For a true bitfield or part of an outer one. Only INTEGER_CSTs are supported for scalar fields, so we may need to convert first.
If we are not at toplevel, save the pending data for our caller. Otherwise output the pending data and padding zeros as needed.
Referenced by initializer_constant_valid_p_1(), and output_constant().
|
static |
Helper for output_constructor. From the current LOCAL state, output a RANGE_EXPR element.
Output the element's initial value.
Count its size.
|
static |
Helper for output_constructor. From the LOCAL state, output an element that is a true bitfield or part of an outer one. BIT_OFFSET is the offset from the start of a possibly ongoing outer byte buffer.
Bit size of this element.
Relative index of this element if this is an array component.
Bit position of this element from the start of the containing constructor.
Bit position of this element from the start of a possibly ongoing outer byte buffer.
From the start of a possibly ongoing outer byte buffer, offsets to the first bit of this element and to the first bit past the end of this element.
If this field does not start in this (or next) byte, skip some bytes.
Output remnant of any bit field in previous bytes.
If still not at proper byte, advance to there.
Set up the buffer if necessary.
If this is nested constructor, recurse passing the bit offset and the pending data, then retrieve the new pending data afterwards.
Otherwise, we must split the element into pieces that fall within separate bytes, and combine each byte with previous or following bit-fields.
Advance from byte to byte within this element when necessary.
Number of bits we can process at once (all part of the same byte).
On big-endian machine, take the most significant bits first (of the bits that are significant) and put them into bytes from the most significant end.
Don't try to take a bunch of bits that cross the word boundary in the INTEGER_CST. We can only select bits from the LOW or HIGH part not from both.
Now get the bits from the appropriate constant word.
Get the result. This works only when: 1 <= this_time <= HOST_BITS_PER_WIDE_INT.
On little-endian machines, take first the least significant bits of the value and pack them starting at the least significant bits of the bytes.
Don't try to take a bunch of bits that cross the word boundary in the INTEGER_CST. We can only select bits from the LOW or HIGH part not from both.
Now get the bits from the appropriate constant word.
Get the result. This works only when: 1 <= this_time <= HOST_BITS_PER_WIDE_INT.
References DECL_ATTRIBUTES, error(), gcc_assert, get_identifier(), lookup_attribute(), mark_weak(), NULL, TARGET_SUPPORTS_WEAK, TREE_ASM_WRITTEN, TREE_CODE, tree_cons, TREE_PUBLIC, and warning().
|
static |
Helper for output_constructor. From the current LOCAL state, output a field element that is not true bitfield or part of an outer one.
Field size and position. Since this structure is static, we know the positions are constant.
Perform the index calculation in modulo arithmetic but sign-extend the result because Ada has negative DECL_FIELD_OFFSETs but we are using an unsigned sizetype.
Output any buffered-up bit-fields preceding this element.
Advance to offset of this element. Note no alignment needed in an array, since that is guaranteed if each element has the proper size.
Find the alignment of this element.
Determine size this element should occupy.
If this is an array with an unspecified upper bound, the initializer determines the size.
??? This ought to only checked if DECL_SIZE_UNIT is NULL, but we cannot do this until the deprecated support for initializing zero-length array members is removed.
Given a non-empty initialization, this field had better be last.
Output the element's initial value.
Count its size.
References assemble_integer(), assemble_zeros(), oc_local_state::byte, oc_local_state::byte_buffer_in_use, GEN_INT, oc_local_state::size, and oc_local_state::total_bytes.
void output_file_directive | ( | ) |
Output a file name in the form wanted by System V.
NA gets INPUT_NAME sans directory names.
|
static |
Output the objects in BLOCK.
Switch to the section and make sure that the first byte is suitably aligned.
Define the values of all anchors relative to the current section position.
Output the objects themselves.
Move to the object's offset, padding with zeros if necessary.
|
static |
A htab_traverse callback used to call output_object_block for each member of object_block_htab.
void output_object_blocks | ( | void | ) |
Output the definitions of all object_blocks.
Referenced by emit_debug_global_declarations().
void output_section_asm_op | ( | ) |
Output DIRECTIVE (a C string) followed by a newline. This is used as a get_unnamed_section callback.
References DEFAULT_INIT_PRIORITY.
void output_shared_constant_pool | ( | void | ) |
Write the contents of the shared constant pool.
Referenced by emit_debug_global_declarations().
void place_block_symbol | ( | ) |
If block symbol SYMBOL has not yet been assigned an offset, place it at the end of its block.
Work out the symbol's size and alignment.
Calculate the object's offset from the start of the block.
Record the block's new alignment and size.
void process_pending_assemble_externals | ( | void | ) |
void record_tm_clone_pair | ( | ) |
|
static |
Return true when RESOLUTION indicate that symbol will be bound locally within current executable or DSO.
Referenced by default_select_section().
|
static |
Return true when RESOLUTION indicate that symbol will be bound to the definition provided by current .o file.
References offset.
Referenced by default_select_section().
void resolve_unique_section | ( | tree | decl, |
int | reloc, | ||
int | flag_function_or_data_sections | ||
) |
If required, set DECL_SECTION_NAME to a unique name.
References DECL_SECTION_NAME, get_named_section(), NULL, NULL_TREE, and text_section.
|
static |
Helper routines for maintaining section_htab.
|
static |
void set_user_assembler_name | ( | ) |
The user has asked for a DECL to have a particular name. Set (or change) it in such a way that we don't prefix an underscore to it.
rtx simplify_subtraction | ( | ) |
Given a MINUS expression, simplify it if both sides include the same symbol.
|
static |
Referenced by mergeable_constant_section().
|
static |
Given NAME, a putative register name, discard any customary prefixes.
References table.
int supports_one_only | ( | void | ) |
Returns 1 if the target configuration supports defining public symbols so that one of them will be chosen at link time instead of generating a multiply-defined symbol error, whether through the use of weak symbols or a target-specific mechanism for having duplicates discarded.
void switch_to_section | ( | ) |
Emit assembly code to switch to section NEW_SECTION. Do nothing if the current section is NEW_SECTION.
|
static |
Helper comparison function for qsorting by the DECL_UID stored in alias_pair->emitted_diags.
tree tree_output_constant_def | ( | ) |
Return a tree representing a reference to constant data in memory for the constant expression EXP.
This is the counterpart of output_constant_def at the Tree level.
Look up EXP in the table of constant descriptors. If we didn't find it, create a new one.
References targetm.
|
inlinestatic |
Follow the IDENTIFIER_TRANSPARENT_ALIAS chain starting at *ALIAS until we find an identifier that is not itself a transparent alias. Modify the alias passed to it by reference (and all aliases on the way to the ultimate target), such that they do not have to be followed again, and return the ultimate target of the alias chain.
References assemble_integer_with_op(), BITS_PER_UNIT, integer_asm_op(), and POINTER_SIZE.
section* unlikely_text_section | ( | void | ) |
Tell assembler to switch to unlikely-to-be-executed text section.
References alloca, and get_section().
bool unlikely_text_section_p | ( | ) |
When called within a function context, return true if the function has been assigned a cold text section and if SECT is that section. When called outside a function context, return true if SECT is the default cold section.
|
static |
Return true if it is possible to put DECL in an object_block.
Only data DECLs can be placed into object blocks.
Detect decls created by dw2_force_const_mem. Such decls are special because DECL_INITIAL doesn't specify the decl's true value. dw2_output_indirect_constants will instead call assemble_variable with dont_output_data set to 1 and then print the contents itself.
If this decl is an alias, then we don't want to emit a definition.
References error().
|
static |
Return true if the current compilation mode benefits from having objects grouped into blocks.
References RTX_HDR_SIZE, and object_block::size.
void weak_finish | ( | void | ) |
Emit any pending weak declarations.
Remove alias_decl from the weak list, but leave entries for the target alone.
Use ASM_WEAKEN_LABEL only if ASM_WEAKEN_DECL is not defined, otherwise we and weak_finish_1 would use different macros.
Remove the alias and the target from the pending weak list so that we do not emit any .weak directives for the former, nor multiple .weak directives for the latter.
Remove other weakrefs to the same target, to speed things up.
Referenced by emit_debug_global_declarations().
|
static |
References assemble_align(), POINTER_SIZE, switch_to_section(), and targetm.
vec<alias_pair, va_gc>* alias_pairs |
Referenced by handle_alias_pairs().
|
static |
The next number to use for internal anchor labels.
section* bss_noswitch_section |
A SECTION_NOSWITCH section used for declaring global BSS variables. May be null.
section* bss_section |
section* comm_section |
|
static |
We give all constants their own alias set. Perhaps redundant with MEM_READONLY_P, but pre-dates it.
|
static |
Referenced by get_constant_size().
|
static |
Number for making the label on the next constant that is stored in memory.
section* ctors_section |
section* data_section |
Referenced by final_start_function().
section* dtors_section |
section* eh_frame_section |
The section that holds the DWARF2 frame unwind information, when known. The section is set either by the target's init_sections hook or by the first call to switch_to_eh_frame_section.
|
static |
|
static |
section* exception_section |
The section that holds the main exception table, when known. The section is set either by the target's init_sections hook or by the first call to switch_to_exception_section.
bool first_function_block_is_cold |
The following global variable indicates if the first basic block in a function belongs to the cold partition or not.
const char* first_global_object_name |
Output variables, constants and external declarations, for GNU compiler. Copyright (C) 1987-2013 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/. This file handles generation of all the assembler code except the instructions of a function. This includes declarations of variables and their initial values.
We also output the assembler code for constants stored in memory and are responsible for combining constants with the same value. The (assembler) name of the first globally-visible object output.
bool in_cold_section_p |
True if code for the current function is currently being directed at the cold section.
section* in_section |
asm_out_file's current section. This is NULL if no section has yet been selected or if we lose track of what the current section is.
|
static |
Assemble the static constant template for function entry trampolines. This is done at most once per compilation. Returns an RTX for the address of the template.
tree last_assemble_variable_decl |
The last decl for which assemble_variable was called, if it did ASM_DECLARE_OBJECT_NAME. If the last call to assemble_variable didn't do that, this holds 0.
section* lcomm_section |
|
static |
A table of object_blocks, indexed by section.
|
static |
We delay assemble_external processing until the compilation unit is finalized. This is the best we can do for right now (i.e. stage 3 of GCC 4.0) - the right thing is to delay it all the way to final. See PR 17982 for further discussion.
section* readonly_data_section |
Referenced by mergeable_string_section().
|
static |
Whether we saw any functions with no_split_stack.
section* sbss_section |
section* sdata_section |
|
static |
Hash table of named sections.
|
static |
A pool of constants that can be shared between functions.
int size_directive_output |
Carry information from ASM_DECLARE_OBJECT_NAME to ASM_FINISH_DECLARE_OBJECT.
section* text_section |
Well-known sections, each one associated with some sort of *_ASM_OP.
Referenced by resolve_unique_section().
section* tls_comm_section |
Various forms of common section. All are guaranteed to be nonnull.
|
static |
Record and output a table of translations from original function to its transaction aware clone. Note that tm_pure functions are considered to be their own clone.
int trampolines_created |
This is a generic routine suitable for use as TARGET_ASM_FILE_END which emits a special section directive used to indicate whether or not this object file needs an executable stack. This is primarily a GNU extension to ELF but could be used on other targets.
|
static |
A linked list of all the unnamed sections.
|
static |
This TREE_LIST contains any weak symbol declarations waiting to be emitted.
const char* weak_global_object_name |
|
static |
This TREE_LIST contains weakref targets.