@@ -126,6 +126,9 @@ class CallBase;
126
126
class CallInst ;
127
127
class InvokeInst ;
128
128
class CallBrInst ;
129
+ class FuncletPadInst ;
130
+ class CatchPadInst ;
131
+ class CleanupPadInst ;
129
132
class GetElementPtrInst ;
130
133
class CastInst ;
131
134
class PtrToIntInst ;
@@ -240,31 +243,34 @@ class Value {
240
243
// / order.
241
244
llvm::Value *Val = nullptr ;
242
245
243
- friend class Context ; // For getting `Val`.
244
- friend class User ; // For getting `Val`.
245
- friend class Use ; // For getting `Val`.
246
- friend class SelectInst ; // For getting `Val`.
247
- friend class ExtractElementInst ; // For getting `Val`.
248
- friend class InsertElementInst ; // For getting `Val`.
249
- friend class BranchInst ; // For getting `Val`.
250
- friend class LoadInst ; // For getting `Val`.
251
- friend class StoreInst ; // For getting `Val`.
252
- friend class ReturnInst ; // For getting `Val`.
253
- friend class CallBase ; // For getting `Val`.
254
- friend class CallInst ; // For getting `Val`.
255
- friend class InvokeInst ; // For getting `Val`.
256
- friend class CallBrInst ; // For getting `Val`.
257
- friend class GetElementPtrInst ; // For getting `Val`.
258
- friend class CatchSwitchInst ; // For getting `Val`.
259
- friend class SwitchInst ; // For getting `Val`.
260
- friend class UnaryOperator ; // For getting `Val`.
261
- friend class BinaryOperator ; // For getting `Val`.
262
- friend class AtomicRMWInst ; // For getting `Val`.
263
- friend class AtomicCmpXchgInst ; // For getting `Val`.
264
- friend class AllocaInst ; // For getting `Val`.
265
- friend class CastInst ; // For getting `Val`.
266
- friend class PHINode ; // For getting `Val`.
267
- friend class UnreachableInst ; // For getting `Val`.
246
+ friend class Context ; // For getting `Val`.
247
+ friend class User ; // For getting `Val`.
248
+ friend class Use ; // For getting `Val`.
249
+ friend class SelectInst ; // For getting `Val`.
250
+ friend class ExtractElementInst ; // For getting `Val`.
251
+ friend class InsertElementInst ; // For getting `Val`.
252
+ friend class BranchInst ; // For getting `Val`.
253
+ friend class LoadInst ; // For getting `Val`.
254
+ friend class StoreInst ; // For getting `Val`.
255
+ friend class ReturnInst ; // For getting `Val`.
256
+ friend class CallBase ; // For getting `Val`.
257
+ friend class CallInst ; // For getting `Val`.
258
+ friend class InvokeInst ; // For getting `Val`.
259
+ friend class CallBrInst ; // For getting `Val`.
260
+ friend class FuncletPadInst ; // For getting `Val`.
261
+ friend class CatchPadInst ; // For getting `Val`.
262
+ friend class CleanupPadInst ; // For getting `Val`.
263
+ friend class GetElementPtrInst ; // For getting `Val`.
264
+ friend class CatchSwitchInst ; // For getting `Val`.
265
+ friend class SwitchInst ; // For getting `Val`.
266
+ friend class UnaryOperator ; // For getting `Val`.
267
+ friend class BinaryOperator ; // For getting `Val`.
268
+ friend class AtomicRMWInst ; // For getting `Val`.
269
+ friend class AtomicCmpXchgInst ; // For getting `Val`.
270
+ friend class AllocaInst ; // For getting `Val`.
271
+ friend class CastInst ; // For getting `Val`.
272
+ friend class PHINode ; // For getting `Val`.
273
+ friend class UnreachableInst ; // For getting `Val`.
268
274
friend class CatchSwitchAddHandler ; // For `Val`.
269
275
270
276
// / All values point to the context.
@@ -676,6 +682,8 @@ class Instruction : public sandboxir::User {
676
682
friend class CallInst ; // For getTopmostLLVMInstruction().
677
683
friend class InvokeInst ; // For getTopmostLLVMInstruction().
678
684
friend class CallBrInst ; // For getTopmostLLVMInstruction().
685
+ friend class CatchPadInst ; // For getTopmostLLVMInstruction().
686
+ friend class CleanupPadInst ; // For getTopmostLLVMInstruction().
679
687
friend class GetElementPtrInst ; // For getTopmostLLVMInstruction().
680
688
friend class CatchSwitchInst ; // For getTopmostLLVMInstruction().
681
689
friend class SwitchInst ; // For getTopmostLLVMInstruction().
@@ -842,6 +850,7 @@ template <typename LLVMT> class SingleLLVMInstructionImpl : public Instruction {
842
850
#include " llvm/SandboxIR/SandboxIRValues.def"
843
851
friend class UnaryInstruction ;
844
852
friend class CallBase ;
853
+ friend class FuncletPadInst ;
845
854
846
855
Use getOperandUseInternal (unsigned OpIdx, bool Verify) const final {
847
856
return getOperandUseDefault (OpIdx, Verify);
@@ -1394,6 +1403,68 @@ class CallBrInst final : public CallBase {
1394
1403
}
1395
1404
};
1396
1405
1406
+ class FuncletPadInst : public SingleLLVMInstructionImpl <llvm::FuncletPadInst> {
1407
+ FuncletPadInst (ClassID SubclassID, Opcode Opc, llvm::Instruction *I,
1408
+ Context &Ctx)
1409
+ : SingleLLVMInstructionImpl(SubclassID, Opc, I, Ctx) {}
1410
+ friend class CatchPadInst ; // For constructor.
1411
+ friend class CleanupPadInst ; // For constructor.
1412
+
1413
+ public:
1414
+ // / Return the number of funcletpad arguments.
1415
+ unsigned arg_size () const {
1416
+ return cast<llvm::FuncletPadInst>(Val)->arg_size ();
1417
+ }
1418
+ // / Return the outer EH-pad this funclet is nested within.
1419
+ // /
1420
+ // / Note: This returns the associated CatchSwitchInst if this FuncletPadInst
1421
+ // / is a CatchPadInst.
1422
+ Value *getParentPad () const ;
1423
+ void setParentPad (Value *ParentPad);
1424
+ // / Return the Idx-th funcletpad argument.
1425
+ Value *getArgOperand (unsigned Idx) const ;
1426
+ // / Set the Idx-th funcletpad argument.
1427
+ void setArgOperand (unsigned Idx, Value *V);
1428
+
1429
+ // TODO: Implement missing functions: arg_operands().
1430
+ static bool classof (const Value *From) {
1431
+ return From->getSubclassID () == ClassID::CatchPad ||
1432
+ From->getSubclassID () == ClassID::CleanupPad;
1433
+ }
1434
+ };
1435
+
1436
+ class CatchPadInst : public FuncletPadInst {
1437
+ CatchPadInst (llvm::CatchPadInst *CPI, Context &Ctx)
1438
+ : FuncletPadInst(ClassID::CatchPad, Opcode::CatchPad, CPI, Ctx) {}
1439
+ friend class Context ; // For constructor.
1440
+
1441
+ public:
1442
+ CatchSwitchInst *getCatchSwitch () const ;
1443
+ // TODO: We have not implemented setCatchSwitch() because we can't revert it
1444
+ // for now, as there is no CatchPadInst member function that can undo it.
1445
+
1446
+ static CatchPadInst *create (Value *ParentPad, ArrayRef<Value *> Args,
1447
+ BBIterator WhereIt, BasicBlock *WhereBB,
1448
+ Context &Ctx, const Twine &Name = " " );
1449
+ static bool classof (const Value *From) {
1450
+ return From->getSubclassID () == ClassID::CatchPad;
1451
+ }
1452
+ };
1453
+
1454
+ class CleanupPadInst : public FuncletPadInst {
1455
+ CleanupPadInst (llvm::CleanupPadInst *CPI, Context &Ctx)
1456
+ : FuncletPadInst(ClassID::CleanupPad, Opcode::CleanupPad, CPI, Ctx) {}
1457
+ friend class Context ; // For constructor.
1458
+
1459
+ public:
1460
+ static CleanupPadInst *create (Value *ParentPad, ArrayRef<Value *> Args,
1461
+ BBIterator WhereIt, BasicBlock *WhereBB,
1462
+ Context &Ctx, const Twine &Name = " " );
1463
+ static bool classof (const Value *From) {
1464
+ return From->getSubclassID () == ClassID::CleanupPad;
1465
+ }
1466
+ };
1467
+
1397
1468
class GetElementPtrInst final
1398
1469
: public SingleLLVMInstructionImpl<llvm::GetElementPtrInst> {
1399
1470
// / Use Context::createGetElementPtrInst(). Don't call
@@ -2294,6 +2365,10 @@ class Context {
2294
2365
friend InvokeInst; // For createInvokeInst()
2295
2366
CallBrInst *createCallBrInst (llvm::CallBrInst *I);
2296
2367
friend CallBrInst; // For createCallBrInst()
2368
+ CatchPadInst *createCatchPadInst (llvm::CatchPadInst *I);
2369
+ friend CatchPadInst; // For createCatchPadInst()
2370
+ CleanupPadInst *createCleanupPadInst (llvm::CleanupPadInst *I);
2371
+ friend CleanupPadInst; // For createCleanupPadInst()
2297
2372
GetElementPtrInst *createGetElementPtrInst (llvm::GetElementPtrInst *I);
2298
2373
friend GetElementPtrInst; // For createGetElementPtrInst()
2299
2374
CatchSwitchInst *createCatchSwitchInst (llvm::CatchSwitchInst *I);
0 commit comments