LLZK 3.0.0
An open-source IR for Zero Knowledge (ZK) circuits
Loading...
Searching...
No Matches
llzk::cast Namespace Reference

Namespaces

namespace  detail

Classes

class  CastDialect
 LLZK type conversion operations. More...
class  FeltToIndexOp
class  FeltToIndexOpAdaptor
class  FeltToIndexOpGenericAdaptor
class  IntToFeltOp
class  IntToFeltOpAdaptor
class  IntToFeltOpGenericAdaptor

Enumerations

enum class  OverflowSemantics : uint32_t { ASSERT = 0 , SATURATE = 1 , WRAP = 2 , TRUNCATE = 3 }

Functions

std::optional< DynamicAPInt > applyIntToFeltOverflow (const DynamicAPInt &value, const Field &field, OverflowSemantics overflow)
std::optional< DynamicAPInt > applyFeltToIndexOverflow (const DynamicAPInt &value, unsigned indexBitWidth, OverflowSemantics overflow)
::llvm::StringRef stringifyOverflowSemantics (OverflowSemantics val)
::std::optional< OverflowSemantics > symbolizeOverflowSemantics (::llvm::StringRef str)
::std::optional< OverflowSemantics > symbolizeOverflowSemantics (uint32_t value)
constexpr unsigned getMaxEnumValForOverflowSemantics ()
inline ::llvm::StringRef stringifyEnum (OverflowSemantics enumValue)
template<typename EnumType>
::std::optional< EnumType > symbolizeEnum (::llvm::StringRef)
template<>
inline ::std::optional< OverflowSemantics > symbolizeEnum< OverflowSemantics > (::llvm::StringRef str)
std::optional< llvm::DynamicAPInt > applyIntToFeltOverflow (const llvm::DynamicAPInt &value, const Field &field, OverflowSemantics overflow)
 Apply overflow semantics for an integer-to-felt conversion.
std::optional< llvm::DynamicAPInt > applyFeltToIndexOverflow (const llvm::DynamicAPInt &value, unsigned indexBitWidth, OverflowSemantics overflow)
 Apply overflow semantics for a felt-to-index conversion.

Enumeration Type Documentation

◆ OverflowSemantics

enum class llzk::cast::OverflowSemantics : uint32_t
strong
Enumerator
ASSERT 
SATURATE 
WRAP 
TRUNCATE 

Definition at line 13 of file Enums.h.inc.

Function Documentation

◆ applyFeltToIndexOverflow() [1/2]

std::optional< DynamicAPInt > llzk::cast::applyFeltToIndexOverflow ( const DynamicAPInt & value,
unsigned indexBitWidth,
OverflowSemantics overflow )

Definition at line 41 of file OverflowSemantics.cpp.

◆ applyFeltToIndexOverflow() [2/2]

std::optional< llvm::DynamicAPInt > llzk::cast::applyFeltToIndexOverflow ( const llvm::DynamicAPInt & value,
unsigned indexBitWidth,
OverflowSemantics overflow )

Apply overflow semantics for a felt-to-index conversion.

indexBitWidth is the storage width; results are always in its nonnegative safe range. Returns nullopt when assert semantics reject the input.

◆ applyIntToFeltOverflow() [1/2]

std::optional< DynamicAPInt > llzk::cast::applyIntToFeltOverflow ( const DynamicAPInt & value,
const Field & field,
OverflowSemantics overflow )

Definition at line 27 of file OverflowSemantics.cpp.

◆ applyIntToFeltOverflow() [2/2]

std::optional< llvm::DynamicAPInt > llzk::cast::applyIntToFeltOverflow ( const llvm::DynamicAPInt & value,
const Field & field,
OverflowSemantics overflow )

Apply overflow semantics for an integer-to-felt conversion.

Returns nullopt when assert semantics reject the input. Otherwise, the result is always in [0, p).

◆ getMaxEnumValForOverflowSemantics()

unsigned llzk::cast::getMaxEnumValForOverflowSemantics ( )
inlineconstexpr

Definition at line 23 of file Enums.h.inc.

◆ stringifyEnum()

inline ::llvm::StringRef llzk::cast::stringifyEnum ( OverflowSemantics enumValue)

Definition at line 28 of file Enums.h.inc.

◆ stringifyOverflowSemantics()

llvm::StringRef llzk::cast::stringifyOverflowSemantics ( OverflowSemantics val)

Definition at line 12 of file Enums.cpp.inc.

◆ symbolizeEnum()

template<typename EnumType>
::std::optional< EnumType > llzk::cast::symbolizeEnum ( ::llvm::StringRef )

◆ symbolizeEnum< OverflowSemantics >()

template<>
inline ::std::optional< OverflowSemantics > llzk::cast::symbolizeEnum< OverflowSemantics > ( ::llvm::StringRef str)

Definition at line 33 of file Enums.h.inc.

◆ symbolizeOverflowSemantics() [1/2]

std::optional< OverflowSemantics > llzk::cast::symbolizeOverflowSemantics ( ::llvm::StringRef str)

Definition at line 22 of file Enums.cpp.inc.

◆ symbolizeOverflowSemantics() [2/2]

std::optional< OverflowSemantics > llzk::cast::symbolizeOverflowSemantics ( uint32_t value)

Definition at line 30 of file Enums.cpp.inc.