CIRCT
21.0.0git
Loading...
Searching...
No Matches
lib
Dialect
ESI
runtime
cpp
include
esi
CLI.h
Go to the documentation of this file.
1
//===- CLI.h - ESI runtime tool CLI parser common ---------------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This file contains the common CLI parser code for ESI runtime tools. Exposed
10
// publicly so that out-of-tree tools can use it. This is a header-only library
11
// to make compilation easier for out-of-tree tools.
12
//
13
// DO NOT EDIT!
14
// This file is distributed as part of an ESI package. The source for this file
15
// should always be modified within CIRCT (lib/dialect/ESI/runtime/cpp).
16
//
17
//===----------------------------------------------------------------------===//
18
19
// NOLINTNEXTLINE(llvm-header-guard)
20
#ifndef ESI_CLI_H
21
#define ESI_CLI_H
22
23
#include "CLI/CLI.hpp"
24
#include "
esi/Context.h
"
25
26
namespace
esi
{
27
28
/// Common options and code for ESI runtime tools.
29
class
CliParser
:
public
CLI::App {
30
public
:
31
CliParser
(
const
std::string &toolName)
32
: CLI::App(toolName),
debug
(false),
verbose
(false) {
33
add_option(
"backend"
,
backend
,
"Backend to use for connection"
)->required();
34
add_option(
"connection"
,
connStr
,
35
"Connection string to use for accelerator communication"
)
36
->required();
37
add_flag(
"--debug"
,
debug
,
"Enable debug logging"
);
38
add_flag(
"-v,--verbose"
,
verbose
,
"Enable verbose (info) logging"
);
39
require_subcommand(0, 1);
40
}
41
42
/// Run the parser.
43
int
esiParse
(
int
argc,
const
char
**argv) {
44
CLI11_PARSE(*
this
, argc, argv);
45
if
(
debug
)
46
ctxt
= Context::withLogger<ConsoleLogger>(
Logger::Level::Debug
);
47
else
if
(
verbose
)
48
ctxt
= Context::withLogger<ConsoleLogger>(
Logger::Level::Info
);
49
return
0;
50
}
51
52
/// Connect to the accelerator using the specified backend and connection.
53
std::unique_ptr<AcceleratorConnection>
connect
() {
54
return
ctxt
.
connect
(
backend
,
connStr
);
55
}
56
57
/// Get the context.
58
Context
&
getContext
() {
return
ctxt
; }
59
60
protected
:
61
Context
ctxt
;
62
63
std::string
backend
;
64
std::string
connStr
;
65
bool
debug
;
66
bool
verbose
;
67
};
68
69
}
// namespace esi
70
71
#endif
// ESI_CLI_H
Context.h
esi::CliParser
Common options and code for ESI runtime tools.
Definition
CLI.h:29
esi::CliParser::getContext
Context & getContext()
Get the context.
Definition
CLI.h:58
esi::CliParser::verbose
bool verbose
Definition
CLI.h:66
esi::CliParser::connect
std::unique_ptr< AcceleratorConnection > connect()
Connect to the accelerator using the specified backend and connection.
Definition
CLI.h:53
esi::CliParser::debug
bool debug
Definition
CLI.h:65
esi::CliParser::esiParse
int esiParse(int argc, const char **argv)
Run the parser.
Definition
CLI.h:43
esi::CliParser::backend
std::string backend
Definition
CLI.h:63
esi::CliParser::ctxt
Context ctxt
Definition
CLI.h:61
esi::CliParser::connStr
std::string connStr
Definition
CLI.h:64
esi::CliParser::CliParser
CliParser(const std::string &toolName)
Definition
CLI.h:31
esi::Context
AcceleratorConnections, Accelerators, and Manifests must all share a context.
Definition
Context.h:31
esi::Context::connect
std::unique_ptr< AcceleratorConnection > connect(std::string backend, std::string connection)
Connect to an accelerator backend.
Definition
Context.cpp:27
esi::Logger::Level::Info
@ Info
esi::Logger::Level::Debug
@ Debug
debug
Definition
debug.py:1
esi
Definition
esi.py:1
Generated on Mon Mar 10 2025 00:07:42 for CIRCT by
1.9.8