1//===--- QuerySession.h -----------------------------------------*- 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#ifndef MLIR_TOOLS_MLIRQUERY_QUERYSESSION_H
10#define MLIR_TOOLS_MLIRQUERY_QUERYSESSION_H
11
12#include "llvm/ADT/StringMap.h"
13
14namespace mlir::query {
15
16class Registry;
17// Represents the state for a particular mlir-query session.
18class QuerySession {
19public:
20 QuerySession(Operation *rootOp, llvm::SourceMgr &sourceMgr, unsigned bufferId,
21 const matcher::Registry &matcherRegistry)
22 : rootOp(rootOp), sourceMgr(sourceMgr), bufferId(bufferId),
23 matcherRegistry(matcherRegistry) {}
24
25 Operation *getRootOp() { return rootOp; }
26 llvm::SourceMgr &getSourceManager() const { return sourceMgr; }
27 unsigned getBufferId() { return bufferId; }
28 const matcher::Registry &getRegistryData() const { return matcherRegistry; }
29
30 llvm::StringMap<matcher::VariantValue> namedValues;
31 bool terminate = false;
32
33private:
34 Operation *rootOp;
35 llvm::SourceMgr &sourceMgr;
36 unsigned bufferId;
37 const matcher::Registry &matcherRegistry;
38};
39
40} // namespace mlir::query
41
42#endif // MLIR_TOOLS_MLIRQUERY_QUERYSESSION_H
43

source code of mlir/include/mlir/Query/QuerySession.h