LLVM 22.0.0git
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.
LLVM_ABI APInt getScalarValue () const
 Returns the value, if this constant is a scalar.

Static Public Member Functions

static LLVM_ABI 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 652 of file Utils.h.

Member Enumeration Documentation

◆ GIConstantKind

Enumerator
Scalar 
FixedVector 
ScalableVector 

Definition at line 654 of file Utils.h.

Constructor & Destructor Documentation

◆ GIConstant() [1/2]

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

Definition at line 662 of file Utils.h.

References FixedVector.

Referenced by getConstant().

◆ GIConstant() [2/2]

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

Definition at line 664 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 668 of file Utils.h.

◆ getScalarValue()

APInt llvm::GIConstant::getScalarValue ( ) const

Returns the value, if this constant is a scalar.

Definition at line 2051 of file Utils.cpp.

References assert(), and Scalar.


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