fix duplicate_type, improve a comment
[cparser] / main.c
diff --git a/main.c b/main.c
index 4930eaf..dd1b82d 100644 (file)
--- a/main.c
+++ b/main.c
@@ -4,6 +4,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdbool.h>
 #include <errno.h>
 #include <string.h>
 #include <assert.h>
@@ -21,6 +22,7 @@
 #include "parser.h"
 #include "ast2firm.h"
 #include "adt/error.h"
+#include "write_fluffy.h"
 
 #ifndef PREPROCESSOR
 #define PREPROCESSOR "cpp"
@@ -36,7 +38,8 @@
 #define pclose(file)      _pclose(file)
 #endif /* _WIN32 */
 
-static int verbose;
+static int  verbose;
+static bool do_dump;
 
 static const ir_settings_if_conv_t *if_conv_info = NULL;
 static const backend_params        *be_params    = NULL;
@@ -61,6 +64,8 @@ static void initialize_firm(void)
        params.arch_op_settings = be_params->arch_op_settings;
        if_conv_info            = be_params->if_conv_info;
 
+       (void) if_conv_info; /* avoid unused warning */
+
        /* intialize firm itself */
        init_firm(&params);
        dbg_init(NULL, NULL, dbg_snprint);
@@ -88,12 +93,9 @@ static void initialize_firm(void)
 
 static void dump(ir_graph *irg, const char *suffix)
 {
-#if 0
-       dump_ir_block_graph(irg, suffix);
-#else
-       (void)irg;
-       (void)suffix;
-#endif
+       if(do_dump) {
+               dump_ir_block_graph(irg, suffix);
+       }
 }
 
 static void get_output_name(char *buf, size_t buflen, const char *inputname,
@@ -223,6 +225,15 @@ static void create_firm_prog(translation_unit_t *unit)
                dump(irg, "-start");
        }
 
+       lower_params_t params;
+
+       params.def_ptr_alignment    = 4;
+       params.flags                = LF_COMPOUND_RETURN | LF_RETURN_HIDDEN;
+       params.hidden_params        = ADD_HIDDEN_ALWAYS_IN_FRONT;
+       params.find_pointer_type    = NULL;
+       params.ret_compound_in_regs = NULL;
+       lower_calls_with_compounds(&params);
+
        lower_highlevel();
        for(int i = 0; i < n_irgs; ++i) {
                ir_graph *const irg = get_irp_irg(i);
@@ -272,8 +283,6 @@ static void optimize(void)
        }
 }
 
-void write_fluffy_decls(translation_unit_t *unit);
-
 typedef enum compile_mode_t {
        Compile,
        CompileAssemble,
@@ -324,6 +333,8 @@ int main(int argc, char **argv)
                        mode = PrintAst;
                } else if(strcmp(arg, "--print-fluffy") == 0) {
                        mode = PrintFluffy;
+               } else if(strcmp(arg, "--dump") == 0) {
+                       do_dump = true;
                } else if(strcmp(arg, "-v") == 0) {
                        verbose = 1;
                } else if(arg[0] == '-' && arg[1] == 'f') {