CIRCT
23.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
// Always accept --trace so tests and scripts don't depend on whether
39
// trace-level logging was compiled into this particular runtime build.
40
#ifdef ESI_RUNTIME_TRACE
41
add_flag(
"--trace"
,
trace
,
"Enable trace logging"
);
42
#else
43
add_flag(
"--trace"
,
trace
,
44
"Enabled ONLY in debug builds with ESI_RUNTIME_TRACE defined, "
45
"which this is not. Ignored but included for compatibility."
);
46
#endif
47
add_flag(
"-v,--verbose"
,
verbose
,
"Enable verbose (info) logging"
);
48
require_subcommand(0, 1);
49
}
50
51
/// Run the parser.
52
int
esiParse
(
int
argc,
const
char
**argv) {
53
CLI11_PARSE(*
this
, argc, argv);
54
if
(
trace
)
55
ctxt
= Context::withLogger<ConsoleLogger>(
Logger::Level::Trace
);
56
else
if
(
debug
)
57
ctxt
= Context::withLogger<ConsoleLogger>(
Logger::Level::Debug
);
58
else
if
(
verbose
)
59
ctxt
= Context::withLogger<ConsoleLogger>(
Logger::Level::Info
);
60
else
61
ctxt
= Context::withLogger<ConsoleLogger>(
Logger::Level::Warning
);
62
return
0;
63
}
64
65
/// Connect to the accelerator using the specified backend and connection.
66
AcceleratorConnection
*
connect
() {
return
ctxt
->connect(
backend
,
connStr
); }
67
68
/// Get the context.
69
Context
&
getContext
() {
return
*
ctxt
; }
70
71
protected
:
72
std::unique_ptr<Context>
ctxt
;
73
74
std::string
backend
;
75
std::string
connStr
;
76
bool
trace
=
false
;
77
bool
debug
=
false
;
78
bool
verbose
=
false
;
79
};
80
81
}
// namespace esi
82
83
#endif
// ESI_CLI_H
Context.h
esi::AcceleratorConnection
Abstract class representing a connection to an accelerator.
Definition
Accelerator.h:89
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:69
esi::CliParser::verbose
bool verbose
Definition
CLI.h:78
esi::CliParser::connect
AcceleratorConnection * connect()
Connect to the accelerator using the specified backend and connection.
Definition
CLI.h:66
esi::CliParser::ctxt
std::unique_ptr< Context > ctxt
Definition
CLI.h:72
esi::CliParser::esiParse
int esiParse(int argc, const char **argv)
Run the parser.
Definition
CLI.h:52
esi::CliParser::trace
bool trace
Definition
CLI.h:76
esi::CliParser::backend
std::string backend
Definition
CLI.h:74
esi::CliParser::connStr
std::string connStr
Definition
CLI.h:75
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:34
esi::Logger::Level::Warning
@ Warning
esi::Logger::Level::Info
@ Info
esi::Logger::Level::Debug
@ Debug
esi::Logger::Level::Trace
@ Trace
debug
Definition
debug.py:1
esi
Definition
esi.py:1
Generated on Tue Apr 21 2026 00:18:09 for CIRCT by
1.9.8