[llvm] [SandboxIR] Implement UnaryInstruction class (PR #101541)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 1 14:55:32 PDT 2024
================
@@ -836,10 +839,26 @@ class BranchInst : public Instruction {
#endif
};
-class LoadInst final : public Instruction {
+/// An abstract class, parent of unary instructions.
+class UnaryInstruction : public Instruction {
+protected:
+ UnaryInstruction(ClassID ID, Opcode Opc, llvm::Instruction *LLVMI,
+ Context &Ctx)
+ : Instruction(ID, Opc, LLVMI, Ctx) {}
+
+public:
+ static bool classof(const Instruction *I) {
+ return I->getOpcode() == Instruction::Opcode::Load || isa<CastInst>(I);
+ }
+ static bool classof(const Value *V) {
+ return isa<Instruction>(V) && classof(cast<Instruction>(V));
----------------
vporpo wrote:
I think you may be misinterpreting the manual. This pattern is *very* common throughout LLVM. It can't be that no one noticed that all this code does not conform with the coding style. InstrTypes.h in particular includes this exact pattern 119 times!
https://github.com/llvm/llvm-project/pull/101541
More information about the llvm-commits
mailing list