LLVM: include/llvm/SandboxIR/Utils.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12#ifndef LLVM_SANDBOXIR_UTILS_H
13#define LLVM_SANDBOXIR_UTILS_H
14
23#include
24
26
28public:
29
30
31
34
36 if (RI->getReturnValue() == nullptr)
37 return RI->getType();
38 }
40 }
41 return V->getType();
42 }
43
44
45
46
49 return SI->getValueOperand();
51 return RI->getReturnValue();
53 }
54
55
56 template
58 static_assert(std::is_same_v<LoadOrStoreT, LoadInst> ||
59 std::is_same_v<LoadOrStoreT, StoreInst>,
60 "Expected sandboxir::Load or sandboxir::Store!");
63 }
64
65
67 return DL.getTypeSizeInBits(Ty->LLVMTy);
68 }
69
70
71
76
77
78
82
83
84 static std::optionalllvm::MemoryLocation
88
89
90
91 template
93 LoadOrStoreT *I1,
95 static_assert(std::is_same_v<LoadOrStoreT, LoadInst> ||
96 std::is_same_v<LoadOrStoreT, StoreInst>,
97 "Expected sandboxir::Load or sandboxir::Store!");
98 llvm::Value *Opnd0 = I0->getPointerOperand()->Val;
99 llvm::Value *Opnd1 = I1->getPointerOperand()->Val;
102 if (Ptr0 != Ptr1)
103 return false;
105 return getPointersDiff(ElemTy, Opnd0, ElemTy, Opnd1, I0->getDataLayout(),
106 SE, false, false);
107 }
108
109
110
111
112 template
116 if (!Diff)
117 return false;
118 return *Diff > 0;
119 }
120
121
124 const std::optional &OptLoc) {
126 }
127
128
129
134};
135
136}
137
138#endif
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.
Definition Utils.h:72
static bool atLowerAddress(LoadOrStoreT *I0, LoadOrStoreT *I1, ScalarEvolution &SE)
\Returns true if I0 accesses a memory location lower than I1.
Definition Utils.h:113
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.
Definition Utils.h:92
static ModRefInfo aliasAnalysisGetModRefInfo(BatchAAResults &BatchAA, const Instruction *I, const std::optional< MemoryLocation > &OptLoc)
Equivalent to BatchAA::getModRefInfo().
Definition Utils.h:123
static unsigned getNumBits(Type *Ty, const DataLayout &DL)
\Returns the number of bits of Ty.
Definition Utils.h:66
static Type * getExpectedType(const Value *V)
\Returns the expected type of Value V.
Definition Utils.h:32
static unsigned getNumBits(Instruction *I)
\Returns the number of bits required to represent the operands or return value of I.
Definition Utils.h:79
static std::optional< llvm::MemoryLocation > memoryLocationGetOrNone(const Instruction *I)
Equivalent to MemoryLocation::getOrNone(I).
Definition Utils.h:85
static Value * getMemInstructionBase(const LoadOrStoreT *LSI)
\Returns the base Value for load or store instruction LSI.
Definition Utils.h:57
static bool verifyFunction(const Function *F, raw_ostream &OS)
Equivalent to llvm::verifyFunction().
Definition Utils.h:130
static Value * getExpectedValue(const Instruction *I)
\Returns the expected Value for this instruction.
Definition Utils.h:47
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 - 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...
ModRefInfo
Flags indicating whether a memory access modifies or references memory.
decltype(auto) cast(const From &Val)
cast - Return the argument parameter cast to the specified type.
LLVM_ABI const Value * getUnderlyingObject(const Value *V, unsigned MaxLookup=MaxLookupSearchDepth)
This method strips off any GEP address adjustments, pointer casts or llvm.threadlocal....