1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205 |
- /* frv simulator fr500 dependent profiling code.
- Copyright (C) 1998-2015 Free Software Foundation, Inc.
- Contributed by Red Hat
- This file is part of the GNU simulators.
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- #define WANT_CPU
- #define WANT_CPU_FRVBF
- #include "sim-main.h"
- #include "bfd.h"
- #if WITH_PROFILE_MODEL_P
- #include "profile.h"
- #include "profile-fr500.h"
- /* Initialize cycle counting for an insn.
- FIRST_P is non-zero if this is the first insn in a set of parallel
- insns. */
- void
- fr500_model_insn_before (SIM_CPU *cpu, int first_p)
- {
- if (first_p)
- {
- MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
- FRV_PROFILE_STATE *ps = CPU_PROFILE_STATE (cpu);
- ps->cur_gr_complex = ps->prev_gr_complex;
- d->cur_fpop = d->prev_fpop;
- d->cur_media = d->prev_media;
- d->cur_cc_complex = d->prev_cc_complex;
- }
- }
- /* Record the cycles computed for an insn.
- LAST_P is non-zero if this is the last insn in a set of parallel insns,
- and we update the total cycle count.
- CYCLES is the cycle count of the insn. */
- void
- fr500_model_insn_after (SIM_CPU *cpu, int last_p, int cycles)
- {
- if (last_p)
- {
- MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
- FRV_PROFILE_STATE *ps = CPU_PROFILE_STATE (cpu);
- ps->prev_gr_complex = ps->cur_gr_complex;
- d->prev_fpop = d->cur_fpop;
- d->prev_media = d->cur_media;
- d->prev_cc_complex = d->cur_cc_complex;
- }
- }
- static void
- set_use_is_fpop (SIM_CPU *cpu, INT fr)
- {
- MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
- fr500_reset_fr_flags (cpu, (fr));
- d->cur_fpop |= (((DI)1) << (fr));
- }
- static void
- set_use_not_fpop (SIM_CPU *cpu, INT fr)
- {
- MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
- d->cur_fpop &= ~(((DI)1) << (fr));
- }
- static int
- use_is_fpop (SIM_CPU *cpu, INT fr)
- {
- MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
- return d->prev_fpop & (((DI)1) << (fr));
- }
- static void
- set_use_is_media ( SIM_CPU *cpu, INT fr)
- {
- MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
- fr500_reset_fr_flags (cpu, (fr));
- d->cur_media |= (((DI)1) << (fr));
- }
- static void
- set_use_not_media (SIM_CPU *cpu, INT fr)
- {
- MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
- d->cur_media &= ~(((DI)1) << (fr));
- }
- static int
- use_is_media (SIM_CPU *cpu, INT fr)
- {
- MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
- return d->prev_media & (((DI)1) << (fr));
- }
- static void
- set_use_is_cc_complex (SIM_CPU *cpu, INT cc)
- {
- MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
- fr500_reset_cc_flags (cpu, cc);
- d->cur_cc_complex |= (((DI)1) << (cc));
- }
- static void
- set_use_not_cc_complex (SIM_CPU *cpu, INT cc)
- {
- MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
- d->cur_cc_complex &= ~(((DI)1) << (cc));
- }
- static int
- use_is_cc_complex (SIM_CPU *cpu, INT cc)
- {
- MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
- return d->prev_cc_complex & (((DI)1) << (cc));
- }
- void
- fr500_reset_fr_flags (SIM_CPU *cpu, INT fr)
- {
- set_use_not_fpop (cpu, fr);
- set_use_not_media (cpu, fr);
- }
- void
- fr500_reset_cc_flags (SIM_CPU *cpu, INT cc)
- {
- set_use_not_cc_complex (cpu, cc);
- }
- /* Latency of floating point registers may be less than recorded when followed
- by another floating point insn. */
- static void
- adjust_float_register_busy (SIM_CPU *cpu, INT in_FRi, INT in_FRj, INT out_FRk,
- int cycles)
- {
- /* If the registers were previously used in a floating point op,
- then their latency will be less than previously recorded.
- See Table 13-13 in the LSI. */
- if (in_FRi >= 0)
- if (use_is_fpop (cpu, in_FRi))
- decrease_FR_busy (cpu, in_FRi, cycles);
- else
- enforce_full_fr_latency (cpu, in_FRi);
-
- if (in_FRj >= 0 && in_FRj != in_FRi)
- if (use_is_fpop (cpu, in_FRj))
- decrease_FR_busy (cpu, in_FRj, cycles);
- else
- enforce_full_fr_latency (cpu, in_FRj);
- if (out_FRk >= 0 && out_FRk != in_FRi && out_FRk != in_FRj)
- if (use_is_fpop (cpu, out_FRk))
- decrease_FR_busy (cpu, out_FRk, cycles);
- else
- enforce_full_fr_latency (cpu, out_FRk);
- }
- /* Latency of floating point registers may be less than recorded when followed
- by another floating point insn. */
- static void
- adjust_double_register_busy (SIM_CPU *cpu, INT in_FRi, INT in_FRj, INT out_FRk,
- int cycles)
- {
- /* If the registers were previously used in a floating point op,
- then their latency will be less than previously recorded.
- See Table 13-13 in the LSI. */
- adjust_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, cycles);
- if (in_FRi >= 0) ++in_FRi;
- if (in_FRj >= 0) ++in_FRj;
- if (out_FRk >= 0) ++out_FRk;
- adjust_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, cycles);
- }
- /* Latency of floating point registers is less than recorded when followed
- by another floating point insn. */
- static void
- restore_float_register_busy (SIM_CPU *cpu, INT in_FRi, INT in_FRj, INT out_FRk,
- int cycles)
- {
- /* If the registers were previously used in a floating point op,
- then their latency will be less than previously recorded.
- See Table 13-13 in the LSI. */
- if (in_FRi >= 0 && use_is_fpop (cpu, in_FRi))
- increase_FR_busy (cpu, in_FRi, cycles);
- if (in_FRj != in_FRi && use_is_fpop (cpu, in_FRj))
- increase_FR_busy (cpu, in_FRj, cycles);
- if (out_FRk != in_FRi && out_FRk != in_FRj && use_is_fpop (cpu, out_FRk))
- increase_FR_busy (cpu, out_FRk, cycles);
- }
- /* Latency of floating point registers is less than recorded when followed
- by another floating point insn. */
- static void
- restore_double_register_busy (SIM_CPU *cpu, INT in_FRi, INT in_FRj, INT out_FRk,
- int cycles)
- {
- /* If the registers were previously used in a floating point op,
- then their latency will be less than previously recorded.
- See Table 13-13 in the LSI. */
- restore_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, cycles);
- if (in_FRi >= 0) ++in_FRi;
- if (in_FRj >= 0) ++in_FRj;
- if (out_FRk >= 0) ++out_FRk;
- restore_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, cycles);
- }
- int
- frvbf_model_fr500_u_exec (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced)
- {
- return idesc->timing->units[unit_num].done;
- }
- int
- frvbf_model_fr500_u_integer (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_GRi, INT in_GRj, INT out_GRk,
- INT out_ICCi_1)
- {
- int cycles;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- {
- /* icc0-icc4 are the upper 4 fields of the CCR. */
- if (out_ICCi_1 >= 0)
- out_ICCi_1 += 4;
- /* The entire VLIW insn must wait if there is a dependency on a register
- which is not ready yet.
- The latency of the registers may be less than previously recorded,
- depending on how they were used previously.
- See Table 13-8 in the LSI. */
- if (in_GRi != out_GRk && in_GRi >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRi))
- decrease_GR_busy (cpu, in_GRi, 1);
- }
- if (in_GRj != out_GRk && in_GRj != in_GRi && in_GRj >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRj))
- decrease_GR_busy (cpu, in_GRj, 1);
- }
- vliw_wait_for_GR (cpu, in_GRi);
- vliw_wait_for_GR (cpu, in_GRj);
- vliw_wait_for_GR (cpu, out_GRk);
- vliw_wait_for_CCR (cpu, out_ICCi_1);
- handle_resource_wait (cpu);
- load_wait_for_GR (cpu, in_GRi);
- load_wait_for_GR (cpu, in_GRj);
- load_wait_for_GR (cpu, out_GRk);
- trace_vliw_wait_cycles (cpu);
- return 0;
- }
- /* GRk is available immediately to the next VLIW insn as is ICCi_1. */
- cycles = idesc->timing->units[unit_num].done;
- return cycles;
- }
- int
- frvbf_model_fr500_u_imul (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_GRi, INT in_GRj, INT out_GRk, INT out_ICCi_1)
- {
- int cycles;
- /* icc0-icc4 are the upper 4 fields of the CCR. */
- if (out_ICCi_1 >= 0)
- out_ICCi_1 += 4;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- {
- /* The entire VLIW insn must wait if there is a dependency on a register
- which is not ready yet.
- The latency of the registers may be less than previously recorded,
- depending on how they were used previously.
- See Table 13-8 in the LSI. */
- if (in_GRi != out_GRk && in_GRi >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRi))
- decrease_GR_busy (cpu, in_GRi, 1);
- }
- if (in_GRj != out_GRk && in_GRj != in_GRi && in_GRj >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRj))
- decrease_GR_busy (cpu, in_GRj, 1);
- }
- vliw_wait_for_GR (cpu, in_GRi);
- vliw_wait_for_GR (cpu, in_GRj);
- vliw_wait_for_GRdouble (cpu, out_GRk);
- vliw_wait_for_CCR (cpu, out_ICCi_1);
- handle_resource_wait (cpu);
- load_wait_for_GR (cpu, in_GRi);
- load_wait_for_GR (cpu, in_GRj);
- load_wait_for_GRdouble (cpu, out_GRk);
- trace_vliw_wait_cycles (cpu);
- return 0;
- }
- /* GRk has a latency of 2 cycles. */
- cycles = idesc->timing->units[unit_num].done;
- update_GRdouble_latency (cpu, out_GRk, cycles + 2);
- set_use_is_gr_complex (cpu, out_GRk);
- set_use_is_gr_complex (cpu, out_GRk + 1);
- /* ICCi_1 has a latency of 1 cycle. */
- update_CCR_latency (cpu, out_ICCi_1, cycles + 1);
- return cycles;
- }
- int
- frvbf_model_fr500_u_idiv (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_GRi, INT in_GRj, INT out_GRk, INT out_ICCi_1)
- {
- int cycles;
- FRV_VLIW *vliw;
- int slot;
- /* icc0-icc4 are the upper 4 fields of the CCR. */
- if (out_ICCi_1 >= 0)
- out_ICCi_1 += 4;
- vliw = CPU_VLIW (cpu);
- slot = vliw->next_slot - 1;
- slot = (*vliw->current_vliw)[slot] - UNIT_I0;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- {
- /* The entire VLIW insn must wait if there is a dependency on a register
- which is not ready yet.
- The latency of the registers may be less than previously recorded,
- depending on how they were used previously.
- See Table 13-8 in the LSI. */
- if (in_GRi != out_GRk && in_GRi >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRi))
- decrease_GR_busy (cpu, in_GRi, 1);
- }
- if (in_GRj != out_GRk && in_GRj != in_GRi && in_GRj >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRj))
- decrease_GR_busy (cpu, in_GRj, 1);
- }
- vliw_wait_for_GR (cpu, in_GRi);
- vliw_wait_for_GR (cpu, in_GRj);
- vliw_wait_for_GR (cpu, out_GRk);
- vliw_wait_for_CCR (cpu, out_ICCi_1);
- vliw_wait_for_idiv_resource (cpu, slot);
- handle_resource_wait (cpu);
- load_wait_for_GR (cpu, in_GRi);
- load_wait_for_GR (cpu, in_GRj);
- load_wait_for_GR (cpu, out_GRk);
- trace_vliw_wait_cycles (cpu);
- return 0;
- }
- /* GRk has a latency of 19 cycles! */
- cycles = idesc->timing->units[unit_num].done;
- update_GR_latency (cpu, out_GRk, cycles + 19);
- set_use_is_gr_complex (cpu, out_GRk);
- /* ICCi_1 has a latency of 19 cycles. */
- update_CCR_latency (cpu, out_ICCi_1, cycles + 19);
- set_use_is_cc_complex (cpu, out_ICCi_1);
- if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
- {
- /* GNER has a latency of 18 cycles. */
- update_SPR_latency (cpu, GNER_FOR_GR (out_GRk), cycles + 18);
- }
- /* the idiv resource has a latency of 18 cycles! */
- update_idiv_resource_latency (cpu, slot, cycles + 18);
- return cycles;
- }
- int
- frvbf_model_fr500_u_branch (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_GRi, INT in_GRj,
- INT in_ICCi_2, INT in_FCCi_2)
- {
- int cycles;
- FRV_PROFILE_STATE *ps;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- {
- /* icc0-icc4 are the upper 4 fields of the CCR. */
- if (in_ICCi_2 >= 0)
- in_ICCi_2 += 4;
- /* The entire VLIW insn must wait if there is a dependency on a register
- which is not ready yet.
- The latency of the registers may be less than previously recorded,
- depending on how they were used previously.
- See Table 13-8 in the LSI. */
- if (in_GRi >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRi))
- decrease_GR_busy (cpu, in_GRi, 1);
- }
- if (in_GRj != in_GRi && in_GRj >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRj))
- decrease_GR_busy (cpu, in_GRj, 1);
- }
- vliw_wait_for_GR (cpu, in_GRi);
- vliw_wait_for_GR (cpu, in_GRj);
- vliw_wait_for_CCR (cpu, in_ICCi_2);
- vliw_wait_for_CCR (cpu, in_FCCi_2);
- handle_resource_wait (cpu);
- load_wait_for_GR (cpu, in_GRi);
- load_wait_for_GR (cpu, in_GRj);
- trace_vliw_wait_cycles (cpu);
- return 0;
- }
- /* When counting branches taken or not taken, don't consider branches after
- the first taken branch in a vliw insn. */
- ps = CPU_PROFILE_STATE (cpu);
- if (! ps->vliw_branch_taken)
- {
- /* (1 << 4): The pc is the 5th element in inputs, outputs.
- ??? can be cleaned up */
- PROFILE_DATA *p = CPU_PROFILE_DATA (cpu);
- int taken = (referenced & (1 << 4)) != 0;
- if (taken)
- {
- ++PROFILE_MODEL_TAKEN_COUNT (p);
- ps->vliw_branch_taken = 1;
- }
- else
- ++PROFILE_MODEL_UNTAKEN_COUNT (p);
- }
- cycles = idesc->timing->units[unit_num].done;
- return cycles;
- }
- int
- frvbf_model_fr500_u_trap (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_GRi, INT in_GRj,
- INT in_ICCi_2, INT in_FCCi_2)
- {
- int cycles;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- {
- /* icc0-icc4 are the upper 4 fields of the CCR. */
- if (in_ICCi_2 >= 0)
- in_ICCi_2 += 4;
- /* The entire VLIW insn must wait if there is a dependency on a register
- which is not ready yet.
- The latency of the registers may be less than previously recorded,
- depending on how they were used previously.
- See Table 13-8 in the LSI. */
- if (in_GRi >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRi))
- decrease_GR_busy (cpu, in_GRi, 1);
- }
- if (in_GRj != in_GRi && in_GRj >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRj))
- decrease_GR_busy (cpu, in_GRj, 1);
- }
- vliw_wait_for_GR (cpu, in_GRi);
- vliw_wait_for_GR (cpu, in_GRj);
- vliw_wait_for_CCR (cpu, in_ICCi_2);
- vliw_wait_for_CCR (cpu, in_FCCi_2);
- handle_resource_wait (cpu);
- load_wait_for_GR (cpu, in_GRi);
- load_wait_for_GR (cpu, in_GRj);
- trace_vliw_wait_cycles (cpu);
- return 0;
- }
- cycles = idesc->timing->units[unit_num].done;
- return cycles;
- }
- int
- frvbf_model_fr500_u_check (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_ICCi_3, INT in_FCCi_3)
- {
- int cycles;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- {
- /* icc0-icc4 are the upper 4 fields of the CCR. */
- if (in_ICCi_3 >= 0)
- in_ICCi_3 += 4;
- /* The entire VLIW insn must wait if there is a dependency on a register
- which is not ready yet. */
- vliw_wait_for_CCR (cpu, in_ICCi_3);
- vliw_wait_for_CCR (cpu, in_FCCi_3);
- handle_resource_wait (cpu);
- trace_vliw_wait_cycles (cpu);
- return 0;
- }
- cycles = idesc->timing->units[unit_num].done;
- return cycles;
- }
- int
- frvbf_model_fr500_u_clrgr (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_GRk)
- {
- int cycles;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- {
- /* Wait for both GNER registers or just the one specified. */
- if (in_GRk == -1)
- {
- vliw_wait_for_SPR (cpu, H_SPR_GNER0);
- vliw_wait_for_SPR (cpu, H_SPR_GNER1);
- }
- else
- vliw_wait_for_SPR (cpu, GNER_FOR_GR (in_GRk));
- handle_resource_wait (cpu);
- trace_vliw_wait_cycles (cpu);
- return 0;
- }
- cycles = idesc->timing->units[unit_num].done;
- return cycles;
- }
- int
- frvbf_model_fr500_u_clrfr (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_FRk)
- {
- int cycles;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- {
- /* Wait for both GNER registers or just the one specified. */
- if (in_FRk == -1)
- {
- vliw_wait_for_SPR (cpu, H_SPR_FNER0);
- vliw_wait_for_SPR (cpu, H_SPR_FNER1);
- }
- else
- vliw_wait_for_SPR (cpu, FNER_FOR_FR (in_FRk));
- handle_resource_wait (cpu);
- trace_vliw_wait_cycles (cpu);
- return 0;
- }
- cycles = idesc->timing->units[unit_num].done;
- return cycles;
- }
- int
- frvbf_model_fr500_u_commit (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_GRk, INT in_FRk)
- {
- int cycles;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- {
- /* If GR is specified, then FR is not and vice-versa. If neither is
- then it's a commitga or commitfa. Check the insn attribute to
- figure out which. */
- if (in_GRk != -1)
- vliw_wait_for_SPR (cpu, GNER_FOR_GR (in_GRk));
- else if (in_FRk != -1)
- vliw_wait_for_SPR (cpu, FNER_FOR_FR (in_FRk));
- else if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_FR_ACCESS))
- {
- vliw_wait_for_SPR (cpu, H_SPR_FNER0);
- vliw_wait_for_SPR (cpu, H_SPR_FNER1);
- }
- else
- {
- vliw_wait_for_SPR (cpu, H_SPR_GNER0);
- vliw_wait_for_SPR (cpu, H_SPR_GNER1);
- }
- handle_resource_wait (cpu);
- trace_vliw_wait_cycles (cpu);
- return 0;
- }
- cycles = idesc->timing->units[unit_num].done;
- return cycles;
- }
- int
- frvbf_model_fr500_u_set_hilo (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT out_GRkhi, INT out_GRklo)
- {
- int cycles;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- {
- /* The entire VLIW insn must wait if there is a dependency on a GR
- which is not ready yet. */
- vliw_wait_for_GR (cpu, out_GRkhi);
- vliw_wait_for_GR (cpu, out_GRklo);
- handle_resource_wait (cpu);
- load_wait_for_GR (cpu, out_GRkhi);
- load_wait_for_GR (cpu, out_GRklo);
- trace_vliw_wait_cycles (cpu);
- return 0;
- }
- /* GRk is available immediately to the next VLIW insn. */
- cycles = idesc->timing->units[unit_num].done;
- set_use_not_gr_complex (cpu, out_GRkhi);
- set_use_not_gr_complex (cpu, out_GRklo);
- return cycles;
- }
- int
- frvbf_model_fr500_u_gr_load (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_GRi, INT in_GRj,
- INT out_GRk, INT out_GRdoublek)
- {
- int cycles;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- {
- /* The entire VLIW insn must wait if there is a dependency on a register
- which is not ready yet.
- The latency of the registers may be less than previously recorded,
- depending on how they were used previously.
- See Table 13-8 in the LSI. */
- if (in_GRi != out_GRk && in_GRi != out_GRdoublek
- && in_GRi != out_GRdoublek + 1 && in_GRi >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRi))
- decrease_GR_busy (cpu, in_GRi, 1);
- }
- if (in_GRj != in_GRi && in_GRj != out_GRk && in_GRj != out_GRdoublek
- && in_GRj != out_GRdoublek + 1 && in_GRj >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRj))
- decrease_GR_busy (cpu, in_GRj, 1);
- }
- vliw_wait_for_GR (cpu, in_GRi);
- vliw_wait_for_GR (cpu, in_GRj);
- vliw_wait_for_GR (cpu, out_GRk);
- vliw_wait_for_GRdouble (cpu, out_GRdoublek);
- handle_resource_wait (cpu);
- load_wait_for_GR (cpu, in_GRi);
- load_wait_for_GR (cpu, in_GRj);
- load_wait_for_GR (cpu, out_GRk);
- load_wait_for_GRdouble (cpu, out_GRdoublek);
- trace_vliw_wait_cycles (cpu);
- return 0;
- }
- cycles = idesc->timing->units[unit_num].done;
- /* The latency of GRk for a load will depend on how long it takes to retrieve
- the the data from the cache or memory. */
- update_GR_latency_for_load (cpu, out_GRk, cycles);
- update_GRdouble_latency_for_load (cpu, out_GRdoublek, cycles);
- if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
- {
- /* GNER has a latency of 2 cycles. */
- update_SPR_latency (cpu, GNER_FOR_GR (out_GRk), cycles + 2);
- update_SPR_latency (cpu, GNER_FOR_GR (out_GRdoublek), cycles + 2);
- }
- if (out_GRk >= 0)
- set_use_is_gr_complex (cpu, out_GRk);
- if (out_GRdoublek != -1)
- {
- set_use_is_gr_complex (cpu, out_GRdoublek);
- set_use_is_gr_complex (cpu, out_GRdoublek + 1);
- }
- return cycles;
- }
- int
- frvbf_model_fr500_u_gr_store (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_GRi, INT in_GRj,
- INT in_GRk, INT in_GRdoublek)
- {
- int cycles;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- {
- /* The entire VLIW insn must wait if there is a dependency on a register
- which is not ready yet.
- The latency of the registers may be less than previously recorded,
- depending on how they were used previously.
- See Table 13-8 in the LSI. */
- if (in_GRi >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRi))
- decrease_GR_busy (cpu, in_GRi, 1);
- }
- if (in_GRj != in_GRi && in_GRj >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRj))
- decrease_GR_busy (cpu, in_GRj, 1);
- }
- if (in_GRk != in_GRi && in_GRk != in_GRj && in_GRk >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRk))
- decrease_GR_busy (cpu, in_GRk, 1);
- }
- if (in_GRdoublek != in_GRi && in_GRdoublek != in_GRj
- && in_GRdoublek + 1 != in_GRi && in_GRdoublek + 1 != in_GRj
- && in_GRdoublek >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRdoublek))
- decrease_GR_busy (cpu, in_GRdoublek, 1);
- if (use_is_gr_complex (cpu, in_GRdoublek + 1))
- decrease_GR_busy (cpu, in_GRdoublek + 1, 1);
- }
- vliw_wait_for_GR (cpu, in_GRi);
- vliw_wait_for_GR (cpu, in_GRj);
- vliw_wait_for_GR (cpu, in_GRk);
- vliw_wait_for_GRdouble (cpu, in_GRdoublek);
- handle_resource_wait (cpu);
- load_wait_for_GR (cpu, in_GRi);
- load_wait_for_GR (cpu, in_GRj);
- load_wait_for_GR (cpu, in_GRk);
- load_wait_for_GRdouble (cpu, in_GRdoublek);
- trace_vliw_wait_cycles (cpu);
- return 0;
- }
- cycles = idesc->timing->units[unit_num].done;
- return cycles;
- }
- int
- frvbf_model_fr500_u_gr_r_store (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_GRi, INT in_GRj,
- INT in_GRk, INT in_GRdoublek)
- {
- int cycles = frvbf_model_fr500_u_gr_store (cpu, idesc, unit_num, referenced,
- in_GRi, in_GRj, in_GRk,
- in_GRdoublek);
- if (model_insn == FRV_INSN_MODEL_PASS_2)
- {
- if (CPU_RSTR_INVALIDATE(cpu))
- request_cache_invalidate (cpu, CPU_DATA_CACHE (cpu), cycles);
- }
- return cycles;
- }
- int
- frvbf_model_fr500_u_fr_load (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_GRi, INT in_GRj,
- INT out_FRk, INT out_FRdoublek)
- {
- int cycles;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- {
- /* The entire VLIW insn must wait if there is a dependency on a register
- which is not ready yet.
- The latency of the registers may be less than previously recorded,
- depending on how they were used previously.
- See Table 13-8 in the LSI. */
- if (in_GRi >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRi))
- decrease_GR_busy (cpu, in_GRi, 1);
- }
- if (in_GRj != in_GRi && in_GRj >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRj))
- decrease_GR_busy (cpu, in_GRj, 1);
- }
- if (out_FRk >= 0)
- {
- if (use_is_media (cpu, out_FRk))
- decrease_FR_busy (cpu, out_FRk, 1);
- else
- adjust_float_register_busy (cpu, -1, -1, out_FRk, 1);
- }
- if (out_FRdoublek >= 0)
- {
- if (use_is_media (cpu, out_FRdoublek))
- decrease_FR_busy (cpu, out_FRdoublek, 1);
- else
- adjust_float_register_busy (cpu, -1, -1, out_FRdoublek, 1);
- if (use_is_media (cpu, out_FRdoublek + 1))
- decrease_FR_busy (cpu, out_FRdoublek + 1, 1);
- else
- adjust_float_register_busy (cpu, -1, -1, out_FRdoublek + 1, 1);
- }
- vliw_wait_for_GR (cpu, in_GRi);
- vliw_wait_for_GR (cpu, in_GRj);
- vliw_wait_for_FR (cpu, out_FRk);
- vliw_wait_for_FRdouble (cpu, out_FRdoublek);
- if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
- {
- vliw_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
- vliw_wait_for_SPR (cpu, FNER_FOR_FR (out_FRdoublek));
- }
- handle_resource_wait (cpu);
- load_wait_for_GR (cpu, in_GRi);
- load_wait_for_GR (cpu, in_GRj);
- load_wait_for_FR (cpu, out_FRk);
- load_wait_for_FRdouble (cpu, out_FRdoublek);
- trace_vliw_wait_cycles (cpu);
- return 0;
- }
- cycles = idesc->timing->units[unit_num].done;
- /* The latency of FRk for a load will depend on how long it takes to retrieve
- the the data from the cache or memory. */
- update_FR_latency_for_load (cpu, out_FRk, cycles);
- update_FRdouble_latency_for_load (cpu, out_FRdoublek, cycles);
- if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
- {
- /* FNER has a latency of 3 cycles. */
- update_SPR_latency (cpu, FNER_FOR_FR (out_FRk), cycles + 3);
- update_SPR_latency (cpu, FNER_FOR_FR (out_FRdoublek), cycles + 3);
- }
- fr500_reset_fr_flags (cpu, out_FRk);
- return cycles;
- }
- int
- frvbf_model_fr500_u_fr_store (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_GRi, INT in_GRj,
- INT in_FRk, INT in_FRdoublek)
- {
- int cycles;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- {
- /* The entire VLIW insn must wait if there is a dependency on a register
- which is not ready yet.
- The latency of the registers may be less than previously recorded,
- depending on how they were used previously.
- See Table 13-8 in the LSI. */
- if (in_GRi >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRi))
- decrease_GR_busy (cpu, in_GRi, 1);
- }
- if (in_GRj != in_GRi && in_GRj >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRj))
- decrease_GR_busy (cpu, in_GRj, 1);
- }
- if (in_FRk >= 0)
- {
- if (use_is_media (cpu, in_FRk))
- decrease_FR_busy (cpu, in_FRk, 1);
- else
- adjust_float_register_busy (cpu, -1, -1, in_FRk, 1);
- }
- if (in_FRdoublek >= 0)
- {
- if (use_is_media (cpu, in_FRdoublek))
- decrease_FR_busy (cpu, in_FRdoublek, 1);
- else
- adjust_float_register_busy (cpu, -1, -1, in_FRdoublek, 1);
- if (use_is_media (cpu, in_FRdoublek + 1))
- decrease_FR_busy (cpu, in_FRdoublek + 1, 1);
- else
- adjust_float_register_busy (cpu, -1, -1, in_FRdoublek + 1, 1);
- }
- vliw_wait_for_GR (cpu, in_GRi);
- vliw_wait_for_GR (cpu, in_GRj);
- vliw_wait_for_FR (cpu, in_FRk);
- vliw_wait_for_FRdouble (cpu, in_FRdoublek);
- handle_resource_wait (cpu);
- load_wait_for_GR (cpu, in_GRi);
- load_wait_for_GR (cpu, in_GRj);
- load_wait_for_FR (cpu, in_FRk);
- load_wait_for_FRdouble (cpu, in_FRdoublek);
- trace_vliw_wait_cycles (cpu);
- return 0;
- }
- cycles = idesc->timing->units[unit_num].done;
- return cycles;
- }
- int
- frvbf_model_fr500_u_fr_r_store (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_GRi, INT in_GRj,
- INT in_FRk, INT in_FRdoublek)
- {
- int cycles = frvbf_model_fr500_u_fr_store (cpu, idesc, unit_num, referenced,
- in_GRi, in_GRj, in_FRk,
- in_FRdoublek);
- if (model_insn == FRV_INSN_MODEL_PASS_2)
- {
- if (CPU_RSTR_INVALIDATE(cpu))
- request_cache_invalidate (cpu, CPU_DATA_CACHE (cpu), cycles);
- }
- return cycles;
- }
- int
- frvbf_model_fr500_u_swap (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_GRi, INT in_GRj, INT out_GRk)
- {
- int cycles;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- {
- /* The entire VLIW insn must wait if there is a dependency on a register
- which is not ready yet.
- The latency of the registers may be less than previously recorded,
- depending on how they were used previously.
- See Table 13-8 in the LSI. */
- if (in_GRi != out_GRk && in_GRi >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRi))
- decrease_GR_busy (cpu, in_GRi, 1);
- }
- if (in_GRj != out_GRk && in_GRj != in_GRi && in_GRj >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRj))
- decrease_GR_busy (cpu, in_GRj, 1);
- }
- vliw_wait_for_GR (cpu, in_GRi);
- vliw_wait_for_GR (cpu, in_GRj);
- vliw_wait_for_GR (cpu, out_GRk);
- handle_resource_wait (cpu);
- load_wait_for_GR (cpu, in_GRi);
- load_wait_for_GR (cpu, in_GRj);
- load_wait_for_GR (cpu, out_GRk);
- trace_vliw_wait_cycles (cpu);
- return 0;
- }
- cycles = idesc->timing->units[unit_num].done;
- /* The latency of GRk will depend on how long it takes to swap
- the the data from the cache or memory. */
- update_GR_latency_for_swap (cpu, out_GRk, cycles);
- set_use_is_gr_complex (cpu, out_GRk);
- return cycles;
- }
- int
- frvbf_model_fr500_u_fr2fr (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_FRj, INT out_FRk)
- {
- int cycles;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- {
- /* The entire VLIW insn must wait if there is a dependency on a register
- which is not ready yet. */
- if (in_FRj >= 0)
- {
- if (use_is_media (cpu, in_FRj))
- decrease_FR_busy (cpu, in_FRj, 1);
- else
- adjust_float_register_busy (cpu, -1, in_FRj, -1, 1);
- }
- if (out_FRk >= 0 && out_FRk != in_FRj)
- {
- if (use_is_media (cpu, out_FRk))
- decrease_FR_busy (cpu, out_FRk, 1);
- else
- adjust_float_register_busy (cpu, -1, -1, out_FRk, 1);
- }
- vliw_wait_for_FR (cpu, in_FRj);
- vliw_wait_for_FR (cpu, out_FRk);
- handle_resource_wait (cpu);
- load_wait_for_FR (cpu, in_FRj);
- load_wait_for_FR (cpu, out_FRk);
- trace_vliw_wait_cycles (cpu);
- return 0;
- }
- /* The latency of FRj is 3 cycles. */
- cycles = idesc->timing->units[unit_num].done;
- update_FR_latency (cpu, out_FRk, cycles + 3);
- return cycles;
- }
- int
- frvbf_model_fr500_u_fr2gr (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_FRk, INT out_GRj)
- {
- int cycles;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- {
- /* The entire VLIW insn must wait if there is a dependency on a register
- which is not ready yet. */
- if (in_FRk >= 0)
- {
- if (use_is_media (cpu, in_FRk))
- decrease_FR_busy (cpu, in_FRk, 1);
- else
- adjust_float_register_busy (cpu, -1, in_FRk, -1, 1);
- }
- vliw_wait_for_FR (cpu, in_FRk);
- vliw_wait_for_GR (cpu, out_GRj);
- handle_resource_wait (cpu);
- load_wait_for_FR (cpu, in_FRk);
- load_wait_for_GR (cpu, out_GRj);
- trace_vliw_wait_cycles (cpu);
- return 0;
- }
- /* The latency of GRj is 2 cycles. */
- cycles = idesc->timing->units[unit_num].done;
- update_GR_latency (cpu, out_GRj, cycles + 2);
- set_use_is_gr_complex (cpu, out_GRj);
- return cycles;
- }
- int
- frvbf_model_fr500_u_spr2gr (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_spr, INT out_GRj)
- {
- int cycles;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- {
- /* The entire VLIW insn must wait if there is a dependency on a register
- which is not ready yet. */
- vliw_wait_for_SPR (cpu, in_spr);
- vliw_wait_for_GR (cpu, out_GRj);
- handle_resource_wait (cpu);
- load_wait_for_GR (cpu, out_GRj);
- trace_vliw_wait_cycles (cpu);
- return 0;
- }
- cycles = idesc->timing->units[unit_num].done;
- #if 0 /* no latency? */
- /* The latency of GRj is 2 cycles. */
- update_GR_latency (cpu, out_GRj, cycles + 2);
- #endif
- return cycles;
- }
- int
- frvbf_model_fr500_u_gr2fr (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_GRj, INT out_FRk)
- {
- int cycles;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- {
- /* The entire VLIW insn must wait if there is a dependency on a register
- which is not ready yet.
- The latency of the registers may be less than previously recorded,
- depending on how they were used previously.
- See Table 13-8 in the LSI. */
- if (in_GRj >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRj))
- decrease_GR_busy (cpu, in_GRj, 1);
- }
- if (out_FRk >= 0)
- {
- if (use_is_media (cpu, out_FRk))
- decrease_FR_busy (cpu, out_FRk, 1);
- else
- adjust_float_register_busy (cpu, -1, -1, out_FRk, 1);
- }
- vliw_wait_for_GR (cpu, in_GRj);
- vliw_wait_for_FR (cpu, out_FRk);
- handle_resource_wait (cpu);
- load_wait_for_GR (cpu, in_GRj);
- load_wait_for_FR (cpu, out_FRk);
- trace_vliw_wait_cycles (cpu);
- return 0;
- }
- /* The latency of FRk is 2 cycles. */
- cycles = idesc->timing->units[unit_num].done;
- update_FR_latency (cpu, out_FRk, cycles + 2);
- /* Mark this use of the register as NOT a floating point op. */
- fr500_reset_fr_flags (cpu, out_FRk);
- return cycles;
- }
- int
- frvbf_model_fr500_u_gr2spr (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_GRj, INT out_spr)
- {
- int cycles;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- {
- /* The entire VLIW insn must wait if there is a dependency on a register
- which is not ready yet.
- The latency of the registers may be less than previously recorded,
- depending on how they were used previously.
- See Table 13-8 in the LSI. */
- if (in_GRj >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRj))
- decrease_GR_busy (cpu, in_GRj, 1);
- }
- vliw_wait_for_GR (cpu, in_GRj);
- vliw_wait_for_SPR (cpu, out_spr);
- handle_resource_wait (cpu);
- load_wait_for_GR (cpu, in_GRj);
- trace_vliw_wait_cycles (cpu);
- return 0;
- }
- cycles = idesc->timing->units[unit_num].done;
- #if 0
- /* The latency of spr is ? cycles. */
- update_SPR_latency (cpu, out_spr, cycles + ?);
- #endif
- return cycles;
- }
- int
- frvbf_model_fr500_u_ici (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_GRi, INT in_GRj)
- {
- int cycles;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- {
- /* The entire VLIW insn must wait if there is a dependency on a register
- which is not ready yet.
- The latency of the registers may be less than previously recorded,
- depending on how they were used previously.
- See Table 13-8 in the LSI. */
- if (in_GRi >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRi))
- decrease_GR_busy (cpu, in_GRi, 1);
- }
- if (in_GRj != in_GRi && in_GRj >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRj))
- decrease_GR_busy (cpu, in_GRj, 1);
- }
- vliw_wait_for_GR (cpu, in_GRi);
- vliw_wait_for_GR (cpu, in_GRj);
- handle_resource_wait (cpu);
- load_wait_for_GR (cpu, in_GRi);
- load_wait_for_GR (cpu, in_GRj);
- trace_vliw_wait_cycles (cpu);
- return 0;
- }
- cycles = idesc->timing->units[unit_num].done;
- request_cache_invalidate (cpu, CPU_INSN_CACHE (cpu), cycles);
- return cycles;
- }
- int
- frvbf_model_fr500_u_dci (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_GRi, INT in_GRj)
- {
- int cycles;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- {
- /* The entire VLIW insn must wait if there is a dependency on a register
- which is not ready yet.
- The latency of the registers may be less than previously recorded,
- depending on how they were used previously.
- See Table 13-8 in the LSI. */
- if (in_GRi >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRi))
- decrease_GR_busy (cpu, in_GRi, 1);
- }
- if (in_GRj != in_GRi && in_GRj >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRj))
- decrease_GR_busy (cpu, in_GRj, 1);
- }
- vliw_wait_for_GR (cpu, in_GRi);
- vliw_wait_for_GR (cpu, in_GRj);
- handle_resource_wait (cpu);
- load_wait_for_GR (cpu, in_GRi);
- load_wait_for_GR (cpu, in_GRj);
- trace_vliw_wait_cycles (cpu);
- return 0;
- }
- cycles = idesc->timing->units[unit_num].done;
- request_cache_invalidate (cpu, CPU_DATA_CACHE (cpu), cycles);
- return cycles;
- }
- int
- frvbf_model_fr500_u_dcf (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_GRi, INT in_GRj)
- {
- int cycles;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- {
- /* The entire VLIW insn must wait if there is a dependency on a register
- which is not ready yet.
- The latency of the registers may be less than previously recorded,
- depending on how they were used previously.
- See Table 13-8 in the LSI. */
- if (in_GRi >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRi))
- decrease_GR_busy (cpu, in_GRi, 1);
- }
- if (in_GRj != in_GRi && in_GRj >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRj))
- decrease_GR_busy (cpu, in_GRj, 1);
- }
- vliw_wait_for_GR (cpu, in_GRi);
- vliw_wait_for_GR (cpu, in_GRj);
- handle_resource_wait (cpu);
- load_wait_for_GR (cpu, in_GRi);
- load_wait_for_GR (cpu, in_GRj);
- trace_vliw_wait_cycles (cpu);
- return 0;
- }
- cycles = idesc->timing->units[unit_num].done;
- request_cache_flush (cpu, CPU_DATA_CACHE (cpu), cycles);
- return cycles;
- }
- int
- frvbf_model_fr500_u_icpl (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_GRi, INT in_GRj)
- {
- int cycles;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- {
- /* The entire VLIW insn must wait if there is a dependency on a register
- which is not ready yet.
- The latency of the registers may be less than previously recorded,
- depending on how they were used previously.
- See Table 13-8 in the LSI. */
- if (in_GRi >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRi))
- decrease_GR_busy (cpu, in_GRi, 1);
- }
- if (in_GRj != in_GRi && in_GRj >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRj))
- decrease_GR_busy (cpu, in_GRj, 1);
- }
- vliw_wait_for_GR (cpu, in_GRi);
- vliw_wait_for_GR (cpu, in_GRj);
- handle_resource_wait (cpu);
- load_wait_for_GR (cpu, in_GRi);
- load_wait_for_GR (cpu, in_GRj);
- trace_vliw_wait_cycles (cpu);
- return 0;
- }
- cycles = idesc->timing->units[unit_num].done;
- request_cache_preload (cpu, CPU_INSN_CACHE (cpu), cycles);
- return cycles;
- }
- int
- frvbf_model_fr500_u_dcpl (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_GRi, INT in_GRj)
- {
- int cycles;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- {
- /* The entire VLIW insn must wait if there is a dependency on a register
- which is not ready yet.
- The latency of the registers may be less than previously recorded,
- depending on how they were used previously.
- See Table 13-8 in the LSI. */
- if (in_GRi >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRi))
- decrease_GR_busy (cpu, in_GRi, 1);
- }
- if (in_GRj != in_GRi && in_GRj >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRj))
- decrease_GR_busy (cpu, in_GRj, 1);
- }
- vliw_wait_for_GR (cpu, in_GRi);
- vliw_wait_for_GR (cpu, in_GRj);
- handle_resource_wait (cpu);
- load_wait_for_GR (cpu, in_GRi);
- load_wait_for_GR (cpu, in_GRj);
- trace_vliw_wait_cycles (cpu);
- return 0;
- }
- cycles = idesc->timing->units[unit_num].done;
- request_cache_preload (cpu, CPU_DATA_CACHE (cpu), cycles);
- return cycles;
- }
- int
- frvbf_model_fr500_u_icul (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_GRi, INT in_GRj)
- {
- int cycles;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- {
- /* The entire VLIW insn must wait if there is a dependency on a register
- which is not ready yet.
- The latency of the registers may be less than previously recorded,
- depending on how they were used previously.
- See Table 13-8 in the LSI. */
- if (in_GRi >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRi))
- decrease_GR_busy (cpu, in_GRi, 1);
- }
- if (in_GRj != in_GRi && in_GRj >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRj))
- decrease_GR_busy (cpu, in_GRj, 1);
- }
- vliw_wait_for_GR (cpu, in_GRi);
- vliw_wait_for_GR (cpu, in_GRj);
- handle_resource_wait (cpu);
- load_wait_for_GR (cpu, in_GRi);
- load_wait_for_GR (cpu, in_GRj);
- trace_vliw_wait_cycles (cpu);
- return 0;
- }
- cycles = idesc->timing->units[unit_num].done;
- request_cache_unlock (cpu, CPU_INSN_CACHE (cpu), cycles);
- return cycles;
- }
- int
- frvbf_model_fr500_u_dcul (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_GRi, INT in_GRj)
- {
- int cycles;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- {
- /* The entire VLIW insn must wait if there is a dependency on a register
- which is not ready yet.
- The latency of the registers may be less than previously recorded,
- depending on how they were used previously.
- See Table 13-8 in the LSI. */
- if (in_GRi >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRi))
- decrease_GR_busy (cpu, in_GRi, 1);
- }
- if (in_GRj != in_GRi && in_GRj >= 0)
- {
- if (use_is_gr_complex (cpu, in_GRj))
- decrease_GR_busy (cpu, in_GRj, 1);
- }
- vliw_wait_for_GR (cpu, in_GRi);
- vliw_wait_for_GR (cpu, in_GRj);
- handle_resource_wait (cpu);
- load_wait_for_GR (cpu, in_GRi);
- load_wait_for_GR (cpu, in_GRj);
- trace_vliw_wait_cycles (cpu);
- return 0;
- }
- cycles = idesc->timing->units[unit_num].done;
- request_cache_unlock (cpu, CPU_DATA_CACHE (cpu), cycles);
- return cycles;
- }
- int
- frvbf_model_fr500_u_float_arith (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_FRi, INT in_FRj,
- INT in_FRdoublei, INT in_FRdoublej,
- INT out_FRk, INT out_FRdoublek)
- {
- int cycles;
- FRV_PROFILE_STATE *ps;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- return 0;
- /* The preprocessing can execute right away. */
- cycles = idesc->timing->units[unit_num].done;
- /* The post processing must wait if there is a dependency on a FR
- which is not ready yet. */
- adjust_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, 1);
- adjust_double_register_busy (cpu, in_FRdoublei, in_FRdoublej, out_FRdoublek,
- 1);
- ps = CPU_PROFILE_STATE (cpu);
- ps->post_wait = cycles;
- post_wait_for_FR (cpu, in_FRi);
- post_wait_for_FR (cpu, in_FRj);
- post_wait_for_FR (cpu, out_FRk);
- post_wait_for_FRdouble (cpu, in_FRdoublei);
- post_wait_for_FRdouble (cpu, in_FRdoublej);
- post_wait_for_FRdouble (cpu, out_FRdoublek);
- if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
- {
- post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
- post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRdoublek));
- }
- restore_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, 1);
- restore_double_register_busy (cpu, in_FRdoublei, in_FRdoublej, out_FRdoublek,
- 1);
- /* The latency of FRk will be at least the latency of the other inputs. */
- update_FR_latency (cpu, out_FRk, ps->post_wait);
- update_FRdouble_latency (cpu, out_FRdoublek, ps->post_wait);
- if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
- {
- update_SPR_latency (cpu, FNER_FOR_FR (out_FRk), ps->post_wait);
- update_SPR_latency (cpu, FNER_FOR_FR (out_FRdoublek), ps->post_wait);
- }
- /* Once initiated, post-processing will take 3 cycles. */
- update_FR_ptime (cpu, out_FRk, 3);
- update_FRdouble_ptime (cpu, out_FRdoublek, 3);
- if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
- {
- update_SPR_ptime (cpu, FNER_FOR_FR (out_FRk), 3);
- update_SPR_ptime (cpu, FNER_FOR_FR (out_FRdoublek), 3);
- }
- /* Mark this use of the register as a floating point op. */
- if (out_FRk >= 0)
- set_use_is_fpop (cpu, out_FRk);
- if (out_FRdoublek >= 0)
- {
- set_use_is_fpop (cpu, out_FRdoublek);
- if (out_FRdoublek < 63)
- set_use_is_fpop (cpu, out_FRdoublek + 1);
- }
- return cycles;
- }
- int
- frvbf_model_fr500_u_float_dual_arith (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_FRi, INT in_FRj,
- INT in_FRdoublei, INT in_FRdoublej,
- INT out_FRk, INT out_FRdoublek)
- {
- int cycles;
- INT dual_FRi;
- INT dual_FRj;
- INT dual_FRk;
- INT dual_FRdoublei;
- INT dual_FRdoublej;
- INT dual_FRdoublek;
- FRV_PROFILE_STATE *ps;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- return 0;
- /* The preprocessing can execute right away. */
- cycles = idesc->timing->units[unit_num].done;
- /* The post processing must wait if there is a dependency on a FR
- which is not ready yet. */
- dual_FRi = DUAL_REG (in_FRi);
- dual_FRj = DUAL_REG (in_FRj);
- dual_FRk = DUAL_REG (out_FRk);
- dual_FRdoublei = DUAL_DOUBLE (in_FRdoublei);
- dual_FRdoublej = DUAL_DOUBLE (in_FRdoublej);
- dual_FRdoublek = DUAL_DOUBLE (out_FRdoublek);
- adjust_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, 1);
- adjust_float_register_busy (cpu, dual_FRi, dual_FRj, dual_FRk, 1);
- adjust_double_register_busy (cpu, in_FRdoublei, in_FRdoublej, out_FRdoublek,
- 1);
- adjust_double_register_busy (cpu, dual_FRdoublei, dual_FRdoublej,
- dual_FRdoublek, 1);
- ps = CPU_PROFILE_STATE (cpu);
- ps->post_wait = cycles;
- post_wait_for_FR (cpu, in_FRi);
- post_wait_for_FR (cpu, in_FRj);
- post_wait_for_FR (cpu, out_FRk);
- post_wait_for_FR (cpu, dual_FRi);
- post_wait_for_FR (cpu, dual_FRj);
- post_wait_for_FR (cpu, dual_FRk);
- post_wait_for_FRdouble (cpu, in_FRdoublei);
- post_wait_for_FRdouble (cpu, in_FRdoublej);
- post_wait_for_FRdouble (cpu, out_FRdoublek);
- post_wait_for_FRdouble (cpu, dual_FRdoublei);
- post_wait_for_FRdouble (cpu, dual_FRdoublej);
- post_wait_for_FRdouble (cpu, dual_FRdoublek);
- if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
- {
- post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
- post_wait_for_SPR (cpu, FNER_FOR_FR (dual_FRk));
- post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRdoublek));
- post_wait_for_SPR (cpu, FNER_FOR_FR (dual_FRdoublek));
- }
- restore_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, 1);
- restore_float_register_busy (cpu, dual_FRi, dual_FRj, dual_FRk, 1);
- restore_double_register_busy (cpu, in_FRdoublei, in_FRdoublej, out_FRdoublek,
- 1);
- restore_double_register_busy (cpu, dual_FRdoublei, dual_FRdoublej,
- dual_FRdoublek, 1);
- /* The latency of FRk will be at least the latency of the other inputs. */
- update_FR_latency (cpu, out_FRk, ps->post_wait);
- update_FR_latency (cpu, dual_FRk, ps->post_wait);
- update_FRdouble_latency (cpu, out_FRdoublek, ps->post_wait);
- update_FRdouble_latency (cpu, dual_FRdoublek, ps->post_wait);
- if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
- {
- update_SPR_latency (cpu, FNER_FOR_FR (out_FRk), ps->post_wait);
- update_SPR_latency (cpu, FNER_FOR_FR (dual_FRk), ps->post_wait);
- update_SPR_latency (cpu, FNER_FOR_FR (out_FRdoublek), ps->post_wait);
- update_SPR_latency (cpu, FNER_FOR_FR (dual_FRdoublek), ps->post_wait);
- }
- /* Once initiated, post-processing will take 3 cycles. */
- update_FR_ptime (cpu, out_FRk, 3);
- update_FR_ptime (cpu, dual_FRk, 3);
- update_FRdouble_ptime (cpu, out_FRdoublek, 3);
- update_FRdouble_ptime (cpu, dual_FRdoublek, 3);
- if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
- {
- update_SPR_ptime (cpu, FNER_FOR_FR (out_FRk), 3);
- update_SPR_ptime (cpu, FNER_FOR_FR (dual_FRk), 3);
- update_SPR_ptime (cpu, FNER_FOR_FR (out_FRdoublek), 3);
- update_SPR_ptime (cpu, FNER_FOR_FR (dual_FRdoublek), 3);
- }
- /* Mark this use of the register as a floating point op. */
- if (out_FRk >= 0)
- set_use_is_fpop (cpu, out_FRk);
- if (dual_FRk >= 0)
- set_use_is_fpop (cpu, dual_FRk);
- if (out_FRdoublek >= 0)
- {
- set_use_is_fpop (cpu, out_FRdoublek);
- if (out_FRdoublek < 63)
- set_use_is_fpop (cpu, out_FRdoublek + 1);
- }
- if (dual_FRdoublek >= 0)
- {
- set_use_is_fpop (cpu, dual_FRdoublek);
- if (dual_FRdoublek < 63)
- set_use_is_fpop (cpu, dual_FRdoublek + 1);
- }
- return cycles;
- }
- int
- frvbf_model_fr500_u_float_div (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_FRi, INT in_FRj, INT out_FRk)
- {
- int cycles;
- FRV_VLIW *vliw;
- int slot;
- FRV_PROFILE_STATE *ps;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- return 0;
- cycles = idesc->timing->units[unit_num].done;
- /* The post processing must wait if there is a dependency on a FR
- which is not ready yet. */
- adjust_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, 1);
- ps = CPU_PROFILE_STATE (cpu);
- ps->post_wait = cycles;
- post_wait_for_FR (cpu, in_FRi);
- post_wait_for_FR (cpu, in_FRj);
- post_wait_for_FR (cpu, out_FRk);
- if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
- post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
- vliw = CPU_VLIW (cpu);
- slot = vliw->next_slot - 1;
- slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
- post_wait_for_fdiv (cpu, slot);
- restore_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, 1);
- /* The latency of FRk will be at least the latency of the other inputs. */
- /* Once initiated, post-processing will take 10 cycles. */
- update_FR_latency (cpu, out_FRk, ps->post_wait);
- update_FR_ptime (cpu, out_FRk, 10);
- if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
- {
- /* FNER has a latency of 10 cycles. */
- update_SPR_latency (cpu, FNER_FOR_FR (out_FRk), ps->post_wait);
- update_SPR_ptime (cpu, FNER_FOR_FR (out_FRk), 10);
- }
- /* The latency of the fdiv unit will be at least the latency of the other
- inputs. Once initiated, post-processing will take 9 cycles. */
- update_fdiv_resource_latency (cpu, slot, ps->post_wait + 9);
- /* Mark this use of the register as a floating point op. */
- set_use_is_fpop (cpu, out_FRk);
- return cycles;
- }
- int
- frvbf_model_fr500_u_float_sqrt (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_FRj, INT in_FRdoublej,
- INT out_FRk, INT out_FRdoublek)
- {
- int cycles;
- FRV_VLIW *vliw;
- int slot;
- FRV_PROFILE_STATE *ps;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- return 0;
- cycles = idesc->timing->units[unit_num].done;
- /* The post processing must wait if there is a dependency on a FR
- which is not ready yet. */
- adjust_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
- adjust_double_register_busy (cpu, -1, in_FRdoublej, out_FRdoublek, 1);
- ps = CPU_PROFILE_STATE (cpu);
- ps->post_wait = cycles;
- post_wait_for_FR (cpu, in_FRj);
- post_wait_for_FR (cpu, out_FRk);
- post_wait_for_FRdouble (cpu, in_FRdoublej);
- post_wait_for_FRdouble (cpu, out_FRdoublek);
- if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
- post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
- vliw = CPU_VLIW (cpu);
- slot = vliw->next_slot - 1;
- slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
- post_wait_for_fsqrt (cpu, slot);
- restore_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
- restore_double_register_busy (cpu, -1, in_FRdoublej, out_FRdoublek, 1);
- /* The latency of FRk will be at least the latency of the other inputs. */
- update_FR_latency (cpu, out_FRk, ps->post_wait);
- update_FRdouble_latency (cpu, out_FRdoublek, ps->post_wait);
- if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
- update_SPR_latency (cpu, FNER_FOR_FR (out_FRk), ps->post_wait);
- /* Once initiated, post-processing will take 15 cycles. */
- update_FR_ptime (cpu, out_FRk, 15);
- update_FRdouble_ptime (cpu, out_FRdoublek, 15);
- if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
- update_SPR_ptime (cpu, FNER_FOR_FR (out_FRk), 15);
- /* The latency of the sqrt unit will be the latency of the other
- inputs plus 14 cycles. */
- update_fsqrt_resource_latency (cpu, slot, ps->post_wait + 14);
- /* Mark this use of the register as a floating point op. */
- if (out_FRk >= 0)
- set_use_is_fpop (cpu, out_FRk);
- if (out_FRdoublek >= 0)
- {
- set_use_is_fpop (cpu, out_FRdoublek);
- if (out_FRdoublek < 63)
- set_use_is_fpop (cpu, out_FRdoublek + 1);
- }
- return cycles;
- }
- int
- frvbf_model_fr500_u_float_dual_sqrt (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_FRj, INT out_FRk)
- {
- int cycles;
- FRV_VLIW *vliw;
- int slot;
- INT dual_FRj;
- INT dual_FRk;
- FRV_PROFILE_STATE *ps;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- return 0;
- cycles = idesc->timing->units[unit_num].done;
- /* The post processing must wait if there is a dependency on a FR
- which is not ready yet. */
- dual_FRj = DUAL_REG (in_FRj);
- dual_FRk = DUAL_REG (out_FRk);
- adjust_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
- adjust_float_register_busy (cpu, -1, dual_FRj, dual_FRk, 1);
- ps = CPU_PROFILE_STATE (cpu);
- ps->post_wait = cycles;
- post_wait_for_FR (cpu, in_FRj);
- post_wait_for_FR (cpu, out_FRk);
- post_wait_for_FR (cpu, dual_FRj);
- post_wait_for_FR (cpu, dual_FRk);
- vliw = CPU_VLIW (cpu);
- slot = vliw->next_slot - 1;
- slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
- post_wait_for_fsqrt (cpu, slot);
- restore_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
- restore_float_register_busy (cpu, -1, dual_FRj, dual_FRk, 1);
- /* The latency of FRk will be at least the latency of the other inputs. */
- update_FR_latency (cpu, out_FRk, ps->post_wait);
- update_FR_latency (cpu, dual_FRk, ps->post_wait);
- /* Once initiated, post-processing will take 15 cycles. */
- update_FR_ptime (cpu, out_FRk, 15);
- update_FR_ptime (cpu, dual_FRk, 15);
- /* The latency of the sqrt unit will be at least the latency of the other
- inputs. */
- update_fsqrt_resource_latency (cpu, slot, ps->post_wait + 14);
- /* Mark this use of the register as a floating point op. */
- if (out_FRk >= 0)
- set_use_is_fpop (cpu, out_FRk);
- if (dual_FRk >= 0)
- set_use_is_fpop (cpu, dual_FRk);
- return cycles;
- }
- int
- frvbf_model_fr500_u_float_compare (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_FRi, INT in_FRj,
- INT in_FRdoublei, INT in_FRdoublej,
- INT out_FCCi_2)
- {
- int cycles;
- FRV_PROFILE_STATE *ps;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- return 0;
- /* The preprocessing can execute right away. */
- cycles = idesc->timing->units[unit_num].done;
- /* The post processing must wait if there is a dependency on a FR
- which is not ready yet. */
- adjust_double_register_busy (cpu, in_FRdoublei, in_FRdoublej, -1, 1);
- ps = CPU_PROFILE_STATE (cpu);
- ps->post_wait = cycles;
- post_wait_for_FR (cpu, in_FRi);
- post_wait_for_FR (cpu, in_FRj);
- post_wait_for_FRdouble (cpu, in_FRdoublei);
- post_wait_for_FRdouble (cpu, in_FRdoublej);
- post_wait_for_CCR (cpu, out_FCCi_2);
- restore_double_register_busy (cpu, in_FRdoublei, in_FRdoublej, -1, 1);
- /* The latency of FCCi_2 will be the latency of the other inputs plus 3
- cycles. */
- update_CCR_latency (cpu, out_FCCi_2, ps->post_wait + 3);
- return cycles;
- }
- int
- frvbf_model_fr500_u_float_dual_compare (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_FRi, INT in_FRj,
- INT out_FCCi_2)
- {
- int cycles;
- INT dual_FRi;
- INT dual_FRj;
- INT dual_FCCi_2;
- FRV_PROFILE_STATE *ps;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- return 0;
- /* The preprocessing can execute right away. */
- cycles = idesc->timing->units[unit_num].done;
- /* The post processing must wait if there is a dependency on a FR
- which is not ready yet. */
- ps = CPU_PROFILE_STATE (cpu);
- ps->post_wait = cycles;
- dual_FRi = DUAL_REG (in_FRi);
- dual_FRj = DUAL_REG (in_FRj);
- dual_FCCi_2 = out_FCCi_2 + 1;
- adjust_float_register_busy (cpu, in_FRi, in_FRj, -1, 1);
- adjust_float_register_busy (cpu, dual_FRi, dual_FRj, -1, 1);
- post_wait_for_FR (cpu, in_FRi);
- post_wait_for_FR (cpu, in_FRj);
- post_wait_for_FR (cpu, dual_FRi);
- post_wait_for_FR (cpu, dual_FRj);
- post_wait_for_CCR (cpu, out_FCCi_2);
- post_wait_for_CCR (cpu, dual_FCCi_2);
- restore_float_register_busy (cpu, in_FRi, in_FRj, -1, 1);
- restore_float_register_busy (cpu, dual_FRi, dual_FRj, -1, 1);
- /* The latency of FCCi_2 will be the latency of the other inputs plus 3
- cycles. */
- update_CCR_latency (cpu, out_FCCi_2, ps->post_wait + 3);
- update_CCR_latency (cpu, dual_FCCi_2, ps->post_wait + 3);
- return cycles;
- }
- int
- frvbf_model_fr500_u_float_convert (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_FRj, INT in_FRintj, INT in_FRdoublej,
- INT out_FRk, INT out_FRintk,
- INT out_FRdoublek)
- {
- int cycles;
- FRV_PROFILE_STATE *ps;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- return 0;
- /* The preprocessing can execute right away. */
- cycles = idesc->timing->units[unit_num].done;
- /* The post processing must wait if there is a dependency on a FR
- which is not ready yet. */
- ps = CPU_PROFILE_STATE (cpu);
- ps->post_wait = cycles;
- adjust_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
- adjust_float_register_busy (cpu, -1, in_FRintj, out_FRintk, 1);
- adjust_double_register_busy (cpu, -1, in_FRdoublej, out_FRdoublek, 1);
- post_wait_for_FR (cpu, in_FRj);
- post_wait_for_FR (cpu, in_FRintj);
- post_wait_for_FRdouble (cpu, in_FRdoublej);
- post_wait_for_FR (cpu, out_FRk);
- post_wait_for_FR (cpu, out_FRintk);
- post_wait_for_FRdouble (cpu, out_FRdoublek);
- if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
- {
- post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
- post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRintk));
- post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRdoublek));
- }
- restore_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
- restore_float_register_busy (cpu, -1, in_FRintj, out_FRintk, 1);
- restore_double_register_busy (cpu, -1, in_FRdoublej, out_FRdoublek, 1);
- /* The latency of FRk will be at least the latency of the other inputs. */
- update_FR_latency (cpu, out_FRk, ps->post_wait);
- update_FR_latency (cpu, out_FRintk, ps->post_wait);
- update_FRdouble_latency (cpu, out_FRdoublek, ps->post_wait);
- if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
- {
- update_SPR_latency (cpu, FNER_FOR_FR (out_FRk), ps->post_wait);
- update_SPR_latency (cpu, FNER_FOR_FR (out_FRintk), ps->post_wait);
- update_SPR_latency (cpu, FNER_FOR_FR (out_FRdoublek), ps->post_wait);
- }
- /* Once initiated, post-processing will take 3 cycles. */
- update_FR_ptime (cpu, out_FRk, 3);
- update_FR_ptime (cpu, out_FRintk, 3);
- update_FRdouble_ptime (cpu, out_FRdoublek, 3);
- if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
- {
- update_SPR_ptime (cpu, FNER_FOR_FR (out_FRk), 3);
- update_SPR_ptime (cpu, FNER_FOR_FR (out_FRintk), 3);
- update_SPR_ptime (cpu, FNER_FOR_FR (out_FRdoublek), 3);
- }
- /* Mark this use of the register as a floating point op. */
- if (out_FRk >= 0)
- set_use_is_fpop (cpu, out_FRk);
- if (out_FRintk >= 0)
- set_use_is_fpop (cpu, out_FRintk);
- if (out_FRdoublek >= 0)
- {
- set_use_is_fpop (cpu, out_FRdoublek);
- set_use_is_fpop (cpu, out_FRdoublek + 1);
- }
- return cycles;
- }
- int
- frvbf_model_fr500_u_float_dual_convert (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_FRj, INT in_FRintj,
- INT out_FRk, INT out_FRintk)
- {
- int cycles;
- INT dual_FRj;
- INT dual_FRintj;
- INT dual_FRk;
- INT dual_FRintk;
- FRV_PROFILE_STATE *ps;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- return 0;
- /* The preprocessing can execute right away. */
- cycles = idesc->timing->units[unit_num].done;
- /* The post processing must wait if there is a dependency on a FR
- which is not ready yet. */
- ps = CPU_PROFILE_STATE (cpu);
- ps->post_wait = cycles;
- dual_FRj = DUAL_REG (in_FRj);
- dual_FRintj = DUAL_REG (in_FRintj);
- dual_FRk = DUAL_REG (out_FRk);
- dual_FRintk = DUAL_REG (out_FRintk);
- adjust_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
- adjust_float_register_busy (cpu, -1, dual_FRj, dual_FRk, 1);
- adjust_float_register_busy (cpu, -1, in_FRintj, out_FRintk, 1);
- adjust_float_register_busy (cpu, -1, dual_FRintj, dual_FRintk, 1);
- post_wait_for_FR (cpu, in_FRj);
- post_wait_for_FR (cpu, in_FRintj);
- post_wait_for_FR (cpu, out_FRk);
- post_wait_for_FR (cpu, out_FRintk);
- post_wait_for_FR (cpu, dual_FRj);
- post_wait_for_FR (cpu, dual_FRintj);
- post_wait_for_FR (cpu, dual_FRk);
- post_wait_for_FR (cpu, dual_FRintk);
- restore_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
- restore_float_register_busy (cpu, -1, dual_FRj, dual_FRk, 1);
- restore_float_register_busy (cpu, -1, in_FRintj, out_FRintk, 1);
- restore_float_register_busy (cpu, -1, dual_FRintj, dual_FRintk, 1);
- /* The latency of FRk will be at least the latency of the other inputs. */
- update_FR_latency (cpu, out_FRk, ps->post_wait);
- update_FR_latency (cpu, out_FRintk, ps->post_wait);
- update_FR_latency (cpu, dual_FRk, ps->post_wait);
- update_FR_latency (cpu, dual_FRintk, ps->post_wait);
- /* Once initiated, post-processing will take 3 cycles. */
- update_FR_ptime (cpu, out_FRk, 3);
- update_FR_ptime (cpu, out_FRintk, 3);
- update_FR_ptime (cpu, dual_FRk, 3);
- update_FR_ptime (cpu, dual_FRintk, 3);
- /* Mark this use of the register as a floating point op. */
- if (out_FRk >= 0)
- set_use_is_fpop (cpu, out_FRk);
- if (out_FRintk >= 0)
- set_use_is_fpop (cpu, out_FRintk);
- return cycles;
- }
- int
- frvbf_model_fr500_u_media (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_FRi, INT in_FRj, INT in_ACC40Si, INT in_ACCGi,
- INT out_FRk,
- INT out_ACC40Sk, INT out_ACC40Uk, INT out_ACCGk)
- {
- int cycles;
- FRV_PROFILE_STATE *ps;
- const CGEN_INSN *insn;
- int is_media_s1;
- int is_media_s2;
- int busy_adjustment[] = {0, 0, 0};
- int *fr;
- int *acc;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- return 0;
- /* The preprocessing can execute right away. */
- cycles = idesc->timing->units[unit_num].done;
- ps = CPU_PROFILE_STATE (cpu);
- insn = idesc->idata;
- /* If the previous use of the registers was a media op,
- then their latency will be less than previously recorded.
- See Table 13-13 in the LSI. */
- if (in_FRi >= 0)
- {
- if (use_is_media (cpu, in_FRi))
- {
- busy_adjustment[0] = 2;
- decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
- }
- else
- enforce_full_fr_latency (cpu, in_FRi);
- }
- if (in_FRj >= 0 && in_FRj != in_FRi)
- {
- if (use_is_media (cpu, in_FRj))
- {
- busy_adjustment[1] = 2;
- decrease_FR_busy (cpu, in_FRj, busy_adjustment[1]);
- }
- else
- enforce_full_fr_latency (cpu, in_FRj);
- }
- if (out_FRk >= 0 && out_FRk != in_FRi && out_FRk != in_FRj)
- {
- if (use_is_media (cpu, out_FRk))
- {
- busy_adjustment[2] = 2;
- decrease_FR_busy (cpu, out_FRk, busy_adjustment[2]);
- }
- else
- enforce_full_fr_latency (cpu, out_FRk);
- }
- /* The post processing must wait if there is a dependency on a FR
- which is not ready yet. */
- ps->post_wait = cycles;
- post_wait_for_FR (cpu, in_FRi);
- post_wait_for_FR (cpu, in_FRj);
- post_wait_for_FR (cpu, out_FRk);
- post_wait_for_ACC (cpu, in_ACC40Si);
- post_wait_for_ACC (cpu, in_ACCGi);
- post_wait_for_ACC (cpu, out_ACC40Sk);
- post_wait_for_ACC (cpu, out_ACC40Uk);
- post_wait_for_ACC (cpu, out_ACCGk);
- /* Restore the busy cycles of the registers we used. */
- fr = ps->fr_busy;
- if (in_FRi >= 0)
- fr[in_FRi] += busy_adjustment[0];
- if (in_FRj >= 0)
- fr[in_FRj] += busy_adjustment[1];
- if (out_FRk >= 0)
- fr[out_FRk] += busy_adjustment[2];
- /* The latency of tht output register will be at least the latency of the
- other inputs. Once initiated, post-processing will take 3 cycles. */
- if (out_FRk >= 0)
- {
- update_FR_latency (cpu, out_FRk, ps->post_wait);
- update_FR_ptime (cpu, out_FRk, 3);
- /* Mark this use of the register as a media op. */
- set_use_is_media (cpu, out_FRk);
- }
- /* The latency of tht output accumulator will be at least the latency of the
- other inputs. Once initiated, post-processing will take 1 cycle. */
- if (out_ACC40Sk >= 0)
- update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
- if (out_ACC40Uk >= 0)
- update_ACC_latency (cpu, out_ACC40Uk, ps->post_wait + 1);
- if (out_ACCGk >= 0)
- update_ACC_latency (cpu, out_ACCGk, ps->post_wait + 1);
- return cycles;
- }
- int
- frvbf_model_fr500_u_media_quad_arith (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_FRi, INT in_FRj,
- INT out_FRk)
- {
- int cycles;
- INT dual_FRi;
- INT dual_FRj;
- INT dual_FRk;
- FRV_PROFILE_STATE *ps;
- int busy_adjustment[] = {0, 0, 0, 0, 0, 0};
- int *fr;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- return 0;
- /* The preprocessing can execute right away. */
- cycles = idesc->timing->units[unit_num].done;
- ps = CPU_PROFILE_STATE (cpu);
- dual_FRi = DUAL_REG (in_FRi);
- dual_FRj = DUAL_REG (in_FRj);
- dual_FRk = DUAL_REG (out_FRk);
- /* If the previous use of the registers was a media op,
- then their latency will be less than previously recorded.
- See Table 13-13 in the LSI. */
- if (use_is_media (cpu, in_FRi))
- {
- busy_adjustment[0] = 2;
- decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
- }
- else
- enforce_full_fr_latency (cpu, in_FRi);
- if (dual_FRi >= 0 && use_is_media (cpu, dual_FRi))
- {
- busy_adjustment[1] = 2;
- decrease_FR_busy (cpu, dual_FRi, busy_adjustment[1]);
- }
- else
- enforce_full_fr_latency (cpu, dual_FRi);
- if (in_FRj != in_FRi)
- {
- if (use_is_media (cpu, in_FRj))
- {
- busy_adjustment[2] = 2;
- decrease_FR_busy (cpu, in_FRj, busy_adjustment[2]);
- }
- else
- enforce_full_fr_latency (cpu, in_FRj);
- if (dual_FRj >= 0 && use_is_media (cpu, dual_FRj))
- {
- busy_adjustment[3] = 2;
- decrease_FR_busy (cpu, dual_FRj, busy_adjustment[3]);
- }
- else
- enforce_full_fr_latency (cpu, dual_FRj + 1);
- }
- if (out_FRk != in_FRi && out_FRk != in_FRj)
- {
- if (use_is_media (cpu, out_FRk))
- {
- busy_adjustment[4] = 2;
- decrease_FR_busy (cpu, out_FRk, busy_adjustment[4]);
- }
- else
- enforce_full_fr_latency (cpu, out_FRk);
- if (dual_FRk >= 0 && use_is_media (cpu, dual_FRk))
- {
- busy_adjustment[5] = 2;
- decrease_FR_busy (cpu, dual_FRk, busy_adjustment[5]);
- }
- else
- enforce_full_fr_latency (cpu, dual_FRk);
- }
- /* The post processing must wait if there is a dependency on a FR
- which is not ready yet. */
- ps->post_wait = cycles;
- post_wait_for_FR (cpu, in_FRi);
- post_wait_for_FR (cpu, dual_FRi);
- post_wait_for_FR (cpu, in_FRj);
- post_wait_for_FR (cpu, dual_FRj);
- post_wait_for_FR (cpu, out_FRk);
- post_wait_for_FR (cpu, dual_FRk);
- /* Restore the busy cycles of the registers we used. */
- fr = ps->fr_busy;
- fr[in_FRi] += busy_adjustment[0];
- if (dual_FRi >= 0)
- fr[dual_FRi] += busy_adjustment[1];
- fr[in_FRj] += busy_adjustment[2];
- if (dual_FRj >= 0)
- fr[dual_FRj] += busy_adjustment[3];
- fr[out_FRk] += busy_adjustment[4];
- if (dual_FRk >= 0)
- fr[dual_FRk] += busy_adjustment[5];
- /* The latency of tht output register will be at least the latency of the
- other inputs. */
- update_FR_latency (cpu, out_FRk, ps->post_wait);
- /* Once initiated, post-processing will take 3 cycles. */
- update_FR_ptime (cpu, out_FRk, 3);
- /* Mark this use of the register as a media op. */
- set_use_is_media (cpu, out_FRk);
- if (dual_FRk >= 0)
- {
- update_FR_latency (cpu, dual_FRk, ps->post_wait);
- update_FR_ptime (cpu, dual_FRk, 3);
- /* Mark this use of the register as a media op. */
- set_use_is_media (cpu, dual_FRk);
- }
- return cycles;
- }
- int
- frvbf_model_fr500_u_media_dual_mul (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_FRi, INT in_FRj,
- INT out_ACC40Sk, INT out_ACC40Uk)
- {
- int cycles;
- INT dual_ACC40Sk;
- INT dual_ACC40Uk;
- FRV_PROFILE_STATE *ps;
- int busy_adjustment[] = {0, 0, 0, 0, 0, 0};
- int *fr;
- int *acc;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- return 0;
- /* The preprocessing can execute right away. */
- cycles = idesc->timing->units[unit_num].done;
- ps = CPU_PROFILE_STATE (cpu);
- dual_ACC40Sk = DUAL_REG (out_ACC40Sk);
- dual_ACC40Uk = DUAL_REG (out_ACC40Uk);
- /* If the previous use of the registers was a media op,
- then their latency will be less than previously recorded.
- See Table 13-13 in the LSI. */
- if (use_is_media (cpu, in_FRi))
- {
- busy_adjustment[0] = 2;
- decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
- }
- else
- enforce_full_fr_latency (cpu, in_FRi);
- if (in_FRj != in_FRi)
- {
- if (use_is_media (cpu, in_FRj))
- {
- busy_adjustment[1] = 2;
- decrease_FR_busy (cpu, in_FRj, busy_adjustment[1]);
- }
- else
- enforce_full_fr_latency (cpu, in_FRj);
- }
- if (out_ACC40Sk >= 0)
- {
- busy_adjustment[2] = 1;
- decrease_ACC_busy (cpu, out_ACC40Sk, busy_adjustment[2]);
- }
- if (dual_ACC40Sk >= 0)
- {
- busy_adjustment[3] = 1;
- decrease_ACC_busy (cpu, dual_ACC40Sk, busy_adjustment[3]);
- }
- if (out_ACC40Uk >= 0)
- {
- busy_adjustment[4] = 1;
- decrease_ACC_busy (cpu, out_ACC40Uk, busy_adjustment[4]);
- }
- if (dual_ACC40Uk >= 0)
- {
- busy_adjustment[5] = 1;
- decrease_ACC_busy (cpu, dual_ACC40Uk, busy_adjustment[5]);
- }
- /* The post processing must wait if there is a dependency on a FR
- which is not ready yet. */
- ps->post_wait = cycles;
- post_wait_for_FR (cpu, in_FRi);
- post_wait_for_FR (cpu, in_FRj);
- post_wait_for_ACC (cpu, out_ACC40Sk);
- post_wait_for_ACC (cpu, dual_ACC40Sk);
- post_wait_for_ACC (cpu, out_ACC40Uk);
- post_wait_for_ACC (cpu, dual_ACC40Uk);
- /* Restore the busy cycles of the registers we used. */
- fr = ps->fr_busy;
- acc = ps->acc_busy;
- fr[in_FRi] += busy_adjustment[0];
- fr[in_FRj] += busy_adjustment[1];
- if (out_ACC40Sk >= 0)
- acc[out_ACC40Sk] += busy_adjustment[2];
- if (dual_ACC40Sk >= 0)
- acc[dual_ACC40Sk] += busy_adjustment[3];
- if (out_ACC40Uk >= 0)
- acc[out_ACC40Uk] += busy_adjustment[4];
- if (dual_ACC40Uk >= 0)
- acc[dual_ACC40Uk] += busy_adjustment[5];
- /* The latency of tht output register will be at least the latency of the
- other inputs. Once initiated, post-processing will take 1 cycle. */
- if (out_ACC40Sk >= 0)
- update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
- if (dual_ACC40Sk >= 0)
- update_ACC_latency (cpu, dual_ACC40Sk, ps->post_wait + 1);
- if (out_ACC40Uk >= 0)
- update_ACC_latency (cpu, out_ACC40Uk, ps->post_wait + 1);
- if (dual_ACC40Uk >= 0)
- update_ACC_latency (cpu, dual_ACC40Uk, ps->post_wait + 1);
- return cycles;
- }
- int
- frvbf_model_fr500_u_media_quad_mul (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_FRi, INT in_FRj,
- INT out_ACC40Sk, INT out_ACC40Uk)
- {
- int cycles;
- INT FRi_1;
- INT FRj_1;
- INT ACC40Sk_1;
- INT ACC40Sk_2;
- INT ACC40Sk_3;
- INT ACC40Uk_1;
- INT ACC40Uk_2;
- INT ACC40Uk_3;
- FRV_PROFILE_STATE *ps;
- int busy_adjustment[] = {0, 0, 0, 0, 0, 0, 0 ,0};
- int *fr;
- int *acc;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- return 0;
- /* The preprocessing can execute right away. */
- cycles = idesc->timing->units[unit_num].done;
- FRi_1 = DUAL_REG (in_FRi);
- FRj_1 = DUAL_REG (in_FRj);
- ACC40Sk_1 = DUAL_REG (out_ACC40Sk);
- ACC40Sk_2 = DUAL_REG (ACC40Sk_1);
- ACC40Sk_3 = DUAL_REG (ACC40Sk_2);
- ACC40Uk_1 = DUAL_REG (out_ACC40Uk);
- ACC40Uk_2 = DUAL_REG (ACC40Uk_1);
- ACC40Uk_3 = DUAL_REG (ACC40Uk_2);
- /* If the previous use of the registers was a media op,
- then their latency will be less than previously recorded.
- See Table 13-13 in the LSI. */
- ps = CPU_PROFILE_STATE (cpu);
- if (use_is_media (cpu, in_FRi))
- {
- busy_adjustment[0] = 2;
- decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
- }
- else
- enforce_full_fr_latency (cpu, in_FRi);
- if (FRi_1 >= 0)
- {
- if (use_is_media (cpu, FRi_1))
- {
- busy_adjustment[1] = 2;
- decrease_FR_busy (cpu, FRi_1, busy_adjustment[1]);
- }
- else
- enforce_full_fr_latency (cpu, FRi_1);
- }
- if (in_FRj != in_FRi)
- {
- if (use_is_media (cpu, in_FRj))
- {
- busy_adjustment[2] = 2;
- decrease_FR_busy (cpu, in_FRj, busy_adjustment[2]);
- }
- else
- enforce_full_fr_latency (cpu, in_FRj);
- if (FRj_1 >= 0)
- {
- if (use_is_media (cpu, FRj_1))
- {
- busy_adjustment[3] = 2;
- decrease_FR_busy (cpu, FRj_1, busy_adjustment[3]);
- }
- else
- enforce_full_fr_latency (cpu, FRj_1);
- }
- }
- if (out_ACC40Sk >= 0)
- {
- busy_adjustment[4] = 1;
- decrease_ACC_busy (cpu, out_ACC40Sk, busy_adjustment[4]);
- if (ACC40Sk_1 >= 0)
- {
- busy_adjustment[5] = 1;
- decrease_ACC_busy (cpu, ACC40Sk_1, busy_adjustment[5]);
- }
- if (ACC40Sk_2 >= 0)
- {
- busy_adjustment[6] = 1;
- decrease_ACC_busy (cpu, ACC40Sk_2, busy_adjustment[6]);
- }
- if (ACC40Sk_3 >= 0)
- {
- busy_adjustment[7] = 1;
- decrease_ACC_busy (cpu, ACC40Sk_3, busy_adjustment[7]);
- }
- }
- else if (out_ACC40Uk >= 0)
- {
- busy_adjustment[4] = 1;
- decrease_ACC_busy (cpu, out_ACC40Uk, busy_adjustment[4]);
- if (ACC40Uk_1 >= 0)
- {
- busy_adjustment[5] = 1;
- decrease_ACC_busy (cpu, ACC40Uk_1, busy_adjustment[5]);
- }
- if (ACC40Uk_2 >= 0)
- {
- busy_adjustment[6] = 1;
- decrease_ACC_busy (cpu, ACC40Uk_2, busy_adjustment[6]);
- }
- if (ACC40Uk_3 >= 0)
- {
- busy_adjustment[7] = 1;
- decrease_ACC_busy (cpu, ACC40Uk_3, busy_adjustment[7]);
- }
- }
- /* The post processing must wait if there is a dependency on a FR
- which is not ready yet. */
- ps->post_wait = cycles;
- post_wait_for_FR (cpu, in_FRi);
- post_wait_for_FR (cpu, FRi_1);
- post_wait_for_FR (cpu, in_FRj);
- post_wait_for_FR (cpu, FRj_1);
- post_wait_for_ACC (cpu, out_ACC40Sk);
- post_wait_for_ACC (cpu, ACC40Sk_1);
- post_wait_for_ACC (cpu, ACC40Sk_2);
- post_wait_for_ACC (cpu, ACC40Sk_3);
- post_wait_for_ACC (cpu, out_ACC40Uk);
- post_wait_for_ACC (cpu, ACC40Uk_1);
- post_wait_for_ACC (cpu, ACC40Uk_2);
- post_wait_for_ACC (cpu, ACC40Uk_3);
- /* Restore the busy cycles of the registers we used. */
- fr = ps->fr_busy;
- acc = ps->acc_busy;
- fr[in_FRi] += busy_adjustment[0];
- if (FRi_1 >= 0)
- fr[FRi_1] += busy_adjustment[1];
- fr[in_FRj] += busy_adjustment[2];
- if (FRj_1 > 0)
- fr[FRj_1] += busy_adjustment[3];
- if (out_ACC40Sk >= 0)
- {
- acc[out_ACC40Sk] += busy_adjustment[4];
- if (ACC40Sk_1 >= 0)
- acc[ACC40Sk_1] += busy_adjustment[5];
- if (ACC40Sk_2 >= 0)
- acc[ACC40Sk_2] += busy_adjustment[6];
- if (ACC40Sk_3 >= 0)
- acc[ACC40Sk_3] += busy_adjustment[7];
- }
- else if (out_ACC40Uk >= 0)
- {
- acc[out_ACC40Uk] += busy_adjustment[4];
- if (ACC40Uk_1 >= 0)
- acc[ACC40Uk_1] += busy_adjustment[5];
- if (ACC40Uk_2 >= 0)
- acc[ACC40Uk_2] += busy_adjustment[6];
- if (ACC40Uk_3 >= 0)
- acc[ACC40Uk_3] += busy_adjustment[7];
- }
- /* The latency of tht output register will be at least the latency of the
- other inputs. Once initiated, post-processing will take 1 cycle. */
- if (out_ACC40Sk >= 0)
- {
- update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
- if (ACC40Sk_1 >= 0)
- update_ACC_latency (cpu, ACC40Sk_1, ps->post_wait + 1);
- if (ACC40Sk_2 >= 0)
- update_ACC_latency (cpu, ACC40Sk_2, ps->post_wait + 1);
- if (ACC40Sk_3 >= 0)
- update_ACC_latency (cpu, ACC40Sk_3, ps->post_wait + 1);
- }
- else if (out_ACC40Uk >= 0)
- {
- update_ACC_latency (cpu, out_ACC40Uk, ps->post_wait + 1);
- if (ACC40Uk_1 >= 0)
- update_ACC_latency (cpu, ACC40Uk_1, ps->post_wait + 1);
- if (ACC40Uk_2 >= 0)
- update_ACC_latency (cpu, ACC40Uk_2, ps->post_wait + 1);
- if (ACC40Uk_3 >= 0)
- update_ACC_latency (cpu, ACC40Uk_3, ps->post_wait + 1);
- }
- return cycles;
- }
- int
- frvbf_model_fr500_u_media_quad_complex (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_FRi, INT in_FRj,
- INT out_ACC40Sk)
- {
- int cycles;
- INT FRi_1;
- INT FRj_1;
- INT ACC40Sk_1;
- FRV_PROFILE_STATE *ps;
- int busy_adjustment[] = {0, 0, 0, 0, 0, 0};
- int *fr;
- int *acc;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- return 0;
- /* The preprocessing can execute right away. */
- cycles = idesc->timing->units[unit_num].done;
- FRi_1 = DUAL_REG (in_FRi);
- FRj_1 = DUAL_REG (in_FRj);
- ACC40Sk_1 = DUAL_REG (out_ACC40Sk);
- /* If the previous use of the registers was a media op,
- then their latency will be less than previously recorded.
- See Table 13-13 in the LSI. */
- ps = CPU_PROFILE_STATE (cpu);
- if (use_is_media (cpu, in_FRi))
- {
- busy_adjustment[0] = 2;
- decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
- }
- else
- enforce_full_fr_latency (cpu, in_FRi);
- if (FRi_1 >= 0)
- {
- if (use_is_media (cpu, FRi_1))
- {
- busy_adjustment[1] = 2;
- decrease_FR_busy (cpu, FRi_1, busy_adjustment[1]);
- }
- else
- enforce_full_fr_latency (cpu, FRi_1);
- }
- if (in_FRj != in_FRi)
- {
- if (use_is_media (cpu, in_FRj))
- {
- busy_adjustment[2] = 2;
- decrease_FR_busy (cpu, in_FRj, busy_adjustment[2]);
- }
- else
- enforce_full_fr_latency (cpu, in_FRj);
- if (FRj_1 >= 0)
- {
- if (use_is_media (cpu, FRj_1))
- {
- busy_adjustment[3] = 2;
- decrease_FR_busy (cpu, FRj_1, busy_adjustment[3]);
- }
- else
- enforce_full_fr_latency (cpu, FRj_1);
- }
- }
- if (out_ACC40Sk >= 0)
- {
- busy_adjustment[4] = 1;
- decrease_ACC_busy (cpu, out_ACC40Sk, busy_adjustment[4]);
- if (ACC40Sk_1 >= 0)
- {
- busy_adjustment[5] = 1;
- decrease_ACC_busy (cpu, ACC40Sk_1, busy_adjustment[5]);
- }
- }
- /* The post processing must wait if there is a dependency on a FR
- which is not ready yet. */
- ps->post_wait = cycles;
- post_wait_for_FR (cpu, in_FRi);
- post_wait_for_FR (cpu, FRi_1);
- post_wait_for_FR (cpu, in_FRj);
- post_wait_for_FR (cpu, FRj_1);
- post_wait_for_ACC (cpu, out_ACC40Sk);
- post_wait_for_ACC (cpu, ACC40Sk_1);
- /* Restore the busy cycles of the registers we used. */
- fr = ps->fr_busy;
- acc = ps->acc_busy;
- fr[in_FRi] += busy_adjustment[0];
- if (FRi_1 >= 0)
- fr[FRi_1] += busy_adjustment[1];
- fr[in_FRj] += busy_adjustment[2];
- if (FRj_1 > 0)
- fr[FRj_1] += busy_adjustment[3];
- if (out_ACC40Sk >= 0)
- {
- acc[out_ACC40Sk] += busy_adjustment[4];
- if (ACC40Sk_1 >= 0)
- acc[ACC40Sk_1] += busy_adjustment[5];
- }
- /* The latency of tht output register will be at least the latency of the
- other inputs. Once initiated, post-processing will take 1 cycle. */
- if (out_ACC40Sk >= 0)
- {
- update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
- if (ACC40Sk_1 >= 0)
- update_ACC_latency (cpu, ACC40Sk_1, ps->post_wait + 1);
- }
- return cycles;
- }
- int
- frvbf_model_fr500_u_media_dual_expand (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_FRi,
- INT out_FRk)
- {
- int cycles;
- INT dual_FRk;
- FRV_PROFILE_STATE *ps;
- int busy_adjustment[] = {0, 0, 0};
- int *fr;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- return 0;
- /* The preprocessing can execute right away. */
- cycles = idesc->timing->units[unit_num].done;
- /* If the previous use of the registers was a media op,
- then their latency will be less than previously recorded.
- See Table 13-13 in the LSI. */
- dual_FRk = DUAL_REG (out_FRk);
- ps = CPU_PROFILE_STATE (cpu);
- if (use_is_media (cpu, in_FRi))
- {
- busy_adjustment[0] = 2;
- decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
- }
- else
- enforce_full_fr_latency (cpu, in_FRi);
- if (out_FRk != in_FRi)
- {
- if (use_is_media (cpu, out_FRk))
- {
- busy_adjustment[1] = 2;
- decrease_FR_busy (cpu, out_FRk, busy_adjustment[1]);
- }
- else
- enforce_full_fr_latency (cpu, out_FRk);
- }
- if (dual_FRk >= 0 && dual_FRk != in_FRi)
- {
- if (use_is_media (cpu, dual_FRk))
- {
- busy_adjustment[2] = 2;
- decrease_FR_busy (cpu, dual_FRk, busy_adjustment[2]);
- }
- else
- enforce_full_fr_latency (cpu, dual_FRk);
- }
- /* The post processing must wait if there is a dependency on a FR
- which is not ready yet. */
- ps->post_wait = cycles;
- post_wait_for_FR (cpu, in_FRi);
- post_wait_for_FR (cpu, out_FRk);
- post_wait_for_FR (cpu, dual_FRk);
- /* Restore the busy cycles of the registers we used. */
- fr = ps->fr_busy;
- fr[in_FRi] += busy_adjustment[0];
- fr[out_FRk] += busy_adjustment[1];
- if (dual_FRk >= 0)
- fr[dual_FRk] += busy_adjustment[2];
- /* The latency of the output register will be at least the latency of the
- other inputs. Once initiated, post-processing will take 3 cycles. */
- update_FR_latency (cpu, out_FRk, ps->post_wait);
- update_FR_ptime (cpu, out_FRk, 3);
- /* Mark this use of the register as a media op. */
- set_use_is_media (cpu, out_FRk);
- if (dual_FRk >= 0)
- {
- update_FR_latency (cpu, dual_FRk, ps->post_wait);
- update_FR_ptime (cpu, dual_FRk, 3);
- /* Mark this use of the register as a media op. */
- set_use_is_media (cpu, dual_FRk);
- }
- return cycles;
- }
- int
- frvbf_model_fr500_u_media_dual_unpack (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_FRi,
- INT out_FRk)
- {
- int cycles;
- INT FRi_1;
- INT FRk_1;
- INT FRk_2;
- INT FRk_3;
- FRV_PROFILE_STATE *ps;
- int busy_adjustment[] = {0, 0, 0, 0, 0, 0};
- int *fr;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- return 0;
- /* The preprocessing can execute right away. */
- cycles = idesc->timing->units[unit_num].done;
- FRi_1 = DUAL_REG (in_FRi);
- FRk_1 = DUAL_REG (out_FRk);
- FRk_2 = DUAL_REG (FRk_1);
- FRk_3 = DUAL_REG (FRk_2);
- /* If the previous use of the registers was a media op,
- then their latency will be less than previously recorded.
- See Table 13-13 in the LSI. */
- ps = CPU_PROFILE_STATE (cpu);
- if (use_is_media (cpu, in_FRi))
- {
- busy_adjustment[0] = 2;
- decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
- }
- else
- enforce_full_fr_latency (cpu, in_FRi);
- if (FRi_1 >= 0 && use_is_media (cpu, FRi_1))
- {
- busy_adjustment[1] = 2;
- decrease_FR_busy (cpu, FRi_1, busy_adjustment[1]);
- }
- else
- enforce_full_fr_latency (cpu, FRi_1);
- if (out_FRk != in_FRi)
- {
- if (use_is_media (cpu, out_FRk))
- {
- busy_adjustment[2] = 2;
- decrease_FR_busy (cpu, out_FRk, busy_adjustment[2]);
- }
- else
- enforce_full_fr_latency (cpu, out_FRk);
- if (FRk_1 >= 0 && FRk_1 != in_FRi)
- {
- if (use_is_media (cpu, FRk_1))
- {
- busy_adjustment[3] = 2;
- decrease_FR_busy (cpu, FRk_1, busy_adjustment[3]);
- }
- else
- enforce_full_fr_latency (cpu, FRk_1);
- }
- if (FRk_2 >= 0 && FRk_2 != in_FRi)
- {
- if (use_is_media (cpu, FRk_2))
- {
- busy_adjustment[4] = 2;
- decrease_FR_busy (cpu, FRk_2, busy_adjustment[4]);
- }
- else
- enforce_full_fr_latency (cpu, FRk_2);
- }
- if (FRk_3 >= 0 && FRk_3 != in_FRi)
- {
- if (use_is_media (cpu, FRk_3))
- {
- busy_adjustment[5] = 2;
- decrease_FR_busy (cpu, FRk_3, busy_adjustment[5]);
- }
- else
- enforce_full_fr_latency (cpu, FRk_3);
- }
- }
- /* The post processing must wait if there is a dependency on a FR
- which is not ready yet. */
- ps->post_wait = cycles;
- post_wait_for_FR (cpu, in_FRi);
- post_wait_for_FR (cpu, FRi_1);
- post_wait_for_FR (cpu, out_FRk);
- post_wait_for_FR (cpu, FRk_1);
- post_wait_for_FR (cpu, FRk_2);
- post_wait_for_FR (cpu, FRk_3);
- /* Restore the busy cycles of the registers we used. */
- fr = ps->fr_busy;
- fr[in_FRi] += busy_adjustment[0];
- if (FRi_1 >= 0)
- fr[FRi_1] += busy_adjustment[1];
- fr[out_FRk] += busy_adjustment[2];
- if (FRk_1 >= 0)
- fr[FRk_1] += busy_adjustment[3];
- if (FRk_2 >= 0)
- fr[FRk_2] += busy_adjustment[4];
- if (FRk_3 >= 0)
- fr[FRk_3] += busy_adjustment[5];
- /* The latency of tht output register will be at least the latency of the
- other inputs. Once initiated, post-processing will take 3 cycles. */
- update_FR_latency (cpu, out_FRk, ps->post_wait);
- update_FR_ptime (cpu, out_FRk, 3);
- /* Mark this use of the register as a media op. */
- set_use_is_media (cpu, out_FRk);
- if (FRk_1 >= 0)
- {
- update_FR_latency (cpu, FRk_1, ps->post_wait);
- update_FR_ptime (cpu, FRk_1, 3);
- /* Mark this use of the register as a media op. */
- set_use_is_media (cpu, FRk_1);
- }
- if (FRk_2 >= 0)
- {
- update_FR_latency (cpu, FRk_2, ps->post_wait);
- update_FR_ptime (cpu, FRk_2, 3);
- /* Mark this use of the register as a media op. */
- set_use_is_media (cpu, FRk_2);
- }
- if (FRk_3 >= 0)
- {
- update_FR_latency (cpu, FRk_3, ps->post_wait);
- update_FR_ptime (cpu, FRk_3, 3);
- /* Mark this use of the register as a media op. */
- set_use_is_media (cpu, FRk_3);
- }
- return cycles;
- }
- int
- frvbf_model_fr500_u_media_dual_btoh (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_FRj,
- INT out_FRk)
- {
- return frvbf_model_fr500_u_media_dual_expand (cpu, idesc, unit_num,
- referenced, in_FRj, out_FRk);
- }
- int
- frvbf_model_fr500_u_media_dual_htob (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_FRj,
- INT out_FRk)
- {
- int cycles;
- INT dual_FRj;
- FRV_PROFILE_STATE *ps;
- int busy_adjustment[] = {0, 0, 0};
- int *fr;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- return 0;
- /* The preprocessing can execute right away. */
- cycles = idesc->timing->units[unit_num].done;
- /* If the previous use of the registers was a media op,
- then their latency will be less than previously recorded.
- See Table 13-13 in the LSI. */
- dual_FRj = DUAL_REG (in_FRj);
- ps = CPU_PROFILE_STATE (cpu);
- if (use_is_media (cpu, in_FRj))
- {
- busy_adjustment[0] = 2;
- decrease_FR_busy (cpu, in_FRj, busy_adjustment[0]);
- }
- else
- enforce_full_fr_latency (cpu, in_FRj);
- if (dual_FRj >= 0)
- {
- if (use_is_media (cpu, dual_FRj))
- {
- busy_adjustment[1] = 2;
- decrease_FR_busy (cpu, dual_FRj, busy_adjustment[1]);
- }
- else
- enforce_full_fr_latency (cpu, dual_FRj);
- }
- if (out_FRk != in_FRj)
- {
- if (use_is_media (cpu, out_FRk))
- {
- busy_adjustment[2] = 2;
- decrease_FR_busy (cpu, out_FRk, busy_adjustment[2]);
- }
- else
- enforce_full_fr_latency (cpu, out_FRk);
- }
- /* The post processing must wait if there is a dependency on a FR
- which is not ready yet. */
- ps->post_wait = cycles;
- post_wait_for_FR (cpu, in_FRj);
- post_wait_for_FR (cpu, dual_FRj);
- post_wait_for_FR (cpu, out_FRk);
- /* Restore the busy cycles of the registers we used. */
- fr = ps->fr_busy;
- fr[in_FRj] += busy_adjustment[0];
- if (dual_FRj >= 0)
- fr[dual_FRj] += busy_adjustment[1];
- fr[out_FRk] += busy_adjustment[2];
- /* The latency of tht output register will be at least the latency of the
- other inputs. */
- update_FR_latency (cpu, out_FRk, ps->post_wait);
- /* Once initiated, post-processing will take 3 cycles. */
- update_FR_ptime (cpu, out_FRk, 3);
- /* Mark this use of the register as a media op. */
- set_use_is_media (cpu, out_FRk);
- return cycles;
- }
- int
- frvbf_model_fr500_u_media_dual_btohe (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced,
- INT in_FRj,
- INT out_FRk)
- {
- int cycles;
- INT FRk_1;
- INT FRk_2;
- INT FRk_3;
- FRV_PROFILE_STATE *ps;
- int busy_adjustment[] = {0, 0, 0, 0, 0};
- int *fr;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- return 0;
- /* The preprocessing can execute right away. */
- cycles = idesc->timing->units[unit_num].done;
- FRk_1 = DUAL_REG (out_FRk);
- FRk_2 = DUAL_REG (FRk_1);
- FRk_3 = DUAL_REG (FRk_2);
- /* If the previous use of the registers was a media op,
- then their latency will be less than previously recorded.
- See Table 13-13 in the LSI. */
- ps = CPU_PROFILE_STATE (cpu);
- if (use_is_media (cpu, in_FRj))
- {
- busy_adjustment[0] = 2;
- decrease_FR_busy (cpu, in_FRj, busy_adjustment[0]);
- }
- else
- enforce_full_fr_latency (cpu, in_FRj);
- if (out_FRk != in_FRj)
- {
- if (use_is_media (cpu, out_FRk))
- {
- busy_adjustment[1] = 2;
- decrease_FR_busy (cpu, out_FRk, busy_adjustment[1]);
- }
- else
- enforce_full_fr_latency (cpu, out_FRk);
- if (FRk_1 >= 0 && FRk_1 != in_FRj)
- {
- if (use_is_media (cpu, FRk_1))
- {
- busy_adjustment[2] = 2;
- decrease_FR_busy (cpu, FRk_1, busy_adjustment[2]);
- }
- else
- enforce_full_fr_latency (cpu, FRk_1);
- }
- if (FRk_2 >= 0 && FRk_2 != in_FRj)
- {
- if (use_is_media (cpu, FRk_2))
- {
- busy_adjustment[3] = 2;
- decrease_FR_busy (cpu, FRk_2, busy_adjustment[3]);
- }
- else
- enforce_full_fr_latency (cpu, FRk_2);
- }
- if (FRk_3 >= 0 && FRk_3 != in_FRj)
- {
- if (use_is_media (cpu, FRk_3))
- {
- busy_adjustment[4] = 2;
- decrease_FR_busy (cpu, FRk_3, busy_adjustment[4]);
- }
- else
- enforce_full_fr_latency (cpu, FRk_3);
- }
- }
- /* The post processing must wait if there is a dependency on a FR
- which is not ready yet. */
- ps->post_wait = cycles;
- post_wait_for_FR (cpu, in_FRj);
- post_wait_for_FR (cpu, out_FRk);
- post_wait_for_FR (cpu, FRk_1);
- post_wait_for_FR (cpu, FRk_2);
- post_wait_for_FR (cpu, FRk_3);
- /* Restore the busy cycles of the registers we used. */
- fr = ps->fr_busy;
- fr[in_FRj] += busy_adjustment[0];
- fr[out_FRk] += busy_adjustment[1];
- if (FRk_1 >= 0)
- fr[FRk_1] += busy_adjustment[2];
- if (FRk_2 >= 0)
- fr[FRk_2] += busy_adjustment[3];
- if (FRk_3 >= 0)
- fr[FRk_3] += busy_adjustment[4];
- /* The latency of tht output register will be at least the latency of the
- other inputs. Once initiated, post-processing will take 3 cycles. */
- update_FR_latency (cpu, out_FRk, ps->post_wait);
- update_FR_ptime (cpu, out_FRk, 3);
- /* Mark this use of the register as a media op. */
- set_use_is_media (cpu, out_FRk);
- if (FRk_1 >= 0)
- {
- update_FR_latency (cpu, FRk_1, ps->post_wait);
- update_FR_ptime (cpu, FRk_1, 3);
- /* Mark this use of the register as a media op. */
- set_use_is_media (cpu, FRk_1);
- }
- if (FRk_2 >= 0)
- {
- update_FR_latency (cpu, FRk_2, ps->post_wait);
- update_FR_ptime (cpu, FRk_2, 3);
- /* Mark this use of the register as a media op. */
- set_use_is_media (cpu, FRk_2);
- }
- if (FRk_3 >= 0)
- {
- update_FR_latency (cpu, FRk_3, ps->post_wait);
- update_FR_ptime (cpu, FRk_3, 3);
- /* Mark this use of the register as a media op. */
- set_use_is_media (cpu, FRk_3);
- }
- return cycles;
- }
- int
- frvbf_model_fr500_u_barrier (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced)
- {
- int cycles;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- {
- int i;
- /* Wait for ALL resources. */
- for (i = 0; i < 64; ++i)
- {
- enforce_full_fr_latency (cpu, i);
- vliw_wait_for_GR (cpu, i);
- vliw_wait_for_FR (cpu, i);
- vliw_wait_for_ACC (cpu, i);
- }
- for (i = 0; i < 8; ++i)
- vliw_wait_for_CCR (cpu, i);
- for (i = 0; i < 2; ++i)
- {
- vliw_wait_for_idiv_resource (cpu, i);
- vliw_wait_for_fdiv_resource (cpu, i);
- vliw_wait_for_fsqrt_resource (cpu, i);
- }
- handle_resource_wait (cpu);
- for (i = 0; i < 64; ++i)
- {
- load_wait_for_GR (cpu, i);
- load_wait_for_FR (cpu, i);
- }
- trace_vliw_wait_cycles (cpu);
- return 0;
- }
- cycles = idesc->timing->units[unit_num].done;
- return cycles;
- }
- int
- frvbf_model_fr500_u_membar (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced)
- {
- int cycles;
- if (model_insn == FRV_INSN_MODEL_PASS_1)
- {
- int i;
- /* Wait for ALL resources, except GR and ICC. */
- for (i = 0; i < 64; ++i)
- {
- enforce_full_fr_latency (cpu, i);
- vliw_wait_for_FR (cpu, i);
- vliw_wait_for_ACC (cpu, i);
- }
- for (i = 0; i < 4; ++i)
- vliw_wait_for_CCR (cpu, i);
- for (i = 0; i < 2; ++i)
- {
- vliw_wait_for_idiv_resource (cpu, i);
- vliw_wait_for_fdiv_resource (cpu, i);
- vliw_wait_for_fsqrt_resource (cpu, i);
- }
- handle_resource_wait (cpu);
- for (i = 0; i < 64; ++i)
- {
- load_wait_for_FR (cpu, i);
- }
- trace_vliw_wait_cycles (cpu);
- return 0;
- }
- cycles = idesc->timing->units[unit_num].done;
- return cycles;
- }
- /* The frv machine is a fictional implementation of the fr500 which implements
- all frv architectural features. */
- int
- frvbf_model_frv_u_exec (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced)
- {
- return idesc->timing->units[unit_num].done;
- }
- /* The simple machine is a fictional implementation of the fr500 which
- implements limited frv architectural features. */
- int
- frvbf_model_simple_u_exec (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced)
- {
- return idesc->timing->units[unit_num].done;
- }
- /* The tomcat machine is models a prototype fr500 machine which had a few
- bugs and restrictions to work around. */
- int
- frvbf_model_tomcat_u_exec (SIM_CPU *cpu, const IDESC *idesc,
- int unit_num, int referenced)
- {
- return idesc->timing->units[unit_num].done;
- }
- #endif /* WITH_PROFILE_MODEL_P */
|