15#ifndef CIRCT_SUPPORT_NPNCLASS_H
16#define CIRCT_SUPPORT_NPNCLASS_H
19#include "llvm/ADT/APInt.h"
20#include "llvm/ADT/ArrayRef.h"
21#include "llvm/ADT/SmallVector.h"
22#include "llvm/Support/raw_ostream.h"
48 const llvm::APInt &
table)
51 "Truth table size mismatch");
60 llvm::APInt
getOutput(
const llvm::APInt &input)
const;
63 void setOutput(
const llvm::APInt &input,
const llvm::APInt &output);
85 void dump(llvm::raw_ostream &os = llvm::errs())
const;
116 unsigned inputNeg,
unsigned outputNeg)
143 llvm::SmallVectorImpl<unsigned> &permutation)
const;
161 void dump(llvm::raw_ostream &os = llvm::errs())
const;
assert(baseType &&"element must be base type")
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Represents a boolean function as a truth table.
BinaryTruthTable()
Default constructor creates an empty truth table.
BinaryTruthTable(unsigned numInputs, unsigned numOutputs)
Constructor for a truth table with given dimensions, initialized to zero.
BinaryTruthTable applyOutputNegation(unsigned negation) const
Apply output negation to create a new truth table.
llvm::APInt table
Truth table data as a packed bit vector.
BinaryTruthTable applyInputNegation(unsigned mask) const
Apply input negation to create a new truth table.
unsigned numInputs
Number of inputs for this boolean function.
BinaryTruthTable(unsigned numInputs, unsigned numOutputs, const llvm::APInt &table)
Constructor for a truth table with given dimensions and evaluation data.
void dump(llvm::raw_ostream &os=llvm::errs()) const
Debug dump method for truth tables.
bool isLexicographicallySmaller(const BinaryTruthTable &other) const
Check if this truth table is lexicographically smaller than another.
bool operator==(const BinaryTruthTable &other) const
Equality comparison for truth tables.
llvm::APInt getOutput(const llvm::APInt &input) const
Get the output value for a given input combination.
BinaryTruthTable applyPermutation(ArrayRef< unsigned > permutation) const
Apply input permutation to create a new truth table.
void setOutput(const llvm::APInt &input, const llvm::APInt &output)
Set the output value for a given input combination.
unsigned numOutputs
Number of outputs for this boolean function.
Represents the canonical form of a boolean function under NPN equivalence.
NPNClass(const BinaryTruthTable &tt)
Constructor from a truth table.
unsigned outputNegation
Output negation mask.
static NPNClass computeNPNCanonicalForm(const BinaryTruthTable &tt)
Compute the canonical NPN form for a given truth table.
void getInputPermutation(const NPNClass &targetNPN, llvm::SmallVectorImpl< unsigned > &permutation) const
Get input permutation from this NPN class to another equivalent NPN class.
BinaryTruthTable truthTable
Canonical truth table.
void dump(llvm::raw_ostream &os=llvm::errs()) const
Debug dump method for NPN classes.
NPNClass()=default
Default constructor creates an empty NPN class.
bool equivalentOtherThanPermutation(const NPNClass &other) const
Equality comparison for NPN classes.
llvm::SmallVector< unsigned > inputPermutation
Input permutation applied.
unsigned inputNegation
Input negation mask.
bool isLexicographicallySmaller(const NPNClass &other) const
NPNClass(const BinaryTruthTable &tt, llvm::SmallVector< unsigned > inputPerm, unsigned inputNeg, unsigned outputNeg)