* read/write behaviour to global variables or changing calling conventions
* from cdecl to fastcall.
*/
- IR_LINKAGE_HIDDEN_USER = 1 << 4
+ IR_LINKAGE_HIDDEN_USER = 1 << 4,
+ /**
+ * Do not generate code even if the entity has a graph attached. The graph
+ * is only used for inlining. Otherwise the entity is regarded as a
+ * declaration of an externally defined entity.
+ * This linkage flag can be used to implement C99 "inline" or GNU89
+ * "extern inline".
+ */
+ IR_LINKAGE_NO_CODEGEN = 1 << 5,
} ir_linkage;
ENUM_BITSET(ir_linkage)
/**
* Returns 1 if the entity has a definition (initializer) in the current
- * compilation unit
+ * compilation unit. Note that this function returns false if
+ * IR_LINKAGE_NO_CODEGEN is set even if a graph is present.
*/
FIRM_API int entity_has_definition(const ir_entity *entity);
if (type == get_code_type())
return;
- /* we already emitted all methods. Except for the trampolines which
- * the assembler/linker generates */
+ /* we already emitted all methods with graphs in other functions like
+ * be_gas_emit_function_prolog(). All others don't need to be emitted.
+ */
if (is_Method_type(type) && section != GAS_SECTION_PIC_TRAMPOLINES) {
- /* functions with graph are already emitted with
- * be_gas_emit_function_prolog */
- if (get_entity_irg(entity) == NULL) {
- emit_visibility(entity);
- }
return;
}
{
static const char suffix[] = ".prof";
- size_t i, num_birgs;
+ size_t i;
+ size_t num_irgs;
+ size_t num_birgs;
be_main_env_t env;
char prof_filename[256];
be_irg_t *birgs;
arch_env = env.arch_env;
/* we might need 1 birg more for instrumentation constructor */
- num_birgs = get_irp_n_irgs();
- birgs = ALLOCAN(be_irg_t, num_birgs + 1);
+ num_irgs = get_irp_n_irgs();
+ birgs = ALLOCAN(be_irg_t, num_irgs + 1);
be_info_init();
/* First: initialize all birgs */
- for (i = 0; i < num_birgs; ++i) {
- ir_graph *irg = get_irp_irg(i);
- initialize_birg(&birgs[i], irg, &env);
+ num_birgs = 0;
+ for (i = 0; i < num_irgs; ++i) {
+ ir_graph *irg = get_irp_irg(i);
+ ir_entity *entity = get_irg_entity(irg);
+ if (get_entity_linkage(entity) & IR_LINKAGE_NO_CODEGEN)
+ continue;
+ initialize_birg(&birgs[num_birgs++], irg, &env);
}
arch_env_handle_intrinsics(arch_env);
for (i = 0; i < n_entities; ++i) {
ir_entity *entity = get_compound_member(segment, i);
if (get_entity_visibility(entity) != ir_visibility_external
- && !(get_entity_linkage(entity) & IR_LINKAGE_HIDDEN_USER))
+ && !(get_entity_linkage(entity) & IR_LINKAGE_HIDDEN_USER)
+ && !(get_entity_linkage(entity) & IR_LINKAGE_NO_CODEGEN))
continue;
visit_entity(entity);
int entity_has_definition(const ir_entity *entity)
{
if (is_method_entity(entity)) {
- return get_entity_irg(entity) != NULL;
+ return get_entity_irg(entity) != NULL
+ && (get_entity_linkage(entity) & IR_LINKAGE_NO_CODEGEN) == 0;
} else {
return entity->initializer != NULL
|| entity_has_compound_ent_values(entity);