profile-fr500.c 91 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205
  1. /* frv simulator fr500 dependent profiling code.
  2. Copyright (C) 1998-2015 Free Software Foundation, Inc.
  3. Contributed by Red Hat
  4. This file is part of the GNU simulators.
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #define WANT_CPU
  17. #define WANT_CPU_FRVBF
  18. #include "sim-main.h"
  19. #include "bfd.h"
  20. #if WITH_PROFILE_MODEL_P
  21. #include "profile.h"
  22. #include "profile-fr500.h"
  23. /* Initialize cycle counting for an insn.
  24. FIRST_P is non-zero if this is the first insn in a set of parallel
  25. insns. */
  26. void
  27. fr500_model_insn_before (SIM_CPU *cpu, int first_p)
  28. {
  29. if (first_p)
  30. {
  31. MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
  32. FRV_PROFILE_STATE *ps = CPU_PROFILE_STATE (cpu);
  33. ps->cur_gr_complex = ps->prev_gr_complex;
  34. d->cur_fpop = d->prev_fpop;
  35. d->cur_media = d->prev_media;
  36. d->cur_cc_complex = d->prev_cc_complex;
  37. }
  38. }
  39. /* Record the cycles computed for an insn.
  40. LAST_P is non-zero if this is the last insn in a set of parallel insns,
  41. and we update the total cycle count.
  42. CYCLES is the cycle count of the insn. */
  43. void
  44. fr500_model_insn_after (SIM_CPU *cpu, int last_p, int cycles)
  45. {
  46. if (last_p)
  47. {
  48. MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
  49. FRV_PROFILE_STATE *ps = CPU_PROFILE_STATE (cpu);
  50. ps->prev_gr_complex = ps->cur_gr_complex;
  51. d->prev_fpop = d->cur_fpop;
  52. d->prev_media = d->cur_media;
  53. d->prev_cc_complex = d->cur_cc_complex;
  54. }
  55. }
  56. static void
  57. set_use_is_fpop (SIM_CPU *cpu, INT fr)
  58. {
  59. MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
  60. fr500_reset_fr_flags (cpu, (fr));
  61. d->cur_fpop |= (((DI)1) << (fr));
  62. }
  63. static void
  64. set_use_not_fpop (SIM_CPU *cpu, INT fr)
  65. {
  66. MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
  67. d->cur_fpop &= ~(((DI)1) << (fr));
  68. }
  69. static int
  70. use_is_fpop (SIM_CPU *cpu, INT fr)
  71. {
  72. MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
  73. return d->prev_fpop & (((DI)1) << (fr));
  74. }
  75. static void
  76. set_use_is_media ( SIM_CPU *cpu, INT fr)
  77. {
  78. MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
  79. fr500_reset_fr_flags (cpu, (fr));
  80. d->cur_media |= (((DI)1) << (fr));
  81. }
  82. static void
  83. set_use_not_media (SIM_CPU *cpu, INT fr)
  84. {
  85. MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
  86. d->cur_media &= ~(((DI)1) << (fr));
  87. }
  88. static int
  89. use_is_media (SIM_CPU *cpu, INT fr)
  90. {
  91. MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
  92. return d->prev_media & (((DI)1) << (fr));
  93. }
  94. static void
  95. set_use_is_cc_complex (SIM_CPU *cpu, INT cc)
  96. {
  97. MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
  98. fr500_reset_cc_flags (cpu, cc);
  99. d->cur_cc_complex |= (((DI)1) << (cc));
  100. }
  101. static void
  102. set_use_not_cc_complex (SIM_CPU *cpu, INT cc)
  103. {
  104. MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
  105. d->cur_cc_complex &= ~(((DI)1) << (cc));
  106. }
  107. static int
  108. use_is_cc_complex (SIM_CPU *cpu, INT cc)
  109. {
  110. MODEL_FR500_DATA *d = CPU_MODEL_DATA (cpu);
  111. return d->prev_cc_complex & (((DI)1) << (cc));
  112. }
  113. void
  114. fr500_reset_fr_flags (SIM_CPU *cpu, INT fr)
  115. {
  116. set_use_not_fpop (cpu, fr);
  117. set_use_not_media (cpu, fr);
  118. }
  119. void
  120. fr500_reset_cc_flags (SIM_CPU *cpu, INT cc)
  121. {
  122. set_use_not_cc_complex (cpu, cc);
  123. }
  124. /* Latency of floating point registers may be less than recorded when followed
  125. by another floating point insn. */
  126. static void
  127. adjust_float_register_busy (SIM_CPU *cpu, INT in_FRi, INT in_FRj, INT out_FRk,
  128. int cycles)
  129. {
  130. /* If the registers were previously used in a floating point op,
  131. then their latency will be less than previously recorded.
  132. See Table 13-13 in the LSI. */
  133. if (in_FRi >= 0)
  134. if (use_is_fpop (cpu, in_FRi))
  135. decrease_FR_busy (cpu, in_FRi, cycles);
  136. else
  137. enforce_full_fr_latency (cpu, in_FRi);
  138. if (in_FRj >= 0 && in_FRj != in_FRi)
  139. if (use_is_fpop (cpu, in_FRj))
  140. decrease_FR_busy (cpu, in_FRj, cycles);
  141. else
  142. enforce_full_fr_latency (cpu, in_FRj);
  143. if (out_FRk >= 0 && out_FRk != in_FRi && out_FRk != in_FRj)
  144. if (use_is_fpop (cpu, out_FRk))
  145. decrease_FR_busy (cpu, out_FRk, cycles);
  146. else
  147. enforce_full_fr_latency (cpu, out_FRk);
  148. }
  149. /* Latency of floating point registers may be less than recorded when followed
  150. by another floating point insn. */
  151. static void
  152. adjust_double_register_busy (SIM_CPU *cpu, INT in_FRi, INT in_FRj, INT out_FRk,
  153. int cycles)
  154. {
  155. /* If the registers were previously used in a floating point op,
  156. then their latency will be less than previously recorded.
  157. See Table 13-13 in the LSI. */
  158. adjust_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, cycles);
  159. if (in_FRi >= 0) ++in_FRi;
  160. if (in_FRj >= 0) ++in_FRj;
  161. if (out_FRk >= 0) ++out_FRk;
  162. adjust_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, cycles);
  163. }
  164. /* Latency of floating point registers is less than recorded when followed
  165. by another floating point insn. */
  166. static void
  167. restore_float_register_busy (SIM_CPU *cpu, INT in_FRi, INT in_FRj, INT out_FRk,
  168. int cycles)
  169. {
  170. /* If the registers were previously used in a floating point op,
  171. then their latency will be less than previously recorded.
  172. See Table 13-13 in the LSI. */
  173. if (in_FRi >= 0 && use_is_fpop (cpu, in_FRi))
  174. increase_FR_busy (cpu, in_FRi, cycles);
  175. if (in_FRj != in_FRi && use_is_fpop (cpu, in_FRj))
  176. increase_FR_busy (cpu, in_FRj, cycles);
  177. if (out_FRk != in_FRi && out_FRk != in_FRj && use_is_fpop (cpu, out_FRk))
  178. increase_FR_busy (cpu, out_FRk, cycles);
  179. }
  180. /* Latency of floating point registers is less than recorded when followed
  181. by another floating point insn. */
  182. static void
  183. restore_double_register_busy (SIM_CPU *cpu, INT in_FRi, INT in_FRj, INT out_FRk,
  184. int cycles)
  185. {
  186. /* If the registers were previously used in a floating point op,
  187. then their latency will be less than previously recorded.
  188. See Table 13-13 in the LSI. */
  189. restore_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, cycles);
  190. if (in_FRi >= 0) ++in_FRi;
  191. if (in_FRj >= 0) ++in_FRj;
  192. if (out_FRk >= 0) ++out_FRk;
  193. restore_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, cycles);
  194. }
  195. int
  196. frvbf_model_fr500_u_exec (SIM_CPU *cpu, const IDESC *idesc,
  197. int unit_num, int referenced)
  198. {
  199. return idesc->timing->units[unit_num].done;
  200. }
  201. int
  202. frvbf_model_fr500_u_integer (SIM_CPU *cpu, const IDESC *idesc,
  203. int unit_num, int referenced,
  204. INT in_GRi, INT in_GRj, INT out_GRk,
  205. INT out_ICCi_1)
  206. {
  207. int cycles;
  208. if (model_insn == FRV_INSN_MODEL_PASS_1)
  209. {
  210. /* icc0-icc4 are the upper 4 fields of the CCR. */
  211. if (out_ICCi_1 >= 0)
  212. out_ICCi_1 += 4;
  213. /* The entire VLIW insn must wait if there is a dependency on a register
  214. which is not ready yet.
  215. The latency of the registers may be less than previously recorded,
  216. depending on how they were used previously.
  217. See Table 13-8 in the LSI. */
  218. if (in_GRi != out_GRk && in_GRi >= 0)
  219. {
  220. if (use_is_gr_complex (cpu, in_GRi))
  221. decrease_GR_busy (cpu, in_GRi, 1);
  222. }
  223. if (in_GRj != out_GRk && in_GRj != in_GRi && in_GRj >= 0)
  224. {
  225. if (use_is_gr_complex (cpu, in_GRj))
  226. decrease_GR_busy (cpu, in_GRj, 1);
  227. }
  228. vliw_wait_for_GR (cpu, in_GRi);
  229. vliw_wait_for_GR (cpu, in_GRj);
  230. vliw_wait_for_GR (cpu, out_GRk);
  231. vliw_wait_for_CCR (cpu, out_ICCi_1);
  232. handle_resource_wait (cpu);
  233. load_wait_for_GR (cpu, in_GRi);
  234. load_wait_for_GR (cpu, in_GRj);
  235. load_wait_for_GR (cpu, out_GRk);
  236. trace_vliw_wait_cycles (cpu);
  237. return 0;
  238. }
  239. /* GRk is available immediately to the next VLIW insn as is ICCi_1. */
  240. cycles = idesc->timing->units[unit_num].done;
  241. return cycles;
  242. }
  243. int
  244. frvbf_model_fr500_u_imul (SIM_CPU *cpu, const IDESC *idesc,
  245. int unit_num, int referenced,
  246. INT in_GRi, INT in_GRj, INT out_GRk, INT out_ICCi_1)
  247. {
  248. int cycles;
  249. /* icc0-icc4 are the upper 4 fields of the CCR. */
  250. if (out_ICCi_1 >= 0)
  251. out_ICCi_1 += 4;
  252. if (model_insn == FRV_INSN_MODEL_PASS_1)
  253. {
  254. /* The entire VLIW insn must wait if there is a dependency on a register
  255. which is not ready yet.
  256. The latency of the registers may be less than previously recorded,
  257. depending on how they were used previously.
  258. See Table 13-8 in the LSI. */
  259. if (in_GRi != out_GRk && in_GRi >= 0)
  260. {
  261. if (use_is_gr_complex (cpu, in_GRi))
  262. decrease_GR_busy (cpu, in_GRi, 1);
  263. }
  264. if (in_GRj != out_GRk && in_GRj != in_GRi && in_GRj >= 0)
  265. {
  266. if (use_is_gr_complex (cpu, in_GRj))
  267. decrease_GR_busy (cpu, in_GRj, 1);
  268. }
  269. vliw_wait_for_GR (cpu, in_GRi);
  270. vliw_wait_for_GR (cpu, in_GRj);
  271. vliw_wait_for_GRdouble (cpu, out_GRk);
  272. vliw_wait_for_CCR (cpu, out_ICCi_1);
  273. handle_resource_wait (cpu);
  274. load_wait_for_GR (cpu, in_GRi);
  275. load_wait_for_GR (cpu, in_GRj);
  276. load_wait_for_GRdouble (cpu, out_GRk);
  277. trace_vliw_wait_cycles (cpu);
  278. return 0;
  279. }
  280. /* GRk has a latency of 2 cycles. */
  281. cycles = idesc->timing->units[unit_num].done;
  282. update_GRdouble_latency (cpu, out_GRk, cycles + 2);
  283. set_use_is_gr_complex (cpu, out_GRk);
  284. set_use_is_gr_complex (cpu, out_GRk + 1);
  285. /* ICCi_1 has a latency of 1 cycle. */
  286. update_CCR_latency (cpu, out_ICCi_1, cycles + 1);
  287. return cycles;
  288. }
  289. int
  290. frvbf_model_fr500_u_idiv (SIM_CPU *cpu, const IDESC *idesc,
  291. int unit_num, int referenced,
  292. INT in_GRi, INT in_GRj, INT out_GRk, INT out_ICCi_1)
  293. {
  294. int cycles;
  295. FRV_VLIW *vliw;
  296. int slot;
  297. /* icc0-icc4 are the upper 4 fields of the CCR. */
  298. if (out_ICCi_1 >= 0)
  299. out_ICCi_1 += 4;
  300. vliw = CPU_VLIW (cpu);
  301. slot = vliw->next_slot - 1;
  302. slot = (*vliw->current_vliw)[slot] - UNIT_I0;
  303. if (model_insn == FRV_INSN_MODEL_PASS_1)
  304. {
  305. /* The entire VLIW insn must wait if there is a dependency on a register
  306. which is not ready yet.
  307. The latency of the registers may be less than previously recorded,
  308. depending on how they were used previously.
  309. See Table 13-8 in the LSI. */
  310. if (in_GRi != out_GRk && in_GRi >= 0)
  311. {
  312. if (use_is_gr_complex (cpu, in_GRi))
  313. decrease_GR_busy (cpu, in_GRi, 1);
  314. }
  315. if (in_GRj != out_GRk && in_GRj != in_GRi && in_GRj >= 0)
  316. {
  317. if (use_is_gr_complex (cpu, in_GRj))
  318. decrease_GR_busy (cpu, in_GRj, 1);
  319. }
  320. vliw_wait_for_GR (cpu, in_GRi);
  321. vliw_wait_for_GR (cpu, in_GRj);
  322. vliw_wait_for_GR (cpu, out_GRk);
  323. vliw_wait_for_CCR (cpu, out_ICCi_1);
  324. vliw_wait_for_idiv_resource (cpu, slot);
  325. handle_resource_wait (cpu);
  326. load_wait_for_GR (cpu, in_GRi);
  327. load_wait_for_GR (cpu, in_GRj);
  328. load_wait_for_GR (cpu, out_GRk);
  329. trace_vliw_wait_cycles (cpu);
  330. return 0;
  331. }
  332. /* GRk has a latency of 19 cycles! */
  333. cycles = idesc->timing->units[unit_num].done;
  334. update_GR_latency (cpu, out_GRk, cycles + 19);
  335. set_use_is_gr_complex (cpu, out_GRk);
  336. /* ICCi_1 has a latency of 19 cycles. */
  337. update_CCR_latency (cpu, out_ICCi_1, cycles + 19);
  338. set_use_is_cc_complex (cpu, out_ICCi_1);
  339. if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
  340. {
  341. /* GNER has a latency of 18 cycles. */
  342. update_SPR_latency (cpu, GNER_FOR_GR (out_GRk), cycles + 18);
  343. }
  344. /* the idiv resource has a latency of 18 cycles! */
  345. update_idiv_resource_latency (cpu, slot, cycles + 18);
  346. return cycles;
  347. }
  348. int
  349. frvbf_model_fr500_u_branch (SIM_CPU *cpu, const IDESC *idesc,
  350. int unit_num, int referenced,
  351. INT in_GRi, INT in_GRj,
  352. INT in_ICCi_2, INT in_FCCi_2)
  353. {
  354. int cycles;
  355. FRV_PROFILE_STATE *ps;
  356. if (model_insn == FRV_INSN_MODEL_PASS_1)
  357. {
  358. /* icc0-icc4 are the upper 4 fields of the CCR. */
  359. if (in_ICCi_2 >= 0)
  360. in_ICCi_2 += 4;
  361. /* The entire VLIW insn must wait if there is a dependency on a register
  362. which is not ready yet.
  363. The latency of the registers may be less than previously recorded,
  364. depending on how they were used previously.
  365. See Table 13-8 in the LSI. */
  366. if (in_GRi >= 0)
  367. {
  368. if (use_is_gr_complex (cpu, in_GRi))
  369. decrease_GR_busy (cpu, in_GRi, 1);
  370. }
  371. if (in_GRj != in_GRi && in_GRj >= 0)
  372. {
  373. if (use_is_gr_complex (cpu, in_GRj))
  374. decrease_GR_busy (cpu, in_GRj, 1);
  375. }
  376. vliw_wait_for_GR (cpu, in_GRi);
  377. vliw_wait_for_GR (cpu, in_GRj);
  378. vliw_wait_for_CCR (cpu, in_ICCi_2);
  379. vliw_wait_for_CCR (cpu, in_FCCi_2);
  380. handle_resource_wait (cpu);
  381. load_wait_for_GR (cpu, in_GRi);
  382. load_wait_for_GR (cpu, in_GRj);
  383. trace_vliw_wait_cycles (cpu);
  384. return 0;
  385. }
  386. /* When counting branches taken or not taken, don't consider branches after
  387. the first taken branch in a vliw insn. */
  388. ps = CPU_PROFILE_STATE (cpu);
  389. if (! ps->vliw_branch_taken)
  390. {
  391. /* (1 << 4): The pc is the 5th element in inputs, outputs.
  392. ??? can be cleaned up */
  393. PROFILE_DATA *p = CPU_PROFILE_DATA (cpu);
  394. int taken = (referenced & (1 << 4)) != 0;
  395. if (taken)
  396. {
  397. ++PROFILE_MODEL_TAKEN_COUNT (p);
  398. ps->vliw_branch_taken = 1;
  399. }
  400. else
  401. ++PROFILE_MODEL_UNTAKEN_COUNT (p);
  402. }
  403. cycles = idesc->timing->units[unit_num].done;
  404. return cycles;
  405. }
  406. int
  407. frvbf_model_fr500_u_trap (SIM_CPU *cpu, const IDESC *idesc,
  408. int unit_num, int referenced,
  409. INT in_GRi, INT in_GRj,
  410. INT in_ICCi_2, INT in_FCCi_2)
  411. {
  412. int cycles;
  413. if (model_insn == FRV_INSN_MODEL_PASS_1)
  414. {
  415. /* icc0-icc4 are the upper 4 fields of the CCR. */
  416. if (in_ICCi_2 >= 0)
  417. in_ICCi_2 += 4;
  418. /* The entire VLIW insn must wait if there is a dependency on a register
  419. which is not ready yet.
  420. The latency of the registers may be less than previously recorded,
  421. depending on how they were used previously.
  422. See Table 13-8 in the LSI. */
  423. if (in_GRi >= 0)
  424. {
  425. if (use_is_gr_complex (cpu, in_GRi))
  426. decrease_GR_busy (cpu, in_GRi, 1);
  427. }
  428. if (in_GRj != in_GRi && in_GRj >= 0)
  429. {
  430. if (use_is_gr_complex (cpu, in_GRj))
  431. decrease_GR_busy (cpu, in_GRj, 1);
  432. }
  433. vliw_wait_for_GR (cpu, in_GRi);
  434. vliw_wait_for_GR (cpu, in_GRj);
  435. vliw_wait_for_CCR (cpu, in_ICCi_2);
  436. vliw_wait_for_CCR (cpu, in_FCCi_2);
  437. handle_resource_wait (cpu);
  438. load_wait_for_GR (cpu, in_GRi);
  439. load_wait_for_GR (cpu, in_GRj);
  440. trace_vliw_wait_cycles (cpu);
  441. return 0;
  442. }
  443. cycles = idesc->timing->units[unit_num].done;
  444. return cycles;
  445. }
  446. int
  447. frvbf_model_fr500_u_check (SIM_CPU *cpu, const IDESC *idesc,
  448. int unit_num, int referenced,
  449. INT in_ICCi_3, INT in_FCCi_3)
  450. {
  451. int cycles;
  452. if (model_insn == FRV_INSN_MODEL_PASS_1)
  453. {
  454. /* icc0-icc4 are the upper 4 fields of the CCR. */
  455. if (in_ICCi_3 >= 0)
  456. in_ICCi_3 += 4;
  457. /* The entire VLIW insn must wait if there is a dependency on a register
  458. which is not ready yet. */
  459. vliw_wait_for_CCR (cpu, in_ICCi_3);
  460. vliw_wait_for_CCR (cpu, in_FCCi_3);
  461. handle_resource_wait (cpu);
  462. trace_vliw_wait_cycles (cpu);
  463. return 0;
  464. }
  465. cycles = idesc->timing->units[unit_num].done;
  466. return cycles;
  467. }
  468. int
  469. frvbf_model_fr500_u_clrgr (SIM_CPU *cpu, const IDESC *idesc,
  470. int unit_num, int referenced,
  471. INT in_GRk)
  472. {
  473. int cycles;
  474. if (model_insn == FRV_INSN_MODEL_PASS_1)
  475. {
  476. /* Wait for both GNER registers or just the one specified. */
  477. if (in_GRk == -1)
  478. {
  479. vliw_wait_for_SPR (cpu, H_SPR_GNER0);
  480. vliw_wait_for_SPR (cpu, H_SPR_GNER1);
  481. }
  482. else
  483. vliw_wait_for_SPR (cpu, GNER_FOR_GR (in_GRk));
  484. handle_resource_wait (cpu);
  485. trace_vliw_wait_cycles (cpu);
  486. return 0;
  487. }
  488. cycles = idesc->timing->units[unit_num].done;
  489. return cycles;
  490. }
  491. int
  492. frvbf_model_fr500_u_clrfr (SIM_CPU *cpu, const IDESC *idesc,
  493. int unit_num, int referenced,
  494. INT in_FRk)
  495. {
  496. int cycles;
  497. if (model_insn == FRV_INSN_MODEL_PASS_1)
  498. {
  499. /* Wait for both GNER registers or just the one specified. */
  500. if (in_FRk == -1)
  501. {
  502. vliw_wait_for_SPR (cpu, H_SPR_FNER0);
  503. vliw_wait_for_SPR (cpu, H_SPR_FNER1);
  504. }
  505. else
  506. vliw_wait_for_SPR (cpu, FNER_FOR_FR (in_FRk));
  507. handle_resource_wait (cpu);
  508. trace_vliw_wait_cycles (cpu);
  509. return 0;
  510. }
  511. cycles = idesc->timing->units[unit_num].done;
  512. return cycles;
  513. }
  514. int
  515. frvbf_model_fr500_u_commit (SIM_CPU *cpu, const IDESC *idesc,
  516. int unit_num, int referenced,
  517. INT in_GRk, INT in_FRk)
  518. {
  519. int cycles;
  520. if (model_insn == FRV_INSN_MODEL_PASS_1)
  521. {
  522. /* If GR is specified, then FR is not and vice-versa. If neither is
  523. then it's a commitga or commitfa. Check the insn attribute to
  524. figure out which. */
  525. if (in_GRk != -1)
  526. vliw_wait_for_SPR (cpu, GNER_FOR_GR (in_GRk));
  527. else if (in_FRk != -1)
  528. vliw_wait_for_SPR (cpu, FNER_FOR_FR (in_FRk));
  529. else if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_FR_ACCESS))
  530. {
  531. vliw_wait_for_SPR (cpu, H_SPR_FNER0);
  532. vliw_wait_for_SPR (cpu, H_SPR_FNER1);
  533. }
  534. else
  535. {
  536. vliw_wait_for_SPR (cpu, H_SPR_GNER0);
  537. vliw_wait_for_SPR (cpu, H_SPR_GNER1);
  538. }
  539. handle_resource_wait (cpu);
  540. trace_vliw_wait_cycles (cpu);
  541. return 0;
  542. }
  543. cycles = idesc->timing->units[unit_num].done;
  544. return cycles;
  545. }
  546. int
  547. frvbf_model_fr500_u_set_hilo (SIM_CPU *cpu, const IDESC *idesc,
  548. int unit_num, int referenced,
  549. INT out_GRkhi, INT out_GRklo)
  550. {
  551. int cycles;
  552. if (model_insn == FRV_INSN_MODEL_PASS_1)
  553. {
  554. /* The entire VLIW insn must wait if there is a dependency on a GR
  555. which is not ready yet. */
  556. vliw_wait_for_GR (cpu, out_GRkhi);
  557. vliw_wait_for_GR (cpu, out_GRklo);
  558. handle_resource_wait (cpu);
  559. load_wait_for_GR (cpu, out_GRkhi);
  560. load_wait_for_GR (cpu, out_GRklo);
  561. trace_vliw_wait_cycles (cpu);
  562. return 0;
  563. }
  564. /* GRk is available immediately to the next VLIW insn. */
  565. cycles = idesc->timing->units[unit_num].done;
  566. set_use_not_gr_complex (cpu, out_GRkhi);
  567. set_use_not_gr_complex (cpu, out_GRklo);
  568. return cycles;
  569. }
  570. int
  571. frvbf_model_fr500_u_gr_load (SIM_CPU *cpu, const IDESC *idesc,
  572. int unit_num, int referenced,
  573. INT in_GRi, INT in_GRj,
  574. INT out_GRk, INT out_GRdoublek)
  575. {
  576. int cycles;
  577. if (model_insn == FRV_INSN_MODEL_PASS_1)
  578. {
  579. /* The entire VLIW insn must wait if there is a dependency on a register
  580. which is not ready yet.
  581. The latency of the registers may be less than previously recorded,
  582. depending on how they were used previously.
  583. See Table 13-8 in the LSI. */
  584. if (in_GRi != out_GRk && in_GRi != out_GRdoublek
  585. && in_GRi != out_GRdoublek + 1 && in_GRi >= 0)
  586. {
  587. if (use_is_gr_complex (cpu, in_GRi))
  588. decrease_GR_busy (cpu, in_GRi, 1);
  589. }
  590. if (in_GRj != in_GRi && in_GRj != out_GRk && in_GRj != out_GRdoublek
  591. && in_GRj != out_GRdoublek + 1 && in_GRj >= 0)
  592. {
  593. if (use_is_gr_complex (cpu, in_GRj))
  594. decrease_GR_busy (cpu, in_GRj, 1);
  595. }
  596. vliw_wait_for_GR (cpu, in_GRi);
  597. vliw_wait_for_GR (cpu, in_GRj);
  598. vliw_wait_for_GR (cpu, out_GRk);
  599. vliw_wait_for_GRdouble (cpu, out_GRdoublek);
  600. handle_resource_wait (cpu);
  601. load_wait_for_GR (cpu, in_GRi);
  602. load_wait_for_GR (cpu, in_GRj);
  603. load_wait_for_GR (cpu, out_GRk);
  604. load_wait_for_GRdouble (cpu, out_GRdoublek);
  605. trace_vliw_wait_cycles (cpu);
  606. return 0;
  607. }
  608. cycles = idesc->timing->units[unit_num].done;
  609. /* The latency of GRk for a load will depend on how long it takes to retrieve
  610. the the data from the cache or memory. */
  611. update_GR_latency_for_load (cpu, out_GRk, cycles);
  612. update_GRdouble_latency_for_load (cpu, out_GRdoublek, cycles);
  613. if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
  614. {
  615. /* GNER has a latency of 2 cycles. */
  616. update_SPR_latency (cpu, GNER_FOR_GR (out_GRk), cycles + 2);
  617. update_SPR_latency (cpu, GNER_FOR_GR (out_GRdoublek), cycles + 2);
  618. }
  619. if (out_GRk >= 0)
  620. set_use_is_gr_complex (cpu, out_GRk);
  621. if (out_GRdoublek != -1)
  622. {
  623. set_use_is_gr_complex (cpu, out_GRdoublek);
  624. set_use_is_gr_complex (cpu, out_GRdoublek + 1);
  625. }
  626. return cycles;
  627. }
  628. int
  629. frvbf_model_fr500_u_gr_store (SIM_CPU *cpu, const IDESC *idesc,
  630. int unit_num, int referenced,
  631. INT in_GRi, INT in_GRj,
  632. INT in_GRk, INT in_GRdoublek)
  633. {
  634. int cycles;
  635. if (model_insn == FRV_INSN_MODEL_PASS_1)
  636. {
  637. /* The entire VLIW insn must wait if there is a dependency on a register
  638. which is not ready yet.
  639. The latency of the registers may be less than previously recorded,
  640. depending on how they were used previously.
  641. See Table 13-8 in the LSI. */
  642. if (in_GRi >= 0)
  643. {
  644. if (use_is_gr_complex (cpu, in_GRi))
  645. decrease_GR_busy (cpu, in_GRi, 1);
  646. }
  647. if (in_GRj != in_GRi && in_GRj >= 0)
  648. {
  649. if (use_is_gr_complex (cpu, in_GRj))
  650. decrease_GR_busy (cpu, in_GRj, 1);
  651. }
  652. if (in_GRk != in_GRi && in_GRk != in_GRj && in_GRk >= 0)
  653. {
  654. if (use_is_gr_complex (cpu, in_GRk))
  655. decrease_GR_busy (cpu, in_GRk, 1);
  656. }
  657. if (in_GRdoublek != in_GRi && in_GRdoublek != in_GRj
  658. && in_GRdoublek + 1 != in_GRi && in_GRdoublek + 1 != in_GRj
  659. && in_GRdoublek >= 0)
  660. {
  661. if (use_is_gr_complex (cpu, in_GRdoublek))
  662. decrease_GR_busy (cpu, in_GRdoublek, 1);
  663. if (use_is_gr_complex (cpu, in_GRdoublek + 1))
  664. decrease_GR_busy (cpu, in_GRdoublek + 1, 1);
  665. }
  666. vliw_wait_for_GR (cpu, in_GRi);
  667. vliw_wait_for_GR (cpu, in_GRj);
  668. vliw_wait_for_GR (cpu, in_GRk);
  669. vliw_wait_for_GRdouble (cpu, in_GRdoublek);
  670. handle_resource_wait (cpu);
  671. load_wait_for_GR (cpu, in_GRi);
  672. load_wait_for_GR (cpu, in_GRj);
  673. load_wait_for_GR (cpu, in_GRk);
  674. load_wait_for_GRdouble (cpu, in_GRdoublek);
  675. trace_vliw_wait_cycles (cpu);
  676. return 0;
  677. }
  678. cycles = idesc->timing->units[unit_num].done;
  679. return cycles;
  680. }
  681. int
  682. frvbf_model_fr500_u_gr_r_store (SIM_CPU *cpu, const IDESC *idesc,
  683. int unit_num, int referenced,
  684. INT in_GRi, INT in_GRj,
  685. INT in_GRk, INT in_GRdoublek)
  686. {
  687. int cycles = frvbf_model_fr500_u_gr_store (cpu, idesc, unit_num, referenced,
  688. in_GRi, in_GRj, in_GRk,
  689. in_GRdoublek);
  690. if (model_insn == FRV_INSN_MODEL_PASS_2)
  691. {
  692. if (CPU_RSTR_INVALIDATE(cpu))
  693. request_cache_invalidate (cpu, CPU_DATA_CACHE (cpu), cycles);
  694. }
  695. return cycles;
  696. }
  697. int
  698. frvbf_model_fr500_u_fr_load (SIM_CPU *cpu, const IDESC *idesc,
  699. int unit_num, int referenced,
  700. INT in_GRi, INT in_GRj,
  701. INT out_FRk, INT out_FRdoublek)
  702. {
  703. int cycles;
  704. if (model_insn == FRV_INSN_MODEL_PASS_1)
  705. {
  706. /* The entire VLIW insn must wait if there is a dependency on a register
  707. which is not ready yet.
  708. The latency of the registers may be less than previously recorded,
  709. depending on how they were used previously.
  710. See Table 13-8 in the LSI. */
  711. if (in_GRi >= 0)
  712. {
  713. if (use_is_gr_complex (cpu, in_GRi))
  714. decrease_GR_busy (cpu, in_GRi, 1);
  715. }
  716. if (in_GRj != in_GRi && in_GRj >= 0)
  717. {
  718. if (use_is_gr_complex (cpu, in_GRj))
  719. decrease_GR_busy (cpu, in_GRj, 1);
  720. }
  721. if (out_FRk >= 0)
  722. {
  723. if (use_is_media (cpu, out_FRk))
  724. decrease_FR_busy (cpu, out_FRk, 1);
  725. else
  726. adjust_float_register_busy (cpu, -1, -1, out_FRk, 1);
  727. }
  728. if (out_FRdoublek >= 0)
  729. {
  730. if (use_is_media (cpu, out_FRdoublek))
  731. decrease_FR_busy (cpu, out_FRdoublek, 1);
  732. else
  733. adjust_float_register_busy (cpu, -1, -1, out_FRdoublek, 1);
  734. if (use_is_media (cpu, out_FRdoublek + 1))
  735. decrease_FR_busy (cpu, out_FRdoublek + 1, 1);
  736. else
  737. adjust_float_register_busy (cpu, -1, -1, out_FRdoublek + 1, 1);
  738. }
  739. vliw_wait_for_GR (cpu, in_GRi);
  740. vliw_wait_for_GR (cpu, in_GRj);
  741. vliw_wait_for_FR (cpu, out_FRk);
  742. vliw_wait_for_FRdouble (cpu, out_FRdoublek);
  743. if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
  744. {
  745. vliw_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
  746. vliw_wait_for_SPR (cpu, FNER_FOR_FR (out_FRdoublek));
  747. }
  748. handle_resource_wait (cpu);
  749. load_wait_for_GR (cpu, in_GRi);
  750. load_wait_for_GR (cpu, in_GRj);
  751. load_wait_for_FR (cpu, out_FRk);
  752. load_wait_for_FRdouble (cpu, out_FRdoublek);
  753. trace_vliw_wait_cycles (cpu);
  754. return 0;
  755. }
  756. cycles = idesc->timing->units[unit_num].done;
  757. /* The latency of FRk for a load will depend on how long it takes to retrieve
  758. the the data from the cache or memory. */
  759. update_FR_latency_for_load (cpu, out_FRk, cycles);
  760. update_FRdouble_latency_for_load (cpu, out_FRdoublek, cycles);
  761. if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
  762. {
  763. /* FNER has a latency of 3 cycles. */
  764. update_SPR_latency (cpu, FNER_FOR_FR (out_FRk), cycles + 3);
  765. update_SPR_latency (cpu, FNER_FOR_FR (out_FRdoublek), cycles + 3);
  766. }
  767. fr500_reset_fr_flags (cpu, out_FRk);
  768. return cycles;
  769. }
  770. int
  771. frvbf_model_fr500_u_fr_store (SIM_CPU *cpu, const IDESC *idesc,
  772. int unit_num, int referenced,
  773. INT in_GRi, INT in_GRj,
  774. INT in_FRk, INT in_FRdoublek)
  775. {
  776. int cycles;
  777. if (model_insn == FRV_INSN_MODEL_PASS_1)
  778. {
  779. /* The entire VLIW insn must wait if there is a dependency on a register
  780. which is not ready yet.
  781. The latency of the registers may be less than previously recorded,
  782. depending on how they were used previously.
  783. See Table 13-8 in the LSI. */
  784. if (in_GRi >= 0)
  785. {
  786. if (use_is_gr_complex (cpu, in_GRi))
  787. decrease_GR_busy (cpu, in_GRi, 1);
  788. }
  789. if (in_GRj != in_GRi && in_GRj >= 0)
  790. {
  791. if (use_is_gr_complex (cpu, in_GRj))
  792. decrease_GR_busy (cpu, in_GRj, 1);
  793. }
  794. if (in_FRk >= 0)
  795. {
  796. if (use_is_media (cpu, in_FRk))
  797. decrease_FR_busy (cpu, in_FRk, 1);
  798. else
  799. adjust_float_register_busy (cpu, -1, -1, in_FRk, 1);
  800. }
  801. if (in_FRdoublek >= 0)
  802. {
  803. if (use_is_media (cpu, in_FRdoublek))
  804. decrease_FR_busy (cpu, in_FRdoublek, 1);
  805. else
  806. adjust_float_register_busy (cpu, -1, -1, in_FRdoublek, 1);
  807. if (use_is_media (cpu, in_FRdoublek + 1))
  808. decrease_FR_busy (cpu, in_FRdoublek + 1, 1);
  809. else
  810. adjust_float_register_busy (cpu, -1, -1, in_FRdoublek + 1, 1);
  811. }
  812. vliw_wait_for_GR (cpu, in_GRi);
  813. vliw_wait_for_GR (cpu, in_GRj);
  814. vliw_wait_for_FR (cpu, in_FRk);
  815. vliw_wait_for_FRdouble (cpu, in_FRdoublek);
  816. handle_resource_wait (cpu);
  817. load_wait_for_GR (cpu, in_GRi);
  818. load_wait_for_GR (cpu, in_GRj);
  819. load_wait_for_FR (cpu, in_FRk);
  820. load_wait_for_FRdouble (cpu, in_FRdoublek);
  821. trace_vliw_wait_cycles (cpu);
  822. return 0;
  823. }
  824. cycles = idesc->timing->units[unit_num].done;
  825. return cycles;
  826. }
  827. int
  828. frvbf_model_fr500_u_fr_r_store (SIM_CPU *cpu, const IDESC *idesc,
  829. int unit_num, int referenced,
  830. INT in_GRi, INT in_GRj,
  831. INT in_FRk, INT in_FRdoublek)
  832. {
  833. int cycles = frvbf_model_fr500_u_fr_store (cpu, idesc, unit_num, referenced,
  834. in_GRi, in_GRj, in_FRk,
  835. in_FRdoublek);
  836. if (model_insn == FRV_INSN_MODEL_PASS_2)
  837. {
  838. if (CPU_RSTR_INVALIDATE(cpu))
  839. request_cache_invalidate (cpu, CPU_DATA_CACHE (cpu), cycles);
  840. }
  841. return cycles;
  842. }
  843. int
  844. frvbf_model_fr500_u_swap (SIM_CPU *cpu, const IDESC *idesc,
  845. int unit_num, int referenced,
  846. INT in_GRi, INT in_GRj, INT out_GRk)
  847. {
  848. int cycles;
  849. if (model_insn == FRV_INSN_MODEL_PASS_1)
  850. {
  851. /* The entire VLIW insn must wait if there is a dependency on a register
  852. which is not ready yet.
  853. The latency of the registers may be less than previously recorded,
  854. depending on how they were used previously.
  855. See Table 13-8 in the LSI. */
  856. if (in_GRi != out_GRk && in_GRi >= 0)
  857. {
  858. if (use_is_gr_complex (cpu, in_GRi))
  859. decrease_GR_busy (cpu, in_GRi, 1);
  860. }
  861. if (in_GRj != out_GRk && in_GRj != in_GRi && in_GRj >= 0)
  862. {
  863. if (use_is_gr_complex (cpu, in_GRj))
  864. decrease_GR_busy (cpu, in_GRj, 1);
  865. }
  866. vliw_wait_for_GR (cpu, in_GRi);
  867. vliw_wait_for_GR (cpu, in_GRj);
  868. vliw_wait_for_GR (cpu, out_GRk);
  869. handle_resource_wait (cpu);
  870. load_wait_for_GR (cpu, in_GRi);
  871. load_wait_for_GR (cpu, in_GRj);
  872. load_wait_for_GR (cpu, out_GRk);
  873. trace_vliw_wait_cycles (cpu);
  874. return 0;
  875. }
  876. cycles = idesc->timing->units[unit_num].done;
  877. /* The latency of GRk will depend on how long it takes to swap
  878. the the data from the cache or memory. */
  879. update_GR_latency_for_swap (cpu, out_GRk, cycles);
  880. set_use_is_gr_complex (cpu, out_GRk);
  881. return cycles;
  882. }
  883. int
  884. frvbf_model_fr500_u_fr2fr (SIM_CPU *cpu, const IDESC *idesc,
  885. int unit_num, int referenced,
  886. INT in_FRj, INT out_FRk)
  887. {
  888. int cycles;
  889. if (model_insn == FRV_INSN_MODEL_PASS_1)
  890. {
  891. /* The entire VLIW insn must wait if there is a dependency on a register
  892. which is not ready yet. */
  893. if (in_FRj >= 0)
  894. {
  895. if (use_is_media (cpu, in_FRj))
  896. decrease_FR_busy (cpu, in_FRj, 1);
  897. else
  898. adjust_float_register_busy (cpu, -1, in_FRj, -1, 1);
  899. }
  900. if (out_FRk >= 0 && out_FRk != in_FRj)
  901. {
  902. if (use_is_media (cpu, out_FRk))
  903. decrease_FR_busy (cpu, out_FRk, 1);
  904. else
  905. adjust_float_register_busy (cpu, -1, -1, out_FRk, 1);
  906. }
  907. vliw_wait_for_FR (cpu, in_FRj);
  908. vliw_wait_for_FR (cpu, out_FRk);
  909. handle_resource_wait (cpu);
  910. load_wait_for_FR (cpu, in_FRj);
  911. load_wait_for_FR (cpu, out_FRk);
  912. trace_vliw_wait_cycles (cpu);
  913. return 0;
  914. }
  915. /* The latency of FRj is 3 cycles. */
  916. cycles = idesc->timing->units[unit_num].done;
  917. update_FR_latency (cpu, out_FRk, cycles + 3);
  918. return cycles;
  919. }
  920. int
  921. frvbf_model_fr500_u_fr2gr (SIM_CPU *cpu, const IDESC *idesc,
  922. int unit_num, int referenced,
  923. INT in_FRk, INT out_GRj)
  924. {
  925. int cycles;
  926. if (model_insn == FRV_INSN_MODEL_PASS_1)
  927. {
  928. /* The entire VLIW insn must wait if there is a dependency on a register
  929. which is not ready yet. */
  930. if (in_FRk >= 0)
  931. {
  932. if (use_is_media (cpu, in_FRk))
  933. decrease_FR_busy (cpu, in_FRk, 1);
  934. else
  935. adjust_float_register_busy (cpu, -1, in_FRk, -1, 1);
  936. }
  937. vliw_wait_for_FR (cpu, in_FRk);
  938. vliw_wait_for_GR (cpu, out_GRj);
  939. handle_resource_wait (cpu);
  940. load_wait_for_FR (cpu, in_FRk);
  941. load_wait_for_GR (cpu, out_GRj);
  942. trace_vliw_wait_cycles (cpu);
  943. return 0;
  944. }
  945. /* The latency of GRj is 2 cycles. */
  946. cycles = idesc->timing->units[unit_num].done;
  947. update_GR_latency (cpu, out_GRj, cycles + 2);
  948. set_use_is_gr_complex (cpu, out_GRj);
  949. return cycles;
  950. }
  951. int
  952. frvbf_model_fr500_u_spr2gr (SIM_CPU *cpu, const IDESC *idesc,
  953. int unit_num, int referenced,
  954. INT in_spr, INT out_GRj)
  955. {
  956. int cycles;
  957. if (model_insn == FRV_INSN_MODEL_PASS_1)
  958. {
  959. /* The entire VLIW insn must wait if there is a dependency on a register
  960. which is not ready yet. */
  961. vliw_wait_for_SPR (cpu, in_spr);
  962. vliw_wait_for_GR (cpu, out_GRj);
  963. handle_resource_wait (cpu);
  964. load_wait_for_GR (cpu, out_GRj);
  965. trace_vliw_wait_cycles (cpu);
  966. return 0;
  967. }
  968. cycles = idesc->timing->units[unit_num].done;
  969. #if 0 /* no latency? */
  970. /* The latency of GRj is 2 cycles. */
  971. update_GR_latency (cpu, out_GRj, cycles + 2);
  972. #endif
  973. return cycles;
  974. }
  975. int
  976. frvbf_model_fr500_u_gr2fr (SIM_CPU *cpu, const IDESC *idesc,
  977. int unit_num, int referenced,
  978. INT in_GRj, INT out_FRk)
  979. {
  980. int cycles;
  981. if (model_insn == FRV_INSN_MODEL_PASS_1)
  982. {
  983. /* The entire VLIW insn must wait if there is a dependency on a register
  984. which is not ready yet.
  985. The latency of the registers may be less than previously recorded,
  986. depending on how they were used previously.
  987. See Table 13-8 in the LSI. */
  988. if (in_GRj >= 0)
  989. {
  990. if (use_is_gr_complex (cpu, in_GRj))
  991. decrease_GR_busy (cpu, in_GRj, 1);
  992. }
  993. if (out_FRk >= 0)
  994. {
  995. if (use_is_media (cpu, out_FRk))
  996. decrease_FR_busy (cpu, out_FRk, 1);
  997. else
  998. adjust_float_register_busy (cpu, -1, -1, out_FRk, 1);
  999. }
  1000. vliw_wait_for_GR (cpu, in_GRj);
  1001. vliw_wait_for_FR (cpu, out_FRk);
  1002. handle_resource_wait (cpu);
  1003. load_wait_for_GR (cpu, in_GRj);
  1004. load_wait_for_FR (cpu, out_FRk);
  1005. trace_vliw_wait_cycles (cpu);
  1006. return 0;
  1007. }
  1008. /* The latency of FRk is 2 cycles. */
  1009. cycles = idesc->timing->units[unit_num].done;
  1010. update_FR_latency (cpu, out_FRk, cycles + 2);
  1011. /* Mark this use of the register as NOT a floating point op. */
  1012. fr500_reset_fr_flags (cpu, out_FRk);
  1013. return cycles;
  1014. }
  1015. int
  1016. frvbf_model_fr500_u_gr2spr (SIM_CPU *cpu, const IDESC *idesc,
  1017. int unit_num, int referenced,
  1018. INT in_GRj, INT out_spr)
  1019. {
  1020. int cycles;
  1021. if (model_insn == FRV_INSN_MODEL_PASS_1)
  1022. {
  1023. /* The entire VLIW insn must wait if there is a dependency on a register
  1024. which is not ready yet.
  1025. The latency of the registers may be less than previously recorded,
  1026. depending on how they were used previously.
  1027. See Table 13-8 in the LSI. */
  1028. if (in_GRj >= 0)
  1029. {
  1030. if (use_is_gr_complex (cpu, in_GRj))
  1031. decrease_GR_busy (cpu, in_GRj, 1);
  1032. }
  1033. vliw_wait_for_GR (cpu, in_GRj);
  1034. vliw_wait_for_SPR (cpu, out_spr);
  1035. handle_resource_wait (cpu);
  1036. load_wait_for_GR (cpu, in_GRj);
  1037. trace_vliw_wait_cycles (cpu);
  1038. return 0;
  1039. }
  1040. cycles = idesc->timing->units[unit_num].done;
  1041. #if 0
  1042. /* The latency of spr is ? cycles. */
  1043. update_SPR_latency (cpu, out_spr, cycles + ?);
  1044. #endif
  1045. return cycles;
  1046. }
  1047. int
  1048. frvbf_model_fr500_u_ici (SIM_CPU *cpu, const IDESC *idesc,
  1049. int unit_num, int referenced,
  1050. INT in_GRi, INT in_GRj)
  1051. {
  1052. int cycles;
  1053. if (model_insn == FRV_INSN_MODEL_PASS_1)
  1054. {
  1055. /* The entire VLIW insn must wait if there is a dependency on a register
  1056. which is not ready yet.
  1057. The latency of the registers may be less than previously recorded,
  1058. depending on how they were used previously.
  1059. See Table 13-8 in the LSI. */
  1060. if (in_GRi >= 0)
  1061. {
  1062. if (use_is_gr_complex (cpu, in_GRi))
  1063. decrease_GR_busy (cpu, in_GRi, 1);
  1064. }
  1065. if (in_GRj != in_GRi && in_GRj >= 0)
  1066. {
  1067. if (use_is_gr_complex (cpu, in_GRj))
  1068. decrease_GR_busy (cpu, in_GRj, 1);
  1069. }
  1070. vliw_wait_for_GR (cpu, in_GRi);
  1071. vliw_wait_for_GR (cpu, in_GRj);
  1072. handle_resource_wait (cpu);
  1073. load_wait_for_GR (cpu, in_GRi);
  1074. load_wait_for_GR (cpu, in_GRj);
  1075. trace_vliw_wait_cycles (cpu);
  1076. return 0;
  1077. }
  1078. cycles = idesc->timing->units[unit_num].done;
  1079. request_cache_invalidate (cpu, CPU_INSN_CACHE (cpu), cycles);
  1080. return cycles;
  1081. }
  1082. int
  1083. frvbf_model_fr500_u_dci (SIM_CPU *cpu, const IDESC *idesc,
  1084. int unit_num, int referenced,
  1085. INT in_GRi, INT in_GRj)
  1086. {
  1087. int cycles;
  1088. if (model_insn == FRV_INSN_MODEL_PASS_1)
  1089. {
  1090. /* The entire VLIW insn must wait if there is a dependency on a register
  1091. which is not ready yet.
  1092. The latency of the registers may be less than previously recorded,
  1093. depending on how they were used previously.
  1094. See Table 13-8 in the LSI. */
  1095. if (in_GRi >= 0)
  1096. {
  1097. if (use_is_gr_complex (cpu, in_GRi))
  1098. decrease_GR_busy (cpu, in_GRi, 1);
  1099. }
  1100. if (in_GRj != in_GRi && in_GRj >= 0)
  1101. {
  1102. if (use_is_gr_complex (cpu, in_GRj))
  1103. decrease_GR_busy (cpu, in_GRj, 1);
  1104. }
  1105. vliw_wait_for_GR (cpu, in_GRi);
  1106. vliw_wait_for_GR (cpu, in_GRj);
  1107. handle_resource_wait (cpu);
  1108. load_wait_for_GR (cpu, in_GRi);
  1109. load_wait_for_GR (cpu, in_GRj);
  1110. trace_vliw_wait_cycles (cpu);
  1111. return 0;
  1112. }
  1113. cycles = idesc->timing->units[unit_num].done;
  1114. request_cache_invalidate (cpu, CPU_DATA_CACHE (cpu), cycles);
  1115. return cycles;
  1116. }
  1117. int
  1118. frvbf_model_fr500_u_dcf (SIM_CPU *cpu, const IDESC *idesc,
  1119. int unit_num, int referenced,
  1120. INT in_GRi, INT in_GRj)
  1121. {
  1122. int cycles;
  1123. if (model_insn == FRV_INSN_MODEL_PASS_1)
  1124. {
  1125. /* The entire VLIW insn must wait if there is a dependency on a register
  1126. which is not ready yet.
  1127. The latency of the registers may be less than previously recorded,
  1128. depending on how they were used previously.
  1129. See Table 13-8 in the LSI. */
  1130. if (in_GRi >= 0)
  1131. {
  1132. if (use_is_gr_complex (cpu, in_GRi))
  1133. decrease_GR_busy (cpu, in_GRi, 1);
  1134. }
  1135. if (in_GRj != in_GRi && in_GRj >= 0)
  1136. {
  1137. if (use_is_gr_complex (cpu, in_GRj))
  1138. decrease_GR_busy (cpu, in_GRj, 1);
  1139. }
  1140. vliw_wait_for_GR (cpu, in_GRi);
  1141. vliw_wait_for_GR (cpu, in_GRj);
  1142. handle_resource_wait (cpu);
  1143. load_wait_for_GR (cpu, in_GRi);
  1144. load_wait_for_GR (cpu, in_GRj);
  1145. trace_vliw_wait_cycles (cpu);
  1146. return 0;
  1147. }
  1148. cycles = idesc->timing->units[unit_num].done;
  1149. request_cache_flush (cpu, CPU_DATA_CACHE (cpu), cycles);
  1150. return cycles;
  1151. }
  1152. int
  1153. frvbf_model_fr500_u_icpl (SIM_CPU *cpu, const IDESC *idesc,
  1154. int unit_num, int referenced,
  1155. INT in_GRi, INT in_GRj)
  1156. {
  1157. int cycles;
  1158. if (model_insn == FRV_INSN_MODEL_PASS_1)
  1159. {
  1160. /* The entire VLIW insn must wait if there is a dependency on a register
  1161. which is not ready yet.
  1162. The latency of the registers may be less than previously recorded,
  1163. depending on how they were used previously.
  1164. See Table 13-8 in the LSI. */
  1165. if (in_GRi >= 0)
  1166. {
  1167. if (use_is_gr_complex (cpu, in_GRi))
  1168. decrease_GR_busy (cpu, in_GRi, 1);
  1169. }
  1170. if (in_GRj != in_GRi && in_GRj >= 0)
  1171. {
  1172. if (use_is_gr_complex (cpu, in_GRj))
  1173. decrease_GR_busy (cpu, in_GRj, 1);
  1174. }
  1175. vliw_wait_for_GR (cpu, in_GRi);
  1176. vliw_wait_for_GR (cpu, in_GRj);
  1177. handle_resource_wait (cpu);
  1178. load_wait_for_GR (cpu, in_GRi);
  1179. load_wait_for_GR (cpu, in_GRj);
  1180. trace_vliw_wait_cycles (cpu);
  1181. return 0;
  1182. }
  1183. cycles = idesc->timing->units[unit_num].done;
  1184. request_cache_preload (cpu, CPU_INSN_CACHE (cpu), cycles);
  1185. return cycles;
  1186. }
  1187. int
  1188. frvbf_model_fr500_u_dcpl (SIM_CPU *cpu, const IDESC *idesc,
  1189. int unit_num, int referenced,
  1190. INT in_GRi, INT in_GRj)
  1191. {
  1192. int cycles;
  1193. if (model_insn == FRV_INSN_MODEL_PASS_1)
  1194. {
  1195. /* The entire VLIW insn must wait if there is a dependency on a register
  1196. which is not ready yet.
  1197. The latency of the registers may be less than previously recorded,
  1198. depending on how they were used previously.
  1199. See Table 13-8 in the LSI. */
  1200. if (in_GRi >= 0)
  1201. {
  1202. if (use_is_gr_complex (cpu, in_GRi))
  1203. decrease_GR_busy (cpu, in_GRi, 1);
  1204. }
  1205. if (in_GRj != in_GRi && in_GRj >= 0)
  1206. {
  1207. if (use_is_gr_complex (cpu, in_GRj))
  1208. decrease_GR_busy (cpu, in_GRj, 1);
  1209. }
  1210. vliw_wait_for_GR (cpu, in_GRi);
  1211. vliw_wait_for_GR (cpu, in_GRj);
  1212. handle_resource_wait (cpu);
  1213. load_wait_for_GR (cpu, in_GRi);
  1214. load_wait_for_GR (cpu, in_GRj);
  1215. trace_vliw_wait_cycles (cpu);
  1216. return 0;
  1217. }
  1218. cycles = idesc->timing->units[unit_num].done;
  1219. request_cache_preload (cpu, CPU_DATA_CACHE (cpu), cycles);
  1220. return cycles;
  1221. }
  1222. int
  1223. frvbf_model_fr500_u_icul (SIM_CPU *cpu, const IDESC *idesc,
  1224. int unit_num, int referenced,
  1225. INT in_GRi, INT in_GRj)
  1226. {
  1227. int cycles;
  1228. if (model_insn == FRV_INSN_MODEL_PASS_1)
  1229. {
  1230. /* The entire VLIW insn must wait if there is a dependency on a register
  1231. which is not ready yet.
  1232. The latency of the registers may be less than previously recorded,
  1233. depending on how they were used previously.
  1234. See Table 13-8 in the LSI. */
  1235. if (in_GRi >= 0)
  1236. {
  1237. if (use_is_gr_complex (cpu, in_GRi))
  1238. decrease_GR_busy (cpu, in_GRi, 1);
  1239. }
  1240. if (in_GRj != in_GRi && in_GRj >= 0)
  1241. {
  1242. if (use_is_gr_complex (cpu, in_GRj))
  1243. decrease_GR_busy (cpu, in_GRj, 1);
  1244. }
  1245. vliw_wait_for_GR (cpu, in_GRi);
  1246. vliw_wait_for_GR (cpu, in_GRj);
  1247. handle_resource_wait (cpu);
  1248. load_wait_for_GR (cpu, in_GRi);
  1249. load_wait_for_GR (cpu, in_GRj);
  1250. trace_vliw_wait_cycles (cpu);
  1251. return 0;
  1252. }
  1253. cycles = idesc->timing->units[unit_num].done;
  1254. request_cache_unlock (cpu, CPU_INSN_CACHE (cpu), cycles);
  1255. return cycles;
  1256. }
  1257. int
  1258. frvbf_model_fr500_u_dcul (SIM_CPU *cpu, const IDESC *idesc,
  1259. int unit_num, int referenced,
  1260. INT in_GRi, INT in_GRj)
  1261. {
  1262. int cycles;
  1263. if (model_insn == FRV_INSN_MODEL_PASS_1)
  1264. {
  1265. /* The entire VLIW insn must wait if there is a dependency on a register
  1266. which is not ready yet.
  1267. The latency of the registers may be less than previously recorded,
  1268. depending on how they were used previously.
  1269. See Table 13-8 in the LSI. */
  1270. if (in_GRi >= 0)
  1271. {
  1272. if (use_is_gr_complex (cpu, in_GRi))
  1273. decrease_GR_busy (cpu, in_GRi, 1);
  1274. }
  1275. if (in_GRj != in_GRi && in_GRj >= 0)
  1276. {
  1277. if (use_is_gr_complex (cpu, in_GRj))
  1278. decrease_GR_busy (cpu, in_GRj, 1);
  1279. }
  1280. vliw_wait_for_GR (cpu, in_GRi);
  1281. vliw_wait_for_GR (cpu, in_GRj);
  1282. handle_resource_wait (cpu);
  1283. load_wait_for_GR (cpu, in_GRi);
  1284. load_wait_for_GR (cpu, in_GRj);
  1285. trace_vliw_wait_cycles (cpu);
  1286. return 0;
  1287. }
  1288. cycles = idesc->timing->units[unit_num].done;
  1289. request_cache_unlock (cpu, CPU_DATA_CACHE (cpu), cycles);
  1290. return cycles;
  1291. }
  1292. int
  1293. frvbf_model_fr500_u_float_arith (SIM_CPU *cpu, const IDESC *idesc,
  1294. int unit_num, int referenced,
  1295. INT in_FRi, INT in_FRj,
  1296. INT in_FRdoublei, INT in_FRdoublej,
  1297. INT out_FRk, INT out_FRdoublek)
  1298. {
  1299. int cycles;
  1300. FRV_PROFILE_STATE *ps;
  1301. if (model_insn == FRV_INSN_MODEL_PASS_1)
  1302. return 0;
  1303. /* The preprocessing can execute right away. */
  1304. cycles = idesc->timing->units[unit_num].done;
  1305. /* The post processing must wait if there is a dependency on a FR
  1306. which is not ready yet. */
  1307. adjust_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, 1);
  1308. adjust_double_register_busy (cpu, in_FRdoublei, in_FRdoublej, out_FRdoublek,
  1309. 1);
  1310. ps = CPU_PROFILE_STATE (cpu);
  1311. ps->post_wait = cycles;
  1312. post_wait_for_FR (cpu, in_FRi);
  1313. post_wait_for_FR (cpu, in_FRj);
  1314. post_wait_for_FR (cpu, out_FRk);
  1315. post_wait_for_FRdouble (cpu, in_FRdoublei);
  1316. post_wait_for_FRdouble (cpu, in_FRdoublej);
  1317. post_wait_for_FRdouble (cpu, out_FRdoublek);
  1318. if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
  1319. {
  1320. post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
  1321. post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRdoublek));
  1322. }
  1323. restore_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, 1);
  1324. restore_double_register_busy (cpu, in_FRdoublei, in_FRdoublej, out_FRdoublek,
  1325. 1);
  1326. /* The latency of FRk will be at least the latency of the other inputs. */
  1327. update_FR_latency (cpu, out_FRk, ps->post_wait);
  1328. update_FRdouble_latency (cpu, out_FRdoublek, ps->post_wait);
  1329. if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
  1330. {
  1331. update_SPR_latency (cpu, FNER_FOR_FR (out_FRk), ps->post_wait);
  1332. update_SPR_latency (cpu, FNER_FOR_FR (out_FRdoublek), ps->post_wait);
  1333. }
  1334. /* Once initiated, post-processing will take 3 cycles. */
  1335. update_FR_ptime (cpu, out_FRk, 3);
  1336. update_FRdouble_ptime (cpu, out_FRdoublek, 3);
  1337. if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
  1338. {
  1339. update_SPR_ptime (cpu, FNER_FOR_FR (out_FRk), 3);
  1340. update_SPR_ptime (cpu, FNER_FOR_FR (out_FRdoublek), 3);
  1341. }
  1342. /* Mark this use of the register as a floating point op. */
  1343. if (out_FRk >= 0)
  1344. set_use_is_fpop (cpu, out_FRk);
  1345. if (out_FRdoublek >= 0)
  1346. {
  1347. set_use_is_fpop (cpu, out_FRdoublek);
  1348. if (out_FRdoublek < 63)
  1349. set_use_is_fpop (cpu, out_FRdoublek + 1);
  1350. }
  1351. return cycles;
  1352. }
  1353. int
  1354. frvbf_model_fr500_u_float_dual_arith (SIM_CPU *cpu, const IDESC *idesc,
  1355. int unit_num, int referenced,
  1356. INT in_FRi, INT in_FRj,
  1357. INT in_FRdoublei, INT in_FRdoublej,
  1358. INT out_FRk, INT out_FRdoublek)
  1359. {
  1360. int cycles;
  1361. INT dual_FRi;
  1362. INT dual_FRj;
  1363. INT dual_FRk;
  1364. INT dual_FRdoublei;
  1365. INT dual_FRdoublej;
  1366. INT dual_FRdoublek;
  1367. FRV_PROFILE_STATE *ps;
  1368. if (model_insn == FRV_INSN_MODEL_PASS_1)
  1369. return 0;
  1370. /* The preprocessing can execute right away. */
  1371. cycles = idesc->timing->units[unit_num].done;
  1372. /* The post processing must wait if there is a dependency on a FR
  1373. which is not ready yet. */
  1374. dual_FRi = DUAL_REG (in_FRi);
  1375. dual_FRj = DUAL_REG (in_FRj);
  1376. dual_FRk = DUAL_REG (out_FRk);
  1377. dual_FRdoublei = DUAL_DOUBLE (in_FRdoublei);
  1378. dual_FRdoublej = DUAL_DOUBLE (in_FRdoublej);
  1379. dual_FRdoublek = DUAL_DOUBLE (out_FRdoublek);
  1380. adjust_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, 1);
  1381. adjust_float_register_busy (cpu, dual_FRi, dual_FRj, dual_FRk, 1);
  1382. adjust_double_register_busy (cpu, in_FRdoublei, in_FRdoublej, out_FRdoublek,
  1383. 1);
  1384. adjust_double_register_busy (cpu, dual_FRdoublei, dual_FRdoublej,
  1385. dual_FRdoublek, 1);
  1386. ps = CPU_PROFILE_STATE (cpu);
  1387. ps->post_wait = cycles;
  1388. post_wait_for_FR (cpu, in_FRi);
  1389. post_wait_for_FR (cpu, in_FRj);
  1390. post_wait_for_FR (cpu, out_FRk);
  1391. post_wait_for_FR (cpu, dual_FRi);
  1392. post_wait_for_FR (cpu, dual_FRj);
  1393. post_wait_for_FR (cpu, dual_FRk);
  1394. post_wait_for_FRdouble (cpu, in_FRdoublei);
  1395. post_wait_for_FRdouble (cpu, in_FRdoublej);
  1396. post_wait_for_FRdouble (cpu, out_FRdoublek);
  1397. post_wait_for_FRdouble (cpu, dual_FRdoublei);
  1398. post_wait_for_FRdouble (cpu, dual_FRdoublej);
  1399. post_wait_for_FRdouble (cpu, dual_FRdoublek);
  1400. if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
  1401. {
  1402. post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
  1403. post_wait_for_SPR (cpu, FNER_FOR_FR (dual_FRk));
  1404. post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRdoublek));
  1405. post_wait_for_SPR (cpu, FNER_FOR_FR (dual_FRdoublek));
  1406. }
  1407. restore_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, 1);
  1408. restore_float_register_busy (cpu, dual_FRi, dual_FRj, dual_FRk, 1);
  1409. restore_double_register_busy (cpu, in_FRdoublei, in_FRdoublej, out_FRdoublek,
  1410. 1);
  1411. restore_double_register_busy (cpu, dual_FRdoublei, dual_FRdoublej,
  1412. dual_FRdoublek, 1);
  1413. /* The latency of FRk will be at least the latency of the other inputs. */
  1414. update_FR_latency (cpu, out_FRk, ps->post_wait);
  1415. update_FR_latency (cpu, dual_FRk, ps->post_wait);
  1416. update_FRdouble_latency (cpu, out_FRdoublek, ps->post_wait);
  1417. update_FRdouble_latency (cpu, dual_FRdoublek, ps->post_wait);
  1418. if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
  1419. {
  1420. update_SPR_latency (cpu, FNER_FOR_FR (out_FRk), ps->post_wait);
  1421. update_SPR_latency (cpu, FNER_FOR_FR (dual_FRk), ps->post_wait);
  1422. update_SPR_latency (cpu, FNER_FOR_FR (out_FRdoublek), ps->post_wait);
  1423. update_SPR_latency (cpu, FNER_FOR_FR (dual_FRdoublek), ps->post_wait);
  1424. }
  1425. /* Once initiated, post-processing will take 3 cycles. */
  1426. update_FR_ptime (cpu, out_FRk, 3);
  1427. update_FR_ptime (cpu, dual_FRk, 3);
  1428. update_FRdouble_ptime (cpu, out_FRdoublek, 3);
  1429. update_FRdouble_ptime (cpu, dual_FRdoublek, 3);
  1430. if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
  1431. {
  1432. update_SPR_ptime (cpu, FNER_FOR_FR (out_FRk), 3);
  1433. update_SPR_ptime (cpu, FNER_FOR_FR (dual_FRk), 3);
  1434. update_SPR_ptime (cpu, FNER_FOR_FR (out_FRdoublek), 3);
  1435. update_SPR_ptime (cpu, FNER_FOR_FR (dual_FRdoublek), 3);
  1436. }
  1437. /* Mark this use of the register as a floating point op. */
  1438. if (out_FRk >= 0)
  1439. set_use_is_fpop (cpu, out_FRk);
  1440. if (dual_FRk >= 0)
  1441. set_use_is_fpop (cpu, dual_FRk);
  1442. if (out_FRdoublek >= 0)
  1443. {
  1444. set_use_is_fpop (cpu, out_FRdoublek);
  1445. if (out_FRdoublek < 63)
  1446. set_use_is_fpop (cpu, out_FRdoublek + 1);
  1447. }
  1448. if (dual_FRdoublek >= 0)
  1449. {
  1450. set_use_is_fpop (cpu, dual_FRdoublek);
  1451. if (dual_FRdoublek < 63)
  1452. set_use_is_fpop (cpu, dual_FRdoublek + 1);
  1453. }
  1454. return cycles;
  1455. }
  1456. int
  1457. frvbf_model_fr500_u_float_div (SIM_CPU *cpu, const IDESC *idesc,
  1458. int unit_num, int referenced,
  1459. INT in_FRi, INT in_FRj, INT out_FRk)
  1460. {
  1461. int cycles;
  1462. FRV_VLIW *vliw;
  1463. int slot;
  1464. FRV_PROFILE_STATE *ps;
  1465. if (model_insn == FRV_INSN_MODEL_PASS_1)
  1466. return 0;
  1467. cycles = idesc->timing->units[unit_num].done;
  1468. /* The post processing must wait if there is a dependency on a FR
  1469. which is not ready yet. */
  1470. adjust_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, 1);
  1471. ps = CPU_PROFILE_STATE (cpu);
  1472. ps->post_wait = cycles;
  1473. post_wait_for_FR (cpu, in_FRi);
  1474. post_wait_for_FR (cpu, in_FRj);
  1475. post_wait_for_FR (cpu, out_FRk);
  1476. if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
  1477. post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
  1478. vliw = CPU_VLIW (cpu);
  1479. slot = vliw->next_slot - 1;
  1480. slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
  1481. post_wait_for_fdiv (cpu, slot);
  1482. restore_float_register_busy (cpu, in_FRi, in_FRj, out_FRk, 1);
  1483. /* The latency of FRk will be at least the latency of the other inputs. */
  1484. /* Once initiated, post-processing will take 10 cycles. */
  1485. update_FR_latency (cpu, out_FRk, ps->post_wait);
  1486. update_FR_ptime (cpu, out_FRk, 10);
  1487. if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
  1488. {
  1489. /* FNER has a latency of 10 cycles. */
  1490. update_SPR_latency (cpu, FNER_FOR_FR (out_FRk), ps->post_wait);
  1491. update_SPR_ptime (cpu, FNER_FOR_FR (out_FRk), 10);
  1492. }
  1493. /* The latency of the fdiv unit will be at least the latency of the other
  1494. inputs. Once initiated, post-processing will take 9 cycles. */
  1495. update_fdiv_resource_latency (cpu, slot, ps->post_wait + 9);
  1496. /* Mark this use of the register as a floating point op. */
  1497. set_use_is_fpop (cpu, out_FRk);
  1498. return cycles;
  1499. }
  1500. int
  1501. frvbf_model_fr500_u_float_sqrt (SIM_CPU *cpu, const IDESC *idesc,
  1502. int unit_num, int referenced,
  1503. INT in_FRj, INT in_FRdoublej,
  1504. INT out_FRk, INT out_FRdoublek)
  1505. {
  1506. int cycles;
  1507. FRV_VLIW *vliw;
  1508. int slot;
  1509. FRV_PROFILE_STATE *ps;
  1510. if (model_insn == FRV_INSN_MODEL_PASS_1)
  1511. return 0;
  1512. cycles = idesc->timing->units[unit_num].done;
  1513. /* The post processing must wait if there is a dependency on a FR
  1514. which is not ready yet. */
  1515. adjust_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
  1516. adjust_double_register_busy (cpu, -1, in_FRdoublej, out_FRdoublek, 1);
  1517. ps = CPU_PROFILE_STATE (cpu);
  1518. ps->post_wait = cycles;
  1519. post_wait_for_FR (cpu, in_FRj);
  1520. post_wait_for_FR (cpu, out_FRk);
  1521. post_wait_for_FRdouble (cpu, in_FRdoublej);
  1522. post_wait_for_FRdouble (cpu, out_FRdoublek);
  1523. if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
  1524. post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
  1525. vliw = CPU_VLIW (cpu);
  1526. slot = vliw->next_slot - 1;
  1527. slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
  1528. post_wait_for_fsqrt (cpu, slot);
  1529. restore_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
  1530. restore_double_register_busy (cpu, -1, in_FRdoublej, out_FRdoublek, 1);
  1531. /* The latency of FRk will be at least the latency of the other inputs. */
  1532. update_FR_latency (cpu, out_FRk, ps->post_wait);
  1533. update_FRdouble_latency (cpu, out_FRdoublek, ps->post_wait);
  1534. if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
  1535. update_SPR_latency (cpu, FNER_FOR_FR (out_FRk), ps->post_wait);
  1536. /* Once initiated, post-processing will take 15 cycles. */
  1537. update_FR_ptime (cpu, out_FRk, 15);
  1538. update_FRdouble_ptime (cpu, out_FRdoublek, 15);
  1539. if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
  1540. update_SPR_ptime (cpu, FNER_FOR_FR (out_FRk), 15);
  1541. /* The latency of the sqrt unit will be the latency of the other
  1542. inputs plus 14 cycles. */
  1543. update_fsqrt_resource_latency (cpu, slot, ps->post_wait + 14);
  1544. /* Mark this use of the register as a floating point op. */
  1545. if (out_FRk >= 0)
  1546. set_use_is_fpop (cpu, out_FRk);
  1547. if (out_FRdoublek >= 0)
  1548. {
  1549. set_use_is_fpop (cpu, out_FRdoublek);
  1550. if (out_FRdoublek < 63)
  1551. set_use_is_fpop (cpu, out_FRdoublek + 1);
  1552. }
  1553. return cycles;
  1554. }
  1555. int
  1556. frvbf_model_fr500_u_float_dual_sqrt (SIM_CPU *cpu, const IDESC *idesc,
  1557. int unit_num, int referenced,
  1558. INT in_FRj, INT out_FRk)
  1559. {
  1560. int cycles;
  1561. FRV_VLIW *vliw;
  1562. int slot;
  1563. INT dual_FRj;
  1564. INT dual_FRk;
  1565. FRV_PROFILE_STATE *ps;
  1566. if (model_insn == FRV_INSN_MODEL_PASS_1)
  1567. return 0;
  1568. cycles = idesc->timing->units[unit_num].done;
  1569. /* The post processing must wait if there is a dependency on a FR
  1570. which is not ready yet. */
  1571. dual_FRj = DUAL_REG (in_FRj);
  1572. dual_FRk = DUAL_REG (out_FRk);
  1573. adjust_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
  1574. adjust_float_register_busy (cpu, -1, dual_FRj, dual_FRk, 1);
  1575. ps = CPU_PROFILE_STATE (cpu);
  1576. ps->post_wait = cycles;
  1577. post_wait_for_FR (cpu, in_FRj);
  1578. post_wait_for_FR (cpu, out_FRk);
  1579. post_wait_for_FR (cpu, dual_FRj);
  1580. post_wait_for_FR (cpu, dual_FRk);
  1581. vliw = CPU_VLIW (cpu);
  1582. slot = vliw->next_slot - 1;
  1583. slot = (*vliw->current_vliw)[slot] - UNIT_FM0;
  1584. post_wait_for_fsqrt (cpu, slot);
  1585. restore_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
  1586. restore_float_register_busy (cpu, -1, dual_FRj, dual_FRk, 1);
  1587. /* The latency of FRk will be at least the latency of the other inputs. */
  1588. update_FR_latency (cpu, out_FRk, ps->post_wait);
  1589. update_FR_latency (cpu, dual_FRk, ps->post_wait);
  1590. /* Once initiated, post-processing will take 15 cycles. */
  1591. update_FR_ptime (cpu, out_FRk, 15);
  1592. update_FR_ptime (cpu, dual_FRk, 15);
  1593. /* The latency of the sqrt unit will be at least the latency of the other
  1594. inputs. */
  1595. update_fsqrt_resource_latency (cpu, slot, ps->post_wait + 14);
  1596. /* Mark this use of the register as a floating point op. */
  1597. if (out_FRk >= 0)
  1598. set_use_is_fpop (cpu, out_FRk);
  1599. if (dual_FRk >= 0)
  1600. set_use_is_fpop (cpu, dual_FRk);
  1601. return cycles;
  1602. }
  1603. int
  1604. frvbf_model_fr500_u_float_compare (SIM_CPU *cpu, const IDESC *idesc,
  1605. int unit_num, int referenced,
  1606. INT in_FRi, INT in_FRj,
  1607. INT in_FRdoublei, INT in_FRdoublej,
  1608. INT out_FCCi_2)
  1609. {
  1610. int cycles;
  1611. FRV_PROFILE_STATE *ps;
  1612. if (model_insn == FRV_INSN_MODEL_PASS_1)
  1613. return 0;
  1614. /* The preprocessing can execute right away. */
  1615. cycles = idesc->timing->units[unit_num].done;
  1616. /* The post processing must wait if there is a dependency on a FR
  1617. which is not ready yet. */
  1618. adjust_double_register_busy (cpu, in_FRdoublei, in_FRdoublej, -1, 1);
  1619. ps = CPU_PROFILE_STATE (cpu);
  1620. ps->post_wait = cycles;
  1621. post_wait_for_FR (cpu, in_FRi);
  1622. post_wait_for_FR (cpu, in_FRj);
  1623. post_wait_for_FRdouble (cpu, in_FRdoublei);
  1624. post_wait_for_FRdouble (cpu, in_FRdoublej);
  1625. post_wait_for_CCR (cpu, out_FCCi_2);
  1626. restore_double_register_busy (cpu, in_FRdoublei, in_FRdoublej, -1, 1);
  1627. /* The latency of FCCi_2 will be the latency of the other inputs plus 3
  1628. cycles. */
  1629. update_CCR_latency (cpu, out_FCCi_2, ps->post_wait + 3);
  1630. return cycles;
  1631. }
  1632. int
  1633. frvbf_model_fr500_u_float_dual_compare (SIM_CPU *cpu, const IDESC *idesc,
  1634. int unit_num, int referenced,
  1635. INT in_FRi, INT in_FRj,
  1636. INT out_FCCi_2)
  1637. {
  1638. int cycles;
  1639. INT dual_FRi;
  1640. INT dual_FRj;
  1641. INT dual_FCCi_2;
  1642. FRV_PROFILE_STATE *ps;
  1643. if (model_insn == FRV_INSN_MODEL_PASS_1)
  1644. return 0;
  1645. /* The preprocessing can execute right away. */
  1646. cycles = idesc->timing->units[unit_num].done;
  1647. /* The post processing must wait if there is a dependency on a FR
  1648. which is not ready yet. */
  1649. ps = CPU_PROFILE_STATE (cpu);
  1650. ps->post_wait = cycles;
  1651. dual_FRi = DUAL_REG (in_FRi);
  1652. dual_FRj = DUAL_REG (in_FRj);
  1653. dual_FCCi_2 = out_FCCi_2 + 1;
  1654. adjust_float_register_busy (cpu, in_FRi, in_FRj, -1, 1);
  1655. adjust_float_register_busy (cpu, dual_FRi, dual_FRj, -1, 1);
  1656. post_wait_for_FR (cpu, in_FRi);
  1657. post_wait_for_FR (cpu, in_FRj);
  1658. post_wait_for_FR (cpu, dual_FRi);
  1659. post_wait_for_FR (cpu, dual_FRj);
  1660. post_wait_for_CCR (cpu, out_FCCi_2);
  1661. post_wait_for_CCR (cpu, dual_FCCi_2);
  1662. restore_float_register_busy (cpu, in_FRi, in_FRj, -1, 1);
  1663. restore_float_register_busy (cpu, dual_FRi, dual_FRj, -1, 1);
  1664. /* The latency of FCCi_2 will be the latency of the other inputs plus 3
  1665. cycles. */
  1666. update_CCR_latency (cpu, out_FCCi_2, ps->post_wait + 3);
  1667. update_CCR_latency (cpu, dual_FCCi_2, ps->post_wait + 3);
  1668. return cycles;
  1669. }
  1670. int
  1671. frvbf_model_fr500_u_float_convert (SIM_CPU *cpu, const IDESC *idesc,
  1672. int unit_num, int referenced,
  1673. INT in_FRj, INT in_FRintj, INT in_FRdoublej,
  1674. INT out_FRk, INT out_FRintk,
  1675. INT out_FRdoublek)
  1676. {
  1677. int cycles;
  1678. FRV_PROFILE_STATE *ps;
  1679. if (model_insn == FRV_INSN_MODEL_PASS_1)
  1680. return 0;
  1681. /* The preprocessing can execute right away. */
  1682. cycles = idesc->timing->units[unit_num].done;
  1683. /* The post processing must wait if there is a dependency on a FR
  1684. which is not ready yet. */
  1685. ps = CPU_PROFILE_STATE (cpu);
  1686. ps->post_wait = cycles;
  1687. adjust_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
  1688. adjust_float_register_busy (cpu, -1, in_FRintj, out_FRintk, 1);
  1689. adjust_double_register_busy (cpu, -1, in_FRdoublej, out_FRdoublek, 1);
  1690. post_wait_for_FR (cpu, in_FRj);
  1691. post_wait_for_FR (cpu, in_FRintj);
  1692. post_wait_for_FRdouble (cpu, in_FRdoublej);
  1693. post_wait_for_FR (cpu, out_FRk);
  1694. post_wait_for_FR (cpu, out_FRintk);
  1695. post_wait_for_FRdouble (cpu, out_FRdoublek);
  1696. if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
  1697. {
  1698. post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRk));
  1699. post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRintk));
  1700. post_wait_for_SPR (cpu, FNER_FOR_FR (out_FRdoublek));
  1701. }
  1702. restore_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
  1703. restore_float_register_busy (cpu, -1, in_FRintj, out_FRintk, 1);
  1704. restore_double_register_busy (cpu, -1, in_FRdoublej, out_FRdoublek, 1);
  1705. /* The latency of FRk will be at least the latency of the other inputs. */
  1706. update_FR_latency (cpu, out_FRk, ps->post_wait);
  1707. update_FR_latency (cpu, out_FRintk, ps->post_wait);
  1708. update_FRdouble_latency (cpu, out_FRdoublek, ps->post_wait);
  1709. if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
  1710. {
  1711. update_SPR_latency (cpu, FNER_FOR_FR (out_FRk), ps->post_wait);
  1712. update_SPR_latency (cpu, FNER_FOR_FR (out_FRintk), ps->post_wait);
  1713. update_SPR_latency (cpu, FNER_FOR_FR (out_FRdoublek), ps->post_wait);
  1714. }
  1715. /* Once initiated, post-processing will take 3 cycles. */
  1716. update_FR_ptime (cpu, out_FRk, 3);
  1717. update_FR_ptime (cpu, out_FRintk, 3);
  1718. update_FRdouble_ptime (cpu, out_FRdoublek, 3);
  1719. if (CGEN_ATTR_VALUE(idesc, idesc->attrs, CGEN_INSN_NON_EXCEPTING))
  1720. {
  1721. update_SPR_ptime (cpu, FNER_FOR_FR (out_FRk), 3);
  1722. update_SPR_ptime (cpu, FNER_FOR_FR (out_FRintk), 3);
  1723. update_SPR_ptime (cpu, FNER_FOR_FR (out_FRdoublek), 3);
  1724. }
  1725. /* Mark this use of the register as a floating point op. */
  1726. if (out_FRk >= 0)
  1727. set_use_is_fpop (cpu, out_FRk);
  1728. if (out_FRintk >= 0)
  1729. set_use_is_fpop (cpu, out_FRintk);
  1730. if (out_FRdoublek >= 0)
  1731. {
  1732. set_use_is_fpop (cpu, out_FRdoublek);
  1733. set_use_is_fpop (cpu, out_FRdoublek + 1);
  1734. }
  1735. return cycles;
  1736. }
  1737. int
  1738. frvbf_model_fr500_u_float_dual_convert (SIM_CPU *cpu, const IDESC *idesc,
  1739. int unit_num, int referenced,
  1740. INT in_FRj, INT in_FRintj,
  1741. INT out_FRk, INT out_FRintk)
  1742. {
  1743. int cycles;
  1744. INT dual_FRj;
  1745. INT dual_FRintj;
  1746. INT dual_FRk;
  1747. INT dual_FRintk;
  1748. FRV_PROFILE_STATE *ps;
  1749. if (model_insn == FRV_INSN_MODEL_PASS_1)
  1750. return 0;
  1751. /* The preprocessing can execute right away. */
  1752. cycles = idesc->timing->units[unit_num].done;
  1753. /* The post processing must wait if there is a dependency on a FR
  1754. which is not ready yet. */
  1755. ps = CPU_PROFILE_STATE (cpu);
  1756. ps->post_wait = cycles;
  1757. dual_FRj = DUAL_REG (in_FRj);
  1758. dual_FRintj = DUAL_REG (in_FRintj);
  1759. dual_FRk = DUAL_REG (out_FRk);
  1760. dual_FRintk = DUAL_REG (out_FRintk);
  1761. adjust_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
  1762. adjust_float_register_busy (cpu, -1, dual_FRj, dual_FRk, 1);
  1763. adjust_float_register_busy (cpu, -1, in_FRintj, out_FRintk, 1);
  1764. adjust_float_register_busy (cpu, -1, dual_FRintj, dual_FRintk, 1);
  1765. post_wait_for_FR (cpu, in_FRj);
  1766. post_wait_for_FR (cpu, in_FRintj);
  1767. post_wait_for_FR (cpu, out_FRk);
  1768. post_wait_for_FR (cpu, out_FRintk);
  1769. post_wait_for_FR (cpu, dual_FRj);
  1770. post_wait_for_FR (cpu, dual_FRintj);
  1771. post_wait_for_FR (cpu, dual_FRk);
  1772. post_wait_for_FR (cpu, dual_FRintk);
  1773. restore_float_register_busy (cpu, -1, in_FRj, out_FRk, 1);
  1774. restore_float_register_busy (cpu, -1, dual_FRj, dual_FRk, 1);
  1775. restore_float_register_busy (cpu, -1, in_FRintj, out_FRintk, 1);
  1776. restore_float_register_busy (cpu, -1, dual_FRintj, dual_FRintk, 1);
  1777. /* The latency of FRk will be at least the latency of the other inputs. */
  1778. update_FR_latency (cpu, out_FRk, ps->post_wait);
  1779. update_FR_latency (cpu, out_FRintk, ps->post_wait);
  1780. update_FR_latency (cpu, dual_FRk, ps->post_wait);
  1781. update_FR_latency (cpu, dual_FRintk, ps->post_wait);
  1782. /* Once initiated, post-processing will take 3 cycles. */
  1783. update_FR_ptime (cpu, out_FRk, 3);
  1784. update_FR_ptime (cpu, out_FRintk, 3);
  1785. update_FR_ptime (cpu, dual_FRk, 3);
  1786. update_FR_ptime (cpu, dual_FRintk, 3);
  1787. /* Mark this use of the register as a floating point op. */
  1788. if (out_FRk >= 0)
  1789. set_use_is_fpop (cpu, out_FRk);
  1790. if (out_FRintk >= 0)
  1791. set_use_is_fpop (cpu, out_FRintk);
  1792. return cycles;
  1793. }
  1794. int
  1795. frvbf_model_fr500_u_media (SIM_CPU *cpu, const IDESC *idesc,
  1796. int unit_num, int referenced,
  1797. INT in_FRi, INT in_FRj, INT in_ACC40Si, INT in_ACCGi,
  1798. INT out_FRk,
  1799. INT out_ACC40Sk, INT out_ACC40Uk, INT out_ACCGk)
  1800. {
  1801. int cycles;
  1802. FRV_PROFILE_STATE *ps;
  1803. const CGEN_INSN *insn;
  1804. int is_media_s1;
  1805. int is_media_s2;
  1806. int busy_adjustment[] = {0, 0, 0};
  1807. int *fr;
  1808. int *acc;
  1809. if (model_insn == FRV_INSN_MODEL_PASS_1)
  1810. return 0;
  1811. /* The preprocessing can execute right away. */
  1812. cycles = idesc->timing->units[unit_num].done;
  1813. ps = CPU_PROFILE_STATE (cpu);
  1814. insn = idesc->idata;
  1815. /* If the previous use of the registers was a media op,
  1816. then their latency will be less than previously recorded.
  1817. See Table 13-13 in the LSI. */
  1818. if (in_FRi >= 0)
  1819. {
  1820. if (use_is_media (cpu, in_FRi))
  1821. {
  1822. busy_adjustment[0] = 2;
  1823. decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
  1824. }
  1825. else
  1826. enforce_full_fr_latency (cpu, in_FRi);
  1827. }
  1828. if (in_FRj >= 0 && in_FRj != in_FRi)
  1829. {
  1830. if (use_is_media (cpu, in_FRj))
  1831. {
  1832. busy_adjustment[1] = 2;
  1833. decrease_FR_busy (cpu, in_FRj, busy_adjustment[1]);
  1834. }
  1835. else
  1836. enforce_full_fr_latency (cpu, in_FRj);
  1837. }
  1838. if (out_FRk >= 0 && out_FRk != in_FRi && out_FRk != in_FRj)
  1839. {
  1840. if (use_is_media (cpu, out_FRk))
  1841. {
  1842. busy_adjustment[2] = 2;
  1843. decrease_FR_busy (cpu, out_FRk, busy_adjustment[2]);
  1844. }
  1845. else
  1846. enforce_full_fr_latency (cpu, out_FRk);
  1847. }
  1848. /* The post processing must wait if there is a dependency on a FR
  1849. which is not ready yet. */
  1850. ps->post_wait = cycles;
  1851. post_wait_for_FR (cpu, in_FRi);
  1852. post_wait_for_FR (cpu, in_FRj);
  1853. post_wait_for_FR (cpu, out_FRk);
  1854. post_wait_for_ACC (cpu, in_ACC40Si);
  1855. post_wait_for_ACC (cpu, in_ACCGi);
  1856. post_wait_for_ACC (cpu, out_ACC40Sk);
  1857. post_wait_for_ACC (cpu, out_ACC40Uk);
  1858. post_wait_for_ACC (cpu, out_ACCGk);
  1859. /* Restore the busy cycles of the registers we used. */
  1860. fr = ps->fr_busy;
  1861. if (in_FRi >= 0)
  1862. fr[in_FRi] += busy_adjustment[0];
  1863. if (in_FRj >= 0)
  1864. fr[in_FRj] += busy_adjustment[1];
  1865. if (out_FRk >= 0)
  1866. fr[out_FRk] += busy_adjustment[2];
  1867. /* The latency of tht output register will be at least the latency of the
  1868. other inputs. Once initiated, post-processing will take 3 cycles. */
  1869. if (out_FRk >= 0)
  1870. {
  1871. update_FR_latency (cpu, out_FRk, ps->post_wait);
  1872. update_FR_ptime (cpu, out_FRk, 3);
  1873. /* Mark this use of the register as a media op. */
  1874. set_use_is_media (cpu, out_FRk);
  1875. }
  1876. /* The latency of tht output accumulator will be at least the latency of the
  1877. other inputs. Once initiated, post-processing will take 1 cycle. */
  1878. if (out_ACC40Sk >= 0)
  1879. update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
  1880. if (out_ACC40Uk >= 0)
  1881. update_ACC_latency (cpu, out_ACC40Uk, ps->post_wait + 1);
  1882. if (out_ACCGk >= 0)
  1883. update_ACC_latency (cpu, out_ACCGk, ps->post_wait + 1);
  1884. return cycles;
  1885. }
  1886. int
  1887. frvbf_model_fr500_u_media_quad_arith (SIM_CPU *cpu, const IDESC *idesc,
  1888. int unit_num, int referenced,
  1889. INT in_FRi, INT in_FRj,
  1890. INT out_FRk)
  1891. {
  1892. int cycles;
  1893. INT dual_FRi;
  1894. INT dual_FRj;
  1895. INT dual_FRk;
  1896. FRV_PROFILE_STATE *ps;
  1897. int busy_adjustment[] = {0, 0, 0, 0, 0, 0};
  1898. int *fr;
  1899. if (model_insn == FRV_INSN_MODEL_PASS_1)
  1900. return 0;
  1901. /* The preprocessing can execute right away. */
  1902. cycles = idesc->timing->units[unit_num].done;
  1903. ps = CPU_PROFILE_STATE (cpu);
  1904. dual_FRi = DUAL_REG (in_FRi);
  1905. dual_FRj = DUAL_REG (in_FRj);
  1906. dual_FRk = DUAL_REG (out_FRk);
  1907. /* If the previous use of the registers was a media op,
  1908. then their latency will be less than previously recorded.
  1909. See Table 13-13 in the LSI. */
  1910. if (use_is_media (cpu, in_FRi))
  1911. {
  1912. busy_adjustment[0] = 2;
  1913. decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
  1914. }
  1915. else
  1916. enforce_full_fr_latency (cpu, in_FRi);
  1917. if (dual_FRi >= 0 && use_is_media (cpu, dual_FRi))
  1918. {
  1919. busy_adjustment[1] = 2;
  1920. decrease_FR_busy (cpu, dual_FRi, busy_adjustment[1]);
  1921. }
  1922. else
  1923. enforce_full_fr_latency (cpu, dual_FRi);
  1924. if (in_FRj != in_FRi)
  1925. {
  1926. if (use_is_media (cpu, in_FRj))
  1927. {
  1928. busy_adjustment[2] = 2;
  1929. decrease_FR_busy (cpu, in_FRj, busy_adjustment[2]);
  1930. }
  1931. else
  1932. enforce_full_fr_latency (cpu, in_FRj);
  1933. if (dual_FRj >= 0 && use_is_media (cpu, dual_FRj))
  1934. {
  1935. busy_adjustment[3] = 2;
  1936. decrease_FR_busy (cpu, dual_FRj, busy_adjustment[3]);
  1937. }
  1938. else
  1939. enforce_full_fr_latency (cpu, dual_FRj + 1);
  1940. }
  1941. if (out_FRk != in_FRi && out_FRk != in_FRj)
  1942. {
  1943. if (use_is_media (cpu, out_FRk))
  1944. {
  1945. busy_adjustment[4] = 2;
  1946. decrease_FR_busy (cpu, out_FRk, busy_adjustment[4]);
  1947. }
  1948. else
  1949. enforce_full_fr_latency (cpu, out_FRk);
  1950. if (dual_FRk >= 0 && use_is_media (cpu, dual_FRk))
  1951. {
  1952. busy_adjustment[5] = 2;
  1953. decrease_FR_busy (cpu, dual_FRk, busy_adjustment[5]);
  1954. }
  1955. else
  1956. enforce_full_fr_latency (cpu, dual_FRk);
  1957. }
  1958. /* The post processing must wait if there is a dependency on a FR
  1959. which is not ready yet. */
  1960. ps->post_wait = cycles;
  1961. post_wait_for_FR (cpu, in_FRi);
  1962. post_wait_for_FR (cpu, dual_FRi);
  1963. post_wait_for_FR (cpu, in_FRj);
  1964. post_wait_for_FR (cpu, dual_FRj);
  1965. post_wait_for_FR (cpu, out_FRk);
  1966. post_wait_for_FR (cpu, dual_FRk);
  1967. /* Restore the busy cycles of the registers we used. */
  1968. fr = ps->fr_busy;
  1969. fr[in_FRi] += busy_adjustment[0];
  1970. if (dual_FRi >= 0)
  1971. fr[dual_FRi] += busy_adjustment[1];
  1972. fr[in_FRj] += busy_adjustment[2];
  1973. if (dual_FRj >= 0)
  1974. fr[dual_FRj] += busy_adjustment[3];
  1975. fr[out_FRk] += busy_adjustment[4];
  1976. if (dual_FRk >= 0)
  1977. fr[dual_FRk] += busy_adjustment[5];
  1978. /* The latency of tht output register will be at least the latency of the
  1979. other inputs. */
  1980. update_FR_latency (cpu, out_FRk, ps->post_wait);
  1981. /* Once initiated, post-processing will take 3 cycles. */
  1982. update_FR_ptime (cpu, out_FRk, 3);
  1983. /* Mark this use of the register as a media op. */
  1984. set_use_is_media (cpu, out_FRk);
  1985. if (dual_FRk >= 0)
  1986. {
  1987. update_FR_latency (cpu, dual_FRk, ps->post_wait);
  1988. update_FR_ptime (cpu, dual_FRk, 3);
  1989. /* Mark this use of the register as a media op. */
  1990. set_use_is_media (cpu, dual_FRk);
  1991. }
  1992. return cycles;
  1993. }
  1994. int
  1995. frvbf_model_fr500_u_media_dual_mul (SIM_CPU *cpu, const IDESC *idesc,
  1996. int unit_num, int referenced,
  1997. INT in_FRi, INT in_FRj,
  1998. INT out_ACC40Sk, INT out_ACC40Uk)
  1999. {
  2000. int cycles;
  2001. INT dual_ACC40Sk;
  2002. INT dual_ACC40Uk;
  2003. FRV_PROFILE_STATE *ps;
  2004. int busy_adjustment[] = {0, 0, 0, 0, 0, 0};
  2005. int *fr;
  2006. int *acc;
  2007. if (model_insn == FRV_INSN_MODEL_PASS_1)
  2008. return 0;
  2009. /* The preprocessing can execute right away. */
  2010. cycles = idesc->timing->units[unit_num].done;
  2011. ps = CPU_PROFILE_STATE (cpu);
  2012. dual_ACC40Sk = DUAL_REG (out_ACC40Sk);
  2013. dual_ACC40Uk = DUAL_REG (out_ACC40Uk);
  2014. /* If the previous use of the registers was a media op,
  2015. then their latency will be less than previously recorded.
  2016. See Table 13-13 in the LSI. */
  2017. if (use_is_media (cpu, in_FRi))
  2018. {
  2019. busy_adjustment[0] = 2;
  2020. decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
  2021. }
  2022. else
  2023. enforce_full_fr_latency (cpu, in_FRi);
  2024. if (in_FRj != in_FRi)
  2025. {
  2026. if (use_is_media (cpu, in_FRj))
  2027. {
  2028. busy_adjustment[1] = 2;
  2029. decrease_FR_busy (cpu, in_FRj, busy_adjustment[1]);
  2030. }
  2031. else
  2032. enforce_full_fr_latency (cpu, in_FRj);
  2033. }
  2034. if (out_ACC40Sk >= 0)
  2035. {
  2036. busy_adjustment[2] = 1;
  2037. decrease_ACC_busy (cpu, out_ACC40Sk, busy_adjustment[2]);
  2038. }
  2039. if (dual_ACC40Sk >= 0)
  2040. {
  2041. busy_adjustment[3] = 1;
  2042. decrease_ACC_busy (cpu, dual_ACC40Sk, busy_adjustment[3]);
  2043. }
  2044. if (out_ACC40Uk >= 0)
  2045. {
  2046. busy_adjustment[4] = 1;
  2047. decrease_ACC_busy (cpu, out_ACC40Uk, busy_adjustment[4]);
  2048. }
  2049. if (dual_ACC40Uk >= 0)
  2050. {
  2051. busy_adjustment[5] = 1;
  2052. decrease_ACC_busy (cpu, dual_ACC40Uk, busy_adjustment[5]);
  2053. }
  2054. /* The post processing must wait if there is a dependency on a FR
  2055. which is not ready yet. */
  2056. ps->post_wait = cycles;
  2057. post_wait_for_FR (cpu, in_FRi);
  2058. post_wait_for_FR (cpu, in_FRj);
  2059. post_wait_for_ACC (cpu, out_ACC40Sk);
  2060. post_wait_for_ACC (cpu, dual_ACC40Sk);
  2061. post_wait_for_ACC (cpu, out_ACC40Uk);
  2062. post_wait_for_ACC (cpu, dual_ACC40Uk);
  2063. /* Restore the busy cycles of the registers we used. */
  2064. fr = ps->fr_busy;
  2065. acc = ps->acc_busy;
  2066. fr[in_FRi] += busy_adjustment[0];
  2067. fr[in_FRj] += busy_adjustment[1];
  2068. if (out_ACC40Sk >= 0)
  2069. acc[out_ACC40Sk] += busy_adjustment[2];
  2070. if (dual_ACC40Sk >= 0)
  2071. acc[dual_ACC40Sk] += busy_adjustment[3];
  2072. if (out_ACC40Uk >= 0)
  2073. acc[out_ACC40Uk] += busy_adjustment[4];
  2074. if (dual_ACC40Uk >= 0)
  2075. acc[dual_ACC40Uk] += busy_adjustment[5];
  2076. /* The latency of tht output register will be at least the latency of the
  2077. other inputs. Once initiated, post-processing will take 1 cycle. */
  2078. if (out_ACC40Sk >= 0)
  2079. update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
  2080. if (dual_ACC40Sk >= 0)
  2081. update_ACC_latency (cpu, dual_ACC40Sk, ps->post_wait + 1);
  2082. if (out_ACC40Uk >= 0)
  2083. update_ACC_latency (cpu, out_ACC40Uk, ps->post_wait + 1);
  2084. if (dual_ACC40Uk >= 0)
  2085. update_ACC_latency (cpu, dual_ACC40Uk, ps->post_wait + 1);
  2086. return cycles;
  2087. }
  2088. int
  2089. frvbf_model_fr500_u_media_quad_mul (SIM_CPU *cpu, const IDESC *idesc,
  2090. int unit_num, int referenced,
  2091. INT in_FRi, INT in_FRj,
  2092. INT out_ACC40Sk, INT out_ACC40Uk)
  2093. {
  2094. int cycles;
  2095. INT FRi_1;
  2096. INT FRj_1;
  2097. INT ACC40Sk_1;
  2098. INT ACC40Sk_2;
  2099. INT ACC40Sk_3;
  2100. INT ACC40Uk_1;
  2101. INT ACC40Uk_2;
  2102. INT ACC40Uk_3;
  2103. FRV_PROFILE_STATE *ps;
  2104. int busy_adjustment[] = {0, 0, 0, 0, 0, 0, 0 ,0};
  2105. int *fr;
  2106. int *acc;
  2107. if (model_insn == FRV_INSN_MODEL_PASS_1)
  2108. return 0;
  2109. /* The preprocessing can execute right away. */
  2110. cycles = idesc->timing->units[unit_num].done;
  2111. FRi_1 = DUAL_REG (in_FRi);
  2112. FRj_1 = DUAL_REG (in_FRj);
  2113. ACC40Sk_1 = DUAL_REG (out_ACC40Sk);
  2114. ACC40Sk_2 = DUAL_REG (ACC40Sk_1);
  2115. ACC40Sk_3 = DUAL_REG (ACC40Sk_2);
  2116. ACC40Uk_1 = DUAL_REG (out_ACC40Uk);
  2117. ACC40Uk_2 = DUAL_REG (ACC40Uk_1);
  2118. ACC40Uk_3 = DUAL_REG (ACC40Uk_2);
  2119. /* If the previous use of the registers was a media op,
  2120. then their latency will be less than previously recorded.
  2121. See Table 13-13 in the LSI. */
  2122. ps = CPU_PROFILE_STATE (cpu);
  2123. if (use_is_media (cpu, in_FRi))
  2124. {
  2125. busy_adjustment[0] = 2;
  2126. decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
  2127. }
  2128. else
  2129. enforce_full_fr_latency (cpu, in_FRi);
  2130. if (FRi_1 >= 0)
  2131. {
  2132. if (use_is_media (cpu, FRi_1))
  2133. {
  2134. busy_adjustment[1] = 2;
  2135. decrease_FR_busy (cpu, FRi_1, busy_adjustment[1]);
  2136. }
  2137. else
  2138. enforce_full_fr_latency (cpu, FRi_1);
  2139. }
  2140. if (in_FRj != in_FRi)
  2141. {
  2142. if (use_is_media (cpu, in_FRj))
  2143. {
  2144. busy_adjustment[2] = 2;
  2145. decrease_FR_busy (cpu, in_FRj, busy_adjustment[2]);
  2146. }
  2147. else
  2148. enforce_full_fr_latency (cpu, in_FRj);
  2149. if (FRj_1 >= 0)
  2150. {
  2151. if (use_is_media (cpu, FRj_1))
  2152. {
  2153. busy_adjustment[3] = 2;
  2154. decrease_FR_busy (cpu, FRj_1, busy_adjustment[3]);
  2155. }
  2156. else
  2157. enforce_full_fr_latency (cpu, FRj_1);
  2158. }
  2159. }
  2160. if (out_ACC40Sk >= 0)
  2161. {
  2162. busy_adjustment[4] = 1;
  2163. decrease_ACC_busy (cpu, out_ACC40Sk, busy_adjustment[4]);
  2164. if (ACC40Sk_1 >= 0)
  2165. {
  2166. busy_adjustment[5] = 1;
  2167. decrease_ACC_busy (cpu, ACC40Sk_1, busy_adjustment[5]);
  2168. }
  2169. if (ACC40Sk_2 >= 0)
  2170. {
  2171. busy_adjustment[6] = 1;
  2172. decrease_ACC_busy (cpu, ACC40Sk_2, busy_adjustment[6]);
  2173. }
  2174. if (ACC40Sk_3 >= 0)
  2175. {
  2176. busy_adjustment[7] = 1;
  2177. decrease_ACC_busy (cpu, ACC40Sk_3, busy_adjustment[7]);
  2178. }
  2179. }
  2180. else if (out_ACC40Uk >= 0)
  2181. {
  2182. busy_adjustment[4] = 1;
  2183. decrease_ACC_busy (cpu, out_ACC40Uk, busy_adjustment[4]);
  2184. if (ACC40Uk_1 >= 0)
  2185. {
  2186. busy_adjustment[5] = 1;
  2187. decrease_ACC_busy (cpu, ACC40Uk_1, busy_adjustment[5]);
  2188. }
  2189. if (ACC40Uk_2 >= 0)
  2190. {
  2191. busy_adjustment[6] = 1;
  2192. decrease_ACC_busy (cpu, ACC40Uk_2, busy_adjustment[6]);
  2193. }
  2194. if (ACC40Uk_3 >= 0)
  2195. {
  2196. busy_adjustment[7] = 1;
  2197. decrease_ACC_busy (cpu, ACC40Uk_3, busy_adjustment[7]);
  2198. }
  2199. }
  2200. /* The post processing must wait if there is a dependency on a FR
  2201. which is not ready yet. */
  2202. ps->post_wait = cycles;
  2203. post_wait_for_FR (cpu, in_FRi);
  2204. post_wait_for_FR (cpu, FRi_1);
  2205. post_wait_for_FR (cpu, in_FRj);
  2206. post_wait_for_FR (cpu, FRj_1);
  2207. post_wait_for_ACC (cpu, out_ACC40Sk);
  2208. post_wait_for_ACC (cpu, ACC40Sk_1);
  2209. post_wait_for_ACC (cpu, ACC40Sk_2);
  2210. post_wait_for_ACC (cpu, ACC40Sk_3);
  2211. post_wait_for_ACC (cpu, out_ACC40Uk);
  2212. post_wait_for_ACC (cpu, ACC40Uk_1);
  2213. post_wait_for_ACC (cpu, ACC40Uk_2);
  2214. post_wait_for_ACC (cpu, ACC40Uk_3);
  2215. /* Restore the busy cycles of the registers we used. */
  2216. fr = ps->fr_busy;
  2217. acc = ps->acc_busy;
  2218. fr[in_FRi] += busy_adjustment[0];
  2219. if (FRi_1 >= 0)
  2220. fr[FRi_1] += busy_adjustment[1];
  2221. fr[in_FRj] += busy_adjustment[2];
  2222. if (FRj_1 > 0)
  2223. fr[FRj_1] += busy_adjustment[3];
  2224. if (out_ACC40Sk >= 0)
  2225. {
  2226. acc[out_ACC40Sk] += busy_adjustment[4];
  2227. if (ACC40Sk_1 >= 0)
  2228. acc[ACC40Sk_1] += busy_adjustment[5];
  2229. if (ACC40Sk_2 >= 0)
  2230. acc[ACC40Sk_2] += busy_adjustment[6];
  2231. if (ACC40Sk_3 >= 0)
  2232. acc[ACC40Sk_3] += busy_adjustment[7];
  2233. }
  2234. else if (out_ACC40Uk >= 0)
  2235. {
  2236. acc[out_ACC40Uk] += busy_adjustment[4];
  2237. if (ACC40Uk_1 >= 0)
  2238. acc[ACC40Uk_1] += busy_adjustment[5];
  2239. if (ACC40Uk_2 >= 0)
  2240. acc[ACC40Uk_2] += busy_adjustment[6];
  2241. if (ACC40Uk_3 >= 0)
  2242. acc[ACC40Uk_3] += busy_adjustment[7];
  2243. }
  2244. /* The latency of tht output register will be at least the latency of the
  2245. other inputs. Once initiated, post-processing will take 1 cycle. */
  2246. if (out_ACC40Sk >= 0)
  2247. {
  2248. update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
  2249. if (ACC40Sk_1 >= 0)
  2250. update_ACC_latency (cpu, ACC40Sk_1, ps->post_wait + 1);
  2251. if (ACC40Sk_2 >= 0)
  2252. update_ACC_latency (cpu, ACC40Sk_2, ps->post_wait + 1);
  2253. if (ACC40Sk_3 >= 0)
  2254. update_ACC_latency (cpu, ACC40Sk_3, ps->post_wait + 1);
  2255. }
  2256. else if (out_ACC40Uk >= 0)
  2257. {
  2258. update_ACC_latency (cpu, out_ACC40Uk, ps->post_wait + 1);
  2259. if (ACC40Uk_1 >= 0)
  2260. update_ACC_latency (cpu, ACC40Uk_1, ps->post_wait + 1);
  2261. if (ACC40Uk_2 >= 0)
  2262. update_ACC_latency (cpu, ACC40Uk_2, ps->post_wait + 1);
  2263. if (ACC40Uk_3 >= 0)
  2264. update_ACC_latency (cpu, ACC40Uk_3, ps->post_wait + 1);
  2265. }
  2266. return cycles;
  2267. }
  2268. int
  2269. frvbf_model_fr500_u_media_quad_complex (SIM_CPU *cpu, const IDESC *idesc,
  2270. int unit_num, int referenced,
  2271. INT in_FRi, INT in_FRj,
  2272. INT out_ACC40Sk)
  2273. {
  2274. int cycles;
  2275. INT FRi_1;
  2276. INT FRj_1;
  2277. INT ACC40Sk_1;
  2278. FRV_PROFILE_STATE *ps;
  2279. int busy_adjustment[] = {0, 0, 0, 0, 0, 0};
  2280. int *fr;
  2281. int *acc;
  2282. if (model_insn == FRV_INSN_MODEL_PASS_1)
  2283. return 0;
  2284. /* The preprocessing can execute right away. */
  2285. cycles = idesc->timing->units[unit_num].done;
  2286. FRi_1 = DUAL_REG (in_FRi);
  2287. FRj_1 = DUAL_REG (in_FRj);
  2288. ACC40Sk_1 = DUAL_REG (out_ACC40Sk);
  2289. /* If the previous use of the registers was a media op,
  2290. then their latency will be less than previously recorded.
  2291. See Table 13-13 in the LSI. */
  2292. ps = CPU_PROFILE_STATE (cpu);
  2293. if (use_is_media (cpu, in_FRi))
  2294. {
  2295. busy_adjustment[0] = 2;
  2296. decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
  2297. }
  2298. else
  2299. enforce_full_fr_latency (cpu, in_FRi);
  2300. if (FRi_1 >= 0)
  2301. {
  2302. if (use_is_media (cpu, FRi_1))
  2303. {
  2304. busy_adjustment[1] = 2;
  2305. decrease_FR_busy (cpu, FRi_1, busy_adjustment[1]);
  2306. }
  2307. else
  2308. enforce_full_fr_latency (cpu, FRi_1);
  2309. }
  2310. if (in_FRj != in_FRi)
  2311. {
  2312. if (use_is_media (cpu, in_FRj))
  2313. {
  2314. busy_adjustment[2] = 2;
  2315. decrease_FR_busy (cpu, in_FRj, busy_adjustment[2]);
  2316. }
  2317. else
  2318. enforce_full_fr_latency (cpu, in_FRj);
  2319. if (FRj_1 >= 0)
  2320. {
  2321. if (use_is_media (cpu, FRj_1))
  2322. {
  2323. busy_adjustment[3] = 2;
  2324. decrease_FR_busy (cpu, FRj_1, busy_adjustment[3]);
  2325. }
  2326. else
  2327. enforce_full_fr_latency (cpu, FRj_1);
  2328. }
  2329. }
  2330. if (out_ACC40Sk >= 0)
  2331. {
  2332. busy_adjustment[4] = 1;
  2333. decrease_ACC_busy (cpu, out_ACC40Sk, busy_adjustment[4]);
  2334. if (ACC40Sk_1 >= 0)
  2335. {
  2336. busy_adjustment[5] = 1;
  2337. decrease_ACC_busy (cpu, ACC40Sk_1, busy_adjustment[5]);
  2338. }
  2339. }
  2340. /* The post processing must wait if there is a dependency on a FR
  2341. which is not ready yet. */
  2342. ps->post_wait = cycles;
  2343. post_wait_for_FR (cpu, in_FRi);
  2344. post_wait_for_FR (cpu, FRi_1);
  2345. post_wait_for_FR (cpu, in_FRj);
  2346. post_wait_for_FR (cpu, FRj_1);
  2347. post_wait_for_ACC (cpu, out_ACC40Sk);
  2348. post_wait_for_ACC (cpu, ACC40Sk_1);
  2349. /* Restore the busy cycles of the registers we used. */
  2350. fr = ps->fr_busy;
  2351. acc = ps->acc_busy;
  2352. fr[in_FRi] += busy_adjustment[0];
  2353. if (FRi_1 >= 0)
  2354. fr[FRi_1] += busy_adjustment[1];
  2355. fr[in_FRj] += busy_adjustment[2];
  2356. if (FRj_1 > 0)
  2357. fr[FRj_1] += busy_adjustment[3];
  2358. if (out_ACC40Sk >= 0)
  2359. {
  2360. acc[out_ACC40Sk] += busy_adjustment[4];
  2361. if (ACC40Sk_1 >= 0)
  2362. acc[ACC40Sk_1] += busy_adjustment[5];
  2363. }
  2364. /* The latency of tht output register will be at least the latency of the
  2365. other inputs. Once initiated, post-processing will take 1 cycle. */
  2366. if (out_ACC40Sk >= 0)
  2367. {
  2368. update_ACC_latency (cpu, out_ACC40Sk, ps->post_wait + 1);
  2369. if (ACC40Sk_1 >= 0)
  2370. update_ACC_latency (cpu, ACC40Sk_1, ps->post_wait + 1);
  2371. }
  2372. return cycles;
  2373. }
  2374. int
  2375. frvbf_model_fr500_u_media_dual_expand (SIM_CPU *cpu, const IDESC *idesc,
  2376. int unit_num, int referenced,
  2377. INT in_FRi,
  2378. INT out_FRk)
  2379. {
  2380. int cycles;
  2381. INT dual_FRk;
  2382. FRV_PROFILE_STATE *ps;
  2383. int busy_adjustment[] = {0, 0, 0};
  2384. int *fr;
  2385. if (model_insn == FRV_INSN_MODEL_PASS_1)
  2386. return 0;
  2387. /* The preprocessing can execute right away. */
  2388. cycles = idesc->timing->units[unit_num].done;
  2389. /* If the previous use of the registers was a media op,
  2390. then their latency will be less than previously recorded.
  2391. See Table 13-13 in the LSI. */
  2392. dual_FRk = DUAL_REG (out_FRk);
  2393. ps = CPU_PROFILE_STATE (cpu);
  2394. if (use_is_media (cpu, in_FRi))
  2395. {
  2396. busy_adjustment[0] = 2;
  2397. decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
  2398. }
  2399. else
  2400. enforce_full_fr_latency (cpu, in_FRi);
  2401. if (out_FRk != in_FRi)
  2402. {
  2403. if (use_is_media (cpu, out_FRk))
  2404. {
  2405. busy_adjustment[1] = 2;
  2406. decrease_FR_busy (cpu, out_FRk, busy_adjustment[1]);
  2407. }
  2408. else
  2409. enforce_full_fr_latency (cpu, out_FRk);
  2410. }
  2411. if (dual_FRk >= 0 && dual_FRk != in_FRi)
  2412. {
  2413. if (use_is_media (cpu, dual_FRk))
  2414. {
  2415. busy_adjustment[2] = 2;
  2416. decrease_FR_busy (cpu, dual_FRk, busy_adjustment[2]);
  2417. }
  2418. else
  2419. enforce_full_fr_latency (cpu, dual_FRk);
  2420. }
  2421. /* The post processing must wait if there is a dependency on a FR
  2422. which is not ready yet. */
  2423. ps->post_wait = cycles;
  2424. post_wait_for_FR (cpu, in_FRi);
  2425. post_wait_for_FR (cpu, out_FRk);
  2426. post_wait_for_FR (cpu, dual_FRk);
  2427. /* Restore the busy cycles of the registers we used. */
  2428. fr = ps->fr_busy;
  2429. fr[in_FRi] += busy_adjustment[0];
  2430. fr[out_FRk] += busy_adjustment[1];
  2431. if (dual_FRk >= 0)
  2432. fr[dual_FRk] += busy_adjustment[2];
  2433. /* The latency of the output register will be at least the latency of the
  2434. other inputs. Once initiated, post-processing will take 3 cycles. */
  2435. update_FR_latency (cpu, out_FRk, ps->post_wait);
  2436. update_FR_ptime (cpu, out_FRk, 3);
  2437. /* Mark this use of the register as a media op. */
  2438. set_use_is_media (cpu, out_FRk);
  2439. if (dual_FRk >= 0)
  2440. {
  2441. update_FR_latency (cpu, dual_FRk, ps->post_wait);
  2442. update_FR_ptime (cpu, dual_FRk, 3);
  2443. /* Mark this use of the register as a media op. */
  2444. set_use_is_media (cpu, dual_FRk);
  2445. }
  2446. return cycles;
  2447. }
  2448. int
  2449. frvbf_model_fr500_u_media_dual_unpack (SIM_CPU *cpu, const IDESC *idesc,
  2450. int unit_num, int referenced,
  2451. INT in_FRi,
  2452. INT out_FRk)
  2453. {
  2454. int cycles;
  2455. INT FRi_1;
  2456. INT FRk_1;
  2457. INT FRk_2;
  2458. INT FRk_3;
  2459. FRV_PROFILE_STATE *ps;
  2460. int busy_adjustment[] = {0, 0, 0, 0, 0, 0};
  2461. int *fr;
  2462. if (model_insn == FRV_INSN_MODEL_PASS_1)
  2463. return 0;
  2464. /* The preprocessing can execute right away. */
  2465. cycles = idesc->timing->units[unit_num].done;
  2466. FRi_1 = DUAL_REG (in_FRi);
  2467. FRk_1 = DUAL_REG (out_FRk);
  2468. FRk_2 = DUAL_REG (FRk_1);
  2469. FRk_3 = DUAL_REG (FRk_2);
  2470. /* If the previous use of the registers was a media op,
  2471. then their latency will be less than previously recorded.
  2472. See Table 13-13 in the LSI. */
  2473. ps = CPU_PROFILE_STATE (cpu);
  2474. if (use_is_media (cpu, in_FRi))
  2475. {
  2476. busy_adjustment[0] = 2;
  2477. decrease_FR_busy (cpu, in_FRi, busy_adjustment[0]);
  2478. }
  2479. else
  2480. enforce_full_fr_latency (cpu, in_FRi);
  2481. if (FRi_1 >= 0 && use_is_media (cpu, FRi_1))
  2482. {
  2483. busy_adjustment[1] = 2;
  2484. decrease_FR_busy (cpu, FRi_1, busy_adjustment[1]);
  2485. }
  2486. else
  2487. enforce_full_fr_latency (cpu, FRi_1);
  2488. if (out_FRk != in_FRi)
  2489. {
  2490. if (use_is_media (cpu, out_FRk))
  2491. {
  2492. busy_adjustment[2] = 2;
  2493. decrease_FR_busy (cpu, out_FRk, busy_adjustment[2]);
  2494. }
  2495. else
  2496. enforce_full_fr_latency (cpu, out_FRk);
  2497. if (FRk_1 >= 0 && FRk_1 != in_FRi)
  2498. {
  2499. if (use_is_media (cpu, FRk_1))
  2500. {
  2501. busy_adjustment[3] = 2;
  2502. decrease_FR_busy (cpu, FRk_1, busy_adjustment[3]);
  2503. }
  2504. else
  2505. enforce_full_fr_latency (cpu, FRk_1);
  2506. }
  2507. if (FRk_2 >= 0 && FRk_2 != in_FRi)
  2508. {
  2509. if (use_is_media (cpu, FRk_2))
  2510. {
  2511. busy_adjustment[4] = 2;
  2512. decrease_FR_busy (cpu, FRk_2, busy_adjustment[4]);
  2513. }
  2514. else
  2515. enforce_full_fr_latency (cpu, FRk_2);
  2516. }
  2517. if (FRk_3 >= 0 && FRk_3 != in_FRi)
  2518. {
  2519. if (use_is_media (cpu, FRk_3))
  2520. {
  2521. busy_adjustment[5] = 2;
  2522. decrease_FR_busy (cpu, FRk_3, busy_adjustment[5]);
  2523. }
  2524. else
  2525. enforce_full_fr_latency (cpu, FRk_3);
  2526. }
  2527. }
  2528. /* The post processing must wait if there is a dependency on a FR
  2529. which is not ready yet. */
  2530. ps->post_wait = cycles;
  2531. post_wait_for_FR (cpu, in_FRi);
  2532. post_wait_for_FR (cpu, FRi_1);
  2533. post_wait_for_FR (cpu, out_FRk);
  2534. post_wait_for_FR (cpu, FRk_1);
  2535. post_wait_for_FR (cpu, FRk_2);
  2536. post_wait_for_FR (cpu, FRk_3);
  2537. /* Restore the busy cycles of the registers we used. */
  2538. fr = ps->fr_busy;
  2539. fr[in_FRi] += busy_adjustment[0];
  2540. if (FRi_1 >= 0)
  2541. fr[FRi_1] += busy_adjustment[1];
  2542. fr[out_FRk] += busy_adjustment[2];
  2543. if (FRk_1 >= 0)
  2544. fr[FRk_1] += busy_adjustment[3];
  2545. if (FRk_2 >= 0)
  2546. fr[FRk_2] += busy_adjustment[4];
  2547. if (FRk_3 >= 0)
  2548. fr[FRk_3] += busy_adjustment[5];
  2549. /* The latency of tht output register will be at least the latency of the
  2550. other inputs. Once initiated, post-processing will take 3 cycles. */
  2551. update_FR_latency (cpu, out_FRk, ps->post_wait);
  2552. update_FR_ptime (cpu, out_FRk, 3);
  2553. /* Mark this use of the register as a media op. */
  2554. set_use_is_media (cpu, out_FRk);
  2555. if (FRk_1 >= 0)
  2556. {
  2557. update_FR_latency (cpu, FRk_1, ps->post_wait);
  2558. update_FR_ptime (cpu, FRk_1, 3);
  2559. /* Mark this use of the register as a media op. */
  2560. set_use_is_media (cpu, FRk_1);
  2561. }
  2562. if (FRk_2 >= 0)
  2563. {
  2564. update_FR_latency (cpu, FRk_2, ps->post_wait);
  2565. update_FR_ptime (cpu, FRk_2, 3);
  2566. /* Mark this use of the register as a media op. */
  2567. set_use_is_media (cpu, FRk_2);
  2568. }
  2569. if (FRk_3 >= 0)
  2570. {
  2571. update_FR_latency (cpu, FRk_3, ps->post_wait);
  2572. update_FR_ptime (cpu, FRk_3, 3);
  2573. /* Mark this use of the register as a media op. */
  2574. set_use_is_media (cpu, FRk_3);
  2575. }
  2576. return cycles;
  2577. }
  2578. int
  2579. frvbf_model_fr500_u_media_dual_btoh (SIM_CPU *cpu, const IDESC *idesc,
  2580. int unit_num, int referenced,
  2581. INT in_FRj,
  2582. INT out_FRk)
  2583. {
  2584. return frvbf_model_fr500_u_media_dual_expand (cpu, idesc, unit_num,
  2585. referenced, in_FRj, out_FRk);
  2586. }
  2587. int
  2588. frvbf_model_fr500_u_media_dual_htob (SIM_CPU *cpu, const IDESC *idesc,
  2589. int unit_num, int referenced,
  2590. INT in_FRj,
  2591. INT out_FRk)
  2592. {
  2593. int cycles;
  2594. INT dual_FRj;
  2595. FRV_PROFILE_STATE *ps;
  2596. int busy_adjustment[] = {0, 0, 0};
  2597. int *fr;
  2598. if (model_insn == FRV_INSN_MODEL_PASS_1)
  2599. return 0;
  2600. /* The preprocessing can execute right away. */
  2601. cycles = idesc->timing->units[unit_num].done;
  2602. /* If the previous use of the registers was a media op,
  2603. then their latency will be less than previously recorded.
  2604. See Table 13-13 in the LSI. */
  2605. dual_FRj = DUAL_REG (in_FRj);
  2606. ps = CPU_PROFILE_STATE (cpu);
  2607. if (use_is_media (cpu, in_FRj))
  2608. {
  2609. busy_adjustment[0] = 2;
  2610. decrease_FR_busy (cpu, in_FRj, busy_adjustment[0]);
  2611. }
  2612. else
  2613. enforce_full_fr_latency (cpu, in_FRj);
  2614. if (dual_FRj >= 0)
  2615. {
  2616. if (use_is_media (cpu, dual_FRj))
  2617. {
  2618. busy_adjustment[1] = 2;
  2619. decrease_FR_busy (cpu, dual_FRj, busy_adjustment[1]);
  2620. }
  2621. else
  2622. enforce_full_fr_latency (cpu, dual_FRj);
  2623. }
  2624. if (out_FRk != in_FRj)
  2625. {
  2626. if (use_is_media (cpu, out_FRk))
  2627. {
  2628. busy_adjustment[2] = 2;
  2629. decrease_FR_busy (cpu, out_FRk, busy_adjustment[2]);
  2630. }
  2631. else
  2632. enforce_full_fr_latency (cpu, out_FRk);
  2633. }
  2634. /* The post processing must wait if there is a dependency on a FR
  2635. which is not ready yet. */
  2636. ps->post_wait = cycles;
  2637. post_wait_for_FR (cpu, in_FRj);
  2638. post_wait_for_FR (cpu, dual_FRj);
  2639. post_wait_for_FR (cpu, out_FRk);
  2640. /* Restore the busy cycles of the registers we used. */
  2641. fr = ps->fr_busy;
  2642. fr[in_FRj] += busy_adjustment[0];
  2643. if (dual_FRj >= 0)
  2644. fr[dual_FRj] += busy_adjustment[1];
  2645. fr[out_FRk] += busy_adjustment[2];
  2646. /* The latency of tht output register will be at least the latency of the
  2647. other inputs. */
  2648. update_FR_latency (cpu, out_FRk, ps->post_wait);
  2649. /* Once initiated, post-processing will take 3 cycles. */
  2650. update_FR_ptime (cpu, out_FRk, 3);
  2651. /* Mark this use of the register as a media op. */
  2652. set_use_is_media (cpu, out_FRk);
  2653. return cycles;
  2654. }
  2655. int
  2656. frvbf_model_fr500_u_media_dual_btohe (SIM_CPU *cpu, const IDESC *idesc,
  2657. int unit_num, int referenced,
  2658. INT in_FRj,
  2659. INT out_FRk)
  2660. {
  2661. int cycles;
  2662. INT FRk_1;
  2663. INT FRk_2;
  2664. INT FRk_3;
  2665. FRV_PROFILE_STATE *ps;
  2666. int busy_adjustment[] = {0, 0, 0, 0, 0};
  2667. int *fr;
  2668. if (model_insn == FRV_INSN_MODEL_PASS_1)
  2669. return 0;
  2670. /* The preprocessing can execute right away. */
  2671. cycles = idesc->timing->units[unit_num].done;
  2672. FRk_1 = DUAL_REG (out_FRk);
  2673. FRk_2 = DUAL_REG (FRk_1);
  2674. FRk_3 = DUAL_REG (FRk_2);
  2675. /* If the previous use of the registers was a media op,
  2676. then their latency will be less than previously recorded.
  2677. See Table 13-13 in the LSI. */
  2678. ps = CPU_PROFILE_STATE (cpu);
  2679. if (use_is_media (cpu, in_FRj))
  2680. {
  2681. busy_adjustment[0] = 2;
  2682. decrease_FR_busy (cpu, in_FRj, busy_adjustment[0]);
  2683. }
  2684. else
  2685. enforce_full_fr_latency (cpu, in_FRj);
  2686. if (out_FRk != in_FRj)
  2687. {
  2688. if (use_is_media (cpu, out_FRk))
  2689. {
  2690. busy_adjustment[1] = 2;
  2691. decrease_FR_busy (cpu, out_FRk, busy_adjustment[1]);
  2692. }
  2693. else
  2694. enforce_full_fr_latency (cpu, out_FRk);
  2695. if (FRk_1 >= 0 && FRk_1 != in_FRj)
  2696. {
  2697. if (use_is_media (cpu, FRk_1))
  2698. {
  2699. busy_adjustment[2] = 2;
  2700. decrease_FR_busy (cpu, FRk_1, busy_adjustment[2]);
  2701. }
  2702. else
  2703. enforce_full_fr_latency (cpu, FRk_1);
  2704. }
  2705. if (FRk_2 >= 0 && FRk_2 != in_FRj)
  2706. {
  2707. if (use_is_media (cpu, FRk_2))
  2708. {
  2709. busy_adjustment[3] = 2;
  2710. decrease_FR_busy (cpu, FRk_2, busy_adjustment[3]);
  2711. }
  2712. else
  2713. enforce_full_fr_latency (cpu, FRk_2);
  2714. }
  2715. if (FRk_3 >= 0 && FRk_3 != in_FRj)
  2716. {
  2717. if (use_is_media (cpu, FRk_3))
  2718. {
  2719. busy_adjustment[4] = 2;
  2720. decrease_FR_busy (cpu, FRk_3, busy_adjustment[4]);
  2721. }
  2722. else
  2723. enforce_full_fr_latency (cpu, FRk_3);
  2724. }
  2725. }
  2726. /* The post processing must wait if there is a dependency on a FR
  2727. which is not ready yet. */
  2728. ps->post_wait = cycles;
  2729. post_wait_for_FR (cpu, in_FRj);
  2730. post_wait_for_FR (cpu, out_FRk);
  2731. post_wait_for_FR (cpu, FRk_1);
  2732. post_wait_for_FR (cpu, FRk_2);
  2733. post_wait_for_FR (cpu, FRk_3);
  2734. /* Restore the busy cycles of the registers we used. */
  2735. fr = ps->fr_busy;
  2736. fr[in_FRj] += busy_adjustment[0];
  2737. fr[out_FRk] += busy_adjustment[1];
  2738. if (FRk_1 >= 0)
  2739. fr[FRk_1] += busy_adjustment[2];
  2740. if (FRk_2 >= 0)
  2741. fr[FRk_2] += busy_adjustment[3];
  2742. if (FRk_3 >= 0)
  2743. fr[FRk_3] += busy_adjustment[4];
  2744. /* The latency of tht output register will be at least the latency of the
  2745. other inputs. Once initiated, post-processing will take 3 cycles. */
  2746. update_FR_latency (cpu, out_FRk, ps->post_wait);
  2747. update_FR_ptime (cpu, out_FRk, 3);
  2748. /* Mark this use of the register as a media op. */
  2749. set_use_is_media (cpu, out_FRk);
  2750. if (FRk_1 >= 0)
  2751. {
  2752. update_FR_latency (cpu, FRk_1, ps->post_wait);
  2753. update_FR_ptime (cpu, FRk_1, 3);
  2754. /* Mark this use of the register as a media op. */
  2755. set_use_is_media (cpu, FRk_1);
  2756. }
  2757. if (FRk_2 >= 0)
  2758. {
  2759. update_FR_latency (cpu, FRk_2, ps->post_wait);
  2760. update_FR_ptime (cpu, FRk_2, 3);
  2761. /* Mark this use of the register as a media op. */
  2762. set_use_is_media (cpu, FRk_2);
  2763. }
  2764. if (FRk_3 >= 0)
  2765. {
  2766. update_FR_latency (cpu, FRk_3, ps->post_wait);
  2767. update_FR_ptime (cpu, FRk_3, 3);
  2768. /* Mark this use of the register as a media op. */
  2769. set_use_is_media (cpu, FRk_3);
  2770. }
  2771. return cycles;
  2772. }
  2773. int
  2774. frvbf_model_fr500_u_barrier (SIM_CPU *cpu, const IDESC *idesc,
  2775. int unit_num, int referenced)
  2776. {
  2777. int cycles;
  2778. if (model_insn == FRV_INSN_MODEL_PASS_1)
  2779. {
  2780. int i;
  2781. /* Wait for ALL resources. */
  2782. for (i = 0; i < 64; ++i)
  2783. {
  2784. enforce_full_fr_latency (cpu, i);
  2785. vliw_wait_for_GR (cpu, i);
  2786. vliw_wait_for_FR (cpu, i);
  2787. vliw_wait_for_ACC (cpu, i);
  2788. }
  2789. for (i = 0; i < 8; ++i)
  2790. vliw_wait_for_CCR (cpu, i);
  2791. for (i = 0; i < 2; ++i)
  2792. {
  2793. vliw_wait_for_idiv_resource (cpu, i);
  2794. vliw_wait_for_fdiv_resource (cpu, i);
  2795. vliw_wait_for_fsqrt_resource (cpu, i);
  2796. }
  2797. handle_resource_wait (cpu);
  2798. for (i = 0; i < 64; ++i)
  2799. {
  2800. load_wait_for_GR (cpu, i);
  2801. load_wait_for_FR (cpu, i);
  2802. }
  2803. trace_vliw_wait_cycles (cpu);
  2804. return 0;
  2805. }
  2806. cycles = idesc->timing->units[unit_num].done;
  2807. return cycles;
  2808. }
  2809. int
  2810. frvbf_model_fr500_u_membar (SIM_CPU *cpu, const IDESC *idesc,
  2811. int unit_num, int referenced)
  2812. {
  2813. int cycles;
  2814. if (model_insn == FRV_INSN_MODEL_PASS_1)
  2815. {
  2816. int i;
  2817. /* Wait for ALL resources, except GR and ICC. */
  2818. for (i = 0; i < 64; ++i)
  2819. {
  2820. enforce_full_fr_latency (cpu, i);
  2821. vliw_wait_for_FR (cpu, i);
  2822. vliw_wait_for_ACC (cpu, i);
  2823. }
  2824. for (i = 0; i < 4; ++i)
  2825. vliw_wait_for_CCR (cpu, i);
  2826. for (i = 0; i < 2; ++i)
  2827. {
  2828. vliw_wait_for_idiv_resource (cpu, i);
  2829. vliw_wait_for_fdiv_resource (cpu, i);
  2830. vliw_wait_for_fsqrt_resource (cpu, i);
  2831. }
  2832. handle_resource_wait (cpu);
  2833. for (i = 0; i < 64; ++i)
  2834. {
  2835. load_wait_for_FR (cpu, i);
  2836. }
  2837. trace_vliw_wait_cycles (cpu);
  2838. return 0;
  2839. }
  2840. cycles = idesc->timing->units[unit_num].done;
  2841. return cycles;
  2842. }
  2843. /* The frv machine is a fictional implementation of the fr500 which implements
  2844. all frv architectural features. */
  2845. int
  2846. frvbf_model_frv_u_exec (SIM_CPU *cpu, const IDESC *idesc,
  2847. int unit_num, int referenced)
  2848. {
  2849. return idesc->timing->units[unit_num].done;
  2850. }
  2851. /* The simple machine is a fictional implementation of the fr500 which
  2852. implements limited frv architectural features. */
  2853. int
  2854. frvbf_model_simple_u_exec (SIM_CPU *cpu, const IDESC *idesc,
  2855. int unit_num, int referenced)
  2856. {
  2857. return idesc->timing->units[unit_num].done;
  2858. }
  2859. /* The tomcat machine is models a prototype fr500 machine which had a few
  2860. bugs and restrictions to work around. */
  2861. int
  2862. frvbf_model_tomcat_u_exec (SIM_CPU *cpu, const IDESC *idesc,
  2863. int unit_num, int referenced)
  2864. {
  2865. return idesc->timing->units[unit_num].done;
  2866. }
  2867. #endif /* WITH_PROFILE_MODEL_P */