Loading [MathJax]/extensions/tex2jax.js
CIRCT 21.0.0git
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
circt::llhd::AndTerm Struct Reference

An individual term of an AND expression in a DNF. More...

#include <DNF.h>

Collaboration diagram for circt::llhd::AndTerm:
Collaboration graph
[legend]

Public Types

enum  Use {
  Id = 0b00 , Past = 0b01 , Not = 0b10 , NotId = Not | Id ,
  NotPast = Not | Past
}
 An integer indicating one use of the value in this term. More...
 
using Uses = std::bitset< 4 >
 The set of uses of this value as a bit mask.
 

Public Member Functions

 AndTerm ()
 Create a null term.
 
 AndTerm (Value value, Uses uses)
 Create a term with a value and a set of uses.
 
bool isFalse () const
 Check if this term is trivially false.
 
bool isTrue () const
 Check if this term is trivially true.
 
std::optional< std::pair< Value, AndTerm::Use > > getSingleTerm () const
 If this AND term has a single use, return it.
 
int compare (const AndTerm other) const
 Compare against another term.
 
bool operator== (const AndTerm other) const
 
bool operator!= (const AndTerm other) const
 
bool operator< (const AndTerm other) const
 
bool operator> (const AndTerm other) const
 
bool operator<= (const AndTerm other) const
 
bool operator>= (const AndTerm other) const
 
unsigned getNumUses () const
 Get the number of uses.
 
void addUse (Use u)
 Add a single use.
 
void addUses (Uses u)
 Add multiple uses.
 
void removeUse (Use u)
 Remove a single use.
 
void removeUses (Uses u)
 Remove multiple uses.
 
bool hasUse (Use u) const
 Check if this term has a specific use of the term's value.
 
bool hasAllUses (Uses u) const
 Check if this term has all of the specified uses of the term's value.
 
bool hasAnyUses (Uses u) const
 Check if this term has any of the specified uses of the term's value.
 
bool isSubsetOf (const AndTerm &other) const
 Check if this term is a subset of another term.
 
unsigned isSubsetOfModuloSingleFlip (const AndTerm &other, Use &flippedUse) const
 Check if this term is a subset of another term modulo a single flipped term.
 
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.
 

Static Public Member Functions

static AndTerm id (Value value)
 Create a term with a plain value.
 
static AndTerm past (Value value)
 Create a term with a past value.
 
static AndTerm posEdge (Value value)
 Create a term representing a posedge on a value.
 
static AndTerm negEdge (Value value)
 Create a term representing a negedge on a value.
 

Public Attributes

Value value
 The value.
 
Uses uses
 The different uses of this value.
 

Static Public Attributes

static constexpr Uses PosEdgeUses = (1 << Id) | (1 << NotPast)
 The set of uses that indicates a posedge.
 
static constexpr Uses NegEdgeUses = (1 << NotId) | (1 << Past)
 The set of uses that indicates a negedge.
 
static constexpr Uses IdUses = (1 << Id) | (1 << NotId)
 The set of present uses.
 
static constexpr Uses PastUses = (1 << Past) | (1 << NotPast)
 The set of past uses.
 

Detailed Description

An individual term of an AND expression in a DNF.

This struct represents all terms of the same Value.

Definition at line 20 of file DNF.h.

Member Typedef Documentation

◆ Uses

using circt::llhd::AndTerm::Uses = std::bitset<4>

The set of uses of this value as a bit mask.

Definition at line 37 of file DNF.h.

Member Enumeration Documentation

◆ Use

An integer indicating one use of the value in this term.

There are four different uses, which means there are a total of 2^4 different combinations each of which has its own bit in the uses mask.

Enumerator
Id 

The plain value x.

Past 

The past value @x.

Not 

The bit that indicates inversion.

NotId 

The inverted value !x.

NotPast 

The inverted past value !@x.

Definition at line 24 of file DNF.h.

Constructor & Destructor Documentation

◆ AndTerm() [1/2]

circt::llhd::AndTerm::AndTerm ( )
inline

Create a null term.

Definition at line 54 of file DNF.h.

Referenced by id(), negEdge(), past(), and posEdge().

◆ AndTerm() [2/2]

circt::llhd::AndTerm::AndTerm ( Value  value,
Uses  uses 
)
inline

Create a term with a value and a set of uses.

Definition at line 56 of file DNF.h.

Member Function Documentation

◆ addUse()

void circt::llhd::AndTerm::addUse ( Use  u)
inline

Add a single use.

Definition at line 92 of file DNF.h.

References uses.

◆ addUses()

void circt::llhd::AndTerm::addUses ( Uses  u)
inline

Add multiple uses.

Definition at line 94 of file DNF.h.

References uses.

◆ compare()

int AndTerm::compare ( const AndTerm  other) const

Compare against another term.

Definition at line 50 of file DNF.cpp.

References uses, and value.

Referenced by operator!=(), operator<(), operator<=(), operator==(), operator>(), and operator>=().

◆ getNumUses()

unsigned circt::llhd::AndTerm::getNumUses ( ) const
inline

Get the number of uses.

Definition at line 89 of file DNF.h.

References uses.

Referenced by getSingleTerm().

◆ getSingleTerm()

std::optional< std::pair< Value, AndTerm::Use > > circt::llhd::AndTerm::getSingleTerm ( ) const
inline

If this AND term has a single use, return it.

Definition at line 73 of file DNF.h.

References getNumUses(), uses, and value.

