OpenADFortTk (basic)
src/whirl2xaif/ty2xaif.h
Go to the documentation of this file.
00001 // -*-Mode: C++;-*-
00002 // $Header: /m_home/m_utkej/Argonne/cvs2svn/cvs/OpenADFortTk/src/whirl2xaif/ty2xaif.h,v 1.9 2008-01-21 13:40:57 utke Exp $
00003 
00004 #ifndef ty2xaif_INCLUDED
00005 #define ty2xaif_INCLUDED
00006 /* ====================================================================
00007  * ====================================================================
00008  *
00009  * Description:
00010  *
00011  *    TY2F_translate: 
00012  *       Add a Fortran language type corresponding to the given TY node
00013  *       into the token_buffer, assuming the xml::ostream& already
00014  *       holds a construct to be declared of this type.  The type
00015  *       may surround the current contents of the given xml::ostream&
00016  *       as though these contents where declared to be of the given
00017  *       type; i.e. for an array or function type.  The qualifiers
00018  *       are not written out for the top-level ty, but will be written
00019  *       for component tys.  After this call, TY2F_Prepend_Structures()
00020  *       should be called in an appropriate context (such as 
00021  *       ST2F_translate()).
00022  *
00023  *    TY2F_translate_purple_array:
00024  *       Inserts a place-holder for assumed sized or adjustable array bounds,
00025  *       while the action is simply dispatched to TY2F_translate() for other
00026  *       types.
00027  *
00028  *    TY2F_Translate_ArrayElt:
00029  *       Translates an array offset into a (multi-dimensional) array
00030  *       indexing operation, based on a given array-type.
00031  *
00032  *    TY2F_Translate_Common:
00033  *       Translates a common-block into Fortran.  After this call, 
00034  *       TY2F_Prepend_Structures() should be called in an appropriate
00035  *       context (such as ST2F_translate()).
00036  *
00037  *    TY2F_Translate_Equivalence:
00038  *       Translates an equivalence spec into Fortran.  After this call, 
00039  *       TY2F_Prepend_Structures() should be called in an appropriate
00040  *       context (such as ST2F_translate()).  If alt_return==TRUE, this
00041  *       equivalence represents the return-variables for alternate return
00042  *       points in a function, and they will be treated as such.
00043  *
00044  *    TY2F_Prepend_Structures:
00045  *       When TY2F_translate(), TY2F_Translate_Common(), or 
00046  *       TY2F_Translate_Equivalence() are invoked, a number of
00047  *       records may be translated in the process.  These will be
00048  *       declared in a buffer internal to ty2f, and this routine
00049  *       must be called to prepend the contents of this internal
00050  *       buffer to a given buffer.  We cannot prepend these 
00051  *       structures to the buffer passed to the "TY2F_translate()" 
00052  *       routine, since we do not know in what context that translation
00053  *       occurs (e.g. it may called for a fld declaration).
00054  *
00055  *     TY2F_Fld_Separator: adds the appropriate field separator for
00056  *                         structure components
00057  *
00058  * KIND_STRUCT field information
00059  * ------------------------------
00060  *
00061  *   TY2F_Free_Fld_Path:  Having called Stab_Get_Fld_Path(), we can
00062  *      reuse the path-elements by invoking TY2F_Free_Fld_Path()
00063  *      before the next call to TY2F_Get_Fld_Path().
00064  *
00065  *   TY2F_Get_Fld_Path:  Returns a path through the substructure of
00066  *      the given KIND_STRUCT to a field element that was found to
00067  *      best match the given type and offset.  While a matching type
00068  *      need not be of the same btype, it must always have the same
00069  *      offset, type-size, and type-alignment.  NULL is returned when
00070  *      no matching field is found.
00071  *
00072  *   TY2F_Translate_Fld_Path:  Given a path to a field, append a field
00073  *      selection string as dictated by Fortran syntax to access this
00074  *      field.  It is assumed that the token_buffer already contains
00075  *      the tokens for the base-record expression.  Note that we use
00076  *      the pointee name to dereference a pointer record elements
00077  *      (after emitting a warning since we do not expect record elements
00078  *      to be pointers).
00079  *
00080  *    TY2F_Dump_Fld_Path: dump to stdout...
00081  *
00082  *    TY2F_Point_At_Path: look within a path for a FLD with the given offset.
00083  *
00084  * ====================================================================
00085  * ====================================================================
00086  */
00087 
00088 #include "Open64IRInterface/Open64BasicTypes.h"
00089 #include "xmlostream.h"
00090 
00091 #include "whirl2xaif.h"
00092 #include "PUXlationContext.h"
00093 
00094 namespace whirl2xaif {
00095 
00096 extern void 
00097 TY2F_translate(xml::ostream& xos, TY_IDX ty, PUXlationContext& ctxt);
00098 
00099 extern void 
00100 TY2F_translate(xml::ostream& xos, TY_IDX ty ,BOOL notyappend, PUXlationContext& ctxt);
00101 
00102 const char*
00103 TranslateTYToSymType(TY_IDX ty);
00104 
00105 const char*
00106 TranslateTYToMType(TY_IDX ty);
00107 
00108 const char*
00109 TranslateTYToSymShape(TY_IDX ty);
00110 
00111 
00112 extern void TY2F_Translate_ArrayElt(xml::ostream& xos,
00113                                     TY_IDX       arr_ty,
00114                                     STAB_OFFSET  arr_ofst);
00115 extern void TY2F_Translate_Common(xml::ostream& xos, 
00116                                   const char   *name, 
00117                                   TY_IDX        ty);
00118 extern void TY2F_Translate_Equivalence(xml::ostream& xos,
00119                                        TY_IDX        ty,
00120                                        BOOL          alt_return);
00121 
00122 extern void TY2F_Prepend_Structures(xml::ostream& xos);
00123 
00124 static  BOOL Array_Bnd_Temp_Var=FALSE;
00125 
00126    /*------- Facilities to get information about FLDs -------*/
00127    /*--------------------------------------------------------*/
00128    
00129 typedef struct Fld_Path_Info FLD_PATH_INFO;
00130 struct Fld_Path_Info
00131 {
00132   FLD_HANDLE     fld;      // Field on the path
00133   BOOL           arr_elt;  // An element in an array field?
00134   STAB_OFFSET    arr_ofst; // Offset of element within an array field
00135   WN *           arr_wn;   // if arr_elt, optional OPC_ARRAY with subscripts
00136   FLD_PATH_INFO *next;     // Next field on the path
00137 };
00138 
00139 extern FLD_PATH_INFO * TY2F_Free_Fld_Path(FLD_PATH_INFO *fld_path);
00140 
00141 
00142 extern FLD_PATH_INFO * TY2F_Get_Fld_Path(TY_IDX    struct_ty, 
00143                                          TY_IDX    object_ty,
00144                                          STAB_OFFSET offset);
00145 
00146 extern void TY2F_Translate_Fld_Path(xml::ostream&   tokens, 
00147                                     FLD_PATH_INFO *fld_path,
00148                                     BOOL           deref,  
00149                                     BOOL           member_of_common,
00150                                     BOOL           name_as_is,
00151                                     PUXlationContext& ctxt);
00152 
00153 
00154 extern void TY2F_Fld_Separator(xml::ostream& xos);
00155 extern FLD_HANDLE TY2F_Last_Fld(FLD_PATH_INFO *fld_path);
00156 
00157 extern void TY2F_Dump_Fld_Path(FLD_PATH_INFO *fld_path) ;
00158 extern FLD_PATH_INFO * TY2F_Point_At_Path(FLD_PATH_INFO * path, STAB_OFFSET off);
00159 
00160 } // end namespace 
00161 
00162 #endif /* ty2xaif_INCLUDED */
00163 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines