printUsage function
Displays comprehensive usage information for the Balbismo compiler.
Prints detailed help text including available compilation modes, command line syntax, supported arguments, and information about how extra arguments are passed to underlying compiler tools.
The usage information covers:
- Basic command syntax
- All available compilation modes with descriptions
- File path specifications
- Output file customization with -o flag
- How extra arguments are forwarded to LLVM tools
- Limitations on argument usage per mode
This function terminates the program with exit code 1 after displaying usage.
Implementation
void printUsage(){
print("Usage: balbismo <mode> <file> [args]");
print("<mode> is one of the following:");
print("Modes:");
print(" gen-ir: Generate IR code");
print(" opt-ir: Generate optimized IR code");
print(" gen-asm: Generate assembly code");
print(" compile: Compile to binary");
print(" run: Gen IR and interpret with lli");
print(" help: Print this message");
print("<file> is the input file to be compiled");
print("[args] are arguments");
print("Arguments:");
print(" -o <file>: Output file path default is build/main.ext where ext is ll, s or nothing");
print(" Extra arguments will be passed to the compilers/interpreters as listed below:");
print(" compile uses clang, run uses lli, gen-asm uses llc and opt-ir uses opt.");
print(" Extra arguments cant be used with gen-ir");
exit(1);
}