Commit 3d6ab117 authored by Matthias Braun's avatar Matthias Braun
Browse files

Rework setting some OS details

The idea here, is that you do not simply set a target operating system
or architecture, but have a setting for all things different between the
operating systems. Knowledge about the name and habits of the operating
system is left to the frontend.
(We may want to provide a small support library in the future to share
the triple parsing and OS -> settings code between multiple frontends).
parent 7a43347c
......@@ -232,9 +232,9 @@ static void emit_line_info(void)
be_gas_emit_switch_section(GAS_SECTION_DEBUG_LINE);
emit_label("line_section_begin");
/* on elf systems gas handles producing the line info for us, and we don't
/* on some systems gas handles producing the line info for us, and we don't
* have to do anything */
if (be_gas_object_file_format != OBJECT_FILE_FORMAT_ELF) {
if (!be_gas_produces_dwarf_line_info()) {
emit_size("line_info_begin", "line_info_end");
emit_label("line_info_begin");
......
......@@ -11,30 +11,39 @@
*/
#include "begnuas.h"
#include <assert.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <assert.h>
#include "obst.h"
#include "tv.h"
#include "be_t.h"
#include "bearch.h"
#include "bedwarf.h"
#include "beemitter.h"
#include "bemodule.h"
#include "entity_t.h"
#include "execfreq.h"
#include "irnode.h"
#include "irprog.h"
#include "entity_t.h"
#include "irtools.h"
#include "lc_opts_enum.h"
#include "obst.h"
#include "panic.h"
#include "tv.h"
#include "util.h"
#include "execfreq.h"
#include "be_t.h"
#include "bearch.h"
#include "beemitter.h"
#include "bedwarf.h"
typedef enum object_file_format_t {
OBJECT_FILE_FORMAT_ELF, /**< Executable and Linkable Format (unixes) */
OBJECT_FILE_FORMAT_COFF, /**< Common Object File Format (Windows) */
OBJECT_FILE_FORMAT_MACH_O, /**< Mach Object File Format (OS/X) */
OBJECT_FILE_FORMAT_LAST = OBJECT_FILE_FORMAT_MACH_O
} object_file_format_t;
/** by default, we generate assembler code for the Linux gas */
object_file_format_t be_gas_object_file_format = OBJECT_FILE_FORMAT_ELF;
elf_variant_t be_gas_elf_variant = ELF_VARIANT_NORMAL;
bool be_gas_emit_types = true;
char be_gas_elf_type_char = '@';
static object_file_format_t be_gas_object_file_format = OBJECT_FILE_FORMAT_ELF;
elf_variant_t be_gas_elf_variant = ELF_VARIANT_NORMAL;
bool be_gas_emit_types = true;
char be_gas_elf_type_char = '@';
static be_gas_section_t current_section = (be_gas_section_t) -1;
static pmap *block_numbers;
......@@ -1562,6 +1571,11 @@ static void emit_global_asms(void)
}
}
bool be_gas_produces_dwarf_line_info(void)
{
return be_gas_object_file_format == OBJECT_FILE_FORMAT_ELF;
}
void be_gas_begin_compilation_unit(const be_main_env_t *env)
{
be_dwarf_open();
......@@ -1582,3 +1596,25 @@ void be_gas_end_compilation_unit(const be_main_env_t *env)
be_dwarf_unit_end();
be_dwarf_close();
}
BE_REGISTER_MODULE_CONSTRUCTOR(be_init_gas)
void be_init_gas(void)
{
static const lc_opt_enum_int_items_t objectformat_items[] = {
{ "elf", OBJECT_FILE_FORMAT_ELF },
{ "coff", OBJECT_FILE_FORMAT_COFF },
{ "mach-o", OBJECT_FILE_FORMAT_MACH_O },
{ NULL, 0 },
};
static lc_opt_enum_int_var_t format_var = {
(int*)&be_gas_object_file_format, objectformat_items
};
static const lc_opt_table_entry_t be_gas_options[] = {
LC_OPT_ENT_ENUM_INT("objectformat", "object file format",
&format_var),
LC_OPT_LAST
};
lc_opt_entry_t *be_grp = lc_opt_get_grp(firm_opt_get_root(), "be");
lc_opt_add_table(be_grp, be_gas_options);
}
......@@ -41,22 +41,13 @@ typedef enum {
} be_gas_section_t;
ENUM_BITSET(be_gas_section_t)
typedef enum object_file_format_t {
OBJECT_FILE_FORMAT_ELF, /**< Executable and Linkable Format (unixes) */
OBJECT_FILE_FORMAT_COFF, /**< Common Object File Format (Windows) */
OBJECT_FILE_FORMAT_MACH_O, /**< Mach Object File Format (OS/X) */
OBJECT_FILE_FORMAT_LAST = OBJECT_FILE_FORMAT_MACH_O
} object_file_format_t;
typedef enum elf_variant_t {
ELF_VARIANT_NORMAL,
ELF_VARIANT_SPARC
} elf_variant_t;
/** The variable where the GAS dialect is stored. */
extern object_file_format_t be_gas_object_file_format;
extern bool be_gas_emit_types;
extern elf_variant_t be_gas_elf_variant;
extern bool be_gas_emit_types;
extern elf_variant_t be_gas_elf_variant;
/**
* the .type directive needs to specify @function, #function or %function
......@@ -138,4 +129,6 @@ void be_emit_jump_table(const ir_node *node, const ir_switch_table *table,
ir_entity *entity,
get_cfop_target_func get_cfop_target);
bool be_gas_produces_dwarf_line_info(void);
#endif
......@@ -41,6 +41,7 @@ void be_init_copyopt(void);
void be_init_copystat(void);
void be_init_daemelspill(void);
void be_init_dwarf(void);
void be_init_gas(void);
void be_init_listsched(void);
void be_init_live(void);
void be_init_loopana(void);
......@@ -79,6 +80,7 @@ void be_init_modules(void)
be_init_copyopt();
be_init_copystat();
be_init_dwarf();
be_init_gas();
be_init_live();
be_init_loopana();
be_init_peephole();
......
......@@ -58,6 +58,7 @@ static ir_entity *old_bp_ent;
static ir_entity *ret_addr_ent;
static ir_entity *omit_fp_ret_addr_ent;
static bool precise_x87_spills;
static bool return_small_struct_in_regs;
typedef ir_node *(*create_const_node_func) (dbg_info *dbgi, ir_node *block);
......@@ -1471,13 +1472,12 @@ static void ia32_lower_for_target(void)
* have hidden parameters but know where to find the structs on the stack.
* (This also forces us to always allocate space for the compound arguments
* on the callframe and we can't just use an arbitrary position on the
* stackframe)
*/
bool darwin_abi = be_gas_object_file_format == OBJECT_FILE_FORMAT_MACH_O;
* stackframe) */
compound_call_lowering_flags lower_call_flags
= LF_RETURN_HIDDEN | LF_DONT_LOWER_ARGUMENTS
| LF_RETURN_SMALL_ARRAY_IN_INTS
| (darwin_abi ? LF_RETURN_SMALL_STRUCT_IN_INTS : LF_NONE);
| (return_small_struct_in_regs ? LF_RETURN_SMALL_STRUCT_IN_INTS
: LF_NONE);
lower_calls_with_compounds(lower_call_flags);
be_after_irp_transform("lower-calls");
......@@ -1544,21 +1544,12 @@ static const backend_params *ia32_get_libfirm_params(void)
return &ia32_backend_params;
}
static const lc_opt_enum_int_items_t gas_items[] = {
{ "elf", OBJECT_FILE_FORMAT_ELF },
{ "mingw", OBJECT_FILE_FORMAT_COFF },
{ "macho", OBJECT_FILE_FORMAT_MACH_O },
{ NULL, 0 }
};
static lc_opt_enum_int_var_t gas_var = {
(int*) &be_gas_object_file_format, gas_items
};
static const lc_opt_table_entry_t ia32_options[] = {
LC_OPT_ENT_ENUM_INT("gasmode", "set the GAS compatibility mode", &gas_var),
LC_OPT_ENT_BOOL("gprof", "create gprof profiling code", &gprof),
LC_OPT_ENT_BOOL("gprof", "Create gprof profiling code", &gprof),
LC_OPT_ENT_BOOL("precise_float_spill", "Spill floatingpoint values precisely (the whole 80 bits)", &precise_x87_spills),
LC_OPT_ENT_BOOL("struct_in_reg",
"Return small structs in integer registers",
&return_small_struct_in_regs),
LC_OPT_LAST
};
......
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