11#include "mlir/IR/Value.h"
12#include "llvm/ADT/APInt.h"
13#include "llvm/ADT/SmallVector.h"
14#include "llvm/Support/raw_ostream.h"
51llvm::raw_ostream &
operator<<(llvm::raw_ostream &os,
const DNFTerm &term);
52llvm::raw_ostream &
operator<<(llvm::raw_ostream &os,
const DNF &dnf);
75 return llvm::countr_zero(
bits.getBitWidth());
85 assert(numTerms <= 16 &&
"excessive truth table");
86 return TruthTable{value ? APInt::getAllOnes(1 << numTerms)
87 : APInt::getZero(1 << numTerms)};
92 assert(numTerms <= 16 &&
"excessive truth table");
119 return APInt::getSplat(bitWidth,
120 APInt::getHighBitsSet(2 << term, 1 << term));
130llvm::raw_ostream &
operator<<(llvm::raw_ostream &os,
const TruthTable &table);
147 return Value::getFromOpaquePointer((
void *)(1));
161 SmallVector<std::pair<TruthTable, ValueEntry>, 1>
entries;
165 :
entries({{condition, entry}}) {}
172llvm::raw_ostream &
operator<<(llvm::raw_ostream &os,
const ValueEntry &entry);
173llvm::raw_ostream &
operator<<(llvm::raw_ostream &os,
174 const std::pair<TruthTable, ValueEntry> &pair);
175llvm::raw_ostream &
operator<<(llvm::raw_ostream &os,
const ValueTable &table);
192 operator bool()
const {
return bool(
reset); }
208 operator bool()
const {
return bool(
clock); }
250 operator bool()
const {
return bool(
value); }
263 return llvm::hash_combine_range(arg.begin(), arg.end());
284 return hash_value(key);
303 return hash_value(key);
assert(baseType &&"element must be base type")
llvm::raw_ostream & operator<<(llvm::raw_ostream &os, const DNFTerm &term)
SmallVector< FixedValue, 2 > FixedValues
A list of i1 values that are fixed to a given value.
static llvm::hash_code hash_value(const FixedValue &arg)
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
A single clock extracted from a process during trigger analysis.
Value clock
The value acting as the clock, causing the register to be set to a value in valueTable when triggered...
bool risingEdge
Whether the clock is sensitive to a rising or falling edge.
Value value
The value the register is set to when the clock is triggered.
Value enable
The optional value acting as an enable.
A single AND operation within a DNF.
uint32_t andTerms
A mask with two bits for each possible term that may be present.
bool operator==(DNFTerm other) const
bool operator!=(DNFTerm other) const
A boolean function expressed in canonical disjunctive normal form.
SmallVector< DNFTerm, 2 > orTerms
A drive op and the clock and reset that resulted from trigger analysis.
ClockInfo clock
The clock that triggers a change to the driven value.
DrvOp op
The drive operation.
ResetInfo reset
The optional reset that triggers a change of the driven value to a fixed reset value.
A single i1 value that is fixed to a given value in the past and the present.
bool present
The assigned value in the present.
bool past
The assigned value in the past, as transported into the presented via a destination operand of a proc...
bool operator==(const FixedValue &other) const
Value value
The IR value being fixed.
A single reset extracted from a process during trigger analysis.
Value value
The value the register is reset to.
Value reset
The value acting as the reset, causing the register to be set to value when triggered.
bool activeHigh
Whether the reset is active when high.
A boolean function expressed as a truth table.
static APInt getTermMask(unsigned bitWidth, unsigned term)
Return a mask that has a 1 in all truth table rows where term is 1, and a 0 otherwise.
bool operator!=(const TruthTable &other) const
DNF canonicalize() const
Convert the truth table into its canonical disjunctive normal form.
static TruthTable getTerm(unsigned numTerms, unsigned term)
Create a boolean expression consisting of a single term.
static TruthTable getPoison()
bool operator==(const TruthTable &other) const
APInt bits
The value of the boolean function for each possible combination of input term assignments.
TruthTable operator~() const
APInt getTermMask(unsigned term) const
unsigned getNumTerms() const
Get the number of terms in the truth table.
TruthTable operator&(const TruthTable &other) const
TruthTable operator^(const TruthTable &other) const
static TruthTable getConst(unsigned numTerms, bool value)
Create a boolean expression with a constant true or false value.
TruthTable operator|(const TruthTable &other) const
TruthTable & operator|=(const TruthTable &other)
TruthTable & operator&=(const TruthTable &other)
TruthTable & operator^=(const TruthTable &other)
A single entry in a value table.
static ValueEntry getUnknown()
bool operator!=(ValueEntry other) const
static ValueEntry getPoison()
void merge(ValueEntry other)
bool operator==(ValueEntry other) const
A table of SSA values and the conditions under which they appear.
SmallVector< std::pair< TruthTable, ValueEntry >, 1 > entries
void addCondition(TruthTable condition)
ValueTable(TruthTable condition, ValueEntry entry)
void merge(const ValueTable &other)
static FixedValue getTombstoneKey()
static FixedValue getEmptyKey()
static bool isEqual(const FixedValue &a, const FixedValue &b)
static unsigned getHashValue(const FixedValue &key)
static FixedValues getTombstoneKey()
static unsigned getHashValue(const FixedValues &key)
circt::llhd::deseq::FixedValues FixedValues
static FixedValues getEmptyKey()
static bool isEqual(const FixedValues &a, const FixedValues &b)