[llvm] [SandboxIR] Implement the InsertElementInst class (PR #102404)
Jorge Gorbe Moya via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 8 14:33:25 PDT 2024
================
@@ -753,6 +755,48 @@ class SelectInst : public Instruction {
#endif
};
+class InsertElementInst final : public Instruction {
+ /// Use Context::createInsertElementInst(). Don't call
+ /// the constructor directly.
+ InsertElementInst(llvm::Instruction *I, Context &Ctx)
+ : Instruction(ClassID::InsertElement, Opcode::InsertElement, I, Ctx) {}
+ InsertElementInst(ClassID SubclassID, llvm::Instruction *I, Context &Ctx)
+ : Instruction(SubclassID, Opcode::InsertElement, I, Ctx) {}
+ friend class Context; // For accessing the constructor in
+ // create*()
+ Use getOperandUseInternal(unsigned OpIdx, bool Verify) const final {
+ return getOperandUseDefault(OpIdx, Verify);
+ }
+ SmallVector<llvm::Instruction *, 1> getLLVMInstrs() const final {
+ return {cast<llvm::Instruction>(Val)};
+ }
+
+public:
+ static Value *create(Value *Vec, Value *NewElt, Value *Idx,
+ Instruction *InsertBefore, Context &Ctx,
+ const Twine &Name = "");
+ static Value *create(Value *Vec, Value *NewElt, Value *Idx,
+ BasicBlock *InsertAtEnd, Context &Ctx,
+ const Twine &Name = "");
+ static bool classof(const Value *From) {
----------------
slackito wrote:
Done, by calling `llvm::InsertElementInst::isValidOperands(Vec->Val, NewElt->Val, Idx->Val)`. It's a static method so I can't `cast<InsertElementInst>(Val)`.
https://github.com/llvm/llvm-project/pull/102404
More information about the llvm-commits
mailing list