Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
ttype.h
Go to the documentation of this file.
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 #ifndef ttype_INCLUDED
00037 #define ttype_INCLUDED
00038 #ifdef __cplusplus
00039 extern "C" {
00040 #endif
00041 /* ====================================================================
00042  * ====================================================================
00043  *
00044  *
00045  * Revision history:
00046  *  26-May-89 - Original Version of header.  Added content.
00047  *  12-Jun-91 - Integrated from Josie
00048  *
00049  * Description:
00050  *
00051  * Routines to map tree nodes to the types of the objects represented.
00052  *
00053  * ====================================================================
00054  * ====================================================================
00055  */
00056 
00057 
00058 #include "srcpos.h"     /* get definition of SRCPOS */
00059 
00060 /* Dummy declarations of structs for prototypes: */
00061 class WN;
00062 
00063 #ifdef FRONT_END
00064 /* Return a character string representation of the input TY */
00065 extern char *FE_Type_Name(TY *ty);
00066 #endif /* FRONT_END */
00067 
00068 /* return the ty for a whirl expression */
00069 extern TY_IDX TY_Of_Expr (const WN *expr);
00070 
00071 /* return the ty for a whirl expression accounting for SCLASS_FORMAL_REF */
00072 extern TY_IDX TY_Of_Parameter(WN *expr);
00073 
00074 /* Determine whether the given type is floating point.  For this
00075  * purpose, the Fortran complex and double complex types are considered
00076  * floating point.
00077  */
00078 extern BOOL Is_Float_Type (TY_IDX t);
00079 
00080 /* ====================================================================
00081  *       QUALIFIED TYPES: 
00082  *
00083  * The TY record has two qualifying flags TY_is_volatile and
00084  * TY_is_const.
00085  *
00086  * The features to note are:
00087  *
00088  *  - The qualified versions of TY records have TY_is_volatile or 
00089  *    TY_is_const flags on. 
00090  *
00091  *  - The qualified and non qualified versions of same types share 
00092  *    TY_flist, TY_arinfo and enum_const lists. sharing of field list 
00093  *    (TY_flist) is important to be able to tell when two struct kind 
00094  *    TY records are same except for volatile or const bits. eg:
00095  *       struct a { int i,j; }; volatile struct a a_v;
00096  *    will have two TYs of KIND_STRUCT. They will share FLDs, i.e., 
00097  *    their TY_flist will point to smae FLD. They will have same TY_name 
00098  *    (same pointer). TY_size and TY_align will be same. Only differences 
00099  *    will be in TY_is_volatile bit, TY_id, TY_tynum (used by mtob) and 
00100  *    TY_next (used for chaining TYs).
00101  *
00102  *  - Because More than one TYs may share TY_flist, mtob and btom have 
00103  *    been changed to maintain this sharing across .B file interface.
00104  *    Look at comment in mtob.c for important restrictions on how TY 
00105  *    records must be numbered.
00106  *
00107  *    The way Steve makes type records and the way I tran them, guarantees 
00108  *    that the non qualified versions of qualified TYs will always exist, 
00109  *    even if they are not used. However, at present there is no easy way 
00110  *    of finding the corresponding non-qualified versions of qualified 
00111  *    types or finding any qualified version of a non-qualified type. 
00112  *    In fact, given 'volatile int p; volatile int q;' Steve makes 
00113  *    two a_type records, one for p and one for q. I may do same. 
00114  *    Compilation of programs having const or volatile may get hit by 
00115  *    the cost of a search.
00116  *
00117  *    It is even more important to not compare TY pointers directly. 
00118  *
00119  *    Coffsdb is going to ignore all TY records having TY_is_volatile 
00120  *    or TY_is_const bit set. i.e., it is not going to dump them to .s 
00121  *    file. Since the TY_name of a qulified TY is same as the TY_name 
00122  *    of corresponding non-qualified TY, the assembler will make links 
00123  *    to the non qualified type.  Mtob will need to find 
00124  *    corresponding-non-qualified TYs for purpose of ordering TYs; for 
00125  *    now we do it the long way: searching through all exisiting types.
00126  *
00127  * ====================================================================
00128  */
00129 
00130 /* Given a qualified type, find a corresponding unqualified type: */
00131 extern TY *Find_Unqualified_Type ( TY * );
00132 
00133 /* Check whether two types are equivalent (similar). Two types are
00134  * equivalent (similar) if they are semantically identical (have the
00135  * same BE representation).  In particular:
00136  *  Two scalar types are equivalent (similar) if their btypes and sizes
00137  *      are the same. 
00138  *  Two pointer types are similar (equivalent) if their btypes are the
00139  *      same (and they point to equivalent types). 
00140  *  A scalar type and a pointer type with the same btype are treated as
00141  *      similar.
00142  *  Two array types are equivalent if their bounds are the same and 
00143  *      their elements are equivalent. 
00144  *  Two function types are equivalent if return equivalent types.
00145  *  Two struct or class types are equivalent only if their field lists
00146  *      are same-pointer, i.e. if TY_clist of the two are the identical
00147  *      pointers.
00148  *  Array, function, struct, and class types are never treated as
00149  *  similar.
00150  *
00151  * Additional qualifiers must match (or don't matter) depending on the
00152  * QUAL_CHECK parameter.  The options are:
00153  *      QUAL_IGNORE - no qualifiers (volatile, const, restrict,
00154  *                    is_character & is_logical) matter.
00155  *      QUAL_CONSIDER - only the volatile, const, restrict qualifiers
00156  *                      are tested and must be the same for the types
00157  *                      to match.
00158  *      QUAL_FULL - full front-end checking of all qualifiers is done
00159  *                  and must match for the types to be equivalent.
00160  *
00161  */
00162 typedef enum {
00163   QUAL_IGNORE   = 1,
00164   QUAL_CONSIDER = 2,
00165   QUAL_FULL     = 3
00166 } QUAL_CHECK;
00167 extern BOOL Equivalent_Types ( TY_IDX, TY_IDX, QUAL_CHECK );
00168 extern BOOL Similar_BE_Types ( TY_IDX, TY_IDX );
00169 
00170 /* records to keep track of typedef names for debug info */
00171 typedef struct tpdef {
00172   char *name; 
00173   TY   *type;
00174   struct tpdef *next;
00175   BOOL is_dumped;
00176 } TPDEF;
00177 
00178 #define TPDEF_name(t)  ((t)->name)
00179 #define TPDEF_type(t)  ((t)->type)
00180 #define TPDEF_next(t)  ((t)->next)
00181 #define TPDEF_is_dumped(t)  ((t)->is_dumped)
00182 
00183 extern TPDEF *Global_Tpdefs, *Local_Tpdefs;
00184 
00185 #define FOR_ALL_GLOBAL_TPDEFS(tp) \
00186         for ( tp = Global_Tpdefs; tp; tp = TPDEF_next(tp) )
00187 
00188 #ifdef __cplusplus
00189 }
00190 #endif
00191 #endif /* ttype_INCLUDED */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines