MLIR  20.0.0git
Classes | Typedefs | Functions | Variables
mlir::polynomial Namespace Reference

Classes

class  MonomialBase
 
class  IntMonomial
 A class representing a monomial of a single-variable polynomial with integer coefficients. More...
 
class  FloatMonomial
 A class representing a monomial of a single-variable polynomial with integer coefficients. More...
 
class  PolynomialBase
 
class  IntPolynomial
 A single-variable polynomial with integer coefficients. More...
 
class  FloatPolynomial
 A single-variable polynomial with double coefficients. More...
 

Typedefs

template<typename MonomialType >
using ParseCoefficientFn = std::function< OptionalParseResult(MonomialType &)>
 A callable that parses the coefficient using the appropriate method for the given monomial type, and stores the parsed coefficient value on the monomial. More...
 

Functions

template<class D , typename T >
inline ::llvm::hash_code hash_value (const PolynomialBase< D, T > &arg)
 
template<class D , typename T >
inline ::llvm::hash_code hash_value (const MonomialBase< D, T > &arg)
 
template<class D , typename T >
raw_ostream & operator<< (raw_ostream &os, const PolynomialBase< D, T > &polynomial)
 
template<typename PolyT , typename MonomialT >
FailureOr< PolyT > fromMonomialsImpl (ArrayRef< MonomialT > monomials)
 
template<typename PolyT , typename MonomialT , typename CoeffT >
PolyT fromCoefficientsImpl (ArrayRef< CoeffT > coeffs)
 
template<typename Monomial >
ParseResult parseMonomial (AsmParser &parser, Monomial &monomial, llvm::StringRef &variable, bool &isConstantTerm, bool &shouldParseMore, ParseCoefficientFn< Monomial > parseAndStoreCoefficient)
 Try to parse a monomial. More...
 
template<typename Monomial >
LogicalResult parsePolynomialAttr (AsmParser &parser, llvm::SmallVector< Monomial > &monomials, llvm::StringSet<> &variables, ParseCoefficientFn< Monomial > parseAndStoreCoefficient)
 

Variables

constexpr unsigned apintBitWidth = 64
 This restricts statically defined polynomials to have at most 64-bit coefficients. More...
 

Typedef Documentation

◆ ParseCoefficientFn

template<typename MonomialType >
using mlir::polynomial::ParseCoefficientFn = typedef std::function<OptionalParseResult(MonomialType &)>

A callable that parses the coefficient using the appropriate method for the given monomial type, and stores the parsed coefficient value on the monomial.

Definition at line 32 of file PolynomialAttributes.cpp.

Function Documentation

◆ fromCoefficientsImpl()

template<typename PolyT , typename MonomialT , typename CoeffT >
PolyT mlir::polynomial::fromCoefficientsImpl ( ArrayRef< CoeffT >  coeffs)

Definition at line 45 of file Polynomial.cpp.

◆ fromMonomialsImpl()

template<typename PolyT , typename MonomialT >
FailureOr<PolyT> mlir::polynomial::fromMonomialsImpl ( ArrayRef< MonomialT >  monomials)

Definition at line 17 of file Polynomial.cpp.

◆ hash_value() [1/2]

template<class D , typename T >
inline ::llvm::hash_code mlir::polynomial::hash_value ( const MonomialBase< D, T > &  arg)

Definition at line 267 of file Polynomial.h.

◆ hash_value() [2/2]

template<class D , typename T >
inline ::llvm::hash_code mlir::polynomial::hash_value ( const PolynomialBase< D, T > &  arg)

◆ operator<<()

template<class D , typename T >
raw_ostream& mlir::polynomial::operator<< ( raw_ostream &  os,
const PolynomialBase< D, T > &  polynomial 
)
inline

◆ parseMonomial()

template<typename Monomial >
ParseResult mlir::polynomial::parseMonomial ( AsmParser parser,
Monomial &  monomial,
llvm::StringRef &  variable,
bool &  isConstantTerm,
bool &  shouldParseMore,
ParseCoefficientFn< Monomial >  parseAndStoreCoefficient 
)

Try to parse a monomial.

If successful, populate the fields of the outparam monomial with the results, and the variable outparam with the parsed variable name. Sets shouldParseMore to true if the monomial is followed by a '+'.

Definition at line 41 of file PolynomialAttributes.cpp.

References apintBitWidth, mlir::AsmParser::emitError(), mlir::AsmParser::getCurrentLocation(), mlir::OptionalParseResult::has_value(), mlir::AsmParser::parseInteger(), mlir::AsmParser::parseOptionalKeyword(), mlir::AsmParser::parseOptionalPlus(), mlir::AsmParser::parseOptionalStar(), and mlir::AsmParser::parseStar().

◆ parsePolynomialAttr()

template<typename Monomial >
LogicalResult mlir::polynomial::parsePolynomialAttr ( AsmParser parser,
llvm::SmallVector< Monomial > &  monomials,
llvm::StringSet<> &  variables,
ParseCoefficientFn< Monomial >  parseAndStoreCoefficient 
)

Variable Documentation

◆ apintBitWidth

constexpr unsigned mlir::polynomial::apintBitWidth = 64
constexpr

This restricts statically defined polynomials to have at most 64-bit coefficients.

This may be relaxed in the future, but it seems unlikely one would want to specify 128-bit polynomials statically in the source code.

Definition at line 30 of file Polynomial.h.

Referenced by parseMonomial().