CIRCT 21.0.0git
|
#include "circt/Dialect/HW/HWAttributes.h"
#include "circt/Dialect/HW/HWDialect.h"
#include "circt/Dialect/HW/HWOps.h"
#include "circt/Dialect/HW/HWTypes.h"
#include "circt/Support/LLVM.h"
#include "mlir/IR/Diagnostics.h"
#include "mlir/IR/DialectImplementation.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "circt/Dialect/HW/HWAttributes.cpp.inc"
Go to the source code of this file.
Macros | |
#define | GET_ATTRDEF_CLASSES |
#define | GET_ATTRDEF_LIST |
Functions | |
static Attribute | parseParamExprWithOpcode (StringRef opcodeStr, DialectAsmParser &p, Type type) |
Internal method used for .mlir file parsing when parsing the "#hw.param.expr.mul" form of the attribute. | |
static std::string | canonicalizeFilename (const Twine &directory, const Twine &filename) |
static void | printSymbolName (AsmPrinter &p, StringAttr sym) |
static TypedAttr | foldBinaryOp (ArrayRef< TypedAttr > operands, llvm::function_ref< APInt(const APInt &, const APInt &)> calculate) |
Given a binary function, if the two operands are known constant integers, use the specified fold function to compute the result. | |
static TypedAttr | foldUnaryOp (ArrayRef< TypedAttr > operands, llvm::function_ref< APInt(const APInt &)> calculate) |
Given a unary function, if the operand is a known constant integer, use the specified fold function to compute the result. | |
static ParamExprAttr | dyn_castPE (PEO opcode, Attribute value) |
If the specified attribute is a ParamExprAttr with the specified opcode, return it. | |
static bool | paramExprOperandSortPredicate (Attribute lhs, Attribute rhs) |
This implements a < comparison for two operands to an associative operation imposing an ordering upon them. | |
static TypedAttr | simplifyAssocOp (PEO opcode, SmallVector< TypedAttr, 4 > &operands, llvm::function_ref< APInt(const APInt &, const APInt &)> calculateFn, llvm::function_ref< bool(const APInt &)> identityConstantFn, llvm::function_ref< bool(const APInt &)> destructiveConstantFn={}) |
Given a fully associative variadic integer operation, constant fold any constant operands and move them to the right. | |
static std::pair< TypedAttr, TypedAttr > | decomposeAddend (TypedAttr operand) |
Analyze an operand to an add. | |
static TypedAttr | getOneOfType (Type type) |
static TypedAttr | simplifyAdd (SmallVector< TypedAttr, 4 > &operands) |
static TypedAttr | simplifyMul (SmallVector< TypedAttr, 4 > &operands) |
static TypedAttr | simplifyAnd (SmallVector< TypedAttr, 4 > &operands) |
static TypedAttr | simplifyOr (SmallVector< TypedAttr, 4 > &operands) |
static TypedAttr | simplifyXor (SmallVector< TypedAttr, 4 > &operands) |
static TypedAttr | simplifyShl (SmallVector< TypedAttr, 4 > &operands) |
static TypedAttr | simplifyShrU (SmallVector< TypedAttr, 4 > &operands) |
static TypedAttr | simplifyShrS (SmallVector< TypedAttr, 4 > &operands) |
static TypedAttr | simplifyDivU (SmallVector< TypedAttr, 4 > &operands) |
static TypedAttr | simplifyDivS (SmallVector< TypedAttr, 4 > &operands) |
static TypedAttr | simplifyModU (SmallVector< TypedAttr, 4 > &operands) |
static TypedAttr | simplifyModS (SmallVector< TypedAttr, 4 > &operands) |
static TypedAttr | simplifyCLog2 (SmallVector< TypedAttr, 4 > &operands) |
static TypedAttr | simplifyStrConcat (SmallVector< TypedAttr, 4 > &operands) |
static FailureOr< Attribute > | replaceDeclRefInExpr (Location loc, const std::map< std::string, Attribute > ¶meters, Attribute paramAttr, bool emitErrors) |
template<typename TArray > | |
FailureOr< Type > | evaluateParametricArrayType (Location loc, ArrayAttr parameters, TArray arrayType, bool emitErrors) |
static bool | isParamAttrWithParamRef (Attribute expr) |
#define GET_ATTRDEF_CLASSES |
Definition at line 34 of file HWAttributes.cpp.
#define GET_ATTRDEF_LIST |
|
static |
Definition at line 72 of file HWAttributes.cpp.
|
static |
Analyze an operand to an add.
If it is a multiplication by a constant (e.g. (a*b*42)
then split it into the non-constant and the constant portions (e.g. a*b
and 42
). Otherwise return the operand as the first value and null as the second (standin for "multiplication by 1").
Definition at line 613 of file HWAttributes.cpp.
References dyn_castPE().
Referenced by simplifyAdd().
|
static |
If the specified attribute is a ParamExprAttr with the specified opcode, return it.
Otherwise return null.
Definition at line 476 of file HWAttributes.cpp.
Referenced by decomposeAddend(), and simplifyMul().
FailureOr< Type > evaluateParametricArrayType | ( | Location | loc, |
ArrayAttr | parameters, | ||
TArray | arrayType, | ||
bool | emitErrors | ||
) |
Definition at line 1020 of file HWAttributes.cpp.
References elementType, circt::hw::evaluateParametricAttr(), and circt::hw::evaluateParametricType().
|
static |
Given a binary function, if the two operands are known constant integers, use the specified fold function to compute the result.
Definition at line 452 of file HWAttributes.cpp.
References assert().
Referenced by simplifyDivS(), simplifyDivU(), simplifyModS(), simplifyModU(), simplifyShrS(), and simplifyShrU().
|
static |
Given a unary function, if the operand is a known constant integer, use the specified fold function to compute the result.
Definition at line 466 of file HWAttributes.cpp.
References assert().
Referenced by simplifyCLog2().
|
static |
Definition at line 622 of file HWAttributes.cpp.
Referenced by simplifyAdd().
|
static |
Definition at line 1070 of file HWAttributes.cpp.
References isParamAttrWithParamRef().
Referenced by isParamAttrWithParamRef(), and circt::hw::isParametricType().
|
static |
This implements a < comparison for two operands to an associative operation imposing an ordering upon them.
The ordering provided puts more complex things to the start of the list, from left to right: expressions :: verbatims :: decl.refs :: constant
Definition at line 490 of file HWAttributes.cpp.
References paramExprOperandSortPredicate().
Referenced by paramExprOperandSortPredicate().
|
static |
Internal method used for .mlir file parsing when parsing the "#hw.param.expr.mul" form of the attribute.
Definition at line 921 of file HWAttributes.cpp.
|
static |
Definition at line 236 of file HWAttributes.cpp.
|
static |
Definition at line 950 of file HWAttributes.cpp.
References replaceDeclRefInExpr().
Referenced by replaceDeclRefInExpr().
|
static |
Definition at line 626 of file HWAttributes.cpp.
References decomposeAddend(), getOneOfType(), and simplifyAssocOp().
|
static |
Definition at line 705 of file HWAttributes.cpp.
References simplifyAssocOp().
|
static |
Given a fully associative variadic integer operation, constant fold any constant operands and move them to the right.
If the whole expression is constant, then return that, otherwise update the operands list.
Definition at line 555 of file HWAttributes.cpp.
Referenced by simplifyAdd(), simplifyAnd(), simplifyMul(), simplifyOr(), and simplifyXor().
|
static |
Definition at line 804 of file HWAttributes.cpp.
References assert(), foldUnaryOp(), and circt::hw::isHWIntegerType().
|
static |
Definition at line 774 of file HWAttributes.cpp.
References assert(), foldBinaryOp(), and circt::hw::isHWIntegerType().
|
static |
Definition at line 764 of file HWAttributes.cpp.
References assert(), foldBinaryOp(), and circt::hw::isHWIntegerType().
|
static |
Definition at line 794 of file HWAttributes.cpp.
References assert(), foldBinaryOp(), and circt::hw::isHWIntegerType().
|
static |
Definition at line 784 of file HWAttributes.cpp.
References assert(), foldBinaryOp(), and circt::hw::isHWIntegerType().
|
static |
Definition at line 675 of file HWAttributes.cpp.
References dyn_castPE(), and simplifyAssocOp().
|
static |
Definition at line 712 of file HWAttributes.cpp.
References simplifyAssocOp().
|
static |
Definition at line 725 of file HWAttributes.cpp.
References assert(), and circt::hw::isHWIntegerType().
|
static |
Definition at line 754 of file HWAttributes.cpp.
References assert(), foldBinaryOp(), and circt::hw::isHWIntegerType().
|
static |
Definition at line 744 of file HWAttributes.cpp.
References assert(), foldBinaryOp(), and circt::hw::isHWIntegerType().
|
static |
Definition at line 812 of file HWAttributes.cpp.
References assert().
|
static |
Definition at line 719 of file HWAttributes.cpp.
References simplifyAssocOp().