@@ -2,8 +2,8 @@ use std::path::PathBuf;
22
33use clap:: Parser ;
44use regalloc2:: {
5- checker:: Checker , serialize:: SerializableFunction , Block , Edit , Function , InstOrEdit , Output ,
6- RegallocOptions ,
5+ checker:: Checker , serialize:: SerializableFunction , Algorithm , Block , Edit , Function ,
6+ InstOrEdit , Output , RegallocOptions ,
77} ;
88
99#[ derive( Parser ) ]
@@ -15,6 +15,24 @@ struct Args {
1515
1616 /// Input file containing a bincode-encoded SerializedFunction.
1717 input : PathBuf ,
18+
19+ /// Which register allocation algorithm to use.
20+ algorithm : CliAlgorithm ,
21+ }
22+
23+ #[ derive( Clone , Copy , Debug , clap:: ValueEnum ) ]
24+ enum CliAlgorithm {
25+ Ion ,
26+ Fastalloc ,
27+ }
28+
29+ impl From < CliAlgorithm > for Algorithm {
30+ fn from ( cli_algo : CliAlgorithm ) -> Algorithm {
31+ match cli_algo {
32+ CliAlgorithm :: Ion => Algorithm :: Ion ,
33+ CliAlgorithm :: Fastalloc => Algorithm :: Fastalloc ,
34+ }
35+ }
1836}
1937
2038fn main ( ) {
@@ -32,6 +50,7 @@ fn main() {
3250 let options = RegallocOptions {
3351 verbose_log : true ,
3452 validate_ssa : true ,
53+ algorithm : args. algorithm . into ( ) ,
3554 } ;
3655 let output = match regalloc2:: run ( & function, function. machine_env ( ) , & options) {
3756 Ok ( output) => output,
0 commit comments