LLVM 24.0.0git
llvm::sandboxir::SameSizeReinterpret Class Reference

Reinterprets the bits of a value as another type of the same size, for example float 1.0 as i32 0x3f800000, a null pointer as i64 0, or <2 x i32> as double. More...

#include "llvm/Transforms/Vectorize/SandboxVectorizer/Passes/LoadStoreVec.h"

Static Public Member Functions

static LLVM_ABI bool canReinterpret (Type *SrcTy, Type *DestTy, const DataLayout &DL)
static LLVM_ABI Value * reinterpretValue (Value *V, Type *DestTy, BasicBlock::iterator WhereIt, Context &Ctx, const DataLayout &DL)
 Reinterprets V as DestTy, which must have the same size in DL, inserting casts before WhereIt.
static LLVM_ABI Constant * reinterpretConstant (Constant *C, Type *DestTy, const DataLayout &DL)
 Reinterprets constant C as DestTy, e.g., float 1.0 to i32 0x3f800000, or a null pointer to i64 0.

Detailed Description

Reinterprets the bits of a value as another type of the same size, for example float 1.0 as i32 0x3f800000, a null pointer as i64 0, or <2 x i32> as double.

Used by createConstantVector() to pack constants, and by vectorizeLoads() to unpack each load from the vector load.

Definition at line 43 of file LoadStoreVec.h.

Member Function Documentation

◆ canReinterpret()

bool llvm::sandboxir::SameSizeReinterpret::canReinterpret ( Type * SrcTy,
Type * DestTy,
const DataLayout & DL )
static
Returns
true if SrcTy can be reinterpreted as DestTy. False when either type is a non-integral pointer, which has no stable integer representation.

Definition at line 89 of file LoadStoreVec.cpp.

References DL, and llvm::sandboxir::isNonIntegralPtr().

Referenced by reinterpretConstant(), and reinterpretValue().

◆ reinterpretConstant()

Constant * llvm::sandboxir::SameSizeReinterpret::reinterpretConstant ( Constant * C,
Type * DestTy,
const DataLayout & DL )
static

Reinterprets constant C as DestTy, e.g., float 1.0 to i32 0x3f800000, or a null pointer to i64 0.

Returns
nullptr if a non-integral pointer is involved.

Definition at line 143 of file LoadStoreVec.cpp.

References C(), canReinterpret(), DL, llvm::sandboxir::ConstantExpr::getBitCast(), llvm::sandboxir::ConstantExpr::getIntToPtr(), llvm::sandboxir::ConstantExpr::getPtrToInt(), llvm_unreachable, and Opc.

◆ reinterpretValue()

Value * llvm::sandboxir::SameSizeReinterpret::reinterpretValue ( Value * V,
Type * DestTy,
BasicBlock::iterator WhereIt,
Context & Ctx,
const DataLayout & DL )
static

Reinterprets V as DestTy, which must have the same size in DL, inserting casts before WhereIt.

Casts of constants fold, so nothing is inserted for those.

Returns
nullptr if a non-integral pointer is involved.

Definition at line 131 of file LoadStoreVec.cpp.

References canReinterpret(), llvm::sandboxir::CastInst::create(), DL, Opc, and V.


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