CIRCT  18.0.0git
FIRRTLAttributes.h
Go to the documentation of this file.
1 //===- FIRRTLAttributes.h - FIRRTL dialect attributes -----------*- 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 file contains the FIRRTL dialect custom attributes.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef CIRCT_DIALECT_FIRRTL_FIRRTLATTRIBUTES_H
14 #define CIRCT_DIALECT_FIRRTL_FIRRTLATTRIBUTES_H
15 
17 #include "circt/Support/LLVM.h"
18 
19 namespace circt {
20 namespace firrtl {
21 
22 //===----------------------------------------------------------------------===//
23 // PortDirections
24 //===----------------------------------------------------------------------===//
25 
26 /// This represents the direction of a single port.
27 enum class Direction { In, Out };
28 
29 /// Prints the Direction to the stream as either "in" or "out".
30 llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const Direction &dir);
31 
32 namespace direction {
33 
34 /// Return an output direction if \p isOutput is true, otherwise return an
35 /// input direction.
36 inline Direction get(bool isOutput) { return (Direction)isOutput; }
37 
38 /// Flip a port direction.
39 Direction flip(Direction direction);
40 
41 inline StringRef toString(Direction direction) {
42  return direction == Direction::In ? "in" : "out";
43 }
44 
45 /// Return a \p IntegerAttr containing the packed representation of an array
46 /// of directions.
47 IntegerAttr packAttribute(MLIRContext *context, ArrayRef<Direction> directions);
48 
49 /// Turn a packed representation of port attributes into a vector that can
50 /// be worked with.
51 SmallVector<Direction> unpackAttribute(IntegerAttr directions);
52 
53 } // namespace direction
54 } // namespace firrtl
55 } // namespace circt
56 
57 #define GET_ATTRDEF_CLASSES
58 #include "circt/Dialect/FIRRTL/FIRRTLAttributes.h.inc"
59 
60 #endif // CIRCT_DIALECT_FIRRTL_FIRRTLATTRIBUTES_H
IntegerAttr packAttribute(MLIRContext *context, ArrayRef< Direction > directions)
Return a IntegerAttr containing the packed representation of an array of directions.
StringRef toString(Direction direction)
Direction flip(Direction direction)
Flip a port direction.
SmallVector< Direction > unpackAttribute(IntegerAttr directions)
Turn a packed representation of port attributes into a vector that can be worked with.
Direction get(bool isOutput)
Return an output direction if isOutput is true, otherwise return an input direction.
Direction
This represents the direction of a single port.
T & operator<<(T &os, FIRVersion version)
Definition: FIRParser.h:115
This file defines an intermediate representation for circuits acting as an abstraction for constraint...
Definition: DebugAnalysis.h:21