CIRCT
22.0.0git
Loading...
Searching...
No Matches
lib
Target
ExportSystemC
Patterns
HWEmissionPatterns.cpp
Go to the documentation of this file.
1
//===- HWEmissionPatterns.cpp - HW Dialect Emission Patterns --------------===//
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 implements the emission patterns for the HW dialect.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#include "
HWEmissionPatterns.h
"
14
#include "../EmissionPrinter.h"
15
#include "
circt/Dialect/HW/HWOps.h
"
16
17
using namespace
circt
;
18
using namespace
circt::hw
;
19
using namespace
circt::ExportSystemC
;
20
21
//===----------------------------------------------------------------------===//
22
// Operation emission patterns.
23
//===----------------------------------------------------------------------===//
24
25
namespace
{
26
/// The ConstantOp always inlines its value. Examples:
27
/// * hw.constant 5 : i32 ==> 5
28
/// * hw.constant 0 : i1 ==> false
29
/// * hw.constant 1 : i1 ==> true
30
struct
ConstantEmitter :
OpEmissionPattern
<ConstantOp> {
31
using
OpEmissionPattern::OpEmissionPattern
;
32
33
MatchResult
matchInlinable
(Value value)
override
{
34
if
(value.getDefiningOp<ConstantOp>())
35
return
Precedence::LIT
;
36
return
{};
37
}
38
39
void
emitInlined
(Value value,
EmissionPrinter
&p)
override
{
40
p.
emitAttr
(value.getDefiningOp<ConstantOp>().getValueAttr());
41
}
42
};
43
}
// namespace
44
45
//===----------------------------------------------------------------------===//
46
// Register Operation and Type emission patterns.
47
//===----------------------------------------------------------------------===//
48
49
void
circt::ExportSystemC::populateHWEmitters
(
OpEmissionPatternSet
&
patterns
,
50
MLIRContext *
context
) {
51
patterns
.add<ConstantEmitter>(
context
);
52
}
context
static std::unique_ptr< Context > context
Definition
DpiEntryPoints.cpp:37
HWEmissionPatterns.h
HWOps.h
circt::ExportSystemC::EmissionPatternSet
This class collects a set of emission patterns with base type 'PatternTy'.
Definition
EmissionPattern.h:237
circt::ExportSystemC::EmissionPrinter
This is intended to be the driving class for all pattern-based IR emission.
Definition
EmissionPrinter.h:27
circt::ExportSystemC::EmissionPrinter::emitAttr
void emitAttr(Attribute attr)
Emit the given attribute to the ostream associated with this printer according to the emission patter...
Definition
EmissionPrinter.cpp:54
circt::ExportSystemC::MatchResult
This class allows a pattern's match function for inlining to pass its result's precedence to the patt...
Definition
EmissionPattern.h:75
circt::ExportSystemC
Definition
ExportSystemC.h:19
circt::ExportSystemC::populateHWEmitters
void populateHWEmitters(OpEmissionPatternSet &patterns, MLIRContext *context)
Definition
HWEmissionPatterns.cpp:49
circt::ExportSystemC::Precedence::LIT
@ LIT
circt::hw
Definition
ExportAIGER.h:26
circt
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition
DebugAnalysis.h:21
patterns
Definition
LTLFolds.cpp:45
circt::ExportSystemC::OpEmissionPattern
This is a convenience class providing default implementations for operation emission patterns.
Definition
EmissionPattern.h:168
circt::ExportSystemC::OpEmissionPattern::OpEmissionPattern
OpEmissionPattern(MLIRContext *context)
Definition
EmissionPattern.h:169
circt::ExportSystemC::OpEmissionPattern::emitInlined
void emitInlined(mlir::Value value, EmissionPrinter &p) override
Emit the expression for the given value.
Definition
EmissionPattern.h:189
circt::ExportSystemC::OpEmissionPattern::matchInlinable
MatchResult matchInlinable(Value value) override
Checks if this pattern is applicable to the given value to emit an inlinable expression.
Definition
EmissionPattern.h:180
Generated on Sat Dec 20 2025 00:09:13 for CIRCT by
1.9.8