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 #define GEN_PASS_DECL_HWARITHTOHW
28 #include "circt/Conversion/Passes.h.inc"
29 
30 /// A helper type converter class that automatically populates the relevant
31 /// materializations and type conversions for converting HWArith to HW.
32 class HWArithToHWTypeConverter : public mlir::TypeConverter {
33 public:
35 
36  // A function which recursively converts any integer type with signedness
37  // semantics to a signless counterpart.
38  mlir::Type removeSignedness(mlir::Type type);
39 
40  // Returns true if any subtype in 'type' has signedness semantics.
41  bool hasSignednessSemantics(mlir::Type type);
42  bool hasSignednessSemantics(mlir::TypeRange types);
43 
44 private:
45  // Memoizations for signedness info and conversions.
46  struct ConvertedType {
47  mlir::Type type;
49  };
50  llvm::DenseMap<mlir::Type, ConvertedType> conversionCache;
51 };
52 
53 /// Get the HWArith to HW conversion patterns.
55  HWArithToHWTypeConverter &typeConverter, RewritePatternSet &patterns);
56 
57 std::unique_ptr<mlir::Pass> createHWArithToHWPass();
58 } // namespace circt
59 
60 #endif // CIRCT_CONVERSION_HWARITHTOHW_HWARITHTOHW_H
A helper type converter class that automatically populates the relevant materializations and type con...
Definition: HWArithToHW.h:32
bool hasSignednessSemantics(mlir::Type type)
mlir::Type removeSignedness(mlir::Type type)
llvm::DenseMap< mlir::Type, ConvertedType > conversionCache
Definition: HWArithToHW.h:50
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()