CIRCT
18.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. More... | |
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. More... | |
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. More... | |
static ParamExprAttr | dyn_castPE (PEO opcode, Attribute value) |
If the specified attribute is a ParamExprAttr with the specified opcode, return it. More... | |
static bool | paramExprOperandSortPredicate (Attribute lhs, Attribute rhs) |
This implements a < comparison for two operands to an associative operation imposing an ordering upon them. More... | |
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. More... | |
static std::pair< TypedAttr, TypedAttr > | decomposeAddend (TypedAttr operand) |
Analyze an operand to an add. More... | |
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.
References append().
|
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 611 of file HWAttributes.cpp.
References dyn_castPE(), and circt::calyx::direction::get().
Referenced by simplifyAdd().
|
static |
If the specified attribute is a ParamExprAttr with the specified opcode, return it.
Otherwise return null.
Definition at line 474 of file HWAttributes.cpp.
References value.
Referenced by decomposeAddend(), and simplifyMul().
FailureOr<Type> evaluateParametricArrayType | ( | Location | loc, |
ArrayAttr | parameters, | ||
TArray | arrayType, | ||
bool | emitErrors | ||
) |
Definition at line 1018 of file HWAttributes.cpp.
|
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 450 of file HWAttributes.cpp.
References assert(), and circt::calyx::direction::get().
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 464 of file HWAttributes.cpp.
References assert(), and circt::calyx::direction::get().
Referenced by simplifyCLog2().
|
static |
Definition at line 620 of file HWAttributes.cpp.
References circt::calyx::direction::get().
Referenced by simplifyAdd().
|
static |
Definition at line 1068 of file HWAttributes.cpp.
|
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 488 of file HWAttributes.cpp.
|
static |
Internal method used for .mlir file parsing when parsing the "#hw.param.expr.mul" form of the attribute.
Definition at line 919 of file HWAttributes.cpp.
|
static |
Definition at line 233 of file HWAttributes.cpp.
|
static |
Definition at line 948 of file HWAttributes.cpp.
|
static |
Definition at line 624 of file HWAttributes.cpp.
References decomposeAddend(), circt::calyx::direction::get(), getOneOfType(), and simplifyAssocOp().
|
static |
Definition at line 703 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 553 of file HWAttributes.cpp.
Referenced by simplifyAdd(), simplifyAnd(), simplifyMul(), simplifyOr(), and simplifyXor().
|
static |
Definition at line 802 of file HWAttributes.cpp.
References assert(), foldUnaryOp(), and circt::hw::isHWIntegerType().
|
static |
Definition at line 772 of file HWAttributes.cpp.
References assert(), foldBinaryOp(), and circt::hw::isHWIntegerType().
|
static |
Definition at line 762 of file HWAttributes.cpp.
References assert(), foldBinaryOp(), and circt::hw::isHWIntegerType().
|
static |
Definition at line 792 of file HWAttributes.cpp.
References assert(), foldBinaryOp(), circt::calyx::direction::get(), and circt::hw::isHWIntegerType().
|
static |
Definition at line 782 of file HWAttributes.cpp.
References assert(), foldBinaryOp(), circt::calyx::direction::get(), and circt::hw::isHWIntegerType().
|
static |
Definition at line 673 of file HWAttributes.cpp.
References dyn_castPE(), circt::calyx::direction::get(), and simplifyAssocOp().
|
static |
Definition at line 710 of file HWAttributes.cpp.
References simplifyAssocOp().
|
static |
Definition at line 723 of file HWAttributes.cpp.
References assert(), circt::calyx::direction::get(), and circt::hw::isHWIntegerType().
|
static |
Definition at line 752 of file HWAttributes.cpp.
References assert(), foldBinaryOp(), and circt::hw::isHWIntegerType().
|
static |
Definition at line 742 of file HWAttributes.cpp.
References assert(), foldBinaryOp(), and circt::hw::isHWIntegerType().
|
static |
Definition at line 810 of file HWAttributes.cpp.
References assert(), and circt::calyx::direction::get().
|
static |
Definition at line 717 of file HWAttributes.cpp.
References simplifyAssocOp().