16 #include "mlir/IR/DialectImplementation.h"
17 #include "llvm/ADT/TypeSwitch.h"
19 using namespace circt;
21 using mlir::AsmParser;
22 using mlir::AsmPrinter;
28 Attribute FVIntegerAttr::parse(AsmParser &p, Type) {
33 if (p.parseLess() ||
parseFVInt(p, value) || p.parseColon() ||
34 p.getCurrentLocation(&widthLoc) || p.parseInteger(width) ||
41 if (width < neededBits) {
42 p.emitError(widthLoc) <<
"integer literal requires at least " << neededBits
43 <<
" bits, but attribute specifies only " << width;
50 void FVIntegerAttr::print(AsmPrinter &p)
const {
53 p <<
" : " << getValue().getBitWidth() <<
">";
60 #define GET_ATTRDEF_CLASSES
61 #include "circt/Dialect/Moore/MooreAttributes.cpp.inc"
63 void MooreDialect::registerAttributes() {
65 #define GET_ATTRDEF_LIST
66 #include "circt/Dialect/Moore/MooreAttributes.cpp.inc"
Four-valued arbitrary precision integers.
FVInt sextOrTrunc(unsigned bitWidth) const
Truncate or sign-extend to a target bit width.
bool isNegative() const
Determine whether the integer interpreted as a signed number would be negative.
unsigned getSignificantBits() const
Compute the minimum bit width necessary to accurately represent this integer's value and sign.
unsigned getActiveBits() const
Compute the number of active bits in the value.
Direction get(bool isOutput)
Returns an output direction if isOutput is true, otherwise returns an input direction.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
void printFVInt(AsmPrinter &p, const FVInt &value)
Print a four-valued integer usign an AsmPrinter.
ParseResult parseFVInt(AsmParser &p, FVInt &result)
Parse a four-valued integer using an AsmParser.