00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include <alloca.h>
00037 #include <stdio.h>
00038 #include <limits.h>
00039 #include <assert.h>
00040
00041 #include "ti_si.h"
00042 #include "ti_errors.h"
00043 #include "targ_isa_bundle.h"
00044 #include "ti_bundle.h"
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 BOOL TI_BUNDLE_Has_Property(
00056 TI_BUNDLE *bundle,
00057 ISA_EXEC_UNIT_PROPERTY property,
00058 INT *error
00059 )
00060 {
00061 INT i;
00062
00063 *error = TI_RC_OKAY;
00064
00065 if (bundle == NULL) {
00066 sprintf(TI_errmsg, "ISA_BUNDLE_INFO is empty");
00067 *error = TI_RC_ERROR;
00068 return FALSE;
00069 }
00070
00071 for (i = 0; i < TI_BUNDLE_slot_count(bundle); i++) {
00072 if (TI_BUNDLE_exec_property(bundle,i) & property)
00073 return TRUE;
00074 }
00075
00076 return FALSE;
00077 }
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087 BOOL TI_BUNDLE_Is_Full(
00088 TI_BUNDLE *bundle,
00089 INT *error
00090 )
00091 {
00092 INT i;
00093
00094 *error = TI_RC_OKAY;
00095
00096 if (bundle == NULL) {
00097 sprintf(TI_errmsg, "ISA_BUNDLE_INFO is empty");
00098 *error = TI_RC_ERROR;
00099 return FALSE;
00100 }
00101
00102 for (i = 0; i < TI_BUNDLE_slot_count(bundle); i++) {
00103 if (!TI_BUNDLE_slot_filled(bundle, i))
00104 return FALSE;
00105 }
00106
00107 return TRUE;
00108 }
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118 BOOL TI_BUNDLE_Is_Empty(
00119 TI_BUNDLE *bundle,
00120 INT *error
00121 )
00122 {
00123 INT i;
00124
00125 *error = TI_RC_OKAY;
00126
00127 if (bundle == NULL) {
00128 sprintf(TI_errmsg, "ISA_BUNDLE_INFO is empty");
00129 *error = TI_RC_ERROR;
00130 return FALSE;
00131 }
00132
00133 for (i = 0; i < TI_BUNDLE_slot_count(bundle); i++) {
00134 if (TI_BUNDLE_slot_filled(bundle, i))
00135 return FALSE;
00136 }
00137
00138 return TRUE;
00139 }
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149 INT TI_BUNDLE_Return_Template(
00150 TI_BUNDLE *bundle
00151 )
00152 {
00153 return TI_BUNDLE_pack_code(bundle);
00154 }
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164 void TI_BUNDLE_Clear(
00165 TI_BUNDLE *bundle
00166 )
00167 {
00168 INT i;
00169 for (i = 0; i < ISA_MAX_SLOTS; i++) {
00170 TI_BUNDLE_slot_filled(bundle, i) = 0;
00171 TI_BUNDLE_exec_property(bundle, i) = 0;
00172 TI_BUNDLE_stop_bit(bundle, i) = 0;
00173 }
00174
00175 Set_TI_BUNDLE_pack_code(bundle, 0);
00176 Set_TI_BUNDLE_stop_mask(bundle, 0x0);
00177 Set_TI_BUNDLE_slot_mask(bundle, 0x0);
00178 Set_TI_BUNDLE_slot_count(bundle, ISA_MAX_SLOTS);
00179
00180 }
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190 BOOL TI_BUNDLE_Slot_Available(
00191 TI_BUNDLE *bundle,
00192 ISA_EXEC_UNIT_PROPERTY property,
00193 INT slot
00194 )
00195 {
00196 INT i, j;
00197 ISA_EXEC_UNIT_PROPERTY slot_prop;
00198 BOOL match;
00199
00200
00201 if (slot >= ISA_MAX_SLOTS) return FALSE;
00202
00203
00204
00205
00206
00207
00208
00209
00210 #define SLOTS_COMPATIBLE(_prop, _bundle_index, _slot_index) \
00211 ((_prop == 0) || \
00212 ((_prop & ISA_EXEC_Slot_Prop(_bundle_index, _slot_index)) == \
00213 ISA_EXEC_Slot_Prop(_bundle_index, _slot_index)))
00214
00215
00216 for (i = 0; i < ISA_MAX_BUNDLES; ++i) {
00217 match = TRUE;
00218 for (j = 0; j < ISA_MAX_SLOTS; ++j) {
00219 slot_prop = (j == slot) ? property : TI_BUNDLE_exec_property(bundle, j);
00220 if ((j == slot) || TI_BUNDLE_slot_filled(bundle, j) ||
00221 TI_BUNDLE_stop_bit(bundle, j)) {
00222 if (!SLOTS_COMPATIBLE(slot_prop, i, j) ||
00223 (TI_BUNDLE_stop_bit(bundle, j) != ISA_EXEC_Stop(i, j))) {
00224 match = FALSE;
00225 break;
00226 }
00227 }
00228 }
00229 if (match) {
00230 Set_TI_BUNDLE_pack_code(bundle, i);
00231 return TRUE;
00232 }
00233 }
00234 return FALSE;
00235 }
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245 BOOL TI_BUNDLE_Stop_Bit_Available(
00246 TI_BUNDLE *bundle,
00247 INT slot
00248 )
00249 {
00250 INT i, j;
00251 ISA_EXEC_UNIT_PROPERTY slot_prop;
00252 BOOL stop_bit_value;
00253 BOOL match;
00254
00255
00256 if (slot >= ISA_MAX_SLOTS) return FALSE;
00257
00258
00259 for (i = 0; i < ISA_MAX_BUNDLES; ++i) {
00260 match = TRUE;
00261 for (j = 0; j < ISA_MAX_SLOTS; ++j) {
00262 stop_bit_value = (j == slot) ? TRUE : TI_BUNDLE_stop_bit(bundle, j);
00263 if (ISA_EXEC_Stop(i, j) != stop_bit_value) {
00264
00265 match = FALSE;
00266 break;
00267 } else if (TI_BUNDLE_slot_filled(bundle, j)) {
00268
00269 slot_prop = TI_BUNDLE_exec_property(bundle, j);
00270 if (!SLOTS_COMPATIBLE(slot_prop, i, j)) {
00271 match = FALSE;
00272 break;
00273 }
00274 }
00275 }
00276 if (match) {
00277 Set_TI_BUNDLE_pack_code(bundle, i);
00278 return TRUE;
00279 }
00280 }
00281 return FALSE;
00282 }
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292 void TI_BUNDLE_Reserve_Slot(
00293 TI_BUNDLE *bundle,
00294 INT slot,
00295 ISA_EXEC_UNIT_PROPERTY property
00296 )
00297 {
00298
00299 TI_BUNDLE_slot_filled(bundle, slot) = TRUE;
00300 Set_TI_BUNDLE_exec_property(bundle, slot, property);
00301 TI_BUNDLE_slot_mask(bundle) |= property <<
00302 (ISA_TAG_SHIFT * (ISA_MAX_SLOTS - slot - 1));
00303 }
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313 void TI_BUNDLE_Reserve_Stop_Bit(
00314 TI_BUNDLE *bundle,
00315 INT slot
00316 )
00317 {
00318 if (slot < 0 || slot > ISA_MAX_SLOTS) {
00319 fprintf(stderr,"TI_BUNDLE_Reserve_Stop_Bit: slot value not legal value \n");
00320 assert(FALSE);
00321 }
00322
00323 Set_TI_BUNDLE_stop_bit(bundle, slot, TRUE);
00324 }
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334 void TI_BUNDLE_Unreserve_Stop_Bit(
00335 TI_BUNDLE *bundle,
00336 INT slot
00337 )
00338 {
00339 if (slot < 0 || slot > ISA_MAX_SLOTS) {
00340 fprintf(stderr,"TI_BUNDLE_Reserve_Stop_Bit: slot value not legal value \n");
00341 assert(FALSE);
00342 }
00343
00344 Set_TI_BUNDLE_stop_bit(bundle, slot, FALSE);
00345 }