Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
ti_latency.c
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 #include <stdio.h>
00037 #include "ti_si.h"
00038 #include "targ_isa_properties.h"
00039 #include "targ_isa_hazards.h"
00040 #include "targ_isa_subset.h"
00041 #include "ti_errors.h"
00042 #include "ti_latency.h"
00043 
00044 
00045 /* ====================================================================
00046  *
00047  *  TI_LATENCY_Commit_Cycle
00048  *
00049  *  See interface description
00050  *
00051  *  If we are asking this question, we are asking it about a branch and we
00052  *  really just want to know if it has a delay slot (and how many).
00053  *  This allows for delay slot filling.
00054  *
00055  * ====================================================================
00056  */
00057 INT TI_LATENCY_Commit_Cycle(
00058   TOP opcode
00059 )
00060 {
00061   if ( opcode == TOP_intrncall ) return 1;
00062   if ( TOP_is_xfer(opcode) ) return 2;
00063   if ( TOP_is_select(opcode) && TOP_is_simulated(opcode) ) return 1;
00064   return 0;
00065 }
00066 
00067 /* ====================================================================
00068  *
00069  *  TI_LATENCY_Operand_Hazard
00070  *
00071  *  See interface description
00072  *
00073  * ====================================================================
00074  */
00075 INT TI_LATENCY_Operand_Hazard(
00076   TOP  opcode,
00077   INT *opnd,
00078   INT *error
00079 )
00080 {
00081   ISA_HAZARD_INFO *info;
00082   INT              ops = 0;
00083   *error = TI_RC_OKAY;
00084 
00085   for ( info = ISA_HAZARD_First(opcode);
00086         info != NULL;
00087         info = ISA_HAZARD_Next(info) 
00088   ) {
00089     if ( ISA_HAZARD_Type(info) == ISA_HAZARD_operand ) {
00090       INT this_ops;
00091       INT pre_ops  = ISA_HAZARD_Pre_Ops(info);
00092       INT post_ops = ISA_HAZARD_Post_Ops(info);
00093 
00094       if ( pre_ops ) {
00095         if (post_ops != 0) {
00096                 sprintf(TI_errmsg, "found both a pre- and post-hazard for %s",
00097                          TOP_Name(opcode));
00098                 *error = TI_RC_ERROR;
00099                 return 0;
00100         }
00101         this_ops = -pre_ops;
00102       } else if ( post_ops ) {
00103         this_ops = post_ops;
00104       } else {
00105         this_ops = 0;
00106       }
00107 
00108       if ( this_ops ) {
00109         if (ops != 0) {
00110                 sprintf(TI_errmsg, "multiple operand hazards for %s",
00111                          TOP_Name(opcode));
00112                 *error = TI_RC_ERROR;
00113                 return 0;
00114         }
00115         ops = this_ops;
00116         *opnd = ISA_HAZARD_Data(info);
00117       }
00118     }
00119   }
00120 
00121   return ops;
00122 }
00123 
00124 
00125 /* ====================================================================
00126  *
00127  *  TI_LATENCY_Result_Hazard
00128  *
00129  *  See interface description
00130  *
00131  * ====================================================================
00132  */
00133 INT TI_LATENCY_Result_Hazard(
00134   TOP opcode,
00135   INT *result,
00136   INT *error
00137 )
00138 {
00139   ISA_HAZARD_INFO *info;
00140   INT              ops = 0;
00141   *error = TI_RC_OKAY;
00142 
00143   for ( info = ISA_HAZARD_First(opcode);
00144         info != NULL;
00145         info = ISA_HAZARD_Next(info) 
00146   ) {
00147     if ( ISA_HAZARD_Type(info) == ISA_HAZARD_result ) {
00148       INT pre_ops  = ISA_HAZARD_Pre_Ops(info);
00149       INT post_ops = ISA_HAZARD_Post_Ops(info);
00150 
00151       if (pre_ops != 0) {
00152         sprintf(TI_errmsg, "found a result pre-hazard for %s",
00153                  TOP_Name(opcode));
00154         *error = TI_RC_ERROR;
00155         return 0;
00156       }
00157 
00158       if ( post_ops ) {
00159         if (ops != 0) {
00160                 sprintf(TI_errmsg, "multiple result hazards for %s",
00161                          TOP_Name(opcode));
00162                 *error = TI_RC_ERROR;
00163                 return 0;
00164         }
00165         ops = post_ops;
00166         *result = ISA_HAZARD_Data(info);
00167       }
00168     }
00169   }
00170 
00171   return ops;
00172 }
00173 
00174 
00175 /* ====================================================================
00176  *
00177  *  TI_LATENCY_Errata_Hazard
00178  *
00179  *  See interface description
00180  *
00181  * ====================================================================
00182  */
00183 INT TI_LATENCY_Errata_Hazard(
00184   TOP  opcode,
00185   INT *number,
00186   INT *error
00187 )
00188 {
00189   ISA_HAZARD_INFO *info;
00190   INT              ops = 0;
00191   *error = TI_RC_OKAY;
00192 
00193   for ( info = ISA_HAZARD_First(opcode);
00194         info != NULL;
00195         info = ISA_HAZARD_Next(info) 
00196   ) {
00197     if ( ISA_HAZARD_Type(info) == ISA_HAZARD_errata ) {
00198       INT pre_ops  = ISA_HAZARD_Pre_Ops(info);
00199       INT post_ops = ISA_HAZARD_Post_Ops(info);
00200 
00201       if (pre_ops != 0) {
00202         sprintf(TI_errmsg, "found an errata pre-hazard for %s",
00203                  TOP_Name(opcode));
00204         *error = TI_RC_ERROR;
00205         return 0;
00206       }
00207 
00208       if ( post_ops ) {
00209         if (ops != 0) {
00210                 sprintf(TI_errmsg, "multiple errata hazards for %s",
00211                          TOP_Name(opcode));
00212                 *error = TI_RC_ERROR;
00213                 return 0;
00214         }
00215         ops = post_ops;
00216         *number = ISA_HAZARD_Data(info);
00217       }
00218     }
00219   }
00220 
00221   return ops;
00222 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines