MLIR 22.0.0git
Context.h
Go to the documentation of this file.
1//===- Context.h - PDLL AST Context -----------------------------*- 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_PDLL_AST_CONTEXT_H_
10#define MLIR_TOOLS_PDLL_AST_CONTEXT_H_
11
14
15namespace mlir {
16namespace pdll {
17namespace ods {
18class Context;
19} // namespace ods
20
21namespace ast {
22/// This class represents the main context of the PDLL AST. It handles
23/// allocating all of the AST constructs, and manages all state necessary for
24/// the AST.
25class Context {
26public:
27 explicit Context(ods::Context &odsContext);
28 Context(const Context &) = delete;
29 Context &operator=(const Context &) = delete;
30
31 /// Return the allocator owned by this context.
32 llvm::BumpPtrAllocator &getAllocator() { return allocator; }
33
34 /// Return the storage uniquer used for AST types.
35 StorageUniquer &getTypeUniquer() { return typeUniquer; }
36
37 /// Return the ODS context used by the AST.
38 ods::Context &getODSContext() { return odsContext; }
39 const ods::Context &getODSContext() const { return odsContext; }
40
41 /// Return the diagnostic engine of this context.
42 DiagnosticEngine &getDiagEngine() { return diagEngine; }
43
44private:
45 /// The diagnostic engine of this AST context.
46 DiagnosticEngine diagEngine;
47
48 /// The ODS context used by the AST.
49 ods::Context &odsContext;
50
51 /// The allocator used for AST nodes, and other entities allocated within the
52 /// context.
53 llvm::BumpPtrAllocator allocator;
54
55 /// The uniquer used for creating AST types.
56 StorageUniquer typeUniquer;
57};
58
59} // namespace ast
60} // namespace pdll
61} // namespace mlir
62
63#endif // MLIR_TOOLS_PDLL_AST_CONTEXT_H_
A utility class to get or create instances of "storage classes".
const ods::Context & getODSContext() const
Definition Context.h:39
Context(ods::Context &odsContext)
Definition Context.cpp:15
llvm::BumpPtrAllocator & getAllocator()
Return the allocator owned by this context.
Definition Context.h:32
DiagnosticEngine & getDiagEngine()
Return the diagnostic engine of this context.
Definition Context.h:42
StorageUniquer & getTypeUniquer()
Return the storage uniquer used for AST types.
Definition Context.h:35
ods::Context & getODSContext()
Return the ODS context used by the AST.
Definition Context.h:38
Context(const Context &)=delete
Context & operator=(const Context &)=delete
This class manages the construction and emission of PDLL diagnostics.
Definition Diagnostic.h:139
This class contains all of the registered ODS operation classes.
Definition Context.h:32
Include the generated interface declarations.