◆ hasAllUses()

bool circt::llhd::AndTerm::hasAllUses ( Uses  u) const
inline

Check if this term has all of the specified uses of the term's value.

Definition at line 103 of file DNF.h.

References uses.

◆ hasAnyUses()

bool circt::llhd::AndTerm::hasAnyUses ( Uses  u) const
inline

Check if this term has any of the specified uses of the term's value.

Definition at line 105 of file DNF.h.

References uses.

◆ hasUse()

bool circt::llhd::AndTerm::hasUse ( Use  u) const
inline

Check if this term has a specific use of the term's value.

Definition at line 101 of file DNF.h.

References uses.

◆ id()

static AndTerm circt::llhd::AndTerm::id ( Value  value)
inlinestatic

Create a term with a plain value.

Definition at line 58 of file DNF.h.

References AndTerm(), Id, and value.

◆ isFalse()

bool circt::llhd::AndTerm::isFalse ( ) const
inline

Check if this term is trivially false.

This is the case if it contains complementary uses, such as Id & !Id.

Definition at line 68 of file DNF.h.

References uses.

◆ isSubsetOf()

bool AndTerm::isSubsetOf ( const AndTerm other) const

Check if this term is a subset of another term.

For example, a & @a is considered a subset of a.

Definition at line 62 of file DNF.cpp.

References uses, and value.

◆ isSubsetOfModuloSingleFlip()

unsigned AndTerm::isSubsetOfModuloSingleFlip ( const AndTerm other,
Use flippedUse 
) const

Check if this term is a subset of another term modulo a single flipped term.

Returns 0 if this term is a subset of the other without any flips; returns 1 if there is a single flip, with flippedUse set to indicate the flipped term; or returns 2 if this term is no subset or there are more than one flips.

Definition at line 68 of file DNF.cpp.

References uses, and value.

◆ isTrue()

bool circt::llhd::AndTerm::isTrue ( ) const
inline

Check if this term is trivially true.

This is the case if there are no uses.

Definition at line 71 of file DNF.h.

References uses.

◆ negEdge()

static AndTerm circt::llhd::AndTerm::negEdge ( Value  value)
inlinestatic

Create a term representing a negedge on a value.

Definition at line 64 of file DNF.h.

References AndTerm(), NegEdgeUses, and value.

◆ operator!=()

bool circt::llhd::AndTerm::operator!= ( const AndTerm  other) const
inline

Definition at line 82 of file DNF.h.

References compare().

◆ operator<()

bool circt::llhd::AndTerm::operator< ( const AndTerm  other) const
inline

Definition at line 83 of file DNF.h.

References compare().

◆ operator<=()

bool circt::llhd::AndTerm::operator<= ( const AndTerm  other) const
inline

Definition at line 85 of file DNF.h.

References compare().

◆ operator==()

bool circt::llhd::AndTerm::operator== ( const AndTerm  other) const
inline

Definition at line 81 of file DNF.h.

References compare().

◆ operator>()

bool circt::llhd::AndTerm::operator> ( const AndTerm  other) const
inline

Definition at line 84 of file DNF.h.

References compare().

◆ operator>=()

bool circt::llhd::AndTerm::operator>= ( const AndTerm  other) const
inline

Definition at line 86 of file DNF.h.

References compare().

◆ past()

static AndTerm circt::llhd::AndTerm::past ( Value  value)
inlinestatic

Create a term with a past value.

Definition at line 60 of file DNF.h.

References AndTerm(), Past, and value.

Referenced by circt::llhd::DNF::withPastValue().

◆ posEdge()

static AndTerm circt::llhd::AndTerm::posEdge ( Value  value)
inlinestatic

Create a term representing a posedge on a value.

Definition at line 62 of file DNF.h.

References AndTerm(), PosEdgeUses, and value.

◆ print()

void AndTerm::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.

Definition at line 98 of file DNF.cpp.

References NegEdgeUses, Not, NotPast, Past, PosEdgeUses, and value.

◆ removeUse()

void circt::llhd::AndTerm::removeUse ( Use  u)
inline

Remove a single use.

Definition at line 96 of file DNF.h.

References uses.

◆ removeUses()

void circt::llhd::AndTerm::removeUses ( Uses  u)
inline

Remove multiple uses.

Definition at line 98 of file DNF.h.

References uses.

Member Data Documentation

◆ IdUses

constexpr Uses circt::llhd::AndTerm::IdUses = (1 << Id) | (1 << NotId)
staticconstexpr

The set of present uses.

Definition at line 44 of file DNF.h.

◆ NegEdgeUses

constexpr Uses circt::llhd::AndTerm::NegEdgeUses = (1 << NotId) | (1 << Past)
staticconstexpr

The set of uses that indicates a negedge.

Definition at line 42 of file DNF.h.

Referenced by negEdge(), and print().

◆ PastUses

constexpr Uses circt::llhd::AndTerm::PastUses = (1 << Past) | (1 << NotPast)
staticconstexpr

The set of past uses.

Definition at line 46 of file DNF.h.

◆ PosEdgeUses

constexpr Uses circt::llhd::AndTerm::PosEdgeUses = (1 << Id) | (1 << NotPast)
staticconstexpr

The set of uses that indicates a posedge.

Definition at line 40 of file DNF.h.

Referenced by posEdge(), and print().

◆ uses

Uses circt::llhd::AndTerm::uses

◆ value

Value circt::llhd::AndTerm::value

The documentation for this struct was generated from the following files: