IntrinsicXlationTable.h
Go to the documentation of this file.00001
00002
00003
00004
00005 #ifndef IntrinsicXlationTable_H
00006 #define IntrinsicXlationTable_H
00007
00008 #include <iostream>
00009 #include <vector>
00010
00011 #include "Open64IRInterface/Open64BasicTypes.h"
00012
00013
00014 namespace fortTkSupport {
00015
00043 class IntrinsicXlationTable {
00044 public:
00045
00046 enum TableType {
00047 W2X,
00048 X2W
00049 };
00050
00055 enum WNOprClass {
00056 WNCall =0,
00057 WNIntrinCall =1,
00058 WNIntrinOp =2,
00059 WNExpr =3,
00060 WNOprClass_UNKNOWN =4
00061 };
00062
00063 static const std::string toString(const WNOprClass& oprcl);
00064
00069 enum XAIFOpr {
00070 XAIFSubCall,
00071 XAIFFuncCall,
00072 XAIFIntrin,
00073 XAIFBoolOp,
00074 XAIFOpr_UNKNOWN
00075 };
00076
00077 static const std::string toString(const XAIFOpr& opr);
00078
00079 struct WHIRLInfo {
00080 WNOprClass oprcl;
00081 OPERATOR opr;
00082 const char* name;
00083 unsigned int numop;
00084 unsigned int numOptional;
00085 void dump(std::ostream& os = std::cerr) const;
00086 void ddump() const;
00087 };
00088
00099 struct XAIFInfo {
00100 XAIFOpr opr;
00101 const char* name;
00102 const char* key;
00103 unsigned int numop;
00104 void dump(std::ostream& os = std::cerr) const;
00105 void ddump() const;
00106 };
00107
00111 struct Entry {
00112 WHIRLInfo whirl_info;
00113 XAIFInfo xaif_info;
00114 };
00115
00116 public:
00117 IntrinsicXlationTable(const TableType& tt);
00118
00119 ~IntrinsicXlationTable();
00120
00124 struct XAIFInfoPair {
00125 XAIFInfoPair(bool aBoolean,
00126 const XAIFInfo& anXAIFInfo);
00127 bool first;
00128 const XAIFInfo& second;
00129 private:
00133 XAIFInfoPair();
00134 };
00135
00139 XAIFInfoPair findXAIFInfo(OPERATOR opr, const char* name, bool mustFind=true);
00140
00141 WHIRLInfo* findWHIRLInfo(XAIFOpr opr, const char* name, const char* key);
00142
00143 void dump(std::ostream& os = std::cerr) const;
00144 void ddump() const;
00145
00146 private:
00147
00151 IntrinsicXlationTable(const IntrinsicXlationTable& p);
00152
00156 IntrinsicXlationTable& operator=(const IntrinsicXlationTable& p);
00157
00158 class LtSortedTable {
00159 public:
00160 LtSortedTable(TableType aTableType, bool ignoreXaifKey=false);
00161 ~LtSortedTable();
00162
00163
00164 bool operator()(const Entry* e1, const Entry* e2) const;
00165
00166
00167 bool operator()(Entry*& e1, const Entry& e2) {
00168 return operator()(dynamic_cast<Entry*>(e1),
00169 dynamic_cast<const Entry*>(&e2));
00170 }
00171 bool operator()(const Entry& e1, Entry*& e2) {
00172 return operator()(dynamic_cast<const Entry*>(&e1),
00173 dynamic_cast<Entry*>(e2));
00174 }
00175
00176
00177 bool operator()(const Entry& e1, const Entry& e2) {
00178 return operator()(dynamic_cast<const Entry*>(&e1),
00179 dynamic_cast<const Entry*>(&e2));
00180 }
00181 bool operator()(const Entry*& e1, const Entry*& e2) {
00182 return operator()(dynamic_cast<const Entry*>(e1),
00183 dynamic_cast<const Entry*>(e2));
00184 }
00185
00186 private:
00190 LtSortedTable();
00191
00192 private:
00193 TableType myTableType;
00194 bool myIgnoreXaifKeyFlag;
00195 };
00196
00197 typedef std::vector<Entry*> SortedTable;
00198 typedef SortedTable::iterator SortedTableIt;
00199 typedef SortedTable::value_type SortedTableVal;
00200
00201 private:
00202
00203 TableType myTableType;
00204 SortedTable mySortedTable;
00205
00206 static Entry ourTable[];
00207 static unsigned int ourTableSize;
00208
00209 };
00210
00211 }
00212
00213 #endif
00214