@@ -51,12 +51,30 @@ enum LiftStatus {
5151 kLiftedInstruction
5252};
5353
54+ // Instruction independent lifting
55+ class OperandLifter {
56+ public:
57+ using OpLifterPtr = std::shared_ptr<OperandLifter>;
58+
59+ // Load the address of a register.
60+ virtual std::pair<llvm::Value *, llvm::Type *>
61+ LoadRegAddress (llvm::BasicBlock *block, llvm::Value *state_ptr,
62+ std::string_view reg_name) const = 0 ;
63+
64+ // Load the value of a register.
65+ virtual llvm::Value *LoadRegValue (llvm::BasicBlock *block,
66+ llvm::Value *state_ptr,
67+ std::string_view reg_name) const = 0;
68+
69+ virtual llvm::Type *GetMemoryType () = 0;
70+ };
71+
5472// Wraps the process of lifting an instruction into a block. This resolves
5573// the intended instruction target to a function, and ensures that the function
5674// is called with the appropriate arguments.
57- class InstructionLifter {
75+ class InstructionLifter : public OperandLifter {
5876 public:
59- using LifterPtr = std::unique_ptr <InstructionLifter>;
77+ using LifterPtr = std::shared_ptr <InstructionLifter>;
6078
6179 virtual ~InstructionLifter (void );
6280
@@ -83,17 +101,17 @@ class InstructionLifter {
83101 // Load the address of a register.
84102 std::pair<llvm::Value *, llvm::Type *>
85103 LoadRegAddress (llvm::BasicBlock *block, llvm::Value *state_ptr,
86- std::string_view reg_name) const ;
104+ std::string_view reg_name) const override final ;
87105
88106 // Load the value of a register.
89107 llvm::Value *LoadRegValue (llvm::BasicBlock *block, llvm::Value *state_ptr,
90- std::string_view reg_name) const ;
108+ std::string_view reg_name) const override final ;
91109
92110 // Clear out the cache of the current register values/addresses loaded.
93111 void ClearCache (void ) const ;
94112
95113
96- llvm::Type *GetMemoryType ();
114+ virtual llvm::Type *GetMemoryType () override final ;
97115
98116 protected:
99117 // Lift an operand to an instruction.
0 commit comments