clang 23.0.0git
clang::interp::Integral< Bits, Signed > Class Template Reference

Wrapper around numeric types. More...

#include "/work/as-worker-4/publish-doxygen-docs/llvm-project/clang/lib/AST/ByteCode/Integral.h"

Inheritance diagram for clang::interp::Integral< Bits, Signed >:
[legend]

Public Types

using ReprT = typename Repr<Bits, Signed>::Type
using AsUnsigned = Integral<Bits, false>

Public Member Functions

 Integral ()
 Zero-initializes an integral.
template<unsigned SrcBits, bool SrcSign>
 Integral (Integral< SrcBits, SrcSign > V)
 Constructs an integral from another integral.
 Integral (IntegralKind Kind, const void *P, OffsetT Offset=0)
 Pointer integral of the given kind.
 Integral (const AddrLabelExpr *P1, const AddrLabelExpr *P2)
 AddrLabelDiff integral.
IntegralKind getKind () const
bool isNumber () const
const void * getPtr () const
ReprT getOffset () const
const AddrLabelExprgetLabel1 () const
const AddrLabelExprgetLabel2 () const
 Integral (const APSInt &V)
 Construct an integral from a value based on signedness.
bool operator< (Integral RHS) const
bool operator> (Integral RHS) const
bool operator<= (Integral RHS) const
bool operator>= (Integral RHS) const
bool operator== (Integral RHS) const
bool operator!= (Integral RHS) const
bool operator>= (unsigned RHS) const
bool operator> (unsigned RHS) const
Integral operator- () const
Integral operator- (const Integral &Other) const
Integral operator~ () const
template<unsigned DstBits, bool DstSign>
 operator Integral< DstBits, DstSign > () const
template<typename Ty, typename = std::enable_if_t<std::is_integral_v<Ty>>>
 operator Ty () const
APSInt toAPSInt () const
APSInt toAPSInt (unsigned BitWidth) const
APInt toAPInt (unsigned BitWidth) const
APValue toAPValue (const ASTContext &) const
Integral< Bits, falsetoUnsigned () const
bool isZero () const
bool isMin () const
bool isMinusOne () const
bool isNegative () const
bool isPositive () const
ComparisonCategoryResult compare (const Integral &RHS) const
void bitcastToMemory (std::byte *Dest) const
std::string toDiagnosticString (const ASTContext &Ctx) const
unsigned countLeadingZeros () const
Integral truncate (unsigned TruncBits) const
void print (llvm::raw_ostream &OS) const

Static Public Member Functions

static constexpr unsigned bitWidth ()
static constexpr bool isSigned ()
static Integral bitcastFromMemory (const std::byte *Src, unsigned BitWidth)
static Integral min (unsigned NumBits)
static Integral max (unsigned NumBits)
static Integral zero (unsigned BitWidth=0)
template<typename ValT>
static std::enable_if_t<!std::is_same_v< ValT, IntegralKind >, Integralfrom (ValT V, unsigned NumBits=0)
template<unsigned SrcBits, bool SrcSign>
static std::enable_if_t< SrcBits !=0, Integralfrom (Integral< SrcBits, SrcSign > V)
template<typename T>
static Integral from (IntegralKind Kind, T V)
static bool increment (Integral A, Integral *R)
static bool decrement (Integral A, Integral *R)
static bool add (Integral A, Integral B, unsigned OpBits, Integral *R)
static bool sub (Integral A, Integral B, unsigned OpBits, Integral *R)
static bool mul (Integral A, Integral B, unsigned OpBits, Integral *R)
static bool rem (Integral A, Integral B, unsigned OpBits, Integral *R)
static bool div (Integral A, Integral B, unsigned OpBits, Integral *R)
static bool bitAnd (Integral A, Integral B, unsigned OpBits, Integral *R)
static bool bitOr (Integral A, Integral B, unsigned OpBits, Integral *R)
static bool bitXor (Integral A, Integral B, unsigned OpBits, Integral *R)
static bool neg (Integral A, Integral *R)
static bool comp (Integral A, Integral *R)
template<unsigned RHSBits, bool RHSSign>
static void shiftLeft (const Integral A, const Integral< RHSBits, RHSSign > B, unsigned OpBits, Integral *R)
template<unsigned RHSBits, bool RHSSign>
static void shiftRight (const Integral A, const Integral< RHSBits, RHSSign > B, unsigned OpBits, Integral *R)

Friends

template<unsigned OtherBits, bool OtherSigned>
class Integral

Detailed Description

template<unsigned Bits, bool Signed>
class clang::interp::Integral< Bits, Signed >

Wrapper around numeric types.

These wrappers are required to shared an interface between APSint and builtin primitive numeral types, while optimising for storage and allowing methods operating on primitive type to compile to fast code.

Definition at line 69 of file Integral.h.

Member Typedef Documentation

◆ AsUnsigned

template<unsigned Bits, bool Signed>
using clang::interp::Integral< Bits, Signed >::AsUnsigned = Integral<Bits, false>

Definition at line 104 of file Integral.h.

◆ ReprT

template<unsigned Bits, bool Signed>
using clang::interp::Integral< Bits, Signed >::ReprT = typename Repr<Bits, Signed>::Type

Definition at line 74 of file Integral.h.

Constructor & Destructor Documentation

◆ Integral() [1/5]

template<unsigned Bits, bool Signed>
clang::interp::Integral< Bits, Signed >::Integral ( )
inline

Zero-initializes an integral.

Definition at line 107 of file Integral.h.

◆ Integral() [2/5]

template<unsigned Bits, bool Signed>
template<unsigned SrcBits, bool SrcSign>
clang::interp::Integral< Bits, Signed >::Integral ( Integral< SrcBits, SrcSign > V)
inlineexplicit

Constructs an integral from another integral.

Definition at line 111 of file Integral.h.

◆ Integral() [3/5]

template<unsigned Bits, bool Signed>
clang::interp::Integral< Bits, Signed >::Integral ( IntegralKind Kind,
const void * P,
OffsetT Offset = 0 )
inlineexplicit

Pointer integral of the given kind.

Definition at line 114 of file Integral.h.

◆ Integral() [4/5]

template<unsigned Bits, bool Signed>
clang::interp::Integral< Bits, Signed >::Integral ( const AddrLabelExpr * P1,
const AddrLabelExpr * P2 )
inlineexplicit

AddrLabelDiff integral.

Definition at line 121 of file Integral.h.

◆ Integral() [5/5]

template<unsigned Bits, bool Signed>
clang::interp::Integral< Bits, Signed >::Integral ( const APSInt & V)
inlineexplicit

Construct an integral from a value based on signedness.

Definition at line 149 of file Integral.h.

Member Function Documentation

◆ add()

template<unsigned Bits, bool Signed>
bool clang::interp::Integral< Bits, Signed >::add ( Integral< Bits, Signed > A,
Integral< Bits, Signed > B,
unsigned OpBits,
Integral< Bits, Signed > * R )
inlinestatic

Definition at line 349 of file Integral.h.

Referenced by clang::interp::Integral< Bits, false >::increment().

◆ bitAnd()

template<unsigned Bits, bool Signed>
bool clang::interp::Integral< Bits, Signed >::bitAnd ( Integral< Bits, Signed > A,
Integral< Bits, Signed > B,
unsigned OpBits,
Integral< Bits, Signed > * R )
inlinestatic

Definition at line 376 of file Integral.h.

◆ bitcastFromMemory()

template<unsigned Bits, bool Signed>
Integral clang::interp::Integral< Bits, Signed >::bitcastFromMemory ( const std::byte * Src,
unsigned BitWidth )
inlinestatic

Definition at line 252 of file Integral.h.

◆ bitcastToMemory()

template<unsigned Bits, bool Signed>
void clang::interp::Integral< Bits, Signed >::bitcastToMemory ( std::byte * Dest) const
inline

Definition at line 247 of file Integral.h.

◆ bitOr()

template<unsigned Bits, bool Signed>
bool clang::interp::Integral< Bits, Signed >::bitOr ( Integral< Bits, Signed > A,
Integral< Bits, Signed > B,
unsigned OpBits,
Integral< Bits, Signed > * R )
inlinestatic

Definition at line 382 of file Integral.h.

◆ bitWidth()

◆ bitXor()

template<unsigned Bits, bool Signed>
bool clang::interp::Integral< Bits, Signed >::bitXor ( Integral< Bits, Signed > A,
Integral< Bits, Signed > B,
unsigned OpBits,
Integral< Bits, Signed > * R )
inlinestatic

Definition at line 388 of file Integral.h.

◆ comp()

template<unsigned Bits, bool Signed>
bool clang::interp::Integral< Bits, Signed >::comp ( Integral< Bits, Signed > A,
Integral< Bits, Signed > * R )
inlinestatic

Definition at line 402 of file Integral.h.

