Commit 54c5bada authored by Christoph Mallon's avatar Christoph Mallon
Browse files

be: Remove struct arch_env_t.

parent b18c2537
......@@ -20,7 +20,6 @@
#include "benode.h"
#include "betranshlp.h"
#include "bearch_TEMPLATE_t.h"
#include "beirg.h"
#include "TEMPLATE_nodes_attr.h"
......
......@@ -11,7 +11,6 @@
#include "TEMPLATE_new_nodes.h"
#include "TEMPLATE_transform.h"
#include "be_t.h"
#include "bearch_TEMPLATE_t.h"
#include "bemodule.h"
#include "benode.h"
#include "bestack.h"
......@@ -66,18 +65,12 @@ static void TEMPLATE_finish(void)
TEMPLATE_free_opcodes();
}
static arch_env_t *TEMPLATE_begin_codegeneration(void)
static void TEMPLATE_begin_codegeneration(void)
{
TEMPLATE_isa_t *isa = XMALLOC(TEMPLATE_isa_t);
return &isa->base;
}
/**
* Closes the output file and frees the ISA structure.
*/
static void TEMPLATE_end_codegeneration(void *self)
static void TEMPLATE_end_codegeneration(void)
{
free(self);
}
static void TEMPLATE_lower_for_target(void)
......
......@@ -10,10 +10,4 @@
#ifndef FIRM_BE_TEMPLATE_BEARCH_TEMPLATE_T_H
#define FIRM_BE_TEMPLATE_BEARCH_TEMPLATE_T_H
#include "bearch.h"
typedef struct TEMPLATE_isa_t {
arch_env_t base; /**< must be derived from arch_isa */
} TEMPLATE_isa_t;
#endif
......@@ -68,7 +68,6 @@ static void transform_sub_to_neg_add(ir_node *node,
ir_node *block = get_nodes_block(node);
dbg_info *dbgi = get_irn_dbg_info(node);
ir_graph *irg = get_irn_irg(node);
ir_node *in1 = get_irn_n(node, 0);
ir_node *in2 = get_irn_n(node, 1);
......@@ -79,7 +78,7 @@ static void transform_sub_to_neg_add(ir_node *node,
if (is_amd64_subs(node)) {
ir_tarval *tv = create_sign_tv(amd64_mode_xmm);
ir_entity *sign_bit_const = create_float_const_entity(irg, tv);
ir_entity *sign_bit_const = create_float_const_entity(tv);
amd64_binop_addr_attr_t xor_attr;
memset(&xor_attr, 0, sizeof(xor_attr));
......
......@@ -386,12 +386,9 @@ static amd64_insn_mode_t get_insn_mode_from_mode(const ir_mode *mode)
panic("unexpected mode");
}
ir_entity *create_float_const_entity(ir_graph *const irg,
ir_tarval *const tv)
ir_entity *create_float_const_entity(ir_tarval *const tv)
{
const arch_env_t *arch_env = be_get_irg_arch_env(irg);
amd64_isa_t *isa = (amd64_isa_t*) arch_env;
ir_entity *entity = pmap_get(ir_entity, isa->constants, tv);
ir_entity *entity = pmap_get(ir_entity, amd64_constants, tv);
if (entity != NULL)
return entity;
......@@ -406,7 +403,7 @@ ir_entity *create_float_const_entity(ir_graph *const irg,
ir_initializer_t *initializer = create_initializer_tarval(tv);
set_entity_initializer(entity, initializer);
pmap_insert(isa->constants, tv, entity);
pmap_insert(amd64_constants, tv, entity);
return entity;
}
......@@ -433,7 +430,7 @@ static ir_node *create_float_const(dbg_info *dbgi, ir_node *block,
{
ir_graph *irg = get_irn_irg(block);
ir_mode *tv_mode = get_tarval_mode(tv);
ir_entity *entity = create_float_const_entity(irg, tv);
ir_entity *entity = create_float_const_entity(tv);
ir_node *nomem = get_irg_no_mem(irg);
ir_node *in[] = { nomem };
......
......@@ -29,10 +29,10 @@ void amd64_transform_graph(ir_graph *irg);
ir_node *amd64_new_IncSP(ir_node *block, ir_node *old_sp, int offset,
unsigned align);
/** Creates an entity for a constant floating point value.
/**
* Creates an entity for a constant floating point value.
*/
ir_entity *create_float_const_entity(ir_graph *const irg,
ir_tarval *const tv);
ir_entity *create_float_const_entity(ir_tarval *const tv);
/** Creates a tarval with the given mode and only
* the most-significant (first) bit set.
......
......@@ -33,6 +33,8 @@
DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
pmap *amd64_constants;
ir_mode *amd64_mode_E;
ir_type *amd64_type_E;
ir_mode *amd64_mode_xmm;
......@@ -644,22 +646,14 @@ static void amd64_finish(void)
amd64_free_opcodes();
}
static arch_env_t *amd64_begin_codegeneration(void)
static void amd64_begin_codegeneration(void)
{
amd64_isa_t *isa = XMALLOC(amd64_isa_t);
isa->constants = pmap_create();
return &isa->base;
amd64_constants = pmap_create();
}
/**
* Closes the output file and frees the ISA structure.
*/
static void amd64_end_codegeneration(void *self)
static void amd64_end_codegeneration(void)
{
amd64_isa_t *isa = (amd64_isa_t*)self;
pmap_destroy(isa->constants);
free(isa);
pmap_destroy(amd64_constants);
}
/**
......
......@@ -13,10 +13,7 @@
#include "bearch.h"
#include "../ia32/x86_cconv.h"
typedef struct amd64_isa_t {
arch_env_t base; /**< must be derived from arch_isa */
pmap *constants; /**< A map of entities that store const tarvals */
} amd64_isa_t;
extern pmap *amd64_constants; /**< A map of entities that store const tarvals */
extern ir_mode *amd64_mode_E;
extern ir_type *amd64_type_E;
......
......@@ -173,24 +173,16 @@ static void arm_handle_intrinsics(ir_graph *irg)
irg_walk_graph(irg, handle_intrinsic, NULL, NULL);
}
static arch_env_t *arm_begin_codegeneration(void)
static void arm_begin_codegeneration(void)
{
arm_isa_t *isa = XMALLOC(arm_isa_t);
be_gas_emit_types = false;
be_gas_elf_type_char = '%';
arm_emit_file_prologue();
return &isa->base;
}
/**
* Closes the output file and frees the ISA structure.
*/
static void arm_end_codegeneration(void *self)
static void arm_end_codegeneration(void)
{
free(self);
}
/**
......
......@@ -32,10 +32,6 @@ typedef enum {
ARM_FPU_FPA,
} arm_fpu_variant_t;
struct arm_isa_t {
arch_env_t base; /**< must be derived from arch_env_t */
};
typedef struct arm_codegen_config_t {
arm_variant_t variant;
arm_fpu_variant_t fpu;
......
......@@ -53,7 +53,6 @@ extern after_transform_func be_after_transform;
extern asm_constraint_flags_t be_asm_constraint_flags[256];
struct be_main_env_t {
arch_env_t *arch_env;
const char *cup_name; /**< name of the compilation unit */
pmap *ent_trampoline_map; /**< A map containing PIC trampolines for methods. */
ir_type *pic_trampolines_type; /**< Class type containing all trampolines */
......
......@@ -19,7 +19,6 @@ typedef struct arch_register_class_t arch_register_class_t;
typedef struct arch_register_req_t arch_register_req_t;
typedef struct arch_register_t arch_register_t;
typedef struct arch_isa_if_t arch_isa_if_t;
typedef struct arch_env_t arch_env_t;
/**
* Some flags describing a node in more detail.
......
......@@ -340,12 +340,12 @@ struct arch_isa_if_t {
* Start codegeneration
* @return a new isa instance
*/
arch_env_t *(*begin_codegeneration)(void);
void (*begin_codegeneration)(void);
/**
* Free the isa instance.
*/
void (*end_codegeneration)(void *self);
void (*end_codegeneration)(void);
/**
* mark node as rematerialized
......@@ -397,12 +397,6 @@ struct arch_isa_if_t {
void (*emit)(ir_graph *irg);
};
/**
* ISA base class.
*/
struct arch_env_t {
};
static inline bool arch_irn_is_ignore(const ir_node *irn)
{
const arch_register_req_t *req = arch_get_irn_register_req(irn);
......
......@@ -93,11 +93,6 @@ static inline be_lv_t *be_get_irg_liveness(const ir_graph *irg)
return be_birg_from_irg(irg)->lv;
}
static inline const arch_env_t *be_get_irg_arch_env(const ir_graph *irg)
{
return be_birg_from_irg(irg)->main_env->arch_env;
}
static inline struct obstack *be_get_be_obst(const ir_graph *irg)
{
be_irg_t *const birg = be_birg_from_irg(irg);
......
......@@ -334,7 +334,8 @@ static be_main_env_t *be_init_env(be_main_env_t *const env,
env->ent_pic_symbol_map = pmap_create();
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();
isa_if->begin_codegeneration();
memset(be_asm_constraint_flags, 0, sizeof(be_asm_constraint_flags));
......@@ -346,7 +347,7 @@ static be_main_env_t *be_init_env(be_main_env_t *const env,
*/
static void be_done_env(be_main_env_t *env)
{
isa_if->end_codegeneration(env->arch_env);
isa_if->end_codegeneration();
pmap_destroy(env->ent_trampoline_map);
pmap_destroy(env->ent_pic_symbol_map);
free_type(env->pic_trampolines_type);
......
......@@ -41,6 +41,8 @@
#include "lowering.h"
#include "panic.h"
pmap *ia32_tv_ent; /**< A map of entities that store const tarvals */
ir_mode *ia32_mode_fpcw;
ir_mode *ia32_mode_flags;
ir_mode *ia32_mode_E;
......@@ -1439,22 +1441,14 @@ static void ia32_finish(void)
obstack_free(&opcodes_obst, NULL);
}
static arch_env_t *ia32_begin_codegeneration(void)
static void ia32_begin_codegeneration(void)
{
ia32_isa_t *isa = XMALLOC(ia32_isa_t);
isa->tv_ent = pmap_create();
return &isa->base;
ia32_tv_ent = pmap_create();
}
/**
* Closes the output file and frees the ISA structure.
*/
static void ia32_end_codegeneration(void *self)
static void ia32_end_codegeneration(void)
{
ia32_isa_t *isa = (ia32_isa_t*)self;
pmap_destroy(isa->tv_ent);
free(self);
pmap_destroy(ia32_tv_ent);
}
static void ia32_mark_remat(ir_node *node)
......
......@@ -34,13 +34,7 @@ typedef struct ia32_irg_data_t {
ir_node *get_eip; /**< get eip node */
} ia32_irg_data_t;
/**
* IA32 ISA object
*/
typedef struct ia32_isa_t {
arch_env_t base; /**< must be derived from arch_env_t */
pmap *tv_ent; /**< A map of entities that store const tarvals */
} ia32_isa_t;
extern pmap *ia32_tv_ent; /**< A map of entities that store const tarvals */
/** The mode for the floating point control word. */
extern ir_mode *ia32_mode_fpcw;
......
......@@ -77,7 +77,7 @@ static void ia32_transform_sub_to_neg_add(ir_node *irn)
res = new_bd_ia32_xXor(dbgi, block, noreg, noreg, nomem, in2, noreg_fp);
int size = get_mode_size_bits(op_mode);
ir_entity *entity = ia32_gen_fp_known_const(irg, size == 32 ? ia32_SSIGN : ia32_DSIGN);
ir_entity *entity = ia32_gen_fp_known_const(size == 32 ? ia32_SSIGN : ia32_DSIGN);
set_ia32_am_ent(res, entity);
set_ia32_op_type(res, ia32_AddrModeS);
set_ia32_ls_mode(res, op_mode);
......
......@@ -301,7 +301,7 @@ static ir_type *get_prim_type(const ir_mode *mode)
}
}
static ir_entity *create_float_const_entity(ir_graph *const irg, ir_tarval *tv, ident *name)
static ir_entity *create_float_const_entity(ir_tarval *tv, ident *name)
{
ir_mode *mode = get_tarval_mode(tv);
if (!ia32_cg_config.use_sse2) {
......@@ -319,8 +319,7 @@ static ir_entity *create_float_const_entity(ir_graph *const irg, ir_tarval *tv,
}
}
ia32_isa_t *const isa = (ia32_isa_t*)be_get_irg_arch_env(irg);
ir_entity *res = pmap_get(ir_entity, isa->tv_ent, tv);
ir_entity *res = pmap_get(ir_entity, ia32_tv_ent, tv);
if (!res) {
if (!name)
name = id_unique("C%u");
......@@ -334,7 +333,7 @@ static ir_entity *create_float_const_entity(ir_graph *const irg, ir_tarval *tv,
ir_initializer_t *const initializer = create_initializer_tarval(tv);
set_entity_initializer(res, initializer);
pmap_insert(isa->tv_ent, tv, res);
pmap_insert(ia32_tv_ent, tv, res);
}
return res;
}
......@@ -410,7 +409,7 @@ static ir_node *gen_Const(ir_node *node)
}
}
#endif /* CONSTRUCT_SSE_CONST */
ir_entity *const floatent = create_float_const_entity(irg, tv, NULL);
ir_entity *const floatent = create_float_const_entity(tv, NULL);
ir_node *base = get_global_base(irg);
load = new_bd_ia32_xLoad(dbgi, block, base, noreg_GP, nomem,
......@@ -429,7 +428,7 @@ static ir_node *gen_Const(ir_node *node)
load = new_bd_ia32_fld1(dbgi, block);
res = load;
} else {
ir_entity *const floatent = create_float_const_entity(irg, tv, NULL);
ir_entity *const floatent = create_float_const_entity(tv, NULL);
/* create_float_const_ent is smart and sometimes creates
smaller entities */
ir_mode *ls_mode = get_type_mode(get_entity_type(floatent));
......@@ -537,7 +536,7 @@ static ir_type *ia32_create_float_array(ir_type *tp)
}
/* Generates an entity for a known FP const (used for FP Neg + Abs) */
ir_entity *ia32_gen_fp_known_const(ir_graph *const irg, ia32_known_const_t kct)
ir_entity *ia32_gen_fp_known_const(ia32_known_const_t const kct)
{
static const struct {
const char *name;
......@@ -583,7 +582,7 @@ ir_entity *ia32_gen_fp_known_const(ir_graph *const irg, ia32_known_const_t kct)
create_initializer_tarval(tv));
set_entity_initializer(ent, initializer);
} else {
ent = create_float_const_entity(irg, tv, name);
ent = create_float_const_entity(tv, name);
}
/* cache the entry */
ent_cache[kct] = ent;
......@@ -812,7 +811,7 @@ static void build_address(ia32_address_mode_t *am, ir_node *node,
if (is_Const(node)) {
ir_graph *const irg = get_irn_irg(node);
ir_tarval *const tv = get_Const_tarval(node);
ir_entity *const entity = create_float_const_entity(irg, tv, NULL);
ir_entity *const entity = create_float_const_entity(tv, NULL);
addr->base = get_global_base(irg);
addr->index = noreg_GP;
addr->mem = nomem;
......@@ -2085,7 +2084,7 @@ static ir_node *gen_Minus(ir_node *node)
new_node = new_bd_ia32_xXor(dbgi, block, base, noreg_GP, nomem, new_op, noreg_xmm);
int size = get_mode_size_bits(mode);
ir_entity *ent = ia32_gen_fp_known_const(irg, size == 32 ? ia32_SSIGN : ia32_DSIGN);
ir_entity *ent = ia32_gen_fp_known_const(size == 32 ? ia32_SSIGN : ia32_DSIGN);
set_ia32_am_ent(new_node, ent);
set_ia32_op_type(new_node, ia32_AddrModeS);
......@@ -2131,7 +2130,7 @@ static ir_node *create_float_abs(dbg_info *dbgi, ir_node *new_block, ir_node *op
new_node = new_bd_ia32_xAnd(dbgi, new_block, base, noreg_GP, nomem, new_op, noreg_fp);
int size = get_mode_size_bits(mode);
ir_entity *ent = ia32_gen_fp_known_const(irg, size == 32 ? ia32_SABS : ia32_DABS);
ir_entity *ent = ia32_gen_fp_known_const(size == 32 ? ia32_SABS : ia32_DABS);
set_ia32_am_ent(new_node, ent);
......@@ -4654,7 +4653,7 @@ static ir_node *gen_ia32_l_LLtoFloat(ir_node *node)
am.addr.mem = nomem;
am.addr.offset = 0;
am.addr.scale = 2;
am.addr.entity = ia32_gen_fp_known_const(irg, ia32_ULLBIAS);
am.addr.entity = ia32_gen_fp_known_const(ia32_ULLBIAS);
am.addr.tls_segment = false;
am.addr.use_frame = 0;
am.addr.frame_entity = NULL;
......
......@@ -39,7 +39,7 @@ typedef enum {
/**
* Generate a known floating point constant
*/
ir_entity *ia32_gen_fp_known_const(ir_graph *irg, ia32_known_const_t kct);
ir_entity *ia32_gen_fp_known_const(ia32_known_const_t kct);
/**
* Skip all Down-Conv's on a given node and return the resulting node.
......
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