11 #include "llvm/Support/KnownBits.h"
13 using namespace circt;
23 Operation *op = v.getDefiningOp();
24 if (!op || depth == 5)
25 return KnownBits(v.getType().getIntOrFloatBitWidth());
28 if (
auto constant = dyn_cast<hw::ConstantOp>(op))
29 return KnownBits::makeConstant(constant.getValue());
32 if (
auto concatOp = dyn_cast<ConcatOp>(op)) {
34 for (
size_t i = 1, e = concatOp.getNumOperands(); i != e; ++i) {
36 unsigned width = otherBits.getBitWidth();
37 unsigned newWidth = result.getBitWidth() +
width;
39 (result.Zero.zext(newWidth) <<
width) | otherBits.Zero.zext(newWidth);
41 (result.One.zext(newWidth) <<
width) | otherBits.One.zext(newWidth);
47 if (
auto andOp = dyn_cast<AndOp>(op)) {
49 for (
size_t i = 1, e = andOp.getNumOperands(); i != e; ++i)
55 if (
auto orOp = dyn_cast<OrOp>(op)) {
57 for (
size_t i = 1, e = orOp.getNumOperands(); i != e; ++i)
63 if (
auto xorOp = dyn_cast<XorOp>(op)) {
65 for (
size_t i = 1, e = xorOp.getNumOperands(); i != e; ++i) {
67 if (result.isUnknown())
75 if (
auto muxOp = dyn_cast<MuxOp>(op)) {
78 return lhs.intersectWith(rhs);
81 return KnownBits(v.getType().getIntOrFloatBitWidth());
static KnownBits computeKnownBits(Value v, unsigned depth)
Given an integer SSA value, check to see if we know anything about the result of the computation.
KnownBits computeKnownBits(Value value)
Compute "known bits" information about the specified value - the set of bits that are guaranteed to a...
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.