◆ compare()

template<unsigned Bits, bool Signed>
ComparisonCategoryResult clang::interp::Integral< Bits, Signed >::compare ( const Integral< Bits, Signed > & RHS) const
inline

Definition at line 243 of file Integral.h.

◆ countLeadingZeros()

template<unsigned Bits, bool Signed>
unsigned clang::interp::Integral< Bits, Signed >::countLeadingZeros ( ) const
inline

Definition at line 267 of file Integral.h.

◆ decrement()

template<unsigned Bits, bool Signed>
bool clang::interp::Integral< Bits, Signed >::decrement ( Integral< Bits, Signed > A,
Integral< Bits, Signed > * R )
inlinestatic

Definition at line 344 of file Integral.h.

◆ div()

template<unsigned Bits, bool Signed>
bool clang::interp::Integral< Bits, Signed >::div ( Integral< Bits, Signed > A,
Integral< Bits, Signed > B,
unsigned OpBits,
Integral< Bits, Signed > * R )
inlinestatic

Definition at line 370 of file Integral.h.

◆ from() [1/3]

template<unsigned Bits, bool Signed>
template<unsigned SrcBits, bool SrcSign>
std::enable_if_t< SrcBits !=0, Integral > clang::interp::Integral< Bits, Signed >::from ( Integral< SrcBits, SrcSign > V)
inlinestatic

Definition at line 321 of file Integral.h.

◆ from() [2/3]

template<unsigned Bits, bool Signed>
template<typename T>
Integral clang::interp::Integral< Bits, Signed >::from ( IntegralKind Kind,
T V )
inlinestatic

Definition at line 335 of file Integral.h.

◆ from() [3/3]

template<unsigned Bits, bool Signed>
template<typename ValT>
std::enable_if_t<!std::is_same_v< ValT, IntegralKind >, Integral > clang::interp::Integral< Bits, Signed >::from ( ValT V,
unsigned NumBits = 0 )
inlinestatic

◆ getKind()

template<unsigned Bits, bool Signed>
IntegralKind clang::interp::Integral< Bits, Signed >::getKind ( ) const
inline

Definition at line 127 of file Integral.h.

◆ getLabel1()

template<unsigned Bits, bool Signed>
const AddrLabelExpr * clang::interp::Integral< Bits, Signed >::getLabel1 ( ) const
inline

Definition at line 139 of file Integral.h.

◆ getLabel2()

template<unsigned Bits, bool Signed>
const AddrLabelExpr * clang::interp::Integral< Bits, Signed >::getLabel2 ( ) const
inline

Definition at line 143 of file Integral.h.

◆ getOffset()

template<unsigned Bits, bool Signed>
ReprT clang::interp::Integral< Bits, Signed >::getOffset ( ) const
inline

Definition at line 134 of file Integral.h.

◆ getPtr()

template<unsigned Bits, bool Signed>
const void * clang::interp::Integral< Bits, Signed >::getPtr ( ) const
inline

Definition at line 129 of file Integral.h.

◆ increment()

template<unsigned Bits, bool Signed>
bool clang::interp::Integral< Bits, Signed >::increment ( Integral< Bits, Signed > A,
Integral< Bits, Signed > * R )
inlinestatic

Definition at line 339 of file Integral.h.

◆ isMin()

template<unsigned Bits, bool Signed>
bool clang::interp::Integral< Bits, Signed >::isMin ( ) const
inline

Definition at line 238 of file Integral.h.

Referenced by clang::interp::Integral< Bits, false >::neg().

◆ isMinusOne()

template<unsigned Bits, bool Signed>
bool clang::interp::Integral< Bits, Signed >::isMinusOne ( ) const
inline

Definition at line 239 of file Integral.h.

◆ isNegative()

template<unsigned Bits, bool Signed>
bool clang::interp::Integral< Bits, Signed >::isNegative ( ) const
inline

Definition at line 240 of file Integral.h.

Referenced by clang::interp::Integral< Bits, false >::isPositive().

◆ isNumber()

◆ isPositive()

template<unsigned Bits, bool Signed>
bool clang::interp::Integral< Bits, Signed >::isPositive ( ) const
inline

◆ isSigned()

template<unsigned Bits, bool Signed>
constexpr bool clang::interp::Integral< Bits, Signed >::isSigned ( )
inlinestaticconstexpr

Definition at line 235 of file Integral.h.

◆ isZero()

template<unsigned Bits, bool Signed>
bool clang::interp::Integral< Bits, Signed >::isZero ( ) const
inline

