Otawa  0.10
otawa::Address Class Reference

The representation of an address in OTAWA. More...

#include <otawa/base.h>

Public Types

typedef t::uint32 page_t
 
typedef t::uint32 offset_t
 

Public Member Functions

 Address (void)
 Build a null address. More...
 
 Address (offset_t offset)
 Build a simple absolute address. More...
 
 Address (page_t page, offset_t offset)
 Build a full address. More...
 
 Address (const Address &address)
 Build an address by cloning. More...
 
 Address (const MemArea &mem_area)
 
page_t page (void) const
 Get the page number. More...
 
offset_t offset (void) const
 Get the offset value. More...
 
offset_t operator* (void) const
 Short cut to offset(). More...
 
bool isNull (void) const
 Test if the address is null. More...
 
 operator offset_t (void) const
 shortcut to offset(). More...
 
Addressoperator= (const Address &address)
 
Addressoperator= (offset_t offset)
 
Addressoperator+= (int offset)
 
Addressoperator+= (t::uint32 offset)
 
Addressoperator-= (int offset)
 
Addressoperator-= (t::uint32 offset)
 
Address operator+ (t::int32 offset) const
 
Address operator+ (t::uint32 offset) const
 
Address operator- (t::int32 offset) const
 
Address operator- (t::uint32 offset) const
 
offset_t operator- (const Address &address) const
 
bool equals (const Address &address) const
 Test if two address are equals. More...
 
int compare (const Address &address) const
 Compare two addresses and returns: More...
 
bool operator== (const Address &addr) const
 
bool operator!= (const Address &addr) const
 
bool operator< (const Address &addr) const
 
bool operator<= (const Address &addr) const
 
bool operator> (const Address &addr) const
 
bool operator>= (const Address &addr) const
 

Static Public Attributes

static Address null
 Null address. More...
 
static const page_t null_page = elm::type_info<page_t>::max
 

Private Attributes

page_t pg
 
offset_t off
 

Detailed Description

The representation of an address in OTAWA.

To match most architectures, the address is split in two component:

  • a page component,
  • an offset component from the page.

The page component may be used to represent different, non overlapping address spaces. For example, a Harvard architecture for example: page 0 may be used to store code and page 1 to store data.

It is bad idea to use the page to represent segemented memory as in the paged mode of the x86 architecture. The rule is that each item must have a unique address in order to perform valid address comparison and computation. For example, the M68HCxx banking memory that assign different code banks in memory from 0x8000 to 0xC000 is better handled by assigning to each an absolute address above the maximal address computed by: 0x10000 + bank_number * 0x4000.

Finally, notice that the page 0xffffffff is reserved to represent the null address.

Member Typedef Documentation

Constructor & Destructor Documentation

otawa::Address::Address ( void  )
inline

Build a null address.

otawa::Address::Address ( offset_t  offset)
inline

Build a simple absolute address.

Parameters
offsetAbsolute value of the address.
otawa::Address::Address ( page_t  page,
offset_t  offset 
)
inline

Build a full address.

Parameters
pageAddress page.
offsetOffset in the page.
otawa::Address::Address ( const Address address)
inline

Build an address by cloning.

Parameters
addressCloned address.
otawa::Address::Address ( const MemArea mem_area)
inline

Member Function Documentation

int otawa::Address::compare ( const Address address) const
inline

Compare two addresses and returns:

  • <0 if the current address is less than the given one,
  • =0 if both addresses are equal,
  • >0 if the current address is greater than the given one.
    Warning
    It is an error to compare address of different pages.
    Parameters
    addressAddress to compare to.
    Returns
    See above.

References off, and pg.

bool otawa::Address::equals ( const Address address) const
inline

Test if two address are equals.

Parameters
addressAddress to compare with.
Returns
True if both addresses are equals, false else.

References off, and pg.

otawa::Address::operator offset_t ( void  ) const
inline

shortcut to offset().

bool otawa::Address::operator!= ( const Address addr) const
inline
offset_t otawa::Address::operator* ( void  ) const
inline

Short cut to offset().

Address otawa::Address::operator+ ( t::int32  offset) const
inline
Address otawa::Address::operator+ ( t::uint32  offset) const
inline
Address& otawa::Address::operator+= ( int  offset)
inline
Address& otawa::Address::operator+= ( t::uint32  offset)
inline
Address otawa::Address::operator- ( t::int32  offset) const
inline
Address otawa::Address::operator- ( t::uint32  offset) const
inline
offset_t otawa::Address::operator- ( const Address address) const
inline

References isNull(), off, and pg.

Address& otawa::Address::operator-= ( int  offset)
inline
Address& otawa::Address::operator-= ( t::uint32  offset)
inline
bool otawa::Address::operator< ( const Address addr) const
inline

References off, and pg.

bool otawa::Address::operator<= ( const Address addr) const
inline

References off, and pg.

Address& otawa::Address::operator= ( const Address address)
inline

References off, and pg.

Address& otawa::Address::operator= ( offset_t  offset)
inline
bool otawa::Address::operator== ( const Address addr) const
inline
bool otawa::Address::operator> ( const Address addr) const
inline

References off, and pg.

bool otawa::Address::operator>= ( const Address addr) const
inline

References off, and pg.

Member Data Documentation

const page_t otawa::Address::null_page = elm::type_info<page_t>::max
static
offset_t otawa::Address::off
private
page_t otawa::Address::pg
private

The documentation for this class was generated from the following files: