CIRCT  19.0.0git
HWArithToHW.h
Go to the documentation of this file.
1 //===- HWArithToHW.h - HWArith to HW conversions ----------------*- 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 header file defines prototypes that expose the HWArithToHW pass
10 // constructor.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef CIRCT_CONVERSION_HWARITHTOHW_HWARITHTOHW_H
15 #define CIRCT_CONVERSION_HWARITHTOHW_HWARITHTOHW_H
16 
17 #include "circt/Support/LLVM.h"
18 #include "mlir/Transforms/DialectConversion.h"
19 #include <memory>
20 
21 namespace mlir {
22 class Pass;
23 } // namespace mlir
24 
25 namespace circt {
26 
27 /// A helper type converter class that automatically populates the relevant
28 /// materializations and type conversions for converting HWArith to HW.
29 class HWArithToHWTypeConverter : public mlir::TypeConverter {
30 public:
32 
33  // A function which recursively converts any integer type with signedness
34  // semantics to a signless counterpart.
35  mlir::Type removeSignedness(mlir::Type type);
36 
37  // Returns true if any subtype in 'type' has signedness semantics.
38  bool hasSignednessSemantics(mlir::Type type);
39  bool hasSignednessSemantics(mlir::TypeRange types);
40 
41 private:
42  // Memoizations for signedness info and conversions.
43  struct ConvertedType {
44  mlir::Type type;
46  };
47  llvm::DenseMap<mlir::Type, ConvertedType> conversionCache;
48 };
49 
50 /// Get the HWArith to HW conversion patterns.
52  HWArithToHWTypeConverter &typeConverter, RewritePatternSet &patterns);
53 
54 std::unique_ptr<mlir::Pass> createHWArithToHWPass();
55 } // namespace circt
56 
57 #endif // CIRCT_CONVERSION_HWARITHTOHW_HWARITHTOHW_H
A helper type converter class that automatically populates the relevant materializations and type con...
Definition: HWArithToHW.h:29
bool hasSignednessSemantics(mlir::Type type)
mlir::Type removeSignedness(mlir::Type type)
llvm::DenseMap< mlir::Type, ConvertedType > conversionCache
Definition: HWArithToHW.h:47
bool hasSignednessSemantics(mlir::TypeRange types)
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition: DebugAnalysis.h:21
void populateHWArithToHWConversionPatterns(HWArithToHWTypeConverter &typeConverter, RewritePatternSet &patterns)
Get the HWArith to HW conversion patterns.
std::unique_ptr< mlir::Pass > createHWArithToHWPass()