Commit 8b493df9 authored by Christian Würdig's avatar Christian Würdig
Browse files

fixed ctor support

parent 26cfbdee
...@@ -1396,6 +1396,7 @@ static ia32_isa_t ia32_isa_template = { ...@@ -1396,6 +1396,7 @@ static ia32_isa_t ia32_isa_template = {
&ia32_gp_regs[REG_ESP], /* stack pointer register */ &ia32_gp_regs[REG_ESP], /* stack pointer register */
&ia32_gp_regs[REG_EBP], /* base pointer register */ &ia32_gp_regs[REG_EBP], /* base pointer register */
-1, /* stack direction */ -1, /* stack direction */
NULL, /* main environment */
}, },
NULL, /* 16bit register names */ NULL, /* 16bit register names */
NULL, /* 8bit register names */ NULL, /* 8bit register names */
...@@ -1412,6 +1413,7 @@ static ia32_isa_t ia32_isa_template = { ...@@ -1412,6 +1413,7 @@ static ia32_isa_t ia32_isa_template = {
arch_pentium_4, /* optimize for architecture */ arch_pentium_4, /* optimize for architecture */
fp_sse2, /* use sse2 unit */ fp_sse2, /* use sse2 unit */
NULL, /* current code generator */ NULL, /* current code generator */
NULL, /* output file */
#ifndef NDEBUG #ifndef NDEBUG
NULL, /* name obstack */ NULL, /* name obstack */
0 /* name obst size */ 0 /* name obst size */
...@@ -1491,7 +1493,7 @@ static void ia32_done(void *self) { ...@@ -1491,7 +1493,7 @@ static void ia32_done(void *self) {
ia32_isa_t *isa = self; ia32_isa_t *isa = self;
/* emit now all global declarations */ /* emit now all global declarations */
ia32_gen_decls(isa->out, isa->cg); ia32_gen_decls(isa->out, isa->arch_isa.main_env);
pmap_destroy(isa->regs_16bit); pmap_destroy(isa->regs_16bit);
pmap_destroy(isa->regs_8bit); pmap_destroy(isa->regs_8bit);
......
...@@ -80,6 +80,7 @@ void ia32_switch_section(FILE *F, section_t sec) { ...@@ -80,6 +80,7 @@ void ia32_switch_section(FILE *F, section_t sec) {
case SECTION_RODATA: case SECTION_RODATA:
case SECTION_COMMON: case SECTION_COMMON:
case SECTION_TLS: case SECTION_TLS:
case SECTION_CTOR:
fprintf(F, "\t%s\n", text[asm_flavour][sec]); fprintf(F, "\t%s\n", text[asm_flavour][sec]);
break; break;
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include "entity.h" #include "entity.h"
#include "irprog.h" #include "irprog.h"
#include "../bearch.h" #include "../be.h"
#include "ia32_emitter.h" #include "ia32_emitter.h"
#include "ia32_gen_decls.h" #include "ia32_gen_decls.h"
...@@ -24,11 +24,11 @@ ...@@ -24,11 +24,11 @@
typedef struct obstack obstack_t; typedef struct obstack obstack_t;
typedef struct _ia32_decl_env { typedef struct _ia32_decl_env {
obstack_t *rodata_obst; obstack_t *rodata_obst;
obstack_t *data_obst; obstack_t *data_obst;
obstack_t *comm_obst; obstack_t *comm_obst;
obstack_t *ctor_obst; obstack_t *ctor_obst;
ia32_code_gen_t *cg; const be_main_env_t *main_env;
} ia32_decl_env_t; } ia32_decl_env_t;
/************************************************************************/ /************************************************************************/
...@@ -599,13 +599,13 @@ static void ia32_dump_globals(ir_type *gt, ia32_decl_env_t *env) ...@@ -599,13 +599,13 @@ static void ia32_dump_globals(ir_type *gt, ia32_decl_env_t *env)
int i, n = get_compound_n_members(gt); int i, n = get_compound_n_members(gt);
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
dump_global(env->cg->arch_env, env->rodata_obst, env->data_obst, env->comm_obst, env->ctor_obst, dump_global(env->main_env->arch_env, env->rodata_obst, env->data_obst, env->comm_obst, env->ctor_obst,
get_compound_member(gt, i)); get_compound_member(gt, i));
} }
/************************************************************************/ /************************************************************************/
void ia32_gen_decls(FILE *out, ia32_code_gen_t *cg) { void ia32_gen_decls(FILE *out, const be_main_env_t *main_env) {
ia32_decl_env_t env; ia32_decl_env_t env;
obstack_t rodata, data, comm, ctor; obstack_t rodata, data, comm, ctor;
int size; int size;
...@@ -616,13 +616,14 @@ void ia32_gen_decls(FILE *out, ia32_code_gen_t *cg) { ...@@ -616,13 +616,14 @@ void ia32_gen_decls(FILE *out, ia32_code_gen_t *cg) {
obstack_init(&data); obstack_init(&data);
obstack_init(&comm); obstack_init(&comm);
if (cg->birg->main_env->options->opt_profile) if (main_env->options->opt_profile)
obstack_init(&ctor); obstack_init(&ctor);
env.rodata_obst = &rodata; env.rodata_obst = &rodata;
env.data_obst = &data; env.data_obst = &data;
env.comm_obst = &comm; env.comm_obst = &comm;
env.ctor_obst = cg->birg->main_env->options->opt_profile ? &ctor : NULL; env.ctor_obst = main_env->options->opt_profile ? &ctor : NULL;
env.main_env = main_env;
ia32_dump_globals(get_glob_type(), &env); ia32_dump_globals(get_glob_type(), &env);
...@@ -647,7 +648,7 @@ void ia32_gen_decls(FILE *out, ia32_code_gen_t *cg) { ...@@ -647,7 +648,7 @@ void ia32_gen_decls(FILE *out, ia32_code_gen_t *cg) {
fwrite(cp, 1, size, out); fwrite(cp, 1, size, out);
} }
if (cg->birg->main_env->options->opt_profile) { if (main_env->options->opt_profile) {
size = obstack_object_size(&ctor); size = obstack_object_size(&ctor);
cp = obstack_finish(&ctor); cp = obstack_finish(&ctor);
if (size > 0) { if (size > 0) {
......
...@@ -7,11 +7,11 @@ ...@@ -7,11 +7,11 @@
#ifndef _IA32_GEN_DECLS_H_ #ifndef _IA32_GEN_DECLS_H_
#define _IA32_GEN_DECLS_H_ #define _IA32_GEN_DECLS_H_
#include "bearch_ia32_t.h" #include "../be.h"
/** /**
* Generate all entities. * Generate all entities.
*/ */
void ia32_gen_decls(FILE *out, ia32_code_gen_t *cg); void ia32_gen_decls(FILE *out, const be_main_env_t *main_env);
#endif /* _IA32_GEN_DECLS_H_ */ #endif /* _IA32_GEN_DECLS_H_ */
Supports Markdown
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