summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJonas Haag <jonas@lophus.org>2015-08-17 17:21:29 +0200
committerPhilipp Serrer <philipp@serrer.de>2018-01-18 17:51:51 +0100
commit32e9c21d875034326dad39a914f00c0e3843ef37 (patch)
tree3ecfe195f779bafd8155492d6bd07a44efa73749
parenteb80375e0c334eba0d1275663168b9bf2649b442 (diff)
Add '-fexceptions' option
-rw-r--r--ir/be/be_t.h1
-rw-r--r--ir/be/bedwarf.c56
-rw-r--r--ir/be/begnuas.h3
-rw-r--r--ir/be/bemain.c2
4 files changed, 37 insertions, 25 deletions
diff --git a/ir/be/be_t.h b/ir/be/be_t.h
index 90c82a1..d3c87c8 100644
--- a/ir/be/be_t.h
+++ b/ir/be/be_t.h
@@ -38,6 +38,7 @@ struct be_options_t {
bool opt_profile_generate; /**< instrument code for profiling */
bool opt_profile_use; /**< use existing profile data */
bool omit_fp; /**< try to omit the frame pointer */
+ bool exceptions; /**< enable exception handling */
bool do_verify; /**< backend verify option */
char ilp_solver[128]; /**< the ilp solver name */
bool verbose_asm; /**< dump verbose assembler */
diff --git a/ir/be/bedwarf.c b/ir/be/bedwarf.c
index f189258..c2cbf67 100644
--- a/ir/be/bedwarf.c
+++ b/ir/be/bedwarf.c
@@ -11,6 +11,7 @@
#include "bedwarf_t.h"
#include "array.h"
+#include "be_t.h"
#include "bearch.h"
#include "beemitter.h"
#include "begnuas.h"
@@ -303,6 +304,11 @@ static void emit_pubnames(void)
emit_label("pubnames_end");
}
+static bool should_emit_frameinfo(void)
+{
+ return be_options.exceptions || debug_level >= LEVEL_FRAMEINFO;
+}
+
void be_dwarf_location(dbg_info *dbgi)
{
if (debug_level < LEVEL_LOCATIONS)
@@ -318,29 +324,29 @@ void be_dwarf_location(dbg_info *dbgi)
void be_dwarf_callframe_register(const arch_register_t *reg)
{
- if (debug_level < LEVEL_FRAMEINFO)
- return;
- be_emit_cstring("\t.cfi_def_cfa_register ");
- be_emit_irprintf("%d\n", reg->dwarf_number);
- be_emit_write_line();
+ if (should_emit_frameinfo()) {
+ be_emit_cstring("\t.cfi_def_cfa_register ");
+ be_emit_irprintf("%d\n", reg->dwarf_number);
+ be_emit_write_line();
+ }
}
void be_dwarf_callframe_offset(int offset)
{
- if (debug_level < LEVEL_FRAMEINFO)
- return;
- be_emit_cstring("\t.cfi_def_cfa_offset ");
- be_emit_irprintf("%d\n", offset);
- be_emit_write_line();
+ if (should_emit_frameinfo()) {
+ be_emit_cstring("\t.cfi_def_cfa_offset ");
+ be_emit_irprintf("%d\n", offset);
+ be_emit_write_line();
+ }
}
void be_dwarf_callframe_spilloffset(const arch_register_t *reg, int offset)
{
- if (debug_level < LEVEL_FRAMEINFO)
- return;
- be_emit_cstring("\t.cfi_offset ");
- be_emit_irprintf("%d, %d\n", reg->dwarf_number, offset);
- be_emit_write_line();
+ if (should_emit_frameinfo()) {
+ be_emit_cstring("\t.cfi_offset ");
+ be_emit_irprintf("%d, %d\n", reg->dwarf_number, offset);
+ be_emit_write_line();
+ }
}
static bool is_extern_entity(const ir_entity *entity)
@@ -503,21 +509,21 @@ void be_dwarf_function_before(const ir_entity *entity,
void be_dwarf_function_begin(void)
{
- if (debug_level < LEVEL_FRAMEINFO)
- return;
- be_emit_cstring("\t.cfi_startproc\n");
- be_emit_write_line();
+ if (should_emit_frameinfo()) {
+ be_emit_cstring("\t.cfi_startproc\n");
+ be_emit_write_line();
+ }
}
void be_dwarf_function_end(void)
{
- if (debug_level < LEVEL_BASIC)
- return;
- const ir_entity *entity = env.cur_ent;
- be_emit_irprintf("%sfunction_end_%s:\n", be_gas_get_private_prefix(),
- get_entity_ld_name(entity));
+ if (debug_level >= LEVEL_BASIC) {
+ const ir_entity *entity = env.cur_ent;
+ be_emit_irprintf("%sfunction_end_%s:\n", be_gas_get_private_prefix(),
+ get_entity_ld_name(entity));
+ }
- if (debug_level >= LEVEL_FRAMEINFO) {
+ if (should_emit_frameinfo()) {
be_emit_cstring("\t.cfi_endproc\n");
be_emit_write_line();
}
diff --git a/ir/be/begnuas.h b/ir/be/begnuas.h
index 27c04fe..81ab009 100644
--- a/ir/be/begnuas.h
+++ b/ir/be/begnuas.h
@@ -56,6 +56,9 @@ extern elf_variant_t be_gas_elf_variant;
*/
extern char be_gas_elf_type_char;
+/** emit cfi directives required for exception handling */
+extern bool be_gas_emit_cfi_directives;
+
/**
* Switch the current output section to the given out.
*
diff --git a/ir/be/bemain.c b/ir/be/bemain.c
index c4b3972..81aa566 100644
--- a/ir/be/bemain.c
+++ b/ir/be/bemain.c
@@ -60,6 +60,7 @@ be_options_t be_options = {
.opt_profile_generate = false,
.opt_profile_use = false,
.omit_fp = false,
+ .exceptions = false,
.do_verify = true,
.ilp_solver = "",
.verbose_asm = true,
@@ -85,6 +86,7 @@ static lc_opt_enum_mask_var_t dump_var = {
static const lc_opt_table_entry_t be_main_options[] = {
LC_OPT_ENT_ENUM_MASK("dump", "dump irg on several occasions", &dump_var),
LC_OPT_ENT_BOOL ("omitfp", "omit frame pointer", &be_options.omit_fp),
+ LC_OPT_ENT_BOOL ("exceptions", "enable exception handling", &be_options.exceptions),
LC_OPT_ENT_BOOL ("verify", "verify the backend irg", &be_options.do_verify),
LC_OPT_ENT_BOOL ("time", "get backend timing statistics", &be_options.timing),
LC_OPT_ENT_BOOL ("profilegenerate", "instrument the code for execution count profiling", &be_options.opt_profile_generate),