Commit 2c7355ad authored by Matthias Braun's avatar Matthias Braun
Browse files

change LC_OPT_ENT_BOOL to take a bool instead of an int destination

parent a716ff6a
......@@ -12,6 +12,7 @@
#define FIRM_BE_BE_T_H
#include <assert.h>
#include <stdbool.h>
#include "be.h"
#include "be_types.h"
......@@ -30,23 +31,18 @@ enum {
DUMP_BE = 1 << 6
};
enum {
BE_TIME_OFF,
BE_TIME_ON
};
/** Backend options */
struct be_options_t {
unsigned dump_flags; /**< backend dumping flags */
int timing; /**< time the backend phases */
int opt_profile_generate; /**< instrument code for profiling */
int opt_profile_use; /**< use existing profile data */
int omit_fp; /**< try to omit the frame pointer */
int pic; /**< create position independent code */
int do_verify; /**< backend verify option */
bool timing; /**< time the backend phases */
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 pic; /**< create position independent code */
bool do_verify; /**< backend verify option */
char ilp_server[128]; /**< the ilp server name */
char ilp_solver[128]; /**< the ilp solver name */
int verbose_asm; /**< dump verbose assembler */
bool verbose_asm; /**< dump verbose assembler */
};
extern be_options_t be_options;
......
......@@ -28,8 +28,8 @@
#define DUMP_ILP 1
static int time_limit = 60;
static int solve_log = 0;
static int time_limit = 60;
static bool solve_log = false;
static unsigned dump_flags = 0;
static const lc_opt_enum_mask_items_t dump_items[] = {
......@@ -43,8 +43,8 @@ static lc_opt_enum_mask_var_t dump_var = {
static const lc_opt_table_entry_t options[] = {
LC_OPT_ENT_INT ("limit", "time limit for solving in seconds (0 for unlimited)", &time_limit),
LC_OPT_ENT_BOOL ("log", "show ilp solving log", &solve_log),
LC_OPT_ENT_ENUM_MASK("dump", "dump flags", &dump_var),
LC_OPT_ENT_BOOL ("log", "show ilp solving log", &solve_log),
LC_OPT_ENT_ENUM_MASK("dump", "dump flags", &dump_var),
LC_OPT_LAST
};
......
......@@ -87,9 +87,9 @@ static int co_get_costs_all_one(const ir_node *root, int pos);
static unsigned dump_flags = 0;
static unsigned style_flags = CO_IFG_DUMP_COLORS;
static int do_stats = 0;
static bool do_stats = false;
static cost_fct_t cost_func = co_get_costs_exec_freq;
static int improve = 1;
static bool improve = true;
static const lc_opt_enum_mask_items_t dump_items[] = {
{ "before", DUMP_BEFORE },
......
......@@ -42,7 +42,7 @@ enum {
};
static int debug_level = LEVEL_NONE;
static int has_cfi_sections = true;
static bool has_cfi_sections = true;
/**
* Usually we simply use the DW_TAG_xxx numbers for our abbrev IDs, but for
......
......@@ -58,16 +58,16 @@
/* options visible for anyone */
be_options_t be_options = {
DUMP_NONE, /* dump flags */
BE_TIME_OFF, /* no timing */
false, /* profile_generate */
false, /* profile_use */
0, /* try to omit frame pointer */
0, /* create PIC code */
true, /* do verification */
"", /* ilp server */
"", /* ilp solver */
1, /* verbose assembler output */
.dump_flags = DUMP_NONE,
.timing = false,
.opt_profile_generate = false,
.opt_profile_use = false,
.omit_fp = false,
.pic = false,
.do_verify = true,
.ilp_server = "",
.ilp_solver = "",
.verbose_asm = true,
};
/* back end instruction set architecture to use */
......@@ -96,9 +96,9 @@ static const lc_opt_table_entry_t be_main_options[] = {
LC_OPT_ENT_BOOL ("pic", "create PIC code", &be_options.pic),
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),
LC_OPT_ENT_BOOL ("profileuse", "use existing profile data", &be_options.opt_profile_use),
LC_OPT_ENT_BOOL ("verboseasm", "enable verbose assembler output", &be_options.verbose_asm),
LC_OPT_ENT_BOOL ("profilegenerate", "instrument the code for execution count profiling", &be_options.opt_profile_generate),
LC_OPT_ENT_BOOL ("profileuse", "use existing profile data", &be_options.opt_profile_use),
LC_OPT_ENT_BOOL ("verboseasm", "enable verbose assembler output", &be_options.verbose_asm),
LC_OPT_ENT_STR("ilp.server", "the ilp server name", &be_options.ilp_server),
LC_OPT_ENT_STR("ilp.solver", "the ilp solver name", &be_options.ilp_solver),
......@@ -462,7 +462,7 @@ void be_lower_for_target(void)
*/
static void be_main_loop(FILE *file_handle, const char *cup_name)
{
be_timing = (be_options.timing == BE_TIME_ON);
be_timing = be_options.timing;
/* perform target lowering if it didn't happen yet */
if (get_irp_n_irgs() > 0 && !irg_is_constrained(get_irp_irg(0), IR_GRAPH_CONSTRAINT_TARGET_LOWERED))
......@@ -693,7 +693,7 @@ void be_main(FILE *file_handle, const char *cup_name)
{
ir_timer_t *t = NULL;
if (be_options.timing == BE_TIME_ON) {
if (be_options.timing) {
t = ir_timer_new();
if (ir_timer_enter_high_priority()) {
......@@ -715,7 +715,7 @@ void be_main(FILE *file_handle, const char *cup_name)
be_main_loop(file_handle, cup_name);
if (be_options.timing == BE_TIME_ON) {
if (be_options.timing) {
ir_timer_stop(t);
ir_timer_leave_high_priority();
if (stat_ev_enabled) {
......
......@@ -60,8 +60,8 @@
#define DO_USEFUL_OPT 1
static int use_exec_freq = true;
static int use_late_decision = false;
static bool use_exec_freq = true;
static bool use_late_decision = false;
typedef struct be_pbqp_alloc_env_t {
pbqp_t *pbqp_inst; /**< PBQP instance for register allocation */
......
......@@ -29,8 +29,8 @@
#include "lc_opts.h"
#include "lc_opts_enum.h"
int be_coalesce_spill_slots = 1;
int be_do_remats = 1;
bool be_coalesce_spill_slots = true;
bool be_do_remats = true;
static const lc_opt_table_entry_t be_spill_options[] = {
LC_OPT_ENT_BOOL ("coalesce_slots", "coalesce the spill slots", &be_coalesce_spill_slots),
......
......@@ -14,8 +14,8 @@
#include "bearch.h"
extern int be_coalesce_spill_slots;
extern int be_do_remats;
extern bool be_coalesce_spill_slots;
extern bool be_do_remats;
typedef void (*be_spill_func)(ir_graph *irg, const arch_register_class_t *cls);
......
......@@ -73,9 +73,9 @@ static spill_env_t *senv; /**< see bespill.h */
static ir_node **blocklist;
static workset_t *temp_workset;
static int move_spills = true;
static int respectloopdepth = true;
static int improve_known_preds = true;
static bool move_spills = true;
static bool respectloopdepth = true;
static bool improve_known_preds = true;
/* factor to weight the different costs of reloading/rematerializing a node
(see bespill.h be_get_reload_costs_no_weight) */
static int remat_bonus = 10;
......
......@@ -89,7 +89,7 @@ static ir_type *between_type = NULL;
static ir_entity *old_bp_ent = NULL;
static ir_entity *ret_addr_ent = NULL;
static ir_entity *omit_fp_ret_addr_ent = NULL;
static int precise_x87_spills;
static bool precise_x87_spills;
typedef ir_node *(*create_const_node_func) (dbg_info *dbgi, ir_node *block);
......@@ -456,7 +456,7 @@ static const arch_irn_ops_t ia32_irn_ops = {
ia32_perform_memory_operand,
};
static int gprof = 0;
static bool gprof = 0;
static ir_node *ia32_turn_back_dest_am(ir_node *node)
{
......
......@@ -134,23 +134,23 @@ typedef enum cpu_arch_features {
} cpu_arch_features;
ENUM_BITSET(cpu_arch_features)
static int opt_size = 0;
static int emit_machcode = 0;
static int use_softfloat = 0;
static int use_sse = 0;
static int use_sse2 = 0;
static int use_sse3 = 0;
static int use_sse4 = 0;
static int use_sse4_1 = 0;
static int use_sse4_2 = 0;
static int use_sse4a = 0;
static int use_sse5 = 0;
static int use_ssse3 = 0;
static bool opt_size = false;
static bool emit_machcode = false;
static bool use_softfloat = false;
static bool use_sse = false;
static bool use_sse2 = false;
static bool use_sse3 = false;
static bool use_sse4 = false;
static bool use_sse4_1 = false;
static bool use_sse4_2 = false;
static bool use_sse4a = false;
static bool use_sse5 = false;
static bool use_ssse3 = false;
static cpu_arch_features arch = cpu_generic;
static cpu_arch_features opt_arch = 0;
static int fpu_arch = 0;
static int opt_cc = 1;
static int opt_unsafe_floatconv = 0;
static bool opt_cc = true;
static bool opt_unsafe_floatconv = false;
/* instruction set architectures. */
static const lc_opt_enum_int_items_t arch_items[] = {
......
......@@ -69,8 +69,8 @@ DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
static const ia32_isa_t *isa;
static char pic_base_label[128];
static ir_label_t exc_label_id;
static int mark_spill_reload = 0;
static int do_pic;
static bool mark_spill_reload;
static bool do_pic;
static bool sp_relative;
static int frame_type_size;
......
......@@ -117,7 +117,7 @@ static lc_opt_enum_int_var_t arch_fpu_var = {
&fpu, fpu_items
};
static int use_softfloat;
static bool use_softfloat;
static const lc_opt_table_entry_t sparc_options[] = {
LC_OPT_ENT_ENUM_INT("fpunit", "select the floating point unit", &arch_fpu_var),
......
......@@ -6,6 +6,7 @@
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <ctype.h>
#include "lc_opts_t.h"
......@@ -16,8 +17,6 @@
#include "xmalloc.h"
#include "obst.h"
#define ERR_STRING "In argument \"%s\": "
#define OPT_DELIM '-'
#define HELP_TEMPL "%-15s %-10s %-45s"
......@@ -53,7 +52,7 @@ static lc_opt_entry_t *init_entry(lc_opt_entry_t *ent, lc_opt_entry_t *parent,
static lc_opt_entry_t *init_grp(lc_opt_entry_t *ent)
{
ent->is_grp = 1;
ent->is_grp = true;
INIT_LIST_HEAD(&ent->v.grp.grps);
INIT_LIST_HEAD(&ent->v.grp.opts);
......@@ -72,7 +71,7 @@ static lc_opt_entry_t *init_opt(lc_opt_entry_t *ent,
{
lc_opt_special_t *s = lc_get_opt_special(ent);
ent->is_grp = 0;
ent->is_grp = false;
list_add_tail(&ent->list, &lc_get_grp_special(ent->parent)->opts);
s->type = type;
......@@ -81,7 +80,6 @@ static lc_opt_entry_t *init_opt(lc_opt_entry_t *ent,
s->dump = dump;
s->dump_vals = dump_vals;
s->length = length;
return ent;
}
......@@ -89,11 +87,11 @@ static lc_opt_entry_t *init_opt(lc_opt_entry_t *ent,
lc_opt_entry_t *lc_opt_root_grp(void)
{
static lc_opt_entry_t root_group;
static int inited = 0;
static bool inited = 0;
if (!inited) {
obstack_init(&obst);
inited = 1;
inited = true;
init_entry(&root_group, NULL, "root", "The root node");
init_grp(&root_group);
......@@ -256,26 +254,26 @@ static char *strtolower(char *buf, size_t n, const char *str)
bool lc_opt_std_cb(const char *name, lc_opt_type_t type, void *data,
size_t length, ...)
{
va_list args;
bool res = false;
int integer;
(void) name;
(void)name;
va_list args;
va_start(args, length);
bool res = false;
if (data) {
res = true;
switch (type) {
case lc_opt_type_bit:
integer = va_arg(args, int);
if (integer)
case lc_opt_type_bit: {
bool val = va_arg(args, int);
if (val)
*(unsigned*)data |= length;
else
*(unsigned*)data &= ~length;
break;
}
case lc_opt_type_boolean:
*((int *) data) = va_arg(args, int);
*((bool*) data) = va_arg(args, int);
break;
case lc_opt_type_string:
......@@ -300,17 +298,17 @@ bool lc_opt_std_cb(const char *name, lc_opt_type_t type, void *data,
int lc_opt_std_dump(char *buf, size_t n, const char *name, lc_opt_type_t type, void *data, size_t length)
{
int res;
(void) name;
(void) length;
(void)name;
(void)length;
int res;
if (data) {
switch (type) {
case lc_opt_type_bit:
res = snprintf(buf, n, "%x", *((unsigned *) data));
res = snprintf(buf, n, "%x", *((bool*) data));
break;
case lc_opt_type_boolean:
res = snprintf(buf, n, "%s", *((int *) data) ? "true" : "false");
res = snprintf(buf, n, "%s", *((bool*) data) ? "true" : "false");
break;
case lc_opt_type_string:
strncpy(buf, (const char*)data, n);
......@@ -336,10 +334,10 @@ int lc_opt_std_dump(char *buf, size_t n, const char *name, lc_opt_type_t type, v
int lc_opt_bool_dump_vals(char *buf, size_t n, const char *name, lc_opt_type_t type, void *data, size_t length)
{
(void) name;
(void) type;
(void) data;
(void) length;
(void)name;
(void)type;
(void)data;
(void)length;
strncpy(buf, "true, false", n);
return n;
}
......@@ -360,14 +358,12 @@ bool lc_opt_occurs(lc_opt_entry_t *opt, const char *value)
{ "0", 0 },
};
if (opt == NULL) {
return 0;
}
if (opt == NULL)
return false;
lc_opt_special_t *s = lc_get_opt_special(opt);
if (!s->cb) {
return 0;
}
if (!s->cb)
return false;
s->is_set = true;
......@@ -375,24 +371,22 @@ bool lc_opt_occurs(lc_opt_entry_t *opt, const char *value)
switch (s->type) {
case lc_opt_type_int: {
int val;
if (sscanf(value, "%i", &val)) {
if (sscanf(value, "%i", &val))
fine = s->cb(opt->name, s->type, s->value, s->length, val);
}
break;
}
case lc_opt_type_double: {
double val;
if (sscanf(value, "%lf", &val)) {
if (sscanf(value, "%lf", &val))
fine = s->cb(opt->name, s->type, s->value, s->length, val);
}
break;
}
case lc_opt_type_boolean:
case lc_opt_type_bit: {
char buf[16];
int val = 0;
bool val = false;
strtolower(buf, sizeof(buf), value);
for (unsigned i = 0; i < ARRAY_SIZE(bool_strings); ++i) {
if (strcmp(buf, bool_strings[i].str) == 0) {
......@@ -402,9 +396,8 @@ bool lc_opt_occurs(lc_opt_entry_t *opt, const char *value)
}
}
if (fine) {
if (fine)
fine = s->cb(opt->name, s->type, s->value, s->length, val);
}
break;
}
......@@ -427,7 +420,6 @@ char *lc_opt_value_to_string(char *buf, size_t len, const lc_opt_entry_t *ent)
s->dump(buf, len, ent->name, s->type, s->value, s->length);
else
strncpy(buf, "<n/a>", len);
return buf;
}
......@@ -437,14 +429,12 @@ static char *lc_opt_values_to_string(char *buf, size_t len,
const lc_opt_special_t *s = lc_get_opt_special(ent);
if (s->dump_vals)
s->dump_vals(buf, len, ent->name, s->type, s->value, s->length);
return buf;
}
bool lc_opt_add_table(lc_opt_entry_t *root, const lc_opt_table_entry_t *table)
{
bool res = false;
for (int i = 0; table[i].name != NULL; ++i) {
const char *name;
const lc_opt_table_entry_t *tab = &table[i];
......@@ -528,7 +518,6 @@ void lc_opt_print_help_for_entry(lc_opt_entry_t *ent, char separator, FILE *f)
lc_opt_print_help_rec(ent, separator, ent, f);
}
static void indent(FILE *f, int n)
{
for (int i = 0; i < n; ++i)
......
......@@ -74,7 +74,7 @@ typedef struct {
_LC_OPT_ENT(name, desc, lc_opt_type_bit, unsigned, addr, mask, lc_opt_std_cb, lc_opt_std_dump, NULL)
#define LC_OPT_ENT_BOOL(name, desc, addr) \
_LC_OPT_ENT(name, desc, lc_opt_type_boolean, int, addr, 0, lc_opt_std_cb, lc_opt_std_dump, lc_opt_bool_dump_vals)
_LC_OPT_ENT(name, desc, lc_opt_type_boolean, bool, addr, 0, lc_opt_std_cb, lc_opt_std_dump, lc_opt_bool_dump_vals)
typedef char lc_opt_str_t[];
#define LC_OPT_ENT_STR(name, desc, buf) \
......
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