@@ -127,6 +127,9 @@ class CallBase;
127127class CallInst ;
128128class InvokeInst ;
129129class CallBrInst ;
130+ class FuncletPadInst ;
131+ class CatchPadInst ;
132+ class CleanupPadInst ;
130133class GetElementPtrInst ;
131134class CastInst ;
132135class PtrToIntInst ;
@@ -256,6 +259,9 @@ class Value {
256259 friend class CallInst ; // For getting `Val`.
257260 friend class InvokeInst ; // For getting `Val`.
258261 friend class CallBrInst ; // For getting `Val`.
262+ friend class FuncletPadInst ; // For getting `Val`.
263+ friend class CatchPadInst ; // For getting `Val`.
264+ friend class CleanupPadInst ; // For getting `Val`.
259265 friend class GetElementPtrInst ; // For getting `Val`.
260266 friend class CatchSwitchInst ; // For getting `Val`.
261267 friend class SwitchInst ; // For getting `Val`.
@@ -679,6 +685,8 @@ class Instruction : public sandboxir::User {
679685 friend class CallInst ; // For getTopmostLLVMInstruction().
680686 friend class InvokeInst ; // For getTopmostLLVMInstruction().
681687 friend class CallBrInst ; // For getTopmostLLVMInstruction().
688+ friend class CatchPadInst ; // For getTopmostLLVMInstruction().
689+ friend class CleanupPadInst ; // For getTopmostLLVMInstruction().
682690 friend class GetElementPtrInst ; // For getTopmostLLVMInstruction().
683691 friend class CatchSwitchInst ; // For getTopmostLLVMInstruction().
684692 friend class SwitchInst ; // For getTopmostLLVMInstruction().
@@ -845,6 +853,7 @@ template <typename LLVMT> class SingleLLVMInstructionImpl : public Instruction {
845853#include " llvm/SandboxIR/SandboxIRValues.def"
846854 friend class UnaryInstruction ;
847855 friend class CallBase ;
856+ friend class FuncletPadInst ;
848857
849858 Use getOperandUseInternal (unsigned OpIdx, bool Verify) const final {
850859 return getOperandUseDefault (OpIdx, Verify);
@@ -1843,6 +1852,68 @@ class CallBrInst final : public CallBase {
18431852 }
18441853};
18451854
1855+ class FuncletPadInst : public SingleLLVMInstructionImpl <llvm::FuncletPadInst> {
1856+ FuncletPadInst (ClassID SubclassID, Opcode Opc, llvm::Instruction *I,
1857+ Context &Ctx)
1858+ : SingleLLVMInstructionImpl(SubclassID, Opc, I, Ctx) {}
1859+ friend class CatchPadInst ; // For constructor.
1860+ friend class CleanupPadInst ; // For constructor.
1861+
1862+ public:
1863+ // / Return the number of funcletpad arguments.
1864+ unsigned arg_size () const {
1865+ return cast<llvm::FuncletPadInst>(Val)->arg_size ();
1866+ }
1867+ // / Return the outer EH-pad this funclet is nested within.
1868+ // /
1869+ // / Note: This returns the associated CatchSwitchInst if this FuncletPadInst
1870+ // / is a CatchPadInst.
1871+ Value *getParentPad () const ;
1872+ void setParentPad (Value *ParentPad);
1873+ // / Return the Idx-th funcletpad argument.
1874+ Value *getArgOperand (unsigned Idx) const ;
1875+ // / Set the Idx-th funcletpad argument.
1876+ void setArgOperand (unsigned Idx, Value *V);
1877+
1878+ // TODO: Implement missing functions: arg_operands().
1879+ static bool classof (const Value *From) {
1880+ return From->getSubclassID () == ClassID::CatchPad ||
1881+ From->getSubclassID () == ClassID::CleanupPad;
1882+ }
1883+ };
1884+
1885+ class CatchPadInst : public FuncletPadInst {
1886+ CatchPadInst (llvm::CatchPadInst *CPI, Context &Ctx)
1887+ : FuncletPadInst(ClassID::CatchPad, Opcode::CatchPad, CPI, Ctx) {}
1888+ friend class Context ; // For constructor.
1889+
1890+ public:
1891+ CatchSwitchInst *getCatchSwitch () const ;
1892+ // TODO: We have not implemented setCatchSwitch() because we can't revert it
1893+ // for now, as there is no CatchPadInst member function that can undo it.
1894+
1895+ static CatchPadInst *create (Value *ParentPad, ArrayRef<Value *> Args,
1896+ BBIterator WhereIt, BasicBlock *WhereBB,
1897+ Context &Ctx, const Twine &Name = " " );
1898+ static bool classof (const Value *From) {
1899+ return From->getSubclassID () == ClassID::CatchPad;
1900+ }
1901+ };
1902+
1903+ class CleanupPadInst : public FuncletPadInst {
1904+ CleanupPadInst (llvm::CleanupPadInst *CPI, Context &Ctx)
1905+ : FuncletPadInst(ClassID::CleanupPad, Opcode::CleanupPad, CPI, Ctx) {}
1906+ friend class Context ; // For constructor.
1907+
1908+ public:
1909+ static CleanupPadInst *create (Value *ParentPad, ArrayRef<Value *> Args,
1910+ BBIterator WhereIt, BasicBlock *WhereBB,
1911+ Context &Ctx, const Twine &Name = " " );
1912+ static bool classof (const Value *From) {
1913+ return From->getSubclassID () == ClassID::CleanupPad;
1914+ }
1915+ };
1916+
18461917class GetElementPtrInst final
18471918 : public SingleLLVMInstructionImpl<llvm::GetElementPtrInst> {
18481919 // / Use Context::createGetElementPtrInst(). Don't call
@@ -2745,6 +2816,10 @@ class Context {
27452816 friend InvokeInst; // For createInvokeInst()
27462817 CallBrInst *createCallBrInst (llvm::CallBrInst *I);
27472818 friend CallBrInst; // For createCallBrInst()
2819+ CatchPadInst *createCatchPadInst (llvm::CatchPadInst *I);
2820+ friend CatchPadInst; // For createCatchPadInst()
2821+ CleanupPadInst *createCleanupPadInst (llvm::CleanupPadInst *I);
2822+ friend CleanupPadInst; // For createCleanupPadInst()
27482823 GetElementPtrInst *createGetElementPtrInst (llvm::GetElementPtrInst *I);
27492824 friend GetElementPtrInst; // For createGetElementPtrInst()
27502825 CatchSwitchInst *createCatchSwitchInst (llvm::CatchSwitchInst *I);
0 commit comments