Definition at line 237 of file Integral.h.

◆ max()

template<unsigned Bits, bool Signed>
Integral clang::interp::Integral< Bits, Signed >::max ( unsigned NumBits)
inlinestatic

Definition at line 307 of file Integral.h.

◆ min()

template<unsigned Bits, bool Signed>
Integral clang::interp::Integral< Bits, Signed >::min ( unsigned NumBits)
inlinestatic

Definition at line 306 of file Integral.h.

Referenced by clang::interp::Integral< Bits, false >::isMin().

◆ mul()

template<unsigned Bits, bool Signed>
bool clang::interp::Integral< Bits, Signed >::mul ( Integral< Bits, Signed > A,
Integral< Bits, Signed > B,
unsigned OpBits,
Integral< Bits, Signed > * R )
inlinestatic

Definition at line 359 of file Integral.h.

◆ neg()

template<unsigned Bits, bool Signed>
bool clang::interp::Integral< Bits, Signed >::neg ( Integral< Bits, Signed > A,
Integral< Bits, Signed > * R )
inlinestatic

Definition at line 394 of file Integral.h.

◆ operator Integral< DstBits, DstSign >()

template<unsigned Bits, bool Signed>
template<unsigned DstBits, bool DstSign>
clang::interp::Integral< Bits, Signed >::operator Integral< DstBits, DstSign > ( ) const
inlineexplicit

Definition at line 173 of file Integral.h.

◆ operator Ty()

template<unsigned Bits, bool Signed>
template<typename Ty, typename = std::enable_if_t<std::is_integral_v<Ty>>>
clang::interp::Integral< Bits, Signed >::operator Ty ( ) const
inlineexplicit

Definition at line 178 of file Integral.h.

◆ operator!=()

template<unsigned Bits, bool Signed>
bool clang::interp::Integral< Bits, Signed >::operator!= ( Integral< Bits, Signed > RHS) const
inline

Definition at line 157 of file Integral.h.

◆ operator-() [1/2]

template<unsigned Bits, bool Signed>
Integral clang::interp::Integral< Bits, Signed >::operator- ( ) const
inline

Definition at line 166 of file Integral.h.

◆ operator-() [2/2]

template<unsigned Bits, bool Signed>
Integral clang::interp::Integral< Bits, Signed >::operator- ( const Integral< Bits, Signed > & Other) const
inline

Definition at line 167 of file Integral.h.

◆ operator<()

template<unsigned Bits, bool Signed>
bool clang::interp::Integral< Bits, Signed >::operator< ( Integral< Bits, Signed > RHS) const
inline

Definition at line 152 of file Integral.h.

◆ operator<=()

template<unsigned Bits, bool Signed>
bool clang::interp::Integral< Bits, Signed >::operator<= ( Integral< Bits, Signed > RHS) const
inline

Definition at line 154 of file Integral.h.

◆ operator==()

template<unsigned Bits, bool Signed>
bool clang::interp::Integral< Bits, Signed >::operator== ( Integral< Bits, Signed > RHS) const
inline

Definition at line 156 of file Integral.h.

◆ operator>() [1/2]

template<unsigned Bits, bool Signed>
bool clang::interp::Integral< Bits, Signed >::operator> ( Integral< Bits, Signed > RHS) const
inline

Definition at line 153 of file Integral.h.

◆ operator>() [2/2]

template<unsigned Bits, bool Signed>
bool clang::interp::Integral< Bits, Signed >::operator> ( unsigned RHS) const
inline

Definition at line 162 of file Integral.h.

◆ operator>=() [1/2]

template<unsigned Bits, bool Signed>
bool clang::interp::Integral< Bits, Signed >::operator>= ( Integral< Bits, Signed > RHS) const
inline

Definition at line 155 of file Integral.h.

◆ operator>=() [2/2]

template<unsigned Bits, bool Signed>
bool clang::interp::Integral< Bits, Signed >::operator>= ( unsigned RHS) const
inline

Definition at line 158 of file Integral.h.

◆ operator~()

template<unsigned Bits, bool Signed>
Integral clang::interp::Integral< Bits, Signed >::operator~ ( ) const
inline

Definition at line 170 of file Integral.h.

◆ print()

template<unsigned Bits, bool Signed>
void clang::interp::Integral< Bits, Signed >::print ( llvm::raw_ostream & OS) const
inline

Definition at line 287 of file Integral.h.

Referenced by clang::interp::operator<<().

◆ rem()

template<unsigned Bits, bool Signed>
bool clang::interp::Integral< Bits, Signed >::rem ( Integral< Bits, Signed > A,
Integral< Bits, Signed > B,
unsigned OpBits,
Integral< Bits, Signed > * R )
inlinestatic

Definition at line 364 of file Integral.h.

◆ shiftLeft()

template<unsigned Bits, bool Signed>
template<unsigned RHSBits, bool RHSSign>
void clang::interp::Integral< Bits, Signed >::shiftLeft ( const Integral< Bits, Signed > A,
const Integral< RHSBits, RHSSign > B,
unsigned OpBits,
Integral< Bits, Signed > * R )
inlinestatic

Definition at line 408 of file Integral.h.

◆ shiftRight()

template<unsigned Bits, bool Signed>
template<unsigned RHSBits, bool RHSSign>
void clang::interp::Integral< Bits, Signed >::shiftRight ( const Integral< Bits, Signed > A,
const Integral< RHSBits, RHSSign > B,
unsigned OpBits,
Integral< Bits, Signed > * R )
inlinestatic

Definition at line 414 of file Integral.h.

◆ sub()

template<unsigned Bits, bool Signed>
bool clang::interp::Integral< Bits, Signed >::sub ( Integral< Bits, Signed > A,
Integral< Bits, Signed > B,
unsigned OpBits,
Integral< Bits, Signed > * R )
inlinestatic

Definition at line 354 of file Integral.h.

Referenced by clang::interp::Integral< Bits, false >::decrement().

◆ toAPInt()

template<unsigned Bits, bool Signed>
APInt clang::interp::Integral< Bits, Signed >::toAPInt ( unsigned BitWidth) const
inline

Definition at line 191 of file Integral.h.

Referenced by clang::interp::Integral< Bits, false >::toAPSInt().

◆ toAPSInt() [1/2]

template<unsigned Bits, bool Signed>
APSInt clang::interp::Integral< Bits, Signed >::toAPSInt ( ) const
inline

Definition at line 182 of file Integral.h.

Referenced by clang::interp::Integral< Bits, false >::toAPValue().

◆ toAPSInt() [2/2]

template<unsigned Bits, bool Signed>
APSInt clang::interp::Integral< Bits, Signed >::toAPSInt ( unsigned BitWidth) const
inline

Definition at line 187 of file Integral.h.

◆ toAPValue()

template<unsigned Bits, bool Signed>
APValue clang::interp::Integral< Bits, Signed >::toAPValue ( const ASTContext & ) const
inline

Definition at line 201 of file Integral.h.

◆ toDiagnosticString()

template<unsigned Bits, bool Signed>
std::string clang::interp::Integral< Bits, Signed >::toDiagnosticString ( const ASTContext & Ctx) const
inline

Definition at line 260 of file Integral.h.

◆ toUnsigned()

template<unsigned Bits, bool Signed>
Integral< Bits, false > clang::interp::Integral< Bits, Signed >::toUnsigned ( ) const
inline

Definition at line 230 of file Integral.h.

◆ truncate()

template<unsigned Bits, bool Signed>
Integral clang::interp::Integral< Bits, Signed >::truncate ( unsigned TruncBits) const
inline

Definition at line 277 of file Integral.h.

◆ zero()

template<unsigned Bits, bool Signed>
Integral clang::interp::Integral< Bits, Signed >::zero ( unsigned BitWidth = 0)
inlinestatic

Definition at line 308 of file Integral.h.

◆ Integral

Member Data Documentation

◆ [struct]

struct { ... } clang::interp::Integral< Bits, Signed >::AddrLabelDiff

◆ L1

template<unsigned Bits, bool Signed>
const AddrLabelExpr* clang::interp::Integral< Bits, Signed >::L1

Definition at line 89 of file Integral.h.

◆ L2

template<unsigned Bits, bool Signed>
const AddrLabelExpr* clang::interp::Integral< Bits, Signed >::L2

Definition at line 90 of file Integral.h.

◆ Offset

template<unsigned Bits, bool Signed>
OffsetT clang::interp::Integral< Bits, Signed >::Offset

Definition at line 86 of file Integral.h.

◆ P

template<unsigned Bits, bool Signed>
const void* clang::interp::Integral< Bits, Signed >::P

Definition at line 85 of file Integral.h.

◆ [struct]

struct { ... } clang::interp::Integral< Bits, Signed >::Ptr

◆ V


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