00001 /* 00002 * Copyright (C) 2000-2001, The University of Queensland 00003 * 00004 * See the file "LICENSE.TERMS" for information on usage and 00005 * redistribution of this file, and for a DISCLAIMER OF ALL 00006 * WARRANTIES. 00007 * 00008 */ 00009 00010 /*============================================================================== 00011 * FILE: register.h 00012 * OVERVIEW: Header information for the Register class. 00013 *============================================================================*/ 00014 00015 /* 00016 * $Revision: 1.4 $ 00017 * 00018 * 28 Apr 02 - Mike: Mods for boomerang 00019 */ 00020 00021 #ifndef __REG_H__ 00022 #define __REG_H__ 00023 00024 class Type; 00025 00026 /*============================================================================== 00027 * The Register class summarises one line of the @REGISTERS section of an SSL 00028 * file. This class is used extensively in sslparser.y, and there is a public 00029 * member of RTLInstDict called DetRegMap which gives a Register object from 00030 * a register index (register indices may not always be sequential, hence it's 00031 * not just an array of Register objects). 00032 * This class plays a more active role in the Interpreter, which is not yet 00033 * integrated into uqbt 00034 *============================================================================*/ 00035 00036 class Register { 00037 public: 00038 00039 Register(); // needed for use in stl classes. 00040 Register(const Register&); 00041 Register operator=(const Register& r2); 00042 bool operator==(const Register& r2) const; 00043 bool operator<(const Register& r2) const; 00044 00045 // access and set functins 00046 void s_name(const char *); 00047 void s_size(int s) {size = s;} 00048 void s_float(bool f) {flt = f;} 00049 void s_address(void *p) {address = p;} 00050 00051 /* These are only used in the interpreter */ 00052 char *g_name() const; 00053 void *g_address() const {return address;} 00054 00055 int g_size() const {return size;} 00056 Type* g_type() const; 00057 00058 /* Set the mapped index. For COVERS registers, this is the lower register 00059 * of the set that this register covers. For example, if the current register 00060 * is f28to31, i would be the index for register f28 00061 * For SHARES registers, this is the "parent" register, e.g. if the current 00062 * register is %al, the parent is %ax (note: not %eax) 00063 */ 00064 void s_mappedIndex(int i) {mappedIndex = i;} 00065 /* Set the mapped offset. This is the bit number where this register starts, 00066 e.g. for register %ah, this is 8. For COVERS regisers, this is 0 */ 00067 void s_mappedOffset(int i) {mappedOffset = i;} 00068 /* Get the mapped index (see above) */ 00069 int g_mappedIndex() const {return mappedIndex;} 00070 /* Get the mapped offset (see above) */ 00071 int g_mappedOffset() const {return mappedOffset;} 00072 /* Get a bool which is true if this is a floating point register */ 00073 bool isFloat() const {return flt;} 00074 00075 private: 00076 char *name; 00077 short size; 00078 void *address; 00079 int mappedIndex; 00080 int mappedOffset; 00081 bool flt; // True if this is a floating point register 00082 }; 00083 00084 #endif