Open64 (mfef90, whirl2f, and IR tools)
TAG: version-openad; SVN changeset: 916
|
00001 /* 00002 00003 Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify it 00006 under the terms of version 2 of the GNU General Public License as 00007 published by the Free Software Foundation. 00008 00009 This program is distributed in the hope that it would be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 00013 Further, this software is distributed without any warranty that it is 00014 free of the rightful claim of any third person regarding infringement 00015 or the like. Any license provided herein, whether implied or 00016 otherwise, applies only to this software file. Patent licenses, if 00017 any, provided herein do not apply to combinations of this program with 00018 other software, or any other product whatsoever. 00019 00020 You should have received a copy of the GNU General Public License along 00021 with this program; if not, write the Free Software Foundation, Inc., 59 00022 Temple Place - Suite 330, Boston MA 02111-1307, USA. 00023 00024 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00025 Mountain View, CA 94043, or: 00026 00027 http://www.sgi.com 00028 00029 For further information regarding this notice, see: 00030 00031 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00032 00033 */ 00034 00035 00036 /* -*-Mode: c++;-*- (Tell emacs to use c++ mode) */ 00037 #ifndef w2cf_translator_INCLUDED 00038 #define w2cf_translator_INCLUDED 00039 00040 // ============================================================== 00041 // ============================================================== 00042 // 00043 // 00044 // Description: 00045 // 00046 // A class used to translate subexpressions within a PU into 00047 // Fortran 77 or C. The purpose of this class is merely to 00048 // function as an abstraction to the whirl2c/whirl2f shared 00049 // objects. 00050 // 00051 // For translation into ANL_CBUFs, new ANL_CBUFs will be allocated 00052 // from the pool and memory reclamation of the cbuf is left to the 00053 // user of this abstraction. 00054 // 00055 // Get_Pointer_To: 00056 // May allocate a TY entry, which will not be freed up until 00057 // the destructor is called on the W2CF_TRANSLATOR. 00058 // 00059 // ============================================================== 00060 // ============================================================== 00061 00062 00063 class W2CF_TRANSLATOR 00064 { 00065 private: 00066 00067 static const INT _Max_W2cf_String_Size; 00068 char *_strbuf; 00069 WN *_pu; 00070 BOOL _translate_to_c; 00071 MEM_POOL *_pool; 00072 00073 static void _Get_Ftn_Name(ANL_CBUF *cbuf, const ST *st); 00074 static BOOL _Is_Ptr_Expr(WN *wn); 00075 00076 static TY_IDX _Get_Expr_Pointed_Ty(WN *wn); 00077 00078 void _Reuse_Ptr(TY_IDX ptr); 00079 00080 void _Istore_Lhs_To_String(ANL_CBUF *cbuf, 00081 WN *lhs, 00082 STAB_OFFSET ofst, 00083 TY_IDX ty, 00084 MTYPE mtype); 00085 00086 void _Mp_Schedtype_To_String(ANL_CBUF *cbuf, 00087 WN_PRAGMA_SCHEDTYPE_KIND kind); 00088 00089 void _Clause_Exprs_To_String(ANL_CBUF *cbuf, 00090 WN_PRAGMA_ID id, 00091 WN **next_clause); 00092 00093 void _Rev_Clause_Exprs_To_String(ANL_CBUF *cbuf, 00094 WN_PRAGMA_ID id, 00095 WN **next_clause); 00096 00097 void _Clause_Symbols_To_String(ANL_CBUF *cbuf, 00098 WN_PRAGMA_ID id, 00099 WN **next_clause); 00100 00101 void _Array_Segment_To_String(ANL_CBUF *cbuf, 00102 WN_PRAGMA_ID id, 00103 WN **next_clause); 00104 00105 void _Prefetch_Attributes_To_String(ANL_CBUF *cbuf, 00106 WN *prefetch, 00107 INT32 size); 00108 00109 void _Skip_Ignored_Clauses(WN **next_clause); 00110 00111 void _Default_Kind_To_String(ANL_CBUF *cbuf, 00112 WN_PRAGMA_DEFAULT_KIND kind); 00113 00114 00115 public: 00116 00117 // ============== Constructors & Destructors ============== 00118 00119 W2CF_TRANSLATOR(WN *pu, MEM_POOL *pool, BOOL translate_to_c); 00120 00121 ~W2CF_TRANSLATOR(); 00122 00123 00124 // ============== Inquiries ============== 00125 00126 TY_IDX Get_Pointer_To(TY_IDX pointed_ty); 00127 BOOL Is_A_Pragma_Clause(WN *clause) const; 00128 BOOL Whileloop_Looks_Like_Forloop(WN *stmt) const; 00129 BOOL Language_is_C() const {return _translate_to_c;} 00130 00131 00132 // ============== Translation ============== 00133 00134 void Expr_To_File(ANL_FILE_MNGR *file_mngr, WN *expr); 00135 00136 void Expr_To_String(ANL_CBUF *cbuf, WN *expr); 00137 00138 void Stid_Lhs_To_String(ANL_CBUF *cbuf, 00139 ST *st, 00140 STAB_OFFSET ofst, 00141 TY_IDX ty, 00142 MTYPE mtype); 00143 00144 void Original_Symname_To_String(ANL_CBUF *cbuf, ST *sym); 00145 void Transformed_Symname_To_String(ANL_CBUF *cbuf, ST *sym); 00146 00147 void A_Pragma_Expr_To_String(ANL_CBUF *cbuf, WN *apragma); 00148 00149 void ClauseList_To_String(ANL_CBUF *cbuf, WN **clause_list); 00150 00151 void Nest_Clauses_To_String(ANL_CBUF *cbuf, 00152 WN *nest_region, 00153 INT nest_levels); 00154 00155 void Prefetch_Attributes_To_String(ANL_CBUF *cbuf, 00156 WN *prefetch, 00157 INT32 size); 00158 00159 }; // class W2CF_TRANSLATOR 00160 00161 #endif /* w2cf_translator_INCLUDED */