CIRCT 24.0.0git
Loading...
Searching...
No Matches
SMTToZ3LLVM.h
Go to the documentation of this file.
1//===- SMTToZ3LLVM.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 CIRCT_CONVERSION_SMTTOZ3LLVM_H
10#define CIRCT_CONVERSION_SMTTOZ3LLVM_H
11
12#include "circt/Support/LLVM.h"
14#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
15#include "llvm/ADT/DenseSet.h"
16#include "llvm/ADT/StringRef.h"
17#include <memory>
18
19namespace circt {
20
21#define GEN_PASS_DECL_LOWERSMTTOZ3LLVM
22#include "circt/Conversion/Passes.h.inc"
23
24/// A symbol cache for LLVM globals and functions relevant to SMT lowering
25/// patterns.
27 /// Creates the LLVM global operations to store the pointers to the solver and
28 /// the context and returns a 'SMTGlobalHandler' initialized with those new
29 /// globals.
30 static SMTGlobalsHandler create(OpBuilder &builder, ModuleOp module);
31
32 /// Initializes the caches and keeps track of the given globals to store the
33 /// pointers to the SMT solver and context. It is assumed that the passed
34 /// global operations are of the correct (or at least compatible) form. E.g.,
35 /// ```
36 /// llvm.mlir.global internal @ctx() {alignment = 8 : i64} : !llvm.ptr {
37 /// %0 = llvm.mlir.zero : !llvm.ptr
38 /// llvm.return %0 : !llvm.ptr
39 /// }
40 /// ```
41 SMTGlobalsHandler(ModuleOp module, mlir::LLVM::GlobalOp solver,
42 mlir::LLVM::GlobalOp ctx);
43
44 /// Initializes the caches and keeps track of the given globals to store the
45 /// pointers to the SMT solver and context. It is assumed that the passed
46 /// global operations are of the correct (or at least compatible) form. E.g.,
47 /// ```
48 /// llvm.mlir.global internal @ctx() {alignment = 8 : i64} : !llvm.ptr {
49 /// %0 = llvm.mlir.zero : !llvm.ptr
50 /// llvm.return %0 : !llvm.ptr
51 /// }
52 /// ```
53 SMTGlobalsHandler(Namespace &&names, mlir::LLVM::GlobalOp solver,
54 mlir::LLVM::GlobalOp ctx);
55
56 /// The global storing the pointer to the SMT solver object currently active.
57 const mlir::LLVM::GlobalOp solver;
58
59 /// The global storing the pointer to the SMT context object currently active.
60 const mlir::LLVM::GlobalOp ctx;
61
63 DenseMap<StringAttr, mlir::LLVM::LLVMFuncOp> funcMap;
64 DenseMap<Block *, Value> ctxCache;
65 DenseMap<Block *, Value> solverCache;
66 DenseMap<StringAttr, mlir::LLVM::GlobalOp> stringCache;
67 /// Names of outlined solver functions that emit BMC counterexamples.
68 /// Names remain stable when func.func operations are converted to llvm.func.
69 llvm::DenseSet<StringAttr> traceFunctionNames;
70 /// Names of outlined solver functions whose final argument points to the
71 /// generated flag tracking whether a counterexample was already emitted.
72 /// This is a subset of traceFunctionNames.
73 llvm::DenseSet<StringAttr> traceEmissionFunctionNames;
74};
75
76/// Populate the given type converter with the SMT to LLVM type conversions.
77void populateSMTToZ3LLVMTypeConverter(TypeConverter &converter);
78
79/// Add the SMT to LLVM IR conversion patterns to 'patterns'. A
80/// 'SMTGlobalHandler' object has to be passed which acts as a symbol cache for
81/// LLVM globals and functions.
83 RewritePatternSet &patterns, TypeConverter &converter,
84 SMTGlobalsHandler &globals, const LowerSMTToZ3LLVMOptions &options);
85
86} // namespace circt
87
88#endif // CIRCT_CONVERSION_SMTTOZ3LLVM_H
A namespace that is used to store existing names and generate new names in some scope within the IR.
Definition Namespace.h:30
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
void populateSMTToZ3LLVMTypeConverter(TypeConverter &converter)
Populate the given type converter with the SMT to LLVM type conversions.
void populateSMTToZ3LLVMConversionPatterns(RewritePatternSet &patterns, TypeConverter &converter, SMTGlobalsHandler &globals, const LowerSMTToZ3LLVMOptions &options)
Add the SMT to LLVM IR conversion patterns to 'patterns'.
A symbol cache for LLVM globals and functions relevant to SMT lowering patterns.
Definition SMTToZ3LLVM.h:26
llvm::DenseSet< StringAttr > traceEmissionFunctionNames
Names of outlined solver functions whose final argument points to the generated flag tracking whether...
Definition SMTToZ3LLVM.h:73
llvm::DenseSet< StringAttr > traceFunctionNames
Names of outlined solver functions that emit BMC counterexamples.
Definition SMTToZ3LLVM.h:69
DenseMap< StringAttr, mlir::LLVM::GlobalOp > stringCache
Definition SMTToZ3LLVM.h:66
DenseMap< StringAttr, mlir::LLVM::LLVMFuncOp > funcMap
Definition SMTToZ3LLVM.h:63
DenseMap< Block *, Value > solverCache
Definition SMTToZ3LLVM.h:65
static SMTGlobalsHandler create(OpBuilder &builder, ModuleOp module)
Creates the LLVM global operations to store the pointers to the solver and the context and returns a ...
const mlir::LLVM::GlobalOp ctx
The global storing the pointer to the SMT context object currently active.
Definition SMTToZ3LLVM.h:60
const mlir::LLVM::GlobalOp solver
The global storing the pointer to the SMT solver object currently active.
Definition SMTToZ3LLVM.h:57
DenseMap< Block *, Value > ctxCache
Definition SMTToZ3LLVM.h:64