#endif
#endif
-/** The current c mode/dialect. */
-unsigned int c_mode = _C89 | _ANSI | _C99 | _GNUC;
-
-/** The 'machine size', 16, 32 or 64 bit, 32bit is the default. */
-unsigned int machine_size = 32;
-
-/** true if the char type is signed. */
-bool char_is_signed = true;
-
-/** true for strict language checking. */
-bool strict_mode = false;
-
-/** use builtins for some libc functions */
-bool use_builtins = false;
-
-/** we have extern function with const attribute. */
-bool have_const_functions = false;
-
-atomic_type_kind_t wchar_atomic_kind = ATOMIC_TYPE_INT;
+unsigned int c_mode = _C89 | _ANSI | _C99 | _GNUC;
+unsigned int machine_size = 32;
+bool byte_order_big_endian = false;
+bool char_is_signed = true;
+bool strict_mode = false;
+bool use_builtins = false;
+bool have_const_functions = false;
+atomic_type_kind_t wchar_atomic_kind = ATOMIC_TYPE_INT;
/* to switch on printing of implicit casts */
extern bool print_implicit_casts;
static file_list_entry_t *temp_files;
-#if defined(_DEBUG) || defined(FIRM_DEBUG)
-/**
- * Debug printf implementation.
- *
- * @param fmt printf style format parameter
- */
-void dbg_printf(const char *fmt, ...)
-{
- va_list list;
-
- if (firm_dump.debug_print) {
- va_start(list, fmt);
- vprintf(fmt, list);
- va_end(list);
- } /* if */
-}
-#endif /* defined(_DEBUG) || defined(FIRM_DEBUG) */
-
static void initialize_firm(void)
{
firm_early_init();
-
- dump_consts_local(1);
- dump_keepalive_edges(1);
}
static void get_output_name(char *buf, size_t buflen, const char *inputname,
static void usage(const char *argv0)
{
- fprintf(stderr, "Usage %s input [-o output] [-c]\n", argv0);
+ fprintf(stderr, "Usage %s [options] input [-o output]\n", argv0);
}
static void print_cparser_version(void)
"warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
}
+static void print_help(const char *argv0)
+{
+ usage(argv0);
+ puts("");
+ puts("\t-fhelp Display help about firm optimisation options");
+ puts("\t-bhelp Display help about firm backend options");
+ puts("A big number of gcc flags is also supported");
+}
+
static void set_be_option(const char *arg)
{
- int res = firm_be_option(arg);
+ int res = be_parse_arg(arg);
(void) res;
assert(res);
}
strstart(orig_opt, "align-jumps=") ||
strstart(orig_opt, "align-functions=")) {
fprintf(stderr, "ignoring gcc option '-f%s'\n", orig_opt);
+ } else if (strstart(orig_opt, "message-length=")) {
+ /* ignore: would only affect error message format */
} else if (streq(opt, "fast-math") ||
streq(opt, "jump-tables") ||
streq(opt, "expensive-optimizations") ||
} else if (option[0] == 'b') {
const char *opt;
GET_ARG_AFTER(opt, "-b");
- int res = firm_be_option(opt);
+ int res = be_parse_arg(opt);
if (res == 0) {
fprintf(stderr, "error: unknown Firm backend option '-b %s'\n",
opt);
if (strstart(opt, "arch=")) {
GET_ARG_AFTER(opt, "-march=");
snprintf(arch_opt, sizeof(arch_opt), "%s-arch=%s", cpu_arch, opt);
- int res = firm_be_option(arch_opt);
+ int res = be_parse_arg(arch_opt);
if (res == 0) {
fprintf(stderr, "Unknown architecture '%s'\n", arch_opt);
argument_errors = true;
} else {
snprintf(arch_opt, sizeof(arch_opt), "%s-opt=%s", cpu_arch, opt);
- int res = firm_be_option(arch_opt);
+ int res = be_parse_arg(arch_opt);
if (res == 0)
argument_errors = true;
}
} else if (strstart(opt, "tune=")) {
GET_ARG_AFTER(opt, "-mtune=");
snprintf(arch_opt, sizeof(arch_opt), "%s-opt=%s", cpu_arch, opt);
- int res = firm_be_option(arch_opt);
+ int res = be_parse_arg(arch_opt);
if (res == 0)
argument_errors = true;
} else if (strstart(opt, "cpu=")) {
GET_ARG_AFTER(opt, "-mcpu=");
snprintf(arch_opt, sizeof(arch_opt), "%s-arch=%s", cpu_arch, opt);
- int res = firm_be_option(arch_opt);
+ int res = be_parse_arg(arch_opt);
if (res == 0)
argument_errors = true;
} else if (strstart(opt, "fpmath=")) {
}
if (!argument_errors) {
snprintf(arch_opt, sizeof(arch_opt), "%s-fpunit=%s", cpu_arch, opt);
- int res = firm_be_option(arch_opt);
+ int res = be_parse_arg(arch_opt);
if (res == 0)
argument_errors = true;
}
} else if (strstart(opt, "preferred-stack-boundary=")) {
GET_ARG_AFTER(opt, "-mpreferred-stack-boundary=");
snprintf(arch_opt, sizeof(arch_opt), "%s-stackalign=%s", cpu_arch, opt);
- int res = firm_be_option(arch_opt);
+ int res = be_parse_arg(arch_opt);
if (res == 0)
argument_errors = true;
} else if (streq(opt, "omit-leaf-frame-pointer")) {
} else if (streq(option, "version")) {
print_cparser_version();
exit(EXIT_SUCCESS);
+ } else if (streq(option, "help")) {
+ print_help(argv[0]);
+ help_displayed = true;
} else if (streq(option, "dump-function")) {
++i;
if (i >= argc) {
streq(suffix, "o") ? FILETYPE_OBJECT :
streq(suffix, "s") ? FILETYPE_PREPROCESSED_ASSEMBLER :
streq(suffix, "so") ? FILETYPE_OBJECT :
- FILETYPE_AUTODETECT;
+ FILETYPE_OBJECT; /* gcc behavior: unknown file extension means object file */
}
}
-
- if (type == FILETYPE_AUTODETECT) {
- fprintf(stderr, "'%s': file format not recognized\n", arg);
- continue;
- }
}
file_list_entry_t *entry
}
}
+ if (help_displayed) {
+ return !argument_errors;
+ }
+
if (print_file_name_file != NULL) {
print_file_name(print_file_name_file);
return 0;
}
-
if (files == NULL) {
fprintf(stderr, "error: no input files specified\n");
argument_errors = true;
}
- if (help_displayed) {
- return !argument_errors;
- }
if (argument_errors) {
usage(argv[0]);
return 1;
c_mode &= ~features_off;
gen_firm_init();
+ byte_order_big_endian = be_get_backend_param()->byte_order_big_endian;
init_symbol_table();
init_types();
init_typehash();
exit(1);
}
- dump_ir_block_graph_file(irg, out);
+ dump_ir_graph_file(out, irg);
fclose(out);
exit(0);
}
exit(0);
}
- gen_firm_finish(asm_out, filename, /*c_mode=*/1,
- have_const_functions);
+ gen_firm_finish(asm_out, filename, have_const_functions);
if (asm_out != out) {
fclose(asm_out);
}