12#ifndef LLVM_SANDBOXIR_UTILS_H
13#define LLVM_SANDBOXIR_UTILS_H
37 if (RI->getReturnValue() ==
nullptr)
50 return SI->getValueOperand();
52 return RI->getReturnValue();
57 template <
typename LoadOrStoreT>
59 static_assert(std::is_same_v<LoadOrStoreT, LoadInst> ||
60 std::is_same_v<LoadOrStoreT, StoreInst>,
61 "Expected sandboxir::Load or sandboxir::Store!");
68 return DL.getTypeSizeInBits(Ty->LLVMTy);
85 static std::optional<llvm::MemoryLocation>
92 template <
typename LoadOrStoreT>
96 static_assert(std::is_same_v<LoadOrStoreT, LoadInst> ||
97 std::is_same_v<LoadOrStoreT, StoreInst>,
98 "Expected sandboxir::Load or sandboxir::Store!");
114 template <
typename LoadOrStoreT>
126 const std::optional<MemoryLocation> &OptLoc) {
141 unsigned *
Fast =
nullptr) {
142 return TTI.allowsMisalignedMemoryAccesses(Ctx.LLVMCtx,
BitWidth,
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file provides utility analysis objects describing memory locations.
This class is a wrapper over an AAResults, and it is intended to be used only when there are no IR ch...
ModRefInfo getModRefInfo(const Instruction *I, const std::optional< MemoryLocation > &OptLoc)
A parsed version of the target data layout string in and methods for querying it.
static LLVM_ABI std::optional< MemoryLocation > getOrNone(const Instruction *Inst)
The main scalar evolution driver.
LLVMContext & getContext() const
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI IntegerType * getInt8Ty(LLVMContext &C)
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream.
Value * getOrCreateValue(llvm::Value *LLVMV)
Get or create a sandboxir::Value for an existing LLVM IR LLVMV.
A sandboxir::User with operands, opcode and linked with previous/next instructions in an instruction ...
Just like llvm::Type these are immutable, unique, never get freed and can only be created via static ...
static unsigned getNumBits(Value *V, const DataLayout &DL)
\Returns the number of bits required to represent the operands or return value of V in DL.
static bool TTIAllowsMisalignedMemoryAccesses(TargetTransformInfo &TTI, Context &Ctx, unsigned BitWidth, unsigned AddressSpace=0, Align Alignment=Align(1), unsigned *Fast=nullptr)
static std::optional< int > getPointerDiffInBytes(LoadOrStoreT *I0, LoadOrStoreT *I1, ScalarEvolution &SE)
\Returns the gap between the memory locations accessed by I0 and I1 in bytes.
static ModRefInfo aliasAnalysisGetModRefInfo(BatchAAResults &BatchAA, const Instruction *I, const std::optional< MemoryLocation > &OptLoc)
Equivalent to BatchAA::getModRefInfo().
static unsigned getNumBits(Type *Ty, const DataLayout &DL)
\Returns the number of bits of Ty.
static Type * getExpectedType(const Value *V)
\Returns the expected type of Value V.
static unsigned getNumBits(Instruction *I)
\Returns the number of bits required to represent the operands or return value of I.
static std::optional< llvm::MemoryLocation > memoryLocationGetOrNone(const Instruction *I)
Equivalent to MemoryLocation::getOrNone(I).
static std::optional< bool > atLowerAddress(LoadOrStoreT *I0, LoadOrStoreT *I1, ScalarEvolution &SE)
\Returns true if I0 accesses a memory location lower than I1.
static Value * getMemInstructionBase(const LoadOrStoreT *LSI)
\Returns the base Value for load or store instruction LSI.
static bool verifyFunction(const Function *F, raw_ostream &OS)
Equivalent to llvm::verifyFunction().
static Value * getExpectedValue(const Instruction *I)
\Returns the expected Value for this instruction.
A SandboxIR Value has users. This is the base class.
Context & Ctx
All values point to the context.
LLVM_ABI Type * getType() const
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI bool verifyFunction(const Function &F, raw_ostream *OS=nullptr)
Check a function for errors, useful for use when debugging a pass.
LLVM_ABI std::optional< int64_t > getPointersDiff(Type *ElemTyA, Value *PtrA, Type *ElemTyB, Value *PtrB, const DataLayout &DL, ScalarEvolution &SE, bool StrictCheck=false, bool CheckType=true)
Returns the distance between the pointers PtrA and PtrB iff they are compatible and it is possible to...
LLVM_ABI const Value * getUnderlyingObject(const Value *V, unsigned MaxLookup=MaxLookupSearchDepth, bool MustPreserveProvenance=false)
This method strips off any GEP address adjustments, pointer casts or llvm.threadlocal....
ModRefInfo
Flags indicating whether a memory access modifies or references memory.
@ Fast
Assign the register banks as fast as possible (default).
constexpr unsigned BitWidth
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
This struct is a compact representation of a valid (non-zero power of two) alignment.