CIRCT 21.0.0git
|
An individual term of an OR expression in a DNF. More...
#include <DNF.h>
Public Types | |
using | AndTerms = SmallVector< AndTerm, 1 > |
Public Member Functions | |
OrTerm () | |
Create a constant true term. | |
OrTerm (AndTerm singleTerm) | |
Create a term with a single element. | |
OrTerm (AndTerms andTerms) | |
Create a term with multiple elements. The terms must be sorted. | |
bool | isTrue () const |
Check if this term is trivially true. | |
bool | isFalse () const |
Check if this term is trivially false. | |
std::optional< std::pair< Value, AndTerm::Use > > | getSingleTerm () const |
If this OR term consists of a single term, return it. | |
bool | contains (const AndTerm &andTerm) const |
Check if this OR term contains a specific AND term. | |
int | compare (const OrTerm &other) const |
Compare against another term. | |
bool | operator== (const OrTerm &other) const |
bool | operator!= (const OrTerm &other) const |
bool | operator< (const OrTerm &other) const |
bool | operator> (const OrTerm &other) const |
bool | operator<= (const OrTerm &other) const |
bool | operator>= (const OrTerm &other) const |
bool | isSubsetOf (const OrTerm &other) const |
Check if this term is a subset of another term. | |
bool | isSubsetOfModuloSingleFlip (const OrTerm &other, unsigned &flippedIdx, AndTerm::Use &flippedUse) const |
Check if this term is a subset of another term modulo a single flipped term. | |
llvm::hash_code | flipInvariantHash () const |
Return a hash code for this term that is invariant to inversion of individual terms. | |
bool | addTerm (AndTerm term) |
Add an AndTerm . | |
bool | addTerms (ArrayRef< AndTerm > terms) |
Add multiple AndTerm s. | |
bool | isSortedAndUnique () const |
Check that all terms in this OrTerm are sorted. | |
std::optional< bool > | evaluate (llvm::function_ref< std::optional< bool >(Value, bool)> evaluateTerm) |
Try to evaluate this term to a constant true or false value. | |
void | print (llvm::raw_ostream &os, llvm::function_ref< void(Value)> printValue={}) const |
Print this term to os , using the given callback to print the value. | |
Public Attributes | |
AndTerms | andTerms |
An individual term of an OR expression in a DNF.
Consists of multiple terms AND-ed together. A true
value is represented as an empty list of AND terms, since the neutral element of the AND operation is true
.
using circt::llhd::OrTerm::AndTerms = SmallVector<AndTerm, 1> |
|
inline |
|
inline |
|
inline |
Create a term with multiple elements. The terms must be sorted.
Definition at line 136 of file DNF.h.
References assert(), and isSortedAndUnique().
bool OrTerm::addTerm | ( | AndTerm | term | ) |
Add an AndTerm
.
Returns false if adding the AndTerm
has made this OrTerm
trivially false.
Definition at line 245 of file DNF.cpp.
References andTerms, compareValueOnly(), circt::llhd::AndTerm::uses, and circt::llhd::AndTerm::value.
Referenced by addTerms().
bool OrTerm::addTerms | ( | ArrayRef< AndTerm > | terms | ) |
int OrTerm::compare | ( | const OrTerm & | other | ) | const |
Compare against another term.
Definition at line 150 of file DNF.cpp.
Referenced by operator!=(), operator<(), operator<=(), operator==(), operator>(), operator>=(), and circt::llhd::DNF::operator|().
bool OrTerm::contains | ( | const AndTerm & | andTerm | ) | const |
std::optional< bool > OrTerm::evaluate | ( | llvm::function_ref< std::optional< bool >(Value, bool)> | evaluateTerm | ) |
Try to evaluate this term to a constant true or false value.
Definition at line 275 of file DNF.cpp.
References andTerms, circt::llhd::AndTerm::Not, and circt::llhd::AndTerm::Past.
llvm::hash_code OrTerm::flipInvariantHash | ( | ) | const |
Return a hash code for this term that is invariant to inversion of individual terms.
Definition at line 230 of file DNF.cpp.
References andTerms, circt::llhd::AndTerm::uses, and circt::llhd::AndTerm::value.
|
inline |
|
inline |
bool OrTerm::isSortedAndUnique | ( | ) | const |
bool OrTerm::isSubsetOf | ( | const OrTerm & | other | ) | const |
bool OrTerm::isSubsetOfModuloSingleFlip | ( | const OrTerm & | other, |
unsigned & | flippedIdx, | ||
AndTerm::Use & | flippedUse | ||
) | const |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
void OrTerm::print | ( | llvm::raw_ostream & | os, |
llvm::function_ref< void(Value)> | printValue = {} |
||
) | const |
AndTerms circt::llhd::OrTerm::andTerms |
Definition at line 129 of file DNF.h.
Referenced by addTerm(), contains(), evaluate(), flipInvariantHash(), getSingleTerm(), isFalse(), isSortedAndUnique(), isSubsetOf(), isSubsetOfModuloSingleFlip(), isTrue(), OrTerm(), and print().