Commit 8939d866 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

ident: Add the macro NEW_IDENT() to create an ident from a string literal.

This unifies several locally defined macros.
parent 95089bd5
......@@ -15,6 +15,7 @@
#include "lc_opts.h"
#include "lc_opts_enum.h"
#include "ident_t.h"
#include "obst.h"
#include "statev.h"
#include "irprog.h"
......@@ -54,8 +55,6 @@
#include "bestack.h"
#include "beemitter.h"
#define NEW_ID(s) new_id_from_chars(s, sizeof(s) - 1)
/* options visible for anyone */
be_options_t be_options = {
.dump_flags = DUMP_NONE,
......@@ -336,9 +335,9 @@ static be_main_env_t *be_init_env(be_main_env_t *const env,
{
memset(env, 0, sizeof(*env));
env->ent_trampoline_map = pmap_create();
env->pic_trampolines_type = new_type_segment(NEW_ID("$PIC_TRAMPOLINE_TYPE"), tf_none);
env->pic_trampolines_type = new_type_segment(NEW_IDENT("$PIC_TRAMPOLINE_TYPE"), tf_none);
env->ent_pic_symbol_map = pmap_create();
env->pic_symbols_type = new_type_segment(NEW_ID("$PIC_SYMBOLS_TYPE"), tf_none);
env->pic_symbols_type = new_type_segment(NEW_IDENT("$PIC_SYMBOLS_TYPE"), tf_none);
env->cup_name = compilation_unit_name;
env->arch_env = isa_if->begin_codegeneration();
......
......@@ -29,6 +29,7 @@
#include "beutil.h"
#include "debug.h"
#include "firmstat_t.h"
#include "ident_t.h"
#include "instrument.h"
#include "irarch.h"
#include "ircons_t.h"
......@@ -218,28 +219,26 @@ static int ia32_get_sp_bias(const ir_node *node)
*/
static void ia32_build_between_type(void)
{
#define IDENT(s) new_id_from_chars(s, sizeof(s)-1)
if (between_type == NULL) {
ir_type *old_bp_type = new_type_primitive(ia32_mode_gp);
ir_type *ret_addr_type = new_type_primitive(ia32_mode_gp);
between_type = new_type_struct(IDENT("ia32_between_type"));
old_bp_ent = new_entity(between_type, IDENT("old_bp"), old_bp_type);
ret_addr_ent = new_entity(between_type, IDENT("ret_addr"), ret_addr_type);
between_type = new_type_struct(NEW_IDENT("ia32_between_type"));
old_bp_ent = new_entity(between_type, NEW_IDENT("old_bp"), old_bp_type);
ret_addr_ent = new_entity(between_type, NEW_IDENT("ret_addr"), ret_addr_type);
set_entity_offset(old_bp_ent, 0);
set_entity_offset(ret_addr_ent, get_type_size_bytes(old_bp_type));
set_type_size_bytes(between_type, get_type_size_bytes(old_bp_type) + get_type_size_bytes(ret_addr_type));
set_type_state(between_type, layout_fixed);
omit_fp_between_type = new_type_struct(IDENT("ia32_between_type_omit_fp"));
omit_fp_ret_addr_ent = new_entity(omit_fp_between_type, IDENT("ret_addr"), ret_addr_type);
omit_fp_between_type = new_type_struct(NEW_IDENT("ia32_between_type_omit_fp"));
omit_fp_ret_addr_ent = new_entity(omit_fp_between_type, NEW_IDENT("ret_addr"), ret_addr_type);
set_entity_offset(omit_fp_ret_addr_ent, 0);
set_type_size_bytes(omit_fp_between_type, get_type_size_bytes(ret_addr_type));
set_type_state(omit_fp_between_type, layout_fixed);
}
#undef IDENT
}
/**
......
......@@ -35,4 +35,6 @@ void firm_init_mangle(void);
void firm_finish_mangle(void);
#define NEW_IDENT(x) new_id_from_chars((x), sizeof(x) - 1)
#endif
......@@ -14,6 +14,7 @@
#include "debug.h"
#include "execfreq_t.h"
#include "hashptr.h"
#include "ident_t.h"
#include "ircons_t.h"
#include "irdump_t.h"
#include "irgwalk.h"
......@@ -138,7 +139,7 @@ static void add_constructor(ir_entity *method)
ir_graph *const irg = get_const_code_irg();
ir_node *const val = new_r_Address(irg, method);
set_entity_ld_ident(ptr, new_id_from_chars("", 0));
set_entity_ld_ident(ptr, NEW_IDENT(""));
set_entity_compiler_generated(ptr, 1);
set_entity_linkage(ptr, IR_LINKAGE_CONSTANT | IR_LINKAGE_HIDDEN_USER);
set_entity_visibility(ptr, ir_visibility_private);
......
......@@ -9,6 +9,7 @@
* @author Goetz Lindenmaier, Michael Beck
* @date 2000
*/
#include "ident_t.h"
#include "irprog_t.h"
#include "irgraph_t.h"
#include "array.h"
......@@ -60,17 +61,15 @@ static void complete_ir_prog(ir_prog *irp, const char *module_name)
ir_init_type(irp);
ir_init_entity(irp);
#define IDENT(x) new_id_from_chars(x, sizeof(x) - 1)
irp->name = new_id_from_str(module_name);
irp->segment_types[IR_SEGMENT_GLOBAL] = new_type_segment(IDENT("GlobalType"), tf_global_type);
irp->segment_types[IR_SEGMENT_THREAD_LOCAL] = new_type_segment(IDENT("ThreadLocal"), tf_tls_type);
irp->segment_types[IR_SEGMENT_CONSTRUCTORS] = new_type_segment(IDENT("Constructors"), tf_info);
irp->segment_types[IR_SEGMENT_DESTRUCTORS] = new_type_segment(IDENT("Destructors"), tf_info);
irp->segment_types[IR_SEGMENT_JCR] = new_type_segment(IDENT("Java Class Registry"), tf_info);
irp->segment_types[IR_SEGMENT_GLOBAL] = new_type_segment(NEW_IDENT("GlobalType"), tf_global_type);
irp->segment_types[IR_SEGMENT_THREAD_LOCAL] = new_type_segment(NEW_IDENT("ThreadLocal"), tf_tls_type);
irp->segment_types[IR_SEGMENT_CONSTRUCTORS] = new_type_segment(NEW_IDENT("Constructors"), tf_info);
irp->segment_types[IR_SEGMENT_DESTRUCTORS] = new_type_segment(NEW_IDENT("Destructors"), tf_info);
irp->segment_types[IR_SEGMENT_JCR] = new_type_segment(NEW_IDENT("Java Class Registry"), tf_info);
irp->const_code_irg = new_const_code_irg();
irp->globals_entity_usage_state = ir_entity_usage_not_computed;
#undef IDENT
}
void init_irprog_1(void)
......
......@@ -8,10 +8,10 @@
* @brief Opcode of types.
* @author Goetz Lindenmaier, Michael Beck
*/
#include "ident_t.h"
#include "xmalloc.h"
#include "tpop_t.h"
#include "type_t.h"
#include "ident.h"
const tp_op *type_class; const tp_op *get_tpop_class (void) { return type_class; }
const tp_op *type_struct; const tp_op *get_tpop_struct (void) { return type_struct; }
......@@ -137,17 +137,15 @@ static const tp_op_ops
void init_tpop(void)
{
#define ID(s) new_id_from_chars(s, sizeof(s) - 1)
type_class = new_tpop(tpo_class , ID("class"), TP_OP_FLAG_COMPOUND, sizeof(cls_attr), &class_ops);
type_struct = new_tpop(tpo_struct , ID("struct"), TP_OP_FLAG_COMPOUND, sizeof(compound_attr), &struct_ops);
type_method = new_tpop(tpo_method , ID("method"), 0, sizeof(mtd_attr), &method_ops);
type_union = new_tpop(tpo_union , ID("union"), TP_OP_FLAG_COMPOUND, sizeof(compound_attr), &union_ops);
type_array = new_tpop(tpo_array , ID("array"), 0, sizeof(arr_attr), &array_ops);
type_pointer = new_tpop(tpo_pointer , ID("pointer"), 0, sizeof(ptr_attr), &pointer_ops);
type_primitive = new_tpop(tpo_primitive , ID("primitive"), 0, 0, &primitive_ops);
tpop_code = new_tpop(tpo_code , ID("code"), 0, 0, &null_ops);
tpop_unknown = new_tpop(tpo_unknown , ID("Unknown"), 0, 0, &null_ops);
#undef ID
type_class = new_tpop(tpo_class, NEW_IDENT("class"), TP_OP_FLAG_COMPOUND, sizeof(cls_attr), &class_ops);
type_struct = new_tpop(tpo_struct, NEW_IDENT("struct"), TP_OP_FLAG_COMPOUND, sizeof(compound_attr), &struct_ops);
type_method = new_tpop(tpo_method, NEW_IDENT("method"), 0, sizeof(mtd_attr), &method_ops);
type_union = new_tpop(tpo_union, NEW_IDENT("union"), TP_OP_FLAG_COMPOUND, sizeof(compound_attr), &union_ops);
type_array = new_tpop(tpo_array, NEW_IDENT("array"), 0, sizeof(arr_attr), &array_ops);
type_pointer = new_tpop(tpo_pointer, NEW_IDENT("pointer"), 0, sizeof(ptr_attr), &pointer_ops);
type_primitive = new_tpop(tpo_primitive, NEW_IDENT("primitive"), 0, 0, &primitive_ops);
tpop_code = new_tpop(tpo_code, NEW_IDENT("code"), 0, 0, &null_ops);
tpop_unknown = new_tpop(tpo_unknown, NEW_IDENT("Unknown"), 0, 0, &null_ops);
}
void finish_tpop(void)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment