Add command-line parser and some debug options #318
No reviewers
Labels
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: M-Labs/nac3#318
Loading…
Reference in New Issue
There is no content yet.
Delete Branch "cmdline-parser"
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?
Clap is used for the implementation of the parser. After the refactoring, the argument order of
<FILE> <THREADS>
is currently preserved, with additional configuration implemented as options.New Options:
-O<n>
: Sets the optimization level of LLVM IR;-O0
corresponds toOptimizationLevel::None
, whereas-O2
corresponds toOptimizationLevel::Default
(which has also been the default).-emit-llvm
: Outputs the LLVM IR of each module after compilation to stdoutFeedback is welcome on alternative behavior, as our current behavior does not match with Clang's behavior, which is:
-emit-llvm
outputs a bitcode file-S -emit-llvm
outputs the human-readable IR into<filename>.ll
.-S
refers to only running C preprocessor and compilation without assembling1d0356e3c4
to5668fd9254
v2: Added
CodeGenLLVMOptions
struct, fixed missing changes tonac3artiq
and test sources.5668fd9254
toa1a455d752
v3: Replaced argument for one more level where
OptimizationLevel
is needed.v4: Rebased on
master
and refactored to passCodeGenLLVMOptions
viaWorkerRegistry
.4613e9e54d
to3d7ccd0b69
WIP: Add command-line parser and some debug optionsto Add command-line parser and some debug optionsThis merge request should be ready for re-review.
@ -16,4 +16,2 @@
rm -f *.o
$nac3standalone $1
rustc -o demo demo.rs -Crelocation-model=static -Clink-arg=./module.o
The script has
set -e
above. I suspect these|| exit
changes are not necessary?I didn't notice that it was there. Removed the
|| exit
changes.@ -159,1 +179,3 @@
let threads: u32 = env::args().nth(2).map(|s| str::parse(&s).unwrap()).unwrap_or(1);
let cli = CommandLineArgs::parse();
let CommandLineArgs { file_name, threads, opt_level, emit_llvm } = cli;
let opt_level: OptimizationLevel = unsafe { transmute(opt_level) };
Can we avoid unsafe and transmute here?
Changed to use
match
expression.