Skip to content

Commit

Permalink
Subclassed Memory_Operand from Operand
Browse files Browse the repository at this point in the history
  • Loading branch information
James H. Hill committed Apr 6, 2015
1 parent e971b51 commit a391aba
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 137 deletions.
6 changes: 3 additions & 3 deletions pin++/Ins.h
Expand Up @@ -13,19 +13,19 @@
#ifndef _OASIS_PIN_INS_H_
#define _OASIS_PIN_INS_H_

#include "pin.H"
#include "Iterator.h"
#include "Insert_T.h"
#include "Operand.h"

#include "Pin_export.h"

namespace OASIS
{
namespace Pin
{

// Forward decl.
class Routine;

// Forward decl.
class Operand;

/**
Expand Down
65 changes: 0 additions & 65 deletions pin++/Memory_Operand.h

This file was deleted.

64 changes: 0 additions & 64 deletions pin++/Memory_Operand.inl

This file was deleted.

56 changes: 53 additions & 3 deletions pin++/Operand.h
Expand Up @@ -13,15 +13,17 @@
#ifndef _OASIS_PIN_OPERAND_H_
#define _OASIS_PIN_OPERAND_H_

#include "Memory_Operand.h"

#include "pin.H"
#include "Pin_export.h"

namespace OASIS
{
namespace Pin
{

// Forward decl.
class Memory_Operand;

/**
* @class Operand
*
Expand All @@ -30,7 +32,17 @@ namespace Pin
class OASIS_PIN_Export Operand
{
public:
/**
* Initializing constructor.
*
* @param[in] ins Parent instruction of the operand
* @param[in] index Index of the operand
*/
Operand (INS ins, int index);

/**
* Copy constructor.
*/
Operand (const Operand & rhs);

/// Destructor.
Expand Down Expand Up @@ -74,11 +86,49 @@ class OASIS_PIN_Export Operand
bool is_read_and_written (void) const;
/// @}

private:
protected:
/// The parent instruction of the operand.
INS ins_;

/// The index of the operand.
int index_;
};

/**
* @class Memory_Operand
*
* Wrapper class for Operand specificlly for memory operands.
*/
class Memory_Operand : public Operand
{
public:
/**
* Initializing constructor.
*
* @param[in] ins Parent instruction of the operand
* @param[in] index Index of the operand
*/
Memory_Operand (INS ins, int index);

/**
* Copy constructor
*/
Memory_Operand (const Memory_Operand & copy);

/// Destructor.
~Memory_Operand (void);

bool is_read (void) const;
bool is_written (void) const;

/// Get the size of the memory operand.
USIZE size (void) const;

void rewrite (REG reg) const;

const Memory_Operand & operator = (const Memory_Operand & rhs);
};

} // namespace OASIS
} // namespace Pin

Expand Down
60 changes: 59 additions & 1 deletion pin++/Operand.inl
@@ -1,5 +1,4 @@
// -*- C++ -*-
// $Id: Operand.inl 2288 2013-09-19 19:09:57Z hillj $

namespace OASIS
{
Expand Down Expand Up @@ -31,6 +30,9 @@ Operand::~Operand (void)
inline
const Operand & Operand::operator = (const Operand & rhs)
{
if (this == &rhs)
return *this;

this->ins_ = rhs.ins_;
this->index_ = rhs.index_;
return *this;
Expand Down Expand Up @@ -169,5 +171,61 @@ Memory_Operand Operand::to_memory_operand (void) const
return Memory_Operand (this->ins_, this->index_);
}


////////////////////////////////////////////////////////////////////////////////////////////////
// Memory_Operand

inline
Memory_Operand::Memory_Operand (INS ins, int index)
: Operand (ins, index)
{

}

inline
Memory_Operand::Memory_Operand (const Memory_Operand & copy)
: Operand (copy)
{

}

inline
Memory_Operand::~Memory_Operand (void)
{

}

inline
const Memory_Operand & Memory_Operand::operator = (const Memory_Operand & rhs)
{
Operand::operator = (rhs);
return *this;
}

inline
bool Memory_Operand::is_read (void) const
{
return INS_MemoryOperandIsRead (this->ins_, this->index_);
}

inline
bool Memory_Operand::is_written (void) const
{
return INS_MemoryOperandIsWritten (this->ins_, this->index_);
}

inline
void Memory_Operand::rewrite (REG reg) const
{
INS_RewriteMemoryOperand (this->ins_, this->index_, reg);
}

inline
USIZE Memory_Operand::size (void) const
{
return INS_MemoryOperandSize (this->ins_, this->index_);
}


} // namespace OASIS
} // namespace Pin
1 change: 0 additions & 1 deletion pin++/pin++.mpc
Expand Up @@ -57,7 +57,6 @@ project (pin++) : pin {
Guard.inl
Lock.inl
Mutex.inl
Memory_Operand.inl
Operand.inl
RW_Mutex.inl
Semaphore.inl
Expand Down

0 comments on commit a391aba

Please sign in to comment.