Commit 3d2b5b38 authored by Michael Beck's avatar Michael Beck
Browse files

Replaced pmaps used for 16 and 8bit register names by simple array lookups.

[r28146]
parent a73a2f92
......@@ -1539,9 +1539,6 @@ static arch_env_t *ia32_init(FILE *file_handle)
ia32_create_opcodes(&ia32_irn_ops);
be_emit_init(file_handle);
isa->regs_16bit = pmap_create();
isa->regs_8bit = pmap_create();
isa->regs_8bit_high = pmap_create();
isa->types = pmap_create();
isa->tv_ent = pmap_create();
isa->cpu = ia32_init_machine_description();
......@@ -1581,9 +1578,6 @@ static void ia32_done(void *self)
/* emit now all global declarations */
be_gas_emit_decls(isa->base.main_env);
pmap_destroy(isa->regs_16bit);
pmap_destroy(isa->regs_8bit);
pmap_destroy(isa->regs_8bit_high);
pmap_destroy(isa->tv_ent);
pmap_destroy(isa->types);
......
......@@ -36,6 +36,7 @@
#include "be.h"
#include "../bemachine.h"
#include "../beemitter.h"
#include "gen_ia32_regalloc_if.h"
#ifdef NDEBUG
#define SET_IA32_ORIG_NODE(n, o)
......@@ -63,13 +64,14 @@ typedef struct ia32_irg_data_t {
* IA32 ISA object
*/
struct ia32_isa_t {
arch_env_t base; /**< must be derived from arch_env_t */
pmap *regs_16bit; /**< Contains the 16bits names of the gp registers */
pmap *regs_8bit; /**< Contains the 8bits names of the gp registers */
pmap *regs_8bit_high; /**< contains the high part of the 8 bit names of the gp registers */
pmap *types; /**< A map of modes to primitive types */
pmap *tv_ent; /**< A map of entities that store const tarvals */
const be_machine_t *cpu; /**< the abstract machine */
arch_env_t base; /**< must be derived from arch_env_t */
pmap *types; /**< A map of modes to primitivetypes */
pmap *tv_ent; /**< A map of entities that store const tarvals */
const be_machine_t *cpu; /**< the abstract machine */
const char *regs_32bit[N_ia32_gp_REGS]; /**< Contains the 32bits names of the gp registers */
const char *regs_16bit[N_ia32_gp_REGS]; /**< Contains the 16bits names of the gp registers */
const char *regs_8bit[N_ia32_gp_REGS]; /**< Contains the 8bits names of the gp registers */
const char *regs_8bit_high[N_ia32_gp_REGS]; /**< contains the high partof the 8 bit names of the gp registers */
};
/**
......
......@@ -39,43 +39,47 @@
/* this is the order of the assigned registers used for parameter passing */
void ia32_build_16bit_reg_map(pmap *reg_map)
void ia32_build_16bit_reg_map(const char *reg_map[])
{
pmap_insert(reg_map, &ia32_registers[REG_EAX], (void*)"ax");
pmap_insert(reg_map, &ia32_registers[REG_EBX], (void*)"bx");
pmap_insert(reg_map, &ia32_registers[REG_ECX], (void*)"cx");
pmap_insert(reg_map, &ia32_registers[REG_EDX], (void*)"dx");
pmap_insert(reg_map, &ia32_registers[REG_ESI], (void*)"si");
pmap_insert(reg_map, &ia32_registers[REG_EDI], (void*)"di");
pmap_insert(reg_map, &ia32_registers[REG_EBP], (void*)"bp");
pmap_insert(reg_map, &ia32_registers[REG_ESP], (void*)"sp");
memset(reg_map, 0, sizeof(reg_map[0]) * N_ia32_gp_REGS);
reg_map[REG_GP_EAX] = "ax";
reg_map[REG_GP_EBX] = "bx";
reg_map[REG_GP_ECX] = "cx";
reg_map[REG_GP_EDX] = "dx";
reg_map[REG_GP_ESI] = "si";
reg_map[REG_GP_EDI] = "di";
reg_map[REG_GP_EBP] = "bp";
reg_map[REG_GP_ESP] = "sp";
}
void ia32_build_8bit_reg_map(pmap *reg_map)
void ia32_build_8bit_reg_map(const char *reg_map[])
{
pmap_insert(reg_map, &ia32_registers[REG_EAX], (void*)"al");
pmap_insert(reg_map, &ia32_registers[REG_EBX], (void*)"bl");
pmap_insert(reg_map, &ia32_registers[REG_ECX], (void*)"cl");
pmap_insert(reg_map, &ia32_registers[REG_EDX], (void*)"dl");
memset(reg_map, 0, sizeof(reg_map[0]) * N_ia32_gp_REGS);
reg_map[REG_GP_EAX] = "al";
reg_map[REG_GP_EBX] = "bl";
reg_map[REG_GP_ECX] = "cl";
reg_map[REG_GP_EDX] = "dl";
}
void ia32_build_8bit_reg_map_high(pmap *reg_map)
void ia32_build_8bit_reg_map_high(const char *reg_map[])
{
pmap_insert(reg_map, &ia32_registers[REG_EAX], (void*)"ah");
pmap_insert(reg_map, &ia32_registers[REG_EBX], (void*)"bh");
pmap_insert(reg_map, &ia32_registers[REG_ECX], (void*)"ch");
pmap_insert(reg_map, &ia32_registers[REG_EDX], (void*)"dh");
memset(reg_map, 0, sizeof(reg_map[0]) * N_ia32_gp_REGS);
reg_map[REG_GP_EAX], "ah";
reg_map[REG_GP_EBX], "bh";
reg_map[REG_GP_ECX], "ch";
reg_map[REG_GP_EDX], "dh";
}
const char *ia32_get_mapped_reg_name(pmap *reg_map, const arch_register_t *reg)
const char *ia32_get_mapped_reg_name(const char *reg_map[], const arch_register_t *reg)
{
pmap_entry *e = pmap_find(reg_map, (void *)reg);
const char *name = reg_map[reg->index];
assert(reg->reg_class->index == CLASS_ia32_gp);
//assert(e && "missing map init?");
if (! e) {
//assert(name && "missing map init?");
if (! name) {
printf("FIXME: ia32map_regs.c:122: returning fake register name for ia32 with 32 register\n");
return reg->name;
}
return (const char*)e->value;
return name;
}
......@@ -36,20 +36,20 @@
/**
* Enters for each general purpose register the corresponding 16bit
* name into a pmap.
* name into a map.
*/
void ia32_build_16bit_reg_map(pmap *reg_map);
void ia32_build_16bit_reg_map(const char *reg_map[]);
/**
* Enters for each general purpose register the corresponding 8bit
* name into a pmap.
* name into a map.
*/
void ia32_build_8bit_reg_map(pmap *reg_map);
void ia32_build_8bit_reg_map_high(pmap *reg_map);
void ia32_build_8bit_reg_map(const char *reg_map[]);
void ia32_build_8bit_reg_map_high(const char *reg_map[]);
/**
* Returns the corresponding mapped name for a register.
*/
const char *ia32_get_mapped_reg_name(pmap *reg_map, const arch_register_t *reg);
const char *ia32_get_mapped_reg_name(const char *reg_map[], const arch_register_t *reg);
#endif
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