X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fsparc%2Fbearch_sparc.c;h=078fdfad779c6582e2c798cd56a2c33ef352c80b;hb=3f1d2fb001738ccea94f601a71a21d6dbf8ad8a9;hp=2f1920cf8d047fd3d19cd8f12c6d9378c5efeb73;hpb=928a879210b0c17d756227d7f6f309ca617337d4;p=libfirm diff --git a/ir/be/sparc/bearch_sparc.c b/ir/be/sparc/bearch_sparc.c index 2f1920cf8..078fdfad7 100644 --- a/ir/be/sparc/bearch_sparc.c +++ b/ir/be/sparc/bearch_sparc.c @@ -21,7 +21,6 @@ * @file * @brief The main sparc backend driver file. * @author Hannes Rapp, Matthias Braun - * @version $Id$ */ #include "config.h" @@ -37,10 +36,13 @@ #include "iroptimize.h" #include "irtools.h" #include "irdump.h" +#include "iropt_t.h" #include "lowering.h" #include "lower_dw.h" +#include "lower_alloc.h" #include "lower_builtins.h" #include "lower_calls.h" +#include "lower_mode_b.h" #include "lower_softfloat.h" #include "bitset.h" @@ -49,18 +51,17 @@ #include "error.h" #include "util.h" -#include "../bearch.h" -#include "../benode.h" -#include "../belower.h" -#include "../besched.h" +#include "bearch.h" +#include "benode.h" +#include "belower.h" +#include "besched.h" #include "be.h" -#include "../bemachine.h" -#include "../bemodule.h" -#include "../beirg.h" -#include "../begnuas.h" -#include "../belistsched.h" -#include "../beflags.h" -#include "../beutil.h" +#include "bemodule.h" +#include "beirg.h" +#include "begnuas.h" +#include "belistsched.h" +#include "beflags.h" +#include "beutil.h" #include "bearch_sparc_t.h" @@ -349,22 +350,24 @@ static void sparc_handle_intrinsics(void) /** * Initializes the backend ISA */ -static arch_env_t *sparc_init(FILE *outfile) +static arch_env_t *sparc_init(const be_main_env_t *env) { sparc_isa_t *isa = XMALLOC(sparc_isa_t); *isa = sparc_isa_template; isa->constants = pmap_create(); be_gas_elf_type_char = '#'; - be_gas_object_file_format = OBJECT_FILE_FORMAT_ELF_SPARC; - - be_emit_init(outfile); + be_gas_object_file_format = OBJECT_FILE_FORMAT_ELF; + be_gas_elf_variant = ELF_VARIANT_SPARC; sparc_register_init(); sparc_create_opcodes(&sparc_irn_ops); sparc_handle_intrinsics(); sparc_cconv_init(); + be_emit_init(env->file_handle); + be_gas_begin_compilation_unit(env); + return &isa->base; } @@ -376,52 +379,26 @@ static void sparc_done(void *self) sparc_isa_t *isa = (sparc_isa_t*)self; /* emit now all global declarations */ - be_gas_emit_decls(isa->base.main_env); + be_gas_end_compilation_unit(isa->base.main_env); pmap_destroy(isa->constants); be_emit_exit(); free(isa); } - -/** - * Get the register class which shall be used to store a value of a given mode. - * @param self The this pointer. - * @param mode The mode in question. - * @return A register class which can hold values of the given mode. - */ -static const arch_register_class_t *sparc_get_reg_class_for_mode(const ir_mode *mode) -{ - if (mode_is_float(mode)) - return &sparc_reg_classes[CLASS_sparc_fp]; - else - return &sparc_reg_classes[CLASS_sparc_gp]; -} - -/** - * Returns the necessary byte alignment for storing a register of given class. - */ -static int sparc_get_reg_class_alignment(const arch_register_class_t *cls) -{ - ir_mode *mode = arch_register_class_mode(cls); - return get_mode_size_bytes(mode); -} - -static ir_node *sparc_create_set(ir_node *cond) -{ - return ir_create_cond_set(cond, mode_Iu); -} - static void sparc_lower_for_target(void) { size_t i, n_irgs = get_irp_n_irgs(); - lower_mode_b_config_t lower_mode_b_config = { - mode_Iu, - sparc_create_set, - 0, - }; + lower_calls_with_compounds(LF_RETURN_HIDDEN); + for (i = 0; i < n_irgs; ++i) { + ir_graph *irg = get_irp_irg(i); + /* Turn all small CopyBs into loads/stores and all bigger CopyBs into + * memcpy calls. */ + lower_CopyB(irg, 31, 32, false); + } + if (sparc_isa_template.fpu_arch == SPARC_FPU_ARCH_SOFTFLOAT) lower_floating_point(); @@ -431,26 +408,16 @@ static void sparc_lower_for_target(void) for (i = 0; i < n_irgs; ++i) { ir_graph *irg = get_irp_irg(i); - ir_lower_mode_b(irg, &lower_mode_b_config); + ir_lower_mode_b(irg, mode_Iu); lower_switch(irg, 4, 256, false); + lower_alloc(irg, SPARC_STACK_ALIGNMENT, false, SPARC_MIN_STACKSIZE); } } static int sparc_is_mux_allowed(ir_node *sel, ir_node *mux_false, ir_node *mux_true) { - ir_graph *irg = get_irn_irg(sel); - ir_mode *mode = get_irn_mode(mux_true); - - if (get_irg_phase_state(irg) == phase_low) - return false; - - if (!mode_is_int(mode) && !mode_is_reference(mode) && mode != mode_b) - return false; - if (is_Const(mux_true) && is_Const_one(mux_true) && - is_Const(mux_false) && is_Const_null(mux_false)) - return true; - return false; + return ir_is_optimizable_mux(sel, mux_false, mux_true); } /** @@ -487,32 +454,27 @@ static const backend_params *sparc_get_backend_params(void) }; ir_mode *mode_long_long - = new_ir_mode("long long", irms_int_number, 64, 1, irma_twos_complement, - 64); + = new_int_mode("long long", irma_twos_complement, 64, 1, 64); ir_type *type_long_long = new_type_primitive(mode_long_long); ir_mode *mode_unsigned_long_long - = new_ir_mode("unsigned long long", irms_int_number, 64, 0, - irma_twos_complement, 64); + = new_int_mode("unsigned long long", irma_twos_complement, 64, 0, 64); ir_type *type_unsigned_long_long = new_type_primitive(mode_unsigned_long_long); - ir_mode *mode_long_double - = new_ir_mode("long double", irms_float_number, 128, 1, - irma_ieee754, 0); - ir_type *type_long_double = new_type_primitive(mode_long_double); - set_type_alignment_bytes(type_long_double, 8); - p.type_long_double = type_long_double; p.type_long_long = type_long_long; p.type_unsigned_long_long = type_unsigned_long_long; - return &p; -} -static ir_graph **sparc_get_backend_irg_list(const void *self, - ir_graph ***irgs) -{ - (void) self; - (void) irgs; - return NULL; + if (sparc_isa_template.fpu_arch == SPARC_FPU_ARCH_SOFTFLOAT) { + p.mode_float_arithmetic = NULL; + p.type_long_double = NULL; + } else { + ir_type *type_long_double = new_type_primitive(mode_Q); + + set_type_alignment_bytes(type_long_double, 8); + set_type_size_bytes(type_long_double, 16); + p.type_long_double = type_long_double; + } + return &p; } static asm_constraint_flags_t sparc_parse_asm_constraint(const char **c) @@ -590,11 +552,8 @@ const arch_isa_if_t sparc_isa_if = { sparc_lower_for_target, sparc_done, NULL, /* handle intrinsics */ - sparc_get_reg_class_for_mode, NULL, - sparc_get_reg_class_alignment, sparc_get_backend_params, - sparc_get_backend_irg_list, NULL, /* mark remat */ sparc_parse_asm_constraint, sparc_is_valid_clobber,