Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
cwh_preg.cxx
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 /* ====================================================================
00037  * ====================================================================
00038  *
00039  *
00040  * Revision history:
00041  *  dd-mmm-95 - Original Version
00042  *
00043  * Description: This file contains routines to provide pregs. 
00044  *              Copied from edwhirl.c, but later all the code to
00045  *              recycle pregs was removed.
00046  *
00047  * ====================================================================
00048  * ====================================================================
00049  */
00050 
00051 static char *source_file = __FILE__;
00052 
00053 #ifdef _KEEP_RCS_ID
00054 #endif /* _KEEP_RCS_ID */
00055 
00056 /* sgi includes */
00057 
00058 #include "defs.h" 
00059 #include "stab.h"
00060 #include "strtab.h"
00061 #include "wn.h"
00062 
00063 /* conversion removes */
00064 
00065 #include "cwh_defines.h"
00066 #include "cwh_preg.h"
00067 #include "cwh_addr.h"
00068 
00069 
00070 
00071 #define MTYPE_MAX MTYPE_V
00072 
00073 static TYPE_ID preg_ty_typeid[MTYPE_MAX];
00074 static TYPE_ID preg_bt_typeid[MTYPE_MAX];
00075 
00076 /*=============================================
00077  *
00078  * cwh_preg_next_preg
00079  * 
00080  * Get the next preg of the given MTYPE.
00081  *
00082  *=============================================
00083  */
00084 extern PREG_det
00085 cwh_preg_next_preg (TYPE_ID    btype,
00086                     char     * name,
00087                     WN       * home_wn )
00088 {
00089 
00090   PREG_det det ;
00091 
00092   DevAssert(((btype < MTYPE_MAX) && (btype > MTYPE_FIRST)),
00093             ("Missing mtype - 2")) ;
00094   
00095   det.preg_ty = Be_Type_Tbl(preg_ty_typeid[btype]) ;
00096   det.preg_st = MTYPE_To_PREG(preg_bt_typeid[btype]);
00097   det.preg    = Create_Preg (btype, name);
00098   
00099   return (det);
00100 } 
00101 
00102 /*=============================================
00103  *
00104  * cwh_preg_temp_save
00105  * 
00106  * Saves the given WN in a preg, whose type is
00107  * that of the expression, and returns a 
00108  * LDID of the preg. 
00109  *
00110  *=============================================
00111  */
00112 extern WN *
00113 cwh_preg_temp_save(char * name, WN  * expr )
00114 {
00115   TYPE_ID  bt;
00116   PREG_NUM pr;
00117   WN      *wn;
00118   
00119   bt = WNRTY(expr);
00120   pr = Create_Preg(bt,Index_To_Str(Save_Str(name)));
00121   cwh_addr_store_ST(MTYPE_To_PREG(bt), pr, 0, expr);
00122 
00123   wn = WN_LdidPreg(bt,pr);
00124   return wn;
00125 }
00126 
00127 /*=============================================
00128  *
00129  * fe_preg_init
00130  *
00131  * Set up preg tables.
00132  *
00133  *=============================================
00134  */
00135 extern void
00136 fe_preg_init (void)
00137 {
00138   int i ;
00139 
00140   for (i = 0 ; i < MTYPE_MAX ; i++ ) {
00141     preg_ty_typeid[i] = MTYPE_I4 ;   
00142     preg_bt_typeid[i] = MTYPE_I4 ;
00143   }
00144 
00145   preg_ty_typeid[MTYPE_I8] = MTYPE_I8 ;   preg_bt_typeid[MTYPE_I8] = MTYPE_I8 ;
00146 
00147   preg_ty_typeid[MTYPE_U1] = MTYPE_U4 ;   
00148   preg_ty_typeid[MTYPE_U2] = MTYPE_U4 ;   
00149   preg_ty_typeid[MTYPE_U4] = MTYPE_U4 ;   
00150   preg_ty_typeid[MTYPE_U8] = MTYPE_U8 ;   preg_bt_typeid[MTYPE_U8] = MTYPE_I8 ;
00151 
00152   preg_ty_typeid[MTYPE_F4] = MTYPE_F4 ;   preg_bt_typeid[MTYPE_F4] = MTYPE_F4 ;
00153   preg_ty_typeid[MTYPE_F8] = MTYPE_F8 ;   preg_bt_typeid[MTYPE_F8] = MTYPE_F8 ;
00154   preg_ty_typeid[MTYPE_FQ] = MTYPE_FQ ;   preg_bt_typeid[MTYPE_FQ] = MTYPE_FQ ;
00155 
00156   preg_ty_typeid[MTYPE_C4] = MTYPE_F4 ;   preg_bt_typeid[MTYPE_C4] = MTYPE_F4 ;
00157   preg_ty_typeid[MTYPE_C8] = MTYPE_F8 ;   preg_bt_typeid[MTYPE_C8] = MTYPE_F8 ;
00158   preg_ty_typeid[MTYPE_CQ] = MTYPE_FQ ;   preg_bt_typeid[MTYPE_CQ] = MTYPE_FQ ;
00159 
00160 
00161 } /* fe_preg_init */
00162 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines