00001 #ifndef _PARAMETER_H
00002 #define _PARAMETER_H
00003
00004 #include "xi-util.h"
00005
00006 namespace xi {
00007
00008 class Type;
00009 class Entry;
00010 class Value;
00011
00012
00013 class Parameter {
00014 int rdma;
00015 bool firstRdma;
00016
00017 public:
00018 Type* type;
00019 const char* name;
00020 const char* given_name;
00021 const char* arrLen;
00022
00023 Value* val;
00024 int line;
00025 int byReference;
00026 bool declaredReference;
00027 int conditional;
00028 bool byConst;
00029
00030
00031 int accelBufferType;
00032 XStr* accelInstName;
00033 bool podType;
00034
00035 friend class ParamList;
00036 void pup(XStr& str);
00037 void pupArray(XStr& str);
00038 void pupRdma(XStr& str, bool genRdma);
00039 void copyPtr(XStr& str);
00040 void check();
00041 void checkPointer(Type* dt);
00042 void marshallArraySizes(XStr& str, Type* dt);
00043 void marshallRegArraySizes(XStr& str);
00044 void marshallRdmaParameters(XStr& str, bool genRdma);
00045 void marshallArrayData(XStr& str);
00046 void marshallRdmaArrayData(XStr& str);
00047 void beginUnmarshall(XStr& str);
00048 void beginUnmarshallArray(XStr& str);
00049 void beginUnmarshallRdma(XStr& str, bool genRdma);
00050 void beginUnmarshallSDAGRdma(XStr& str);
00051 void beginUnmarshallSDAGCall(XStr& str);
00052 void beginUnmarshallSDAGCallRdma(XStr& str, bool genRdma);
00053 void unmarshallArrayData(XStr& str);
00054 void unmarshallRegArrayData(XStr& str);
00055 void unmarshallRdmaArrayData(XStr& str, bool genRegArray);
00056 void adjustUnmarshalledRdmaPtrsSDAG(XStr& str);
00057 void unmarshallRegArrayDataSDAG(XStr& str);
00058 void unmarshallRdmaArrayDataSDAG(XStr& str);
00059 void unmarshallRegArrayDataSDAGCall(XStr& str);
00060 void unmarshallRdmaArrayDataSDAGCall(XStr& str);
00061 void pupAllValues(XStr& str);
00062
00063 public:
00064 Entry* entry;
00065 Parameter(int Nline, Type* Ntype, const char* Nname = 0, const char* NarrLen = 0,
00066 Value* Nvalue = 0);
00067 void setConditional(int c);
00068 void setRdma(int r);
00069 void setFirstRdma(bool fr);
00070 int print(XStr& str, int withDefaultValues = 0, int useConst = 1, int fwdNum = 0);
00071 void printAddress(XStr& str);
00072 void printValue(XStr& str);
00073 int isMessage(void) const;
00074 int isVoid(void) const;
00075 int isCkArgMsgPtr(void) const;
00076 int isCkMigMsgPtr(void) const;
00077 int isArray(void) const;
00078 int isRdma(void) const;
00079 int isSendRdma(void) const;
00080 int isRecvRdma(void) const;
00081 int getRdma(void) const;
00082 int isFirstRdma(void) const;
00083 int isConditional(void) const;
00084 Type* getType(void) { return type; }
00085 const char* getArrayLen(void) const { return arrLen; }
00086 const char* getGivenName(void) const { return given_name; }
00087 void setGivenName(const char* s) { given_name = s; }
00088 const char* getName(void) const { return name; }
00089 void printMsg(XStr& str);
00090 void storePostedRdmaPtrs(XStr& str, bool genRdma, bool isSDAGGen, int &count);
00091 int operator==(const Parameter& parm) const;
00092
00093
00094 public:
00095 enum {
00096 ACCEL_BUFFER_TYPE_UNKNOWN = 0,
00097 ACCEL_BUFFER_TYPE_MIN = 1,
00098 ACCEL_BUFFER_TYPE_READWRITE = 1,
00099 ACCEL_BUFFER_TYPE_READONLY = 2,
00100 ACCEL_BUFFER_TYPE_WRITEONLY = 3,
00101 ACCEL_BUFFER_TYPE_MAX = 3
00102 };
00103 void setAccelBufferType(int abt);
00104 int getAccelBufferType();
00105 void setAccelInstName(XStr* ain);
00106 XStr* getAccelInstName(void);
00107 };
00108
00109 class ParamList {
00110 typedef int (Parameter::*pred_t)(void) const;
00111 int orEach(pred_t f);
00112 typedef void (Parameter::*fn_t)(XStr& str);
00113 typedef void (Parameter::*rdmafn_t)(XStr& str, bool genRegArray);
00114 typedef void (Parameter::*rdmarecvfn_t)(XStr& str, bool genRdma, bool isSDAGGen, int &count);
00115 void callEach(fn_t f, XStr& str);
00116 void callEach(rdmafn_t f, XStr& str, bool genRegArray);
00117 void callEach(rdmarecvfn_t f, XStr& str, bool genRdma, bool isSDAGGen);
00118 void encloseFlag(XStr& str);
00119 bool manyPointers;
00120
00121 public:
00122 Entry* entry;
00123 Parameter* param;
00124 ParamList* next;
00125 ParamList(ParamList* pl);
00126 ParamList(Parameter* Nparam, ParamList* Nnext = NULL);
00127 int print(XStr& str, int withDefaultValues = 0, int useConst = 1, int fwdNum = 0);
00128 void printTypes(XStr& str, int withDefaultValues = 0, int useConst = 1);
00129 void printAddress(XStr& str);
00130 void printValue(XStr& str);
00131 int isNamed(void) const;
00132 int isBuiltin(void) const;
00133 int isMessage(void) const;
00134 const char* getArrayLen(void) const;
00135 int isArray(void) const;
00136 int isReference(void) const;
00137 int declaredReference(void) const;
00138 bool isConst(void) const;
00139 int isVoid(void) const;
00140 int isPointer(void) const;
00141 int hasRdma(void);
00142 int hasSendRdma(void);
00143 int hasRecvRdma(void);
00144 int isRdma(void);
00145 int getRdma(void);
00146 int isFirstRdma(void);
00147 int isRecvRdma(void);
00148 const char* getGivenName(void) const;
00149 void setGivenName(const char* s);
00150 const char* getName(void) const;
00151 int isMarshalled(void) const;
00152 int isCkArgMsgPtr(void) const;
00153 int isCkMigMsgPtr(void) const;
00154 int getNumStars(void) const;
00155 const char* getBaseName(void);
00156 void genMsgProxyName(XStr& str);
00157 void printMsg(XStr& str);
00158 void preprocess();
00159 int hasConditional();
00160 void marshall(XStr& str, XStr& entry);
00161 void beginUnmarshall(XStr& str);
00162 void beginUnmarshallSDAG(XStr& str);
00163 void beginUnmarshallSDAGCall(XStr& str, bool usesImplBuf);
00164 void beginRednWrapperUnmarshall(XStr& str, bool isSDAGGen);
00165 void unmarshall(XStr& str, bool isInline = false, bool isFirst = true, bool isRdmaPost=false);
00166 void unmarshallForward(XStr& str, bool isInline = false, bool isFirst = true, bool isRdmaPost = false, int fwdNum = 1);
00167 void unmarshallSDAGCall(XStr& str, int isFirst = 1);
00168 void unmarshallAddress(XStr& str, int isFirst = 1);
00169 void pupAllValues(XStr& str);
00170 void endUnmarshall(XStr& str);
00171 int operator==(ParamList& plist);
00172 void checkParamList();
00173 void storePostedRdmaPtrs(XStr& str, bool isSDAGGen);
00174 };
00175
00176 }
00177
00178 #endif // ifndef _TYPE_H