LLVM 20.0.0git
Public Types | Public Member Functions | Static Public Member Functions | List of all members
llvm::GIConstant Class Reference

An integer-like constant. More...

#include "llvm/CodeGen/GlobalISel/Utils.h"

Public Types

enum class  GIConstantKind { Scalar , FixedVector , ScalableVector }
 

Public Member Functions

 GIConstant (ArrayRef< APInt > Values)
 
 GIConstant (const APInt &Value, GIConstantKind Kind)
 
GIConstantKind getKind () const
 Returns the kind of of this constant, e.g, Scalar.
 
APInt getScalarValue () const
 Returns the value, if this constant is a scalar.
 

Static Public Member Functions

static std::optional< GIConstantgetConstant (Register Const, const MachineRegisterInfo &MRI)
 

Detailed Description

An integer-like constant.

It abstracts over scalar, fixed-length vectors, and scalable vectors. In the common case, it provides a common API and feels like an APInt, while still providing low-level access. It can be used for constant-folding.

bool isZero() abstracts over the kind.

switch(const.getKind()) { } provides low-level access.

Definition at line 606 of file Utils.h.

Member Enumeration Documentation

◆ GIConstantKind

Enumerator
Scalar 
FixedVector 
ScalableVector 

Definition at line 608 of file Utils.h.

Constructor & Destructor Documentation

◆ GIConstant() [1/2]

llvm::GIConstant::GIConstant ( ArrayRef< APInt Values)
inline

Definition at line 616 of file Utils.h.

◆ GIConstant() [2/2]

llvm::GIConstant::GIConstant ( const APInt Value,
GIConstantKind  Kind 
)
inline

Definition at line 618 of file Utils.h.

Member Function Documentation

◆ getConstant()

std::optional< GIConstant > llvm::GIConstant::getConstant ( Register  Const,
const MachineRegisterInfo MRI 
)
static

◆ getKind()

GIConstantKind llvm::GIConstant::getKind ( ) const
inline

Returns the kind of of this constant, e.g, Scalar.

Definition at line 622 of file Utils.h.

◆ getScalarValue()

APInt llvm::GIConstant::getScalarValue ( ) const

Returns the value, if this constant is a scalar.

Definition at line 1967 of file Utils.cpp.

References assert(), and Scalar.


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