Add "--dump-size" option

This commit is contained in:
Dmitry Stogov 2023-02-21 22:22:41 +03:00
parent 637fe28e90
commit 8b4678a9ae

View File

@ -29,6 +29,8 @@ static void help(const char *cmd)
" --dump-after-live-ranges - dump IR after live ranges identification\n"
" --dump-after-coalescing - dump IR after live ranges coalescing\n"
" --dump-after-all - dump IR after each pass\n"
" --dump-final - dump IR after all pass\n"
" --dump-size - dump generated code size\n"
" --dump-use-lists - dump def->use lists\n"
" --dump-cfg - dump CFG (Control Flow Graph)\n"
" --dump-cfg-map - dump CFG map (instruction to BB number)\n"
@ -226,6 +228,7 @@ int main(int argc, char **argv)
int opt_level = 2;
uint32_t mflags = 0;
uint64_t debug_regset = 0xffffffffffffffff;
bool dump_size = 0;
ir_consistency_check();
@ -300,6 +303,8 @@ int main(int argc, char **argv)
dump |= IR_DUMP_AFTER_ALL;
} else if (strcmp(argv[i], "--dump-final") == 0) {
dump |= IR_DUMP_FINAL;
} else if (strcmp(argv[i], "--dump-size") == 0) {
dump_size = 1;
} else if (strcmp(argv[i], "-S") == 0) {
dump_asm = 1;
} else if (strcmp(argv[i], "--run") == 0) {
@ -408,6 +413,9 @@ int main(int argc, char **argv)
ir_disasm_add_symbol("test", (uintptr_t)entry, size);
ir_disasm("test", entry, size, 0, &ctx, stderr);
}
if (dump_size) {
fprintf(stderr, "\ncode size = %lld\n", (long long int)size);
}
if (run) {
int (*func)(void) = entry;
int ret;