Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
Instruction.cpp
Go to the documentation of this file.
1//===- Instruction.cpp - The Instructions of Sandbox IR -------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "llvm/SandboxIR/Instruction.h"
10#include "llvm/SandboxIR/Function.h"
11
12namespacellvm::sandboxir {
13
14constchar *Instruction::getOpcodeName(Opcode Opc) {
15switch (Opc) {
16#define OP(OPC) \
17 case Opcode::OPC: \
18 return #OPC;
19#define OPCODES(...) __VA_ARGS__
20#define DEF_INSTR(ID, OPC, CLASS) OPC
21#include "llvm/SandboxIR/Values.def"
22 }
23llvm_unreachable("Unknown Opcode");
24}
25
26llvm::Instruction *Instruction::getTopmostLLVMInstruction() const{
27Instruction *Prev =getPrevNode();
28if (Prev ==nullptr) {
29// If at top of the BB, return the first BB instruction.
30return &*cast<llvm::BasicBlock>(getParent()->Val)->begin();
31 }
32// Else get the Previous sandbox IR instruction's bottom IR instruction and
33// return its successor.
34llvm::Instruction *PrevBotI = cast<llvm::Instruction>(Prev->Val);
35return PrevBotI->getNextNode();
36}
37
38BBIteratorInstruction::getIterator() const{
39auto *I = cast<llvm::Instruction>(Val);
40returnBasicBlock::iterator(I->getParent(),I->getIterator(), &Ctx);
41}
42
43Instruction *Instruction::getNextNode() const{
44assert(getParent() !=nullptr &&"Detached!");
45assert(getIterator() !=getParent()->end() &&"Already at end!");
46// `Val` is the bottom-most LLVM IR instruction. Get the next in the chain,
47// and get the corresponding sandboxir Instruction that maps to it. This works
48// even for SandboxIR Instructions that map to more than one LLVM Instruction.
49auto *LLVMI = cast<llvm::Instruction>(Val);
50assert(LLVMI->getParent() !=nullptr &&"LLVM IR instr is detached!");
51auto *NextLLVMI = LLVMI->getNextNode();
52auto *NextI = cast_or_null<Instruction>(Ctx.getValue(NextLLVMI));
53if (NextI ==nullptr)
54returnnullptr;
55return NextI;
56}
57
58Instruction *Instruction::getPrevNode() const{
59assert(getParent() !=nullptr &&"Detached!");
60auto It =getIterator();
61if (It !=getParent()->begin())
62return std::prev(getIterator()).get();
63returnnullptr;
64}
65
66voidInstruction::removeFromParent() {
67Ctx.getTracker().emplaceIfTracking<RemoveFromParent>(this);
68
69// Detach all the LLVM IR instructions from their parent BB.
70for (llvm::Instruction *I :getLLVMInstrs())
71I->removeFromParent();
72}
73
74voidInstruction::eraseFromParent() {
75assert(users().empty() &&"Still connected to users, can't erase!");
76
77Ctx.runEraseInstrCallbacks(this);
78 std::unique_ptr<Value> Detached =Ctx.detach(this);
79auto LLVMInstrs =getLLVMInstrs();
80
81auto &Tracker =Ctx.getTracker();
82if (Tracker.isTracking()) {
83 Tracker.track(std::make_unique<EraseFromParent>(std::move(Detached)));
84// We don't actually delete the IR instruction, because then it would be
85// impossible to bring it back from the dead at the same memory location.
86// Instead we remove it from its BB and track its current location.
87for (llvm::Instruction *I : LLVMInstrs)
88I->removeFromParent();
89// TODO: Multi-instructions need special treatment because some of the
90// references are internal to the instruction.
91for (llvm::Instruction *I : LLVMInstrs)
92I->dropAllReferences();
93 }else {
94// Erase in reverse to avoid erasing nstructions with attached uses.
95for (llvm::Instruction *I :reverse(LLVMInstrs))
96I->eraseFromParent();
97 }
98}
99
100voidInstruction::moveBefore(BasicBlock &BB,constBBIterator &WhereIt) {
101if (std::next(getIterator()) == WhereIt)
102// Destination is same as origin, nothing to do.
103return;
104
105Ctx.runMoveInstrCallbacks(this, WhereIt);
106Ctx.getTracker().emplaceIfTracking<MoveInstr>(this);
107
108auto *LLVMBB = cast<llvm::BasicBlock>(BB.Val);
109llvm::BasicBlock::iterator It;
110if (WhereIt == BB.end()) {
111 It = LLVMBB->end();
112 }else {
113Instruction *WhereI = &*WhereIt;
114 It = WhereI->getTopmostLLVMInstruction()->getIterator();
115 }
116// TODO: Move this to the verifier of sandboxir::Instruction.
117assert(is_sorted(getLLVMInstrs(),
118 [](auto *I1,auto *I2) {return I1->comesBefore(I2); }) &&
119"Expected program order!");
120// Do the actual move in LLVM IR.
121for (auto *I :getLLVMInstrs())
122I->moveBefore(*LLVMBB, It);
123}
124
125voidInstruction::insertBefore(Instruction *BeforeI) {
126llvm::Instruction *BeforeTopI = BeforeI->getTopmostLLVMInstruction();
127
128Ctx.getTracker().emplaceIfTracking<InsertIntoBB>(this);
129
130// Insert the LLVM IR Instructions in program order.
131for (llvm::Instruction *I :getLLVMInstrs())
132I->insertBefore(BeforeTopI->getIterator());
133}
134
135voidInstruction::insertAfter(Instruction *AfterI) {
136insertInto(AfterI->getParent(), std::next(AfterI->getIterator()));
137}
138
139voidInstruction::insertInto(BasicBlock *BB,constBBIterator &WhereIt) {
140llvm::BasicBlock *LLVMBB = cast<llvm::BasicBlock>(BB->Val);
141llvm::Instruction *LLVMBeforeI;
142llvm::BasicBlock::iterator LLVMBeforeIt;
143Instruction *BeforeI;
144if (WhereIt != BB->end()) {
145 BeforeI = &*WhereIt;
146 LLVMBeforeI = BeforeI->getTopmostLLVMInstruction();
147 LLVMBeforeIt = LLVMBeforeI->getIterator();
148 }else {
149 BeforeI =nullptr;
150 LLVMBeforeI =nullptr;
151 LLVMBeforeIt = LLVMBB->end();
152 }
153
154Ctx.getTracker().emplaceIfTracking<InsertIntoBB>(this);
155
156// Insert the LLVM IR Instructions in program order.
157for (llvm::Instruction *I :getLLVMInstrs())
158I->insertInto(LLVMBB, LLVMBeforeIt);
159}
160
161BasicBlock *Instruction::getParent() const{
162// Get the LLVM IR Instruction that this maps to, get its parent, and get the
163// corresponding sandboxir::BasicBlock by looking it up in sandboxir::Context.
164auto *BB = cast<llvm::Instruction>(Val)->getParent();
165if (BB ==nullptr)
166returnnullptr;
167return cast<BasicBlock>(Ctx.getValue(BB));
168}
169
170boolInstruction::classof(constsandboxir::Value *From) {
171switch (From->getSubclassID()) {
172#define DEF_INSTR(ID, OPC, CLASS) \
173 case ClassID::ID: \
174 return true;
175#include "llvm/SandboxIR/Values.def"
176default:
177returnfalse;
178 }
179}
180
181voidInstruction::setHasNoUnsignedWrap(boolB) {
182Ctx.getTracker()
183 .emplaceIfTracking<GenericSetter<&Instruction::hasNoUnsignedWrap,
184 &Instruction::setHasNoUnsignedWrap>>(
185this);
186 cast<llvm::Instruction>(Val)->setHasNoUnsignedWrap(B);
187}
188
189voidInstruction::setHasNoSignedWrap(boolB) {
190Ctx.getTracker()
191 .emplaceIfTracking<GenericSetter<&Instruction::hasNoSignedWrap,
192 &Instruction::setHasNoSignedWrap>>(this);
193 cast<llvm::Instruction>(Val)->setHasNoSignedWrap(B);
194}
195
196voidInstruction::setFast(boolB) {
197Ctx.getTracker()
198 .emplaceIfTracking<
199 GenericSetter<&Instruction::isFast, &Instruction::setFast>>(this);
200 cast<llvm::Instruction>(Val)->setFast(B);
201}
202
203voidInstruction::setIsExact(boolB) {
204Ctx.getTracker()
205 .emplaceIfTracking<
206GenericSetter<&Instruction::isExact, &Instruction::setIsExact>>(this);
207 cast<llvm::Instruction>(Val)->setIsExact(B);
208}
209
210voidInstruction::setHasAllowReassoc(boolB) {
211Ctx.getTracker()
212 .emplaceIfTracking<GenericSetter<&Instruction::hasAllowReassoc,
213 &Instruction::setHasAllowReassoc>>(this);
214 cast<llvm::Instruction>(Val)->setHasAllowReassoc(B);
215}
216
217voidInstruction::setHasNoNaNs(boolB) {
218Ctx.getTracker()
219 .emplaceIfTracking<
220GenericSetter<&Instruction::hasNoNaNs, &Instruction::setHasNoNaNs>>(
221this);
222 cast<llvm::Instruction>(Val)->setHasNoNaNs(B);
223}
224
225voidInstruction::setHasNoInfs(boolB) {
226Ctx.getTracker()
227 .emplaceIfTracking<
228GenericSetter<&Instruction::hasNoInfs, &Instruction::setHasNoInfs>>(
229this);
230 cast<llvm::Instruction>(Val)->setHasNoInfs(B);
231}
232
233voidInstruction::setHasNoSignedZeros(boolB) {
234Ctx.getTracker()
235 .emplaceIfTracking<GenericSetter<&Instruction::hasNoSignedZeros,
236 &Instruction::setHasNoSignedZeros>>(
237this);
238 cast<llvm::Instruction>(Val)->setHasNoSignedZeros(B);
239}
240
241voidInstruction::setHasAllowReciprocal(boolB) {
242Ctx.getTracker()
243 .emplaceIfTracking<GenericSetter<&Instruction::hasAllowReciprocal,
244 &Instruction::setHasAllowReciprocal>>(
245this);
246 cast<llvm::Instruction>(Val)->setHasAllowReciprocal(B);
247}
248
249voidInstruction::setHasAllowContract(boolB) {
250Ctx.getTracker()
251 .emplaceIfTracking<GenericSetter<&Instruction::hasAllowContract,
252 &Instruction::setHasAllowContract>>(
253this);
254 cast<llvm::Instruction>(Val)->setHasAllowContract(B);
255}
256
257voidInstruction::setFastMathFlags(FastMathFlags FMF) {
258Ctx.getTracker()
259 .emplaceIfTracking<GenericSetter<&Instruction::getFastMathFlags,
260 &Instruction::copyFastMathFlags>>(this);
261 cast<llvm::Instruction>(Val)->setFastMathFlags(FMF);
262}
263
264voidInstruction::copyFastMathFlags(FastMathFlags FMF) {
265Ctx.getTracker()
266 .emplaceIfTracking<GenericSetter<&Instruction::getFastMathFlags,
267 &Instruction::copyFastMathFlags>>(this);
268 cast<llvm::Instruction>(Val)->copyFastMathFlags(FMF);
269}
270
271Type *Instruction::getAccessType() const{
272returnCtx.getType(cast<llvm::Instruction>(Val)->getAccessType());
273}
274
275voidInstruction::setHasApproxFunc(boolB) {
276Ctx.getTracker()
277 .emplaceIfTracking<GenericSetter<&Instruction::hasApproxFunc,
278 &Instruction::setHasApproxFunc>>(this);
279 cast<llvm::Instruction>(Val)->setHasApproxFunc(B);
280}
281
282#ifndef NDEBUG
283voidInstruction::dumpOS(raw_ostream &OS) const{
284OS <<"Unimplemented! Please override dump().";
285}
286#endif// NDEBUG
287
288VAArgInst *VAArgInst::create(Value *List,Type *Ty,InsertPosition Pos,
289Context &Ctx,constTwine &Name) {
290auto &Builder =setInsertPos(Pos);
291auto *LLVMI =
292 cast<llvm::VAArgInst>(Builder.CreateVAArg(List->Val, Ty->LLVMTy,Name));
293returnCtx.createVAArgInst(LLVMI);
294}
295
296Value *VAArgInst::getPointerOperand() {
297returnCtx.getValue(cast<llvm::VAArgInst>(Val)->getPointerOperand());
298}
299
300FreezeInst *FreezeInst::create(Value *V,InsertPosition Pos,Context &Ctx,
301constTwine &Name) {
302auto &Builder =setInsertPos(Pos);
303auto *LLVMI = cast<llvm::FreezeInst>(Builder.CreateFreeze(V->Val,Name));
304returnCtx.createFreezeInst(LLVMI);
305}
306
307FenceInst *FenceInst::create(AtomicOrdering Ordering,InsertPosition Pos,
308Context &Ctx,SyncScope::ID SSID) {
309auto &Builder =Instruction::setInsertPos(Pos);
310llvm::FenceInst *LLVMI = Builder.CreateFence(Ordering, SSID);
311returnCtx.createFenceInst(LLVMI);
312}
313
314voidFenceInst::setOrdering(AtomicOrdering Ordering) {
315Ctx.getTracker()
316 .emplaceIfTracking<
317GenericSetter<&FenceInst::getOrdering, &FenceInst::setOrdering>>(
318this);
319 cast<llvm::FenceInst>(Val)->setOrdering(Ordering);
320}
321
322voidFenceInst::setSyncScopeID(SyncScope::ID SSID) {
323Ctx.getTracker()
324 .emplaceIfTracking<GenericSetter<&FenceInst::getSyncScopeID,
325 &FenceInst::setSyncScopeID>>(this);
326 cast<llvm::FenceInst>(Val)->setSyncScopeID(SSID);
327}
328
329Value *SelectInst::create(Value *Cond,Value *True,Value *False,
330InsertPosition Pos, Context &Ctx,constTwine &Name) {
331auto &Builder =Instruction::setInsertPos(Pos);
332llvm::Value *NewV =
333 Builder.CreateSelect(Cond->Val, True->Val, False->Val,Name);
334if (auto *NewSI = dyn_cast<llvm::SelectInst>(NewV))
335returnCtx.createSelectInst(NewSI);
336assert(isa<llvm::Constant>(NewV) &&"Expected constant");
337returnCtx.getOrCreateConstant(cast<llvm::Constant>(NewV));
338}
339
340voidSelectInst::swapValues() {
341Ctx.getTracker().emplaceIfTracking<UseSwap>(getOperandUse(1),
342getOperandUse(2));
343 cast<llvm::SelectInst>(Val)->swapValues();
344}
345
346boolSelectInst::classof(constValue *From) {
347returnFrom->getSubclassID() == ClassID::Select;
348}
349
350BranchInst *BranchInst::create(BasicBlock *IfTrue,InsertPosition Pos,
351Context &Ctx) {
352auto &Builder =setInsertPos(Pos);
353llvm::BranchInst *NewBr =
354 Builder.CreateBr(cast<llvm::BasicBlock>(IfTrue->Val));
355returnCtx.createBranchInst(NewBr);
356}
357
358BranchInst *BranchInst::create(BasicBlock *IfTrue,BasicBlock *IfFalse,
359Value *Cond,InsertPosition Pos,Context &Ctx) {
360auto &Builder =setInsertPos(Pos);
361llvm::BranchInst *NewBr =
362 Builder.CreateCondBr(Cond->Val, cast<llvm::BasicBlock>(IfTrue->Val),
363 cast<llvm::BasicBlock>(IfFalse->Val));
364returnCtx.createBranchInst(NewBr);
365}
366
367boolBranchInst::classof(constValue *From) {
368returnFrom->getSubclassID() == ClassID::Br;
369}
370
371Value *BranchInst::getCondition() const{
372assert(isConditional() &&"Cannot get condition of an uncond branch!");
373returnCtx.getValue(cast<llvm::BranchInst>(Val)->getCondition());
374}
375
376BasicBlock *BranchInst::getSuccessor(unsigned SuccIdx) const{
377assert(SuccIdx <getNumSuccessors() &&
378"Successor # out of range for Branch!");
379return cast_or_null<BasicBlock>(
380Ctx.getValue(cast<llvm::BranchInst>(Val)->getSuccessor(SuccIdx)));
381}
382
383voidBranchInst::setSuccessor(unsignedIdx,BasicBlock *NewSucc) {
384assert((Idx == 0 ||Idx == 1) &&"Out of bounds!");
385setOperand(2u -Idx, NewSucc);
386}
387
388BasicBlock *BranchInst::LLVMBBToSBBB::operator()(llvm::BasicBlock *BB) const{
389return cast<BasicBlock>(Ctx.getValue(BB));
390}
391constBasicBlock *
392BranchInst::ConstLLVMBBToSBBB::operator()(constllvm::BasicBlock *BB) const{
393return cast<BasicBlock>(Ctx.getValue(BB));
394}
395
396voidLoadInst::setVolatile(bool V) {
397Ctx.getTracker()
398 .emplaceIfTracking<
399 GenericSetter<&LoadInst::isVolatile, &LoadInst::setVolatile>>(this);
400 cast<llvm::LoadInst>(Val)->setVolatile(V);
401}
402
403LoadInst *LoadInst::create(Type *Ty,Value *Ptr,MaybeAlignAlign,
404InsertPosition Pos,bool IsVolatile,Context &Ctx,
405constTwine &Name) {
406auto &Builder =setInsertPos(Pos);
407auto *NewLI =
408 Builder.CreateAlignedLoad(Ty->LLVMTy,Ptr->Val,Align, IsVolatile,Name);
409auto *NewSBI =Ctx.createLoadInst(NewLI);
410return NewSBI;
411}
412
413boolLoadInst::classof(constValue *From) {
414returnFrom->getSubclassID() == ClassID::Load;
415}
416
417Value *LoadInst::getPointerOperand() const{
418returnCtx.getValue(cast<llvm::LoadInst>(Val)->getPointerOperand());
419}
420
421voidStoreInst::setVolatile(bool V) {
422Ctx.getTracker()
423 .emplaceIfTracking<
424 GenericSetter<&StoreInst::isVolatile, &StoreInst::setVolatile>>(this);
425 cast<llvm::StoreInst>(Val)->setVolatile(V);
426}
427
428StoreInst *StoreInst::create(Value *V,Value *Ptr,MaybeAlignAlign,
429InsertPosition Pos,bool IsVolatile,
430Context &Ctx) {
431auto &Builder =setInsertPos(Pos);
432auto *NewSI = Builder.CreateAlignedStore(V->Val,Ptr->Val,Align, IsVolatile);
433auto *NewSBI =Ctx.createStoreInst(NewSI);
434return NewSBI;
435}
436
437boolStoreInst::classof(constValue *From) {
438returnFrom->getSubclassID() == ClassID::Store;
439}
440
441Value *StoreInst::getValueOperand() const{
442returnCtx.getValue(cast<llvm::StoreInst>(Val)->getValueOperand());
443}
444
445Value *StoreInst::getPointerOperand() const{
446returnCtx.getValue(cast<llvm::StoreInst>(Val)->getPointerOperand());
447}
448
449UnreachableInst *UnreachableInst::create(InsertPosition Pos,Context &Ctx) {
450auto &Builder =setInsertPos(Pos);
451llvm::UnreachableInst *NewUI = Builder.CreateUnreachable();
452returnCtx.createUnreachableInst(NewUI);
453}
454
455boolUnreachableInst::classof(constValue *From) {
456returnFrom->getSubclassID() == ClassID::Unreachable;
457}
458
459ReturnInst *ReturnInst::createCommon(Value *RetVal,IRBuilder<> &Builder,
460Context &Ctx) {
461llvm::ReturnInst *NewRI;
462if (RetVal !=nullptr)
463 NewRI = Builder.CreateRet(RetVal->Val);
464else
465 NewRI = Builder.CreateRetVoid();
466returnCtx.createReturnInst(NewRI);
467}
468
469ReturnInst *ReturnInst::create(Value *RetVal,InsertPosition Pos,
470Context &Ctx) {
471auto &Builder =setInsertPos(Pos);
472return createCommon(RetVal, Builder,Ctx);
473}
474
475Value *ReturnInst::getReturnValue() const{
476auto *LLVMRetVal = cast<llvm::ReturnInst>(Val)->getReturnValue();
477return LLVMRetVal !=nullptr ?Ctx.getValue(LLVMRetVal) :nullptr;
478}
479
480FunctionType *CallBase::getFunctionType() const{
481return cast<FunctionType>(
482Ctx.getType(cast<llvm::CallBase>(Val)->getFunctionType()));
483}
484
485Value *CallBase::getCalledOperand() const{
486returnCtx.getValue(cast<llvm::CallBase>(Val)->getCalledOperand());
487}
488
489UseCallBase::getCalledOperandUse() const{
490llvm::Use *LLVMUse = &cast<llvm::CallBase>(Val)->getCalledOperandUse();
491returnUse(LLVMUse, cast<User>(Ctx.getValue(LLVMUse->getUser())),Ctx);
492}
493
494Function *CallBase::getCalledFunction() const{
495return cast_or_null<Function>(
496Ctx.getValue(cast<llvm::CallBase>(Val)->getCalledFunction()));
497}
498Function *CallBase::getCaller() {
499return cast<Function>(Ctx.getValue(cast<llvm::CallBase>(Val)->getCaller()));
500}
501
502voidCallBase::setCalledFunction(Function *F) {
503// F's function type is private, so we rely on `setCalledFunction()` to update
504// it. But even though we are calling `setCalledFunction()` we also need to
505// track this change at the SandboxIR level, which is why we call
506// `setCalledOperand()` here.
507// Note: This may break if `setCalledFunction()` early returns if `F`
508// is already set, but we do have a unit test for it.
509setCalledOperand(F);
510 cast<llvm::CallBase>(Val)->setCalledFunction(
511 cast<llvm::FunctionType>(F->getFunctionType()->LLVMTy),
512 cast<llvm::Function>(F->Val));
513}
514
515CallInst *CallInst::create(FunctionType *FTy,Value *Func,
516ArrayRef<Value *> Args,InsertPosition Pos,
517 Context &Ctx,constTwine &NameStr) {
518auto &Builder =setInsertPos(Pos);
519SmallVector<llvm::Value *> LLVMArgs;
520 LLVMArgs.reserve(Args.size());
521for (Value *Arg : Args)
522 LLVMArgs.push_back(Arg->Val);
523llvm::CallInst *NewCI = Builder.CreateCall(
524 cast<llvm::FunctionType>(FTy->LLVMTy), Func->Val, LLVMArgs, NameStr);
525returnCtx.createCallInst(NewCI);
526}
527
528InvokeInst *InvokeInst::create(FunctionType *FTy,Value *Func,
529BasicBlock *IfNormal,BasicBlock *IfException,
530ArrayRef<Value *> Args,InsertPosition Pos,
531Context &Ctx,constTwine &NameStr) {
532auto &Builder =setInsertPos(Pos);
533SmallVector<llvm::Value *> LLVMArgs;
534 LLVMArgs.reserve(Args.size());
535for (Value *Arg : Args)
536 LLVMArgs.push_back(Arg->Val);
537llvm::InvokeInst *Invoke = Builder.CreateInvoke(
538 cast<llvm::FunctionType>(FTy->LLVMTy), Func->Val,
539 cast<llvm::BasicBlock>(IfNormal->Val),
540 cast<llvm::BasicBlock>(IfException->Val), LLVMArgs, NameStr);
541returnCtx.createInvokeInst(Invoke);
542}
543
544BasicBlock *InvokeInst::getNormalDest() const{
545return cast<BasicBlock>(
546Ctx.getValue(cast<llvm::InvokeInst>(Val)->getNormalDest()));
547}
548BasicBlock *InvokeInst::getUnwindDest() const{
549return cast<BasicBlock>(
550Ctx.getValue(cast<llvm::InvokeInst>(Val)->getUnwindDest()));
551}
552voidInvokeInst::setNormalDest(BasicBlock *BB) {
553setOperand(1, BB);
554assert(getNormalDest() == BB &&"LLVM IR uses a different operan index!");
555}
556voidInvokeInst::setUnwindDest(BasicBlock *BB) {
557setOperand(2, BB);
558assert(getUnwindDest() == BB &&"LLVM IR uses a different operan index!");
559}
560LandingPadInst *InvokeInst::getLandingPadInst() const{
561return cast<LandingPadInst>(
562Ctx.getValue(cast<llvm::InvokeInst>(Val)->getLandingPadInst()));
563 ;
564}
565BasicBlock *InvokeInst::getSuccessor(unsigned SuccIdx) const{
566return cast<BasicBlock>(
567Ctx.getValue(cast<llvm::InvokeInst>(Val)->getSuccessor(SuccIdx)));
568}
569
570CallBrInst *CallBrInst::create(FunctionType *FTy,Value *Func,
571BasicBlock *DefaultDest,
572ArrayRef<BasicBlock *> IndirectDests,
573ArrayRef<Value *> Args,InsertPosition Pos,
574 Context &Ctx,constTwine &NameStr) {
575auto &Builder =setInsertPos(Pos);
576SmallVector<llvm::BasicBlock *> LLVMIndirectDests;
577 LLVMIndirectDests.reserve(IndirectDests.size());
578for (BasicBlock *IndDest : IndirectDests)
579 LLVMIndirectDests.push_back(cast<llvm::BasicBlock>(IndDest->Val));
580
581SmallVector<llvm::Value *> LLVMArgs;
582 LLVMArgs.reserve(Args.size());
583for (Value *Arg : Args)
584 LLVMArgs.push_back(Arg->Val);
585
586llvm::CallBrInst *CallBr =
587 Builder.CreateCallBr(cast<llvm::FunctionType>(FTy->LLVMTy), Func->Val,
588 cast<llvm::BasicBlock>(DefaultDest->Val),
589 LLVMIndirectDests, LLVMArgs, NameStr);
590returnCtx.createCallBrInst(CallBr);
591}
592
593Value *CallBrInst::getIndirectDestLabel(unsignedIdx) const{
594returnCtx.getValue(cast<llvm::CallBrInst>(Val)->getIndirectDestLabel(Idx));
595}
596Value *CallBrInst::getIndirectDestLabelUse(unsignedIdx) const{
597returnCtx.getValue(
598 cast<llvm::CallBrInst>(Val)->getIndirectDestLabelUse(Idx));
599}
600BasicBlock *CallBrInst::getDefaultDest() const{
601return cast<BasicBlock>(
602Ctx.getValue(cast<llvm::CallBrInst>(Val)->getDefaultDest()));
603}
604BasicBlock *CallBrInst::getIndirectDest(unsignedIdx) const{
605return cast<BasicBlock>(
606Ctx.getValue(cast<llvm::CallBrInst>(Val)->getIndirectDest(Idx)));
607}
608llvm::SmallVector<BasicBlock *, 16>CallBrInst::getIndirectDests() const{
609SmallVector<BasicBlock *, 16> BBs;
610for (llvm::BasicBlock *LLVMBB :
611 cast<llvm::CallBrInst>(Val)->getIndirectDests())
612 BBs.push_back(cast<BasicBlock>(Ctx.getValue(LLVMBB)));
613return BBs;
614}
615voidCallBrInst::setDefaultDest(BasicBlock *BB) {
616Ctx.getTracker()
617 .emplaceIfTracking<GenericSetter<&CallBrInst::getDefaultDest,
618 &CallBrInst::setDefaultDest>>(this);
619 cast<llvm::CallBrInst>(Val)->setDefaultDest(cast<llvm::BasicBlock>(BB->Val));
620}
621voidCallBrInst::setIndirectDest(unsignedIdx,BasicBlock *BB) {
622Ctx.getTracker()
623 .emplaceIfTracking<GenericSetterWithIdx<&CallBrInst::getIndirectDest,
624 &CallBrInst::setIndirectDest>>(
625this,Idx);
626 cast<llvm::CallBrInst>(Val)->setIndirectDest(Idx,
627 cast<llvm::BasicBlock>(BB->Val));
628}
629BasicBlock *CallBrInst::getSuccessor(unsignedIdx) const{
630return cast<BasicBlock>(
631Ctx.getValue(cast<llvm::CallBrInst>(Val)->getSuccessor(Idx)));
632}
633
634LandingPadInst *LandingPadInst::create(Type *RetTy,unsigned NumReservedClauses,
635InsertPosition Pos,Context &Ctx,
636constTwine &Name) {
637auto &Builder =setInsertPos(Pos);
638llvm::LandingPadInst *LLVMI =
639 Builder.CreateLandingPad(RetTy->LLVMTy, NumReservedClauses,Name);
640returnCtx.createLandingPadInst(LLVMI);
641}
642
643voidLandingPadInst::setCleanup(bool V) {
644Ctx.getTracker()
645 .emplaceIfTracking<GenericSetter<&LandingPadInst::isCleanup,
646 &LandingPadInst::setCleanup>>(this);
647 cast<llvm::LandingPadInst>(Val)->setCleanup(V);
648}
649
650Constant *LandingPadInst::getClause(unsignedIdx) const{
651return cast<Constant>(
652Ctx.getValue(cast<llvm::LandingPadInst>(Val)->getClause(Idx)));
653}
654
655Value *FuncletPadInst::getParentPad() const{
656returnCtx.getValue(cast<llvm::FuncletPadInst>(Val)->getParentPad());
657}
658
659voidFuncletPadInst::setParentPad(Value *ParentPad) {
660Ctx.getTracker()
661 .emplaceIfTracking<GenericSetter<&FuncletPadInst::getParentPad,
662 &FuncletPadInst::setParentPad>>(this);
663 cast<llvm::FuncletPadInst>(Val)->setParentPad(ParentPad->Val);
664}
665
666Value *FuncletPadInst::getArgOperand(unsignedIdx) const{
667returnCtx.getValue(cast<llvm::FuncletPadInst>(Val)->getArgOperand(Idx));
668}
669
670voidFuncletPadInst::setArgOperand(unsignedIdx,Value *V) {
671Ctx.getTracker()
672 .emplaceIfTracking<GenericSetterWithIdx<&FuncletPadInst::getArgOperand,
673 &FuncletPadInst::setArgOperand>>(
674this,Idx);
675 cast<llvm::FuncletPadInst>(Val)->setArgOperand(Idx, V->Val);
676}
677
678CatchSwitchInst *CatchPadInst::getCatchSwitch() const{
679return cast<CatchSwitchInst>(
680Ctx.getValue(cast<llvm::CatchPadInst>(Val)->getCatchSwitch()));
681}
682
683CatchPadInst *CatchPadInst::create(Value *ParentPad,ArrayRef<Value *> Args,
684InsertPosition Pos,Context &Ctx,
685constTwine &Name) {
686auto &Builder =setInsertPos(Pos);
687SmallVector<llvm::Value *> LLVMArgs;
688 LLVMArgs.reserve(Args.size());
689for (auto *Arg : Args)
690 LLVMArgs.push_back(Arg->Val);
691llvm::CatchPadInst *LLVMI =
692 Builder.CreateCatchPad(ParentPad->Val, LLVMArgs,Name);
693returnCtx.createCatchPadInst(LLVMI);
694}
695
696CleanupPadInst *CleanupPadInst::create(Value *ParentPad,ArrayRef<Value *> Args,
697InsertPosition Pos,Context &Ctx,
698constTwine &Name) {
699auto &Builder =setInsertPos(Pos);
700SmallVector<llvm::Value *> LLVMArgs;
701 LLVMArgs.reserve(Args.size());
702for (auto *Arg : Args)
703 LLVMArgs.push_back(Arg->Val);
704llvm::CleanupPadInst *LLVMI =
705 Builder.CreateCleanupPad(ParentPad->Val, LLVMArgs,Name);
706returnCtx.createCleanupPadInst(LLVMI);
707}
708
709CatchReturnInst *CatchReturnInst::create(CatchPadInst *CatchPad,BasicBlock *BB,
710InsertPosition Pos,Context &Ctx) {
711auto &Builder =setInsertPos(Pos);
712llvm::CatchReturnInst *LLVMI = Builder.CreateCatchRet(
713 cast<llvm::CatchPadInst>(CatchPad->Val), cast<llvm::BasicBlock>(BB->Val));
714returnCtx.createCatchReturnInst(LLVMI);
715}
716
717CatchPadInst *CatchReturnInst::getCatchPad() const{
718return cast<CatchPadInst>(
719Ctx.getValue(cast<llvm::CatchReturnInst>(Val)->getCatchPad()));
720}
721
722voidCatchReturnInst::setCatchPad(CatchPadInst *CatchPad) {
723Ctx.getTracker()
724 .emplaceIfTracking<GenericSetter<&CatchReturnInst::getCatchPad,
725 &CatchReturnInst::setCatchPad>>(this);
726 cast<llvm::CatchReturnInst>(Val)->setCatchPad(
727 cast<llvm::CatchPadInst>(CatchPad->Val));
728}
729
730BasicBlock *CatchReturnInst::getSuccessor() const{
731return cast<BasicBlock>(
732Ctx.getValue(cast<llvm::CatchReturnInst>(Val)->getSuccessor()));
733}
734
735voidCatchReturnInst::setSuccessor(BasicBlock *NewSucc) {
736Ctx.getTracker()
737 .emplaceIfTracking<GenericSetter<&CatchReturnInst::getSuccessor,
738 &CatchReturnInst::setSuccessor>>(this);
739 cast<llvm::CatchReturnInst>(Val)->setSuccessor(
740 cast<llvm::BasicBlock>(NewSucc->Val));
741}
742
743Value *CatchReturnInst::getCatchSwitchParentPad() const{
744returnCtx.getValue(
745 cast<llvm::CatchReturnInst>(Val)->getCatchSwitchParentPad());
746}
747
748CleanupReturnInst *CleanupReturnInst::create(CleanupPadInst *CleanupPad,
749BasicBlock *UnwindBB,
750InsertPosition Pos, Context &Ctx) {
751auto &Builder =setInsertPos(Pos);
752auto *LLVMUnwindBB =
753 UnwindBB !=nullptr ? cast<llvm::BasicBlock>(UnwindBB->Val) :nullptr;
754llvm::CleanupReturnInst *LLVMI = Builder.CreateCleanupRet(
755 cast<llvm::CleanupPadInst>(CleanupPad->Val), LLVMUnwindBB);
756returnCtx.createCleanupReturnInst(LLVMI);
757}
758
759CleanupPadInst *CleanupReturnInst::getCleanupPad() const{
760return cast<CleanupPadInst>(
761Ctx.getValue(cast<llvm::CleanupReturnInst>(Val)->getCleanupPad()));
762}
763
764voidCleanupReturnInst::setCleanupPad(CleanupPadInst *CleanupPad) {
765Ctx.getTracker()
766 .emplaceIfTracking<GenericSetter<&CleanupReturnInst::getCleanupPad,
767 &CleanupReturnInst::setCleanupPad>>(
768this);
769 cast<llvm::CleanupReturnInst>(Val)->setCleanupPad(
770 cast<llvm::CleanupPadInst>(CleanupPad->Val));
771}
772
773BasicBlock *CleanupReturnInst::getUnwindDest() const{
774return cast_or_null<BasicBlock>(
775Ctx.getValue(cast<llvm::CleanupReturnInst>(Val)->getUnwindDest()));
776}
777
778voidCleanupReturnInst::setUnwindDest(BasicBlock *NewDest) {
779Ctx.getTracker()
780 .emplaceIfTracking<GenericSetter<&CleanupReturnInst::getUnwindDest,
781 &CleanupReturnInst::setUnwindDest>>(
782this);
783 cast<llvm::CleanupReturnInst>(Val)->setUnwindDest(
784 cast<llvm::BasicBlock>(NewDest->Val));
785}
786
787Value *GetElementPtrInst::create(Type *Ty,Value *Ptr,
788ArrayRef<Value *> IdxList,InsertPosition Pos,
789Context &Ctx,constTwine &NameStr) {
790auto &Builder =setInsertPos(Pos);
791SmallVector<llvm::Value *> LLVMIdxList;
792 LLVMIdxList.reserve(IdxList.size());
793for (Value *Idx : IdxList)
794 LLVMIdxList.push_back(Idx->Val);
795llvm::Value *NewV =
796 Builder.CreateGEP(Ty->LLVMTy,Ptr->Val, LLVMIdxList, NameStr);
797if (auto *NewGEP = dyn_cast<llvm::GetElementPtrInst>(NewV))
798returnCtx.createGetElementPtrInst(NewGEP);
799assert(isa<llvm::Constant>(NewV) &&"Expected constant");
800returnCtx.getOrCreateConstant(cast<llvm::Constant>(NewV));
801}
802
803Type *GetElementPtrInst::getSourceElementType() const{
804returnCtx.getType(
805 cast<llvm::GetElementPtrInst>(Val)->getSourceElementType());
806}
807
808Type *GetElementPtrInst::getResultElementType() const{
809returnCtx.getType(
810 cast<llvm::GetElementPtrInst>(Val)->getResultElementType());
811}
812
813Value *GetElementPtrInst::getPointerOperand() const{
814returnCtx.getValue(cast<llvm::GetElementPtrInst>(Val)->getPointerOperand());
815}
816
817Type *GetElementPtrInst::getPointerOperandType() const{
818returnCtx.getType(
819 cast<llvm::GetElementPtrInst>(Val)->getPointerOperandType());
820}
821
822BasicBlock *PHINode::LLVMBBToBB::operator()(llvm::BasicBlock *LLVMBB) const{
823return cast<BasicBlock>(Ctx.getValue(LLVMBB));
824}
825
826PHINode *PHINode::create(Type *Ty,unsigned NumReservedValues,
827InsertPosition Pos,Context &Ctx,constTwine &Name) {
828auto &Builder =setInsertPos(Pos);
829llvm::PHINode *NewPHI =
830 Builder.CreatePHI(Ty->LLVMTy, NumReservedValues,Name);
831returnCtx.createPHINode(NewPHI);
832}
833
834boolPHINode::classof(constValue *From) {
835returnFrom->getSubclassID() == ClassID::PHI;
836}
837
838Value *PHINode::getIncomingValue(unsignedIdx) const{
839returnCtx.getValue(cast<llvm::PHINode>(Val)->getIncomingValue(Idx));
840}
841voidPHINode::setIncomingValue(unsignedIdx,Value *V) {
842Ctx.getTracker()
843 .emplaceIfTracking<GenericSetterWithIdx<&PHINode::getIncomingValue,
844 &PHINode::setIncomingValue>>(this,
845Idx);
846 cast<llvm::PHINode>(Val)->setIncomingValue(Idx, V->Val);
847}
848BasicBlock *PHINode::getIncomingBlock(unsignedIdx) const{
849return cast<BasicBlock>(
850Ctx.getValue(cast<llvm::PHINode>(Val)->getIncomingBlock(Idx)));
851}
852BasicBlock *PHINode::getIncomingBlock(constUse &U) const{
853llvm::Use *LLVMUse = U.LLVMUse;
854llvm::BasicBlock *BB = cast<llvm::PHINode>(Val)->getIncomingBlock(*LLVMUse);
855return cast<BasicBlock>(Ctx.getValue(BB));
856}
857voidPHINode::setIncomingBlock(unsignedIdx,BasicBlock *BB) {
858// Helper to disambiguate PHINode::getIncomingBlock(unsigned).
859constexprBasicBlock *(PHINode::*GetIncomingBlockFn)(unsigned)const =
860 &PHINode::getIncomingBlock;
861Ctx.getTracker()
862 .emplaceIfTracking<
863GenericSetterWithIdx<GetIncomingBlockFn, &PHINode::setIncomingBlock>>(
864this,Idx);
865 cast<llvm::PHINode>(Val)->setIncomingBlock(Idx,
866 cast<llvm::BasicBlock>(BB->Val));
867}
868voidPHINode::addIncoming(Value *V,BasicBlock *BB) {
869auto &Tracker =Ctx.getTracker();
870Tracker.emplaceIfTracking<PHIAddIncoming>(this);
871
872 cast<llvm::PHINode>(Val)->addIncoming(V->Val,
873 cast<llvm::BasicBlock>(BB->Val));
874}
875Value *PHINode::removeIncomingValue(unsignedIdx) {
876auto &Tracker =Ctx.getTracker();
877Tracker.emplaceIfTracking<PHIRemoveIncoming>(this,Idx);
878llvm::Value *LLVMV =
879 cast<llvm::PHINode>(Val)->removeIncomingValue(Idx,
880/*DeletePHIIfEmpty=*/false);
881returnCtx.getValue(LLVMV);
882}
883Value *PHINode::removeIncomingValue(BasicBlock *BB) {
884auto &Tracker =Ctx.getTracker();
885Tracker.emplaceIfTracking<PHIRemoveIncoming>(this,getBasicBlockIndex(BB));
886
887auto *LLVMBB = cast<llvm::BasicBlock>(BB->Val);
888llvm::Value *LLVMV =
889 cast<llvm::PHINode>(Val)->removeIncomingValue(LLVMBB,
890/*DeletePHIIfEmpty=*/false);
891returnCtx.getValue(LLVMV);
892}
893intPHINode::getBasicBlockIndex(constBasicBlock *BB) const{
894auto *LLVMBB = cast<llvm::BasicBlock>(BB->Val);
895return cast<llvm::PHINode>(Val)->getBasicBlockIndex(LLVMBB);
896}
897Value *PHINode::getIncomingValueForBlock(constBasicBlock *BB) const{
898auto *LLVMBB = cast<llvm::BasicBlock>(BB->Val);
899llvm::Value *LLVMV =
900 cast<llvm::PHINode>(Val)->getIncomingValueForBlock(LLVMBB);
901returnCtx.getValue(LLVMV);
902}
903Value *PHINode::hasConstantValue() const{
904llvm::Value *LLVMV = cast<llvm::PHINode>(Val)->hasConstantValue();
905return LLVMV !=nullptr ?Ctx.getValue(LLVMV) :nullptr;
906}
907voidPHINode::replaceIncomingBlockWith(constBasicBlock *Old,BasicBlock *New) {
908assert(New && Old &&"Sandbox IR PHI node got a null basic block!");
909for (unsignedIdx = 0, NumOps = cast<llvm::PHINode>(Val)->getNumOperands();
910Idx != NumOps; ++Idx)
911if (getIncomingBlock(Idx) == Old)
912setIncomingBlock(Idx, New);
913}
914voidPHINode::removeIncomingValueIf(function_ref<bool(unsigned)> Predicate) {
915// Avoid duplicate tracking by going through this->removeIncomingValue here at
916// the expense of some performance. Copy PHI::removeIncomingValueIf more
917// directly if performance becomes an issue.
918
919// Removing the element at index X, moves the element previously at X + 1
920// to X. Working from the end avoids complications from that.
921unsignedIdx =getNumIncomingValues();
922while (Idx > 0) {
923if (Predicate(Idx - 1))
924removeIncomingValue(Idx - 1);
925 --Idx;
926 }
927}
928
929Value *CmpInst::create(PredicateP,Value *S1,Value *S2,InsertPosition Pos,
930Context &Ctx,constTwine &Name) {
931auto &Builder =setInsertPos(Pos);
932auto *LLVMV = Builder.CreateCmp(P,S1->Val, S2->Val,Name);
933// It may have been folded into a constant.
934if (auto *LLVMC = dyn_cast<llvm::Constant>(LLVMV))
935returnCtx.getOrCreateConstant(LLVMC);
936if (isa<llvm::ICmpInst>(LLVMV))
937returnCtx.createICmpInst(cast<llvm::ICmpInst>(LLVMV));
938returnCtx.createFCmpInst(cast<llvm::FCmpInst>(LLVMV));
939}
940
941Value *CmpInst::createWithCopiedFlags(PredicateP,Value *S1,Value *S2,
942constInstruction *F,InsertPosition Pos,
943Context &Ctx,constTwine &Name) {
944Value *V =create(P,S1, S2, Pos,Ctx,Name);
945if (auto *C = dyn_cast<Constant>(V))
946returnC;
947 cast<llvm::CmpInst>(V->Val)->copyIRFlags(F->Val);
948return V;
949}
950
951Type *CmpInst::makeCmpResultType(Type *OpndType) {
952if (auto *VT = dyn_cast<VectorType>(OpndType)) {
953// TODO: Cleanup when we have more complete support for
954// sandboxir::VectorType
955return OpndType->getContext().getType(llvm::VectorType::get(
956llvm::Type::getInt1Ty(OpndType->getContext().LLVMCtx),
957 cast<llvm::VectorType>(VT->LLVMTy)->getElementCount()));
958 }
959returnType::getInt1Ty(OpndType->getContext());
960}
961
962voidCmpInst::setPredicate(PredicateP) {
963Ctx.getTracker()
964 .emplaceIfTracking<
965GenericSetter<&CmpInst::getPredicate, &CmpInst::setPredicate>>(this);
966 cast<llvm::CmpInst>(Val)->setPredicate(P);
967}
968
969voidCmpInst::swapOperands() {
970if (ICmpInst *IC = dyn_cast<ICmpInst>(this))
971 IC->swapOperands();
972else
973 cast<FCmpInst>(this)->swapOperands();
974}
975
976voidICmpInst::swapOperands() {
977Ctx.getTracker().emplaceIfTracking<CmpSwapOperands>(this);
978 cast<llvm::ICmpInst>(Val)->swapOperands();
979}
980
981voidFCmpInst::swapOperands() {
982Ctx.getTracker().emplaceIfTracking<CmpSwapOperands>(this);
983 cast<llvm::FCmpInst>(Val)->swapOperands();
984}
985
986#ifndef NDEBUG
987voidCmpInst::dumpOS(raw_ostream &OS) const{
988dumpCommonPrefix(OS);
989dumpCommonSuffix(OS);
990}
991
992voidCmpInst::dump() const{
993dumpOS(dbgs());
994dbgs() <<"\n";
995}
996#endif// NDEBUG
997
998staticllvm::Instruction::CastOpsgetLLVMCastOp(Instruction::Opcode Opc) {
999switch (Opc) {
1000case Instruction::Opcode::ZExt:
1001returnstatic_cast<llvm::Instruction::CastOps>(llvm::Instruction::ZExt);
1002case Instruction::Opcode::SExt:
1003returnstatic_cast<llvm::Instruction::CastOps>(llvm::Instruction::SExt);
1004case Instruction::Opcode::FPToUI:
1005returnstatic_cast<llvm::Instruction::CastOps>(llvm::Instruction::FPToUI);
1006case Instruction::Opcode::FPToSI:
1007returnstatic_cast<llvm::Instruction::CastOps>(llvm::Instruction::FPToSI);
1008case Instruction::Opcode::FPExt:
1009returnstatic_cast<llvm::Instruction::CastOps>(llvm::Instruction::FPExt);
1010case Instruction::Opcode::PtrToInt:
1011returnstatic_cast<llvm::Instruction::CastOps>(llvm::Instruction::PtrToInt);
1012case Instruction::Opcode::IntToPtr:
1013returnstatic_cast<llvm::Instruction::CastOps>(llvm::Instruction::IntToPtr);
1014case Instruction::Opcode::SIToFP:
1015returnstatic_cast<llvm::Instruction::CastOps>(llvm::Instruction::SIToFP);
1016case Instruction::Opcode::UIToFP:
1017returnstatic_cast<llvm::Instruction::CastOps>(llvm::Instruction::UIToFP);
1018case Instruction::Opcode::Trunc:
1019returnstatic_cast<llvm::Instruction::CastOps>(llvm::Instruction::Trunc);
1020case Instruction::Opcode::FPTrunc:
1021returnstatic_cast<llvm::Instruction::CastOps>(llvm::Instruction::FPTrunc);
1022case Instruction::Opcode::BitCast:
1023returnstatic_cast<llvm::Instruction::CastOps>(llvm::Instruction::BitCast);
1024case Instruction::Opcode::AddrSpaceCast:
1025returnstatic_cast<llvm::Instruction::CastOps>(
1026 llvm::Instruction::AddrSpaceCast);
1027default:
1028llvm_unreachable("Opcode not suitable for CastInst!");
1029 }
1030}
1031
1032/// \Returns the LLVM opcode that corresponds to \p Opc.
1033staticllvm::Instruction::UnaryOpsgetLLVMUnaryOp(Instruction::Opcode Opc) {
1034switch (Opc) {
1035case Instruction::Opcode::FNeg:
1036returnstatic_cast<llvm::Instruction::UnaryOps>(llvm::Instruction::FNeg);
1037default:
1038llvm_unreachable("Not a unary op!");
1039 }
1040}
1041
1042CatchSwitchInst *CatchSwitchInst::create(Value *ParentPad,BasicBlock *UnwindBB,
1043unsigned NumHandlers,
1044InsertPosition Pos,Context &Ctx,
1045constTwine &Name) {
1046auto &Builder =setInsertPos(Pos);
1047llvm::CatchSwitchInst *LLVMCSI = Builder.CreateCatchSwitch(
1048 ParentPad->Val, cast<llvm::BasicBlock>(UnwindBB->Val), NumHandlers,Name);
1049returnCtx.createCatchSwitchInst(LLVMCSI);
1050}
1051
1052Value *CatchSwitchInst::getParentPad() const{
1053returnCtx.getValue(cast<llvm::CatchSwitchInst>(Val)->getParentPad());
1054}
1055
1056voidCatchSwitchInst::setParentPad(Value *ParentPad) {
1057Ctx.getTracker()
1058 .emplaceIfTracking<GenericSetter<&CatchSwitchInst::getParentPad,
1059 &CatchSwitchInst::setParentPad>>(this);
1060 cast<llvm::CatchSwitchInst>(Val)->setParentPad(ParentPad->Val);
1061}
1062
1063BasicBlock *CatchSwitchInst::getUnwindDest() const{
1064return cast_or_null<BasicBlock>(
1065Ctx.getValue(cast<llvm::CatchSwitchInst>(Val)->getUnwindDest()));
1066}
1067
1068voidCatchSwitchInst::setUnwindDest(BasicBlock *UnwindDest) {
1069Ctx.getTracker()
1070 .emplaceIfTracking<GenericSetter<&CatchSwitchInst::getUnwindDest,
1071 &CatchSwitchInst::setUnwindDest>>(this);
1072 cast<llvm::CatchSwitchInst>(Val)->setUnwindDest(
1073 cast<llvm::BasicBlock>(UnwindDest->Val));
1074}
1075
1076voidCatchSwitchInst::addHandler(BasicBlock *Dest) {
1077Ctx.getTracker().emplaceIfTracking<CatchSwitchAddHandler>(this);
1078 cast<llvm::CatchSwitchInst>(Val)->addHandler(
1079 cast<llvm::BasicBlock>(Dest->Val));
1080}
1081
1082ResumeInst *ResumeInst::create(Value *Exn,InsertPosition Pos,Context &Ctx) {
1083auto &Builder =setInsertPos(Pos);
1084auto *LLVMI = cast<llvm::ResumeInst>(Builder.CreateResume(Exn->Val));
1085returnCtx.createResumeInst(LLVMI);
1086}
1087
1088Value *ResumeInst::getValue() const{
1089returnCtx.getValue(cast<llvm::ResumeInst>(Val)->getValue());
1090}
1091
1092SwitchInst *SwitchInst::create(Value *V,BasicBlock *Dest,unsigned NumCases,
1093InsertPosition Pos,Context &Ctx,
1094constTwine &Name) {
1095auto &Builder =setInsertPos(Pos);
1096llvm::SwitchInst *LLVMSwitch =
1097 Builder.CreateSwitch(V->Val, cast<llvm::BasicBlock>(Dest->Val), NumCases);
1098returnCtx.createSwitchInst(LLVMSwitch);
1099}
1100
1101Value *SwitchInst::getCondition() const{
1102returnCtx.getValue(cast<llvm::SwitchInst>(Val)->getCondition());
1103}
1104
1105voidSwitchInst::setCondition(Value *V) {
1106Ctx.getTracker()
1107 .emplaceIfTracking<
1108GenericSetter<&SwitchInst::getCondition, &SwitchInst::setCondition>>(
1109this);
1110 cast<llvm::SwitchInst>(Val)->setCondition(V->Val);
1111}
1112
1113BasicBlock *SwitchInst::getDefaultDest() const{
1114return cast<BasicBlock>(
1115Ctx.getValue(cast<llvm::SwitchInst>(Val)->getDefaultDest()));
1116}
1117
1118voidSwitchInst::setDefaultDest(BasicBlock *DefaultCase) {
1119Ctx.getTracker()
1120 .emplaceIfTracking<GenericSetter<&SwitchInst::getDefaultDest,
1121 &SwitchInst::setDefaultDest>>(this);
1122 cast<llvm::SwitchInst>(Val)->setDefaultDest(
1123 cast<llvm::BasicBlock>(DefaultCase->Val));
1124}
1125ConstantInt *SwitchInst::findCaseDest(BasicBlock *BB) {
1126auto *LLVMC = cast<llvm::SwitchInst>(Val)->findCaseDest(
1127 cast<llvm::BasicBlock>(BB->Val));
1128return LLVMC !=nullptr ? cast<ConstantInt>(Ctx.getValue(LLVMC)) :nullptr;
1129}
1130
1131voidSwitchInst::addCase(ConstantInt *OnVal,BasicBlock *Dest) {
1132Ctx.getTracker().emplaceIfTracking<SwitchAddCase>(this, OnVal);
1133// TODO: Track this!
1134 cast<llvm::SwitchInst>(Val)->addCase(cast<llvm::ConstantInt>(OnVal->Val),
1135 cast<llvm::BasicBlock>(Dest->Val));
1136}
1137
1138SwitchInst::CaseItSwitchInst::removeCase(CaseIt It) {
1139Ctx.getTracker().emplaceIfTracking<SwitchRemoveCase>(this);
1140
1141auto *LLVMSwitch = cast<llvm::SwitchInst>(Val);
1142unsigned CaseNum = It -case_begin();
1143llvm::SwitchInst::CaseIt LLVMIt(LLVMSwitch, CaseNum);
1144auto LLVMCaseIt =LLVMSwitch->removeCase(LLVMIt);
1145unsigned Num = LLVMCaseIt -LLVMSwitch->case_begin();
1146returnCaseIt(this, Num);
1147}
1148
1149BasicBlock *SwitchInst::getSuccessor(unsignedIdx) const{
1150return cast<BasicBlock>(
1151Ctx.getValue(cast<llvm::SwitchInst>(Val)->getSuccessor(Idx)));
1152}
1153
1154voidSwitchInst::setSuccessor(unsignedIdx,BasicBlock *NewSucc) {
1155Ctx.getTracker()
1156 .emplaceIfTracking<GenericSetterWithIdx<&SwitchInst::getSuccessor,
1157 &SwitchInst::setSuccessor>>(this,
1158Idx);
1159 cast<llvm::SwitchInst>(Val)->setSuccessor(
1160Idx, cast<llvm::BasicBlock>(NewSucc->Val));
1161}
1162
1163Value *UnaryOperator::create(Instruction::OpcodeOp,Value *OpV,
1164InsertPosition Pos,Context &Ctx,
1165constTwine &Name) {
1166auto &Builder =setInsertPos(Pos);
1167auto *NewLLVMV = Builder.CreateUnOp(getLLVMUnaryOp(Op), OpV->Val,Name);
1168if (auto *NewUnOpV = dyn_cast<llvm::UnaryOperator>(NewLLVMV)) {
1169returnCtx.createUnaryOperator(NewUnOpV);
1170 }
1171assert(isa<llvm::Constant>(NewLLVMV) &&"Expected constant");
1172returnCtx.getOrCreateConstant(cast<llvm::Constant>(NewLLVMV));
1173}
1174
1175Value *UnaryOperator::createWithCopiedFlags(Instruction::OpcodeOp,Value *OpV,
1176Value *CopyFrom,InsertPosition Pos,
1177Context &Ctx,constTwine &Name) {
1178auto *NewV =create(Op, OpV, Pos,Ctx,Name);
1179if (auto *UnI = dyn_cast<llvm::UnaryOperator>(NewV->Val))
1180 UnI->copyIRFlags(CopyFrom->Val);
1181return NewV;
1182}
1183
1184/// \Returns the LLVM opcode that corresponds to \p Opc.
1185staticllvm::Instruction::BinaryOpsgetLLVMBinaryOp(Instruction::Opcode Opc) {
1186switch (Opc) {
1187case Instruction::Opcode::Add:
1188returnstatic_cast<llvm::Instruction::BinaryOps>(llvm::Instruction::Add);
1189case Instruction::Opcode::FAdd:
1190returnstatic_cast<llvm::Instruction::BinaryOps>(llvm::Instruction::FAdd);
1191case Instruction::Opcode::Sub:
1192returnstatic_cast<llvm::Instruction::BinaryOps>(llvm::Instruction::Sub);
1193case Instruction::Opcode::FSub:
1194returnstatic_cast<llvm::Instruction::BinaryOps>(llvm::Instruction::FSub);
1195case Instruction::Opcode::Mul:
1196returnstatic_cast<llvm::Instruction::BinaryOps>(llvm::Instruction::Mul);
1197case Instruction::Opcode::FMul:
1198returnstatic_cast<llvm::Instruction::BinaryOps>(llvm::Instruction::FMul);
1199case Instruction::Opcode::UDiv:
1200returnstatic_cast<llvm::Instruction::BinaryOps>(llvm::Instruction::UDiv);
1201case Instruction::Opcode::SDiv:
1202returnstatic_cast<llvm::Instruction::BinaryOps>(llvm::Instruction::SDiv);
1203case Instruction::Opcode::FDiv:
1204returnstatic_cast<llvm::Instruction::BinaryOps>(llvm::Instruction::FDiv);
1205case Instruction::Opcode::URem:
1206returnstatic_cast<llvm::Instruction::BinaryOps>(llvm::Instruction::URem);
1207case Instruction::Opcode::SRem:
1208returnstatic_cast<llvm::Instruction::BinaryOps>(llvm::Instruction::SRem);
1209case Instruction::Opcode::FRem:
1210returnstatic_cast<llvm::Instruction::BinaryOps>(llvm::Instruction::FRem);
1211case Instruction::Opcode::Shl:
1212returnstatic_cast<llvm::Instruction::BinaryOps>(llvm::Instruction::Shl);
1213case Instruction::Opcode::LShr:
1214returnstatic_cast<llvm::Instruction::BinaryOps>(llvm::Instruction::LShr);
1215case Instruction::Opcode::AShr:
1216returnstatic_cast<llvm::Instruction::BinaryOps>(llvm::Instruction::AShr);
1217case Instruction::Opcode::And:
1218returnstatic_cast<llvm::Instruction::BinaryOps>(llvm::Instruction::And);
1219case Instruction::Opcode::Or:
1220returnstatic_cast<llvm::Instruction::BinaryOps>(llvm::Instruction::Or);
1221case Instruction::Opcode::Xor:
1222returnstatic_cast<llvm::Instruction::BinaryOps>(llvm::Instruction::Xor);
1223default:
1224llvm_unreachable("Not a binary op!");
1225 }
1226}
1227Value *BinaryOperator::create(Instruction::OpcodeOp,Value *LHS,Value *RHS,
1228InsertPosition Pos,Context &Ctx,
1229constTwine &Name) {
1230auto &Builder =setInsertPos(Pos);
1231llvm::Value *NewV =
1232 Builder.CreateBinOp(getLLVMBinaryOp(Op),LHS->Val,RHS->Val,Name);
1233if (auto *NewBinOp = dyn_cast<llvm::BinaryOperator>(NewV))
1234returnCtx.createBinaryOperator(NewBinOp);
1235assert(isa<llvm::Constant>(NewV) &&"Expected constant");
1236returnCtx.getOrCreateConstant(cast<llvm::Constant>(NewV));
1237}
1238
1239Value *BinaryOperator::createWithCopiedFlags(Instruction::OpcodeOp,Value *LHS,
1240Value *RHS,Value *CopyFrom,
1241InsertPosition Pos,Context &Ctx,
1242constTwine &Name) {
1243
1244Value *NewV =create(Op, LHS, RHS, Pos,Ctx,Name);
1245if (auto *NewBO = dyn_cast<BinaryOperator>(NewV))
1246 cast<llvm::BinaryOperator>(NewBO->Val)->copyIRFlags(CopyFrom->Val);
1247return NewV;
1248}
1249
1250voidPossiblyDisjointInst::setIsDisjoint(boolB) {
1251Ctx.getTracker()
1252 .emplaceIfTracking<GenericSetter<&PossiblyDisjointInst::isDisjoint,
1253 &PossiblyDisjointInst::setIsDisjoint>>(
1254this);
1255 cast<llvm::PossiblyDisjointInst>(Val)->setIsDisjoint(B);
1256}
1257
1258voidAtomicRMWInst::setAlignment(AlignAlign) {
1259Ctx.getTracker()
1260 .emplaceIfTracking<GenericSetter<&AtomicRMWInst::getAlign,
1261 &AtomicRMWInst::setAlignment>>(this);
1262 cast<llvm::AtomicRMWInst>(Val)->setAlignment(Align);
1263}
1264
1265voidAtomicRMWInst::setVolatile(bool V) {
1266Ctx.getTracker()
1267 .emplaceIfTracking<GenericSetter<&AtomicRMWInst::isVolatile,
1268 &AtomicRMWInst::setVolatile>>(this);
1269 cast<llvm::AtomicRMWInst>(Val)->setVolatile(V);
1270}
1271
1272voidAtomicRMWInst::setOrdering(AtomicOrdering Ordering) {
1273Ctx.getTracker()
1274 .emplaceIfTracking<GenericSetter<&AtomicRMWInst::getOrdering,
1275 &AtomicRMWInst::setOrdering>>(this);
1276 cast<llvm::AtomicRMWInst>(Val)->setOrdering(Ordering);
1277}
1278
1279voidAtomicRMWInst::setSyncScopeID(SyncScope::ID SSID) {
1280Ctx.getTracker()
1281 .emplaceIfTracking<GenericSetter<&AtomicRMWInst::getSyncScopeID,
1282 &AtomicRMWInst::setSyncScopeID>>(this);
1283 cast<llvm::AtomicRMWInst>(Val)->setSyncScopeID(SSID);
1284}
1285
1286Value *AtomicRMWInst::getPointerOperand() {
1287returnCtx.getValue(cast<llvm::AtomicRMWInst>(Val)->getPointerOperand());
1288}
1289
1290Value *AtomicRMWInst::getValOperand() {
1291returnCtx.getValue(cast<llvm::AtomicRMWInst>(Val)->getValOperand());
1292}
1293
1294AtomicRMWInst *AtomicRMWInst::create(BinOpOp,Value *Ptr,Value *Val,
1295MaybeAlignAlign,AtomicOrdering Ordering,
1296InsertPosition Pos,Context &Ctx,
1297SyncScope::ID SSID,constTwine &Name) {
1298auto &Builder =setInsertPos(Pos);
1299auto *LLVMAtomicRMW =
1300 Builder.CreateAtomicRMW(Op,Ptr->Val,Val->Val,Align, Ordering, SSID);
1301LLVMAtomicRMW->setName(Name);
1302returnCtx.createAtomicRMWInst(LLVMAtomicRMW);
1303}
1304
1305voidAtomicCmpXchgInst::setSyncScopeID(SyncScope::ID SSID) {
1306Ctx.getTracker()
1307 .emplaceIfTracking<GenericSetter<&AtomicCmpXchgInst::getSyncScopeID,
1308 &AtomicCmpXchgInst::setSyncScopeID>>(
1309this);
1310 cast<llvm::AtomicCmpXchgInst>(Val)->setSyncScopeID(SSID);
1311}
1312
1313Value *AtomicCmpXchgInst::getPointerOperand() {
1314returnCtx.getValue(cast<llvm::AtomicCmpXchgInst>(Val)->getPointerOperand());
1315}
1316
1317Value *AtomicCmpXchgInst::getCompareOperand() {
1318returnCtx.getValue(cast<llvm::AtomicCmpXchgInst>(Val)->getCompareOperand());
1319}
1320
1321Value *AtomicCmpXchgInst::getNewValOperand() {
1322returnCtx.getValue(cast<llvm::AtomicCmpXchgInst>(Val)->getNewValOperand());
1323}
1324
1325AtomicCmpXchgInst *
1326AtomicCmpXchgInst::create(Value *Ptr,Value *Cmp,Value *New,MaybeAlignAlign,
1327AtomicOrdering SuccessOrdering,
1328AtomicOrdering FailureOrdering,InsertPosition Pos,
1329Context &Ctx,SyncScope::ID SSID,constTwine &Name) {
1330auto &Builder =setInsertPos(Pos);
1331auto *LLVMAtomicCmpXchg =
1332 Builder.CreateAtomicCmpXchg(Ptr->Val, Cmp->Val, New->Val,Align,
1333 SuccessOrdering, FailureOrdering, SSID);
1334LLVMAtomicCmpXchg->setName(Name);
1335returnCtx.createAtomicCmpXchgInst(LLVMAtomicCmpXchg);
1336}
1337
1338voidAtomicCmpXchgInst::setAlignment(AlignAlign) {
1339Ctx.getTracker()
1340 .emplaceIfTracking<GenericSetter<&AtomicCmpXchgInst::getAlign,
1341 &AtomicCmpXchgInst::setAlignment>>(this);
1342 cast<llvm::AtomicCmpXchgInst>(Val)->setAlignment(Align);
1343}
1344
1345voidAtomicCmpXchgInst::setVolatile(bool V) {
1346Ctx.getTracker()
1347 .emplaceIfTracking<GenericSetter<&AtomicCmpXchgInst::isVolatile,
1348 &AtomicCmpXchgInst::setVolatile>>(this);
1349 cast<llvm::AtomicCmpXchgInst>(Val)->setVolatile(V);
1350}
1351
1352voidAtomicCmpXchgInst::setWeak(bool IsWeak) {
1353Ctx.getTracker()
1354 .emplaceIfTracking<GenericSetter<&AtomicCmpXchgInst::isWeak,
1355 &AtomicCmpXchgInst::setWeak>>(this);
1356 cast<llvm::AtomicCmpXchgInst>(Val)->setWeak(IsWeak);
1357}
1358
1359voidAtomicCmpXchgInst::setSuccessOrdering(AtomicOrdering Ordering) {
1360Ctx.getTracker()
1361 .emplaceIfTracking<GenericSetter<&AtomicCmpXchgInst::getSuccessOrdering,
1362 &AtomicCmpXchgInst::setSuccessOrdering>>(
1363this);
1364 cast<llvm::AtomicCmpXchgInst>(Val)->setSuccessOrdering(Ordering);
1365}
1366
1367voidAtomicCmpXchgInst::setFailureOrdering(AtomicOrdering Ordering) {
1368Ctx.getTracker()
1369 .emplaceIfTracking<GenericSetter<&AtomicCmpXchgInst::getFailureOrdering,
1370 &AtomicCmpXchgInst::setFailureOrdering>>(
1371this);
1372 cast<llvm::AtomicCmpXchgInst>(Val)->setFailureOrdering(Ordering);
1373}
1374
1375AllocaInst *AllocaInst::create(Type *Ty,unsigned AddrSpace,InsertPosition Pos,
1376Context &Ctx,Value *ArraySize,
1377constTwine &Name) {
1378auto &Builder =setInsertPos(Pos);
1379auto *NewAlloca =
1380 Builder.CreateAlloca(Ty->LLVMTy, AddrSpace, ArraySize->Val,Name);
1381returnCtx.createAllocaInst(NewAlloca);
1382}
1383
1384Type *AllocaInst::getAllocatedType() const{
1385returnCtx.getType(cast<llvm::AllocaInst>(Val)->getAllocatedType());
1386}
1387
1388voidAllocaInst::setAllocatedType(Type *Ty) {
1389Ctx.getTracker()
1390 .emplaceIfTracking<GenericSetter<&AllocaInst::getAllocatedType,
1391 &AllocaInst::setAllocatedType>>(this);
1392 cast<llvm::AllocaInst>(Val)->setAllocatedType(Ty->LLVMTy);
1393}
1394
1395voidAllocaInst::setAlignment(AlignAlign) {
1396Ctx.getTracker()
1397 .emplaceIfTracking<
1398GenericSetter<&AllocaInst::getAlign, &AllocaInst::setAlignment>>(
1399this);
1400 cast<llvm::AllocaInst>(Val)->setAlignment(Align);
1401}
1402
1403voidAllocaInst::setUsedWithInAlloca(bool V) {
1404Ctx.getTracker()
1405 .emplaceIfTracking<GenericSetter<&AllocaInst::isUsedWithInAlloca,
1406 &AllocaInst::setUsedWithInAlloca>>(this);
1407 cast<llvm::AllocaInst>(Val)->setUsedWithInAlloca(V);
1408}
1409
1410Value *AllocaInst::getArraySize() {
1411returnCtx.getValue(cast<llvm::AllocaInst>(Val)->getArraySize());
1412}
1413
1414PointerType *AllocaInst::getType() const{
1415return cast<PointerType>(Ctx.getType(cast<llvm::AllocaInst>(Val)->getType()));
1416}
1417
1418Value *CastInst::create(Type *DestTy,OpcodeOp,Value *Operand,
1419InsertPosition Pos,Context &Ctx,constTwine &Name) {
1420assert(getLLVMCastOp(Op) &&"Opcode not suitable for CastInst!");
1421auto &Builder =setInsertPos(Pos);
1422auto *NewV =
1423 Builder.CreateCast(getLLVMCastOp(Op), Operand->Val, DestTy->LLVMTy,Name);
1424if (auto *NewCI = dyn_cast<llvm::CastInst>(NewV))
1425returnCtx.createCastInst(NewCI);
1426assert(isa<llvm::Constant>(NewV) &&"Expected constant");
1427returnCtx.getOrCreateConstant(cast<llvm::Constant>(NewV));
1428}
1429
1430boolCastInst::classof(constValue *From) {
1431returnFrom->getSubclassID() == ClassID::Cast;
1432}
1433
1434Type *CastInst::getSrcTy() const{
1435returnCtx.getType(cast<llvm::CastInst>(Val)->getSrcTy());
1436}
1437
1438Type *CastInst::getDestTy() const{
1439returnCtx.getType(cast<llvm::CastInst>(Val)->getDestTy());
1440}
1441
1442voidPossiblyNonNegInst::setNonNeg(boolB) {
1443Ctx.getTracker()
1444 .emplaceIfTracking<GenericSetter<&PossiblyNonNegInst::hasNonNeg,
1445 &PossiblyNonNegInst::setNonNeg>>(this);
1446 cast<llvm::PossiblyNonNegInst>(Val)->setNonNeg(B);
1447}
1448
1449Value *InsertElementInst::create(Value *Vec,Value *NewElt,Value *Idx,
1450InsertPosition Pos,Context &Ctx,
1451constTwine &Name) {
1452auto &Builder =Instruction::setInsertPos(Pos);
1453llvm::Value *NewV =
1454 Builder.CreateInsertElement(Vec->Val, NewElt->Val,Idx->Val,Name);
1455if (auto *NewInsert = dyn_cast<llvm::InsertElementInst>(NewV))
1456returnCtx.createInsertElementInst(NewInsert);
1457assert(isa<llvm::Constant>(NewV) &&"Expected constant");
1458returnCtx.getOrCreateConstant(cast<llvm::Constant>(NewV));
1459}
1460
1461Value *ExtractElementInst::create(Value *Vec,Value *Idx,InsertPosition Pos,
1462Context &Ctx,constTwine &Name) {
1463auto &Builder =setInsertPos(Pos);
1464llvm::Value *NewV = Builder.CreateExtractElement(Vec->Val,Idx->Val,Name);
1465if (auto *NewExtract = dyn_cast<llvm::ExtractElementInst>(NewV))
1466returnCtx.createExtractElementInst(NewExtract);
1467assert(isa<llvm::Constant>(NewV) &&"Expected constant");
1468returnCtx.getOrCreateConstant(cast<llvm::Constant>(NewV));
1469}
1470
1471Value *ShuffleVectorInst::create(Value *V1,Value *V2,Value *Mask,
1472InsertPosition Pos,Context &Ctx,
1473constTwine &Name) {
1474auto &Builder =setInsertPos(Pos);
1475llvm::Value *NewV =
1476 Builder.CreateShuffleVector(V1->Val, V2->Val, Mask->Val,Name);
1477if (auto *NewShuffle = dyn_cast<llvm::ShuffleVectorInst>(NewV))
1478returnCtx.createShuffleVectorInst(NewShuffle);
1479assert(isa<llvm::Constant>(NewV) &&"Expected constant");
1480returnCtx.getOrCreateConstant(cast<llvm::Constant>(NewV));
1481}
1482
1483Value *ShuffleVectorInst::create(Value *V1,Value *V2,ArrayRef<int> Mask,
1484InsertPosition Pos,Context &Ctx,
1485constTwine &Name) {
1486auto &Builder =setInsertPos(Pos);
1487llvm::Value *NewV = Builder.CreateShuffleVector(V1->Val, V2->Val, Mask,Name);
1488if (auto *NewShuffle = dyn_cast<llvm::ShuffleVectorInst>(NewV))
1489returnCtx.createShuffleVectorInst(NewShuffle);
1490assert(isa<llvm::Constant>(NewV) &&"Expected constant");
1491returnCtx.getOrCreateConstant(cast<llvm::Constant>(NewV));
1492}
1493
1494voidShuffleVectorInst::setShuffleMask(ArrayRef<int> Mask) {
1495Ctx.getTracker().emplaceIfTracking<ShuffleVectorSetMask>(this);
1496 cast<llvm::ShuffleVectorInst>(Val)->setShuffleMask(Mask);
1497}
1498
1499VectorType *ShuffleVectorInst::getType() const{
1500return cast<VectorType>(
1501Ctx.getType(cast<llvm::ShuffleVectorInst>(Val)->getType()));
1502}
1503
1504voidShuffleVectorInst::commute() {
1505Ctx.getTracker().emplaceIfTracking<ShuffleVectorSetMask>(this);
1506Ctx.getTracker().emplaceIfTracking<UseSwap>(getOperandUse(0),
1507getOperandUse(1));
1508 cast<llvm::ShuffleVectorInst>(Val)->commute();
1509}
1510
1511Constant *ShuffleVectorInst::getShuffleMaskForBitcode() const{
1512returnCtx.getOrCreateConstant(
1513 cast<llvm::ShuffleVectorInst>(Val)->getShuffleMaskForBitcode());
1514}
1515
1516Constant *ShuffleVectorInst::convertShuffleMaskForBitcode(ArrayRef<int> Mask,
1517Type *ResultTy) {
1518return ResultTy->getContext().getOrCreateConstant(
1519llvm::ShuffleVectorInst::convertShuffleMaskForBitcode(Mask,
1520 ResultTy->LLVMTy));
1521}
1522
1523VectorType *ExtractElementInst::getVectorOperandType() const{
1524return cast<VectorType>(Ctx.getType(getVectorOperand()->getType()->LLVMTy));
1525}
1526
1527Value *ExtractValueInst::create(Value *Agg,ArrayRef<unsigned> Idxs,
1528InsertPosition Pos,Context &Ctx,
1529constTwine &Name) {
1530auto &Builder =setInsertPos(Pos);
1531llvm::Value *NewV = Builder.CreateExtractValue(Agg->Val, Idxs,Name);
1532if (auto *NewExtractValueInst = dyn_cast<llvm::ExtractValueInst>(NewV))
1533returnCtx.createExtractValueInst(NewExtractValueInst);
1534assert(isa<llvm::Constant>(NewV) &&"Expected constant");
1535returnCtx.getOrCreateConstant(cast<llvm::Constant>(NewV));
1536}
1537
1538Type *ExtractValueInst::getIndexedType(Type *Agg,ArrayRef<unsigned> Idxs) {
1539auto *LLVMTy =llvm::ExtractValueInst::getIndexedType(Agg->LLVMTy, Idxs);
1540return Agg->getContext().getType(LLVMTy);
1541}
1542
1543Value *InsertValueInst::create(Value *Agg,Value *Val,ArrayRef<unsigned> Idxs,
1544InsertPosition Pos,Context &Ctx,
1545constTwine &Name) {
1546auto &Builder =setInsertPos(Pos);
1547llvm::Value *NewV = Builder.CreateInsertValue(Agg->Val,Val->Val, Idxs,Name);
1548if (auto *NewInsertValueInst = dyn_cast<llvm::InsertValueInst>(NewV))
1549returnCtx.createInsertValueInst(NewInsertValueInst);
1550assert(isa<llvm::Constant>(NewV) &&"Expected constant");
1551returnCtx.getOrCreateConstant(cast<llvm::Constant>(NewV));
1552}
1553
1554ConstantTokenNone *ConstantTokenNone::get(Context &Ctx) {
1555auto *LLVMC =llvm::ConstantTokenNone::get(Ctx.LLVMCtx);
1556return cast<ConstantTokenNone>(Ctx.getOrCreateConstant(LLVMC));
1557}
1558
1559}// namespace llvm::sandboxir
S1
static const LLT S1
Definition:AMDGPULegalizerInfo.cpp:282
From
BlockVerifier::State From
Definition:BlockVerifier.cpp:57
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
RetTy
return RetTy
Definition:DeadArgumentElimination.cpp:361
Idx
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
Definition:DeadArgumentElimination.cpp:353
Name
std::string Name
Definition:ELFObjHandler.cpp:77
F
#define F(x, y, z)
Definition:MD5.cpp:55
I
#define I(x, y, z)
Definition:MD5.cpp:58
P
#define P(N)
Cond
const SmallVectorImpl< MachineOperand > & Cond
Definition:RISCVRedundantCopyElimination.cpp:75
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
OS
raw_pwrite_stream & OS
Definition:SampleProfWriter.cpp:51
Function.h
Instruction.h
Ptr
@ Ptr
Definition:TargetLibraryInfo.cpp:77
RHS
Value * RHS
Definition:X86PartialReduction.cpp:74
LHS
Value * LHS
Definition:X86PartialReduction.cpp:73
Predicate
Definition:AMDGPURegBankLegalizeRules.cpp:332
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition:ArrayRef.h:41
llvm::ArrayRef::size
size_t size() const
size - Get the array size.
Definition:ArrayRef.h:168
llvm::AtomicCmpXchgInst
An instruction that atomically checks whether a specified value is in a memory location,...
Definition:Instructions.h:501
llvm::AtomicRMWInst::BinOp
BinOp
This enumeration lists the possible modifications atomicrmw can make.
Definition:Instructions.h:716
llvm::BasicBlock
LLVM Basic Block Representation.
Definition:BasicBlock.h:61
llvm::BasicBlock::end
iterator end()
Definition:BasicBlock.h:464
llvm::BasicBlock::iterator
InstListType::iterator iterator
Instruction iterators...
Definition:BasicBlock.h:177
llvm::BranchInst
Conditional or Unconditional Branch instruction.
Definition:Instructions.h:3016
llvm::CallBrInst
CallBr instruction, tracking function calls that may not return control but instead transfer it to a ...
Definition:Instructions.h:3830
llvm::CallInst
This class represents a function call, abstracting a target machine's calling convention.
Definition:Instructions.h:1479
llvm::CatchPadInst
Definition:Instructions.h:4250
llvm::CatchReturnInst
Definition:Instructions.h:4289
llvm::CatchSwitchInst
Definition:Instructions.h:4056
llvm::CleanupPadInst
Definition:Instructions.h:4221
llvm::CleanupReturnInst
Definition:Instructions.h:4364
llvm::ConstantTokenNone::get
static ConstantTokenNone * get(LLVMContext &Context)
Return the ConstantTokenNone.
Definition:Constants.cpp:1522
llvm::DWARFExpression::Operation
This class represents an Operation in the Expression.
Definition:DWARFExpression.h:32
llvm::ExtractValueInst::getIndexedType
static Type * getIndexedType(Type *Agg, ArrayRef< unsigned > Idxs)
Returns the type of the element that would be extracted with an extractvalue instruction with the spe...
Definition:Instructions.cpp:2499
llvm::FastMathFlags
Convenience struct for specifying and reasoning about fast-math flags.
Definition:FMF.h:20
llvm::FenceInst
An instruction for ordering other memory operations.
Definition:Instructions.h:424
llvm::Function
Definition:Function.h:63
llvm::IRBuilderBase::CreateCleanupPad
CleanupPadInst * CreateCleanupPad(Value *ParentPad, ArrayRef< Value * > Args={}, const Twine &Name="")
Definition:IRBuilder.h:1296
llvm::IRBuilderBase::CreateCatchPad
CatchPadInst * CreateCatchPad(Value *ParentPad, ArrayRef< Value * > Args, const Twine &Name="")
Definition:IRBuilder.h:1291
llvm::IRBuilderBase::CreateInsertElement
Value * CreateInsertElement(Type *VecTy, Value *NewElt, Value *Idx, const Twine &Name="")
Definition:IRBuilder.h:2511
llvm::IRBuilderBase::CreateAtomicCmpXchg
AtomicCmpXchgInst * CreateAtomicCmpXchg(Value *Ptr, Value *Cmp, Value *New, MaybeAlign Align, AtomicOrdering SuccessOrdering, AtomicOrdering FailureOrdering, SyncScope::ID SSID=SyncScope::System)
Definition:IRBuilder.h:1849
llvm::IRBuilderBase::CreateAlloca
AllocaInst * CreateAlloca(Type *Ty, unsigned AddrSpace, Value *ArraySize=nullptr, const Twine &Name="")
Definition:IRBuilder.h:1781
llvm::IRBuilderBase::CreateInsertValue
Value * CreateInsertValue(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &Name="")
Definition:IRBuilder.h:2562
llvm::IRBuilderBase::CreateExtractElement
Value * CreateExtractElement(Value *Vec, Value *Idx, const Twine &Name="")
Definition:IRBuilder.h:2499
llvm::IRBuilderBase::CreateExtractValue
Value * CreateExtractValue(Value *Agg, ArrayRef< unsigned > Idxs, const Twine &Name="")
Definition:IRBuilder.h:2555
llvm::IRBuilderBase::CreateLandingPad
LandingPadInst * CreateLandingPad(Type *Ty, unsigned NumClauses, const Twine &Name="")
Definition:IRBuilder.h:2569
llvm::IRBuilderBase::CreateInvoke
InvokeInst * CreateInvoke(FunctionType *Ty, Value *Callee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > OpBundles, const Twine &Name="")
Create an invoke instruction.
Definition:IRBuilder.h:1202
llvm::IRBuilderBase::CreateCallBr
CallBrInst * CreateCallBr(FunctionType *Ty, Value *Callee, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args={}, const Twine &Name="")
Create a callbr instruction.
Definition:IRBuilder.h:1240
llvm::IRBuilderBase::CreateCast
Value * CreateCast(Instruction::CastOps Op, Value *V, Type *DestTy, const Twine &Name="", MDNode *FPMathTag=nullptr, FMFSource FMFSource={})
Definition:IRBuilder.h:2186
llvm::IRBuilderBase::CreateCatchRet
CatchReturnInst * CreateCatchRet(CatchPadInst *CatchPad, BasicBlock *BB)
Definition:IRBuilder.h:1302
llvm::IRBuilderBase::CreateCleanupRet
CleanupReturnInst * CreateCleanupRet(CleanupPadInst *CleanupPad, BasicBlock *UnwindBB=nullptr)
Definition:IRBuilder.h:1279
llvm::IRBuilderBase::CreateRet
ReturnInst * CreateRet(Value *V)
Create a 'ret <val>' instruction.
Definition:IRBuilder.h:1139
llvm::IRBuilderBase::CreateGEP
Value * CreateGEP(Type *Ty, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &Name="", GEPNoWrapFlags NW=GEPNoWrapFlags::none())
Definition:IRBuilder.h:1874
llvm::IRBuilderBase::CreateCatchSwitch
CatchSwitchInst * CreateCatchSwitch(Value *ParentPad, BasicBlock *UnwindBB, unsigned NumHandlers, const Twine &Name="")
Definition:IRBuilder.h:1284
llvm::IRBuilderBase::CreateUnOp
Value * CreateUnOp(Instruction::UnaryOps Opc, Value *V, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition:IRBuilder.h:1761
llvm::IRBuilderBase::CreateCmp
Value * CreateCmp(CmpInst::Predicate Pred, Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition:IRBuilder.h:2404
llvm::IRBuilderBase::CreatePHI
PHINode * CreatePHI(Type *Ty, unsigned NumReservedValues, const Twine &Name="")
Definition:IRBuilder.h:2435
llvm::IRBuilderBase::CreateSwitch
SwitchInst * CreateSwitch(Value *V, BasicBlock *Dest, unsigned NumCases=10, MDNode *BranchWeights=nullptr, MDNode *Unpredictable=nullptr)
Create a switch instruction with the specified value, default dest, and with a hint for the number of...
Definition:IRBuilder.h:1187
llvm::IRBuilderBase::CreateShuffleVector
Value * CreateShuffleVector(Value *V1, Value *V2, Value *Mask, const Twine &Name="")
Definition:IRBuilder.h:2533
llvm::IRBuilderBase::CreateRetVoid
ReturnInst * CreateRetVoid()
Create a 'ret void' instruction.
Definition:IRBuilder.h:1134
llvm::IRBuilderBase::CreateCall
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value * > Args={}, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition:IRBuilder.h:2449
llvm::IRBuilderBase::CreateAtomicRMW
AtomicRMWInst * CreateAtomicRMW(AtomicRMWInst::BinOp Op, Value *Ptr, Value *Val, MaybeAlign Align, AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System)
Definition:IRBuilder.h:1862
llvm::IRBuilderBase::CreateBinOp
Value * CreateBinOp(Instruction::BinaryOps Opc, Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition:IRBuilder.h:1671
llvm::IRBuilderBase::CreateResume
ResumeInst * CreateResume(Value *Exn)
Definition:IRBuilder.h:1275
llvm::IRBuilder
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Definition:IRBuilder.h:2705
llvm::InsertPosition
Definition:Instruction.h:48
llvm::Instruction
Definition:Instruction.h:68
llvm::Instruction::BinaryOps
BinaryOps
Definition:Instruction.h:989
llvm::Instruction::UnaryOps
UnaryOps
Definition:Instruction.h:982
llvm::Instruction::CastOps
CastOps
Definition:Instruction.h:1003
llvm::InvokeInst
Invoke instruction.
Definition:Instructions.h:3670
llvm::LandingPadInst
The landingpad instruction holds all of the information necessary to generate correct exception handl...
Definition:Instructions.h:2840
llvm::PHINode
Definition:Instructions.h:2600
llvm::ReturnInst
Return a value (possibly void), from a function.
Definition:Instructions.h:2938
llvm::ShuffleVectorInst::convertShuffleMaskForBitcode
static Constant * convertShuffleMaskForBitcode(ArrayRef< int > Mask, Type *ResultTy)
Definition:Instructions.cpp:1827
llvm::SmallVectorImpl::reserve
void reserve(size_type N)
Definition:SmallVector.h:663
llvm::SmallVectorTemplateBase::push_back
void push_back(const T &Elt)
Definition:SmallVector.h:413
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition:SmallVector.h:1196
llvm::SwitchInst::CaseIteratorImpl
Definition:Instructions.h:3273
llvm::SwitchInst
Multiway switch.
Definition:Instructions.h:3154
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition:Twine.h:81
llvm::Type::getInt1Ty
static IntegerType * getInt1Ty(LLVMContext &C)
llvm::UnreachableInst
This function has undefined behavior.
Definition:Instructions.h:4461
llvm::Use
A Use represents the edge between a Value definition and its users.
Definition:Use.h:43
llvm::Value
LLVM Value Representation.
Definition:Value.h:74
llvm::VectorType::get
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition:STLFunctionalExtras.h:37
llvm::ilist_node_impl::getIterator
self_iterator getIterator()
Definition:ilist_node.h:132
llvm::ilist_node_with_parent::getNextNode
NodeTy * getNextNode()
Get the next node, or nullptr for the list tail.
Definition:ilist_node.h:353
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition:raw_ostream.h:52
llvm::sandboxir::AllocaInst
Definition:Instruction.h:2186
llvm::sandboxir::AllocaInst::isUsedWithInAlloca
bool isUsedWithInAlloca() const
Return true if this alloca is used as an inalloca argument to a call.
Definition:Instruction.h:2241
llvm::sandboxir::AllocaInst::getAllocatedType
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
Definition:Instruction.cpp:1384
llvm::sandboxir::AllocaInst::setAllocatedType
void setAllocatedType(Type *Ty)
for use only in special circumstances that need to generically transform a whole instruction (eg: IR ...
Definition:Instruction.cpp:1388
llvm::sandboxir::AllocaInst::getArraySize
Value * getArraySize()
Get the number of elements allocated.
Definition:Instruction.cpp:1410
llvm::sandboxir::AllocaInst::getType
PointerType * getType() const
Overload to return most specific pointer type.
Definition:Instruction.cpp:1414
llvm::sandboxir::AllocaInst::setUsedWithInAlloca
void setUsedWithInAlloca(bool V)
Specify whether this alloca is used to represent the arguments to a call.
Definition:Instruction.cpp:1403
llvm::sandboxir::AllocaInst::setAlignment
void setAlignment(Align Align)
Definition:Instruction.cpp:1395
llvm::sandboxir::AllocaInst::create
static AllocaInst * create(Type *Ty, unsigned AddrSpace, InsertPosition Pos, Context &Ctx, Value *ArraySize=nullptr, const Twine &Name="")
Definition:Instruction.cpp:1375
llvm::sandboxir::AtomicCmpXchgInst::getPointerOperand
Value * getPointerOperand()
Definition:Instruction.cpp:1313
llvm::sandboxir::AtomicCmpXchgInst::setSuccessOrdering
void setSuccessOrdering(AtomicOrdering Ordering)
Definition:Instruction.cpp:1359
llvm::sandboxir::AtomicCmpXchgInst::setWeak
void setWeak(bool IsWeak)
Definition:Instruction.cpp:1352
llvm::sandboxir::AtomicCmpXchgInst::setVolatile
void setVolatile(bool V)
Specify whether this is a volatile cmpxchg.
Definition:Instruction.cpp:1345
llvm::sandboxir::AtomicCmpXchgInst::setFailureOrdering
void setFailureOrdering(AtomicOrdering Ordering)
Definition:Instruction.cpp:1367
llvm::sandboxir::AtomicCmpXchgInst::getFailureOrdering
AtomicOrdering getFailureOrdering() const
Definition:Instruction.h:2144
llvm::sandboxir::AtomicCmpXchgInst::setAlignment
void setAlignment(Align Align)
Definition:Instruction.cpp:1338
llvm::sandboxir::AtomicCmpXchgInst::getCompareOperand
Value * getCompareOperand()
Definition:Instruction.cpp:1317
llvm::sandboxir::AtomicCmpXchgInst::create
static AtomicCmpXchgInst * create(Value *Ptr, Value *Cmp, Value *New, MaybeAlign Align, AtomicOrdering SuccessOrdering, AtomicOrdering FailureOrdering, InsertPosition Pos, Context &Ctx, SyncScope::ID SSID=SyncScope::System, const Twine &Name="")
Definition:Instruction.cpp:1326
llvm::sandboxir::AtomicCmpXchgInst::isVolatile
bool isVolatile() const
Return true if this is a cmpxchg from a volatile memory location.
Definition:Instruction.h:2125
llvm::sandboxir::AtomicCmpXchgInst::setSyncScopeID
void setSyncScopeID(SyncScope::ID SSID)
Definition:Instruction.cpp:1305
llvm::sandboxir::AtomicCmpXchgInst::getSuccessOrdering
AtomicOrdering getSuccessOrdering() const
Definition:Instruction.h:2139
llvm::sandboxir::AtomicCmpXchgInst::getSyncScopeID
SyncScope::ID getSyncScopeID() const
Definition:Instruction.h:2151
llvm::sandboxir::AtomicCmpXchgInst::getNewValOperand
Value * getNewValOperand()
Definition:Instruction.cpp:1321
llvm::sandboxir::AtomicCmpXchgInst::getAlign
Align getAlign() const
Return the alignment of the memory that is being allocated by the instruction.
Definition:Instruction.h:2118
llvm::sandboxir::AtomicCmpXchgInst::isWeak
bool isWeak() const
Return true if this cmpxchg may spuriously fail.
Definition:Instruction.h:2131
llvm::sandboxir::AtomicRMWInst
Definition:Instruction.h:2047
llvm::sandboxir::AtomicRMWInst::getValOperand
Value * getValOperand()
Definition:Instruction.cpp:1290
llvm::sandboxir::AtomicRMWInst::create
static AtomicRMWInst * create(BinOp Op, Value *Ptr, Value *Val, MaybeAlign Align, AtomicOrdering Ordering, InsertPosition Pos, Context &Ctx, SyncScope::ID SSID=SyncScope::System, const Twine &Name="")
Definition:Instruction.cpp:1294
llvm::sandboxir::AtomicRMWInst::setSyncScopeID
void setSyncScopeID(SyncScope::ID SSID)
Definition:Instruction.cpp:1279
llvm::sandboxir::AtomicRMWInst::setOrdering
void setOrdering(AtomicOrdering Ordering)
Definition:Instruction.cpp:1272
llvm::sandboxir::AtomicRMWInst::getSyncScopeID
SyncScope::ID getSyncScopeID() const
Definition:Instruction.h:2078
llvm::sandboxir::AtomicRMWInst::getAlign
Align getAlign() const
Definition:Instruction.h:2068
llvm::sandboxir::AtomicRMWInst::setVolatile
void setVolatile(bool V)
Definition:Instruction.cpp:1265
llvm::sandboxir::AtomicRMWInst::getOrdering
AtomicOrdering getOrdering() const
Definition:Instruction.h:2074
llvm::sandboxir::AtomicRMWInst::getPointerOperand
Value * getPointerOperand()
Definition:Instruction.cpp:1286
llvm::sandboxir::AtomicRMWInst::isVolatile
bool isVolatile() const
Definition:Instruction.h:2070
llvm::sandboxir::AtomicRMWInst::setAlignment
void setAlignment(Align Align)
Definition:Instruction.cpp:1258
llvm::sandboxir::BBIterator
Iterator for Instructions in a `BasicBlock.
Definition:BasicBlock.h:23
llvm::sandboxir::BasicBlock
Contains a list of sandboxir::Instruction's.
Definition:BasicBlock.h:67
llvm::sandboxir::BasicBlock::iterator
BBIterator iterator
Definition:BasicBlock.h:86
llvm::sandboxir::BasicBlock::getParent
Function * getParent() const
Definition:BasicBlock.cpp:53
llvm::sandboxir::BasicBlock::end
iterator end() const
Definition:BasicBlock.h:88
llvm::sandboxir::BinaryOperator::create
static Value * create(Instruction::Opcode Op, Value *LHS, Value *RHS, InsertPosition Pos, Context &Ctx, const Twine &Name="")
Definition:Instruction.cpp:1227
llvm::sandboxir::BinaryOperator::createWithCopiedFlags
static Value * createWithCopiedFlags(Instruction::Opcode Op, Value *LHS, Value *RHS, Value *CopyFrom, InsertPosition Pos, Context &Ctx, const Twine &Name="")
Definition:Instruction.cpp:1239
llvm::sandboxir::BranchInst
Definition:Instruction.h:1020
llvm::sandboxir::BranchInst::getSuccessor
BasicBlock * getSuccessor(unsigned SuccIdx) const
Definition:Instruction.cpp:376
llvm::sandboxir::BranchInst::getCondition
Value * getCondition() const
Definition:Instruction.cpp:371
llvm::sandboxir::BranchInst::setSuccessor
void setSuccessor(unsigned Idx, BasicBlock *NewSucc)
Definition:Instruction.cpp:383
llvm::sandboxir::BranchInst::getNumSuccessors
unsigned getNumSuccessors() const
Definition:Instruction.h:1041
llvm::sandboxir::BranchInst::create
static BranchInst * create(BasicBlock *IfTrue, InsertPosition Pos, Context &Ctx)
Definition:Instruction.cpp:350
llvm::sandboxir::BranchInst::classof
static bool classof(const Value *From)
For isa/dyn_cast.
Definition:Instruction.cpp:367
llvm::sandboxir::BranchInst::isConditional
bool isConditional() const
Definition:Instruction.h:1036
llvm::sandboxir::CallBase::getCalledFunction
Function * getCalledFunction() const
Definition:Instruction.cpp:494
llvm::sandboxir::CallBase::getCalledOperandUse
Use getCalledOperandUse() const
Definition:Instruction.cpp:489
llvm::sandboxir::CallBase::getFunctionType
FunctionType * getFunctionType() const
Definition:Instruction.cpp:480
llvm::sandboxir::CallBase::setCalledFunction
void setCalledFunction(Function *F)
Definition:Instruction.cpp:502
llvm::sandboxir::CallBase::getCaller
Function * getCaller()
Definition:Instruction.cpp:498
llvm::sandboxir::CallBase::getCalledOperand
Value * getCalledOperand() const
Definition:Instruction.cpp:485
llvm::sandboxir::CallBase::setCalledOperand
void setCalledOperand(Value *V)
Definition:Instruction.h:1414
llvm::sandboxir::CallBrInst
Definition:Instruction.h:1475
llvm::sandboxir::CallBrInst::getIndirectDestLabelUse
Value * getIndirectDestLabelUse(unsigned Idx) const
Definition:Instruction.cpp:596
llvm::sandboxir::CallBrInst::create
static CallBrInst * create(FunctionType *FTy, Value *Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, InsertPosition Pos, Context &Ctx, const Twine &NameStr="")
Definition:Instruction.cpp:570
llvm::sandboxir::CallBrInst::getIndirectDestLabel
Value * getIndirectDestLabel(unsigned Idx) const
Definition:Instruction.cpp:593
llvm::sandboxir::CallBrInst::getSuccessor
BasicBlock * getSuccessor(unsigned Idx) const
Definition:Instruction.cpp:629
llvm::sandboxir::CallBrInst::setIndirectDest
void setIndirectDest(unsigned Idx, BasicBlock *BB)
Definition:Instruction.cpp:621
llvm::sandboxir::CallBrInst::getDefaultDest
BasicBlock * getDefaultDest() const
Definition:Instruction.cpp:600
llvm::sandboxir::CallBrInst::getIndirectDest
BasicBlock * getIndirectDest(unsigned Idx) const
Definition:Instruction.cpp:604
llvm::sandboxir::CallBrInst::getIndirectDests
SmallVector< BasicBlock *, 16 > getIndirectDests() const
Definition:Instruction.cpp:608
llvm::sandboxir::CallBrInst::setDefaultDest
void setDefaultDest(BasicBlock *BB)
Definition:Instruction.cpp:615
llvm::sandboxir::CallInst
Definition:Instruction.h:1422
llvm::sandboxir::CallInst::create
static CallInst * create(FunctionType *FTy, Value *Func, ArrayRef< Value * > Args, InsertPosition Pos, Context &Ctx, const Twine &NameStr="")
Definition:Instruction.cpp:515
llvm::sandboxir::CastInst::getSrcTy
Type * getSrcTy() const
Definition:Instruction.cpp:1434
llvm::sandboxir::CastInst::create
static Value * create(Type *DestTy, Opcode Op, Value *Operand, InsertPosition Pos, Context &Ctx, const Twine &Name="")
Definition:Instruction.cpp:1418
llvm::sandboxir::CastInst::getDestTy
Type * getDestTy() const
Definition:Instruction.cpp:1438
llvm::sandboxir::CastInst::classof
static bool classof(const Value *From)
For isa/dyn_cast.
Definition:Instruction.cpp:1430
llvm::sandboxir::CatchPadInst
Definition:Instruction.h:1582
llvm::sandboxir::CatchPadInst::create
static CatchPadInst * create(Value *ParentPad, ArrayRef< Value * > Args, InsertPosition Pos, Context &Ctx, const Twine &Name="")
Definition:Instruction.cpp:683
llvm::sandboxir::CatchPadInst::getCatchSwitch
CatchSwitchInst * getCatchSwitch() const
Definition:Instruction.cpp:678
llvm::sandboxir::CatchReturnInst
Definition:Instruction.h:1615
llvm::sandboxir::CatchReturnInst::getCatchPad
CatchPadInst * getCatchPad() const
Definition:Instruction.cpp:717
llvm::sandboxir::CatchReturnInst::getSuccessor
BasicBlock * getSuccessor() const
Definition:Instruction.cpp:730
llvm::sandboxir::CatchReturnInst::setSuccessor
void setSuccessor(BasicBlock *NewSucc)
Definition:Instruction.cpp:735
llvm::sandboxir::CatchReturnInst::setCatchPad
void setCatchPad(CatchPadInst *CatchPad)
Definition:Instruction.cpp:722
llvm::sandboxir::CatchReturnInst::getCatchSwitchParentPad
Value * getCatchSwitchParentPad() const
Definition:Instruction.cpp:743
llvm::sandboxir::CatchReturnInst::create
static CatchReturnInst * create(CatchPadInst *CatchPad, BasicBlock *BB, InsertPosition Pos, Context &Ctx)
Definition:Instruction.cpp:709
llvm::sandboxir::CatchSwitchAddHandler
Definition:Tracker.h:330
llvm::sandboxir::CatchSwitchInst
Definition:Instruction.h:1746
llvm::sandboxir::CatchSwitchInst::addHandler
void addHandler(BasicBlock *Dest)
Definition:Instruction.cpp:1076
llvm::sandboxir::CatchSwitchInst::setParentPad
void setParentPad(Value *ParentPad)
Definition:Instruction.cpp:1056
llvm::sandboxir::CatchSwitchInst::setUnwindDest
void setUnwindDest(BasicBlock *UnwindDest)
Definition:Instruction.cpp:1068
llvm::sandboxir::CatchSwitchInst::create
static CatchSwitchInst * create(Value *ParentPad, BasicBlock *UnwindBB, unsigned NumHandlers, InsertPosition Pos, Context &Ctx, const Twine &Name="")
Definition:Instruction.cpp:1042
llvm::sandboxir::CatchSwitchInst::getUnwindDest
BasicBlock * getUnwindDest() const
Definition:Instruction.cpp:1063
llvm::sandboxir::CatchSwitchInst::getParentPad
Value * getParentPad() const
Definition:Instruction.cpp:1052
llvm::sandboxir::CleanupPadInst
Definition:Instruction.h:1600
llvm::sandboxir::CleanupPadInst::create
static CleanupPadInst * create(Value *ParentPad, ArrayRef< Value * > Args, InsertPosition Pos, Context &Ctx, const Twine &Name="")
Definition:Instruction.cpp:696
llvm::sandboxir::CleanupReturnInst
Definition:Instruction.h:1638
llvm::sandboxir::CleanupReturnInst::getCleanupPad
CleanupPadInst * getCleanupPad() const
Definition:Instruction.cpp:759
llvm::sandboxir::CleanupReturnInst::setUnwindDest
void setUnwindDest(BasicBlock *NewDest)
Definition:Instruction.cpp:778
llvm::sandboxir::CleanupReturnInst::create
static CleanupReturnInst * create(CleanupPadInst *CleanupPad, BasicBlock *UnwindBB, InsertPosition Pos, Context &Ctx)
Definition:Instruction.cpp:748
llvm::sandboxir::CleanupReturnInst::getUnwindDest
BasicBlock * getUnwindDest() const
Definition:Instruction.cpp:773
llvm::sandboxir::CleanupReturnInst::setCleanupPad
void setCleanupPad(CleanupPadInst *CleanupPad)
Definition:Instruction.cpp:764
llvm::sandboxir::CmpInst::dumpOS
void dumpOS(raw_ostream &OS) const override
Definition:Instruction.cpp:987
llvm::sandboxir::CmpInst::dump
LLVM_DUMP_METHOD void dump() const
Definition:Instruction.cpp:992
llvm::sandboxir::CmpInst::createWithCopiedFlags
static Value * createWithCopiedFlags(Predicate Pred, Value *S1, Value *S2, const Instruction *FlagsSource, InsertPosition Pos, Context &Ctx, const Twine &Name="")
Definition:Instruction.cpp:941
llvm::sandboxir::CmpInst::makeCmpResultType
static Type * makeCmpResultType(Type *OpndType)
Create a result type for fcmp/icmp.
Definition:Instruction.cpp:951
llvm::sandboxir::CmpInst::create
static Value * create(Predicate Pred, Value *S1, Value *S2, InsertPosition Pos, Context &Ctx, const Twine &Name="")
Definition:Instruction.cpp:929
llvm::sandboxir::CmpInst::setPredicate
void setPredicate(Predicate P)
Definition:Instruction.cpp:962
llvm::sandboxir::CmpInst::swapOperands
void swapOperands()
Definition:Instruction.cpp:969
llvm::sandboxir::CmpSwapOperands
Definition:Tracker.h:182
llvm::sandboxir::ConstantInt
Definition:Constant.h:69
llvm::sandboxir::ConstantTokenNone
Definition:Constant.h:1220
llvm::sandboxir::ConstantTokenNone::get
static ConstantTokenNone * get(Context &Ctx)
Return the ConstantTokenNone.
Definition:Instruction.cpp:1554
llvm::sandboxir::Constant
Definition:Constant.h:32
llvm::sandboxir::Context
Definition:Context.h:30
llvm::sandboxir::Context::createGetElementPtrInst
GetElementPtrInst * createGetElementPtrInst(llvm::GetElementPtrInst *I)
Definition:Context.cpp:546
llvm::sandboxir::Context::createCallBrInst
CallBrInst * createCallBrInst(llvm::CallBrInst *I)
Definition:Context.cpp:513
llvm::sandboxir::Context::getValue
sandboxir::Value * getValue(llvm::Value *V) const
Definition:Context.cpp:601
llvm::sandboxir::Context::createReturnInst
ReturnInst * createReturnInst(llvm::ReturnInst *I)
Definition:Context.cpp:498
llvm::sandboxir::Context::runEraseInstrCallbacks
void runEraseInstrCallbacks(Instruction *I)
Definition:Context.cpp:669
llvm::sandboxir::Context::createVAArgInst
VAArgInst * createVAArgInst(llvm::VAArgInst *SI)
Definition:Context.cpp:430
llvm::sandboxir::Context::createCleanupReturnInst
CleanupReturnInst * createCleanupReturnInst(llvm::CleanupReturnInst *I)
Definition:Context.cpp:540
llvm::sandboxir::Context::createAllocaInst
AllocaInst * createAllocaInst(llvm::AllocaInst *I)
Definition:Context.cpp:581
llvm::sandboxir::Context::getType
Type * getType(llvm::Type *LLVMTy)
Definition:Context.h:239
llvm::sandboxir::Context::createAtomicRMWInst
AtomicRMWInst * createAtomicRMWInst(llvm::AtomicRMWInst *I)
Definition:Context.cpp:571
llvm::sandboxir::Context::createInsertValueInst
InsertValueInst * createInsertValueInst(llvm::InsertValueInst *IVI)
Definition:Context.cpp:477
llvm::sandboxir::Context::createFCmpInst
FCmpInst * createFCmpInst(llvm::FCmpInst *I)
Definition:Context.cpp:597
llvm::sandboxir::Context::createExtractElementInst
ExtractElementInst * createExtractElementInst(llvm::ExtractElementInst *EEI)
Definition:Context.cpp:451
llvm::sandboxir::Context::getOrCreateConstant
Constant * getOrCreateConstant(llvm::Constant *LLVMC)
Get or create a sandboxir::Constant from an existing LLVM IR LLVMC.
Definition:Context.cpp:417
llvm::sandboxir::Context::createBranchInst
BranchInst * createBranchInst(llvm::BranchInst *I)
Definition:Context.cpp:483
llvm::sandboxir::Context::createShuffleVectorInst
ShuffleVectorInst * createShuffleVectorInst(llvm::ShuffleVectorInst *SVI)
Definition:Context.cpp:465
llvm::sandboxir::Context::createBinaryOperator
BinaryOperator * createBinaryOperator(llvm::BinaryOperator *I)
Definition:Context.cpp:567
llvm::sandboxir::Context::createLoadInst
LoadInst * createLoadInst(llvm::LoadInst *LI)
Definition:Context.cpp:488
llvm::sandboxir::Context::createFreezeInst
FreezeInst * createFreezeInst(llvm::FreezeInst *SI)
Definition:Context.cpp:435
llvm::sandboxir::Context::createPHINode
PHINode * createPHINode(llvm::PHINode *I)
Definition:Context.cpp:589
llvm::sandboxir::Context::createCatchPadInst
CatchPadInst * createCatchPadInst(llvm::CatchPadInst *I)
Definition:Context.cpp:527
llvm::sandboxir::Context::createICmpInst
ICmpInst * createICmpInst(llvm::ICmpInst *I)
Definition:Context.cpp:593
llvm::sandboxir::Context::detach
std::unique_ptr< Value > detach(Value *V)
Remove SBV from all SandboxIR maps and stop owning it.
Definition:Context.cpp:27
llvm::sandboxir::Context::createExtractValueInst
ExtractValueInst * createExtractValueInst(llvm::ExtractValueInst *IVI)
Definition:Context.cpp:471
llvm::sandboxir::Context::createCastInst
CastInst * createCastInst(llvm::CastInst *I)
Definition:Context.cpp:585
llvm::sandboxir::Context::createStoreInst
StoreInst * createStoreInst(llvm::StoreInst *SI)
Definition:Context.cpp:493
llvm::sandboxir::Context::createCatchReturnInst
CatchReturnInst * createCatchReturnInst(llvm::CatchReturnInst *I)
Definition:Context.cpp:535
llvm::sandboxir::Context::createCatchSwitchInst
CatchSwitchInst * createCatchSwitchInst(llvm::CatchSwitchInst *I)
Definition:Context.cpp:551
llvm::sandboxir::Context::createCleanupPadInst
CleanupPadInst * createCleanupPadInst(llvm::CleanupPadInst *I)
Definition:Context.cpp:531
llvm::sandboxir::Context::createFenceInst
FenceInst * createFenceInst(llvm::FenceInst *SI)
Definition:Context.cpp:440
llvm::sandboxir::Context::createCallInst
CallInst * createCallInst(llvm::CallInst *I)
Definition:Context.cpp:503
llvm::sandboxir::Context::createSwitchInst
SwitchInst * createSwitchInst(llvm::SwitchInst *I)
Definition:Context.cpp:559
llvm::sandboxir::Context::runMoveInstrCallbacks
void runMoveInstrCallbacks(Instruction *I, const BBIterator &Where)
Definition:Context.cpp:679
llvm::sandboxir::Context::createUnaryOperator
UnaryOperator * createUnaryOperator(llvm::UnaryOperator *I)
Definition:Context.cpp:563
llvm::sandboxir::Context::createInvokeInst
InvokeInst * createInvokeInst(llvm::InvokeInst *I)
Definition:Context.cpp:508
llvm::sandboxir::Context::createLandingPadInst
LandingPadInst * createLandingPadInst(llvm::LandingPadInst *I)
Definition:Context.cpp:523
llvm::sandboxir::Context::createInsertElementInst
InsertElementInst * createInsertElementInst(llvm::InsertElementInst *IEI)
Definition:Context.cpp:458
llvm::sandboxir::Context::createSelectInst
SelectInst * createSelectInst(llvm::SelectInst *SI)
Definition:Context.cpp:445
llvm::sandboxir::Context::createResumeInst
ResumeInst * createResumeInst(llvm::ResumeInst *I)
Definition:Context.cpp:555
llvm::sandboxir::Context::LLVMCtx
LLVMContext & LLVMCtx
Definition:Context.h:65
llvm::sandboxir::Context::getTracker
Tracker & getTracker()
Definition:Context.h:222
llvm::sandboxir::Context::createUnreachableInst
UnreachableInst * createUnreachableInst(llvm::UnreachableInst *UI)
Definition:Context.cpp:518
llvm::sandboxir::Context::createAtomicCmpXchgInst
AtomicCmpXchgInst * createAtomicCmpXchgInst(llvm::AtomicCmpXchgInst *I)
Definition:Context.cpp:576
llvm::sandboxir::ExtractElementInst::getVectorOperand
Value * getVectorOperand()
Definition:Instruction.h:515
llvm::sandboxir::ExtractElementInst::create
static Value * create(Value *Vec, Value *Idx, InsertPosition Pos, Context &Ctx, const Twine &Name="")
Definition:Instruction.cpp:1461
llvm::sandboxir::ExtractElementInst::getVectorOperandType
VectorType * getVectorOperandType() const
Definition:Instruction.cpp:1523
llvm::sandboxir::ExtractValueInst::create
static Value * create(Value *Agg, ArrayRef< unsigned > Idxs, InsertPosition Pos, Context &Ctx, const Twine &Name="")
Definition:Instruction.cpp:1527
llvm::sandboxir::ExtractValueInst::getIndexedType
static Type * getIndexedType(Type *Agg, ArrayRef< unsigned > Idxs)
Returns the type of the element that would be extracted with an extractvalue instruction with the spe...
Definition:Instruction.cpp:1538
llvm::sandboxir::FCmpInst::swapOperands
void swapOperands()
Definition:Instruction.cpp:981
llvm::sandboxir::FenceInst
Definition:Instruction.h:411
llvm::sandboxir::FenceInst::create
static FenceInst * create(AtomicOrdering Ordering, InsertPosition Pos, Context &Ctx, SyncScope::ID SSID=SyncScope::System)
Definition:Instruction.cpp:307
llvm::sandboxir::FenceInst::setOrdering
void setOrdering(AtomicOrdering Ordering)
Sets the ordering constraint of this fence instruction.
Definition:Instruction.cpp:314
llvm::sandboxir::FenceInst::getSyncScopeID
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this fence instruction.
Definition:Instruction.h:428
llvm::sandboxir::FenceInst::setSyncScopeID
void setSyncScopeID(SyncScope::ID SSID)
Sets the synchronization scope ID of this fence instruction.
Definition:Instruction.cpp:322
llvm::sandboxir::FreezeInst
Definition:Instruction.h:1180
llvm::sandboxir::FreezeInst::create
static FreezeInst * create(Value *V, InsertPosition Pos, Context &Ctx, const Twine &Name="")
Definition:Instruction.cpp:300
llvm::sandboxir::FuncletPadInst::getArgOperand
Value * getArgOperand(unsigned Idx) const
Return the Idx-th funcletpad argument.
Definition:Instruction.cpp:666
llvm::sandboxir::FuncletPadInst::getParentPad
Value * getParentPad() const
Return the outer EH-pad this funclet is nested within.
Definition:Instruction.cpp:655
llvm::sandboxir::FuncletPadInst::setParentPad
void setParentPad(Value *ParentPad)
Definition:Instruction.cpp:659
llvm::sandboxir::FuncletPadInst::setArgOperand
void setArgOperand(unsigned Idx, Value *V)
Set the Idx-th funcletpad argument.
Definition:Instruction.cpp:670
llvm::sandboxir::FunctionType
Definition:Type.h:450
llvm::sandboxir::Function
Definition:Function.h:18
llvm::sandboxir::GenericSetterWithIdx
Similar to GenericSetter but the setters/getters have an index as their first argument.
Definition:Tracker.h:303
llvm::sandboxir::GenericSetter
This class can be used for tracking most instruction setters.
Definition:Tracker.h:275
llvm::sandboxir::GetElementPtrInst::getResultElementType
Type * getResultElementType() const
Definition:Instruction.cpp:808
llvm::sandboxir::GetElementPtrInst::getPointerOperandType
Type * getPointerOperandType() const
Definition:Instruction.cpp:817
llvm::sandboxir::GetElementPtrInst::getSourceElementType
Type * getSourceElementType() const
Definition:Instruction.cpp:803
llvm::sandboxir::GetElementPtrInst::getPointerOperand
Value * getPointerOperand() const
Definition:Instruction.cpp:813
llvm::sandboxir::GetElementPtrInst::create
static Value * create(Type *Ty, Value *Ptr, ArrayRef< Value * > IdxList, InsertPosition Pos, Context &Ctx, const Twine &NameStr="")
Definition:Instruction.cpp:787
llvm::sandboxir::ICmpInst
Definition:Instruction.h:2528
llvm::sandboxir::ICmpInst::swapOperands
void swapOperands()
Definition:Instruction.cpp:976
llvm::sandboxir::InsertElementInst::create
static Value * create(Value *Vec, Value *NewElt, Value *Idx, InsertPosition Pos, Context &Ctx, const Twine &Name="")
Definition:Instruction.cpp:1449
llvm::sandboxir::InsertIntoBB
Definition:Tracker.h:398
llvm::sandboxir::InsertPosition
Definition:Instruction.h:25
llvm::sandboxir::InsertValueInst::create
static Value * create(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, InsertPosition Pos, Context &Ctx, const Twine &Name="")
Definition:Instruction.cpp:1543
llvm::sandboxir::Instruction
A sandboxir::User with operands, opcode and linked with previous/next instructions in an instruction ...
Definition:Instruction.h:42
llvm::sandboxir::Instruction::hasNoUnsignedWrap
bool hasNoUnsignedWrap() const
Determine whether the no signed wrap flag is set.
Definition:Instruction.h:225
llvm::sandboxir::Instruction::setInsertPos
static IRBuilder & setInsertPos(InsertPosition Pos)
Helper function for create().
Definition:Instruction.h:103
llvm::sandboxir::Instruction::setFastMathFlags
void setFastMathFlags(FastMathFlags FMF)
Convenience function for setting multiple fast-math flags on this instruction, which must be an opera...
Definition:Instruction.cpp:257
llvm::sandboxir::Instruction::hasAllowReassoc
bool hasAllowReassoc() const
Determine whether the allow-reassociation flag is set.
Definition:Instruction.h:245
llvm::sandboxir::Instruction::setHasAllowReassoc
void setHasAllowReassoc(bool B)
Set or clear the reassociation flag on this instruction, which must be an operator which supports thi...
Definition:Instruction.cpp:210
llvm::sandboxir::Instruction::hasNoSignedZeros
bool hasNoSignedZeros() const
Determine whether the no-signed-zeros flag is set.
Definition:Instruction.h:270
llvm::sandboxir::Instruction::getOpcodeName
const char * getOpcodeName() const
Definition:Instruction.h:131
llvm::sandboxir::Instruction::setHasNoSignedWrap
void setHasNoSignedWrap(bool B=true)
Set or clear the nsw flag on this instruction, which must be an operator which supports this flag.
Definition:Instruction.cpp:189
llvm::sandboxir::Instruction::insertAfter
void insertAfter(Instruction *AfterI)
Insert this detached instruction after AfterI.
Definition:Instruction.cpp:135
llvm::sandboxir::Instruction::moveBefore
void moveBefore(BasicBlock &BB, const BBIterator &WhereIt)
Move this instruction to WhereIt.
Definition:Instruction.cpp:100
llvm::sandboxir::Instruction::hasAllowContract
bool hasAllowContract() const
Determine whether the allow-contract flag is set.
Definition:Instruction.h:286
llvm::sandboxir::Instruction::setIsExact
void setIsExact(bool B=true)
Set or clear the exact flag on this instruction, which must be an operator which supports this flag.
Definition:Instruction.cpp:203
llvm::sandboxir::Instruction::hasApproxFunc
bool hasApproxFunc() const
Determine whether the approximate-math-functions flag is set.
Definition:Instruction.h:294
llvm::sandboxir::Instruction::hasNoSignedWrap
bool hasNoSignedWrap() const
Determine whether the no signed wrap flag is set.
Definition:Instruction.h:232
llvm::sandboxir::Instruction::Opcode
Opcode
Definition:Instruction.h:44
llvm::sandboxir::Instruction::setHasNoUnsignedWrap
void setHasNoUnsignedWrap(bool B=true)
Set or clear the nuw flag on this instruction, which must be an operator which supports this flag.
Definition:Instruction.cpp:181
llvm::sandboxir::Instruction::dumpOS
void dumpOS(raw_ostream &OS) const override
Definition:Instruction.cpp:283
llvm::sandboxir::Instruction::getIterator
BBIterator getIterator() const
\Returns a BasicBlock::iterator for this Instruction.
Definition:Instruction.cpp:38
llvm::sandboxir::Instruction::setFast
void setFast(bool B)
Set or clear all fast-math-flags on this instruction, which must be an operator which supports this f...
Definition:Instruction.cpp:196
llvm::sandboxir::Instruction::setHasApproxFunc
void setHasApproxFunc(bool B)
Set or clear the approximate-math-functions flag on this instruction, which must be an operator which...
Definition:Instruction.cpp:275
llvm::sandboxir::Instruction::setHasNoNaNs
void setHasNoNaNs(bool B)
Set or clear the no-nans flag on this instruction, which must be an operator which supports this flag...
Definition:Instruction.cpp:217
llvm::sandboxir::Instruction::copyFastMathFlags
void copyFastMathFlags(FastMathFlags FMF)
Convenience function for transferring all fast-math flag values to this instruction,...
Definition:Instruction.cpp:264
llvm::sandboxir::Instruction::setHasNoSignedZeros
void setHasNoSignedZeros(bool B)
Set or clear the no-signed-zeros flag on this instruction, which must be an operator which supports t...
Definition:Instruction.cpp:233
llvm::sandboxir::Instruction::insertInto
void insertInto(BasicBlock *BB, const BBIterator &WhereIt)
Insert this detached instruction into BB at WhereIt.
Definition:Instruction.cpp:139
llvm::sandboxir::Instruction::getTopmostLLVMInstruction
llvm::Instruction * getTopmostLLVMInstruction() const
A SandboxIR Instruction may map to multiple LLVM IR Instruction.
Definition:Instruction.cpp:26
llvm::sandboxir::Instruction::setHasAllowContract
void setHasAllowContract(bool B)
Set or clear the allow-contract flag on this instruction, which must be an operator which supports th...
Definition:Instruction.cpp:249
llvm::sandboxir::Instruction::getLLVMInstrs
virtual SmallVector< llvm::Instruction *, 1 > getLLVMInstrs() const =0
\Returns the LLVM IR Instructions that this SandboxIR maps to in program order.
llvm::sandboxir::Instruction::Opc
Opcode Opc
Definition:Instruction.h:56
llvm::sandboxir::Instruction::getAccessType
Type * getAccessType() const
Definition:Instruction.cpp:271
llvm::sandboxir::Instruction::getFastMathFlags
FastMathFlags getFastMathFlags() const
Convenience function for getting all the fast-math flags, which must be an operator which supports th...
Definition:Instruction.h:304
llvm::sandboxir::Instruction::getNextNode
Instruction * getNextNode() const
\Returns the next sandboxir::Instruction in the block, or nullptr if at the end of the block.
Definition:Instruction.cpp:43
llvm::sandboxir::Instruction::removeFromParent
void removeFromParent()
Detach this from its parent BasicBlock without deleting it.
Definition:Instruction.cpp:66
llvm::sandboxir::Instruction::getPrevNode
Instruction * getPrevNode() const
\Returns the previous sandboxir::Instruction in the block, or nullptr if at the beginning of the bloc...
Definition:Instruction.cpp:58
llvm::sandboxir::Instruction::hasAllowReciprocal
bool hasAllowReciprocal() const
Determine whether the allow-reciprocal flag is set.
Definition:Instruction.h:278
llvm::sandboxir::Instruction::insertBefore
void insertBefore(Instruction *BeforeI)
Insert this detached instruction before BeforeI.
Definition:Instruction.cpp:125
llvm::sandboxir::Instruction::eraseFromParent
void eraseFromParent()
Detach this Value from its parent and delete it.
Definition:Instruction.cpp:74
llvm::sandboxir::Instruction::setHasAllowReciprocal
void setHasAllowReciprocal(bool B)
Set or clear the allow-reciprocal flag on this instruction, which must be an operator which supports ...
Definition:Instruction.cpp:241
llvm::sandboxir::Instruction::setHasNoInfs
void setHasNoInfs(bool B)
Set or clear the no-infs flag on this instruction, which must be an operator which supports this flag...
Definition:Instruction.cpp:225
llvm::sandboxir::Instruction::getParent
BasicBlock * getParent() const
\Returns the BasicBlock containing this Instruction, or null if it is detached.
Definition:Instruction.cpp:161
llvm::sandboxir::Instruction::classof
static bool classof(const sandboxir::Value *From)
For isa/dyn_cast.
Definition:Instruction.cpp:170
llvm::sandboxir::InvokeInst
Definition:Instruction.h:1440
llvm::sandboxir::InvokeInst::getUnwindDest
BasicBlock * getUnwindDest() const
Definition:Instruction.cpp:548
llvm::sandboxir::InvokeInst::create
static InvokeInst * create(FunctionType *FTy, Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, InsertPosition Pos, Context &Ctx, const Twine &NameStr="")
Definition:Instruction.cpp:528
llvm::sandboxir::InvokeInst::setNormalDest
void setNormalDest(BasicBlock *BB)
Definition:Instruction.cpp:552
llvm::sandboxir::InvokeInst::setUnwindDest
void setUnwindDest(BasicBlock *BB)
Definition:Instruction.cpp:556
llvm::sandboxir::InvokeInst::getSuccessor
BasicBlock * getSuccessor(unsigned SuccIdx) const
Definition:Instruction.cpp:565
llvm::sandboxir::InvokeInst::getNormalDest
BasicBlock * getNormalDest() const
Definition:Instruction.cpp:544
llvm::sandboxir::InvokeInst::getLandingPadInst
LandingPadInst * getLandingPadInst() const
Definition:Instruction.cpp:560
llvm::sandboxir::LandingPadInst
Definition:Instruction.h:1508
llvm::sandboxir::LandingPadInst::isCleanup
bool isCleanup() const
Return 'true' if this landingpad instruction is a cleanup.
Definition:Instruction.h:1521
llvm::sandboxir::LandingPadInst::setCleanup
void setCleanup(bool V)
Indicate that this landingpad instruction is a cleanup.
Definition:Instruction.cpp:643
llvm::sandboxir::LandingPadInst::getClause
Constant * getClause(unsigned Idx) const
Get the value of the clause at index Idx.
Definition:Instruction.cpp:650
llvm::sandboxir::LandingPadInst::create
static LandingPadInst * create(Type *RetTy, unsigned NumReservedClauses, InsertPosition Pos, Context &Ctx, const Twine &Name="")
Definition:Instruction.cpp:634
llvm::sandboxir::LoadInst
Definition:Instruction.h:1193
llvm::sandboxir::LoadInst::create
static LoadInst * create(Type *Ty, Value *Ptr, MaybeAlign Align, InsertPosition Pos, bool IsVolatile, Context &Ctx, const Twine &Name="")
Definition:Instruction.cpp:403
llvm::sandboxir::LoadInst::setVolatile
void setVolatile(bool V)
Specify whether this is a volatile load or not.
Definition:Instruction.cpp:396
llvm::sandboxir::LoadInst::getPointerOperand
Value * getPointerOperand() const
Definition:Instruction.cpp:417
llvm::sandboxir::LoadInst::classof
static bool classof(const Value *From)
For isa/dyn_cast.
Definition:Instruction.cpp:413
llvm::sandboxir::PHIAddIncoming
Definition:Tracker.h:168
llvm::sandboxir::PHINode
Definition:Instruction.h:2377
llvm::sandboxir::PHINode::hasConstantValue
Value * hasConstantValue() const
Definition:Instruction.cpp:903
llvm::sandboxir::PHINode::getBasicBlockIndex
int getBasicBlockIndex(const BasicBlock *BB) const
Definition:Instruction.cpp:893
llvm::sandboxir::PHINode::getNumIncomingValues
unsigned getNumIncomingValues() const
Definition:Instruction.h:2417
llvm::sandboxir::PHINode::getIncomingValue
Value * getIncomingValue(unsigned Idx) const
Definition:Instruction.cpp:838
llvm::sandboxir::PHINode::setIncomingBlock
void setIncomingBlock(unsigned Idx, BasicBlock *BB)
Definition:Instruction.cpp:857
llvm::sandboxir::PHINode::removeIncomingValueIf
void removeIncomingValueIf(function_ref< bool(unsigned)> Predicate)
Definition:Instruction.cpp:914
llvm::sandboxir::PHINode::classof
static bool classof(const Value *From)
For isa/dyn_cast.
Definition:Instruction.cpp:834
llvm::sandboxir::PHINode::create
static PHINode * create(Type *Ty, unsigned NumReservedValues, InsertPosition Pos, Context &Ctx, const Twine &Name="")
Definition:Instruction.cpp:826
llvm::sandboxir::PHINode::removeIncomingValue
Value * removeIncomingValue(unsigned Idx)
Definition:Instruction.cpp:875
llvm::sandboxir::PHINode::setIncomingValue
void setIncomingValue(unsigned Idx, Value *V)
Definition:Instruction.cpp:841
llvm::sandboxir::PHINode::getIncomingBlock
BasicBlock * getIncomingBlock(unsigned Idx) const
Definition:Instruction.cpp:848
llvm::sandboxir::PHINode::replaceIncomingBlockWith
void replaceIncomingBlockWith(const BasicBlock *Old, BasicBlock *New)
Definition:Instruction.cpp:907
llvm::sandboxir::PHINode::getIncomingValueForBlock
Value * getIncomingValueForBlock(const BasicBlock *BB) const
Definition:Instruction.cpp:897
llvm::sandboxir::PHINode::addIncoming
void addIncoming(Value *V, BasicBlock *BB)
Definition:Instruction.cpp:868
llvm::sandboxir::PHIRemoveIncoming
Definition:Tracker.h:152
llvm::sandboxir::PointerType
Definition:Type.h:291
llvm::sandboxir::PossiblyDisjointInst::setIsDisjoint
void setIsDisjoint(bool B)
Definition:Instruction.cpp:1250
llvm::sandboxir::PossiblyDisjointInst::isDisjoint
bool isDisjoint() const
Definition:Instruction.h:2037
llvm::sandboxir::PossiblyNonNegInst::hasNonNeg
bool hasNonNeg() const
Definition:Instruction.h:2308
llvm::sandboxir::PossiblyNonNegInst::setNonNeg
void setNonNeg(bool B)
Definition:Instruction.cpp:1442
llvm::sandboxir::RemoveFromParent
Definition:Tracker.h:245
llvm::sandboxir::ResumeInst
Definition:Instruction.h:1836
llvm::sandboxir::ResumeInst::create
static ResumeInst * create(Value *Exn, InsertPosition Pos, Context &Ctx)
Definition:Instruction.cpp:1082
llvm::sandboxir::ResumeInst::getValue
Value * getValue() const
Definition:Instruction.cpp:1088
llvm::sandboxir::ReturnInst
Definition:Instruction.h:1272
llvm::sandboxir::ReturnInst::create
static ReturnInst * create(Value *RetVal, InsertPosition Pos, Context &Ctx)
Definition:Instruction.cpp:469
llvm::sandboxir::ReturnInst::getReturnValue
Value * getReturnValue() const
\Returns null if there is no return value.
Definition:Instruction.cpp:475
llvm::sandboxir::SelectInst::classof
static bool classof(const Value *From)
For isa/dyn_cast.
Definition:Instruction.cpp:346
llvm::sandboxir::SelectInst::swapValues
void swapValues()
Definition:Instruction.cpp:340
llvm::sandboxir::SelectInst::create
static Value * create(Value *Cond, Value *True, Value *False, InsertPosition Pos, Context &Ctx, const Twine &Name="")
Definition:Instruction.cpp:329
llvm::sandboxir::ShuffleVectorInst::getType
VectorType * getType() const
Overload to return most specific vector type.
Definition:Instruction.cpp:1499
llvm::sandboxir::ShuffleVectorInst::getShuffleMaskForBitcode
Constant * getShuffleMaskForBitcode() const
Return the mask for this instruction, for use in bitcode.
Definition:Instruction.cpp:1511
llvm::sandboxir::ShuffleVectorInst::commute
void commute()
Swap the operands and adjust the mask to preserve the semantics of the instruction.
Definition:Instruction.cpp:1504
llvm::sandboxir::ShuffleVectorInst::create
static Value * create(Value *V1, Value *V2, Value *Mask, InsertPosition Pos, Context &Ctx, const Twine &Name="")
Definition:Instruction.cpp:1471
llvm::sandboxir::ShuffleVectorInst::convertShuffleMaskForBitcode
static Constant * convertShuffleMaskForBitcode(ArrayRef< int > Mask, Type *ResultTy)
Definition:Instruction.cpp:1516
llvm::sandboxir::ShuffleVectorInst::setShuffleMask
void setShuffleMask(ArrayRef< int > Mask)
Definition:Instruction.cpp:1494
llvm::sandboxir::ShuffleVectorSetMask
Definition:Tracker.h:424
llvm::sandboxir::StoreInst
Definition:Instruction.h:1222
llvm::sandboxir::StoreInst::setVolatile
void setVolatile(bool V)
Specify whether this is a volatile store or not.
Definition:Instruction.cpp:421
llvm::sandboxir::StoreInst::classof
static bool classof(const Value *From)
For isa/dyn_cast.
Definition:Instruction.cpp:437
llvm::sandboxir::StoreInst::create
static StoreInst * create(Value *V, Value *Ptr, MaybeAlign Align, InsertPosition Pos, bool IsVolatile, Context &Ctx)
Definition:Instruction.cpp:428
llvm::sandboxir::StoreInst::getPointerOperand
Value * getPointerOperand() const
Definition:Instruction.cpp:445
llvm::sandboxir::StoreInst::getValueOperand
Value * getValueOperand() const
Definition:Instruction.cpp:441
llvm::sandboxir::SwitchAddCase
Definition:Tracker.h:347
llvm::sandboxir::SwitchInst
Definition:Instruction.h:1852
llvm::sandboxir::SwitchInst::create
static SwitchInst * create(Value *V, BasicBlock *Dest, unsigned NumCases, InsertPosition Pos, Context &Ctx, const Twine &Name="")
Definition:Instruction.cpp:1092
llvm::sandboxir::SwitchInst::addCase
void addCase(ConstantInt *OnVal, BasicBlock *Dest)
Definition:Instruction.cpp:1131
llvm::sandboxir::SwitchInst::getSuccessor
BasicBlock * getSuccessor(unsigned Idx) const
Definition:Instruction.cpp:1149
llvm::sandboxir::SwitchInst::case_begin
CaseIt case_begin()
Returns a read/write iterator that points to the first case in the SwitchInst.
Definition:Instruction.h:1886
llvm::sandboxir::SwitchInst::setDefaultDest
void setDefaultDest(BasicBlock *DefaultCase)
Definition:Instruction.cpp:1118
llvm::sandboxir::SwitchInst::CaseIt
llvm::SwitchInst::CaseIteratorImpl< CaseHandle > CaseIt
Definition:Instruction.h:1881
llvm::sandboxir::SwitchInst::getDefaultDest
BasicBlock * getDefaultDest() const
Definition:Instruction.cpp:1113
llvm::sandboxir::SwitchInst::getCondition
Value * getCondition() const
Definition:Instruction.cpp:1101
llvm::sandboxir::SwitchInst::setSuccessor
void setSuccessor(unsigned Idx, BasicBlock *NewSucc)
Definition:Instruction.cpp:1154
llvm::sandboxir::SwitchInst::setCondition
void setCondition(Value *V)
Definition:Instruction.cpp:1105
llvm::sandboxir::SwitchInst::findCaseDest
ConstantInt * findCaseDest(BasicBlock *BB)
Definition:Instruction.cpp:1125
llvm::sandboxir::SwitchInst::removeCase
CaseIt removeCase(CaseIt It)
This method removes the specified case and its successor from the switch instruction.
Definition:Instruction.cpp:1138
llvm::sandboxir::SwitchRemoveCase
Definition:Tracker.h:362
llvm::sandboxir::Tracker
The tracker collects all the change objects and implements the main API for saving / reverting / acce...
Definition:Tracker.h:440
llvm::sandboxir::Tracker::track
void track(std::unique_ptr< IRChangeBase > &&Change)
Record Change and take ownership.
Definition:Tracker.h:478
llvm::sandboxir::Tracker::emplaceIfTracking
bool emplaceIfTracking(ArgsT... Args)
A convenience wrapper for track() that constructs and tracks the Change object if tracking is enabled...
Definition:Tracker.h:495
llvm::sandboxir::Type
Just like llvm::Type these are immutable, unique, never get freed and can only be created via static ...
Definition:Type.h:43
llvm::sandboxir::Type::LLVMTy
llvm::Type * LLVMTy
Definition:Type.h:45
llvm::sandboxir::Type::getInt1Ty
static Type * getInt1Ty(Context &Ctx)
llvm::sandboxir::Type::getContext
Context & getContext() const
Definition:Type.h:89
llvm::sandboxir::UnaryOperator::createWithCopiedFlags
static Value * createWithCopiedFlags(Instruction::Opcode Op, Value *OpV, Value *CopyFrom, InsertPosition Pos, Context &Ctx, const Twine &Name="")
Definition:Instruction.cpp:1175
llvm::sandboxir::UnaryOperator::create
static Value * create(Instruction::Opcode Op, Value *OpV, InsertPosition Pos, Context &Ctx, const Twine &Name="")
Definition:Instruction.cpp:1163
llvm::sandboxir::UnreachableInst
Definition:Instruction.h:1250
llvm::sandboxir::UnreachableInst::create
static UnreachableInst * create(InsertPosition Pos, Context &Ctx)
Definition:Instruction.cpp:449
llvm::sandboxir::UnreachableInst::classof
static bool classof(const Value *From)
Definition:Instruction.cpp:455
llvm::sandboxir::UseSwap
Tracks swapping a Use with another Use.
Definition:Tracker.h:196
llvm::sandboxir::Use
Represents a Def-use/Use-def edge in SandboxIR.
Definition:Use.h:32
llvm::sandboxir::User::setOperand
virtual void setOperand(unsigned OperandIdx, Value *Operand)
Definition:User.cpp:91
llvm::sandboxir::User::getNumOperands
virtual unsigned getNumOperands() const
Definition:User.h:128
llvm::sandboxir::User::getOperandUse
Use getOperandUse(unsigned OpIdx) const
\Returns the operand edge for OpIdx.
Definition:User.h:125
llvm::sandboxir::VAArgInst
Definition:Instruction.h:1160
llvm::sandboxir::VAArgInst::getPointerOperand
Value * getPointerOperand()
Definition:Instruction.cpp:296
llvm::sandboxir::VAArgInst::create
static VAArgInst * create(Value *List, Type *Ty, InsertPosition Pos, Context &Ctx, const Twine &Name="")
Definition:Instruction.cpp:288
llvm::sandboxir::Value
A SandboxIR Value has users. This is the base class.
Definition:Value.h:63
llvm::sandboxir::Value::Val
llvm::Value * Val
The LLVM Value that corresponds to this SandboxIR Value.
Definition:Value.h:103
llvm::sandboxir::Value::dumpCommonSuffix
void dumpCommonSuffix(raw_ostream &OS) const
Definition:Value.cpp:105
llvm::sandboxir::Value::Ctx
Context & Ctx
All values point to the context.
Definition:Value.h:173
llvm::sandboxir::Value::getType
Type * getType() const
Definition:Value.cpp:46
llvm::sandboxir::Value::users
iterator_range< user_iterator > users()
Definition:Value.h:225
llvm::sandboxir::Value::dumpCommonPrefix
void dumpCommonPrefix(raw_ostream &OS) const
Definition:Value.cpp:98
llvm::sandboxir::VectorType
Definition:Type.h:325
uint8_t
LLVMAtomicRMW
@ LLVMAtomicRMW
Definition:Core.h:136
LLVMAtomicCmpXchg
@ LLVMAtomicCmpXchg
Definition:Core.h:135
LLVMSwitch
@ LLVMSwitch
Definition:Core.h:64
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition:ErrorHandling.h:143
llvm::CallingConv::C
@ C
The default llvm calling convention, compatible with C.
Definition:CallingConv.h:34
llvm::sandboxir
Definition:Argument.h:15
llvm::sandboxir::getLLVMCastOp
static llvm::Instruction::CastOps getLLVMCastOp(Instruction::Opcode Opc)
Definition:Instruction.cpp:998
llvm::sandboxir::getLLVMUnaryOp
static llvm::Instruction::UnaryOps getLLVMUnaryOp(Instruction::Opcode Opc)
\Returns the LLVM opcode that corresponds to Opc.
Definition:Instruction.cpp:1033
llvm::sandboxir::getLLVMBinaryOp
static llvm::Instruction::BinaryOps getLLVMBinaryOp(Instruction::Opcode Opc)
\Returns the LLVM opcode that corresponds to Opc.
Definition:Instruction.cpp:1185
llvm::reverse
auto reverse(ContainerTy &&C)
Definition:STLExtras.h:420
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition:Debug.cpp:163
llvm::is_sorted
bool is_sorted(R &&Range, Compare C)
Wrapper function around std::is_sorted to check if elements in a range R are sorted with respect to a...
Definition:STLExtras.h:1926
llvm::AtomicOrdering
AtomicOrdering
Atomic ordering for LLVM's memory model.
Definition:AtomicOrdering.h:56
llvm::BasicBlockSection::List
@ List
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition:Alignment.h:39
llvm::MaybeAlign
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Definition:Alignment.h:117

Generated on Thu Jul 17 2025 12:29:40 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp