CIRCT 24.0.0git
Loading...
Searching...
No Matches
LowerTypes.cpp File Reference
#include "circt/Dialect/FIRRTL/FIRRTLAttributes.h"
#include "circt/Dialect/FIRRTL/FIRRTLOps.h"
#include "circt/Dialect/FIRRTL/FIRRTLTypes.h"
#include "circt/Dialect/FIRRTL/FIRRTLUtils.h"
#include "circt/Dialect/FIRRTL/FIRRTLVisitors.h"
#include "circt/Dialect/FIRRTL/Passes.h"
#include "circt/Dialect/HW/HWAttributes.h"
#include "circt/Dialect/HW/HWOpInterfaces.h"
#include "circt/Support/Debug.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "mlir/IR/Threading.h"
#include "mlir/Pass/Pass.h"
#include "llvm/ADT/APSInt.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Debug.h"
#include "circt/Dialect/FIRRTL/Passes.h.inc"
Include dependency graph for LowerTypes.cpp:

Go to the source code of this file.

Namespaces

namespace  circt
 The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
namespace  circt::firrtl

Macros

#define DEBUG_TYPE   "firrtl-lower-types"
#define GEN_PASS_DEF_LOWERFIRRTLTYPES

Functions

static FIRRTLType mapLoweredType (FIRRTLType type, FIRRTLBaseType fieldType)
 Return fieldType or fieldType as same ref as type.
static Type mapLoweredType (Type type, FIRRTLBaseType fieldType)
 Return fieldType or fieldType as same ref as type.
static bool isOneDimVectorType (FIRRTLType type)
 Return true if the type is a 1d vector type or ground type.
static bool containsBundleType (FIRRTLType type)
 Return true if the type has a bundle type as subtype.
static bool isPreservableAggregateType (Type type, PreserveAggregate::PreserveMode mode)
 Return true if we can preserve the type.
static bool peelType (Type type, SmallVectorImpl< FlatBundleFieldEntry > &fields, PreserveAggregate::PreserveMode mode)
 Peel one layer of an aggregate type into its components.
static bool isNotSubAccess (Operation *op)
 Return if something is not a normal subaccess.
static SmallVector< Operation * > getSAWritePath (Operation *op)
 Look through and collect subfields leading to a subaccess.
static MemOp cloneMemWithNewType (ImplicitLocOpBuilder *b, MemOp op, FlatBundleFieldEntry field)
 Clone memory for the specified field. Returns null op on error.
template<typename T>
static void eraseElementsAtIndices (SmallVectorImpl< T > &vec, const llvm::BitVector &removalMask)
 Helper function to remove elements from a vector based on a BitVector mask.
static Value cloneAccess (ImplicitLocOpBuilder *builder, Operation *op, Value rhs)

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "firrtl-lower-types"

Definition at line 47 of file LowerTypes.cpp.

◆ GEN_PASS_DEF_LOWERFIRRTLTYPES

#define GEN_PASS_DEF_LOWERFIRRTLTYPES

Definition at line 51 of file LowerTypes.cpp.

Function Documentation

◆ cloneAccess()

Value cloneAccess ( ImplicitLocOpBuilder * builder,
Operation * op,
Value rhs )
static

Definition at line 948 of file LowerTypes.cpp.

◆ cloneMemWithNewType()

MemOp cloneMemWithNewType ( ImplicitLocOpBuilder * b,
MemOp op,
FlatBundleFieldEntry field )
static

◆ containsBundleType()

bool containsBundleType ( FIRRTLType type)
static

Return true if the type has a bundle type as subtype.

Definition at line 114 of file LowerTypes.cpp.

References circt::firrtl::FIRRTLTypeSwitch< T, ResultT >::Case(), and containsBundleType().

Referenced by containsBundleType(), and isPreservableAggregateType().

◆ eraseElementsAtIndices()

template<typename T>
void eraseElementsAtIndices ( SmallVectorImpl< T > & vec,
const llvm::BitVector & removalMask )
static

Helper function to remove elements from a vector based on a BitVector mask.

Definition at line 847 of file LowerTypes.cpp.

References assert().

◆ getSAWritePath()

SmallVector< Operation * > getSAWritePath ( Operation * op)
static

Look through and collect subfields leading to a subaccess.

Definition at line 211 of file LowerTypes.cpp.

References isNotSubAccess().

◆ isNotSubAccess()

bool isNotSubAccess ( Operation * op)
static

Return if something is not a normal subaccess.

Non-normal includes zero-length vectors and constant indexes (which are really subindexes).

Definition at line 201 of file LowerTypes.cpp.

Referenced by getSAWritePath().

◆ isOneDimVectorType()

bool isOneDimVectorType ( FIRRTLType type)
static

Return true if the type is a 1d vector type or ground type.

Definition at line 101 of file LowerTypes.cpp.

References circt::firrtl::FIRRTLTypeSwitch< T, ResultT >::Case().

Referenced by isPreservableAggregateType().

◆ isPreservableAggregateType()

◆ mapLoweredType() [1/2]

FIRRTLType mapLoweredType ( FIRRTLType type,
FIRRTLBaseType fieldType )
static

Return fieldType or fieldType as same ref as type.

Definition at line 88 of file LowerTypes.cpp.

References circt::firrtl::mapBaseType().

Referenced by mapLoweredType().

◆ mapLoweredType() [2/2]

Type mapLoweredType ( Type type,
FIRRTLBaseType fieldType )
static

Return fieldType or fieldType as same ref as type.

Definition at line 93 of file LowerTypes.cpp.

References mapLoweredType(), and circt::firrtl::type_dyn_cast().

◆ peelType()

bool peelType ( Type type,
SmallVectorImpl< FlatBundleFieldEntry > & fields,
PreserveAggregate::PreserveMode mode )
static

Peel one layer of an aggregate type into its components.

Type may be complex, but empty, in which case fields is empty, but the return is true.

Definition at line 164 of file LowerTypes.cpp.

References circt::firrtl::FIRRTLTypeSwitch< T, ResultT >::Case(), isPreservableAggregateType(), and circt::firrtl::type_dyn_cast().