Commit 60634256 authored by Nguyen, Thien Minh's avatar Nguyen, Thien Minh
Browse files

Link main qcor command line with qcor-mlir-tool

Pass optimization level (-Ox) and a couple of useful options

Should complete https://github.com/ORNL-QCI/qcor/issues/178



Signed-off-by: default avatarThien Nguyen <nguyentm@ornl.gov>
parent 9284f9fd
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -75,7 +75,10 @@ int main(int argc, char **argv) {

  llvm::cl::ParseCommandLineOptions(argc, argv,
                                    "qcor quantum assembly compiler\n");
  bool qoptimizations = mlir_quantum_opt;
  // If any *clang* optimization is requested, turn on quantum optimization as
  // well.
  bool qoptimizations =
      mlir_quantum_opt || OptLevelO1 || OptLevelO2 || OptLevelO3;
  std::string input_func_name = "";
  if (!mlir_specified_func_name.empty()) {
    input_func_name = mlir_specified_func_name;
+16 −0
Original line number Diff line number Diff line
@@ -450,6 +450,22 @@ def main(argv=None):
        if '--q-optimize' in sys.argv[1:]:
            sys.argv.remove('--q-optimize')
            extra_args.append('--q-optimize')
        # Parse clang -Ox optimization level:
        opt_level_options = ['-O0', '-O1', '-O2', '-O3'] 
        for opt_level_option in opt_level_options:
            if opt_level_option in sys.argv[1:]:
                # Forward to mlir tool
                extra_args.append(opt_level_option)

        # Some options that we want to pass on to mlir tool
        # (a subset of --help that we think is useful)
        mlir_forward_options = ['--pass-timing', '--print-ir-after-all', '--print-ir-after-change', '--print-ir-before-all']
        for mlir_forward_option in mlir_forward_options:
            if mlir_forward_option in sys.argv[1:]:
                # Forward to mlir tool
                extra_args.append(mlir_forward_option)
                # and remove from the main qcor args
                sys.argv.remove(mlir_forward_option)

        if '--emit-mlir' in sys.argv[1:]:
            result = subprocess.run(['@CMAKE_INSTALL_PREFIX@/bin/qcor-mlir-tool',