static int elaborate(int argc, char **argv) { set_work_lib(); static struct option long_options[] = { {"disable-opt", no_argument, 0, 'o'}, {"dump-llvm", no_argument, 0, 'd'}, {"native", no_argument, 0, 'n'}, {"cover", no_argument, 0, 'c'}, {0, 0, 0, 0} }; int c, index = 0; const char *spec = ""; optind = 1; while ((c = getopt_long(argc, argv, spec, long_options, &index)) != -1) { switch (c) { case 'o': opt_set_int("optimise", 0); break; case 'd': opt_set_int("dump-llvm", 1); break; case 'n': opt_set_int("native", 1); break; case 'c': opt_set_int("cover", 1); break; case 0: // Set a flag break; case '?': // getopt_long already printed an error message exit(EXIT_FAILURE); default: abort(); } } if (optind == argc) fatal("missing top-level unit name"); ident_t unit_i = to_unit_name(argv[optind]); tree_t unit = lib_get(lib_work(), unit_i); if (unit == NULL) fatal("cannot find unit %s in library %s", istr(unit_i), istr(lib_name(lib_work()))); tree_t e = elab(unit); if (e == NULL) return EXIT_FAILURE; opt(e); group_nets(e); // Save the library now so the code generator can attach temporary // meta data to trees lib_save(lib_work()); cgen(e); link_bc(e); return EXIT_SUCCESS; }
static int elaborate(int argc, char **argv) { set_work_lib(); static struct option long_options[] = { { "disable-opt", no_argument, 0, 'o' }, { "dump-llvm", no_argument, 0, 'd' }, { "dump-vcode", optional_argument, 0, 'V' }, { "native", no_argument, 0, 'n' }, { "cover", no_argument, 0, 'c' }, { "verbose", no_argument, 0, 'v' }, { 0, 0, 0, 0 } }; bool verbose = false; int c, index = 0; const char *spec = "v"; optind = 1; while ((c = getopt_long(argc, argv, spec, long_options, &index)) != -1) { switch (c) { case 'o': opt_set_int("optimise", 0); break; case 'd': opt_set_int("dump-llvm", 1); break; case 'V': opt_set_str("dump-vcode", optarg ?: ""); break; case 'n': opt_set_int("native", 1); break; case 'c': opt_set_int("cover", 1); break; case 'v': verbose = true; break; case 0: // Set a flag break; case '?': fatal("unrecognised elaborate option %s", argv[optind - 1]); default: abort(); } } if (optind == argc) fatal("missing top-level unit name"); elab_verbose(verbose, "initialising"); ident_t unit_i = to_unit_name(argv[optind]); tree_t unit = lib_get(lib_work(), unit_i); if (unit == NULL) fatal("cannot find unit %s in library %s", istr(unit_i), istr(lib_name(lib_work()))); elab_verbose(verbose, "loading top-level unit"); tree_t e = elab(unit); if (e == NULL) return EXIT_FAILURE; elab_verbose(verbose, "elaborating design"); opt(e); elab_verbose(verbose, "optimising design"); group_nets(e); elab_verbose(verbose, "grouping nets"); // Save the library now so the code generator can attach temporary // meta data to trees lib_save(lib_work()); elab_verbose(verbose, "saving library"); lower_unit(e); elab_verbose(verbose, "generating intermediate code"); cgen(e); elab_verbose(verbose, "generating LLVM"); link_bc(e); elab_verbose(verbose, "linking"); return EXIT_SUCCESS; }