1
0

softfloat.c 1.3 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501
  1. /**** start inlining ../../source/8086-SSE/softfloat_raiseFlags.c ****/
  2. /*============================================================================
  3. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  4. Package, Release 3e, by John R. Hauser.
  5. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  6. All rights reserved.
  7. Redistribution and use in source and binary forms, with or without
  8. modification, are permitted provided that the following conditions are met:
  9. 1. Redistributions of source code must retain the above copyright notice,
  10. this list of conditions, and the following disclaimer.
  11. 2. Redistributions in binary form must reproduce the above copyright notice,
  12. this list of conditions, and the following disclaimer in the documentation
  13. and/or other materials provided with the distribution.
  14. 3. Neither the name of the University nor the names of its contributors may
  15. be used to endorse or promote products derived from this software without
  16. specific prior written permission.
  17. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  18. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  20. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  21. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  26. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. =============================================================================*/
  28. /**** start inlining platform.h ****/
  29. /*============================================================================
  30. This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
  31. Package, Release 3e, by John R. Hauser.
  32. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  33. University of California. All rights reserved.
  34. Redistribution and use in source and binary forms, with or without
  35. modification, are permitted provided that the following conditions are met:
  36. 1. Redistributions of source code must retain the above copyright notice,
  37. this list of conditions, and the following disclaimer.
  38. 2. Redistributions in binary form must reproduce the above copyright notice,
  39. this list of conditions, and the following disclaimer in the documentation
  40. and/or other materials provided with the distribution.
  41. 3. Neither the name of the University nor the names of its contributors may
  42. be used to endorse or promote products derived from this software without
  43. specific prior written permission.
  44. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  45. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  46. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  47. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  48. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  49. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  50. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  51. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  52. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  53. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  54. =============================================================================*/
  55. /*----------------------------------------------------------------------------
  56. *----------------------------------------------------------------------------*/
  57. #define LITTLEENDIAN 1
  58. /*----------------------------------------------------------------------------
  59. *----------------------------------------------------------------------------*/
  60. #ifdef __GNUC_STDC_INLINE__
  61. #define INLINE inline
  62. #else
  63. #define INLINE extern inline
  64. #endif
  65. /*----------------------------------------------------------------------------
  66. *----------------------------------------------------------------------------*/
  67. #define SOFTFLOAT_BUILTIN_CLZ 1
  68. #define SOFTFLOAT_INTRINSIC_INT128 1
  69. /**** start inlining opts-GCC.h ****/
  70. /*============================================================================
  71. This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
  72. Package, Release 3e, by John R. Hauser.
  73. Copyright 2017 The Regents of the University of California. All rights
  74. reserved.
  75. Redistribution and use in source and binary forms, with or without
  76. modification, are permitted provided that the following conditions are met:
  77. 1. Redistributions of source code must retain the above copyright notice,
  78. this list of conditions, and the following disclaimer.
  79. 2. Redistributions in binary form must reproduce the above copyright notice,
  80. this list of conditions, and the following disclaimer in the documentation
  81. and/or other materials provided with the distribution.
  82. 3. Neither the name of the University nor the names of its contributors may
  83. be used to endorse or promote products derived from this software without
  84. specific prior written permission.
  85. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  86. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  87. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  88. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  89. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  90. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  91. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  92. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  93. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  94. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  95. =============================================================================*/
  96. #ifndef opts_GCC_h
  97. #define opts_GCC_h 1
  98. #ifdef INLINE
  99. #include <stdint.h>
  100. /**** start inlining primitiveTypes.h ****/
  101. /*============================================================================
  102. This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
  103. Package, Release 3e, by John R. Hauser.
  104. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  105. All rights reserved.
  106. Redistribution and use in source and binary forms, with or without
  107. modification, are permitted provided that the following conditions are met:
  108. 1. Redistributions of source code must retain the above copyright notice,
  109. this list of conditions, and the following disclaimer.
  110. 2. Redistributions in binary form must reproduce the above copyright notice,
  111. this list of conditions, and the following disclaimer in the documentation
  112. and/or other materials provided with the distribution.
  113. 3. Neither the name of the University nor the names of its contributors may
  114. be used to endorse or promote products derived from this software without
  115. specific prior written permission.
  116. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  117. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  118. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  119. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  120. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  121. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  122. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  123. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  124. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  125. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  126. =============================================================================*/
  127. #ifndef primitiveTypes_h
  128. #define primitiveTypes_h 1
  129. #include <stdint.h>
  130. #ifdef SOFTFLOAT_FAST_INT64
  131. #ifdef LITTLEENDIAN
  132. struct uint128 { uint64_t v0, v64; };
  133. struct uint64_extra { uint64_t extra, v; };
  134. struct uint128_extra { uint64_t extra; struct uint128 v; };
  135. #else
  136. struct uint128 { uint64_t v64, v0; };
  137. struct uint64_extra { uint64_t v, extra; };
  138. struct uint128_extra { struct uint128 v; uint64_t extra; };
  139. #endif
  140. #endif
  141. /*----------------------------------------------------------------------------
  142. | These macros are used to isolate the differences in word order between big-
  143. | endian and little-endian platforms.
  144. *----------------------------------------------------------------------------*/
  145. #ifdef LITTLEENDIAN
  146. #define wordIncr 1
  147. #define indexWord( total, n ) (n)
  148. #define indexWordHi( total ) ((total) - 1)
  149. #define indexWordLo( total ) 0
  150. #define indexMultiword( total, m, n ) (n)
  151. #define indexMultiwordHi( total, n ) ((total) - (n))
  152. #define indexMultiwordLo( total, n ) 0
  153. #define indexMultiwordHiBut( total, n ) (n)
  154. #define indexMultiwordLoBut( total, n ) 0
  155. #define INIT_UINTM4( v3, v2, v1, v0 ) { v0, v1, v2, v3 }
  156. #else
  157. #define wordIncr -1
  158. #define indexWord( total, n ) ((total) - 1 - (n))
  159. #define indexWordHi( total ) 0
  160. #define indexWordLo( total ) ((total) - 1)
  161. #define indexMultiword( total, m, n ) ((total) - 1 - (m))
  162. #define indexMultiwordHi( total, n ) 0
  163. #define indexMultiwordLo( total, n ) ((total) - (n))
  164. #define indexMultiwordHiBut( total, n ) 0
  165. #define indexMultiwordLoBut( total, n ) (n)
  166. #define INIT_UINTM4( v3, v2, v1, v0 ) { v3, v2, v1, v0 }
  167. #endif
  168. #endif
  169. /**** ended inlining primitiveTypes.h ****/
  170. #ifdef SOFTFLOAT_BUILTIN_CLZ
  171. INLINE uint_fast8_t softfloat_countLeadingZeros16( uint16_t a )
  172. { return a ? __builtin_clz( a ) - 16 : 16; }
  173. #define softfloat_countLeadingZeros16 softfloat_countLeadingZeros16
  174. INLINE uint_fast8_t softfloat_countLeadingZeros32( uint32_t a )
  175. { return a ? __builtin_clz( a ) : 32; }
  176. #define softfloat_countLeadingZeros32 softfloat_countLeadingZeros32
  177. INLINE uint_fast8_t softfloat_countLeadingZeros64( uint64_t a )
  178. { return a ? __builtin_clzll( a ) : 64; }
  179. #define softfloat_countLeadingZeros64 softfloat_countLeadingZeros64
  180. #endif
  181. #ifdef SOFTFLOAT_INTRINSIC_INT128
  182. INLINE struct uint128 softfloat_mul64ByShifted32To128( uint64_t a, uint32_t b )
  183. {
  184. union { unsigned __int128 ui; struct uint128 s; } uZ;
  185. uZ.ui = (unsigned __int128) a * ((uint_fast64_t) b<<32);
  186. return uZ.s;
  187. }
  188. #define softfloat_mul64ByShifted32To128 softfloat_mul64ByShifted32To128
  189. INLINE struct uint128 softfloat_mul64To128( uint64_t a, uint64_t b )
  190. {
  191. union { unsigned __int128 ui; struct uint128 s; } uZ;
  192. uZ.ui = (unsigned __int128) a * b;
  193. return uZ.s;
  194. }
  195. #define softfloat_mul64To128 softfloat_mul64To128
  196. INLINE
  197. struct uint128 softfloat_mul128By32( uint64_t a64, uint64_t a0, uint32_t b )
  198. {
  199. union { unsigned __int128 ui; struct uint128 s; } uZ;
  200. uZ.ui = ((unsigned __int128) a64<<64 | a0) * b;
  201. return uZ.s;
  202. }
  203. #define softfloat_mul128By32 softfloat_mul128By32
  204. INLINE
  205. void
  206. softfloat_mul128To256M(
  207. uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0, uint64_t *zPtr )
  208. {
  209. unsigned __int128 z0, mid1, mid, z128;
  210. z0 = (unsigned __int128) a0 * b0;
  211. mid1 = (unsigned __int128) a64 * b0;
  212. mid = mid1 + (unsigned __int128) a0 * b64;
  213. z128 = (unsigned __int128) a64 * b64;
  214. z128 += (unsigned __int128) (mid < mid1)<<64 | mid>>64;
  215. mid <<= 64;
  216. z0 += mid;
  217. z128 += (z0 < mid);
  218. zPtr[indexWord( 4, 0 )] = z0;
  219. zPtr[indexWord( 4, 1 )] = z0>>64;
  220. zPtr[indexWord( 4, 2 )] = z128;
  221. zPtr[indexWord( 4, 3 )] = z128>>64;
  222. }
  223. #define softfloat_mul128To256M softfloat_mul128To256M
  224. #endif
  225. #endif
  226. #endif
  227. /**** ended inlining opts-GCC.h ****/
  228. /**** ended inlining platform.h ****/
  229. /**** start inlining softfloat.h ****/
  230. /*============================================================================
  231. This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
  232. Package, Release 3e, by John R. Hauser.
  233. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  234. University of California. All rights reserved.
  235. Redistribution and use in source and binary forms, with or without
  236. modification, are permitted provided that the following conditions are met:
  237. 1. Redistributions of source code must retain the above copyright notice,
  238. this list of conditions, and the following disclaimer.
  239. 2. Redistributions in binary form must reproduce the above copyright notice,
  240. this list of conditions, and the following disclaimer in the documentation
  241. and/or other materials provided with the distribution.
  242. 3. Neither the name of the University nor the names of its contributors may
  243. be used to endorse or promote products derived from this software without
  244. specific prior written permission.
  245. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  246. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  247. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  248. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  249. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  250. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  251. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  252. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  253. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  254. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  255. =============================================================================*/
  256. /*============================================================================
  257. | Note: If SoftFloat is made available as a general library for programs to
  258. | use, it is strongly recommended that a platform-specific version of this
  259. | header, "softfloat.h", be created that folds in "softfloat_types.h" and that
  260. | eliminates all dependencies on compile-time macros.
  261. *============================================================================*/
  262. #ifndef softfloat_h
  263. #define softfloat_h 1
  264. #include <stdbool.h>
  265. #include <stdint.h>
  266. /**** start inlining softfloat_types.h ****/
  267. /*============================================================================
  268. This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
  269. Package, Release 3e, by John R. Hauser.
  270. Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
  271. California. All rights reserved.
  272. Redistribution and use in source and binary forms, with or without
  273. modification, are permitted provided that the following conditions are met:
  274. 1. Redistributions of source code must retain the above copyright notice,
  275. this list of conditions, and the following disclaimer.
  276. 2. Redistributions in binary form must reproduce the above copyright notice,
  277. this list of conditions, and the following disclaimer in the documentation
  278. and/or other materials provided with the distribution.
  279. 3. Neither the name of the University nor the names of its contributors may
  280. be used to endorse or promote products derived from this software without
  281. specific prior written permission.
  282. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  283. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  284. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  285. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  286. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  287. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  288. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  289. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  290. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  291. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  292. =============================================================================*/
  293. #ifndef softfloat_types_h
  294. #define softfloat_types_h 1
  295. #include <stdint.h>
  296. /*----------------------------------------------------------------------------
  297. | Types used to pass 16-bit, 32-bit, 64-bit, and 128-bit floating-point
  298. | arguments and results to/from functions. These types must be exactly
  299. | 16 bits, 32 bits, 64 bits, and 128 bits in size, respectively. Where a
  300. | platform has "native" support for IEEE-Standard floating-point formats,
  301. | the types below may, if desired, be defined as aliases for the native types
  302. | (typically 'float' and 'double', and possibly 'long double').
  303. *----------------------------------------------------------------------------*/
  304. typedef struct { uint16_t v; } float16_t;
  305. typedef struct { uint32_t v; } float32_t;
  306. typedef struct { uint64_t v; } float64_t;
  307. typedef struct { uint64_t v[2]; } float128_t;
  308. /*----------------------------------------------------------------------------
  309. | The format of an 80-bit extended floating-point number in memory. This
  310. | structure must contain a 16-bit field named 'signExp' and a 64-bit field
  311. | named 'signif'.
  312. *----------------------------------------------------------------------------*/
  313. #ifdef LITTLEENDIAN
  314. struct extFloat80M { uint64_t signif; uint16_t signExp; };
  315. #else
  316. struct extFloat80M { uint16_t signExp; uint64_t signif; };
  317. #endif
  318. /*----------------------------------------------------------------------------
  319. | The type used to pass 80-bit extended floating-point arguments and
  320. | results to/from functions. This type must have size identical to
  321. | 'struct extFloat80M'. Type 'extFloat80_t' can be defined as an alias for
  322. | 'struct extFloat80M'. Alternatively, if a platform has "native" support
  323. | for IEEE-Standard 80-bit extended floating-point, it may be possible,
  324. | if desired, to define 'extFloat80_t' as an alias for the native type
  325. | (presumably either 'long double' or a nonstandard compiler-intrinsic type).
  326. | In that case, the 'signif' and 'signExp' fields of 'struct extFloat80M'
  327. | must align exactly with the locations in memory of the sign, exponent, and
  328. | significand of the native type.
  329. *----------------------------------------------------------------------------*/
  330. typedef struct extFloat80M extFloat80_t;
  331. #endif
  332. /**** ended inlining softfloat_types.h ****/
  333. #ifndef THREAD_LOCAL
  334. #define THREAD_LOCAL
  335. #endif
  336. /*----------------------------------------------------------------------------
  337. | Software floating-point underflow tininess-detection mode.
  338. *----------------------------------------------------------------------------*/
  339. extern THREAD_LOCAL uint_fast8_t softfloat_detectTininess;
  340. enum {
  341. softfloat_tininess_beforeRounding = 0,
  342. softfloat_tininess_afterRounding = 1
  343. };
  344. /*----------------------------------------------------------------------------
  345. | Software floating-point rounding mode. (Mode "odd" is supported only if
  346. | SoftFloat is compiled with macro 'SOFTFLOAT_ROUND_ODD' defined.)
  347. *----------------------------------------------------------------------------*/
  348. extern THREAD_LOCAL uint_fast8_t softfloat_roundingMode;
  349. enum {
  350. softfloat_round_near_even = 0,
  351. softfloat_round_minMag = 1,
  352. softfloat_round_min = 2,
  353. softfloat_round_max = 3,
  354. softfloat_round_near_maxMag = 4,
  355. softfloat_round_odd = 6
  356. };
  357. /*----------------------------------------------------------------------------
  358. | Software floating-point exception flags.
  359. *----------------------------------------------------------------------------*/
  360. extern THREAD_LOCAL uint_fast8_t softfloat_exceptionFlags;
  361. enum {
  362. softfloat_flag_inexact = 1,
  363. softfloat_flag_underflow = 2,
  364. softfloat_flag_overflow = 4,
  365. softfloat_flag_infinite = 8,
  366. softfloat_flag_invalid = 16
  367. };
  368. /*----------------------------------------------------------------------------
  369. | Routine to raise any or all of the software floating-point exception flags.
  370. *----------------------------------------------------------------------------*/
  371. void softfloat_raiseFlags( uint_fast8_t );
  372. /*----------------------------------------------------------------------------
  373. | Integer-to-floating-point conversion routines.
  374. *----------------------------------------------------------------------------*/
  375. float16_t ui32_to_f16( uint32_t );
  376. float32_t ui32_to_f32( uint32_t );
  377. float64_t ui32_to_f64( uint32_t );
  378. #ifdef SOFTFLOAT_FAST_INT64
  379. extFloat80_t ui32_to_extF80( uint32_t );
  380. float128_t ui32_to_f128( uint32_t );
  381. #endif
  382. void ui32_to_extF80M( uint32_t, extFloat80_t * );
  383. void ui32_to_f128M( uint32_t, float128_t * );
  384. float16_t ui64_to_f16( uint64_t );
  385. float32_t ui64_to_f32( uint64_t );
  386. float64_t ui64_to_f64( uint64_t );
  387. #ifdef SOFTFLOAT_FAST_INT64
  388. extFloat80_t ui64_to_extF80( uint64_t );
  389. float128_t ui64_to_f128( uint64_t );
  390. #endif
  391. void ui64_to_extF80M( uint64_t, extFloat80_t * );
  392. void ui64_to_f128M( uint64_t, float128_t * );
  393. float16_t i32_to_f16( int32_t );
  394. float32_t i32_to_f32( int32_t );
  395. float64_t i32_to_f64( int32_t );
  396. #ifdef SOFTFLOAT_FAST_INT64
  397. extFloat80_t i32_to_extF80( int32_t );
  398. float128_t i32_to_f128( int32_t );
  399. #endif
  400. void i32_to_extF80M( int32_t, extFloat80_t * );
  401. void i32_to_f128M( int32_t, float128_t * );
  402. float16_t i64_to_f16( int64_t );
  403. float32_t i64_to_f32( int64_t );
  404. float64_t i64_to_f64( int64_t );
  405. #ifdef SOFTFLOAT_FAST_INT64
  406. extFloat80_t i64_to_extF80( int64_t );
  407. float128_t i64_to_f128( int64_t );
  408. #endif
  409. void i64_to_extF80M( int64_t, extFloat80_t * );
  410. void i64_to_f128M( int64_t, float128_t * );
  411. /*----------------------------------------------------------------------------
  412. | 16-bit (half-precision) floating-point operations.
  413. *----------------------------------------------------------------------------*/
  414. uint_fast32_t f16_to_ui32( float16_t, uint_fast8_t, bool );
  415. uint_fast64_t f16_to_ui64( float16_t, uint_fast8_t, bool );
  416. int_fast32_t f16_to_i32( float16_t, uint_fast8_t, bool );
  417. int_fast64_t f16_to_i64( float16_t, uint_fast8_t, bool );
  418. uint_fast32_t f16_to_ui32_r_minMag( float16_t, bool );
  419. uint_fast64_t f16_to_ui64_r_minMag( float16_t, bool );
  420. int_fast32_t f16_to_i32_r_minMag( float16_t, bool );
  421. int_fast64_t f16_to_i64_r_minMag( float16_t, bool );
  422. float32_t f16_to_f32( float16_t );
  423. float64_t f16_to_f64( float16_t );
  424. #ifdef SOFTFLOAT_FAST_INT64
  425. extFloat80_t f16_to_extF80( float16_t );
  426. float128_t f16_to_f128( float16_t );
  427. #endif
  428. void f16_to_extF80M( float16_t, extFloat80_t * );
  429. void f16_to_f128M( float16_t, float128_t * );
  430. float16_t f16_roundToInt( float16_t, uint_fast8_t, bool );
  431. float16_t f16_add( float16_t, float16_t );
  432. float16_t f16_sub( float16_t, float16_t );
  433. float16_t f16_mul( float16_t, float16_t );
  434. float16_t f16_mulAdd( float16_t, float16_t, float16_t );
  435. float16_t f16_div( float16_t, float16_t );
  436. float16_t f16_rem( float16_t, float16_t );
  437. float16_t f16_sqrt( float16_t );
  438. bool f16_eq( float16_t, float16_t );
  439. bool f16_le( float16_t, float16_t );
  440. bool f16_lt( float16_t, float16_t );
  441. bool f16_eq_signaling( float16_t, float16_t );
  442. bool f16_le_quiet( float16_t, float16_t );
  443. bool f16_lt_quiet( float16_t, float16_t );
  444. bool f16_isSignalingNaN( float16_t );
  445. /*----------------------------------------------------------------------------
  446. | 32-bit (single-precision) floating-point operations.
  447. *----------------------------------------------------------------------------*/
  448. uint_fast32_t f32_to_ui32( float32_t, uint_fast8_t, bool );
  449. uint_fast64_t f32_to_ui64( float32_t, uint_fast8_t, bool );
  450. int_fast32_t f32_to_i32( float32_t, uint_fast8_t, bool );
  451. int_fast64_t f32_to_i64( float32_t, uint_fast8_t, bool );
  452. uint_fast32_t f32_to_ui32_r_minMag( float32_t, bool );
  453. uint_fast64_t f32_to_ui64_r_minMag( float32_t, bool );
  454. int_fast32_t f32_to_i32_r_minMag( float32_t, bool );
  455. int_fast64_t f32_to_i64_r_minMag( float32_t, bool );
  456. float16_t f32_to_f16( float32_t );
  457. float64_t f32_to_f64( float32_t );
  458. #ifdef SOFTFLOAT_FAST_INT64
  459. extFloat80_t f32_to_extF80( float32_t );
  460. float128_t f32_to_f128( float32_t );
  461. #endif
  462. void f32_to_extF80M( float32_t, extFloat80_t * );
  463. void f32_to_f128M( float32_t, float128_t * );
  464. float32_t f32_roundToInt( float32_t, uint_fast8_t, bool );
  465. float32_t f32_add( float32_t, float32_t );
  466. float32_t f32_sub( float32_t, float32_t );
  467. float32_t f32_mul( float32_t, float32_t );
  468. float32_t f32_mulAdd( float32_t, float32_t, float32_t );
  469. float32_t f32_div( float32_t, float32_t );
  470. float32_t f32_rem( float32_t, float32_t );
  471. float32_t f32_sqrt( float32_t );
  472. bool f32_eq( float32_t, float32_t );
  473. bool f32_le( float32_t, float32_t );
  474. bool f32_lt( float32_t, float32_t );
  475. bool f32_eq_signaling( float32_t, float32_t );
  476. bool f32_le_quiet( float32_t, float32_t );
  477. bool f32_lt_quiet( float32_t, float32_t );
  478. bool f32_isSignalingNaN( float32_t );
  479. /*----------------------------------------------------------------------------
  480. | 64-bit (double-precision) floating-point operations.
  481. *----------------------------------------------------------------------------*/
  482. uint_fast32_t f64_to_ui32( float64_t, uint_fast8_t, bool );
  483. uint_fast64_t f64_to_ui64( float64_t, uint_fast8_t, bool );
  484. int_fast32_t f64_to_i32( float64_t, uint_fast8_t, bool );
  485. int_fast64_t f64_to_i64( float64_t, uint_fast8_t, bool );
  486. uint_fast32_t f64_to_ui32_r_minMag( float64_t, bool );
  487. uint_fast64_t f64_to_ui64_r_minMag( float64_t, bool );
  488. int_fast32_t f64_to_i32_r_minMag( float64_t, bool );
  489. int_fast64_t f64_to_i64_r_minMag( float64_t, bool );
  490. float16_t f64_to_f16( float64_t );
  491. float32_t f64_to_f32( float64_t );
  492. #ifdef SOFTFLOAT_FAST_INT64
  493. extFloat80_t f64_to_extF80( float64_t );
  494. float128_t f64_to_f128( float64_t );
  495. #endif
  496. void f64_to_extF80M( float64_t, extFloat80_t * );
  497. void f64_to_f128M( float64_t, float128_t * );
  498. float64_t f64_roundToInt( float64_t, uint_fast8_t, bool );
  499. float64_t f64_add( float64_t, float64_t );
  500. float64_t f64_sub( float64_t, float64_t );
  501. float64_t f64_mul( float64_t, float64_t );
  502. float64_t f64_mulAdd( float64_t, float64_t, float64_t );
  503. float64_t f64_div( float64_t, float64_t );
  504. float64_t f64_rem( float64_t, float64_t );
  505. float64_t f64_sqrt( float64_t );
  506. bool f64_eq( float64_t, float64_t );
  507. bool f64_le( float64_t, float64_t );
  508. bool f64_lt( float64_t, float64_t );
  509. bool f64_eq_signaling( float64_t, float64_t );
  510. bool f64_le_quiet( float64_t, float64_t );
  511. bool f64_lt_quiet( float64_t, float64_t );
  512. bool f64_isSignalingNaN( float64_t );
  513. /*----------------------------------------------------------------------------
  514. | Rounding precision for 80-bit extended double-precision floating-point.
  515. | Valid values are 32, 64, and 80.
  516. *----------------------------------------------------------------------------*/
  517. extern THREAD_LOCAL uint_fast8_t extF80_roundingPrecision;
  518. /*----------------------------------------------------------------------------
  519. | 80-bit extended double-precision floating-point operations.
  520. *----------------------------------------------------------------------------*/
  521. #ifdef SOFTFLOAT_FAST_INT64
  522. uint_fast32_t extF80_to_ui32( extFloat80_t, uint_fast8_t, bool );
  523. uint_fast64_t extF80_to_ui64( extFloat80_t, uint_fast8_t, bool );
  524. int_fast32_t extF80_to_i32( extFloat80_t, uint_fast8_t, bool );
  525. int_fast64_t extF80_to_i64( extFloat80_t, uint_fast8_t, bool );
  526. uint_fast32_t extF80_to_ui32_r_minMag( extFloat80_t, bool );
  527. uint_fast64_t extF80_to_ui64_r_minMag( extFloat80_t, bool );
  528. int_fast32_t extF80_to_i32_r_minMag( extFloat80_t, bool );
  529. int_fast64_t extF80_to_i64_r_minMag( extFloat80_t, bool );
  530. float16_t extF80_to_f16( extFloat80_t );
  531. float32_t extF80_to_f32( extFloat80_t );
  532. float64_t extF80_to_f64( extFloat80_t );
  533. float128_t extF80_to_f128( extFloat80_t );
  534. extFloat80_t extF80_roundToInt( extFloat80_t, uint_fast8_t, bool );
  535. extFloat80_t extF80_add( extFloat80_t, extFloat80_t );
  536. extFloat80_t extF80_sub( extFloat80_t, extFloat80_t );
  537. extFloat80_t extF80_mul( extFloat80_t, extFloat80_t );
  538. extFloat80_t extF80_div( extFloat80_t, extFloat80_t );
  539. extFloat80_t extF80_rem( extFloat80_t, extFloat80_t );
  540. extFloat80_t extF80_sqrt( extFloat80_t );
  541. bool extF80_eq( extFloat80_t, extFloat80_t );
  542. bool extF80_le( extFloat80_t, extFloat80_t );
  543. bool extF80_lt( extFloat80_t, extFloat80_t );
  544. bool extF80_eq_signaling( extFloat80_t, extFloat80_t );
  545. bool extF80_le_quiet( extFloat80_t, extFloat80_t );
  546. bool extF80_lt_quiet( extFloat80_t, extFloat80_t );
  547. bool extF80_isSignalingNaN( extFloat80_t );
  548. #endif
  549. uint_fast32_t extF80M_to_ui32( const extFloat80_t *, uint_fast8_t, bool );
  550. uint_fast64_t extF80M_to_ui64( const extFloat80_t *, uint_fast8_t, bool );
  551. int_fast32_t extF80M_to_i32( const extFloat80_t *, uint_fast8_t, bool );
  552. int_fast64_t extF80M_to_i64( const extFloat80_t *, uint_fast8_t, bool );
  553. uint_fast32_t extF80M_to_ui32_r_minMag( const extFloat80_t *, bool );
  554. uint_fast64_t extF80M_to_ui64_r_minMag( const extFloat80_t *, bool );
  555. int_fast32_t extF80M_to_i32_r_minMag( const extFloat80_t *, bool );
  556. int_fast64_t extF80M_to_i64_r_minMag( const extFloat80_t *, bool );
  557. float16_t extF80M_to_f16( const extFloat80_t * );
  558. float32_t extF80M_to_f32( const extFloat80_t * );
  559. float64_t extF80M_to_f64( const extFloat80_t * );
  560. void extF80M_to_f128M( const extFloat80_t *, float128_t * );
  561. void
  562. extF80M_roundToInt(
  563. const extFloat80_t *, uint_fast8_t, bool, extFloat80_t * );
  564. void extF80M_add( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
  565. void extF80M_sub( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
  566. void extF80M_mul( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
  567. void extF80M_div( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
  568. void extF80M_rem( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
  569. void extF80M_sqrt( const extFloat80_t *, extFloat80_t * );
  570. bool extF80M_eq( const extFloat80_t *, const extFloat80_t * );
  571. bool extF80M_le( const extFloat80_t *, const extFloat80_t * );
  572. bool extF80M_lt( const extFloat80_t *, const extFloat80_t * );
  573. bool extF80M_eq_signaling( const extFloat80_t *, const extFloat80_t * );
  574. bool extF80M_le_quiet( const extFloat80_t *, const extFloat80_t * );
  575. bool extF80M_lt_quiet( const extFloat80_t *, const extFloat80_t * );
  576. bool extF80M_isSignalingNaN( const extFloat80_t * );
  577. /*----------------------------------------------------------------------------
  578. | 128-bit (quadruple-precision) floating-point operations.
  579. *----------------------------------------------------------------------------*/
  580. #ifdef SOFTFLOAT_FAST_INT64
  581. uint_fast32_t f128_to_ui32( float128_t, uint_fast8_t, bool );
  582. uint_fast64_t f128_to_ui64( float128_t, uint_fast8_t, bool );
  583. int_fast32_t f128_to_i32( float128_t, uint_fast8_t, bool );
  584. int_fast64_t f128_to_i64( float128_t, uint_fast8_t, bool );
  585. uint_fast32_t f128_to_ui32_r_minMag( float128_t, bool );
  586. uint_fast64_t f128_to_ui64_r_minMag( float128_t, bool );
  587. int_fast32_t f128_to_i32_r_minMag( float128_t, bool );
  588. int_fast64_t f128_to_i64_r_minMag( float128_t, bool );
  589. float16_t f128_to_f16( float128_t );
  590. float32_t f128_to_f32( float128_t );
  591. float64_t f128_to_f64( float128_t );
  592. extFloat80_t f128_to_extF80( float128_t );
  593. float128_t f128_roundToInt( float128_t, uint_fast8_t, bool );
  594. float128_t f128_add( float128_t, float128_t );
  595. float128_t f128_sub( float128_t, float128_t );
  596. float128_t f128_mul( float128_t, float128_t );
  597. float128_t f128_mulAdd( float128_t, float128_t, float128_t );
  598. float128_t f128_div( float128_t, float128_t );
  599. float128_t f128_rem( float128_t, float128_t );
  600. float128_t f128_sqrt( float128_t );
  601. bool f128_eq( float128_t, float128_t );
  602. bool f128_le( float128_t, float128_t );
  603. bool f128_lt( float128_t, float128_t );
  604. bool f128_eq_signaling( float128_t, float128_t );
  605. bool f128_le_quiet( float128_t, float128_t );
  606. bool f128_lt_quiet( float128_t, float128_t );
  607. bool f128_isSignalingNaN( float128_t );
  608. #endif
  609. uint_fast32_t f128M_to_ui32( const float128_t *, uint_fast8_t, bool );
  610. uint_fast64_t f128M_to_ui64( const float128_t *, uint_fast8_t, bool );
  611. int_fast32_t f128M_to_i32( const float128_t *, uint_fast8_t, bool );
  612. int_fast64_t f128M_to_i64( const float128_t *, uint_fast8_t, bool );
  613. uint_fast32_t f128M_to_ui32_r_minMag( const float128_t *, bool );
  614. uint_fast64_t f128M_to_ui64_r_minMag( const float128_t *, bool );
  615. int_fast32_t f128M_to_i32_r_minMag( const float128_t *, bool );
  616. int_fast64_t f128M_to_i64_r_minMag( const float128_t *, bool );
  617. float16_t f128M_to_f16( const float128_t * );
  618. float32_t f128M_to_f32( const float128_t * );
  619. float64_t f128M_to_f64( const float128_t * );
  620. void f128M_to_extF80M( const float128_t *, extFloat80_t * );
  621. void f128M_roundToInt( const float128_t *, uint_fast8_t, bool, float128_t * );
  622. void f128M_add( const float128_t *, const float128_t *, float128_t * );
  623. void f128M_sub( const float128_t *, const float128_t *, float128_t * );
  624. void f128M_mul( const float128_t *, const float128_t *, float128_t * );
  625. void
  626. f128M_mulAdd(
  627. const float128_t *, const float128_t *, const float128_t *, float128_t *
  628. );
  629. void f128M_div( const float128_t *, const float128_t *, float128_t * );
  630. void f128M_rem( const float128_t *, const float128_t *, float128_t * );
  631. void f128M_sqrt( const float128_t *, float128_t * );
  632. bool f128M_eq( const float128_t *, const float128_t * );
  633. bool f128M_le( const float128_t *, const float128_t * );
  634. bool f128M_lt( const float128_t *, const float128_t * );
  635. bool f128M_eq_signaling( const float128_t *, const float128_t * );
  636. bool f128M_le_quiet( const float128_t *, const float128_t * );
  637. bool f128M_lt_quiet( const float128_t *, const float128_t * );
  638. bool f128M_isSignalingNaN( const float128_t * );
  639. #endif
  640. /**** ended inlining softfloat.h ****/
  641. /*----------------------------------------------------------------------------
  642. | Raises the exceptions specified by `flags'. Floating-point traps can be
  643. | defined here if desired. It is currently not possible for such a trap
  644. | to substitute a result value. If traps are not implemented, this routine
  645. | should be simply `softfloat_exceptionFlags |= flags;'.
  646. *----------------------------------------------------------------------------*/
  647. void softfloat_raiseFlags( uint_fast8_t flags )
  648. {
  649. softfloat_exceptionFlags |= flags;
  650. }
  651. /**** ended inlining ../../source/8086-SSE/softfloat_raiseFlags.c ****/
  652. /**** start inlining ../../source/8086-SSE/s_f16UIToCommonNaN.c ****/
  653. /*============================================================================
  654. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  655. Package, Release 3e, by John R. Hauser.
  656. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  657. California. All rights reserved.
  658. Redistribution and use in source and binary forms, with or without
  659. modification, are permitted provided that the following conditions are met:
  660. 1. Redistributions of source code must retain the above copyright notice,
  661. this list of conditions, and the following disclaimer.
  662. 2. Redistributions in binary form must reproduce the above copyright notice,
  663. this list of conditions, and the following disclaimer in the documentation
  664. and/or other materials provided with the distribution.
  665. 3. Neither the name of the University nor the names of its contributors may
  666. be used to endorse or promote products derived from this software without
  667. specific prior written permission.
  668. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  669. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  670. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  671. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  672. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  673. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  674. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  675. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  676. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  677. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  678. =============================================================================*/
  679. #include <stdint.h>
  680. /**** skipping file: platform.h ****/
  681. /**** start inlining specialize.h ****/
  682. /*============================================================================
  683. This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
  684. Package, Release 3e, by John R. Hauser.
  685. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2018 The Regents of the
  686. University of California. All rights reserved.
  687. Redistribution and use in source and binary forms, with or without
  688. modification, are permitted provided that the following conditions are met:
  689. 1. Redistributions of source code must retain the above copyright notice,
  690. this list of conditions, and the following disclaimer.
  691. 2. Redistributions in binary form must reproduce the above copyright notice,
  692. this list of conditions, and the following disclaimer in the documentation
  693. and/or other materials provided with the distribution.
  694. 3. Neither the name of the University nor the names of its contributors may
  695. be used to endorse or promote products derived from this software without
  696. specific prior written permission.
  697. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  698. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  699. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  700. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  701. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  702. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  703. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  704. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  705. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  706. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  707. =============================================================================*/
  708. #ifndef specialize_h
  709. #define specialize_h 1
  710. #include <stdbool.h>
  711. #include <stdint.h>
  712. /**** skipping file: primitiveTypes.h ****/
  713. /**** skipping file: softfloat.h ****/
  714. /*----------------------------------------------------------------------------
  715. | Default value for 'softfloat_detectTininess'.
  716. *----------------------------------------------------------------------------*/
  717. #define init_detectTininess softfloat_tininess_afterRounding
  718. /*----------------------------------------------------------------------------
  719. | The values to return on conversions to 32-bit integer formats that raise an
  720. | invalid exception.
  721. *----------------------------------------------------------------------------*/
  722. #define ui32_fromPosOverflow 0xFFFFFFFF
  723. #define ui32_fromNegOverflow 0xFFFFFFFF
  724. #define ui32_fromNaN 0xFFFFFFFF
  725. #define i32_fromPosOverflow (-0x7FFFFFFF - 1)
  726. #define i32_fromNegOverflow (-0x7FFFFFFF - 1)
  727. #define i32_fromNaN (-0x7FFFFFFF - 1)
  728. /*----------------------------------------------------------------------------
  729. | The values to return on conversions to 64-bit integer formats that raise an
  730. | invalid exception.
  731. *----------------------------------------------------------------------------*/
  732. #define ui64_fromPosOverflow UINT64_C( 0xFFFFFFFFFFFFFFFF )
  733. #define ui64_fromNegOverflow UINT64_C( 0xFFFFFFFFFFFFFFFF )
  734. #define ui64_fromNaN UINT64_C( 0xFFFFFFFFFFFFFFFF )
  735. #define i64_fromPosOverflow (-INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1)
  736. #define i64_fromNegOverflow (-INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1)
  737. #define i64_fromNaN (-INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1)
  738. /*----------------------------------------------------------------------------
  739. | "Common NaN" structure, used to transfer NaN representations from one format
  740. | to another.
  741. *----------------------------------------------------------------------------*/
  742. struct commonNaN {
  743. bool sign;
  744. #ifdef LITTLEENDIAN
  745. uint64_t v0, v64;
  746. #else
  747. uint64_t v64, v0;
  748. #endif
  749. };
  750. /*----------------------------------------------------------------------------
  751. | The bit pattern for a default generated 16-bit floating-point NaN.
  752. *----------------------------------------------------------------------------*/
  753. #define defaultNaNF16UI 0xFE00
  754. /*----------------------------------------------------------------------------
  755. | Returns true when 16-bit unsigned integer 'uiA' has the bit pattern of a
  756. | 16-bit floating-point signaling NaN.
  757. | Note: This macro evaluates its argument more than once.
  758. *----------------------------------------------------------------------------*/
  759. #define softfloat_isSigNaNF16UI( uiA ) ((((uiA) & 0x7E00) == 0x7C00) && ((uiA) & 0x01FF))
  760. /*----------------------------------------------------------------------------
  761. | Assuming 'uiA' has the bit pattern of a 16-bit floating-point NaN, converts
  762. | this NaN to the common NaN form, and stores the resulting common NaN at the
  763. | location pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid
  764. | exception is raised.
  765. *----------------------------------------------------------------------------*/
  766. void softfloat_f16UIToCommonNaN( uint_fast16_t uiA, struct commonNaN *zPtr );
  767. /*----------------------------------------------------------------------------
  768. | Converts the common NaN pointed to by 'aPtr' into a 16-bit floating-point
  769. | NaN, and returns the bit pattern of this value as an unsigned integer.
  770. *----------------------------------------------------------------------------*/
  771. uint_fast16_t softfloat_commonNaNToF16UI( const struct commonNaN *aPtr );
  772. /*----------------------------------------------------------------------------
  773. | Interpreting 'uiA' and 'uiB' as the bit patterns of two 16-bit floating-
  774. | point values, at least one of which is a NaN, returns the bit pattern of
  775. | the combined NaN result. If either 'uiA' or 'uiB' has the pattern of a
  776. | signaling NaN, the invalid exception is raised.
  777. *----------------------------------------------------------------------------*/
  778. uint_fast16_t
  779. softfloat_propagateNaNF16UI( uint_fast16_t uiA, uint_fast16_t uiB );
  780. /*----------------------------------------------------------------------------
  781. | The bit pattern for a default generated 32-bit floating-point NaN.
  782. *----------------------------------------------------------------------------*/
  783. #define defaultNaNF32UI 0xFFC00000
  784. /*----------------------------------------------------------------------------
  785. | Returns true when 32-bit unsigned integer 'uiA' has the bit pattern of a
  786. | 32-bit floating-point signaling NaN.
  787. | Note: This macro evaluates its argument more than once.
  788. *----------------------------------------------------------------------------*/
  789. #define softfloat_isSigNaNF32UI( uiA ) ((((uiA) & 0x7FC00000) == 0x7F800000) && ((uiA) & 0x003FFFFF))
  790. /*----------------------------------------------------------------------------
  791. | Assuming 'uiA' has the bit pattern of a 32-bit floating-point NaN, converts
  792. | this NaN to the common NaN form, and stores the resulting common NaN at the
  793. | location pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid
  794. | exception is raised.
  795. *----------------------------------------------------------------------------*/
  796. void softfloat_f32UIToCommonNaN( uint_fast32_t uiA, struct commonNaN *zPtr );
  797. /*----------------------------------------------------------------------------
  798. | Converts the common NaN pointed to by 'aPtr' into a 32-bit floating-point
  799. | NaN, and returns the bit pattern of this value as an unsigned integer.
  800. *----------------------------------------------------------------------------*/
  801. uint_fast32_t softfloat_commonNaNToF32UI( const struct commonNaN *aPtr );
  802. /*----------------------------------------------------------------------------
  803. | Interpreting 'uiA' and 'uiB' as the bit patterns of two 32-bit floating-
  804. | point values, at least one of which is a NaN, returns the bit pattern of
  805. | the combined NaN result. If either 'uiA' or 'uiB' has the pattern of a
  806. | signaling NaN, the invalid exception is raised.
  807. *----------------------------------------------------------------------------*/
  808. uint_fast32_t
  809. softfloat_propagateNaNF32UI( uint_fast32_t uiA, uint_fast32_t uiB );
  810. /*----------------------------------------------------------------------------
  811. | The bit pattern for a default generated 64-bit floating-point NaN.
  812. *----------------------------------------------------------------------------*/
  813. #define defaultNaNF64UI UINT64_C( 0xFFF8000000000000 )
  814. /*----------------------------------------------------------------------------
  815. | Returns true when 64-bit unsigned integer 'uiA' has the bit pattern of a
  816. | 64-bit floating-point signaling NaN.
  817. | Note: This macro evaluates its argument more than once.
  818. *----------------------------------------------------------------------------*/
  819. #define softfloat_isSigNaNF64UI( uiA ) ((((uiA) & UINT64_C( 0x7FF8000000000000 )) == UINT64_C( 0x7FF0000000000000 )) && ((uiA) & UINT64_C( 0x0007FFFFFFFFFFFF )))
  820. /*----------------------------------------------------------------------------
  821. | Assuming 'uiA' has the bit pattern of a 64-bit floating-point NaN, converts
  822. | this NaN to the common NaN form, and stores the resulting common NaN at the
  823. | location pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid
  824. | exception is raised.
  825. *----------------------------------------------------------------------------*/
  826. void softfloat_f64UIToCommonNaN( uint_fast64_t uiA, struct commonNaN *zPtr );
  827. /*----------------------------------------------------------------------------
  828. | Converts the common NaN pointed to by 'aPtr' into a 64-bit floating-point
  829. | NaN, and returns the bit pattern of this value as an unsigned integer.
  830. *----------------------------------------------------------------------------*/
  831. uint_fast64_t softfloat_commonNaNToF64UI( const struct commonNaN *aPtr );
  832. /*----------------------------------------------------------------------------
  833. | Interpreting 'uiA' and 'uiB' as the bit patterns of two 64-bit floating-
  834. | point values, at least one of which is a NaN, returns the bit pattern of
  835. | the combined NaN result. If either 'uiA' or 'uiB' has the pattern of a
  836. | signaling NaN, the invalid exception is raised.
  837. *----------------------------------------------------------------------------*/
  838. uint_fast64_t
  839. softfloat_propagateNaNF64UI( uint_fast64_t uiA, uint_fast64_t uiB );
  840. /*----------------------------------------------------------------------------
  841. | The bit pattern for a default generated 80-bit extended floating-point NaN.
  842. *----------------------------------------------------------------------------*/
  843. #define defaultNaNExtF80UI64 0xFFFF
  844. #define defaultNaNExtF80UI0 UINT64_C( 0xC000000000000000 )
  845. /*----------------------------------------------------------------------------
  846. | Returns true when the 80-bit unsigned integer formed from concatenating
  847. | 16-bit 'uiA64' and 64-bit 'uiA0' has the bit pattern of an 80-bit extended
  848. | floating-point signaling NaN.
  849. | Note: This macro evaluates its arguments more than once.
  850. *----------------------------------------------------------------------------*/
  851. #define softfloat_isSigNaNExtF80UI( uiA64, uiA0 ) ((((uiA64) & 0x7FFF) == 0x7FFF) && ! ((uiA0) & UINT64_C( 0x4000000000000000 )) && ((uiA0) & UINT64_C( 0x3FFFFFFFFFFFFFFF )))
  852. #ifdef SOFTFLOAT_FAST_INT64
  853. /*----------------------------------------------------------------------------
  854. | The following functions are needed only when 'SOFTFLOAT_FAST_INT64' is
  855. | defined.
  856. *----------------------------------------------------------------------------*/
  857. /*----------------------------------------------------------------------------
  858. | Assuming the unsigned integer formed from concatenating 'uiA64' and 'uiA0'
  859. | has the bit pattern of an 80-bit extended floating-point NaN, converts
  860. | this NaN to the common NaN form, and stores the resulting common NaN at the
  861. | location pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid
  862. | exception is raised.
  863. *----------------------------------------------------------------------------*/
  864. void
  865. softfloat_extF80UIToCommonNaN(
  866. uint_fast16_t uiA64, uint_fast64_t uiA0, struct commonNaN *zPtr );
  867. /*----------------------------------------------------------------------------
  868. | Converts the common NaN pointed to by 'aPtr' into an 80-bit extended
  869. | floating-point NaN, and returns the bit pattern of this value as an unsigned
  870. | integer.
  871. *----------------------------------------------------------------------------*/
  872. struct uint128 softfloat_commonNaNToExtF80UI( const struct commonNaN *aPtr );
  873. /*----------------------------------------------------------------------------
  874. | Interpreting the unsigned integer formed from concatenating 'uiA64' and
  875. | 'uiA0' as an 80-bit extended floating-point value, and likewise interpreting
  876. | the unsigned integer formed from concatenating 'uiB64' and 'uiB0' as another
  877. | 80-bit extended floating-point value, and assuming at least on of these
  878. | floating-point values is a NaN, returns the bit pattern of the combined NaN
  879. | result. If either original floating-point value is a signaling NaN, the
  880. | invalid exception is raised.
  881. *----------------------------------------------------------------------------*/
  882. struct uint128
  883. softfloat_propagateNaNExtF80UI(
  884. uint_fast16_t uiA64,
  885. uint_fast64_t uiA0,
  886. uint_fast16_t uiB64,
  887. uint_fast64_t uiB0
  888. );
  889. /*----------------------------------------------------------------------------
  890. | The bit pattern for a default generated 128-bit floating-point NaN.
  891. *----------------------------------------------------------------------------*/
  892. #define defaultNaNF128UI64 UINT64_C( 0xFFFF800000000000 )
  893. #define defaultNaNF128UI0 UINT64_C( 0 )
  894. /*----------------------------------------------------------------------------
  895. | Returns true when the 128-bit unsigned integer formed from concatenating
  896. | 64-bit 'uiA64' and 64-bit 'uiA0' has the bit pattern of a 128-bit floating-
  897. | point signaling NaN.
  898. | Note: This macro evaluates its arguments more than once.
  899. *----------------------------------------------------------------------------*/
  900. #define softfloat_isSigNaNF128UI( uiA64, uiA0 ) ((((uiA64) & UINT64_C( 0x7FFF800000000000 )) == UINT64_C( 0x7FFF000000000000 )) && ((uiA0) || ((uiA64) & UINT64_C( 0x00007FFFFFFFFFFF ))))
  901. /*----------------------------------------------------------------------------
  902. | Assuming the unsigned integer formed from concatenating 'uiA64' and 'uiA0'
  903. | has the bit pattern of a 128-bit floating-point NaN, converts this NaN to
  904. | the common NaN form, and stores the resulting common NaN at the location
  905. | pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid exception
  906. | is raised.
  907. *----------------------------------------------------------------------------*/
  908. void
  909. softfloat_f128UIToCommonNaN(
  910. uint_fast64_t uiA64, uint_fast64_t uiA0, struct commonNaN *zPtr );
  911. /*----------------------------------------------------------------------------
  912. | Converts the common NaN pointed to by 'aPtr' into a 128-bit floating-point
  913. | NaN, and returns the bit pattern of this value as an unsigned integer.
  914. *----------------------------------------------------------------------------*/
  915. struct uint128 softfloat_commonNaNToF128UI( const struct commonNaN * );
  916. /*----------------------------------------------------------------------------
  917. | Interpreting the unsigned integer formed from concatenating 'uiA64' and
  918. | 'uiA0' as a 128-bit floating-point value, and likewise interpreting the
  919. | unsigned integer formed from concatenating 'uiB64' and 'uiB0' as another
  920. | 128-bit floating-point value, and assuming at least on of these floating-
  921. | point values is a NaN, returns the bit pattern of the combined NaN result.
  922. | If either original floating-point value is a signaling NaN, the invalid
  923. | exception is raised.
  924. *----------------------------------------------------------------------------*/
  925. struct uint128
  926. softfloat_propagateNaNF128UI(
  927. uint_fast64_t uiA64,
  928. uint_fast64_t uiA0,
  929. uint_fast64_t uiB64,
  930. uint_fast64_t uiB0
  931. );
  932. #else
  933. /*----------------------------------------------------------------------------
  934. | The following functions are needed only when 'SOFTFLOAT_FAST_INT64' is not
  935. | defined.
  936. *----------------------------------------------------------------------------*/
  937. /*----------------------------------------------------------------------------
  938. | Assuming the 80-bit extended floating-point value pointed to by 'aSPtr' is
  939. | a NaN, converts this NaN to the common NaN form, and stores the resulting
  940. | common NaN at the location pointed to by 'zPtr'. If the NaN is a signaling
  941. | NaN, the invalid exception is raised.
  942. *----------------------------------------------------------------------------*/
  943. void
  944. softfloat_extF80MToCommonNaN(
  945. const struct extFloat80M *aSPtr, struct commonNaN *zPtr );
  946. /*----------------------------------------------------------------------------
  947. | Converts the common NaN pointed to by 'aPtr' into an 80-bit extended
  948. | floating-point NaN, and stores this NaN at the location pointed to by
  949. | 'zSPtr'.
  950. *----------------------------------------------------------------------------*/
  951. void
  952. softfloat_commonNaNToExtF80M(
  953. const struct commonNaN *aPtr, struct extFloat80M *zSPtr );
  954. /*----------------------------------------------------------------------------
  955. | Assuming at least one of the two 80-bit extended floating-point values
  956. | pointed to by 'aSPtr' and 'bSPtr' is a NaN, stores the combined NaN result
  957. | at the location pointed to by 'zSPtr'. If either original floating-point
  958. | value is a signaling NaN, the invalid exception is raised.
  959. *----------------------------------------------------------------------------*/
  960. void
  961. softfloat_propagateNaNExtF80M(
  962. const struct extFloat80M *aSPtr,
  963. const struct extFloat80M *bSPtr,
  964. struct extFloat80M *zSPtr
  965. );
  966. /*----------------------------------------------------------------------------
  967. | The bit pattern for a default generated 128-bit floating-point NaN.
  968. *----------------------------------------------------------------------------*/
  969. #define defaultNaNF128UI96 0xFFFF8000
  970. #define defaultNaNF128UI64 0
  971. #define defaultNaNF128UI32 0
  972. #define defaultNaNF128UI0 0
  973. /*----------------------------------------------------------------------------
  974. | Assuming the 128-bit floating-point value pointed to by 'aWPtr' is a NaN,
  975. | converts this NaN to the common NaN form, and stores the resulting common
  976. | NaN at the location pointed to by 'zPtr'. If the NaN is a signaling NaN,
  977. | the invalid exception is raised. Argument 'aWPtr' points to an array of
  978. | four 32-bit elements that concatenate in the platform's normal endian order
  979. | to form a 128-bit floating-point value.
  980. *----------------------------------------------------------------------------*/
  981. void
  982. softfloat_f128MToCommonNaN( const uint32_t *aWPtr, struct commonNaN *zPtr );
  983. /*----------------------------------------------------------------------------
  984. | Converts the common NaN pointed to by 'aPtr' into a 128-bit floating-point
  985. | NaN, and stores this NaN at the location pointed to by 'zWPtr'. Argument
  986. | 'zWPtr' points to an array of four 32-bit elements that concatenate in the
  987. | platform's normal endian order to form a 128-bit floating-point value.
  988. *----------------------------------------------------------------------------*/
  989. void
  990. softfloat_commonNaNToF128M( const struct commonNaN *aPtr, uint32_t *zWPtr );
  991. /*----------------------------------------------------------------------------
  992. | Assuming at least one of the two 128-bit floating-point values pointed to by
  993. | 'aWPtr' and 'bWPtr' is a NaN, stores the combined NaN result at the location
  994. | pointed to by 'zWPtr'. If either original floating-point value is a
  995. | signaling NaN, the invalid exception is raised. Each of 'aWPtr', 'bWPtr',
  996. | and 'zWPtr' points to an array of four 32-bit elements that concatenate in
  997. | the platform's normal endian order to form a 128-bit floating-point value.
  998. *----------------------------------------------------------------------------*/
  999. void
  1000. softfloat_propagateNaNF128M(
  1001. const uint32_t *aWPtr, const uint32_t *bWPtr, uint32_t *zWPtr );
  1002. #endif
  1003. #endif
  1004. /**** ended inlining specialize.h ****/
  1005. /**** skipping file: softfloat.h ****/
  1006. /*----------------------------------------------------------------------------
  1007. | Assuming `uiA' has the bit pattern of a 16-bit floating-point NaN, converts
  1008. | this NaN to the common NaN form, and stores the resulting common NaN at the
  1009. | location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
  1010. | exception is raised.
  1011. *----------------------------------------------------------------------------*/
  1012. void softfloat_f16UIToCommonNaN( uint_fast16_t uiA, struct commonNaN *zPtr )
  1013. {
  1014. if ( softfloat_isSigNaNF16UI( uiA ) ) {
  1015. softfloat_raiseFlags( softfloat_flag_invalid );
  1016. }
  1017. zPtr->sign = uiA>>15;
  1018. zPtr->v64 = (uint_fast64_t) uiA<<54;
  1019. zPtr->v0 = 0;
  1020. }
  1021. /**** ended inlining ../../source/8086-SSE/s_f16UIToCommonNaN.c ****/
  1022. /**** start inlining ../../source/8086-SSE/s_commonNaNToF16UI.c ****/
  1023. /*============================================================================
  1024. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  1025. Package, Release 3e, by John R. Hauser.
  1026. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  1027. California. All rights reserved.
  1028. Redistribution and use in source and binary forms, with or without
  1029. modification, are permitted provided that the following conditions are met:
  1030. 1. Redistributions of source code must retain the above copyright notice,
  1031. this list of conditions, and the following disclaimer.
  1032. 2. Redistributions in binary form must reproduce the above copyright notice,
  1033. this list of conditions, and the following disclaimer in the documentation
  1034. and/or other materials provided with the distribution.
  1035. 3. Neither the name of the University nor the names of its contributors may
  1036. be used to endorse or promote products derived from this software without
  1037. specific prior written permission.
  1038. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  1039. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  1040. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  1041. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  1042. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  1043. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  1044. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  1045. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  1046. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  1047. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  1048. =============================================================================*/
  1049. #include <stdint.h>
  1050. /**** skipping file: platform.h ****/
  1051. /**** skipping file: specialize.h ****/
  1052. /*----------------------------------------------------------------------------
  1053. | Converts the common NaN pointed to by `aPtr' into a 16-bit floating-point
  1054. | NaN, and returns the bit pattern of this value as an unsigned integer.
  1055. *----------------------------------------------------------------------------*/
  1056. uint_fast16_t softfloat_commonNaNToF16UI( const struct commonNaN *aPtr )
  1057. {
  1058. return (uint_fast16_t) aPtr->sign<<15 | 0x7E00 | aPtr->v64>>54;
  1059. }
  1060. /**** ended inlining ../../source/8086-SSE/s_commonNaNToF16UI.c ****/
  1061. /**** start inlining ../../source/8086-SSE/s_propagateNaNF16UI.c ****/
  1062. /*============================================================================
  1063. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  1064. Package, Release 3e, by John R. Hauser.
  1065. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  1066. California. All rights reserved.
  1067. Redistribution and use in source and binary forms, with or without
  1068. modification, are permitted provided that the following conditions are met:
  1069. 1. Redistributions of source code must retain the above copyright notice,
  1070. this list of conditions, and the following disclaimer.
  1071. 2. Redistributions in binary form must reproduce the above copyright notice,
  1072. this list of conditions, and the following disclaimer in the documentation
  1073. and/or other materials provided with the distribution.
  1074. 3. Neither the name of the University nor the names of its contributors may
  1075. be used to endorse or promote products derived from this software without
  1076. specific prior written permission.
  1077. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  1078. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  1079. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  1080. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  1081. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  1082. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  1083. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  1084. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  1085. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  1086. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  1087. =============================================================================*/
  1088. #include <stdbool.h>
  1089. #include <stdint.h>
  1090. /**** skipping file: platform.h ****/
  1091. /**** start inlining internals.h ****/
  1092. /*============================================================================
  1093. This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
  1094. Package, Release 3e, by John R. Hauser.
  1095. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  1096. University of California. All rights reserved.
  1097. Redistribution and use in source and binary forms, with or without
  1098. modification, are permitted provided that the following conditions are met:
  1099. 1. Redistributions of source code must retain the above copyright notice,
  1100. this list of conditions, and the following disclaimer.
  1101. 2. Redistributions in binary form must reproduce the above copyright notice,
  1102. this list of conditions, and the following disclaimer in the documentation
  1103. and/or other materials provided with the distribution.
  1104. 3. Neither the name of the University nor the names of its contributors may
  1105. be used to endorse or promote products derived from this software without
  1106. specific prior written permission.
  1107. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  1108. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  1109. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  1110. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  1111. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  1112. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  1113. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  1114. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  1115. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  1116. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  1117. =============================================================================*/
  1118. #ifndef internals_h
  1119. #define internals_h 1
  1120. #include <stdbool.h>
  1121. #include <stdint.h>
  1122. /**** start inlining primitives.h ****/
  1123. /*============================================================================
  1124. This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
  1125. Package, Release 3e, by John R. Hauser.
  1126. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  1127. University of California. All rights reserved.
  1128. Redistribution and use in source and binary forms, with or without
  1129. modification, are permitted provided that the following conditions are met:
  1130. 1. Redistributions of source code must retain the above copyright notice,
  1131. this list of conditions, and the following disclaimer.
  1132. 2. Redistributions in binary form must reproduce the above copyright notice,
  1133. this list of conditions, and the following disclaimer in the documentation
  1134. and/or other materials provided with the distribution.
  1135. 3. Neither the name of the University nor the names of its contributors may
  1136. be used to endorse or promote products derived from this software without
  1137. specific prior written permission.
  1138. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  1139. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  1140. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  1141. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  1142. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  1143. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  1144. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  1145. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  1146. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  1147. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  1148. =============================================================================*/
  1149. #ifndef primitives_h
  1150. #define primitives_h 1
  1151. #include <stdbool.h>
  1152. #include <stdint.h>
  1153. /**** skipping file: primitiveTypes.h ****/
  1154. #ifndef softfloat_shortShiftRightJam64
  1155. #define softfloat_shortShiftRightJam64 softfloat_shortShiftRightJam64
  1156. /*----------------------------------------------------------------------------
  1157. | Shifts 'a' right by the number of bits given in 'dist', which must be in
  1158. | the range 1 to 63. If any nonzero bits are shifted off, they are "jammed"
  1159. | into the least-significant bit of the shifted value by setting the least-
  1160. | significant bit to 1. This shifted-and-jammed value is returned.
  1161. *----------------------------------------------------------------------------*/
  1162. #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
  1163. INLINE
  1164. uint64_t softfloat_shortShiftRightJam64( uint64_t a, uint_fast8_t dist )
  1165. { return a>>dist | ((a & (((uint_fast64_t) 1<<dist) - 1)) != 0); }
  1166. #else
  1167. uint64_t softfloat_shortShiftRightJam64( uint64_t a, uint_fast8_t dist );
  1168. #endif
  1169. #endif
  1170. #ifndef softfloat_shiftRightJam32
  1171. #define softfloat_shiftRightJam32 softfloat_shiftRightJam32
  1172. /*----------------------------------------------------------------------------
  1173. | Shifts 'a' right by the number of bits given in 'dist', which must not
  1174. | be zero. If any nonzero bits are shifted off, they are "jammed" into the
  1175. | least-significant bit of the shifted value by setting the least-significant
  1176. | bit to 1. This shifted-and-jammed value is returned.
  1177. | The value of 'dist' can be arbitrarily large. In particular, if 'dist' is
  1178. | greater than 32, the result will be either 0 or 1, depending on whether 'a'
  1179. | is zero or nonzero.
  1180. *----------------------------------------------------------------------------*/
  1181. #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
  1182. INLINE uint32_t softfloat_shiftRightJam32( uint32_t a, uint_fast16_t dist )
  1183. {
  1184. return
  1185. (dist < 31) ? a>>dist | ((uint32_t) (a<<(-dist & 31)) != 0) : (a != 0);
  1186. }
  1187. #else
  1188. uint32_t softfloat_shiftRightJam32( uint32_t a, uint_fast16_t dist );
  1189. #endif
  1190. #endif
  1191. #ifndef softfloat_shiftRightJam64
  1192. #define softfloat_shiftRightJam64 softfloat_shiftRightJam64
  1193. /*----------------------------------------------------------------------------
  1194. | Shifts 'a' right by the number of bits given in 'dist', which must not
  1195. | be zero. If any nonzero bits are shifted off, they are "jammed" into the
  1196. | least-significant bit of the shifted value by setting the least-significant
  1197. | bit to 1. This shifted-and-jammed value is returned.
  1198. | The value of 'dist' can be arbitrarily large. In particular, if 'dist' is
  1199. | greater than 64, the result will be either 0 or 1, depending on whether 'a'
  1200. | is zero or nonzero.
  1201. *----------------------------------------------------------------------------*/
  1202. #if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
  1203. INLINE uint64_t softfloat_shiftRightJam64( uint64_t a, uint_fast32_t dist )
  1204. {
  1205. return
  1206. (dist < 63) ? a>>dist | ((uint64_t) (a<<(-dist & 63)) != 0) : (a != 0);
  1207. }
  1208. #else
  1209. uint64_t softfloat_shiftRightJam64( uint64_t a, uint_fast32_t dist );
  1210. #endif
  1211. #endif
  1212. /*----------------------------------------------------------------------------
  1213. | A constant table that translates an 8-bit unsigned integer (the array index)
  1214. | into the number of leading 0 bits before the most-significant 1 of that
  1215. | integer. For integer zero (index 0), the corresponding table element is 8.
  1216. *----------------------------------------------------------------------------*/
  1217. extern const uint_least8_t softfloat_countLeadingZeros8[256];
  1218. #ifndef softfloat_countLeadingZeros16
  1219. #define softfloat_countLeadingZeros16 softfloat_countLeadingZeros16
  1220. /*----------------------------------------------------------------------------
  1221. | Returns the number of leading 0 bits before the most-significant 1 bit of
  1222. | 'a'. If 'a' is zero, 16 is returned.
  1223. *----------------------------------------------------------------------------*/
  1224. #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
  1225. INLINE uint_fast8_t softfloat_countLeadingZeros16( uint16_t a )
  1226. {
  1227. uint_fast8_t count = 8;
  1228. if ( 0x100 <= a ) {
  1229. count = 0;
  1230. a >>= 8;
  1231. }
  1232. count += softfloat_countLeadingZeros8[a];
  1233. return count;
  1234. }
  1235. #else
  1236. uint_fast8_t softfloat_countLeadingZeros16( uint16_t a );
  1237. #endif
  1238. #endif
  1239. #ifndef softfloat_countLeadingZeros32
  1240. #define softfloat_countLeadingZeros32 softfloat_countLeadingZeros32
  1241. /*----------------------------------------------------------------------------
  1242. | Returns the number of leading 0 bits before the most-significant 1 bit of
  1243. | 'a'. If 'a' is zero, 32 is returned.
  1244. *----------------------------------------------------------------------------*/
  1245. #if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
  1246. INLINE uint_fast8_t softfloat_countLeadingZeros32( uint32_t a )
  1247. {
  1248. uint_fast8_t count = 0;
  1249. if ( a < 0x10000 ) {
  1250. count = 16;
  1251. a <<= 16;
  1252. }
  1253. if ( a < 0x1000000 ) {
  1254. count += 8;
  1255. a <<= 8;
  1256. }
  1257. count += softfloat_countLeadingZeros8[a>>24];
  1258. return count;
  1259. }
  1260. #else
  1261. uint_fast8_t softfloat_countLeadingZeros32( uint32_t a );
  1262. #endif
  1263. #endif
  1264. #ifndef softfloat_countLeadingZeros64
  1265. #define softfloat_countLeadingZeros64 softfloat_countLeadingZeros64
  1266. /*----------------------------------------------------------------------------
  1267. | Returns the number of leading 0 bits before the most-significant 1 bit of
  1268. | 'a'. If 'a' is zero, 64 is returned.
  1269. *----------------------------------------------------------------------------*/
  1270. uint_fast8_t softfloat_countLeadingZeros64( uint64_t a );
  1271. #endif
  1272. extern const uint16_t softfloat_approxRecip_1k0s[16];
  1273. extern const uint16_t softfloat_approxRecip_1k1s[16];
  1274. #ifndef softfloat_approxRecip32_1
  1275. /*----------------------------------------------------------------------------
  1276. | Returns an approximation to the reciprocal of the number represented by 'a',
  1277. | where 'a' is interpreted as an unsigned fixed-point number with one integer
  1278. | bit and 31 fraction bits. The 'a' input must be "normalized", meaning that
  1279. | its most-significant bit (bit 31) must be 1. Thus, if A is the value of
  1280. | the fixed-point interpretation of 'a', then 1 <= A < 2. The returned value
  1281. | is interpreted as a pure unsigned fraction, having no integer bits and 32
  1282. | fraction bits. The approximation returned is never greater than the true
  1283. | reciprocal 1/A, and it differs from the true reciprocal by at most 2.006 ulp
  1284. | (units in the last place).
  1285. *----------------------------------------------------------------------------*/
  1286. #ifdef SOFTFLOAT_FAST_DIV64TO32
  1287. #define softfloat_approxRecip32_1( a ) ((uint32_t) (UINT64_C( 0x7FFFFFFFFFFFFFFF ) / (uint32_t) (a)))
  1288. #else
  1289. uint32_t softfloat_approxRecip32_1( uint32_t a );
  1290. #endif
  1291. #endif
  1292. extern const uint16_t softfloat_approxRecipSqrt_1k0s[16];
  1293. extern const uint16_t softfloat_approxRecipSqrt_1k1s[16];
  1294. #ifndef softfloat_approxRecipSqrt32_1
  1295. /*----------------------------------------------------------------------------
  1296. | Returns an approximation to the reciprocal of the square root of the number
  1297. | represented by 'a', where 'a' is interpreted as an unsigned fixed-point
  1298. | number either with one integer bit and 31 fraction bits or with two integer
  1299. | bits and 30 fraction bits. The format of 'a' is determined by 'oddExpA',
  1300. | which must be either 0 or 1. If 'oddExpA' is 1, 'a' is interpreted as
  1301. | having one integer bit, and if 'oddExpA' is 0, 'a' is interpreted as having
  1302. | two integer bits. The 'a' input must be "normalized", meaning that its
  1303. | most-significant bit (bit 31) must be 1. Thus, if A is the value of the
  1304. | fixed-point interpretation of 'a', it follows that 1 <= A < 2 when 'oddExpA'
  1305. | is 1, and 2 <= A < 4 when 'oddExpA' is 0.
  1306. | The returned value is interpreted as a pure unsigned fraction, having
  1307. | no integer bits and 32 fraction bits. The approximation returned is never
  1308. | greater than the true reciprocal 1/sqrt(A), and it differs from the true
  1309. | reciprocal by at most 2.06 ulp (units in the last place). The approximation
  1310. | returned is also always within the range 0.5 to 1; thus, the most-
  1311. | significant bit of the result is always set.
  1312. *----------------------------------------------------------------------------*/
  1313. uint32_t softfloat_approxRecipSqrt32_1( unsigned int oddExpA, uint32_t a );
  1314. #endif
  1315. #ifdef SOFTFLOAT_FAST_INT64
  1316. /*----------------------------------------------------------------------------
  1317. | The following functions are needed only when 'SOFTFLOAT_FAST_INT64' is
  1318. | defined.
  1319. *----------------------------------------------------------------------------*/
  1320. #ifndef softfloat_eq128
  1321. #define softfloat_eq128 softfloat_eq128
  1322. /*----------------------------------------------------------------------------
  1323. | Returns true if the 128-bit unsigned integer formed by concatenating 'a64'
  1324. | and 'a0' is equal to the 128-bit unsigned integer formed by concatenating
  1325. | 'b64' and 'b0'.
  1326. *----------------------------------------------------------------------------*/
  1327. #if defined INLINE_LEVEL && (1 <= INLINE_LEVEL)
  1328. INLINE
  1329. bool softfloat_eq128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
  1330. { return (a64 == b64) && (a0 == b0); }
  1331. #else
  1332. bool softfloat_eq128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
  1333. #endif
  1334. #endif
  1335. #ifndef softfloat_le128
  1336. #define softfloat_le128 softfloat_le128
  1337. /*----------------------------------------------------------------------------
  1338. | Returns true if the 128-bit unsigned integer formed by concatenating 'a64'
  1339. | and 'a0' is less than or equal to the 128-bit unsigned integer formed by
  1340. | concatenating 'b64' and 'b0'.
  1341. *----------------------------------------------------------------------------*/
  1342. #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
  1343. INLINE
  1344. bool softfloat_le128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
  1345. { return (a64 < b64) || ((a64 == b64) && (a0 <= b0)); }
  1346. #else
  1347. bool softfloat_le128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
  1348. #endif
  1349. #endif
  1350. #ifndef softfloat_lt128
  1351. #define softfloat_lt128 softfloat_lt128
  1352. /*----------------------------------------------------------------------------
  1353. | Returns true if the 128-bit unsigned integer formed by concatenating 'a64'
  1354. | and 'a0' is less than the 128-bit unsigned integer formed by concatenating
  1355. | 'b64' and 'b0'.
  1356. *----------------------------------------------------------------------------*/
  1357. #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
  1358. INLINE
  1359. bool softfloat_lt128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
  1360. { return (a64 < b64) || ((a64 == b64) && (a0 < b0)); }
  1361. #else
  1362. bool softfloat_lt128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
  1363. #endif
  1364. #endif
  1365. #ifndef softfloat_shortShiftLeft128
  1366. #define softfloat_shortShiftLeft128 softfloat_shortShiftLeft128
  1367. /*----------------------------------------------------------------------------
  1368. | Shifts the 128 bits formed by concatenating 'a64' and 'a0' left by the
  1369. | number of bits given in 'dist', which must be in the range 1 to 63.
  1370. *----------------------------------------------------------------------------*/
  1371. #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
  1372. INLINE
  1373. struct uint128
  1374. softfloat_shortShiftLeft128( uint64_t a64, uint64_t a0, uint_fast8_t dist )
  1375. {
  1376. struct uint128 z;
  1377. z.v64 = a64<<dist | a0>>(-dist & 63);
  1378. z.v0 = a0<<dist;
  1379. return z;
  1380. }
  1381. #else
  1382. struct uint128
  1383. softfloat_shortShiftLeft128( uint64_t a64, uint64_t a0, uint_fast8_t dist );
  1384. #endif
  1385. #endif
  1386. #ifndef softfloat_shortShiftRight128
  1387. #define softfloat_shortShiftRight128 softfloat_shortShiftRight128
  1388. /*----------------------------------------------------------------------------
  1389. | Shifts the 128 bits formed by concatenating 'a64' and 'a0' right by the
  1390. | number of bits given in 'dist', which must be in the range 1 to 63.
  1391. *----------------------------------------------------------------------------*/
  1392. #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
  1393. INLINE
  1394. struct uint128
  1395. softfloat_shortShiftRight128( uint64_t a64, uint64_t a0, uint_fast8_t dist )
  1396. {
  1397. struct uint128 z;
  1398. z.v64 = a64>>dist;
  1399. z.v0 = a64<<(-dist & 63) | a0>>dist;
  1400. return z;
  1401. }
  1402. #else
  1403. struct uint128
  1404. softfloat_shortShiftRight128( uint64_t a64, uint64_t a0, uint_fast8_t dist );
  1405. #endif
  1406. #endif
  1407. #ifndef softfloat_shortShiftRightJam64Extra
  1408. #define softfloat_shortShiftRightJam64Extra softfloat_shortShiftRightJam64Extra
  1409. /*----------------------------------------------------------------------------
  1410. | This function is the same as 'softfloat_shiftRightJam64Extra' (below),
  1411. | except that 'dist' must be in the range 1 to 63.
  1412. *----------------------------------------------------------------------------*/
  1413. #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
  1414. INLINE
  1415. struct uint64_extra
  1416. softfloat_shortShiftRightJam64Extra(
  1417. uint64_t a, uint64_t extra, uint_fast8_t dist )
  1418. {
  1419. struct uint64_extra z;
  1420. z.v = a>>dist;
  1421. z.extra = a<<(-dist & 63) | (extra != 0);
  1422. return z;
  1423. }
  1424. #else
  1425. struct uint64_extra
  1426. softfloat_shortShiftRightJam64Extra(
  1427. uint64_t a, uint64_t extra, uint_fast8_t dist );
  1428. #endif
  1429. #endif
  1430. #ifndef softfloat_shortShiftRightJam128
  1431. #define softfloat_shortShiftRightJam128 softfloat_shortShiftRightJam128
  1432. /*----------------------------------------------------------------------------
  1433. | Shifts the 128 bits formed by concatenating 'a64' and 'a0' right by the
  1434. | number of bits given in 'dist', which must be in the range 1 to 63. If any
  1435. | nonzero bits are shifted off, they are "jammed" into the least-significant
  1436. | bit of the shifted value by setting the least-significant bit to 1. This
  1437. | shifted-and-jammed value is returned.
  1438. *----------------------------------------------------------------------------*/
  1439. #if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
  1440. INLINE
  1441. struct uint128
  1442. softfloat_shortShiftRightJam128(
  1443. uint64_t a64, uint64_t a0, uint_fast8_t dist )
  1444. {
  1445. uint_fast8_t negDist = -dist;
  1446. struct uint128 z;
  1447. z.v64 = a64>>dist;
  1448. z.v0 =
  1449. a64<<(negDist & 63) | a0>>dist
  1450. | ((uint64_t) (a0<<(negDist & 63)) != 0);
  1451. return z;
  1452. }
  1453. #else
  1454. struct uint128
  1455. softfloat_shortShiftRightJam128(
  1456. uint64_t a64, uint64_t a0, uint_fast8_t dist );
  1457. #endif
  1458. #endif
  1459. #ifndef softfloat_shortShiftRightJam128Extra
  1460. #define softfloat_shortShiftRightJam128Extra softfloat_shortShiftRightJam128Extra
  1461. /*----------------------------------------------------------------------------
  1462. | This function is the same as 'softfloat_shiftRightJam128Extra' (below),
  1463. | except that 'dist' must be in the range 1 to 63.
  1464. *----------------------------------------------------------------------------*/
  1465. #if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
  1466. INLINE
  1467. struct uint128_extra
  1468. softfloat_shortShiftRightJam128Extra(
  1469. uint64_t a64, uint64_t a0, uint64_t extra, uint_fast8_t dist )
  1470. {
  1471. uint_fast8_t negDist = -dist;
  1472. struct uint128_extra z;
  1473. z.v.v64 = a64>>dist;
  1474. z.v.v0 = a64<<(negDist & 63) | a0>>dist;
  1475. z.extra = a0<<(negDist & 63) | (extra != 0);
  1476. return z;
  1477. }
  1478. #else
  1479. struct uint128_extra
  1480. softfloat_shortShiftRightJam128Extra(
  1481. uint64_t a64, uint64_t a0, uint64_t extra, uint_fast8_t dist );
  1482. #endif
  1483. #endif
  1484. #ifndef softfloat_shiftRightJam64Extra
  1485. #define softfloat_shiftRightJam64Extra softfloat_shiftRightJam64Extra
  1486. /*----------------------------------------------------------------------------
  1487. | Shifts the 128 bits formed by concatenating 'a' and 'extra' right by 64
  1488. | _plus_ the number of bits given in 'dist', which must not be zero. This
  1489. | shifted value is at most 64 nonzero bits and is returned in the 'v' field
  1490. | of the 'struct uint64_extra' result. The 64-bit 'extra' field of the result
  1491. | contains a value formed as follows from the bits that were shifted off: The
  1492. | _last_ bit shifted off is the most-significant bit of the 'extra' field, and
  1493. | the other 63 bits of the 'extra' field are all zero if and only if _all_but_
  1494. | _the_last_ bits shifted off were all zero.
  1495. | (This function makes more sense if 'a' and 'extra' are considered to form
  1496. | an unsigned fixed-point number with binary point between 'a' and 'extra'.
  1497. | This fixed-point value is shifted right by the number of bits given in
  1498. | 'dist', and the integer part of this shifted value is returned in the 'v'
  1499. | field of the result. The fractional part of the shifted value is modified
  1500. | as described above and returned in the 'extra' field of the result.)
  1501. *----------------------------------------------------------------------------*/
  1502. #if defined INLINE_LEVEL && (4 <= INLINE_LEVEL)
  1503. INLINE
  1504. struct uint64_extra
  1505. softfloat_shiftRightJam64Extra(
  1506. uint64_t a, uint64_t extra, uint_fast32_t dist )
  1507. {
  1508. struct uint64_extra z;
  1509. if ( dist < 64 ) {
  1510. z.v = a>>dist;
  1511. z.extra = a<<(-dist & 63);
  1512. } else {
  1513. z.v = 0;
  1514. z.extra = (dist == 64) ? a : (a != 0);
  1515. }
  1516. z.extra |= (extra != 0);
  1517. return z;
  1518. }
  1519. #else
  1520. struct uint64_extra
  1521. softfloat_shiftRightJam64Extra(
  1522. uint64_t a, uint64_t extra, uint_fast32_t dist );
  1523. #endif
  1524. #endif
  1525. #ifndef softfloat_shiftRightJam128
  1526. //#define softfloat_shiftRightJam128 softfloat_shiftRightJam128
  1527. /*----------------------------------------------------------------------------
  1528. | Shifts the 128 bits formed by concatenating 'a64' and 'a0' right by the
  1529. | number of bits given in 'dist', which must not be zero. If any nonzero bits
  1530. | are shifted off, they are "jammed" into the least-significant bit of the
  1531. | shifted value by setting the least-significant bit to 1. This shifted-and-
  1532. | jammed value is returned.
  1533. | The value of 'dist' can be arbitrarily large. In particular, if 'dist' is
  1534. | greater than 128, the result will be either 0 or 1, depending on whether the
  1535. | original 128 bits are all zeros.
  1536. *----------------------------------------------------------------------------*/
  1537. struct uint128
  1538. softfloat_shiftRightJam128( uint64_t a64, uint64_t a0, uint_fast32_t dist );
  1539. #endif
  1540. #ifndef softfloat_shiftRightJam128Extra
  1541. #define softfloat_shiftRightJam128Extra softfloat_shiftRightJam128Extra
  1542. /*----------------------------------------------------------------------------
  1543. | Shifts the 192 bits formed by concatenating 'a64', 'a0', and 'extra' right
  1544. | by 64 _plus_ the number of bits given in 'dist', which must not be zero.
  1545. | This shifted value is at most 128 nonzero bits and is returned in the 'v'
  1546. | field of the 'struct uint128_extra' result. The 64-bit 'extra' field of the
  1547. | result contains a value formed as follows from the bits that were shifted
  1548. | off: The _last_ bit shifted off is the most-significant bit of the 'extra'
  1549. | field, and the other 63 bits of the 'extra' field are all zero if and only
  1550. | if _all_but_the_last_ bits shifted off were all zero.
  1551. | (This function makes more sense if 'a64', 'a0', and 'extra' are considered
  1552. | to form an unsigned fixed-point number with binary point between 'a0' and
  1553. | 'extra'. This fixed-point value is shifted right by the number of bits
  1554. | given in 'dist', and the integer part of this shifted value is returned
  1555. | in the 'v' field of the result. The fractional part of the shifted value
  1556. | is modified as described above and returned in the 'extra' field of the
  1557. | result.)
  1558. *----------------------------------------------------------------------------*/
  1559. struct uint128_extra
  1560. softfloat_shiftRightJam128Extra(
  1561. uint64_t a64, uint64_t a0, uint64_t extra, uint_fast32_t dist );
  1562. #endif
  1563. #ifndef softfloat_shiftRightJam256M
  1564. #define softfloat_shiftRightJam256M softfloat_shiftRightJam256M
  1565. /*----------------------------------------------------------------------------
  1566. | Shifts the 256-bit unsigned integer pointed to by 'aPtr' right by the number
  1567. | of bits given in 'dist', which must not be zero. If any nonzero bits are
  1568. | shifted off, they are "jammed" into the least-significant bit of the shifted
  1569. | value by setting the least-significant bit to 1. This shifted-and-jammed
  1570. | value is stored at the location pointed to by 'zPtr'. Each of 'aPtr' and
  1571. | 'zPtr' points to an array of four 64-bit elements that concatenate in the
  1572. | platform's normal endian order to form a 256-bit integer.
  1573. | The value of 'dist' can be arbitrarily large. In particular, if 'dist'
  1574. | is greater than 256, the stored result will be either 0 or 1, depending on
  1575. | whether the original 256 bits are all zeros.
  1576. *----------------------------------------------------------------------------*/
  1577. void
  1578. softfloat_shiftRightJam256M(
  1579. const uint64_t *aPtr, uint_fast32_t dist, uint64_t *zPtr );
  1580. #endif
  1581. #ifndef softfloat_add128
  1582. #define softfloat_add128 softfloat_add128
  1583. /*----------------------------------------------------------------------------
  1584. | Returns the sum of the 128-bit integer formed by concatenating 'a64' and
  1585. | 'a0' and the 128-bit integer formed by concatenating 'b64' and 'b0'. The
  1586. | addition is modulo 2^128, so any carry out is lost.
  1587. *----------------------------------------------------------------------------*/
  1588. #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
  1589. INLINE
  1590. struct uint128
  1591. softfloat_add128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
  1592. {
  1593. struct uint128 z;
  1594. z.v0 = a0 + b0;
  1595. z.v64 = a64 + b64 + (z.v0 < a0);
  1596. return z;
  1597. }
  1598. #else
  1599. struct uint128
  1600. softfloat_add128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
  1601. #endif
  1602. #endif
  1603. #ifndef softfloat_add256M
  1604. /*----------------------------------------------------------------------------
  1605. | Adds the two 256-bit integers pointed to by 'aPtr' and 'bPtr'. The addition
  1606. | is modulo 2^256, so any carry out is lost. The sum is stored at the
  1607. | location pointed to by 'zPtr'. Each of 'aPtr', 'bPtr', and 'zPtr' points to
  1608. | an array of four 64-bit elements that concatenate in the platform's normal
  1609. | endian order to form a 256-bit integer.
  1610. *----------------------------------------------------------------------------*/
  1611. void
  1612. softfloat_add256M(
  1613. const uint64_t *aPtr, const uint64_t *bPtr, uint64_t *zPtr );
  1614. #endif
  1615. #ifndef softfloat_sub128
  1616. #define softfloat_sub128 softfloat_sub128
  1617. /*----------------------------------------------------------------------------
  1618. | Returns the difference of the 128-bit integer formed by concatenating 'a64'
  1619. | and 'a0' and the 128-bit integer formed by concatenating 'b64' and 'b0'.
  1620. | The subtraction is modulo 2^128, so any borrow out (carry out) is lost.
  1621. *----------------------------------------------------------------------------*/
  1622. #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
  1623. INLINE
  1624. struct uint128
  1625. softfloat_sub128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
  1626. {
  1627. struct uint128 z;
  1628. z.v0 = a0 - b0;
  1629. z.v64 = a64 - b64;
  1630. z.v64 -= (a0 < b0);
  1631. return z;
  1632. }
  1633. #else
  1634. struct uint128
  1635. softfloat_sub128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
  1636. #endif
  1637. #endif
  1638. #ifndef softfloat_sub256M
  1639. /*----------------------------------------------------------------------------
  1640. | Subtracts the 256-bit integer pointed to by 'bPtr' from the 256-bit integer
  1641. | pointed to by 'aPtr'. The addition is modulo 2^256, so any borrow out
  1642. | (carry out) is lost. The difference is stored at the location pointed to
  1643. | by 'zPtr'. Each of 'aPtr', 'bPtr', and 'zPtr' points to an array of four
  1644. | 64-bit elements that concatenate in the platform's normal endian order to
  1645. | form a 256-bit integer.
  1646. *----------------------------------------------------------------------------*/
  1647. void
  1648. softfloat_sub256M(
  1649. const uint64_t *aPtr, const uint64_t *bPtr, uint64_t *zPtr );
  1650. #endif
  1651. #ifndef softfloat_mul64ByShifted32To128
  1652. /*----------------------------------------------------------------------------
  1653. | Returns the 128-bit product of 'a', 'b', and 2^32.
  1654. *----------------------------------------------------------------------------*/
  1655. #if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
  1656. INLINE struct uint128 softfloat_mul64ByShifted32To128( uint64_t a, uint32_t b )
  1657. {
  1658. uint_fast64_t mid;
  1659. struct uint128 z;
  1660. mid = (uint_fast64_t) (uint32_t) a * b;
  1661. z.v0 = mid<<32;
  1662. z.v64 = (uint_fast64_t) (uint32_t) (a>>32) * b + (mid>>32);
  1663. return z;
  1664. }
  1665. #else
  1666. struct uint128 softfloat_mul64ByShifted32To128( uint64_t a, uint32_t b );
  1667. #endif
  1668. #endif
  1669. #ifndef softfloat_mul64To128
  1670. /*----------------------------------------------------------------------------
  1671. | Returns the 128-bit product of 'a' and 'b'.
  1672. *----------------------------------------------------------------------------*/
  1673. struct uint128 softfloat_mul64To128( uint64_t a, uint64_t b );
  1674. #endif
  1675. #ifndef softfloat_mul128By32
  1676. /*----------------------------------------------------------------------------
  1677. | Returns the product of the 128-bit integer formed by concatenating 'a64' and
  1678. | 'a0', multiplied by 'b'. The multiplication is modulo 2^128; any overflow
  1679. | bits are discarded.
  1680. *----------------------------------------------------------------------------*/
  1681. #if defined INLINE_LEVEL && (4 <= INLINE_LEVEL)
  1682. INLINE
  1683. struct uint128 softfloat_mul128By32( uint64_t a64, uint64_t a0, uint32_t b )
  1684. {
  1685. struct uint128 z;
  1686. uint_fast64_t mid;
  1687. uint_fast32_t carry;
  1688. z.v0 = a0 * b;
  1689. mid = (uint_fast64_t) (uint32_t) (a0>>32) * b;
  1690. carry = (uint32_t) ((uint_fast32_t) (z.v0>>32) - (uint_fast32_t) mid);
  1691. z.v64 = a64 * b + (uint_fast32_t) ((mid + carry)>>32);
  1692. return z;
  1693. }
  1694. #else
  1695. struct uint128 softfloat_mul128By32( uint64_t a64, uint64_t a0, uint32_t b );
  1696. #endif
  1697. #endif
  1698. #ifndef softfloat_mul128To256M
  1699. /*----------------------------------------------------------------------------
  1700. | Multiplies the 128-bit unsigned integer formed by concatenating 'a64' and
  1701. | 'a0' by the 128-bit unsigned integer formed by concatenating 'b64' and
  1702. | 'b0'. The 256-bit product is stored at the location pointed to by 'zPtr'.
  1703. | Argument 'zPtr' points to an array of four 64-bit elements that concatenate
  1704. | in the platform's normal endian order to form a 256-bit integer.
  1705. *----------------------------------------------------------------------------*/
  1706. void
  1707. softfloat_mul128To256M(
  1708. uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0, uint64_t *zPtr );
  1709. #endif
  1710. #else
  1711. /*----------------------------------------------------------------------------
  1712. | The following functions are needed only when 'SOFTFLOAT_FAST_INT64' is not
  1713. | defined.
  1714. *----------------------------------------------------------------------------*/
  1715. #ifndef softfloat_compare96M
  1716. /*----------------------------------------------------------------------------
  1717. | Compares the two 96-bit unsigned integers pointed to by 'aPtr' and 'bPtr'.
  1718. | Returns -1 if the first integer (A) is less than the second (B); returns 0
  1719. | if the two integers are equal; and returns +1 if the first integer (A)
  1720. | is greater than the second (B). (The result is thus the signum of A - B.)
  1721. | Each of 'aPtr' and 'bPtr' points to an array of three 32-bit elements that
  1722. | concatenate in the platform's normal endian order to form a 96-bit integer.
  1723. *----------------------------------------------------------------------------*/
  1724. int_fast8_t softfloat_compare96M( const uint32_t *aPtr, const uint32_t *bPtr );
  1725. #endif
  1726. #ifndef softfloat_compare128M
  1727. /*----------------------------------------------------------------------------
  1728. | Compares the two 128-bit unsigned integers pointed to by 'aPtr' and 'bPtr'.
  1729. | Returns -1 if the first integer (A) is less than the second (B); returns 0
  1730. | if the two integers are equal; and returns +1 if the first integer (A)
  1731. | is greater than the second (B). (The result is thus the signum of A - B.)
  1732. | Each of 'aPtr' and 'bPtr' points to an array of four 32-bit elements that
  1733. | concatenate in the platform's normal endian order to form a 128-bit integer.
  1734. *----------------------------------------------------------------------------*/
  1735. int_fast8_t
  1736. softfloat_compare128M( const uint32_t *aPtr, const uint32_t *bPtr );
  1737. #endif
  1738. #ifndef softfloat_shortShiftLeft64To96M
  1739. /*----------------------------------------------------------------------------
  1740. | Extends 'a' to 96 bits and shifts the value left by the number of bits given
  1741. | in 'dist', which must be in the range 1 to 31. The result is stored at the
  1742. | location pointed to by 'zPtr'. Argument 'zPtr' points to an array of three
  1743. | 32-bit elements that concatenate in the platform's normal endian order to
  1744. | form a 96-bit integer.
  1745. *----------------------------------------------------------------------------*/
  1746. #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
  1747. INLINE
  1748. void
  1749. softfloat_shortShiftLeft64To96M(
  1750. uint64_t a, uint_fast8_t dist, uint32_t *zPtr )
  1751. {
  1752. zPtr[indexWord( 3, 0 )] = (uint32_t) a<<dist;
  1753. a >>= 32 - dist;
  1754. zPtr[indexWord( 3, 2 )] = a>>32;
  1755. zPtr[indexWord( 3, 1 )] = a;
  1756. }
  1757. #else
  1758. void
  1759. softfloat_shortShiftLeft64To96M(
  1760. uint64_t a, uint_fast8_t dist, uint32_t *zPtr );
  1761. #endif
  1762. #endif
  1763. #ifndef softfloat_shortShiftLeftM
  1764. /*----------------------------------------------------------------------------
  1765. | Shifts the N-bit unsigned integer pointed to by 'aPtr' left by the number
  1766. | of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
  1767. | must be in the range 1 to 31. Any nonzero bits shifted off are lost. The
  1768. | shifted N-bit result is stored at the location pointed to by 'zPtr'. Each
  1769. | of 'aPtr' and 'zPtr' points to a 'size_words'-long array of 32-bit elements
  1770. | that concatenate in the platform's normal endian order to form an N-bit
  1771. | integer.
  1772. *----------------------------------------------------------------------------*/
  1773. void
  1774. softfloat_shortShiftLeftM(
  1775. uint_fast8_t size_words,
  1776. const uint32_t *aPtr,
  1777. uint_fast8_t dist,
  1778. uint32_t *zPtr
  1779. );
  1780. #endif
  1781. #ifndef softfloat_shortShiftLeft96M
  1782. /*----------------------------------------------------------------------------
  1783. | This function or macro is the same as 'softfloat_shortShiftLeftM' with
  1784. | 'size_words' = 3 (N = 96).
  1785. *----------------------------------------------------------------------------*/
  1786. #define softfloat_shortShiftLeft96M( aPtr, dist, zPtr ) softfloat_shortShiftLeftM( 3, aPtr, dist, zPtr )
  1787. #endif
  1788. #ifndef softfloat_shortShiftLeft128M
  1789. /*----------------------------------------------------------------------------
  1790. | This function or macro is the same as 'softfloat_shortShiftLeftM' with
  1791. | 'size_words' = 4 (N = 128).
  1792. *----------------------------------------------------------------------------*/
  1793. #define softfloat_shortShiftLeft128M( aPtr, dist, zPtr ) softfloat_shortShiftLeftM( 4, aPtr, dist, zPtr )
  1794. #endif
  1795. #ifndef softfloat_shortShiftLeft160M
  1796. /*----------------------------------------------------------------------------
  1797. | This function or macro is the same as 'softfloat_shortShiftLeftM' with
  1798. | 'size_words' = 5 (N = 160).
  1799. *----------------------------------------------------------------------------*/
  1800. #define softfloat_shortShiftLeft160M( aPtr, dist, zPtr ) softfloat_shortShiftLeftM( 5, aPtr, dist, zPtr )
  1801. #endif
  1802. #ifndef softfloat_shiftLeftM
  1803. /*----------------------------------------------------------------------------
  1804. | Shifts the N-bit unsigned integer pointed to by 'aPtr' left by the number
  1805. | of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
  1806. | must not be zero. Any nonzero bits shifted off are lost. The shifted
  1807. | N-bit result is stored at the location pointed to by 'zPtr'. Each of 'aPtr'
  1808. | and 'zPtr' points to a 'size_words'-long array of 32-bit elements that
  1809. | concatenate in the platform's normal endian order to form an N-bit integer.
  1810. | The value of 'dist' can be arbitrarily large. In particular, if 'dist' is
  1811. | greater than N, the stored result will be 0.
  1812. *----------------------------------------------------------------------------*/
  1813. void
  1814. softfloat_shiftLeftM(
  1815. uint_fast8_t size_words,
  1816. const uint32_t *aPtr,
  1817. uint32_t dist,
  1818. uint32_t *zPtr
  1819. );
  1820. #endif
  1821. #ifndef softfloat_shiftLeft96M
  1822. /*----------------------------------------------------------------------------
  1823. | This function or macro is the same as 'softfloat_shiftLeftM' with
  1824. | 'size_words' = 3 (N = 96).
  1825. *----------------------------------------------------------------------------*/
  1826. #define softfloat_shiftLeft96M( aPtr, dist, zPtr ) softfloat_shiftLeftM( 3, aPtr, dist, zPtr )
  1827. #endif
  1828. #ifndef softfloat_shiftLeft128M
  1829. /*----------------------------------------------------------------------------
  1830. | This function or macro is the same as 'softfloat_shiftLeftM' with
  1831. | 'size_words' = 4 (N = 128).
  1832. *----------------------------------------------------------------------------*/
  1833. #define softfloat_shiftLeft128M( aPtr, dist, zPtr ) softfloat_shiftLeftM( 4, aPtr, dist, zPtr )
  1834. #endif
  1835. #ifndef softfloat_shiftLeft160M
  1836. /*----------------------------------------------------------------------------
  1837. | This function or macro is the same as 'softfloat_shiftLeftM' with
  1838. | 'size_words' = 5 (N = 160).
  1839. *----------------------------------------------------------------------------*/
  1840. #define softfloat_shiftLeft160M( aPtr, dist, zPtr ) softfloat_shiftLeftM( 5, aPtr, dist, zPtr )
  1841. #endif
  1842. #ifndef softfloat_shortShiftRightM
  1843. /*----------------------------------------------------------------------------
  1844. | Shifts the N-bit unsigned integer pointed to by 'aPtr' right by the number
  1845. | of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
  1846. | must be in the range 1 to 31. Any nonzero bits shifted off are lost. The
  1847. | shifted N-bit result is stored at the location pointed to by 'zPtr'. Each
  1848. | of 'aPtr' and 'zPtr' points to a 'size_words'-long array of 32-bit elements
  1849. | that concatenate in the platform's normal endian order to form an N-bit
  1850. | integer.
  1851. *----------------------------------------------------------------------------*/
  1852. void
  1853. softfloat_shortShiftRightM(
  1854. uint_fast8_t size_words,
  1855. const uint32_t *aPtr,
  1856. uint_fast8_t dist,
  1857. uint32_t *zPtr
  1858. );
  1859. #endif
  1860. #ifndef softfloat_shortShiftRight128M
  1861. /*----------------------------------------------------------------------------
  1862. | This function or macro is the same as 'softfloat_shortShiftRightM' with
  1863. | 'size_words' = 4 (N = 128).
  1864. *----------------------------------------------------------------------------*/
  1865. #define softfloat_shortShiftRight128M( aPtr, dist, zPtr ) softfloat_shortShiftRightM( 4, aPtr, dist, zPtr )
  1866. #endif
  1867. #ifndef softfloat_shortShiftRight160M
  1868. /*----------------------------------------------------------------------------
  1869. | This function or macro is the same as 'softfloat_shortShiftRightM' with
  1870. | 'size_words' = 5 (N = 160).
  1871. *----------------------------------------------------------------------------*/
  1872. #define softfloat_shortShiftRight160M( aPtr, dist, zPtr ) softfloat_shortShiftRightM( 5, aPtr, dist, zPtr )
  1873. #endif
  1874. #ifndef softfloat_shortShiftRightJamM
  1875. /*----------------------------------------------------------------------------
  1876. | Shifts the N-bit unsigned integer pointed to by 'aPtr' right by the number
  1877. | of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
  1878. | must be in the range 1 to 31. If any nonzero bits are shifted off, they are
  1879. | "jammed" into the least-significant bit of the shifted value by setting the
  1880. | least-significant bit to 1. This shifted-and-jammed N-bit result is stored
  1881. | at the location pointed to by 'zPtr'. Each of 'aPtr' and 'zPtr' points
  1882. | to a 'size_words'-long array of 32-bit elements that concatenate in the
  1883. | platform's normal endian order to form an N-bit integer.
  1884. *----------------------------------------------------------------------------*/
  1885. void
  1886. softfloat_shortShiftRightJamM(
  1887. uint_fast8_t, const uint32_t *, uint_fast8_t, uint32_t * );
  1888. #endif
  1889. #ifndef softfloat_shortShiftRightJam160M
  1890. /*----------------------------------------------------------------------------
  1891. | This function or macro is the same as 'softfloat_shortShiftRightJamM' with
  1892. | 'size_words' = 5 (N = 160).
  1893. *----------------------------------------------------------------------------*/
  1894. #define softfloat_shortShiftRightJam160M( aPtr, dist, zPtr ) softfloat_shortShiftRightJamM( 5, aPtr, dist, zPtr )
  1895. #endif
  1896. #ifndef softfloat_shiftRightM
  1897. /*----------------------------------------------------------------------------
  1898. | Shifts the N-bit unsigned integer pointed to by 'aPtr' right by the number
  1899. | of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
  1900. | must not be zero. Any nonzero bits shifted off are lost. The shifted
  1901. | N-bit result is stored at the location pointed to by 'zPtr'. Each of 'aPtr'
  1902. | and 'zPtr' points to a 'size_words'-long array of 32-bit elements that
  1903. | concatenate in the platform's normal endian order to form an N-bit integer.
  1904. | The value of 'dist' can be arbitrarily large. In particular, if 'dist' is
  1905. | greater than N, the stored result will be 0.
  1906. *----------------------------------------------------------------------------*/
  1907. void
  1908. softfloat_shiftRightM(
  1909. uint_fast8_t size_words,
  1910. const uint32_t *aPtr,
  1911. uint32_t dist,
  1912. uint32_t *zPtr
  1913. );
  1914. #endif
  1915. #ifndef softfloat_shiftRight96M
  1916. /*----------------------------------------------------------------------------
  1917. | This function or macro is the same as 'softfloat_shiftRightM' with
  1918. | 'size_words' = 3 (N = 96).
  1919. *----------------------------------------------------------------------------*/
  1920. #define softfloat_shiftRight96M( aPtr, dist, zPtr ) softfloat_shiftRightM( 3, aPtr, dist, zPtr )
  1921. #endif
  1922. #ifndef softfloat_shiftRightJamM
  1923. /*----------------------------------------------------------------------------
  1924. | Shifts the N-bit unsigned integer pointed to by 'aPtr' right by the number
  1925. | of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
  1926. | must not be zero. If any nonzero bits are shifted off, they are "jammed"
  1927. | into the least-significant bit of the shifted value by setting the least-
  1928. | significant bit to 1. This shifted-and-jammed N-bit result is stored
  1929. | at the location pointed to by 'zPtr'. Each of 'aPtr' and 'zPtr' points
  1930. | to a 'size_words'-long array of 32-bit elements that concatenate in the
  1931. | platform's normal endian order to form an N-bit integer.
  1932. | The value of 'dist' can be arbitrarily large. In particular, if 'dist'
  1933. | is greater than N, the stored result will be either 0 or 1, depending on
  1934. | whether the original N bits are all zeros.
  1935. *----------------------------------------------------------------------------*/
  1936. void
  1937. softfloat_shiftRightJamM(
  1938. uint_fast8_t size_words,
  1939. const uint32_t *aPtr,
  1940. uint32_t dist,
  1941. uint32_t *zPtr
  1942. );
  1943. #endif
  1944. #ifndef softfloat_shiftRightJam96M
  1945. /*----------------------------------------------------------------------------
  1946. | This function or macro is the same as 'softfloat_shiftRightJamM' with
  1947. | 'size_words' = 3 (N = 96).
  1948. *----------------------------------------------------------------------------*/
  1949. #define softfloat_shiftRightJam96M( aPtr, dist, zPtr ) softfloat_shiftRightJamM( 3, aPtr, dist, zPtr )
  1950. #endif
  1951. #ifndef softfloat_shiftRightJam128M
  1952. /*----------------------------------------------------------------------------
  1953. | This function or macro is the same as 'softfloat_shiftRightJamM' with
  1954. | 'size_words' = 4 (N = 128).
  1955. *----------------------------------------------------------------------------*/
  1956. #define softfloat_shiftRightJam128M( aPtr, dist, zPtr ) softfloat_shiftRightJamM( 4, aPtr, dist, zPtr )
  1957. #endif
  1958. #ifndef softfloat_shiftRightJam160M
  1959. /*----------------------------------------------------------------------------
  1960. | This function or macro is the same as 'softfloat_shiftRightJamM' with
  1961. | 'size_words' = 5 (N = 160).
  1962. *----------------------------------------------------------------------------*/
  1963. #define softfloat_shiftRightJam160M( aPtr, dist, zPtr ) softfloat_shiftRightJamM( 5, aPtr, dist, zPtr )
  1964. #endif
  1965. #ifndef softfloat_addM
  1966. /*----------------------------------------------------------------------------
  1967. | Adds the two N-bit integers pointed to by 'aPtr' and 'bPtr', where N =
  1968. | 'size_words' * 32. The addition is modulo 2^N, so any carry out is lost.
  1969. | The N-bit sum is stored at the location pointed to by 'zPtr'. Each of
  1970. | 'aPtr', 'bPtr', and 'zPtr' points to a 'size_words'-long array of 32-bit
  1971. | elements that concatenate in the platform's normal endian order to form an
  1972. | N-bit integer.
  1973. *----------------------------------------------------------------------------*/
  1974. void
  1975. softfloat_addM(
  1976. uint_fast8_t size_words,
  1977. const uint32_t *aPtr,
  1978. const uint32_t *bPtr,
  1979. uint32_t *zPtr
  1980. );
  1981. #endif
  1982. #ifndef softfloat_add96M
  1983. /*----------------------------------------------------------------------------
  1984. | This function or macro is the same as 'softfloat_addM' with 'size_words'
  1985. | = 3 (N = 96).
  1986. *----------------------------------------------------------------------------*/
  1987. #define softfloat_add96M( aPtr, bPtr, zPtr ) softfloat_addM( 3, aPtr, bPtr, zPtr )
  1988. #endif
  1989. #ifndef softfloat_add128M
  1990. /*----------------------------------------------------------------------------
  1991. | This function or macro is the same as 'softfloat_addM' with 'size_words'
  1992. | = 4 (N = 128).
  1993. *----------------------------------------------------------------------------*/
  1994. #define softfloat_add128M( aPtr, bPtr, zPtr ) softfloat_addM( 4, aPtr, bPtr, zPtr )
  1995. #endif
  1996. #ifndef softfloat_add160M
  1997. /*----------------------------------------------------------------------------
  1998. | This function or macro is the same as 'softfloat_addM' with 'size_words'
  1999. | = 5 (N = 160).
  2000. *----------------------------------------------------------------------------*/
  2001. #define softfloat_add160M( aPtr, bPtr, zPtr ) softfloat_addM( 5, aPtr, bPtr, zPtr )
  2002. #endif
  2003. #ifndef softfloat_addCarryM
  2004. /*----------------------------------------------------------------------------
  2005. | Adds the two N-bit unsigned integers pointed to by 'aPtr' and 'bPtr', where
  2006. | N = 'size_words' * 32, plus 'carry', which must be either 0 or 1. The N-bit
  2007. | sum (modulo 2^N) is stored at the location pointed to by 'zPtr', and any
  2008. | carry out is returned as the result. Each of 'aPtr', 'bPtr', and 'zPtr'
  2009. | points to a 'size_words'-long array of 32-bit elements that concatenate in
  2010. | the platform's normal endian order to form an N-bit integer.
  2011. *----------------------------------------------------------------------------*/
  2012. uint_fast8_t
  2013. softfloat_addCarryM(
  2014. uint_fast8_t size_words,
  2015. const uint32_t *aPtr,
  2016. const uint32_t *bPtr,
  2017. uint_fast8_t carry,
  2018. uint32_t *zPtr
  2019. );
  2020. #endif
  2021. #ifndef softfloat_addComplCarryM
  2022. /*----------------------------------------------------------------------------
  2023. | This function or macro is the same as 'softfloat_addCarryM', except that
  2024. | the value of the unsigned integer pointed to by 'bPtr' is bit-wise completed
  2025. | before the addition.
  2026. *----------------------------------------------------------------------------*/
  2027. uint_fast8_t
  2028. softfloat_addComplCarryM(
  2029. uint_fast8_t size_words,
  2030. const uint32_t *aPtr,
  2031. const uint32_t *bPtr,
  2032. uint_fast8_t carry,
  2033. uint32_t *zPtr
  2034. );
  2035. #endif
  2036. #ifndef softfloat_addComplCarry96M
  2037. /*----------------------------------------------------------------------------
  2038. | This function or macro is the same as 'softfloat_addComplCarryM' with
  2039. | 'size_words' = 3 (N = 96).
  2040. *----------------------------------------------------------------------------*/
  2041. #define softfloat_addComplCarry96M( aPtr, bPtr, carry, zPtr ) softfloat_addComplCarryM( 3, aPtr, bPtr, carry, zPtr )
  2042. #endif
  2043. #ifndef softfloat_negXM
  2044. /*----------------------------------------------------------------------------
  2045. | Replaces the N-bit unsigned integer pointed to by 'zPtr' by the
  2046. | 2s-complement of itself, where N = 'size_words' * 32. Argument 'zPtr'
  2047. | points to a 'size_words'-long array of 32-bit elements that concatenate in
  2048. | the platform's normal endian order to form an N-bit integer.
  2049. *----------------------------------------------------------------------------*/
  2050. void softfloat_negXM( uint_fast8_t size_words, uint32_t *zPtr );
  2051. #endif
  2052. #ifndef softfloat_negX96M
  2053. /*----------------------------------------------------------------------------
  2054. | This function or macro is the same as 'softfloat_negXM' with 'size_words'
  2055. | = 3 (N = 96).
  2056. *----------------------------------------------------------------------------*/
  2057. #define softfloat_negX96M( zPtr ) softfloat_negXM( 3, zPtr )
  2058. #endif
  2059. #ifndef softfloat_negX128M
  2060. /*----------------------------------------------------------------------------
  2061. | This function or macro is the same as 'softfloat_negXM' with 'size_words'
  2062. | = 4 (N = 128).
  2063. *----------------------------------------------------------------------------*/
  2064. #define softfloat_negX128M( zPtr ) softfloat_negXM( 4, zPtr )
  2065. #endif
  2066. #ifndef softfloat_negX160M
  2067. /*----------------------------------------------------------------------------
  2068. | This function or macro is the same as 'softfloat_negXM' with 'size_words'
  2069. | = 5 (N = 160).
  2070. *----------------------------------------------------------------------------*/
  2071. #define softfloat_negX160M( zPtr ) softfloat_negXM( 5, zPtr )
  2072. #endif
  2073. #ifndef softfloat_negX256M
  2074. /*----------------------------------------------------------------------------
  2075. | This function or macro is the same as 'softfloat_negXM' with 'size_words'
  2076. | = 8 (N = 256).
  2077. *----------------------------------------------------------------------------*/
  2078. #define softfloat_negX256M( zPtr ) softfloat_negXM( 8, zPtr )
  2079. #endif
  2080. #ifndef softfloat_sub1XM
  2081. /*----------------------------------------------------------------------------
  2082. | Subtracts 1 from the N-bit integer pointed to by 'zPtr', where N =
  2083. | 'size_words' * 32. The subtraction is modulo 2^N, so any borrow out (carry
  2084. | out) is lost. Argument 'zPtr' points to a 'size_words'-long array of 32-bit
  2085. | elements that concatenate in the platform's normal endian order to form an
  2086. | N-bit integer.
  2087. *----------------------------------------------------------------------------*/
  2088. void softfloat_sub1XM( uint_fast8_t size_words, uint32_t *zPtr );
  2089. #endif
  2090. #ifndef softfloat_sub1X96M
  2091. /*----------------------------------------------------------------------------
  2092. | This function or macro is the same as 'softfloat_sub1XM' with 'size_words'
  2093. | = 3 (N = 96).
  2094. *----------------------------------------------------------------------------*/
  2095. #define softfloat_sub1X96M( zPtr ) softfloat_sub1XM( 3, zPtr )
  2096. #endif
  2097. #ifndef softfloat_sub1X160M
  2098. /*----------------------------------------------------------------------------
  2099. | This function or macro is the same as 'softfloat_sub1XM' with 'size_words'
  2100. | = 5 (N = 160).
  2101. *----------------------------------------------------------------------------*/
  2102. #define softfloat_sub1X160M( zPtr ) softfloat_sub1XM( 5, zPtr )
  2103. #endif
  2104. #ifndef softfloat_subM
  2105. /*----------------------------------------------------------------------------
  2106. | Subtracts the two N-bit integers pointed to by 'aPtr' and 'bPtr', where N =
  2107. | 'size_words' * 32. The subtraction is modulo 2^N, so any borrow out (carry
  2108. | out) is lost. The N-bit difference is stored at the location pointed to by
  2109. | 'zPtr'. Each of 'aPtr', 'bPtr', and 'zPtr' points to a 'size_words'-long
  2110. | array of 32-bit elements that concatenate in the platform's normal endian
  2111. | order to form an N-bit integer.
  2112. *----------------------------------------------------------------------------*/
  2113. void
  2114. softfloat_subM(
  2115. uint_fast8_t size_words,
  2116. const uint32_t *aPtr,
  2117. const uint32_t *bPtr,
  2118. uint32_t *zPtr
  2119. );
  2120. #endif
  2121. #ifndef softfloat_sub96M
  2122. /*----------------------------------------------------------------------------
  2123. | This function or macro is the same as 'softfloat_subM' with 'size_words'
  2124. | = 3 (N = 96).
  2125. *----------------------------------------------------------------------------*/
  2126. #define softfloat_sub96M( aPtr, bPtr, zPtr ) softfloat_subM( 3, aPtr, bPtr, zPtr )
  2127. #endif
  2128. #ifndef softfloat_sub128M
  2129. /*----------------------------------------------------------------------------
  2130. | This function or macro is the same as 'softfloat_subM' with 'size_words'
  2131. | = 4 (N = 128).
  2132. *----------------------------------------------------------------------------*/
  2133. #define softfloat_sub128M( aPtr, bPtr, zPtr ) softfloat_subM( 4, aPtr, bPtr, zPtr )
  2134. #endif
  2135. #ifndef softfloat_sub160M
  2136. /*----------------------------------------------------------------------------
  2137. | This function or macro is the same as 'softfloat_subM' with 'size_words'
  2138. | = 5 (N = 160).
  2139. *----------------------------------------------------------------------------*/
  2140. #define softfloat_sub160M( aPtr, bPtr, zPtr ) softfloat_subM( 5, aPtr, bPtr, zPtr )
  2141. #endif
  2142. #ifndef softfloat_mul64To128M
  2143. /*----------------------------------------------------------------------------
  2144. | Multiplies 'a' and 'b' and stores the 128-bit product at the location
  2145. | pointed to by 'zPtr'. Argument 'zPtr' points to an array of four 32-bit
  2146. | elements that concatenate in the platform's normal endian order to form a
  2147. | 128-bit integer.
  2148. *----------------------------------------------------------------------------*/
  2149. void softfloat_mul64To128M( uint64_t a, uint64_t b, uint32_t *zPtr );
  2150. #endif
  2151. #ifndef softfloat_mul128MTo256M
  2152. /*----------------------------------------------------------------------------
  2153. | Multiplies the two 128-bit unsigned integers pointed to by 'aPtr' and
  2154. | 'bPtr', and stores the 256-bit product at the location pointed to by 'zPtr'.
  2155. | Each of 'aPtr' and 'bPtr' points to an array of four 32-bit elements that
  2156. | concatenate in the platform's normal endian order to form a 128-bit integer.
  2157. | Argument 'zPtr' points to an array of eight 32-bit elements that concatenate
  2158. | to form a 256-bit integer.
  2159. *----------------------------------------------------------------------------*/
  2160. void
  2161. softfloat_mul128MTo256M(
  2162. const uint32_t *aPtr, const uint32_t *bPtr, uint32_t *zPtr );
  2163. #endif
  2164. #ifndef softfloat_remStepMBy32
  2165. /*----------------------------------------------------------------------------
  2166. | Performs a "remainder reduction step" as follows: Arguments 'remPtr' and
  2167. | 'bPtr' both point to N-bit unsigned integers, where N = 'size_words' * 32.
  2168. | Defining R and B as the values of those integers, the expression (R<<'dist')
  2169. | - B * q is computed modulo 2^N, and the N-bit result is stored at the
  2170. | location pointed to by 'zPtr'. Each of 'remPtr', 'bPtr', and 'zPtr' points
  2171. | to a 'size_words'-long array of 32-bit elements that concatenate in the
  2172. | platform's normal endian order to form an N-bit integer.
  2173. *----------------------------------------------------------------------------*/
  2174. void
  2175. softfloat_remStepMBy32(
  2176. uint_fast8_t size_words,
  2177. const uint32_t *remPtr,
  2178. uint_fast8_t dist,
  2179. const uint32_t *bPtr,
  2180. uint32_t q,
  2181. uint32_t *zPtr
  2182. );
  2183. #endif
  2184. #ifndef softfloat_remStep96MBy32
  2185. /*----------------------------------------------------------------------------
  2186. | This function or macro is the same as 'softfloat_remStepMBy32' with
  2187. | 'size_words' = 3 (N = 96).
  2188. *----------------------------------------------------------------------------*/
  2189. #define softfloat_remStep96MBy32( remPtr, dist, bPtr, q, zPtr ) softfloat_remStepMBy32( 3, remPtr, dist, bPtr, q, zPtr )
  2190. #endif
  2191. #ifndef softfloat_remStep128MBy32
  2192. /*----------------------------------------------------------------------------
  2193. | This function or macro is the same as 'softfloat_remStepMBy32' with
  2194. | 'size_words' = 4 (N = 128).
  2195. *----------------------------------------------------------------------------*/
  2196. #define softfloat_remStep128MBy32( remPtr, dist, bPtr, q, zPtr ) softfloat_remStepMBy32( 4, remPtr, dist, bPtr, q, zPtr )
  2197. #endif
  2198. #ifndef softfloat_remStep160MBy32
  2199. /*----------------------------------------------------------------------------
  2200. | This function or macro is the same as 'softfloat_remStepMBy32' with
  2201. | 'size_words' = 5 (N = 160).
  2202. *----------------------------------------------------------------------------*/
  2203. #define softfloat_remStep160MBy32( remPtr, dist, bPtr, q, zPtr ) softfloat_remStepMBy32( 5, remPtr, dist, bPtr, q, zPtr )
  2204. #endif
  2205. #endif
  2206. #endif
  2207. /**** ended inlining primitives.h ****/
  2208. /**** skipping file: softfloat_types.h ****/
  2209. union ui16_f16 { uint16_t ui; float16_t f; };
  2210. union ui32_f32 { uint32_t ui; float32_t f; };
  2211. union ui64_f64 { uint64_t ui; float64_t f; };
  2212. #ifdef SOFTFLOAT_FAST_INT64
  2213. union extF80M_extF80 { struct extFloat80M fM; extFloat80_t f; };
  2214. union ui128_f128 { struct uint128 ui; float128_t f; };
  2215. #endif
  2216. enum {
  2217. softfloat_mulAdd_subC = 1,
  2218. softfloat_mulAdd_subProd = 2
  2219. };
  2220. /*----------------------------------------------------------------------------
  2221. *----------------------------------------------------------------------------*/
  2222. uint_fast32_t softfloat_roundToUI32( bool, uint_fast64_t, uint_fast8_t, bool );
  2223. #ifdef SOFTFLOAT_FAST_INT64
  2224. uint_fast64_t
  2225. softfloat_roundToUI64(
  2226. bool, uint_fast64_t, uint_fast64_t, uint_fast8_t, bool );
  2227. #else
  2228. uint_fast64_t softfloat_roundMToUI64( bool, uint32_t *, uint_fast8_t, bool );
  2229. #endif
  2230. int_fast32_t softfloat_roundToI32( bool, uint_fast64_t, uint_fast8_t, bool );
  2231. #ifdef SOFTFLOAT_FAST_INT64
  2232. int_fast64_t
  2233. softfloat_roundToI64(
  2234. bool, uint_fast64_t, uint_fast64_t, uint_fast8_t, bool );
  2235. #else
  2236. int_fast64_t softfloat_roundMToI64( bool, uint32_t *, uint_fast8_t, bool );
  2237. #endif
  2238. /*----------------------------------------------------------------------------
  2239. *----------------------------------------------------------------------------*/
  2240. #define signF16UI( a ) ((bool) ((uint16_t) (a)>>15))
  2241. #define expF16UI( a ) ((int_fast8_t) ((a)>>10) & 0x1F)
  2242. #define fracF16UI( a ) ((a) & 0x03FF)
  2243. #define packToF16UI( sign, exp, sig ) (((uint16_t) (sign)<<15) + ((uint16_t) (exp)<<10) + (sig))
  2244. #define isNaNF16UI( a ) (((~(a) & 0x7C00) == 0) && ((a) & 0x03FF))
  2245. struct exp8_sig16 { int_fast8_t exp; uint_fast16_t sig; };
  2246. struct exp8_sig16 softfloat_normSubnormalF16Sig( uint_fast16_t );
  2247. float16_t softfloat_roundPackToF16( bool, int_fast16_t, uint_fast16_t );
  2248. float16_t softfloat_normRoundPackToF16( bool, int_fast16_t, uint_fast16_t );
  2249. float16_t softfloat_addMagsF16( uint_fast16_t, uint_fast16_t );
  2250. float16_t softfloat_subMagsF16( uint_fast16_t, uint_fast16_t );
  2251. float16_t
  2252. softfloat_mulAddF16(
  2253. uint_fast16_t, uint_fast16_t, uint_fast16_t, uint_fast8_t );
  2254. /*----------------------------------------------------------------------------
  2255. *----------------------------------------------------------------------------*/
  2256. #define signF32UI( a ) ((bool) ((uint32_t) (a)>>31))
  2257. #define expF32UI( a ) ((int_fast16_t) ((a)>>23) & 0xFF)
  2258. #define fracF32UI( a ) ((a) & 0x007FFFFF)
  2259. #define packToF32UI( sign, exp, sig ) (((uint32_t) (sign)<<31) + ((uint32_t) (exp)<<23) + (sig))
  2260. #define isNaNF32UI( a ) (((~(a) & 0x7F800000) == 0) && ((a) & 0x007FFFFF))
  2261. struct exp16_sig32 { int_fast16_t exp; uint_fast32_t sig; };
  2262. struct exp16_sig32 softfloat_normSubnormalF32Sig( uint_fast32_t );
  2263. float32_t softfloat_roundPackToF32( bool, int_fast16_t, uint_fast32_t );
  2264. float32_t softfloat_normRoundPackToF32( bool, int_fast16_t, uint_fast32_t );
  2265. float32_t softfloat_addMagsF32( uint_fast32_t, uint_fast32_t );
  2266. float32_t softfloat_subMagsF32( uint_fast32_t, uint_fast32_t );
  2267. float32_t
  2268. softfloat_mulAddF32(
  2269. uint_fast32_t, uint_fast32_t, uint_fast32_t, uint_fast8_t );
  2270. /*----------------------------------------------------------------------------
  2271. *----------------------------------------------------------------------------*/
  2272. #define signF64UI( a ) ((bool) ((uint64_t) (a)>>63))
  2273. #define expF64UI( a ) ((int_fast16_t) ((a)>>52) & 0x7FF)
  2274. #define fracF64UI( a ) ((a) & UINT64_C( 0x000FFFFFFFFFFFFF ))
  2275. #define packToF64UI( sign, exp, sig ) ((uint64_t) (((uint_fast64_t) (sign)<<63) + ((uint_fast64_t) (exp)<<52) + (sig)))
  2276. #define isNaNF64UI( a ) (((~(a) & UINT64_C( 0x7FF0000000000000 )) == 0) && ((a) & UINT64_C( 0x000FFFFFFFFFFFFF )))
  2277. struct exp16_sig64 { int_fast16_t exp; uint_fast64_t sig; };
  2278. struct exp16_sig64 softfloat_normSubnormalF64Sig( uint_fast64_t );
  2279. float64_t softfloat_roundPackToF64( bool, int_fast16_t, uint_fast64_t );
  2280. float64_t softfloat_normRoundPackToF64( bool, int_fast16_t, uint_fast64_t );
  2281. float64_t softfloat_addMagsF64( uint_fast64_t, uint_fast64_t, bool );
  2282. float64_t softfloat_subMagsF64( uint_fast64_t, uint_fast64_t, bool );
  2283. float64_t
  2284. softfloat_mulAddF64(
  2285. uint_fast64_t, uint_fast64_t, uint_fast64_t, uint_fast8_t );
  2286. /*----------------------------------------------------------------------------
  2287. *----------------------------------------------------------------------------*/
  2288. #define signExtF80UI64( a64 ) ((bool) ((uint16_t) (a64)>>15))
  2289. #define expExtF80UI64( a64 ) ((a64) & 0x7FFF)
  2290. #define packToExtF80UI64( sign, exp ) ((uint_fast16_t) (sign)<<15 | (exp))
  2291. #define isNaNExtF80UI( a64, a0 ) ((((a64) & 0x7FFF) == 0x7FFF) && ((a0) & UINT64_C( 0x7FFFFFFFFFFFFFFF )))
  2292. #ifdef SOFTFLOAT_FAST_INT64
  2293. /*----------------------------------------------------------------------------
  2294. *----------------------------------------------------------------------------*/
  2295. struct exp32_sig64 { int_fast32_t exp; uint64_t sig; };
  2296. struct exp32_sig64 softfloat_normSubnormalExtF80Sig( uint_fast64_t );
  2297. extFloat80_t
  2298. softfloat_roundPackToExtF80(
  2299. bool, int_fast32_t, uint_fast64_t, uint_fast64_t, uint_fast8_t );
  2300. extFloat80_t
  2301. softfloat_normRoundPackToExtF80(
  2302. bool, int_fast32_t, uint_fast64_t, uint_fast64_t, uint_fast8_t );
  2303. extFloat80_t
  2304. softfloat_addMagsExtF80(
  2305. uint_fast16_t, uint_fast64_t, uint_fast16_t, uint_fast64_t, bool );
  2306. extFloat80_t
  2307. softfloat_subMagsExtF80(
  2308. uint_fast16_t, uint_fast64_t, uint_fast16_t, uint_fast64_t, bool );
  2309. /*----------------------------------------------------------------------------
  2310. *----------------------------------------------------------------------------*/
  2311. #define signF128UI64( a64 ) ((bool) ((uint64_t) (a64)>>63))
  2312. #define expF128UI64( a64 ) ((int_fast32_t) ((a64)>>48) & 0x7FFF)
  2313. #define fracF128UI64( a64 ) ((a64) & UINT64_C( 0x0000FFFFFFFFFFFF ))
  2314. #define packToF128UI64( sign, exp, sig64 ) (((uint_fast64_t) (sign)<<63) + ((uint_fast64_t) (exp)<<48) + (sig64))
  2315. #define isNaNF128UI( a64, a0 ) (((~(a64) & UINT64_C( 0x7FFF000000000000 )) == 0) && (a0 || ((a64) & UINT64_C( 0x0000FFFFFFFFFFFF ))))
  2316. struct exp32_sig128 { int_fast32_t exp; struct uint128 sig; };
  2317. struct exp32_sig128
  2318. softfloat_normSubnormalF128Sig( uint_fast64_t, uint_fast64_t );
  2319. float128_t
  2320. softfloat_roundPackToF128(
  2321. bool, int_fast32_t, uint_fast64_t, uint_fast64_t, uint_fast64_t );
  2322. float128_t
  2323. softfloat_normRoundPackToF128(
  2324. bool, int_fast32_t, uint_fast64_t, uint_fast64_t );
  2325. float128_t
  2326. softfloat_addMagsF128(
  2327. uint_fast64_t, uint_fast64_t, uint_fast64_t, uint_fast64_t, bool );
  2328. float128_t
  2329. softfloat_subMagsF128(
  2330. uint_fast64_t, uint_fast64_t, uint_fast64_t, uint_fast64_t, bool );
  2331. float128_t
  2332. softfloat_mulAddF128(
  2333. uint_fast64_t,
  2334. uint_fast64_t,
  2335. uint_fast64_t,
  2336. uint_fast64_t,
  2337. uint_fast64_t,
  2338. uint_fast64_t,
  2339. uint_fast8_t
  2340. );
  2341. #else
  2342. /*----------------------------------------------------------------------------
  2343. *----------------------------------------------------------------------------*/
  2344. bool
  2345. softfloat_tryPropagateNaNExtF80M(
  2346. const struct extFloat80M *,
  2347. const struct extFloat80M *,
  2348. struct extFloat80M *
  2349. );
  2350. void softfloat_invalidExtF80M( struct extFloat80M * );
  2351. int softfloat_normExtF80SigM( uint64_t * );
  2352. void
  2353. softfloat_roundPackMToExtF80M(
  2354. bool, int32_t, uint32_t *, uint_fast8_t, struct extFloat80M * );
  2355. void
  2356. softfloat_normRoundPackMToExtF80M(
  2357. bool, int32_t, uint32_t *, uint_fast8_t, struct extFloat80M * );
  2358. void
  2359. softfloat_addExtF80M(
  2360. const struct extFloat80M *,
  2361. const struct extFloat80M *,
  2362. struct extFloat80M *,
  2363. bool
  2364. );
  2365. int
  2366. softfloat_compareNonnormExtF80M(
  2367. const struct extFloat80M *, const struct extFloat80M * );
  2368. /*----------------------------------------------------------------------------
  2369. *----------------------------------------------------------------------------*/
  2370. #define signF128UI96( a96 ) ((bool) ((uint32_t) (a96)>>31))
  2371. #define expF128UI96( a96 ) ((int32_t) ((a96)>>16) & 0x7FFF)
  2372. #define fracF128UI96( a96 ) ((a96) & 0x0000FFFF)
  2373. #define packToF128UI96( sign, exp, sig96 ) (((uint32_t) (sign)<<31) + ((uint32_t) (exp)<<16) + (sig96))
  2374. bool softfloat_isNaNF128M( const uint32_t * );
  2375. bool
  2376. softfloat_tryPropagateNaNF128M(
  2377. const uint32_t *, const uint32_t *, uint32_t * );
  2378. void softfloat_invalidF128M( uint32_t * );
  2379. int softfloat_shiftNormSigF128M( const uint32_t *, uint_fast8_t, uint32_t * );
  2380. void softfloat_roundPackMToF128M( bool, int32_t, uint32_t *, uint32_t * );
  2381. void softfloat_normRoundPackMToF128M( bool, int32_t, uint32_t *, uint32_t * );
  2382. void
  2383. softfloat_addF128M( const uint32_t *, const uint32_t *, uint32_t *, bool );
  2384. void
  2385. softfloat_mulAddF128M(
  2386. const uint32_t *,
  2387. const uint32_t *,
  2388. const uint32_t *,
  2389. uint32_t *,
  2390. uint_fast8_t
  2391. );
  2392. #endif
  2393. #endif
  2394. /**** ended inlining internals.h ****/
  2395. /**** skipping file: specialize.h ****/
  2396. /**** skipping file: softfloat.h ****/
  2397. /*----------------------------------------------------------------------------
  2398. | Interpreting `uiA' and `uiB' as the bit patterns of two 16-bit floating-
  2399. | point values, at least one of which is a NaN, returns the bit pattern of
  2400. | the combined NaN result. If either `uiA' or `uiB' has the pattern of a
  2401. | signaling NaN, the invalid exception is raised.
  2402. *----------------------------------------------------------------------------*/
  2403. uint_fast16_t
  2404. softfloat_propagateNaNF16UI( uint_fast16_t uiA, uint_fast16_t uiB )
  2405. {
  2406. bool isSigNaNA;
  2407. isSigNaNA = softfloat_isSigNaNF16UI( uiA );
  2408. if ( isSigNaNA || softfloat_isSigNaNF16UI( uiB ) ) {
  2409. softfloat_raiseFlags( softfloat_flag_invalid );
  2410. if ( isSigNaNA ) return uiA | 0x0200;
  2411. }
  2412. return (isNaNF16UI( uiA ) ? uiA : uiB) | 0x0200;
  2413. }
  2414. /**** ended inlining ../../source/8086-SSE/s_propagateNaNF16UI.c ****/
  2415. /**** start inlining ../../source/8086-SSE/s_f32UIToCommonNaN.c ****/
  2416. /*============================================================================
  2417. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  2418. Package, Release 3e, by John R. Hauser.
  2419. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  2420. All rights reserved.
  2421. Redistribution and use in source and binary forms, with or without
  2422. modification, are permitted provided that the following conditions are met:
  2423. 1. Redistributions of source code must retain the above copyright notice,
  2424. this list of conditions, and the following disclaimer.
  2425. 2. Redistributions in binary form must reproduce the above copyright notice,
  2426. this list of conditions, and the following disclaimer in the documentation
  2427. and/or other materials provided with the distribution.
  2428. 3. Neither the name of the University nor the names of its contributors may
  2429. be used to endorse or promote products derived from this software without
  2430. specific prior written permission.
  2431. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  2432. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  2433. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  2434. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  2435. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  2436. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  2437. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  2438. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  2439. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  2440. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  2441. =============================================================================*/
  2442. #include <stdint.h>
  2443. /**** skipping file: platform.h ****/
  2444. /**** skipping file: specialize.h ****/
  2445. /**** skipping file: softfloat.h ****/
  2446. /*----------------------------------------------------------------------------
  2447. | Assuming `uiA' has the bit pattern of a 32-bit floating-point NaN, converts
  2448. | this NaN to the common NaN form, and stores the resulting common NaN at the
  2449. | location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
  2450. | exception is raised.
  2451. *----------------------------------------------------------------------------*/
  2452. void softfloat_f32UIToCommonNaN( uint_fast32_t uiA, struct commonNaN *zPtr )
  2453. {
  2454. if ( softfloat_isSigNaNF32UI( uiA ) ) {
  2455. softfloat_raiseFlags( softfloat_flag_invalid );
  2456. }
  2457. zPtr->sign = uiA>>31;
  2458. zPtr->v64 = (uint_fast64_t) uiA<<41;
  2459. zPtr->v0 = 0;
  2460. }
  2461. /**** ended inlining ../../source/8086-SSE/s_f32UIToCommonNaN.c ****/
  2462. /**** start inlining ../../source/8086-SSE/s_commonNaNToF32UI.c ****/
  2463. /*============================================================================
  2464. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  2465. Package, Release 3e, by John R. Hauser.
  2466. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  2467. All rights reserved.
  2468. Redistribution and use in source and binary forms, with or without
  2469. modification, are permitted provided that the following conditions are met:
  2470. 1. Redistributions of source code must retain the above copyright notice,
  2471. this list of conditions, and the following disclaimer.
  2472. 2. Redistributions in binary form must reproduce the above copyright notice,
  2473. this list of conditions, and the following disclaimer in the documentation
  2474. and/or other materials provided with the distribution.
  2475. 3. Neither the name of the University nor the names of its contributors may
  2476. be used to endorse or promote products derived from this software without
  2477. specific prior written permission.
  2478. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  2479. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  2480. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  2481. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  2482. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  2483. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  2484. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  2485. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  2486. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  2487. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  2488. =============================================================================*/
  2489. #include <stdint.h>
  2490. /**** skipping file: platform.h ****/
  2491. /**** skipping file: specialize.h ****/
  2492. /*----------------------------------------------------------------------------
  2493. | Converts the common NaN pointed to by `aPtr' into a 32-bit floating-point
  2494. | NaN, and returns the bit pattern of this value as an unsigned integer.
  2495. *----------------------------------------------------------------------------*/
  2496. uint_fast32_t softfloat_commonNaNToF32UI( const struct commonNaN *aPtr )
  2497. {
  2498. return (uint_fast32_t) aPtr->sign<<31 | 0x7FC00000 | aPtr->v64>>41;
  2499. }
  2500. /**** ended inlining ../../source/8086-SSE/s_commonNaNToF32UI.c ****/
  2501. /**** start inlining ../../source/8086-SSE/s_propagateNaNF32UI.c ****/
  2502. /*============================================================================
  2503. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  2504. Package, Release 3e, by John R. Hauser.
  2505. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  2506. All rights reserved.
  2507. Redistribution and use in source and binary forms, with or without
  2508. modification, are permitted provided that the following conditions are met:
  2509. 1. Redistributions of source code must retain the above copyright notice,
  2510. this list of conditions, and the following disclaimer.
  2511. 2. Redistributions in binary form must reproduce the above copyright notice,
  2512. this list of conditions, and the following disclaimer in the documentation
  2513. and/or other materials provided with the distribution.
  2514. 3. Neither the name of the University nor the names of its contributors may
  2515. be used to endorse or promote products derived from this software without
  2516. specific prior written permission.
  2517. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  2518. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  2519. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  2520. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  2521. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  2522. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  2523. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  2524. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  2525. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  2526. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  2527. =============================================================================*/
  2528. #include <stdbool.h>
  2529. #include <stdint.h>
  2530. /**** skipping file: platform.h ****/
  2531. /**** skipping file: internals.h ****/
  2532. /**** skipping file: specialize.h ****/
  2533. /**** skipping file: softfloat.h ****/
  2534. /*----------------------------------------------------------------------------
  2535. | Interpreting `uiA' and `uiB' as the bit patterns of two 32-bit floating-
  2536. | point values, at least one of which is a NaN, returns the bit pattern of
  2537. | the combined NaN result. If either `uiA' or `uiB' has the pattern of a
  2538. | signaling NaN, the invalid exception is raised.
  2539. *----------------------------------------------------------------------------*/
  2540. uint_fast32_t
  2541. softfloat_propagateNaNF32UI( uint_fast32_t uiA, uint_fast32_t uiB )
  2542. {
  2543. bool isSigNaNA;
  2544. isSigNaNA = softfloat_isSigNaNF32UI( uiA );
  2545. if ( isSigNaNA || softfloat_isSigNaNF32UI( uiB ) ) {
  2546. softfloat_raiseFlags( softfloat_flag_invalid );
  2547. if ( isSigNaNA ) return uiA | 0x00400000;
  2548. }
  2549. return (isNaNF32UI( uiA ) ? uiA : uiB) | 0x00400000;
  2550. }
  2551. /**** ended inlining ../../source/8086-SSE/s_propagateNaNF32UI.c ****/
  2552. /**** start inlining ../../source/8086-SSE/s_f64UIToCommonNaN.c ****/
  2553. /*============================================================================
  2554. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  2555. Package, Release 3e, by John R. Hauser.
  2556. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  2557. All rights reserved.
  2558. Redistribution and use in source and binary forms, with or without
  2559. modification, are permitted provided that the following conditions are met:
  2560. 1. Redistributions of source code must retain the above copyright notice,
  2561. this list of conditions, and the following disclaimer.
  2562. 2. Redistributions in binary form must reproduce the above copyright notice,
  2563. this list of conditions, and the following disclaimer in the documentation
  2564. and/or other materials provided with the distribution.
  2565. 3. Neither the name of the University nor the names of its contributors may
  2566. be used to endorse or promote products derived from this software without
  2567. specific prior written permission.
  2568. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  2569. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  2570. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  2571. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  2572. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  2573. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  2574. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  2575. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  2576. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  2577. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  2578. =============================================================================*/
  2579. #include <stdint.h>
  2580. /**** skipping file: platform.h ****/
  2581. /**** skipping file: specialize.h ****/
  2582. /**** skipping file: softfloat.h ****/
  2583. /*----------------------------------------------------------------------------
  2584. | Assuming `uiA' has the bit pattern of a 64-bit floating-point NaN, converts
  2585. | this NaN to the common NaN form, and stores the resulting common NaN at the
  2586. | location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
  2587. | exception is raised.
  2588. *----------------------------------------------------------------------------*/
  2589. void softfloat_f64UIToCommonNaN( uint_fast64_t uiA, struct commonNaN *zPtr )
  2590. {
  2591. if ( softfloat_isSigNaNF64UI( uiA ) ) {
  2592. softfloat_raiseFlags( softfloat_flag_invalid );
  2593. }
  2594. zPtr->sign = uiA>>63;
  2595. zPtr->v64 = uiA<<12;
  2596. zPtr->v0 = 0;
  2597. }
  2598. /**** ended inlining ../../source/8086-SSE/s_f64UIToCommonNaN.c ****/
  2599. /**** start inlining ../../source/8086-SSE/s_commonNaNToF64UI.c ****/
  2600. /*============================================================================
  2601. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  2602. Package, Release 3e, by John R. Hauser.
  2603. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  2604. All rights reserved.
  2605. Redistribution and use in source and binary forms, with or without
  2606. modification, are permitted provided that the following conditions are met:
  2607. 1. Redistributions of source code must retain the above copyright notice,
  2608. this list of conditions, and the following disclaimer.
  2609. 2. Redistributions in binary form must reproduce the above copyright notice,
  2610. this list of conditions, and the following disclaimer in the documentation
  2611. and/or other materials provided with the distribution.
  2612. 3. Neither the name of the University nor the names of its contributors may
  2613. be used to endorse or promote products derived from this software without
  2614. specific prior written permission.
  2615. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  2616. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  2617. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  2618. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  2619. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  2620. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  2621. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  2622. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  2623. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  2624. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  2625. =============================================================================*/
  2626. #include <stdint.h>
  2627. /**** skipping file: platform.h ****/
  2628. /**** skipping file: specialize.h ****/
  2629. /*----------------------------------------------------------------------------
  2630. | Converts the common NaN pointed to by `aPtr' into a 64-bit floating-point
  2631. | NaN, and returns the bit pattern of this value as an unsigned integer.
  2632. *----------------------------------------------------------------------------*/
  2633. uint_fast64_t softfloat_commonNaNToF64UI( const struct commonNaN *aPtr )
  2634. {
  2635. return
  2636. (uint_fast64_t) aPtr->sign<<63 | UINT64_C( 0x7FF8000000000000 )
  2637. | aPtr->v64>>12;
  2638. }
  2639. /**** ended inlining ../../source/8086-SSE/s_commonNaNToF64UI.c ****/
  2640. /**** start inlining ../../source/8086-SSE/s_propagateNaNF64UI.c ****/
  2641. /*============================================================================
  2642. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  2643. Package, Release 3e, by John R. Hauser.
  2644. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  2645. All rights reserved.
  2646. Redistribution and use in source and binary forms, with or without
  2647. modification, are permitted provided that the following conditions are met:
  2648. 1. Redistributions of source code must retain the above copyright notice,
  2649. this list of conditions, and the following disclaimer.
  2650. 2. Redistributions in binary form must reproduce the above copyright notice,
  2651. this list of conditions, and the following disclaimer in the documentation
  2652. and/or other materials provided with the distribution.
  2653. 3. Neither the name of the University nor the names of its contributors may
  2654. be used to endorse or promote products derived from this software without
  2655. specific prior written permission.
  2656. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  2657. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  2658. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  2659. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  2660. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  2661. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  2662. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  2663. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  2664. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  2665. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  2666. =============================================================================*/
  2667. #include <stdbool.h>
  2668. #include <stdint.h>
  2669. /**** skipping file: platform.h ****/
  2670. /**** skipping file: internals.h ****/
  2671. /**** skipping file: specialize.h ****/
  2672. /**** skipping file: softfloat.h ****/
  2673. /*----------------------------------------------------------------------------
  2674. | Interpreting `uiA' and `uiB' as the bit patterns of two 64-bit floating-
  2675. | point values, at least one of which is a NaN, returns the bit pattern of
  2676. | the combined NaN result. If either `uiA' or `uiB' has the pattern of a
  2677. | signaling NaN, the invalid exception is raised.
  2678. *----------------------------------------------------------------------------*/
  2679. uint_fast64_t
  2680. softfloat_propagateNaNF64UI( uint_fast64_t uiA, uint_fast64_t uiB )
  2681. {
  2682. bool isSigNaNA;
  2683. isSigNaNA = softfloat_isSigNaNF64UI( uiA );
  2684. if ( isSigNaNA || softfloat_isSigNaNF64UI( uiB ) ) {
  2685. softfloat_raiseFlags( softfloat_flag_invalid );
  2686. if ( isSigNaNA ) return uiA | UINT64_C( 0x0008000000000000 );
  2687. }
  2688. return (isNaNF64UI( uiA ) ? uiA : uiB) | UINT64_C( 0x0008000000000000 );
  2689. }
  2690. /**** ended inlining ../../source/8086-SSE/s_propagateNaNF64UI.c ****/
  2691. /**** start inlining ../../source/8086-SSE/extF80M_isSignalingNaN.c ****/
  2692. /*============================================================================
  2693. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  2694. Package, Release 3e, by John R. Hauser.
  2695. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  2696. All rights reserved.
  2697. Redistribution and use in source and binary forms, with or without
  2698. modification, are permitted provided that the following conditions are met:
  2699. 1. Redistributions of source code must retain the above copyright notice,
  2700. this list of conditions, and the following disclaimer.
  2701. 2. Redistributions in binary form must reproduce the above copyright notice,
  2702. this list of conditions, and the following disclaimer in the documentation
  2703. and/or other materials provided with the distribution.
  2704. 3. Neither the name of the University nor the names of its contributors may
  2705. be used to endorse or promote products derived from this software without
  2706. specific prior written permission.
  2707. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  2708. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  2709. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  2710. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  2711. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  2712. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  2713. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  2714. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  2715. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  2716. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  2717. =============================================================================*/
  2718. #include <stdbool.h>
  2719. #include <stdint.h>
  2720. /**** skipping file: platform.h ****/
  2721. /**** skipping file: softfloat.h ****/
  2722. /*----------------------------------------------------------------------------
  2723. *----------------------------------------------------------------------------*/
  2724. bool extF80M_isSignalingNaN( const extFloat80_t *aPtr )
  2725. {
  2726. const struct extFloat80M *aSPtr;
  2727. uint64_t uiA0;
  2728. aSPtr = (const struct extFloat80M *) aPtr;
  2729. if ( (aSPtr->signExp & 0x7FFF) != 0x7FFF ) return false;
  2730. uiA0 = aSPtr->signif;
  2731. return
  2732. ! (uiA0 & UINT64_C( 0x4000000000000000 ))
  2733. && (uiA0 & UINT64_C( 0x3FFFFFFFFFFFFFFF));
  2734. }
  2735. /**** ended inlining ../../source/8086-SSE/extF80M_isSignalingNaN.c ****/
  2736. /**** start inlining ../../source/8086-SSE/s_extF80UIToCommonNaN.c ****/
  2737. /*============================================================================
  2738. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  2739. Package, Release 3e, by John R. Hauser.
  2740. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  2741. All rights reserved.
  2742. Redistribution and use in source and binary forms, with or without
  2743. modification, are permitted provided that the following conditions are met:
  2744. 1. Redistributions of source code must retain the above copyright notice,
  2745. this list of conditions, and the following disclaimer.
  2746. 2. Redistributions in binary form must reproduce the above copyright notice,
  2747. this list of conditions, and the following disclaimer in the documentation
  2748. and/or other materials provided with the distribution.
  2749. 3. Neither the name of the University nor the names of its contributors may
  2750. be used to endorse or promote products derived from this software without
  2751. specific prior written permission.
  2752. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  2753. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  2754. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  2755. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  2756. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  2757. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  2758. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  2759. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  2760. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  2761. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  2762. =============================================================================*/
  2763. #include <stdint.h>
  2764. /**** skipping file: platform.h ****/
  2765. /**** skipping file: specialize.h ****/
  2766. /**** skipping file: softfloat.h ****/
  2767. /*----------------------------------------------------------------------------
  2768. | Assuming the unsigned integer formed from concatenating `uiA64' and `uiA0'
  2769. | has the bit pattern of an 80-bit extended floating-point NaN, converts
  2770. | this NaN to the common NaN form, and stores the resulting common NaN at the
  2771. | location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
  2772. | exception is raised.
  2773. *----------------------------------------------------------------------------*/
  2774. void
  2775. softfloat_extF80UIToCommonNaN(
  2776. uint_fast16_t uiA64, uint_fast64_t uiA0, struct commonNaN *zPtr )
  2777. {
  2778. if ( softfloat_isSigNaNExtF80UI( uiA64, uiA0 ) ) {
  2779. softfloat_raiseFlags( softfloat_flag_invalid );
  2780. }
  2781. zPtr->sign = uiA64>>15;
  2782. zPtr->v64 = uiA0<<1;
  2783. zPtr->v0 = 0;
  2784. }
  2785. /**** ended inlining ../../source/8086-SSE/s_extF80UIToCommonNaN.c ****/
  2786. /**** start inlining ../../source/8086-SSE/s_commonNaNToExtF80UI.c ****/
  2787. /*============================================================================
  2788. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  2789. Package, Release 3e, by John R. Hauser.
  2790. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  2791. All rights reserved.
  2792. Redistribution and use in source and binary forms, with or without
  2793. modification, are permitted provided that the following conditions are met:
  2794. 1. Redistributions of source code must retain the above copyright notice,
  2795. this list of conditions, and the following disclaimer.
  2796. 2. Redistributions in binary form must reproduce the above copyright notice,
  2797. this list of conditions, and the following disclaimer in the documentation
  2798. and/or other materials provided with the distribution.
  2799. 3. Neither the name of the University nor the names of its contributors may
  2800. be used to endorse or promote products derived from this software without
  2801. specific prior written permission.
  2802. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  2803. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  2804. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  2805. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  2806. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  2807. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  2808. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  2809. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  2810. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  2811. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  2812. =============================================================================*/
  2813. #include <stdint.h>
  2814. /**** skipping file: platform.h ****/
  2815. /**** skipping file: primitives.h ****/
  2816. /**** skipping file: specialize.h ****/
  2817. /*----------------------------------------------------------------------------
  2818. | Converts the common NaN pointed to by `aPtr' into an 80-bit extended
  2819. | floating-point NaN, and returns the bit pattern of this value as an unsigned
  2820. | integer.
  2821. *----------------------------------------------------------------------------*/
  2822. struct uint128 softfloat_commonNaNToExtF80UI( const struct commonNaN *aPtr )
  2823. {
  2824. struct uint128 uiZ;
  2825. uiZ.v64 = (uint_fast16_t) aPtr->sign<<15 | 0x7FFF;
  2826. uiZ.v0 = UINT64_C( 0xC000000000000000 ) | aPtr->v64>>1;
  2827. return uiZ;
  2828. }
  2829. /**** ended inlining ../../source/8086-SSE/s_commonNaNToExtF80UI.c ****/
  2830. /**** start inlining ../../source/8086-SSE/s_propagateNaNExtF80UI.c ****/
  2831. /*============================================================================
  2832. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  2833. Package, Release 3e, by John R. Hauser.
  2834. Copyright 2011, 2012, 2013, 2014, 2018 The Regents of the University of
  2835. California. All rights reserved.
  2836. Redistribution and use in source and binary forms, with or without
  2837. modification, are permitted provided that the following conditions are met:
  2838. 1. Redistributions of source code must retain the above copyright notice,
  2839. this list of conditions, and the following disclaimer.
  2840. 2. Redistributions in binary form must reproduce the above copyright notice,
  2841. this list of conditions, and the following disclaimer in the documentation
  2842. and/or other materials provided with the distribution.
  2843. 3. Neither the name of the University nor the names of its contributors may
  2844. be used to endorse or promote products derived from this software without
  2845. specific prior written permission.
  2846. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  2847. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  2848. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  2849. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  2850. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  2851. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  2852. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  2853. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  2854. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  2855. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  2856. =============================================================================*/
  2857. #include <stdbool.h>
  2858. #include <stdint.h>
  2859. /**** skipping file: platform.h ****/
  2860. /**** skipping file: internals.h ****/
  2861. /**** skipping file: specialize.h ****/
  2862. /**** skipping file: softfloat.h ****/
  2863. /*----------------------------------------------------------------------------
  2864. | Interpreting the unsigned integer formed from concatenating 'uiA64' and
  2865. | 'uiA0' as an 80-bit extended floating-point value, and likewise interpreting
  2866. | the unsigned integer formed from concatenating 'uiB64' and 'uiB0' as another
  2867. | 80-bit extended floating-point value, and assuming at least on of these
  2868. | floating-point values is a NaN, returns the bit pattern of the combined NaN
  2869. | result. If either original floating-point value is a signaling NaN, the
  2870. | invalid exception is raised.
  2871. *----------------------------------------------------------------------------*/
  2872. struct uint128
  2873. softfloat_propagateNaNExtF80UI(
  2874. uint_fast16_t uiA64,
  2875. uint_fast64_t uiA0,
  2876. uint_fast16_t uiB64,
  2877. uint_fast64_t uiB0
  2878. )
  2879. {
  2880. bool isSigNaNA, isSigNaNB;
  2881. uint_fast64_t uiNonsigA0, uiNonsigB0;
  2882. uint_fast16_t uiMagA64, uiMagB64;
  2883. struct uint128 uiZ;
  2884. /*------------------------------------------------------------------------
  2885. *------------------------------------------------------------------------*/
  2886. isSigNaNA = softfloat_isSigNaNExtF80UI( uiA64, uiA0 );
  2887. isSigNaNB = softfloat_isSigNaNExtF80UI( uiB64, uiB0 );
  2888. /*------------------------------------------------------------------------
  2889. | Make NaNs non-signaling.
  2890. *------------------------------------------------------------------------*/
  2891. uiNonsigA0 = uiA0 | UINT64_C( 0xC000000000000000 );
  2892. uiNonsigB0 = uiB0 | UINT64_C( 0xC000000000000000 );
  2893. /*------------------------------------------------------------------------
  2894. *------------------------------------------------------------------------*/
  2895. if ( isSigNaNA | isSigNaNB ) {
  2896. softfloat_raiseFlags( softfloat_flag_invalid );
  2897. if ( isSigNaNA ) {
  2898. if ( isSigNaNB ) goto returnLargerMag;
  2899. if ( isNaNExtF80UI( uiB64, uiB0 ) ) goto returnB;
  2900. goto returnA;
  2901. } else {
  2902. if ( isNaNExtF80UI( uiA64, uiA0 ) ) goto returnA;
  2903. goto returnB;
  2904. }
  2905. }
  2906. returnLargerMag:
  2907. uiMagA64 = uiA64 & 0x7FFF;
  2908. uiMagB64 = uiB64 & 0x7FFF;
  2909. if ( uiMagA64 < uiMagB64 ) goto returnB;
  2910. if ( uiMagB64 < uiMagA64 ) goto returnA;
  2911. if ( uiA0 < uiB0 ) goto returnB;
  2912. if ( uiB0 < uiA0 ) goto returnA;
  2913. if ( uiA64 < uiB64 ) goto returnA;
  2914. returnB:
  2915. uiZ.v64 = uiB64;
  2916. uiZ.v0 = uiNonsigB0;
  2917. return uiZ;
  2918. returnA:
  2919. uiZ.v64 = uiA64;
  2920. uiZ.v0 = uiNonsigA0;
  2921. return uiZ;
  2922. }
  2923. /**** ended inlining ../../source/8086-SSE/s_propagateNaNExtF80UI.c ****/
  2924. /**** start inlining ../../source/8086-SSE/f128M_isSignalingNaN.c ****/
  2925. /*============================================================================
  2926. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  2927. Package, Release 3e, by John R. Hauser.
  2928. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  2929. All rights reserved.
  2930. Redistribution and use in source and binary forms, with or without
  2931. modification, are permitted provided that the following conditions are met:
  2932. 1. Redistributions of source code must retain the above copyright notice,
  2933. this list of conditions, and the following disclaimer.
  2934. 2. Redistributions in binary form must reproduce the above copyright notice,
  2935. this list of conditions, and the following disclaimer in the documentation
  2936. and/or other materials provided with the distribution.
  2937. 3. Neither the name of the University nor the names of its contributors may
  2938. be used to endorse or promote products derived from this software without
  2939. specific prior written permission.
  2940. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  2941. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  2942. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  2943. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  2944. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  2945. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  2946. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  2947. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  2948. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  2949. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  2950. =============================================================================*/
  2951. #include <stdbool.h>
  2952. #include <stdint.h>
  2953. /**** skipping file: platform.h ****/
  2954. /**** skipping file: primitives.h ****/
  2955. /**** skipping file: softfloat.h ****/
  2956. /*----------------------------------------------------------------------------
  2957. *----------------------------------------------------------------------------*/
  2958. bool f128M_isSignalingNaN( const float128_t *aPtr )
  2959. {
  2960. const uint32_t *aWPtr;
  2961. uint32_t uiA96;
  2962. aWPtr = (const uint32_t *) aPtr;
  2963. uiA96 = aWPtr[indexWordHi( 4 )];
  2964. if ( (uiA96 & 0x7FFF8000) != 0x7FFF0000 ) return false;
  2965. return
  2966. ((uiA96 & 0x00007FFF) != 0)
  2967. || ((aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
  2968. | aWPtr[indexWord( 4, 0 )])
  2969. != 0);
  2970. }
  2971. /**** ended inlining ../../source/8086-SSE/f128M_isSignalingNaN.c ****/
  2972. /**** start inlining ../../source/8086-SSE/s_f128UIToCommonNaN.c ****/
  2973. /*============================================================================
  2974. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  2975. Package, Release 3e, by John R. Hauser.
  2976. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  2977. All rights reserved.
  2978. Redistribution and use in source and binary forms, with or without
  2979. modification, are permitted provided that the following conditions are met:
  2980. 1. Redistributions of source code must retain the above copyright notice,
  2981. this list of conditions, and the following disclaimer.
  2982. 2. Redistributions in binary form must reproduce the above copyright notice,
  2983. this list of conditions, and the following disclaimer in the documentation
  2984. and/or other materials provided with the distribution.
  2985. 3. Neither the name of the University nor the names of its contributors may
  2986. be used to endorse or promote products derived from this software without
  2987. specific prior written permission.
  2988. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  2989. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  2990. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  2991. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  2992. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  2993. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  2994. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  2995. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  2996. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  2997. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  2998. =============================================================================*/
  2999. #include <stdint.h>
  3000. /**** skipping file: platform.h ****/
  3001. /**** skipping file: primitives.h ****/
  3002. /**** skipping file: specialize.h ****/
  3003. /**** skipping file: softfloat.h ****/
  3004. /*----------------------------------------------------------------------------
  3005. | Assuming the unsigned integer formed from concatenating `uiA64' and `uiA0'
  3006. | has the bit pattern of a 128-bit floating-point NaN, converts this NaN to
  3007. | the common NaN form, and stores the resulting common NaN at the location
  3008. | pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid exception
  3009. | is raised.
  3010. *----------------------------------------------------------------------------*/
  3011. void
  3012. softfloat_f128UIToCommonNaN(
  3013. uint_fast64_t uiA64, uint_fast64_t uiA0, struct commonNaN *zPtr )
  3014. {
  3015. struct uint128 NaNSig;
  3016. if ( softfloat_isSigNaNF128UI( uiA64, uiA0 ) ) {
  3017. softfloat_raiseFlags( softfloat_flag_invalid );
  3018. }
  3019. NaNSig = softfloat_shortShiftLeft128( uiA64, uiA0, 16 );
  3020. zPtr->sign = uiA64>>63;
  3021. zPtr->v64 = NaNSig.v64;
  3022. zPtr->v0 = NaNSig.v0;
  3023. }
  3024. /**** ended inlining ../../source/8086-SSE/s_f128UIToCommonNaN.c ****/
  3025. /**** start inlining ../../source/8086-SSE/s_commonNaNToF128UI.c ****/
  3026. /*============================================================================
  3027. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  3028. Package, Release 3e, by John R. Hauser.
  3029. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  3030. All rights reserved.
  3031. Redistribution and use in source and binary forms, with or without
  3032. modification, are permitted provided that the following conditions are met:
  3033. 1. Redistributions of source code must retain the above copyright notice,
  3034. this list of conditions, and the following disclaimer.
  3035. 2. Redistributions in binary form must reproduce the above copyright notice,
  3036. this list of conditions, and the following disclaimer in the documentation
  3037. and/or other materials provided with the distribution.
  3038. 3. Neither the name of the University nor the names of its contributors may
  3039. be used to endorse or promote products derived from this software without
  3040. specific prior written permission.
  3041. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  3042. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  3043. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  3044. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  3045. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  3046. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  3047. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  3048. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  3049. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  3050. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3051. =============================================================================*/
  3052. #include <stdint.h>
  3053. /**** skipping file: platform.h ****/
  3054. /**** skipping file: primitives.h ****/
  3055. /**** skipping file: specialize.h ****/
  3056. /*----------------------------------------------------------------------------
  3057. | Converts the common NaN pointed to by `aPtr' into a 128-bit floating-point
  3058. | NaN, and returns the bit pattern of this value as an unsigned integer.
  3059. *----------------------------------------------------------------------------*/
  3060. struct uint128 softfloat_commonNaNToF128UI( const struct commonNaN *aPtr )
  3061. {
  3062. struct uint128 uiZ;
  3063. uiZ = softfloat_shortShiftRight128( aPtr->v64, aPtr->v0, 16 );
  3064. uiZ.v64 |= (uint_fast64_t) aPtr->sign<<63 | UINT64_C( 0x7FFF800000000000 );
  3065. return uiZ;
  3066. }
  3067. /**** ended inlining ../../source/8086-SSE/s_commonNaNToF128UI.c ****/
  3068. /**** start inlining ../../source/8086-SSE/s_propagateNaNF128UI.c ****/
  3069. /*============================================================================
  3070. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  3071. Package, Release 3e, by John R. Hauser.
  3072. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  3073. All rights reserved.
  3074. Redistribution and use in source and binary forms, with or without
  3075. modification, are permitted provided that the following conditions are met:
  3076. 1. Redistributions of source code must retain the above copyright notice,
  3077. this list of conditions, and the following disclaimer.
  3078. 2. Redistributions in binary form must reproduce the above copyright notice,
  3079. this list of conditions, and the following disclaimer in the documentation
  3080. and/or other materials provided with the distribution.
  3081. 3. Neither the name of the University nor the names of its contributors may
  3082. be used to endorse or promote products derived from this software without
  3083. specific prior written permission.
  3084. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  3085. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  3086. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  3087. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  3088. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  3089. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  3090. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  3091. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  3092. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  3093. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3094. =============================================================================*/
  3095. #include <stdbool.h>
  3096. #include <stdint.h>
  3097. /**** skipping file: platform.h ****/
  3098. /**** skipping file: internals.h ****/
  3099. /**** skipping file: specialize.h ****/
  3100. /**** skipping file: softfloat.h ****/
  3101. /*----------------------------------------------------------------------------
  3102. | Interpreting the unsigned integer formed from concatenating `uiA64' and
  3103. | `uiA0' as a 128-bit floating-point value, and likewise interpreting the
  3104. | unsigned integer formed from concatenating `uiB64' and `uiB0' as another
  3105. | 128-bit floating-point value, and assuming at least on of these floating-
  3106. | point values is a NaN, returns the bit pattern of the combined NaN result.
  3107. | If either original floating-point value is a signaling NaN, the invalid
  3108. | exception is raised.
  3109. *----------------------------------------------------------------------------*/
  3110. struct uint128
  3111. softfloat_propagateNaNF128UI(
  3112. uint_fast64_t uiA64,
  3113. uint_fast64_t uiA0,
  3114. uint_fast64_t uiB64,
  3115. uint_fast64_t uiB0
  3116. )
  3117. {
  3118. bool isSigNaNA;
  3119. struct uint128 uiZ;
  3120. isSigNaNA = softfloat_isSigNaNF128UI( uiA64, uiA0 );
  3121. if ( isSigNaNA || softfloat_isSigNaNF128UI( uiB64, uiB0 ) ) {
  3122. softfloat_raiseFlags( softfloat_flag_invalid );
  3123. if ( isSigNaNA ) goto returnNonsigA;
  3124. }
  3125. if ( isNaNF128UI( uiA64, uiA0 ) ) {
  3126. returnNonsigA:
  3127. uiZ.v64 = uiA64;
  3128. uiZ.v0 = uiA0;
  3129. } else {
  3130. uiZ.v64 = uiB64;
  3131. uiZ.v0 = uiB0;
  3132. }
  3133. uiZ.v64 |= UINT64_C( 0x0000800000000000 );
  3134. return uiZ;
  3135. }
  3136. /**** ended inlining ../../source/8086-SSE/s_propagateNaNF128UI.c ****/
  3137. /**** start inlining ../../source/s_eq128.c ****/
  3138. /*============================================================================
  3139. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  3140. Package, Release 3e, by John R. Hauser.
  3141. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  3142. California. All rights reserved.
  3143. Redistribution and use in source and binary forms, with or without
  3144. modification, are permitted provided that the following conditions are met:
  3145. 1. Redistributions of source code must retain the above copyright notice,
  3146. this list of conditions, and the following disclaimer.
  3147. 2. Redistributions in binary form must reproduce the above copyright notice,
  3148. this list of conditions, and the following disclaimer in the documentation
  3149. and/or other materials provided with the distribution.
  3150. 3. Neither the name of the University nor the names of its contributors may
  3151. be used to endorse or promote products derived from this software without
  3152. specific prior written permission.
  3153. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  3154. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  3155. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  3156. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  3157. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  3158. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  3159. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  3160. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  3161. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  3162. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3163. =============================================================================*/
  3164. #include <stdbool.h>
  3165. #include <stdint.h>
  3166. /**** skipping file: platform.h ****/
  3167. #ifndef softfloat_eq128
  3168. #define softfloat_eq128 softfloat_eq128
  3169. bool softfloat_eq128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
  3170. {
  3171. return (a64 == b64) && (a0 == b0);
  3172. }
  3173. #endif
  3174. /**** ended inlining ../../source/s_eq128.c ****/
  3175. /**** start inlining ../../source/s_le128.c ****/
  3176. /*============================================================================
  3177. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  3178. Package, Release 3e, by John R. Hauser.
  3179. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  3180. California. All rights reserved.
  3181. Redistribution and use in source and binary forms, with or without
  3182. modification, are permitted provided that the following conditions are met:
  3183. 1. Redistributions of source code must retain the above copyright notice,
  3184. this list of conditions, and the following disclaimer.
  3185. 2. Redistributions in binary form must reproduce the above copyright notice,
  3186. this list of conditions, and the following disclaimer in the documentation
  3187. and/or other materials provided with the distribution.
  3188. 3. Neither the name of the University nor the names of its contributors may
  3189. be used to endorse or promote products derived from this software without
  3190. specific prior written permission.
  3191. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  3192. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  3193. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  3194. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  3195. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  3196. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  3197. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  3198. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  3199. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  3200. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3201. =============================================================================*/
  3202. #include <stdbool.h>
  3203. #include <stdint.h>
  3204. /**** skipping file: platform.h ****/
  3205. #ifndef softfloat_le128
  3206. #define softfloat_le128 softfloat_le128
  3207. bool softfloat_le128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
  3208. {
  3209. return (a64 < b64) || ((a64 == b64) && (a0 <= b0));
  3210. }
  3211. #endif
  3212. /**** ended inlining ../../source/s_le128.c ****/
  3213. /**** start inlining ../../source/s_lt128.c ****/
  3214. /*============================================================================
  3215. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  3216. Package, Release 3e, by John R. Hauser.
  3217. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  3218. California. All rights reserved.
  3219. Redistribution and use in source and binary forms, with or without
  3220. modification, are permitted provided that the following conditions are met:
  3221. 1. Redistributions of source code must retain the above copyright notice,
  3222. this list of conditions, and the following disclaimer.
  3223. 2. Redistributions in binary form must reproduce the above copyright notice,
  3224. this list of conditions, and the following disclaimer in the documentation
  3225. and/or other materials provided with the distribution.
  3226. 3. Neither the name of the University nor the names of its contributors may
  3227. be used to endorse or promote products derived from this software without
  3228. specific prior written permission.
  3229. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  3230. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  3231. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  3232. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  3233. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  3234. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  3235. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  3236. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  3237. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  3238. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3239. =============================================================================*/
  3240. #include <stdbool.h>
  3241. #include <stdint.h>
  3242. /**** skipping file: platform.h ****/
  3243. #ifndef softfloat_lt128
  3244. #define softfloat_lt128 softfloat_lt128
  3245. bool softfloat_lt128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
  3246. {
  3247. return (a64 < b64) || ((a64 == b64) && (a0 < b0));
  3248. }
  3249. #endif
  3250. /**** ended inlining ../../source/s_lt128.c ****/
  3251. /**** start inlining ../../source/s_shortShiftLeft128.c ****/
  3252. /*============================================================================
  3253. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  3254. Package, Release 3e, by John R. Hauser.
  3255. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  3256. California. All rights reserved.
  3257. Redistribution and use in source and binary forms, with or without
  3258. modification, are permitted provided that the following conditions are met:
  3259. 1. Redistributions of source code must retain the above copyright notice,
  3260. this list of conditions, and the following disclaimer.
  3261. 2. Redistributions in binary form must reproduce the above copyright notice,
  3262. this list of conditions, and the following disclaimer in the documentation
  3263. and/or other materials provided with the distribution.
  3264. 3. Neither the name of the University nor the names of its contributors may
  3265. be used to endorse or promote products derived from this software without
  3266. specific prior written permission.
  3267. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  3268. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  3269. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  3270. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  3271. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  3272. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  3273. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  3274. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  3275. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  3276. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3277. =============================================================================*/
  3278. #include <stdint.h>
  3279. /**** skipping file: platform.h ****/
  3280. /**** skipping file: primitiveTypes.h ****/
  3281. #ifndef softfloat_shortShiftLeft128
  3282. #define softfloat_shortShiftLeft128 softfloat_shortShiftLeft128
  3283. struct uint128
  3284. softfloat_shortShiftLeft128( uint64_t a64, uint64_t a0, uint_fast8_t dist )
  3285. {
  3286. struct uint128 z;
  3287. z.v64 = a64<<dist | a0>>(-dist & 63);
  3288. z.v0 = a0<<dist;
  3289. return z;
  3290. }
  3291. #endif
  3292. /**** ended inlining ../../source/s_shortShiftLeft128.c ****/
  3293. /**** start inlining ../../source/s_shortShiftRight128.c ****/
  3294. /*============================================================================
  3295. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  3296. Package, Release 3e, by John R. Hauser.
  3297. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  3298. California. All rights reserved.
  3299. Redistribution and use in source and binary forms, with or without
  3300. modification, are permitted provided that the following conditions are met:
  3301. 1. Redistributions of source code must retain the above copyright notice,
  3302. this list of conditions, and the following disclaimer.
  3303. 2. Redistributions in binary form must reproduce the above copyright notice,
  3304. this list of conditions, and the following disclaimer in the documentation
  3305. and/or other materials provided with the distribution.
  3306. 3. Neither the name of the University nor the names of its contributors may
  3307. be used to endorse or promote products derived from this software without
  3308. specific prior written permission.
  3309. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  3310. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  3311. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  3312. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  3313. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  3314. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  3315. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  3316. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  3317. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  3318. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3319. =============================================================================*/
  3320. #include <stdint.h>
  3321. /**** skipping file: platform.h ****/
  3322. /**** skipping file: primitiveTypes.h ****/
  3323. #ifndef softfloat_shortShiftRight128
  3324. #define softfloat_shortShiftRight128 softfloat_shortShiftRight128
  3325. struct uint128
  3326. softfloat_shortShiftRight128( uint64_t a64, uint64_t a0, uint_fast8_t dist )
  3327. {
  3328. struct uint128 z;
  3329. z.v64 = a64>>dist;
  3330. z.v0 = a64<<(-dist & 63) | a0>>dist;
  3331. return z;
  3332. }
  3333. #endif
  3334. /**** ended inlining ../../source/s_shortShiftRight128.c ****/
  3335. /**** start inlining ../../source/s_shortShiftRightJam64.c ****/
  3336. /*============================================================================
  3337. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  3338. Package, Release 3e, by John R. Hauser.
  3339. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  3340. California. All rights reserved.
  3341. Redistribution and use in source and binary forms, with or without
  3342. modification, are permitted provided that the following conditions are met:
  3343. 1. Redistributions of source code must retain the above copyright notice,
  3344. this list of conditions, and the following disclaimer.
  3345. 2. Redistributions in binary form must reproduce the above copyright notice,
  3346. this list of conditions, and the following disclaimer in the documentation
  3347. and/or other materials provided with the distribution.
  3348. 3. Neither the name of the University nor the names of its contributors may
  3349. be used to endorse or promote products derived from this software without
  3350. specific prior written permission.
  3351. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  3352. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  3353. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  3354. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  3355. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  3356. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  3357. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  3358. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  3359. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  3360. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3361. =============================================================================*/
  3362. #include <stdint.h>
  3363. /**** skipping file: platform.h ****/
  3364. #ifndef softfloat_shortShiftRightJam64
  3365. #define softfloat_shortShiftRightJam64 softfloat_shortShiftRightJam64
  3366. uint64_t softfloat_shortShiftRightJam64( uint64_t a, uint_fast8_t dist )
  3367. {
  3368. return a>>dist | ((a & (((uint_fast64_t) 1<<dist) - 1)) != 0);
  3369. }
  3370. #endif
  3371. /**** ended inlining ../../source/s_shortShiftRightJam64.c ****/
  3372. /**** start inlining ../../source/s_shortShiftRightJam64Extra.c ****/
  3373. /*============================================================================
  3374. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  3375. Package, Release 3e, by John R. Hauser.
  3376. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  3377. California. All rights reserved.
  3378. Redistribution and use in source and binary forms, with or without
  3379. modification, are permitted provided that the following conditions are met:
  3380. 1. Redistributions of source code must retain the above copyright notice,
  3381. this list of conditions, and the following disclaimer.
  3382. 2. Redistributions in binary form must reproduce the above copyright notice,
  3383. this list of conditions, and the following disclaimer in the documentation
  3384. and/or other materials provided with the distribution.
  3385. 3. Neither the name of the University nor the names of its contributors may
  3386. be used to endorse or promote products derived from this software without
  3387. specific prior written permission.
  3388. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  3389. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  3390. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  3391. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  3392. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  3393. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  3394. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  3395. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  3396. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  3397. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3398. =============================================================================*/
  3399. #include <stdint.h>
  3400. /**** skipping file: platform.h ****/
  3401. /**** skipping file: primitiveTypes.h ****/
  3402. #ifndef softfloat_shortShiftRightJam64Extra
  3403. #define softfloat_shortShiftRightJam64Extra softfloat_shortShiftRightJam64Extra
  3404. struct uint64_extra
  3405. softfloat_shortShiftRightJam64Extra(
  3406. uint64_t a, uint64_t extra, uint_fast8_t dist )
  3407. {
  3408. struct uint64_extra z;
  3409. z.v = a>>dist;
  3410. z.extra = a<<(-dist & 63) | (extra != 0);
  3411. return z;
  3412. }
  3413. #endif
  3414. /**** ended inlining ../../source/s_shortShiftRightJam64Extra.c ****/
  3415. /**** start inlining ../../source/s_shortShiftRightJam128.c ****/
  3416. /*============================================================================
  3417. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  3418. Package, Release 3e, by John R. Hauser.
  3419. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  3420. California. All rights reserved.
  3421. Redistribution and use in source and binary forms, with or without
  3422. modification, are permitted provided that the following conditions are met:
  3423. 1. Redistributions of source code must retain the above copyright notice,
  3424. this list of conditions, and the following disclaimer.
  3425. 2. Redistributions in binary form must reproduce the above copyright notice,
  3426. this list of conditions, and the following disclaimer in the documentation
  3427. and/or other materials provided with the distribution.
  3428. 3. Neither the name of the University nor the names of its contributors may
  3429. be used to endorse or promote products derived from this software without
  3430. specific prior written permission.
  3431. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  3432. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  3433. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  3434. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  3435. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  3436. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  3437. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  3438. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  3439. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  3440. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3441. =============================================================================*/
  3442. #include <stdint.h>
  3443. /**** skipping file: platform.h ****/
  3444. /**** skipping file: primitiveTypes.h ****/
  3445. #ifndef softfloat_shortShiftRightJam128
  3446. #define softfloat_shortShiftRightJam128 softfloat_shortShiftRightJam128
  3447. struct uint128
  3448. softfloat_shortShiftRightJam128(
  3449. uint64_t a64, uint64_t a0, uint_fast8_t dist )
  3450. {
  3451. uint_fast8_t uNegDist;
  3452. struct uint128 z;
  3453. uNegDist = -dist;
  3454. z.v64 = a64>>dist;
  3455. z.v0 =
  3456. a64<<(uNegDist & 63) | a0>>dist
  3457. | ((uint64_t) (a0<<(uNegDist & 63)) != 0);
  3458. return z;
  3459. }
  3460. #endif
  3461. /**** ended inlining ../../source/s_shortShiftRightJam128.c ****/
  3462. /**** start inlining ../../source/s_shortShiftRightJam128Extra.c ****/
  3463. /*============================================================================
  3464. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  3465. Package, Release 3e, by John R. Hauser.
  3466. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  3467. California. All rights reserved.
  3468. Redistribution and use in source and binary forms, with or without
  3469. modification, are permitted provided that the following conditions are met:
  3470. 1. Redistributions of source code must retain the above copyright notice,
  3471. this list of conditions, and the following disclaimer.
  3472. 2. Redistributions in binary form must reproduce the above copyright notice,
  3473. this list of conditions, and the following disclaimer in the documentation
  3474. and/or other materials provided with the distribution.
  3475. 3. Neither the name of the University nor the names of its contributors may
  3476. be used to endorse or promote products derived from this software without
  3477. specific prior written permission.
  3478. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  3479. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  3480. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  3481. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  3482. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  3483. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  3484. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  3485. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  3486. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  3487. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3488. =============================================================================*/
  3489. #include <stdint.h>
  3490. /**** skipping file: platform.h ****/
  3491. /**** skipping file: primitiveTypes.h ****/
  3492. #ifndef softfloat_shortShiftRightJam128Extra
  3493. #define softfloat_shortShiftRightJam128Extra softfloat_shortShiftRightJam128Extra
  3494. struct uint128_extra
  3495. softfloat_shortShiftRightJam128Extra(
  3496. uint64_t a64, uint64_t a0, uint64_t extra, uint_fast8_t dist )
  3497. {
  3498. uint_fast8_t uNegDist;
  3499. struct uint128_extra z;
  3500. uNegDist = -dist;
  3501. z.v.v64 = a64>>dist;
  3502. z.v.v0 = a64<<(uNegDist & 63) | a0>>dist;
  3503. z.extra = a0<<(uNegDist & 63) | (extra != 0);
  3504. return z;
  3505. }
  3506. #endif
  3507. /**** ended inlining ../../source/s_shortShiftRightJam128Extra.c ****/
  3508. /**** start inlining ../../source/s_shiftRightJam32.c ****/
  3509. /*============================================================================
  3510. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  3511. Package, Release 3e, by John R. Hauser.
  3512. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  3513. California. All rights reserved.
  3514. Redistribution and use in source and binary forms, with or without
  3515. modification, are permitted provided that the following conditions are met:
  3516. 1. Redistributions of source code must retain the above copyright notice,
  3517. this list of conditions, and the following disclaimer.
  3518. 2. Redistributions in binary form must reproduce the above copyright notice,
  3519. this list of conditions, and the following disclaimer in the documentation
  3520. and/or other materials provided with the distribution.
  3521. 3. Neither the name of the University nor the names of its contributors may
  3522. be used to endorse or promote products derived from this software without
  3523. specific prior written permission.
  3524. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  3525. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  3526. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  3527. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  3528. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  3529. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  3530. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  3531. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  3532. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  3533. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3534. =============================================================================*/
  3535. #include <stdint.h>
  3536. /**** skipping file: platform.h ****/
  3537. #ifndef softfloat_shiftRightJam32
  3538. #define softfloat_shiftRightJam32 softfloat_shiftRightJam32
  3539. uint32_t softfloat_shiftRightJam32( uint32_t a, uint_fast16_t dist )
  3540. {
  3541. return
  3542. (dist < 31) ? a>>dist | ((uint32_t) (a<<(-dist & 31)) != 0) : (a != 0);
  3543. }
  3544. #endif
  3545. /**** ended inlining ../../source/s_shiftRightJam32.c ****/
  3546. /**** start inlining ../../source/s_shiftRightJam64.c ****/
  3547. /*============================================================================
  3548. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  3549. Package, Release 3e, by John R. Hauser.
  3550. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  3551. California. All rights reserved.
  3552. Redistribution and use in source and binary forms, with or without
  3553. modification, are permitted provided that the following conditions are met:
  3554. 1. Redistributions of source code must retain the above copyright notice,
  3555. this list of conditions, and the following disclaimer.
  3556. 2. Redistributions in binary form must reproduce the above copyright notice,
  3557. this list of conditions, and the following disclaimer in the documentation
  3558. and/or other materials provided with the distribution.
  3559. 3. Neither the name of the University nor the names of its contributors may
  3560. be used to endorse or promote products derived from this software without
  3561. specific prior written permission.
  3562. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  3563. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  3564. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  3565. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  3566. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  3567. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  3568. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  3569. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  3570. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  3571. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3572. =============================================================================*/
  3573. #include <stdint.h>
  3574. /**** skipping file: platform.h ****/
  3575. #ifndef softfloat_shiftRightJam64
  3576. #define softfloat_shiftRightJam64 softfloat_shiftRightJam64
  3577. uint64_t softfloat_shiftRightJam64( uint64_t a, uint_fast32_t dist )
  3578. {
  3579. return
  3580. (dist < 63) ? a>>dist | ((uint64_t) (a<<(-dist & 63)) != 0) : (a != 0);
  3581. }
  3582. #endif
  3583. /**** ended inlining ../../source/s_shiftRightJam64.c ****/
  3584. /**** start inlining ../../source/s_shiftRightJam64Extra.c ****/
  3585. /*============================================================================
  3586. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  3587. Package, Release 3e, by John R. Hauser.
  3588. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  3589. California. All rights reserved.
  3590. Redistribution and use in source and binary forms, with or without
  3591. modification, are permitted provided that the following conditions are met:
  3592. 1. Redistributions of source code must retain the above copyright notice,
  3593. this list of conditions, and the following disclaimer.
  3594. 2. Redistributions in binary form must reproduce the above copyright notice,
  3595. this list of conditions, and the following disclaimer in the documentation
  3596. and/or other materials provided with the distribution.
  3597. 3. Neither the name of the University nor the names of its contributors may
  3598. be used to endorse or promote products derived from this software without
  3599. specific prior written permission.
  3600. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  3601. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  3602. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  3603. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  3604. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  3605. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  3606. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  3607. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  3608. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  3609. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3610. =============================================================================*/
  3611. #include <stdint.h>
  3612. /**** skipping file: platform.h ****/
  3613. /**** skipping file: primitiveTypes.h ****/
  3614. #ifndef softfloat_shiftRightJam64Extra
  3615. #define softfloat_shiftRightJam64Extra softfloat_shiftRightJam64Extra
  3616. struct uint64_extra
  3617. softfloat_shiftRightJam64Extra(
  3618. uint64_t a, uint64_t extra, uint_fast32_t dist )
  3619. {
  3620. struct uint64_extra z;
  3621. if ( dist < 64 ) {
  3622. z.v = a>>dist;
  3623. z.extra = a<<(-dist & 63);
  3624. } else {
  3625. z.v = 0;
  3626. z.extra = (dist == 64) ? a : (a != 0);
  3627. }
  3628. z.extra |= (extra != 0);
  3629. return z;
  3630. }
  3631. #endif
  3632. /**** ended inlining ../../source/s_shiftRightJam64Extra.c ****/
  3633. /**** start inlining ../../source/s_shiftRightJam128.c ****/
  3634. /*============================================================================
  3635. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  3636. Package, Release 3e, by John R. Hauser.
  3637. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  3638. California. All rights reserved.
  3639. Redistribution and use in source and binary forms, with or without
  3640. modification, are permitted provided that the following conditions are met:
  3641. 1. Redistributions of source code must retain the above copyright notice,
  3642. this list of conditions, and the following disclaimer.
  3643. 2. Redistributions in binary form must reproduce the above copyright notice,
  3644. this list of conditions, and the following disclaimer in the documentation
  3645. and/or other materials provided with the distribution.
  3646. 3. Neither the name of the University nor the names of its contributors may
  3647. be used to endorse or promote products derived from this software without
  3648. specific prior written permission.
  3649. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  3650. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  3651. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  3652. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  3653. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  3654. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  3655. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  3656. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  3657. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  3658. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3659. =============================================================================*/
  3660. #include <stdint.h>
  3661. /**** skipping file: platform.h ****/
  3662. /**** skipping file: primitiveTypes.h ****/
  3663. #ifndef softfloat_shiftRightJam128
  3664. struct uint128
  3665. softfloat_shiftRightJam128( uint64_t a64, uint64_t a0, uint_fast32_t dist )
  3666. {
  3667. uint_fast8_t u8NegDist;
  3668. struct uint128 z;
  3669. if ( dist < 64 ) {
  3670. u8NegDist = -dist;
  3671. z.v64 = a64>>dist;
  3672. z.v0 =
  3673. a64<<(u8NegDist & 63) | a0>>dist
  3674. | ((uint64_t) (a0<<(u8NegDist & 63)) != 0);
  3675. } else {
  3676. z.v64 = 0;
  3677. z.v0 =
  3678. (dist < 127)
  3679. ? a64>>(dist & 63)
  3680. | (((a64 & (((uint_fast64_t) 1<<(dist & 63)) - 1)) | a0)
  3681. != 0)
  3682. : ((a64 | a0) != 0);
  3683. }
  3684. return z;
  3685. }
  3686. #endif
  3687. /**** ended inlining ../../source/s_shiftRightJam128.c ****/
  3688. /**** start inlining ../../source/s_shiftRightJam128Extra.c ****/
  3689. /*============================================================================
  3690. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  3691. Package, Release 3e, by John R. Hauser.
  3692. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  3693. California. All rights reserved.
  3694. Redistribution and use in source and binary forms, with or without
  3695. modification, are permitted provided that the following conditions are met:
  3696. 1. Redistributions of source code must retain the above copyright notice,
  3697. this list of conditions, and the following disclaimer.
  3698. 2. Redistributions in binary form must reproduce the above copyright notice,
  3699. this list of conditions, and the following disclaimer in the documentation
  3700. and/or other materials provided with the distribution.
  3701. 3. Neither the name of the University nor the names of its contributors may
  3702. be used to endorse or promote products derived from this software without
  3703. specific prior written permission.
  3704. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  3705. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  3706. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  3707. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  3708. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  3709. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  3710. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  3711. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  3712. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  3713. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3714. =============================================================================*/
  3715. #include <stdint.h>
  3716. /**** skipping file: platform.h ****/
  3717. /**** skipping file: primitiveTypes.h ****/
  3718. #ifndef softfloat_shiftRightJam128Extra
  3719. struct uint128_extra
  3720. softfloat_shiftRightJam128Extra(
  3721. uint64_t a64, uint64_t a0, uint64_t extra, uint_fast32_t dist )
  3722. {
  3723. uint_fast8_t u8NegDist;
  3724. struct uint128_extra z;
  3725. u8NegDist = -dist;
  3726. if ( dist < 64 ) {
  3727. z.v.v64 = a64>>dist;
  3728. z.v.v0 = a64<<(u8NegDist & 63) | a0>>dist;
  3729. z.extra = a0<<(u8NegDist & 63);
  3730. } else {
  3731. z.v.v64 = 0;
  3732. if ( dist == 64 ) {
  3733. z.v.v0 = a64;
  3734. z.extra = a0;
  3735. } else {
  3736. extra |= a0;
  3737. if ( dist < 128 ) {
  3738. z.v.v0 = a64>>(dist & 63);
  3739. z.extra = a64<<(u8NegDist & 63);
  3740. } else {
  3741. z.v.v0 = 0;
  3742. z.extra = (dist == 128) ? a64 : (a64 != 0);
  3743. }
  3744. }
  3745. }
  3746. z.extra |= (extra != 0);
  3747. return z;
  3748. }
  3749. #endif
  3750. /**** ended inlining ../../source/s_shiftRightJam128Extra.c ****/
  3751. /**** start inlining ../../source/s_shiftRightJam256M.c ****/
  3752. /*============================================================================
  3753. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  3754. Package, Release 3e, by John R. Hauser.
  3755. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  3756. California. All rights reserved.
  3757. Redistribution and use in source and binary forms, with or without
  3758. modification, are permitted provided that the following conditions are met:
  3759. 1. Redistributions of source code must retain the above copyright notice,
  3760. this list of conditions, and the following disclaimer.
  3761. 2. Redistributions in binary form must reproduce the above copyright notice,
  3762. this list of conditions, and the following disclaimer in the documentation
  3763. and/or other materials provided with the distribution.
  3764. 3. Neither the name of the University nor the names of its contributors may
  3765. be used to endorse or promote products derived from this software without
  3766. specific prior written permission.
  3767. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  3768. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  3769. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  3770. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  3771. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  3772. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  3773. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  3774. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  3775. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  3776. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3777. =============================================================================*/
  3778. #include <stdint.h>
  3779. /**** skipping file: platform.h ****/
  3780. /**** skipping file: primitiveTypes.h ****/
  3781. #ifndef softfloat_shiftRightJam256M
  3782. static
  3783. void
  3784. softfloat_shortShiftRightJamM(
  3785. uint_fast8_t size_words,
  3786. const uint64_t *aPtr,
  3787. uint_fast8_t dist,
  3788. uint64_t *zPtr
  3789. )
  3790. {
  3791. uint_fast8_t uNegDist;
  3792. unsigned int index, lastIndex;
  3793. uint64_t partWordZ, wordA;
  3794. uNegDist = -dist;
  3795. index = indexWordLo( size_words );
  3796. lastIndex = indexWordHi( size_words );
  3797. wordA = aPtr[index];
  3798. partWordZ = wordA>>dist;
  3799. if ( partWordZ<<dist != wordA ) partWordZ |= 1;
  3800. while ( index != lastIndex ) {
  3801. wordA = aPtr[index + wordIncr];
  3802. zPtr[index] = wordA<<(uNegDist & 63) | partWordZ;
  3803. index += wordIncr;
  3804. partWordZ = wordA>>dist;
  3805. }
  3806. zPtr[index] = partWordZ;
  3807. }
  3808. void
  3809. softfloat_shiftRightJam256M(
  3810. const uint64_t *aPtr, uint_fast32_t dist, uint64_t *zPtr )
  3811. {
  3812. uint64_t wordJam;
  3813. uint_fast32_t wordDist;
  3814. uint64_t *ptr;
  3815. uint_fast8_t i, innerDist;
  3816. wordJam = 0;
  3817. wordDist = dist>>6;
  3818. if ( wordDist ) {
  3819. if ( 4 < wordDist ) wordDist = 4;
  3820. ptr = (uint64_t *) (aPtr + indexMultiwordLo( 4, wordDist ));
  3821. i = wordDist;
  3822. do {
  3823. wordJam = *ptr++;
  3824. if ( wordJam ) break;
  3825. --i;
  3826. } while ( i );
  3827. ptr = zPtr;
  3828. }
  3829. if ( wordDist < 4 ) {
  3830. aPtr += indexMultiwordHiBut( 4, wordDist );
  3831. innerDist = dist & 63;
  3832. if ( innerDist ) {
  3833. softfloat_shortShiftRightJamM(
  3834. 4 - wordDist,
  3835. aPtr,
  3836. innerDist,
  3837. zPtr + indexMultiwordLoBut( 4, wordDist )
  3838. );
  3839. if ( ! wordDist ) goto wordJam;
  3840. } else {
  3841. aPtr += indexWordLo( 4 - wordDist );
  3842. ptr = zPtr + indexWordLo( 4 );
  3843. for ( i = 4 - wordDist; i; --i ) {
  3844. *ptr = *aPtr;
  3845. aPtr += wordIncr;
  3846. ptr += wordIncr;
  3847. }
  3848. }
  3849. ptr = zPtr + indexMultiwordHi( 4, wordDist );
  3850. }
  3851. do {
  3852. *ptr++ = 0;
  3853. --wordDist;
  3854. } while ( wordDist );
  3855. wordJam:
  3856. if ( wordJam ) zPtr[indexWordLo( 4 )] |= 1;
  3857. }
  3858. #endif
  3859. /**** ended inlining ../../source/s_shiftRightJam256M.c ****/
  3860. /**** start inlining ../../source/s_countLeadingZeros8.c ****/
  3861. /*============================================================================
  3862. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  3863. Package, Release 3e, by John R. Hauser.
  3864. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  3865. All rights reserved.
  3866. Redistribution and use in source and binary forms, with or without
  3867. modification, are permitted provided that the following conditions are met:
  3868. 1. Redistributions of source code must retain the above copyright notice,
  3869. this list of conditions, and the following disclaimer.
  3870. 2. Redistributions in binary form must reproduce the above copyright notice,
  3871. this list of conditions, and the following disclaimer in the documentation
  3872. and/or other materials provided with the distribution.
  3873. 3. Neither the name of the University nor the names of its contributors may
  3874. be used to endorse or promote products derived from this software without
  3875. specific prior written permission.
  3876. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  3877. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  3878. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  3879. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  3880. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  3881. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  3882. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  3883. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  3884. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  3885. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3886. =============================================================================*/
  3887. #include <stdint.h>
  3888. /**** skipping file: platform.h ****/
  3889. /**** skipping file: primitives.h ****/
  3890. const uint_least8_t softfloat_countLeadingZeros8[256] = {
  3891. 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
  3892. 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
  3893. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  3894. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  3895. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  3896. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  3897. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  3898. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  3899. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  3900. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  3901. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  3902. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  3903. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  3904. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  3905. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  3906. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  3907. };
  3908. /**** ended inlining ../../source/s_countLeadingZeros8.c ****/
  3909. /**** start inlining ../../source/s_countLeadingZeros16.c ****/
  3910. /*============================================================================
  3911. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  3912. Package, Release 3e, by John R. Hauser.
  3913. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  3914. California. All rights reserved.
  3915. Redistribution and use in source and binary forms, with or without
  3916. modification, are permitted provided that the following conditions are met:
  3917. 1. Redistributions of source code must retain the above copyright notice,
  3918. this list of conditions, and the following disclaimer.
  3919. 2. Redistributions in binary form must reproduce the above copyright notice,
  3920. this list of conditions, and the following disclaimer in the documentation
  3921. and/or other materials provided with the distribution.
  3922. 3. Neither the name of the University nor the names of its contributors may
  3923. be used to endorse or promote products derived from this software without
  3924. specific prior written permission.
  3925. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  3926. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  3927. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  3928. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  3929. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  3930. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  3931. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  3932. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  3933. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  3934. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3935. =============================================================================*/
  3936. #include <stdint.h>
  3937. /**** skipping file: platform.h ****/
  3938. #ifndef softfloat_countLeadingZeros16
  3939. #define softfloat_countLeadingZeros16 softfloat_countLeadingZeros16
  3940. /**** skipping file: primitives.h ****/
  3941. uint_fast8_t softfloat_countLeadingZeros16( uint16_t a )
  3942. {
  3943. uint_fast8_t count;
  3944. count = 8;
  3945. if ( 0x100 <= a ) {
  3946. count = 0;
  3947. a >>= 8;
  3948. }
  3949. count += softfloat_countLeadingZeros8[a];
  3950. return count;
  3951. }
  3952. #endif
  3953. /**** ended inlining ../../source/s_countLeadingZeros16.c ****/
  3954. /**** start inlining ../../source/s_countLeadingZeros32.c ****/
  3955. /*============================================================================
  3956. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  3957. Package, Release 3e, by John R. Hauser.
  3958. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  3959. California. All rights reserved.
  3960. Redistribution and use in source and binary forms, with or without
  3961. modification, are permitted provided that the following conditions are met:
  3962. 1. Redistributions of source code must retain the above copyright notice,
  3963. this list of conditions, and the following disclaimer.
  3964. 2. Redistributions in binary form must reproduce the above copyright notice,
  3965. this list of conditions, and the following disclaimer in the documentation
  3966. and/or other materials provided with the distribution.
  3967. 3. Neither the name of the University nor the names of its contributors may
  3968. be used to endorse or promote products derived from this software without
  3969. specific prior written permission.
  3970. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  3971. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  3972. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  3973. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  3974. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  3975. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  3976. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  3977. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  3978. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  3979. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3980. =============================================================================*/
  3981. #include <stdint.h>
  3982. /**** skipping file: platform.h ****/
  3983. #ifndef softfloat_countLeadingZeros32
  3984. #define softfloat_countLeadingZeros32 softfloat_countLeadingZeros32
  3985. /**** skipping file: primitives.h ****/
  3986. uint_fast8_t softfloat_countLeadingZeros32( uint32_t a )
  3987. {
  3988. uint_fast8_t count;
  3989. count = 0;
  3990. if ( a < 0x10000 ) {
  3991. count = 16;
  3992. a <<= 16;
  3993. }
  3994. if ( a < 0x1000000 ) {
  3995. count += 8;
  3996. a <<= 8;
  3997. }
  3998. count += softfloat_countLeadingZeros8[a>>24];
  3999. return count;
  4000. }
  4001. #endif
  4002. /**** ended inlining ../../source/s_countLeadingZeros32.c ****/
  4003. /**** start inlining ../../source/s_countLeadingZeros64.c ****/
  4004. /*============================================================================
  4005. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  4006. Package, Release 3e, by John R. Hauser.
  4007. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  4008. California. All rights reserved.
  4009. Redistribution and use in source and binary forms, with or without
  4010. modification, are permitted provided that the following conditions are met:
  4011. 1. Redistributions of source code must retain the above copyright notice,
  4012. this list of conditions, and the following disclaimer.
  4013. 2. Redistributions in binary form must reproduce the above copyright notice,
  4014. this list of conditions, and the following disclaimer in the documentation
  4015. and/or other materials provided with the distribution.
  4016. 3. Neither the name of the University nor the names of its contributors may
  4017. be used to endorse or promote products derived from this software without
  4018. specific prior written permission.
  4019. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  4020. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  4021. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  4022. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  4023. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  4024. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  4025. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  4026. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  4027. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  4028. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  4029. =============================================================================*/
  4030. #include <stdint.h>
  4031. /**** skipping file: platform.h ****/
  4032. #ifndef softfloat_countLeadingZeros64
  4033. #define softfloat_countLeadingZeros64 softfloat_countLeadingZeros64
  4034. /**** skipping file: primitives.h ****/
  4035. uint_fast8_t softfloat_countLeadingZeros64( uint64_t a )
  4036. {
  4037. uint_fast8_t count;
  4038. uint32_t a32;
  4039. count = 0;
  4040. a32 = a>>32;
  4041. if ( ! a32 ) {
  4042. count = 32;
  4043. a32 = a;
  4044. }
  4045. /*------------------------------------------------------------------------
  4046. | From here, result is current count + count leading zeros of `a32'.
  4047. *------------------------------------------------------------------------*/
  4048. if ( a32 < 0x10000 ) {
  4049. count += 16;
  4050. a32 <<= 16;
  4051. }
  4052. if ( a32 < 0x1000000 ) {
  4053. count += 8;
  4054. a32 <<= 8;
  4055. }
  4056. count += softfloat_countLeadingZeros8[a32>>24];
  4057. return count;
  4058. }
  4059. #endif
  4060. /**** ended inlining ../../source/s_countLeadingZeros64.c ****/
  4061. /**** start inlining ../../source/s_add128.c ****/
  4062. /*============================================================================
  4063. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  4064. Package, Release 3e, by John R. Hauser.
  4065. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  4066. California. All rights reserved.
  4067. Redistribution and use in source and binary forms, with or without
  4068. modification, are permitted provided that the following conditions are met:
  4069. 1. Redistributions of source code must retain the above copyright notice,
  4070. this list of conditions, and the following disclaimer.
  4071. 2. Redistributions in binary form must reproduce the above copyright notice,
  4072. this list of conditions, and the following disclaimer in the documentation
  4073. and/or other materials provided with the distribution.
  4074. 3. Neither the name of the University nor the names of its contributors may
  4075. be used to endorse or promote products derived from this software without
  4076. specific prior written permission.
  4077. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  4078. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  4079. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  4080. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  4081. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  4082. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  4083. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  4084. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  4085. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  4086. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  4087. =============================================================================*/
  4088. #include <stdint.h>
  4089. /**** skipping file: platform.h ****/
  4090. /**** skipping file: primitiveTypes.h ****/
  4091. #ifndef softfloat_add128
  4092. struct uint128
  4093. softfloat_add128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
  4094. {
  4095. struct uint128 z;
  4096. z.v0 = a0 + b0;
  4097. z.v64 = a64 + b64 + (z.v0 < a0);
  4098. return z;
  4099. }
  4100. #endif
  4101. /**** ended inlining ../../source/s_add128.c ****/
  4102. /**** start inlining ../../source/s_add256M.c ****/
  4103. /*============================================================================
  4104. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  4105. Package, Release 3e, by John R. Hauser.
  4106. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  4107. California. All rights reserved.
  4108. Redistribution and use in source and binary forms, with or without
  4109. modification, are permitted provided that the following conditions are met:
  4110. 1. Redistributions of source code must retain the above copyright notice,
  4111. this list of conditions, and the following disclaimer.
  4112. 2. Redistributions in binary form must reproduce the above copyright notice,
  4113. this list of conditions, and the following disclaimer in the documentation
  4114. and/or other materials provided with the distribution.
  4115. 3. Neither the name of the University nor the names of its contributors may
  4116. be used to endorse or promote products derived from this software without
  4117. specific prior written permission.
  4118. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  4119. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  4120. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  4121. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  4122. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  4123. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  4124. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  4125. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  4126. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  4127. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  4128. =============================================================================*/
  4129. #include <stdint.h>
  4130. /**** skipping file: platform.h ****/
  4131. /**** skipping file: primitiveTypes.h ****/
  4132. #ifndef softfloat_add256M
  4133. void
  4134. softfloat_add256M(
  4135. const uint64_t *aPtr, const uint64_t *bPtr, uint64_t *zPtr )
  4136. {
  4137. unsigned int index;
  4138. uint_fast8_t carry;
  4139. uint64_t wordA, wordZ;
  4140. index = indexWordLo( 4 );
  4141. carry = 0;
  4142. for (;;) {
  4143. wordA = aPtr[index];
  4144. wordZ = wordA + bPtr[index] + carry;
  4145. zPtr[index] = wordZ;
  4146. if ( index == indexWordHi( 4 ) ) break;
  4147. if ( wordZ != wordA ) carry = (wordZ < wordA);
  4148. index += wordIncr;
  4149. }
  4150. }
  4151. #endif
  4152. /**** ended inlining ../../source/s_add256M.c ****/
  4153. /**** start inlining ../../source/s_sub128.c ****/
  4154. /*============================================================================
  4155. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  4156. Package, Release 3e, by John R. Hauser.
  4157. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  4158. California. All rights reserved.
  4159. Redistribution and use in source and binary forms, with or without
  4160. modification, are permitted provided that the following conditions are met:
  4161. 1. Redistributions of source code must retain the above copyright notice,
  4162. this list of conditions, and the following disclaimer.
  4163. 2. Redistributions in binary form must reproduce the above copyright notice,
  4164. this list of conditions, and the following disclaimer in the documentation
  4165. and/or other materials provided with the distribution.
  4166. 3. Neither the name of the University nor the names of its contributors may
  4167. be used to endorse or promote products derived from this software without
  4168. specific prior written permission.
  4169. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  4170. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  4171. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  4172. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  4173. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  4174. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  4175. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  4176. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  4177. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  4178. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  4179. =============================================================================*/
  4180. #include <stdint.h>
  4181. /**** skipping file: platform.h ****/
  4182. /**** skipping file: primitiveTypes.h ****/
  4183. #ifndef softfloat_sub128
  4184. #define softfloat_sub128 softfloat_sub128
  4185. struct uint128
  4186. softfloat_sub128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
  4187. {
  4188. struct uint128 z;
  4189. z.v0 = a0 - b0;
  4190. z.v64 = a64 - b64 - (a0 < b0);
  4191. return z;
  4192. }
  4193. #endif
  4194. /**** ended inlining ../../source/s_sub128.c ****/
  4195. /**** start inlining ../../source/s_sub256M.c ****/
  4196. /*============================================================================
  4197. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  4198. Package, Release 3e, by John R. Hauser.
  4199. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  4200. California. All rights reserved.
  4201. Redistribution and use in source and binary forms, with or without
  4202. modification, are permitted provided that the following conditions are met:
  4203. 1. Redistributions of source code must retain the above copyright notice,
  4204. this list of conditions, and the following disclaimer.
  4205. 2. Redistributions in binary form must reproduce the above copyright notice,
  4206. this list of conditions, and the following disclaimer in the documentation
  4207. and/or other materials provided with the distribution.
  4208. 3. Neither the name of the University nor the names of its contributors may
  4209. be used to endorse or promote products derived from this software without
  4210. specific prior written permission.
  4211. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  4212. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  4213. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  4214. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  4215. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  4216. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  4217. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  4218. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  4219. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  4220. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  4221. =============================================================================*/
  4222. #include <stdint.h>
  4223. /**** skipping file: platform.h ****/
  4224. /**** skipping file: primitiveTypes.h ****/
  4225. #ifndef softfloat_sub256M
  4226. void
  4227. softfloat_sub256M(
  4228. const uint64_t *aPtr, const uint64_t *bPtr, uint64_t *zPtr )
  4229. {
  4230. unsigned int index;
  4231. uint_fast8_t borrow;
  4232. uint64_t wordA, wordB;
  4233. index = indexWordLo( 4 );
  4234. borrow = 0;
  4235. for (;;) {
  4236. wordA = aPtr[index];
  4237. wordB = bPtr[index];
  4238. zPtr[index] = wordA - wordB - borrow;
  4239. if ( index == indexWordHi( 4 ) ) break;
  4240. borrow = borrow ? (wordA <= wordB) : (wordA < wordB);
  4241. index += wordIncr;
  4242. }
  4243. }
  4244. #endif
  4245. /**** ended inlining ../../source/s_sub256M.c ****/
  4246. /**** start inlining ../../source/s_mul64ByShifted32To128.c ****/
  4247. /*============================================================================
  4248. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  4249. Package, Release 3e, by John R. Hauser.
  4250. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  4251. California. All rights reserved.
  4252. Redistribution and use in source and binary forms, with or without
  4253. modification, are permitted provided that the following conditions are met:
  4254. 1. Redistributions of source code must retain the above copyright notice,
  4255. this list of conditions, and the following disclaimer.
  4256. 2. Redistributions in binary form must reproduce the above copyright notice,
  4257. this list of conditions, and the following disclaimer in the documentation
  4258. and/or other materials provided with the distribution.
  4259. 3. Neither the name of the University nor the names of its contributors may
  4260. be used to endorse or promote products derived from this software without
  4261. specific prior written permission.
  4262. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  4263. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  4264. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  4265. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  4266. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  4267. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  4268. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  4269. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  4270. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  4271. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  4272. =============================================================================*/
  4273. #include <stdint.h>
  4274. /**** skipping file: platform.h ****/
  4275. /**** skipping file: primitiveTypes.h ****/
  4276. #ifndef softfloat_mul64ByShifted32To128
  4277. struct uint128 softfloat_mul64ByShifted32To128( uint64_t a, uint32_t b )
  4278. {
  4279. uint_fast64_t mid;
  4280. struct uint128 z;
  4281. mid = (uint_fast64_t) (uint32_t) a * b;
  4282. z.v0 = mid<<32;
  4283. z.v64 = (uint_fast64_t) (uint32_t) (a>>32) * b + (mid>>32);
  4284. return z;
  4285. }
  4286. #endif
  4287. /**** ended inlining ../../source/s_mul64ByShifted32To128.c ****/
  4288. /**** start inlining ../../source/s_mul64To128.c ****/
  4289. /*============================================================================
  4290. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  4291. Package, Release 3e, by John R. Hauser.
  4292. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  4293. California. All rights reserved.
  4294. Redistribution and use in source and binary forms, with or without
  4295. modification, are permitted provided that the following conditions are met:
  4296. 1. Redistributions of source code must retain the above copyright notice,
  4297. this list of conditions, and the following disclaimer.
  4298. 2. Redistributions in binary form must reproduce the above copyright notice,
  4299. this list of conditions, and the following disclaimer in the documentation
  4300. and/or other materials provided with the distribution.
  4301. 3. Neither the name of the University nor the names of its contributors may
  4302. be used to endorse or promote products derived from this software without
  4303. specific prior written permission.
  4304. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  4305. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  4306. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  4307. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  4308. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  4309. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  4310. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  4311. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  4312. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  4313. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  4314. =============================================================================*/
  4315. #include <stdint.h>
  4316. /**** skipping file: platform.h ****/
  4317. /**** skipping file: primitiveTypes.h ****/
  4318. #ifndef softfloat_mul64To128
  4319. struct uint128 softfloat_mul64To128( uint64_t a, uint64_t b )
  4320. {
  4321. uint32_t a32, a0, b32, b0;
  4322. struct uint128 z;
  4323. uint64_t mid1, mid;
  4324. a32 = a>>32;
  4325. a0 = a;
  4326. b32 = b>>32;
  4327. b0 = b;
  4328. z.v0 = (uint_fast64_t) a0 * b0;
  4329. mid1 = (uint_fast64_t) a32 * b0;
  4330. mid = mid1 + (uint_fast64_t) a0 * b32;
  4331. z.v64 = (uint_fast64_t) a32 * b32;
  4332. z.v64 += (uint_fast64_t) (mid < mid1)<<32 | mid>>32;
  4333. mid <<= 32;
  4334. z.v0 += mid;
  4335. z.v64 += (z.v0 < mid);
  4336. return z;
  4337. }
  4338. #endif
  4339. /**** ended inlining ../../source/s_mul64To128.c ****/
  4340. /**** start inlining ../../source/s_mul128By32.c ****/
  4341. /*============================================================================
  4342. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  4343. Package, Release 3e, by John R. Hauser.
  4344. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  4345. California. All rights reserved.
  4346. Redistribution and use in source and binary forms, with or without
  4347. modification, are permitted provided that the following conditions are met:
  4348. 1. Redistributions of source code must retain the above copyright notice,
  4349. this list of conditions, and the following disclaimer.
  4350. 2. Redistributions in binary form must reproduce the above copyright notice,
  4351. this list of conditions, and the following disclaimer in the documentation
  4352. and/or other materials provided with the distribution.
  4353. 3. Neither the name of the University nor the names of its contributors may
  4354. be used to endorse or promote products derived from this software without
  4355. specific prior written permission.
  4356. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  4357. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  4358. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  4359. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  4360. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  4361. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  4362. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  4363. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  4364. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  4365. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  4366. =============================================================================*/
  4367. #include <stdint.h>
  4368. /**** skipping file: platform.h ****/
  4369. /**** skipping file: primitiveTypes.h ****/
  4370. #ifndef softfloat_mul128By32
  4371. struct uint128 softfloat_mul128By32( uint64_t a64, uint64_t a0, uint32_t b )
  4372. {
  4373. struct uint128 z;
  4374. uint_fast64_t mid;
  4375. uint_fast32_t carry;
  4376. z.v0 = a0 * b;
  4377. mid = (uint_fast64_t) (uint32_t) (a0>>32) * b;
  4378. carry = (uint32_t) ((uint_fast32_t) (z.v0>>32) - (uint_fast32_t) mid);
  4379. z.v64 = a64 * b + (uint_fast32_t) ((mid + carry)>>32);
  4380. return z;
  4381. }
  4382. #endif
  4383. /**** ended inlining ../../source/s_mul128By32.c ****/
  4384. /**** start inlining ../../source/s_mul128To256M.c ****/
  4385. /*============================================================================
  4386. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  4387. Package, Release 3e, by John R. Hauser.
  4388. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  4389. California. All rights reserved.
  4390. Redistribution and use in source and binary forms, with or without
  4391. modification, are permitted provided that the following conditions are met:
  4392. 1. Redistributions of source code must retain the above copyright notice,
  4393. this list of conditions, and the following disclaimer.
  4394. 2. Redistributions in binary form must reproduce the above copyright notice,
  4395. this list of conditions, and the following disclaimer in the documentation
  4396. and/or other materials provided with the distribution.
  4397. 3. Neither the name of the University nor the names of its contributors may
  4398. be used to endorse or promote products derived from this software without
  4399. specific prior written permission.
  4400. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  4401. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  4402. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  4403. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  4404. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  4405. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  4406. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  4407. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  4408. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  4409. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  4410. =============================================================================*/
  4411. #include <stdint.h>
  4412. /**** skipping file: platform.h ****/
  4413. #ifndef softfloat_mul128To256M
  4414. #define softfloat_mul128To256M softfloat_mul128To256M
  4415. /**** skipping file: primitives.h ****/
  4416. void
  4417. softfloat_mul128To256M(
  4418. uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0, uint64_t *zPtr )
  4419. {
  4420. struct uint128 p0, p64, p128;
  4421. uint_fast64_t z64, z128, z192;
  4422. p0 = softfloat_mul64To128( a0, b0 );
  4423. zPtr[indexWord( 4, 0 )] = p0.v0;
  4424. p64 = softfloat_mul64To128( a64, b0 );
  4425. z64 = p64.v0 + p0.v64;
  4426. z128 = p64.v64 + (z64 < p64.v0);
  4427. p128 = softfloat_mul64To128( a64, b64 );
  4428. z128 += p128.v0;
  4429. z192 = p128.v64 + (z128 < p128.v0);
  4430. p64 = softfloat_mul64To128( a0, b64 );
  4431. z64 += p64.v0;
  4432. zPtr[indexWord( 4, 1 )] = z64;
  4433. p64.v64 += (z64 < p64.v0);
  4434. z128 += p64.v64;
  4435. zPtr[indexWord( 4, 2 )] = z128;
  4436. zPtr[indexWord( 4, 3 )] = z192 + (z128 < p64.v64);
  4437. }
  4438. #endif
  4439. /**** ended inlining ../../source/s_mul128To256M.c ****/
  4440. /**** start inlining ../../source/s_approxRecip_1Ks.c ****/
  4441. /*============================================================================
  4442. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  4443. Package, Release 3e, by John R. Hauser.
  4444. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  4445. California. All rights reserved.
  4446. Redistribution and use in source and binary forms, with or without
  4447. modification, are permitted provided that the following conditions are met:
  4448. 1. Redistributions of source code must retain the above copyright notice,
  4449. this list of conditions, and the following disclaimer.
  4450. 2. Redistributions in binary form must reproduce the above copyright notice,
  4451. this list of conditions, and the following disclaimer in the documentation
  4452. and/or other materials provided with the distribution.
  4453. 3. Neither the name of the University nor the names of its contributors may
  4454. be used to endorse or promote products derived from this software without
  4455. specific prior written permission.
  4456. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  4457. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  4458. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  4459. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  4460. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  4461. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  4462. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  4463. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  4464. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  4465. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  4466. =============================================================================*/
  4467. #include <stdint.h>
  4468. /**** skipping file: platform.h ****/
  4469. /**** skipping file: primitives.h ****/
  4470. const uint16_t softfloat_approxRecip_1k0s[16] = {
  4471. 0xFFC4, 0xF0BE, 0xE363, 0xD76F, 0xCCAD, 0xC2F0, 0xBA16, 0xB201,
  4472. 0xAA97, 0xA3C6, 0x9D7A, 0x97A6, 0x923C, 0x8D32, 0x887E, 0x8417
  4473. };
  4474. const uint16_t softfloat_approxRecip_1k1s[16] = {
  4475. 0xF0F1, 0xD62C, 0xBFA1, 0xAC77, 0x9C0A, 0x8DDB, 0x8185, 0x76BA,
  4476. 0x6D3B, 0x64D4, 0x5D5C, 0x56B1, 0x50B6, 0x4B55, 0x4679, 0x4211
  4477. };
  4478. /**** ended inlining ../../source/s_approxRecip_1Ks.c ****/
  4479. /**** start inlining ../../source/s_approxRecip32_1.c ****/
  4480. /*============================================================================
  4481. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  4482. Package, Release 3e, by John R. Hauser.
  4483. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  4484. California. All rights reserved.
  4485. Redistribution and use in source and binary forms, with or without
  4486. modification, are permitted provided that the following conditions are met:
  4487. 1. Redistributions of source code must retain the above copyright notice,
  4488. this list of conditions, and the following disclaimer.
  4489. 2. Redistributions in binary form must reproduce the above copyright notice,
  4490. this list of conditions, and the following disclaimer in the documentation
  4491. and/or other materials provided with the distribution.
  4492. 3. Neither the name of the University nor the names of its contributors may
  4493. be used to endorse or promote products derived from this software without
  4494. specific prior written permission.
  4495. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  4496. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  4497. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  4498. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  4499. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  4500. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  4501. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  4502. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  4503. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  4504. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  4505. =============================================================================*/
  4506. #include <stdint.h>
  4507. /**** skipping file: platform.h ****/
  4508. #ifndef softfloat_approxRecip32_1
  4509. extern const uint16_t softfloat_approxRecip_1k0s[16];
  4510. extern const uint16_t softfloat_approxRecip_1k1s[16];
  4511. uint32_t softfloat_approxRecip32_1( uint32_t a )
  4512. {
  4513. int index;
  4514. uint16_t eps, r0;
  4515. uint32_t sigma0;
  4516. uint_fast32_t r;
  4517. uint32_t sqrSigma0;
  4518. index = a>>27 & 0xF;
  4519. eps = (uint16_t) (a>>11);
  4520. r0 = softfloat_approxRecip_1k0s[index]
  4521. - ((softfloat_approxRecip_1k1s[index] * (uint_fast32_t) eps)>>20);
  4522. sigma0 = ~(uint_fast32_t) ((r0 * (uint_fast64_t) a)>>7);
  4523. r = ((uint_fast32_t) r0<<16) + ((r0 * (uint_fast64_t) sigma0)>>24);
  4524. sqrSigma0 = ((uint_fast64_t) sigma0 * sigma0)>>32;
  4525. r += ((uint32_t) r * (uint_fast64_t) sqrSigma0)>>48;
  4526. return r;
  4527. }
  4528. #endif
  4529. /**** ended inlining ../../source/s_approxRecip32_1.c ****/
  4530. /**** start inlining ../../source/s_approxRecipSqrt_1Ks.c ****/
  4531. /*============================================================================
  4532. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  4533. Package, Release 3e, by John R. Hauser.
  4534. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  4535. California. All rights reserved.
  4536. Redistribution and use in source and binary forms, with or without
  4537. modification, are permitted provided that the following conditions are met:
  4538. 1. Redistributions of source code must retain the above copyright notice,
  4539. this list of conditions, and the following disclaimer.
  4540. 2. Redistributions in binary form must reproduce the above copyright notice,
  4541. this list of conditions, and the following disclaimer in the documentation
  4542. and/or other materials provided with the distribution.
  4543. 3. Neither the name of the University nor the names of its contributors may
  4544. be used to endorse or promote products derived from this software without
  4545. specific prior written permission.
  4546. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  4547. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  4548. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  4549. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  4550. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  4551. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  4552. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  4553. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  4554. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  4555. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  4556. =============================================================================*/
  4557. #include <stdint.h>
  4558. /**** skipping file: platform.h ****/
  4559. /**** skipping file: primitives.h ****/
  4560. const uint16_t softfloat_approxRecipSqrt_1k0s[16] = {
  4561. 0xB4C9, 0xFFAB, 0xAA7D, 0xF11C, 0xA1C5, 0xE4C7, 0x9A43, 0xDA29,
  4562. 0x93B5, 0xD0E5, 0x8DED, 0xC8B7, 0x88C6, 0xC16D, 0x8424, 0xBAE1
  4563. };
  4564. const uint16_t softfloat_approxRecipSqrt_1k1s[16] = {
  4565. 0xA5A5, 0xEA42, 0x8C21, 0xC62D, 0x788F, 0xAA7F, 0x6928, 0x94B6,
  4566. 0x5CC7, 0x8335, 0x52A6, 0x74E2, 0x4A3E, 0x68FE, 0x432B, 0x5EFD
  4567. };
  4568. /**** ended inlining ../../source/s_approxRecipSqrt_1Ks.c ****/
  4569. /**** start inlining ../../source/s_approxRecipSqrt32_1.c ****/
  4570. /*============================================================================
  4571. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  4572. Package, Release 3e, by John R. Hauser.
  4573. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  4574. California. All rights reserved.
  4575. Redistribution and use in source and binary forms, with or without
  4576. modification, are permitted provided that the following conditions are met:
  4577. 1. Redistributions of source code must retain the above copyright notice,
  4578. this list of conditions, and the following disclaimer.
  4579. 2. Redistributions in binary form must reproduce the above copyright notice,
  4580. this list of conditions, and the following disclaimer in the documentation
  4581. and/or other materials provided with the distribution.
  4582. 3. Neither the name of the University nor the names of its contributors may
  4583. be used to endorse or promote products derived from this software without
  4584. specific prior written permission.
  4585. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  4586. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  4587. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  4588. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  4589. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  4590. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  4591. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  4592. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  4593. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  4594. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  4595. =============================================================================*/
  4596. #include <stdint.h>
  4597. /**** skipping file: platform.h ****/
  4598. #ifndef softfloat_approxRecipSqrt32_1
  4599. extern const uint16_t softfloat_approxRecipSqrt_1k0s[];
  4600. extern const uint16_t softfloat_approxRecipSqrt_1k1s[];
  4601. uint32_t softfloat_approxRecipSqrt32_1( unsigned int oddExpA, uint32_t a )
  4602. {
  4603. int index;
  4604. uint16_t eps, r0;
  4605. uint_fast32_t ESqrR0;
  4606. uint32_t sigma0;
  4607. uint_fast32_t r;
  4608. uint32_t sqrSigma0;
  4609. index = (a>>27 & 0xE) + oddExpA;
  4610. eps = (uint16_t) (a>>12);
  4611. r0 = softfloat_approxRecipSqrt_1k0s[index]
  4612. - ((softfloat_approxRecipSqrt_1k1s[index] * (uint_fast32_t) eps)
  4613. >>20);
  4614. ESqrR0 = (uint_fast32_t) r0 * r0;
  4615. if ( ! oddExpA ) ESqrR0 <<= 1;
  4616. sigma0 = ~(uint_fast32_t) (((uint32_t) ESqrR0 * (uint_fast64_t) a)>>23);
  4617. r = ((uint_fast32_t) r0<<16) + ((r0 * (uint_fast64_t) sigma0)>>25);
  4618. sqrSigma0 = ((uint_fast64_t) sigma0 * sigma0)>>32;
  4619. r += ((uint32_t) ((r>>1) + (r>>3) - ((uint_fast32_t) r0<<14))
  4620. * (uint_fast64_t) sqrSigma0)
  4621. >>48;
  4622. if ( ! (r & 0x80000000) ) r = 0x80000000;
  4623. return r;
  4624. }
  4625. #endif
  4626. /**** ended inlining ../../source/s_approxRecipSqrt32_1.c ****/
  4627. /**** start inlining ../../source/s_roundToUI32.c ****/
  4628. /*============================================================================
  4629. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  4630. Package, Release 3e, by John R. Hauser.
  4631. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  4632. University of California. All rights reserved.
  4633. Redistribution and use in source and binary forms, with or without
  4634. modification, are permitted provided that the following conditions are met:
  4635. 1. Redistributions of source code must retain the above copyright notice,
  4636. this list of conditions, and the following disclaimer.
  4637. 2. Redistributions in binary form must reproduce the above copyright notice,
  4638. this list of conditions, and the following disclaimer in the documentation
  4639. and/or other materials provided with the distribution.
  4640. 3. Neither the name of the University nor the names of its contributors may
  4641. be used to endorse or promote products derived from this software without
  4642. specific prior written permission.
  4643. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  4644. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  4645. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  4646. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  4647. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  4648. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  4649. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  4650. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  4651. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  4652. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  4653. =============================================================================*/
  4654. #include <stdbool.h>
  4655. #include <stdint.h>
  4656. /**** skipping file: platform.h ****/
  4657. /**** skipping file: internals.h ****/
  4658. /**** skipping file: specialize.h ****/
  4659. /**** skipping file: softfloat.h ****/
  4660. uint_fast32_t
  4661. softfloat_roundToUI32(
  4662. bool sign, uint_fast64_t sig, uint_fast8_t roundingMode, bool exact )
  4663. {
  4664. uint_fast16_t roundIncrement, roundBits;
  4665. uint_fast32_t z;
  4666. /*------------------------------------------------------------------------
  4667. *------------------------------------------------------------------------*/
  4668. roundIncrement = 0x800;
  4669. if (
  4670. (roundingMode != softfloat_round_near_maxMag)
  4671. && (roundingMode != softfloat_round_near_even)
  4672. ) {
  4673. roundIncrement = 0;
  4674. if ( sign ) {
  4675. if ( !sig ) return 0;
  4676. if ( roundingMode == softfloat_round_min ) goto invalid;
  4677. #ifdef SOFTFLOAT_ROUND_ODD
  4678. if ( roundingMode == softfloat_round_odd ) goto invalid;
  4679. #endif
  4680. } else {
  4681. if ( roundingMode == softfloat_round_max ) roundIncrement = 0xFFF;
  4682. }
  4683. }
  4684. roundBits = sig & 0xFFF;
  4685. sig += roundIncrement;
  4686. if ( sig & UINT64_C( 0xFFFFF00000000000 ) ) goto invalid;
  4687. z = sig>>12;
  4688. if (
  4689. (roundBits == 0x800) && (roundingMode == softfloat_round_near_even)
  4690. ) {
  4691. z &= ~(uint_fast32_t) 1;
  4692. }
  4693. if ( sign && z ) goto invalid;
  4694. if ( roundBits ) {
  4695. #ifdef SOFTFLOAT_ROUND_ODD
  4696. if ( roundingMode == softfloat_round_odd ) z |= 1;
  4697. #endif
  4698. if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
  4699. }
  4700. return z;
  4701. /*------------------------------------------------------------------------
  4702. *------------------------------------------------------------------------*/
  4703. invalid:
  4704. softfloat_raiseFlags( softfloat_flag_invalid );
  4705. return sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
  4706. }
  4707. /**** ended inlining ../../source/s_roundToUI32.c ****/
  4708. /**** start inlining ../../source/s_roundToUI64.c ****/
  4709. /*============================================================================
  4710. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  4711. Package, Release 3e, by John R. Hauser.
  4712. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  4713. University of California. All rights reserved.
  4714. Redistribution and use in source and binary forms, with or without
  4715. modification, are permitted provided that the following conditions are met:
  4716. 1. Redistributions of source code must retain the above copyright notice,
  4717. this list of conditions, and the following disclaimer.
  4718. 2. Redistributions in binary form must reproduce the above copyright notice,
  4719. this list of conditions, and the following disclaimer in the documentation
  4720. and/or other materials provided with the distribution.
  4721. 3. Neither the name of the University nor the names of its contributors may
  4722. be used to endorse or promote products derived from this software without
  4723. specific prior written permission.
  4724. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  4725. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  4726. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  4727. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  4728. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  4729. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  4730. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  4731. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  4732. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  4733. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  4734. =============================================================================*/
  4735. #include <stdbool.h>
  4736. #include <stdint.h>
  4737. /**** skipping file: platform.h ****/
  4738. /**** skipping file: internals.h ****/
  4739. /**** skipping file: specialize.h ****/
  4740. /**** skipping file: softfloat.h ****/
  4741. uint_fast64_t
  4742. softfloat_roundToUI64(
  4743. bool sign,
  4744. uint_fast64_t sig,
  4745. uint_fast64_t sigExtra,
  4746. uint_fast8_t roundingMode,
  4747. bool exact
  4748. )
  4749. {
  4750. /*------------------------------------------------------------------------
  4751. *------------------------------------------------------------------------*/
  4752. if (
  4753. (roundingMode == softfloat_round_near_maxMag)
  4754. || (roundingMode == softfloat_round_near_even)
  4755. ) {
  4756. if ( UINT64_C( 0x8000000000000000 ) <= sigExtra ) goto increment;
  4757. } else {
  4758. if ( sign ) {
  4759. if ( !(sig | sigExtra) ) return 0;
  4760. if ( roundingMode == softfloat_round_min ) goto invalid;
  4761. #ifdef SOFTFLOAT_ROUND_ODD
  4762. if ( roundingMode == softfloat_round_odd ) goto invalid;
  4763. #endif
  4764. } else {
  4765. if ( (roundingMode == softfloat_round_max) && sigExtra ) {
  4766. increment:
  4767. ++sig;
  4768. if ( !sig ) goto invalid;
  4769. if (
  4770. (sigExtra == UINT64_C( 0x8000000000000000 ))
  4771. && (roundingMode == softfloat_round_near_even)
  4772. ) {
  4773. sig &= ~(uint_fast64_t) 1;
  4774. }
  4775. }
  4776. }
  4777. }
  4778. if ( sign && sig ) goto invalid;
  4779. if ( sigExtra ) {
  4780. #ifdef SOFTFLOAT_ROUND_ODD
  4781. if ( roundingMode == softfloat_round_odd ) sig |= 1;
  4782. #endif
  4783. if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
  4784. }
  4785. return sig;
  4786. /*------------------------------------------------------------------------
  4787. *------------------------------------------------------------------------*/
  4788. invalid:
  4789. softfloat_raiseFlags( softfloat_flag_invalid );
  4790. return sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
  4791. }
  4792. /**** ended inlining ../../source/s_roundToUI64.c ****/
  4793. /**** start inlining ../../source/s_roundToI32.c ****/
  4794. /*============================================================================
  4795. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  4796. Package, Release 3e, by John R. Hauser.
  4797. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  4798. University of California. All rights reserved.
  4799. Redistribution and use in source and binary forms, with or without
  4800. modification, are permitted provided that the following conditions are met:
  4801. 1. Redistributions of source code must retain the above copyright notice,
  4802. this list of conditions, and the following disclaimer.
  4803. 2. Redistributions in binary form must reproduce the above copyright notice,
  4804. this list of conditions, and the following disclaimer in the documentation
  4805. and/or other materials provided with the distribution.
  4806. 3. Neither the name of the University nor the names of its contributors may
  4807. be used to endorse or promote products derived from this software without
  4808. specific prior written permission.
  4809. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  4810. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  4811. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  4812. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  4813. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  4814. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  4815. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  4816. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  4817. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  4818. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  4819. =============================================================================*/
  4820. #include <stdbool.h>
  4821. #include <stdint.h>
  4822. /**** skipping file: platform.h ****/
  4823. /**** skipping file: internals.h ****/
  4824. /**** skipping file: specialize.h ****/
  4825. /**** skipping file: softfloat.h ****/
  4826. int_fast32_t
  4827. softfloat_roundToI32(
  4828. bool sign, uint_fast64_t sig, uint_fast8_t roundingMode, bool exact )
  4829. {
  4830. uint_fast16_t roundIncrement, roundBits;
  4831. uint_fast32_t sig32;
  4832. union { uint32_t ui; int32_t i; } uZ;
  4833. int_fast32_t z;
  4834. /*------------------------------------------------------------------------
  4835. *------------------------------------------------------------------------*/
  4836. roundIncrement = 0x800;
  4837. if (
  4838. (roundingMode != softfloat_round_near_maxMag)
  4839. && (roundingMode != softfloat_round_near_even)
  4840. ) {
  4841. roundIncrement = 0;
  4842. if (
  4843. sign
  4844. ? (roundingMode == softfloat_round_min)
  4845. #ifdef SOFTFLOAT_ROUND_ODD
  4846. || (roundingMode == softfloat_round_odd)
  4847. #endif
  4848. : (roundingMode == softfloat_round_max)
  4849. ) {
  4850. roundIncrement = 0xFFF;
  4851. }
  4852. }
  4853. roundBits = sig & 0xFFF;
  4854. sig += roundIncrement;
  4855. if ( sig & UINT64_C( 0xFFFFF00000000000 ) ) goto invalid;
  4856. sig32 = sig>>12;
  4857. if (
  4858. (roundBits == 0x800) && (roundingMode == softfloat_round_near_even)
  4859. ) {
  4860. sig32 &= ~(uint_fast32_t) 1;
  4861. }
  4862. uZ.ui = sign ? -sig32 : sig32;
  4863. z = uZ.i;
  4864. if ( z && ((z < 0) ^ sign) ) goto invalid;
  4865. if ( roundBits ) {
  4866. #ifdef SOFTFLOAT_ROUND_ODD
  4867. if ( roundingMode == softfloat_round_odd ) z |= 1;
  4868. #endif
  4869. if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
  4870. }
  4871. return z;
  4872. /*------------------------------------------------------------------------
  4873. *------------------------------------------------------------------------*/
  4874. invalid:
  4875. softfloat_raiseFlags( softfloat_flag_invalid );
  4876. return sign ? i32_fromNegOverflow : i32_fromPosOverflow;
  4877. }
  4878. /**** ended inlining ../../source/s_roundToI32.c ****/
  4879. /**** start inlining ../../source/s_roundToI64.c ****/
  4880. /*============================================================================
  4881. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  4882. Package, Release 3e, by John R. Hauser.
  4883. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  4884. University of California. All rights reserved.
  4885. Redistribution and use in source and binary forms, with or without
  4886. modification, are permitted provided that the following conditions are met:
  4887. 1. Redistributions of source code must retain the above copyright notice,
  4888. this list of conditions, and the following disclaimer.
  4889. 2. Redistributions in binary form must reproduce the above copyright notice,
  4890. this list of conditions, and the following disclaimer in the documentation
  4891. and/or other materials provided with the distribution.
  4892. 3. Neither the name of the University nor the names of its contributors may
  4893. be used to endorse or promote products derived from this software without
  4894. specific prior written permission.
  4895. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  4896. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  4897. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  4898. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  4899. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  4900. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  4901. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  4902. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  4903. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  4904. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  4905. =============================================================================*/
  4906. #include <stdbool.h>
  4907. #include <stdint.h>
  4908. /**** skipping file: platform.h ****/
  4909. /**** skipping file: internals.h ****/
  4910. /**** skipping file: specialize.h ****/
  4911. /**** skipping file: softfloat.h ****/
  4912. int_fast64_t
  4913. softfloat_roundToI64(
  4914. bool sign,
  4915. uint_fast64_t sig,
  4916. uint_fast64_t sigExtra,
  4917. uint_fast8_t roundingMode,
  4918. bool exact
  4919. )
  4920. {
  4921. union { uint64_t ui; int64_t i; } uZ;
  4922. int_fast64_t z;
  4923. /*------------------------------------------------------------------------
  4924. *------------------------------------------------------------------------*/
  4925. if (
  4926. (roundingMode == softfloat_round_near_maxMag)
  4927. || (roundingMode == softfloat_round_near_even)
  4928. ) {
  4929. if ( UINT64_C( 0x8000000000000000 ) <= sigExtra ) goto increment;
  4930. } else {
  4931. if (
  4932. sigExtra
  4933. && (sign
  4934. ? (roundingMode == softfloat_round_min)
  4935. #ifdef SOFTFLOAT_ROUND_ODD
  4936. || (roundingMode == softfloat_round_odd)
  4937. #endif
  4938. : (roundingMode == softfloat_round_max))
  4939. ) {
  4940. increment:
  4941. ++sig;
  4942. if ( !sig ) goto invalid;
  4943. if (
  4944. (sigExtra == UINT64_C( 0x8000000000000000 ))
  4945. && (roundingMode == softfloat_round_near_even)
  4946. ) {
  4947. sig &= ~(uint_fast64_t) 1;
  4948. }
  4949. }
  4950. }
  4951. uZ.ui = sign ? -sig : sig;
  4952. z = uZ.i;
  4953. if ( z && ((z < 0) ^ sign) ) goto invalid;
  4954. if ( sigExtra ) {
  4955. #ifdef SOFTFLOAT_ROUND_ODD
  4956. if ( roundingMode == softfloat_round_odd ) z |= 1;
  4957. #endif
  4958. if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
  4959. }
  4960. return z;
  4961. /*------------------------------------------------------------------------
  4962. *------------------------------------------------------------------------*/
  4963. invalid:
  4964. softfloat_raiseFlags( softfloat_flag_invalid );
  4965. return sign ? i64_fromNegOverflow : i64_fromPosOverflow;
  4966. }
  4967. /**** ended inlining ../../source/s_roundToI64.c ****/
  4968. /**** start inlining ../../source/s_normSubnormalF16Sig.c ****/
  4969. /*============================================================================
  4970. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  4971. Package, Release 3e, by John R. Hauser.
  4972. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  4973. California. All rights reserved.
  4974. Redistribution and use in source and binary forms, with or without
  4975. modification, are permitted provided that the following conditions are met:
  4976. 1. Redistributions of source code must retain the above copyright notice,
  4977. this list of conditions, and the following disclaimer.
  4978. 2. Redistributions in binary form must reproduce the above copyright notice,
  4979. this list of conditions, and the following disclaimer in the documentation
  4980. and/or other materials provided with the distribution.
  4981. 3. Neither the name of the University nor the names of its contributors may
  4982. be used to endorse or promote products derived from this software without
  4983. specific prior written permission.
  4984. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  4985. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  4986. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  4987. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  4988. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  4989. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  4990. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  4991. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  4992. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  4993. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  4994. =============================================================================*/
  4995. #include <stdint.h>
  4996. /**** skipping file: platform.h ****/
  4997. /**** skipping file: internals.h ****/
  4998. struct exp8_sig16 softfloat_normSubnormalF16Sig( uint_fast16_t sig )
  4999. {
  5000. int_fast8_t shiftDist;
  5001. struct exp8_sig16 z;
  5002. shiftDist = softfloat_countLeadingZeros16( sig ) - 5;
  5003. z.exp = 1 - shiftDist;
  5004. z.sig = sig<<shiftDist;
  5005. return z;
  5006. }
  5007. /**** ended inlining ../../source/s_normSubnormalF16Sig.c ****/
  5008. /**** start inlining ../../source/s_roundPackToF16.c ****/
  5009. /*============================================================================
  5010. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  5011. Package, Release 3e, by John R. Hauser.
  5012. Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
  5013. California. All rights reserved.
  5014. Redistribution and use in source and binary forms, with or without
  5015. modification, are permitted provided that the following conditions are met:
  5016. 1. Redistributions of source code must retain the above copyright notice,
  5017. this list of conditions, and the following disclaimer.
  5018. 2. Redistributions in binary form must reproduce the above copyright notice,
  5019. this list of conditions, and the following disclaimer in the documentation
  5020. and/or other materials provided with the distribution.
  5021. 3. Neither the name of the University nor the names of its contributors may
  5022. be used to endorse or promote products derived from this software without
  5023. specific prior written permission.
  5024. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  5025. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  5026. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  5027. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  5028. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  5029. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  5030. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  5031. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  5032. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  5033. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  5034. =============================================================================*/
  5035. #include <stdbool.h>
  5036. #include <stdint.h>
  5037. /**** skipping file: platform.h ****/
  5038. /**** skipping file: internals.h ****/
  5039. /**** skipping file: softfloat.h ****/
  5040. float16_t
  5041. softfloat_roundPackToF16( bool sign, int_fast16_t exp, uint_fast16_t sig )
  5042. {
  5043. uint_fast8_t roundingMode;
  5044. bool roundNearEven;
  5045. uint_fast8_t roundIncrement, roundBits;
  5046. bool isTiny;
  5047. uint_fast16_t uiZ;
  5048. union ui16_f16 uZ;
  5049. /*------------------------------------------------------------------------
  5050. *------------------------------------------------------------------------*/
  5051. roundingMode = softfloat_roundingMode;
  5052. roundNearEven = (roundingMode == softfloat_round_near_even);
  5053. roundIncrement = 0x8;
  5054. if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
  5055. roundIncrement =
  5056. (roundingMode
  5057. == (sign ? softfloat_round_min : softfloat_round_max))
  5058. ? 0xF
  5059. : 0;
  5060. }
  5061. roundBits = sig & 0xF;
  5062. /*------------------------------------------------------------------------
  5063. *------------------------------------------------------------------------*/
  5064. if ( 0x1D <= (unsigned int) exp ) {
  5065. if ( exp < 0 ) {
  5066. /*----------------------------------------------------------------
  5067. *----------------------------------------------------------------*/
  5068. isTiny =
  5069. (softfloat_detectTininess == softfloat_tininess_beforeRounding)
  5070. || (exp < -1) || (sig + roundIncrement < 0x8000);
  5071. sig = softfloat_shiftRightJam32( sig, -exp );
  5072. exp = 0;
  5073. roundBits = sig & 0xF;
  5074. if ( isTiny && roundBits ) {
  5075. softfloat_raiseFlags( softfloat_flag_underflow );
  5076. }
  5077. } else if ( (0x1D < exp) || (0x8000 <= sig + roundIncrement) ) {
  5078. /*----------------------------------------------------------------
  5079. *----------------------------------------------------------------*/
  5080. softfloat_raiseFlags(
  5081. softfloat_flag_overflow | softfloat_flag_inexact );
  5082. uiZ = packToF16UI( sign, 0x1F, 0 ) - ! roundIncrement;
  5083. goto uiZ;
  5084. }
  5085. }
  5086. /*------------------------------------------------------------------------
  5087. *------------------------------------------------------------------------*/
  5088. sig = (sig + roundIncrement)>>4;
  5089. if ( roundBits ) {
  5090. softfloat_exceptionFlags |= softfloat_flag_inexact;
  5091. #ifdef SOFTFLOAT_ROUND_ODD
  5092. if ( roundingMode == softfloat_round_odd ) {
  5093. sig |= 1;
  5094. goto packReturn;
  5095. }
  5096. #endif
  5097. }
  5098. sig &= ~(uint_fast16_t) (! (roundBits ^ 8) & roundNearEven);
  5099. if ( ! sig ) exp = 0;
  5100. /*------------------------------------------------------------------------
  5101. *------------------------------------------------------------------------*/
  5102. packReturn:
  5103. uiZ = packToF16UI( sign, exp, sig );
  5104. uiZ:
  5105. uZ.ui = uiZ;
  5106. return uZ.f;
  5107. }
  5108. /**** ended inlining ../../source/s_roundPackToF16.c ****/
  5109. /**** start inlining ../../source/s_normRoundPackToF16.c ****/
  5110. /*============================================================================
  5111. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  5112. Package, Release 3e, by John R. Hauser.
  5113. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  5114. California. All rights reserved.
  5115. Redistribution and use in source and binary forms, with or without
  5116. modification, are permitted provided that the following conditions are met:
  5117. 1. Redistributions of source code must retain the above copyright notice,
  5118. this list of conditions, and the following disclaimer.
  5119. 2. Redistributions in binary form must reproduce the above copyright notice,
  5120. this list of conditions, and the following disclaimer in the documentation
  5121. and/or other materials provided with the distribution.
  5122. 3. Neither the name of the University nor the names of its contributors may
  5123. be used to endorse or promote products derived from this software without
  5124. specific prior written permission.
  5125. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  5126. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  5127. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  5128. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  5129. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  5130. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  5131. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  5132. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  5133. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  5134. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  5135. =============================================================================*/
  5136. #include <stdbool.h>
  5137. #include <stdint.h>
  5138. /**** skipping file: platform.h ****/
  5139. /**** skipping file: internals.h ****/
  5140. float16_t
  5141. softfloat_normRoundPackToF16( bool sign, int_fast16_t exp, uint_fast16_t sig )
  5142. {
  5143. int_fast8_t shiftDist;
  5144. union ui16_f16 uZ;
  5145. shiftDist = softfloat_countLeadingZeros16( sig ) - 1;
  5146. exp -= shiftDist;
  5147. if ( (4 <= shiftDist) && ((unsigned int) exp < 0x1D) ) {
  5148. uZ.ui = packToF16UI( sign, sig ? exp : 0, sig<<(shiftDist - 4) );
  5149. return uZ.f;
  5150. } else {
  5151. return softfloat_roundPackToF16( sign, exp, sig<<shiftDist );
  5152. }
  5153. }
  5154. /**** ended inlining ../../source/s_normRoundPackToF16.c ****/
  5155. /**** start inlining ../../source/s_addMagsF16.c ****/
  5156. /*============================================================================
  5157. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  5158. Package, Release 3e, by John R. Hauser.
  5159. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  5160. University of California. All rights reserved.
  5161. Redistribution and use in source and binary forms, with or without
  5162. modification, are permitted provided that the following conditions are met:
  5163. 1. Redistributions of source code must retain the above copyright notice,
  5164. this list of conditions, and the following disclaimer.
  5165. 2. Redistributions in binary form must reproduce the above copyright notice,
  5166. this list of conditions, and the following disclaimer in the documentation
  5167. and/or other materials provided with the distribution.
  5168. 3. Neither the name of the University nor the names of its contributors may
  5169. be used to endorse or promote products derived from this software without
  5170. specific prior written permission.
  5171. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  5172. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  5173. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  5174. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  5175. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  5176. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  5177. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  5178. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  5179. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  5180. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  5181. =============================================================================*/
  5182. #include <stdbool.h>
  5183. #include <stdint.h>
  5184. /**** skipping file: platform.h ****/
  5185. /**** skipping file: internals.h ****/
  5186. /**** skipping file: specialize.h ****/
  5187. /**** skipping file: softfloat.h ****/
  5188. float16_t softfloat_addMagsF16( uint_fast16_t uiA, uint_fast16_t uiB )
  5189. {
  5190. int_fast8_t expA;
  5191. uint_fast16_t sigA;
  5192. int_fast8_t expB;
  5193. uint_fast16_t sigB;
  5194. int_fast8_t expDiff;
  5195. uint_fast16_t uiZ;
  5196. bool signZ;
  5197. int_fast8_t expZ;
  5198. uint_fast16_t sigZ;
  5199. uint_fast16_t sigX, sigY;
  5200. int_fast8_t shiftDist;
  5201. uint_fast32_t sig32Z;
  5202. int_fast8_t roundingMode;
  5203. union ui16_f16 uZ;
  5204. /*------------------------------------------------------------------------
  5205. *------------------------------------------------------------------------*/
  5206. expA = expF16UI( uiA );
  5207. sigA = fracF16UI( uiA );
  5208. expB = expF16UI( uiB );
  5209. sigB = fracF16UI( uiB );
  5210. /*------------------------------------------------------------------------
  5211. *------------------------------------------------------------------------*/
  5212. expDiff = expA - expB;
  5213. if ( ! expDiff ) {
  5214. /*--------------------------------------------------------------------
  5215. *--------------------------------------------------------------------*/
  5216. if ( ! expA ) {
  5217. uiZ = uiA + sigB;
  5218. goto uiZ;
  5219. }
  5220. if ( expA == 0x1F ) {
  5221. if ( sigA | sigB ) goto propagateNaN;
  5222. uiZ = uiA;
  5223. goto uiZ;
  5224. }
  5225. signZ = signF16UI( uiA );
  5226. expZ = expA;
  5227. sigZ = 0x0800 + sigA + sigB;
  5228. if ( ! (sigZ & 1) && (expZ < 0x1E) ) {
  5229. sigZ >>= 1;
  5230. goto pack;
  5231. }
  5232. sigZ <<= 3;
  5233. } else {
  5234. /*--------------------------------------------------------------------
  5235. *--------------------------------------------------------------------*/
  5236. signZ = signF16UI( uiA );
  5237. if ( expDiff < 0 ) {
  5238. /*----------------------------------------------------------------
  5239. *----------------------------------------------------------------*/
  5240. if ( expB == 0x1F ) {
  5241. if ( sigB ) goto propagateNaN;
  5242. uiZ = packToF16UI( signZ, 0x1F, 0 );
  5243. goto uiZ;
  5244. }
  5245. if ( expDiff <= -13 ) {
  5246. uiZ = packToF16UI( signZ, expB, sigB );
  5247. if ( expA | sigA ) goto addEpsilon;
  5248. goto uiZ;
  5249. }
  5250. expZ = expB;
  5251. sigX = sigB | 0x0400;
  5252. sigY = sigA + (expA ? 0x0400 : sigA);
  5253. shiftDist = 19 + expDiff;
  5254. } else {
  5255. /*----------------------------------------------------------------
  5256. *----------------------------------------------------------------*/
  5257. uiZ = uiA;
  5258. if ( expA == 0x1F ) {
  5259. if ( sigA ) goto propagateNaN;
  5260. goto uiZ;
  5261. }
  5262. if ( 13 <= expDiff ) {
  5263. if ( expB | sigB ) goto addEpsilon;
  5264. goto uiZ;
  5265. }
  5266. expZ = expA;
  5267. sigX = sigA | 0x0400;
  5268. sigY = sigB + (expB ? 0x0400 : sigB);
  5269. shiftDist = 19 - expDiff;
  5270. }
  5271. sig32Z =
  5272. ((uint_fast32_t) sigX<<19) + ((uint_fast32_t) sigY<<shiftDist);
  5273. if ( sig32Z < 0x40000000 ) {
  5274. --expZ;
  5275. sig32Z <<= 1;
  5276. }
  5277. sigZ = sig32Z>>16;
  5278. if ( sig32Z & 0xFFFF ) {
  5279. sigZ |= 1;
  5280. } else {
  5281. if ( ! (sigZ & 0xF) && (expZ < 0x1E) ) {
  5282. sigZ >>= 4;
  5283. goto pack;
  5284. }
  5285. }
  5286. }
  5287. return softfloat_roundPackToF16( signZ, expZ, sigZ );
  5288. /*------------------------------------------------------------------------
  5289. *------------------------------------------------------------------------*/
  5290. propagateNaN:
  5291. uiZ = softfloat_propagateNaNF16UI( uiA, uiB );
  5292. goto uiZ;
  5293. /*------------------------------------------------------------------------
  5294. *------------------------------------------------------------------------*/
  5295. addEpsilon:
  5296. roundingMode = softfloat_roundingMode;
  5297. if ( roundingMode != softfloat_round_near_even ) {
  5298. if (
  5299. roundingMode
  5300. == (signF16UI( uiZ ) ? softfloat_round_min
  5301. : softfloat_round_max)
  5302. ) {
  5303. ++uiZ;
  5304. if ( (uint16_t) (uiZ<<1) == 0xF800 ) {
  5305. softfloat_raiseFlags(
  5306. softfloat_flag_overflow | softfloat_flag_inexact );
  5307. }
  5308. }
  5309. #ifdef SOFTFLOAT_ROUND_ODD
  5310. else if ( roundingMode == softfloat_round_odd ) {
  5311. uiZ |= 1;
  5312. }
  5313. #endif
  5314. }
  5315. softfloat_exceptionFlags |= softfloat_flag_inexact;
  5316. goto uiZ;
  5317. /*------------------------------------------------------------------------
  5318. *------------------------------------------------------------------------*/
  5319. pack:
  5320. uiZ = packToF16UI( signZ, expZ, sigZ );
  5321. uiZ:
  5322. uZ.ui = uiZ;
  5323. return uZ.f;
  5324. }
  5325. /**** ended inlining ../../source/s_addMagsF16.c ****/
  5326. /**** start inlining ../../source/s_subMagsF16.c ****/
  5327. /*============================================================================
  5328. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  5329. Package, Release 3e, by John R. Hauser.
  5330. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  5331. University of California. All rights reserved.
  5332. Redistribution and use in source and binary forms, with or without
  5333. modification, are permitted provided that the following conditions are met:
  5334. 1. Redistributions of source code must retain the above copyright notice,
  5335. this list of conditions, and the following disclaimer.
  5336. 2. Redistributions in binary form must reproduce the above copyright notice,
  5337. this list of conditions, and the following disclaimer in the documentation
  5338. and/or other materials provided with the distribution.
  5339. 3. Neither the name of the University nor the names of its contributors may
  5340. be used to endorse or promote products derived from this software without
  5341. specific prior written permission.
  5342. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  5343. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  5344. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  5345. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  5346. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  5347. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  5348. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  5349. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  5350. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  5351. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  5352. =============================================================================*/
  5353. #include <stdbool.h>
  5354. #include <stdint.h>
  5355. /**** skipping file: platform.h ****/
  5356. /**** skipping file: internals.h ****/
  5357. /**** skipping file: specialize.h ****/
  5358. /**** skipping file: softfloat.h ****/
  5359. float16_t softfloat_subMagsF16( uint_fast16_t uiA, uint_fast16_t uiB )
  5360. {
  5361. int_fast8_t expA;
  5362. uint_fast16_t sigA;
  5363. int_fast8_t expB;
  5364. uint_fast16_t sigB;
  5365. int_fast8_t expDiff;
  5366. uint_fast16_t uiZ;
  5367. int_fast16_t sigDiff;
  5368. bool signZ;
  5369. int_fast8_t shiftDist, expZ;
  5370. uint_fast16_t sigZ, sigX, sigY;
  5371. uint_fast32_t sig32Z;
  5372. int_fast8_t roundingMode;
  5373. union ui16_f16 uZ;
  5374. /*------------------------------------------------------------------------
  5375. *------------------------------------------------------------------------*/
  5376. expA = expF16UI( uiA );
  5377. sigA = fracF16UI( uiA );
  5378. expB = expF16UI( uiB );
  5379. sigB = fracF16UI( uiB );
  5380. /*------------------------------------------------------------------------
  5381. *------------------------------------------------------------------------*/
  5382. expDiff = expA - expB;
  5383. if ( ! expDiff ) {
  5384. /*--------------------------------------------------------------------
  5385. *--------------------------------------------------------------------*/
  5386. if ( expA == 0x1F ) {
  5387. if ( sigA | sigB ) goto propagateNaN;
  5388. softfloat_raiseFlags( softfloat_flag_invalid );
  5389. uiZ = defaultNaNF16UI;
  5390. goto uiZ;
  5391. }
  5392. sigDiff = sigA - sigB;
  5393. if ( ! sigDiff ) {
  5394. uiZ =
  5395. packToF16UI(
  5396. (softfloat_roundingMode == softfloat_round_min), 0, 0 );
  5397. goto uiZ;
  5398. }
  5399. if ( expA ) --expA;
  5400. signZ = signF16UI( uiA );
  5401. if ( sigDiff < 0 ) {
  5402. signZ = ! signZ;
  5403. sigDiff = -sigDiff;
  5404. }
  5405. shiftDist = softfloat_countLeadingZeros16( sigDiff ) - 5;
  5406. expZ = expA - shiftDist;
  5407. if ( expZ < 0 ) {
  5408. shiftDist = expA;
  5409. expZ = 0;
  5410. }
  5411. sigZ = sigDiff<<shiftDist;
  5412. goto pack;
  5413. } else {
  5414. /*--------------------------------------------------------------------
  5415. *--------------------------------------------------------------------*/
  5416. signZ = signF16UI( uiA );
  5417. if ( expDiff < 0 ) {
  5418. /*----------------------------------------------------------------
  5419. *----------------------------------------------------------------*/
  5420. signZ = ! signZ;
  5421. if ( expB == 0x1F ) {
  5422. if ( sigB ) goto propagateNaN;
  5423. uiZ = packToF16UI( signZ, 0x1F, 0 );
  5424. goto uiZ;
  5425. }
  5426. if ( expDiff <= -13 ) {
  5427. uiZ = packToF16UI( signZ, expB, sigB );
  5428. if ( expA | sigA ) goto subEpsilon;
  5429. goto uiZ;
  5430. }
  5431. expZ = expA + 19;
  5432. sigX = sigB | 0x0400;
  5433. sigY = sigA + (expA ? 0x0400 : sigA);
  5434. expDiff = -expDiff;
  5435. } else {
  5436. /*----------------------------------------------------------------
  5437. *----------------------------------------------------------------*/
  5438. uiZ = uiA;
  5439. if ( expA == 0x1F ) {
  5440. if ( sigA ) goto propagateNaN;
  5441. goto uiZ;
  5442. }
  5443. if ( 13 <= expDiff ) {
  5444. if ( expB | sigB ) goto subEpsilon;
  5445. goto uiZ;
  5446. }
  5447. expZ = expB + 19;
  5448. sigX = sigA | 0x0400;
  5449. sigY = sigB + (expB ? 0x0400 : sigB);
  5450. }
  5451. sig32Z = ((uint_fast32_t) sigX<<expDiff) - sigY;
  5452. shiftDist = softfloat_countLeadingZeros32( sig32Z ) - 1;
  5453. sig32Z <<= shiftDist;
  5454. expZ -= shiftDist;
  5455. sigZ = sig32Z>>16;
  5456. if ( sig32Z & 0xFFFF ) {
  5457. sigZ |= 1;
  5458. } else {
  5459. if ( ! (sigZ & 0xF) && ((unsigned int) expZ < 0x1E) ) {
  5460. sigZ >>= 4;
  5461. goto pack;
  5462. }
  5463. }
  5464. return softfloat_roundPackToF16( signZ, expZ, sigZ );
  5465. }
  5466. /*------------------------------------------------------------------------
  5467. *------------------------------------------------------------------------*/
  5468. propagateNaN:
  5469. uiZ = softfloat_propagateNaNF16UI( uiA, uiB );
  5470. goto uiZ;
  5471. /*------------------------------------------------------------------------
  5472. *------------------------------------------------------------------------*/
  5473. subEpsilon:
  5474. roundingMode = softfloat_roundingMode;
  5475. if ( roundingMode != softfloat_round_near_even ) {
  5476. if (
  5477. (roundingMode == softfloat_round_minMag)
  5478. || (roundingMode
  5479. == (signF16UI( uiZ ) ? softfloat_round_max
  5480. : softfloat_round_min))
  5481. ) {
  5482. --uiZ;
  5483. }
  5484. #ifdef SOFTFLOAT_ROUND_ODD
  5485. else if ( roundingMode == softfloat_round_odd ) {
  5486. uiZ = (uiZ - 1) | 1;
  5487. }
  5488. #endif
  5489. }
  5490. softfloat_exceptionFlags |= softfloat_flag_inexact;
  5491. goto uiZ;
  5492. /*------------------------------------------------------------------------
  5493. *------------------------------------------------------------------------*/
  5494. pack:
  5495. uiZ = packToF16UI( signZ, expZ, sigZ );
  5496. uiZ:
  5497. uZ.ui = uiZ;
  5498. return uZ.f;
  5499. }
  5500. /**** ended inlining ../../source/s_subMagsF16.c ****/
  5501. /**** start inlining ../../source/s_mulAddF16.c ****/
  5502. /*============================================================================
  5503. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  5504. Package, Release 3e, by John R. Hauser.
  5505. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  5506. California. All rights reserved.
  5507. Redistribution and use in source and binary forms, with or without
  5508. modification, are permitted provided that the following conditions are met:
  5509. 1. Redistributions of source code must retain the above copyright notice,
  5510. this list of conditions, and the following disclaimer.
  5511. 2. Redistributions in binary form must reproduce the above copyright notice,
  5512. this list of conditions, and the following disclaimer in the documentation
  5513. and/or other materials provided with the distribution.
  5514. 3. Neither the name of the University nor the names of its contributors may
  5515. be used to endorse or promote products derived from this software without
  5516. specific prior written permission.
  5517. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  5518. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  5519. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  5520. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  5521. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  5522. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  5523. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  5524. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  5525. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  5526. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  5527. =============================================================================*/
  5528. #include <stdbool.h>
  5529. #include <stdint.h>
  5530. /**** skipping file: platform.h ****/
  5531. /**** skipping file: internals.h ****/
  5532. /**** skipping file: specialize.h ****/
  5533. /**** skipping file: softfloat.h ****/
  5534. float16_t
  5535. softfloat_mulAddF16(
  5536. uint_fast16_t uiA, uint_fast16_t uiB, uint_fast16_t uiC, uint_fast8_t op )
  5537. {
  5538. bool signA;
  5539. int_fast8_t expA;
  5540. uint_fast16_t sigA;
  5541. bool signB;
  5542. int_fast8_t expB;
  5543. uint_fast16_t sigB;
  5544. bool signC;
  5545. int_fast8_t expC;
  5546. uint_fast16_t sigC;
  5547. bool signProd;
  5548. uint_fast16_t magBits, uiZ;
  5549. struct exp8_sig16 normExpSig;
  5550. int_fast8_t expProd;
  5551. uint_fast32_t sigProd;
  5552. bool signZ;
  5553. int_fast8_t expZ;
  5554. uint_fast16_t sigZ;
  5555. int_fast8_t expDiff;
  5556. uint_fast32_t sig32Z, sig32C;
  5557. int_fast8_t shiftDist;
  5558. union ui16_f16 uZ;
  5559. /*------------------------------------------------------------------------
  5560. *------------------------------------------------------------------------*/
  5561. signA = signF16UI( uiA );
  5562. expA = expF16UI( uiA );
  5563. sigA = fracF16UI( uiA );
  5564. signB = signF16UI( uiB );
  5565. expB = expF16UI( uiB );
  5566. sigB = fracF16UI( uiB );
  5567. signC = signF16UI( uiC ) ^ (op == softfloat_mulAdd_subC);
  5568. expC = expF16UI( uiC );
  5569. sigC = fracF16UI( uiC );
  5570. signProd = signA ^ signB ^ (op == softfloat_mulAdd_subProd);
  5571. /*------------------------------------------------------------------------
  5572. *------------------------------------------------------------------------*/
  5573. if ( expA == 0x1F ) {
  5574. if ( sigA || ((expB == 0x1F) && sigB) ) goto propagateNaN_ABC;
  5575. magBits = expB | sigB;
  5576. goto infProdArg;
  5577. }
  5578. if ( expB == 0x1F ) {
  5579. if ( sigB ) goto propagateNaN_ABC;
  5580. magBits = expA | sigA;
  5581. goto infProdArg;
  5582. }
  5583. if ( expC == 0x1F ) {
  5584. if ( sigC ) {
  5585. uiZ = 0;
  5586. goto propagateNaN_ZC;
  5587. }
  5588. uiZ = uiC;
  5589. goto uiZ;
  5590. }
  5591. /*------------------------------------------------------------------------
  5592. *------------------------------------------------------------------------*/
  5593. if ( ! expA ) {
  5594. if ( ! sigA ) goto zeroProd;
  5595. normExpSig = softfloat_normSubnormalF16Sig( sigA );
  5596. expA = normExpSig.exp;
  5597. sigA = normExpSig.sig;
  5598. }
  5599. if ( ! expB ) {
  5600. if ( ! sigB ) goto zeroProd;
  5601. normExpSig = softfloat_normSubnormalF16Sig( sigB );
  5602. expB = normExpSig.exp;
  5603. sigB = normExpSig.sig;
  5604. }
  5605. /*------------------------------------------------------------------------
  5606. *------------------------------------------------------------------------*/
  5607. expProd = expA + expB - 0xE;
  5608. sigA = (sigA | 0x0400)<<4;
  5609. sigB = (sigB | 0x0400)<<4;
  5610. sigProd = (uint_fast32_t) sigA * sigB;
  5611. if ( sigProd < 0x20000000 ) {
  5612. --expProd;
  5613. sigProd <<= 1;
  5614. }
  5615. signZ = signProd;
  5616. if ( ! expC ) {
  5617. if ( ! sigC ) {
  5618. expZ = expProd - 1;
  5619. sigZ = sigProd>>15 | ((sigProd & 0x7FFF) != 0);
  5620. goto roundPack;
  5621. }
  5622. normExpSig = softfloat_normSubnormalF16Sig( sigC );
  5623. expC = normExpSig.exp;
  5624. sigC = normExpSig.sig;
  5625. }
  5626. sigC = (sigC | 0x0400)<<3;
  5627. /*------------------------------------------------------------------------
  5628. *------------------------------------------------------------------------*/
  5629. expDiff = expProd - expC;
  5630. if ( signProd == signC ) {
  5631. /*--------------------------------------------------------------------
  5632. *--------------------------------------------------------------------*/
  5633. if ( expDiff <= 0 ) {
  5634. expZ = expC;
  5635. sigZ = sigC + softfloat_shiftRightJam32( sigProd, 16 - expDiff );
  5636. } else {
  5637. expZ = expProd;
  5638. sig32Z =
  5639. sigProd
  5640. + softfloat_shiftRightJam32(
  5641. (uint_fast32_t) sigC<<16, expDiff );
  5642. sigZ = sig32Z>>16 | ((sig32Z & 0xFFFF) != 0 );
  5643. }
  5644. if ( sigZ < 0x4000 ) {
  5645. --expZ;
  5646. sigZ <<= 1;
  5647. }
  5648. } else {
  5649. /*--------------------------------------------------------------------
  5650. *--------------------------------------------------------------------*/
  5651. sig32C = (uint_fast32_t) sigC<<16;
  5652. if ( expDiff < 0 ) {
  5653. signZ = signC;
  5654. expZ = expC;
  5655. sig32Z = sig32C - softfloat_shiftRightJam32( sigProd, -expDiff );
  5656. } else if ( ! expDiff ) {
  5657. expZ = expProd;
  5658. sig32Z = sigProd - sig32C;
  5659. if ( ! sig32Z ) goto completeCancellation;
  5660. if ( sig32Z & 0x80000000 ) {
  5661. signZ = ! signZ;
  5662. sig32Z = -sig32Z;
  5663. }
  5664. } else {
  5665. expZ = expProd;
  5666. sig32Z = sigProd - softfloat_shiftRightJam32( sig32C, expDiff );
  5667. }
  5668. shiftDist = softfloat_countLeadingZeros32( sig32Z ) - 1;
  5669. expZ -= shiftDist;
  5670. shiftDist -= 16;
  5671. if ( shiftDist < 0 ) {
  5672. sigZ =
  5673. sig32Z>>(-shiftDist)
  5674. | ((uint32_t) (sig32Z<<(shiftDist & 31)) != 0);
  5675. } else {
  5676. sigZ = (uint_fast16_t) sig32Z<<shiftDist;
  5677. }
  5678. }
  5679. roundPack:
  5680. return softfloat_roundPackToF16( signZ, expZ, sigZ );
  5681. /*------------------------------------------------------------------------
  5682. *------------------------------------------------------------------------*/
  5683. propagateNaN_ABC:
  5684. uiZ = softfloat_propagateNaNF16UI( uiA, uiB );
  5685. goto propagateNaN_ZC;
  5686. /*------------------------------------------------------------------------
  5687. *------------------------------------------------------------------------*/
  5688. infProdArg:
  5689. if ( magBits ) {
  5690. uiZ = packToF16UI( signProd, 0x1F, 0 );
  5691. if ( expC != 0x1F ) goto uiZ;
  5692. if ( sigC ) goto propagateNaN_ZC;
  5693. if ( signProd == signC ) goto uiZ;
  5694. }
  5695. softfloat_raiseFlags( softfloat_flag_invalid );
  5696. uiZ = defaultNaNF16UI;
  5697. propagateNaN_ZC:
  5698. uiZ = softfloat_propagateNaNF16UI( uiZ, uiC );
  5699. goto uiZ;
  5700. /*------------------------------------------------------------------------
  5701. *------------------------------------------------------------------------*/
  5702. zeroProd:
  5703. uiZ = uiC;
  5704. if ( ! (expC | sigC) && (signProd != signC) ) {
  5705. completeCancellation:
  5706. uiZ =
  5707. packToF16UI(
  5708. (softfloat_roundingMode == softfloat_round_min), 0, 0 );
  5709. }
  5710. uiZ:
  5711. uZ.ui = uiZ;
  5712. return uZ.f;
  5713. }
  5714. /**** ended inlining ../../source/s_mulAddF16.c ****/
  5715. /**** start inlining ../../source/s_normSubnormalF32Sig.c ****/
  5716. /*============================================================================
  5717. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  5718. Package, Release 3e, by John R. Hauser.
  5719. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  5720. California. All rights reserved.
  5721. Redistribution and use in source and binary forms, with or without
  5722. modification, are permitted provided that the following conditions are met:
  5723. 1. Redistributions of source code must retain the above copyright notice,
  5724. this list of conditions, and the following disclaimer.
  5725. 2. Redistributions in binary form must reproduce the above copyright notice,
  5726. this list of conditions, and the following disclaimer in the documentation
  5727. and/or other materials provided with the distribution.
  5728. 3. Neither the name of the University nor the names of its contributors may
  5729. be used to endorse or promote products derived from this software without
  5730. specific prior written permission.
  5731. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  5732. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  5733. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  5734. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  5735. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  5736. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  5737. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  5738. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  5739. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  5740. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  5741. =============================================================================*/
  5742. #include <stdint.h>
  5743. /**** skipping file: platform.h ****/
  5744. /**** skipping file: internals.h ****/
  5745. struct exp16_sig32 softfloat_normSubnormalF32Sig( uint_fast32_t sig )
  5746. {
  5747. int_fast8_t shiftDist;
  5748. struct exp16_sig32 z;
  5749. shiftDist = softfloat_countLeadingZeros32( sig ) - 8;
  5750. z.exp = 1 - shiftDist;
  5751. z.sig = sig<<shiftDist;
  5752. return z;
  5753. }
  5754. /**** ended inlining ../../source/s_normSubnormalF32Sig.c ****/
  5755. /**** start inlining ../../source/s_roundPackToF32.c ****/
  5756. /*============================================================================
  5757. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  5758. Package, Release 3e, by John R. Hauser.
  5759. Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
  5760. California. All rights reserved.
  5761. Redistribution and use in source and binary forms, with or without
  5762. modification, are permitted provided that the following conditions are met:
  5763. 1. Redistributions of source code must retain the above copyright notice,
  5764. this list of conditions, and the following disclaimer.
  5765. 2. Redistributions in binary form must reproduce the above copyright notice,
  5766. this list of conditions, and the following disclaimer in the documentation
  5767. and/or other materials provided with the distribution.
  5768. 3. Neither the name of the University nor the names of its contributors may
  5769. be used to endorse or promote products derived from this software without
  5770. specific prior written permission.
  5771. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  5772. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  5773. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  5774. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  5775. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  5776. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  5777. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  5778. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  5779. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  5780. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  5781. =============================================================================*/
  5782. #include <stdbool.h>
  5783. #include <stdint.h>
  5784. /**** skipping file: platform.h ****/
  5785. /**** skipping file: internals.h ****/
  5786. /**** skipping file: softfloat.h ****/
  5787. float32_t
  5788. softfloat_roundPackToF32( bool sign, int_fast16_t exp, uint_fast32_t sig )
  5789. {
  5790. uint_fast8_t roundingMode;
  5791. bool roundNearEven;
  5792. uint_fast8_t roundIncrement, roundBits;
  5793. bool isTiny;
  5794. uint_fast32_t uiZ;
  5795. union ui32_f32 uZ;
  5796. /*------------------------------------------------------------------------
  5797. *------------------------------------------------------------------------*/
  5798. roundingMode = softfloat_roundingMode;
  5799. roundNearEven = (roundingMode == softfloat_round_near_even);
  5800. roundIncrement = 0x40;
  5801. if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
  5802. roundIncrement =
  5803. (roundingMode
  5804. == (sign ? softfloat_round_min : softfloat_round_max))
  5805. ? 0x7F
  5806. : 0;
  5807. }
  5808. roundBits = sig & 0x7F;
  5809. /*------------------------------------------------------------------------
  5810. *------------------------------------------------------------------------*/
  5811. if ( 0xFD <= (unsigned int) exp ) {
  5812. if ( exp < 0 ) {
  5813. /*----------------------------------------------------------------
  5814. *----------------------------------------------------------------*/
  5815. isTiny =
  5816. (softfloat_detectTininess == softfloat_tininess_beforeRounding)
  5817. || (exp < -1) || (sig + roundIncrement < 0x80000000);
  5818. sig = softfloat_shiftRightJam32( sig, -exp );
  5819. exp = 0;
  5820. roundBits = sig & 0x7F;
  5821. if ( isTiny && roundBits ) {
  5822. softfloat_raiseFlags( softfloat_flag_underflow );
  5823. }
  5824. } else if ( (0xFD < exp) || (0x80000000 <= sig + roundIncrement) ) {
  5825. /*----------------------------------------------------------------
  5826. *----------------------------------------------------------------*/
  5827. softfloat_raiseFlags(
  5828. softfloat_flag_overflow | softfloat_flag_inexact );
  5829. uiZ = packToF32UI( sign, 0xFF, 0 ) - ! roundIncrement;
  5830. goto uiZ;
  5831. }
  5832. }
  5833. /*------------------------------------------------------------------------
  5834. *------------------------------------------------------------------------*/
  5835. sig = (sig + roundIncrement)>>7;
  5836. if ( roundBits ) {
  5837. softfloat_exceptionFlags |= softfloat_flag_inexact;
  5838. #ifdef SOFTFLOAT_ROUND_ODD
  5839. if ( roundingMode == softfloat_round_odd ) {
  5840. sig |= 1;
  5841. goto packReturn;
  5842. }
  5843. #endif
  5844. }
  5845. sig &= ~(uint_fast32_t) (! (roundBits ^ 0x40) & roundNearEven);
  5846. if ( ! sig ) exp = 0;
  5847. /*------------------------------------------------------------------------
  5848. *------------------------------------------------------------------------*/
  5849. packReturn:
  5850. uiZ = packToF32UI( sign, exp, sig );
  5851. uiZ:
  5852. uZ.ui = uiZ;
  5853. return uZ.f;
  5854. }
  5855. /**** ended inlining ../../source/s_roundPackToF32.c ****/
  5856. /**** start inlining ../../source/s_normRoundPackToF32.c ****/
  5857. /*============================================================================
  5858. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  5859. Package, Release 3e, by John R. Hauser.
  5860. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  5861. California. All rights reserved.
  5862. Redistribution and use in source and binary forms, with or without
  5863. modification, are permitted provided that the following conditions are met:
  5864. 1. Redistributions of source code must retain the above copyright notice,
  5865. this list of conditions, and the following disclaimer.
  5866. 2. Redistributions in binary form must reproduce the above copyright notice,
  5867. this list of conditions, and the following disclaimer in the documentation
  5868. and/or other materials provided with the distribution.
  5869. 3. Neither the name of the University nor the names of its contributors may
  5870. be used to endorse or promote products derived from this software without
  5871. specific prior written permission.
  5872. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  5873. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  5874. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  5875. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  5876. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  5877. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  5878. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  5879. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  5880. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  5881. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  5882. =============================================================================*/
  5883. #include <stdbool.h>
  5884. #include <stdint.h>
  5885. /**** skipping file: platform.h ****/
  5886. /**** skipping file: internals.h ****/
  5887. float32_t
  5888. softfloat_normRoundPackToF32( bool sign, int_fast16_t exp, uint_fast32_t sig )
  5889. {
  5890. int_fast8_t shiftDist;
  5891. union ui32_f32 uZ;
  5892. shiftDist = softfloat_countLeadingZeros32( sig ) - 1;
  5893. exp -= shiftDist;
  5894. if ( (7 <= shiftDist) && ((unsigned int) exp < 0xFD) ) {
  5895. uZ.ui = packToF32UI( sign, sig ? exp : 0, sig<<(shiftDist - 7) );
  5896. return uZ.f;
  5897. } else {
  5898. return softfloat_roundPackToF32( sign, exp, sig<<shiftDist );
  5899. }
  5900. }
  5901. /**** ended inlining ../../source/s_normRoundPackToF32.c ****/
  5902. /**** start inlining ../../source/s_addMagsF32.c ****/
  5903. /*============================================================================
  5904. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  5905. Package, Release 3e, by John R. Hauser.
  5906. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  5907. California. All rights reserved.
  5908. Redistribution and use in source and binary forms, with or without
  5909. modification, are permitted provided that the following conditions are met:
  5910. 1. Redistributions of source code must retain the above copyright notice,
  5911. this list of conditions, and the following disclaimer.
  5912. 2. Redistributions in binary form must reproduce the above copyright notice,
  5913. this list of conditions, and the following disclaimer in the documentation
  5914. and/or other materials provided with the distribution.
  5915. 3. Neither the name of the University nor the names of its contributors may
  5916. be used to endorse or promote products derived from this software without
  5917. specific prior written permission.
  5918. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  5919. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  5920. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  5921. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  5922. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  5923. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  5924. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  5925. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  5926. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  5927. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  5928. =============================================================================*/
  5929. #include <stdbool.h>
  5930. #include <stdint.h>
  5931. /**** skipping file: platform.h ****/
  5932. /**** skipping file: internals.h ****/
  5933. /**** skipping file: specialize.h ****/
  5934. float32_t softfloat_addMagsF32( uint_fast32_t uiA, uint_fast32_t uiB )
  5935. {
  5936. int_fast16_t expA;
  5937. uint_fast32_t sigA;
  5938. int_fast16_t expB;
  5939. uint_fast32_t sigB;
  5940. int_fast16_t expDiff;
  5941. uint_fast32_t uiZ;
  5942. bool signZ;
  5943. int_fast16_t expZ;
  5944. uint_fast32_t sigZ;
  5945. union ui32_f32 uZ;
  5946. /*------------------------------------------------------------------------
  5947. *------------------------------------------------------------------------*/
  5948. expA = expF32UI( uiA );
  5949. sigA = fracF32UI( uiA );
  5950. expB = expF32UI( uiB );
  5951. sigB = fracF32UI( uiB );
  5952. /*------------------------------------------------------------------------
  5953. *------------------------------------------------------------------------*/
  5954. expDiff = expA - expB;
  5955. if ( ! expDiff ) {
  5956. /*--------------------------------------------------------------------
  5957. *--------------------------------------------------------------------*/
  5958. if ( ! expA ) {
  5959. uiZ = uiA + sigB;
  5960. goto uiZ;
  5961. }
  5962. if ( expA == 0xFF ) {
  5963. if ( sigA | sigB ) goto propagateNaN;
  5964. uiZ = uiA;
  5965. goto uiZ;
  5966. }
  5967. signZ = signF32UI( uiA );
  5968. expZ = expA;
  5969. sigZ = 0x01000000 + sigA + sigB;
  5970. if ( ! (sigZ & 1) && (expZ < 0xFE) ) {
  5971. uiZ = packToF32UI( signZ, expZ, sigZ>>1 );
  5972. goto uiZ;
  5973. }
  5974. sigZ <<= 6;
  5975. } else {
  5976. /*--------------------------------------------------------------------
  5977. *--------------------------------------------------------------------*/
  5978. signZ = signF32UI( uiA );
  5979. sigA <<= 6;
  5980. sigB <<= 6;
  5981. if ( expDiff < 0 ) {
  5982. if ( expB == 0xFF ) {
  5983. if ( sigB ) goto propagateNaN;
  5984. uiZ = packToF32UI( signZ, 0xFF, 0 );
  5985. goto uiZ;
  5986. }
  5987. expZ = expB;
  5988. sigA += expA ? 0x20000000 : sigA;
  5989. sigA = softfloat_shiftRightJam32( sigA, -expDiff );
  5990. } else {
  5991. if ( expA == 0xFF ) {
  5992. if ( sigA ) goto propagateNaN;
  5993. uiZ = uiA;
  5994. goto uiZ;
  5995. }
  5996. expZ = expA;
  5997. sigB += expB ? 0x20000000 : sigB;
  5998. sigB = softfloat_shiftRightJam32( sigB, expDiff );
  5999. }
  6000. sigZ = 0x20000000 + sigA + sigB;
  6001. if ( sigZ < 0x40000000 ) {
  6002. --expZ;
  6003. sigZ <<= 1;
  6004. }
  6005. }
  6006. return softfloat_roundPackToF32( signZ, expZ, sigZ );
  6007. /*------------------------------------------------------------------------
  6008. *------------------------------------------------------------------------*/
  6009. propagateNaN:
  6010. uiZ = softfloat_propagateNaNF32UI( uiA, uiB );
  6011. uiZ:
  6012. uZ.ui = uiZ;
  6013. return uZ.f;
  6014. }
  6015. /**** ended inlining ../../source/s_addMagsF32.c ****/
  6016. /**** start inlining ../../source/s_subMagsF32.c ****/
  6017. /*============================================================================
  6018. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  6019. Package, Release 3e, by John R. Hauser.
  6020. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  6021. California. All rights reserved.
  6022. Redistribution and use in source and binary forms, with or without
  6023. modification, are permitted provided that the following conditions are met:
  6024. 1. Redistributions of source code must retain the above copyright notice,
  6025. this list of conditions, and the following disclaimer.
  6026. 2. Redistributions in binary form must reproduce the above copyright notice,
  6027. this list of conditions, and the following disclaimer in the documentation
  6028. and/or other materials provided with the distribution.
  6029. 3. Neither the name of the University nor the names of its contributors may
  6030. be used to endorse or promote products derived from this software without
  6031. specific prior written permission.
  6032. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  6033. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  6034. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  6035. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  6036. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  6037. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  6038. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  6039. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  6040. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  6041. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  6042. =============================================================================*/
  6043. #include <stdbool.h>
  6044. #include <stdint.h>
  6045. /**** skipping file: platform.h ****/
  6046. /**** skipping file: internals.h ****/
  6047. /**** skipping file: specialize.h ****/
  6048. /**** skipping file: softfloat.h ****/
  6049. float32_t softfloat_subMagsF32( uint_fast32_t uiA, uint_fast32_t uiB )
  6050. {
  6051. int_fast16_t expA;
  6052. uint_fast32_t sigA;
  6053. int_fast16_t expB;
  6054. uint_fast32_t sigB;
  6055. int_fast16_t expDiff;
  6056. uint_fast32_t uiZ;
  6057. int_fast32_t sigDiff;
  6058. bool signZ;
  6059. int_fast8_t shiftDist;
  6060. int_fast16_t expZ;
  6061. uint_fast32_t sigX, sigY;
  6062. union ui32_f32 uZ;
  6063. /*------------------------------------------------------------------------
  6064. *------------------------------------------------------------------------*/
  6065. expA = expF32UI( uiA );
  6066. sigA = fracF32UI( uiA );
  6067. expB = expF32UI( uiB );
  6068. sigB = fracF32UI( uiB );
  6069. /*------------------------------------------------------------------------
  6070. *------------------------------------------------------------------------*/
  6071. expDiff = expA - expB;
  6072. if ( ! expDiff ) {
  6073. /*--------------------------------------------------------------------
  6074. *--------------------------------------------------------------------*/
  6075. if ( expA == 0xFF ) {
  6076. if ( sigA | sigB ) goto propagateNaN;
  6077. softfloat_raiseFlags( softfloat_flag_invalid );
  6078. uiZ = defaultNaNF32UI;
  6079. goto uiZ;
  6080. }
  6081. sigDiff = sigA - sigB;
  6082. if ( ! sigDiff ) {
  6083. uiZ =
  6084. packToF32UI(
  6085. (softfloat_roundingMode == softfloat_round_min), 0, 0 );
  6086. goto uiZ;
  6087. }
  6088. if ( expA ) --expA;
  6089. signZ = signF32UI( uiA );
  6090. if ( sigDiff < 0 ) {
  6091. signZ = ! signZ;
  6092. sigDiff = -sigDiff;
  6093. }
  6094. shiftDist = softfloat_countLeadingZeros32( sigDiff ) - 8;
  6095. expZ = expA - shiftDist;
  6096. if ( expZ < 0 ) {
  6097. shiftDist = expA;
  6098. expZ = 0;
  6099. }
  6100. uiZ = packToF32UI( signZ, expZ, sigDiff<<shiftDist );
  6101. goto uiZ;
  6102. } else {
  6103. /*--------------------------------------------------------------------
  6104. *--------------------------------------------------------------------*/
  6105. signZ = signF32UI( uiA );
  6106. sigA <<= 7;
  6107. sigB <<= 7;
  6108. if ( expDiff < 0 ) {
  6109. /*----------------------------------------------------------------
  6110. *----------------------------------------------------------------*/
  6111. signZ = ! signZ;
  6112. if ( expB == 0xFF ) {
  6113. if ( sigB ) goto propagateNaN;
  6114. uiZ = packToF32UI( signZ, 0xFF, 0 );
  6115. goto uiZ;
  6116. }
  6117. expZ = expB - 1;
  6118. sigX = sigB | 0x40000000;
  6119. sigY = sigA + (expA ? 0x40000000 : sigA);
  6120. expDiff = -expDiff;
  6121. } else {
  6122. /*----------------------------------------------------------------
  6123. *----------------------------------------------------------------*/
  6124. if ( expA == 0xFF ) {
  6125. if ( sigA ) goto propagateNaN;
  6126. uiZ = uiA;
  6127. goto uiZ;
  6128. }
  6129. expZ = expA - 1;
  6130. sigX = sigA | 0x40000000;
  6131. sigY = sigB + (expB ? 0x40000000 : sigB);
  6132. }
  6133. return
  6134. softfloat_normRoundPackToF32(
  6135. signZ, expZ, sigX - softfloat_shiftRightJam32( sigY, expDiff )
  6136. );
  6137. }
  6138. /*------------------------------------------------------------------------
  6139. *------------------------------------------------------------------------*/
  6140. propagateNaN:
  6141. uiZ = softfloat_propagateNaNF32UI( uiA, uiB );
  6142. uiZ:
  6143. uZ.ui = uiZ;
  6144. return uZ.f;
  6145. }
  6146. /**** ended inlining ../../source/s_subMagsF32.c ****/
  6147. /**** start inlining ../../source/s_mulAddF32.c ****/
  6148. /*============================================================================
  6149. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  6150. Package, Release 3e, by John R. Hauser.
  6151. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  6152. California. All rights reserved.
  6153. Redistribution and use in source and binary forms, with or without
  6154. modification, are permitted provided that the following conditions are met:
  6155. 1. Redistributions of source code must retain the above copyright notice,
  6156. this list of conditions, and the following disclaimer.
  6157. 2. Redistributions in binary form must reproduce the above copyright notice,
  6158. this list of conditions, and the following disclaimer in the documentation
  6159. and/or other materials provided with the distribution.
  6160. 3. Neither the name of the University nor the names of its contributors may
  6161. be used to endorse or promote products derived from this software without
  6162. specific prior written permission.
  6163. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  6164. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  6165. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  6166. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  6167. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  6168. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  6169. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  6170. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  6171. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  6172. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  6173. =============================================================================*/
  6174. #include <stdbool.h>
  6175. #include <stdint.h>
  6176. /**** skipping file: platform.h ****/
  6177. /**** skipping file: internals.h ****/
  6178. /**** skipping file: specialize.h ****/
  6179. /**** skipping file: softfloat.h ****/
  6180. float32_t
  6181. softfloat_mulAddF32(
  6182. uint_fast32_t uiA, uint_fast32_t uiB, uint_fast32_t uiC, uint_fast8_t op )
  6183. {
  6184. bool signA;
  6185. int_fast16_t expA;
  6186. uint_fast32_t sigA;
  6187. bool signB;
  6188. int_fast16_t expB;
  6189. uint_fast32_t sigB;
  6190. bool signC;
  6191. int_fast16_t expC;
  6192. uint_fast32_t sigC;
  6193. bool signProd;
  6194. uint_fast32_t magBits, uiZ;
  6195. struct exp16_sig32 normExpSig;
  6196. int_fast16_t expProd;
  6197. uint_fast64_t sigProd;
  6198. bool signZ;
  6199. int_fast16_t expZ;
  6200. uint_fast32_t sigZ;
  6201. int_fast16_t expDiff;
  6202. uint_fast64_t sig64Z, sig64C;
  6203. int_fast8_t shiftDist;
  6204. union ui32_f32 uZ;
  6205. /*------------------------------------------------------------------------
  6206. *------------------------------------------------------------------------*/
  6207. signA = signF32UI( uiA );
  6208. expA = expF32UI( uiA );
  6209. sigA = fracF32UI( uiA );
  6210. signB = signF32UI( uiB );
  6211. expB = expF32UI( uiB );
  6212. sigB = fracF32UI( uiB );
  6213. signC = signF32UI( uiC ) ^ (op == softfloat_mulAdd_subC);
  6214. expC = expF32UI( uiC );
  6215. sigC = fracF32UI( uiC );
  6216. signProd = signA ^ signB ^ (op == softfloat_mulAdd_subProd);
  6217. /*------------------------------------------------------------------------
  6218. *------------------------------------------------------------------------*/
  6219. if ( expA == 0xFF ) {
  6220. if ( sigA || ((expB == 0xFF) && sigB) ) goto propagateNaN_ABC;
  6221. magBits = expB | sigB;
  6222. goto infProdArg;
  6223. }
  6224. if ( expB == 0xFF ) {
  6225. if ( sigB ) goto propagateNaN_ABC;
  6226. magBits = expA | sigA;
  6227. goto infProdArg;
  6228. }
  6229. if ( expC == 0xFF ) {
  6230. if ( sigC ) {
  6231. uiZ = 0;
  6232. goto propagateNaN_ZC;
  6233. }
  6234. uiZ = uiC;
  6235. goto uiZ;
  6236. }
  6237. /*------------------------------------------------------------------------
  6238. *------------------------------------------------------------------------*/
  6239. if ( ! expA ) {
  6240. if ( ! sigA ) goto zeroProd;
  6241. normExpSig = softfloat_normSubnormalF32Sig( sigA );
  6242. expA = normExpSig.exp;
  6243. sigA = normExpSig.sig;
  6244. }
  6245. if ( ! expB ) {
  6246. if ( ! sigB ) goto zeroProd;
  6247. normExpSig = softfloat_normSubnormalF32Sig( sigB );
  6248. expB = normExpSig.exp;
  6249. sigB = normExpSig.sig;
  6250. }
  6251. /*------------------------------------------------------------------------
  6252. *------------------------------------------------------------------------*/
  6253. expProd = expA + expB - 0x7E;
  6254. sigA = (sigA | 0x00800000)<<7;
  6255. sigB = (sigB | 0x00800000)<<7;
  6256. sigProd = (uint_fast64_t) sigA * sigB;
  6257. if ( sigProd < UINT64_C( 0x2000000000000000 ) ) {
  6258. --expProd;
  6259. sigProd <<= 1;
  6260. }
  6261. signZ = signProd;
  6262. if ( ! expC ) {
  6263. if ( ! sigC ) {
  6264. expZ = expProd - 1;
  6265. sigZ = softfloat_shortShiftRightJam64( sigProd, 31 );
  6266. goto roundPack;
  6267. }
  6268. normExpSig = softfloat_normSubnormalF32Sig( sigC );
  6269. expC = normExpSig.exp;
  6270. sigC = normExpSig.sig;
  6271. }
  6272. sigC = (sigC | 0x00800000)<<6;
  6273. /*------------------------------------------------------------------------
  6274. *------------------------------------------------------------------------*/
  6275. expDiff = expProd - expC;
  6276. if ( signProd == signC ) {
  6277. /*--------------------------------------------------------------------
  6278. *--------------------------------------------------------------------*/
  6279. if ( expDiff <= 0 ) {
  6280. expZ = expC;
  6281. sigZ = sigC + softfloat_shiftRightJam64( sigProd, 32 - expDiff );
  6282. } else {
  6283. expZ = expProd;
  6284. sig64Z =
  6285. sigProd
  6286. + softfloat_shiftRightJam64(
  6287. (uint_fast64_t) sigC<<32, expDiff );
  6288. sigZ = softfloat_shortShiftRightJam64( sig64Z, 32 );
  6289. }
  6290. if ( sigZ < 0x40000000 ) {
  6291. --expZ;
  6292. sigZ <<= 1;
  6293. }
  6294. } else {
  6295. /*--------------------------------------------------------------------
  6296. *--------------------------------------------------------------------*/
  6297. sig64C = (uint_fast64_t) sigC<<32;
  6298. if ( expDiff < 0 ) {
  6299. signZ = signC;
  6300. expZ = expC;
  6301. sig64Z = sig64C - softfloat_shiftRightJam64( sigProd, -expDiff );
  6302. } else if ( ! expDiff ) {
  6303. expZ = expProd;
  6304. sig64Z = sigProd - sig64C;
  6305. if ( ! sig64Z ) goto completeCancellation;
  6306. if ( sig64Z & UINT64_C( 0x8000000000000000 ) ) {
  6307. signZ = ! signZ;
  6308. sig64Z = -sig64Z;
  6309. }
  6310. } else {
  6311. expZ = expProd;
  6312. sig64Z = sigProd - softfloat_shiftRightJam64( sig64C, expDiff );
  6313. }
  6314. shiftDist = softfloat_countLeadingZeros64( sig64Z ) - 1;
  6315. expZ -= shiftDist;
  6316. shiftDist -= 32;
  6317. if ( shiftDist < 0 ) {
  6318. sigZ = softfloat_shortShiftRightJam64( sig64Z, -shiftDist );
  6319. } else {
  6320. sigZ = (uint_fast32_t) sig64Z<<shiftDist;
  6321. }
  6322. }
  6323. roundPack:
  6324. return softfloat_roundPackToF32( signZ, expZ, sigZ );
  6325. /*------------------------------------------------------------------------
  6326. *------------------------------------------------------------------------*/
  6327. propagateNaN_ABC:
  6328. uiZ = softfloat_propagateNaNF32UI( uiA, uiB );
  6329. goto propagateNaN_ZC;
  6330. /*------------------------------------------------------------------------
  6331. *------------------------------------------------------------------------*/
  6332. infProdArg:
  6333. if ( magBits ) {
  6334. uiZ = packToF32UI( signProd, 0xFF, 0 );
  6335. if ( expC != 0xFF ) goto uiZ;
  6336. if ( sigC ) goto propagateNaN_ZC;
  6337. if ( signProd == signC ) goto uiZ;
  6338. }
  6339. softfloat_raiseFlags( softfloat_flag_invalid );
  6340. uiZ = defaultNaNF32UI;
  6341. propagateNaN_ZC:
  6342. uiZ = softfloat_propagateNaNF32UI( uiZ, uiC );
  6343. goto uiZ;
  6344. /*------------------------------------------------------------------------
  6345. *------------------------------------------------------------------------*/
  6346. zeroProd:
  6347. uiZ = uiC;
  6348. if ( ! (expC | sigC) && (signProd != signC) ) {
  6349. completeCancellation:
  6350. uiZ =
  6351. packToF32UI(
  6352. (softfloat_roundingMode == softfloat_round_min), 0, 0 );
  6353. }
  6354. uiZ:
  6355. uZ.ui = uiZ;
  6356. return uZ.f;
  6357. }
  6358. /**** ended inlining ../../source/s_mulAddF32.c ****/
  6359. /**** start inlining ../../source/s_normSubnormalF64Sig.c ****/
  6360. /*============================================================================
  6361. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  6362. Package, Release 3e, by John R. Hauser.
  6363. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  6364. California. All rights reserved.
  6365. Redistribution and use in source and binary forms, with or without
  6366. modification, are permitted provided that the following conditions are met:
  6367. 1. Redistributions of source code must retain the above copyright notice,
  6368. this list of conditions, and the following disclaimer.
  6369. 2. Redistributions in binary form must reproduce the above copyright notice,
  6370. this list of conditions, and the following disclaimer in the documentation
  6371. and/or other materials provided with the distribution.
  6372. 3. Neither the name of the University nor the names of its contributors may
  6373. be used to endorse or promote products derived from this software without
  6374. specific prior written permission.
  6375. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  6376. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  6377. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  6378. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  6379. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  6380. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  6381. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  6382. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  6383. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  6384. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  6385. =============================================================================*/
  6386. #include <stdint.h>
  6387. /**** skipping file: platform.h ****/
  6388. /**** skipping file: internals.h ****/
  6389. struct exp16_sig64 softfloat_normSubnormalF64Sig( uint_fast64_t sig )
  6390. {
  6391. int_fast8_t shiftDist;
  6392. struct exp16_sig64 z;
  6393. shiftDist = softfloat_countLeadingZeros64( sig ) - 11;
  6394. z.exp = 1 - shiftDist;
  6395. z.sig = sig<<shiftDist;
  6396. return z;
  6397. }
  6398. /**** ended inlining ../../source/s_normSubnormalF64Sig.c ****/
  6399. /**** start inlining ../../source/s_roundPackToF64.c ****/
  6400. /*============================================================================
  6401. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  6402. Package, Release 3e, by John R. Hauser.
  6403. Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
  6404. California. All rights reserved.
  6405. Redistribution and use in source and binary forms, with or without
  6406. modification, are permitted provided that the following conditions are met:
  6407. 1. Redistributions of source code must retain the above copyright notice,
  6408. this list of conditions, and the following disclaimer.
  6409. 2. Redistributions in binary form must reproduce the above copyright notice,
  6410. this list of conditions, and the following disclaimer in the documentation
  6411. and/or other materials provided with the distribution.
  6412. 3. Neither the name of the University nor the names of its contributors may
  6413. be used to endorse or promote products derived from this software without
  6414. specific prior written permission.
  6415. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  6416. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  6417. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  6418. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  6419. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  6420. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  6421. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  6422. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  6423. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  6424. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  6425. =============================================================================*/
  6426. #include <stdbool.h>
  6427. #include <stdint.h>
  6428. /**** skipping file: platform.h ****/
  6429. /**** skipping file: internals.h ****/
  6430. /**** skipping file: softfloat.h ****/
  6431. float64_t
  6432. softfloat_roundPackToF64( bool sign, int_fast16_t exp, uint_fast64_t sig )
  6433. {
  6434. uint_fast8_t roundingMode;
  6435. bool roundNearEven;
  6436. uint_fast16_t roundIncrement, roundBits;
  6437. bool isTiny;
  6438. uint_fast64_t uiZ;
  6439. union ui64_f64 uZ;
  6440. /*------------------------------------------------------------------------
  6441. *------------------------------------------------------------------------*/
  6442. roundingMode = softfloat_roundingMode;
  6443. roundNearEven = (roundingMode == softfloat_round_near_even);
  6444. roundIncrement = 0x200;
  6445. if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
  6446. roundIncrement =
  6447. (roundingMode
  6448. == (sign ? softfloat_round_min : softfloat_round_max))
  6449. ? 0x3FF
  6450. : 0;
  6451. }
  6452. roundBits = sig & 0x3FF;
  6453. /*------------------------------------------------------------------------
  6454. *------------------------------------------------------------------------*/
  6455. if ( 0x7FD <= (uint16_t) exp ) {
  6456. if ( exp < 0 ) {
  6457. /*----------------------------------------------------------------
  6458. *----------------------------------------------------------------*/
  6459. isTiny =
  6460. (softfloat_detectTininess == softfloat_tininess_beforeRounding)
  6461. || (exp < -1)
  6462. || (sig + roundIncrement < UINT64_C( 0x8000000000000000 ));
  6463. sig = softfloat_shiftRightJam64( sig, -exp );
  6464. exp = 0;
  6465. roundBits = sig & 0x3FF;
  6466. if ( isTiny && roundBits ) {
  6467. softfloat_raiseFlags( softfloat_flag_underflow );
  6468. }
  6469. } else if (
  6470. (0x7FD < exp)
  6471. || (UINT64_C( 0x8000000000000000 ) <= sig + roundIncrement)
  6472. ) {
  6473. /*----------------------------------------------------------------
  6474. *----------------------------------------------------------------*/
  6475. softfloat_raiseFlags(
  6476. softfloat_flag_overflow | softfloat_flag_inexact );
  6477. uiZ = packToF64UI( sign, 0x7FF, 0 ) - ! roundIncrement;
  6478. goto uiZ;
  6479. }
  6480. }
  6481. /*------------------------------------------------------------------------
  6482. *------------------------------------------------------------------------*/
  6483. sig = (sig + roundIncrement)>>10;
  6484. if ( roundBits ) {
  6485. softfloat_exceptionFlags |= softfloat_flag_inexact;
  6486. #ifdef SOFTFLOAT_ROUND_ODD
  6487. if ( roundingMode == softfloat_round_odd ) {
  6488. sig |= 1;
  6489. goto packReturn;
  6490. }
  6491. #endif
  6492. }
  6493. sig &= ~(uint_fast64_t) (! (roundBits ^ 0x200) & roundNearEven);
  6494. if ( ! sig ) exp = 0;
  6495. /*------------------------------------------------------------------------
  6496. *------------------------------------------------------------------------*/
  6497. packReturn:
  6498. uiZ = packToF64UI( sign, exp, sig );
  6499. uiZ:
  6500. uZ.ui = uiZ;
  6501. return uZ.f;
  6502. }
  6503. /**** ended inlining ../../source/s_roundPackToF64.c ****/
  6504. /**** start inlining ../../source/s_normRoundPackToF64.c ****/
  6505. /*============================================================================
  6506. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  6507. Package, Release 3e, by John R. Hauser.
  6508. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  6509. California. All rights reserved.
  6510. Redistribution and use in source and binary forms, with or without
  6511. modification, are permitted provided that the following conditions are met:
  6512. 1. Redistributions of source code must retain the above copyright notice,
  6513. this list of conditions, and the following disclaimer.
  6514. 2. Redistributions in binary form must reproduce the above copyright notice,
  6515. this list of conditions, and the following disclaimer in the documentation
  6516. and/or other materials provided with the distribution.
  6517. 3. Neither the name of the University nor the names of its contributors may
  6518. be used to endorse or promote products derived from this software without
  6519. specific prior written permission.
  6520. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  6521. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  6522. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  6523. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  6524. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  6525. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  6526. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  6527. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  6528. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  6529. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  6530. =============================================================================*/
  6531. #include <stdbool.h>
  6532. #include <stdint.h>
  6533. /**** skipping file: platform.h ****/
  6534. /**** skipping file: internals.h ****/
  6535. float64_t
  6536. softfloat_normRoundPackToF64( bool sign, int_fast16_t exp, uint_fast64_t sig )
  6537. {
  6538. int_fast8_t shiftDist;
  6539. union ui64_f64 uZ;
  6540. shiftDist = softfloat_countLeadingZeros64( sig ) - 1;
  6541. exp -= shiftDist;
  6542. if ( (10 <= shiftDist) && ((unsigned int) exp < 0x7FD) ) {
  6543. uZ.ui = packToF64UI( sign, sig ? exp : 0, sig<<(shiftDist - 10) );
  6544. return uZ.f;
  6545. } else {
  6546. return softfloat_roundPackToF64( sign, exp, sig<<shiftDist );
  6547. }
  6548. }
  6549. /**** ended inlining ../../source/s_normRoundPackToF64.c ****/
  6550. /**** start inlining ../../source/s_addMagsF64.c ****/
  6551. /*============================================================================
  6552. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  6553. Package, Release 3e, by John R. Hauser.
  6554. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  6555. California. All rights reserved.
  6556. Redistribution and use in source and binary forms, with or without
  6557. modification, are permitted provided that the following conditions are met:
  6558. 1. Redistributions of source code must retain the above copyright notice,
  6559. this list of conditions, and the following disclaimer.
  6560. 2. Redistributions in binary form must reproduce the above copyright notice,
  6561. this list of conditions, and the following disclaimer in the documentation
  6562. and/or other materials provided with the distribution.
  6563. 3. Neither the name of the University nor the names of its contributors may
  6564. be used to endorse or promote products derived from this software without
  6565. specific prior written permission.
  6566. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  6567. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  6568. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  6569. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  6570. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  6571. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  6572. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  6573. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  6574. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  6575. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  6576. =============================================================================*/
  6577. #include <stdbool.h>
  6578. #include <stdint.h>
  6579. /**** skipping file: platform.h ****/
  6580. /**** skipping file: internals.h ****/
  6581. /**** skipping file: specialize.h ****/
  6582. float64_t
  6583. softfloat_addMagsF64( uint_fast64_t uiA, uint_fast64_t uiB, bool signZ )
  6584. {
  6585. int_fast16_t expA;
  6586. uint_fast64_t sigA;
  6587. int_fast16_t expB;
  6588. uint_fast64_t sigB;
  6589. int_fast16_t expDiff;
  6590. uint_fast64_t uiZ;
  6591. int_fast16_t expZ;
  6592. uint_fast64_t sigZ;
  6593. union ui64_f64 uZ;
  6594. /*------------------------------------------------------------------------
  6595. *------------------------------------------------------------------------*/
  6596. expA = expF64UI( uiA );
  6597. sigA = fracF64UI( uiA );
  6598. expB = expF64UI( uiB );
  6599. sigB = fracF64UI( uiB );
  6600. /*------------------------------------------------------------------------
  6601. *------------------------------------------------------------------------*/
  6602. expDiff = expA - expB;
  6603. if ( ! expDiff ) {
  6604. /*--------------------------------------------------------------------
  6605. *--------------------------------------------------------------------*/
  6606. if ( ! expA ) {
  6607. uiZ = uiA + sigB;
  6608. goto uiZ;
  6609. }
  6610. if ( expA == 0x7FF ) {
  6611. if ( sigA | sigB ) goto propagateNaN;
  6612. uiZ = uiA;
  6613. goto uiZ;
  6614. }
  6615. expZ = expA;
  6616. sigZ = UINT64_C( 0x0020000000000000 ) + sigA + sigB;
  6617. sigZ <<= 9;
  6618. } else {
  6619. /*--------------------------------------------------------------------
  6620. *--------------------------------------------------------------------*/
  6621. sigA <<= 9;
  6622. sigB <<= 9;
  6623. if ( expDiff < 0 ) {
  6624. if ( expB == 0x7FF ) {
  6625. if ( sigB ) goto propagateNaN;
  6626. uiZ = packToF64UI( signZ, 0x7FF, 0 );
  6627. goto uiZ;
  6628. }
  6629. expZ = expB;
  6630. if ( expA ) {
  6631. sigA += UINT64_C( 0x2000000000000000 );
  6632. } else {
  6633. sigA <<= 1;
  6634. }
  6635. sigA = softfloat_shiftRightJam64( sigA, -expDiff );
  6636. } else {
  6637. if ( expA == 0x7FF ) {
  6638. if ( sigA ) goto propagateNaN;
  6639. uiZ = uiA;
  6640. goto uiZ;
  6641. }
  6642. expZ = expA;
  6643. if ( expB ) {
  6644. sigB += UINT64_C( 0x2000000000000000 );
  6645. } else {
  6646. sigB <<= 1;
  6647. }
  6648. sigB = softfloat_shiftRightJam64( sigB, expDiff );
  6649. }
  6650. sigZ = UINT64_C( 0x2000000000000000 ) + sigA + sigB;
  6651. if ( sigZ < UINT64_C( 0x4000000000000000 ) ) {
  6652. --expZ;
  6653. sigZ <<= 1;
  6654. }
  6655. }
  6656. return softfloat_roundPackToF64( signZ, expZ, sigZ );
  6657. /*------------------------------------------------------------------------
  6658. *------------------------------------------------------------------------*/
  6659. propagateNaN:
  6660. uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
  6661. uiZ:
  6662. uZ.ui = uiZ;
  6663. return uZ.f;
  6664. }
  6665. /**** ended inlining ../../source/s_addMagsF64.c ****/
  6666. /**** start inlining ../../source/s_subMagsF64.c ****/
  6667. /*============================================================================
  6668. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  6669. Package, Release 3e, by John R. Hauser.
  6670. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  6671. California. All rights reserved.
  6672. Redistribution and use in source and binary forms, with or without
  6673. modification, are permitted provided that the following conditions are met:
  6674. 1. Redistributions of source code must retain the above copyright notice,
  6675. this list of conditions, and the following disclaimer.
  6676. 2. Redistributions in binary form must reproduce the above copyright notice,
  6677. this list of conditions, and the following disclaimer in the documentation
  6678. and/or other materials provided with the distribution.
  6679. 3. Neither the name of the University nor the names of its contributors may
  6680. be used to endorse or promote products derived from this software without
  6681. specific prior written permission.
  6682. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  6683. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  6684. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  6685. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  6686. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  6687. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  6688. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  6689. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  6690. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  6691. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  6692. =============================================================================*/
  6693. #include <stdbool.h>
  6694. #include <stdint.h>
  6695. /**** skipping file: platform.h ****/
  6696. /**** skipping file: internals.h ****/
  6697. /**** skipping file: specialize.h ****/
  6698. /**** skipping file: softfloat.h ****/
  6699. float64_t
  6700. softfloat_subMagsF64( uint_fast64_t uiA, uint_fast64_t uiB, bool signZ )
  6701. {
  6702. int_fast16_t expA;
  6703. uint_fast64_t sigA;
  6704. int_fast16_t expB;
  6705. uint_fast64_t sigB;
  6706. int_fast16_t expDiff;
  6707. uint_fast64_t uiZ;
  6708. int_fast64_t sigDiff;
  6709. int_fast8_t shiftDist;
  6710. int_fast16_t expZ;
  6711. uint_fast64_t sigZ;
  6712. union ui64_f64 uZ;
  6713. /*------------------------------------------------------------------------
  6714. *------------------------------------------------------------------------*/
  6715. expA = expF64UI( uiA );
  6716. sigA = fracF64UI( uiA );
  6717. expB = expF64UI( uiB );
  6718. sigB = fracF64UI( uiB );
  6719. /*------------------------------------------------------------------------
  6720. *------------------------------------------------------------------------*/
  6721. expDiff = expA - expB;
  6722. if ( ! expDiff ) {
  6723. /*--------------------------------------------------------------------
  6724. *--------------------------------------------------------------------*/
  6725. if ( expA == 0x7FF ) {
  6726. if ( sigA | sigB ) goto propagateNaN;
  6727. softfloat_raiseFlags( softfloat_flag_invalid );
  6728. uiZ = defaultNaNF64UI;
  6729. goto uiZ;
  6730. }
  6731. sigDiff = sigA - sigB;
  6732. if ( ! sigDiff ) {
  6733. uiZ =
  6734. packToF64UI(
  6735. (softfloat_roundingMode == softfloat_round_min), 0, 0 );
  6736. goto uiZ;
  6737. }
  6738. if ( expA ) --expA;
  6739. if ( sigDiff < 0 ) {
  6740. signZ = ! signZ;
  6741. sigDiff = -sigDiff;
  6742. }
  6743. shiftDist = softfloat_countLeadingZeros64( sigDiff ) - 11;
  6744. expZ = expA - shiftDist;
  6745. if ( expZ < 0 ) {
  6746. shiftDist = expA;
  6747. expZ = 0;
  6748. }
  6749. uiZ = packToF64UI( signZ, expZ, sigDiff<<shiftDist );
  6750. goto uiZ;
  6751. } else {
  6752. /*--------------------------------------------------------------------
  6753. *--------------------------------------------------------------------*/
  6754. sigA <<= 10;
  6755. sigB <<= 10;
  6756. if ( expDiff < 0 ) {
  6757. /*----------------------------------------------------------------
  6758. *----------------------------------------------------------------*/
  6759. signZ = ! signZ;
  6760. if ( expB == 0x7FF ) {
  6761. if ( sigB ) goto propagateNaN;
  6762. uiZ = packToF64UI( signZ, 0x7FF, 0 );
  6763. goto uiZ;
  6764. }
  6765. sigA += expA ? UINT64_C( 0x4000000000000000 ) : sigA;
  6766. sigA = softfloat_shiftRightJam64( sigA, -expDiff );
  6767. sigB |= UINT64_C( 0x4000000000000000 );
  6768. expZ = expB;
  6769. sigZ = sigB - sigA;
  6770. } else {
  6771. /*----------------------------------------------------------------
  6772. *----------------------------------------------------------------*/
  6773. if ( expA == 0x7FF ) {
  6774. if ( sigA ) goto propagateNaN;
  6775. uiZ = uiA;
  6776. goto uiZ;
  6777. }
  6778. sigB += expB ? UINT64_C( 0x4000000000000000 ) : sigB;
  6779. sigB = softfloat_shiftRightJam64( sigB, expDiff );
  6780. sigA |= UINT64_C( 0x4000000000000000 );
  6781. expZ = expA;
  6782. sigZ = sigA - sigB;
  6783. }
  6784. return softfloat_normRoundPackToF64( signZ, expZ - 1, sigZ );
  6785. }
  6786. /*------------------------------------------------------------------------
  6787. *------------------------------------------------------------------------*/
  6788. propagateNaN:
  6789. uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
  6790. uiZ:
  6791. uZ.ui = uiZ;
  6792. return uZ.f;
  6793. }
  6794. /**** ended inlining ../../source/s_subMagsF64.c ****/
  6795. /**** start inlining ../../source/s_mulAddF64.c ****/
  6796. /*============================================================================
  6797. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  6798. Package, Release 3e, by John R. Hauser.
  6799. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  6800. California. All rights reserved.
  6801. Redistribution and use in source and binary forms, with or without
  6802. modification, are permitted provided that the following conditions are met:
  6803. 1. Redistributions of source code must retain the above copyright notice,
  6804. this list of conditions, and the following disclaimer.
  6805. 2. Redistributions in binary form must reproduce the above copyright notice,
  6806. this list of conditions, and the following disclaimer in the documentation
  6807. and/or other materials provided with the distribution.
  6808. 3. Neither the name of the University nor the names of its contributors may
  6809. be used to endorse or promote products derived from this software without
  6810. specific prior written permission.
  6811. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  6812. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  6813. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  6814. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  6815. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  6816. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  6817. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  6818. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  6819. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  6820. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  6821. =============================================================================*/
  6822. #include <stdbool.h>
  6823. #include <stdint.h>
  6824. /**** skipping file: platform.h ****/
  6825. /**** skipping file: internals.h ****/
  6826. /**** skipping file: specialize.h ****/
  6827. /**** skipping file: softfloat.h ****/
  6828. #ifdef SOFTFLOAT_FAST_INT64
  6829. float64_t
  6830. softfloat_mulAddF64(
  6831. uint_fast64_t uiA, uint_fast64_t uiB, uint_fast64_t uiC, uint_fast8_t op )
  6832. {
  6833. bool signA;
  6834. int_fast16_t expA;
  6835. uint_fast64_t sigA;
  6836. bool signB;
  6837. int_fast16_t expB;
  6838. uint_fast64_t sigB;
  6839. bool signC;
  6840. int_fast16_t expC;
  6841. uint_fast64_t sigC;
  6842. bool signZ;
  6843. uint_fast64_t magBits, uiZ;
  6844. struct exp16_sig64 normExpSig;
  6845. int_fast16_t expZ;
  6846. struct uint128 sig128Z;
  6847. uint_fast64_t sigZ;
  6848. int_fast16_t expDiff;
  6849. struct uint128 sig128C;
  6850. int_fast8_t shiftDist;
  6851. union ui64_f64 uZ;
  6852. /*------------------------------------------------------------------------
  6853. *------------------------------------------------------------------------*/
  6854. signA = signF64UI( uiA );
  6855. expA = expF64UI( uiA );
  6856. sigA = fracF64UI( uiA );
  6857. signB = signF64UI( uiB );
  6858. expB = expF64UI( uiB );
  6859. sigB = fracF64UI( uiB );
  6860. signC = signF64UI( uiC ) ^ (op == softfloat_mulAdd_subC);
  6861. expC = expF64UI( uiC );
  6862. sigC = fracF64UI( uiC );
  6863. signZ = signA ^ signB ^ (op == softfloat_mulAdd_subProd);
  6864. /*------------------------------------------------------------------------
  6865. *------------------------------------------------------------------------*/
  6866. if ( expA == 0x7FF ) {
  6867. if ( sigA || ((expB == 0x7FF) && sigB) ) goto propagateNaN_ABC;
  6868. magBits = expB | sigB;
  6869. goto infProdArg;
  6870. }
  6871. if ( expB == 0x7FF ) {
  6872. if ( sigB ) goto propagateNaN_ABC;
  6873. magBits = expA | sigA;
  6874. goto infProdArg;
  6875. }
  6876. if ( expC == 0x7FF ) {
  6877. if ( sigC ) {
  6878. uiZ = 0;
  6879. goto propagateNaN_ZC;
  6880. }
  6881. uiZ = uiC;
  6882. goto uiZ;
  6883. }
  6884. /*------------------------------------------------------------------------
  6885. *------------------------------------------------------------------------*/
  6886. if ( ! expA ) {
  6887. if ( ! sigA ) goto zeroProd;
  6888. normExpSig = softfloat_normSubnormalF64Sig( sigA );
  6889. expA = normExpSig.exp;
  6890. sigA = normExpSig.sig;
  6891. }
  6892. if ( ! expB ) {
  6893. if ( ! sigB ) goto zeroProd;
  6894. normExpSig = softfloat_normSubnormalF64Sig( sigB );
  6895. expB = normExpSig.exp;
  6896. sigB = normExpSig.sig;
  6897. }
  6898. /*------------------------------------------------------------------------
  6899. *------------------------------------------------------------------------*/
  6900. expZ = expA + expB - 0x3FE;
  6901. sigA = (sigA | UINT64_C( 0x0010000000000000 ))<<10;
  6902. sigB = (sigB | UINT64_C( 0x0010000000000000 ))<<10;
  6903. sig128Z = softfloat_mul64To128( sigA, sigB );
  6904. if ( sig128Z.v64 < UINT64_C( 0x2000000000000000 ) ) {
  6905. --expZ;
  6906. sig128Z =
  6907. softfloat_add128(
  6908. sig128Z.v64, sig128Z.v0, sig128Z.v64, sig128Z.v0 );
  6909. }
  6910. if ( ! expC ) {
  6911. if ( ! sigC ) {
  6912. --expZ;
  6913. sigZ = sig128Z.v64<<1 | (sig128Z.v0 != 0);
  6914. goto roundPack;
  6915. }
  6916. normExpSig = softfloat_normSubnormalF64Sig( sigC );
  6917. expC = normExpSig.exp;
  6918. sigC = normExpSig.sig;
  6919. }
  6920. sigC = (sigC | UINT64_C( 0x0010000000000000 ))<<9;
  6921. /*------------------------------------------------------------------------
  6922. *------------------------------------------------------------------------*/
  6923. expDiff = expZ - expC;
  6924. if ( expDiff < 0 ) {
  6925. expZ = expC;
  6926. if ( (signZ == signC) || (expDiff < -1) ) {
  6927. sig128Z.v64 = softfloat_shiftRightJam64( sig128Z.v64, -expDiff );
  6928. } else {
  6929. sig128Z =
  6930. softfloat_shortShiftRightJam128( sig128Z.v64, sig128Z.v0, 1 );
  6931. }
  6932. } else if ( expDiff ) {
  6933. sig128C = softfloat_shiftRightJam128( sigC, 0, expDiff );
  6934. }
  6935. /*------------------------------------------------------------------------
  6936. *------------------------------------------------------------------------*/
  6937. if ( signZ == signC ) {
  6938. /*--------------------------------------------------------------------
  6939. *--------------------------------------------------------------------*/
  6940. if ( expDiff <= 0 ) {
  6941. sigZ = (sigC + sig128Z.v64) | (sig128Z.v0 != 0);
  6942. } else {
  6943. sig128Z =
  6944. softfloat_add128(
  6945. sig128Z.v64, sig128Z.v0, sig128C.v64, sig128C.v0 );
  6946. sigZ = sig128Z.v64 | (sig128Z.v0 != 0);
  6947. }
  6948. if ( sigZ < UINT64_C( 0x4000000000000000 ) ) {
  6949. --expZ;
  6950. sigZ <<= 1;
  6951. }
  6952. } else {
  6953. /*--------------------------------------------------------------------
  6954. *--------------------------------------------------------------------*/
  6955. if ( expDiff < 0 ) {
  6956. signZ = signC;
  6957. sig128Z = softfloat_sub128( sigC, 0, sig128Z.v64, sig128Z.v0 );
  6958. } else if ( ! expDiff ) {
  6959. sig128Z.v64 = sig128Z.v64 - sigC;
  6960. if ( ! (sig128Z.v64 | sig128Z.v0) ) goto completeCancellation;
  6961. if ( sig128Z.v64 & UINT64_C( 0x8000000000000000 ) ) {
  6962. signZ = ! signZ;
  6963. sig128Z = softfloat_sub128( 0, 0, sig128Z.v64, sig128Z.v0 );
  6964. }
  6965. } else {
  6966. sig128Z =
  6967. softfloat_sub128(
  6968. sig128Z.v64, sig128Z.v0, sig128C.v64, sig128C.v0 );
  6969. }
  6970. /*--------------------------------------------------------------------
  6971. *--------------------------------------------------------------------*/
  6972. if ( ! sig128Z.v64 ) {
  6973. expZ -= 64;
  6974. sig128Z.v64 = sig128Z.v0;
  6975. sig128Z.v0 = 0;
  6976. }
  6977. shiftDist = softfloat_countLeadingZeros64( sig128Z.v64 ) - 1;
  6978. expZ -= shiftDist;
  6979. if ( shiftDist < 0 ) {
  6980. sigZ = softfloat_shortShiftRightJam64( sig128Z.v64, -shiftDist );
  6981. } else {
  6982. sig128Z =
  6983. softfloat_shortShiftLeft128(
  6984. sig128Z.v64, sig128Z.v0, shiftDist );
  6985. sigZ = sig128Z.v64;
  6986. }
  6987. sigZ |= (sig128Z.v0 != 0);
  6988. }
  6989. roundPack:
  6990. return softfloat_roundPackToF64( signZ, expZ, sigZ );
  6991. /*------------------------------------------------------------------------
  6992. *------------------------------------------------------------------------*/
  6993. propagateNaN_ABC:
  6994. uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
  6995. goto propagateNaN_ZC;
  6996. /*------------------------------------------------------------------------
  6997. *------------------------------------------------------------------------*/
  6998. infProdArg:
  6999. if ( magBits ) {
  7000. uiZ = packToF64UI( signZ, 0x7FF, 0 );
  7001. if ( expC != 0x7FF ) goto uiZ;
  7002. if ( sigC ) goto propagateNaN_ZC;
  7003. if ( signZ == signC ) goto uiZ;
  7004. }
  7005. softfloat_raiseFlags( softfloat_flag_invalid );
  7006. uiZ = defaultNaNF64UI;
  7007. propagateNaN_ZC:
  7008. uiZ = softfloat_propagateNaNF64UI( uiZ, uiC );
  7009. goto uiZ;
  7010. /*------------------------------------------------------------------------
  7011. *------------------------------------------------------------------------*/
  7012. zeroProd:
  7013. uiZ = uiC;
  7014. if ( ! (expC | sigC) && (signZ != signC) ) {
  7015. completeCancellation:
  7016. uiZ =
  7017. packToF64UI(
  7018. (softfloat_roundingMode == softfloat_round_min), 0, 0 );
  7019. }
  7020. uiZ:
  7021. uZ.ui = uiZ;
  7022. return uZ.f;
  7023. }
  7024. #else
  7025. float64_t
  7026. softfloat_mulAddF64(
  7027. uint_fast64_t uiA, uint_fast64_t uiB, uint_fast64_t uiC, uint_fast8_t op )
  7028. {
  7029. bool signA;
  7030. int_fast16_t expA;
  7031. uint64_t sigA;
  7032. bool signB;
  7033. int_fast16_t expB;
  7034. uint64_t sigB;
  7035. bool signC;
  7036. int_fast16_t expC;
  7037. uint64_t sigC;
  7038. bool signZ;
  7039. uint64_t magBits, uiZ;
  7040. struct exp16_sig64 normExpSig;
  7041. int_fast16_t expZ;
  7042. uint32_t sig128Z[4];
  7043. uint64_t sigZ;
  7044. int_fast16_t shiftDist, expDiff;
  7045. uint32_t sig128C[4];
  7046. union ui64_f64 uZ;
  7047. /*------------------------------------------------------------------------
  7048. *------------------------------------------------------------------------*/
  7049. signA = signF64UI( uiA );
  7050. expA = expF64UI( uiA );
  7051. sigA = fracF64UI( uiA );
  7052. signB = signF64UI( uiB );
  7053. expB = expF64UI( uiB );
  7054. sigB = fracF64UI( uiB );
  7055. signC = signF64UI( uiC ) ^ (op == softfloat_mulAdd_subC);
  7056. expC = expF64UI( uiC );
  7057. sigC = fracF64UI( uiC );
  7058. signZ = signA ^ signB ^ (op == softfloat_mulAdd_subProd);
  7059. /*------------------------------------------------------------------------
  7060. *------------------------------------------------------------------------*/
  7061. if ( expA == 0x7FF ) {
  7062. if ( sigA || ((expB == 0x7FF) && sigB) ) goto propagateNaN_ABC;
  7063. magBits = expB | sigB;
  7064. goto infProdArg;
  7065. }
  7066. if ( expB == 0x7FF ) {
  7067. if ( sigB ) goto propagateNaN_ABC;
  7068. magBits = expA | sigA;
  7069. goto infProdArg;
  7070. }
  7071. if ( expC == 0x7FF ) {
  7072. if ( sigC ) {
  7073. uiZ = 0;
  7074. goto propagateNaN_ZC;
  7075. }
  7076. uiZ = uiC;
  7077. goto uiZ;
  7078. }
  7079. /*------------------------------------------------------------------------
  7080. *------------------------------------------------------------------------*/
  7081. if ( ! expA ) {
  7082. if ( ! sigA ) goto zeroProd;
  7083. normExpSig = softfloat_normSubnormalF64Sig( sigA );
  7084. expA = normExpSig.exp;
  7085. sigA = normExpSig.sig;
  7086. }
  7087. if ( ! expB ) {
  7088. if ( ! sigB ) goto zeroProd;
  7089. normExpSig = softfloat_normSubnormalF64Sig( sigB );
  7090. expB = normExpSig.exp;
  7091. sigB = normExpSig.sig;
  7092. }
  7093. /*------------------------------------------------------------------------
  7094. *------------------------------------------------------------------------*/
  7095. expZ = expA + expB - 0x3FE;
  7096. sigA = (sigA | UINT64_C( 0x0010000000000000 ))<<10;
  7097. sigB = (sigB | UINT64_C( 0x0010000000000000 ))<<11;
  7098. softfloat_mul64To128M( sigA, sigB, sig128Z );
  7099. sigZ =
  7100. (uint64_t) sig128Z[indexWord( 4, 3 )]<<32 | sig128Z[indexWord( 4, 2 )];
  7101. shiftDist = 0;
  7102. if ( ! (sigZ & UINT64_C( 0x4000000000000000 )) ) {
  7103. --expZ;
  7104. shiftDist = -1;
  7105. }
  7106. if ( ! expC ) {
  7107. if ( ! sigC ) {
  7108. if ( shiftDist ) sigZ <<= 1;
  7109. goto sigZ;
  7110. }
  7111. normExpSig = softfloat_normSubnormalF64Sig( sigC );
  7112. expC = normExpSig.exp;
  7113. sigC = normExpSig.sig;
  7114. }
  7115. sigC = (sigC | UINT64_C( 0x0010000000000000 ))<<10;
  7116. /*------------------------------------------------------------------------
  7117. *------------------------------------------------------------------------*/
  7118. expDiff = expZ - expC;
  7119. if ( expDiff < 0 ) {
  7120. expZ = expC;
  7121. if ( (signZ == signC) || (expDiff < -1) ) {
  7122. shiftDist -= expDiff;
  7123. if ( shiftDist) {
  7124. sigZ = softfloat_shiftRightJam64( sigZ, shiftDist );
  7125. }
  7126. } else {
  7127. if ( ! shiftDist ) {
  7128. softfloat_shortShiftRight128M( sig128Z, 1, sig128Z );
  7129. }
  7130. }
  7131. } else {
  7132. if ( shiftDist ) softfloat_add128M( sig128Z, sig128Z, sig128Z );
  7133. if ( ! expDiff ) {
  7134. sigZ =
  7135. (uint64_t) sig128Z[indexWord( 4, 3 )]<<32
  7136. | sig128Z[indexWord( 4, 2 )];
  7137. } else {
  7138. sig128C[indexWord( 4, 3 )] = sigC>>32;
  7139. sig128C[indexWord( 4, 2 )] = sigC;
  7140. sig128C[indexWord( 4, 1 )] = 0;
  7141. sig128C[indexWord( 4, 0 )] = 0;
  7142. softfloat_shiftRightJam128M( sig128C, expDiff, sig128C );
  7143. }
  7144. }
  7145. /*------------------------------------------------------------------------
  7146. *------------------------------------------------------------------------*/
  7147. if ( signZ == signC ) {
  7148. /*--------------------------------------------------------------------
  7149. *--------------------------------------------------------------------*/
  7150. if ( expDiff <= 0 ) {
  7151. sigZ += sigC;
  7152. } else {
  7153. softfloat_add128M( sig128Z, sig128C, sig128Z );
  7154. sigZ =
  7155. (uint64_t) sig128Z[indexWord( 4, 3 )]<<32
  7156. | sig128Z[indexWord( 4, 2 )];
  7157. }
  7158. if ( sigZ & UINT64_C( 0x8000000000000000 ) ) {
  7159. ++expZ;
  7160. sigZ = softfloat_shortShiftRightJam64( sigZ, 1 );
  7161. }
  7162. } else {
  7163. /*--------------------------------------------------------------------
  7164. *--------------------------------------------------------------------*/
  7165. if ( expDiff < 0 ) {
  7166. signZ = signC;
  7167. if ( expDiff < -1 ) {
  7168. sigZ = sigC - sigZ;
  7169. if (
  7170. sig128Z[indexWord( 4, 1 )] || sig128Z[indexWord( 4, 0 )]
  7171. ) {
  7172. sigZ = (sigZ - 1) | 1;
  7173. }
  7174. if ( ! (sigZ & UINT64_C( 0x4000000000000000 )) ) {
  7175. --expZ;
  7176. sigZ <<= 1;
  7177. }
  7178. goto roundPack;
  7179. } else {
  7180. sig128C[indexWord( 4, 3 )] = sigC>>32;
  7181. sig128C[indexWord( 4, 2 )] = sigC;
  7182. sig128C[indexWord( 4, 1 )] = 0;
  7183. sig128C[indexWord( 4, 0 )] = 0;
  7184. softfloat_sub128M( sig128C, sig128Z, sig128Z );
  7185. }
  7186. } else if ( ! expDiff ) {
  7187. sigZ -= sigC;
  7188. if (
  7189. ! sigZ && ! sig128Z[indexWord( 4, 1 )]
  7190. && ! sig128Z[indexWord( 4, 0 )]
  7191. ) {
  7192. goto completeCancellation;
  7193. }
  7194. sig128Z[indexWord( 4, 3 )] = sigZ>>32;
  7195. sig128Z[indexWord( 4, 2 )] = sigZ;
  7196. if ( sigZ & UINT64_C( 0x8000000000000000 ) ) {
  7197. signZ = ! signZ;
  7198. softfloat_negX128M( sig128Z );
  7199. }
  7200. } else {
  7201. softfloat_sub128M( sig128Z, sig128C, sig128Z );
  7202. if ( 1 < expDiff ) {
  7203. sigZ =
  7204. (uint64_t) sig128Z[indexWord( 4, 3 )]<<32
  7205. | sig128Z[indexWord( 4, 2 )];
  7206. if ( ! (sigZ & UINT64_C( 0x4000000000000000 )) ) {
  7207. --expZ;
  7208. sigZ <<= 1;
  7209. }
  7210. goto sigZ;
  7211. }
  7212. }
  7213. /*--------------------------------------------------------------------
  7214. *--------------------------------------------------------------------*/
  7215. shiftDist = 0;
  7216. sigZ =
  7217. (uint64_t) sig128Z[indexWord( 4, 3 )]<<32
  7218. | sig128Z[indexWord( 4, 2 )];
  7219. if ( ! sigZ ) {
  7220. shiftDist = 64;
  7221. sigZ =
  7222. (uint64_t) sig128Z[indexWord( 4, 1 )]<<32
  7223. | sig128Z[indexWord( 4, 0 )];
  7224. }
  7225. shiftDist += softfloat_countLeadingZeros64( sigZ ) - 1;
  7226. if ( shiftDist ) {
  7227. expZ -= shiftDist;
  7228. softfloat_shiftLeft128M( sig128Z, shiftDist, sig128Z );
  7229. sigZ =
  7230. (uint64_t) sig128Z[indexWord( 4, 3 )]<<32
  7231. | sig128Z[indexWord( 4, 2 )];
  7232. }
  7233. }
  7234. sigZ:
  7235. if ( sig128Z[indexWord( 4, 1 )] || sig128Z[indexWord( 4, 0 )] ) sigZ |= 1;
  7236. roundPack:
  7237. return softfloat_roundPackToF64( signZ, expZ - 1, sigZ );
  7238. /*------------------------------------------------------------------------
  7239. *------------------------------------------------------------------------*/
  7240. propagateNaN_ABC:
  7241. uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
  7242. goto propagateNaN_ZC;
  7243. /*------------------------------------------------------------------------
  7244. *------------------------------------------------------------------------*/
  7245. infProdArg:
  7246. if ( magBits ) {
  7247. uiZ = packToF64UI( signZ, 0x7FF, 0 );
  7248. if ( expC != 0x7FF ) goto uiZ;
  7249. if ( sigC ) goto propagateNaN_ZC;
  7250. if ( signZ == signC ) goto uiZ;
  7251. }
  7252. softfloat_raiseFlags( softfloat_flag_invalid );
  7253. uiZ = defaultNaNF64UI;
  7254. propagateNaN_ZC:
  7255. uiZ = softfloat_propagateNaNF64UI( uiZ, uiC );
  7256. goto uiZ;
  7257. /*------------------------------------------------------------------------
  7258. *------------------------------------------------------------------------*/
  7259. zeroProd:
  7260. uiZ = uiC;
  7261. if ( ! (expC | sigC) && (signZ != signC) ) {
  7262. completeCancellation:
  7263. uiZ =
  7264. packToF64UI(
  7265. (softfloat_roundingMode == softfloat_round_min), 0, 0 );
  7266. }
  7267. uiZ:
  7268. uZ.ui = uiZ;
  7269. return uZ.f;
  7270. }
  7271. #endif
  7272. /**** ended inlining ../../source/s_mulAddF64.c ****/
  7273. /**** start inlining ../../source/s_normSubnormalExtF80Sig.c ****/
  7274. /*============================================================================
  7275. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  7276. Package, Release 3e, by John R. Hauser.
  7277. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  7278. California. All rights reserved.
  7279. Redistribution and use in source and binary forms, with or without
  7280. modification, are permitted provided that the following conditions are met:
  7281. 1. Redistributions of source code must retain the above copyright notice,
  7282. this list of conditions, and the following disclaimer.
  7283. 2. Redistributions in binary form must reproduce the above copyright notice,
  7284. this list of conditions, and the following disclaimer in the documentation
  7285. and/or other materials provided with the distribution.
  7286. 3. Neither the name of the University nor the names of its contributors may
  7287. be used to endorse or promote products derived from this software without
  7288. specific prior written permission.
  7289. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  7290. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  7291. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  7292. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  7293. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  7294. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  7295. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  7296. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  7297. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  7298. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  7299. =============================================================================*/
  7300. #include <stdint.h>
  7301. /**** skipping file: platform.h ****/
  7302. /**** skipping file: internals.h ****/
  7303. struct exp32_sig64 softfloat_normSubnormalExtF80Sig( uint_fast64_t sig )
  7304. {
  7305. int_fast8_t shiftDist;
  7306. struct exp32_sig64 z;
  7307. shiftDist = softfloat_countLeadingZeros64( sig );
  7308. z.exp = -shiftDist;
  7309. z.sig = sig<<shiftDist;
  7310. return z;
  7311. }
  7312. /**** ended inlining ../../source/s_normSubnormalExtF80Sig.c ****/
  7313. /**** start inlining ../../source/s_roundPackToExtF80.c ****/
  7314. /*============================================================================
  7315. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  7316. Package, Release 3e, by John R. Hauser.
  7317. Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
  7318. California. All rights reserved.
  7319. Redistribution and use in source and binary forms, with or without
  7320. modification, are permitted provided that the following conditions are met:
  7321. 1. Redistributions of source code must retain the above copyright notice,
  7322. this list of conditions, and the following disclaimer.
  7323. 2. Redistributions in binary form must reproduce the above copyright notice,
  7324. this list of conditions, and the following disclaimer in the documentation
  7325. and/or other materials provided with the distribution.
  7326. 3. Neither the name of the University nor the names of its contributors may
  7327. be used to endorse or promote products derived from this software without
  7328. specific prior written permission.
  7329. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  7330. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  7331. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  7332. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  7333. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  7334. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  7335. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  7336. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  7337. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  7338. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  7339. =============================================================================*/
  7340. #include <stdbool.h>
  7341. #include <stdint.h>
  7342. /**** skipping file: platform.h ****/
  7343. /**** skipping file: internals.h ****/
  7344. /**** skipping file: softfloat.h ****/
  7345. extFloat80_t
  7346. softfloat_roundPackToExtF80(
  7347. bool sign,
  7348. int_fast32_t exp,
  7349. uint_fast64_t sig,
  7350. uint_fast64_t sigExtra,
  7351. uint_fast8_t roundingPrecision
  7352. )
  7353. {
  7354. uint_fast8_t roundingMode;
  7355. bool roundNearEven;
  7356. uint_fast64_t roundIncrement, roundMask, roundBits;
  7357. bool isTiny, doIncrement;
  7358. struct uint64_extra sig64Extra;
  7359. union { struct extFloat80M s; extFloat80_t f; } uZ;
  7360. /*------------------------------------------------------------------------
  7361. *------------------------------------------------------------------------*/
  7362. roundingMode = softfloat_roundingMode;
  7363. roundNearEven = (roundingMode == softfloat_round_near_even);
  7364. if ( roundingPrecision == 80 ) goto precision80;
  7365. if ( roundingPrecision == 64 ) {
  7366. roundIncrement = UINT64_C( 0x0000000000000400 );
  7367. roundMask = UINT64_C( 0x00000000000007FF );
  7368. } else if ( roundingPrecision == 32 ) {
  7369. roundIncrement = UINT64_C( 0x0000008000000000 );
  7370. roundMask = UINT64_C( 0x000000FFFFFFFFFF );
  7371. } else {
  7372. goto precision80;
  7373. }
  7374. sig |= (sigExtra != 0);
  7375. if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
  7376. roundIncrement =
  7377. (roundingMode
  7378. == (sign ? softfloat_round_min : softfloat_round_max))
  7379. ? roundMask
  7380. : 0;
  7381. }
  7382. roundBits = sig & roundMask;
  7383. /*------------------------------------------------------------------------
  7384. *------------------------------------------------------------------------*/
  7385. if ( 0x7FFD <= (uint32_t) (exp - 1) ) {
  7386. if ( exp <= 0 ) {
  7387. /*----------------------------------------------------------------
  7388. *----------------------------------------------------------------*/
  7389. isTiny =
  7390. (softfloat_detectTininess
  7391. == softfloat_tininess_beforeRounding)
  7392. || (exp < 0)
  7393. || (sig <= (uint64_t) (sig + roundIncrement));
  7394. sig = softfloat_shiftRightJam64( sig, 1 - exp );
  7395. roundBits = sig & roundMask;
  7396. if ( roundBits ) {
  7397. if ( isTiny ) softfloat_raiseFlags( softfloat_flag_underflow );
  7398. softfloat_exceptionFlags |= softfloat_flag_inexact;
  7399. #ifdef SOFTFLOAT_ROUND_ODD
  7400. if ( roundingMode == softfloat_round_odd ) {
  7401. sig |= roundMask + 1;
  7402. }
  7403. #endif
  7404. }
  7405. sig += roundIncrement;
  7406. exp = ((sig & UINT64_C( 0x8000000000000000 )) != 0);
  7407. roundIncrement = roundMask + 1;
  7408. if ( roundNearEven && (roundBits<<1 == roundIncrement) ) {
  7409. roundMask |= roundIncrement;
  7410. }
  7411. sig &= ~roundMask;
  7412. goto packReturn;
  7413. }
  7414. if (
  7415. (0x7FFE < exp)
  7416. || ((exp == 0x7FFE) && ((uint64_t) (sig + roundIncrement) < sig))
  7417. ) {
  7418. goto overflow;
  7419. }
  7420. }
  7421. /*------------------------------------------------------------------------
  7422. *------------------------------------------------------------------------*/
  7423. if ( roundBits ) {
  7424. softfloat_exceptionFlags |= softfloat_flag_inexact;
  7425. #ifdef SOFTFLOAT_ROUND_ODD
  7426. if ( roundingMode == softfloat_round_odd ) {
  7427. sig = (sig & ~roundMask) | (roundMask + 1);
  7428. goto packReturn;
  7429. }
  7430. #endif
  7431. }
  7432. sig = (uint64_t) (sig + roundIncrement);
  7433. if ( sig < roundIncrement ) {
  7434. ++exp;
  7435. sig = UINT64_C( 0x8000000000000000 );
  7436. }
  7437. roundIncrement = roundMask + 1;
  7438. if ( roundNearEven && (roundBits<<1 == roundIncrement) ) {
  7439. roundMask |= roundIncrement;
  7440. }
  7441. sig &= ~roundMask;
  7442. goto packReturn;
  7443. /*------------------------------------------------------------------------
  7444. *------------------------------------------------------------------------*/
  7445. precision80:
  7446. doIncrement = (UINT64_C( 0x8000000000000000 ) <= sigExtra);
  7447. if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
  7448. doIncrement =
  7449. (roundingMode
  7450. == (sign ? softfloat_round_min : softfloat_round_max))
  7451. && sigExtra;
  7452. }
  7453. /*------------------------------------------------------------------------
  7454. *------------------------------------------------------------------------*/
  7455. if ( 0x7FFD <= (uint32_t) (exp - 1) ) {
  7456. if ( exp <= 0 ) {
  7457. /*----------------------------------------------------------------
  7458. *----------------------------------------------------------------*/
  7459. isTiny =
  7460. (softfloat_detectTininess
  7461. == softfloat_tininess_beforeRounding)
  7462. || (exp < 0)
  7463. || ! doIncrement
  7464. || (sig < UINT64_C( 0xFFFFFFFFFFFFFFFF ));
  7465. sig64Extra =
  7466. softfloat_shiftRightJam64Extra( sig, sigExtra, 1 - exp );
  7467. exp = 0;
  7468. sig = sig64Extra.v;
  7469. sigExtra = sig64Extra.extra;
  7470. if ( sigExtra ) {
  7471. if ( isTiny ) softfloat_raiseFlags( softfloat_flag_underflow );
  7472. softfloat_exceptionFlags |= softfloat_flag_inexact;
  7473. #ifdef SOFTFLOAT_ROUND_ODD
  7474. if ( roundingMode == softfloat_round_odd ) {
  7475. sig |= 1;
  7476. goto packReturn;
  7477. }
  7478. #endif
  7479. }
  7480. doIncrement = (UINT64_C( 0x8000000000000000 ) <= sigExtra);
  7481. if (
  7482. ! roundNearEven
  7483. && (roundingMode != softfloat_round_near_maxMag)
  7484. ) {
  7485. doIncrement =
  7486. (roundingMode
  7487. == (sign ? softfloat_round_min : softfloat_round_max))
  7488. && sigExtra;
  7489. }
  7490. if ( doIncrement ) {
  7491. ++sig;
  7492. sig &=
  7493. ~(uint_fast64_t)
  7494. (! (sigExtra & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
  7495. & roundNearEven);
  7496. exp = ((sig & UINT64_C( 0x8000000000000000 )) != 0);
  7497. }
  7498. goto packReturn;
  7499. }
  7500. if (
  7501. (0x7FFE < exp)
  7502. || ((exp == 0x7FFE) && (sig == UINT64_C( 0xFFFFFFFFFFFFFFFF ))
  7503. && doIncrement)
  7504. ) {
  7505. /*----------------------------------------------------------------
  7506. *----------------------------------------------------------------*/
  7507. roundMask = 0;
  7508. overflow:
  7509. softfloat_raiseFlags(
  7510. softfloat_flag_overflow | softfloat_flag_inexact );
  7511. if (
  7512. roundNearEven
  7513. || (roundingMode == softfloat_round_near_maxMag)
  7514. || (roundingMode
  7515. == (sign ? softfloat_round_min : softfloat_round_max))
  7516. ) {
  7517. exp = 0x7FFF;
  7518. sig = UINT64_C( 0x8000000000000000 );
  7519. } else {
  7520. exp = 0x7FFE;
  7521. sig = ~roundMask;
  7522. }
  7523. goto packReturn;
  7524. }
  7525. }
  7526. /*------------------------------------------------------------------------
  7527. *------------------------------------------------------------------------*/
  7528. if ( sigExtra ) {
  7529. softfloat_exceptionFlags |= softfloat_flag_inexact;
  7530. #ifdef SOFTFLOAT_ROUND_ODD
  7531. if ( roundingMode == softfloat_round_odd ) {
  7532. sig |= 1;
  7533. goto packReturn;
  7534. }
  7535. #endif
  7536. }
  7537. if ( doIncrement ) {
  7538. ++sig;
  7539. if ( ! sig ) {
  7540. ++exp;
  7541. sig = UINT64_C( 0x8000000000000000 );
  7542. } else {
  7543. sig &=
  7544. ~(uint_fast64_t)
  7545. (! (sigExtra & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
  7546. & roundNearEven);
  7547. }
  7548. }
  7549. /*------------------------------------------------------------------------
  7550. *------------------------------------------------------------------------*/
  7551. packReturn:
  7552. uZ.s.signExp = packToExtF80UI64( sign, exp );
  7553. uZ.s.signif = sig;
  7554. return uZ.f;
  7555. }
  7556. /**** ended inlining ../../source/s_roundPackToExtF80.c ****/
  7557. /**** start inlining ../../source/s_normRoundPackToExtF80.c ****/
  7558. /*============================================================================
  7559. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  7560. Package, Release 3e, by John R. Hauser.
  7561. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  7562. California. All rights reserved.
  7563. Redistribution and use in source and binary forms, with or without
  7564. modification, are permitted provided that the following conditions are met:
  7565. 1. Redistributions of source code must retain the above copyright notice,
  7566. this list of conditions, and the following disclaimer.
  7567. 2. Redistributions in binary form must reproduce the above copyright notice,
  7568. this list of conditions, and the following disclaimer in the documentation
  7569. and/or other materials provided with the distribution.
  7570. 3. Neither the name of the University nor the names of its contributors may
  7571. be used to endorse or promote products derived from this software without
  7572. specific prior written permission.
  7573. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  7574. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  7575. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  7576. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  7577. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  7578. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  7579. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  7580. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  7581. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  7582. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  7583. =============================================================================*/
  7584. #include <stdbool.h>
  7585. #include <stdint.h>
  7586. /**** skipping file: platform.h ****/
  7587. /**** skipping file: internals.h ****/
  7588. extFloat80_t
  7589. softfloat_normRoundPackToExtF80(
  7590. bool sign,
  7591. int_fast32_t exp,
  7592. uint_fast64_t sig,
  7593. uint_fast64_t sigExtra,
  7594. uint_fast8_t roundingPrecision
  7595. )
  7596. {
  7597. int_fast8_t shiftDist;
  7598. struct uint128 sig128;
  7599. if ( ! sig ) {
  7600. exp -= 64;
  7601. sig = sigExtra;
  7602. sigExtra = 0;
  7603. }
  7604. shiftDist = softfloat_countLeadingZeros64( sig );
  7605. exp -= shiftDist;
  7606. if ( shiftDist ) {
  7607. sig128 = softfloat_shortShiftLeft128( sig, sigExtra, shiftDist );
  7608. sig = sig128.v64;
  7609. sigExtra = sig128.v0;
  7610. }
  7611. return
  7612. softfloat_roundPackToExtF80(
  7613. sign, exp, sig, sigExtra, roundingPrecision );
  7614. }
  7615. /**** ended inlining ../../source/s_normRoundPackToExtF80.c ****/
  7616. /**** start inlining ../../source/s_addMagsExtF80.c ****/
  7617. /*============================================================================
  7618. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  7619. Package, Release 3e, by John R. Hauser.
  7620. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  7621. All rights reserved.
  7622. Redistribution and use in source and binary forms, with or without
  7623. modification, are permitted provided that the following conditions are met:
  7624. 1. Redistributions of source code must retain the above copyright notice,
  7625. this list of conditions, and the following disclaimer.
  7626. 2. Redistributions in binary form must reproduce the above copyright notice,
  7627. this list of conditions, and the following disclaimer in the documentation
  7628. and/or other materials provided with the distribution.
  7629. 3. Neither the name of the University nor the names of its contributors may
  7630. be used to endorse or promote products derived from this software without
  7631. specific prior written permission.
  7632. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  7633. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  7634. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  7635. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  7636. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  7637. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  7638. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  7639. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  7640. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  7641. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  7642. =============================================================================*/
  7643. #include <stdbool.h>
  7644. #include <stdint.h>
  7645. /**** skipping file: platform.h ****/
  7646. /**** skipping file: internals.h ****/
  7647. /**** skipping file: specialize.h ****/
  7648. /**** skipping file: softfloat.h ****/
  7649. extFloat80_t
  7650. softfloat_addMagsExtF80(
  7651. uint_fast16_t uiA64,
  7652. uint_fast64_t uiA0,
  7653. uint_fast16_t uiB64,
  7654. uint_fast64_t uiB0,
  7655. bool signZ
  7656. )
  7657. {
  7658. int_fast32_t expA;
  7659. uint_fast64_t sigA;
  7660. int_fast32_t expB;
  7661. uint_fast64_t sigB;
  7662. int_fast32_t expDiff;
  7663. uint_fast16_t uiZ64;
  7664. uint_fast64_t uiZ0, sigZ, sigZExtra;
  7665. struct exp32_sig64 normExpSig;
  7666. int_fast32_t expZ;
  7667. struct uint64_extra sig64Extra;
  7668. struct uint128 uiZ;
  7669. union { struct extFloat80M s; extFloat80_t f; } uZ;
  7670. /*------------------------------------------------------------------------
  7671. *------------------------------------------------------------------------*/
  7672. expA = expExtF80UI64( uiA64 );
  7673. sigA = uiA0;
  7674. expB = expExtF80UI64( uiB64 );
  7675. sigB = uiB0;
  7676. /*------------------------------------------------------------------------
  7677. *------------------------------------------------------------------------*/
  7678. expDiff = expA - expB;
  7679. if ( ! expDiff ) {
  7680. if ( expA == 0x7FFF ) {
  7681. if ( (sigA | sigB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
  7682. goto propagateNaN;
  7683. }
  7684. uiZ64 = uiA64;
  7685. uiZ0 = uiA0;
  7686. goto uiZ;
  7687. }
  7688. sigZ = sigA + sigB;
  7689. sigZExtra = 0;
  7690. if ( ! expA ) {
  7691. normExpSig = softfloat_normSubnormalExtF80Sig( sigZ );
  7692. expZ = normExpSig.exp + 1;
  7693. sigZ = normExpSig.sig;
  7694. goto roundAndPack;
  7695. }
  7696. expZ = expA;
  7697. goto shiftRight1;
  7698. }
  7699. /*------------------------------------------------------------------------
  7700. *------------------------------------------------------------------------*/
  7701. if ( expDiff < 0 ) {
  7702. if ( expB == 0x7FFF ) {
  7703. if ( sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
  7704. uiZ64 = packToExtF80UI64( signZ, 0x7FFF );
  7705. uiZ0 = uiB0;
  7706. goto uiZ;
  7707. }
  7708. expZ = expB;
  7709. if ( ! expA ) {
  7710. ++expDiff;
  7711. sigZExtra = 0;
  7712. if ( ! expDiff ) goto newlyAligned;
  7713. }
  7714. sig64Extra = softfloat_shiftRightJam64Extra( sigA, 0, -expDiff );
  7715. sigA = sig64Extra.v;
  7716. sigZExtra = sig64Extra.extra;
  7717. } else {
  7718. if ( expA == 0x7FFF ) {
  7719. if ( sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
  7720. uiZ64 = uiA64;
  7721. uiZ0 = uiA0;
  7722. goto uiZ;
  7723. }
  7724. expZ = expA;
  7725. if ( ! expB ) {
  7726. --expDiff;
  7727. sigZExtra = 0;
  7728. if ( ! expDiff ) goto newlyAligned;
  7729. }
  7730. sig64Extra = softfloat_shiftRightJam64Extra( sigB, 0, expDiff );
  7731. sigB = sig64Extra.v;
  7732. sigZExtra = sig64Extra.extra;
  7733. }
  7734. newlyAligned:
  7735. sigZ = sigA + sigB;
  7736. if ( sigZ & UINT64_C( 0x8000000000000000 ) ) goto roundAndPack;
  7737. /*------------------------------------------------------------------------
  7738. *------------------------------------------------------------------------*/
  7739. shiftRight1:
  7740. sig64Extra = softfloat_shortShiftRightJam64Extra( sigZ, sigZExtra, 1 );
  7741. sigZ = sig64Extra.v | UINT64_C( 0x8000000000000000 );
  7742. sigZExtra = sig64Extra.extra;
  7743. ++expZ;
  7744. roundAndPack:
  7745. return
  7746. softfloat_roundPackToExtF80(
  7747. signZ, expZ, sigZ, sigZExtra, extF80_roundingPrecision );
  7748. /*------------------------------------------------------------------------
  7749. *------------------------------------------------------------------------*/
  7750. propagateNaN:
  7751. uiZ = softfloat_propagateNaNExtF80UI( uiA64, uiA0, uiB64, uiB0 );
  7752. uiZ64 = uiZ.v64;
  7753. uiZ0 = uiZ.v0;
  7754. uiZ:
  7755. uZ.s.signExp = uiZ64;
  7756. uZ.s.signif = uiZ0;
  7757. return uZ.f;
  7758. }
  7759. /**** ended inlining ../../source/s_addMagsExtF80.c ****/
  7760. /**** start inlining ../../source/s_subMagsExtF80.c ****/
  7761. /*============================================================================
  7762. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  7763. Package, Release 3e, by John R. Hauser.
  7764. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  7765. California. All rights reserved.
  7766. Redistribution and use in source and binary forms, with or without
  7767. modification, are permitted provided that the following conditions are met:
  7768. 1. Redistributions of source code must retain the above copyright notice,
  7769. this list of conditions, and the following disclaimer.
  7770. 2. Redistributions in binary form must reproduce the above copyright notice,
  7771. this list of conditions, and the following disclaimer in the documentation
  7772. and/or other materials provided with the distribution.
  7773. 3. Neither the name of the University nor the names of its contributors may
  7774. be used to endorse or promote products derived from this software without
  7775. specific prior written permission.
  7776. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  7777. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  7778. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  7779. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  7780. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  7781. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  7782. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  7783. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  7784. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  7785. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  7786. =============================================================================*/
  7787. #include <stdbool.h>
  7788. #include <stdint.h>
  7789. /**** skipping file: platform.h ****/
  7790. /**** skipping file: internals.h ****/
  7791. /**** skipping file: specialize.h ****/
  7792. /**** skipping file: softfloat.h ****/
  7793. extFloat80_t
  7794. softfloat_subMagsExtF80(
  7795. uint_fast16_t uiA64,
  7796. uint_fast64_t uiA0,
  7797. uint_fast16_t uiB64,
  7798. uint_fast64_t uiB0,
  7799. bool signZ
  7800. )
  7801. {
  7802. int_fast32_t expA;
  7803. uint_fast64_t sigA;
  7804. int_fast32_t expB;
  7805. uint_fast64_t sigB;
  7806. int_fast32_t expDiff;
  7807. uint_fast16_t uiZ64;
  7808. uint_fast64_t uiZ0;
  7809. int_fast32_t expZ;
  7810. uint_fast64_t sigExtra;
  7811. struct uint128 sig128, uiZ;
  7812. union { struct extFloat80M s; extFloat80_t f; } uZ;
  7813. /*------------------------------------------------------------------------
  7814. *------------------------------------------------------------------------*/
  7815. expA = expExtF80UI64( uiA64 );
  7816. sigA = uiA0;
  7817. expB = expExtF80UI64( uiB64 );
  7818. sigB = uiB0;
  7819. /*------------------------------------------------------------------------
  7820. *------------------------------------------------------------------------*/
  7821. expDiff = expA - expB;
  7822. if ( 0 < expDiff ) goto expABigger;
  7823. if ( expDiff < 0 ) goto expBBigger;
  7824. if ( expA == 0x7FFF ) {
  7825. if ( (sigA | sigB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
  7826. goto propagateNaN;
  7827. }
  7828. softfloat_raiseFlags( softfloat_flag_invalid );
  7829. uiZ64 = defaultNaNExtF80UI64;
  7830. uiZ0 = defaultNaNExtF80UI0;
  7831. goto uiZ;
  7832. }
  7833. /*------------------------------------------------------------------------
  7834. *------------------------------------------------------------------------*/
  7835. expZ = expA;
  7836. if ( ! expZ ) expZ = 1;
  7837. sigExtra = 0;
  7838. if ( sigB < sigA ) goto aBigger;
  7839. if ( sigA < sigB ) goto bBigger;
  7840. uiZ64 =
  7841. packToExtF80UI64( (softfloat_roundingMode == softfloat_round_min), 0 );
  7842. uiZ0 = 0;
  7843. goto uiZ;
  7844. /*------------------------------------------------------------------------
  7845. *------------------------------------------------------------------------*/
  7846. expBBigger:
  7847. if ( expB == 0x7FFF ) {
  7848. if ( sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
  7849. uiZ64 = packToExtF80UI64( signZ ^ 1, 0x7FFF );
  7850. uiZ0 = UINT64_C( 0x8000000000000000 );
  7851. goto uiZ;
  7852. }
  7853. if ( ! expA ) {
  7854. ++expDiff;
  7855. sigExtra = 0;
  7856. if ( ! expDiff ) goto newlyAlignedBBigger;
  7857. }
  7858. sig128 = softfloat_shiftRightJam128( sigA, 0, -expDiff );
  7859. sigA = sig128.v64;
  7860. sigExtra = sig128.v0;
  7861. newlyAlignedBBigger:
  7862. expZ = expB;
  7863. bBigger:
  7864. signZ = ! signZ;
  7865. sig128 = softfloat_sub128( sigB, 0, sigA, sigExtra );
  7866. goto normRoundPack;
  7867. /*------------------------------------------------------------------------
  7868. *------------------------------------------------------------------------*/
  7869. expABigger:
  7870. if ( expA == 0x7FFF ) {
  7871. if ( sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
  7872. uiZ64 = uiA64;
  7873. uiZ0 = uiA0;
  7874. goto uiZ;
  7875. }
  7876. if ( ! expB ) {
  7877. --expDiff;
  7878. sigExtra = 0;
  7879. if ( ! expDiff ) goto newlyAlignedABigger;
  7880. }
  7881. sig128 = softfloat_shiftRightJam128( sigB, 0, expDiff );
  7882. sigB = sig128.v64;
  7883. sigExtra = sig128.v0;
  7884. newlyAlignedABigger:
  7885. expZ = expA;
  7886. aBigger:
  7887. sig128 = softfloat_sub128( sigA, 0, sigB, sigExtra );
  7888. /*------------------------------------------------------------------------
  7889. *------------------------------------------------------------------------*/
  7890. normRoundPack:
  7891. return
  7892. softfloat_normRoundPackToExtF80(
  7893. signZ, expZ, sig128.v64, sig128.v0, extF80_roundingPrecision );
  7894. /*------------------------------------------------------------------------
  7895. *------------------------------------------------------------------------*/
  7896. propagateNaN:
  7897. uiZ = softfloat_propagateNaNExtF80UI( uiA64, uiA0, uiB64, uiB0 );
  7898. uiZ64 = uiZ.v64;
  7899. uiZ0 = uiZ.v0;
  7900. uiZ:
  7901. uZ.s.signExp = uiZ64;
  7902. uZ.s.signif = uiZ0;
  7903. return uZ.f;
  7904. }
  7905. /**** ended inlining ../../source/s_subMagsExtF80.c ****/
  7906. /**** start inlining ../../source/s_normSubnormalF128Sig.c ****/
  7907. /*============================================================================
  7908. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  7909. Package, Release 3e, by John R. Hauser.
  7910. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  7911. California. All rights reserved.
  7912. Redistribution and use in source and binary forms, with or without
  7913. modification, are permitted provided that the following conditions are met:
  7914. 1. Redistributions of source code must retain the above copyright notice,
  7915. this list of conditions, and the following disclaimer.
  7916. 2. Redistributions in binary form must reproduce the above copyright notice,
  7917. this list of conditions, and the following disclaimer in the documentation
  7918. and/or other materials provided with the distribution.
  7919. 3. Neither the name of the University nor the names of its contributors may
  7920. be used to endorse or promote products derived from this software without
  7921. specific prior written permission.
  7922. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  7923. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  7924. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  7925. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  7926. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  7927. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  7928. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  7929. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  7930. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  7931. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  7932. =============================================================================*/
  7933. #include <stdint.h>
  7934. /**** skipping file: platform.h ****/
  7935. /**** skipping file: internals.h ****/
  7936. struct exp32_sig128
  7937. softfloat_normSubnormalF128Sig( uint_fast64_t sig64, uint_fast64_t sig0 )
  7938. {
  7939. int_fast8_t shiftDist;
  7940. struct exp32_sig128 z;
  7941. if ( ! sig64 ) {
  7942. shiftDist = softfloat_countLeadingZeros64( sig0 ) - 15;
  7943. z.exp = -63 - shiftDist;
  7944. if ( shiftDist < 0 ) {
  7945. z.sig.v64 = sig0>>-shiftDist;
  7946. z.sig.v0 = sig0<<(shiftDist & 63);
  7947. } else {
  7948. z.sig.v64 = sig0<<shiftDist;
  7949. z.sig.v0 = 0;
  7950. }
  7951. } else {
  7952. shiftDist = softfloat_countLeadingZeros64( sig64 ) - 15;
  7953. z.exp = 1 - shiftDist;
  7954. z.sig = softfloat_shortShiftLeft128( sig64, sig0, shiftDist );
  7955. }
  7956. return z;
  7957. }
  7958. /**** ended inlining ../../source/s_normSubnormalF128Sig.c ****/
  7959. /**** start inlining ../../source/s_roundPackToF128.c ****/
  7960. /*============================================================================
  7961. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  7962. Package, Release 3e, by John R. Hauser.
  7963. Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
  7964. California. All rights reserved.
  7965. Redistribution and use in source and binary forms, with or without
  7966. modification, are permitted provided that the following conditions are met:
  7967. 1. Redistributions of source code must retain the above copyright notice,
  7968. this list of conditions, and the following disclaimer.
  7969. 2. Redistributions in binary form must reproduce the above copyright notice,
  7970. this list of conditions, and the following disclaimer in the documentation
  7971. and/or other materials provided with the distribution.
  7972. 3. Neither the name of the University nor the names of its contributors may
  7973. be used to endorse or promote products derived from this software without
  7974. specific prior written permission.
  7975. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  7976. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  7977. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  7978. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  7979. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  7980. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  7981. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  7982. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  7983. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  7984. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  7985. =============================================================================*/
  7986. #include <stdbool.h>
  7987. #include <stdint.h>
  7988. /**** skipping file: platform.h ****/
  7989. /**** skipping file: internals.h ****/
  7990. /**** skipping file: softfloat.h ****/
  7991. float128_t
  7992. softfloat_roundPackToF128(
  7993. bool sign,
  7994. int_fast32_t exp,
  7995. uint_fast64_t sig64,
  7996. uint_fast64_t sig0,
  7997. uint_fast64_t sigExtra
  7998. )
  7999. {
  8000. uint_fast8_t roundingMode;
  8001. bool roundNearEven, doIncrement, isTiny;
  8002. struct uint128_extra sig128Extra;
  8003. uint_fast64_t uiZ64, uiZ0;
  8004. struct uint128 sig128;
  8005. union ui128_f128 uZ;
  8006. /*------------------------------------------------------------------------
  8007. *------------------------------------------------------------------------*/
  8008. roundingMode = softfloat_roundingMode;
  8009. roundNearEven = (roundingMode == softfloat_round_near_even);
  8010. doIncrement = (UINT64_C( 0x8000000000000000 ) <= sigExtra);
  8011. if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
  8012. doIncrement =
  8013. (roundingMode
  8014. == (sign ? softfloat_round_min : softfloat_round_max))
  8015. && sigExtra;
  8016. }
  8017. /*------------------------------------------------------------------------
  8018. *------------------------------------------------------------------------*/
  8019. if ( 0x7FFD <= (uint32_t) exp ) {
  8020. if ( exp < 0 ) {
  8021. /*----------------------------------------------------------------
  8022. *----------------------------------------------------------------*/
  8023. isTiny =
  8024. (softfloat_detectTininess
  8025. == softfloat_tininess_beforeRounding)
  8026. || (exp < -1)
  8027. || ! doIncrement
  8028. || softfloat_lt128(
  8029. sig64,
  8030. sig0,
  8031. UINT64_C( 0x0001FFFFFFFFFFFF ),
  8032. UINT64_C( 0xFFFFFFFFFFFFFFFF )
  8033. );
  8034. sig128Extra =
  8035. softfloat_shiftRightJam128Extra( sig64, sig0, sigExtra, -exp );
  8036. sig64 = sig128Extra.v.v64;
  8037. sig0 = sig128Extra.v.v0;
  8038. sigExtra = sig128Extra.extra;
  8039. exp = 0;
  8040. if ( isTiny && sigExtra ) {
  8041. softfloat_raiseFlags( softfloat_flag_underflow );
  8042. }
  8043. doIncrement = (UINT64_C( 0x8000000000000000 ) <= sigExtra);
  8044. if (
  8045. ! roundNearEven
  8046. && (roundingMode != softfloat_round_near_maxMag)
  8047. ) {
  8048. doIncrement =
  8049. (roundingMode
  8050. == (sign ? softfloat_round_min : softfloat_round_max))
  8051. && sigExtra;
  8052. }
  8053. } else if (
  8054. (0x7FFD < exp)
  8055. || ((exp == 0x7FFD)
  8056. && softfloat_eq128(
  8057. sig64,
  8058. sig0,
  8059. UINT64_C( 0x0001FFFFFFFFFFFF ),
  8060. UINT64_C( 0xFFFFFFFFFFFFFFFF )
  8061. )
  8062. && doIncrement)
  8063. ) {
  8064. /*----------------------------------------------------------------
  8065. *----------------------------------------------------------------*/
  8066. softfloat_raiseFlags(
  8067. softfloat_flag_overflow | softfloat_flag_inexact );
  8068. if (
  8069. roundNearEven
  8070. || (roundingMode == softfloat_round_near_maxMag)
  8071. || (roundingMode
  8072. == (sign ? softfloat_round_min : softfloat_round_max))
  8073. ) {
  8074. uiZ64 = packToF128UI64( sign, 0x7FFF, 0 );
  8075. uiZ0 = 0;
  8076. } else {
  8077. uiZ64 =
  8078. packToF128UI64(
  8079. sign, 0x7FFE, UINT64_C( 0x0000FFFFFFFFFFFF ) );
  8080. uiZ0 = UINT64_C( 0xFFFFFFFFFFFFFFFF );
  8081. }
  8082. goto uiZ;
  8083. }
  8084. }
  8085. /*------------------------------------------------------------------------
  8086. *------------------------------------------------------------------------*/
  8087. if ( sigExtra ) {
  8088. softfloat_exceptionFlags |= softfloat_flag_inexact;
  8089. #ifdef SOFTFLOAT_ROUND_ODD
  8090. if ( roundingMode == softfloat_round_odd ) {
  8091. sig0 |= 1;
  8092. goto packReturn;
  8093. }
  8094. #endif
  8095. }
  8096. if ( doIncrement ) {
  8097. sig128 = softfloat_add128( sig64, sig0, 0, 1 );
  8098. sig64 = sig128.v64;
  8099. sig0 =
  8100. sig128.v0
  8101. & ~(uint64_t)
  8102. (! (sigExtra & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
  8103. & roundNearEven);
  8104. } else {
  8105. if ( ! (sig64 | sig0) ) exp = 0;
  8106. }
  8107. /*------------------------------------------------------------------------
  8108. *------------------------------------------------------------------------*/
  8109. packReturn:
  8110. uiZ64 = packToF128UI64( sign, exp, sig64 );
  8111. uiZ0 = sig0;
  8112. uiZ:
  8113. uZ.ui.v64 = uiZ64;
  8114. uZ.ui.v0 = uiZ0;
  8115. return uZ.f;
  8116. }
  8117. /**** ended inlining ../../source/s_roundPackToF128.c ****/
  8118. /**** start inlining ../../source/s_normRoundPackToF128.c ****/
  8119. /*============================================================================
  8120. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  8121. Package, Release 3e, by John R. Hauser.
  8122. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  8123. California. All rights reserved.
  8124. Redistribution and use in source and binary forms, with or without
  8125. modification, are permitted provided that the following conditions are met:
  8126. 1. Redistributions of source code must retain the above copyright notice,
  8127. this list of conditions, and the following disclaimer.
  8128. 2. Redistributions in binary form must reproduce the above copyright notice,
  8129. this list of conditions, and the following disclaimer in the documentation
  8130. and/or other materials provided with the distribution.
  8131. 3. Neither the name of the University nor the names of its contributors may
  8132. be used to endorse or promote products derived from this software without
  8133. specific prior written permission.
  8134. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  8135. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  8136. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  8137. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  8138. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  8139. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  8140. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  8141. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  8142. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  8143. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  8144. =============================================================================*/
  8145. #include <stdbool.h>
  8146. #include <stdint.h>
  8147. /**** skipping file: platform.h ****/
  8148. /**** skipping file: internals.h ****/
  8149. float128_t
  8150. softfloat_normRoundPackToF128(
  8151. bool sign, int_fast32_t exp, uint_fast64_t sig64, uint_fast64_t sig0 )
  8152. {
  8153. int_fast8_t shiftDist;
  8154. struct uint128 sig128;
  8155. union ui128_f128 uZ;
  8156. uint_fast64_t sigExtra;
  8157. struct uint128_extra sig128Extra;
  8158. if ( ! sig64 ) {
  8159. exp -= 64;
  8160. sig64 = sig0;
  8161. sig0 = 0;
  8162. }
  8163. shiftDist = softfloat_countLeadingZeros64( sig64 ) - 15;
  8164. exp -= shiftDist;
  8165. if ( 0 <= shiftDist ) {
  8166. if ( shiftDist ) {
  8167. sig128 = softfloat_shortShiftLeft128( sig64, sig0, shiftDist );
  8168. sig64 = sig128.v64;
  8169. sig0 = sig128.v0;
  8170. }
  8171. if ( (uint32_t) exp < 0x7FFD ) {
  8172. uZ.ui.v64 = packToF128UI64( sign, sig64 | sig0 ? exp : 0, sig64 );
  8173. uZ.ui.v0 = sig0;
  8174. return uZ.f;
  8175. }
  8176. sigExtra = 0;
  8177. } else {
  8178. sig128Extra =
  8179. softfloat_shortShiftRightJam128Extra( sig64, sig0, 0, -shiftDist );
  8180. sig64 = sig128Extra.v.v64;
  8181. sig0 = sig128Extra.v.v0;
  8182. sigExtra = sig128Extra.extra;
  8183. }
  8184. return softfloat_roundPackToF128( sign, exp, sig64, sig0, sigExtra );
  8185. }
  8186. /**** ended inlining ../../source/s_normRoundPackToF128.c ****/
  8187. /**** start inlining ../../source/s_addMagsF128.c ****/
  8188. /*============================================================================
  8189. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  8190. Package, Release 3e, by John R. Hauser.
  8191. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  8192. All rights reserved.
  8193. Redistribution and use in source and binary forms, with or without
  8194. modification, are permitted provided that the following conditions are met:
  8195. 1. Redistributions of source code must retain the above copyright notice,
  8196. this list of conditions, and the following disclaimer.
  8197. 2. Redistributions in binary form must reproduce the above copyright notice,
  8198. this list of conditions, and the following disclaimer in the documentation
  8199. and/or other materials provided with the distribution.
  8200. 3. Neither the name of the University nor the names of its contributors may
  8201. be used to endorse or promote products derived from this software without
  8202. specific prior written permission.
  8203. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  8204. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  8205. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  8206. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  8207. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  8208. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  8209. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  8210. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  8211. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  8212. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  8213. =============================================================================*/
  8214. #include <stdbool.h>
  8215. #include <stdint.h>
  8216. /**** skipping file: platform.h ****/
  8217. /**** skipping file: internals.h ****/
  8218. /**** skipping file: specialize.h ****/
  8219. float128_t
  8220. softfloat_addMagsF128(
  8221. uint_fast64_t uiA64,
  8222. uint_fast64_t uiA0,
  8223. uint_fast64_t uiB64,
  8224. uint_fast64_t uiB0,
  8225. bool signZ
  8226. )
  8227. {
  8228. int_fast32_t expA;
  8229. struct uint128 sigA;
  8230. int_fast32_t expB;
  8231. struct uint128 sigB;
  8232. int_fast32_t expDiff;
  8233. struct uint128 uiZ, sigZ;
  8234. int_fast32_t expZ;
  8235. uint_fast64_t sigZExtra;
  8236. struct uint128_extra sig128Extra;
  8237. union ui128_f128 uZ;
  8238. expA = expF128UI64( uiA64 );
  8239. sigA.v64 = fracF128UI64( uiA64 );
  8240. sigA.v0 = uiA0;
  8241. expB = expF128UI64( uiB64 );
  8242. sigB.v64 = fracF128UI64( uiB64 );
  8243. sigB.v0 = uiB0;
  8244. expDiff = expA - expB;
  8245. if ( ! expDiff ) {
  8246. if ( expA == 0x7FFF ) {
  8247. if ( sigA.v64 | sigA.v0 | sigB.v64 | sigB.v0 ) goto propagateNaN;
  8248. uiZ.v64 = uiA64;
  8249. uiZ.v0 = uiA0;
  8250. goto uiZ;
  8251. }
  8252. sigZ = softfloat_add128( sigA.v64, sigA.v0, sigB.v64, sigB.v0 );
  8253. if ( ! expA ) {
  8254. uiZ.v64 = packToF128UI64( signZ, 0, sigZ.v64 );
  8255. uiZ.v0 = sigZ.v0;
  8256. goto uiZ;
  8257. }
  8258. expZ = expA;
  8259. sigZ.v64 |= UINT64_C( 0x0002000000000000 );
  8260. sigZExtra = 0;
  8261. goto shiftRight1;
  8262. }
  8263. if ( expDiff < 0 ) {
  8264. if ( expB == 0x7FFF ) {
  8265. if ( sigB.v64 | sigB.v0 ) goto propagateNaN;
  8266. uiZ.v64 = packToF128UI64( signZ, 0x7FFF, 0 );
  8267. uiZ.v0 = 0;
  8268. goto uiZ;
  8269. }
  8270. expZ = expB;
  8271. if ( expA ) {
  8272. sigA.v64 |= UINT64_C( 0x0001000000000000 );
  8273. } else {
  8274. ++expDiff;
  8275. sigZExtra = 0;
  8276. if ( ! expDiff ) goto newlyAligned;
  8277. }
  8278. sig128Extra =
  8279. softfloat_shiftRightJam128Extra( sigA.v64, sigA.v0, 0, -expDiff );
  8280. sigA = sig128Extra.v;
  8281. sigZExtra = sig128Extra.extra;
  8282. } else {
  8283. if ( expA == 0x7FFF ) {
  8284. if ( sigA.v64 | sigA.v0 ) goto propagateNaN;
  8285. uiZ.v64 = uiA64;
  8286. uiZ.v0 = uiA0;
  8287. goto uiZ;
  8288. }
  8289. expZ = expA;
  8290. if ( expB ) {
  8291. sigB.v64 |= UINT64_C( 0x0001000000000000 );
  8292. } else {
  8293. --expDiff;
  8294. sigZExtra = 0;
  8295. if ( ! expDiff ) goto newlyAligned;
  8296. }
  8297. sig128Extra =
  8298. softfloat_shiftRightJam128Extra( sigB.v64, sigB.v0, 0, expDiff );
  8299. sigB = sig128Extra.v;
  8300. sigZExtra = sig128Extra.extra;
  8301. }
  8302. newlyAligned:
  8303. sigZ =
  8304. softfloat_add128(
  8305. sigA.v64 | UINT64_C( 0x0001000000000000 ),
  8306. sigA.v0,
  8307. sigB.v64,
  8308. sigB.v0
  8309. );
  8310. --expZ;
  8311. if ( sigZ.v64 < UINT64_C( 0x0002000000000000 ) ) goto roundAndPack;
  8312. ++expZ;
  8313. shiftRight1:
  8314. sig128Extra =
  8315. softfloat_shortShiftRightJam128Extra(
  8316. sigZ.v64, sigZ.v0, sigZExtra, 1 );
  8317. sigZ = sig128Extra.v;
  8318. sigZExtra = sig128Extra.extra;
  8319. roundAndPack:
  8320. return
  8321. softfloat_roundPackToF128( signZ, expZ, sigZ.v64, sigZ.v0, sigZExtra );
  8322. propagateNaN:
  8323. uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, uiB64, uiB0 );
  8324. uiZ:
  8325. uZ.ui = uiZ;
  8326. return uZ.f;
  8327. }
  8328. /**** ended inlining ../../source/s_addMagsF128.c ****/
  8329. /**** start inlining ../../source/s_subMagsF128.c ****/
  8330. /*============================================================================
  8331. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  8332. Package, Release 3e, by John R. Hauser.
  8333. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  8334. California. All rights reserved.
  8335. Redistribution and use in source and binary forms, with or without
  8336. modification, are permitted provided that the following conditions are met:
  8337. 1. Redistributions of source code must retain the above copyright notice,
  8338. this list of conditions, and the following disclaimer.
  8339. 2. Redistributions in binary form must reproduce the above copyright notice,
  8340. this list of conditions, and the following disclaimer in the documentation
  8341. and/or other materials provided with the distribution.
  8342. 3. Neither the name of the University nor the names of its contributors may
  8343. be used to endorse or promote products derived from this software without
  8344. specific prior written permission.
  8345. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  8346. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  8347. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  8348. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  8349. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  8350. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  8351. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  8352. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  8353. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  8354. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  8355. =============================================================================*/
  8356. #include <stdbool.h>
  8357. #include <stdint.h>
  8358. /**** skipping file: platform.h ****/
  8359. /**** skipping file: internals.h ****/
  8360. /**** skipping file: specialize.h ****/
  8361. /**** skipping file: softfloat.h ****/
  8362. float128_t
  8363. softfloat_subMagsF128(
  8364. uint_fast64_t uiA64,
  8365. uint_fast64_t uiA0,
  8366. uint_fast64_t uiB64,
  8367. uint_fast64_t uiB0,
  8368. bool signZ
  8369. )
  8370. {
  8371. int_fast32_t expA;
  8372. struct uint128 sigA;
  8373. int_fast32_t expB;
  8374. struct uint128 sigB, sigZ;
  8375. int_fast32_t expDiff, expZ;
  8376. struct uint128 uiZ;
  8377. union ui128_f128 uZ;
  8378. expA = expF128UI64( uiA64 );
  8379. sigA.v64 = fracF128UI64( uiA64 );
  8380. sigA.v0 = uiA0;
  8381. expB = expF128UI64( uiB64 );
  8382. sigB.v64 = fracF128UI64( uiB64 );
  8383. sigB.v0 = uiB0;
  8384. sigA = softfloat_shortShiftLeft128( sigA.v64, sigA.v0, 4 );
  8385. sigB = softfloat_shortShiftLeft128( sigB.v64, sigB.v0, 4 );
  8386. expDiff = expA - expB;
  8387. if ( 0 < expDiff ) goto expABigger;
  8388. if ( expDiff < 0 ) goto expBBigger;
  8389. if ( expA == 0x7FFF ) {
  8390. if ( sigA.v64 | sigA.v0 | sigB.v64 | sigB.v0 ) goto propagateNaN;
  8391. softfloat_raiseFlags( softfloat_flag_invalid );
  8392. uiZ.v64 = defaultNaNF128UI64;
  8393. uiZ.v0 = defaultNaNF128UI0;
  8394. goto uiZ;
  8395. }
  8396. expZ = expA;
  8397. if ( ! expZ ) expZ = 1;
  8398. if ( sigB.v64 < sigA.v64 ) goto aBigger;
  8399. if ( sigA.v64 < sigB.v64 ) goto bBigger;
  8400. if ( sigB.v0 < sigA.v0 ) goto aBigger;
  8401. if ( sigA.v0 < sigB.v0 ) goto bBigger;
  8402. uiZ.v64 =
  8403. packToF128UI64(
  8404. (softfloat_roundingMode == softfloat_round_min), 0, 0 );
  8405. uiZ.v0 = 0;
  8406. goto uiZ;
  8407. expBBigger:
  8408. if ( expB == 0x7FFF ) {
  8409. if ( sigB.v64 | sigB.v0 ) goto propagateNaN;
  8410. uiZ.v64 = packToF128UI64( signZ ^ 1, 0x7FFF, 0 );
  8411. uiZ.v0 = 0;
  8412. goto uiZ;
  8413. }
  8414. if ( expA ) {
  8415. sigA.v64 |= UINT64_C( 0x0010000000000000 );
  8416. } else {
  8417. ++expDiff;
  8418. if ( ! expDiff ) goto newlyAlignedBBigger;
  8419. }
  8420. sigA = softfloat_shiftRightJam128( sigA.v64, sigA.v0, -expDiff );
  8421. newlyAlignedBBigger:
  8422. expZ = expB;
  8423. sigB.v64 |= UINT64_C( 0x0010000000000000 );
  8424. bBigger:
  8425. signZ = ! signZ;
  8426. sigZ = softfloat_sub128( sigB.v64, sigB.v0, sigA.v64, sigA.v0 );
  8427. goto normRoundPack;
  8428. expABigger:
  8429. if ( expA == 0x7FFF ) {
  8430. if ( sigA.v64 | sigA.v0 ) goto propagateNaN;
  8431. uiZ.v64 = uiA64;
  8432. uiZ.v0 = uiA0;
  8433. goto uiZ;
  8434. }
  8435. if ( expB ) {
  8436. sigB.v64 |= UINT64_C( 0x0010000000000000 );
  8437. } else {
  8438. --expDiff;
  8439. if ( ! expDiff ) goto newlyAlignedABigger;
  8440. }
  8441. sigB = softfloat_shiftRightJam128( sigB.v64, sigB.v0, expDiff );
  8442. newlyAlignedABigger:
  8443. expZ = expA;
  8444. sigA.v64 |= UINT64_C( 0x0010000000000000 );
  8445. aBigger:
  8446. sigZ = softfloat_sub128( sigA.v64, sigA.v0, sigB.v64, sigB.v0 );
  8447. normRoundPack:
  8448. return softfloat_normRoundPackToF128( signZ, expZ - 5, sigZ.v64, sigZ.v0 );
  8449. propagateNaN:
  8450. uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, uiB64, uiB0 );
  8451. uiZ:
  8452. uZ.ui = uiZ;
  8453. return uZ.f;
  8454. }
  8455. /**** ended inlining ../../source/s_subMagsF128.c ****/
  8456. /**** start inlining ../../source/s_mulAddF128.c ****/
  8457. /*============================================================================
  8458. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  8459. Package, Release 3e, by John R. Hauser.
  8460. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  8461. California. All rights reserved.
  8462. Redistribution and use in source and binary forms, with or without
  8463. modification, are permitted provided that the following conditions are met:
  8464. 1. Redistributions of source code must retain the above copyright notice,
  8465. this list of conditions, and the following disclaimer.
  8466. 2. Redistributions in binary form must reproduce the above copyright notice,
  8467. this list of conditions, and the following disclaimer in the documentation
  8468. and/or other materials provided with the distribution.
  8469. 3. Neither the name of the University nor the names of its contributors may
  8470. be used to endorse or promote products derived from this software without
  8471. specific prior written permission.
  8472. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  8473. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  8474. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  8475. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  8476. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  8477. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  8478. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  8479. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  8480. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  8481. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  8482. =============================================================================*/
  8483. #include <stdbool.h>
  8484. #include <stdint.h>
  8485. /**** skipping file: platform.h ****/
  8486. /**** skipping file: internals.h ****/
  8487. /**** skipping file: specialize.h ****/
  8488. /**** skipping file: softfloat.h ****/
  8489. float128_t
  8490. softfloat_mulAddF128(
  8491. uint_fast64_t uiA64,
  8492. uint_fast64_t uiA0,
  8493. uint_fast64_t uiB64,
  8494. uint_fast64_t uiB0,
  8495. uint_fast64_t uiC64,
  8496. uint_fast64_t uiC0,
  8497. uint_fast8_t op
  8498. )
  8499. {
  8500. bool signA;
  8501. int_fast32_t expA;
  8502. struct uint128 sigA;
  8503. bool signB;
  8504. int_fast32_t expB;
  8505. struct uint128 sigB;
  8506. bool signC;
  8507. int_fast32_t expC;
  8508. struct uint128 sigC;
  8509. bool signZ;
  8510. uint_fast64_t magBits;
  8511. struct uint128 uiZ;
  8512. struct exp32_sig128 normExpSig;
  8513. int_fast32_t expZ;
  8514. uint64_t sig256Z[4];
  8515. struct uint128 sigZ;
  8516. int_fast32_t shiftDist, expDiff;
  8517. struct uint128 x128;
  8518. uint64_t sig256C[4];
  8519. static uint64_t zero256[4] = INIT_UINTM4( 0, 0, 0, 0 );
  8520. uint_fast64_t sigZExtra, sig256Z0;
  8521. union ui128_f128 uZ;
  8522. /*------------------------------------------------------------------------
  8523. *------------------------------------------------------------------------*/
  8524. signA = signF128UI64( uiA64 );
  8525. expA = expF128UI64( uiA64 );
  8526. sigA.v64 = fracF128UI64( uiA64 );
  8527. sigA.v0 = uiA0;
  8528. signB = signF128UI64( uiB64 );
  8529. expB = expF128UI64( uiB64 );
  8530. sigB.v64 = fracF128UI64( uiB64 );
  8531. sigB.v0 = uiB0;
  8532. signC = signF128UI64( uiC64 ) ^ (op == softfloat_mulAdd_subC);
  8533. expC = expF128UI64( uiC64 );
  8534. sigC.v64 = fracF128UI64( uiC64 );
  8535. sigC.v0 = uiC0;
  8536. signZ = signA ^ signB ^ (op == softfloat_mulAdd_subProd);
  8537. /*------------------------------------------------------------------------
  8538. *------------------------------------------------------------------------*/
  8539. if ( expA == 0x7FFF ) {
  8540. if (
  8541. (sigA.v64 | sigA.v0) || ((expB == 0x7FFF) && (sigB.v64 | sigB.v0))
  8542. ) {
  8543. goto propagateNaN_ABC;
  8544. }
  8545. magBits = expB | sigB.v64 | sigB.v0;
  8546. goto infProdArg;
  8547. }
  8548. if ( expB == 0x7FFF ) {
  8549. if ( sigB.v64 | sigB.v0 ) goto propagateNaN_ABC;
  8550. magBits = expA | sigA.v64 | sigA.v0;
  8551. goto infProdArg;
  8552. }
  8553. if ( expC == 0x7FFF ) {
  8554. if ( sigC.v64 | sigC.v0 ) {
  8555. uiZ.v64 = 0;
  8556. uiZ.v0 = 0;
  8557. goto propagateNaN_ZC;
  8558. }
  8559. uiZ.v64 = uiC64;
  8560. uiZ.v0 = uiC0;
  8561. goto uiZ;
  8562. }
  8563. /*------------------------------------------------------------------------
  8564. *------------------------------------------------------------------------*/
  8565. if ( ! expA ) {
  8566. if ( ! (sigA.v64 | sigA.v0) ) goto zeroProd;
  8567. normExpSig = softfloat_normSubnormalF128Sig( sigA.v64, sigA.v0 );
  8568. expA = normExpSig.exp;
  8569. sigA = normExpSig.sig;
  8570. }
  8571. if ( ! expB ) {
  8572. if ( ! (sigB.v64 | sigB.v0) ) goto zeroProd;
  8573. normExpSig = softfloat_normSubnormalF128Sig( sigB.v64, sigB.v0 );
  8574. expB = normExpSig.exp;
  8575. sigB = normExpSig.sig;
  8576. }
  8577. /*------------------------------------------------------------------------
  8578. *------------------------------------------------------------------------*/
  8579. expZ = expA + expB - 0x3FFE;
  8580. sigA.v64 |= UINT64_C( 0x0001000000000000 );
  8581. sigB.v64 |= UINT64_C( 0x0001000000000000 );
  8582. sigA = softfloat_shortShiftLeft128( sigA.v64, sigA.v0, 8 );
  8583. sigB = softfloat_shortShiftLeft128( sigB.v64, sigB.v0, 15 );
  8584. softfloat_mul128To256M( sigA.v64, sigA.v0, sigB.v64, sigB.v0, sig256Z );
  8585. sigZ.v64 = sig256Z[indexWord( 4, 3 )];
  8586. sigZ.v0 = sig256Z[indexWord( 4, 2 )];
  8587. shiftDist = 0;
  8588. if ( ! (sigZ.v64 & UINT64_C( 0x0100000000000000 )) ) {
  8589. --expZ;
  8590. shiftDist = -1;
  8591. }
  8592. if ( ! expC ) {
  8593. if ( ! (sigC.v64 | sigC.v0) ) {
  8594. shiftDist += 8;
  8595. goto sigZ;
  8596. }
  8597. normExpSig = softfloat_normSubnormalF128Sig( sigC.v64, sigC.v0 );
  8598. expC = normExpSig.exp;
  8599. sigC = normExpSig.sig;
  8600. }
  8601. sigC.v64 |= UINT64_C( 0x0001000000000000 );
  8602. sigC = softfloat_shortShiftLeft128( sigC.v64, sigC.v0, 8 );
  8603. /*------------------------------------------------------------------------
  8604. *------------------------------------------------------------------------*/
  8605. expDiff = expZ - expC;
  8606. if ( expDiff < 0 ) {
  8607. expZ = expC;
  8608. if ( (signZ == signC) || (expDiff < -1) ) {
  8609. shiftDist -= expDiff;
  8610. if ( shiftDist ) {
  8611. sigZ =
  8612. softfloat_shiftRightJam128( sigZ.v64, sigZ.v0, shiftDist );
  8613. }
  8614. } else {
  8615. if ( ! shiftDist ) {
  8616. x128 =
  8617. softfloat_shortShiftRight128(
  8618. sig256Z[indexWord( 4, 1 )], sig256Z[indexWord( 4, 0 )],
  8619. 1
  8620. );
  8621. sig256Z[indexWord( 4, 1 )] = (sigZ.v0<<63) | x128.v64;
  8622. sig256Z[indexWord( 4, 0 )] = x128.v0;
  8623. sigZ = softfloat_shortShiftRight128( sigZ.v64, sigZ.v0, 1 );
  8624. sig256Z[indexWord( 4, 3 )] = sigZ.v64;
  8625. sig256Z[indexWord( 4, 2 )] = sigZ.v0;
  8626. }
  8627. }
  8628. } else {
  8629. if ( shiftDist ) softfloat_add256M( sig256Z, sig256Z, sig256Z );
  8630. if ( ! expDiff ) {
  8631. sigZ.v64 = sig256Z[indexWord( 4, 3 )];
  8632. sigZ.v0 = sig256Z[indexWord( 4, 2 )];
  8633. } else {
  8634. sig256C[indexWord( 4, 3 )] = sigC.v64;
  8635. sig256C[indexWord( 4, 2 )] = sigC.v0;
  8636. sig256C[indexWord( 4, 1 )] = 0;
  8637. sig256C[indexWord( 4, 0 )] = 0;
  8638. softfloat_shiftRightJam256M( sig256C, expDiff, sig256C );
  8639. }
  8640. }
  8641. /*------------------------------------------------------------------------
  8642. *------------------------------------------------------------------------*/
  8643. shiftDist = 8;
  8644. if ( signZ == signC ) {
  8645. /*--------------------------------------------------------------------
  8646. *--------------------------------------------------------------------*/
  8647. if ( expDiff <= 0 ) {
  8648. sigZ = softfloat_add128( sigC.v64, sigC.v0, sigZ.v64, sigZ.v0 );
  8649. } else {
  8650. softfloat_add256M( sig256Z, sig256C, sig256Z );
  8651. sigZ.v64 = sig256Z[indexWord( 4, 3 )];
  8652. sigZ.v0 = sig256Z[indexWord( 4, 2 )];
  8653. }
  8654. if ( sigZ.v64 & UINT64_C( 0x0200000000000000 ) ) {
  8655. ++expZ;
  8656. shiftDist = 9;
  8657. }
  8658. } else {
  8659. /*--------------------------------------------------------------------
  8660. *--------------------------------------------------------------------*/
  8661. if ( expDiff < 0 ) {
  8662. signZ = signC;
  8663. if ( expDiff < -1 ) {
  8664. sigZ =
  8665. softfloat_sub128( sigC.v64, sigC.v0, sigZ.v64, sigZ.v0 );
  8666. sigZExtra =
  8667. sig256Z[indexWord( 4, 1 )] | sig256Z[indexWord( 4, 0 )];
  8668. if ( sigZExtra ) {
  8669. sigZ = softfloat_sub128( sigZ.v64, sigZ.v0, 0, 1 );
  8670. }
  8671. if ( ! (sigZ.v64 & UINT64_C( 0x0100000000000000 )) ) {
  8672. --expZ;
  8673. shiftDist = 7;
  8674. }
  8675. goto shiftRightRoundPack;
  8676. } else {
  8677. sig256C[indexWord( 4, 3 )] = sigC.v64;
  8678. sig256C[indexWord( 4, 2 )] = sigC.v0;
  8679. sig256C[indexWord( 4, 1 )] = 0;
  8680. sig256C[indexWord( 4, 0 )] = 0;
  8681. softfloat_sub256M( sig256C, sig256Z, sig256Z );
  8682. }
  8683. } else if ( ! expDiff ) {
  8684. sigZ = softfloat_sub128( sigZ.v64, sigZ.v0, sigC.v64, sigC.v0 );
  8685. if (
  8686. ! (sigZ.v64 | sigZ.v0) && ! sig256Z[indexWord( 4, 1 )]
  8687. && ! sig256Z[indexWord( 4, 0 )]
  8688. ) {
  8689. goto completeCancellation;
  8690. }
  8691. sig256Z[indexWord( 4, 3 )] = sigZ.v64;
  8692. sig256Z[indexWord( 4, 2 )] = sigZ.v0;
  8693. if ( sigZ.v64 & UINT64_C( 0x8000000000000000 ) ) {
  8694. signZ = ! signZ;
  8695. softfloat_sub256M( zero256, sig256Z, sig256Z );
  8696. }
  8697. } else {
  8698. softfloat_sub256M( sig256Z, sig256C, sig256Z );
  8699. if ( 1 < expDiff ) {
  8700. sigZ.v64 = sig256Z[indexWord( 4, 3 )];
  8701. sigZ.v0 = sig256Z[indexWord( 4, 2 )];
  8702. if ( ! (sigZ.v64 & UINT64_C( 0x0100000000000000 )) ) {
  8703. --expZ;
  8704. shiftDist = 7;
  8705. }
  8706. goto sigZ;
  8707. }
  8708. }
  8709. /*--------------------------------------------------------------------
  8710. *--------------------------------------------------------------------*/
  8711. sigZ.v64 = sig256Z[indexWord( 4, 3 )];
  8712. sigZ.v0 = sig256Z[indexWord( 4, 2 )];
  8713. sigZExtra = sig256Z[indexWord( 4, 1 )];
  8714. sig256Z0 = sig256Z[indexWord( 4, 0 )];
  8715. if ( sigZ.v64 ) {
  8716. if ( sig256Z0 ) sigZExtra |= 1;
  8717. } else {
  8718. expZ -= 64;
  8719. sigZ.v64 = sigZ.v0;
  8720. sigZ.v0 = sigZExtra;
  8721. sigZExtra = sig256Z0;
  8722. if ( ! sigZ.v64 ) {
  8723. expZ -= 64;
  8724. sigZ.v64 = sigZ.v0;
  8725. sigZ.v0 = sigZExtra;
  8726. sigZExtra = 0;
  8727. if ( ! sigZ.v64 ) {
  8728. expZ -= 64;
  8729. sigZ.v64 = sigZ.v0;
  8730. sigZ.v0 = 0;
  8731. }
  8732. }
  8733. }
  8734. shiftDist = softfloat_countLeadingZeros64( sigZ.v64 );
  8735. expZ += 7 - shiftDist;
  8736. shiftDist = 15 - shiftDist;
  8737. if ( 0 < shiftDist ) goto shiftRightRoundPack;
  8738. if ( shiftDist ) {
  8739. shiftDist = -shiftDist;
  8740. sigZ = softfloat_shortShiftLeft128( sigZ.v64, sigZ.v0, shiftDist );
  8741. x128 = softfloat_shortShiftLeft128( 0, sigZExtra, shiftDist );
  8742. sigZ.v0 |= x128.v64;
  8743. sigZExtra = x128.v0;
  8744. }
  8745. goto roundPack;
  8746. }
  8747. sigZ:
  8748. sigZExtra = sig256Z[indexWord( 4, 1 )] | sig256Z[indexWord( 4, 0 )];
  8749. shiftRightRoundPack:
  8750. sigZExtra = (uint64_t) (sigZ.v0<<(64 - shiftDist)) | (sigZExtra != 0);
  8751. sigZ = softfloat_shortShiftRight128( sigZ.v64, sigZ.v0, shiftDist );
  8752. roundPack:
  8753. return
  8754. softfloat_roundPackToF128(
  8755. signZ, expZ - 1, sigZ.v64, sigZ.v0, sigZExtra );
  8756. /*------------------------------------------------------------------------
  8757. *------------------------------------------------------------------------*/
  8758. propagateNaN_ABC:
  8759. uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, uiB64, uiB0 );
  8760. goto propagateNaN_ZC;
  8761. /*------------------------------------------------------------------------
  8762. *------------------------------------------------------------------------*/
  8763. infProdArg:
  8764. if ( magBits ) {
  8765. uiZ.v64 = packToF128UI64( signZ, 0x7FFF, 0 );
  8766. uiZ.v0 = 0;
  8767. if ( expC != 0x7FFF ) goto uiZ;
  8768. if ( sigC.v64 | sigC.v0 ) goto propagateNaN_ZC;
  8769. if ( signZ == signC ) goto uiZ;
  8770. }
  8771. softfloat_raiseFlags( softfloat_flag_invalid );
  8772. uiZ.v64 = defaultNaNF128UI64;
  8773. uiZ.v0 = defaultNaNF128UI0;
  8774. propagateNaN_ZC:
  8775. uiZ = softfloat_propagateNaNF128UI( uiZ.v64, uiZ.v0, uiC64, uiC0 );
  8776. goto uiZ;
  8777. /*------------------------------------------------------------------------
  8778. *------------------------------------------------------------------------*/
  8779. zeroProd:
  8780. uiZ.v64 = uiC64;
  8781. uiZ.v0 = uiC0;
  8782. if ( ! (expC | sigC.v64 | sigC.v0) && (signZ != signC) ) {
  8783. completeCancellation:
  8784. uiZ.v64 =
  8785. packToF128UI64(
  8786. (softfloat_roundingMode == softfloat_round_min), 0, 0 );
  8787. uiZ.v0 = 0;
  8788. }
  8789. uiZ:
  8790. uZ.ui = uiZ;
  8791. return uZ.f;
  8792. }
  8793. /**** ended inlining ../../source/s_mulAddF128.c ****/
  8794. /**** start inlining ../../source/softfloat_state.c ****/
  8795. /*============================================================================
  8796. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  8797. Package, Release 3e, by John R. Hauser.
  8798. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  8799. California. All Rights Reserved.
  8800. Redistribution and use in source and binary forms, with or without
  8801. modification, are permitted provided that the following conditions are met:
  8802. 1. Redistributions of source code must retain the above copyright notice,
  8803. this list of conditions, and the following disclaimer.
  8804. 2. Redistributions in binary form must reproduce the above copyright notice,
  8805. this list of conditions, and the following disclaimer in the documentation
  8806. and/or other materials provided with the distribution.
  8807. 3. Neither the name of the University nor the names of its contributors may
  8808. be used to endorse or promote products derived from this software without
  8809. specific prior written permission.
  8810. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  8811. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  8812. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  8813. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  8814. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  8815. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  8816. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  8817. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  8818. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  8819. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  8820. =============================================================================*/
  8821. #include <stdint.h>
  8822. /**** skipping file: platform.h ****/
  8823. /**** skipping file: internals.h ****/
  8824. /**** skipping file: specialize.h ****/
  8825. /**** skipping file: softfloat.h ****/
  8826. #ifndef THREAD_LOCAL
  8827. #define THREAD_LOCAL
  8828. #endif
  8829. THREAD_LOCAL uint_fast8_t softfloat_roundingMode = softfloat_round_near_even;
  8830. THREAD_LOCAL uint_fast8_t softfloat_detectTininess = init_detectTininess;
  8831. THREAD_LOCAL uint_fast8_t softfloat_exceptionFlags = 0;
  8832. THREAD_LOCAL uint_fast8_t extF80_roundingPrecision = 80;
  8833. /**** ended inlining ../../source/softfloat_state.c ****/
  8834. /**** start inlining ../../source/ui32_to_f16.c ****/
  8835. /*============================================================================
  8836. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  8837. Package, Release 3e, by John R. Hauser.
  8838. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  8839. California. All Rights Reserved.
  8840. Redistribution and use in source and binary forms, with or without
  8841. modification, are permitted provided that the following conditions are met:
  8842. 1. Redistributions of source code must retain the above copyright notice,
  8843. this list of conditions, and the following disclaimer.
  8844. 2. Redistributions in binary form must reproduce the above copyright notice,
  8845. this list of conditions, and the following disclaimer in the documentation
  8846. and/or other materials provided with the distribution.
  8847. 3. Neither the name of the University nor the names of its contributors may
  8848. be used to endorse or promote products derived from this software without
  8849. specific prior written permission.
  8850. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  8851. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  8852. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  8853. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  8854. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  8855. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  8856. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  8857. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  8858. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  8859. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  8860. =============================================================================*/
  8861. #include <stdint.h>
  8862. /**** skipping file: platform.h ****/
  8863. /**** skipping file: internals.h ****/
  8864. /**** skipping file: softfloat.h ****/
  8865. float16_t ui32_to_f16( uint32_t a )
  8866. {
  8867. int_fast8_t shiftDist;
  8868. union ui16_f16 u;
  8869. uint_fast16_t sig;
  8870. shiftDist = softfloat_countLeadingZeros32( a ) - 21;
  8871. if ( 0 <= shiftDist ) {
  8872. u.ui =
  8873. a ? packToF16UI(
  8874. 0, 0x18 - shiftDist, (uint_fast16_t) a<<shiftDist )
  8875. : 0;
  8876. return u.f;
  8877. } else {
  8878. shiftDist += 4;
  8879. sig =
  8880. (shiftDist < 0)
  8881. ? a>>(-shiftDist) | ((uint32_t) (a<<(shiftDist & 31)) != 0)
  8882. : (uint_fast16_t) a<<shiftDist;
  8883. return softfloat_roundPackToF16( 0, 0x1C - shiftDist, sig );
  8884. }
  8885. }
  8886. /**** ended inlining ../../source/ui32_to_f16.c ****/
  8887. /**** start inlining ../../source/ui32_to_f32.c ****/
  8888. /*============================================================================
  8889. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  8890. Package, Release 3e, by John R. Hauser.
  8891. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  8892. All Rights Reserved.
  8893. Redistribution and use in source and binary forms, with or without
  8894. modification, are permitted provided that the following conditions are met:
  8895. 1. Redistributions of source code must retain the above copyright notice,
  8896. this list of conditions, and the following disclaimer.
  8897. 2. Redistributions in binary form must reproduce the above copyright notice,
  8898. this list of conditions, and the following disclaimer in the documentation
  8899. and/or other materials provided with the distribution.
  8900. 3. Neither the name of the University nor the names of its contributors may
  8901. be used to endorse or promote products derived from this software without
  8902. specific prior written permission.
  8903. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  8904. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  8905. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  8906. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  8907. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  8908. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  8909. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  8910. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  8911. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  8912. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  8913. =============================================================================*/
  8914. #include <stdint.h>
  8915. /**** skipping file: platform.h ****/
  8916. /**** skipping file: internals.h ****/
  8917. /**** skipping file: softfloat.h ****/
  8918. float32_t ui32_to_f32( uint32_t a )
  8919. {
  8920. union ui32_f32 uZ;
  8921. if ( ! a ) {
  8922. uZ.ui = 0;
  8923. return uZ.f;
  8924. }
  8925. if ( a & 0x80000000 ) {
  8926. return softfloat_roundPackToF32( 0, 0x9D, a>>1 | (a & 1) );
  8927. } else {
  8928. return softfloat_normRoundPackToF32( 0, 0x9C, a );
  8929. }
  8930. }
  8931. /**** ended inlining ../../source/ui32_to_f32.c ****/
  8932. /**** start inlining ../../source/ui32_to_f64.c ****/
  8933. /*============================================================================
  8934. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  8935. Package, Release 3e, by John R. Hauser.
  8936. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  8937. California. All Rights Reserved.
  8938. Redistribution and use in source and binary forms, with or without
  8939. modification, are permitted provided that the following conditions are met:
  8940. 1. Redistributions of source code must retain the above copyright notice,
  8941. this list of conditions, and the following disclaimer.
  8942. 2. Redistributions in binary form must reproduce the above copyright notice,
  8943. this list of conditions, and the following disclaimer in the documentation
  8944. and/or other materials provided with the distribution.
  8945. 3. Neither the name of the University nor the names of its contributors may
  8946. be used to endorse or promote products derived from this software without
  8947. specific prior written permission.
  8948. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  8949. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  8950. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  8951. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  8952. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  8953. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  8954. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  8955. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  8956. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  8957. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  8958. =============================================================================*/
  8959. #include <stdint.h>
  8960. /**** skipping file: platform.h ****/
  8961. /**** skipping file: internals.h ****/
  8962. /**** skipping file: softfloat.h ****/
  8963. float64_t ui32_to_f64( uint32_t a )
  8964. {
  8965. uint_fast64_t uiZ;
  8966. int_fast8_t shiftDist;
  8967. union ui64_f64 uZ;
  8968. if ( ! a ) {
  8969. uiZ = 0;
  8970. } else {
  8971. shiftDist = softfloat_countLeadingZeros32( a ) + 21;
  8972. uiZ =
  8973. packToF64UI( 0, 0x432 - shiftDist, (uint_fast64_t) a<<shiftDist );
  8974. }
  8975. uZ.ui = uiZ;
  8976. return uZ.f;
  8977. }
  8978. /**** ended inlining ../../source/ui32_to_f64.c ****/
  8979. /**** start inlining ../../source/ui32_to_extF80.c ****/
  8980. /*============================================================================
  8981. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  8982. Package, Release 3e, by John R. Hauser.
  8983. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  8984. California. All Rights Reserved.
  8985. Redistribution and use in source and binary forms, with or without
  8986. modification, are permitted provided that the following conditions are met:
  8987. 1. Redistributions of source code must retain the above copyright notice,
  8988. this list of conditions, and the following disclaimer.
  8989. 2. Redistributions in binary form must reproduce the above copyright notice,
  8990. this list of conditions, and the following disclaimer in the documentation
  8991. and/or other materials provided with the distribution.
  8992. 3. Neither the name of the University nor the names of its contributors may
  8993. be used to endorse or promote products derived from this software without
  8994. specific prior written permission.
  8995. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  8996. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  8997. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  8998. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  8999. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  9000. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  9001. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  9002. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  9003. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  9004. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9005. =============================================================================*/
  9006. #include <stdint.h>
  9007. /**** skipping file: platform.h ****/
  9008. /**** skipping file: internals.h ****/
  9009. /**** skipping file: softfloat.h ****/
  9010. extFloat80_t ui32_to_extF80( uint32_t a )
  9011. {
  9012. uint_fast16_t uiZ64;
  9013. int_fast8_t shiftDist;
  9014. union { struct extFloat80M s; extFloat80_t f; } uZ;
  9015. uiZ64 = 0;
  9016. if ( a ) {
  9017. shiftDist = softfloat_countLeadingZeros32( a );
  9018. uiZ64 = 0x401E - shiftDist;
  9019. a <<= shiftDist;
  9020. }
  9021. uZ.s.signExp = uiZ64;
  9022. uZ.s.signif = (uint_fast64_t) a<<32;
  9023. return uZ.f;
  9024. }
  9025. /**** ended inlining ../../source/ui32_to_extF80.c ****/
  9026. /**** start inlining ../../source/ui32_to_extF80M.c ****/
  9027. /*============================================================================
  9028. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  9029. Package, Release 3e, by John R. Hauser.
  9030. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  9031. California. All Rights Reserved.
  9032. Redistribution and use in source and binary forms, with or without
  9033. modification, are permitted provided that the following conditions are met:
  9034. 1. Redistributions of source code must retain the above copyright notice,
  9035. this list of conditions, and the following disclaimer.
  9036. 2. Redistributions in binary form must reproduce the above copyright notice,
  9037. this list of conditions, and the following disclaimer in the documentation
  9038. and/or other materials provided with the distribution.
  9039. 3. Neither the name of the University nor the names of its contributors may
  9040. be used to endorse or promote products derived from this software without
  9041. specific prior written permission.
  9042. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  9043. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  9044. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  9045. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  9046. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  9047. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  9048. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  9049. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  9050. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  9051. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9052. =============================================================================*/
  9053. #include <stdint.h>
  9054. /**** skipping file: platform.h ****/
  9055. /**** skipping file: internals.h ****/
  9056. /**** skipping file: softfloat.h ****/
  9057. #ifdef SOFTFLOAT_FAST_INT64
  9058. void ui32_to_extF80M( uint32_t a, extFloat80_t *zPtr )
  9059. {
  9060. *zPtr = ui32_to_extF80( a );
  9061. }
  9062. #else
  9063. void ui32_to_extF80M( uint32_t a, extFloat80_t *zPtr )
  9064. {
  9065. struct extFloat80M *zSPtr;
  9066. uint_fast16_t uiZ64;
  9067. uint64_t sigZ;
  9068. int_fast8_t shiftDist;
  9069. zSPtr = (struct extFloat80M *) zPtr;
  9070. uiZ64 = 0;
  9071. sigZ = 0;
  9072. if ( a ) {
  9073. shiftDist = softfloat_countLeadingZeros32( a );
  9074. uiZ64 = packToExtF80UI64( 0, 0x401E - shiftDist );
  9075. sigZ = (uint64_t) (a<<shiftDist)<<32;
  9076. }
  9077. zSPtr->signExp = uiZ64;
  9078. zSPtr->signif = sigZ;
  9079. }
  9080. #endif
  9081. /**** ended inlining ../../source/ui32_to_extF80M.c ****/
  9082. /**** start inlining ../../source/ui32_to_f128.c ****/
  9083. /*============================================================================
  9084. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  9085. Package, Release 3e, by John R. Hauser.
  9086. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  9087. California. All Rights Reserved.
  9088. Redistribution and use in source and binary forms, with or without
  9089. modification, are permitted provided that the following conditions are met:
  9090. 1. Redistributions of source code must retain the above copyright notice,
  9091. this list of conditions, and the following disclaimer.
  9092. 2. Redistributions in binary form must reproduce the above copyright notice,
  9093. this list of conditions, and the following disclaimer in the documentation
  9094. and/or other materials provided with the distribution.
  9095. 3. Neither the name of the University nor the names of its contributors may
  9096. be used to endorse or promote products derived from this software without
  9097. specific prior written permission.
  9098. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  9099. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  9100. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  9101. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  9102. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  9103. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  9104. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  9105. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  9106. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  9107. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9108. =============================================================================*/
  9109. #include <stdint.h>
  9110. /**** skipping file: platform.h ****/
  9111. /**** skipping file: internals.h ****/
  9112. /**** skipping file: softfloat.h ****/
  9113. float128_t ui32_to_f128( uint32_t a )
  9114. {
  9115. uint_fast64_t uiZ64;
  9116. int_fast8_t shiftDist;
  9117. union ui128_f128 uZ;
  9118. uiZ64 = 0;
  9119. if ( a ) {
  9120. shiftDist = softfloat_countLeadingZeros32( a ) + 17;
  9121. uiZ64 =
  9122. packToF128UI64(
  9123. 0, 0x402E - shiftDist, (uint_fast64_t) a<<shiftDist );
  9124. }
  9125. uZ.ui.v64 = uiZ64;
  9126. uZ.ui.v0 = 0;
  9127. return uZ.f;
  9128. }
  9129. /**** ended inlining ../../source/ui32_to_f128.c ****/
  9130. /**** start inlining ../../source/ui32_to_f128M.c ****/
  9131. /*============================================================================
  9132. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  9133. Package, Release 3e, by John R. Hauser.
  9134. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  9135. California. All Rights Reserved.
  9136. Redistribution and use in source and binary forms, with or without
  9137. modification, are permitted provided that the following conditions are met:
  9138. 1. Redistributions of source code must retain the above copyright notice,
  9139. this list of conditions, and the following disclaimer.
  9140. 2. Redistributions in binary form must reproduce the above copyright notice,
  9141. this list of conditions, and the following disclaimer in the documentation
  9142. and/or other materials provided with the distribution.
  9143. 3. Neither the name of the University nor the names of its contributors may
  9144. be used to endorse or promote products derived from this software without
  9145. specific prior written permission.
  9146. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  9147. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  9148. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  9149. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  9150. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  9151. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  9152. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  9153. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  9154. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  9155. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9156. =============================================================================*/
  9157. #include <stdint.h>
  9158. /**** skipping file: platform.h ****/
  9159. /**** skipping file: internals.h ****/
  9160. /**** skipping file: softfloat.h ****/
  9161. #ifdef SOFTFLOAT_FAST_INT64
  9162. void ui32_to_f128M( uint32_t a, float128_t *zPtr )
  9163. {
  9164. *zPtr = ui32_to_f128( a );
  9165. }
  9166. #else
  9167. void ui32_to_f128M( uint32_t a, float128_t *zPtr )
  9168. {
  9169. uint32_t *zWPtr, uiZ96, uiZ64;
  9170. int_fast8_t shiftDist;
  9171. uint64_t normA;
  9172. zWPtr = (uint32_t *) zPtr;
  9173. uiZ96 = 0;
  9174. uiZ64 = 0;
  9175. if ( a ) {
  9176. shiftDist = softfloat_countLeadingZeros32( a ) + 17;
  9177. normA = (uint64_t) a<<shiftDist;
  9178. uiZ96 = packToF128UI96( 0, 0x402E - shiftDist, normA>>32 );
  9179. uiZ64 = normA;
  9180. }
  9181. zWPtr[indexWord( 4, 3 )] = uiZ96;
  9182. zWPtr[indexWord( 4, 2 )] = uiZ64;
  9183. zWPtr[indexWord( 4, 1 )] = 0;
  9184. zWPtr[indexWord( 4, 0 )] = 0;
  9185. }
  9186. #endif
  9187. /**** ended inlining ../../source/ui32_to_f128M.c ****/
  9188. /**** start inlining ../../source/ui64_to_f16.c ****/
  9189. /*============================================================================
  9190. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  9191. Package, Release 3e, by John R. Hauser.
  9192. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  9193. California. All Rights Reserved.
  9194. Redistribution and use in source and binary forms, with or without
  9195. modification, are permitted provided that the following conditions are met:
  9196. 1. Redistributions of source code must retain the above copyright notice,
  9197. this list of conditions, and the following disclaimer.
  9198. 2. Redistributions in binary form must reproduce the above copyright notice,
  9199. this list of conditions, and the following disclaimer in the documentation
  9200. and/or other materials provided with the distribution.
  9201. 3. Neither the name of the University nor the names of its contributors may
  9202. be used to endorse or promote products derived from this software without
  9203. specific prior written permission.
  9204. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  9205. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  9206. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  9207. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  9208. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  9209. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  9210. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  9211. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  9212. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  9213. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9214. =============================================================================*/
  9215. #include <stdint.h>
  9216. /**** skipping file: platform.h ****/
  9217. /**** skipping file: internals.h ****/
  9218. /**** skipping file: softfloat.h ****/
  9219. float16_t ui64_to_f16( uint64_t a )
  9220. {
  9221. int_fast8_t shiftDist;
  9222. union ui16_f16 u;
  9223. uint_fast16_t sig;
  9224. shiftDist = softfloat_countLeadingZeros64( a ) - 53;
  9225. if ( 0 <= shiftDist ) {
  9226. u.ui =
  9227. a ? packToF16UI(
  9228. 0, 0x18 - shiftDist, (uint_fast16_t) a<<shiftDist )
  9229. : 0;
  9230. return u.f;
  9231. } else {
  9232. shiftDist += 4;
  9233. sig =
  9234. (shiftDist < 0) ? softfloat_shortShiftRightJam64( a, -shiftDist )
  9235. : (uint_fast16_t) a<<shiftDist;
  9236. return softfloat_roundPackToF16( 0, 0x1C - shiftDist, sig );
  9237. }
  9238. }
  9239. /**** ended inlining ../../source/ui64_to_f16.c ****/
  9240. /**** start inlining ../../source/ui64_to_f32.c ****/
  9241. /*============================================================================
  9242. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  9243. Package, Release 3e, by John R. Hauser.
  9244. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  9245. California. All Rights Reserved.
  9246. Redistribution and use in source and binary forms, with or without
  9247. modification, are permitted provided that the following conditions are met:
  9248. 1. Redistributions of source code must retain the above copyright notice,
  9249. this list of conditions, and the following disclaimer.
  9250. 2. Redistributions in binary form must reproduce the above copyright notice,
  9251. this list of conditions, and the following disclaimer in the documentation
  9252. and/or other materials provided with the distribution.
  9253. 3. Neither the name of the University nor the names of its contributors may
  9254. be used to endorse or promote products derived from this software without
  9255. specific prior written permission.
  9256. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  9257. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  9258. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  9259. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  9260. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  9261. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  9262. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  9263. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  9264. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  9265. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9266. =============================================================================*/
  9267. #include <stdint.h>
  9268. /**** skipping file: platform.h ****/
  9269. /**** skipping file: internals.h ****/
  9270. /**** skipping file: softfloat.h ****/
  9271. float32_t ui64_to_f32( uint64_t a )
  9272. {
  9273. int_fast8_t shiftDist;
  9274. union ui32_f32 u;
  9275. uint_fast32_t sig;
  9276. shiftDist = softfloat_countLeadingZeros64( a ) - 40;
  9277. if ( 0 <= shiftDist ) {
  9278. u.ui =
  9279. a ? packToF32UI(
  9280. 0, 0x95 - shiftDist, (uint_fast32_t) a<<shiftDist )
  9281. : 0;
  9282. return u.f;
  9283. } else {
  9284. shiftDist += 7;
  9285. sig =
  9286. (shiftDist < 0) ? softfloat_shortShiftRightJam64( a, -shiftDist )
  9287. : (uint_fast32_t) a<<shiftDist;
  9288. return softfloat_roundPackToF32( 0, 0x9C - shiftDist, sig );
  9289. }
  9290. }
  9291. /**** ended inlining ../../source/ui64_to_f32.c ****/
  9292. /**** start inlining ../../source/ui64_to_f64.c ****/
  9293. /*============================================================================
  9294. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  9295. Package, Release 3e, by John R. Hauser.
  9296. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  9297. All Rights Reserved.
  9298. Redistribution and use in source and binary forms, with or without
  9299. modification, are permitted provided that the following conditions are met:
  9300. 1. Redistributions of source code must retain the above copyright notice,
  9301. this list of conditions, and the following disclaimer.
  9302. 2. Redistributions in binary form must reproduce the above copyright notice,
  9303. this list of conditions, and the following disclaimer in the documentation
  9304. and/or other materials provided with the distribution.
  9305. 3. Neither the name of the University nor the names of its contributors may
  9306. be used to endorse or promote products derived from this software without
  9307. specific prior written permission.
  9308. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  9309. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  9310. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  9311. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  9312. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  9313. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  9314. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  9315. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  9316. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  9317. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9318. =============================================================================*/
  9319. #include <stdint.h>
  9320. /**** skipping file: platform.h ****/
  9321. /**** skipping file: internals.h ****/
  9322. /**** skipping file: softfloat.h ****/
  9323. float64_t ui64_to_f64( uint64_t a )
  9324. {
  9325. union ui64_f64 uZ;
  9326. if ( ! a ) {
  9327. uZ.ui = 0;
  9328. return uZ.f;
  9329. }
  9330. if ( a & UINT64_C( 0x8000000000000000 ) ) {
  9331. return
  9332. softfloat_roundPackToF64(
  9333. 0, 0x43D, softfloat_shortShiftRightJam64( a, 1 ) );
  9334. } else {
  9335. return softfloat_normRoundPackToF64( 0, 0x43C, a );
  9336. }
  9337. }
  9338. /**** ended inlining ../../source/ui64_to_f64.c ****/
  9339. /**** start inlining ../../source/ui64_to_extF80.c ****/
  9340. /*============================================================================
  9341. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  9342. Package, Release 3e, by John R. Hauser.
  9343. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  9344. California. All Rights Reserved.
  9345. Redistribution and use in source and binary forms, with or without
  9346. modification, are permitted provided that the following conditions are met:
  9347. 1. Redistributions of source code must retain the above copyright notice,
  9348. this list of conditions, and the following disclaimer.
  9349. 2. Redistributions in binary form must reproduce the above copyright notice,
  9350. this list of conditions, and the following disclaimer in the documentation
  9351. and/or other materials provided with the distribution.
  9352. 3. Neither the name of the University nor the names of its contributors may
  9353. be used to endorse or promote products derived from this software without
  9354. specific prior written permission.
  9355. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  9356. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  9357. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  9358. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  9359. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  9360. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  9361. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  9362. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  9363. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  9364. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9365. =============================================================================*/
  9366. #include <stdint.h>
  9367. /**** skipping file: platform.h ****/
  9368. /**** skipping file: internals.h ****/
  9369. /**** skipping file: softfloat.h ****/
  9370. extFloat80_t ui64_to_extF80( uint64_t a )
  9371. {
  9372. uint_fast16_t uiZ64;
  9373. int_fast8_t shiftDist;
  9374. union { struct extFloat80M s; extFloat80_t f; } uZ;
  9375. uiZ64 = 0;
  9376. if ( a ) {
  9377. shiftDist = softfloat_countLeadingZeros64( a );
  9378. uiZ64 = 0x403E - shiftDist;
  9379. a <<= shiftDist;
  9380. }
  9381. uZ.s.signExp = uiZ64;
  9382. uZ.s.signif = a;
  9383. return uZ.f;
  9384. }
  9385. /**** ended inlining ../../source/ui64_to_extF80.c ****/
  9386. /**** start inlining ../../source/ui64_to_extF80M.c ****/
  9387. /*============================================================================
  9388. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  9389. Package, Release 3e, by John R. Hauser.
  9390. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  9391. California. All Rights Reserved.
  9392. Redistribution and use in source and binary forms, with or without
  9393. modification, are permitted provided that the following conditions are met:
  9394. 1. Redistributions of source code must retain the above copyright notice,
  9395. this list of conditions, and the following disclaimer.
  9396. 2. Redistributions in binary form must reproduce the above copyright notice,
  9397. this list of conditions, and the following disclaimer in the documentation
  9398. and/or other materials provided with the distribution.
  9399. 3. Neither the name of the University nor the names of its contributors may
  9400. be used to endorse or promote products derived from this software without
  9401. specific prior written permission.
  9402. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  9403. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  9404. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  9405. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  9406. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  9407. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  9408. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  9409. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  9410. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  9411. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9412. =============================================================================*/
  9413. #include <stdint.h>
  9414. /**** skipping file: platform.h ****/
  9415. /**** skipping file: internals.h ****/
  9416. /**** skipping file: softfloat.h ****/
  9417. #ifdef SOFTFLOAT_FAST_INT64
  9418. void ui64_to_extF80M( uint64_t a, extFloat80_t *zPtr )
  9419. {
  9420. *zPtr = ui64_to_extF80( a );
  9421. }
  9422. #else
  9423. void ui64_to_extF80M( uint64_t a, extFloat80_t *zPtr )
  9424. {
  9425. struct extFloat80M *zSPtr;
  9426. uint_fast16_t uiZ64;
  9427. uint64_t sigZ;
  9428. int_fast8_t shiftDist;
  9429. zSPtr = (struct extFloat80M *) zPtr;
  9430. uiZ64 = 0;
  9431. sigZ = 0;
  9432. if ( a ) {
  9433. shiftDist = softfloat_countLeadingZeros64( a );
  9434. uiZ64 = packToExtF80UI64( 0, 0x403E - shiftDist );
  9435. sigZ = a<<shiftDist;
  9436. }
  9437. zSPtr->signExp = uiZ64;
  9438. zSPtr->signif = sigZ;
  9439. }
  9440. #endif
  9441. /**** ended inlining ../../source/ui64_to_extF80M.c ****/
  9442. /**** start inlining ../../source/ui64_to_f128.c ****/
  9443. /*============================================================================
  9444. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  9445. Package, Release 3e, by John R. Hauser.
  9446. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  9447. California. All Rights Reserved.
  9448. Redistribution and use in source and binary forms, with or without
  9449. modification, are permitted provided that the following conditions are met:
  9450. 1. Redistributions of source code must retain the above copyright notice,
  9451. this list of conditions, and the following disclaimer.
  9452. 2. Redistributions in binary form must reproduce the above copyright notice,
  9453. this list of conditions, and the following disclaimer in the documentation
  9454. and/or other materials provided with the distribution.
  9455. 3. Neither the name of the University nor the names of its contributors may
  9456. be used to endorse or promote products derived from this software without
  9457. specific prior written permission.
  9458. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  9459. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  9460. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  9461. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  9462. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  9463. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  9464. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  9465. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  9466. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  9467. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9468. =============================================================================*/
  9469. #include <stdint.h>
  9470. /**** skipping file: platform.h ****/
  9471. /**** skipping file: internals.h ****/
  9472. /**** skipping file: softfloat.h ****/
  9473. float128_t ui64_to_f128( uint64_t a )
  9474. {
  9475. uint_fast64_t uiZ64, uiZ0;
  9476. int_fast8_t shiftDist;
  9477. struct uint128 zSig;
  9478. union ui128_f128 uZ;
  9479. if ( ! a ) {
  9480. uiZ64 = 0;
  9481. uiZ0 = 0;
  9482. } else {
  9483. shiftDist = softfloat_countLeadingZeros64( a ) + 49;
  9484. if ( 64 <= shiftDist ) {
  9485. zSig.v64 = a<<(shiftDist - 64);
  9486. zSig.v0 = 0;
  9487. } else {
  9488. zSig = softfloat_shortShiftLeft128( 0, a, shiftDist );
  9489. }
  9490. uiZ64 = packToF128UI64( 0, 0x406E - shiftDist, zSig.v64 );
  9491. uiZ0 = zSig.v0;
  9492. }
  9493. uZ.ui.v64 = uiZ64;
  9494. uZ.ui.v0 = uiZ0;
  9495. return uZ.f;
  9496. }
  9497. /**** ended inlining ../../source/ui64_to_f128.c ****/
  9498. /**** start inlining ../../source/ui64_to_f128M.c ****/
  9499. /*============================================================================
  9500. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  9501. Package, Release 3e, by John R. Hauser.
  9502. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  9503. California. All Rights Reserved.
  9504. Redistribution and use in source and binary forms, with or without
  9505. modification, are permitted provided that the following conditions are met:
  9506. 1. Redistributions of source code must retain the above copyright notice,
  9507. this list of conditions, and the following disclaimer.
  9508. 2. Redistributions in binary form must reproduce the above copyright notice,
  9509. this list of conditions, and the following disclaimer in the documentation
  9510. and/or other materials provided with the distribution.
  9511. 3. Neither the name of the University nor the names of its contributors may
  9512. be used to endorse or promote products derived from this software without
  9513. specific prior written permission.
  9514. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  9515. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  9516. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  9517. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  9518. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  9519. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  9520. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  9521. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  9522. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  9523. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9524. =============================================================================*/
  9525. #include <stdint.h>
  9526. /**** skipping file: platform.h ****/
  9527. /**** skipping file: internals.h ****/
  9528. /**** skipping file: softfloat.h ****/
  9529. #ifdef SOFTFLOAT_FAST_INT64
  9530. void ui64_to_f128M( uint64_t a, float128_t *zPtr )
  9531. {
  9532. *zPtr = ui64_to_f128( a );
  9533. }
  9534. #else
  9535. void ui64_to_f128M( uint64_t a, float128_t *zPtr )
  9536. {
  9537. uint32_t *zWPtr, uiZ96, uiZ64;
  9538. uint_fast8_t shiftDist;
  9539. uint32_t *ptr;
  9540. zWPtr = (uint32_t *) zPtr;
  9541. uiZ96 = 0;
  9542. uiZ64 = 0;
  9543. zWPtr[indexWord( 4, 1 )] = 0;
  9544. zWPtr[indexWord( 4, 0 )] = 0;
  9545. if ( a ) {
  9546. shiftDist = softfloat_countLeadingZeros64( a ) + 17;
  9547. if ( shiftDist < 32 ) {
  9548. ptr = zWPtr + indexMultiwordHi( 4, 3 );
  9549. ptr[indexWord( 3, 2 )] = 0;
  9550. ptr[indexWord( 3, 1 )] = a>>32;
  9551. ptr[indexWord( 3, 0 )] = a;
  9552. softfloat_shortShiftLeft96M( ptr, shiftDist, ptr );
  9553. ptr[indexWordHi( 3 )] =
  9554. packToF128UI96( 0, 0x404E - shiftDist, ptr[indexWordHi( 3 )] );
  9555. return;
  9556. }
  9557. a <<= shiftDist - 32;
  9558. uiZ96 = packToF128UI96( 0, 0x404E - shiftDist, a>>32 );
  9559. uiZ64 = a;
  9560. }
  9561. zWPtr[indexWord( 4, 3 )] = uiZ96;
  9562. zWPtr[indexWord( 4, 2 )] = uiZ64;
  9563. }
  9564. #endif
  9565. /**** ended inlining ../../source/ui64_to_f128M.c ****/
  9566. /**** start inlining ../../source/i32_to_f16.c ****/
  9567. /*============================================================================
  9568. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  9569. Package, Release 3e, by John R. Hauser.
  9570. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  9571. California. All rights reserved.
  9572. Redistribution and use in source and binary forms, with or without
  9573. modification, are permitted provided that the following conditions are met:
  9574. 1. Redistributions of source code must retain the above copyright notice,
  9575. this list of conditions, and the following disclaimer.
  9576. 2. Redistributions in binary form must reproduce the above copyright notice,
  9577. this list of conditions, and the following disclaimer in the documentation
  9578. and/or other materials provided with the distribution.
  9579. 3. Neither the name of the University nor the names of its contributors may
  9580. be used to endorse or promote products derived from this software without
  9581. specific prior written permission.
  9582. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  9583. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  9584. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  9585. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  9586. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  9587. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  9588. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  9589. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  9590. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  9591. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9592. =============================================================================*/
  9593. #include <stdbool.h>
  9594. #include <stdint.h>
  9595. /**** skipping file: platform.h ****/
  9596. /**** skipping file: internals.h ****/
  9597. /**** skipping file: softfloat.h ****/
  9598. float16_t i32_to_f16( int32_t a )
  9599. {
  9600. bool sign;
  9601. uint_fast32_t absA;
  9602. int_fast8_t shiftDist;
  9603. union ui16_f16 u;
  9604. uint_fast16_t sig;
  9605. sign = (a < 0);
  9606. absA = sign ? -(uint_fast32_t) a : (uint_fast32_t) a;
  9607. shiftDist = softfloat_countLeadingZeros32( absA ) - 21;
  9608. if ( 0 <= shiftDist ) {
  9609. u.ui =
  9610. a ? packToF16UI(
  9611. sign, 0x18 - shiftDist, (uint_fast16_t) absA<<shiftDist )
  9612. : 0;
  9613. return u.f;
  9614. } else {
  9615. shiftDist += 4;
  9616. sig =
  9617. (shiftDist < 0)
  9618. ? absA>>(-shiftDist)
  9619. | ((uint32_t) (absA<<(shiftDist & 31)) != 0)
  9620. : (uint_fast16_t) absA<<shiftDist;
  9621. return softfloat_roundPackToF16( sign, 0x1C - shiftDist, sig );
  9622. }
  9623. }
  9624. /**** ended inlining ../../source/i32_to_f16.c ****/
  9625. /**** start inlining ../../source/i32_to_f32.c ****/
  9626. /*============================================================================
  9627. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  9628. Package, Release 3e, by John R. Hauser.
  9629. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  9630. All rights reserved.
  9631. Redistribution and use in source and binary forms, with or without
  9632. modification, are permitted provided that the following conditions are met:
  9633. 1. Redistributions of source code must retain the above copyright notice,
  9634. this list of conditions, and the following disclaimer.
  9635. 2. Redistributions in binary form must reproduce the above copyright notice,
  9636. this list of conditions, and the following disclaimer in the documentation
  9637. and/or other materials provided with the distribution.
  9638. 3. Neither the name of the University nor the names of its contributors may
  9639. be used to endorse or promote products derived from this software without
  9640. specific prior written permission.
  9641. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  9642. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  9643. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  9644. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  9645. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  9646. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  9647. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  9648. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  9649. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  9650. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9651. =============================================================================*/
  9652. #include <stdbool.h>
  9653. #include <stdint.h>
  9654. /**** skipping file: platform.h ****/
  9655. /**** skipping file: internals.h ****/
  9656. /**** skipping file: softfloat.h ****/
  9657. float32_t i32_to_f32( int32_t a )
  9658. {
  9659. bool sign;
  9660. union ui32_f32 uZ;
  9661. uint_fast32_t absA;
  9662. sign = (a < 0);
  9663. if ( ! (a & 0x7FFFFFFF) ) {
  9664. uZ.ui = sign ? packToF32UI( 1, 0x9E, 0 ) : 0;
  9665. return uZ.f;
  9666. }
  9667. absA = sign ? -(uint_fast32_t) a : (uint_fast32_t) a;
  9668. return softfloat_normRoundPackToF32( sign, 0x9C, absA );
  9669. }
  9670. /**** ended inlining ../../source/i32_to_f32.c ****/
  9671. /**** start inlining ../../source/i32_to_f64.c ****/
  9672. /*============================================================================
  9673. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  9674. Package, Release 3e, by John R. Hauser.
  9675. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  9676. California. All rights reserved.
  9677. Redistribution and use in source and binary forms, with or without
  9678. modification, are permitted provided that the following conditions are met:
  9679. 1. Redistributions of source code must retain the above copyright notice,
  9680. this list of conditions, and the following disclaimer.
  9681. 2. Redistributions in binary form must reproduce the above copyright notice,
  9682. this list of conditions, and the following disclaimer in the documentation
  9683. and/or other materials provided with the distribution.
  9684. 3. Neither the name of the University nor the names of its contributors may
  9685. be used to endorse or promote products derived from this software without
  9686. specific prior written permission.
  9687. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  9688. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  9689. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  9690. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  9691. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  9692. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  9693. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  9694. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  9695. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  9696. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9697. =============================================================================*/
  9698. #include <stdbool.h>
  9699. #include <stdint.h>
  9700. /**** skipping file: platform.h ****/
  9701. /**** skipping file: internals.h ****/
  9702. /**** skipping file: softfloat.h ****/
  9703. float64_t i32_to_f64( int32_t a )
  9704. {
  9705. uint_fast64_t uiZ;
  9706. bool sign;
  9707. uint_fast32_t absA;
  9708. int_fast8_t shiftDist;
  9709. union ui64_f64 uZ;
  9710. if ( ! a ) {
  9711. uiZ = 0;
  9712. } else {
  9713. sign = (a < 0);
  9714. absA = sign ? -(uint_fast32_t) a : (uint_fast32_t) a;
  9715. shiftDist = softfloat_countLeadingZeros32( absA ) + 21;
  9716. uiZ =
  9717. packToF64UI(
  9718. sign, 0x432 - shiftDist, (uint_fast64_t) absA<<shiftDist );
  9719. }
  9720. uZ.ui = uiZ;
  9721. return uZ.f;
  9722. }
  9723. /**** ended inlining ../../source/i32_to_f64.c ****/
  9724. /**** start inlining ../../source/i32_to_extF80.c ****/
  9725. /*============================================================================
  9726. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  9727. Package, Release 3e, by John R. Hauser.
  9728. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  9729. California. All rights reserved.
  9730. Redistribution and use in source and binary forms, with or without
  9731. modification, are permitted provided that the following conditions are met:
  9732. 1. Redistributions of source code must retain the above copyright notice,
  9733. this list of conditions, and the following disclaimer.
  9734. 2. Redistributions in binary form must reproduce the above copyright notice,
  9735. this list of conditions, and the following disclaimer in the documentation
  9736. and/or other materials provided with the distribution.
  9737. 3. Neither the name of the University nor the names of its contributors may
  9738. be used to endorse or promote products derived from this software without
  9739. specific prior written permission.
  9740. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  9741. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  9742. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  9743. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  9744. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  9745. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  9746. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  9747. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  9748. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  9749. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9750. =============================================================================*/
  9751. #include <stdbool.h>
  9752. #include <stdint.h>
  9753. /**** skipping file: platform.h ****/
  9754. /**** skipping file: internals.h ****/
  9755. /**** skipping file: softfloat.h ****/
  9756. extFloat80_t i32_to_extF80( int32_t a )
  9757. {
  9758. uint_fast16_t uiZ64;
  9759. uint_fast32_t absA;
  9760. bool sign;
  9761. int_fast8_t shiftDist;
  9762. union { struct extFloat80M s; extFloat80_t f; } uZ;
  9763. uiZ64 = 0;
  9764. absA = 0;
  9765. if ( a ) {
  9766. sign = (a < 0);
  9767. absA = sign ? -(uint_fast32_t) a : (uint_fast32_t) a;
  9768. shiftDist = softfloat_countLeadingZeros32( absA );
  9769. uiZ64 = packToExtF80UI64( sign, 0x401E - shiftDist );
  9770. absA <<= shiftDist;
  9771. }
  9772. uZ.s.signExp = uiZ64;
  9773. uZ.s.signif = (uint_fast64_t) absA<<32;
  9774. return uZ.f;
  9775. }
  9776. /**** ended inlining ../../source/i32_to_extF80.c ****/
  9777. /**** start inlining ../../source/i32_to_extF80M.c ****/
  9778. /*============================================================================
  9779. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  9780. Package, Release 3e, by John R. Hauser.
  9781. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  9782. California. All rights reserved.
  9783. Redistribution and use in source and binary forms, with or without
  9784. modification, are permitted provided that the following conditions are met:
  9785. 1. Redistributions of source code must retain the above copyright notice,
  9786. this list of conditions, and the following disclaimer.
  9787. 2. Redistributions in binary form must reproduce the above copyright notice,
  9788. this list of conditions, and the following disclaimer in the documentation
  9789. and/or other materials provided with the distribution.
  9790. 3. Neither the name of the University nor the names of its contributors may
  9791. be used to endorse or promote products derived from this software without
  9792. specific prior written permission.
  9793. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  9794. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  9795. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  9796. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  9797. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  9798. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  9799. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  9800. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  9801. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  9802. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9803. =============================================================================*/
  9804. #include <stdint.h>
  9805. /**** skipping file: platform.h ****/
  9806. /**** skipping file: internals.h ****/
  9807. /**** skipping file: softfloat.h ****/
  9808. #ifdef SOFTFLOAT_FAST_INT64
  9809. void i32_to_extF80M( int32_t a, extFloat80_t *zPtr )
  9810. {
  9811. *zPtr = i32_to_extF80( a );
  9812. }
  9813. #else
  9814. void i32_to_extF80M( int32_t a, extFloat80_t *zPtr )
  9815. {
  9816. struct extFloat80M *zSPtr;
  9817. uint_fast16_t uiZ64;
  9818. uint64_t sigZ;
  9819. bool sign;
  9820. uint32_t absA;
  9821. int_fast8_t shiftDist;
  9822. zSPtr = (struct extFloat80M *) zPtr;
  9823. uiZ64 = 0;
  9824. sigZ = 0;
  9825. if ( a ) {
  9826. sign = (a < 0);
  9827. absA = sign ? -(uint32_t) a : (uint32_t) a;
  9828. shiftDist = softfloat_countLeadingZeros32( absA );
  9829. uiZ64 = packToExtF80UI64( sign, 0x401E - shiftDist );
  9830. sigZ = (uint64_t) (absA<<shiftDist)<<32;
  9831. }
  9832. zSPtr->signExp = uiZ64;
  9833. zSPtr->signif = sigZ;
  9834. }
  9835. #endif
  9836. /**** ended inlining ../../source/i32_to_extF80M.c ****/
  9837. /**** start inlining ../../source/i32_to_f128.c ****/
  9838. /*============================================================================
  9839. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  9840. Package, Release 3e, by John R. Hauser.
  9841. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  9842. California. All rights reserved.
  9843. Redistribution and use in source and binary forms, with or without
  9844. modification, are permitted provided that the following conditions are met:
  9845. 1. Redistributions of source code must retain the above copyright notice,
  9846. this list of conditions, and the following disclaimer.
  9847. 2. Redistributions in binary form must reproduce the above copyright notice,
  9848. this list of conditions, and the following disclaimer in the documentation
  9849. and/or other materials provided with the distribution.
  9850. 3. Neither the name of the University nor the names of its contributors may
  9851. be used to endorse or promote products derived from this software without
  9852. specific prior written permission.
  9853. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  9854. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  9855. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  9856. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  9857. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  9858. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  9859. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  9860. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  9861. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  9862. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9863. =============================================================================*/
  9864. #include <stdint.h>
  9865. /**** skipping file: platform.h ****/
  9866. /**** skipping file: internals.h ****/
  9867. /**** skipping file: softfloat.h ****/
  9868. float128_t i32_to_f128( int32_t a )
  9869. {
  9870. uint_fast64_t uiZ64;
  9871. bool sign;
  9872. uint_fast32_t absA;
  9873. int_fast8_t shiftDist;
  9874. union ui128_f128 uZ;
  9875. uiZ64 = 0;
  9876. if ( a ) {
  9877. sign = (a < 0);
  9878. absA = sign ? -(uint_fast32_t) a : (uint_fast32_t) a;
  9879. shiftDist = softfloat_countLeadingZeros32( absA ) + 17;
  9880. uiZ64 =
  9881. packToF128UI64(
  9882. sign, 0x402E - shiftDist, (uint_fast64_t) absA<<shiftDist );
  9883. }
  9884. uZ.ui.v64 = uiZ64;
  9885. uZ.ui.v0 = 0;
  9886. return uZ.f;
  9887. }
  9888. /**** ended inlining ../../source/i32_to_f128.c ****/
  9889. /**** start inlining ../../source/i32_to_f128M.c ****/
  9890. /*============================================================================
  9891. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  9892. Package, Release 3e, by John R. Hauser.
  9893. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  9894. California. All rights reserved.
  9895. Redistribution and use in source and binary forms, with or without
  9896. modification, are permitted provided that the following conditions are met:
  9897. 1. Redistributions of source code must retain the above copyright notice,
  9898. this list of conditions, and the following disclaimer.
  9899. 2. Redistributions in binary form must reproduce the above copyright notice,
  9900. this list of conditions, and the following disclaimer in the documentation
  9901. and/or other materials provided with the distribution.
  9902. 3. Neither the name of the University nor the names of its contributors may
  9903. be used to endorse or promote products derived from this software without
  9904. specific prior written permission.
  9905. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  9906. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  9907. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  9908. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  9909. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  9910. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  9911. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  9912. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  9913. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  9914. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9915. =============================================================================*/
  9916. #include <stdint.h>
  9917. /**** skipping file: platform.h ****/
  9918. /**** skipping file: internals.h ****/
  9919. /**** skipping file: softfloat.h ****/
  9920. #ifdef SOFTFLOAT_FAST_INT64
  9921. void i32_to_f128M( int32_t a, float128_t *zPtr )
  9922. {
  9923. *zPtr = i32_to_f128( a );
  9924. }
  9925. #else
  9926. void i32_to_f128M( int32_t a, float128_t *zPtr )
  9927. {
  9928. uint32_t *zWPtr;
  9929. uint32_t uiZ96, uiZ64;
  9930. bool sign;
  9931. uint32_t absA;
  9932. int_fast8_t shiftDist;
  9933. uint64_t normAbsA;
  9934. zWPtr = (uint32_t *) zPtr;
  9935. uiZ96 = 0;
  9936. uiZ64 = 0;
  9937. if ( a ) {
  9938. sign = (a < 0);
  9939. absA = sign ? -(uint32_t) a : (uint32_t) a;
  9940. shiftDist = softfloat_countLeadingZeros32( absA ) + 17;
  9941. normAbsA = (uint64_t) absA<<shiftDist;
  9942. uiZ96 = packToF128UI96( sign, 0x402E - shiftDist, normAbsA>>32 );
  9943. uiZ64 = normAbsA;
  9944. }
  9945. zWPtr[indexWord( 4, 3 )] = uiZ96;
  9946. zWPtr[indexWord( 4, 2 )] = uiZ64;
  9947. zWPtr[indexWord( 4, 1 )] = 0;
  9948. zWPtr[indexWord( 4, 0 )] = 0;
  9949. }
  9950. #endif
  9951. /**** ended inlining ../../source/i32_to_f128M.c ****/
  9952. /**** start inlining ../../source/i64_to_f16.c ****/
  9953. /*============================================================================
  9954. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  9955. Package, Release 3e, by John R. Hauser.
  9956. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  9957. California. All rights reserved.
  9958. Redistribution and use in source and binary forms, with or without
  9959. modification, are permitted provided that the following conditions are met:
  9960. 1. Redistributions of source code must retain the above copyright notice,
  9961. this list of conditions, and the following disclaimer.
  9962. 2. Redistributions in binary form must reproduce the above copyright notice,
  9963. this list of conditions, and the following disclaimer in the documentation
  9964. and/or other materials provided with the distribution.
  9965. 3. Neither the name of the University nor the names of its contributors may
  9966. be used to endorse or promote products derived from this software without
  9967. specific prior written permission.
  9968. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  9969. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  9970. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  9971. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  9972. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  9973. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  9974. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  9975. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  9976. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  9977. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  9978. =============================================================================*/
  9979. #include <stdbool.h>
  9980. #include <stdint.h>
  9981. /**** skipping file: platform.h ****/
  9982. /**** skipping file: internals.h ****/
  9983. /**** skipping file: softfloat.h ****/
  9984. float16_t i64_to_f16( int64_t a )
  9985. {
  9986. bool sign;
  9987. uint_fast64_t absA;
  9988. int_fast8_t shiftDist;
  9989. union ui16_f16 u;
  9990. uint_fast16_t sig;
  9991. sign = (a < 0);
  9992. absA = sign ? -(uint_fast64_t) a : (uint_fast64_t) a;
  9993. shiftDist = softfloat_countLeadingZeros64( absA ) - 53;
  9994. if ( 0 <= shiftDist ) {
  9995. u.ui =
  9996. a ? packToF16UI(
  9997. sign, 0x18 - shiftDist, (uint_fast16_t) absA<<shiftDist )
  9998. : 0;
  9999. return u.f;
  10000. } else {
  10001. shiftDist += 4;
  10002. sig =
  10003. (shiftDist < 0)
  10004. ? softfloat_shortShiftRightJam64( absA, -shiftDist )
  10005. : (uint_fast16_t) absA<<shiftDist;
  10006. return softfloat_roundPackToF16( sign, 0x1C - shiftDist, sig );
  10007. }
  10008. }
  10009. /**** ended inlining ../../source/i64_to_f16.c ****/
  10010. /**** start inlining ../../source/i64_to_f32.c ****/
  10011. /*============================================================================
  10012. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  10013. Package, Release 3e, by John R. Hauser.
  10014. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  10015. California. All rights reserved.
  10016. Redistribution and use in source and binary forms, with or without
  10017. modification, are permitted provided that the following conditions are met:
  10018. 1. Redistributions of source code must retain the above copyright notice,
  10019. this list of conditions, and the following disclaimer.
  10020. 2. Redistributions in binary form must reproduce the above copyright notice,
  10021. this list of conditions, and the following disclaimer in the documentation
  10022. and/or other materials provided with the distribution.
  10023. 3. Neither the name of the University nor the names of its contributors may
  10024. be used to endorse or promote products derived from this software without
  10025. specific prior written permission.
  10026. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  10027. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  10028. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  10029. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  10030. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  10031. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  10032. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  10033. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  10034. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  10035. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  10036. =============================================================================*/
  10037. #include <stdbool.h>
  10038. #include <stdint.h>
  10039. /**** skipping file: platform.h ****/
  10040. /**** skipping file: internals.h ****/
  10041. /**** skipping file: softfloat.h ****/
  10042. float32_t i64_to_f32( int64_t a )
  10043. {
  10044. bool sign;
  10045. uint_fast64_t absA;
  10046. int_fast8_t shiftDist;
  10047. union ui32_f32 u;
  10048. uint_fast32_t sig;
  10049. sign = (a < 0);
  10050. absA = sign ? -(uint_fast64_t) a : (uint_fast64_t) a;
  10051. shiftDist = softfloat_countLeadingZeros64( absA ) - 40;
  10052. if ( 0 <= shiftDist ) {
  10053. u.ui =
  10054. a ? packToF32UI(
  10055. sign, 0x95 - shiftDist, (uint_fast32_t) absA<<shiftDist )
  10056. : 0;
  10057. return u.f;
  10058. } else {
  10059. shiftDist += 7;
  10060. sig =
  10061. (shiftDist < 0)
  10062. ? softfloat_shortShiftRightJam64( absA, -shiftDist )
  10063. : (uint_fast32_t) absA<<shiftDist;
  10064. return softfloat_roundPackToF32( sign, 0x9C - shiftDist, sig );
  10065. }
  10066. }
  10067. /**** ended inlining ../../source/i64_to_f32.c ****/
  10068. /**** start inlining ../../source/i64_to_f64.c ****/
  10069. /*============================================================================
  10070. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  10071. Package, Release 3e, by John R. Hauser.
  10072. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  10073. All rights reserved.
  10074. Redistribution and use in source and binary forms, with or without
  10075. modification, are permitted provided that the following conditions are met:
  10076. 1. Redistributions of source code must retain the above copyright notice,
  10077. this list of conditions, and the following disclaimer.
  10078. 2. Redistributions in binary form must reproduce the above copyright notice,
  10079. this list of conditions, and the following disclaimer in the documentation
  10080. and/or other materials provided with the distribution.
  10081. 3. Neither the name of the University nor the names of its contributors may
  10082. be used to endorse or promote products derived from this software without
  10083. specific prior written permission.
  10084. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  10085. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  10086. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  10087. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  10088. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  10089. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  10090. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  10091. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  10092. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  10093. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  10094. =============================================================================*/
  10095. #include <stdbool.h>
  10096. #include <stdint.h>
  10097. /**** skipping file: platform.h ****/
  10098. /**** skipping file: internals.h ****/
  10099. /**** skipping file: softfloat.h ****/
  10100. float64_t i64_to_f64( int64_t a )
  10101. {
  10102. bool sign;
  10103. union ui64_f64 uZ;
  10104. uint_fast64_t absA;
  10105. sign = (a < 0);
  10106. if ( ! (a & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ) {
  10107. uZ.ui = sign ? packToF64UI( 1, 0x43E, 0 ) : 0;
  10108. return uZ.f;
  10109. }
  10110. absA = sign ? -(uint_fast64_t) a : (uint_fast64_t) a;
  10111. return softfloat_normRoundPackToF64( sign, 0x43C, absA );
  10112. }
  10113. /**** ended inlining ../../source/i64_to_f64.c ****/
  10114. /**** start inlining ../../source/i64_to_extF80.c ****/
  10115. /*============================================================================
  10116. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  10117. Package, Release 3e, by John R. Hauser.
  10118. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  10119. California. All rights reserved.
  10120. Redistribution and use in source and binary forms, with or without
  10121. modification, are permitted provided that the following conditions are met:
  10122. 1. Redistributions of source code must retain the above copyright notice,
  10123. this list of conditions, and the following disclaimer.
  10124. 2. Redistributions in binary form must reproduce the above copyright notice,
  10125. this list of conditions, and the following disclaimer in the documentation
  10126. and/or other materials provided with the distribution.
  10127. 3. Neither the name of the University nor the names of its contributors may
  10128. be used to endorse or promote products derived from this software without
  10129. specific prior written permission.
  10130. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  10131. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  10132. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  10133. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  10134. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  10135. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  10136. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  10137. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  10138. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  10139. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  10140. =============================================================================*/
  10141. #include <stdbool.h>
  10142. #include <stdint.h>
  10143. /**** skipping file: platform.h ****/
  10144. /**** skipping file: internals.h ****/
  10145. /**** skipping file: softfloat.h ****/
  10146. extFloat80_t i64_to_extF80( int64_t a )
  10147. {
  10148. uint_fast16_t uiZ64;
  10149. uint_fast64_t absA;
  10150. bool sign;
  10151. int_fast8_t shiftDist;
  10152. union { struct extFloat80M s; extFloat80_t f; } uZ;
  10153. uiZ64 = 0;
  10154. absA = 0;
  10155. if ( a ) {
  10156. sign = (a < 0);
  10157. absA = sign ? -(uint_fast64_t) a : (uint_fast64_t) a;
  10158. shiftDist = softfloat_countLeadingZeros64( absA );
  10159. uiZ64 = packToExtF80UI64( sign, 0x403E - shiftDist );
  10160. absA <<= shiftDist;
  10161. }
  10162. uZ.s.signExp = uiZ64;
  10163. uZ.s.signif = absA;
  10164. return uZ.f;
  10165. }
  10166. /**** ended inlining ../../source/i64_to_extF80.c ****/
  10167. /**** start inlining ../../source/i64_to_extF80M.c ****/
  10168. /*============================================================================
  10169. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  10170. Package, Release 3e, by John R. Hauser.
  10171. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  10172. California. All rights reserved.
  10173. Redistribution and use in source and binary forms, with or without
  10174. modification, are permitted provided that the following conditions are met:
  10175. 1. Redistributions of source code must retain the above copyright notice,
  10176. this list of conditions, and the following disclaimer.
  10177. 2. Redistributions in binary form must reproduce the above copyright notice,
  10178. this list of conditions, and the following disclaimer in the documentation
  10179. and/or other materials provided with the distribution.
  10180. 3. Neither the name of the University nor the names of its contributors may
  10181. be used to endorse or promote products derived from this software without
  10182. specific prior written permission.
  10183. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  10184. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  10185. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  10186. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  10187. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  10188. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  10189. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  10190. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  10191. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  10192. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  10193. =============================================================================*/
  10194. #include <stdint.h>
  10195. /**** skipping file: platform.h ****/
  10196. /**** skipping file: internals.h ****/
  10197. /**** skipping file: softfloat.h ****/
  10198. #ifdef SOFTFLOAT_FAST_INT64
  10199. void i64_to_extF80M( int64_t a, extFloat80_t *zPtr )
  10200. {
  10201. *zPtr = i64_to_extF80( a );
  10202. }
  10203. #else
  10204. void i64_to_extF80M( int64_t a, extFloat80_t *zPtr )
  10205. {
  10206. struct extFloat80M *zSPtr;
  10207. uint_fast16_t uiZ64;
  10208. uint64_t sigZ;
  10209. bool sign;
  10210. uint64_t absA;
  10211. int_fast8_t shiftDist;
  10212. zSPtr = (struct extFloat80M *) zPtr;
  10213. uiZ64 = 0;
  10214. sigZ = 0;
  10215. if ( a ) {
  10216. sign = (a < 0);
  10217. absA = sign ? -(uint64_t) a : (uint64_t) a;
  10218. shiftDist = softfloat_countLeadingZeros64( absA );
  10219. uiZ64 = packToExtF80UI64( sign, 0x403E - shiftDist );
  10220. sigZ = absA<<shiftDist;
  10221. }
  10222. zSPtr->signExp = uiZ64;
  10223. zSPtr->signif = sigZ;
  10224. }
  10225. #endif
  10226. /**** ended inlining ../../source/i64_to_extF80M.c ****/
  10227. /**** start inlining ../../source/i64_to_f128.c ****/
  10228. /*============================================================================
  10229. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  10230. Package, Release 3e, by John R. Hauser.
  10231. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  10232. California. All rights reserved.
  10233. Redistribution and use in source and binary forms, with or without
  10234. modification, are permitted provided that the following conditions are met:
  10235. 1. Redistributions of source code must retain the above copyright notice,
  10236. this list of conditions, and the following disclaimer.
  10237. 2. Redistributions in binary form must reproduce the above copyright notice,
  10238. this list of conditions, and the following disclaimer in the documentation
  10239. and/or other materials provided with the distribution.
  10240. 3. Neither the name of the University nor the names of its contributors may
  10241. be used to endorse or promote products derived from this software without
  10242. specific prior written permission.
  10243. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  10244. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  10245. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  10246. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  10247. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  10248. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  10249. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  10250. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  10251. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  10252. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  10253. =============================================================================*/
  10254. #include <stdint.h>
  10255. /**** skipping file: platform.h ****/
  10256. /**** skipping file: internals.h ****/
  10257. /**** skipping file: softfloat.h ****/
  10258. float128_t i64_to_f128( int64_t a )
  10259. {
  10260. uint_fast64_t uiZ64, uiZ0;
  10261. bool sign;
  10262. uint_fast64_t absA;
  10263. int_fast8_t shiftDist;
  10264. struct uint128 zSig;
  10265. union ui128_f128 uZ;
  10266. if ( ! a ) {
  10267. uiZ64 = 0;
  10268. uiZ0 = 0;
  10269. } else {
  10270. sign = (a < 0);
  10271. absA = sign ? -(uint_fast64_t) a : (uint_fast64_t) a;
  10272. shiftDist = softfloat_countLeadingZeros64( absA ) + 49;
  10273. if ( 64 <= shiftDist ) {
  10274. zSig.v64 = absA<<(shiftDist - 64);
  10275. zSig.v0 = 0;
  10276. } else {
  10277. zSig = softfloat_shortShiftLeft128( 0, absA, shiftDist );
  10278. }
  10279. uiZ64 = packToF128UI64( sign, 0x406E - shiftDist, zSig.v64 );
  10280. uiZ0 = zSig.v0;
  10281. }
  10282. uZ.ui.v64 = uiZ64;
  10283. uZ.ui.v0 = uiZ0;
  10284. return uZ.f;
  10285. }
  10286. /**** ended inlining ../../source/i64_to_f128.c ****/
  10287. /**** start inlining ../../source/i64_to_f128M.c ****/
  10288. /*============================================================================
  10289. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  10290. Package, Release 3e, by John R. Hauser.
  10291. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  10292. California. All rights reserved.
  10293. Redistribution and use in source and binary forms, with or without
  10294. modification, are permitted provided that the following conditions are met:
  10295. 1. Redistributions of source code must retain the above copyright notice,
  10296. this list of conditions, and the following disclaimer.
  10297. 2. Redistributions in binary form must reproduce the above copyright notice,
  10298. this list of conditions, and the following disclaimer in the documentation
  10299. and/or other materials provided with the distribution.
  10300. 3. Neither the name of the University nor the names of its contributors may
  10301. be used to endorse or promote products derived from this software without
  10302. specific prior written permission.
  10303. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  10304. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  10305. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  10306. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  10307. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  10308. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  10309. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  10310. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  10311. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  10312. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  10313. =============================================================================*/
  10314. #include <stdint.h>
  10315. /**** skipping file: platform.h ****/
  10316. /**** skipping file: internals.h ****/
  10317. /**** skipping file: softfloat.h ****/
  10318. #ifdef SOFTFLOAT_FAST_INT64
  10319. void i64_to_f128M( int64_t a, float128_t *zPtr )
  10320. {
  10321. *zPtr = i64_to_f128( a );
  10322. }
  10323. #else
  10324. void i64_to_f128M( int64_t a, float128_t *zPtr )
  10325. {
  10326. uint32_t *zWPtr;
  10327. uint32_t uiZ96, uiZ64;
  10328. bool sign;
  10329. uint64_t absA;
  10330. uint_fast8_t shiftDist;
  10331. uint32_t *ptr;
  10332. zWPtr = (uint32_t *) zPtr;
  10333. uiZ96 = 0;
  10334. uiZ64 = 0;
  10335. zWPtr[indexWord( 4, 1 )] = 0;
  10336. zWPtr[indexWord( 4, 0 )] = 0;
  10337. if ( a ) {
  10338. sign = (a < 0);
  10339. absA = sign ? -(uint64_t) a : (uint64_t) a;
  10340. shiftDist = softfloat_countLeadingZeros64( absA ) + 17;
  10341. if ( shiftDist < 32 ) {
  10342. ptr = zWPtr + indexMultiwordHi( 4, 3 );
  10343. ptr[indexWord( 3, 2 )] = 0;
  10344. ptr[indexWord( 3, 1 )] = absA>>32;
  10345. ptr[indexWord( 3, 0 )] = absA;
  10346. softfloat_shortShiftLeft96M( ptr, shiftDist, ptr );
  10347. ptr[indexWordHi( 3 )] =
  10348. packToF128UI96(
  10349. sign, 0x404E - shiftDist, ptr[indexWordHi( 3 )] );
  10350. return;
  10351. }
  10352. absA <<= shiftDist - 32;
  10353. uiZ96 = packToF128UI96( sign, 0x404E - shiftDist, absA>>32 );
  10354. uiZ64 = absA;
  10355. }
  10356. zWPtr[indexWord( 4, 3 )] = uiZ96;
  10357. zWPtr[indexWord( 4, 2 )] = uiZ64;
  10358. }
  10359. #endif
  10360. /**** ended inlining ../../source/i64_to_f128M.c ****/
  10361. /**** start inlining ../../source/f16_to_ui32.c ****/
  10362. /*============================================================================
  10363. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  10364. Package, Release 3e, by John R. Hauser.
  10365. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  10366. University of California. All rights reserved.
  10367. Redistribution and use in source and binary forms, with or without
  10368. modification, are permitted provided that the following conditions are met:
  10369. 1. Redistributions of source code must retain the above copyright notice,
  10370. this list of conditions, and the following disclaimer.
  10371. 2. Redistributions in binary form must reproduce the above copyright notice,
  10372. this list of conditions, and the following disclaimer in the documentation
  10373. and/or other materials provided with the distribution.
  10374. 3. Neither the name of the University nor the names of its contributors may
  10375. be used to endorse or promote products derived from this software without
  10376. specific prior written permission.
  10377. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  10378. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  10379. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  10380. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  10381. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  10382. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  10383. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  10384. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  10385. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  10386. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  10387. =============================================================================*/
  10388. #include <stdbool.h>
  10389. #include <stdint.h>
  10390. /**** skipping file: platform.h ****/
  10391. /**** skipping file: internals.h ****/
  10392. /**** skipping file: specialize.h ****/
  10393. /**** skipping file: softfloat.h ****/
  10394. uint_fast32_t f16_to_ui32( float16_t a, uint_fast8_t roundingMode, bool exact )
  10395. {
  10396. union ui16_f16 uA;
  10397. uint_fast16_t uiA;
  10398. bool sign;
  10399. int_fast8_t exp;
  10400. uint_fast16_t frac;
  10401. uint_fast32_t sig32;
  10402. int_fast8_t shiftDist;
  10403. /*------------------------------------------------------------------------
  10404. *------------------------------------------------------------------------*/
  10405. uA.f = a;
  10406. uiA = uA.ui;
  10407. sign = signF16UI( uiA );
  10408. exp = expF16UI( uiA );
  10409. frac = fracF16UI( uiA );
  10410. /*------------------------------------------------------------------------
  10411. *------------------------------------------------------------------------*/
  10412. if ( exp == 0x1F ) {
  10413. softfloat_raiseFlags( softfloat_flag_invalid );
  10414. return
  10415. frac ? ui32_fromNaN
  10416. : sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
  10417. }
  10418. /*------------------------------------------------------------------------
  10419. *------------------------------------------------------------------------*/
  10420. sig32 = frac;
  10421. if ( exp ) {
  10422. sig32 |= 0x0400;
  10423. shiftDist = exp - 0x19;
  10424. if ( (0 <= shiftDist) && ! sign ) {
  10425. return sig32<<shiftDist;
  10426. }
  10427. shiftDist = exp - 0x0D;
  10428. if ( 0 < shiftDist ) sig32 <<= shiftDist;
  10429. }
  10430. return softfloat_roundToUI32( sign, sig32, roundingMode, exact );
  10431. }
  10432. /**** ended inlining ../../source/f16_to_ui32.c ****/
  10433. /**** start inlining ../../source/f16_to_ui64.c ****/
  10434. /*============================================================================
  10435. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  10436. Package, Release 3e, by John R. Hauser.
  10437. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 The Regents of the
  10438. University of California. All rights reserved.
  10439. Redistribution and use in source and binary forms, with or without
  10440. modification, are permitted provided that the following conditions are met:
  10441. 1. Redistributions of source code must retain the above copyright notice,
  10442. this list of conditions, and the following disclaimer.
  10443. 2. Redistributions in binary form must reproduce the above copyright notice,
  10444. this list of conditions, and the following disclaimer in the documentation
  10445. and/or other materials provided with the distribution.
  10446. 3. Neither the name of the University nor the names of its contributors may
  10447. be used to endorse or promote products derived from this software without
  10448. specific prior written permission.
  10449. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  10450. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  10451. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  10452. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  10453. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  10454. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  10455. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  10456. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  10457. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  10458. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  10459. =============================================================================*/
  10460. #include <stdbool.h>
  10461. #include <stdint.h>
  10462. /**** skipping file: platform.h ****/
  10463. /**** skipping file: internals.h ****/
  10464. /**** skipping file: specialize.h ****/
  10465. /**** skipping file: softfloat.h ****/
  10466. uint_fast64_t f16_to_ui64( float16_t a, uint_fast8_t roundingMode, bool exact )
  10467. {
  10468. union ui16_f16 uA;
  10469. uint_fast16_t uiA;
  10470. bool sign;
  10471. int_fast8_t exp;
  10472. uint_fast16_t frac;
  10473. uint_fast32_t sig32;
  10474. int_fast8_t shiftDist;
  10475. #ifndef SOFTFLOAT_FAST_INT64
  10476. uint32_t extSig[3];
  10477. #endif
  10478. /*------------------------------------------------------------------------
  10479. *------------------------------------------------------------------------*/
  10480. uA.f = a;
  10481. uiA = uA.ui;
  10482. sign = signF16UI( uiA );
  10483. exp = expF16UI( uiA );
  10484. frac = fracF16UI( uiA );
  10485. /*------------------------------------------------------------------------
  10486. *------------------------------------------------------------------------*/
  10487. if ( exp == 0x1F ) {
  10488. softfloat_raiseFlags( softfloat_flag_invalid );
  10489. return
  10490. frac ? ui64_fromNaN
  10491. : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
  10492. }
  10493. /*------------------------------------------------------------------------
  10494. *------------------------------------------------------------------------*/
  10495. sig32 = frac;
  10496. if ( exp ) {
  10497. sig32 |= 0x0400;
  10498. shiftDist = exp - 0x19;
  10499. if ( (0 <= shiftDist) && ! sign ) {
  10500. return sig32<<shiftDist;
  10501. }
  10502. shiftDist = exp - 0x0D;
  10503. if ( 0 < shiftDist ) sig32 <<= shiftDist;
  10504. }
  10505. #ifdef SOFTFLOAT_FAST_INT64
  10506. return
  10507. softfloat_roundToUI64(
  10508. sign, sig32>>12, (uint_fast64_t) sig32<<52, roundingMode, exact );
  10509. #else
  10510. extSig[indexWord( 3, 2 )] = 0;
  10511. extSig[indexWord( 3, 1 )] = sig32>>12;
  10512. extSig[indexWord( 3, 0 )] = sig32<<20;
  10513. return softfloat_roundMToUI64( sign, extSig, roundingMode, exact );
  10514. #endif
  10515. }
  10516. /**** ended inlining ../../source/f16_to_ui64.c ****/
  10517. /**** start inlining ../../source/f16_to_i32.c ****/
  10518. /*============================================================================
  10519. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  10520. Package, Release 3e, by John R. Hauser.
  10521. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  10522. University of California. All rights reserved.
  10523. Redistribution and use in source and binary forms, with or without
  10524. modification, are permitted provided that the following conditions are met:
  10525. 1. Redistributions of source code must retain the above copyright notice,
  10526. this list of conditions, and the following disclaimer.
  10527. 2. Redistributions in binary form must reproduce the above copyright notice,
  10528. this list of conditions, and the following disclaimer in the documentation
  10529. and/or other materials provided with the distribution.
  10530. 3. Neither the name of the University nor the names of its contributors may
  10531. be used to endorse or promote products derived from this software without
  10532. specific prior written permission.
  10533. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  10534. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  10535. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  10536. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  10537. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  10538. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  10539. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  10540. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  10541. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  10542. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  10543. =============================================================================*/
  10544. #include <stdbool.h>
  10545. #include <stdint.h>
  10546. /**** skipping file: platform.h ****/
  10547. /**** skipping file: internals.h ****/
  10548. /**** skipping file: specialize.h ****/
  10549. /**** skipping file: softfloat.h ****/
  10550. int_fast32_t f16_to_i32( float16_t a, uint_fast8_t roundingMode, bool exact )
  10551. {
  10552. union ui16_f16 uA;
  10553. uint_fast16_t uiA;
  10554. bool sign;
  10555. int_fast8_t exp;
  10556. uint_fast16_t frac;
  10557. int_fast32_t sig32;
  10558. int_fast8_t shiftDist;
  10559. /*------------------------------------------------------------------------
  10560. *------------------------------------------------------------------------*/
  10561. uA.f = a;
  10562. uiA = uA.ui;
  10563. sign = signF16UI( uiA );
  10564. exp = expF16UI( uiA );
  10565. frac = fracF16UI( uiA );
  10566. /*------------------------------------------------------------------------
  10567. *------------------------------------------------------------------------*/
  10568. if ( exp == 0x1F ) {
  10569. softfloat_raiseFlags( softfloat_flag_invalid );
  10570. return
  10571. frac ? i32_fromNaN
  10572. : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
  10573. }
  10574. /*------------------------------------------------------------------------
  10575. *------------------------------------------------------------------------*/
  10576. sig32 = frac;
  10577. if ( exp ) {
  10578. sig32 |= 0x0400;
  10579. shiftDist = exp - 0x19;
  10580. if ( 0 <= shiftDist ) {
  10581. sig32 <<= shiftDist;
  10582. return sign ? -sig32 : sig32;
  10583. }
  10584. shiftDist = exp - 0x0D;
  10585. if ( 0 < shiftDist ) sig32 <<= shiftDist;
  10586. }
  10587. return
  10588. softfloat_roundToI32(
  10589. sign, (uint_fast32_t) sig32, roundingMode, exact );
  10590. }
  10591. /**** ended inlining ../../source/f16_to_i32.c ****/
  10592. /**** start inlining ../../source/f16_to_i64.c ****/
  10593. /*============================================================================
  10594. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  10595. Package, Release 3e, by John R. Hauser.
  10596. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  10597. University of California. All rights reserved.
  10598. Redistribution and use in source and binary forms, with or without
  10599. modification, are permitted provided that the following conditions are met:
  10600. 1. Redistributions of source code must retain the above copyright notice,
  10601. this list of conditions, and the following disclaimer.
  10602. 2. Redistributions in binary form must reproduce the above copyright notice,
  10603. this list of conditions, and the following disclaimer in the documentation
  10604. and/or other materials provided with the distribution.
  10605. 3. Neither the name of the University nor the names of its contributors may
  10606. be used to endorse or promote products derived from this software without
  10607. specific prior written permission.
  10608. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  10609. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  10610. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  10611. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  10612. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  10613. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  10614. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  10615. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  10616. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  10617. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  10618. =============================================================================*/
  10619. #include <stdbool.h>
  10620. #include <stdint.h>
  10621. /**** skipping file: platform.h ****/
  10622. /**** skipping file: internals.h ****/
  10623. /**** skipping file: specialize.h ****/
  10624. /**** skipping file: softfloat.h ****/
  10625. int_fast64_t f16_to_i64( float16_t a, uint_fast8_t roundingMode, bool exact )
  10626. {
  10627. union ui16_f16 uA;
  10628. uint_fast16_t uiA;
  10629. bool sign;
  10630. int_fast8_t exp;
  10631. uint_fast16_t frac;
  10632. int_fast32_t sig32;
  10633. int_fast8_t shiftDist;
  10634. /*------------------------------------------------------------------------
  10635. *------------------------------------------------------------------------*/
  10636. uA.f = a;
  10637. uiA = uA.ui;
  10638. sign = signF16UI( uiA );
  10639. exp = expF16UI( uiA );
  10640. frac = fracF16UI( uiA );
  10641. /*------------------------------------------------------------------------
  10642. *------------------------------------------------------------------------*/
  10643. if ( exp == 0x1F ) {
  10644. softfloat_raiseFlags( softfloat_flag_invalid );
  10645. return
  10646. frac ? i64_fromNaN
  10647. : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
  10648. }
  10649. /*------------------------------------------------------------------------
  10650. *------------------------------------------------------------------------*/
  10651. sig32 = frac;
  10652. if ( exp ) {
  10653. sig32 |= 0x0400;
  10654. shiftDist = exp - 0x19;
  10655. if ( 0 <= shiftDist ) {
  10656. sig32 <<= shiftDist;
  10657. return sign ? -sig32 : sig32;
  10658. }
  10659. shiftDist = exp - 0x0D;
  10660. if ( 0 < shiftDist ) sig32 <<= shiftDist;
  10661. }
  10662. return
  10663. softfloat_roundToI32(
  10664. sign, (uint_fast32_t) sig32, roundingMode, exact );
  10665. }
  10666. /**** ended inlining ../../source/f16_to_i64.c ****/
  10667. /**** start inlining ../../source/f16_to_ui32_r_minMag.c ****/
  10668. /*============================================================================
  10669. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  10670. Package, Release 3e, by John R. Hauser.
  10671. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  10672. California. All rights reserved.
  10673. Redistribution and use in source and binary forms, with or without
  10674. modification, are permitted provided that the following conditions are met:
  10675. 1. Redistributions of source code must retain the above copyright notice,
  10676. this list of conditions, and the following disclaimer.
  10677. 2. Redistributions in binary form must reproduce the above copyright notice,
  10678. this list of conditions, and the following disclaimer in the documentation
  10679. and/or other materials provided with the distribution.
  10680. 3. Neither the name of the University nor the names of its contributors may
  10681. be used to endorse or promote products derived from this software without
  10682. specific prior written permission.
  10683. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  10684. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  10685. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  10686. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  10687. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  10688. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  10689. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  10690. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  10691. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  10692. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  10693. =============================================================================*/
  10694. #include <stdbool.h>
  10695. #include <stdint.h>
  10696. /**** skipping file: platform.h ****/
  10697. /**** skipping file: internals.h ****/
  10698. /**** skipping file: specialize.h ****/
  10699. /**** skipping file: softfloat.h ****/
  10700. uint_fast32_t f16_to_ui32_r_minMag( float16_t a, bool exact )
  10701. {
  10702. union ui16_f16 uA;
  10703. uint_fast16_t uiA;
  10704. int_fast8_t exp;
  10705. uint_fast16_t frac;
  10706. int_fast8_t shiftDist;
  10707. bool sign;
  10708. uint_fast32_t alignedSig;
  10709. /*------------------------------------------------------------------------
  10710. *------------------------------------------------------------------------*/
  10711. uA.f = a;
  10712. uiA = uA.ui;
  10713. exp = expF16UI( uiA );
  10714. frac = fracF16UI( uiA );
  10715. /*------------------------------------------------------------------------
  10716. *------------------------------------------------------------------------*/
  10717. shiftDist = exp - 0x0F;
  10718. if ( shiftDist < 0 ) {
  10719. if ( exact && (exp | frac) ) {
  10720. softfloat_exceptionFlags |= softfloat_flag_inexact;
  10721. }
  10722. return 0;
  10723. }
  10724. /*------------------------------------------------------------------------
  10725. *------------------------------------------------------------------------*/
  10726. sign = signF16UI( uiA );
  10727. if ( sign || (exp == 0x1F) ) {
  10728. softfloat_raiseFlags( softfloat_flag_invalid );
  10729. return
  10730. (exp == 0x1F) && frac ? ui32_fromNaN
  10731. : sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
  10732. }
  10733. /*------------------------------------------------------------------------
  10734. *------------------------------------------------------------------------*/
  10735. alignedSig = (uint_fast32_t) (frac | 0x0400)<<shiftDist;
  10736. if ( exact && (alignedSig & 0x3FF) ) {
  10737. softfloat_exceptionFlags |= softfloat_flag_inexact;
  10738. }
  10739. return alignedSig>>10;
  10740. }
  10741. /**** ended inlining ../../source/f16_to_ui32_r_minMag.c ****/
  10742. /**** start inlining ../../source/f16_to_ui64_r_minMag.c ****/
  10743. /*============================================================================
  10744. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  10745. Package, Release 3e, by John R. Hauser.
  10746. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  10747. California. All rights reserved.
  10748. Redistribution and use in source and binary forms, with or without
  10749. modification, are permitted provided that the following conditions are met:
  10750. 1. Redistributions of source code must retain the above copyright notice,
  10751. this list of conditions, and the following disclaimer.
  10752. 2. Redistributions in binary form must reproduce the above copyright notice,
  10753. this list of conditions, and the following disclaimer in the documentation
  10754. and/or other materials provided with the distribution.
  10755. 3. Neither the name of the University nor the names of its contributors may
  10756. be used to endorse or promote products derived from this software without
  10757. specific prior written permission.
  10758. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  10759. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  10760. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  10761. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  10762. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  10763. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  10764. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  10765. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  10766. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  10767. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  10768. =============================================================================*/
  10769. #include <stdbool.h>
  10770. #include <stdint.h>
  10771. /**** skipping file: platform.h ****/
  10772. /**** skipping file: internals.h ****/
  10773. /**** skipping file: specialize.h ****/
  10774. /**** skipping file: softfloat.h ****/
  10775. uint_fast64_t f16_to_ui64_r_minMag( float16_t a, bool exact )
  10776. {
  10777. union ui16_f16 uA;
  10778. uint_fast16_t uiA;
  10779. int_fast8_t exp;
  10780. uint_fast16_t frac;
  10781. int_fast8_t shiftDist;
  10782. bool sign;
  10783. uint_fast32_t alignedSig;
  10784. /*------------------------------------------------------------------------
  10785. *------------------------------------------------------------------------*/
  10786. uA.f = a;
  10787. uiA = uA.ui;
  10788. exp = expF16UI( uiA );
  10789. frac = fracF16UI( uiA );
  10790. /*------------------------------------------------------------------------
  10791. *------------------------------------------------------------------------*/
  10792. shiftDist = exp - 0x0F;
  10793. if ( shiftDist < 0 ) {
  10794. if ( exact && (exp | frac) ) {
  10795. softfloat_exceptionFlags |= softfloat_flag_inexact;
  10796. }
  10797. return 0;
  10798. }
  10799. /*------------------------------------------------------------------------
  10800. *------------------------------------------------------------------------*/
  10801. sign = signF16UI( uiA );
  10802. if ( sign || (exp == 0x1F) ) {
  10803. softfloat_raiseFlags( softfloat_flag_invalid );
  10804. return
  10805. (exp == 0x1F) && frac ? ui64_fromNaN
  10806. : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
  10807. }
  10808. /*------------------------------------------------------------------------
  10809. *------------------------------------------------------------------------*/
  10810. alignedSig = (uint_fast32_t) (frac | 0x0400)<<shiftDist;
  10811. if ( exact && (alignedSig & 0x3FF) ) {
  10812. softfloat_exceptionFlags |= softfloat_flag_inexact;
  10813. }
  10814. return alignedSig>>10;
  10815. }
  10816. /**** ended inlining ../../source/f16_to_ui64_r_minMag.c ****/
  10817. /**** start inlining ../../source/f16_to_i32_r_minMag.c ****/
  10818. /*============================================================================
  10819. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  10820. Package, Release 3e, by John R. Hauser.
  10821. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  10822. California. All rights reserved.
  10823. Redistribution and use in source and binary forms, with or without
  10824. modification, are permitted provided that the following conditions are met:
  10825. 1. Redistributions of source code must retain the above copyright notice,
  10826. this list of conditions, and the following disclaimer.
  10827. 2. Redistributions in binary form must reproduce the above copyright notice,
  10828. this list of conditions, and the following disclaimer in the documentation
  10829. and/or other materials provided with the distribution.
  10830. 3. Neither the name of the University nor the names of its contributors may
  10831. be used to endorse or promote products derived from this software without
  10832. specific prior written permission.
  10833. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  10834. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  10835. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  10836. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  10837. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  10838. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  10839. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  10840. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  10841. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  10842. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  10843. =============================================================================*/
  10844. #include <stdbool.h>
  10845. #include <stdint.h>
  10846. /**** skipping file: platform.h ****/
  10847. /**** skipping file: internals.h ****/
  10848. /**** skipping file: specialize.h ****/
  10849. /**** skipping file: softfloat.h ****/
  10850. int_fast32_t f16_to_i32_r_minMag( float16_t a, bool exact )
  10851. {
  10852. union ui16_f16 uA;
  10853. uint_fast16_t uiA;
  10854. int_fast8_t exp;
  10855. uint_fast16_t frac;
  10856. int_fast8_t shiftDist;
  10857. bool sign;
  10858. int_fast32_t alignedSig;
  10859. /*------------------------------------------------------------------------
  10860. *------------------------------------------------------------------------*/
  10861. uA.f = a;
  10862. uiA = uA.ui;
  10863. exp = expF16UI( uiA );
  10864. frac = fracF16UI( uiA );
  10865. /*------------------------------------------------------------------------
  10866. *------------------------------------------------------------------------*/
  10867. shiftDist = exp - 0x0F;
  10868. if ( shiftDist < 0 ) {
  10869. if ( exact && (exp | frac) ) {
  10870. softfloat_exceptionFlags |= softfloat_flag_inexact;
  10871. }
  10872. return 0;
  10873. }
  10874. /*------------------------------------------------------------------------
  10875. *------------------------------------------------------------------------*/
  10876. sign = signF16UI( uiA );
  10877. if ( exp == 0x1F ) {
  10878. softfloat_raiseFlags( softfloat_flag_invalid );
  10879. return
  10880. (exp == 0x1F) && frac ? i32_fromNaN
  10881. : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
  10882. }
  10883. /*------------------------------------------------------------------------
  10884. *------------------------------------------------------------------------*/
  10885. alignedSig = (int_fast32_t) (frac | 0x0400)<<shiftDist;
  10886. if ( exact && (alignedSig & 0x3FF) ) {
  10887. softfloat_exceptionFlags |= softfloat_flag_inexact;
  10888. }
  10889. alignedSig >>= 10;
  10890. return sign ? -alignedSig : alignedSig;
  10891. }
  10892. /**** ended inlining ../../source/f16_to_i32_r_minMag.c ****/
  10893. /**** start inlining ../../source/f16_to_i64_r_minMag.c ****/
  10894. /*============================================================================
  10895. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  10896. Package, Release 3e, by John R. Hauser.
  10897. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  10898. California. All rights reserved.
  10899. Redistribution and use in source and binary forms, with or without
  10900. modification, are permitted provided that the following conditions are met:
  10901. 1. Redistributions of source code must retain the above copyright notice,
  10902. this list of conditions, and the following disclaimer.
  10903. 2. Redistributions in binary form must reproduce the above copyright notice,
  10904. this list of conditions, and the following disclaimer in the documentation
  10905. and/or other materials provided with the distribution.
  10906. 3. Neither the name of the University nor the names of its contributors may
  10907. be used to endorse or promote products derived from this software without
  10908. specific prior written permission.
  10909. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  10910. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  10911. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  10912. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  10913. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  10914. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  10915. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  10916. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  10917. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  10918. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  10919. =============================================================================*/
  10920. #include <stdbool.h>
  10921. #include <stdint.h>
  10922. /**** skipping file: platform.h ****/
  10923. /**** skipping file: internals.h ****/
  10924. /**** skipping file: specialize.h ****/
  10925. /**** skipping file: softfloat.h ****/
  10926. int_fast64_t f16_to_i64_r_minMag( float16_t a, bool exact )
  10927. {
  10928. union ui16_f16 uA;
  10929. uint_fast16_t uiA;
  10930. int_fast8_t exp;
  10931. uint_fast16_t frac;
  10932. int_fast8_t shiftDist;
  10933. bool sign;
  10934. int_fast32_t alignedSig;
  10935. /*------------------------------------------------------------------------
  10936. *------------------------------------------------------------------------*/
  10937. uA.f = a;
  10938. uiA = uA.ui;
  10939. exp = expF16UI( uiA );
  10940. frac = fracF16UI( uiA );
  10941. /*------------------------------------------------------------------------
  10942. *------------------------------------------------------------------------*/
  10943. shiftDist = exp - 0x0F;
  10944. if ( shiftDist < 0 ) {
  10945. if ( exact && (exp | frac) ) {
  10946. softfloat_exceptionFlags |= softfloat_flag_inexact;
  10947. }
  10948. return 0;
  10949. }
  10950. /*------------------------------------------------------------------------
  10951. *------------------------------------------------------------------------*/
  10952. sign = signF16UI( uiA );
  10953. if ( exp == 0x1F ) {
  10954. softfloat_raiseFlags( softfloat_flag_invalid );
  10955. return
  10956. (exp == 0x1F) && frac ? i64_fromNaN
  10957. : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
  10958. }
  10959. /*------------------------------------------------------------------------
  10960. *------------------------------------------------------------------------*/
  10961. alignedSig = (int_fast32_t) (frac | 0x0400)<<shiftDist;
  10962. if ( exact && (alignedSig & 0x3FF) ) {
  10963. softfloat_exceptionFlags |= softfloat_flag_inexact;
  10964. }
  10965. alignedSig >>= 10;
  10966. return sign ? -alignedSig : alignedSig;
  10967. }
  10968. /**** ended inlining ../../source/f16_to_i64_r_minMag.c ****/
  10969. /**** start inlining ../../source/f16_to_f32.c ****/
  10970. /*============================================================================
  10971. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  10972. Package, Release 3e, by John R. Hauser.
  10973. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  10974. California. All rights reserved.
  10975. Redistribution and use in source and binary forms, with or without
  10976. modification, are permitted provided that the following conditions are met:
  10977. 1. Redistributions of source code must retain the above copyright notice,
  10978. this list of conditions, and the following disclaimer.
  10979. 2. Redistributions in binary form must reproduce the above copyright notice,
  10980. this list of conditions, and the following disclaimer in the documentation
  10981. and/or other materials provided with the distribution.
  10982. 3. Neither the name of the University nor the names of its contributors may
  10983. be used to endorse or promote products derived from this software without
  10984. specific prior written permission.
  10985. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  10986. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  10987. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  10988. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  10989. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  10990. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  10991. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  10992. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  10993. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  10994. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  10995. =============================================================================*/
  10996. #include <stdbool.h>
  10997. #include <stdint.h>
  10998. /**** skipping file: platform.h ****/
  10999. /**** skipping file: internals.h ****/
  11000. /**** skipping file: specialize.h ****/
  11001. /**** skipping file: softfloat.h ****/
  11002. float32_t f16_to_f32( float16_t a )
  11003. {
  11004. union ui16_f16 uA;
  11005. uint_fast16_t uiA;
  11006. bool sign;
  11007. int_fast8_t exp;
  11008. uint_fast16_t frac;
  11009. struct commonNaN commonNaN;
  11010. uint_fast32_t uiZ;
  11011. struct exp8_sig16 normExpSig;
  11012. union ui32_f32 uZ;
  11013. /*------------------------------------------------------------------------
  11014. *------------------------------------------------------------------------*/
  11015. uA.f = a;
  11016. uiA = uA.ui;
  11017. sign = signF16UI( uiA );
  11018. exp = expF16UI( uiA );
  11019. frac = fracF16UI( uiA );
  11020. /*------------------------------------------------------------------------
  11021. *------------------------------------------------------------------------*/
  11022. if ( exp == 0x1F ) {
  11023. if ( frac ) {
  11024. softfloat_f16UIToCommonNaN( uiA, &commonNaN );
  11025. uiZ = softfloat_commonNaNToF32UI( &commonNaN );
  11026. } else {
  11027. uiZ = packToF32UI( sign, 0xFF, 0 );
  11028. }
  11029. goto uiZ;
  11030. }
  11031. /*------------------------------------------------------------------------
  11032. *------------------------------------------------------------------------*/
  11033. if ( ! exp ) {
  11034. if ( ! frac ) {
  11035. uiZ = packToF32UI( sign, 0, 0 );
  11036. goto uiZ;
  11037. }
  11038. normExpSig = softfloat_normSubnormalF16Sig( frac );
  11039. exp = normExpSig.exp - 1;
  11040. frac = normExpSig.sig;
  11041. }
  11042. /*------------------------------------------------------------------------
  11043. *------------------------------------------------------------------------*/
  11044. uiZ = packToF32UI( sign, exp + 0x70, (uint_fast32_t) frac<<13 );
  11045. uiZ:
  11046. uZ.ui = uiZ;
  11047. return uZ.f;
  11048. }
  11049. /**** ended inlining ../../source/f16_to_f32.c ****/
  11050. /**** start inlining ../../source/f16_to_f64.c ****/
  11051. /*============================================================================
  11052. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  11053. Package, Release 3e, by John R. Hauser.
  11054. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  11055. California. All rights reserved.
  11056. Redistribution and use in source and binary forms, with or without
  11057. modification, are permitted provided that the following conditions are met:
  11058. 1. Redistributions of source code must retain the above copyright notice,
  11059. this list of conditions, and the following disclaimer.
  11060. 2. Redistributions in binary form must reproduce the above copyright notice,
  11061. this list of conditions, and the following disclaimer in the documentation
  11062. and/or other materials provided with the distribution.
  11063. 3. Neither the name of the University nor the names of its contributors may
  11064. be used to endorse or promote products derived from this software without
  11065. specific prior written permission.
  11066. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  11067. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  11068. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  11069. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  11070. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  11071. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  11072. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  11073. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  11074. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  11075. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  11076. =============================================================================*/
  11077. #include <stdbool.h>
  11078. #include <stdint.h>
  11079. /**** skipping file: platform.h ****/
  11080. /**** skipping file: internals.h ****/
  11081. /**** skipping file: specialize.h ****/
  11082. /**** skipping file: softfloat.h ****/
  11083. float64_t f16_to_f64( float16_t a )
  11084. {
  11085. union ui16_f16 uA;
  11086. uint_fast16_t uiA;
  11087. bool sign;
  11088. int_fast8_t exp;
  11089. uint_fast16_t frac;
  11090. struct commonNaN commonNaN;
  11091. uint_fast64_t uiZ;
  11092. struct exp8_sig16 normExpSig;
  11093. union ui64_f64 uZ;
  11094. /*------------------------------------------------------------------------
  11095. *------------------------------------------------------------------------*/
  11096. uA.f = a;
  11097. uiA = uA.ui;
  11098. sign = signF16UI( uiA );
  11099. exp = expF16UI( uiA );
  11100. frac = fracF16UI( uiA );
  11101. /*------------------------------------------------------------------------
  11102. *------------------------------------------------------------------------*/
  11103. if ( exp == 0x1F ) {
  11104. if ( frac ) {
  11105. softfloat_f16UIToCommonNaN( uiA, &commonNaN );
  11106. uiZ = softfloat_commonNaNToF64UI( &commonNaN );
  11107. } else {
  11108. uiZ = packToF64UI( sign, 0x7FF, 0 );
  11109. }
  11110. goto uiZ;
  11111. }
  11112. /*------------------------------------------------------------------------
  11113. *------------------------------------------------------------------------*/
  11114. if ( ! exp ) {
  11115. if ( ! frac ) {
  11116. uiZ = packToF64UI( sign, 0, 0 );
  11117. goto uiZ;
  11118. }
  11119. normExpSig = softfloat_normSubnormalF16Sig( frac );
  11120. exp = normExpSig.exp - 1;
  11121. frac = normExpSig.sig;
  11122. }
  11123. /*------------------------------------------------------------------------
  11124. *------------------------------------------------------------------------*/
  11125. uiZ = packToF64UI( sign, exp + 0x3F0, (uint_fast64_t) frac<<42 );
  11126. uiZ:
  11127. uZ.ui = uiZ;
  11128. return uZ.f;
  11129. }
  11130. /**** ended inlining ../../source/f16_to_f64.c ****/
  11131. /**** start inlining ../../source/f16_to_extF80.c ****/
  11132. /*============================================================================
  11133. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  11134. Package, Release 3e, by John R. Hauser.
  11135. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  11136. California. All rights reserved.
  11137. Redistribution and use in source and binary forms, with or without
  11138. modification, are permitted provided that the following conditions are met:
  11139. 1. Redistributions of source code must retain the above copyright notice,
  11140. this list of conditions, and the following disclaimer.
  11141. 2. Redistributions in binary form must reproduce the above copyright notice,
  11142. this list of conditions, and the following disclaimer in the documentation
  11143. and/or other materials provided with the distribution.
  11144. 3. Neither the name of the University nor the names of its contributors may
  11145. be used to endorse or promote products derived from this software without
  11146. specific prior written permission.
  11147. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  11148. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  11149. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  11150. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  11151. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  11152. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  11153. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  11154. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  11155. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  11156. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  11157. =============================================================================*/
  11158. #include <stdbool.h>
  11159. #include <stdint.h>
  11160. /**** skipping file: platform.h ****/
  11161. /**** skipping file: internals.h ****/
  11162. /**** skipping file: specialize.h ****/
  11163. /**** skipping file: softfloat.h ****/
  11164. extFloat80_t f16_to_extF80( float16_t a )
  11165. {
  11166. union ui16_f16 uA;
  11167. uint_fast16_t uiA;
  11168. bool sign;
  11169. int_fast8_t exp;
  11170. uint_fast16_t frac;
  11171. struct commonNaN commonNaN;
  11172. struct uint128 uiZ;
  11173. uint_fast16_t uiZ64;
  11174. uint_fast64_t uiZ0;
  11175. struct exp8_sig16 normExpSig;
  11176. union { struct extFloat80M s; extFloat80_t f; } uZ;
  11177. /*------------------------------------------------------------------------
  11178. *------------------------------------------------------------------------*/
  11179. uA.f = a;
  11180. uiA = uA.ui;
  11181. sign = signF16UI( uiA );
  11182. exp = expF16UI( uiA );
  11183. frac = fracF16UI( uiA );
  11184. /*------------------------------------------------------------------------
  11185. *------------------------------------------------------------------------*/
  11186. if ( exp == 0x1F ) {
  11187. if ( frac ) {
  11188. softfloat_f16UIToCommonNaN( uiA, &commonNaN );
  11189. uiZ = softfloat_commonNaNToExtF80UI( &commonNaN );
  11190. uiZ64 = uiZ.v64;
  11191. uiZ0 = uiZ.v0;
  11192. } else {
  11193. uiZ64 = packToExtF80UI64( sign, 0x7FFF );
  11194. uiZ0 = UINT64_C( 0x8000000000000000 );
  11195. }
  11196. goto uiZ;
  11197. }
  11198. /*------------------------------------------------------------------------
  11199. *------------------------------------------------------------------------*/
  11200. if ( ! exp ) {
  11201. if ( ! frac ) {
  11202. uiZ64 = packToExtF80UI64( sign, 0 );
  11203. uiZ0 = 0;
  11204. goto uiZ;
  11205. }
  11206. normExpSig = softfloat_normSubnormalF16Sig( frac );
  11207. exp = normExpSig.exp;
  11208. frac = normExpSig.sig;
  11209. }
  11210. /*------------------------------------------------------------------------
  11211. *------------------------------------------------------------------------*/
  11212. uiZ64 = packToExtF80UI64( sign, exp + 0x3FF0 );
  11213. uiZ0 = (uint_fast64_t) (frac | 0x0400)<<53;
  11214. uiZ:
  11215. uZ.s.signExp = uiZ64;
  11216. uZ.s.signif = uiZ0;
  11217. return uZ.f;
  11218. }
  11219. /**** ended inlining ../../source/f16_to_extF80.c ****/
  11220. /**** start inlining ../../source/f16_to_extF80M.c ****/
  11221. /*============================================================================
  11222. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  11223. Package, Release 3e, by John R. Hauser.
  11224. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  11225. California. All rights reserved.
  11226. Redistribution and use in source and binary forms, with or without
  11227. modification, are permitted provided that the following conditions are met:
  11228. 1. Redistributions of source code must retain the above copyright notice,
  11229. this list of conditions, and the following disclaimer.
  11230. 2. Redistributions in binary form must reproduce the above copyright notice,
  11231. this list of conditions, and the following disclaimer in the documentation
  11232. and/or other materials provided with the distribution.
  11233. 3. Neither the name of the University nor the names of its contributors may
  11234. be used to endorse or promote products derived from this software without
  11235. specific prior written permission.
  11236. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  11237. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  11238. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  11239. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  11240. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  11241. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  11242. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  11243. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  11244. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  11245. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  11246. =============================================================================*/
  11247. #include <stdbool.h>
  11248. #include <stdint.h>
  11249. /**** skipping file: platform.h ****/
  11250. /**** skipping file: internals.h ****/
  11251. /**** skipping file: specialize.h ****/
  11252. /**** skipping file: softfloat.h ****/
  11253. #ifdef SOFTFLOAT_FAST_INT64
  11254. void f16_to_extF80M( float16_t a, extFloat80_t *zPtr )
  11255. {
  11256. *zPtr = f16_to_extF80( a );
  11257. }
  11258. #else
  11259. void f16_to_extF80M( float16_t a, extFloat80_t *zPtr )
  11260. {
  11261. struct extFloat80M *zSPtr;
  11262. union ui16_f16 uA;
  11263. uint16_t uiA;
  11264. bool sign;
  11265. int_fast8_t exp;
  11266. uint16_t frac;
  11267. struct commonNaN commonNaN;
  11268. uint_fast16_t uiZ64;
  11269. uint32_t uiZ32;
  11270. struct exp8_sig16 normExpSig;
  11271. /*------------------------------------------------------------------------
  11272. *------------------------------------------------------------------------*/
  11273. zSPtr = (struct extFloat80M *) zPtr;
  11274. uA.f = a;
  11275. uiA = uA.ui;
  11276. sign = signF16UI( uiA );
  11277. exp = expF16UI( uiA );
  11278. frac = fracF16UI( uiA );
  11279. /*------------------------------------------------------------------------
  11280. *------------------------------------------------------------------------*/
  11281. if ( exp == 0x1F ) {
  11282. if ( frac ) {
  11283. softfloat_f16UIToCommonNaN( uiA, &commonNaN );
  11284. softfloat_commonNaNToExtF80M( &commonNaN, zSPtr );
  11285. return;
  11286. }
  11287. uiZ64 = packToExtF80UI64( sign, 0x7FFF );
  11288. uiZ32 = 0x80000000;
  11289. goto uiZ;
  11290. }
  11291. /*------------------------------------------------------------------------
  11292. *------------------------------------------------------------------------*/
  11293. if ( ! exp ) {
  11294. if ( ! frac ) {
  11295. uiZ64 = packToExtF80UI64( sign, 0 );
  11296. uiZ32 = 0;
  11297. goto uiZ;
  11298. }
  11299. normExpSig = softfloat_normSubnormalF16Sig( frac );
  11300. exp = normExpSig.exp;
  11301. frac = normExpSig.sig;
  11302. }
  11303. /*------------------------------------------------------------------------
  11304. *------------------------------------------------------------------------*/
  11305. uiZ64 = packToExtF80UI64( sign, exp + 0x3FF0 );
  11306. uiZ32 = 0x80000000 | (uint32_t) frac<<21;
  11307. uiZ:
  11308. zSPtr->signExp = uiZ64;
  11309. zSPtr->signif = (uint64_t) uiZ32<<32;
  11310. }
  11311. #endif
  11312. /**** ended inlining ../../source/f16_to_extF80M.c ****/
  11313. /**** start inlining ../../source/f16_to_f128.c ****/
  11314. /*============================================================================
  11315. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  11316. Package, Release 3e, by John R. Hauser.
  11317. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  11318. California. All rights reserved.
  11319. Redistribution and use in source and binary forms, with or without
  11320. modification, are permitted provided that the following conditions are met:
  11321. 1. Redistributions of source code must retain the above copyright notice,
  11322. this list of conditions, and the following disclaimer.
  11323. 2. Redistributions in binary form must reproduce the above copyright notice,
  11324. this list of conditions, and the following disclaimer in the documentation
  11325. and/or other materials provided with the distribution.
  11326. 3. Neither the name of the University nor the names of its contributors may
  11327. be used to endorse or promote products derived from this software without
  11328. specific prior written permission.
  11329. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  11330. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  11331. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  11332. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  11333. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  11334. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  11335. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  11336. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  11337. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  11338. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  11339. =============================================================================*/
  11340. #include <stdbool.h>
  11341. #include <stdint.h>
  11342. /**** skipping file: platform.h ****/
  11343. /**** skipping file: internals.h ****/
  11344. /**** skipping file: specialize.h ****/
  11345. /**** skipping file: softfloat.h ****/
  11346. float128_t f16_to_f128( float16_t a )
  11347. {
  11348. union ui16_f16 uA;
  11349. uint_fast16_t uiA;
  11350. bool sign;
  11351. int_fast8_t exp;
  11352. uint_fast16_t frac;
  11353. struct commonNaN commonNaN;
  11354. struct uint128 uiZ;
  11355. struct exp8_sig16 normExpSig;
  11356. union ui128_f128 uZ;
  11357. /*------------------------------------------------------------------------
  11358. *------------------------------------------------------------------------*/
  11359. uA.f = a;
  11360. uiA = uA.ui;
  11361. sign = signF16UI( uiA );
  11362. exp = expF16UI( uiA );
  11363. frac = fracF16UI( uiA );
  11364. /*------------------------------------------------------------------------
  11365. *------------------------------------------------------------------------*/
  11366. if ( exp == 0x1F ) {
  11367. if ( frac ) {
  11368. softfloat_f16UIToCommonNaN( uiA, &commonNaN );
  11369. uiZ = softfloat_commonNaNToF128UI( &commonNaN );
  11370. } else {
  11371. uiZ.v64 = packToF128UI64( sign, 0x7FFF, 0 );
  11372. uiZ.v0 = 0;
  11373. }
  11374. goto uiZ;
  11375. }
  11376. /*------------------------------------------------------------------------
  11377. *------------------------------------------------------------------------*/
  11378. if ( ! exp ) {
  11379. if ( ! frac ) {
  11380. uiZ.v64 = packToF128UI64( sign, 0, 0 );
  11381. uiZ.v0 = 0;
  11382. goto uiZ;
  11383. }
  11384. normExpSig = softfloat_normSubnormalF16Sig( frac );
  11385. exp = normExpSig.exp - 1;
  11386. frac = normExpSig.sig;
  11387. }
  11388. /*------------------------------------------------------------------------
  11389. *------------------------------------------------------------------------*/
  11390. uiZ.v64 = packToF128UI64( sign, exp + 0x3FF0, (uint_fast64_t) frac<<38 );
  11391. uiZ.v0 = 0;
  11392. uiZ:
  11393. uZ.ui = uiZ;
  11394. return uZ.f;
  11395. }
  11396. /**** ended inlining ../../source/f16_to_f128.c ****/
  11397. /**** start inlining ../../source/f16_to_f128M.c ****/
  11398. /*============================================================================
  11399. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  11400. Package, Release 3e, by John R. Hauser.
  11401. Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
  11402. California. All rights reserved.
  11403. Redistribution and use in source and binary forms, with or without
  11404. modification, are permitted provided that the following conditions are met:
  11405. 1. Redistributions of source code must retain the above copyright notice,
  11406. this list of conditions, and the following disclaimer.
  11407. 2. Redistributions in binary form must reproduce the above copyright notice,
  11408. this list of conditions, and the following disclaimer in the documentation
  11409. and/or other materials provided with the distribution.
  11410. 3. Neither the name of the University nor the names of its contributors may
  11411. be used to endorse or promote products derived from this software without
  11412. specific prior written permission.
  11413. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  11414. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  11415. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  11416. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  11417. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  11418. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  11419. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  11420. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  11421. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  11422. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  11423. =============================================================================*/
  11424. #include <stdbool.h>
  11425. #include <stdint.h>
  11426. /**** skipping file: platform.h ****/
  11427. /**** skipping file: internals.h ****/
  11428. /**** skipping file: specialize.h ****/
  11429. /**** skipping file: softfloat.h ****/
  11430. #ifdef SOFTFLOAT_FAST_INT64
  11431. void f16_to_f128M( float16_t a, float128_t *zPtr )
  11432. {
  11433. *zPtr = f16_to_f128( a );
  11434. }
  11435. #else
  11436. void f16_to_f128M( float16_t a, float128_t *zPtr )
  11437. {
  11438. uint32_t *zWPtr;
  11439. union ui16_f16 uA;
  11440. uint16_t uiA;
  11441. bool sign;
  11442. int_fast8_t exp;
  11443. uint16_t frac;
  11444. struct commonNaN commonNaN;
  11445. uint32_t uiZ96;
  11446. struct exp8_sig16 normExpSig;
  11447. /*------------------------------------------------------------------------
  11448. *------------------------------------------------------------------------*/
  11449. zWPtr = (uint32_t *) zPtr;
  11450. /*------------------------------------------------------------------------
  11451. *------------------------------------------------------------------------*/
  11452. uA.f = a;
  11453. uiA = uA.ui;
  11454. sign = signF16UI( uiA );
  11455. exp = expF16UI( uiA );
  11456. frac = fracF16UI( uiA );
  11457. /*------------------------------------------------------------------------
  11458. *------------------------------------------------------------------------*/
  11459. if ( exp == 0x1F ) {
  11460. if ( frac ) {
  11461. softfloat_f16UIToCommonNaN( uiA, &commonNaN );
  11462. softfloat_commonNaNToF128M( &commonNaN, zWPtr );
  11463. return;
  11464. }
  11465. uiZ96 = packToF128UI96( sign, 0x7FFF, 0 );
  11466. goto uiZ;
  11467. }
  11468. /*------------------------------------------------------------------------
  11469. *------------------------------------------------------------------------*/
  11470. if ( ! exp ) {
  11471. if ( ! frac ) {
  11472. uiZ96 = packToF128UI96( sign, 0, 0 );
  11473. goto uiZ;
  11474. }
  11475. normExpSig = softfloat_normSubnormalF16Sig( frac );
  11476. exp = normExpSig.exp - 1;
  11477. frac = normExpSig.sig;
  11478. }
  11479. /*------------------------------------------------------------------------
  11480. *------------------------------------------------------------------------*/
  11481. uiZ96 = packToF128UI96( sign, exp + 0x3FF0, (uint32_t) frac<<6 );
  11482. uiZ:
  11483. zWPtr[indexWord( 4, 3 )] = uiZ96;
  11484. zWPtr[indexWord( 4, 2 )] = 0;
  11485. zWPtr[indexWord( 4, 1 )] = 0;
  11486. zWPtr[indexWord( 4, 0 )] = 0;
  11487. }
  11488. #endif
  11489. /**** ended inlining ../../source/f16_to_f128M.c ****/
  11490. /**** start inlining ../../source/f16_roundToInt.c ****/
  11491. /*============================================================================
  11492. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  11493. Package, Release 3e, by John R. Hauser.
  11494. Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
  11495. California. All rights reserved.
  11496. Redistribution and use in source and binary forms, with or without
  11497. modification, are permitted provided that the following conditions are met:
  11498. 1. Redistributions of source code must retain the above copyright notice,
  11499. this list of conditions, and the following disclaimer.
  11500. 2. Redistributions in binary form must reproduce the above copyright notice,
  11501. this list of conditions, and the following disclaimer in the documentation
  11502. and/or other materials provided with the distribution.
  11503. 3. Neither the name of the University nor the names of its contributors may
  11504. be used to endorse or promote products derived from this software without
  11505. specific prior written permission.
  11506. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  11507. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  11508. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  11509. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  11510. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  11511. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  11512. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  11513. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  11514. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  11515. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  11516. =============================================================================*/
  11517. #include <stdbool.h>
  11518. #include <stdint.h>
  11519. /**** skipping file: platform.h ****/
  11520. /**** skipping file: internals.h ****/
  11521. /**** skipping file: specialize.h ****/
  11522. /**** skipping file: softfloat.h ****/
  11523. float16_t f16_roundToInt( float16_t a, uint_fast8_t roundingMode, bool exact )
  11524. {
  11525. union ui16_f16 uA;
  11526. uint_fast16_t uiA;
  11527. int_fast8_t exp;
  11528. uint_fast16_t uiZ, lastBitMask, roundBitsMask;
  11529. union ui16_f16 uZ;
  11530. /*------------------------------------------------------------------------
  11531. *------------------------------------------------------------------------*/
  11532. uA.f = a;
  11533. uiA = uA.ui;
  11534. exp = expF16UI( uiA );
  11535. /*------------------------------------------------------------------------
  11536. *------------------------------------------------------------------------*/
  11537. if ( exp <= 0xE ) {
  11538. if ( !(uint16_t) (uiA<<1) ) return a;
  11539. if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
  11540. uiZ = uiA & packToF16UI( 1, 0, 0 );
  11541. switch ( roundingMode ) {
  11542. case softfloat_round_near_even:
  11543. if ( !fracF16UI( uiA ) ) break;
  11544. case softfloat_round_near_maxMag:
  11545. if ( exp == 0xE ) uiZ |= packToF16UI( 0, 0xF, 0 );
  11546. break;
  11547. case softfloat_round_min:
  11548. if ( uiZ ) uiZ = packToF16UI( 1, 0xF, 0 );
  11549. break;
  11550. case softfloat_round_max:
  11551. if ( !uiZ ) uiZ = packToF16UI( 0, 0xF, 0 );
  11552. break;
  11553. #ifdef SOFTFLOAT_ROUND_ODD
  11554. case softfloat_round_odd:
  11555. uiZ |= packToF16UI( 0, 0xF, 0 );
  11556. break;
  11557. #endif
  11558. }
  11559. goto uiZ;
  11560. }
  11561. /*------------------------------------------------------------------------
  11562. *------------------------------------------------------------------------*/
  11563. if ( 0x19 <= exp ) {
  11564. if ( (exp == 0x1F) && fracF16UI( uiA ) ) {
  11565. uiZ = softfloat_propagateNaNF16UI( uiA, 0 );
  11566. goto uiZ;
  11567. }
  11568. return a;
  11569. }
  11570. /*------------------------------------------------------------------------
  11571. *------------------------------------------------------------------------*/
  11572. uiZ = uiA;
  11573. lastBitMask = (uint_fast16_t) 1<<(0x19 - exp);
  11574. roundBitsMask = lastBitMask - 1;
  11575. if ( roundingMode == softfloat_round_near_maxMag ) {
  11576. uiZ += lastBitMask>>1;
  11577. } else if ( roundingMode == softfloat_round_near_even ) {
  11578. uiZ += lastBitMask>>1;
  11579. if ( !(uiZ & roundBitsMask) ) uiZ &= ~lastBitMask;
  11580. } else if (
  11581. roundingMode
  11582. == (signF16UI( uiZ ) ? softfloat_round_min : softfloat_round_max)
  11583. ) {
  11584. uiZ += roundBitsMask;
  11585. }
  11586. uiZ &= ~roundBitsMask;
  11587. if ( uiZ != uiA ) {
  11588. #ifdef SOFTFLOAT_ROUND_ODD
  11589. if ( roundingMode == softfloat_round_odd ) uiZ |= lastBitMask;
  11590. #endif
  11591. if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
  11592. }
  11593. uiZ:
  11594. uZ.ui = uiZ;
  11595. return uZ.f;
  11596. }
  11597. /**** ended inlining ../../source/f16_roundToInt.c ****/
  11598. /**** start inlining ../../source/f16_add.c ****/
  11599. /*============================================================================
  11600. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  11601. Package, Release 3e, by John R. Hauser.
  11602. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  11603. California. All rights reserved.
  11604. Redistribution and use in source and binary forms, with or without
  11605. modification, are permitted provided that the following conditions are met:
  11606. 1. Redistributions of source code must retain the above copyright notice,
  11607. this list of conditions, and the following disclaimer.
  11608. 2. Redistributions in binary form must reproduce the above copyright notice,
  11609. this list of conditions, and the following disclaimer in the documentation
  11610. and/or other materials provided with the distribution.
  11611. 3. Neither the name of the University nor the names of its contributors may
  11612. be used to endorse or promote products derived from this software without
  11613. specific prior written permission.
  11614. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  11615. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  11616. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  11617. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  11618. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  11619. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  11620. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  11621. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  11622. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  11623. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  11624. =============================================================================*/
  11625. #include <stdbool.h>
  11626. #include <stdint.h>
  11627. /**** skipping file: platform.h ****/
  11628. /**** skipping file: internals.h ****/
  11629. /**** skipping file: softfloat.h ****/
  11630. float16_t f16_add( float16_t a, float16_t b )
  11631. {
  11632. union ui16_f16 uA;
  11633. uint_fast16_t uiA;
  11634. union ui16_f16 uB;
  11635. uint_fast16_t uiB;
  11636. #if ! defined INLINE_LEVEL || (INLINE_LEVEL < 1)
  11637. float16_t (*magsFuncPtr)( uint_fast16_t, uint_fast16_t );
  11638. #endif
  11639. uA.f = a;
  11640. uiA = uA.ui;
  11641. uB.f = b;
  11642. uiB = uB.ui;
  11643. #if defined INLINE_LEVEL && (1 <= INLINE_LEVEL)
  11644. if ( signF16UI( uiA ^ uiB ) ) {
  11645. return softfloat_subMagsF16( uiA, uiB );
  11646. } else {
  11647. return softfloat_addMagsF16( uiA, uiB );
  11648. }
  11649. #else
  11650. magsFuncPtr =
  11651. signF16UI( uiA ^ uiB ) ? softfloat_subMagsF16 : softfloat_addMagsF16;
  11652. return (*magsFuncPtr)( uiA, uiB );
  11653. #endif
  11654. }
  11655. /**** ended inlining ../../source/f16_add.c ****/
  11656. /**** start inlining ../../source/f16_sub.c ****/
  11657. /*============================================================================
  11658. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  11659. Package, Release 3e, by John R. Hauser.
  11660. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  11661. California. All rights reserved.
  11662. Redistribution and use in source and binary forms, with or without
  11663. modification, are permitted provided that the following conditions are met:
  11664. 1. Redistributions of source code must retain the above copyright notice,
  11665. this list of conditions, and the following disclaimer.
  11666. 2. Redistributions in binary form must reproduce the above copyright notice,
  11667. this list of conditions, and the following disclaimer in the documentation
  11668. and/or other materials provided with the distribution.
  11669. 3. Neither the name of the University nor the names of its contributors may
  11670. be used to endorse or promote products derived from this software without
  11671. specific prior written permission.
  11672. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  11673. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  11674. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  11675. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  11676. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  11677. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  11678. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  11679. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  11680. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  11681. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  11682. =============================================================================*/
  11683. #include <stdbool.h>
  11684. #include <stdint.h>
  11685. /**** skipping file: platform.h ****/
  11686. /**** skipping file: internals.h ****/
  11687. /**** skipping file: softfloat.h ****/
  11688. float16_t f16_sub( float16_t a, float16_t b )
  11689. {
  11690. union ui16_f16 uA;
  11691. uint_fast16_t uiA;
  11692. union ui16_f16 uB;
  11693. uint_fast16_t uiB;
  11694. #if ! defined INLINE_LEVEL || (INLINE_LEVEL < 1)
  11695. float16_t (*magsFuncPtr)( uint_fast16_t, uint_fast16_t );
  11696. #endif
  11697. uA.f = a;
  11698. uiA = uA.ui;
  11699. uB.f = b;
  11700. uiB = uB.ui;
  11701. #if defined INLINE_LEVEL && (1 <= INLINE_LEVEL)
  11702. if ( signF16UI( uiA ^ uiB ) ) {
  11703. return softfloat_addMagsF16( uiA, uiB );
  11704. } else {
  11705. return softfloat_subMagsF16( uiA, uiB );
  11706. }
  11707. #else
  11708. magsFuncPtr =
  11709. signF16UI( uiA ^ uiB ) ? softfloat_addMagsF16 : softfloat_subMagsF16;
  11710. return (*magsFuncPtr)( uiA, uiB );
  11711. #endif
  11712. }
  11713. /**** ended inlining ../../source/f16_sub.c ****/
  11714. /**** start inlining ../../source/f16_mul.c ****/
  11715. /*============================================================================
  11716. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  11717. Package, Release 3e, by John R. Hauser.
  11718. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  11719. California. All rights reserved.
  11720. Redistribution and use in source and binary forms, with or without
  11721. modification, are permitted provided that the following conditions are met:
  11722. 1. Redistributions of source code must retain the above copyright notice,
  11723. this list of conditions, and the following disclaimer.
  11724. 2. Redistributions in binary form must reproduce the above copyright notice,
  11725. this list of conditions, and the following disclaimer in the documentation
  11726. and/or other materials provided with the distribution.
  11727. 3. Neither the name of the University nor the names of its contributors may
  11728. be used to endorse or promote products derived from this software without
  11729. specific prior written permission.
  11730. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  11731. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  11732. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  11733. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  11734. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  11735. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  11736. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  11737. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  11738. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  11739. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  11740. =============================================================================*/
  11741. #include <stdbool.h>
  11742. #include <stdint.h>
  11743. /**** skipping file: platform.h ****/
  11744. /**** skipping file: internals.h ****/
  11745. /**** skipping file: specialize.h ****/
  11746. /**** skipping file: softfloat.h ****/
  11747. float16_t f16_mul( float16_t a, float16_t b )
  11748. {
  11749. union ui16_f16 uA;
  11750. uint_fast16_t uiA;
  11751. bool signA;
  11752. int_fast8_t expA;
  11753. uint_fast16_t sigA;
  11754. union ui16_f16 uB;
  11755. uint_fast16_t uiB;
  11756. bool signB;
  11757. int_fast8_t expB;
  11758. uint_fast16_t sigB;
  11759. bool signZ;
  11760. uint_fast16_t magBits;
  11761. struct exp8_sig16 normExpSig;
  11762. int_fast8_t expZ;
  11763. uint_fast32_t sig32Z;
  11764. uint_fast16_t sigZ, uiZ;
  11765. union ui16_f16 uZ;
  11766. /*------------------------------------------------------------------------
  11767. *------------------------------------------------------------------------*/
  11768. uA.f = a;
  11769. uiA = uA.ui;
  11770. signA = signF16UI( uiA );
  11771. expA = expF16UI( uiA );
  11772. sigA = fracF16UI( uiA );
  11773. uB.f = b;
  11774. uiB = uB.ui;
  11775. signB = signF16UI( uiB );
  11776. expB = expF16UI( uiB );
  11777. sigB = fracF16UI( uiB );
  11778. signZ = signA ^ signB;
  11779. /*------------------------------------------------------------------------
  11780. *------------------------------------------------------------------------*/
  11781. if ( expA == 0x1F ) {
  11782. if ( sigA || ((expB == 0x1F) && sigB) ) goto propagateNaN;
  11783. magBits = expB | sigB;
  11784. goto infArg;
  11785. }
  11786. if ( expB == 0x1F ) {
  11787. if ( sigB ) goto propagateNaN;
  11788. magBits = expA | sigA;
  11789. goto infArg;
  11790. }
  11791. /*------------------------------------------------------------------------
  11792. *------------------------------------------------------------------------*/
  11793. if ( ! expA ) {
  11794. if ( ! sigA ) goto zero;
  11795. normExpSig = softfloat_normSubnormalF16Sig( sigA );
  11796. expA = normExpSig.exp;
  11797. sigA = normExpSig.sig;
  11798. }
  11799. if ( ! expB ) {
  11800. if ( ! sigB ) goto zero;
  11801. normExpSig = softfloat_normSubnormalF16Sig( sigB );
  11802. expB = normExpSig.exp;
  11803. sigB = normExpSig.sig;
  11804. }
  11805. /*------------------------------------------------------------------------
  11806. *------------------------------------------------------------------------*/
  11807. expZ = expA + expB - 0xF;
  11808. sigA = (sigA | 0x0400)<<4;
  11809. sigB = (sigB | 0x0400)<<5;
  11810. sig32Z = (uint_fast32_t) sigA * sigB;
  11811. sigZ = sig32Z>>16;
  11812. if ( sig32Z & 0xFFFF ) sigZ |= 1;
  11813. if ( sigZ < 0x4000 ) {
  11814. --expZ;
  11815. sigZ <<= 1;
  11816. }
  11817. return softfloat_roundPackToF16( signZ, expZ, sigZ );
  11818. /*------------------------------------------------------------------------
  11819. *------------------------------------------------------------------------*/
  11820. propagateNaN:
  11821. uiZ = softfloat_propagateNaNF16UI( uiA, uiB );
  11822. goto uiZ;
  11823. /*------------------------------------------------------------------------
  11824. *------------------------------------------------------------------------*/
  11825. infArg:
  11826. if ( ! magBits ) {
  11827. softfloat_raiseFlags( softfloat_flag_invalid );
  11828. uiZ = defaultNaNF16UI;
  11829. } else {
  11830. uiZ = packToF16UI( signZ, 0x1F, 0 );
  11831. }
  11832. goto uiZ;
  11833. /*------------------------------------------------------------------------
  11834. *------------------------------------------------------------------------*/
  11835. zero:
  11836. uiZ = packToF16UI( signZ, 0, 0 );
  11837. uiZ:
  11838. uZ.ui = uiZ;
  11839. return uZ.f;
  11840. }
  11841. /**** ended inlining ../../source/f16_mul.c ****/
  11842. /**** start inlining ../../source/f16_mulAdd.c ****/
  11843. /*============================================================================
  11844. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  11845. Package, Release 3e, by John R. Hauser.
  11846. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  11847. California. All rights reserved.
  11848. Redistribution and use in source and binary forms, with or without
  11849. modification, are permitted provided that the following conditions are met:
  11850. 1. Redistributions of source code must retain the above copyright notice,
  11851. this list of conditions, and the following disclaimer.
  11852. 2. Redistributions in binary form must reproduce the above copyright notice,
  11853. this list of conditions, and the following disclaimer in the documentation
  11854. and/or other materials provided with the distribution.
  11855. 3. Neither the name of the University nor the names of its contributors may
  11856. be used to endorse or promote products derived from this software without
  11857. specific prior written permission.
  11858. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  11859. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  11860. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  11861. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  11862. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  11863. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  11864. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  11865. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  11866. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  11867. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  11868. =============================================================================*/
  11869. #include <stdint.h>
  11870. /**** skipping file: platform.h ****/
  11871. /**** skipping file: internals.h ****/
  11872. /**** skipping file: softfloat.h ****/
  11873. float16_t f16_mulAdd( float16_t a, float16_t b, float16_t c )
  11874. {
  11875. union ui16_f16 uA;
  11876. uint_fast16_t uiA;
  11877. union ui16_f16 uB;
  11878. uint_fast16_t uiB;
  11879. union ui16_f16 uC;
  11880. uint_fast16_t uiC;
  11881. uA.f = a;
  11882. uiA = uA.ui;
  11883. uB.f = b;
  11884. uiB = uB.ui;
  11885. uC.f = c;
  11886. uiC = uC.ui;
  11887. return softfloat_mulAddF16( uiA, uiB, uiC, 0 );
  11888. }
  11889. /**** ended inlining ../../source/f16_mulAdd.c ****/
  11890. /**** start inlining ../../source/f16_div.c ****/
  11891. /*============================================================================
  11892. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  11893. Package, Release 3e, by John R. Hauser.
  11894. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  11895. California. All rights reserved.
  11896. Redistribution and use in source and binary forms, with or without
  11897. modification, are permitted provided that the following conditions are met:
  11898. 1. Redistributions of source code must retain the above copyright notice,
  11899. this list of conditions, and the following disclaimer.
  11900. 2. Redistributions in binary form must reproduce the above copyright notice,
  11901. this list of conditions, and the following disclaimer in the documentation
  11902. and/or other materials provided with the distribution.
  11903. 3. Neither the name of the University nor the names of its contributors may
  11904. be used to endorse or promote products derived from this software without
  11905. specific prior written permission.
  11906. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  11907. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  11908. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  11909. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  11910. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  11911. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  11912. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  11913. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  11914. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  11915. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  11916. =============================================================================*/
  11917. #include <stdbool.h>
  11918. #include <stdint.h>
  11919. /**** skipping file: platform.h ****/
  11920. /**** skipping file: internals.h ****/
  11921. /**** skipping file: specialize.h ****/
  11922. /**** skipping file: softfloat.h ****/
  11923. extern const uint16_t softfloat_approxRecip_1k0s[];
  11924. extern const uint16_t softfloat_approxRecip_1k1s[];
  11925. float16_t f16_div( float16_t a, float16_t b )
  11926. {
  11927. union ui16_f16 uA;
  11928. uint_fast16_t uiA;
  11929. bool signA;
  11930. int_fast8_t expA;
  11931. uint_fast16_t sigA;
  11932. union ui16_f16 uB;
  11933. uint_fast16_t uiB;
  11934. bool signB;
  11935. int_fast8_t expB;
  11936. uint_fast16_t sigB;
  11937. bool signZ;
  11938. struct exp8_sig16 normExpSig;
  11939. int_fast8_t expZ;
  11940. #ifdef SOFTFLOAT_FAST_DIV32TO16
  11941. uint_fast32_t sig32A;
  11942. uint_fast16_t sigZ;
  11943. #else
  11944. int index;
  11945. uint16_t r0;
  11946. uint_fast16_t sigZ, rem;
  11947. #endif
  11948. uint_fast16_t uiZ;
  11949. union ui16_f16 uZ;
  11950. /*------------------------------------------------------------------------
  11951. *------------------------------------------------------------------------*/
  11952. uA.f = a;
  11953. uiA = uA.ui;
  11954. signA = signF16UI( uiA );
  11955. expA = expF16UI( uiA );
  11956. sigA = fracF16UI( uiA );
  11957. uB.f = b;
  11958. uiB = uB.ui;
  11959. signB = signF16UI( uiB );
  11960. expB = expF16UI( uiB );
  11961. sigB = fracF16UI( uiB );
  11962. signZ = signA ^ signB;
  11963. /*------------------------------------------------------------------------
  11964. *------------------------------------------------------------------------*/
  11965. if ( expA == 0x1F ) {
  11966. if ( sigA ) goto propagateNaN;
  11967. if ( expB == 0x1F ) {
  11968. if ( sigB ) goto propagateNaN;
  11969. goto invalid;
  11970. }
  11971. goto infinity;
  11972. }
  11973. if ( expB == 0x1F ) {
  11974. if ( sigB ) goto propagateNaN;
  11975. goto zero;
  11976. }
  11977. /*------------------------------------------------------------------------
  11978. *------------------------------------------------------------------------*/
  11979. if ( ! expB ) {
  11980. if ( ! sigB ) {
  11981. if ( ! (expA | sigA) ) goto invalid;
  11982. softfloat_raiseFlags( softfloat_flag_infinite );
  11983. goto infinity;
  11984. }
  11985. normExpSig = softfloat_normSubnormalF16Sig( sigB );
  11986. expB = normExpSig.exp;
  11987. sigB = normExpSig.sig;
  11988. }
  11989. if ( ! expA ) {
  11990. if ( ! sigA ) goto zero;
  11991. normExpSig = softfloat_normSubnormalF16Sig( sigA );
  11992. expA = normExpSig.exp;
  11993. sigA = normExpSig.sig;
  11994. }
  11995. /*------------------------------------------------------------------------
  11996. *------------------------------------------------------------------------*/
  11997. expZ = expA - expB + 0xE;
  11998. sigA |= 0x0400;
  11999. sigB |= 0x0400;
  12000. #ifdef SOFTFLOAT_FAST_DIV32TO16
  12001. if ( sigA < sigB ) {
  12002. --expZ;
  12003. sig32A = (uint_fast32_t) sigA<<15;
  12004. } else {
  12005. sig32A = (uint_fast32_t) sigA<<14;
  12006. }
  12007. sigZ = sig32A / sigB;
  12008. if ( ! (sigZ & 7) ) sigZ |= ((uint_fast32_t) sigB * sigZ != sig32A);
  12009. #else
  12010. if ( sigA < sigB ) {
  12011. --expZ;
  12012. sigA <<= 5;
  12013. } else {
  12014. sigA <<= 4;
  12015. }
  12016. index = sigB>>6 & 0xF;
  12017. r0 = softfloat_approxRecip_1k0s[index]
  12018. - (((uint_fast32_t) softfloat_approxRecip_1k1s[index]
  12019. * (sigB & 0x3F))
  12020. >>10);
  12021. sigZ = ((uint_fast32_t) sigA * r0)>>16;
  12022. rem = (sigA<<10) - sigZ * sigB;
  12023. sigZ += (rem * (uint_fast32_t) r0)>>26;
  12024. /*------------------------------------------------------------------------
  12025. *------------------------------------------------------------------------*/
  12026. ++sigZ;
  12027. if ( ! (sigZ & 7) ) {
  12028. sigZ &= ~1;
  12029. rem = (sigA<<10) - sigZ * sigB;
  12030. if ( rem & 0x8000 ) {
  12031. sigZ -= 2;
  12032. } else {
  12033. if ( rem ) sigZ |= 1;
  12034. }
  12035. }
  12036. #endif
  12037. return softfloat_roundPackToF16( signZ, expZ, sigZ );
  12038. /*------------------------------------------------------------------------
  12039. *------------------------------------------------------------------------*/
  12040. propagateNaN:
  12041. uiZ = softfloat_propagateNaNF16UI( uiA, uiB );
  12042. goto uiZ;
  12043. /*------------------------------------------------------------------------
  12044. *------------------------------------------------------------------------*/
  12045. invalid:
  12046. softfloat_raiseFlags( softfloat_flag_invalid );
  12047. uiZ = defaultNaNF16UI;
  12048. goto uiZ;
  12049. /*------------------------------------------------------------------------
  12050. *------------------------------------------------------------------------*/
  12051. infinity:
  12052. uiZ = packToF16UI( signZ, 0x1F, 0 );
  12053. goto uiZ;
  12054. /*------------------------------------------------------------------------
  12055. *------------------------------------------------------------------------*/
  12056. zero:
  12057. uiZ = packToF16UI( signZ, 0, 0 );
  12058. uiZ:
  12059. uZ.ui = uiZ;
  12060. return uZ.f;
  12061. }
  12062. /**** ended inlining ../../source/f16_div.c ****/
  12063. /**** start inlining ../../source/f16_rem.c ****/
  12064. /*============================================================================
  12065. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  12066. Package, Release 3e, by John R. Hauser.
  12067. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  12068. California. All rights reserved.
  12069. Redistribution and use in source and binary forms, with or without
  12070. modification, are permitted provided that the following conditions are met:
  12071. 1. Redistributions of source code must retain the above copyright notice,
  12072. this list of conditions, and the following disclaimer.
  12073. 2. Redistributions in binary form must reproduce the above copyright notice,
  12074. this list of conditions, and the following disclaimer in the documentation
  12075. and/or other materials provided with the distribution.
  12076. 3. Neither the name of the University nor the names of its contributors may
  12077. be used to endorse or promote products derived from this software without
  12078. specific prior written permission.
  12079. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  12080. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  12081. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  12082. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  12083. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  12084. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  12085. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  12086. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12087. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  12088. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  12089. =============================================================================*/
  12090. #include <stdbool.h>
  12091. #include <stdint.h>
  12092. /**** skipping file: platform.h ****/
  12093. /**** skipping file: internals.h ****/
  12094. /**** skipping file: specialize.h ****/
  12095. /**** skipping file: softfloat.h ****/
  12096. float16_t f16_rem( float16_t a, float16_t b )
  12097. {
  12098. union ui16_f16 uA;
  12099. uint_fast16_t uiA;
  12100. bool signA;
  12101. int_fast8_t expA;
  12102. uint_fast16_t sigA;
  12103. union ui16_f16 uB;
  12104. uint_fast16_t uiB;
  12105. int_fast8_t expB;
  12106. uint_fast16_t sigB;
  12107. struct exp8_sig16 normExpSig;
  12108. uint16_t rem;
  12109. int_fast8_t expDiff;
  12110. uint_fast16_t q;
  12111. uint32_t recip32, q32;
  12112. uint16_t altRem, meanRem;
  12113. bool signRem;
  12114. uint_fast16_t uiZ;
  12115. union ui16_f16 uZ;
  12116. /*------------------------------------------------------------------------
  12117. *------------------------------------------------------------------------*/
  12118. uA.f = a;
  12119. uiA = uA.ui;
  12120. signA = signF16UI( uiA );
  12121. expA = expF16UI( uiA );
  12122. sigA = fracF16UI( uiA );
  12123. uB.f = b;
  12124. uiB = uB.ui;
  12125. expB = expF16UI( uiB );
  12126. sigB = fracF16UI( uiB );
  12127. /*------------------------------------------------------------------------
  12128. *------------------------------------------------------------------------*/
  12129. if ( expA == 0x1F ) {
  12130. if ( sigA || ((expB == 0x1F) && sigB) ) goto propagateNaN;
  12131. goto invalid;
  12132. }
  12133. if ( expB == 0x1F ) {
  12134. if ( sigB ) goto propagateNaN;
  12135. return a;
  12136. }
  12137. /*------------------------------------------------------------------------
  12138. *------------------------------------------------------------------------*/
  12139. if ( ! expB ) {
  12140. if ( ! sigB ) goto invalid;
  12141. normExpSig = softfloat_normSubnormalF16Sig( sigB );
  12142. expB = normExpSig.exp;
  12143. sigB = normExpSig.sig;
  12144. }
  12145. if ( ! expA ) {
  12146. if ( ! sigA ) return a;
  12147. normExpSig = softfloat_normSubnormalF16Sig( sigA );
  12148. expA = normExpSig.exp;
  12149. sigA = normExpSig.sig;
  12150. }
  12151. /*------------------------------------------------------------------------
  12152. *------------------------------------------------------------------------*/
  12153. rem = sigA | 0x0400;
  12154. sigB |= 0x0400;
  12155. expDiff = expA - expB;
  12156. if ( expDiff < 1 ) {
  12157. if ( expDiff < -1 ) return a;
  12158. sigB <<= 3;
  12159. if ( expDiff ) {
  12160. rem <<= 2;
  12161. q = 0;
  12162. } else {
  12163. rem <<= 3;
  12164. q = (sigB <= rem);
  12165. if ( q ) rem -= sigB;
  12166. }
  12167. } else {
  12168. recip32 = softfloat_approxRecip32_1( (uint_fast32_t) sigB<<21 );
  12169. /*--------------------------------------------------------------------
  12170. | Changing the shift of `rem' here requires also changing the initial
  12171. | subtraction from `expDiff'.
  12172. *--------------------------------------------------------------------*/
  12173. rem <<= 4;
  12174. expDiff -= 31;
  12175. /*--------------------------------------------------------------------
  12176. | The scale of `sigB' affects how many bits are obtained during each
  12177. | cycle of the loop. Currently this is 29 bits per loop iteration,
  12178. | which is believed to be the maximum possible.
  12179. *--------------------------------------------------------------------*/
  12180. sigB <<= 3;
  12181. for (;;) {
  12182. q32 = (rem * (uint_fast64_t) recip32)>>16;
  12183. if ( expDiff < 0 ) break;
  12184. rem = -((uint_fast16_t) q32 * sigB);
  12185. expDiff -= 29;
  12186. }
  12187. /*--------------------------------------------------------------------
  12188. | (`expDiff' cannot be less than -30 here.)
  12189. *--------------------------------------------------------------------*/
  12190. q32 >>= ~expDiff & 31;
  12191. q = q32;
  12192. rem = (rem<<(expDiff + 30)) - q * sigB;
  12193. }
  12194. /*------------------------------------------------------------------------
  12195. *------------------------------------------------------------------------*/
  12196. do {
  12197. altRem = rem;
  12198. ++q;
  12199. rem -= sigB;
  12200. } while ( ! (rem & 0x8000) );
  12201. meanRem = rem + altRem;
  12202. if ( (meanRem & 0x8000) || (! meanRem && (q & 1)) ) rem = altRem;
  12203. signRem = signA;
  12204. if ( 0x8000 <= rem ) {
  12205. signRem = ! signRem;
  12206. rem = -rem;
  12207. }
  12208. return softfloat_normRoundPackToF16( signRem, expB, rem );
  12209. /*------------------------------------------------------------------------
  12210. *------------------------------------------------------------------------*/
  12211. propagateNaN:
  12212. uiZ = softfloat_propagateNaNF16UI( uiA, uiB );
  12213. goto uiZ;
  12214. invalid:
  12215. softfloat_raiseFlags( softfloat_flag_invalid );
  12216. uiZ = defaultNaNF16UI;
  12217. uiZ:
  12218. uZ.ui = uiZ;
  12219. return uZ.f;
  12220. }
  12221. /**** ended inlining ../../source/f16_rem.c ****/
  12222. /**** start inlining ../../source/f16_sqrt.c ****/
  12223. /*============================================================================
  12224. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  12225. Package, Release 3e, by John R. Hauser.
  12226. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  12227. California. All rights reserved.
  12228. Redistribution and use in source and binary forms, with or without
  12229. modification, are permitted provided that the following conditions are met:
  12230. 1. Redistributions of source code must retain the above copyright notice,
  12231. this list of conditions, and the following disclaimer.
  12232. 2. Redistributions in binary form must reproduce the above copyright notice,
  12233. this list of conditions, and the following disclaimer in the documentation
  12234. and/or other materials provided with the distribution.
  12235. 3. Neither the name of the University nor the names of its contributors may
  12236. be used to endorse or promote products derived from this software without
  12237. specific prior written permission.
  12238. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  12239. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  12240. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  12241. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  12242. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  12243. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  12244. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  12245. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12246. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  12247. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  12248. =============================================================================*/
  12249. #include <stdbool.h>
  12250. #include <stdint.h>
  12251. /**** skipping file: platform.h ****/
  12252. /**** skipping file: internals.h ****/
  12253. /**** skipping file: specialize.h ****/
  12254. /**** skipping file: softfloat.h ****/
  12255. extern const uint16_t softfloat_approxRecipSqrt_1k0s[];
  12256. extern const uint16_t softfloat_approxRecipSqrt_1k1s[];
  12257. float16_t f16_sqrt( float16_t a )
  12258. {
  12259. union ui16_f16 uA;
  12260. uint_fast16_t uiA;
  12261. bool signA;
  12262. int_fast8_t expA;
  12263. uint_fast16_t sigA, uiZ;
  12264. struct exp8_sig16 normExpSig;
  12265. int_fast8_t expZ;
  12266. int index;
  12267. uint_fast16_t r0;
  12268. uint_fast32_t ESqrR0;
  12269. uint16_t sigma0;
  12270. uint_fast16_t recipSqrt16, sigZ, shiftedSigZ;
  12271. uint16_t negRem;
  12272. union ui16_f16 uZ;
  12273. /*------------------------------------------------------------------------
  12274. *------------------------------------------------------------------------*/
  12275. uA.f = a;
  12276. uiA = uA.ui;
  12277. signA = signF16UI( uiA );
  12278. expA = expF16UI( uiA );
  12279. sigA = fracF16UI( uiA );
  12280. /*------------------------------------------------------------------------
  12281. *------------------------------------------------------------------------*/
  12282. if ( expA == 0x1F ) {
  12283. if ( sigA ) {
  12284. uiZ = softfloat_propagateNaNF16UI( uiA, 0 );
  12285. goto uiZ;
  12286. }
  12287. if ( ! signA ) return a;
  12288. goto invalid;
  12289. }
  12290. /*------------------------------------------------------------------------
  12291. *------------------------------------------------------------------------*/
  12292. if ( signA ) {
  12293. if ( ! (expA | sigA) ) return a;
  12294. goto invalid;
  12295. }
  12296. /*------------------------------------------------------------------------
  12297. *------------------------------------------------------------------------*/
  12298. if ( ! expA ) {
  12299. if ( ! sigA ) return a;
  12300. normExpSig = softfloat_normSubnormalF16Sig( sigA );
  12301. expA = normExpSig.exp;
  12302. sigA = normExpSig.sig;
  12303. }
  12304. /*------------------------------------------------------------------------
  12305. *------------------------------------------------------------------------*/
  12306. expZ = ((expA - 0xF)>>1) + 0xE;
  12307. expA &= 1;
  12308. sigA |= 0x0400;
  12309. index = (sigA>>6 & 0xE) + expA;
  12310. r0 = softfloat_approxRecipSqrt_1k0s[index]
  12311. - (((uint_fast32_t) softfloat_approxRecipSqrt_1k1s[index]
  12312. * (sigA & 0x7F))
  12313. >>11);
  12314. ESqrR0 = ((uint_fast32_t) r0 * r0)>>1;
  12315. if ( expA ) ESqrR0 >>= 1;
  12316. sigma0 = ~(uint_fast16_t) ((ESqrR0 * sigA)>>16);
  12317. recipSqrt16 = r0 + (((uint_fast32_t) r0 * sigma0)>>25);
  12318. if ( ! (recipSqrt16 & 0x8000) ) recipSqrt16 = 0x8000;
  12319. sigZ = ((uint_fast32_t) (sigA<<5) * recipSqrt16)>>16;
  12320. if ( expA ) sigZ >>= 1;
  12321. /*------------------------------------------------------------------------
  12322. *------------------------------------------------------------------------*/
  12323. ++sigZ;
  12324. if ( ! (sigZ & 7) ) {
  12325. shiftedSigZ = sigZ>>1;
  12326. negRem = shiftedSigZ * shiftedSigZ;
  12327. sigZ &= ~1;
  12328. if ( negRem & 0x8000 ) {
  12329. sigZ |= 1;
  12330. } else {
  12331. if ( negRem ) --sigZ;
  12332. }
  12333. }
  12334. return softfloat_roundPackToF16( 0, expZ, sigZ );
  12335. /*------------------------------------------------------------------------
  12336. *------------------------------------------------------------------------*/
  12337. invalid:
  12338. softfloat_raiseFlags( softfloat_flag_invalid );
  12339. uiZ = defaultNaNF16UI;
  12340. uiZ:
  12341. uZ.ui = uiZ;
  12342. return uZ.f;
  12343. }
  12344. /**** ended inlining ../../source/f16_sqrt.c ****/
  12345. /**** start inlining ../../source/f16_eq.c ****/
  12346. /*============================================================================
  12347. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  12348. Package, Release 3e, by John R. Hauser.
  12349. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  12350. California. All rights reserved.
  12351. Redistribution and use in source and binary forms, with or without
  12352. modification, are permitted provided that the following conditions are met:
  12353. 1. Redistributions of source code must retain the above copyright notice,
  12354. this list of conditions, and the following disclaimer.
  12355. 2. Redistributions in binary form must reproduce the above copyright notice,
  12356. this list of conditions, and the following disclaimer in the documentation
  12357. and/or other materials provided with the distribution.
  12358. 3. Neither the name of the University nor the names of its contributors may
  12359. be used to endorse or promote products derived from this software without
  12360. specific prior written permission.
  12361. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  12362. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  12363. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  12364. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  12365. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  12366. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  12367. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  12368. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12369. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  12370. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  12371. =============================================================================*/
  12372. #include <stdbool.h>
  12373. #include <stdint.h>
  12374. /**** skipping file: platform.h ****/
  12375. /**** skipping file: internals.h ****/
  12376. /**** skipping file: specialize.h ****/
  12377. /**** skipping file: softfloat.h ****/
  12378. bool f16_eq( float16_t a, float16_t b )
  12379. {
  12380. union ui16_f16 uA;
  12381. uint_fast16_t uiA;
  12382. union ui16_f16 uB;
  12383. uint_fast16_t uiB;
  12384. uA.f = a;
  12385. uiA = uA.ui;
  12386. uB.f = b;
  12387. uiB = uB.ui;
  12388. if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
  12389. if (
  12390. softfloat_isSigNaNF16UI( uiA ) || softfloat_isSigNaNF16UI( uiB )
  12391. ) {
  12392. softfloat_raiseFlags( softfloat_flag_invalid );
  12393. }
  12394. return false;
  12395. }
  12396. return (uiA == uiB) || ! (uint16_t) ((uiA | uiB)<<1);
  12397. }
  12398. /**** ended inlining ../../source/f16_eq.c ****/
  12399. /**** start inlining ../../source/f16_le.c ****/
  12400. /*============================================================================
  12401. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  12402. Package, Release 3e, by John R. Hauser.
  12403. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  12404. California. All rights reserved.
  12405. Redistribution and use in source and binary forms, with or without
  12406. modification, are permitted provided that the following conditions are met:
  12407. 1. Redistributions of source code must retain the above copyright notice,
  12408. this list of conditions, and the following disclaimer.
  12409. 2. Redistributions in binary form must reproduce the above copyright notice,
  12410. this list of conditions, and the following disclaimer in the documentation
  12411. and/or other materials provided with the distribution.
  12412. 3. Neither the name of the University nor the names of its contributors may
  12413. be used to endorse or promote products derived from this software without
  12414. specific prior written permission.
  12415. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  12416. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  12417. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  12418. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  12419. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  12420. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  12421. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  12422. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12423. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  12424. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  12425. =============================================================================*/
  12426. #include <stdbool.h>
  12427. #include <stdint.h>
  12428. /**** skipping file: platform.h ****/
  12429. /**** skipping file: internals.h ****/
  12430. /**** skipping file: softfloat.h ****/
  12431. bool f16_le( float16_t a, float16_t b )
  12432. {
  12433. union ui16_f16 uA;
  12434. uint_fast16_t uiA;
  12435. union ui16_f16 uB;
  12436. uint_fast16_t uiB;
  12437. bool signA, signB;
  12438. uA.f = a;
  12439. uiA = uA.ui;
  12440. uB.f = b;
  12441. uiB = uB.ui;
  12442. if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
  12443. softfloat_raiseFlags( softfloat_flag_invalid );
  12444. return false;
  12445. }
  12446. signA = signF16UI( uiA );
  12447. signB = signF16UI( uiB );
  12448. return
  12449. (signA != signB) ? signA || ! (uint16_t) ((uiA | uiB)<<1)
  12450. : (uiA == uiB) || (signA ^ (uiA < uiB));
  12451. }
  12452. /**** ended inlining ../../source/f16_le.c ****/
  12453. /**** start inlining ../../source/f16_lt.c ****/
  12454. /*============================================================================
  12455. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  12456. Package, Release 3e, by John R. Hauser.
  12457. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  12458. California. All rights reserved.
  12459. Redistribution and use in source and binary forms, with or without
  12460. modification, are permitted provided that the following conditions are met:
  12461. 1. Redistributions of source code must retain the above copyright notice,
  12462. this list of conditions, and the following disclaimer.
  12463. 2. Redistributions in binary form must reproduce the above copyright notice,
  12464. this list of conditions, and the following disclaimer in the documentation
  12465. and/or other materials provided with the distribution.
  12466. 3. Neither the name of the University nor the names of its contributors may
  12467. be used to endorse or promote products derived from this software without
  12468. specific prior written permission.
  12469. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  12470. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  12471. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  12472. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  12473. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  12474. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  12475. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  12476. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12477. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  12478. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  12479. =============================================================================*/
  12480. #include <stdbool.h>
  12481. #include <stdint.h>
  12482. /**** skipping file: platform.h ****/
  12483. /**** skipping file: internals.h ****/
  12484. /**** skipping file: softfloat.h ****/
  12485. bool f16_lt( float16_t a, float16_t b )
  12486. {
  12487. union ui16_f16 uA;
  12488. uint_fast16_t uiA;
  12489. union ui16_f16 uB;
  12490. uint_fast16_t uiB;
  12491. bool signA, signB;
  12492. uA.f = a;
  12493. uiA = uA.ui;
  12494. uB.f = b;
  12495. uiB = uB.ui;
  12496. if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
  12497. softfloat_raiseFlags( softfloat_flag_invalid );
  12498. return false;
  12499. }
  12500. signA = signF16UI( uiA );
  12501. signB = signF16UI( uiB );
  12502. return
  12503. (signA != signB) ? signA && ((uint16_t) ((uiA | uiB)<<1) != 0)
  12504. : (uiA != uiB) && (signA ^ (uiA < uiB));
  12505. }
  12506. /**** ended inlining ../../source/f16_lt.c ****/
  12507. /**** start inlining ../../source/f16_eq_signaling.c ****/
  12508. /*============================================================================
  12509. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  12510. Package, Release 3e, by John R. Hauser.
  12511. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  12512. California. All rights reserved.
  12513. Redistribution and use in source and binary forms, with or without
  12514. modification, are permitted provided that the following conditions are met:
  12515. 1. Redistributions of source code must retain the above copyright notice,
  12516. this list of conditions, and the following disclaimer.
  12517. 2. Redistributions in binary form must reproduce the above copyright notice,
  12518. this list of conditions, and the following disclaimer in the documentation
  12519. and/or other materials provided with the distribution.
  12520. 3. Neither the name of the University nor the names of its contributors may
  12521. be used to endorse or promote products derived from this software without
  12522. specific prior written permission.
  12523. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  12524. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  12525. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  12526. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  12527. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  12528. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  12529. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  12530. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12531. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  12532. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  12533. =============================================================================*/
  12534. #include <stdbool.h>
  12535. #include <stdint.h>
  12536. /**** skipping file: platform.h ****/
  12537. /**** skipping file: internals.h ****/
  12538. /**** skipping file: softfloat.h ****/
  12539. bool f16_eq_signaling( float16_t a, float16_t b )
  12540. {
  12541. union ui16_f16 uA;
  12542. uint_fast16_t uiA;
  12543. union ui16_f16 uB;
  12544. uint_fast16_t uiB;
  12545. uA.f = a;
  12546. uiA = uA.ui;
  12547. uB.f = b;
  12548. uiB = uB.ui;
  12549. if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
  12550. softfloat_raiseFlags( softfloat_flag_invalid );
  12551. return false;
  12552. }
  12553. return (uiA == uiB) || ! (uint16_t) ((uiA | uiB)<<1);
  12554. }
  12555. /**** ended inlining ../../source/f16_eq_signaling.c ****/
  12556. /**** start inlining ../../source/f16_le_quiet.c ****/
  12557. /*============================================================================
  12558. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  12559. Package, Release 3e, by John R. Hauser.
  12560. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  12561. California. All rights reserved.
  12562. Redistribution and use in source and binary forms, with or without
  12563. modification, are permitted provided that the following conditions are met:
  12564. 1. Redistributions of source code must retain the above copyright notice,
  12565. this list of conditions, and the following disclaimer.
  12566. 2. Redistributions in binary form must reproduce the above copyright notice,
  12567. this list of conditions, and the following disclaimer in the documentation
  12568. and/or other materials provided with the distribution.
  12569. 3. Neither the name of the University nor the names of its contributors may
  12570. be used to endorse or promote products derived from this software without
  12571. specific prior written permission.
  12572. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  12573. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  12574. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  12575. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  12576. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  12577. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  12578. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  12579. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12580. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  12581. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  12582. =============================================================================*/
  12583. #include <stdbool.h>
  12584. #include <stdint.h>
  12585. /**** skipping file: platform.h ****/
  12586. /**** skipping file: internals.h ****/
  12587. /**** skipping file: specialize.h ****/
  12588. /**** skipping file: softfloat.h ****/
  12589. bool f16_le_quiet( float16_t a, float16_t b )
  12590. {
  12591. union ui16_f16 uA;
  12592. uint_fast16_t uiA;
  12593. union ui16_f16 uB;
  12594. uint_fast16_t uiB;
  12595. bool signA, signB;
  12596. uA.f = a;
  12597. uiA = uA.ui;
  12598. uB.f = b;
  12599. uiB = uB.ui;
  12600. if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
  12601. if (
  12602. softfloat_isSigNaNF16UI( uiA ) || softfloat_isSigNaNF16UI( uiB )
  12603. ) {
  12604. softfloat_raiseFlags( softfloat_flag_invalid );
  12605. }
  12606. return false;
  12607. }
  12608. signA = signF16UI( uiA );
  12609. signB = signF16UI( uiB );
  12610. return
  12611. (signA != signB) ? signA || ! (uint16_t) ((uiA | uiB)<<1)
  12612. : (uiA == uiB) || (signA ^ (uiA < uiB));
  12613. }
  12614. /**** ended inlining ../../source/f16_le_quiet.c ****/
  12615. /**** start inlining ../../source/f16_lt_quiet.c ****/
  12616. /*============================================================================
  12617. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  12618. Package, Release 3e, by John R. Hauser.
  12619. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  12620. California. All rights reserved.
  12621. Redistribution and use in source and binary forms, with or without
  12622. modification, are permitted provided that the following conditions are met:
  12623. 1. Redistributions of source code must retain the above copyright notice,
  12624. this list of conditions, and the following disclaimer.
  12625. 2. Redistributions in binary form must reproduce the above copyright notice,
  12626. this list of conditions, and the following disclaimer in the documentation
  12627. and/or other materials provided with the distribution.
  12628. 3. Neither the name of the University nor the names of its contributors may
  12629. be used to endorse or promote products derived from this software without
  12630. specific prior written permission.
  12631. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  12632. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  12633. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  12634. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  12635. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  12636. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  12637. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  12638. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12639. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  12640. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  12641. =============================================================================*/
  12642. #include <stdbool.h>
  12643. #include <stdint.h>
  12644. /**** skipping file: platform.h ****/
  12645. /**** skipping file: internals.h ****/
  12646. /**** skipping file: specialize.h ****/
  12647. /**** skipping file: softfloat.h ****/
  12648. bool f16_lt_quiet( float16_t a, float16_t b )
  12649. {
  12650. union ui16_f16 uA;
  12651. uint_fast16_t uiA;
  12652. union ui16_f16 uB;
  12653. uint_fast16_t uiB;
  12654. bool signA, signB;
  12655. uA.f = a;
  12656. uiA = uA.ui;
  12657. uB.f = b;
  12658. uiB = uB.ui;
  12659. if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
  12660. if (
  12661. softfloat_isSigNaNF16UI( uiA ) || softfloat_isSigNaNF16UI( uiB )
  12662. ) {
  12663. softfloat_raiseFlags( softfloat_flag_invalid );
  12664. }
  12665. return false;
  12666. }
  12667. signA = signF16UI( uiA );
  12668. signB = signF16UI( uiB );
  12669. return
  12670. (signA != signB) ? signA && ((uint16_t) ((uiA | uiB)<<1) != 0)
  12671. : (uiA != uiB) && (signA ^ (uiA < uiB));
  12672. }
  12673. /**** ended inlining ../../source/f16_lt_quiet.c ****/
  12674. /**** start inlining ../../source/f16_isSignalingNaN.c ****/
  12675. /*============================================================================
  12676. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  12677. Package, Release 3e, by John R. Hauser.
  12678. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  12679. California. All rights reserved.
  12680. Redistribution and use in source and binary forms, with or without
  12681. modification, are permitted provided that the following conditions are met:
  12682. 1. Redistributions of source code must retain the above copyright notice,
  12683. this list of conditions, and the following disclaimer.
  12684. 2. Redistributions in binary form must reproduce the above copyright notice,
  12685. this list of conditions, and the following disclaimer in the documentation
  12686. and/or other materials provided with the distribution.
  12687. 3. Neither the name of the University nor the names of its contributors may
  12688. be used to endorse or promote products derived from this software without
  12689. specific prior written permission.
  12690. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  12691. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  12692. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  12693. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  12694. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  12695. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  12696. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  12697. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12698. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  12699. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  12700. =============================================================================*/
  12701. #include <stdbool.h>
  12702. /**** skipping file: platform.h ****/
  12703. /**** skipping file: internals.h ****/
  12704. /**** skipping file: specialize.h ****/
  12705. /**** skipping file: softfloat.h ****/
  12706. bool f16_isSignalingNaN( float16_t a )
  12707. {
  12708. union ui16_f16 uA;
  12709. uA.f = a;
  12710. return softfloat_isSigNaNF16UI( uA.ui );
  12711. }
  12712. /**** ended inlining ../../source/f16_isSignalingNaN.c ****/
  12713. /**** start inlining ../../source/f32_to_ui32.c ****/
  12714. /*============================================================================
  12715. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  12716. Package, Release 3e, by John R. Hauser.
  12717. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  12718. University of California. All rights reserved.
  12719. Redistribution and use in source and binary forms, with or without
  12720. modification, are permitted provided that the following conditions are met:
  12721. 1. Redistributions of source code must retain the above copyright notice,
  12722. this list of conditions, and the following disclaimer.
  12723. 2. Redistributions in binary form must reproduce the above copyright notice,
  12724. this list of conditions, and the following disclaimer in the documentation
  12725. and/or other materials provided with the distribution.
  12726. 3. Neither the name of the University nor the names of its contributors may
  12727. be used to endorse or promote products derived from this software without
  12728. specific prior written permission.
  12729. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  12730. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  12731. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  12732. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  12733. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  12734. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  12735. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  12736. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12737. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  12738. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  12739. =============================================================================*/
  12740. #include <stdbool.h>
  12741. #include <stdint.h>
  12742. /**** skipping file: platform.h ****/
  12743. /**** skipping file: internals.h ****/
  12744. /**** skipping file: specialize.h ****/
  12745. /**** skipping file: softfloat.h ****/
  12746. uint_fast32_t f32_to_ui32( float32_t a, uint_fast8_t roundingMode, bool exact )
  12747. {
  12748. union ui32_f32 uA;
  12749. uint_fast32_t uiA;
  12750. bool sign;
  12751. int_fast16_t exp;
  12752. uint_fast32_t sig;
  12753. uint_fast64_t sig64;
  12754. int_fast16_t shiftDist;
  12755. /*------------------------------------------------------------------------
  12756. *------------------------------------------------------------------------*/
  12757. uA.f = a;
  12758. uiA = uA.ui;
  12759. sign = signF32UI( uiA );
  12760. exp = expF32UI( uiA );
  12761. sig = fracF32UI( uiA );
  12762. /*------------------------------------------------------------------------
  12763. *------------------------------------------------------------------------*/
  12764. #if (ui32_fromNaN != ui32_fromPosOverflow) || (ui32_fromNaN != ui32_fromNegOverflow)
  12765. if ( (exp == 0xFF) && sig ) {
  12766. #if (ui32_fromNaN == ui32_fromPosOverflow)
  12767. sign = 0;
  12768. #elif (ui32_fromNaN == ui32_fromNegOverflow)
  12769. sign = 1;
  12770. #else
  12771. softfloat_raiseFlags( softfloat_flag_invalid );
  12772. return ui32_fromNaN;
  12773. #endif
  12774. }
  12775. #endif
  12776. /*------------------------------------------------------------------------
  12777. *------------------------------------------------------------------------*/
  12778. if ( exp ) sig |= 0x00800000;
  12779. sig64 = (uint_fast64_t) sig<<32;
  12780. shiftDist = 0xAA - exp;
  12781. if ( 0 < shiftDist ) sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
  12782. return softfloat_roundToUI32( sign, sig64, roundingMode, exact );
  12783. }
  12784. /**** ended inlining ../../source/f32_to_ui32.c ****/
  12785. /**** start inlining ../../source/f32_to_ui64.c ****/
  12786. /*============================================================================
  12787. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  12788. Package, Release 3e, by John R. Hauser.
  12789. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  12790. University of California. All rights reserved.
  12791. Redistribution and use in source and binary forms, with or without
  12792. modification, are permitted provided that the following conditions are met:
  12793. 1. Redistributions of source code must retain the above copyright notice,
  12794. this list of conditions, and the following disclaimer.
  12795. 2. Redistributions in binary form must reproduce the above copyright notice,
  12796. this list of conditions, and the following disclaimer in the documentation
  12797. and/or other materials provided with the distribution.
  12798. 3. Neither the name of the University nor the names of its contributors may
  12799. be used to endorse or promote products derived from this software without
  12800. specific prior written permission.
  12801. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  12802. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  12803. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  12804. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  12805. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  12806. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  12807. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  12808. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12809. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  12810. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  12811. =============================================================================*/
  12812. #include <stdbool.h>
  12813. #include <stdint.h>
  12814. /**** skipping file: platform.h ****/
  12815. /**** skipping file: internals.h ****/
  12816. /**** skipping file: specialize.h ****/
  12817. /**** skipping file: softfloat.h ****/
  12818. uint_fast64_t f32_to_ui64( float32_t a, uint_fast8_t roundingMode, bool exact )
  12819. {
  12820. union ui32_f32 uA;
  12821. uint_fast32_t uiA;
  12822. bool sign;
  12823. int_fast16_t exp;
  12824. uint_fast32_t sig;
  12825. int_fast16_t shiftDist;
  12826. #ifdef SOFTFLOAT_FAST_INT64
  12827. uint_fast64_t sig64, extra;
  12828. struct uint64_extra sig64Extra;
  12829. #else
  12830. uint32_t extSig[3];
  12831. #endif
  12832. /*------------------------------------------------------------------------
  12833. *------------------------------------------------------------------------*/
  12834. uA.f = a;
  12835. uiA = uA.ui;
  12836. sign = signF32UI( uiA );
  12837. exp = expF32UI( uiA );
  12838. sig = fracF32UI( uiA );
  12839. /*------------------------------------------------------------------------
  12840. *------------------------------------------------------------------------*/
  12841. shiftDist = 0xBE - exp;
  12842. if ( shiftDist < 0 ) {
  12843. softfloat_raiseFlags( softfloat_flag_invalid );
  12844. return
  12845. (exp == 0xFF) && sig ? ui64_fromNaN
  12846. : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
  12847. }
  12848. /*------------------------------------------------------------------------
  12849. *------------------------------------------------------------------------*/
  12850. if ( exp ) sig |= 0x00800000;
  12851. #ifdef SOFTFLOAT_FAST_INT64
  12852. sig64 = (uint_fast64_t) sig<<40;
  12853. extra = 0;
  12854. if ( shiftDist ) {
  12855. sig64Extra = softfloat_shiftRightJam64Extra( sig64, 0, shiftDist );
  12856. sig64 = sig64Extra.v;
  12857. extra = sig64Extra.extra;
  12858. }
  12859. return softfloat_roundToUI64( sign, sig64, extra, roundingMode, exact );
  12860. #else
  12861. extSig[indexWord( 3, 2 )] = sig<<8;
  12862. extSig[indexWord( 3, 1 )] = 0;
  12863. extSig[indexWord( 3, 0 )] = 0;
  12864. if ( shiftDist ) softfloat_shiftRightJam96M( extSig, shiftDist, extSig );
  12865. return softfloat_roundMToUI64( sign, extSig, roundingMode, exact );
  12866. #endif
  12867. }
  12868. /**** ended inlining ../../source/f32_to_ui64.c ****/
  12869. /**** start inlining ../../source/f32_to_i32.c ****/
  12870. /*============================================================================
  12871. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  12872. Package, Release 3e, by John R. Hauser.
  12873. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  12874. University of California. All rights reserved.
  12875. Redistribution and use in source and binary forms, with or without
  12876. modification, are permitted provided that the following conditions are met:
  12877. 1. Redistributions of source code must retain the above copyright notice,
  12878. this list of conditions, and the following disclaimer.
  12879. 2. Redistributions in binary form must reproduce the above copyright notice,
  12880. this list of conditions, and the following disclaimer in the documentation
  12881. and/or other materials provided with the distribution.
  12882. 3. Neither the name of the University nor the names of its contributors may
  12883. be used to endorse or promote products derived from this software without
  12884. specific prior written permission.
  12885. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  12886. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  12887. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  12888. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  12889. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  12890. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  12891. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  12892. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12893. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  12894. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  12895. =============================================================================*/
  12896. #include <stdbool.h>
  12897. #include <stdint.h>
  12898. /**** skipping file: platform.h ****/
  12899. /**** skipping file: internals.h ****/
  12900. /**** skipping file: specialize.h ****/
  12901. /**** skipping file: softfloat.h ****/
  12902. int_fast32_t f32_to_i32( float32_t a, uint_fast8_t roundingMode, bool exact )
  12903. {
  12904. union ui32_f32 uA;
  12905. uint_fast32_t uiA;
  12906. bool sign;
  12907. int_fast16_t exp;
  12908. uint_fast32_t sig;
  12909. uint_fast64_t sig64;
  12910. int_fast16_t shiftDist;
  12911. /*------------------------------------------------------------------------
  12912. *------------------------------------------------------------------------*/
  12913. uA.f = a;
  12914. uiA = uA.ui;
  12915. sign = signF32UI( uiA );
  12916. exp = expF32UI( uiA );
  12917. sig = fracF32UI( uiA );
  12918. /*------------------------------------------------------------------------
  12919. *------------------------------------------------------------------------*/
  12920. #if (i32_fromNaN != i32_fromPosOverflow) || (i32_fromNaN != i32_fromNegOverflow)
  12921. if ( (exp == 0xFF) && sig ) {
  12922. #if (i32_fromNaN == i32_fromPosOverflow)
  12923. sign = 0;
  12924. #elif (i32_fromNaN == i32_fromNegOverflow)
  12925. sign = 1;
  12926. #else
  12927. softfloat_raiseFlags( softfloat_flag_invalid );
  12928. return i32_fromNaN;
  12929. #endif
  12930. }
  12931. #endif
  12932. /*------------------------------------------------------------------------
  12933. *------------------------------------------------------------------------*/
  12934. if ( exp ) sig |= 0x00800000;
  12935. sig64 = (uint_fast64_t) sig<<32;
  12936. shiftDist = 0xAA - exp;
  12937. if ( 0 < shiftDist ) sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
  12938. return softfloat_roundToI32( sign, sig64, roundingMode, exact );
  12939. }
  12940. /**** ended inlining ../../source/f32_to_i32.c ****/
  12941. /**** start inlining ../../source/f32_to_i64.c ****/
  12942. /*============================================================================
  12943. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  12944. Package, Release 3e, by John R. Hauser.
  12945. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  12946. University of California. All rights reserved.
  12947. Redistribution and use in source and binary forms, with or without
  12948. modification, are permitted provided that the following conditions are met:
  12949. 1. Redistributions of source code must retain the above copyright notice,
  12950. this list of conditions, and the following disclaimer.
  12951. 2. Redistributions in binary form must reproduce the above copyright notice,
  12952. this list of conditions, and the following disclaimer in the documentation
  12953. and/or other materials provided with the distribution.
  12954. 3. Neither the name of the University nor the names of its contributors may
  12955. be used to endorse or promote products derived from this software without
  12956. specific prior written permission.
  12957. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  12958. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  12959. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  12960. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  12961. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  12962. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  12963. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  12964. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12965. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  12966. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  12967. =============================================================================*/
  12968. #include <stdbool.h>
  12969. #include <stdint.h>
  12970. /**** skipping file: platform.h ****/
  12971. /**** skipping file: internals.h ****/
  12972. /**** skipping file: specialize.h ****/
  12973. /**** skipping file: softfloat.h ****/
  12974. int_fast64_t f32_to_i64( float32_t a, uint_fast8_t roundingMode, bool exact )
  12975. {
  12976. union ui32_f32 uA;
  12977. uint_fast32_t uiA;
  12978. bool sign;
  12979. int_fast16_t exp;
  12980. uint_fast32_t sig;
  12981. int_fast16_t shiftDist;
  12982. #ifdef SOFTFLOAT_FAST_INT64
  12983. uint_fast64_t sig64, extra;
  12984. struct uint64_extra sig64Extra;
  12985. #else
  12986. uint32_t extSig[3];
  12987. #endif
  12988. /*------------------------------------------------------------------------
  12989. *------------------------------------------------------------------------*/
  12990. uA.f = a;
  12991. uiA = uA.ui;
  12992. sign = signF32UI( uiA );
  12993. exp = expF32UI( uiA );
  12994. sig = fracF32UI( uiA );
  12995. /*------------------------------------------------------------------------
  12996. *------------------------------------------------------------------------*/
  12997. shiftDist = 0xBE - exp;
  12998. if ( shiftDist < 0 ) {
  12999. softfloat_raiseFlags( softfloat_flag_invalid );
  13000. return
  13001. (exp == 0xFF) && sig ? i64_fromNaN
  13002. : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
  13003. }
  13004. /*------------------------------------------------------------------------
  13005. *------------------------------------------------------------------------*/
  13006. if ( exp ) sig |= 0x00800000;
  13007. #ifdef SOFTFLOAT_FAST_INT64
  13008. sig64 = (uint_fast64_t) sig<<40;
  13009. extra = 0;
  13010. if ( shiftDist ) {
  13011. sig64Extra = softfloat_shiftRightJam64Extra( sig64, 0, shiftDist );
  13012. sig64 = sig64Extra.v;
  13013. extra = sig64Extra.extra;
  13014. }
  13015. return softfloat_roundToI64( sign, sig64, extra, roundingMode, exact );
  13016. #else
  13017. extSig[indexWord( 3, 2 )] = sig<<8;
  13018. extSig[indexWord( 3, 1 )] = 0;
  13019. extSig[indexWord( 3, 0 )] = 0;
  13020. if ( shiftDist ) softfloat_shiftRightJam96M( extSig, shiftDist, extSig );
  13021. return softfloat_roundMToI64( sign, extSig, roundingMode, exact );
  13022. #endif
  13023. }
  13024. /**** ended inlining ../../source/f32_to_i64.c ****/
  13025. /**** start inlining ../../source/f32_to_ui32_r_minMag.c ****/
  13026. /*============================================================================
  13027. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  13028. Package, Release 3e, by John R. Hauser.
  13029. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  13030. California. All rights reserved.
  13031. Redistribution and use in source and binary forms, with or without
  13032. modification, are permitted provided that the following conditions are met:
  13033. 1. Redistributions of source code must retain the above copyright notice,
  13034. this list of conditions, and the following disclaimer.
  13035. 2. Redistributions in binary form must reproduce the above copyright notice,
  13036. this list of conditions, and the following disclaimer in the documentation
  13037. and/or other materials provided with the distribution.
  13038. 3. Neither the name of the University nor the names of its contributors may
  13039. be used to endorse or promote products derived from this software without
  13040. specific prior written permission.
  13041. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  13042. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  13043. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  13044. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  13045. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  13046. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  13047. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  13048. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  13049. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  13050. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  13051. =============================================================================*/
  13052. #include <stdbool.h>
  13053. #include <stdint.h>
  13054. /**** skipping file: platform.h ****/
  13055. /**** skipping file: internals.h ****/
  13056. /**** skipping file: specialize.h ****/
  13057. /**** skipping file: softfloat.h ****/
  13058. uint_fast32_t f32_to_ui32_r_minMag( float32_t a, bool exact )
  13059. {
  13060. union ui32_f32 uA;
  13061. uint_fast32_t uiA;
  13062. int_fast16_t exp;
  13063. uint_fast32_t sig;
  13064. int_fast16_t shiftDist;
  13065. bool sign;
  13066. uint_fast32_t z;
  13067. /*------------------------------------------------------------------------
  13068. *------------------------------------------------------------------------*/
  13069. uA.f = a;
  13070. uiA = uA.ui;
  13071. exp = expF32UI( uiA );
  13072. sig = fracF32UI( uiA );
  13073. /*------------------------------------------------------------------------
  13074. *------------------------------------------------------------------------*/
  13075. shiftDist = 0x9E - exp;
  13076. if ( 32 <= shiftDist ) {
  13077. if ( exact && (exp | sig) ) {
  13078. softfloat_exceptionFlags |= softfloat_flag_inexact;
  13079. }
  13080. return 0;
  13081. }
  13082. /*------------------------------------------------------------------------
  13083. *------------------------------------------------------------------------*/
  13084. sign = signF32UI( uiA );
  13085. if ( sign || (shiftDist < 0) ) {
  13086. softfloat_raiseFlags( softfloat_flag_invalid );
  13087. return
  13088. (exp == 0xFF) && sig ? ui32_fromNaN
  13089. : sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
  13090. }
  13091. /*------------------------------------------------------------------------
  13092. *------------------------------------------------------------------------*/
  13093. sig = (sig | 0x00800000)<<8;
  13094. z = sig>>shiftDist;
  13095. if ( exact && (z<<shiftDist != sig) ) {
  13096. softfloat_exceptionFlags |= softfloat_flag_inexact;
  13097. }
  13098. return z;
  13099. }
  13100. /**** ended inlining ../../source/f32_to_ui32_r_minMag.c ****/
  13101. /**** start inlining ../../source/f32_to_ui64_r_minMag.c ****/
  13102. /*============================================================================
  13103. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  13104. Package, Release 3e, by John R. Hauser.
  13105. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  13106. California. All rights reserved.
  13107. Redistribution and use in source and binary forms, with or without
  13108. modification, are permitted provided that the following conditions are met:
  13109. 1. Redistributions of source code must retain the above copyright notice,
  13110. this list of conditions, and the following disclaimer.
  13111. 2. Redistributions in binary form must reproduce the above copyright notice,
  13112. this list of conditions, and the following disclaimer in the documentation
  13113. and/or other materials provided with the distribution.
  13114. 3. Neither the name of the University nor the names of its contributors may
  13115. be used to endorse or promote products derived from this software without
  13116. specific prior written permission.
  13117. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  13118. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  13119. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  13120. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  13121. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  13122. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  13123. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  13124. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  13125. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  13126. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  13127. =============================================================================*/
  13128. #include <stdbool.h>
  13129. #include <stdint.h>
  13130. /**** skipping file: platform.h ****/
  13131. /**** skipping file: internals.h ****/
  13132. /**** skipping file: specialize.h ****/
  13133. /**** skipping file: softfloat.h ****/
  13134. uint_fast64_t f32_to_ui64_r_minMag( float32_t a, bool exact )
  13135. {
  13136. union ui32_f32 uA;
  13137. uint_fast32_t uiA;
  13138. int_fast16_t exp;
  13139. uint_fast32_t sig;
  13140. int_fast16_t shiftDist;
  13141. bool sign;
  13142. uint_fast64_t sig64, z;
  13143. /*------------------------------------------------------------------------
  13144. *------------------------------------------------------------------------*/
  13145. uA.f = a;
  13146. uiA = uA.ui;
  13147. exp = expF32UI( uiA );
  13148. sig = fracF32UI( uiA );
  13149. /*------------------------------------------------------------------------
  13150. *------------------------------------------------------------------------*/
  13151. shiftDist = 0xBE - exp;
  13152. if ( 64 <= shiftDist ) {
  13153. if ( exact && (exp | sig) ) {
  13154. softfloat_exceptionFlags |= softfloat_flag_inexact;
  13155. }
  13156. return 0;
  13157. }
  13158. /*------------------------------------------------------------------------
  13159. *------------------------------------------------------------------------*/
  13160. sign = signF32UI( uiA );
  13161. if ( sign || (shiftDist < 0) ) {
  13162. softfloat_raiseFlags( softfloat_flag_invalid );
  13163. return
  13164. (exp == 0xFF) && sig ? ui64_fromNaN
  13165. : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
  13166. }
  13167. /*------------------------------------------------------------------------
  13168. *------------------------------------------------------------------------*/
  13169. sig |= 0x00800000;
  13170. sig64 = (uint_fast64_t) sig<<40;
  13171. z = sig64>>shiftDist;
  13172. shiftDist = 40 - shiftDist;
  13173. if ( exact && (shiftDist < 0) && (uint32_t) (sig<<(shiftDist & 31)) ) {
  13174. softfloat_exceptionFlags |= softfloat_flag_inexact;
  13175. }
  13176. return z;
  13177. }
  13178. /**** ended inlining ../../source/f32_to_ui64_r_minMag.c ****/
  13179. /**** start inlining ../../source/f32_to_i32_r_minMag.c ****/
  13180. /*============================================================================
  13181. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  13182. Package, Release 3e, by John R. Hauser.
  13183. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  13184. California. All rights reserved.
  13185. Redistribution and use in source and binary forms, with or without
  13186. modification, are permitted provided that the following conditions are met:
  13187. 1. Redistributions of source code must retain the above copyright notice,
  13188. this list of conditions, and the following disclaimer.
  13189. 2. Redistributions in binary form must reproduce the above copyright notice,
  13190. this list of conditions, and the following disclaimer in the documentation
  13191. and/or other materials provided with the distribution.
  13192. 3. Neither the name of the University nor the names of its contributors may
  13193. be used to endorse or promote products derived from this software without
  13194. specific prior written permission.
  13195. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  13196. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  13197. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  13198. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  13199. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  13200. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  13201. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  13202. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  13203. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  13204. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  13205. =============================================================================*/
  13206. #include <stdbool.h>
  13207. #include <stdint.h>
  13208. /**** skipping file: platform.h ****/
  13209. /**** skipping file: internals.h ****/
  13210. /**** skipping file: specialize.h ****/
  13211. /**** skipping file: softfloat.h ****/
  13212. int_fast32_t f32_to_i32_r_minMag( float32_t a, bool exact )
  13213. {
  13214. union ui32_f32 uA;
  13215. uint_fast32_t uiA;
  13216. int_fast16_t exp;
  13217. uint_fast32_t sig;
  13218. int_fast16_t shiftDist;
  13219. bool sign;
  13220. int_fast32_t absZ;
  13221. /*------------------------------------------------------------------------
  13222. *------------------------------------------------------------------------*/
  13223. uA.f = a;
  13224. uiA = uA.ui;
  13225. exp = expF32UI( uiA );
  13226. sig = fracF32UI( uiA );
  13227. /*------------------------------------------------------------------------
  13228. *------------------------------------------------------------------------*/
  13229. shiftDist = 0x9E - exp;
  13230. if ( 32 <= shiftDist ) {
  13231. if ( exact && (exp | sig) ) {
  13232. softfloat_exceptionFlags |= softfloat_flag_inexact;
  13233. }
  13234. return 0;
  13235. }
  13236. /*------------------------------------------------------------------------
  13237. *------------------------------------------------------------------------*/
  13238. sign = signF32UI( uiA );
  13239. if ( shiftDist <= 0 ) {
  13240. if ( uiA == packToF32UI( 1, 0x9E, 0 ) ) return -0x7FFFFFFF - 1;
  13241. softfloat_raiseFlags( softfloat_flag_invalid );
  13242. return
  13243. (exp == 0xFF) && sig ? i32_fromNaN
  13244. : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
  13245. }
  13246. /*------------------------------------------------------------------------
  13247. *------------------------------------------------------------------------*/
  13248. sig = (sig | 0x00800000)<<8;
  13249. absZ = sig>>shiftDist;
  13250. if ( exact && ((uint_fast32_t) absZ<<shiftDist != sig) ) {
  13251. softfloat_exceptionFlags |= softfloat_flag_inexact;
  13252. }
  13253. return sign ? -absZ : absZ;
  13254. }
  13255. /**** ended inlining ../../source/f32_to_i32_r_minMag.c ****/
  13256. /**** start inlining ../../source/f32_to_i64_r_minMag.c ****/
  13257. /*============================================================================
  13258. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  13259. Package, Release 3e, by John R. Hauser.
  13260. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  13261. California. All rights reserved.
  13262. Redistribution and use in source and binary forms, with or without
  13263. modification, are permitted provided that the following conditions are met:
  13264. 1. Redistributions of source code must retain the above copyright notice,
  13265. this list of conditions, and the following disclaimer.
  13266. 2. Redistributions in binary form must reproduce the above copyright notice,
  13267. this list of conditions, and the following disclaimer in the documentation
  13268. and/or other materials provided with the distribution.
  13269. 3. Neither the name of the University nor the names of its contributors may
  13270. be used to endorse or promote products derived from this software without
  13271. specific prior written permission.
  13272. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  13273. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  13274. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  13275. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  13276. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  13277. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  13278. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  13279. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  13280. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  13281. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  13282. =============================================================================*/
  13283. #include <stdbool.h>
  13284. #include <stdint.h>
  13285. /**** skipping file: platform.h ****/
  13286. /**** skipping file: internals.h ****/
  13287. /**** skipping file: specialize.h ****/
  13288. /**** skipping file: softfloat.h ****/
  13289. int_fast64_t f32_to_i64_r_minMag( float32_t a, bool exact )
  13290. {
  13291. union ui32_f32 uA;
  13292. uint_fast32_t uiA;
  13293. int_fast16_t exp;
  13294. uint_fast32_t sig;
  13295. int_fast16_t shiftDist;
  13296. bool sign;
  13297. uint_fast64_t sig64;
  13298. int_fast64_t absZ;
  13299. /*------------------------------------------------------------------------
  13300. *------------------------------------------------------------------------*/
  13301. uA.f = a;
  13302. uiA = uA.ui;
  13303. exp = expF32UI( uiA );
  13304. sig = fracF32UI( uiA );
  13305. /*------------------------------------------------------------------------
  13306. *------------------------------------------------------------------------*/
  13307. shiftDist = 0xBE - exp;
  13308. if ( 64 <= shiftDist ) {
  13309. if ( exact && (exp | sig) ) {
  13310. softfloat_exceptionFlags |= softfloat_flag_inexact;
  13311. }
  13312. return 0;
  13313. }
  13314. /*------------------------------------------------------------------------
  13315. *------------------------------------------------------------------------*/
  13316. sign = signF32UI( uiA );
  13317. if ( shiftDist <= 0 ) {
  13318. if ( uiA == packToF32UI( 1, 0xBE, 0 ) ) {
  13319. return -INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1;
  13320. }
  13321. softfloat_raiseFlags( softfloat_flag_invalid );
  13322. return
  13323. (exp == 0xFF) && sig ? i64_fromNaN
  13324. : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
  13325. }
  13326. /*------------------------------------------------------------------------
  13327. *------------------------------------------------------------------------*/
  13328. sig |= 0x00800000;
  13329. sig64 = (uint_fast64_t) sig<<40;
  13330. absZ = sig64>>shiftDist;
  13331. shiftDist = 40 - shiftDist;
  13332. if ( exact && (shiftDist < 0) && (uint32_t) (sig<<(shiftDist & 31)) ) {
  13333. softfloat_exceptionFlags |= softfloat_flag_inexact;
  13334. }
  13335. return sign ? -absZ : absZ;
  13336. }
  13337. /**** ended inlining ../../source/f32_to_i64_r_minMag.c ****/
  13338. /**** start inlining ../../source/f32_to_f16.c ****/
  13339. /*============================================================================
  13340. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  13341. Package, Release 3e, by John R. Hauser.
  13342. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  13343. California. All rights reserved.
  13344. Redistribution and use in source and binary forms, with or without
  13345. modification, are permitted provided that the following conditions are met:
  13346. 1. Redistributions of source code must retain the above copyright notice,
  13347. this list of conditions, and the following disclaimer.
  13348. 2. Redistributions in binary form must reproduce the above copyright notice,
  13349. this list of conditions, and the following disclaimer in the documentation
  13350. and/or other materials provided with the distribution.
  13351. 3. Neither the name of the University nor the names of its contributors may
  13352. be used to endorse or promote products derived from this software without
  13353. specific prior written permission.
  13354. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  13355. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  13356. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  13357. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  13358. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  13359. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  13360. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  13361. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  13362. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  13363. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  13364. =============================================================================*/
  13365. #include <stdbool.h>
  13366. #include <stdint.h>
  13367. /**** skipping file: platform.h ****/
  13368. /**** skipping file: internals.h ****/
  13369. /**** skipping file: specialize.h ****/
  13370. /**** skipping file: softfloat.h ****/
  13371. float16_t f32_to_f16( float32_t a )
  13372. {
  13373. union ui32_f32 uA;
  13374. uint_fast32_t uiA;
  13375. bool sign;
  13376. int_fast16_t exp;
  13377. uint_fast32_t frac;
  13378. struct commonNaN commonNaN;
  13379. uint_fast16_t uiZ, frac16;
  13380. union ui16_f16 uZ;
  13381. /*------------------------------------------------------------------------
  13382. *------------------------------------------------------------------------*/
  13383. uA.f = a;
  13384. uiA = uA.ui;
  13385. sign = signF32UI( uiA );
  13386. exp = expF32UI( uiA );
  13387. frac = fracF32UI( uiA );
  13388. /*------------------------------------------------------------------------
  13389. *------------------------------------------------------------------------*/
  13390. if ( exp == 0xFF ) {
  13391. if ( frac ) {
  13392. softfloat_f32UIToCommonNaN( uiA, &commonNaN );
  13393. uiZ = softfloat_commonNaNToF16UI( &commonNaN );
  13394. } else {
  13395. uiZ = packToF16UI( sign, 0x1F, 0 );
  13396. }
  13397. goto uiZ;
  13398. }
  13399. /*------------------------------------------------------------------------
  13400. *------------------------------------------------------------------------*/
  13401. frac16 = frac>>9 | ((frac & 0x1FF) != 0);
  13402. if ( ! (exp | frac16) ) {
  13403. uiZ = packToF16UI( sign, 0, 0 );
  13404. goto uiZ;
  13405. }
  13406. /*------------------------------------------------------------------------
  13407. *------------------------------------------------------------------------*/
  13408. return softfloat_roundPackToF16( sign, exp - 0x71, frac16 | 0x4000 );
  13409. uiZ:
  13410. uZ.ui = uiZ;
  13411. return uZ.f;
  13412. }
  13413. /**** ended inlining ../../source/f32_to_f16.c ****/
  13414. /**** start inlining ../../source/f32_to_f64.c ****/
  13415. /*============================================================================
  13416. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  13417. Package, Release 3e, by John R. Hauser.
  13418. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  13419. California. All rights reserved.
  13420. Redistribution and use in source and binary forms, with or without
  13421. modification, are permitted provided that the following conditions are met:
  13422. 1. Redistributions of source code must retain the above copyright notice,
  13423. this list of conditions, and the following disclaimer.
  13424. 2. Redistributions in binary form must reproduce the above copyright notice,
  13425. this list of conditions, and the following disclaimer in the documentation
  13426. and/or other materials provided with the distribution.
  13427. 3. Neither the name of the University nor the names of its contributors may
  13428. be used to endorse or promote products derived from this software without
  13429. specific prior written permission.
  13430. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  13431. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  13432. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  13433. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  13434. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  13435. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  13436. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  13437. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  13438. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  13439. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  13440. =============================================================================*/
  13441. #include <stdbool.h>
  13442. #include <stdint.h>
  13443. /**** skipping file: platform.h ****/
  13444. /**** skipping file: internals.h ****/
  13445. /**** skipping file: specialize.h ****/
  13446. /**** skipping file: softfloat.h ****/
  13447. float64_t f32_to_f64( float32_t a )
  13448. {
  13449. union ui32_f32 uA;
  13450. uint_fast32_t uiA;
  13451. bool sign;
  13452. int_fast16_t exp;
  13453. uint_fast32_t frac;
  13454. struct commonNaN commonNaN;
  13455. uint_fast64_t uiZ;
  13456. struct exp16_sig32 normExpSig;
  13457. union ui64_f64 uZ;
  13458. /*------------------------------------------------------------------------
  13459. *------------------------------------------------------------------------*/
  13460. uA.f = a;
  13461. uiA = uA.ui;
  13462. sign = signF32UI( uiA );
  13463. exp = expF32UI( uiA );
  13464. frac = fracF32UI( uiA );
  13465. /*------------------------------------------------------------------------
  13466. *------------------------------------------------------------------------*/
  13467. if ( exp == 0xFF ) {
  13468. if ( frac ) {
  13469. softfloat_f32UIToCommonNaN( uiA, &commonNaN );
  13470. uiZ = softfloat_commonNaNToF64UI( &commonNaN );
  13471. } else {
  13472. uiZ = packToF64UI( sign, 0x7FF, 0 );
  13473. }
  13474. goto uiZ;
  13475. }
  13476. /*------------------------------------------------------------------------
  13477. *------------------------------------------------------------------------*/
  13478. if ( ! exp ) {
  13479. if ( ! frac ) {
  13480. uiZ = packToF64UI( sign, 0, 0 );
  13481. goto uiZ;
  13482. }
  13483. normExpSig = softfloat_normSubnormalF32Sig( frac );
  13484. exp = normExpSig.exp - 1;
  13485. frac = normExpSig.sig;
  13486. }
  13487. /*------------------------------------------------------------------------
  13488. *------------------------------------------------------------------------*/
  13489. uiZ = packToF64UI( sign, exp + 0x380, (uint_fast64_t) frac<<29 );
  13490. uiZ:
  13491. uZ.ui = uiZ;
  13492. return uZ.f;
  13493. }
  13494. /**** ended inlining ../../source/f32_to_f64.c ****/
  13495. /**** start inlining ../../source/f32_to_extF80.c ****/
  13496. /*============================================================================
  13497. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  13498. Package, Release 3e, by John R. Hauser.
  13499. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  13500. California. All rights reserved.
  13501. Redistribution and use in source and binary forms, with or without
  13502. modification, are permitted provided that the following conditions are met:
  13503. 1. Redistributions of source code must retain the above copyright notice,
  13504. this list of conditions, and the following disclaimer.
  13505. 2. Redistributions in binary form must reproduce the above copyright notice,
  13506. this list of conditions, and the following disclaimer in the documentation
  13507. and/or other materials provided with the distribution.
  13508. 3. Neither the name of the University nor the names of its contributors may
  13509. be used to endorse or promote products derived from this software without
  13510. specific prior written permission.
  13511. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  13512. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  13513. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  13514. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  13515. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  13516. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  13517. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  13518. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  13519. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  13520. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  13521. =============================================================================*/
  13522. #include <stdbool.h>
  13523. #include <stdint.h>
  13524. /**** skipping file: platform.h ****/
  13525. /**** skipping file: internals.h ****/
  13526. /**** skipping file: specialize.h ****/
  13527. /**** skipping file: softfloat.h ****/
  13528. extFloat80_t f32_to_extF80( float32_t a )
  13529. {
  13530. union ui32_f32 uA;
  13531. uint_fast32_t uiA;
  13532. bool sign;
  13533. int_fast16_t exp;
  13534. uint_fast32_t frac;
  13535. struct commonNaN commonNaN;
  13536. struct uint128 uiZ;
  13537. uint_fast16_t uiZ64;
  13538. uint_fast64_t uiZ0;
  13539. struct exp16_sig32 normExpSig;
  13540. union { struct extFloat80M s; extFloat80_t f; } uZ;
  13541. /*------------------------------------------------------------------------
  13542. *------------------------------------------------------------------------*/
  13543. uA.f = a;
  13544. uiA = uA.ui;
  13545. sign = signF32UI( uiA );
  13546. exp = expF32UI( uiA );
  13547. frac = fracF32UI( uiA );
  13548. /*------------------------------------------------------------------------
  13549. *------------------------------------------------------------------------*/
  13550. if ( exp == 0xFF ) {
  13551. if ( frac ) {
  13552. softfloat_f32UIToCommonNaN( uiA, &commonNaN );
  13553. uiZ = softfloat_commonNaNToExtF80UI( &commonNaN );
  13554. uiZ64 = uiZ.v64;
  13555. uiZ0 = uiZ.v0;
  13556. } else {
  13557. uiZ64 = packToExtF80UI64( sign, 0x7FFF );
  13558. uiZ0 = UINT64_C( 0x8000000000000000 );
  13559. }
  13560. goto uiZ;
  13561. }
  13562. /*------------------------------------------------------------------------
  13563. *------------------------------------------------------------------------*/
  13564. if ( ! exp ) {
  13565. if ( ! frac ) {
  13566. uiZ64 = packToExtF80UI64( sign, 0 );
  13567. uiZ0 = 0;
  13568. goto uiZ;
  13569. }
  13570. normExpSig = softfloat_normSubnormalF32Sig( frac );
  13571. exp = normExpSig.exp;
  13572. frac = normExpSig.sig;
  13573. }
  13574. /*------------------------------------------------------------------------
  13575. *------------------------------------------------------------------------*/
  13576. uiZ64 = packToExtF80UI64( sign, exp + 0x3F80 );
  13577. uiZ0 = (uint_fast64_t) (frac | 0x00800000)<<40;
  13578. uiZ:
  13579. uZ.s.signExp = uiZ64;
  13580. uZ.s.signif = uiZ0;
  13581. return uZ.f;
  13582. }
  13583. /**** ended inlining ../../source/f32_to_extF80.c ****/
  13584. /**** start inlining ../../source/f32_to_extF80M.c ****/
  13585. /*============================================================================
  13586. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  13587. Package, Release 3e, by John R. Hauser.
  13588. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  13589. California. All rights reserved.
  13590. Redistribution and use in source and binary forms, with or without
  13591. modification, are permitted provided that the following conditions are met:
  13592. 1. Redistributions of source code must retain the above copyright notice,
  13593. this list of conditions, and the following disclaimer.
  13594. 2. Redistributions in binary form must reproduce the above copyright notice,
  13595. this list of conditions, and the following disclaimer in the documentation
  13596. and/or other materials provided with the distribution.
  13597. 3. Neither the name of the University nor the names of its contributors may
  13598. be used to endorse or promote products derived from this software without
  13599. specific prior written permission.
  13600. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  13601. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  13602. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  13603. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  13604. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  13605. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  13606. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  13607. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  13608. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  13609. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  13610. =============================================================================*/
  13611. #include <stdbool.h>
  13612. #include <stdint.h>
  13613. /**** skipping file: platform.h ****/
  13614. /**** skipping file: internals.h ****/
  13615. /**** skipping file: specialize.h ****/
  13616. /**** skipping file: softfloat.h ****/
  13617. #ifdef SOFTFLOAT_FAST_INT64
  13618. void f32_to_extF80M( float32_t a, extFloat80_t *zPtr )
  13619. {
  13620. *zPtr = f32_to_extF80( a );
  13621. }
  13622. #else
  13623. void f32_to_extF80M( float32_t a, extFloat80_t *zPtr )
  13624. {
  13625. struct extFloat80M *zSPtr;
  13626. union ui32_f32 uA;
  13627. uint32_t uiA;
  13628. bool sign;
  13629. int_fast16_t exp;
  13630. uint32_t frac;
  13631. struct commonNaN commonNaN;
  13632. uint_fast16_t uiZ64;
  13633. uint32_t uiZ32;
  13634. struct exp16_sig32 normExpSig;
  13635. /*------------------------------------------------------------------------
  13636. *------------------------------------------------------------------------*/
  13637. zSPtr = (struct extFloat80M *) zPtr;
  13638. uA.f = a;
  13639. uiA = uA.ui;
  13640. sign = signF32UI( uiA );
  13641. exp = expF32UI( uiA );
  13642. frac = fracF32UI( uiA );
  13643. /*------------------------------------------------------------------------
  13644. *------------------------------------------------------------------------*/
  13645. if ( exp == 0xFF ) {
  13646. if ( frac ) {
  13647. softfloat_f32UIToCommonNaN( uiA, &commonNaN );
  13648. softfloat_commonNaNToExtF80M( &commonNaN, zSPtr );
  13649. return;
  13650. }
  13651. uiZ64 = packToExtF80UI64( sign, 0x7FFF );
  13652. uiZ32 = 0x80000000;
  13653. goto uiZ;
  13654. }
  13655. /*------------------------------------------------------------------------
  13656. *------------------------------------------------------------------------*/
  13657. if ( ! exp ) {
  13658. if ( ! frac ) {
  13659. uiZ64 = packToExtF80UI64( sign, 0 );
  13660. uiZ32 = 0;
  13661. goto uiZ;
  13662. }
  13663. normExpSig = softfloat_normSubnormalF32Sig( frac );
  13664. exp = normExpSig.exp;
  13665. frac = normExpSig.sig;
  13666. }
  13667. /*------------------------------------------------------------------------
  13668. *------------------------------------------------------------------------*/
  13669. uiZ64 = packToExtF80UI64( sign, exp + 0x3F80 );
  13670. uiZ32 = 0x80000000 | (uint32_t) frac<<8;
  13671. uiZ:
  13672. zSPtr->signExp = uiZ64;
  13673. zSPtr->signif = (uint64_t) uiZ32<<32;
  13674. }
  13675. #endif
  13676. /**** ended inlining ../../source/f32_to_extF80M.c ****/
  13677. /**** start inlining ../../source/f32_to_f128.c ****/
  13678. /*============================================================================
  13679. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  13680. Package, Release 3e, by John R. Hauser.
  13681. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  13682. California. All rights reserved.
  13683. Redistribution and use in source and binary forms, with or without
  13684. modification, are permitted provided that the following conditions are met:
  13685. 1. Redistributions of source code must retain the above copyright notice,
  13686. this list of conditions, and the following disclaimer.
  13687. 2. Redistributions in binary form must reproduce the above copyright notice,
  13688. this list of conditions, and the following disclaimer in the documentation
  13689. and/or other materials provided with the distribution.
  13690. 3. Neither the name of the University nor the names of its contributors may
  13691. be used to endorse or promote products derived from this software without
  13692. specific prior written permission.
  13693. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  13694. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  13695. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  13696. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  13697. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  13698. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  13699. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  13700. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  13701. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  13702. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  13703. =============================================================================*/
  13704. #include <stdbool.h>
  13705. #include <stdint.h>
  13706. /**** skipping file: platform.h ****/
  13707. /**** skipping file: internals.h ****/
  13708. /**** skipping file: specialize.h ****/
  13709. /**** skipping file: softfloat.h ****/
  13710. float128_t f32_to_f128( float32_t a )
  13711. {
  13712. union ui32_f32 uA;
  13713. uint_fast32_t uiA;
  13714. bool sign;
  13715. int_fast16_t exp;
  13716. uint_fast32_t frac;
  13717. struct commonNaN commonNaN;
  13718. struct uint128 uiZ;
  13719. struct exp16_sig32 normExpSig;
  13720. union ui128_f128 uZ;
  13721. /*------------------------------------------------------------------------
  13722. *------------------------------------------------------------------------*/
  13723. uA.f = a;
  13724. uiA = uA.ui;
  13725. sign = signF32UI( uiA );
  13726. exp = expF32UI( uiA );
  13727. frac = fracF32UI( uiA );
  13728. /*------------------------------------------------------------------------
  13729. *------------------------------------------------------------------------*/
  13730. if ( exp == 0xFF ) {
  13731. if ( frac ) {
  13732. softfloat_f32UIToCommonNaN( uiA, &commonNaN );
  13733. uiZ = softfloat_commonNaNToF128UI( &commonNaN );
  13734. } else {
  13735. uiZ.v64 = packToF128UI64( sign, 0x7FFF, 0 );
  13736. uiZ.v0 = 0;
  13737. }
  13738. goto uiZ;
  13739. }
  13740. /*------------------------------------------------------------------------
  13741. *------------------------------------------------------------------------*/
  13742. if ( ! exp ) {
  13743. if ( ! frac ) {
  13744. uiZ.v64 = packToF128UI64( sign, 0, 0 );
  13745. uiZ.v0 = 0;
  13746. goto uiZ;
  13747. }
  13748. normExpSig = softfloat_normSubnormalF32Sig( frac );
  13749. exp = normExpSig.exp - 1;
  13750. frac = normExpSig.sig;
  13751. }
  13752. /*------------------------------------------------------------------------
  13753. *------------------------------------------------------------------------*/
  13754. uiZ.v64 = packToF128UI64( sign, exp + 0x3F80, (uint_fast64_t) frac<<25 );
  13755. uiZ.v0 = 0;
  13756. uiZ:
  13757. uZ.ui = uiZ;
  13758. return uZ.f;
  13759. }
  13760. /**** ended inlining ../../source/f32_to_f128.c ****/
  13761. /**** start inlining ../../source/f32_to_f128M.c ****/
  13762. /*============================================================================
  13763. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  13764. Package, Release 3e, by John R. Hauser.
  13765. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  13766. California. All rights reserved.
  13767. Redistribution and use in source and binary forms, with or without
  13768. modification, are permitted provided that the following conditions are met:
  13769. 1. Redistributions of source code must retain the above copyright notice,
  13770. this list of conditions, and the following disclaimer.
  13771. 2. Redistributions in binary form must reproduce the above copyright notice,
  13772. this list of conditions, and the following disclaimer in the documentation
  13773. and/or other materials provided with the distribution.
  13774. 3. Neither the name of the University nor the names of its contributors may
  13775. be used to endorse or promote products derived from this software without
  13776. specific prior written permission.
  13777. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  13778. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  13779. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  13780. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  13781. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  13782. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  13783. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  13784. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  13785. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  13786. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  13787. =============================================================================*/
  13788. #include <stdbool.h>
  13789. #include <stdint.h>
  13790. /**** skipping file: platform.h ****/
  13791. /**** skipping file: internals.h ****/
  13792. /**** skipping file: specialize.h ****/
  13793. /**** skipping file: softfloat.h ****/
  13794. #ifdef SOFTFLOAT_FAST_INT64
  13795. void f32_to_f128M( float32_t a, float128_t *zPtr )
  13796. {
  13797. *zPtr = f32_to_f128( a );
  13798. }
  13799. #else
  13800. void f32_to_f128M( float32_t a, float128_t *zPtr )
  13801. {
  13802. uint32_t *zWPtr;
  13803. union ui32_f32 uA;
  13804. uint32_t uiA;
  13805. bool sign;
  13806. int_fast16_t exp;
  13807. uint32_t frac, uiZ64;
  13808. struct commonNaN commonNaN;
  13809. uint32_t uiZ96;
  13810. struct exp16_sig32 normExpSig;
  13811. uint64_t frac64;
  13812. /*------------------------------------------------------------------------
  13813. *------------------------------------------------------------------------*/
  13814. zWPtr = (uint32_t *) zPtr;
  13815. /*------------------------------------------------------------------------
  13816. *------------------------------------------------------------------------*/
  13817. uA.f = a;
  13818. uiA = uA.ui;
  13819. sign = signF32UI( uiA );
  13820. exp = expF32UI( uiA );
  13821. frac = fracF32UI( uiA );
  13822. /*------------------------------------------------------------------------
  13823. *------------------------------------------------------------------------*/
  13824. uiZ64 = 0;
  13825. if ( exp == 0xFF ) {
  13826. if ( frac ) {
  13827. softfloat_f32UIToCommonNaN( uiA, &commonNaN );
  13828. softfloat_commonNaNToF128M( &commonNaN, zWPtr );
  13829. return;
  13830. }
  13831. uiZ96 = packToF128UI96( sign, 0x7FFF, 0 );
  13832. goto uiZ;
  13833. }
  13834. /*------------------------------------------------------------------------
  13835. *------------------------------------------------------------------------*/
  13836. if ( ! exp ) {
  13837. if ( ! frac ) {
  13838. uiZ96 = packToF128UI96( sign, 0, 0 );
  13839. goto uiZ;
  13840. }
  13841. normExpSig = softfloat_normSubnormalF32Sig( frac );
  13842. exp = normExpSig.exp - 1;
  13843. frac = normExpSig.sig;
  13844. }
  13845. /*------------------------------------------------------------------------
  13846. *------------------------------------------------------------------------*/
  13847. frac64 = (uint64_t) frac<<25;
  13848. uiZ96 = packToF128UI96( sign, exp + 0x3F80, frac64>>32 );
  13849. uiZ64 = frac64;
  13850. uiZ:
  13851. zWPtr[indexWord( 4, 3 )] = uiZ96;
  13852. zWPtr[indexWord( 4, 2 )] = uiZ64;
  13853. zWPtr[indexWord( 4, 1 )] = 0;
  13854. zWPtr[indexWord( 4, 0 )] = 0;
  13855. }
  13856. #endif
  13857. /**** ended inlining ../../source/f32_to_f128M.c ****/
  13858. /**** start inlining ../../source/f32_roundToInt.c ****/
  13859. /*============================================================================
  13860. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  13861. Package, Release 3e, by John R. Hauser.
  13862. Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
  13863. California. All rights reserved.
  13864. Redistribution and use in source and binary forms, with or without
  13865. modification, are permitted provided that the following conditions are met:
  13866. 1. Redistributions of source code must retain the above copyright notice,
  13867. this list of conditions, and the following disclaimer.
  13868. 2. Redistributions in binary form must reproduce the above copyright notice,
  13869. this list of conditions, and the following disclaimer in the documentation
  13870. and/or other materials provided with the distribution.
  13871. 3. Neither the name of the University nor the names of its contributors may
  13872. be used to endorse or promote products derived from this software without
  13873. specific prior written permission.
  13874. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  13875. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  13876. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  13877. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  13878. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  13879. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  13880. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  13881. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  13882. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  13883. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  13884. =============================================================================*/
  13885. #include <stdbool.h>
  13886. #include <stdint.h>
  13887. /**** skipping file: platform.h ****/
  13888. /**** skipping file: internals.h ****/
  13889. /**** skipping file: specialize.h ****/
  13890. /**** skipping file: softfloat.h ****/
  13891. float32_t f32_roundToInt( float32_t a, uint_fast8_t roundingMode, bool exact )
  13892. {
  13893. union ui32_f32 uA;
  13894. uint_fast32_t uiA;
  13895. int_fast16_t exp;
  13896. uint_fast32_t uiZ, lastBitMask, roundBitsMask;
  13897. union ui32_f32 uZ;
  13898. /*------------------------------------------------------------------------
  13899. *------------------------------------------------------------------------*/
  13900. uA.f = a;
  13901. uiA = uA.ui;
  13902. exp = expF32UI( uiA );
  13903. /*------------------------------------------------------------------------
  13904. *------------------------------------------------------------------------*/
  13905. if ( exp <= 0x7E ) {
  13906. if ( !(uint32_t) (uiA<<1) ) return a;
  13907. if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
  13908. uiZ = uiA & packToF32UI( 1, 0, 0 );
  13909. switch ( roundingMode ) {
  13910. case softfloat_round_near_even:
  13911. if ( !fracF32UI( uiA ) ) break;
  13912. case softfloat_round_near_maxMag:
  13913. if ( exp == 0x7E ) uiZ |= packToF32UI( 0, 0x7F, 0 );
  13914. break;
  13915. case softfloat_round_min:
  13916. if ( uiZ ) uiZ = packToF32UI( 1, 0x7F, 0 );
  13917. break;
  13918. case softfloat_round_max:
  13919. if ( !uiZ ) uiZ = packToF32UI( 0, 0x7F, 0 );
  13920. break;
  13921. #ifdef SOFTFLOAT_ROUND_ODD
  13922. case softfloat_round_odd:
  13923. uiZ |= packToF32UI( 0, 0x7F, 0 );
  13924. break;
  13925. #endif
  13926. }
  13927. goto uiZ;
  13928. }
  13929. /*------------------------------------------------------------------------
  13930. *------------------------------------------------------------------------*/
  13931. if ( 0x96 <= exp ) {
  13932. if ( (exp == 0xFF) && fracF32UI( uiA ) ) {
  13933. uiZ = softfloat_propagateNaNF32UI( uiA, 0 );
  13934. goto uiZ;
  13935. }
  13936. return a;
  13937. }
  13938. /*------------------------------------------------------------------------
  13939. *------------------------------------------------------------------------*/
  13940. uiZ = uiA;
  13941. lastBitMask = (uint_fast32_t) 1<<(0x96 - exp);
  13942. roundBitsMask = lastBitMask - 1;
  13943. if ( roundingMode == softfloat_round_near_maxMag ) {
  13944. uiZ += lastBitMask>>1;
  13945. } else if ( roundingMode == softfloat_round_near_even ) {
  13946. uiZ += lastBitMask>>1;
  13947. if ( !(uiZ & roundBitsMask) ) uiZ &= ~lastBitMask;
  13948. } else if (
  13949. roundingMode
  13950. == (signF32UI( uiZ ) ? softfloat_round_min : softfloat_round_max)
  13951. ) {
  13952. uiZ += roundBitsMask;
  13953. }
  13954. uiZ &= ~roundBitsMask;
  13955. if ( uiZ != uiA ) {
  13956. #ifdef SOFTFLOAT_ROUND_ODD
  13957. if ( roundingMode == softfloat_round_odd ) uiZ |= lastBitMask;
  13958. #endif
  13959. if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
  13960. }
  13961. uiZ:
  13962. uZ.ui = uiZ;
  13963. return uZ.f;
  13964. }
  13965. /**** ended inlining ../../source/f32_roundToInt.c ****/
  13966. /**** start inlining ../../source/f32_add.c ****/
  13967. /*============================================================================
  13968. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  13969. Package, Release 3e, by John R. Hauser.
  13970. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  13971. California. All rights reserved.
  13972. Redistribution and use in source and binary forms, with or without
  13973. modification, are permitted provided that the following conditions are met:
  13974. 1. Redistributions of source code must retain the above copyright notice,
  13975. this list of conditions, and the following disclaimer.
  13976. 2. Redistributions in binary form must reproduce the above copyright notice,
  13977. this list of conditions, and the following disclaimer in the documentation
  13978. and/or other materials provided with the distribution.
  13979. 3. Neither the name of the University nor the names of its contributors may
  13980. be used to endorse or promote products derived from this software without
  13981. specific prior written permission.
  13982. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  13983. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  13984. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  13985. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  13986. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  13987. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  13988. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  13989. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  13990. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  13991. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  13992. =============================================================================*/
  13993. #include <stdbool.h>
  13994. #include <stdint.h>
  13995. /**** skipping file: platform.h ****/
  13996. /**** skipping file: internals.h ****/
  13997. /**** skipping file: softfloat.h ****/
  13998. float32_t f32_add( float32_t a, float32_t b )
  13999. {
  14000. union ui32_f32 uA;
  14001. uint_fast32_t uiA;
  14002. union ui32_f32 uB;
  14003. uint_fast32_t uiB;
  14004. #if ! defined INLINE_LEVEL || (INLINE_LEVEL < 1)
  14005. float32_t (*magsFuncPtr)( uint_fast32_t, uint_fast32_t );
  14006. #endif
  14007. uA.f = a;
  14008. uiA = uA.ui;
  14009. uB.f = b;
  14010. uiB = uB.ui;
  14011. #if defined INLINE_LEVEL && (1 <= INLINE_LEVEL)
  14012. if ( signF32UI( uiA ^ uiB ) ) {
  14013. return softfloat_subMagsF32( uiA, uiB );
  14014. } else {
  14015. return softfloat_addMagsF32( uiA, uiB );
  14016. }
  14017. #else
  14018. magsFuncPtr =
  14019. signF32UI( uiA ^ uiB ) ? softfloat_subMagsF32 : softfloat_addMagsF32;
  14020. return (*magsFuncPtr)( uiA, uiB );
  14021. #endif
  14022. }
  14023. /**** ended inlining ../../source/f32_add.c ****/
  14024. /**** start inlining ../../source/f32_sub.c ****/
  14025. /*============================================================================
  14026. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  14027. Package, Release 3e, by John R. Hauser.
  14028. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  14029. California. All rights reserved.
  14030. Redistribution and use in source and binary forms, with or without
  14031. modification, are permitted provided that the following conditions are met:
  14032. 1. Redistributions of source code must retain the above copyright notice,
  14033. this list of conditions, and the following disclaimer.
  14034. 2. Redistributions in binary form must reproduce the above copyright notice,
  14035. this list of conditions, and the following disclaimer in the documentation
  14036. and/or other materials provided with the distribution.
  14037. 3. Neither the name of the University nor the names of its contributors may
  14038. be used to endorse or promote products derived from this software without
  14039. specific prior written permission.
  14040. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  14041. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  14042. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  14043. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  14044. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  14045. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  14046. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  14047. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14048. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  14049. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14050. =============================================================================*/
  14051. #include <stdbool.h>
  14052. #include <stdint.h>
  14053. /**** skipping file: platform.h ****/
  14054. /**** skipping file: internals.h ****/
  14055. /**** skipping file: softfloat.h ****/
  14056. float32_t f32_sub( float32_t a, float32_t b )
  14057. {
  14058. union ui32_f32 uA;
  14059. uint_fast32_t uiA;
  14060. union ui32_f32 uB;
  14061. uint_fast32_t uiB;
  14062. #if ! defined INLINE_LEVEL || (INLINE_LEVEL < 1)
  14063. float32_t (*magsFuncPtr)( uint_fast32_t, uint_fast32_t );
  14064. #endif
  14065. uA.f = a;
  14066. uiA = uA.ui;
  14067. uB.f = b;
  14068. uiB = uB.ui;
  14069. #if defined INLINE_LEVEL && (1 <= INLINE_LEVEL)
  14070. if ( signF32UI( uiA ^ uiB ) ) {
  14071. return softfloat_addMagsF32( uiA, uiB );
  14072. } else {
  14073. return softfloat_subMagsF32( uiA, uiB );
  14074. }
  14075. #else
  14076. magsFuncPtr =
  14077. signF32UI( uiA ^ uiB ) ? softfloat_addMagsF32 : softfloat_subMagsF32;
  14078. return (*magsFuncPtr)( uiA, uiB );
  14079. #endif
  14080. }
  14081. /**** ended inlining ../../source/f32_sub.c ****/
  14082. /**** start inlining ../../source/f32_mul.c ****/
  14083. /*============================================================================
  14084. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  14085. Package, Release 3e, by John R. Hauser.
  14086. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  14087. California. All rights reserved.
  14088. Redistribution and use in source and binary forms, with or without
  14089. modification, are permitted provided that the following conditions are met:
  14090. 1. Redistributions of source code must retain the above copyright notice,
  14091. this list of conditions, and the following disclaimer.
  14092. 2. Redistributions in binary form must reproduce the above copyright notice,
  14093. this list of conditions, and the following disclaimer in the documentation
  14094. and/or other materials provided with the distribution.
  14095. 3. Neither the name of the University nor the names of its contributors may
  14096. be used to endorse or promote products derived from this software without
  14097. specific prior written permission.
  14098. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  14099. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  14100. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  14101. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  14102. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  14103. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  14104. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  14105. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14106. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  14107. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14108. =============================================================================*/
  14109. #include <stdbool.h>
  14110. #include <stdint.h>
  14111. /**** skipping file: platform.h ****/
  14112. /**** skipping file: internals.h ****/
  14113. /**** skipping file: specialize.h ****/
  14114. /**** skipping file: softfloat.h ****/
  14115. float32_t f32_mul( float32_t a, float32_t b )
  14116. {
  14117. union ui32_f32 uA;
  14118. uint_fast32_t uiA;
  14119. bool signA;
  14120. int_fast16_t expA;
  14121. uint_fast32_t sigA;
  14122. union ui32_f32 uB;
  14123. uint_fast32_t uiB;
  14124. bool signB;
  14125. int_fast16_t expB;
  14126. uint_fast32_t sigB;
  14127. bool signZ;
  14128. uint_fast32_t magBits;
  14129. struct exp16_sig32 normExpSig;
  14130. int_fast16_t expZ;
  14131. uint_fast32_t sigZ, uiZ;
  14132. union ui32_f32 uZ;
  14133. /*------------------------------------------------------------------------
  14134. *------------------------------------------------------------------------*/
  14135. uA.f = a;
  14136. uiA = uA.ui;
  14137. signA = signF32UI( uiA );
  14138. expA = expF32UI( uiA );
  14139. sigA = fracF32UI( uiA );
  14140. uB.f = b;
  14141. uiB = uB.ui;
  14142. signB = signF32UI( uiB );
  14143. expB = expF32UI( uiB );
  14144. sigB = fracF32UI( uiB );
  14145. signZ = signA ^ signB;
  14146. /*------------------------------------------------------------------------
  14147. *------------------------------------------------------------------------*/
  14148. if ( expA == 0xFF ) {
  14149. if ( sigA || ((expB == 0xFF) && sigB) ) goto propagateNaN;
  14150. magBits = expB | sigB;
  14151. goto infArg;
  14152. }
  14153. if ( expB == 0xFF ) {
  14154. if ( sigB ) goto propagateNaN;
  14155. magBits = expA | sigA;
  14156. goto infArg;
  14157. }
  14158. /*------------------------------------------------------------------------
  14159. *------------------------------------------------------------------------*/
  14160. if ( ! expA ) {
  14161. if ( ! sigA ) goto zero;
  14162. normExpSig = softfloat_normSubnormalF32Sig( sigA );
  14163. expA = normExpSig.exp;
  14164. sigA = normExpSig.sig;
  14165. }
  14166. if ( ! expB ) {
  14167. if ( ! sigB ) goto zero;
  14168. normExpSig = softfloat_normSubnormalF32Sig( sigB );
  14169. expB = normExpSig.exp;
  14170. sigB = normExpSig.sig;
  14171. }
  14172. /*------------------------------------------------------------------------
  14173. *------------------------------------------------------------------------*/
  14174. expZ = expA + expB - 0x7F;
  14175. sigA = (sigA | 0x00800000)<<7;
  14176. sigB = (sigB | 0x00800000)<<8;
  14177. sigZ = softfloat_shortShiftRightJam64( (uint_fast64_t) sigA * sigB, 32 );
  14178. if ( sigZ < 0x40000000 ) {
  14179. --expZ;
  14180. sigZ <<= 1;
  14181. }
  14182. return softfloat_roundPackToF32( signZ, expZ, sigZ );
  14183. /*------------------------------------------------------------------------
  14184. *------------------------------------------------------------------------*/
  14185. propagateNaN:
  14186. uiZ = softfloat_propagateNaNF32UI( uiA, uiB );
  14187. goto uiZ;
  14188. /*------------------------------------------------------------------------
  14189. *------------------------------------------------------------------------*/
  14190. infArg:
  14191. if ( ! magBits ) {
  14192. softfloat_raiseFlags( softfloat_flag_invalid );
  14193. uiZ = defaultNaNF32UI;
  14194. } else {
  14195. uiZ = packToF32UI( signZ, 0xFF, 0 );
  14196. }
  14197. goto uiZ;
  14198. /*------------------------------------------------------------------------
  14199. *------------------------------------------------------------------------*/
  14200. zero:
  14201. uiZ = packToF32UI( signZ, 0, 0 );
  14202. uiZ:
  14203. uZ.ui = uiZ;
  14204. return uZ.f;
  14205. }
  14206. /**** ended inlining ../../source/f32_mul.c ****/
  14207. /**** start inlining ../../source/f32_mulAdd.c ****/
  14208. /*============================================================================
  14209. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  14210. Package, Release 3e, by John R. Hauser.
  14211. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  14212. All rights reserved.
  14213. Redistribution and use in source and binary forms, with or without
  14214. modification, are permitted provided that the following conditions are met:
  14215. 1. Redistributions of source code must retain the above copyright notice,
  14216. this list of conditions, and the following disclaimer.
  14217. 2. Redistributions in binary form must reproduce the above copyright notice,
  14218. this list of conditions, and the following disclaimer in the documentation
  14219. and/or other materials provided with the distribution.
  14220. 3. Neither the name of the University nor the names of its contributors may
  14221. be used to endorse or promote products derived from this software without
  14222. specific prior written permission.
  14223. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  14224. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  14225. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  14226. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  14227. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  14228. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  14229. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  14230. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14231. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  14232. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14233. =============================================================================*/
  14234. #include <stdint.h>
  14235. /**** skipping file: platform.h ****/
  14236. /**** skipping file: internals.h ****/
  14237. /**** skipping file: softfloat.h ****/
  14238. float32_t f32_mulAdd( float32_t a, float32_t b, float32_t c )
  14239. {
  14240. union ui32_f32 uA;
  14241. uint_fast32_t uiA;
  14242. union ui32_f32 uB;
  14243. uint_fast32_t uiB;
  14244. union ui32_f32 uC;
  14245. uint_fast32_t uiC;
  14246. uA.f = a;
  14247. uiA = uA.ui;
  14248. uB.f = b;
  14249. uiB = uB.ui;
  14250. uC.f = c;
  14251. uiC = uC.ui;
  14252. return softfloat_mulAddF32( uiA, uiB, uiC, 0 );
  14253. }
  14254. /**** ended inlining ../../source/f32_mulAdd.c ****/
  14255. /**** start inlining ../../source/f32_div.c ****/
  14256. /*============================================================================
  14257. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  14258. Package, Release 3e, by John R. Hauser.
  14259. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  14260. All rights reserved.
  14261. Redistribution and use in source and binary forms, with or without
  14262. modification, are permitted provided that the following conditions are met:
  14263. 1. Redistributions of source code must retain the above copyright notice,
  14264. this list of conditions, and the following disclaimer.
  14265. 2. Redistributions in binary form must reproduce the above copyright notice,
  14266. this list of conditions, and the following disclaimer in the documentation
  14267. and/or other materials provided with the distribution.
  14268. 3. Neither the name of the University nor the names of its contributors may
  14269. be used to endorse or promote products derived from this software without
  14270. specific prior written permission.
  14271. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  14272. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  14273. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  14274. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  14275. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  14276. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  14277. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  14278. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14279. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  14280. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14281. =============================================================================*/
  14282. #include <stdbool.h>
  14283. #include <stdint.h>
  14284. /**** skipping file: platform.h ****/
  14285. /**** skipping file: internals.h ****/
  14286. /**** skipping file: specialize.h ****/
  14287. /**** skipping file: softfloat.h ****/
  14288. float32_t f32_div( float32_t a, float32_t b )
  14289. {
  14290. union ui32_f32 uA;
  14291. uint_fast32_t uiA;
  14292. bool signA;
  14293. int_fast16_t expA;
  14294. uint_fast32_t sigA;
  14295. union ui32_f32 uB;
  14296. uint_fast32_t uiB;
  14297. bool signB;
  14298. int_fast16_t expB;
  14299. uint_fast32_t sigB;
  14300. bool signZ;
  14301. struct exp16_sig32 normExpSig;
  14302. int_fast16_t expZ;
  14303. #ifdef SOFTFLOAT_FAST_DIV64TO32
  14304. uint_fast64_t sig64A;
  14305. uint_fast32_t sigZ;
  14306. #else
  14307. uint_fast32_t sigZ;
  14308. uint_fast64_t rem;
  14309. #endif
  14310. uint_fast32_t uiZ;
  14311. union ui32_f32 uZ;
  14312. /*------------------------------------------------------------------------
  14313. *------------------------------------------------------------------------*/
  14314. uA.f = a;
  14315. uiA = uA.ui;
  14316. signA = signF32UI( uiA );
  14317. expA = expF32UI( uiA );
  14318. sigA = fracF32UI( uiA );
  14319. uB.f = b;
  14320. uiB = uB.ui;
  14321. signB = signF32UI( uiB );
  14322. expB = expF32UI( uiB );
  14323. sigB = fracF32UI( uiB );
  14324. signZ = signA ^ signB;
  14325. /*------------------------------------------------------------------------
  14326. *------------------------------------------------------------------------*/
  14327. if ( expA == 0xFF ) {
  14328. if ( sigA ) goto propagateNaN;
  14329. if ( expB == 0xFF ) {
  14330. if ( sigB ) goto propagateNaN;
  14331. goto invalid;
  14332. }
  14333. goto infinity;
  14334. }
  14335. if ( expB == 0xFF ) {
  14336. if ( sigB ) goto propagateNaN;
  14337. goto zero;
  14338. }
  14339. /*------------------------------------------------------------------------
  14340. *------------------------------------------------------------------------*/
  14341. if ( ! expB ) {
  14342. if ( ! sigB ) {
  14343. if ( ! (expA | sigA) ) goto invalid;
  14344. softfloat_raiseFlags( softfloat_flag_infinite );
  14345. goto infinity;
  14346. }
  14347. normExpSig = softfloat_normSubnormalF32Sig( sigB );
  14348. expB = normExpSig.exp;
  14349. sigB = normExpSig.sig;
  14350. }
  14351. if ( ! expA ) {
  14352. if ( ! sigA ) goto zero;
  14353. normExpSig = softfloat_normSubnormalF32Sig( sigA );
  14354. expA = normExpSig.exp;
  14355. sigA = normExpSig.sig;
  14356. }
  14357. /*------------------------------------------------------------------------
  14358. *------------------------------------------------------------------------*/
  14359. expZ = expA - expB + 0x7E;
  14360. sigA |= 0x00800000;
  14361. sigB |= 0x00800000;
  14362. #ifdef SOFTFLOAT_FAST_DIV64TO32
  14363. if ( sigA < sigB ) {
  14364. --expZ;
  14365. sig64A = (uint_fast64_t) sigA<<31;
  14366. } else {
  14367. sig64A = (uint_fast64_t) sigA<<30;
  14368. }
  14369. sigZ = sig64A / sigB;
  14370. if ( ! (sigZ & 0x3F) ) sigZ |= ((uint_fast64_t) sigB * sigZ != sig64A);
  14371. #else
  14372. if ( sigA < sigB ) {
  14373. --expZ;
  14374. sigA <<= 8;
  14375. } else {
  14376. sigA <<= 7;
  14377. }
  14378. sigB <<= 8;
  14379. sigZ = ((uint_fast64_t) sigA * softfloat_approxRecip32_1( sigB ))>>32;
  14380. /*------------------------------------------------------------------------
  14381. *------------------------------------------------------------------------*/
  14382. sigZ += 2;
  14383. if ( (sigZ & 0x3F) < 2 ) {
  14384. sigZ &= ~3;
  14385. #ifdef SOFTFLOAT_FAST_INT64
  14386. rem = ((uint_fast64_t) sigA<<31) - (uint_fast64_t) sigZ * sigB;
  14387. #else
  14388. rem = ((uint_fast64_t) sigA<<32) - (uint_fast64_t) (sigZ<<1) * sigB;
  14389. #endif
  14390. if ( rem & UINT64_C( 0x8000000000000000 ) ) {
  14391. sigZ -= 4;
  14392. } else {
  14393. if ( rem ) sigZ |= 1;
  14394. }
  14395. }
  14396. #endif
  14397. return softfloat_roundPackToF32( signZ, expZ, sigZ );
  14398. /*------------------------------------------------------------------------
  14399. *------------------------------------------------------------------------*/
  14400. propagateNaN:
  14401. uiZ = softfloat_propagateNaNF32UI( uiA, uiB );
  14402. goto uiZ;
  14403. /*------------------------------------------------------------------------
  14404. *------------------------------------------------------------------------*/
  14405. invalid:
  14406. softfloat_raiseFlags( softfloat_flag_invalid );
  14407. uiZ = defaultNaNF32UI;
  14408. goto uiZ;
  14409. /*------------------------------------------------------------------------
  14410. *------------------------------------------------------------------------*/
  14411. infinity:
  14412. uiZ = packToF32UI( signZ, 0xFF, 0 );
  14413. goto uiZ;
  14414. /*------------------------------------------------------------------------
  14415. *------------------------------------------------------------------------*/
  14416. zero:
  14417. uiZ = packToF32UI( signZ, 0, 0 );
  14418. uiZ:
  14419. uZ.ui = uiZ;
  14420. return uZ.f;
  14421. }
  14422. /**** ended inlining ../../source/f32_div.c ****/
  14423. /**** start inlining ../../source/f32_rem.c ****/
  14424. /*============================================================================
  14425. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  14426. Package, Release 3e, by John R. Hauser.
  14427. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  14428. All rights reserved.
  14429. Redistribution and use in source and binary forms, with or without
  14430. modification, are permitted provided that the following conditions are met:
  14431. 1. Redistributions of source code must retain the above copyright notice,
  14432. this list of conditions, and the following disclaimer.
  14433. 2. Redistributions in binary form must reproduce the above copyright notice,
  14434. this list of conditions, and the following disclaimer in the documentation
  14435. and/or other materials provided with the distribution.
  14436. 3. Neither the name of the University nor the names of its contributors may
  14437. be used to endorse or promote products derived from this software without
  14438. specific prior written permission.
  14439. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  14440. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  14441. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  14442. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  14443. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  14444. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  14445. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  14446. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14447. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  14448. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14449. =============================================================================*/
  14450. #include <stdbool.h>
  14451. #include <stdint.h>
  14452. /**** skipping file: platform.h ****/
  14453. /**** skipping file: internals.h ****/
  14454. /**** skipping file: specialize.h ****/
  14455. /**** skipping file: softfloat.h ****/
  14456. float32_t f32_rem( float32_t a, float32_t b )
  14457. {
  14458. union ui32_f32 uA;
  14459. uint_fast32_t uiA;
  14460. bool signA;
  14461. int_fast16_t expA;
  14462. uint_fast32_t sigA;
  14463. union ui32_f32 uB;
  14464. uint_fast32_t uiB;
  14465. int_fast16_t expB;
  14466. uint_fast32_t sigB;
  14467. struct exp16_sig32 normExpSig;
  14468. uint32_t rem;
  14469. int_fast16_t expDiff;
  14470. uint32_t q, recip32, altRem, meanRem;
  14471. bool signRem;
  14472. uint_fast32_t uiZ;
  14473. union ui32_f32 uZ;
  14474. /*------------------------------------------------------------------------
  14475. *------------------------------------------------------------------------*/
  14476. uA.f = a;
  14477. uiA = uA.ui;
  14478. signA = signF32UI( uiA );
  14479. expA = expF32UI( uiA );
  14480. sigA = fracF32UI( uiA );
  14481. uB.f = b;
  14482. uiB = uB.ui;
  14483. expB = expF32UI( uiB );
  14484. sigB = fracF32UI( uiB );
  14485. /*------------------------------------------------------------------------
  14486. *------------------------------------------------------------------------*/
  14487. if ( expA == 0xFF ) {
  14488. if ( sigA || ((expB == 0xFF) && sigB) ) goto propagateNaN;
  14489. goto invalid;
  14490. }
  14491. if ( expB == 0xFF ) {
  14492. if ( sigB ) goto propagateNaN;
  14493. return a;
  14494. }
  14495. /*------------------------------------------------------------------------
  14496. *------------------------------------------------------------------------*/
  14497. if ( ! expB ) {
  14498. if ( ! sigB ) goto invalid;
  14499. normExpSig = softfloat_normSubnormalF32Sig( sigB );
  14500. expB = normExpSig.exp;
  14501. sigB = normExpSig.sig;
  14502. }
  14503. if ( ! expA ) {
  14504. if ( ! sigA ) return a;
  14505. normExpSig = softfloat_normSubnormalF32Sig( sigA );
  14506. expA = normExpSig.exp;
  14507. sigA = normExpSig.sig;
  14508. }
  14509. /*------------------------------------------------------------------------
  14510. *------------------------------------------------------------------------*/
  14511. rem = sigA | 0x00800000;
  14512. sigB |= 0x00800000;
  14513. expDiff = expA - expB;
  14514. if ( expDiff < 1 ) {
  14515. if ( expDiff < -1 ) return a;
  14516. sigB <<= 6;
  14517. if ( expDiff ) {
  14518. rem <<= 5;
  14519. q = 0;
  14520. } else {
  14521. rem <<= 6;
  14522. q = (sigB <= rem);
  14523. if ( q ) rem -= sigB;
  14524. }
  14525. } else {
  14526. recip32 = softfloat_approxRecip32_1( sigB<<8 );
  14527. /*--------------------------------------------------------------------
  14528. | Changing the shift of `rem' here requires also changing the initial
  14529. | subtraction from `expDiff'.
  14530. *--------------------------------------------------------------------*/
  14531. rem <<= 7;
  14532. expDiff -= 31;
  14533. /*--------------------------------------------------------------------
  14534. | The scale of `sigB' affects how many bits are obtained during each
  14535. | cycle of the loop. Currently this is 29 bits per loop iteration,
  14536. | which is believed to be the maximum possible.
  14537. *--------------------------------------------------------------------*/
  14538. sigB <<= 6;
  14539. for (;;) {
  14540. q = (rem * (uint_fast64_t) recip32)>>32;
  14541. if ( expDiff < 0 ) break;
  14542. rem = -(q * (uint32_t) sigB);
  14543. expDiff -= 29;
  14544. }
  14545. /*--------------------------------------------------------------------
  14546. | (`expDiff' cannot be less than -30 here.)
  14547. *--------------------------------------------------------------------*/
  14548. q >>= ~expDiff & 31;
  14549. rem = (rem<<(expDiff + 30)) - q * (uint32_t) sigB;
  14550. }
  14551. /*------------------------------------------------------------------------
  14552. *------------------------------------------------------------------------*/
  14553. do {
  14554. altRem = rem;
  14555. ++q;
  14556. rem -= sigB;
  14557. } while ( ! (rem & 0x80000000) );
  14558. meanRem = rem + altRem;
  14559. if ( (meanRem & 0x80000000) || (! meanRem && (q & 1)) ) rem = altRem;
  14560. signRem = signA;
  14561. if ( 0x80000000 <= rem ) {
  14562. signRem = ! signRem;
  14563. rem = -rem;
  14564. }
  14565. return softfloat_normRoundPackToF32( signRem, expB, rem );
  14566. /*------------------------------------------------------------------------
  14567. *------------------------------------------------------------------------*/
  14568. propagateNaN:
  14569. uiZ = softfloat_propagateNaNF32UI( uiA, uiB );
  14570. goto uiZ;
  14571. invalid:
  14572. softfloat_raiseFlags( softfloat_flag_invalid );
  14573. uiZ = defaultNaNF32UI;
  14574. uiZ:
  14575. uZ.ui = uiZ;
  14576. return uZ.f;
  14577. }
  14578. /**** ended inlining ../../source/f32_rem.c ****/
  14579. /**** start inlining ../../source/f32_sqrt.c ****/
  14580. /*============================================================================
  14581. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  14582. Package, Release 3e, by John R. Hauser.
  14583. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  14584. California. All rights reserved.
  14585. Redistribution and use in source and binary forms, with or without
  14586. modification, are permitted provided that the following conditions are met:
  14587. 1. Redistributions of source code must retain the above copyright notice,
  14588. this list of conditions, and the following disclaimer.
  14589. 2. Redistributions in binary form must reproduce the above copyright notice,
  14590. this list of conditions, and the following disclaimer in the documentation
  14591. and/or other materials provided with the distribution.
  14592. 3. Neither the name of the University nor the names of its contributors may
  14593. be used to endorse or promote products derived from this software without
  14594. specific prior written permission.
  14595. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  14596. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  14597. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  14598. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  14599. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  14600. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  14601. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  14602. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14603. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  14604. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14605. =============================================================================*/
  14606. #include <stdbool.h>
  14607. #include <stdint.h>
  14608. /**** skipping file: platform.h ****/
  14609. /**** skipping file: internals.h ****/
  14610. /**** skipping file: specialize.h ****/
  14611. /**** skipping file: softfloat.h ****/
  14612. float32_t f32_sqrt( float32_t a )
  14613. {
  14614. union ui32_f32 uA;
  14615. uint_fast32_t uiA;
  14616. bool signA;
  14617. int_fast16_t expA;
  14618. uint_fast32_t sigA, uiZ;
  14619. struct exp16_sig32 normExpSig;
  14620. int_fast16_t expZ;
  14621. uint_fast32_t sigZ, shiftedSigZ;
  14622. uint32_t negRem;
  14623. union ui32_f32 uZ;
  14624. /*------------------------------------------------------------------------
  14625. *------------------------------------------------------------------------*/
  14626. uA.f = a;
  14627. uiA = uA.ui;
  14628. signA = signF32UI( uiA );
  14629. expA = expF32UI( uiA );
  14630. sigA = fracF32UI( uiA );
  14631. /*------------------------------------------------------------------------
  14632. *------------------------------------------------------------------------*/
  14633. if ( expA == 0xFF ) {
  14634. if ( sigA ) {
  14635. uiZ = softfloat_propagateNaNF32UI( uiA, 0 );
  14636. goto uiZ;
  14637. }
  14638. if ( ! signA ) return a;
  14639. goto invalid;
  14640. }
  14641. /*------------------------------------------------------------------------
  14642. *------------------------------------------------------------------------*/
  14643. if ( signA ) {
  14644. if ( ! (expA | sigA) ) return a;
  14645. goto invalid;
  14646. }
  14647. /*------------------------------------------------------------------------
  14648. *------------------------------------------------------------------------*/
  14649. if ( ! expA ) {
  14650. if ( ! sigA ) return a;
  14651. normExpSig = softfloat_normSubnormalF32Sig( sigA );
  14652. expA = normExpSig.exp;
  14653. sigA = normExpSig.sig;
  14654. }
  14655. /*------------------------------------------------------------------------
  14656. *------------------------------------------------------------------------*/
  14657. expZ = ((expA - 0x7F)>>1) + 0x7E;
  14658. expA &= 1;
  14659. sigA = (sigA | 0x00800000)<<8;
  14660. sigZ =
  14661. ((uint_fast64_t) sigA * softfloat_approxRecipSqrt32_1( expA, sigA ))
  14662. >>32;
  14663. if ( expA ) sigZ >>= 1;
  14664. /*------------------------------------------------------------------------
  14665. *------------------------------------------------------------------------*/
  14666. sigZ += 2;
  14667. if ( (sigZ & 0x3F) < 2 ) {
  14668. shiftedSigZ = sigZ>>2;
  14669. negRem = shiftedSigZ * shiftedSigZ;
  14670. sigZ &= ~3;
  14671. if ( negRem & 0x80000000 ) {
  14672. sigZ |= 1;
  14673. } else {
  14674. if ( negRem ) --sigZ;
  14675. }
  14676. }
  14677. return softfloat_roundPackToF32( 0, expZ, sigZ );
  14678. /*------------------------------------------------------------------------
  14679. *------------------------------------------------------------------------*/
  14680. invalid:
  14681. softfloat_raiseFlags( softfloat_flag_invalid );
  14682. uiZ = defaultNaNF32UI;
  14683. uiZ:
  14684. uZ.ui = uiZ;
  14685. return uZ.f;
  14686. }
  14687. /**** ended inlining ../../source/f32_sqrt.c ****/
  14688. /**** start inlining ../../source/f32_eq.c ****/
  14689. /*============================================================================
  14690. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  14691. Package, Release 3e, by John R. Hauser.
  14692. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  14693. All rights reserved.
  14694. Redistribution and use in source and binary forms, with or without
  14695. modification, are permitted provided that the following conditions are met:
  14696. 1. Redistributions of source code must retain the above copyright notice,
  14697. this list of conditions, and the following disclaimer.
  14698. 2. Redistributions in binary form must reproduce the above copyright notice,
  14699. this list of conditions, and the following disclaimer in the documentation
  14700. and/or other materials provided with the distribution.
  14701. 3. Neither the name of the University nor the names of its contributors may
  14702. be used to endorse or promote products derived from this software without
  14703. specific prior written permission.
  14704. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  14705. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  14706. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  14707. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  14708. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  14709. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  14710. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  14711. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14712. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  14713. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14714. =============================================================================*/
  14715. #include <stdbool.h>
  14716. #include <stdint.h>
  14717. /**** skipping file: platform.h ****/
  14718. /**** skipping file: internals.h ****/
  14719. /**** skipping file: specialize.h ****/
  14720. /**** skipping file: softfloat.h ****/
  14721. bool f32_eq( float32_t a, float32_t b )
  14722. {
  14723. union ui32_f32 uA;
  14724. uint_fast32_t uiA;
  14725. union ui32_f32 uB;
  14726. uint_fast32_t uiB;
  14727. uA.f = a;
  14728. uiA = uA.ui;
  14729. uB.f = b;
  14730. uiB = uB.ui;
  14731. if ( isNaNF32UI( uiA ) || isNaNF32UI( uiB ) ) {
  14732. if (
  14733. softfloat_isSigNaNF32UI( uiA ) || softfloat_isSigNaNF32UI( uiB )
  14734. ) {
  14735. softfloat_raiseFlags( softfloat_flag_invalid );
  14736. }
  14737. return false;
  14738. }
  14739. return (uiA == uiB) || ! (uint32_t) ((uiA | uiB)<<1);
  14740. }
  14741. /**** ended inlining ../../source/f32_eq.c ****/
  14742. /**** start inlining ../../source/f32_le.c ****/
  14743. /*============================================================================
  14744. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  14745. Package, Release 3e, by John R. Hauser.
  14746. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  14747. All rights reserved.
  14748. Redistribution and use in source and binary forms, with or without
  14749. modification, are permitted provided that the following conditions are met:
  14750. 1. Redistributions of source code must retain the above copyright notice,
  14751. this list of conditions, and the following disclaimer.
  14752. 2. Redistributions in binary form must reproduce the above copyright notice,
  14753. this list of conditions, and the following disclaimer in the documentation
  14754. and/or other materials provided with the distribution.
  14755. 3. Neither the name of the University nor the names of its contributors may
  14756. be used to endorse or promote products derived from this software without
  14757. specific prior written permission.
  14758. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  14759. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  14760. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  14761. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  14762. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  14763. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  14764. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  14765. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14766. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  14767. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14768. =============================================================================*/
  14769. #include <stdbool.h>
  14770. #include <stdint.h>
  14771. /**** skipping file: platform.h ****/
  14772. /**** skipping file: internals.h ****/
  14773. /**** skipping file: softfloat.h ****/
  14774. bool f32_le( float32_t a, float32_t b )
  14775. {
  14776. union ui32_f32 uA;
  14777. uint_fast32_t uiA;
  14778. union ui32_f32 uB;
  14779. uint_fast32_t uiB;
  14780. bool signA, signB;
  14781. uA.f = a;
  14782. uiA = uA.ui;
  14783. uB.f = b;
  14784. uiB = uB.ui;
  14785. if ( isNaNF32UI( uiA ) || isNaNF32UI( uiB ) ) {
  14786. softfloat_raiseFlags( softfloat_flag_invalid );
  14787. return false;
  14788. }
  14789. signA = signF32UI( uiA );
  14790. signB = signF32UI( uiB );
  14791. return
  14792. (signA != signB) ? signA || ! (uint32_t) ((uiA | uiB)<<1)
  14793. : (uiA == uiB) || (signA ^ (uiA < uiB));
  14794. }
  14795. /**** ended inlining ../../source/f32_le.c ****/
  14796. /**** start inlining ../../source/f32_lt.c ****/
  14797. /*============================================================================
  14798. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  14799. Package, Release 3e, by John R. Hauser.
  14800. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  14801. All rights reserved.
  14802. Redistribution and use in source and binary forms, with or without
  14803. modification, are permitted provided that the following conditions are met:
  14804. 1. Redistributions of source code must retain the above copyright notice,
  14805. this list of conditions, and the following disclaimer.
  14806. 2. Redistributions in binary form must reproduce the above copyright notice,
  14807. this list of conditions, and the following disclaimer in the documentation
  14808. and/or other materials provided with the distribution.
  14809. 3. Neither the name of the University nor the names of its contributors may
  14810. be used to endorse or promote products derived from this software without
  14811. specific prior written permission.
  14812. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  14813. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  14814. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  14815. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  14816. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  14817. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  14818. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  14819. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14820. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  14821. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14822. =============================================================================*/
  14823. #include <stdbool.h>
  14824. #include <stdint.h>
  14825. /**** skipping file: platform.h ****/
  14826. /**** skipping file: internals.h ****/
  14827. /**** skipping file: softfloat.h ****/
  14828. bool f32_lt( float32_t a, float32_t b )
  14829. {
  14830. union ui32_f32 uA;
  14831. uint_fast32_t uiA;
  14832. union ui32_f32 uB;
  14833. uint_fast32_t uiB;
  14834. bool signA, signB;
  14835. uA.f = a;
  14836. uiA = uA.ui;
  14837. uB.f = b;
  14838. uiB = uB.ui;
  14839. if ( isNaNF32UI( uiA ) || isNaNF32UI( uiB ) ) {
  14840. softfloat_raiseFlags( softfloat_flag_invalid );
  14841. return false;
  14842. }
  14843. signA = signF32UI( uiA );
  14844. signB = signF32UI( uiB );
  14845. return
  14846. (signA != signB) ? signA && ((uint32_t) ((uiA | uiB)<<1) != 0)
  14847. : (uiA != uiB) && (signA ^ (uiA < uiB));
  14848. }
  14849. /**** ended inlining ../../source/f32_lt.c ****/
  14850. /**** start inlining ../../source/f32_eq_signaling.c ****/
  14851. /*============================================================================
  14852. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  14853. Package, Release 3e, by John R. Hauser.
  14854. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  14855. All rights reserved.
  14856. Redistribution and use in source and binary forms, with or without
  14857. modification, are permitted provided that the following conditions are met:
  14858. 1. Redistributions of source code must retain the above copyright notice,
  14859. this list of conditions, and the following disclaimer.
  14860. 2. Redistributions in binary form must reproduce the above copyright notice,
  14861. this list of conditions, and the following disclaimer in the documentation
  14862. and/or other materials provided with the distribution.
  14863. 3. Neither the name of the University nor the names of its contributors may
  14864. be used to endorse or promote products derived from this software without
  14865. specific prior written permission.
  14866. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  14867. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  14868. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  14869. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  14870. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  14871. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  14872. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  14873. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14874. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  14875. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14876. =============================================================================*/
  14877. #include <stdbool.h>
  14878. #include <stdint.h>
  14879. /**** skipping file: platform.h ****/
  14880. /**** skipping file: internals.h ****/
  14881. /**** skipping file: softfloat.h ****/
  14882. bool f32_eq_signaling( float32_t a, float32_t b )
  14883. {
  14884. union ui32_f32 uA;
  14885. uint_fast32_t uiA;
  14886. union ui32_f32 uB;
  14887. uint_fast32_t uiB;
  14888. uA.f = a;
  14889. uiA = uA.ui;
  14890. uB.f = b;
  14891. uiB = uB.ui;
  14892. if ( isNaNF32UI( uiA ) || isNaNF32UI( uiB ) ) {
  14893. softfloat_raiseFlags( softfloat_flag_invalid );
  14894. return false;
  14895. }
  14896. return (uiA == uiB) || ! (uint32_t) ((uiA | uiB)<<1);
  14897. }
  14898. /**** ended inlining ../../source/f32_eq_signaling.c ****/
  14899. /**** start inlining ../../source/f32_le_quiet.c ****/
  14900. /*============================================================================
  14901. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  14902. Package, Release 3e, by John R. Hauser.
  14903. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  14904. All rights reserved.
  14905. Redistribution and use in source and binary forms, with or without
  14906. modification, are permitted provided that the following conditions are met:
  14907. 1. Redistributions of source code must retain the above copyright notice,
  14908. this list of conditions, and the following disclaimer.
  14909. 2. Redistributions in binary form must reproduce the above copyright notice,
  14910. this list of conditions, and the following disclaimer in the documentation
  14911. and/or other materials provided with the distribution.
  14912. 3. Neither the name of the University nor the names of its contributors may
  14913. be used to endorse or promote products derived from this software without
  14914. specific prior written permission.
  14915. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  14916. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  14917. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  14918. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  14919. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  14920. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  14921. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  14922. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14923. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  14924. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14925. =============================================================================*/
  14926. #include <stdbool.h>
  14927. #include <stdint.h>
  14928. /**** skipping file: platform.h ****/
  14929. /**** skipping file: internals.h ****/
  14930. /**** skipping file: specialize.h ****/
  14931. /**** skipping file: softfloat.h ****/
  14932. bool f32_le_quiet( float32_t a, float32_t b )
  14933. {
  14934. union ui32_f32 uA;
  14935. uint_fast32_t uiA;
  14936. union ui32_f32 uB;
  14937. uint_fast32_t uiB;
  14938. bool signA, signB;
  14939. uA.f = a;
  14940. uiA = uA.ui;
  14941. uB.f = b;
  14942. uiB = uB.ui;
  14943. if ( isNaNF32UI( uiA ) || isNaNF32UI( uiB ) ) {
  14944. if (
  14945. softfloat_isSigNaNF32UI( uiA ) || softfloat_isSigNaNF32UI( uiB )
  14946. ) {
  14947. softfloat_raiseFlags( softfloat_flag_invalid );
  14948. }
  14949. return false;
  14950. }
  14951. signA = signF32UI( uiA );
  14952. signB = signF32UI( uiB );
  14953. return
  14954. (signA != signB) ? signA || ! (uint32_t) ((uiA | uiB)<<1)
  14955. : (uiA == uiB) || (signA ^ (uiA < uiB));
  14956. }
  14957. /**** ended inlining ../../source/f32_le_quiet.c ****/
  14958. /**** start inlining ../../source/f32_lt_quiet.c ****/
  14959. /*============================================================================
  14960. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  14961. Package, Release 3e, by John R. Hauser.
  14962. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  14963. All rights reserved.
  14964. Redistribution and use in source and binary forms, with or without
  14965. modification, are permitted provided that the following conditions are met:
  14966. 1. Redistributions of source code must retain the above copyright notice,
  14967. this list of conditions, and the following disclaimer.
  14968. 2. Redistributions in binary form must reproduce the above copyright notice,
  14969. this list of conditions, and the following disclaimer in the documentation
  14970. and/or other materials provided with the distribution.
  14971. 3. Neither the name of the University nor the names of its contributors may
  14972. be used to endorse or promote products derived from this software without
  14973. specific prior written permission.
  14974. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  14975. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  14976. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  14977. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  14978. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  14979. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  14980. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  14981. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14982. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  14983. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14984. =============================================================================*/
  14985. #include <stdbool.h>
  14986. #include <stdint.h>
  14987. /**** skipping file: platform.h ****/
  14988. /**** skipping file: internals.h ****/
  14989. /**** skipping file: specialize.h ****/
  14990. /**** skipping file: softfloat.h ****/
  14991. bool f32_lt_quiet( float32_t a, float32_t b )
  14992. {
  14993. union ui32_f32 uA;
  14994. uint_fast32_t uiA;
  14995. union ui32_f32 uB;
  14996. uint_fast32_t uiB;
  14997. bool signA, signB;
  14998. uA.f = a;
  14999. uiA = uA.ui;
  15000. uB.f = b;
  15001. uiB = uB.ui;
  15002. if ( isNaNF32UI( uiA ) || isNaNF32UI( uiB ) ) {
  15003. if (
  15004. softfloat_isSigNaNF32UI( uiA ) || softfloat_isSigNaNF32UI( uiB )
  15005. ) {
  15006. softfloat_raiseFlags( softfloat_flag_invalid );
  15007. }
  15008. return false;
  15009. }
  15010. signA = signF32UI( uiA );
  15011. signB = signF32UI( uiB );
  15012. return
  15013. (signA != signB) ? signA && ((uint32_t) ((uiA | uiB)<<1) != 0)
  15014. : (uiA != uiB) && (signA ^ (uiA < uiB));
  15015. }
  15016. /**** ended inlining ../../source/f32_lt_quiet.c ****/
  15017. /**** start inlining ../../source/f32_isSignalingNaN.c ****/
  15018. /*============================================================================
  15019. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  15020. Package, Release 3e, by John R. Hauser.
  15021. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  15022. All rights reserved.
  15023. Redistribution and use in source and binary forms, with or without
  15024. modification, are permitted provided that the following conditions are met:
  15025. 1. Redistributions of source code must retain the above copyright notice,
  15026. this list of conditions, and the following disclaimer.
  15027. 2. Redistributions in binary form must reproduce the above copyright notice,
  15028. this list of conditions, and the following disclaimer in the documentation
  15029. and/or other materials provided with the distribution.
  15030. 3. Neither the name of the University nor the names of its contributors may
  15031. be used to endorse or promote products derived from this software without
  15032. specific prior written permission.
  15033. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  15034. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  15035. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  15036. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  15037. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  15038. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  15039. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  15040. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  15041. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  15042. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  15043. =============================================================================*/
  15044. #include <stdbool.h>
  15045. /**** skipping file: platform.h ****/
  15046. /**** skipping file: internals.h ****/
  15047. /**** skipping file: specialize.h ****/
  15048. /**** skipping file: softfloat.h ****/
  15049. bool f32_isSignalingNaN( float32_t a )
  15050. {
  15051. union ui32_f32 uA;
  15052. uA.f = a;
  15053. return softfloat_isSigNaNF32UI( uA.ui );
  15054. }
  15055. /**** ended inlining ../../source/f32_isSignalingNaN.c ****/
  15056. /**** start inlining ../../source/f64_to_ui32.c ****/
  15057. /*============================================================================
  15058. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  15059. Package, Release 3e, by John R. Hauser.
  15060. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  15061. University of California. All rights reserved.
  15062. Redistribution and use in source and binary forms, with or without
  15063. modification, are permitted provided that the following conditions are met:
  15064. 1. Redistributions of source code must retain the above copyright notice,
  15065. this list of conditions, and the following disclaimer.
  15066. 2. Redistributions in binary form must reproduce the above copyright notice,
  15067. this list of conditions, and the following disclaimer in the documentation
  15068. and/or other materials provided with the distribution.
  15069. 3. Neither the name of the University nor the names of its contributors may
  15070. be used to endorse or promote products derived from this software without
  15071. specific prior written permission.
  15072. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  15073. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  15074. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  15075. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  15076. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  15077. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  15078. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  15079. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  15080. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  15081. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  15082. =============================================================================*/
  15083. #include <stdbool.h>
  15084. #include <stdint.h>
  15085. /**** skipping file: platform.h ****/
  15086. /**** skipping file: internals.h ****/
  15087. /**** skipping file: specialize.h ****/
  15088. /**** skipping file: softfloat.h ****/
  15089. uint_fast32_t f64_to_ui32( float64_t a, uint_fast8_t roundingMode, bool exact )
  15090. {
  15091. union ui64_f64 uA;
  15092. uint_fast64_t uiA;
  15093. bool sign;
  15094. int_fast16_t exp;
  15095. uint_fast64_t sig;
  15096. int_fast16_t shiftDist;
  15097. /*------------------------------------------------------------------------
  15098. *------------------------------------------------------------------------*/
  15099. uA.f = a;
  15100. uiA = uA.ui;
  15101. sign = signF64UI( uiA );
  15102. exp = expF64UI( uiA );
  15103. sig = fracF64UI( uiA );
  15104. /*------------------------------------------------------------------------
  15105. *------------------------------------------------------------------------*/
  15106. #if (ui32_fromNaN != ui32_fromPosOverflow) || (ui32_fromNaN != ui32_fromNegOverflow)
  15107. if ( (exp == 0x7FF) && sig ) {
  15108. #if (ui32_fromNaN == ui32_fromPosOverflow)
  15109. sign = 0;
  15110. #elif (ui32_fromNaN == ui32_fromNegOverflow)
  15111. sign = 1;
  15112. #else
  15113. softfloat_raiseFlags( softfloat_flag_invalid );
  15114. return ui32_fromNaN;
  15115. #endif
  15116. }
  15117. #endif
  15118. /*------------------------------------------------------------------------
  15119. *------------------------------------------------------------------------*/
  15120. if ( exp ) sig |= UINT64_C( 0x0010000000000000 );
  15121. shiftDist = 0x427 - exp;
  15122. if ( 0 < shiftDist ) sig = softfloat_shiftRightJam64( sig, shiftDist );
  15123. return softfloat_roundToUI32( sign, sig, roundingMode, exact );
  15124. }
  15125. /**** ended inlining ../../source/f64_to_ui32.c ****/
  15126. /**** start inlining ../../source/f64_to_ui64.c ****/
  15127. /*============================================================================
  15128. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  15129. Package, Release 3e, by John R. Hauser.
  15130. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  15131. University of California. All rights reserved.
  15132. Redistribution and use in source and binary forms, with or without
  15133. modification, are permitted provided that the following conditions are met:
  15134. 1. Redistributions of source code must retain the above copyright notice,
  15135. this list of conditions, and the following disclaimer.
  15136. 2. Redistributions in binary form must reproduce the above copyright notice,
  15137. this list of conditions, and the following disclaimer in the documentation
  15138. and/or other materials provided with the distribution.
  15139. 3. Neither the name of the University nor the names of its contributors may
  15140. be used to endorse or promote products derived from this software without
  15141. specific prior written permission.
  15142. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  15143. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  15144. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  15145. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  15146. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  15147. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  15148. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  15149. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  15150. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  15151. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  15152. =============================================================================*/
  15153. #include <stdbool.h>
  15154. #include <stdint.h>
  15155. /**** skipping file: platform.h ****/
  15156. /**** skipping file: internals.h ****/
  15157. /**** skipping file: specialize.h ****/
  15158. /**** skipping file: softfloat.h ****/
  15159. uint_fast64_t f64_to_ui64( float64_t a, uint_fast8_t roundingMode, bool exact )
  15160. {
  15161. union ui64_f64 uA;
  15162. uint_fast64_t uiA;
  15163. bool sign;
  15164. int_fast16_t exp;
  15165. uint_fast64_t sig;
  15166. int_fast16_t shiftDist;
  15167. #ifdef SOFTFLOAT_FAST_INT64
  15168. struct uint64_extra sigExtra;
  15169. #else
  15170. uint32_t extSig[3];
  15171. #endif
  15172. /*------------------------------------------------------------------------
  15173. *------------------------------------------------------------------------*/
  15174. uA.f = a;
  15175. uiA = uA.ui;
  15176. sign = signF64UI( uiA );
  15177. exp = expF64UI( uiA );
  15178. sig = fracF64UI( uiA );
  15179. /*------------------------------------------------------------------------
  15180. *------------------------------------------------------------------------*/
  15181. if ( exp ) sig |= UINT64_C( 0x0010000000000000 );
  15182. shiftDist = 0x433 - exp;
  15183. #ifdef SOFTFLOAT_FAST_INT64
  15184. if ( shiftDist <= 0 ) {
  15185. if ( shiftDist < -11 ) goto invalid;
  15186. sigExtra.v = sig<<-shiftDist;
  15187. sigExtra.extra = 0;
  15188. } else {
  15189. sigExtra = softfloat_shiftRightJam64Extra( sig, 0, shiftDist );
  15190. }
  15191. return
  15192. softfloat_roundToUI64(
  15193. sign, sigExtra.v, sigExtra.extra, roundingMode, exact );
  15194. #else
  15195. extSig[indexWord( 3, 0 )] = 0;
  15196. if ( shiftDist <= 0 ) {
  15197. if ( shiftDist < -11 ) goto invalid;
  15198. sig <<= -shiftDist;
  15199. extSig[indexWord( 3, 2 )] = sig>>32;
  15200. extSig[indexWord( 3, 1 )] = sig;
  15201. } else {
  15202. extSig[indexWord( 3, 2 )] = sig>>32;
  15203. extSig[indexWord( 3, 1 )] = sig;
  15204. softfloat_shiftRightJam96M( extSig, shiftDist, extSig );
  15205. }
  15206. return softfloat_roundMToUI64( sign, extSig, roundingMode, exact );
  15207. #endif
  15208. /*------------------------------------------------------------------------
  15209. *------------------------------------------------------------------------*/
  15210. invalid:
  15211. softfloat_raiseFlags( softfloat_flag_invalid );
  15212. return
  15213. (exp == 0x7FF) && fracF64UI( uiA ) ? ui64_fromNaN
  15214. : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
  15215. }
  15216. /**** ended inlining ../../source/f64_to_ui64.c ****/
  15217. /**** start inlining ../../source/f64_to_i32.c ****/
  15218. /*============================================================================
  15219. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  15220. Package, Release 3e, by John R. Hauser.
  15221. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  15222. University of California. All rights reserved.
  15223. Redistribution and use in source and binary forms, with or without
  15224. modification, are permitted provided that the following conditions are met:
  15225. 1. Redistributions of source code must retain the above copyright notice,
  15226. this list of conditions, and the following disclaimer.
  15227. 2. Redistributions in binary form must reproduce the above copyright notice,
  15228. this list of conditions, and the following disclaimer in the documentation
  15229. and/or other materials provided with the distribution.
  15230. 3. Neither the name of the University nor the names of its contributors may
  15231. be used to endorse or promote products derived from this software without
  15232. specific prior written permission.
  15233. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  15234. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  15235. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  15236. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  15237. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  15238. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  15239. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  15240. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  15241. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  15242. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  15243. =============================================================================*/
  15244. #include <stdbool.h>
  15245. #include <stdint.h>
  15246. /**** skipping file: platform.h ****/
  15247. /**** skipping file: internals.h ****/
  15248. /**** skipping file: specialize.h ****/
  15249. /**** skipping file: softfloat.h ****/
  15250. int_fast32_t f64_to_i32( float64_t a, uint_fast8_t roundingMode, bool exact )
  15251. {
  15252. union ui64_f64 uA;
  15253. uint_fast64_t uiA;
  15254. bool sign;
  15255. int_fast16_t exp;
  15256. uint_fast64_t sig;
  15257. int_fast16_t shiftDist;
  15258. /*------------------------------------------------------------------------
  15259. *------------------------------------------------------------------------*/
  15260. uA.f = a;
  15261. uiA = uA.ui;
  15262. sign = signF64UI( uiA );
  15263. exp = expF64UI( uiA );
  15264. sig = fracF64UI( uiA );
  15265. /*------------------------------------------------------------------------
  15266. *------------------------------------------------------------------------*/
  15267. #if (i32_fromNaN != i32_fromPosOverflow) || (i32_fromNaN != i32_fromNegOverflow)
  15268. if ( (exp == 0x7FF) && sig ) {
  15269. #if (i32_fromNaN == i32_fromPosOverflow)
  15270. sign = 0;
  15271. #elif (i32_fromNaN == i32_fromNegOverflow)
  15272. sign = 1;
  15273. #else
  15274. softfloat_raiseFlags( softfloat_flag_invalid );
  15275. return i32_fromNaN;
  15276. #endif
  15277. }
  15278. #endif
  15279. /*------------------------------------------------------------------------
  15280. *------------------------------------------------------------------------*/
  15281. if ( exp ) sig |= UINT64_C( 0x0010000000000000 );
  15282. shiftDist = 0x427 - exp;
  15283. if ( 0 < shiftDist ) sig = softfloat_shiftRightJam64( sig, shiftDist );
  15284. return softfloat_roundToI32( sign, sig, roundingMode, exact );
  15285. }
  15286. /**** ended inlining ../../source/f64_to_i32.c ****/
  15287. /**** start inlining ../../source/f64_to_i64.c ****/
  15288. /*============================================================================
  15289. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  15290. Package, Release 3e, by John R. Hauser.
  15291. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  15292. University of California. All rights reserved.
  15293. Redistribution and use in source and binary forms, with or without
  15294. modification, are permitted provided that the following conditions are met:
  15295. 1. Redistributions of source code must retain the above copyright notice,
  15296. this list of conditions, and the following disclaimer.
  15297. 2. Redistributions in binary form must reproduce the above copyright notice,
  15298. this list of conditions, and the following disclaimer in the documentation
  15299. and/or other materials provided with the distribution.
  15300. 3. Neither the name of the University nor the names of its contributors may
  15301. be used to endorse or promote products derived from this software without
  15302. specific prior written permission.
  15303. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  15304. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  15305. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  15306. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  15307. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  15308. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  15309. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  15310. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  15311. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  15312. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  15313. =============================================================================*/
  15314. #include <stdbool.h>
  15315. #include <stdint.h>
  15316. /**** skipping file: platform.h ****/
  15317. /**** skipping file: internals.h ****/
  15318. /**** skipping file: specialize.h ****/
  15319. /**** skipping file: softfloat.h ****/
  15320. int_fast64_t f64_to_i64( float64_t a, uint_fast8_t roundingMode, bool exact )
  15321. {
  15322. union ui64_f64 uA;
  15323. uint_fast64_t uiA;
  15324. bool sign;
  15325. int_fast16_t exp;
  15326. uint_fast64_t sig;
  15327. int_fast16_t shiftDist;
  15328. #ifdef SOFTFLOAT_FAST_INT64
  15329. struct uint64_extra sigExtra;
  15330. #else
  15331. uint32_t extSig[3];
  15332. #endif
  15333. /*------------------------------------------------------------------------
  15334. *------------------------------------------------------------------------*/
  15335. uA.f = a;
  15336. uiA = uA.ui;
  15337. sign = signF64UI( uiA );
  15338. exp = expF64UI( uiA );
  15339. sig = fracF64UI( uiA );
  15340. /*------------------------------------------------------------------------
  15341. *------------------------------------------------------------------------*/
  15342. if ( exp ) sig |= UINT64_C( 0x0010000000000000 );
  15343. shiftDist = 0x433 - exp;
  15344. #ifdef SOFTFLOAT_FAST_INT64
  15345. if ( shiftDist <= 0 ) {
  15346. if ( shiftDist < -11 ) goto invalid;
  15347. sigExtra.v = sig<<-shiftDist;
  15348. sigExtra.extra = 0;
  15349. } else {
  15350. sigExtra = softfloat_shiftRightJam64Extra( sig, 0, shiftDist );
  15351. }
  15352. return
  15353. softfloat_roundToI64(
  15354. sign, sigExtra.v, sigExtra.extra, roundingMode, exact );
  15355. #else
  15356. extSig[indexWord( 3, 0 )] = 0;
  15357. if ( shiftDist <= 0 ) {
  15358. if ( shiftDist < -11 ) goto invalid;
  15359. sig <<= -shiftDist;
  15360. extSig[indexWord( 3, 2 )] = sig>>32;
  15361. extSig[indexWord( 3, 1 )] = sig;
  15362. } else {
  15363. extSig[indexWord( 3, 2 )] = sig>>32;
  15364. extSig[indexWord( 3, 1 )] = sig;
  15365. softfloat_shiftRightJam96M( extSig, shiftDist, extSig );
  15366. }
  15367. return softfloat_roundMToI64( sign, extSig, roundingMode, exact );
  15368. #endif
  15369. /*------------------------------------------------------------------------
  15370. *------------------------------------------------------------------------*/
  15371. invalid:
  15372. softfloat_raiseFlags( softfloat_flag_invalid );
  15373. return
  15374. (exp == 0x7FF) && fracF64UI( uiA ) ? i64_fromNaN
  15375. : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
  15376. }
  15377. /**** ended inlining ../../source/f64_to_i64.c ****/
  15378. /**** start inlining ../../source/f64_to_ui32_r_minMag.c ****/
  15379. /*============================================================================
  15380. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  15381. Package, Release 3e, by John R. Hauser.
  15382. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  15383. California. All rights reserved.
  15384. Redistribution and use in source and binary forms, with or without
  15385. modification, are permitted provided that the following conditions are met:
  15386. 1. Redistributions of source code must retain the above copyright notice,
  15387. this list of conditions, and the following disclaimer.
  15388. 2. Redistributions in binary form must reproduce the above copyright notice,
  15389. this list of conditions, and the following disclaimer in the documentation
  15390. and/or other materials provided with the distribution.
  15391. 3. Neither the name of the University nor the names of its contributors may
  15392. be used to endorse or promote products derived from this software without
  15393. specific prior written permission.
  15394. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  15395. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  15396. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  15397. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  15398. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  15399. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  15400. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  15401. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  15402. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  15403. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  15404. =============================================================================*/
  15405. #include <stdbool.h>
  15406. #include <stdint.h>
  15407. /**** skipping file: platform.h ****/
  15408. /**** skipping file: internals.h ****/
  15409. /**** skipping file: specialize.h ****/
  15410. /**** skipping file: softfloat.h ****/
  15411. uint_fast32_t f64_to_ui32_r_minMag( float64_t a, bool exact )
  15412. {
  15413. union ui64_f64 uA;
  15414. uint_fast64_t uiA;
  15415. int_fast16_t exp;
  15416. uint_fast64_t sig;
  15417. int_fast16_t shiftDist;
  15418. bool sign;
  15419. uint_fast32_t z;
  15420. /*------------------------------------------------------------------------
  15421. *------------------------------------------------------------------------*/
  15422. uA.f = a;
  15423. uiA = uA.ui;
  15424. exp = expF64UI( uiA );
  15425. sig = fracF64UI( uiA );
  15426. /*------------------------------------------------------------------------
  15427. *------------------------------------------------------------------------*/
  15428. shiftDist = 0x433 - exp;
  15429. if ( 53 <= shiftDist ) {
  15430. if ( exact && (exp | sig) ) {
  15431. softfloat_exceptionFlags |= softfloat_flag_inexact;
  15432. }
  15433. return 0;
  15434. }
  15435. /*------------------------------------------------------------------------
  15436. *------------------------------------------------------------------------*/
  15437. sign = signF64UI( uiA );
  15438. if ( sign || (shiftDist < 21) ) {
  15439. softfloat_raiseFlags( softfloat_flag_invalid );
  15440. return
  15441. (exp == 0x7FF) && sig ? ui32_fromNaN
  15442. : sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
  15443. }
  15444. /*------------------------------------------------------------------------
  15445. *------------------------------------------------------------------------*/
  15446. sig |= UINT64_C( 0x0010000000000000 );
  15447. z = sig>>shiftDist;
  15448. if ( exact && ((uint_fast64_t) z<<shiftDist != sig) ) {
  15449. softfloat_exceptionFlags |= softfloat_flag_inexact;
  15450. }
  15451. return z;
  15452. }
  15453. /**** ended inlining ../../source/f64_to_ui32_r_minMag.c ****/
  15454. /**** start inlining ../../source/f64_to_ui64_r_minMag.c ****/
  15455. /*============================================================================
  15456. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  15457. Package, Release 3e, by John R. Hauser.
  15458. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  15459. California. All rights reserved.
  15460. Redistribution and use in source and binary forms, with or without
  15461. modification, are permitted provided that the following conditions are met:
  15462. 1. Redistributions of source code must retain the above copyright notice,
  15463. this list of conditions, and the following disclaimer.
  15464. 2. Redistributions in binary form must reproduce the above copyright notice,
  15465. this list of conditions, and the following disclaimer in the documentation
  15466. and/or other materials provided with the distribution.
  15467. 3. Neither the name of the University nor the names of its contributors may
  15468. be used to endorse or promote products derived from this software without
  15469. specific prior written permission.
  15470. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  15471. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  15472. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  15473. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  15474. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  15475. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  15476. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  15477. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  15478. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  15479. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  15480. =============================================================================*/
  15481. #include <stdbool.h>
  15482. #include <stdint.h>
  15483. /**** skipping file: platform.h ****/
  15484. /**** skipping file: internals.h ****/
  15485. /**** skipping file: specialize.h ****/
  15486. /**** skipping file: softfloat.h ****/
  15487. uint_fast64_t f64_to_ui64_r_minMag( float64_t a, bool exact )
  15488. {
  15489. union ui64_f64 uA;
  15490. uint_fast64_t uiA;
  15491. int_fast16_t exp;
  15492. uint_fast64_t sig;
  15493. int_fast16_t shiftDist;
  15494. bool sign;
  15495. uint_fast64_t z;
  15496. /*------------------------------------------------------------------------
  15497. *------------------------------------------------------------------------*/
  15498. uA.f = a;
  15499. uiA = uA.ui;
  15500. exp = expF64UI( uiA );
  15501. sig = fracF64UI( uiA );
  15502. /*------------------------------------------------------------------------
  15503. *------------------------------------------------------------------------*/
  15504. shiftDist = 0x433 - exp;
  15505. if ( 53 <= shiftDist ) {
  15506. if ( exact && (exp | sig) ) {
  15507. softfloat_exceptionFlags |= softfloat_flag_inexact;
  15508. }
  15509. return 0;
  15510. }
  15511. /*------------------------------------------------------------------------
  15512. *------------------------------------------------------------------------*/
  15513. sign = signF64UI( uiA );
  15514. if ( sign ) goto invalid;
  15515. if ( shiftDist <= 0 ) {
  15516. if ( shiftDist < -11 ) goto invalid;
  15517. z = (sig | UINT64_C( 0x0010000000000000 ))<<-shiftDist;
  15518. } else {
  15519. sig |= UINT64_C( 0x0010000000000000 );
  15520. z = sig>>shiftDist;
  15521. if ( exact && (uint64_t) (sig<<(-shiftDist & 63)) ) {
  15522. softfloat_exceptionFlags |= softfloat_flag_inexact;
  15523. }
  15524. }
  15525. return z;
  15526. /*------------------------------------------------------------------------
  15527. *------------------------------------------------------------------------*/
  15528. invalid:
  15529. softfloat_raiseFlags( softfloat_flag_invalid );
  15530. return
  15531. (exp == 0x7FF) && sig ? ui64_fromNaN
  15532. : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
  15533. }
  15534. /**** ended inlining ../../source/f64_to_ui64_r_minMag.c ****/
  15535. /**** start inlining ../../source/f64_to_i32_r_minMag.c ****/
  15536. /*============================================================================
  15537. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  15538. Package, Release 3e, by John R. Hauser.
  15539. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  15540. California. All rights reserved.
  15541. Redistribution and use in source and binary forms, with or without
  15542. modification, are permitted provided that the following conditions are met:
  15543. 1. Redistributions of source code must retain the above copyright notice,
  15544. this list of conditions, and the following disclaimer.
  15545. 2. Redistributions in binary form must reproduce the above copyright notice,
  15546. this list of conditions, and the following disclaimer in the documentation
  15547. and/or other materials provided with the distribution.
  15548. 3. Neither the name of the University nor the names of its contributors may
  15549. be used to endorse or promote products derived from this software without
  15550. specific prior written permission.
  15551. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  15552. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  15553. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  15554. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  15555. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  15556. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  15557. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  15558. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  15559. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  15560. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  15561. =============================================================================*/
  15562. #include <stdbool.h>
  15563. #include <stdint.h>
  15564. /**** skipping file: platform.h ****/
  15565. /**** skipping file: internals.h ****/
  15566. /**** skipping file: specialize.h ****/
  15567. /**** skipping file: softfloat.h ****/
  15568. int_fast32_t f64_to_i32_r_minMag( float64_t a, bool exact )
  15569. {
  15570. union ui64_f64 uA;
  15571. uint_fast64_t uiA;
  15572. int_fast16_t exp;
  15573. uint_fast64_t sig;
  15574. int_fast16_t shiftDist;
  15575. bool sign;
  15576. int_fast32_t absZ;
  15577. /*------------------------------------------------------------------------
  15578. *------------------------------------------------------------------------*/
  15579. uA.f = a;
  15580. uiA = uA.ui;
  15581. exp = expF64UI( uiA );
  15582. sig = fracF64UI( uiA );
  15583. /*------------------------------------------------------------------------
  15584. *------------------------------------------------------------------------*/
  15585. shiftDist = 0x433 - exp;
  15586. if ( 53 <= shiftDist ) {
  15587. if ( exact && (exp | sig) ) {
  15588. softfloat_exceptionFlags |= softfloat_flag_inexact;
  15589. }
  15590. return 0;
  15591. }
  15592. /*------------------------------------------------------------------------
  15593. *------------------------------------------------------------------------*/
  15594. sign = signF64UI( uiA );
  15595. if ( shiftDist < 22 ) {
  15596. if (
  15597. sign && (exp == 0x41E) && (sig < UINT64_C( 0x0000000000200000 ))
  15598. ) {
  15599. if ( exact && sig ) {
  15600. softfloat_exceptionFlags |= softfloat_flag_inexact;
  15601. }
  15602. return -0x7FFFFFFF - 1;
  15603. }
  15604. softfloat_raiseFlags( softfloat_flag_invalid );
  15605. return
  15606. (exp == 0x7FF) && sig ? i32_fromNaN
  15607. : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
  15608. }
  15609. /*------------------------------------------------------------------------
  15610. *------------------------------------------------------------------------*/
  15611. sig |= UINT64_C( 0x0010000000000000 );
  15612. absZ = sig>>shiftDist;
  15613. if ( exact && ((uint_fast64_t) (uint_fast32_t) absZ<<shiftDist != sig) ) {
  15614. softfloat_exceptionFlags |= softfloat_flag_inexact;
  15615. }
  15616. return sign ? -absZ : absZ;
  15617. }
  15618. /**** ended inlining ../../source/f64_to_i32_r_minMag.c ****/
  15619. /**** start inlining ../../source/f64_to_i64_r_minMag.c ****/
  15620. /*============================================================================
  15621. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  15622. Package, Release 3e, by John R. Hauser.
  15623. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  15624. California. All rights reserved.
  15625. Redistribution and use in source and binary forms, with or without
  15626. modification, are permitted provided that the following conditions are met:
  15627. 1. Redistributions of source code must retain the above copyright notice,
  15628. this list of conditions, and the following disclaimer.
  15629. 2. Redistributions in binary form must reproduce the above copyright notice,
  15630. this list of conditions, and the following disclaimer in the documentation
  15631. and/or other materials provided with the distribution.
  15632. 3. Neither the name of the University nor the names of its contributors may
  15633. be used to endorse or promote products derived from this software without
  15634. specific prior written permission.
  15635. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  15636. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  15637. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  15638. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  15639. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  15640. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  15641. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  15642. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  15643. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  15644. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  15645. =============================================================================*/
  15646. #include <stdbool.h>
  15647. #include <stdint.h>
  15648. /**** skipping file: platform.h ****/
  15649. /**** skipping file: internals.h ****/
  15650. /**** skipping file: specialize.h ****/
  15651. /**** skipping file: softfloat.h ****/
  15652. int_fast64_t f64_to_i64_r_minMag( float64_t a, bool exact )
  15653. {
  15654. union ui64_f64 uA;
  15655. uint_fast64_t uiA;
  15656. bool sign;
  15657. int_fast16_t exp;
  15658. uint_fast64_t sig;
  15659. int_fast16_t shiftDist;
  15660. int_fast64_t absZ;
  15661. /*------------------------------------------------------------------------
  15662. *------------------------------------------------------------------------*/
  15663. uA.f = a;
  15664. uiA = uA.ui;
  15665. sign = signF64UI( uiA );
  15666. exp = expF64UI( uiA );
  15667. sig = fracF64UI( uiA );
  15668. /*------------------------------------------------------------------------
  15669. *------------------------------------------------------------------------*/
  15670. shiftDist = 0x433 - exp;
  15671. if ( shiftDist <= 0 ) {
  15672. /*--------------------------------------------------------------------
  15673. *--------------------------------------------------------------------*/
  15674. if ( shiftDist < -10 ) {
  15675. if ( uiA == packToF64UI( 1, 0x43E, 0 ) ) {
  15676. return -INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1;
  15677. }
  15678. softfloat_raiseFlags( softfloat_flag_invalid );
  15679. return
  15680. (exp == 0x7FF) && sig ? i64_fromNaN
  15681. : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
  15682. }
  15683. /*--------------------------------------------------------------------
  15684. *--------------------------------------------------------------------*/
  15685. sig |= UINT64_C( 0x0010000000000000 );
  15686. absZ = sig<<-shiftDist;
  15687. } else {
  15688. /*--------------------------------------------------------------------
  15689. *--------------------------------------------------------------------*/
  15690. if ( 53 <= shiftDist ) {
  15691. if ( exact && (exp | sig) ) {
  15692. softfloat_exceptionFlags |= softfloat_flag_inexact;
  15693. }
  15694. return 0;
  15695. }
  15696. /*--------------------------------------------------------------------
  15697. *--------------------------------------------------------------------*/
  15698. sig |= UINT64_C( 0x0010000000000000 );
  15699. absZ = sig>>shiftDist;
  15700. if ( exact && (absZ<<shiftDist != sig) ) {
  15701. softfloat_exceptionFlags |= softfloat_flag_inexact;
  15702. }
  15703. }
  15704. return sign ? -absZ : absZ;
  15705. }
  15706. /**** ended inlining ../../source/f64_to_i64_r_minMag.c ****/
  15707. /**** start inlining ../../source/f64_to_f16.c ****/
  15708. /*============================================================================
  15709. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  15710. Package, Release 3e, by John R. Hauser.
  15711. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  15712. California. All rights reserved.
  15713. Redistribution and use in source and binary forms, with or without
  15714. modification, are permitted provided that the following conditions are met:
  15715. 1. Redistributions of source code must retain the above copyright notice,
  15716. this list of conditions, and the following disclaimer.
  15717. 2. Redistributions in binary form must reproduce the above copyright notice,
  15718. this list of conditions, and the following disclaimer in the documentation
  15719. and/or other materials provided with the distribution.
  15720. 3. Neither the name of the University nor the names of its contributors may
  15721. be used to endorse or promote products derived from this software without
  15722. specific prior written permission.
  15723. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  15724. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  15725. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  15726. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  15727. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  15728. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  15729. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  15730. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  15731. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  15732. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  15733. =============================================================================*/
  15734. #include <stdbool.h>
  15735. #include <stdint.h>
  15736. /**** skipping file: platform.h ****/
  15737. /**** skipping file: internals.h ****/
  15738. /**** skipping file: specialize.h ****/
  15739. /**** skipping file: softfloat.h ****/
  15740. float16_t f64_to_f16( float64_t a )
  15741. {
  15742. union ui64_f64 uA;
  15743. uint_fast64_t uiA;
  15744. bool sign;
  15745. int_fast16_t exp;
  15746. uint_fast64_t frac;
  15747. struct commonNaN commonNaN;
  15748. uint_fast16_t uiZ, frac16;
  15749. union ui16_f16 uZ;
  15750. /*------------------------------------------------------------------------
  15751. *------------------------------------------------------------------------*/
  15752. uA.f = a;
  15753. uiA = uA.ui;
  15754. sign = signF64UI( uiA );
  15755. exp = expF64UI( uiA );
  15756. frac = fracF64UI( uiA );
  15757. /*------------------------------------------------------------------------
  15758. *------------------------------------------------------------------------*/
  15759. if ( exp == 0x7FF ) {
  15760. if ( frac ) {
  15761. softfloat_f64UIToCommonNaN( uiA, &commonNaN );
  15762. uiZ = softfloat_commonNaNToF16UI( &commonNaN );
  15763. } else {
  15764. uiZ = packToF16UI( sign, 0x1F, 0 );
  15765. }
  15766. goto uiZ;
  15767. }
  15768. /*------------------------------------------------------------------------
  15769. *------------------------------------------------------------------------*/
  15770. frac16 = softfloat_shortShiftRightJam64( frac, 38 );
  15771. if ( ! (exp | frac16) ) {
  15772. uiZ = packToF16UI( sign, 0, 0 );
  15773. goto uiZ;
  15774. }
  15775. /*------------------------------------------------------------------------
  15776. *------------------------------------------------------------------------*/
  15777. return softfloat_roundPackToF16( sign, exp - 0x3F1, frac16 | 0x4000 );
  15778. uiZ:
  15779. uZ.ui = uiZ;
  15780. return uZ.f;
  15781. }
  15782. /**** ended inlining ../../source/f64_to_f16.c ****/
  15783. /**** start inlining ../../source/f64_to_f32.c ****/
  15784. /*============================================================================
  15785. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  15786. Package, Release 3e, by John R. Hauser.
  15787. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  15788. California. All rights reserved.
  15789. Redistribution and use in source and binary forms, with or without
  15790. modification, are permitted provided that the following conditions are met:
  15791. 1. Redistributions of source code must retain the above copyright notice,
  15792. this list of conditions, and the following disclaimer.
  15793. 2. Redistributions in binary form must reproduce the above copyright notice,
  15794. this list of conditions, and the following disclaimer in the documentation
  15795. and/or other materials provided with the distribution.
  15796. 3. Neither the name of the University nor the names of its contributors may
  15797. be used to endorse or promote products derived from this software without
  15798. specific prior written permission.
  15799. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  15800. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  15801. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  15802. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  15803. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  15804. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  15805. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  15806. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  15807. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  15808. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  15809. =============================================================================*/
  15810. #include <stdbool.h>
  15811. #include <stdint.h>
  15812. /**** skipping file: platform.h ****/
  15813. /**** skipping file: internals.h ****/
  15814. /**** skipping file: specialize.h ****/
  15815. /**** skipping file: softfloat.h ****/
  15816. float32_t f64_to_f32( float64_t a )
  15817. {
  15818. union ui64_f64 uA;
  15819. uint_fast64_t uiA;
  15820. bool sign;
  15821. int_fast16_t exp;
  15822. uint_fast64_t frac;
  15823. struct commonNaN commonNaN;
  15824. uint_fast32_t uiZ, frac32;
  15825. union ui32_f32 uZ;
  15826. /*------------------------------------------------------------------------
  15827. *------------------------------------------------------------------------*/
  15828. uA.f = a;
  15829. uiA = uA.ui;
  15830. sign = signF64UI( uiA );
  15831. exp = expF64UI( uiA );
  15832. frac = fracF64UI( uiA );
  15833. /*------------------------------------------------------------------------
  15834. *------------------------------------------------------------------------*/
  15835. if ( exp == 0x7FF ) {
  15836. if ( frac ) {
  15837. softfloat_f64UIToCommonNaN( uiA, &commonNaN );
  15838. uiZ = softfloat_commonNaNToF32UI( &commonNaN );
  15839. } else {
  15840. uiZ = packToF32UI( sign, 0xFF, 0 );
  15841. }
  15842. goto uiZ;
  15843. }
  15844. /*------------------------------------------------------------------------
  15845. *------------------------------------------------------------------------*/
  15846. frac32 = softfloat_shortShiftRightJam64( frac, 22 );
  15847. if ( ! (exp | frac32) ) {
  15848. uiZ = packToF32UI( sign, 0, 0 );
  15849. goto uiZ;
  15850. }
  15851. /*------------------------------------------------------------------------
  15852. *------------------------------------------------------------------------*/
  15853. return softfloat_roundPackToF32( sign, exp - 0x381, frac32 | 0x40000000 );
  15854. uiZ:
  15855. uZ.ui = uiZ;
  15856. return uZ.f;
  15857. }
  15858. /**** ended inlining ../../source/f64_to_f32.c ****/
  15859. /**** start inlining ../../source/f64_to_extF80.c ****/
  15860. /*============================================================================
  15861. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  15862. Package, Release 3e, by John R. Hauser.
  15863. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  15864. California. All rights reserved.
  15865. Redistribution and use in source and binary forms, with or without
  15866. modification, are permitted provided that the following conditions are met:
  15867. 1. Redistributions of source code must retain the above copyright notice,
  15868. this list of conditions, and the following disclaimer.
  15869. 2. Redistributions in binary form must reproduce the above copyright notice,
  15870. this list of conditions, and the following disclaimer in the documentation
  15871. and/or other materials provided with the distribution.
  15872. 3. Neither the name of the University nor the names of its contributors may
  15873. be used to endorse or promote products derived from this software without
  15874. specific prior written permission.
  15875. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  15876. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  15877. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  15878. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  15879. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  15880. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  15881. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  15882. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  15883. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  15884. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  15885. =============================================================================*/
  15886. #include <stdbool.h>
  15887. #include <stdint.h>
  15888. /**** skipping file: platform.h ****/
  15889. /**** skipping file: internals.h ****/
  15890. /**** skipping file: specialize.h ****/
  15891. /**** skipping file: softfloat.h ****/
  15892. extFloat80_t f64_to_extF80( float64_t a )
  15893. {
  15894. union ui64_f64 uA;
  15895. uint_fast64_t uiA;
  15896. bool sign;
  15897. int_fast16_t exp;
  15898. uint_fast64_t frac;
  15899. struct commonNaN commonNaN;
  15900. struct uint128 uiZ;
  15901. uint_fast16_t uiZ64;
  15902. uint_fast64_t uiZ0;
  15903. struct exp16_sig64 normExpSig;
  15904. union { struct extFloat80M s; extFloat80_t f; } uZ;
  15905. /*------------------------------------------------------------------------
  15906. *------------------------------------------------------------------------*/
  15907. uA.f = a;
  15908. uiA = uA.ui;
  15909. sign = signF64UI( uiA );
  15910. exp = expF64UI( uiA );
  15911. frac = fracF64UI( uiA );
  15912. /*------------------------------------------------------------------------
  15913. *------------------------------------------------------------------------*/
  15914. if ( exp == 0x7FF ) {
  15915. if ( frac ) {
  15916. softfloat_f64UIToCommonNaN( uiA, &commonNaN );
  15917. uiZ = softfloat_commonNaNToExtF80UI( &commonNaN );
  15918. uiZ64 = uiZ.v64;
  15919. uiZ0 = uiZ.v0;
  15920. } else {
  15921. uiZ64 = packToExtF80UI64( sign, 0x7FFF );
  15922. uiZ0 = UINT64_C( 0x8000000000000000 );
  15923. }
  15924. goto uiZ;
  15925. }
  15926. /*------------------------------------------------------------------------
  15927. *------------------------------------------------------------------------*/
  15928. if ( ! exp ) {
  15929. if ( ! frac ) {
  15930. uiZ64 = packToExtF80UI64( sign, 0 );
  15931. uiZ0 = 0;
  15932. goto uiZ;
  15933. }
  15934. normExpSig = softfloat_normSubnormalF64Sig( frac );
  15935. exp = normExpSig.exp;
  15936. frac = normExpSig.sig;
  15937. }
  15938. /*------------------------------------------------------------------------
  15939. *------------------------------------------------------------------------*/
  15940. uiZ64 = packToExtF80UI64( sign, exp + 0x3C00 );
  15941. uiZ0 = (frac | UINT64_C( 0x0010000000000000 ))<<11;
  15942. uiZ:
  15943. uZ.s.signExp = uiZ64;
  15944. uZ.s.signif = uiZ0;
  15945. return uZ.f;
  15946. }
  15947. /**** ended inlining ../../source/f64_to_extF80.c ****/
  15948. /**** start inlining ../../source/f64_to_extF80M.c ****/
  15949. /*============================================================================
  15950. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  15951. Package, Release 3e, by John R. Hauser.
  15952. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  15953. California. All rights reserved.
  15954. Redistribution and use in source and binary forms, with or without
  15955. modification, are permitted provided that the following conditions are met:
  15956. 1. Redistributions of source code must retain the above copyright notice,
  15957. this list of conditions, and the following disclaimer.
  15958. 2. Redistributions in binary form must reproduce the above copyright notice,
  15959. this list of conditions, and the following disclaimer in the documentation
  15960. and/or other materials provided with the distribution.
  15961. 3. Neither the name of the University nor the names of its contributors may
  15962. be used to endorse or promote products derived from this software without
  15963. specific prior written permission.
  15964. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  15965. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  15966. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  15967. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  15968. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  15969. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  15970. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  15971. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  15972. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  15973. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  15974. =============================================================================*/
  15975. #include <stdbool.h>
  15976. #include <stdint.h>
  15977. /**** skipping file: platform.h ****/
  15978. /**** skipping file: internals.h ****/
  15979. /**** skipping file: specialize.h ****/
  15980. /**** skipping file: softfloat.h ****/
  15981. #ifdef SOFTFLOAT_FAST_INT64
  15982. void f64_to_extF80M( float64_t a, extFloat80_t *zPtr )
  15983. {
  15984. *zPtr = f64_to_extF80( a );
  15985. }
  15986. #else
  15987. void f64_to_extF80M( float64_t a, extFloat80_t *zPtr )
  15988. {
  15989. struct extFloat80M *zSPtr;
  15990. union ui64_f64 uA;
  15991. uint64_t uiA;
  15992. bool sign;
  15993. int_fast16_t exp;
  15994. uint64_t frac;
  15995. struct commonNaN commonNaN;
  15996. uint_fast16_t uiZ64;
  15997. uint64_t uiZ0;
  15998. struct exp16_sig64 normExpSig;
  15999. /*------------------------------------------------------------------------
  16000. *------------------------------------------------------------------------*/
  16001. zSPtr = (struct extFloat80M *) zPtr;
  16002. uA.f = a;
  16003. uiA = uA.ui;
  16004. sign = signF64UI( uiA );
  16005. exp = expF64UI( uiA );
  16006. frac = fracF64UI( uiA );
  16007. /*------------------------------------------------------------------------
  16008. *------------------------------------------------------------------------*/
  16009. if ( exp == 0x7FF ) {
  16010. if ( frac ) {
  16011. softfloat_f64UIToCommonNaN( uiA, &commonNaN );
  16012. softfloat_commonNaNToExtF80M( &commonNaN, zSPtr );
  16013. return;
  16014. }
  16015. uiZ64 = packToExtF80UI64( sign, 0x7FFF );
  16016. uiZ0 = UINT64_C( 0x8000000000000000 );
  16017. goto uiZ;
  16018. }
  16019. /*------------------------------------------------------------------------
  16020. *------------------------------------------------------------------------*/
  16021. if ( ! exp ) {
  16022. if ( ! frac ) {
  16023. uiZ64 = packToExtF80UI64( sign, 0 );
  16024. uiZ0 = 0;
  16025. goto uiZ;
  16026. }
  16027. normExpSig = softfloat_normSubnormalF64Sig( frac );
  16028. exp = normExpSig.exp;
  16029. frac = normExpSig.sig;
  16030. }
  16031. /*------------------------------------------------------------------------
  16032. *------------------------------------------------------------------------*/
  16033. uiZ64 = packToExtF80UI64( sign, exp + 0x3C00 );
  16034. uiZ0 = UINT64_C( 0x8000000000000000 ) | frac<<11;
  16035. uiZ:
  16036. zSPtr->signExp = uiZ64;
  16037. zSPtr->signif = uiZ0;
  16038. }
  16039. #endif
  16040. /**** ended inlining ../../source/f64_to_extF80M.c ****/
  16041. /**** start inlining ../../source/f64_to_f128.c ****/
  16042. /*============================================================================
  16043. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  16044. Package, Release 3e, by John R. Hauser.
  16045. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  16046. California. All rights reserved.
  16047. Redistribution and use in source and binary forms, with or without
  16048. modification, are permitted provided that the following conditions are met:
  16049. 1. Redistributions of source code must retain the above copyright notice,
  16050. this list of conditions, and the following disclaimer.
  16051. 2. Redistributions in binary form must reproduce the above copyright notice,
  16052. this list of conditions, and the following disclaimer in the documentation
  16053. and/or other materials provided with the distribution.
  16054. 3. Neither the name of the University nor the names of its contributors may
  16055. be used to endorse or promote products derived from this software without
  16056. specific prior written permission.
  16057. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  16058. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16059. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  16060. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  16061. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  16062. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  16063. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  16064. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  16065. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  16066. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16067. =============================================================================*/
  16068. #include <stdbool.h>
  16069. #include <stdint.h>
  16070. /**** skipping file: platform.h ****/
  16071. /**** skipping file: internals.h ****/
  16072. /**** skipping file: specialize.h ****/
  16073. /**** skipping file: softfloat.h ****/
  16074. float128_t f64_to_f128( float64_t a )
  16075. {
  16076. union ui64_f64 uA;
  16077. uint_fast64_t uiA;
  16078. bool sign;
  16079. int_fast16_t exp;
  16080. uint_fast64_t frac;
  16081. struct commonNaN commonNaN;
  16082. struct uint128 uiZ;
  16083. struct exp16_sig64 normExpSig;
  16084. struct uint128 frac128;
  16085. union ui128_f128 uZ;
  16086. /*------------------------------------------------------------------------
  16087. *------------------------------------------------------------------------*/
  16088. uA.f = a;
  16089. uiA = uA.ui;
  16090. sign = signF64UI( uiA );
  16091. exp = expF64UI( uiA );
  16092. frac = fracF64UI( uiA );
  16093. /*------------------------------------------------------------------------
  16094. *------------------------------------------------------------------------*/
  16095. if ( exp == 0x7FF ) {
  16096. if ( frac ) {
  16097. softfloat_f64UIToCommonNaN( uiA, &commonNaN );
  16098. uiZ = softfloat_commonNaNToF128UI( &commonNaN );
  16099. } else {
  16100. uiZ.v64 = packToF128UI64( sign, 0x7FFF, 0 );
  16101. uiZ.v0 = 0;
  16102. }
  16103. goto uiZ;
  16104. }
  16105. /*------------------------------------------------------------------------
  16106. *------------------------------------------------------------------------*/
  16107. if ( ! exp ) {
  16108. if ( ! frac ) {
  16109. uiZ.v64 = packToF128UI64( sign, 0, 0 );
  16110. uiZ.v0 = 0;
  16111. goto uiZ;
  16112. }
  16113. normExpSig = softfloat_normSubnormalF64Sig( frac );
  16114. exp = normExpSig.exp - 1;
  16115. frac = normExpSig.sig;
  16116. }
  16117. /*------------------------------------------------------------------------
  16118. *------------------------------------------------------------------------*/
  16119. frac128 = softfloat_shortShiftLeft128( 0, frac, 60 );
  16120. uiZ.v64 = packToF128UI64( sign, exp + 0x3C00, frac128.v64 );
  16121. uiZ.v0 = frac128.v0;
  16122. uiZ:
  16123. uZ.ui = uiZ;
  16124. return uZ.f;
  16125. }
  16126. /**** ended inlining ../../source/f64_to_f128.c ****/
  16127. /**** start inlining ../../source/f64_to_f128M.c ****/
  16128. /*============================================================================
  16129. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  16130. Package, Release 3e, by John R. Hauser.
  16131. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  16132. All rights reserved.
  16133. Redistribution and use in source and binary forms, with or without
  16134. modification, are permitted provided that the following conditions are met:
  16135. 1. Redistributions of source code must retain the above copyright notice,
  16136. this list of conditions, and the following disclaimer.
  16137. 2. Redistributions in binary form must reproduce the above copyright notice,
  16138. this list of conditions, and the following disclaimer in the documentation
  16139. and/or other materials provided with the distribution.
  16140. 3. Neither the name of the University nor the names of its contributors may
  16141. be used to endorse or promote products derived from this software without
  16142. specific prior written permission.
  16143. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  16144. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16145. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  16146. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  16147. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  16148. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  16149. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  16150. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  16151. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  16152. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16153. =============================================================================*/
  16154. #include <stdbool.h>
  16155. #include <stdint.h>
  16156. /**** skipping file: platform.h ****/
  16157. /**** skipping file: internals.h ****/
  16158. /**** skipping file: specialize.h ****/
  16159. /**** skipping file: softfloat.h ****/
  16160. #ifdef SOFTFLOAT_FAST_INT64
  16161. void f64_to_f128M( float64_t a, float128_t *zPtr )
  16162. {
  16163. *zPtr = f64_to_f128( a );
  16164. }
  16165. #else
  16166. void f64_to_f128M( float64_t a, float128_t *zPtr )
  16167. {
  16168. uint32_t *zWPtr;
  16169. union ui64_f64 uA;
  16170. uint64_t uiA;
  16171. bool sign;
  16172. int_fast16_t exp;
  16173. uint64_t frac;
  16174. struct commonNaN commonNaN;
  16175. uint32_t uiZ96;
  16176. struct exp16_sig64 normExpSig;
  16177. /*------------------------------------------------------------------------
  16178. *------------------------------------------------------------------------*/
  16179. zWPtr = (uint32_t *) zPtr;
  16180. /*------------------------------------------------------------------------
  16181. *------------------------------------------------------------------------*/
  16182. uA.f = a;
  16183. uiA = uA.ui;
  16184. sign = signF64UI( uiA );
  16185. exp = expF64UI( uiA );
  16186. frac = fracF64UI( uiA );
  16187. /*------------------------------------------------------------------------
  16188. *------------------------------------------------------------------------*/
  16189. zWPtr[indexWord( 4, 0 )] = 0;
  16190. if ( exp == 0x7FF ) {
  16191. if ( frac ) {
  16192. softfloat_f64UIToCommonNaN( uiA, &commonNaN );
  16193. softfloat_commonNaNToF128M( &commonNaN, zWPtr );
  16194. return;
  16195. }
  16196. uiZ96 = packToF128UI96( sign, 0x7FFF, 0 );
  16197. goto uiZ;
  16198. }
  16199. /*------------------------------------------------------------------------
  16200. *------------------------------------------------------------------------*/
  16201. if ( ! exp ) {
  16202. if ( ! frac ) {
  16203. uiZ96 = packToF128UI96( sign, 0, 0 );
  16204. goto uiZ;
  16205. }
  16206. normExpSig = softfloat_normSubnormalF64Sig( frac );
  16207. exp = normExpSig.exp - 1;
  16208. frac = normExpSig.sig;
  16209. }
  16210. /*------------------------------------------------------------------------
  16211. *------------------------------------------------------------------------*/
  16212. zWPtr[indexWord( 4, 1 )] = (uint32_t) frac<<28;
  16213. frac >>= 4;
  16214. zWPtr[indexWordHi( 4 )] = packToF128UI96( sign, exp + 0x3C00, frac>>32 );
  16215. zWPtr[indexWord( 4, 2 )] = frac;
  16216. return;
  16217. /*------------------------------------------------------------------------
  16218. *------------------------------------------------------------------------*/
  16219. uiZ:
  16220. zWPtr[indexWord( 4, 3 )] = uiZ96;
  16221. zWPtr[indexWord( 4, 2 )] = 0;
  16222. zWPtr[indexWord( 4, 1 )] = 0;
  16223. }
  16224. #endif
  16225. /**** ended inlining ../../source/f64_to_f128M.c ****/
  16226. /**** start inlining ../../source/f64_roundToInt.c ****/
  16227. /*============================================================================
  16228. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  16229. Package, Release 3e, by John R. Hauser.
  16230. Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
  16231. California. All rights reserved.
  16232. Redistribution and use in source and binary forms, with or without
  16233. modification, are permitted provided that the following conditions are met:
  16234. 1. Redistributions of source code must retain the above copyright notice,
  16235. this list of conditions, and the following disclaimer.
  16236. 2. Redistributions in binary form must reproduce the above copyright notice,
  16237. this list of conditions, and the following disclaimer in the documentation
  16238. and/or other materials provided with the distribution.
  16239. 3. Neither the name of the University nor the names of its contributors may
  16240. be used to endorse or promote products derived from this software without
  16241. specific prior written permission.
  16242. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  16243. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16244. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  16245. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  16246. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  16247. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  16248. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  16249. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  16250. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  16251. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16252. =============================================================================*/
  16253. #include <stdbool.h>
  16254. #include <stdint.h>
  16255. /**** skipping file: platform.h ****/
  16256. /**** skipping file: internals.h ****/
  16257. /**** skipping file: specialize.h ****/
  16258. /**** skipping file: softfloat.h ****/
  16259. float64_t f64_roundToInt( float64_t a, uint_fast8_t roundingMode, bool exact )
  16260. {
  16261. union ui64_f64 uA;
  16262. uint_fast64_t uiA;
  16263. int_fast16_t exp;
  16264. uint_fast64_t uiZ, lastBitMask, roundBitsMask;
  16265. union ui64_f64 uZ;
  16266. /*------------------------------------------------------------------------
  16267. *------------------------------------------------------------------------*/
  16268. uA.f = a;
  16269. uiA = uA.ui;
  16270. exp = expF64UI( uiA );
  16271. /*------------------------------------------------------------------------
  16272. *------------------------------------------------------------------------*/
  16273. if ( exp <= 0x3FE ) {
  16274. if ( !(uiA & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ) return a;
  16275. if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
  16276. uiZ = uiA & packToF64UI( 1, 0, 0 );
  16277. switch ( roundingMode ) {
  16278. case softfloat_round_near_even:
  16279. if ( !fracF64UI( uiA ) ) break;
  16280. case softfloat_round_near_maxMag:
  16281. if ( exp == 0x3FE ) uiZ |= packToF64UI( 0, 0x3FF, 0 );
  16282. break;
  16283. case softfloat_round_min:
  16284. if ( uiZ ) uiZ = packToF64UI( 1, 0x3FF, 0 );
  16285. break;
  16286. case softfloat_round_max:
  16287. if ( !uiZ ) uiZ = packToF64UI( 0, 0x3FF, 0 );
  16288. break;
  16289. #ifdef SOFTFLOAT_ROUND_ODD
  16290. case softfloat_round_odd:
  16291. uiZ |= packToF64UI( 0, 0x3FF, 0 );
  16292. break;
  16293. #endif
  16294. }
  16295. goto uiZ;
  16296. }
  16297. /*------------------------------------------------------------------------
  16298. *------------------------------------------------------------------------*/
  16299. if ( 0x433 <= exp ) {
  16300. if ( (exp == 0x7FF) && fracF64UI( uiA ) ) {
  16301. uiZ = softfloat_propagateNaNF64UI( uiA, 0 );
  16302. goto uiZ;
  16303. }
  16304. return a;
  16305. }
  16306. /*------------------------------------------------------------------------
  16307. *------------------------------------------------------------------------*/
  16308. uiZ = uiA;
  16309. lastBitMask = (uint_fast64_t) 1<<(0x433 - exp);
  16310. roundBitsMask = lastBitMask - 1;
  16311. if ( roundingMode == softfloat_round_near_maxMag ) {
  16312. uiZ += lastBitMask>>1;
  16313. } else if ( roundingMode == softfloat_round_near_even ) {
  16314. uiZ += lastBitMask>>1;
  16315. if ( !(uiZ & roundBitsMask) ) uiZ &= ~lastBitMask;
  16316. } else if (
  16317. roundingMode
  16318. == (signF64UI( uiZ ) ? softfloat_round_min : softfloat_round_max)
  16319. ) {
  16320. uiZ += roundBitsMask;
  16321. }
  16322. uiZ &= ~roundBitsMask;
  16323. if ( uiZ != uiA ) {
  16324. #ifdef SOFTFLOAT_ROUND_ODD
  16325. if ( roundingMode == softfloat_round_odd ) uiZ |= lastBitMask;
  16326. #endif
  16327. if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
  16328. }
  16329. uiZ:
  16330. uZ.ui = uiZ;
  16331. return uZ.f;
  16332. }
  16333. /**** ended inlining ../../source/f64_roundToInt.c ****/
  16334. /**** start inlining ../../source/f64_add.c ****/
  16335. /*============================================================================
  16336. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  16337. Package, Release 3e, by John R. Hauser.
  16338. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  16339. All rights reserved.
  16340. Redistribution and use in source and binary forms, with or without
  16341. modification, are permitted provided that the following conditions are met:
  16342. 1. Redistributions of source code must retain the above copyright notice,
  16343. this list of conditions, and the following disclaimer.
  16344. 2. Redistributions in binary form must reproduce the above copyright notice,
  16345. this list of conditions, and the following disclaimer in the documentation
  16346. and/or other materials provided with the distribution.
  16347. 3. Neither the name of the University nor the names of its contributors may
  16348. be used to endorse or promote products derived from this software without
  16349. specific prior written permission.
  16350. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  16351. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16352. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  16353. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  16354. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  16355. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  16356. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  16357. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  16358. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  16359. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16360. =============================================================================*/
  16361. #include <stdbool.h>
  16362. #include <stdint.h>
  16363. /**** skipping file: platform.h ****/
  16364. /**** skipping file: internals.h ****/
  16365. /**** skipping file: softfloat.h ****/
  16366. float64_t f64_add( float64_t a, float64_t b )
  16367. {
  16368. union ui64_f64 uA;
  16369. uint_fast64_t uiA;
  16370. bool signA;
  16371. union ui64_f64 uB;
  16372. uint_fast64_t uiB;
  16373. bool signB;
  16374. #if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
  16375. float64_t (*magsFuncPtr)( uint_fast64_t, uint_fast64_t, bool );
  16376. #endif
  16377. uA.f = a;
  16378. uiA = uA.ui;
  16379. signA = signF64UI( uiA );
  16380. uB.f = b;
  16381. uiB = uB.ui;
  16382. signB = signF64UI( uiB );
  16383. #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
  16384. if ( signA == signB ) {
  16385. return softfloat_addMagsF64( uiA, uiB, signA );
  16386. } else {
  16387. return softfloat_subMagsF64( uiA, uiB, signA );
  16388. }
  16389. #else
  16390. magsFuncPtr =
  16391. (signA == signB) ? softfloat_addMagsF64 : softfloat_subMagsF64;
  16392. return (*magsFuncPtr)( uiA, uiB, signA );
  16393. #endif
  16394. }
  16395. /**** ended inlining ../../source/f64_add.c ****/
  16396. /**** start inlining ../../source/f64_sub.c ****/
  16397. /*============================================================================
  16398. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  16399. Package, Release 3e, by John R. Hauser.
  16400. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  16401. All rights reserved.
  16402. Redistribution and use in source and binary forms, with or without
  16403. modification, are permitted provided that the following conditions are met:
  16404. 1. Redistributions of source code must retain the above copyright notice,
  16405. this list of conditions, and the following disclaimer.
  16406. 2. Redistributions in binary form must reproduce the above copyright notice,
  16407. this list of conditions, and the following disclaimer in the documentation
  16408. and/or other materials provided with the distribution.
  16409. 3. Neither the name of the University nor the names of its contributors may
  16410. be used to endorse or promote products derived from this software without
  16411. specific prior written permission.
  16412. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  16413. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16414. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  16415. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  16416. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  16417. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  16418. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  16419. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  16420. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  16421. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16422. =============================================================================*/
  16423. #include <stdbool.h>
  16424. #include <stdint.h>
  16425. /**** skipping file: platform.h ****/
  16426. /**** skipping file: internals.h ****/
  16427. /**** skipping file: softfloat.h ****/
  16428. float64_t f64_sub( float64_t a, float64_t b )
  16429. {
  16430. union ui64_f64 uA;
  16431. uint_fast64_t uiA;
  16432. bool signA;
  16433. union ui64_f64 uB;
  16434. uint_fast64_t uiB;
  16435. bool signB;
  16436. #if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
  16437. float64_t (*magsFuncPtr)( uint_fast64_t, uint_fast64_t, bool );
  16438. #endif
  16439. uA.f = a;
  16440. uiA = uA.ui;
  16441. signA = signF64UI( uiA );
  16442. uB.f = b;
  16443. uiB = uB.ui;
  16444. signB = signF64UI( uiB );
  16445. #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
  16446. if ( signA == signB ) {
  16447. return softfloat_subMagsF64( uiA, uiB, signA );
  16448. } else {
  16449. return softfloat_addMagsF64( uiA, uiB, signA );
  16450. }
  16451. #else
  16452. magsFuncPtr =
  16453. (signA == signB) ? softfloat_subMagsF64 : softfloat_addMagsF64;
  16454. return (*magsFuncPtr)( uiA, uiB, signA );
  16455. #endif
  16456. }
  16457. /**** ended inlining ../../source/f64_sub.c ****/
  16458. /**** start inlining ../../source/f64_mul.c ****/
  16459. /*============================================================================
  16460. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  16461. Package, Release 3e, by John R. Hauser.
  16462. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  16463. All rights reserved.
  16464. Redistribution and use in source and binary forms, with or without
  16465. modification, are permitted provided that the following conditions are met:
  16466. 1. Redistributions of source code must retain the above copyright notice,
  16467. this list of conditions, and the following disclaimer.
  16468. 2. Redistributions in binary form must reproduce the above copyright notice,
  16469. this list of conditions, and the following disclaimer in the documentation
  16470. and/or other materials provided with the distribution.
  16471. 3. Neither the name of the University nor the names of its contributors may
  16472. be used to endorse or promote products derived from this software without
  16473. specific prior written permission.
  16474. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  16475. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16476. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  16477. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  16478. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  16479. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  16480. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  16481. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  16482. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  16483. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16484. =============================================================================*/
  16485. #include <stdbool.h>
  16486. #include <stdint.h>
  16487. /**** skipping file: platform.h ****/
  16488. /**** skipping file: internals.h ****/
  16489. /**** skipping file: specialize.h ****/
  16490. /**** skipping file: softfloat.h ****/
  16491. float64_t f64_mul( float64_t a, float64_t b )
  16492. {
  16493. union ui64_f64 uA;
  16494. uint_fast64_t uiA;
  16495. bool signA;
  16496. int_fast16_t expA;
  16497. uint_fast64_t sigA;
  16498. union ui64_f64 uB;
  16499. uint_fast64_t uiB;
  16500. bool signB;
  16501. int_fast16_t expB;
  16502. uint_fast64_t sigB;
  16503. bool signZ;
  16504. uint_fast64_t magBits;
  16505. struct exp16_sig64 normExpSig;
  16506. int_fast16_t expZ;
  16507. #ifdef SOFTFLOAT_FAST_INT64
  16508. struct uint128 sig128Z;
  16509. #else
  16510. uint32_t sig128Z[4];
  16511. #endif
  16512. uint_fast64_t sigZ, uiZ;
  16513. union ui64_f64 uZ;
  16514. /*------------------------------------------------------------------------
  16515. *------------------------------------------------------------------------*/
  16516. uA.f = a;
  16517. uiA = uA.ui;
  16518. signA = signF64UI( uiA );
  16519. expA = expF64UI( uiA );
  16520. sigA = fracF64UI( uiA );
  16521. uB.f = b;
  16522. uiB = uB.ui;
  16523. signB = signF64UI( uiB );
  16524. expB = expF64UI( uiB );
  16525. sigB = fracF64UI( uiB );
  16526. signZ = signA ^ signB;
  16527. /*------------------------------------------------------------------------
  16528. *------------------------------------------------------------------------*/
  16529. if ( expA == 0x7FF ) {
  16530. if ( sigA || ((expB == 0x7FF) && sigB) ) goto propagateNaN;
  16531. magBits = expB | sigB;
  16532. goto infArg;
  16533. }
  16534. if ( expB == 0x7FF ) {
  16535. if ( sigB ) goto propagateNaN;
  16536. magBits = expA | sigA;
  16537. goto infArg;
  16538. }
  16539. /*------------------------------------------------------------------------
  16540. *------------------------------------------------------------------------*/
  16541. if ( ! expA ) {
  16542. if ( ! sigA ) goto zero;
  16543. normExpSig = softfloat_normSubnormalF64Sig( sigA );
  16544. expA = normExpSig.exp;
  16545. sigA = normExpSig.sig;
  16546. }
  16547. if ( ! expB ) {
  16548. if ( ! sigB ) goto zero;
  16549. normExpSig = softfloat_normSubnormalF64Sig( sigB );
  16550. expB = normExpSig.exp;
  16551. sigB = normExpSig.sig;
  16552. }
  16553. /*------------------------------------------------------------------------
  16554. *------------------------------------------------------------------------*/
  16555. expZ = expA + expB - 0x3FF;
  16556. sigA = (sigA | UINT64_C( 0x0010000000000000 ))<<10;
  16557. sigB = (sigB | UINT64_C( 0x0010000000000000 ))<<11;
  16558. #ifdef SOFTFLOAT_FAST_INT64
  16559. sig128Z = softfloat_mul64To128( sigA, sigB );
  16560. sigZ = sig128Z.v64 | (sig128Z.v0 != 0);
  16561. #else
  16562. softfloat_mul64To128M( sigA, sigB, sig128Z );
  16563. sigZ =
  16564. (uint64_t) sig128Z[indexWord( 4, 3 )]<<32 | sig128Z[indexWord( 4, 2 )];
  16565. if ( sig128Z[indexWord( 4, 1 )] || sig128Z[indexWord( 4, 0 )] ) sigZ |= 1;
  16566. #endif
  16567. if ( sigZ < UINT64_C( 0x4000000000000000 ) ) {
  16568. --expZ;
  16569. sigZ <<= 1;
  16570. }
  16571. return softfloat_roundPackToF64( signZ, expZ, sigZ );
  16572. /*------------------------------------------------------------------------
  16573. *------------------------------------------------------------------------*/
  16574. propagateNaN:
  16575. uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
  16576. goto uiZ;
  16577. /*------------------------------------------------------------------------
  16578. *------------------------------------------------------------------------*/
  16579. infArg:
  16580. if ( ! magBits ) {
  16581. softfloat_raiseFlags( softfloat_flag_invalid );
  16582. uiZ = defaultNaNF64UI;
  16583. } else {
  16584. uiZ = packToF64UI( signZ, 0x7FF, 0 );
  16585. }
  16586. goto uiZ;
  16587. /*------------------------------------------------------------------------
  16588. *------------------------------------------------------------------------*/
  16589. zero:
  16590. uiZ = packToF64UI( signZ, 0, 0 );
  16591. uiZ:
  16592. uZ.ui = uiZ;
  16593. return uZ.f;
  16594. }
  16595. /**** ended inlining ../../source/f64_mul.c ****/
  16596. /**** start inlining ../../source/f64_mulAdd.c ****/
  16597. /*============================================================================
  16598. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  16599. Package, Release 3e, by John R. Hauser.
  16600. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  16601. All rights reserved.
  16602. Redistribution and use in source and binary forms, with or without
  16603. modification, are permitted provided that the following conditions are met:
  16604. 1. Redistributions of source code must retain the above copyright notice,
  16605. this list of conditions, and the following disclaimer.
  16606. 2. Redistributions in binary form must reproduce the above copyright notice,
  16607. this list of conditions, and the following disclaimer in the documentation
  16608. and/or other materials provided with the distribution.
  16609. 3. Neither the name of the University nor the names of its contributors may
  16610. be used to endorse or promote products derived from this software without
  16611. specific prior written permission.
  16612. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  16613. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16614. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  16615. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  16616. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  16617. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  16618. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  16619. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  16620. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  16621. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16622. =============================================================================*/
  16623. #include <stdint.h>
  16624. /**** skipping file: platform.h ****/
  16625. /**** skipping file: internals.h ****/
  16626. /**** skipping file: softfloat.h ****/
  16627. float64_t f64_mulAdd( float64_t a, float64_t b, float64_t c )
  16628. {
  16629. union ui64_f64 uA;
  16630. uint_fast64_t uiA;
  16631. union ui64_f64 uB;
  16632. uint_fast64_t uiB;
  16633. union ui64_f64 uC;
  16634. uint_fast64_t uiC;
  16635. uA.f = a;
  16636. uiA = uA.ui;
  16637. uB.f = b;
  16638. uiB = uB.ui;
  16639. uC.f = c;
  16640. uiC = uC.ui;
  16641. return softfloat_mulAddF64( uiA, uiB, uiC, 0 );
  16642. }
  16643. /**** ended inlining ../../source/f64_mulAdd.c ****/
  16644. /**** start inlining ../../source/f64_div.c ****/
  16645. /*============================================================================
  16646. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  16647. Package, Release 3e, by John R. Hauser.
  16648. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  16649. All rights reserved.
  16650. Redistribution and use in source and binary forms, with or without
  16651. modification, are permitted provided that the following conditions are met:
  16652. 1. Redistributions of source code must retain the above copyright notice,
  16653. this list of conditions, and the following disclaimer.
  16654. 2. Redistributions in binary form must reproduce the above copyright notice,
  16655. this list of conditions, and the following disclaimer in the documentation
  16656. and/or other materials provided with the distribution.
  16657. 3. Neither the name of the University nor the names of its contributors may
  16658. be used to endorse or promote products derived from this software without
  16659. specific prior written permission.
  16660. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  16661. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16662. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  16663. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  16664. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  16665. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  16666. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  16667. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  16668. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  16669. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16670. =============================================================================*/
  16671. #include <stdbool.h>
  16672. #include <stdint.h>
  16673. /**** skipping file: platform.h ****/
  16674. /**** skipping file: internals.h ****/
  16675. /**** skipping file: specialize.h ****/
  16676. /**** skipping file: softfloat.h ****/
  16677. float64_t f64_div( float64_t a, float64_t b )
  16678. {
  16679. union ui64_f64 uA;
  16680. uint_fast64_t uiA;
  16681. bool signA;
  16682. int_fast16_t expA;
  16683. uint_fast64_t sigA;
  16684. union ui64_f64 uB;
  16685. uint_fast64_t uiB;
  16686. bool signB;
  16687. int_fast16_t expB;
  16688. uint_fast64_t sigB;
  16689. bool signZ;
  16690. struct exp16_sig64 normExpSig;
  16691. int_fast16_t expZ;
  16692. uint32_t recip32, sig32Z, doubleTerm;
  16693. uint_fast64_t rem;
  16694. uint32_t q;
  16695. uint_fast64_t sigZ;
  16696. uint_fast64_t uiZ;
  16697. union ui64_f64 uZ;
  16698. /*------------------------------------------------------------------------
  16699. *------------------------------------------------------------------------*/
  16700. uA.f = a;
  16701. uiA = uA.ui;
  16702. signA = signF64UI( uiA );
  16703. expA = expF64UI( uiA );
  16704. sigA = fracF64UI( uiA );
  16705. uB.f = b;
  16706. uiB = uB.ui;
  16707. signB = signF64UI( uiB );
  16708. expB = expF64UI( uiB );
  16709. sigB = fracF64UI( uiB );
  16710. signZ = signA ^ signB;
  16711. /*------------------------------------------------------------------------
  16712. *------------------------------------------------------------------------*/
  16713. if ( expA == 0x7FF ) {
  16714. if ( sigA ) goto propagateNaN;
  16715. if ( expB == 0x7FF ) {
  16716. if ( sigB ) goto propagateNaN;
  16717. goto invalid;
  16718. }
  16719. goto infinity;
  16720. }
  16721. if ( expB == 0x7FF ) {
  16722. if ( sigB ) goto propagateNaN;
  16723. goto zero;
  16724. }
  16725. /*------------------------------------------------------------------------
  16726. *------------------------------------------------------------------------*/
  16727. if ( ! expB ) {
  16728. if ( ! sigB ) {
  16729. if ( ! (expA | sigA) ) goto invalid;
  16730. softfloat_raiseFlags( softfloat_flag_infinite );
  16731. goto infinity;
  16732. }
  16733. normExpSig = softfloat_normSubnormalF64Sig( sigB );
  16734. expB = normExpSig.exp;
  16735. sigB = normExpSig.sig;
  16736. }
  16737. if ( ! expA ) {
  16738. if ( ! sigA ) goto zero;
  16739. normExpSig = softfloat_normSubnormalF64Sig( sigA );
  16740. expA = normExpSig.exp;
  16741. sigA = normExpSig.sig;
  16742. }
  16743. /*------------------------------------------------------------------------
  16744. *------------------------------------------------------------------------*/
  16745. expZ = expA - expB + 0x3FE;
  16746. sigA |= UINT64_C( 0x0010000000000000 );
  16747. sigB |= UINT64_C( 0x0010000000000000 );
  16748. if ( sigA < sigB ) {
  16749. --expZ;
  16750. sigA <<= 11;
  16751. } else {
  16752. sigA <<= 10;
  16753. }
  16754. sigB <<= 11;
  16755. recip32 = softfloat_approxRecip32_1( sigB>>32 ) - 2;
  16756. sig32Z = ((uint32_t) (sigA>>32) * (uint_fast64_t) recip32)>>32;
  16757. doubleTerm = sig32Z<<1;
  16758. rem =
  16759. ((sigA - (uint_fast64_t) doubleTerm * (uint32_t) (sigB>>32))<<28)
  16760. - (uint_fast64_t) doubleTerm * ((uint32_t) sigB>>4);
  16761. q = (((uint32_t) (rem>>32) * (uint_fast64_t) recip32)>>32) + 4;
  16762. sigZ = ((uint_fast64_t) sig32Z<<32) + ((uint_fast64_t) q<<4);
  16763. /*------------------------------------------------------------------------
  16764. *------------------------------------------------------------------------*/
  16765. if ( (sigZ & 0x1FF) < 4<<4 ) {
  16766. q &= ~7;
  16767. sigZ &= ~(uint_fast64_t) 0x7F;
  16768. doubleTerm = q<<1;
  16769. rem =
  16770. ((rem - (uint_fast64_t) doubleTerm * (uint32_t) (sigB>>32))<<28)
  16771. - (uint_fast64_t) doubleTerm * ((uint32_t) sigB>>4);
  16772. if ( rem & UINT64_C( 0x8000000000000000 ) ) {
  16773. sigZ -= 1<<7;
  16774. } else {
  16775. if ( rem ) sigZ |= 1;
  16776. }
  16777. }
  16778. return softfloat_roundPackToF64( signZ, expZ, sigZ );
  16779. /*------------------------------------------------------------------------
  16780. *------------------------------------------------------------------------*/
  16781. propagateNaN:
  16782. uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
  16783. goto uiZ;
  16784. /*------------------------------------------------------------------------
  16785. *------------------------------------------------------------------------*/
  16786. invalid:
  16787. softfloat_raiseFlags( softfloat_flag_invalid );
  16788. uiZ = defaultNaNF64UI;
  16789. goto uiZ;
  16790. /*------------------------------------------------------------------------
  16791. *------------------------------------------------------------------------*/
  16792. infinity:
  16793. uiZ = packToF64UI( signZ, 0x7FF, 0 );
  16794. goto uiZ;
  16795. /*------------------------------------------------------------------------
  16796. *------------------------------------------------------------------------*/
  16797. zero:
  16798. uiZ = packToF64UI( signZ, 0, 0 );
  16799. uiZ:
  16800. uZ.ui = uiZ;
  16801. return uZ.f;
  16802. }
  16803. /**** ended inlining ../../source/f64_div.c ****/
  16804. /**** start inlining ../../source/f64_rem.c ****/
  16805. /*============================================================================
  16806. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  16807. Package, Release 3e, by John R. Hauser.
  16808. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  16809. All rights reserved.
  16810. Redistribution and use in source and binary forms, with or without
  16811. modification, are permitted provided that the following conditions are met:
  16812. 1. Redistributions of source code must retain the above copyright notice,
  16813. this list of conditions, and the following disclaimer.
  16814. 2. Redistributions in binary form must reproduce the above copyright notice,
  16815. this list of conditions, and the following disclaimer in the documentation
  16816. and/or other materials provided with the distribution.
  16817. 3. Neither the name of the University nor the names of its contributors may
  16818. be used to endorse or promote products derived from this software without
  16819. specific prior written permission.
  16820. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  16821. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16822. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  16823. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  16824. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  16825. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  16826. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  16827. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  16828. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  16829. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16830. =============================================================================*/
  16831. #include <stdbool.h>
  16832. #include <stdint.h>
  16833. /**** skipping file: platform.h ****/
  16834. /**** skipping file: internals.h ****/
  16835. /**** skipping file: specialize.h ****/
  16836. /**** skipping file: softfloat.h ****/
  16837. float64_t f64_rem( float64_t a, float64_t b )
  16838. {
  16839. union ui64_f64 uA;
  16840. uint_fast64_t uiA;
  16841. bool signA;
  16842. int_fast16_t expA;
  16843. uint_fast64_t sigA;
  16844. union ui64_f64 uB;
  16845. uint_fast64_t uiB;
  16846. int_fast16_t expB;
  16847. uint_fast64_t sigB;
  16848. struct exp16_sig64 normExpSig;
  16849. uint64_t rem;
  16850. int_fast16_t expDiff;
  16851. uint32_t q, recip32;
  16852. uint_fast64_t q64;
  16853. uint64_t altRem, meanRem;
  16854. bool signRem;
  16855. uint_fast64_t uiZ;
  16856. union ui64_f64 uZ;
  16857. /*------------------------------------------------------------------------
  16858. *------------------------------------------------------------------------*/
  16859. uA.f = a;
  16860. uiA = uA.ui;
  16861. signA = signF64UI( uiA );
  16862. expA = expF64UI( uiA );
  16863. sigA = fracF64UI( uiA );
  16864. uB.f = b;
  16865. uiB = uB.ui;
  16866. expB = expF64UI( uiB );
  16867. sigB = fracF64UI( uiB );
  16868. /*------------------------------------------------------------------------
  16869. *------------------------------------------------------------------------*/
  16870. if ( expA == 0x7FF ) {
  16871. if ( sigA || ((expB == 0x7FF) && sigB) ) goto propagateNaN;
  16872. goto invalid;
  16873. }
  16874. if ( expB == 0x7FF ) {
  16875. if ( sigB ) goto propagateNaN;
  16876. return a;
  16877. }
  16878. /*------------------------------------------------------------------------
  16879. *------------------------------------------------------------------------*/
  16880. if ( expA < expB - 1 ) return a;
  16881. /*------------------------------------------------------------------------
  16882. *------------------------------------------------------------------------*/
  16883. if ( ! expB ) {
  16884. if ( ! sigB ) goto invalid;
  16885. normExpSig = softfloat_normSubnormalF64Sig( sigB );
  16886. expB = normExpSig.exp;
  16887. sigB = normExpSig.sig;
  16888. }
  16889. if ( ! expA ) {
  16890. if ( ! sigA ) return a;
  16891. normExpSig = softfloat_normSubnormalF64Sig( sigA );
  16892. expA = normExpSig.exp;
  16893. sigA = normExpSig.sig;
  16894. }
  16895. /*------------------------------------------------------------------------
  16896. *------------------------------------------------------------------------*/
  16897. rem = sigA | UINT64_C( 0x0010000000000000 );
  16898. sigB |= UINT64_C( 0x0010000000000000 );
  16899. expDiff = expA - expB;
  16900. if ( expDiff < 1 ) {
  16901. if ( expDiff < -1 ) return a;
  16902. sigB <<= 9;
  16903. if ( expDiff ) {
  16904. rem <<= 8;
  16905. q = 0;
  16906. } else {
  16907. rem <<= 9;
  16908. q = (sigB <= rem);
  16909. if ( q ) rem -= sigB;
  16910. }
  16911. } else {
  16912. recip32 = softfloat_approxRecip32_1( sigB>>21 );
  16913. /*--------------------------------------------------------------------
  16914. | Changing the shift of `rem' here requires also changing the initial
  16915. | subtraction from `expDiff'.
  16916. *--------------------------------------------------------------------*/
  16917. rem <<= 9;
  16918. expDiff -= 30;
  16919. /*--------------------------------------------------------------------
  16920. | The scale of `sigB' affects how many bits are obtained during each
  16921. | cycle of the loop. Currently this is 29 bits per loop iteration,
  16922. | the maximum possible.
  16923. *--------------------------------------------------------------------*/
  16924. sigB <<= 9;
  16925. for (;;) {
  16926. q64 = (uint32_t) (rem>>32) * (uint_fast64_t) recip32;
  16927. if ( expDiff < 0 ) break;
  16928. q = (q64 + 0x80000000)>>32;
  16929. #ifdef SOFTFLOAT_FAST_INT64
  16930. rem <<= 29;
  16931. #else
  16932. rem = (uint_fast64_t) (uint32_t) (rem>>3)<<32;
  16933. #endif
  16934. rem -= q * (uint64_t) sigB;
  16935. if ( rem & UINT64_C( 0x8000000000000000 ) ) rem += sigB;
  16936. expDiff -= 29;
  16937. }
  16938. /*--------------------------------------------------------------------
  16939. | (`expDiff' cannot be less than -29 here.)
  16940. *--------------------------------------------------------------------*/
  16941. q = (uint32_t) (q64>>32)>>(~expDiff & 31);
  16942. rem = (rem<<(expDiff + 30)) - q * (uint64_t) sigB;
  16943. if ( rem & UINT64_C( 0x8000000000000000 ) ) {
  16944. altRem = rem + sigB;
  16945. goto selectRem;
  16946. }
  16947. }
  16948. /*------------------------------------------------------------------------
  16949. *------------------------------------------------------------------------*/
  16950. do {
  16951. altRem = rem;
  16952. ++q;
  16953. rem -= sigB;
  16954. } while ( ! (rem & UINT64_C( 0x8000000000000000 )) );
  16955. selectRem:
  16956. meanRem = rem + altRem;
  16957. if (
  16958. (meanRem & UINT64_C( 0x8000000000000000 )) || (! meanRem && (q & 1))
  16959. ) {
  16960. rem = altRem;
  16961. }
  16962. signRem = signA;
  16963. if ( rem & UINT64_C( 0x8000000000000000 ) ) {
  16964. signRem = ! signRem;
  16965. rem = -rem;
  16966. }
  16967. return softfloat_normRoundPackToF64( signRem, expB, rem );
  16968. /*------------------------------------------------------------------------
  16969. *------------------------------------------------------------------------*/
  16970. propagateNaN:
  16971. uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
  16972. goto uiZ;
  16973. invalid:
  16974. softfloat_raiseFlags( softfloat_flag_invalid );
  16975. uiZ = defaultNaNF64UI;
  16976. uiZ:
  16977. uZ.ui = uiZ;
  16978. return uZ.f;
  16979. }
  16980. /**** ended inlining ../../source/f64_rem.c ****/
  16981. /**** start inlining ../../source/f64_sqrt.c ****/
  16982. /*============================================================================
  16983. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  16984. Package, Release 3e, by John R. Hauser.
  16985. Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
  16986. California. All rights reserved.
  16987. Redistribution and use in source and binary forms, with or without
  16988. modification, are permitted provided that the following conditions are met:
  16989. 1. Redistributions of source code must retain the above copyright notice,
  16990. this list of conditions, and the following disclaimer.
  16991. 2. Redistributions in binary form must reproduce the above copyright notice,
  16992. this list of conditions, and the following disclaimer in the documentation
  16993. and/or other materials provided with the distribution.
  16994. 3. Neither the name of the University nor the names of its contributors may
  16995. be used to endorse or promote products derived from this software without
  16996. specific prior written permission.
  16997. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  16998. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16999. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  17000. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  17001. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  17002. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  17003. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  17004. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  17005. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  17006. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  17007. =============================================================================*/
  17008. #include <stdbool.h>
  17009. #include <stdint.h>
  17010. /**** skipping file: platform.h ****/
  17011. /**** skipping file: internals.h ****/
  17012. /**** skipping file: specialize.h ****/
  17013. /**** skipping file: softfloat.h ****/
  17014. float64_t f64_sqrt( float64_t a )
  17015. {
  17016. union ui64_f64 uA;
  17017. uint_fast64_t uiA;
  17018. bool signA;
  17019. int_fast16_t expA;
  17020. uint_fast64_t sigA, uiZ;
  17021. struct exp16_sig64 normExpSig;
  17022. int_fast16_t expZ;
  17023. uint32_t sig32A, recipSqrt32, sig32Z;
  17024. uint_fast64_t rem;
  17025. uint32_t q;
  17026. uint_fast64_t sigZ, shiftedSigZ;
  17027. union ui64_f64 uZ;
  17028. /*------------------------------------------------------------------------
  17029. *------------------------------------------------------------------------*/
  17030. uA.f = a;
  17031. uiA = uA.ui;
  17032. signA = signF64UI( uiA );
  17033. expA = expF64UI( uiA );
  17034. sigA = fracF64UI( uiA );
  17035. /*------------------------------------------------------------------------
  17036. *------------------------------------------------------------------------*/
  17037. if ( expA == 0x7FF ) {
  17038. if ( sigA ) {
  17039. uiZ = softfloat_propagateNaNF64UI( uiA, 0 );
  17040. goto uiZ;
  17041. }
  17042. if ( ! signA ) return a;
  17043. goto invalid;
  17044. }
  17045. /*------------------------------------------------------------------------
  17046. *------------------------------------------------------------------------*/
  17047. if ( signA ) {
  17048. if ( ! (expA | sigA) ) return a;
  17049. goto invalid;
  17050. }
  17051. /*------------------------------------------------------------------------
  17052. *------------------------------------------------------------------------*/
  17053. if ( ! expA ) {
  17054. if ( ! sigA ) return a;
  17055. normExpSig = softfloat_normSubnormalF64Sig( sigA );
  17056. expA = normExpSig.exp;
  17057. sigA = normExpSig.sig;
  17058. }
  17059. /*------------------------------------------------------------------------
  17060. | (`sig32Z' is guaranteed to be a lower bound on the square root of
  17061. | `sig32A', which makes `sig32Z' also a lower bound on the square root of
  17062. | `sigA'.)
  17063. *------------------------------------------------------------------------*/
  17064. expZ = ((expA - 0x3FF)>>1) + 0x3FE;
  17065. expA &= 1;
  17066. sigA |= UINT64_C( 0x0010000000000000 );
  17067. sig32A = sigA>>21;
  17068. recipSqrt32 = softfloat_approxRecipSqrt32_1( expA, sig32A );
  17069. sig32Z = ((uint_fast64_t) sig32A * recipSqrt32)>>32;
  17070. if ( expA ) {
  17071. sigA <<= 8;
  17072. sig32Z >>= 1;
  17073. } else {
  17074. sigA <<= 9;
  17075. }
  17076. rem = sigA - (uint_fast64_t) sig32Z * sig32Z;
  17077. q = ((uint32_t) (rem>>2) * (uint_fast64_t) recipSqrt32)>>32;
  17078. sigZ = ((uint_fast64_t) sig32Z<<32 | 1<<5) + ((uint_fast64_t) q<<3);
  17079. /*------------------------------------------------------------------------
  17080. *------------------------------------------------------------------------*/
  17081. if ( (sigZ & 0x1FF) < 0x22 ) {
  17082. sigZ &= ~(uint_fast64_t) 0x3F;
  17083. shiftedSigZ = sigZ>>6;
  17084. rem = (sigA<<52) - shiftedSigZ * shiftedSigZ;
  17085. if ( rem & UINT64_C( 0x8000000000000000 ) ) {
  17086. --sigZ;
  17087. } else {
  17088. if ( rem ) sigZ |= 1;
  17089. }
  17090. }
  17091. return softfloat_roundPackToF64( 0, expZ, sigZ );
  17092. /*------------------------------------------------------------------------
  17093. *------------------------------------------------------------------------*/
  17094. invalid:
  17095. softfloat_raiseFlags( softfloat_flag_invalid );
  17096. uiZ = defaultNaNF64UI;
  17097. uiZ:
  17098. uZ.ui = uiZ;
  17099. return uZ.f;
  17100. }
  17101. /**** ended inlining ../../source/f64_sqrt.c ****/
  17102. /**** start inlining ../../source/f64_eq.c ****/
  17103. /*============================================================================
  17104. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  17105. Package, Release 3e, by John R. Hauser.
  17106. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  17107. All rights reserved.
  17108. Redistribution and use in source and binary forms, with or without
  17109. modification, are permitted provided that the following conditions are met:
  17110. 1. Redistributions of source code must retain the above copyright notice,
  17111. this list of conditions, and the following disclaimer.
  17112. 2. Redistributions in binary form must reproduce the above copyright notice,
  17113. this list of conditions, and the following disclaimer in the documentation
  17114. and/or other materials provided with the distribution.
  17115. 3. Neither the name of the University nor the names of its contributors may
  17116. be used to endorse or promote products derived from this software without
  17117. specific prior written permission.
  17118. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  17119. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17120. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  17121. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  17122. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  17123. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  17124. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  17125. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  17126. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  17127. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  17128. =============================================================================*/
  17129. #include <stdbool.h>
  17130. #include <stdint.h>
  17131. /**** skipping file: platform.h ****/
  17132. /**** skipping file: internals.h ****/
  17133. /**** skipping file: specialize.h ****/
  17134. /**** skipping file: softfloat.h ****/
  17135. bool f64_eq( float64_t a, float64_t b )
  17136. {
  17137. union ui64_f64 uA;
  17138. uint_fast64_t uiA;
  17139. union ui64_f64 uB;
  17140. uint_fast64_t uiB;
  17141. uA.f = a;
  17142. uiA = uA.ui;
  17143. uB.f = b;
  17144. uiB = uB.ui;
  17145. if ( isNaNF64UI( uiA ) || isNaNF64UI( uiB ) ) {
  17146. if (
  17147. softfloat_isSigNaNF64UI( uiA ) || softfloat_isSigNaNF64UI( uiB )
  17148. ) {
  17149. softfloat_raiseFlags( softfloat_flag_invalid );
  17150. }
  17151. return false;
  17152. }
  17153. return (uiA == uiB) || ! ((uiA | uiB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ));
  17154. }
  17155. /**** ended inlining ../../source/f64_eq.c ****/
  17156. /**** start inlining ../../source/f64_le.c ****/
  17157. /*============================================================================
  17158. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  17159. Package, Release 3e, by John R. Hauser.
  17160. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  17161. All rights reserved.
  17162. Redistribution and use in source and binary forms, with or without
  17163. modification, are permitted provided that the following conditions are met:
  17164. 1. Redistributions of source code must retain the above copyright notice,
  17165. this list of conditions, and the following disclaimer.
  17166. 2. Redistributions in binary form must reproduce the above copyright notice,
  17167. this list of conditions, and the following disclaimer in the documentation
  17168. and/or other materials provided with the distribution.
  17169. 3. Neither the name of the University nor the names of its contributors may
  17170. be used to endorse or promote products derived from this software without
  17171. specific prior written permission.
  17172. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  17173. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17174. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  17175. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  17176. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  17177. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  17178. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  17179. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  17180. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  17181. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  17182. =============================================================================*/
  17183. #include <stdbool.h>
  17184. #include <stdint.h>
  17185. /**** skipping file: platform.h ****/
  17186. /**** skipping file: internals.h ****/
  17187. /**** skipping file: softfloat.h ****/
  17188. bool f64_le( float64_t a, float64_t b )
  17189. {
  17190. union ui64_f64 uA;
  17191. uint_fast64_t uiA;
  17192. union ui64_f64 uB;
  17193. uint_fast64_t uiB;
  17194. bool signA, signB;
  17195. uA.f = a;
  17196. uiA = uA.ui;
  17197. uB.f = b;
  17198. uiB = uB.ui;
  17199. if ( isNaNF64UI( uiA ) || isNaNF64UI( uiB ) ) {
  17200. softfloat_raiseFlags( softfloat_flag_invalid );
  17201. return false;
  17202. }
  17203. signA = signF64UI( uiA );
  17204. signB = signF64UI( uiB );
  17205. return
  17206. (signA != signB)
  17207. ? signA || ! ((uiA | uiB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
  17208. : (uiA == uiB) || (signA ^ (uiA < uiB));
  17209. }
  17210. /**** ended inlining ../../source/f64_le.c ****/
  17211. /**** start inlining ../../source/f64_lt.c ****/
  17212. /*============================================================================
  17213. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  17214. Package, Release 3e, by John R. Hauser.
  17215. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  17216. All rights reserved.
  17217. Redistribution and use in source and binary forms, with or without
  17218. modification, are permitted provided that the following conditions are met:
  17219. 1. Redistributions of source code must retain the above copyright notice,
  17220. this list of conditions, and the following disclaimer.
  17221. 2. Redistributions in binary form must reproduce the above copyright notice,
  17222. this list of conditions, and the following disclaimer in the documentation
  17223. and/or other materials provided with the distribution.
  17224. 3. Neither the name of the University nor the names of its contributors may
  17225. be used to endorse or promote products derived from this software without
  17226. specific prior written permission.
  17227. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  17228. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17229. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  17230. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  17231. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  17232. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  17233. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  17234. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  17235. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  17236. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  17237. =============================================================================*/
  17238. #include <stdbool.h>
  17239. #include <stdint.h>
  17240. /**** skipping file: platform.h ****/
  17241. /**** skipping file: internals.h ****/
  17242. /**** skipping file: softfloat.h ****/
  17243. bool f64_lt( float64_t a, float64_t b )
  17244. {
  17245. union ui64_f64 uA;
  17246. uint_fast64_t uiA;
  17247. union ui64_f64 uB;
  17248. uint_fast64_t uiB;
  17249. bool signA, signB;
  17250. uA.f = a;
  17251. uiA = uA.ui;
  17252. uB.f = b;
  17253. uiB = uB.ui;
  17254. if ( isNaNF64UI( uiA ) || isNaNF64UI( uiB ) ) {
  17255. softfloat_raiseFlags( softfloat_flag_invalid );
  17256. return false;
  17257. }
  17258. signA = signF64UI( uiA );
  17259. signB = signF64UI( uiB );
  17260. return
  17261. (signA != signB)
  17262. ? signA && ((uiA | uiB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
  17263. : (uiA != uiB) && (signA ^ (uiA < uiB));
  17264. }
  17265. /**** ended inlining ../../source/f64_lt.c ****/
  17266. /**** start inlining ../../source/f64_eq_signaling.c ****/
  17267. /*============================================================================
  17268. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  17269. Package, Release 3e, by John R. Hauser.
  17270. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  17271. All rights reserved.
  17272. Redistribution and use in source and binary forms, with or without
  17273. modification, are permitted provided that the following conditions are met:
  17274. 1. Redistributions of source code must retain the above copyright notice,
  17275. this list of conditions, and the following disclaimer.
  17276. 2. Redistributions in binary form must reproduce the above copyright notice,
  17277. this list of conditions, and the following disclaimer in the documentation
  17278. and/or other materials provided with the distribution.
  17279. 3. Neither the name of the University nor the names of its contributors may
  17280. be used to endorse or promote products derived from this software without
  17281. specific prior written permission.
  17282. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  17283. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17284. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  17285. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  17286. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  17287. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  17288. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  17289. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  17290. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  17291. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  17292. =============================================================================*/
  17293. #include <stdbool.h>
  17294. #include <stdint.h>
  17295. /**** skipping file: platform.h ****/
  17296. /**** skipping file: internals.h ****/
  17297. /**** skipping file: softfloat.h ****/
  17298. bool f64_eq_signaling( float64_t a, float64_t b )
  17299. {
  17300. union ui64_f64 uA;
  17301. uint_fast64_t uiA;
  17302. union ui64_f64 uB;
  17303. uint_fast64_t uiB;
  17304. uA.f = a;
  17305. uiA = uA.ui;
  17306. uB.f = b;
  17307. uiB = uB.ui;
  17308. if ( isNaNF64UI( uiA ) || isNaNF64UI( uiB ) ) {
  17309. softfloat_raiseFlags( softfloat_flag_invalid );
  17310. return false;
  17311. }
  17312. return (uiA == uiB) || ! ((uiA | uiB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ));
  17313. }
  17314. /**** ended inlining ../../source/f64_eq_signaling.c ****/
  17315. /**** start inlining ../../source/f64_le_quiet.c ****/
  17316. /*============================================================================
  17317. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  17318. Package, Release 3e, by John R. Hauser.
  17319. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  17320. All rights reserved.
  17321. Redistribution and use in source and binary forms, with or without
  17322. modification, are permitted provided that the following conditions are met:
  17323. 1. Redistributions of source code must retain the above copyright notice,
  17324. this list of conditions, and the following disclaimer.
  17325. 2. Redistributions in binary form must reproduce the above copyright notice,
  17326. this list of conditions, and the following disclaimer in the documentation
  17327. and/or other materials provided with the distribution.
  17328. 3. Neither the name of the University nor the names of its contributors may
  17329. be used to endorse or promote products derived from this software without
  17330. specific prior written permission.
  17331. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  17332. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17333. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  17334. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  17335. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  17336. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  17337. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  17338. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  17339. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  17340. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  17341. =============================================================================*/
  17342. #include <stdbool.h>
  17343. #include <stdint.h>
  17344. /**** skipping file: platform.h ****/
  17345. /**** skipping file: internals.h ****/
  17346. /**** skipping file: specialize.h ****/
  17347. /**** skipping file: softfloat.h ****/
  17348. bool f64_le_quiet( float64_t a, float64_t b )
  17349. {
  17350. union ui64_f64 uA;
  17351. uint_fast64_t uiA;
  17352. union ui64_f64 uB;
  17353. uint_fast64_t uiB;
  17354. bool signA, signB;
  17355. uA.f = a;
  17356. uiA = uA.ui;
  17357. uB.f = b;
  17358. uiB = uB.ui;
  17359. if ( isNaNF64UI( uiA ) || isNaNF64UI( uiB ) ) {
  17360. if (
  17361. softfloat_isSigNaNF64UI( uiA ) || softfloat_isSigNaNF64UI( uiB )
  17362. ) {
  17363. softfloat_raiseFlags( softfloat_flag_invalid );
  17364. }
  17365. return false;
  17366. }
  17367. signA = signF64UI( uiA );
  17368. signB = signF64UI( uiB );
  17369. return
  17370. (signA != signB)
  17371. ? signA || ! ((uiA | uiB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
  17372. : (uiA == uiB) || (signA ^ (uiA < uiB));
  17373. }
  17374. /**** ended inlining ../../source/f64_le_quiet.c ****/
  17375. /**** start inlining ../../source/f64_lt_quiet.c ****/
  17376. /*============================================================================
  17377. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  17378. Package, Release 3e, by John R. Hauser.
  17379. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  17380. All rights reserved.
  17381. Redistribution and use in source and binary forms, with or without
  17382. modification, are permitted provided that the following conditions are met:
  17383. 1. Redistributions of source code must retain the above copyright notice,
  17384. this list of conditions, and the following disclaimer.
  17385. 2. Redistributions in binary form must reproduce the above copyright notice,
  17386. this list of conditions, and the following disclaimer in the documentation
  17387. and/or other materials provided with the distribution.
  17388. 3. Neither the name of the University nor the names of its contributors may
  17389. be used to endorse or promote products derived from this software without
  17390. specific prior written permission.
  17391. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  17392. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17393. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  17394. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  17395. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  17396. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  17397. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  17398. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  17399. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  17400. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  17401. =============================================================================*/
  17402. #include <stdbool.h>
  17403. #include <stdint.h>
  17404. /**** skipping file: platform.h ****/
  17405. /**** skipping file: internals.h ****/
  17406. /**** skipping file: specialize.h ****/
  17407. /**** skipping file: softfloat.h ****/
  17408. bool f64_lt_quiet( float64_t a, float64_t b )
  17409. {
  17410. union ui64_f64 uA;
  17411. uint_fast64_t uiA;
  17412. union ui64_f64 uB;
  17413. uint_fast64_t uiB;
  17414. bool signA, signB;
  17415. uA.f = a;
  17416. uiA = uA.ui;
  17417. uB.f = b;
  17418. uiB = uB.ui;
  17419. if ( isNaNF64UI( uiA ) || isNaNF64UI( uiB ) ) {
  17420. if (
  17421. softfloat_isSigNaNF64UI( uiA ) || softfloat_isSigNaNF64UI( uiB )
  17422. ) {
  17423. softfloat_raiseFlags( softfloat_flag_invalid );
  17424. }
  17425. return false;
  17426. }
  17427. signA = signF64UI( uiA );
  17428. signB = signF64UI( uiB );
  17429. return
  17430. (signA != signB)
  17431. ? signA && ((uiA | uiB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
  17432. : (uiA != uiB) && (signA ^ (uiA < uiB));
  17433. }
  17434. /**** ended inlining ../../source/f64_lt_quiet.c ****/
  17435. /**** start inlining ../../source/f64_isSignalingNaN.c ****/
  17436. /*============================================================================
  17437. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  17438. Package, Release 3e, by John R. Hauser.
  17439. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  17440. All rights reserved.
  17441. Redistribution and use in source and binary forms, with or without
  17442. modification, are permitted provided that the following conditions are met:
  17443. 1. Redistributions of source code must retain the above copyright notice,
  17444. this list of conditions, and the following disclaimer.
  17445. 2. Redistributions in binary form must reproduce the above copyright notice,
  17446. this list of conditions, and the following disclaimer in the documentation
  17447. and/or other materials provided with the distribution.
  17448. 3. Neither the name of the University nor the names of its contributors may
  17449. be used to endorse or promote products derived from this software without
  17450. specific prior written permission.
  17451. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  17452. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17453. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  17454. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  17455. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  17456. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  17457. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  17458. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  17459. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  17460. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  17461. =============================================================================*/
  17462. #include <stdbool.h>
  17463. /**** skipping file: platform.h ****/
  17464. /**** skipping file: internals.h ****/
  17465. /**** skipping file: specialize.h ****/
  17466. /**** skipping file: softfloat.h ****/
  17467. bool f64_isSignalingNaN( float64_t a )
  17468. {
  17469. union ui64_f64 uA;
  17470. uA.f = a;
  17471. return softfloat_isSigNaNF64UI( uA.ui );
  17472. }
  17473. /**** ended inlining ../../source/f64_isSignalingNaN.c ****/
  17474. /**** start inlining ../../source/extF80_to_ui32.c ****/
  17475. /*============================================================================
  17476. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  17477. Package, Release 3e, by John R. Hauser.
  17478. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  17479. University of California. All rights reserved.
  17480. Redistribution and use in source and binary forms, with or without
  17481. modification, are permitted provided that the following conditions are met:
  17482. 1. Redistributions of source code must retain the above copyright notice,
  17483. this list of conditions, and the following disclaimer.
  17484. 2. Redistributions in binary form must reproduce the above copyright notice,
  17485. this list of conditions, and the following disclaimer in the documentation
  17486. and/or other materials provided with the distribution.
  17487. 3. Neither the name of the University nor the names of its contributors may
  17488. be used to endorse or promote products derived from this software without
  17489. specific prior written permission.
  17490. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  17491. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17492. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  17493. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  17494. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  17495. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  17496. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  17497. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  17498. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  17499. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  17500. =============================================================================*/
  17501. #include <stdbool.h>
  17502. #include <stdint.h>
  17503. /**** skipping file: platform.h ****/
  17504. /**** skipping file: internals.h ****/
  17505. /**** skipping file: specialize.h ****/
  17506. /**** skipping file: softfloat.h ****/
  17507. uint_fast32_t
  17508. extF80_to_ui32( extFloat80_t a, uint_fast8_t roundingMode, bool exact )
  17509. {
  17510. union { struct extFloat80M s; extFloat80_t f; } uA;
  17511. uint_fast16_t uiA64;
  17512. bool sign;
  17513. int_fast32_t exp;
  17514. uint_fast64_t sig;
  17515. int_fast32_t shiftDist;
  17516. /*------------------------------------------------------------------------
  17517. *------------------------------------------------------------------------*/
  17518. uA.f = a;
  17519. uiA64 = uA.s.signExp;
  17520. sign = signExtF80UI64( uiA64 );
  17521. exp = expExtF80UI64( uiA64 );
  17522. sig = uA.s.signif;
  17523. /*------------------------------------------------------------------------
  17524. *------------------------------------------------------------------------*/
  17525. #if (ui32_fromNaN != ui32_fromPosOverflow) || (ui32_fromNaN != ui32_fromNegOverflow)
  17526. if ( (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ) {
  17527. #if (ui32_fromNaN == ui32_fromPosOverflow)
  17528. sign = 0;
  17529. #elif (ui32_fromNaN == ui32_fromNegOverflow)
  17530. sign = 1;
  17531. #else
  17532. softfloat_raiseFlags( softfloat_flag_invalid );
  17533. return ui32_fromNaN;
  17534. #endif
  17535. }
  17536. #endif
  17537. /*------------------------------------------------------------------------
  17538. *------------------------------------------------------------------------*/
  17539. shiftDist = 0x4032 - exp;
  17540. if ( shiftDist <= 0 ) shiftDist = 1;
  17541. sig = softfloat_shiftRightJam64( sig, shiftDist );
  17542. return softfloat_roundToUI32( sign, sig, roundingMode, exact );
  17543. }
  17544. /**** ended inlining ../../source/extF80_to_ui32.c ****/
  17545. /**** start inlining ../../source/extF80_to_ui64.c ****/
  17546. /*============================================================================
  17547. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  17548. Package, Release 3e, by John R. Hauser.
  17549. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  17550. University of California. All rights reserved.
  17551. Redistribution and use in source and binary forms, with or without
  17552. modification, are permitted provided that the following conditions are met:
  17553. 1. Redistributions of source code must retain the above copyright notice,
  17554. this list of conditions, and the following disclaimer.
  17555. 2. Redistributions in binary form must reproduce the above copyright notice,
  17556. this list of conditions, and the following disclaimer in the documentation
  17557. and/or other materials provided with the distribution.
  17558. 3. Neither the name of the University nor the names of its contributors may
  17559. be used to endorse or promote products derived from this software without
  17560. specific prior written permission.
  17561. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  17562. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17563. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  17564. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  17565. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  17566. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  17567. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  17568. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  17569. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  17570. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  17571. =============================================================================*/
  17572. #include <stdbool.h>
  17573. #include <stdint.h>
  17574. /**** skipping file: platform.h ****/
  17575. /**** skipping file: internals.h ****/
  17576. /**** skipping file: specialize.h ****/
  17577. /**** skipping file: softfloat.h ****/
  17578. uint_fast64_t
  17579. extF80_to_ui64( extFloat80_t a, uint_fast8_t roundingMode, bool exact )
  17580. {
  17581. union { struct extFloat80M s; extFloat80_t f; } uA;
  17582. uint_fast16_t uiA64;
  17583. bool sign;
  17584. int_fast32_t exp;
  17585. uint_fast64_t sig;
  17586. int_fast32_t shiftDist;
  17587. uint_fast64_t sigExtra;
  17588. struct uint64_extra sig64Extra;
  17589. /*------------------------------------------------------------------------
  17590. *------------------------------------------------------------------------*/
  17591. uA.f = a;
  17592. uiA64 = uA.s.signExp;
  17593. sign = signExtF80UI64( uiA64 );
  17594. exp = expExtF80UI64( uiA64 );
  17595. sig = uA.s.signif;
  17596. /*------------------------------------------------------------------------
  17597. *------------------------------------------------------------------------*/
  17598. shiftDist = 0x403E - exp;
  17599. if ( shiftDist < 0 ) {
  17600. softfloat_raiseFlags( softfloat_flag_invalid );
  17601. return
  17602. (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
  17603. ? ui64_fromNaN
  17604. : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
  17605. }
  17606. /*------------------------------------------------------------------------
  17607. *------------------------------------------------------------------------*/
  17608. sigExtra = 0;
  17609. if ( shiftDist ) {
  17610. sig64Extra = softfloat_shiftRightJam64Extra( sig, 0, shiftDist );
  17611. sig = sig64Extra.v;
  17612. sigExtra = sig64Extra.extra;
  17613. }
  17614. return softfloat_roundToUI64( sign, sig, sigExtra, roundingMode, exact );
  17615. }
  17616. /**** ended inlining ../../source/extF80_to_ui64.c ****/
  17617. /**** start inlining ../../source/extF80_to_i32.c ****/
  17618. /*============================================================================
  17619. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  17620. Package, Release 3e, by John R. Hauser.
  17621. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  17622. University of California. All rights reserved.
  17623. Redistribution and use in source and binary forms, with or without
  17624. modification, are permitted provided that the following conditions are met:
  17625. 1. Redistributions of source code must retain the above copyright notice,
  17626. this list of conditions, and the following disclaimer.
  17627. 2. Redistributions in binary form must reproduce the above copyright notice,
  17628. this list of conditions, and the following disclaimer in the documentation
  17629. and/or other materials provided with the distribution.
  17630. 3. Neither the name of the University nor the names of its contributors may
  17631. be used to endorse or promote products derived from this software without
  17632. specific prior written permission.
  17633. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  17634. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17635. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  17636. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  17637. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  17638. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  17639. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  17640. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  17641. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  17642. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  17643. =============================================================================*/
  17644. #include <stdbool.h>
  17645. #include <stdint.h>
  17646. /**** skipping file: platform.h ****/
  17647. /**** skipping file: internals.h ****/
  17648. /**** skipping file: specialize.h ****/
  17649. /**** skipping file: softfloat.h ****/
  17650. int_fast32_t
  17651. extF80_to_i32( extFloat80_t a, uint_fast8_t roundingMode, bool exact )
  17652. {
  17653. union { struct extFloat80M s; extFloat80_t f; } uA;
  17654. uint_fast16_t uiA64;
  17655. bool sign;
  17656. int_fast32_t exp;
  17657. uint_fast64_t sig;
  17658. int_fast32_t shiftDist;
  17659. /*------------------------------------------------------------------------
  17660. *------------------------------------------------------------------------*/
  17661. uA.f = a;
  17662. uiA64 = uA.s.signExp;
  17663. sign = signExtF80UI64( uiA64 );
  17664. exp = expExtF80UI64( uiA64 );
  17665. sig = uA.s.signif;
  17666. /*------------------------------------------------------------------------
  17667. *------------------------------------------------------------------------*/
  17668. #if (i32_fromNaN != i32_fromPosOverflow) || (i32_fromNaN != i32_fromNegOverflow)
  17669. if ( (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ) {
  17670. #if (i32_fromNaN == i32_fromPosOverflow)
  17671. sign = 0;
  17672. #elif (i32_fromNaN == i32_fromNegOverflow)
  17673. sign = 1;
  17674. #else
  17675. softfloat_raiseFlags( softfloat_flag_invalid );
  17676. return i32_fromNaN;
  17677. #endif
  17678. }
  17679. #endif
  17680. /*------------------------------------------------------------------------
  17681. *------------------------------------------------------------------------*/
  17682. shiftDist = 0x4032 - exp;
  17683. if ( shiftDist <= 0 ) shiftDist = 1;
  17684. sig = softfloat_shiftRightJam64( sig, shiftDist );
  17685. return softfloat_roundToI32( sign, sig, roundingMode, exact );
  17686. }
  17687. /**** ended inlining ../../source/extF80_to_i32.c ****/
  17688. /**** start inlining ../../source/extF80_to_i64.c ****/
  17689. /*============================================================================
  17690. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  17691. Package, Release 3e, by John R. Hauser.
  17692. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  17693. University of California. All rights reserved.
  17694. Redistribution and use in source and binary forms, with or without
  17695. modification, are permitted provided that the following conditions are met:
  17696. 1. Redistributions of source code must retain the above copyright notice,
  17697. this list of conditions, and the following disclaimer.
  17698. 2. Redistributions in binary form must reproduce the above copyright notice,
  17699. this list of conditions, and the following disclaimer in the documentation
  17700. and/or other materials provided with the distribution.
  17701. 3. Neither the name of the University nor the names of its contributors may
  17702. be used to endorse or promote products derived from this software without
  17703. specific prior written permission.
  17704. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  17705. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17706. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  17707. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  17708. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  17709. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  17710. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  17711. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  17712. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  17713. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  17714. =============================================================================*/
  17715. #include <stdbool.h>
  17716. #include <stdint.h>
  17717. /**** skipping file: platform.h ****/
  17718. /**** skipping file: internals.h ****/
  17719. /**** skipping file: specialize.h ****/
  17720. /**** skipping file: softfloat.h ****/
  17721. int_fast64_t
  17722. extF80_to_i64( extFloat80_t a, uint_fast8_t roundingMode, bool exact )
  17723. {
  17724. union { struct extFloat80M s; extFloat80_t f; } uA;
  17725. uint_fast16_t uiA64;
  17726. bool sign;
  17727. int_fast32_t exp;
  17728. uint_fast64_t sig;
  17729. int_fast32_t shiftDist;
  17730. uint_fast64_t sigExtra;
  17731. struct uint64_extra sig64Extra;
  17732. /*------------------------------------------------------------------------
  17733. *------------------------------------------------------------------------*/
  17734. uA.f = a;
  17735. uiA64 = uA.s.signExp;
  17736. sign = signExtF80UI64( uiA64 );
  17737. exp = expExtF80UI64( uiA64 );
  17738. sig = uA.s.signif;
  17739. /*------------------------------------------------------------------------
  17740. *------------------------------------------------------------------------*/
  17741. shiftDist = 0x403E - exp;
  17742. if ( shiftDist <= 0 ) {
  17743. /*--------------------------------------------------------------------
  17744. *--------------------------------------------------------------------*/
  17745. if ( shiftDist ) {
  17746. softfloat_raiseFlags( softfloat_flag_invalid );
  17747. return
  17748. (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
  17749. ? i64_fromNaN
  17750. : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
  17751. }
  17752. /*--------------------------------------------------------------------
  17753. *--------------------------------------------------------------------*/
  17754. sigExtra = 0;
  17755. } else {
  17756. /*--------------------------------------------------------------------
  17757. *--------------------------------------------------------------------*/
  17758. sig64Extra = softfloat_shiftRightJam64Extra( sig, 0, shiftDist );
  17759. sig = sig64Extra.v;
  17760. sigExtra = sig64Extra.extra;
  17761. }
  17762. return softfloat_roundToI64( sign, sig, sigExtra, roundingMode, exact );
  17763. }
  17764. /**** ended inlining ../../source/extF80_to_i64.c ****/
  17765. /**** start inlining ../../source/extF80_to_ui32_r_minMag.c ****/
  17766. /*============================================================================
  17767. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  17768. Package, Release 3e, by John R. Hauser.
  17769. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  17770. California. All rights reserved.
  17771. Redistribution and use in source and binary forms, with or without
  17772. modification, are permitted provided that the following conditions are met:
  17773. 1. Redistributions of source code must retain the above copyright notice,
  17774. this list of conditions, and the following disclaimer.
  17775. 2. Redistributions in binary form must reproduce the above copyright notice,
  17776. this list of conditions, and the following disclaimer in the documentation
  17777. and/or other materials provided with the distribution.
  17778. 3. Neither the name of the University nor the names of its contributors may
  17779. be used to endorse or promote products derived from this software without
  17780. specific prior written permission.
  17781. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  17782. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17783. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  17784. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  17785. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  17786. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  17787. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  17788. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  17789. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  17790. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  17791. =============================================================================*/
  17792. #include <stdbool.h>
  17793. #include <stdint.h>
  17794. /**** skipping file: platform.h ****/
  17795. /**** skipping file: internals.h ****/
  17796. /**** skipping file: specialize.h ****/
  17797. /**** skipping file: softfloat.h ****/
  17798. uint_fast32_t extF80_to_ui32_r_minMag( extFloat80_t a, bool exact )
  17799. {
  17800. union { struct extFloat80M s; extFloat80_t f; } uA;
  17801. uint_fast16_t uiA64;
  17802. int_fast32_t exp;
  17803. uint_fast64_t sig;
  17804. int_fast32_t shiftDist;
  17805. bool sign;
  17806. uint_fast32_t z;
  17807. /*------------------------------------------------------------------------
  17808. *------------------------------------------------------------------------*/
  17809. uA.f = a;
  17810. uiA64 = uA.s.signExp;
  17811. exp = expExtF80UI64( uiA64 );
  17812. sig = uA.s.signif;
  17813. /*------------------------------------------------------------------------
  17814. *------------------------------------------------------------------------*/
  17815. shiftDist = 0x403E - exp;
  17816. if ( 64 <= shiftDist ) {
  17817. if ( exact && (exp | sig) ) {
  17818. softfloat_exceptionFlags |= softfloat_flag_inexact;
  17819. }
  17820. return 0;
  17821. }
  17822. /*------------------------------------------------------------------------
  17823. *------------------------------------------------------------------------*/
  17824. sign = signExtF80UI64( uiA64 );
  17825. if ( sign || (shiftDist < 32) ) {
  17826. softfloat_raiseFlags( softfloat_flag_invalid );
  17827. return
  17828. (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
  17829. ? ui32_fromNaN
  17830. : sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
  17831. }
  17832. /*------------------------------------------------------------------------
  17833. *------------------------------------------------------------------------*/
  17834. z = sig>>shiftDist;
  17835. if ( exact && ((uint_fast64_t) z<<shiftDist != sig) ) {
  17836. softfloat_exceptionFlags |= softfloat_flag_inexact;
  17837. }
  17838. return z;
  17839. }
  17840. /**** ended inlining ../../source/extF80_to_ui32_r_minMag.c ****/
  17841. /**** start inlining ../../source/extF80_to_ui64_r_minMag.c ****/
  17842. /*============================================================================
  17843. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  17844. Package, Release 3e, by John R. Hauser.
  17845. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  17846. California. All rights reserved.
  17847. Redistribution and use in source and binary forms, with or without
  17848. modification, are permitted provided that the following conditions are met:
  17849. 1. Redistributions of source code must retain the above copyright notice,
  17850. this list of conditions, and the following disclaimer.
  17851. 2. Redistributions in binary form must reproduce the above copyright notice,
  17852. this list of conditions, and the following disclaimer in the documentation
  17853. and/or other materials provided with the distribution.
  17854. 3. Neither the name of the University nor the names of its contributors may
  17855. be used to endorse or promote products derived from this software without
  17856. specific prior written permission.
  17857. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  17858. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17859. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  17860. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  17861. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  17862. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  17863. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  17864. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  17865. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  17866. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  17867. =============================================================================*/
  17868. #include <stdbool.h>
  17869. #include <stdint.h>
  17870. /**** skipping file: platform.h ****/
  17871. /**** skipping file: internals.h ****/
  17872. /**** skipping file: specialize.h ****/
  17873. /**** skipping file: softfloat.h ****/
  17874. uint_fast64_t extF80_to_ui64_r_minMag( extFloat80_t a, bool exact )
  17875. {
  17876. union { struct extFloat80M s; extFloat80_t f; } uA;
  17877. uint_fast16_t uiA64;
  17878. int_fast32_t exp;
  17879. uint_fast64_t sig;
  17880. int_fast32_t shiftDist;
  17881. bool sign;
  17882. uint_fast64_t z;
  17883. /*------------------------------------------------------------------------
  17884. *------------------------------------------------------------------------*/
  17885. uA.f = a;
  17886. uiA64 = uA.s.signExp;
  17887. exp = expExtF80UI64( uiA64 );
  17888. sig = uA.s.signif;
  17889. /*------------------------------------------------------------------------
  17890. *------------------------------------------------------------------------*/
  17891. shiftDist = 0x403E - exp;
  17892. if ( 64 <= shiftDist ) {
  17893. if ( exact && (exp | sig) ) {
  17894. softfloat_exceptionFlags |= softfloat_flag_inexact;
  17895. }
  17896. return 0;
  17897. }
  17898. /*------------------------------------------------------------------------
  17899. *------------------------------------------------------------------------*/
  17900. sign = signExtF80UI64( uiA64 );
  17901. if ( sign || (shiftDist < 0) ) {
  17902. softfloat_raiseFlags( softfloat_flag_invalid );
  17903. return
  17904. (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
  17905. ? ui64_fromNaN
  17906. : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
  17907. }
  17908. /*------------------------------------------------------------------------
  17909. *------------------------------------------------------------------------*/
  17910. z = sig>>shiftDist;
  17911. if ( exact && (z<<shiftDist != sig) ) {
  17912. softfloat_exceptionFlags |= softfloat_flag_inexact;
  17913. }
  17914. return z;
  17915. }
  17916. /**** ended inlining ../../source/extF80_to_ui64_r_minMag.c ****/
  17917. /**** start inlining ../../source/extF80_to_i32_r_minMag.c ****/
  17918. /*============================================================================
  17919. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  17920. Package, Release 3e, by John R. Hauser.
  17921. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  17922. California. All rights reserved.
  17923. Redistribution and use in source and binary forms, with or without
  17924. modification, are permitted provided that the following conditions are met:
  17925. 1. Redistributions of source code must retain the above copyright notice,
  17926. this list of conditions, and the following disclaimer.
  17927. 2. Redistributions in binary form must reproduce the above copyright notice,
  17928. this list of conditions, and the following disclaimer in the documentation
  17929. and/or other materials provided with the distribution.
  17930. 3. Neither the name of the University nor the names of its contributors may
  17931. be used to endorse or promote products derived from this software without
  17932. specific prior written permission.
  17933. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  17934. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17935. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  17936. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  17937. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  17938. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  17939. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  17940. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  17941. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  17942. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  17943. =============================================================================*/
  17944. #include <stdbool.h>
  17945. #include <stdint.h>
  17946. /**** skipping file: platform.h ****/
  17947. /**** skipping file: internals.h ****/
  17948. /**** skipping file: specialize.h ****/
  17949. /**** skipping file: softfloat.h ****/
  17950. int_fast32_t extF80_to_i32_r_minMag( extFloat80_t a, bool exact )
  17951. {
  17952. union { struct extFloat80M s; extFloat80_t f; } uA;
  17953. uint_fast16_t uiA64;
  17954. int_fast32_t exp;
  17955. uint_fast64_t sig;
  17956. int_fast32_t shiftDist;
  17957. bool sign;
  17958. int_fast32_t absZ;
  17959. /*------------------------------------------------------------------------
  17960. *------------------------------------------------------------------------*/
  17961. uA.f = a;
  17962. uiA64 = uA.s.signExp;
  17963. exp = expExtF80UI64( uiA64 );
  17964. sig = uA.s.signif;
  17965. /*------------------------------------------------------------------------
  17966. *------------------------------------------------------------------------*/
  17967. shiftDist = 0x403E - exp;
  17968. if ( 64 <= shiftDist ) {
  17969. if ( exact && (exp | sig) ) {
  17970. softfloat_exceptionFlags |= softfloat_flag_inexact;
  17971. }
  17972. return 0;
  17973. }
  17974. /*------------------------------------------------------------------------
  17975. *------------------------------------------------------------------------*/
  17976. sign = signExtF80UI64( uiA64 );
  17977. if ( shiftDist < 33 ) {
  17978. if (
  17979. (uiA64 == packToExtF80UI64( 1, 0x401E ))
  17980. && (sig < UINT64_C( 0x8000000100000000 ))
  17981. ) {
  17982. if ( exact && (sig & UINT64_C( 0x00000000FFFFFFFF )) ) {
  17983. softfloat_exceptionFlags |= softfloat_flag_inexact;
  17984. }
  17985. return -0x7FFFFFFF - 1;
  17986. }
  17987. softfloat_raiseFlags( softfloat_flag_invalid );
  17988. return
  17989. (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
  17990. ? i32_fromNaN
  17991. : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
  17992. }
  17993. /*------------------------------------------------------------------------
  17994. *------------------------------------------------------------------------*/
  17995. absZ = sig>>shiftDist;
  17996. if ( exact && ((uint_fast64_t) (uint_fast32_t) absZ<<shiftDist != sig) ) {
  17997. softfloat_exceptionFlags |= softfloat_flag_inexact;
  17998. }
  17999. return sign ? -absZ : absZ;
  18000. }
  18001. /**** ended inlining ../../source/extF80_to_i32_r_minMag.c ****/
  18002. /**** start inlining ../../source/extF80_to_i64_r_minMag.c ****/
  18003. /*============================================================================
  18004. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  18005. Package, Release 3e, by John R. Hauser.
  18006. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  18007. California. All rights reserved.
  18008. Redistribution and use in source and binary forms, with or without
  18009. modification, are permitted provided that the following conditions are met:
  18010. 1. Redistributions of source code must retain the above copyright notice,
  18011. this list of conditions, and the following disclaimer.
  18012. 2. Redistributions in binary form must reproduce the above copyright notice,
  18013. this list of conditions, and the following disclaimer in the documentation
  18014. and/or other materials provided with the distribution.
  18015. 3. Neither the name of the University nor the names of its contributors may
  18016. be used to endorse or promote products derived from this software without
  18017. specific prior written permission.
  18018. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  18019. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18020. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  18021. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  18022. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  18023. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  18024. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  18025. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  18026. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  18027. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  18028. =============================================================================*/
  18029. #include <stdbool.h>
  18030. #include <stdint.h>
  18031. /**** skipping file: platform.h ****/
  18032. /**** skipping file: internals.h ****/
  18033. /**** skipping file: specialize.h ****/
  18034. /**** skipping file: softfloat.h ****/
  18035. int_fast64_t extF80_to_i64_r_minMag( extFloat80_t a, bool exact )
  18036. {
  18037. union { struct extFloat80M s; extFloat80_t f; } uA;
  18038. uint_fast16_t uiA64;
  18039. int_fast32_t exp;
  18040. uint_fast64_t sig;
  18041. int_fast32_t shiftDist;
  18042. bool sign;
  18043. int_fast64_t absZ;
  18044. /*------------------------------------------------------------------------
  18045. *------------------------------------------------------------------------*/
  18046. uA.f = a;
  18047. uiA64 = uA.s.signExp;
  18048. exp = expExtF80UI64( uiA64 );
  18049. sig = uA.s.signif;
  18050. /*------------------------------------------------------------------------
  18051. *------------------------------------------------------------------------*/
  18052. shiftDist = 0x403E - exp;
  18053. if ( 64 <= shiftDist ) {
  18054. if ( exact && (exp | sig) ) {
  18055. softfloat_exceptionFlags |= softfloat_flag_inexact;
  18056. }
  18057. return 0;
  18058. }
  18059. /*------------------------------------------------------------------------
  18060. *------------------------------------------------------------------------*/
  18061. sign = signExtF80UI64( uiA64 );
  18062. if ( shiftDist <= 0 ) {
  18063. if (
  18064. (uiA64 == packToExtF80UI64( 1, 0x403E ))
  18065. && (sig == UINT64_C( 0x8000000000000000 ))
  18066. ) {
  18067. return -INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1;
  18068. }
  18069. softfloat_raiseFlags( softfloat_flag_invalid );
  18070. return
  18071. (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
  18072. ? i64_fromNaN
  18073. : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
  18074. }
  18075. /*------------------------------------------------------------------------
  18076. *------------------------------------------------------------------------*/
  18077. absZ = sig>>shiftDist;
  18078. if ( exact && (uint64_t) (sig<<(-shiftDist & 63)) ) {
  18079. softfloat_exceptionFlags |= softfloat_flag_inexact;
  18080. }
  18081. return sign ? -absZ : absZ;
  18082. }
  18083. /**** ended inlining ../../source/extF80_to_i64_r_minMag.c ****/
  18084. /**** start inlining ../../source/extF80_to_f16.c ****/
  18085. /*============================================================================
  18086. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  18087. Package, Release 3e, by John R. Hauser.
  18088. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  18089. California. All rights reserved.
  18090. Redistribution and use in source and binary forms, with or without
  18091. modification, are permitted provided that the following conditions are met:
  18092. 1. Redistributions of source code must retain the above copyright notice,
  18093. this list of conditions, and the following disclaimer.
  18094. 2. Redistributions in binary form must reproduce the above copyright notice,
  18095. this list of conditions, and the following disclaimer in the documentation
  18096. and/or other materials provided with the distribution.
  18097. 3. Neither the name of the University nor the names of its contributors may
  18098. be used to endorse or promote products derived from this software without
  18099. specific prior written permission.
  18100. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  18101. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18102. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  18103. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  18104. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  18105. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  18106. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  18107. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  18108. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  18109. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  18110. =============================================================================*/
  18111. #include <stdbool.h>
  18112. #include <stdint.h>
  18113. /**** skipping file: platform.h ****/
  18114. /**** skipping file: internals.h ****/
  18115. /**** skipping file: specialize.h ****/
  18116. /**** skipping file: softfloat.h ****/
  18117. float16_t extF80_to_f16( extFloat80_t a )
  18118. {
  18119. union { struct extFloat80M s; extFloat80_t f; } uA;
  18120. uint_fast16_t uiA64;
  18121. uint_fast64_t uiA0;
  18122. bool sign;
  18123. int_fast32_t exp;
  18124. uint_fast64_t sig;
  18125. struct commonNaN commonNaN;
  18126. uint_fast16_t uiZ, sig16;
  18127. union ui16_f16 uZ;
  18128. /*------------------------------------------------------------------------
  18129. *------------------------------------------------------------------------*/
  18130. uA.f = a;
  18131. uiA64 = uA.s.signExp;
  18132. uiA0 = uA.s.signif;
  18133. sign = signExtF80UI64( uiA64 );
  18134. exp = expExtF80UI64( uiA64 );
  18135. sig = uiA0;
  18136. /*------------------------------------------------------------------------
  18137. *------------------------------------------------------------------------*/
  18138. if ( exp == 0x7FFF ) {
  18139. if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
  18140. softfloat_extF80UIToCommonNaN( uiA64, uiA0, &commonNaN );
  18141. uiZ = softfloat_commonNaNToF16UI( &commonNaN );
  18142. } else {
  18143. uiZ = packToF16UI( sign, 0x1F, 0 );
  18144. }
  18145. goto uiZ;
  18146. }
  18147. /*------------------------------------------------------------------------
  18148. *------------------------------------------------------------------------*/
  18149. sig16 = softfloat_shortShiftRightJam64( sig, 49 );
  18150. if ( ! (exp | sig16) ) {
  18151. uiZ = packToF16UI( sign, 0, 0 );
  18152. goto uiZ;
  18153. }
  18154. /*------------------------------------------------------------------------
  18155. *------------------------------------------------------------------------*/
  18156. exp -= 0x3FF1;
  18157. if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
  18158. if ( exp < -0x40 ) exp = -0x40;
  18159. }
  18160. return softfloat_roundPackToF16( sign, exp, sig16 );
  18161. /*------------------------------------------------------------------------
  18162. *------------------------------------------------------------------------*/
  18163. uiZ:
  18164. uZ.ui = uiZ;
  18165. return uZ.f;
  18166. }
  18167. /**** ended inlining ../../source/extF80_to_f16.c ****/
  18168. /**** start inlining ../../source/extF80_to_f32.c ****/
  18169. /*============================================================================
  18170. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  18171. Package, Release 3e, by John R. Hauser.
  18172. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  18173. California. All rights reserved.
  18174. Redistribution and use in source and binary forms, with or without
  18175. modification, are permitted provided that the following conditions are met:
  18176. 1. Redistributions of source code must retain the above copyright notice,
  18177. this list of conditions, and the following disclaimer.
  18178. 2. Redistributions in binary form must reproduce the above copyright notice,
  18179. this list of conditions, and the following disclaimer in the documentation
  18180. and/or other materials provided with the distribution.
  18181. 3. Neither the name of the University nor the names of its contributors may
  18182. be used to endorse or promote products derived from this software without
  18183. specific prior written permission.
  18184. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  18185. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18186. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  18187. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  18188. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  18189. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  18190. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  18191. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  18192. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  18193. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  18194. =============================================================================*/
  18195. #include <stdbool.h>
  18196. #include <stdint.h>
  18197. /**** skipping file: platform.h ****/
  18198. /**** skipping file: internals.h ****/
  18199. /**** skipping file: specialize.h ****/
  18200. /**** skipping file: softfloat.h ****/
  18201. float32_t extF80_to_f32( extFloat80_t a )
  18202. {
  18203. union { struct extFloat80M s; extFloat80_t f; } uA;
  18204. uint_fast16_t uiA64;
  18205. uint_fast64_t uiA0;
  18206. bool sign;
  18207. int_fast32_t exp;
  18208. uint_fast64_t sig;
  18209. struct commonNaN commonNaN;
  18210. uint_fast32_t uiZ, sig32;
  18211. union ui32_f32 uZ;
  18212. /*------------------------------------------------------------------------
  18213. *------------------------------------------------------------------------*/
  18214. uA.f = a;
  18215. uiA64 = uA.s.signExp;
  18216. uiA0 = uA.s.signif;
  18217. sign = signExtF80UI64( uiA64 );
  18218. exp = expExtF80UI64( uiA64 );
  18219. sig = uiA0;
  18220. /*------------------------------------------------------------------------
  18221. *------------------------------------------------------------------------*/
  18222. if ( exp == 0x7FFF ) {
  18223. if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
  18224. softfloat_extF80UIToCommonNaN( uiA64, uiA0, &commonNaN );
  18225. uiZ = softfloat_commonNaNToF32UI( &commonNaN );
  18226. } else {
  18227. uiZ = packToF32UI( sign, 0xFF, 0 );
  18228. }
  18229. goto uiZ;
  18230. }
  18231. /*------------------------------------------------------------------------
  18232. *------------------------------------------------------------------------*/
  18233. sig32 = softfloat_shortShiftRightJam64( sig, 33 );
  18234. if ( ! (exp | sig32) ) {
  18235. uiZ = packToF32UI( sign, 0, 0 );
  18236. goto uiZ;
  18237. }
  18238. /*------------------------------------------------------------------------
  18239. *------------------------------------------------------------------------*/
  18240. exp -= 0x3F81;
  18241. if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
  18242. if ( exp < -0x1000 ) exp = -0x1000;
  18243. }
  18244. return softfloat_roundPackToF32( sign, exp, sig32 );
  18245. /*------------------------------------------------------------------------
  18246. *------------------------------------------------------------------------*/
  18247. uiZ:
  18248. uZ.ui = uiZ;
  18249. return uZ.f;
  18250. }
  18251. /**** ended inlining ../../source/extF80_to_f32.c ****/
  18252. /**** start inlining ../../source/extF80_to_f64.c ****/
  18253. /*============================================================================
  18254. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  18255. Package, Release 3e, by John R. Hauser.
  18256. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  18257. California. All rights reserved.
  18258. Redistribution and use in source and binary forms, with or without
  18259. modification, are permitted provided that the following conditions are met:
  18260. 1. Redistributions of source code must retain the above copyright notice,
  18261. this list of conditions, and the following disclaimer.
  18262. 2. Redistributions in binary form must reproduce the above copyright notice,
  18263. this list of conditions, and the following disclaimer in the documentation
  18264. and/or other materials provided with the distribution.
  18265. 3. Neither the name of the University nor the names of its contributors may
  18266. be used to endorse or promote products derived from this software without
  18267. specific prior written permission.
  18268. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  18269. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18270. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  18271. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  18272. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  18273. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  18274. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  18275. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  18276. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  18277. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  18278. =============================================================================*/
  18279. #include <stdbool.h>
  18280. #include <stdint.h>
  18281. /**** skipping file: platform.h ****/
  18282. /**** skipping file: internals.h ****/
  18283. /**** skipping file: specialize.h ****/
  18284. /**** skipping file: softfloat.h ****/
  18285. float64_t extF80_to_f64( extFloat80_t a )
  18286. {
  18287. union { struct extFloat80M s; extFloat80_t f; } uA;
  18288. uint_fast16_t uiA64;
  18289. uint_fast64_t uiA0;
  18290. bool sign;
  18291. int_fast32_t exp;
  18292. uint_fast64_t sig;
  18293. struct commonNaN commonNaN;
  18294. uint_fast64_t uiZ;
  18295. union ui64_f64 uZ;
  18296. /*------------------------------------------------------------------------
  18297. *------------------------------------------------------------------------*/
  18298. uA.f = a;
  18299. uiA64 = uA.s.signExp;
  18300. uiA0 = uA.s.signif;
  18301. sign = signExtF80UI64( uiA64 );
  18302. exp = expExtF80UI64( uiA64 );
  18303. sig = uiA0;
  18304. /*------------------------------------------------------------------------
  18305. *------------------------------------------------------------------------*/
  18306. if ( ! (exp | sig) ) {
  18307. uiZ = packToF64UI( sign, 0, 0 );
  18308. goto uiZ;
  18309. }
  18310. /*------------------------------------------------------------------------
  18311. *------------------------------------------------------------------------*/
  18312. if ( exp == 0x7FFF ) {
  18313. if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
  18314. softfloat_extF80UIToCommonNaN( uiA64, uiA0, &commonNaN );
  18315. uiZ = softfloat_commonNaNToF64UI( &commonNaN );
  18316. } else {
  18317. uiZ = packToF64UI( sign, 0x7FF, 0 );
  18318. }
  18319. goto uiZ;
  18320. }
  18321. /*------------------------------------------------------------------------
  18322. *------------------------------------------------------------------------*/
  18323. sig = softfloat_shortShiftRightJam64( sig, 1 );
  18324. exp -= 0x3C01;
  18325. if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
  18326. if ( exp < -0x1000 ) exp = -0x1000;
  18327. }
  18328. return softfloat_roundPackToF64( sign, exp, sig );
  18329. /*------------------------------------------------------------------------
  18330. *------------------------------------------------------------------------*/
  18331. uiZ:
  18332. uZ.ui = uiZ;
  18333. return uZ.f;
  18334. }
  18335. /**** ended inlining ../../source/extF80_to_f64.c ****/
  18336. /**** start inlining ../../source/extF80_to_f128.c ****/
  18337. /*============================================================================
  18338. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  18339. Package, Release 3e, by John R. Hauser.
  18340. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  18341. All rights reserved.
  18342. Redistribution and use in source and binary forms, with or without
  18343. modification, are permitted provided that the following conditions are met:
  18344. 1. Redistributions of source code must retain the above copyright notice,
  18345. this list of conditions, and the following disclaimer.
  18346. 2. Redistributions in binary form must reproduce the above copyright notice,
  18347. this list of conditions, and the following disclaimer in the documentation
  18348. and/or other materials provided with the distribution.
  18349. 3. Neither the name of the University nor the names of its contributors may
  18350. be used to endorse or promote products derived from this software without
  18351. specific prior written permission.
  18352. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  18353. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18354. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  18355. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  18356. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  18357. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  18358. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  18359. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  18360. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  18361. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  18362. =============================================================================*/
  18363. #include <stdbool.h>
  18364. #include <stdint.h>
  18365. /**** skipping file: platform.h ****/
  18366. /**** skipping file: internals.h ****/
  18367. /**** skipping file: specialize.h ****/
  18368. /**** skipping file: softfloat.h ****/
  18369. float128_t extF80_to_f128( extFloat80_t a )
  18370. {
  18371. union { struct extFloat80M s; extFloat80_t f; } uA;
  18372. uint_fast16_t uiA64;
  18373. uint_fast64_t uiA0;
  18374. uint_fast16_t exp;
  18375. uint_fast64_t frac;
  18376. struct commonNaN commonNaN;
  18377. struct uint128 uiZ;
  18378. bool sign;
  18379. struct uint128 frac128;
  18380. union ui128_f128 uZ;
  18381. uA.f = a;
  18382. uiA64 = uA.s.signExp;
  18383. uiA0 = uA.s.signif;
  18384. exp = expExtF80UI64( uiA64 );
  18385. frac = uiA0 & UINT64_C( 0x7FFFFFFFFFFFFFFF );
  18386. if ( (exp == 0x7FFF) && frac ) {
  18387. softfloat_extF80UIToCommonNaN( uiA64, uiA0, &commonNaN );
  18388. uiZ = softfloat_commonNaNToF128UI( &commonNaN );
  18389. } else {
  18390. sign = signExtF80UI64( uiA64 );
  18391. frac128 = softfloat_shortShiftLeft128( 0, frac, 49 );
  18392. uiZ.v64 = packToF128UI64( sign, exp, frac128.v64 );
  18393. uiZ.v0 = frac128.v0;
  18394. }
  18395. uZ.ui = uiZ;
  18396. return uZ.f;
  18397. }
  18398. /**** ended inlining ../../source/extF80_to_f128.c ****/
  18399. /**** start inlining ../../source/extF80_roundToInt.c ****/
  18400. /*============================================================================
  18401. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  18402. Package, Release 3e, by John R. Hauser.
  18403. Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
  18404. California. All rights reserved.
  18405. Redistribution and use in source and binary forms, with or without
  18406. modification, are permitted provided that the following conditions are met:
  18407. 1. Redistributions of source code must retain the above copyright notice,
  18408. this list of conditions, and the following disclaimer.
  18409. 2. Redistributions in binary form must reproduce the above copyright notice,
  18410. this list of conditions, and the following disclaimer in the documentation
  18411. and/or other materials provided with the distribution.
  18412. 3. Neither the name of the University nor the names of its contributors may
  18413. be used to endorse or promote products derived from this software without
  18414. specific prior written permission.
  18415. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  18416. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18417. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  18418. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  18419. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  18420. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  18421. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  18422. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  18423. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  18424. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  18425. =============================================================================*/
  18426. #include <stdbool.h>
  18427. #include <stdint.h>
  18428. /**** skipping file: platform.h ****/
  18429. /**** skipping file: internals.h ****/
  18430. /**** skipping file: specialize.h ****/
  18431. /**** skipping file: softfloat.h ****/
  18432. extFloat80_t
  18433. extF80_roundToInt( extFloat80_t a, uint_fast8_t roundingMode, bool exact )
  18434. {
  18435. union { struct extFloat80M s; extFloat80_t f; } uA;
  18436. uint_fast16_t uiA64, signUI64;
  18437. int_fast32_t exp;
  18438. uint_fast64_t sigA;
  18439. uint_fast16_t uiZ64;
  18440. uint_fast64_t sigZ;
  18441. struct exp32_sig64 normExpSig;
  18442. struct uint128 uiZ;
  18443. uint_fast64_t lastBitMask, roundBitsMask;
  18444. union { struct extFloat80M s; extFloat80_t f; } uZ;
  18445. /*------------------------------------------------------------------------
  18446. *------------------------------------------------------------------------*/
  18447. uA.f = a;
  18448. uiA64 = uA.s.signExp;
  18449. signUI64 = uiA64 & packToExtF80UI64( 1, 0 );
  18450. exp = expExtF80UI64( uiA64 );
  18451. sigA = uA.s.signif;
  18452. /*------------------------------------------------------------------------
  18453. *------------------------------------------------------------------------*/
  18454. if ( !(sigA & UINT64_C( 0x8000000000000000 )) && (exp != 0x7FFF) ) {
  18455. if ( !sigA ) {
  18456. uiZ64 = signUI64;
  18457. sigZ = 0;
  18458. goto uiZ;
  18459. }
  18460. normExpSig = softfloat_normSubnormalExtF80Sig( sigA );
  18461. exp += normExpSig.exp;
  18462. sigA = normExpSig.sig;
  18463. }
  18464. /*------------------------------------------------------------------------
  18465. *------------------------------------------------------------------------*/
  18466. if ( 0x403E <= exp ) {
  18467. if ( exp == 0x7FFF ) {
  18468. if ( sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
  18469. uiZ = softfloat_propagateNaNExtF80UI( uiA64, sigA, 0, 0 );
  18470. uiZ64 = uiZ.v64;
  18471. sigZ = uiZ.v0;
  18472. goto uiZ;
  18473. }
  18474. sigZ = UINT64_C( 0x8000000000000000 );
  18475. } else {
  18476. sigZ = sigA;
  18477. }
  18478. uiZ64 = signUI64 | exp;
  18479. goto uiZ;
  18480. }
  18481. if ( exp <= 0x3FFE ) {
  18482. if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
  18483. switch ( roundingMode ) {
  18484. case softfloat_round_near_even:
  18485. if ( !(sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ) break;
  18486. case softfloat_round_near_maxMag:
  18487. if ( exp == 0x3FFE ) goto mag1;
  18488. break;
  18489. case softfloat_round_min:
  18490. if ( signUI64 ) goto mag1;
  18491. break;
  18492. case softfloat_round_max:
  18493. if ( !signUI64 ) goto mag1;
  18494. break;
  18495. #ifdef SOFTFLOAT_ROUND_ODD
  18496. case softfloat_round_odd:
  18497. goto mag1;
  18498. #endif
  18499. }
  18500. uiZ64 = signUI64;
  18501. sigZ = 0;
  18502. goto uiZ;
  18503. mag1:
  18504. uiZ64 = signUI64 | 0x3FFF;
  18505. sigZ = UINT64_C( 0x8000000000000000 );
  18506. goto uiZ;
  18507. }
  18508. /*------------------------------------------------------------------------
  18509. *------------------------------------------------------------------------*/
  18510. uiZ64 = signUI64 | exp;
  18511. lastBitMask = (uint_fast64_t) 1<<(0x403E - exp);
  18512. roundBitsMask = lastBitMask - 1;
  18513. sigZ = sigA;
  18514. if ( roundingMode == softfloat_round_near_maxMag ) {
  18515. sigZ += lastBitMask>>1;
  18516. } else if ( roundingMode == softfloat_round_near_even ) {
  18517. sigZ += lastBitMask>>1;
  18518. if ( !(sigZ & roundBitsMask) ) sigZ &= ~lastBitMask;
  18519. } else if (
  18520. roundingMode == (signUI64 ? softfloat_round_min : softfloat_round_max)
  18521. ) {
  18522. sigZ += roundBitsMask;
  18523. }
  18524. sigZ &= ~roundBitsMask;
  18525. if ( !sigZ ) {
  18526. ++uiZ64;
  18527. sigZ = UINT64_C( 0x8000000000000000 );
  18528. }
  18529. if ( sigZ != sigA ) {
  18530. #ifdef SOFTFLOAT_ROUND_ODD
  18531. if ( roundingMode == softfloat_round_odd ) sigZ |= lastBitMask;
  18532. #endif
  18533. if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
  18534. }
  18535. uiZ:
  18536. uZ.s.signExp = uiZ64;
  18537. uZ.s.signif = sigZ;
  18538. return uZ.f;
  18539. }
  18540. /**** ended inlining ../../source/extF80_roundToInt.c ****/
  18541. /**** start inlining ../../source/extF80_add.c ****/
  18542. /*============================================================================
  18543. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  18544. Package, Release 3e, by John R. Hauser.
  18545. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  18546. All rights reserved.
  18547. Redistribution and use in source and binary forms, with or without
  18548. modification, are permitted provided that the following conditions are met:
  18549. 1. Redistributions of source code must retain the above copyright notice,
  18550. this list of conditions, and the following disclaimer.
  18551. 2. Redistributions in binary form must reproduce the above copyright notice,
  18552. this list of conditions, and the following disclaimer in the documentation
  18553. and/or other materials provided with the distribution.
  18554. 3. Neither the name of the University nor the names of its contributors may
  18555. be used to endorse or promote products derived from this software without
  18556. specific prior written permission.
  18557. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  18558. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18559. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  18560. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  18561. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  18562. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  18563. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  18564. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  18565. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  18566. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  18567. =============================================================================*/
  18568. #include <stdbool.h>
  18569. #include <stdint.h>
  18570. /**** skipping file: platform.h ****/
  18571. /**** skipping file: internals.h ****/
  18572. /**** skipping file: softfloat.h ****/
  18573. extFloat80_t extF80_add( extFloat80_t a, extFloat80_t b )
  18574. {
  18575. union { struct extFloat80M s; extFloat80_t f; } uA;
  18576. uint_fast16_t uiA64;
  18577. uint_fast64_t uiA0;
  18578. bool signA;
  18579. union { struct extFloat80M s; extFloat80_t f; } uB;
  18580. uint_fast16_t uiB64;
  18581. uint_fast64_t uiB0;
  18582. bool signB;
  18583. #if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
  18584. extFloat80_t
  18585. (*magsFuncPtr)(
  18586. uint_fast16_t, uint_fast64_t, uint_fast16_t, uint_fast64_t, bool );
  18587. #endif
  18588. uA.f = a;
  18589. uiA64 = uA.s.signExp;
  18590. uiA0 = uA.s.signif;
  18591. signA = signExtF80UI64( uiA64 );
  18592. uB.f = b;
  18593. uiB64 = uB.s.signExp;
  18594. uiB0 = uB.s.signif;
  18595. signB = signExtF80UI64( uiB64 );
  18596. #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
  18597. if ( signA == signB ) {
  18598. return softfloat_addMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
  18599. } else {
  18600. return softfloat_subMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
  18601. }
  18602. #else
  18603. magsFuncPtr =
  18604. (signA == signB) ? softfloat_addMagsExtF80 : softfloat_subMagsExtF80;
  18605. return (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
  18606. #endif
  18607. }
  18608. /**** ended inlining ../../source/extF80_add.c ****/
  18609. /**** start inlining ../../source/extF80_sub.c ****/
  18610. /*============================================================================
  18611. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  18612. Package, Release 3e, by John R. Hauser.
  18613. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  18614. All rights reserved.
  18615. Redistribution and use in source and binary forms, with or without
  18616. modification, are permitted provided that the following conditions are met:
  18617. 1. Redistributions of source code must retain the above copyright notice,
  18618. this list of conditions, and the following disclaimer.
  18619. 2. Redistributions in binary form must reproduce the above copyright notice,
  18620. this list of conditions, and the following disclaimer in the documentation
  18621. and/or other materials provided with the distribution.
  18622. 3. Neither the name of the University nor the names of its contributors may
  18623. be used to endorse or promote products derived from this software without
  18624. specific prior written permission.
  18625. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  18626. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18627. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  18628. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  18629. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  18630. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  18631. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  18632. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  18633. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  18634. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  18635. =============================================================================*/
  18636. #include <stdbool.h>
  18637. #include <stdint.h>
  18638. /**** skipping file: platform.h ****/
  18639. /**** skipping file: internals.h ****/
  18640. /**** skipping file: softfloat.h ****/
  18641. extFloat80_t extF80_sub( extFloat80_t a, extFloat80_t b )
  18642. {
  18643. union { struct extFloat80M s; extFloat80_t f; } uA;
  18644. uint_fast16_t uiA64;
  18645. uint_fast64_t uiA0;
  18646. bool signA;
  18647. union { struct extFloat80M s; extFloat80_t f; } uB;
  18648. uint_fast16_t uiB64;
  18649. uint_fast64_t uiB0;
  18650. bool signB;
  18651. #if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
  18652. extFloat80_t
  18653. (*magsFuncPtr)(
  18654. uint_fast16_t, uint_fast64_t, uint_fast16_t, uint_fast64_t, bool );
  18655. #endif
  18656. uA.f = a;
  18657. uiA64 = uA.s.signExp;
  18658. uiA0 = uA.s.signif;
  18659. signA = signExtF80UI64( uiA64 );
  18660. uB.f = b;
  18661. uiB64 = uB.s.signExp;
  18662. uiB0 = uB.s.signif;
  18663. signB = signExtF80UI64( uiB64 );
  18664. #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
  18665. if ( signA == signB ) {
  18666. return softfloat_subMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
  18667. } else {
  18668. return softfloat_addMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
  18669. }
  18670. #else
  18671. magsFuncPtr =
  18672. (signA == signB) ? softfloat_subMagsExtF80 : softfloat_addMagsExtF80;
  18673. return (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
  18674. #endif
  18675. }
  18676. /**** ended inlining ../../source/extF80_sub.c ****/
  18677. /**** start inlining ../../source/extF80_mul.c ****/
  18678. /*============================================================================
  18679. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  18680. Package, Release 3e, by John R. Hauser.
  18681. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  18682. All rights reserved.
  18683. Redistribution and use in source and binary forms, with or without
  18684. modification, are permitted provided that the following conditions are met:
  18685. 1. Redistributions of source code must retain the above copyright notice,
  18686. this list of conditions, and the following disclaimer.
  18687. 2. Redistributions in binary form must reproduce the above copyright notice,
  18688. this list of conditions, and the following disclaimer in the documentation
  18689. and/or other materials provided with the distribution.
  18690. 3. Neither the name of the University nor the names of its contributors may
  18691. be used to endorse or promote products derived from this software without
  18692. specific prior written permission.
  18693. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  18694. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18695. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  18696. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  18697. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  18698. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  18699. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  18700. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  18701. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  18702. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  18703. =============================================================================*/
  18704. #include <stdbool.h>
  18705. #include <stdint.h>
  18706. /**** skipping file: platform.h ****/
  18707. /**** skipping file: internals.h ****/
  18708. /**** skipping file: specialize.h ****/
  18709. /**** skipping file: softfloat.h ****/
  18710. extFloat80_t extF80_mul( extFloat80_t a, extFloat80_t b )
  18711. {
  18712. union { struct extFloat80M s; extFloat80_t f; } uA;
  18713. uint_fast16_t uiA64;
  18714. uint_fast64_t uiA0;
  18715. bool signA;
  18716. int_fast32_t expA;
  18717. uint_fast64_t sigA;
  18718. union { struct extFloat80M s; extFloat80_t f; } uB;
  18719. uint_fast16_t uiB64;
  18720. uint_fast64_t uiB0;
  18721. bool signB;
  18722. int_fast32_t expB;
  18723. uint_fast64_t sigB;
  18724. bool signZ;
  18725. uint_fast64_t magBits;
  18726. struct exp32_sig64 normExpSig;
  18727. int_fast32_t expZ;
  18728. struct uint128 sig128Z, uiZ;
  18729. uint_fast16_t uiZ64;
  18730. uint_fast64_t uiZ0;
  18731. union { struct extFloat80M s; extFloat80_t f; } uZ;
  18732. /*------------------------------------------------------------------------
  18733. *------------------------------------------------------------------------*/
  18734. uA.f = a;
  18735. uiA64 = uA.s.signExp;
  18736. uiA0 = uA.s.signif;
  18737. signA = signExtF80UI64( uiA64 );
  18738. expA = expExtF80UI64( uiA64 );
  18739. sigA = uiA0;
  18740. uB.f = b;
  18741. uiB64 = uB.s.signExp;
  18742. uiB0 = uB.s.signif;
  18743. signB = signExtF80UI64( uiB64 );
  18744. expB = expExtF80UI64( uiB64 );
  18745. sigB = uiB0;
  18746. signZ = signA ^ signB;
  18747. /*------------------------------------------------------------------------
  18748. *------------------------------------------------------------------------*/
  18749. if ( expA == 0x7FFF ) {
  18750. if (
  18751. (sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
  18752. || ((expB == 0x7FFF) && (sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF )))
  18753. ) {
  18754. goto propagateNaN;
  18755. }
  18756. magBits = expB | sigB;
  18757. goto infArg;
  18758. }
  18759. if ( expB == 0x7FFF ) {
  18760. if ( sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
  18761. magBits = expA | sigA;
  18762. goto infArg;
  18763. }
  18764. /*------------------------------------------------------------------------
  18765. *------------------------------------------------------------------------*/
  18766. if ( ! expA ) expA = 1;
  18767. if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
  18768. if ( ! sigA ) goto zero;
  18769. normExpSig = softfloat_normSubnormalExtF80Sig( sigA );
  18770. expA += normExpSig.exp;
  18771. sigA = normExpSig.sig;
  18772. }
  18773. if ( ! expB ) expB = 1;
  18774. if ( ! (sigB & UINT64_C( 0x8000000000000000 )) ) {
  18775. if ( ! sigB ) goto zero;
  18776. normExpSig = softfloat_normSubnormalExtF80Sig( sigB );
  18777. expB += normExpSig.exp;
  18778. sigB = normExpSig.sig;
  18779. }
  18780. /*------------------------------------------------------------------------
  18781. *------------------------------------------------------------------------*/
  18782. expZ = expA + expB - 0x3FFE;
  18783. sig128Z = softfloat_mul64To128( sigA, sigB );
  18784. if ( sig128Z.v64 < UINT64_C( 0x8000000000000000 ) ) {
  18785. --expZ;
  18786. sig128Z =
  18787. softfloat_add128(
  18788. sig128Z.v64, sig128Z.v0, sig128Z.v64, sig128Z.v0 );
  18789. }
  18790. return
  18791. softfloat_roundPackToExtF80(
  18792. signZ, expZ, sig128Z.v64, sig128Z.v0, extF80_roundingPrecision );
  18793. /*------------------------------------------------------------------------
  18794. *------------------------------------------------------------------------*/
  18795. propagateNaN:
  18796. uiZ = softfloat_propagateNaNExtF80UI( uiA64, uiA0, uiB64, uiB0 );
  18797. uiZ64 = uiZ.v64;
  18798. uiZ0 = uiZ.v0;
  18799. goto uiZ;
  18800. /*------------------------------------------------------------------------
  18801. *------------------------------------------------------------------------*/
  18802. infArg:
  18803. if ( ! magBits ) {
  18804. softfloat_raiseFlags( softfloat_flag_invalid );
  18805. uiZ64 = defaultNaNExtF80UI64;
  18806. uiZ0 = defaultNaNExtF80UI0;
  18807. } else {
  18808. uiZ64 = packToExtF80UI64( signZ, 0x7FFF );
  18809. uiZ0 = UINT64_C( 0x8000000000000000 );
  18810. }
  18811. goto uiZ;
  18812. /*------------------------------------------------------------------------
  18813. *------------------------------------------------------------------------*/
  18814. zero:
  18815. uiZ64 = packToExtF80UI64( signZ, 0 );
  18816. uiZ0 = 0;
  18817. uiZ:
  18818. uZ.s.signExp = uiZ64;
  18819. uZ.s.signif = uiZ0;
  18820. return uZ.f;
  18821. }
  18822. /**** ended inlining ../../source/extF80_mul.c ****/
  18823. /**** start inlining ../../source/extF80_div.c ****/
  18824. /*============================================================================
  18825. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  18826. Package, Release 3e, by John R. Hauser.
  18827. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  18828. All rights reserved.
  18829. Redistribution and use in source and binary forms, with or without
  18830. modification, are permitted provided that the following conditions are met:
  18831. 1. Redistributions of source code must retain the above copyright notice,
  18832. this list of conditions, and the following disclaimer.
  18833. 2. Redistributions in binary form must reproduce the above copyright notice,
  18834. this list of conditions, and the following disclaimer in the documentation
  18835. and/or other materials provided with the distribution.
  18836. 3. Neither the name of the University nor the names of its contributors may
  18837. be used to endorse or promote products derived from this software without
  18838. specific prior written permission.
  18839. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  18840. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18841. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  18842. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  18843. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  18844. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  18845. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  18846. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  18847. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  18848. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  18849. =============================================================================*/
  18850. #include <stdbool.h>
  18851. #include <stdint.h>
  18852. /**** skipping file: platform.h ****/
  18853. /**** skipping file: internals.h ****/
  18854. /**** skipping file: specialize.h ****/
  18855. /**** skipping file: softfloat.h ****/
  18856. extFloat80_t extF80_div( extFloat80_t a, extFloat80_t b )
  18857. {
  18858. union { struct extFloat80M s; extFloat80_t f; } uA;
  18859. uint_fast16_t uiA64;
  18860. uint_fast64_t uiA0;
  18861. bool signA;
  18862. int_fast32_t expA;
  18863. uint_fast64_t sigA;
  18864. union { struct extFloat80M s; extFloat80_t f; } uB;
  18865. uint_fast16_t uiB64;
  18866. uint_fast64_t uiB0;
  18867. bool signB;
  18868. int_fast32_t expB;
  18869. uint_fast64_t sigB;
  18870. bool signZ;
  18871. struct exp32_sig64 normExpSig;
  18872. int_fast32_t expZ;
  18873. struct uint128 rem;
  18874. uint_fast32_t recip32;
  18875. uint_fast64_t sigZ;
  18876. int ix;
  18877. uint_fast64_t q64;
  18878. uint_fast32_t q;
  18879. struct uint128 term;
  18880. uint_fast64_t sigZExtra;
  18881. struct uint128 uiZ;
  18882. uint_fast16_t uiZ64;
  18883. uint_fast64_t uiZ0;
  18884. union { struct extFloat80M s; extFloat80_t f; } uZ;
  18885. /*------------------------------------------------------------------------
  18886. *------------------------------------------------------------------------*/
  18887. uA.f = a;
  18888. uiA64 = uA.s.signExp;
  18889. uiA0 = uA.s.signif;
  18890. signA = signExtF80UI64( uiA64 );
  18891. expA = expExtF80UI64( uiA64 );
  18892. sigA = uiA0;
  18893. uB.f = b;
  18894. uiB64 = uB.s.signExp;
  18895. uiB0 = uB.s.signif;
  18896. signB = signExtF80UI64( uiB64 );
  18897. expB = expExtF80UI64( uiB64 );
  18898. sigB = uiB0;
  18899. signZ = signA ^ signB;
  18900. /*------------------------------------------------------------------------
  18901. *------------------------------------------------------------------------*/
  18902. if ( expA == 0x7FFF ) {
  18903. if ( sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
  18904. if ( expB == 0x7FFF ) {
  18905. if ( sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
  18906. goto invalid;
  18907. }
  18908. goto infinity;
  18909. }
  18910. if ( expB == 0x7FFF ) {
  18911. if ( sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
  18912. goto zero;
  18913. }
  18914. /*------------------------------------------------------------------------
  18915. *------------------------------------------------------------------------*/
  18916. if ( ! expB ) expB = 1;
  18917. if ( ! (sigB & UINT64_C( 0x8000000000000000 )) ) {
  18918. if ( ! sigB ) {
  18919. if ( ! sigA ) goto invalid;
  18920. softfloat_raiseFlags( softfloat_flag_infinite );
  18921. goto infinity;
  18922. }
  18923. normExpSig = softfloat_normSubnormalExtF80Sig( sigB );
  18924. expB += normExpSig.exp;
  18925. sigB = normExpSig.sig;
  18926. }
  18927. if ( ! expA ) expA = 1;
  18928. if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
  18929. if ( ! sigA ) goto zero;
  18930. normExpSig = softfloat_normSubnormalExtF80Sig( sigA );
  18931. expA += normExpSig.exp;
  18932. sigA = normExpSig.sig;
  18933. }
  18934. /*------------------------------------------------------------------------
  18935. *------------------------------------------------------------------------*/
  18936. expZ = expA - expB + 0x3FFF;
  18937. if ( sigA < sigB ) {
  18938. --expZ;
  18939. rem = softfloat_shortShiftLeft128( 0, sigA, 32 );
  18940. } else {
  18941. rem = softfloat_shortShiftLeft128( 0, sigA, 31 );
  18942. }
  18943. recip32 = softfloat_approxRecip32_1( sigB>>32 );
  18944. sigZ = 0;
  18945. ix = 2;
  18946. for (;;) {
  18947. q64 = (uint_fast64_t) (uint32_t) (rem.v64>>2) * recip32;
  18948. q = (q64 + 0x80000000)>>32;
  18949. --ix;
  18950. if ( ix < 0 ) break;
  18951. rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
  18952. term = softfloat_mul64ByShifted32To128( sigB, q );
  18953. rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
  18954. if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
  18955. --q;
  18956. rem = softfloat_add128( rem.v64, rem.v0, sigB>>32, sigB<<32 );
  18957. }
  18958. sigZ = (sigZ<<29) + q;
  18959. }
  18960. /*------------------------------------------------------------------------
  18961. *------------------------------------------------------------------------*/
  18962. if ( ((q + 1) & 0x3FFFFF) < 2 ) {
  18963. rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
  18964. term = softfloat_mul64ByShifted32To128( sigB, q );
  18965. rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
  18966. term = softfloat_shortShiftLeft128( 0, sigB, 32 );
  18967. if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
  18968. --q;
  18969. rem = softfloat_add128( rem.v64, rem.v0, term.v64, term.v0 );
  18970. } else if ( softfloat_le128( term.v64, term.v0, rem.v64, rem.v0 ) ) {
  18971. ++q;
  18972. rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
  18973. }
  18974. if ( rem.v64 | rem.v0 ) q |= 1;
  18975. }
  18976. /*------------------------------------------------------------------------
  18977. *------------------------------------------------------------------------*/
  18978. sigZ = (sigZ<<6) + (q>>23);
  18979. sigZExtra = (uint64_t) ((uint_fast64_t) q<<41);
  18980. return
  18981. softfloat_roundPackToExtF80(
  18982. signZ, expZ, sigZ, sigZExtra, extF80_roundingPrecision );
  18983. /*------------------------------------------------------------------------
  18984. *------------------------------------------------------------------------*/
  18985. propagateNaN:
  18986. uiZ = softfloat_propagateNaNExtF80UI( uiA64, uiA0, uiB64, uiB0 );
  18987. uiZ64 = uiZ.v64;
  18988. uiZ0 = uiZ.v0;
  18989. goto uiZ;
  18990. /*------------------------------------------------------------------------
  18991. *------------------------------------------------------------------------*/
  18992. invalid:
  18993. softfloat_raiseFlags( softfloat_flag_invalid );
  18994. uiZ64 = defaultNaNExtF80UI64;
  18995. uiZ0 = defaultNaNExtF80UI0;
  18996. goto uiZ;
  18997. /*------------------------------------------------------------------------
  18998. *------------------------------------------------------------------------*/
  18999. infinity:
  19000. uiZ64 = packToExtF80UI64( signZ, 0x7FFF );
  19001. uiZ0 = UINT64_C( 0x8000000000000000 );
  19002. goto uiZ;
  19003. /*------------------------------------------------------------------------
  19004. *------------------------------------------------------------------------*/
  19005. zero:
  19006. uiZ64 = packToExtF80UI64( signZ, 0 );
  19007. uiZ0 = 0;
  19008. uiZ:
  19009. uZ.s.signExp = uiZ64;
  19010. uZ.s.signif = uiZ0;
  19011. return uZ.f;
  19012. }
  19013. /**** ended inlining ../../source/extF80_div.c ****/
  19014. /**** start inlining ../../source/extF80_rem.c ****/
  19015. /*============================================================================
  19016. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  19017. Package, Release 3e, by John R. Hauser.
  19018. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  19019. University of California. All rights reserved.
  19020. Redistribution and use in source and binary forms, with or without
  19021. modification, are permitted provided that the following conditions are met:
  19022. 1. Redistributions of source code must retain the above copyright notice,
  19023. this list of conditions, and the following disclaimer.
  19024. 2. Redistributions in binary form must reproduce the above copyright notice,
  19025. this list of conditions, and the following disclaimer in the documentation
  19026. and/or other materials provided with the distribution.
  19027. 3. Neither the name of the University nor the names of its contributors may
  19028. be used to endorse or promote products derived from this software without
  19029. specific prior written permission.
  19030. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  19031. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19032. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  19033. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  19034. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  19035. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  19036. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  19037. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  19038. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  19039. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  19040. =============================================================================*/
  19041. #include <stdbool.h>
  19042. #include <stdint.h>
  19043. /**** skipping file: platform.h ****/
  19044. /**** skipping file: internals.h ****/
  19045. /**** skipping file: specialize.h ****/
  19046. /**** skipping file: softfloat.h ****/
  19047. extFloat80_t extF80_rem( extFloat80_t a, extFloat80_t b )
  19048. {
  19049. union { struct extFloat80M s; extFloat80_t f; } uA;
  19050. uint_fast16_t uiA64;
  19051. uint_fast64_t uiA0;
  19052. bool signA;
  19053. int_fast32_t expA;
  19054. uint_fast64_t sigA;
  19055. union { struct extFloat80M s; extFloat80_t f; } uB;
  19056. uint_fast16_t uiB64;
  19057. uint_fast64_t uiB0;
  19058. int_fast32_t expB;
  19059. uint_fast64_t sigB;
  19060. struct exp32_sig64 normExpSig;
  19061. int_fast32_t expDiff;
  19062. struct uint128 rem, shiftedSigB;
  19063. uint_fast32_t q, recip32;
  19064. uint_fast64_t q64;
  19065. struct uint128 term, altRem, meanRem;
  19066. bool signRem;
  19067. struct uint128 uiZ;
  19068. uint_fast16_t uiZ64;
  19069. uint_fast64_t uiZ0;
  19070. union { struct extFloat80M s; extFloat80_t f; } uZ;
  19071. /*------------------------------------------------------------------------
  19072. *------------------------------------------------------------------------*/
  19073. uA.f = a;
  19074. uiA64 = uA.s.signExp;
  19075. uiA0 = uA.s.signif;
  19076. signA = signExtF80UI64( uiA64 );
  19077. expA = expExtF80UI64( uiA64 );
  19078. sigA = uiA0;
  19079. uB.f = b;
  19080. uiB64 = uB.s.signExp;
  19081. uiB0 = uB.s.signif;
  19082. expB = expExtF80UI64( uiB64 );
  19083. sigB = uiB0;
  19084. /*------------------------------------------------------------------------
  19085. *------------------------------------------------------------------------*/
  19086. if ( expA == 0x7FFF ) {
  19087. if (
  19088. (sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
  19089. || ((expB == 0x7FFF) && (sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF )))
  19090. ) {
  19091. goto propagateNaN;
  19092. }
  19093. goto invalid;
  19094. }
  19095. if ( expB == 0x7FFF ) {
  19096. if ( sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
  19097. /*--------------------------------------------------------------------
  19098. | Argument b is an infinity. Doubling `expB' is an easy way to ensure
  19099. | that `expDiff' later is less than -1, which will result in returning
  19100. | a canonicalized version of argument a.
  19101. *--------------------------------------------------------------------*/
  19102. expB += expB;
  19103. }
  19104. /*------------------------------------------------------------------------
  19105. *------------------------------------------------------------------------*/
  19106. if ( ! expB ) expB = 1;
  19107. if ( ! (sigB & UINT64_C( 0x8000000000000000 )) ) {
  19108. if ( ! sigB ) goto invalid;
  19109. normExpSig = softfloat_normSubnormalExtF80Sig( sigB );
  19110. expB += normExpSig.exp;
  19111. sigB = normExpSig.sig;
  19112. }
  19113. if ( ! expA ) expA = 1;
  19114. if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
  19115. if ( ! sigA ) {
  19116. expA = 0;
  19117. goto copyA;
  19118. }
  19119. normExpSig = softfloat_normSubnormalExtF80Sig( sigA );
  19120. expA += normExpSig.exp;
  19121. sigA = normExpSig.sig;
  19122. }
  19123. /*------------------------------------------------------------------------
  19124. *------------------------------------------------------------------------*/
  19125. expDiff = expA - expB;
  19126. if ( expDiff < -1 ) goto copyA;
  19127. rem = softfloat_shortShiftLeft128( 0, sigA, 32 );
  19128. shiftedSigB = softfloat_shortShiftLeft128( 0, sigB, 32 );
  19129. if ( expDiff < 1 ) {
  19130. if ( expDiff ) {
  19131. --expB;
  19132. shiftedSigB = softfloat_shortShiftLeft128( 0, sigB, 33 );
  19133. q = 0;
  19134. } else {
  19135. q = (sigB <= sigA);
  19136. if ( q ) {
  19137. rem =
  19138. softfloat_sub128(
  19139. rem.v64, rem.v0, shiftedSigB.v64, shiftedSigB.v0 );
  19140. }
  19141. }
  19142. } else {
  19143. recip32 = softfloat_approxRecip32_1( sigB>>32 );
  19144. expDiff -= 30;
  19145. for (;;) {
  19146. q64 = (uint_fast64_t) (uint32_t) (rem.v64>>2) * recip32;
  19147. if ( expDiff < 0 ) break;
  19148. q = (q64 + 0x80000000)>>32;
  19149. rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
  19150. term = softfloat_mul64ByShifted32To128( sigB, q );
  19151. rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
  19152. if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
  19153. rem =
  19154. softfloat_add128(
  19155. rem.v64, rem.v0, shiftedSigB.v64, shiftedSigB.v0 );
  19156. }
  19157. expDiff -= 29;
  19158. }
  19159. /*--------------------------------------------------------------------
  19160. | (`expDiff' cannot be less than -29 here.)
  19161. *--------------------------------------------------------------------*/
  19162. q = (uint32_t) (q64>>32)>>(~expDiff & 31);
  19163. rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, expDiff + 30 );
  19164. term = softfloat_mul64ByShifted32To128( sigB, q );
  19165. rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
  19166. if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
  19167. altRem =
  19168. softfloat_add128(
  19169. rem.v64, rem.v0, shiftedSigB.v64, shiftedSigB.v0 );
  19170. goto selectRem;
  19171. }
  19172. }
  19173. /*------------------------------------------------------------------------
  19174. *------------------------------------------------------------------------*/
  19175. do {
  19176. altRem = rem;
  19177. ++q;
  19178. rem =
  19179. softfloat_sub128(
  19180. rem.v64, rem.v0, shiftedSigB.v64, shiftedSigB.v0 );
  19181. } while ( ! (rem.v64 & UINT64_C( 0x8000000000000000 )) );
  19182. selectRem:
  19183. meanRem = softfloat_add128( rem.v64, rem.v0, altRem.v64, altRem.v0 );
  19184. if (
  19185. (meanRem.v64 & UINT64_C( 0x8000000000000000 ))
  19186. || (! (meanRem.v64 | meanRem.v0) && (q & 1))
  19187. ) {
  19188. rem = altRem;
  19189. }
  19190. signRem = signA;
  19191. if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
  19192. signRem = ! signRem;
  19193. rem = softfloat_sub128( 0, 0, rem.v64, rem.v0 );
  19194. }
  19195. return
  19196. softfloat_normRoundPackToExtF80(
  19197. signRem, rem.v64 | rem.v0 ? expB + 32 : 0, rem.v64, rem.v0, 80 );
  19198. /*------------------------------------------------------------------------
  19199. *------------------------------------------------------------------------*/
  19200. propagateNaN:
  19201. uiZ = softfloat_propagateNaNExtF80UI( uiA64, uiA0, uiB64, uiB0 );
  19202. uiZ64 = uiZ.v64;
  19203. uiZ0 = uiZ.v0;
  19204. goto uiZ;
  19205. /*------------------------------------------------------------------------
  19206. *------------------------------------------------------------------------*/
  19207. invalid:
  19208. softfloat_raiseFlags( softfloat_flag_invalid );
  19209. uiZ64 = defaultNaNExtF80UI64;
  19210. uiZ0 = defaultNaNExtF80UI0;
  19211. goto uiZ;
  19212. /*------------------------------------------------------------------------
  19213. *------------------------------------------------------------------------*/
  19214. copyA:
  19215. if ( expA < 1 ) {
  19216. sigA >>= 1 - expA;
  19217. expA = 0;
  19218. }
  19219. uiZ64 = packToExtF80UI64( signA, expA );
  19220. uiZ0 = sigA;
  19221. uiZ:
  19222. uZ.s.signExp = uiZ64;
  19223. uZ.s.signif = uiZ0;
  19224. return uZ.f;
  19225. }
  19226. /**** ended inlining ../../source/extF80_rem.c ****/
  19227. /**** start inlining ../../source/extF80_sqrt.c ****/
  19228. /*============================================================================
  19229. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  19230. Package, Release 3e, by John R. Hauser.
  19231. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  19232. University of California. All rights reserved.
  19233. Redistribution and use in source and binary forms, with or without
  19234. modification, are permitted provided that the following conditions are met:
  19235. 1. Redistributions of source code must retain the above copyright notice,
  19236. this list of conditions, and the following disclaimer.
  19237. 2. Redistributions in binary form must reproduce the above copyright notice,
  19238. this list of conditions, and the following disclaimer in the documentation
  19239. and/or other materials provided with the distribution.
  19240. 3. Neither the name of the University nor the names of its contributors may
  19241. be used to endorse or promote products derived from this software without
  19242. specific prior written permission.
  19243. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  19244. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19245. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  19246. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  19247. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  19248. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  19249. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  19250. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  19251. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  19252. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  19253. =============================================================================*/
  19254. #include <stdbool.h>
  19255. #include <stdint.h>
  19256. /**** skipping file: platform.h ****/
  19257. /**** skipping file: internals.h ****/
  19258. /**** skipping file: specialize.h ****/
  19259. /**** skipping file: softfloat.h ****/
  19260. extFloat80_t extF80_sqrt( extFloat80_t a )
  19261. {
  19262. union { struct extFloat80M s; extFloat80_t f; } uA;
  19263. uint_fast16_t uiA64;
  19264. uint_fast64_t uiA0;
  19265. bool signA;
  19266. int_fast32_t expA;
  19267. uint_fast64_t sigA;
  19268. struct uint128 uiZ;
  19269. uint_fast16_t uiZ64;
  19270. uint_fast64_t uiZ0;
  19271. struct exp32_sig64 normExpSig;
  19272. int_fast32_t expZ;
  19273. uint_fast32_t sig32A, recipSqrt32, sig32Z;
  19274. struct uint128 rem;
  19275. uint_fast64_t q, x64, sigZ;
  19276. struct uint128 y, term;
  19277. uint_fast64_t sigZExtra;
  19278. union { struct extFloat80M s; extFloat80_t f; } uZ;
  19279. /*------------------------------------------------------------------------
  19280. *------------------------------------------------------------------------*/
  19281. uA.f = a;
  19282. uiA64 = uA.s.signExp;
  19283. uiA0 = uA.s.signif;
  19284. signA = signExtF80UI64( uiA64 );
  19285. expA = expExtF80UI64( uiA64 );
  19286. sigA = uiA0;
  19287. /*------------------------------------------------------------------------
  19288. *------------------------------------------------------------------------*/
  19289. if ( expA == 0x7FFF ) {
  19290. if ( sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
  19291. uiZ = softfloat_propagateNaNExtF80UI( uiA64, uiA0, 0, 0 );
  19292. uiZ64 = uiZ.v64;
  19293. uiZ0 = uiZ.v0;
  19294. goto uiZ;
  19295. }
  19296. if ( ! signA ) return a;
  19297. goto invalid;
  19298. }
  19299. /*------------------------------------------------------------------------
  19300. *------------------------------------------------------------------------*/
  19301. if ( signA ) {
  19302. if ( ! sigA ) goto zero;
  19303. goto invalid;
  19304. }
  19305. /*------------------------------------------------------------------------
  19306. *------------------------------------------------------------------------*/
  19307. if ( ! expA ) expA = 1;
  19308. if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
  19309. if ( ! sigA ) goto zero;
  19310. normExpSig = softfloat_normSubnormalExtF80Sig( sigA );
  19311. expA += normExpSig.exp;
  19312. sigA = normExpSig.sig;
  19313. }
  19314. /*------------------------------------------------------------------------
  19315. | (`sig32Z' is guaranteed to be a lower bound on the square root of
  19316. | `sig32A', which makes `sig32Z' also a lower bound on the square root of
  19317. | `sigA'.)
  19318. *------------------------------------------------------------------------*/
  19319. expZ = ((expA - 0x3FFF)>>1) + 0x3FFF;
  19320. expA &= 1;
  19321. sig32A = sigA>>32;
  19322. recipSqrt32 = softfloat_approxRecipSqrt32_1( expA, sig32A );
  19323. sig32Z = ((uint_fast64_t) sig32A * recipSqrt32)>>32;
  19324. if ( expA ) {
  19325. sig32Z >>= 1;
  19326. rem = softfloat_shortShiftLeft128( 0, sigA, 61 );
  19327. } else {
  19328. rem = softfloat_shortShiftLeft128( 0, sigA, 62 );
  19329. }
  19330. rem.v64 -= (uint_fast64_t) sig32Z * sig32Z;
  19331. /*------------------------------------------------------------------------
  19332. *------------------------------------------------------------------------*/
  19333. q = ((uint32_t) (rem.v64>>2) * (uint_fast64_t) recipSqrt32)>>32;
  19334. x64 = (uint_fast64_t) sig32Z<<32;
  19335. sigZ = x64 + (q<<3);
  19336. y = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
  19337. /*------------------------------------------------------------------------
  19338. | (Repeating this loop is a rare occurrence.)
  19339. *------------------------------------------------------------------------*/
  19340. for (;;) {
  19341. term = softfloat_mul64ByShifted32To128( x64 + sigZ, q );
  19342. rem = softfloat_sub128( y.v64, y.v0, term.v64, term.v0 );
  19343. if ( ! (rem.v64 & UINT64_C( 0x8000000000000000 )) ) break;
  19344. --q;
  19345. sigZ -= 1<<3;
  19346. }
  19347. /*------------------------------------------------------------------------
  19348. *------------------------------------------------------------------------*/
  19349. q = (((rem.v64>>2) * recipSqrt32)>>32) + 2;
  19350. x64 = sigZ;
  19351. sigZ = (sigZ<<1) + (q>>25);
  19352. sigZExtra = (uint64_t) (q<<39);
  19353. /*------------------------------------------------------------------------
  19354. *------------------------------------------------------------------------*/
  19355. if ( (q & 0xFFFFFF) <= 2 ) {
  19356. q &= ~(uint_fast64_t) 0xFFFF;
  19357. sigZExtra = (uint64_t) (q<<39);
  19358. term = softfloat_mul64ByShifted32To128( x64 + (q>>27), q );
  19359. x64 = (uint32_t) (q<<5) * (uint_fast64_t) (uint32_t) q;
  19360. term = softfloat_add128( term.v64, term.v0, 0, x64 );
  19361. rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 28 );
  19362. rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
  19363. if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
  19364. if ( ! sigZExtra ) --sigZ;
  19365. --sigZExtra;
  19366. } else {
  19367. if ( rem.v64 | rem.v0 ) sigZExtra |= 1;
  19368. }
  19369. }
  19370. return
  19371. softfloat_roundPackToExtF80(
  19372. 0, expZ, sigZ, sigZExtra, extF80_roundingPrecision );
  19373. /*------------------------------------------------------------------------
  19374. *------------------------------------------------------------------------*/
  19375. invalid:
  19376. softfloat_raiseFlags( softfloat_flag_invalid );
  19377. uiZ64 = defaultNaNExtF80UI64;
  19378. uiZ0 = defaultNaNExtF80UI0;
  19379. goto uiZ;
  19380. /*------------------------------------------------------------------------
  19381. *------------------------------------------------------------------------*/
  19382. zero:
  19383. uiZ64 = packToExtF80UI64( signA, 0 );
  19384. uiZ0 = 0;
  19385. uiZ:
  19386. uZ.s.signExp = uiZ64;
  19387. uZ.s.signif = uiZ0;
  19388. return uZ.f;
  19389. }
  19390. /**** ended inlining ../../source/extF80_sqrt.c ****/
  19391. /**** start inlining ../../source/extF80_eq.c ****/
  19392. /*============================================================================
  19393. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  19394. Package, Release 3e, by John R. Hauser.
  19395. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  19396. All rights reserved.
  19397. Redistribution and use in source and binary forms, with or without
  19398. modification, are permitted provided that the following conditions are met:
  19399. 1. Redistributions of source code must retain the above copyright notice,
  19400. this list of conditions, and the following disclaimer.
  19401. 2. Redistributions in binary form must reproduce the above copyright notice,
  19402. this list of conditions, and the following disclaimer in the documentation
  19403. and/or other materials provided with the distribution.
  19404. 3. Neither the name of the University nor the names of its contributors may
  19405. be used to endorse or promote products derived from this software without
  19406. specific prior written permission.
  19407. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  19408. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19409. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  19410. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  19411. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  19412. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  19413. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  19414. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  19415. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  19416. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  19417. =============================================================================*/
  19418. #include <stdbool.h>
  19419. #include <stdint.h>
  19420. /**** skipping file: platform.h ****/
  19421. /**** skipping file: internals.h ****/
  19422. /**** skipping file: specialize.h ****/
  19423. /**** skipping file: softfloat.h ****/
  19424. bool extF80_eq( extFloat80_t a, extFloat80_t b )
  19425. {
  19426. union { struct extFloat80M s; extFloat80_t f; } uA;
  19427. uint_fast16_t uiA64;
  19428. uint_fast64_t uiA0;
  19429. union { struct extFloat80M s; extFloat80_t f; } uB;
  19430. uint_fast16_t uiB64;
  19431. uint_fast64_t uiB0;
  19432. uA.f = a;
  19433. uiA64 = uA.s.signExp;
  19434. uiA0 = uA.s.signif;
  19435. uB.f = b;
  19436. uiB64 = uB.s.signExp;
  19437. uiB0 = uB.s.signif;
  19438. if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
  19439. if (
  19440. softfloat_isSigNaNExtF80UI( uiA64, uiA0 )
  19441. || softfloat_isSigNaNExtF80UI( uiB64, uiB0 )
  19442. ) {
  19443. softfloat_raiseFlags( softfloat_flag_invalid );
  19444. }
  19445. return false;
  19446. }
  19447. return
  19448. (uiA0 == uiB0)
  19449. && ((uiA64 == uiB64) || (! uiA0 && ! ((uiA64 | uiB64) & 0x7FFF)));
  19450. }
  19451. /**** ended inlining ../../source/extF80_eq.c ****/
  19452. /**** start inlining ../../source/extF80_le.c ****/
  19453. /*============================================================================
  19454. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  19455. Package, Release 3e, by John R. Hauser.
  19456. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  19457. All rights reserved.
  19458. Redistribution and use in source and binary forms, with or without
  19459. modification, are permitted provided that the following conditions are met:
  19460. 1. Redistributions of source code must retain the above copyright notice,
  19461. this list of conditions, and the following disclaimer.
  19462. 2. Redistributions in binary form must reproduce the above copyright notice,
  19463. this list of conditions, and the following disclaimer in the documentation
  19464. and/or other materials provided with the distribution.
  19465. 3. Neither the name of the University nor the names of its contributors may
  19466. be used to endorse or promote products derived from this software without
  19467. specific prior written permission.
  19468. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  19469. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19470. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  19471. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  19472. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  19473. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  19474. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  19475. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  19476. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  19477. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  19478. =============================================================================*/
  19479. #include <stdbool.h>
  19480. #include <stdint.h>
  19481. /**** skipping file: platform.h ****/
  19482. /**** skipping file: internals.h ****/
  19483. /**** skipping file: specialize.h ****/
  19484. /**** skipping file: softfloat.h ****/
  19485. bool extF80_le( extFloat80_t a, extFloat80_t b )
  19486. {
  19487. union { struct extFloat80M s; extFloat80_t f; } uA;
  19488. uint_fast16_t uiA64;
  19489. uint_fast64_t uiA0;
  19490. union { struct extFloat80M s; extFloat80_t f; } uB;
  19491. uint_fast16_t uiB64;
  19492. uint_fast64_t uiB0;
  19493. bool signA, signB;
  19494. uA.f = a;
  19495. uiA64 = uA.s.signExp;
  19496. uiA0 = uA.s.signif;
  19497. uB.f = b;
  19498. uiB64 = uB.s.signExp;
  19499. uiB0 = uB.s.signif;
  19500. if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
  19501. softfloat_raiseFlags( softfloat_flag_invalid );
  19502. return false;
  19503. }
  19504. signA = signExtF80UI64( uiA64 );
  19505. signB = signExtF80UI64( uiB64 );
  19506. return
  19507. (signA != signB)
  19508. ? signA || ! (((uiA64 | uiB64) & 0x7FFF) | uiA0 | uiB0)
  19509. : ((uiA64 == uiB64) && (uiA0 == uiB0))
  19510. || (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
  19511. }
  19512. /**** ended inlining ../../source/extF80_le.c ****/
  19513. /**** start inlining ../../source/extF80_lt.c ****/
  19514. /*============================================================================
  19515. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  19516. Package, Release 3e, by John R. Hauser.
  19517. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  19518. All rights reserved.
  19519. Redistribution and use in source and binary forms, with or without
  19520. modification, are permitted provided that the following conditions are met:
  19521. 1. Redistributions of source code must retain the above copyright notice,
  19522. this list of conditions, and the following disclaimer.
  19523. 2. Redistributions in binary form must reproduce the above copyright notice,
  19524. this list of conditions, and the following disclaimer in the documentation
  19525. and/or other materials provided with the distribution.
  19526. 3. Neither the name of the University nor the names of its contributors may
  19527. be used to endorse or promote products derived from this software without
  19528. specific prior written permission.
  19529. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  19530. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19531. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  19532. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  19533. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  19534. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  19535. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  19536. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  19537. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  19538. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  19539. =============================================================================*/
  19540. #include <stdbool.h>
  19541. #include <stdint.h>
  19542. /**** skipping file: platform.h ****/
  19543. /**** skipping file: internals.h ****/
  19544. /**** skipping file: specialize.h ****/
  19545. /**** skipping file: softfloat.h ****/
  19546. bool extF80_lt( extFloat80_t a, extFloat80_t b )
  19547. {
  19548. union { struct extFloat80M s; extFloat80_t f; } uA;
  19549. uint_fast16_t uiA64;
  19550. uint_fast64_t uiA0;
  19551. union { struct extFloat80M s; extFloat80_t f; } uB;
  19552. uint_fast16_t uiB64;
  19553. uint_fast64_t uiB0;
  19554. bool signA, signB;
  19555. uA.f = a;
  19556. uiA64 = uA.s.signExp;
  19557. uiA0 = uA.s.signif;
  19558. uB.f = b;
  19559. uiB64 = uB.s.signExp;
  19560. uiB0 = uB.s.signif;
  19561. if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
  19562. softfloat_raiseFlags( softfloat_flag_invalid );
  19563. return false;
  19564. }
  19565. signA = signExtF80UI64( uiA64 );
  19566. signB = signExtF80UI64( uiB64 );
  19567. return
  19568. (signA != signB)
  19569. ? signA && (((uiA64 | uiB64) & 0x7FFF) | uiA0 | uiB0)
  19570. : ((uiA64 != uiB64) || (uiA0 != uiB0))
  19571. && (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
  19572. }
  19573. /**** ended inlining ../../source/extF80_lt.c ****/
  19574. /**** start inlining ../../source/extF80_eq_signaling.c ****/
  19575. /*============================================================================
  19576. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  19577. Package, Release 3e, by John R. Hauser.
  19578. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  19579. All rights reserved.
  19580. Redistribution and use in source and binary forms, with or without
  19581. modification, are permitted provided that the following conditions are met:
  19582. 1. Redistributions of source code must retain the above copyright notice,
  19583. this list of conditions, and the following disclaimer.
  19584. 2. Redistributions in binary form must reproduce the above copyright notice,
  19585. this list of conditions, and the following disclaimer in the documentation
  19586. and/or other materials provided with the distribution.
  19587. 3. Neither the name of the University nor the names of its contributors may
  19588. be used to endorse or promote products derived from this software without
  19589. specific prior written permission.
  19590. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  19591. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19592. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  19593. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  19594. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  19595. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  19596. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  19597. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  19598. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  19599. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  19600. =============================================================================*/
  19601. #include <stdbool.h>
  19602. #include <stdint.h>
  19603. /**** skipping file: platform.h ****/
  19604. /**** skipping file: internals.h ****/
  19605. /**** skipping file: softfloat.h ****/
  19606. bool extF80_eq_signaling( extFloat80_t a, extFloat80_t b )
  19607. {
  19608. union { struct extFloat80M s; extFloat80_t f; } uA;
  19609. uint_fast16_t uiA64;
  19610. uint_fast64_t uiA0;
  19611. union { struct extFloat80M s; extFloat80_t f; } uB;
  19612. uint_fast16_t uiB64;
  19613. uint_fast64_t uiB0;
  19614. uA.f = a;
  19615. uiA64 = uA.s.signExp;
  19616. uiA0 = uA.s.signif;
  19617. uB.f = b;
  19618. uiB64 = uB.s.signExp;
  19619. uiB0 = uB.s.signif;
  19620. if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
  19621. softfloat_raiseFlags( softfloat_flag_invalid );
  19622. return false;
  19623. }
  19624. return
  19625. (uiA0 == uiB0)
  19626. && ((uiA64 == uiB64) || (! uiA0 && ! ((uiA64 | uiB64) & 0x7FFF)));
  19627. }
  19628. /**** ended inlining ../../source/extF80_eq_signaling.c ****/
  19629. /**** start inlining ../../source/extF80_le_quiet.c ****/
  19630. /*============================================================================
  19631. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  19632. Package, Release 3e, by John R. Hauser.
  19633. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  19634. All rights reserved.
  19635. Redistribution and use in source and binary forms, with or without
  19636. modification, are permitted provided that the following conditions are met:
  19637. 1. Redistributions of source code must retain the above copyright notice,
  19638. this list of conditions, and the following disclaimer.
  19639. 2. Redistributions in binary form must reproduce the above copyright notice,
  19640. this list of conditions, and the following disclaimer in the documentation
  19641. and/or other materials provided with the distribution.
  19642. 3. Neither the name of the University nor the names of its contributors may
  19643. be used to endorse or promote products derived from this software without
  19644. specific prior written permission.
  19645. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  19646. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19647. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  19648. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  19649. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  19650. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  19651. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  19652. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  19653. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  19654. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  19655. =============================================================================*/
  19656. #include <stdbool.h>
  19657. #include <stdint.h>
  19658. /**** skipping file: platform.h ****/
  19659. /**** skipping file: internals.h ****/
  19660. /**** skipping file: specialize.h ****/
  19661. /**** skipping file: softfloat.h ****/
  19662. bool extF80_le_quiet( extFloat80_t a, extFloat80_t b )
  19663. {
  19664. union { struct extFloat80M s; extFloat80_t f; } uA;
  19665. uint_fast16_t uiA64;
  19666. uint_fast64_t uiA0;
  19667. union { struct extFloat80M s; extFloat80_t f; } uB;
  19668. uint_fast16_t uiB64;
  19669. uint_fast64_t uiB0;
  19670. bool signA, signB;
  19671. uA.f = a;
  19672. uiA64 = uA.s.signExp;
  19673. uiA0 = uA.s.signif;
  19674. uB.f = b;
  19675. uiB64 = uB.s.signExp;
  19676. uiB0 = uB.s.signif;
  19677. if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
  19678. if (
  19679. softfloat_isSigNaNExtF80UI( uiA64, uiA0 )
  19680. || softfloat_isSigNaNExtF80UI( uiB64, uiB0 )
  19681. ) {
  19682. softfloat_raiseFlags( softfloat_flag_invalid );
  19683. }
  19684. return false;
  19685. }
  19686. signA = signExtF80UI64( uiA64 );
  19687. signB = signExtF80UI64( uiB64 );
  19688. return
  19689. (signA != signB)
  19690. ? signA || ! (((uiA64 | uiB64) & 0x7FFF) | uiA0 | uiB0)
  19691. : ((uiA64 == uiB64) && (uiA0 == uiB0))
  19692. || (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
  19693. }
  19694. /**** ended inlining ../../source/extF80_le_quiet.c ****/
  19695. /**** start inlining ../../source/extF80_lt_quiet.c ****/
  19696. /*============================================================================
  19697. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  19698. Package, Release 3e, by John R. Hauser.
  19699. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  19700. All rights reserved.
  19701. Redistribution and use in source and binary forms, with or without
  19702. modification, are permitted provided that the following conditions are met:
  19703. 1. Redistributions of source code must retain the above copyright notice,
  19704. this list of conditions, and the following disclaimer.
  19705. 2. Redistributions in binary form must reproduce the above copyright notice,
  19706. this list of conditions, and the following disclaimer in the documentation
  19707. and/or other materials provided with the distribution.
  19708. 3. Neither the name of the University nor the names of its contributors may
  19709. be used to endorse or promote products derived from this software without
  19710. specific prior written permission.
  19711. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  19712. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19713. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  19714. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  19715. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  19716. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  19717. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  19718. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  19719. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  19720. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  19721. =============================================================================*/
  19722. #include <stdbool.h>
  19723. #include <stdint.h>
  19724. /**** skipping file: platform.h ****/
  19725. /**** skipping file: internals.h ****/
  19726. /**** skipping file: specialize.h ****/
  19727. /**** skipping file: softfloat.h ****/
  19728. bool extF80_lt_quiet( extFloat80_t a, extFloat80_t b )
  19729. {
  19730. union { struct extFloat80M s; extFloat80_t f; } uA;
  19731. uint_fast16_t uiA64;
  19732. uint_fast64_t uiA0;
  19733. union { struct extFloat80M s; extFloat80_t f; } uB;
  19734. uint_fast16_t uiB64;
  19735. uint_fast64_t uiB0;
  19736. bool signA, signB;
  19737. uA.f = a;
  19738. uiA64 = uA.s.signExp;
  19739. uiA0 = uA.s.signif;
  19740. uB.f = b;
  19741. uiB64 = uB.s.signExp;
  19742. uiB0 = uB.s.signif;
  19743. if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
  19744. if (
  19745. softfloat_isSigNaNExtF80UI( uiA64, uiA0 )
  19746. || softfloat_isSigNaNExtF80UI( uiB64, uiB0 )
  19747. ) {
  19748. softfloat_raiseFlags( softfloat_flag_invalid );
  19749. }
  19750. return false;
  19751. }
  19752. signA = signExtF80UI64( uiA64 );
  19753. signB = signExtF80UI64( uiB64 );
  19754. return
  19755. (signA != signB)
  19756. ? signA && (((uiA64 | uiB64) & 0x7FFF) | uiA0 | uiB0)
  19757. : ((uiA64 != uiB64) || (uiA0 != uiB0))
  19758. && (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
  19759. }
  19760. /**** ended inlining ../../source/extF80_lt_quiet.c ****/
  19761. /**** start inlining ../../source/extF80_isSignalingNaN.c ****/
  19762. /*============================================================================
  19763. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  19764. Package, Release 3e, by John R. Hauser.
  19765. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  19766. All rights reserved.
  19767. Redistribution and use in source and binary forms, with or without
  19768. modification, are permitted provided that the following conditions are met:
  19769. 1. Redistributions of source code must retain the above copyright notice,
  19770. this list of conditions, and the following disclaimer.
  19771. 2. Redistributions in binary form must reproduce the above copyright notice,
  19772. this list of conditions, and the following disclaimer in the documentation
  19773. and/or other materials provided with the distribution.
  19774. 3. Neither the name of the University nor the names of its contributors may
  19775. be used to endorse or promote products derived from this software without
  19776. specific prior written permission.
  19777. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  19778. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19779. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  19780. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  19781. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  19782. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  19783. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  19784. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  19785. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  19786. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  19787. =============================================================================*/
  19788. #include <stdbool.h>
  19789. /**** skipping file: platform.h ****/
  19790. /**** skipping file: internals.h ****/
  19791. /**** skipping file: specialize.h ****/
  19792. /**** skipping file: softfloat.h ****/
  19793. bool extF80_isSignalingNaN( extFloat80_t a )
  19794. {
  19795. union { struct extFloat80M s; extFloat80_t f; } uA;
  19796. uA.f = a;
  19797. return softfloat_isSigNaNExtF80UI( uA.s.signExp, uA.s.signif );
  19798. }
  19799. /**** ended inlining ../../source/extF80_isSignalingNaN.c ****/
  19800. /**** start inlining ../../source/extF80M_to_ui32.c ****/
  19801. /*============================================================================
  19802. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  19803. Package, Release 3e, by John R. Hauser.
  19804. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  19805. University of California. All rights reserved.
  19806. Redistribution and use in source and binary forms, with or without
  19807. modification, are permitted provided that the following conditions are met:
  19808. 1. Redistributions of source code must retain the above copyright notice,
  19809. this list of conditions, and the following disclaimer.
  19810. 2. Redistributions in binary form must reproduce the above copyright notice,
  19811. this list of conditions, and the following disclaimer in the documentation
  19812. and/or other materials provided with the distribution.
  19813. 3. Neither the name of the University nor the names of its contributors may
  19814. be used to endorse or promote products derived from this software without
  19815. specific prior written permission.
  19816. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  19817. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19818. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  19819. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  19820. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  19821. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  19822. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  19823. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  19824. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  19825. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  19826. =============================================================================*/
  19827. #include <stdbool.h>
  19828. #include <stdint.h>
  19829. /**** skipping file: platform.h ****/
  19830. /**** skipping file: internals.h ****/
  19831. /**** skipping file: specialize.h ****/
  19832. /**** skipping file: softfloat.h ****/
  19833. #ifdef SOFTFLOAT_FAST_INT64
  19834. uint_fast32_t
  19835. extF80M_to_ui32(
  19836. const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
  19837. {
  19838. return extF80_to_ui32( *aPtr, roundingMode, exact );
  19839. }
  19840. #else
  19841. uint_fast32_t
  19842. extF80M_to_ui32(
  19843. const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
  19844. {
  19845. const struct extFloat80M *aSPtr;
  19846. uint_fast16_t uiA64;
  19847. bool sign;
  19848. int32_t exp;
  19849. uint64_t sig;
  19850. int32_t shiftDist;
  19851. /*------------------------------------------------------------------------
  19852. *------------------------------------------------------------------------*/
  19853. aSPtr = (const struct extFloat80M *) aPtr;
  19854. uiA64 = aSPtr->signExp;
  19855. sign = signExtF80UI64( uiA64 );
  19856. exp = expExtF80UI64( uiA64 );
  19857. sig = aSPtr->signif;
  19858. /*------------------------------------------------------------------------
  19859. *------------------------------------------------------------------------*/
  19860. shiftDist = 0x4032 - exp;
  19861. if ( shiftDist <= 0 ) {
  19862. if ( sig>>32 ) goto invalid;
  19863. if ( -32 < shiftDist ) {
  19864. sig <<= -shiftDist;
  19865. } else {
  19866. if ( (uint32_t) sig ) goto invalid;
  19867. }
  19868. } else {
  19869. sig = softfloat_shiftRightJam64( sig, shiftDist );
  19870. }
  19871. return softfloat_roundToUI32( sign, sig, roundingMode, exact );
  19872. /*------------------------------------------------------------------------
  19873. *------------------------------------------------------------------------*/
  19874. invalid:
  19875. softfloat_raiseFlags( softfloat_flag_invalid );
  19876. return
  19877. (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
  19878. ? ui32_fromNaN
  19879. : sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
  19880. }
  19881. #endif
  19882. /**** ended inlining ../../source/extF80M_to_ui32.c ****/
  19883. /**** start inlining ../../source/extF80M_to_ui64.c ****/
  19884. /*============================================================================
  19885. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  19886. Package, Release 3e, by John R. Hauser.
  19887. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  19888. University of California. All rights reserved.
  19889. Redistribution and use in source and binary forms, with or without
  19890. modification, are permitted provided that the following conditions are met:
  19891. 1. Redistributions of source code must retain the above copyright notice,
  19892. this list of conditions, and the following disclaimer.
  19893. 2. Redistributions in binary form must reproduce the above copyright notice,
  19894. this list of conditions, and the following disclaimer in the documentation
  19895. and/or other materials provided with the distribution.
  19896. 3. Neither the name of the University nor the names of its contributors may
  19897. be used to endorse or promote products derived from this software without
  19898. specific prior written permission.
  19899. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  19900. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19901. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  19902. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  19903. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  19904. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  19905. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  19906. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  19907. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  19908. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  19909. =============================================================================*/
  19910. #include <stdbool.h>
  19911. #include <stdint.h>
  19912. /**** skipping file: platform.h ****/
  19913. /**** skipping file: internals.h ****/
  19914. /**** skipping file: specialize.h ****/
  19915. /**** skipping file: softfloat.h ****/
  19916. #ifdef SOFTFLOAT_FAST_INT64
  19917. uint_fast64_t
  19918. extF80M_to_ui64(
  19919. const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
  19920. {
  19921. return extF80_to_ui64( *aPtr, roundingMode, exact );
  19922. }
  19923. #else
  19924. uint_fast64_t
  19925. extF80M_to_ui64(
  19926. const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
  19927. {
  19928. const struct extFloat80M *aSPtr;
  19929. uint_fast16_t uiA64;
  19930. bool sign;
  19931. int32_t exp;
  19932. uint64_t sig;
  19933. int32_t shiftDist;
  19934. uint32_t extSig[3];
  19935. /*------------------------------------------------------------------------
  19936. *------------------------------------------------------------------------*/
  19937. aSPtr = (const struct extFloat80M *) aPtr;
  19938. uiA64 = aSPtr->signExp;
  19939. sign = signExtF80UI64( uiA64 );
  19940. exp = expExtF80UI64( uiA64 );
  19941. sig = aSPtr->signif;
  19942. /*------------------------------------------------------------------------
  19943. *------------------------------------------------------------------------*/
  19944. shiftDist = 0x403E - exp;
  19945. if ( shiftDist < 0 ) {
  19946. softfloat_raiseFlags( softfloat_flag_invalid );
  19947. return
  19948. (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
  19949. ? ui64_fromNaN
  19950. : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
  19951. }
  19952. /*------------------------------------------------------------------------
  19953. *------------------------------------------------------------------------*/
  19954. extSig[indexWord( 3, 2 )] = sig>>32;
  19955. extSig[indexWord( 3, 1 )] = sig;
  19956. extSig[indexWord( 3, 0 )] = 0;
  19957. if ( shiftDist ) softfloat_shiftRightJam96M( extSig, shiftDist, extSig );
  19958. return softfloat_roundMToUI64( sign, extSig, roundingMode, exact );
  19959. }
  19960. #endif
  19961. /**** ended inlining ../../source/extF80M_to_ui64.c ****/
  19962. /**** start inlining ../../source/extF80M_to_i32.c ****/
  19963. /*============================================================================
  19964. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  19965. Package, Release 3e, by John R. Hauser.
  19966. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  19967. University of California. All rights reserved.
  19968. Redistribution and use in source and binary forms, with or without
  19969. modification, are permitted provided that the following conditions are met:
  19970. 1. Redistributions of source code must retain the above copyright notice,
  19971. this list of conditions, and the following disclaimer.
  19972. 2. Redistributions in binary form must reproduce the above copyright notice,
  19973. this list of conditions, and the following disclaimer in the documentation
  19974. and/or other materials provided with the distribution.
  19975. 3. Neither the name of the University nor the names of its contributors may
  19976. be used to endorse or promote products derived from this software without
  19977. specific prior written permission.
  19978. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  19979. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19980. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  19981. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  19982. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  19983. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  19984. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  19985. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  19986. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  19987. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  19988. =============================================================================*/
  19989. #include <stdbool.h>
  19990. #include <stdint.h>
  19991. /**** skipping file: platform.h ****/
  19992. /**** skipping file: internals.h ****/
  19993. /**** skipping file: specialize.h ****/
  19994. /**** skipping file: softfloat.h ****/
  19995. #ifdef SOFTFLOAT_FAST_INT64
  19996. int_fast32_t
  19997. extF80M_to_i32(
  19998. const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
  19999. {
  20000. return extF80_to_i32( *aPtr, roundingMode, exact );
  20001. }
  20002. #else
  20003. int_fast32_t
  20004. extF80M_to_i32(
  20005. const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
  20006. {
  20007. const struct extFloat80M *aSPtr;
  20008. uint_fast16_t uiA64;
  20009. bool sign;
  20010. int32_t exp;
  20011. uint64_t sig;
  20012. int32_t shiftDist;
  20013. /*------------------------------------------------------------------------
  20014. *------------------------------------------------------------------------*/
  20015. aSPtr = (const struct extFloat80M *) aPtr;
  20016. uiA64 = aSPtr->signExp;
  20017. sign = signExtF80UI64( uiA64 );
  20018. exp = expExtF80UI64( uiA64 );
  20019. sig = aSPtr->signif;
  20020. /*------------------------------------------------------------------------
  20021. *------------------------------------------------------------------------*/
  20022. shiftDist = 0x4032 - exp;
  20023. if ( shiftDist <= 0 ) {
  20024. if ( sig>>32 ) goto invalid;
  20025. if ( -32 < shiftDist ) {
  20026. sig <<= -shiftDist;
  20027. } else {
  20028. if ( (uint32_t) sig ) goto invalid;
  20029. }
  20030. } else {
  20031. sig = softfloat_shiftRightJam64( sig, shiftDist );
  20032. }
  20033. return softfloat_roundToI32( sign, sig, roundingMode, exact );
  20034. /*------------------------------------------------------------------------
  20035. *------------------------------------------------------------------------*/
  20036. invalid:
  20037. softfloat_raiseFlags( softfloat_flag_invalid );
  20038. return
  20039. (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ? i32_fromNaN
  20040. : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
  20041. }
  20042. #endif
  20043. /**** ended inlining ../../source/extF80M_to_i32.c ****/
  20044. /**** start inlining ../../source/extF80M_to_i64.c ****/
  20045. /*============================================================================
  20046. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  20047. Package, Release 3e, by John R. Hauser.
  20048. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  20049. University of California. All rights reserved.
  20050. Redistribution and use in source and binary forms, with or without
  20051. modification, are permitted provided that the following conditions are met:
  20052. 1. Redistributions of source code must retain the above copyright notice,
  20053. this list of conditions, and the following disclaimer.
  20054. 2. Redistributions in binary form must reproduce the above copyright notice,
  20055. this list of conditions, and the following disclaimer in the documentation
  20056. and/or other materials provided with the distribution.
  20057. 3. Neither the name of the University nor the names of its contributors may
  20058. be used to endorse or promote products derived from this software without
  20059. specific prior written permission.
  20060. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  20061. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20062. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  20063. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  20064. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  20065. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  20066. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  20067. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  20068. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  20069. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  20070. =============================================================================*/
  20071. #include <stdbool.h>
  20072. #include <stdint.h>
  20073. /**** skipping file: platform.h ****/
  20074. /**** skipping file: internals.h ****/
  20075. /**** skipping file: specialize.h ****/
  20076. /**** skipping file: softfloat.h ****/
  20077. #ifdef SOFTFLOAT_FAST_INT64
  20078. int_fast64_t
  20079. extF80M_to_i64(
  20080. const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
  20081. {
  20082. return extF80_to_i64( *aPtr, roundingMode, exact );
  20083. }
  20084. #else
  20085. int_fast64_t
  20086. extF80M_to_i64(
  20087. const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
  20088. {
  20089. const struct extFloat80M *aSPtr;
  20090. uint_fast16_t uiA64;
  20091. bool sign;
  20092. int32_t exp;
  20093. uint64_t sig;
  20094. int32_t shiftDist;
  20095. uint32_t extSig[3];
  20096. /*------------------------------------------------------------------------
  20097. *------------------------------------------------------------------------*/
  20098. aSPtr = (const struct extFloat80M *) aPtr;
  20099. uiA64 = aSPtr->signExp;
  20100. sign = signExtF80UI64( uiA64 );
  20101. exp = expExtF80UI64( uiA64 );
  20102. sig = aSPtr->signif;
  20103. /*------------------------------------------------------------------------
  20104. *------------------------------------------------------------------------*/
  20105. shiftDist = 0x403E - exp;
  20106. if ( shiftDist < 0 ) {
  20107. softfloat_raiseFlags( softfloat_flag_invalid );
  20108. return
  20109. (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
  20110. ? i64_fromNaN
  20111. : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
  20112. }
  20113. /*------------------------------------------------------------------------
  20114. *------------------------------------------------------------------------*/
  20115. extSig[indexWord( 3, 2 )] = sig>>32;
  20116. extSig[indexWord( 3, 1 )] = sig;
  20117. extSig[indexWord( 3, 0 )] = 0;
  20118. if ( shiftDist ) softfloat_shiftRightJam96M( extSig, shiftDist, extSig );
  20119. return softfloat_roundMToI64( sign, extSig, roundingMode, exact );
  20120. }
  20121. #endif
  20122. /**** ended inlining ../../source/extF80M_to_i64.c ****/
  20123. /**** start inlining ../../source/extF80M_to_ui32_r_minMag.c ****/
  20124. /*============================================================================
  20125. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  20126. Package, Release 3e, by John R. Hauser.
  20127. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  20128. California. All rights reserved.
  20129. Redistribution and use in source and binary forms, with or without
  20130. modification, are permitted provided that the following conditions are met:
  20131. 1. Redistributions of source code must retain the above copyright notice,
  20132. this list of conditions, and the following disclaimer.
  20133. 2. Redistributions in binary form must reproduce the above copyright notice,
  20134. this list of conditions, and the following disclaimer in the documentation
  20135. and/or other materials provided with the distribution.
  20136. 3. Neither the name of the University nor the names of its contributors may
  20137. be used to endorse or promote products derived from this software without
  20138. specific prior written permission.
  20139. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  20140. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20141. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  20142. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  20143. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  20144. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  20145. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  20146. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  20147. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  20148. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  20149. =============================================================================*/
  20150. #include <stdbool.h>
  20151. #include <stdint.h>
  20152. /**** skipping file: platform.h ****/
  20153. /**** skipping file: internals.h ****/
  20154. /**** skipping file: specialize.h ****/
  20155. /**** skipping file: softfloat.h ****/
  20156. #ifdef SOFTFLOAT_FAST_INT64
  20157. uint_fast32_t extF80M_to_ui32_r_minMag( const extFloat80_t *aPtr, bool exact )
  20158. {
  20159. return extF80_to_ui32_r_minMag( *aPtr, exact );
  20160. }
  20161. #else
  20162. uint_fast32_t extF80M_to_ui32_r_minMag( const extFloat80_t *aPtr, bool exact )
  20163. {
  20164. const struct extFloat80M *aSPtr;
  20165. uint_fast16_t uiA64;
  20166. int32_t exp;
  20167. uint64_t sig;
  20168. int32_t shiftDist;
  20169. bool sign;
  20170. uint64_t shiftedSig;
  20171. uint32_t z;
  20172. /*------------------------------------------------------------------------
  20173. *------------------------------------------------------------------------*/
  20174. aSPtr = (const struct extFloat80M *) aPtr;
  20175. uiA64 = aSPtr->signExp;
  20176. exp = expExtF80UI64( uiA64 );
  20177. sig = aSPtr->signif;
  20178. /*------------------------------------------------------------------------
  20179. *------------------------------------------------------------------------*/
  20180. if ( ! sig && (exp != 0x7FFF) ) return 0;
  20181. shiftDist = 0x403E - exp;
  20182. if ( 64 <= shiftDist ) {
  20183. if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
  20184. return 0;
  20185. }
  20186. /*------------------------------------------------------------------------
  20187. *------------------------------------------------------------------------*/
  20188. sign = signExtF80UI64( uiA64 );
  20189. if ( shiftDist < 0 ) {
  20190. if ( sign || sig>>32 || (shiftDist <= -31) ) goto invalid;
  20191. shiftedSig = (uint64_t) (uint32_t) sig<<-shiftDist;
  20192. if ( shiftedSig>>32 ) goto invalid;
  20193. z = shiftedSig;
  20194. } else {
  20195. shiftedSig = sig;
  20196. if ( shiftDist ) shiftedSig >>= shiftDist;
  20197. if ( shiftedSig>>32 ) goto invalid;
  20198. z = shiftedSig;
  20199. if ( sign && z ) goto invalid;
  20200. if ( exact && shiftDist && ((uint64_t) z<<shiftDist != sig) ) {
  20201. softfloat_exceptionFlags |= softfloat_flag_inexact;
  20202. }
  20203. }
  20204. return z;
  20205. /*------------------------------------------------------------------------
  20206. *------------------------------------------------------------------------*/
  20207. invalid:
  20208. softfloat_raiseFlags( softfloat_flag_invalid );
  20209. return
  20210. (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
  20211. ? ui32_fromNaN
  20212. : sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
  20213. }
  20214. #endif
  20215. /**** ended inlining ../../source/extF80M_to_ui32_r_minMag.c ****/
  20216. /**** start inlining ../../source/extF80M_to_ui64_r_minMag.c ****/
  20217. /*============================================================================
  20218. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  20219. Package, Release 3e, by John R. Hauser.
  20220. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  20221. California. All rights reserved.
  20222. Redistribution and use in source and binary forms, with or without
  20223. modification, are permitted provided that the following conditions are met:
  20224. 1. Redistributions of source code must retain the above copyright notice,
  20225. this list of conditions, and the following disclaimer.
  20226. 2. Redistributions in binary form must reproduce the above copyright notice,
  20227. this list of conditions, and the following disclaimer in the documentation
  20228. and/or other materials provided with the distribution.
  20229. 3. Neither the name of the University nor the names of its contributors may
  20230. be used to endorse or promote products derived from this software without
  20231. specific prior written permission.
  20232. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  20233. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20234. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  20235. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  20236. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  20237. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  20238. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  20239. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  20240. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  20241. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  20242. =============================================================================*/
  20243. #include <stdbool.h>
  20244. #include <stdint.h>
  20245. /**** skipping file: platform.h ****/
  20246. /**** skipping file: internals.h ****/
  20247. /**** skipping file: specialize.h ****/
  20248. /**** skipping file: softfloat.h ****/
  20249. #ifdef SOFTFLOAT_FAST_INT64
  20250. uint_fast64_t extF80M_to_ui64_r_minMag( const extFloat80_t *aPtr, bool exact )
  20251. {
  20252. return extF80_to_ui64_r_minMag( *aPtr, exact );
  20253. }
  20254. #else
  20255. uint_fast64_t extF80M_to_ui64_r_minMag( const extFloat80_t *aPtr, bool exact )
  20256. {
  20257. const struct extFloat80M *aSPtr;
  20258. uint_fast16_t uiA64;
  20259. int32_t exp;
  20260. uint64_t sig;
  20261. int32_t shiftDist;
  20262. bool sign;
  20263. uint64_t z;
  20264. /*------------------------------------------------------------------------
  20265. *------------------------------------------------------------------------*/
  20266. aSPtr = (const struct extFloat80M *) aPtr;
  20267. uiA64 = aSPtr->signExp;
  20268. exp = expExtF80UI64( uiA64 );
  20269. sig = aSPtr->signif;
  20270. /*------------------------------------------------------------------------
  20271. *------------------------------------------------------------------------*/
  20272. if ( ! sig && (exp != 0x7FFF) ) return 0;
  20273. shiftDist = 0x403E - exp;
  20274. if ( 64 <= shiftDist ) {
  20275. if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
  20276. return 0;
  20277. }
  20278. /*------------------------------------------------------------------------
  20279. *------------------------------------------------------------------------*/
  20280. sign = signExtF80UI64( uiA64 );
  20281. if ( shiftDist < 0 ) {
  20282. if ( sign || (shiftDist <= -63) ) goto invalid;
  20283. shiftDist = -shiftDist;
  20284. z = sig<<shiftDist;
  20285. if ( z>>shiftDist != sig ) goto invalid;
  20286. } else {
  20287. z = sig;
  20288. if ( shiftDist ) z >>= shiftDist;
  20289. if ( sign && z ) goto invalid;
  20290. if ( exact && shiftDist && (z<<shiftDist != sig) ) {
  20291. softfloat_exceptionFlags |= softfloat_flag_inexact;
  20292. }
  20293. }
  20294. return z;
  20295. /*------------------------------------------------------------------------
  20296. *------------------------------------------------------------------------*/
  20297. invalid:
  20298. softfloat_raiseFlags( softfloat_flag_invalid );
  20299. return
  20300. (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
  20301. ? ui64_fromNaN
  20302. : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
  20303. }
  20304. #endif
  20305. /**** ended inlining ../../source/extF80M_to_ui64_r_minMag.c ****/
  20306. /**** start inlining ../../source/extF80M_to_i32_r_minMag.c ****/
  20307. /*============================================================================
  20308. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  20309. Package, Release 3e, by John R. Hauser.
  20310. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  20311. California. All rights reserved.
  20312. Redistribution and use in source and binary forms, with or without
  20313. modification, are permitted provided that the following conditions are met:
  20314. 1. Redistributions of source code must retain the above copyright notice,
  20315. this list of conditions, and the following disclaimer.
  20316. 2. Redistributions in binary form must reproduce the above copyright notice,
  20317. this list of conditions, and the following disclaimer in the documentation
  20318. and/or other materials provided with the distribution.
  20319. 3. Neither the name of the University nor the names of its contributors may
  20320. be used to endorse or promote products derived from this software without
  20321. specific prior written permission.
  20322. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  20323. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20324. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  20325. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  20326. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  20327. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  20328. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  20329. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  20330. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  20331. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  20332. =============================================================================*/
  20333. #include <stdbool.h>
  20334. #include <stdint.h>
  20335. /**** skipping file: platform.h ****/
  20336. /**** skipping file: internals.h ****/
  20337. /**** skipping file: specialize.h ****/
  20338. /**** skipping file: softfloat.h ****/
  20339. #ifdef SOFTFLOAT_FAST_INT64
  20340. int_fast32_t extF80M_to_i32_r_minMag( const extFloat80_t *aPtr, bool exact )
  20341. {
  20342. return extF80_to_i32_r_minMag( *aPtr, exact );
  20343. }
  20344. #else
  20345. int_fast32_t extF80M_to_i32_r_minMag( const extFloat80_t *aPtr, bool exact )
  20346. {
  20347. const struct extFloat80M *aSPtr;
  20348. uint_fast16_t uiA64;
  20349. int32_t exp;
  20350. uint64_t sig;
  20351. int32_t shiftDist;
  20352. bool sign, raiseInexact;
  20353. int32_t z;
  20354. uint64_t shiftedSig;
  20355. uint32_t absZ;
  20356. union { uint32_t ui; int32_t i; } u;
  20357. /*------------------------------------------------------------------------
  20358. *------------------------------------------------------------------------*/
  20359. aSPtr = (const struct extFloat80M *) aPtr;
  20360. uiA64 = aSPtr->signExp;
  20361. exp = expExtF80UI64( uiA64 );
  20362. sig = aSPtr->signif;
  20363. /*------------------------------------------------------------------------
  20364. *------------------------------------------------------------------------*/
  20365. if ( ! sig && (exp != 0x7FFF) ) return 0;
  20366. shiftDist = 0x403E - exp;
  20367. if ( 64 <= shiftDist ) {
  20368. raiseInexact = exact;
  20369. z = 0;
  20370. } else {
  20371. sign = signExtF80UI64( uiA64 );
  20372. raiseInexact = false;
  20373. if ( shiftDist < 0 ) {
  20374. if ( sig>>32 || (shiftDist <= -31) ) goto invalid;
  20375. shiftedSig = (uint64_t) (uint32_t) sig<<-shiftDist;
  20376. if ( shiftedSig>>32 ) goto invalid;
  20377. absZ = shiftedSig;
  20378. } else {
  20379. shiftedSig = sig;
  20380. if ( shiftDist ) shiftedSig >>= shiftDist;
  20381. if ( shiftedSig>>32 ) goto invalid;
  20382. absZ = shiftedSig;
  20383. if ( exact && shiftDist ) {
  20384. raiseInexact = ((uint64_t) absZ<<shiftDist != sig);
  20385. }
  20386. }
  20387. if ( sign ) {
  20388. if ( 0x80000000 < absZ ) goto invalid;
  20389. u.ui = -absZ;
  20390. z = u.i;
  20391. } else {
  20392. if ( 0x80000000 <= absZ ) goto invalid;
  20393. z = absZ;
  20394. }
  20395. }
  20396. if ( raiseInexact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
  20397. return z;
  20398. /*------------------------------------------------------------------------
  20399. *------------------------------------------------------------------------*/
  20400. invalid:
  20401. softfloat_raiseFlags( softfloat_flag_invalid );
  20402. return
  20403. (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ? i32_fromNaN
  20404. : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
  20405. }
  20406. #endif
  20407. /**** ended inlining ../../source/extF80M_to_i32_r_minMag.c ****/
  20408. /**** start inlining ../../source/extF80M_to_i64_r_minMag.c ****/
  20409. /*============================================================================
  20410. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  20411. Package, Release 3e, by John R. Hauser.
  20412. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  20413. California. All rights reserved.
  20414. Redistribution and use in source and binary forms, with or without
  20415. modification, are permitted provided that the following conditions are met:
  20416. 1. Redistributions of source code must retain the above copyright notice,
  20417. this list of conditions, and the following disclaimer.
  20418. 2. Redistributions in binary form must reproduce the above copyright notice,
  20419. this list of conditions, and the following disclaimer in the documentation
  20420. and/or other materials provided with the distribution.
  20421. 3. Neither the name of the University nor the names of its contributors may
  20422. be used to endorse or promote products derived from this software without
  20423. specific prior written permission.
  20424. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  20425. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20426. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  20427. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  20428. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  20429. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  20430. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  20431. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  20432. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  20433. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  20434. =============================================================================*/
  20435. #include <stdbool.h>
  20436. #include <stdint.h>
  20437. /**** skipping file: platform.h ****/
  20438. /**** skipping file: internals.h ****/
  20439. /**** skipping file: specialize.h ****/
  20440. /**** skipping file: softfloat.h ****/
  20441. #ifdef SOFTFLOAT_FAST_INT64
  20442. int_fast64_t extF80M_to_i64_r_minMag( const extFloat80_t *aPtr, bool exact )
  20443. {
  20444. return extF80_to_i64_r_minMag( *aPtr, exact );
  20445. }
  20446. #else
  20447. int_fast64_t extF80M_to_i64_r_minMag( const extFloat80_t *aPtr, bool exact )
  20448. {
  20449. const struct extFloat80M *aSPtr;
  20450. uint_fast16_t uiA64;
  20451. int32_t exp;
  20452. uint64_t sig;
  20453. int32_t shiftDist;
  20454. bool sign, raiseInexact;
  20455. int64_t z;
  20456. uint64_t absZ;
  20457. union { uint64_t ui; int64_t i; } u;
  20458. /*------------------------------------------------------------------------
  20459. *------------------------------------------------------------------------*/
  20460. aSPtr = (const struct extFloat80M *) aPtr;
  20461. uiA64 = aSPtr->signExp;
  20462. exp = expExtF80UI64( uiA64 );
  20463. sig = aSPtr->signif;
  20464. /*------------------------------------------------------------------------
  20465. *------------------------------------------------------------------------*/
  20466. if ( ! sig && (exp != 0x7FFF) ) return 0;
  20467. shiftDist = 0x403E - exp;
  20468. if ( 64 <= shiftDist ) {
  20469. raiseInexact = exact;
  20470. z = 0;
  20471. } else {
  20472. sign = signExtF80UI64( uiA64 );
  20473. raiseInexact = false;
  20474. if ( shiftDist < 0 ) {
  20475. if ( shiftDist <= -63 ) goto invalid;
  20476. shiftDist = -shiftDist;
  20477. absZ = sig<<shiftDist;
  20478. if ( absZ>>shiftDist != sig ) goto invalid;
  20479. } else {
  20480. absZ = sig;
  20481. if ( shiftDist ) absZ >>= shiftDist;
  20482. if ( exact && shiftDist ) raiseInexact = (absZ<<shiftDist != sig);
  20483. }
  20484. if ( sign ) {
  20485. if ( UINT64_C( 0x8000000000000000 ) < absZ ) goto invalid;
  20486. u.ui = -absZ;
  20487. z = u.i;
  20488. } else {
  20489. if ( UINT64_C( 0x8000000000000000 ) <= absZ ) goto invalid;
  20490. z = absZ;
  20491. }
  20492. }
  20493. if ( raiseInexact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
  20494. return z;
  20495. /*------------------------------------------------------------------------
  20496. *------------------------------------------------------------------------*/
  20497. invalid:
  20498. softfloat_raiseFlags( softfloat_flag_invalid );
  20499. return
  20500. (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ? i64_fromNaN
  20501. : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
  20502. }
  20503. #endif
  20504. /**** ended inlining ../../source/extF80M_to_i64_r_minMag.c ****/
  20505. /**** start inlining ../../source/extF80M_to_f16.c ****/
  20506. /*============================================================================
  20507. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  20508. Package, Release 3e, by John R. Hauser.
  20509. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  20510. California. All rights reserved.
  20511. Redistribution and use in source and binary forms, with or without
  20512. modification, are permitted provided that the following conditions are met:
  20513. 1. Redistributions of source code must retain the above copyright notice,
  20514. this list of conditions, and the following disclaimer.
  20515. 2. Redistributions in binary form must reproduce the above copyright notice,
  20516. this list of conditions, and the following disclaimer in the documentation
  20517. and/or other materials provided with the distribution.
  20518. 3. Neither the name of the University nor the names of its contributors may
  20519. be used to endorse or promote products derived from this software without
  20520. specific prior written permission.
  20521. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  20522. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20523. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  20524. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  20525. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  20526. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  20527. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  20528. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  20529. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  20530. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  20531. =============================================================================*/
  20532. #include <stdbool.h>
  20533. #include <stdint.h>
  20534. /**** skipping file: platform.h ****/
  20535. /**** skipping file: internals.h ****/
  20536. /**** skipping file: specialize.h ****/
  20537. /**** skipping file: softfloat.h ****/
  20538. #ifdef SOFTFLOAT_FAST_INT64
  20539. float16_t extF80M_to_f16( const extFloat80_t *aPtr )
  20540. {
  20541. return extF80_to_f16( *aPtr );
  20542. }
  20543. #else
  20544. float16_t extF80M_to_f16( const extFloat80_t *aPtr )
  20545. {
  20546. const struct extFloat80M *aSPtr;
  20547. uint_fast16_t uiA64;
  20548. bool sign;
  20549. int32_t exp;
  20550. uint64_t sig;
  20551. struct commonNaN commonNaN;
  20552. uint16_t uiZ, sig16;
  20553. union ui16_f16 uZ;
  20554. /*------------------------------------------------------------------------
  20555. *------------------------------------------------------------------------*/
  20556. aSPtr = (const struct extFloat80M *) aPtr;
  20557. /*------------------------------------------------------------------------
  20558. *------------------------------------------------------------------------*/
  20559. uiA64 = aSPtr->signExp;
  20560. sign = signExtF80UI64( uiA64 );
  20561. exp = expExtF80UI64( uiA64 );
  20562. sig = aSPtr->signif;
  20563. /*------------------------------------------------------------------------
  20564. *------------------------------------------------------------------------*/
  20565. if ( exp == 0x7FFF ) {
  20566. if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
  20567. softfloat_extF80MToCommonNaN( aSPtr, &commonNaN );
  20568. uiZ = softfloat_commonNaNToF16UI( &commonNaN );
  20569. } else {
  20570. uiZ = packToF16UI( sign, 0x1F, 0 );
  20571. }
  20572. goto uiZ;
  20573. }
  20574. /*------------------------------------------------------------------------
  20575. *------------------------------------------------------------------------*/
  20576. if ( ! (sig & UINT64_C( 0x8000000000000000 )) ) {
  20577. if ( ! sig ) {
  20578. uiZ = packToF16UI( sign, 0, 0 );
  20579. goto uiZ;
  20580. }
  20581. exp += softfloat_normExtF80SigM( &sig );
  20582. }
  20583. /*------------------------------------------------------------------------
  20584. *------------------------------------------------------------------------*/
  20585. sig16 = softfloat_shortShiftRightJam64( sig, 49 );
  20586. exp -= 0x3FF1;
  20587. if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
  20588. if ( exp < -0x40 ) exp = -0x40;
  20589. }
  20590. return softfloat_roundPackToF16( sign, exp, sig16 );
  20591. /*------------------------------------------------------------------------
  20592. *------------------------------------------------------------------------*/
  20593. uiZ:
  20594. uZ.ui = uiZ;
  20595. return uZ.f;
  20596. }
  20597. #endif
  20598. /**** ended inlining ../../source/extF80M_to_f16.c ****/
  20599. /**** start inlining ../../source/extF80M_to_f32.c ****/
  20600. /*============================================================================
  20601. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  20602. Package, Release 3e, by John R. Hauser.
  20603. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  20604. California. All rights reserved.
  20605. Redistribution and use in source and binary forms, with or without
  20606. modification, are permitted provided that the following conditions are met:
  20607. 1. Redistributions of source code must retain the above copyright notice,
  20608. this list of conditions, and the following disclaimer.
  20609. 2. Redistributions in binary form must reproduce the above copyright notice,
  20610. this list of conditions, and the following disclaimer in the documentation
  20611. and/or other materials provided with the distribution.
  20612. 3. Neither the name of the University nor the names of its contributors may
  20613. be used to endorse or promote products derived from this software without
  20614. specific prior written permission.
  20615. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  20616. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20617. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  20618. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  20619. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  20620. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  20621. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  20622. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  20623. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  20624. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  20625. =============================================================================*/
  20626. #include <stdbool.h>
  20627. #include <stdint.h>
  20628. /**** skipping file: platform.h ****/
  20629. /**** skipping file: internals.h ****/
  20630. /**** skipping file: specialize.h ****/
  20631. /**** skipping file: softfloat.h ****/
  20632. #ifdef SOFTFLOAT_FAST_INT64
  20633. float32_t extF80M_to_f32( const extFloat80_t *aPtr )
  20634. {
  20635. return extF80_to_f32( *aPtr );
  20636. }
  20637. #else
  20638. float32_t extF80M_to_f32( const extFloat80_t *aPtr )
  20639. {
  20640. const struct extFloat80M *aSPtr;
  20641. uint_fast16_t uiA64;
  20642. bool sign;
  20643. int32_t exp;
  20644. uint64_t sig;
  20645. struct commonNaN commonNaN;
  20646. uint32_t uiZ, sig32;
  20647. union ui32_f32 uZ;
  20648. /*------------------------------------------------------------------------
  20649. *------------------------------------------------------------------------*/
  20650. aSPtr = (const struct extFloat80M *) aPtr;
  20651. /*------------------------------------------------------------------------
  20652. *------------------------------------------------------------------------*/
  20653. uiA64 = aSPtr->signExp;
  20654. sign = signExtF80UI64( uiA64 );
  20655. exp = expExtF80UI64( uiA64 );
  20656. sig = aSPtr->signif;
  20657. /*------------------------------------------------------------------------
  20658. *------------------------------------------------------------------------*/
  20659. if ( exp == 0x7FFF ) {
  20660. if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
  20661. softfloat_extF80MToCommonNaN( aSPtr, &commonNaN );
  20662. uiZ = softfloat_commonNaNToF32UI( &commonNaN );
  20663. } else {
  20664. uiZ = packToF32UI( sign, 0xFF, 0 );
  20665. }
  20666. goto uiZ;
  20667. }
  20668. /*------------------------------------------------------------------------
  20669. *------------------------------------------------------------------------*/
  20670. if ( ! (sig & UINT64_C( 0x8000000000000000 )) ) {
  20671. if ( ! sig ) {
  20672. uiZ = packToF32UI( sign, 0, 0 );
  20673. goto uiZ;
  20674. }
  20675. exp += softfloat_normExtF80SigM( &sig );
  20676. }
  20677. /*------------------------------------------------------------------------
  20678. *------------------------------------------------------------------------*/
  20679. sig32 = softfloat_shortShiftRightJam64( sig, 33 );
  20680. exp -= 0x3F81;
  20681. if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
  20682. if ( exp < -0x1000 ) exp = -0x1000;
  20683. }
  20684. return softfloat_roundPackToF32( sign, exp, sig32 );
  20685. /*------------------------------------------------------------------------
  20686. *------------------------------------------------------------------------*/
  20687. uiZ:
  20688. uZ.ui = uiZ;
  20689. return uZ.f;
  20690. }
  20691. #endif
  20692. /**** ended inlining ../../source/extF80M_to_f32.c ****/
  20693. /**** start inlining ../../source/extF80M_to_f64.c ****/
  20694. /*============================================================================
  20695. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  20696. Package, Release 3e, by John R. Hauser.
  20697. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  20698. California. All rights reserved.
  20699. Redistribution and use in source and binary forms, with or without
  20700. modification, are permitted provided that the following conditions are met:
  20701. 1. Redistributions of source code must retain the above copyright notice,
  20702. this list of conditions, and the following disclaimer.
  20703. 2. Redistributions in binary form must reproduce the above copyright notice,
  20704. this list of conditions, and the following disclaimer in the documentation
  20705. and/or other materials provided with the distribution.
  20706. 3. Neither the name of the University nor the names of its contributors may
  20707. be used to endorse or promote products derived from this software without
  20708. specific prior written permission.
  20709. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  20710. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20711. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  20712. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  20713. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  20714. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  20715. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  20716. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  20717. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  20718. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  20719. =============================================================================*/
  20720. #include <stdbool.h>
  20721. #include <stdint.h>
  20722. /**** skipping file: platform.h ****/
  20723. /**** skipping file: internals.h ****/
  20724. /**** skipping file: specialize.h ****/
  20725. /**** skipping file: softfloat.h ****/
  20726. #ifdef SOFTFLOAT_FAST_INT64
  20727. float64_t extF80M_to_f64( const extFloat80_t *aPtr )
  20728. {
  20729. return extF80_to_f64( *aPtr );
  20730. }
  20731. #else
  20732. float64_t extF80M_to_f64( const extFloat80_t *aPtr )
  20733. {
  20734. const struct extFloat80M *aSPtr;
  20735. uint_fast16_t uiA64;
  20736. bool sign;
  20737. int32_t exp;
  20738. uint64_t sig;
  20739. struct commonNaN commonNaN;
  20740. uint64_t uiZ;
  20741. union ui64_f64 uZ;
  20742. /*------------------------------------------------------------------------
  20743. *------------------------------------------------------------------------*/
  20744. aSPtr = (const struct extFloat80M *) aPtr;
  20745. /*------------------------------------------------------------------------
  20746. *------------------------------------------------------------------------*/
  20747. uiA64 = aSPtr->signExp;
  20748. sign = signExtF80UI64( uiA64 );
  20749. exp = expExtF80UI64( uiA64 );
  20750. sig = aSPtr->signif;
  20751. /*------------------------------------------------------------------------
  20752. *------------------------------------------------------------------------*/
  20753. if ( exp == 0x7FFF ) {
  20754. if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
  20755. softfloat_extF80MToCommonNaN( aSPtr, &commonNaN );
  20756. uiZ = softfloat_commonNaNToF64UI( &commonNaN );
  20757. } else {
  20758. uiZ = packToF64UI( sign, 0x7FF, 0 );
  20759. }
  20760. goto uiZ;
  20761. }
  20762. /*------------------------------------------------------------------------
  20763. *------------------------------------------------------------------------*/
  20764. if ( ! (sig & UINT64_C( 0x8000000000000000 )) ) {
  20765. if ( ! sig ) {
  20766. uiZ = packToF64UI( sign, 0, 0 );
  20767. goto uiZ;
  20768. }
  20769. exp += softfloat_normExtF80SigM( &sig );
  20770. }
  20771. /*------------------------------------------------------------------------
  20772. *------------------------------------------------------------------------*/
  20773. sig = softfloat_shortShiftRightJam64( sig, 1 );
  20774. exp -= 0x3C01;
  20775. if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
  20776. if ( exp < -0x1000 ) exp = -0x1000;
  20777. }
  20778. return softfloat_roundPackToF64( sign, exp, sig );
  20779. /*------------------------------------------------------------------------
  20780. *------------------------------------------------------------------------*/
  20781. uiZ:
  20782. uZ.ui = uiZ;
  20783. return uZ.f;
  20784. }
  20785. #endif
  20786. /**** ended inlining ../../source/extF80M_to_f64.c ****/
  20787. /**** start inlining ../../source/extF80M_to_f128M.c ****/
  20788. /*============================================================================
  20789. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  20790. Package, Release 3e, by John R. Hauser.
  20791. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  20792. All rights reserved.
  20793. Redistribution and use in source and binary forms, with or without
  20794. modification, are permitted provided that the following conditions are met:
  20795. 1. Redistributions of source code must retain the above copyright notice,
  20796. this list of conditions, and the following disclaimer.
  20797. 2. Redistributions in binary form must reproduce the above copyright notice,
  20798. this list of conditions, and the following disclaimer in the documentation
  20799. and/or other materials provided with the distribution.
  20800. 3. Neither the name of the University nor the names of its contributors may
  20801. be used to endorse or promote products derived from this software without
  20802. specific prior written permission.
  20803. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  20804. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20805. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  20806. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  20807. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  20808. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  20809. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  20810. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  20811. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  20812. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  20813. =============================================================================*/
  20814. #include <stdbool.h>
  20815. #include <stdint.h>
  20816. /**** skipping file: platform.h ****/
  20817. /**** skipping file: internals.h ****/
  20818. /**** skipping file: specialize.h ****/
  20819. /**** skipping file: softfloat.h ****/
  20820. #ifdef SOFTFLOAT_FAST_INT64
  20821. void extF80M_to_f128M( const extFloat80_t *aPtr, float128_t *zPtr )
  20822. {
  20823. *zPtr = extF80_to_f128( *aPtr );
  20824. }
  20825. #else
  20826. void extF80M_to_f128M( const extFloat80_t *aPtr, float128_t *zPtr )
  20827. {
  20828. const struct extFloat80M *aSPtr;
  20829. uint32_t *zWPtr;
  20830. uint_fast16_t uiA64;
  20831. bool sign;
  20832. int32_t exp;
  20833. uint64_t sig;
  20834. struct commonNaN commonNaN;
  20835. uint32_t uiZ96;
  20836. /*------------------------------------------------------------------------
  20837. *------------------------------------------------------------------------*/
  20838. aSPtr = (const struct extFloat80M *) aPtr;
  20839. zWPtr = (uint32_t *) zPtr;
  20840. /*------------------------------------------------------------------------
  20841. *------------------------------------------------------------------------*/
  20842. uiA64 = aSPtr->signExp;
  20843. sign = signExtF80UI64( uiA64 );
  20844. exp = expExtF80UI64( uiA64 );
  20845. sig = aSPtr->signif;
  20846. /*------------------------------------------------------------------------
  20847. *------------------------------------------------------------------------*/
  20848. zWPtr[indexWord( 4, 0 )] = 0;
  20849. if ( exp == 0x7FFF ) {
  20850. if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
  20851. softfloat_extF80MToCommonNaN( aSPtr, &commonNaN );
  20852. softfloat_commonNaNToF128M( &commonNaN, zWPtr );
  20853. return;
  20854. }
  20855. uiZ96 = packToF128UI96( sign, 0x7FFF, 0 );
  20856. goto uiZ;
  20857. }
  20858. /*------------------------------------------------------------------------
  20859. *------------------------------------------------------------------------*/
  20860. if ( exp ) --exp;
  20861. if ( ! (sig & UINT64_C( 0x8000000000000000 )) ) {
  20862. if ( ! sig ) {
  20863. uiZ96 = packToF128UI96( sign, 0, 0 );
  20864. goto uiZ;
  20865. }
  20866. exp += softfloat_normExtF80SigM( &sig );
  20867. }
  20868. /*------------------------------------------------------------------------
  20869. *------------------------------------------------------------------------*/
  20870. zWPtr[indexWord( 4, 1 )] = (uint32_t) sig<<17;
  20871. sig >>= 15;
  20872. zWPtr[indexWord( 4, 2 )] = sig;
  20873. if ( exp < 0 ) {
  20874. zWPtr[indexWordHi( 4 )] = sig>>32;
  20875. softfloat_shiftRight96M(
  20876. &zWPtr[indexMultiwordHi( 4, 3 )],
  20877. -exp,
  20878. &zWPtr[indexMultiwordHi( 4, 3 )]
  20879. );
  20880. exp = 0;
  20881. sig = (uint64_t) zWPtr[indexWordHi( 4 )]<<32;
  20882. }
  20883. zWPtr[indexWordHi( 4 )] = packToF128UI96( sign, exp, sig>>32 );
  20884. return;
  20885. /*------------------------------------------------------------------------
  20886. *------------------------------------------------------------------------*/
  20887. uiZ:
  20888. zWPtr[indexWord( 4, 3 )] = uiZ96;
  20889. zWPtr[indexWord( 4, 2 )] = 0;
  20890. zWPtr[indexWord( 4, 1 )] = 0;
  20891. }
  20892. #endif
  20893. /**** ended inlining ../../source/extF80M_to_f128M.c ****/
  20894. /**** start inlining ../../source/extF80M_roundToInt.c ****/
  20895. /*============================================================================
  20896. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  20897. Package, Release 3e, by John R. Hauser.
  20898. Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
  20899. California. All rights reserved.
  20900. Redistribution and use in source and binary forms, with or without
  20901. modification, are permitted provided that the following conditions are met:
  20902. 1. Redistributions of source code must retain the above copyright notice,
  20903. this list of conditions, and the following disclaimer.
  20904. 2. Redistributions in binary form must reproduce the above copyright notice,
  20905. this list of conditions, and the following disclaimer in the documentation
  20906. and/or other materials provided with the distribution.
  20907. 3. Neither the name of the University nor the names of its contributors may
  20908. be used to endorse or promote products derived from this software without
  20909. specific prior written permission.
  20910. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  20911. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20912. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  20913. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  20914. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  20915. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  20916. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  20917. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  20918. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  20919. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  20920. =============================================================================*/
  20921. #include <stdbool.h>
  20922. #include <stdint.h>
  20923. /**** skipping file: platform.h ****/
  20924. /**** skipping file: internals.h ****/
  20925. /**** skipping file: specialize.h ****/
  20926. /**** skipping file: softfloat.h ****/
  20927. #ifdef SOFTFLOAT_FAST_INT64
  20928. void
  20929. extF80M_roundToInt(
  20930. const extFloat80_t *aPtr,
  20931. uint_fast8_t roundingMode,
  20932. bool exact,
  20933. extFloat80_t *zPtr
  20934. )
  20935. {
  20936. *zPtr = extF80_roundToInt( *aPtr, roundingMode, exact );
  20937. }
  20938. #else
  20939. void
  20940. extF80M_roundToInt(
  20941. const extFloat80_t *aPtr,
  20942. uint_fast8_t roundingMode,
  20943. bool exact,
  20944. extFloat80_t *zPtr
  20945. )
  20946. {
  20947. const struct extFloat80M *aSPtr;
  20948. struct extFloat80M *zSPtr;
  20949. uint_fast16_t uiA64, signUI64;
  20950. int32_t exp;
  20951. uint64_t sigA;
  20952. uint_fast16_t uiZ64;
  20953. uint64_t sigZ, lastBitMask, roundBitsMask;
  20954. /*------------------------------------------------------------------------
  20955. *------------------------------------------------------------------------*/
  20956. aSPtr = (const struct extFloat80M *) aPtr;
  20957. zSPtr = (struct extFloat80M *) zPtr;
  20958. /*------------------------------------------------------------------------
  20959. *------------------------------------------------------------------------*/
  20960. uiA64 = aSPtr->signExp;
  20961. signUI64 = uiA64 & packToExtF80UI64( 1, 0 );
  20962. exp = expExtF80UI64( uiA64 );
  20963. sigA = aSPtr->signif;
  20964. /*------------------------------------------------------------------------
  20965. *------------------------------------------------------------------------*/
  20966. if ( !(sigA & UINT64_C( 0x8000000000000000 )) && (exp != 0x7FFF) ) {
  20967. if ( !sigA ) {
  20968. uiZ64 = signUI64;
  20969. sigZ = 0;
  20970. goto uiZ;
  20971. }
  20972. exp += softfloat_normExtF80SigM( &sigA );
  20973. }
  20974. /*------------------------------------------------------------------------
  20975. *------------------------------------------------------------------------*/
  20976. if ( exp <= 0x3FFE ) {
  20977. if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
  20978. switch ( roundingMode ) {
  20979. case softfloat_round_near_even:
  20980. if ( !(sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ) break;
  20981. case softfloat_round_near_maxMag:
  20982. if ( exp == 0x3FFE ) goto mag1;
  20983. break;
  20984. case softfloat_round_min:
  20985. if ( signUI64 ) goto mag1;
  20986. break;
  20987. case softfloat_round_max:
  20988. if ( !signUI64 ) goto mag1;
  20989. break;
  20990. #ifdef SOFTFLOAT_ROUND_ODD
  20991. case softfloat_round_odd:
  20992. goto mag1;
  20993. #endif
  20994. }
  20995. uiZ64 = signUI64;
  20996. sigZ = 0;
  20997. goto uiZ;
  20998. mag1:
  20999. uiZ64 = signUI64 | 0x3FFF;
  21000. sigZ = UINT64_C( 0x8000000000000000 );
  21001. goto uiZ;
  21002. }
  21003. /*------------------------------------------------------------------------
  21004. *------------------------------------------------------------------------*/
  21005. if ( 0x403E <= exp ) {
  21006. if ( exp == 0x7FFF ) {
  21007. if ( sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
  21008. softfloat_propagateNaNExtF80M( aSPtr, 0, zSPtr );
  21009. return;
  21010. }
  21011. sigZ = UINT64_C( 0x8000000000000000 );
  21012. } else {
  21013. sigZ = sigA;
  21014. }
  21015. uiZ64 = signUI64 | exp;
  21016. goto uiZ;
  21017. }
  21018. /*------------------------------------------------------------------------
  21019. *------------------------------------------------------------------------*/
  21020. uiZ64 = signUI64 | exp;
  21021. lastBitMask = (uint64_t) 1<<(0x403E - exp);
  21022. roundBitsMask = lastBitMask - 1;
  21023. sigZ = sigA;
  21024. if ( roundingMode == softfloat_round_near_maxMag ) {
  21025. sigZ += lastBitMask>>1;
  21026. } else if ( roundingMode == softfloat_round_near_even ) {
  21027. sigZ += lastBitMask>>1;
  21028. if ( !(sigZ & roundBitsMask) ) sigZ &= ~lastBitMask;
  21029. } else if (
  21030. roundingMode == (signUI64 ? softfloat_round_min : softfloat_round_max)
  21031. ) {
  21032. sigZ += roundBitsMask;
  21033. }
  21034. sigZ &= ~roundBitsMask;
  21035. if ( !sigZ ) {
  21036. ++uiZ64;
  21037. sigZ = UINT64_C( 0x8000000000000000 );
  21038. }
  21039. if ( sigZ != sigA ) {
  21040. #ifdef SOFTFLOAT_ROUND_ODD
  21041. if ( roundingMode == softfloat_round_odd ) sigZ |= lastBitMask;
  21042. #endif
  21043. if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
  21044. }
  21045. uiZ:
  21046. zSPtr->signExp = uiZ64;
  21047. zSPtr->signif = sigZ;
  21048. return;
  21049. }
  21050. #endif
  21051. /**** ended inlining ../../source/extF80M_roundToInt.c ****/
  21052. /**** start inlining ../../source/extF80M_add.c ****/
  21053. /*============================================================================
  21054. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  21055. Package, Release 3e, by John R. Hauser.
  21056. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  21057. All rights reserved.
  21058. Redistribution and use in source and binary forms, with or without
  21059. modification, are permitted provided that the following conditions are met:
  21060. 1. Redistributions of source code must retain the above copyright notice,
  21061. this list of conditions, and the following disclaimer.
  21062. 2. Redistributions in binary form must reproduce the above copyright notice,
  21063. this list of conditions, and the following disclaimer in the documentation
  21064. and/or other materials provided with the distribution.
  21065. 3. Neither the name of the University nor the names of its contributors may
  21066. be used to endorse or promote products derived from this software without
  21067. specific prior written permission.
  21068. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  21069. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21070. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  21071. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  21072. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21073. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  21074. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  21075. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  21076. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  21077. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  21078. =============================================================================*/
  21079. #include <stdbool.h>
  21080. /**** skipping file: platform.h ****/
  21081. /**** skipping file: internals.h ****/
  21082. /**** skipping file: softfloat.h ****/
  21083. #ifdef SOFTFLOAT_FAST_INT64
  21084. void
  21085. extF80M_add(
  21086. const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
  21087. {
  21088. const struct extFloat80M *aSPtr, *bSPtr;
  21089. uint_fast16_t uiA64;
  21090. uint_fast64_t uiA0;
  21091. bool signA;
  21092. uint_fast16_t uiB64;
  21093. uint_fast64_t uiB0;
  21094. bool signB;
  21095. #if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
  21096. extFloat80_t
  21097. (*magsFuncPtr)(
  21098. uint_fast16_t, uint_fast64_t, uint_fast16_t, uint_fast64_t, bool );
  21099. #endif
  21100. aSPtr = (const struct extFloat80M *) aPtr;
  21101. bSPtr = (const struct extFloat80M *) bPtr;
  21102. uiA64 = aSPtr->signExp;
  21103. uiA0 = aSPtr->signif;
  21104. signA = signExtF80UI64( uiA64 );
  21105. uiB64 = bSPtr->signExp;
  21106. uiB0 = bSPtr->signif;
  21107. signB = signExtF80UI64( uiB64 );
  21108. #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
  21109. if ( signA == signB ) {
  21110. *zPtr = softfloat_addMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
  21111. } else {
  21112. *zPtr = softfloat_subMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
  21113. }
  21114. #else
  21115. magsFuncPtr =
  21116. (signA == signB) ? softfloat_addMagsExtF80 : softfloat_subMagsExtF80;
  21117. *zPtr = (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
  21118. #endif
  21119. }
  21120. #else
  21121. void
  21122. extF80M_add(
  21123. const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
  21124. {
  21125. softfloat_addExtF80M(
  21126. (const struct extFloat80M *) aPtr,
  21127. (const struct extFloat80M *) bPtr,
  21128. (struct extFloat80M *) zPtr,
  21129. false
  21130. );
  21131. }
  21132. #endif
  21133. /**** ended inlining ../../source/extF80M_add.c ****/
  21134. /**** start inlining ../../source/extF80M_sub.c ****/
  21135. /*============================================================================
  21136. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  21137. Package, Release 3e, by John R. Hauser.
  21138. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  21139. All rights reserved.
  21140. Redistribution and use in source and binary forms, with or without
  21141. modification, are permitted provided that the following conditions are met:
  21142. 1. Redistributions of source code must retain the above copyright notice,
  21143. this list of conditions, and the following disclaimer.
  21144. 2. Redistributions in binary form must reproduce the above copyright notice,
  21145. this list of conditions, and the following disclaimer in the documentation
  21146. and/or other materials provided with the distribution.
  21147. 3. Neither the name of the University nor the names of its contributors may
  21148. be used to endorse or promote products derived from this software without
  21149. specific prior written permission.
  21150. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  21151. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21152. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  21153. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  21154. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21155. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  21156. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  21157. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  21158. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  21159. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  21160. =============================================================================*/
  21161. #include <stdbool.h>
  21162. /**** skipping file: platform.h ****/
  21163. /**** skipping file: internals.h ****/
  21164. /**** skipping file: softfloat.h ****/
  21165. #ifdef SOFTFLOAT_FAST_INT64
  21166. void
  21167. extF80M_sub(
  21168. const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
  21169. {
  21170. const struct extFloat80M *aSPtr, *bSPtr;
  21171. uint_fast16_t uiA64;
  21172. uint_fast64_t uiA0;
  21173. bool signA;
  21174. uint_fast16_t uiB64;
  21175. uint_fast64_t uiB0;
  21176. bool signB;
  21177. #if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
  21178. extFloat80_t
  21179. (*magsFuncPtr)(
  21180. uint_fast16_t, uint_fast64_t, uint_fast16_t, uint_fast64_t, bool );
  21181. #endif
  21182. aSPtr = (const struct extFloat80M *) aPtr;
  21183. bSPtr = (const struct extFloat80M *) bPtr;
  21184. uiA64 = aSPtr->signExp;
  21185. uiA0 = aSPtr->signif;
  21186. signA = signExtF80UI64( uiA64 );
  21187. uiB64 = bSPtr->signExp;
  21188. uiB0 = bSPtr->signif;
  21189. signB = signExtF80UI64( uiB64 );
  21190. #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
  21191. if ( signA == signB ) {
  21192. *zPtr = softfloat_subMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
  21193. } else {
  21194. *zPtr = softfloat_addMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
  21195. }
  21196. #else
  21197. magsFuncPtr =
  21198. (signA == signB) ? softfloat_subMagsExtF80 : softfloat_addMagsExtF80;
  21199. *zPtr = (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
  21200. #endif
  21201. }
  21202. #else
  21203. void
  21204. extF80M_sub(
  21205. const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
  21206. {
  21207. softfloat_addExtF80M(
  21208. (const struct extFloat80M *) aPtr,
  21209. (const struct extFloat80M *) bPtr,
  21210. (struct extFloat80M *) zPtr,
  21211. true
  21212. );
  21213. }
  21214. #endif
  21215. /**** ended inlining ../../source/extF80M_sub.c ****/
  21216. /**** start inlining ../../source/extF80M_mul.c ****/
  21217. /*============================================================================
  21218. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  21219. Package, Release 3e, by John R. Hauser.
  21220. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  21221. All rights reserved.
  21222. Redistribution and use in source and binary forms, with or without
  21223. modification, are permitted provided that the following conditions are met:
  21224. 1. Redistributions of source code must retain the above copyright notice,
  21225. this list of conditions, and the following disclaimer.
  21226. 2. Redistributions in binary form must reproduce the above copyright notice,
  21227. this list of conditions, and the following disclaimer in the documentation
  21228. and/or other materials provided with the distribution.
  21229. 3. Neither the name of the University nor the names of its contributors may
  21230. be used to endorse or promote products derived from this software without
  21231. specific prior written permission.
  21232. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  21233. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21234. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  21235. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  21236. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21237. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  21238. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  21239. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  21240. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  21241. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  21242. =============================================================================*/
  21243. #include <stdbool.h>
  21244. #include <stdint.h>
  21245. /**** skipping file: platform.h ****/
  21246. /**** skipping file: internals.h ****/
  21247. /**** skipping file: specialize.h ****/
  21248. /**** skipping file: softfloat.h ****/
  21249. #ifdef SOFTFLOAT_FAST_INT64
  21250. void
  21251. extF80M_mul(
  21252. const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
  21253. {
  21254. *zPtr = extF80_mul( *aPtr, *bPtr );
  21255. }
  21256. #else
  21257. void
  21258. extF80M_mul(
  21259. const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
  21260. {
  21261. const struct extFloat80M *aSPtr, *bSPtr;
  21262. struct extFloat80M *zSPtr;
  21263. uint_fast16_t uiA64;
  21264. int32_t expA;
  21265. uint_fast16_t uiB64;
  21266. int32_t expB;
  21267. bool signZ;
  21268. uint_fast16_t exp, uiZ64;
  21269. uint64_t uiZ0, sigA, sigB;
  21270. int32_t expZ;
  21271. uint32_t sigProd[4], *extSigZPtr;
  21272. /*------------------------------------------------------------------------
  21273. *------------------------------------------------------------------------*/
  21274. aSPtr = (const struct extFloat80M *) aPtr;
  21275. bSPtr = (const struct extFloat80M *) bPtr;
  21276. zSPtr = (struct extFloat80M *) zPtr;
  21277. /*------------------------------------------------------------------------
  21278. *------------------------------------------------------------------------*/
  21279. uiA64 = aSPtr->signExp;
  21280. expA = expExtF80UI64( uiA64 );
  21281. uiB64 = bSPtr->signExp;
  21282. expB = expExtF80UI64( uiB64 );
  21283. signZ = signExtF80UI64( uiA64 ) ^ signExtF80UI64( uiB64 );
  21284. /*------------------------------------------------------------------------
  21285. *------------------------------------------------------------------------*/
  21286. if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
  21287. if ( softfloat_tryPropagateNaNExtF80M( aSPtr, bSPtr, zSPtr ) ) return;
  21288. if (
  21289. (! aSPtr->signif && (expA != 0x7FFF))
  21290. || (! bSPtr->signif && (expB != 0x7FFF))
  21291. ) {
  21292. softfloat_invalidExtF80M( zSPtr );
  21293. return;
  21294. }
  21295. uiZ64 = packToExtF80UI64( signZ, 0x7FFF );
  21296. uiZ0 = UINT64_C( 0x8000000000000000 );
  21297. goto uiZ;
  21298. }
  21299. /*------------------------------------------------------------------------
  21300. *------------------------------------------------------------------------*/
  21301. if ( ! expA ) expA = 1;
  21302. sigA = aSPtr->signif;
  21303. if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
  21304. if ( ! sigA ) goto zero;
  21305. expA += softfloat_normExtF80SigM( &sigA );
  21306. }
  21307. if ( ! expB ) expB = 1;
  21308. sigB = bSPtr->signif;
  21309. if ( ! (sigB & UINT64_C( 0x8000000000000000 )) ) {
  21310. if ( ! sigB ) goto zero;
  21311. expB += softfloat_normExtF80SigM( &sigB );
  21312. }
  21313. /*------------------------------------------------------------------------
  21314. *------------------------------------------------------------------------*/
  21315. expZ = expA + expB - 0x3FFE;
  21316. softfloat_mul64To128M( sigA, sigB, sigProd );
  21317. if ( sigProd[indexWordLo( 4 )] ) sigProd[indexWord( 4, 1 )] |= 1;
  21318. extSigZPtr = &sigProd[indexMultiwordHi( 4, 3 )];
  21319. if ( sigProd[indexWordHi( 4 )] < 0x80000000 ) {
  21320. --expZ;
  21321. softfloat_add96M( extSigZPtr, extSigZPtr, extSigZPtr );
  21322. }
  21323. softfloat_roundPackMToExtF80M(
  21324. signZ, expZ, extSigZPtr, extF80_roundingPrecision, zSPtr );
  21325. return;
  21326. /*------------------------------------------------------------------------
  21327. *------------------------------------------------------------------------*/
  21328. zero:
  21329. uiZ64 = packToExtF80UI64( signZ, 0 );
  21330. uiZ0 = 0;
  21331. uiZ:
  21332. zSPtr->signExp = uiZ64;
  21333. zSPtr->signif = uiZ0;
  21334. }
  21335. #endif
  21336. /**** ended inlining ../../source/extF80M_mul.c ****/
  21337. /**** start inlining ../../source/extF80M_div.c ****/
  21338. /*============================================================================
  21339. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  21340. Package, Release 3e, by John R. Hauser.
  21341. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  21342. California. All rights reserved.
  21343. Redistribution and use in source and binary forms, with or without
  21344. modification, are permitted provided that the following conditions are met:
  21345. 1. Redistributions of source code must retain the above copyright notice,
  21346. this list of conditions, and the following disclaimer.
  21347. 2. Redistributions in binary form must reproduce the above copyright notice,
  21348. this list of conditions, and the following disclaimer in the documentation
  21349. and/or other materials provided with the distribution.
  21350. 3. Neither the name of the University nor the names of its contributors may
  21351. be used to endorse or promote products derived from this software without
  21352. specific prior written permission.
  21353. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  21354. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21355. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  21356. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  21357. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21358. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  21359. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  21360. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  21361. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  21362. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  21363. =============================================================================*/
  21364. #include <stdbool.h>
  21365. #include <stdint.h>
  21366. /**** skipping file: platform.h ****/
  21367. /**** skipping file: internals.h ****/
  21368. /**** skipping file: specialize.h ****/
  21369. /**** skipping file: softfloat.h ****/
  21370. #ifdef SOFTFLOAT_FAST_INT64
  21371. void
  21372. extF80M_div(
  21373. const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
  21374. {
  21375. *zPtr = extF80_div( *aPtr, *bPtr );
  21376. }
  21377. #else
  21378. void
  21379. extF80M_div(
  21380. const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
  21381. {
  21382. const struct extFloat80M *aSPtr, *bSPtr;
  21383. struct extFloat80M *zSPtr;
  21384. uint_fast16_t uiA64;
  21385. int32_t expA;
  21386. uint_fast16_t uiB64;
  21387. int32_t expB;
  21388. bool signZ;
  21389. uint64_t sigA, x64;
  21390. int32_t expZ;
  21391. int shiftDist;
  21392. uint32_t y[3], recip32, sigB[3];
  21393. int ix;
  21394. uint32_t q, qs[2];
  21395. uint_fast16_t uiZ64;
  21396. uint64_t uiZ0;
  21397. /*------------------------------------------------------------------------
  21398. *------------------------------------------------------------------------*/
  21399. aSPtr = (const struct extFloat80M *) aPtr;
  21400. bSPtr = (const struct extFloat80M *) bPtr;
  21401. zSPtr = (struct extFloat80M *) zPtr;
  21402. /*------------------------------------------------------------------------
  21403. *------------------------------------------------------------------------*/
  21404. uiA64 = aSPtr->signExp;
  21405. expA = expExtF80UI64( uiA64 );
  21406. uiB64 = bSPtr->signExp;
  21407. expB = expExtF80UI64( uiB64 );
  21408. signZ = signExtF80UI64( uiA64 ) ^ signExtF80UI64( uiB64 );
  21409. /*------------------------------------------------------------------------
  21410. *------------------------------------------------------------------------*/
  21411. if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
  21412. if ( softfloat_tryPropagateNaNExtF80M( aSPtr, bSPtr, zSPtr ) ) return;
  21413. if ( expA == 0x7FFF ) {
  21414. if ( expB == 0x7FFF ) goto invalid;
  21415. goto infinity;
  21416. }
  21417. goto zero;
  21418. }
  21419. /*------------------------------------------------------------------------
  21420. *------------------------------------------------------------------------*/
  21421. sigA = aSPtr->signif;
  21422. x64 = bSPtr->signif;
  21423. if ( ! expB ) expB = 1;
  21424. if ( ! (x64 & UINT64_C( 0x8000000000000000 )) ) {
  21425. if ( ! x64 ) {
  21426. if ( ! sigA ) goto invalid;
  21427. softfloat_raiseFlags( softfloat_flag_infinite );
  21428. goto infinity;
  21429. }
  21430. expB += softfloat_normExtF80SigM( &x64 );
  21431. }
  21432. if ( ! expA ) expA = 1;
  21433. if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
  21434. if ( ! sigA ) goto zero;
  21435. expA += softfloat_normExtF80SigM( &sigA );
  21436. }
  21437. /*------------------------------------------------------------------------
  21438. *------------------------------------------------------------------------*/
  21439. expZ = expA - expB + 0x3FFF;
  21440. shiftDist = 29;
  21441. if ( sigA < x64 ) {
  21442. --expZ;
  21443. shiftDist = 30;
  21444. }
  21445. softfloat_shortShiftLeft64To96M( sigA, shiftDist, y );
  21446. recip32 = softfloat_approxRecip32_1( x64>>32 );
  21447. sigB[indexWord( 3, 0 )] = (uint32_t) x64<<30;
  21448. x64 >>= 2;
  21449. sigB[indexWord( 3, 2 )] = x64>>32;
  21450. sigB[indexWord( 3, 1 )] = x64;
  21451. ix = 2;
  21452. for (;;) {
  21453. x64 = (uint64_t) y[indexWordHi( 3 )] * recip32;
  21454. q = (x64 + 0x80000000)>>32;
  21455. --ix;
  21456. if ( ix < 0 ) break;
  21457. softfloat_remStep96MBy32( y, 29, sigB, q, y );
  21458. if ( y[indexWordHi( 3 )] & 0x80000000 ) {
  21459. --q;
  21460. softfloat_add96M( y, sigB, y );
  21461. }
  21462. qs[ix] = q;
  21463. }
  21464. /*------------------------------------------------------------------------
  21465. *------------------------------------------------------------------------*/
  21466. if ( ((q + 1) & 0x3FFFFF) < 2 ) {
  21467. softfloat_remStep96MBy32( y, 29, sigB, q, y );
  21468. if ( y[indexWordHi( 3 )] & 0x80000000 ) {
  21469. --q;
  21470. softfloat_add96M( y, sigB, y );
  21471. } else if ( softfloat_compare96M( sigB, y ) <= 0 ) {
  21472. ++q;
  21473. softfloat_sub96M( y, sigB, y );
  21474. }
  21475. if (
  21476. y[indexWordLo( 3 )] || y[indexWord( 3, 1 )] || y[indexWord( 3, 2 )]
  21477. ) {
  21478. q |= 1;
  21479. }
  21480. }
  21481. /*------------------------------------------------------------------------
  21482. *------------------------------------------------------------------------*/
  21483. x64 = (uint64_t) q<<9;
  21484. y[indexWord( 3, 0 )] = x64;
  21485. x64 = ((uint64_t) qs[0]<<6) + (x64>>32);
  21486. y[indexWord( 3, 1 )] = x64;
  21487. y[indexWord( 3, 2 )] = (qs[1]<<3) + (x64>>32);
  21488. softfloat_roundPackMToExtF80M(
  21489. signZ, expZ, y, extF80_roundingPrecision, zSPtr );
  21490. return;
  21491. /*------------------------------------------------------------------------
  21492. *------------------------------------------------------------------------*/
  21493. invalid:
  21494. softfloat_invalidExtF80M( zSPtr );
  21495. return;
  21496. /*------------------------------------------------------------------------
  21497. *------------------------------------------------------------------------*/
  21498. infinity:
  21499. uiZ64 = packToExtF80UI64( signZ, 0x7FFF );
  21500. uiZ0 = UINT64_C( 0x8000000000000000 );
  21501. goto uiZ;
  21502. /*------------------------------------------------------------------------
  21503. *------------------------------------------------------------------------*/
  21504. zero:
  21505. uiZ64 = packToExtF80UI64( signZ, 0 );
  21506. uiZ0 = 0;
  21507. uiZ:
  21508. zSPtr->signExp = uiZ64;
  21509. zSPtr->signif = uiZ0;
  21510. }
  21511. #endif
  21512. /**** ended inlining ../../source/extF80M_div.c ****/
  21513. /**** start inlining ../../source/extF80M_rem.c ****/
  21514. /*============================================================================
  21515. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  21516. Package, Release 3e, by John R. Hauser.
  21517. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  21518. All rights reserved.
  21519. Redistribution and use in source and binary forms, with or without
  21520. modification, are permitted provided that the following conditions are met:
  21521. 1. Redistributions of source code must retain the above copyright notice,
  21522. this list of conditions, and the following disclaimer.
  21523. 2. Redistributions in binary form must reproduce the above copyright notice,
  21524. this list of conditions, and the following disclaimer in the documentation
  21525. and/or other materials provided with the distribution.
  21526. 3. Neither the name of the University nor the names of its contributors may
  21527. be used to endorse or promote products derived from this software without
  21528. specific prior written permission.
  21529. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  21530. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21531. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  21532. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  21533. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21534. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  21535. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  21536. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  21537. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  21538. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  21539. =============================================================================*/
  21540. #include <stdbool.h>
  21541. #include <stdint.h>
  21542. /**** skipping file: platform.h ****/
  21543. /**** skipping file: internals.h ****/
  21544. /**** skipping file: specialize.h ****/
  21545. /**** skipping file: softfloat.h ****/
  21546. #ifdef SOFTFLOAT_FAST_INT64
  21547. void
  21548. extF80M_rem(
  21549. const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
  21550. {
  21551. *zPtr = extF80_rem( *aPtr, *bPtr );
  21552. }
  21553. #else
  21554. void
  21555. extF80M_rem(
  21556. const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
  21557. {
  21558. const struct extFloat80M *aSPtr, *bSPtr;
  21559. struct extFloat80M *zSPtr;
  21560. uint_fast16_t uiA64;
  21561. int32_t expA, expB;
  21562. uint64_t x64;
  21563. bool signRem;
  21564. uint64_t sigA;
  21565. int32_t expDiff;
  21566. uint32_t rem[3], x[3], sig32B, q, recip32, rem2[3], *remPtr, *altRemPtr;
  21567. uint32_t *newRemPtr, wordMeanRem;
  21568. /*------------------------------------------------------------------------
  21569. *------------------------------------------------------------------------*/
  21570. aSPtr = (const struct extFloat80M *) aPtr;
  21571. bSPtr = (const struct extFloat80M *) bPtr;
  21572. zSPtr = (struct extFloat80M *) zPtr;
  21573. /*------------------------------------------------------------------------
  21574. *------------------------------------------------------------------------*/
  21575. uiA64 = aSPtr->signExp;
  21576. expA = expExtF80UI64( uiA64 );
  21577. expB = expExtF80UI64( bSPtr->signExp );
  21578. /*------------------------------------------------------------------------
  21579. *------------------------------------------------------------------------*/
  21580. if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
  21581. if ( softfloat_tryPropagateNaNExtF80M( aSPtr, bSPtr, zSPtr ) ) return;
  21582. if ( expA == 0x7FFF ) goto invalid;
  21583. /*--------------------------------------------------------------------
  21584. | If we get here, then argument b is an infinity and `expB' is 0x7FFF;
  21585. | Doubling `expB' is an easy way to ensure that `expDiff' later is
  21586. | less than -1, which will result in returning a canonicalized version
  21587. | of argument a.
  21588. *--------------------------------------------------------------------*/
  21589. expB += expB;
  21590. }
  21591. /*------------------------------------------------------------------------
  21592. *------------------------------------------------------------------------*/
  21593. if ( ! expB ) expB = 1;
  21594. x64 = bSPtr->signif;
  21595. if ( ! (x64 & UINT64_C( 0x8000000000000000 )) ) {
  21596. if ( ! x64 ) goto invalid;
  21597. expB += softfloat_normExtF80SigM( &x64 );
  21598. }
  21599. signRem = signExtF80UI64( uiA64 );
  21600. if ( ! expA ) expA = 1;
  21601. sigA = aSPtr->signif;
  21602. if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
  21603. if ( ! sigA ) {
  21604. expA = 0;
  21605. goto copyA;
  21606. }
  21607. expA += softfloat_normExtF80SigM( &sigA );
  21608. }
  21609. /*------------------------------------------------------------------------
  21610. *------------------------------------------------------------------------*/
  21611. expDiff = expA - expB;
  21612. if ( expDiff < -1 ) goto copyA;
  21613. rem[indexWord( 3, 2 )] = sigA>>34;
  21614. rem[indexWord( 3, 1 )] = sigA>>2;
  21615. rem[indexWord( 3, 0 )] = (uint32_t) sigA<<30;
  21616. x[indexWord( 3, 0 )] = (uint32_t) x64<<30;
  21617. sig32B = x64>>32;
  21618. x64 >>= 2;
  21619. x[indexWord( 3, 2 )] = x64>>32;
  21620. x[indexWord( 3, 1 )] = x64;
  21621. if ( expDiff < 1 ) {
  21622. if ( expDiff ) {
  21623. --expB;
  21624. softfloat_add96M( x, x, x );
  21625. q = 0;
  21626. } else {
  21627. q = (softfloat_compare96M( x, rem ) <= 0);
  21628. if ( q ) softfloat_sub96M( rem, x, rem );
  21629. }
  21630. } else {
  21631. recip32 = softfloat_approxRecip32_1( sig32B );
  21632. expDiff -= 30;
  21633. for (;;) {
  21634. x64 = (uint64_t) rem[indexWordHi( 3 )] * recip32;
  21635. if ( expDiff < 0 ) break;
  21636. q = (x64 + 0x80000000)>>32;
  21637. softfloat_remStep96MBy32( rem, 29, x, q, rem );
  21638. if ( rem[indexWordHi( 3 )] & 0x80000000 ) {
  21639. softfloat_add96M( rem, x, rem );
  21640. }
  21641. expDiff -= 29;
  21642. }
  21643. /*--------------------------------------------------------------------
  21644. | (`expDiff' cannot be less than -29 here.)
  21645. *--------------------------------------------------------------------*/
  21646. q = (uint32_t) (x64>>32)>>(~expDiff & 31);
  21647. softfloat_remStep96MBy32( rem, expDiff + 30, x, q, rem );
  21648. if ( rem[indexWordHi( 3 )] & 0x80000000 ) {
  21649. remPtr = rem;
  21650. altRemPtr = rem2;
  21651. softfloat_add96M( remPtr, x, altRemPtr );
  21652. goto selectRem;
  21653. }
  21654. }
  21655. /*------------------------------------------------------------------------
  21656. *------------------------------------------------------------------------*/
  21657. remPtr = rem;
  21658. altRemPtr = rem2;
  21659. do {
  21660. ++q;
  21661. newRemPtr = altRemPtr;
  21662. softfloat_sub96M( remPtr, x, newRemPtr );
  21663. altRemPtr = remPtr;
  21664. remPtr = newRemPtr;
  21665. } while ( ! (remPtr[indexWordHi( 3 )] & 0x80000000) );
  21666. selectRem:
  21667. softfloat_add96M( remPtr, altRemPtr, x );
  21668. wordMeanRem = x[indexWordHi( 3 )];
  21669. if (
  21670. (wordMeanRem & 0x80000000)
  21671. || (! wordMeanRem && (q & 1) && ! x[indexWord( 3, 0 )]
  21672. && ! x[indexWord( 3, 1 )])
  21673. ) {
  21674. remPtr = altRemPtr;
  21675. }
  21676. if ( remPtr[indexWordHi( 3 )] & 0x80000000 ) {
  21677. signRem = ! signRem;
  21678. softfloat_negX96M( remPtr );
  21679. }
  21680. softfloat_normRoundPackMToExtF80M( signRem, expB + 2, remPtr, 80, zSPtr );
  21681. return;
  21682. /*------------------------------------------------------------------------
  21683. *------------------------------------------------------------------------*/
  21684. invalid:
  21685. softfloat_invalidExtF80M( zSPtr );
  21686. return;
  21687. /*------------------------------------------------------------------------
  21688. *------------------------------------------------------------------------*/
  21689. copyA:
  21690. if ( expA < 1 ) {
  21691. sigA >>= 1 - expA;
  21692. expA = 0;
  21693. }
  21694. zSPtr->signExp = packToExtF80UI64( signRem, expA );
  21695. zSPtr->signif = sigA;
  21696. }
  21697. #endif
  21698. /**** ended inlining ../../source/extF80M_rem.c ****/
  21699. /**** start inlining ../../source/extF80M_sqrt.c ****/
  21700. /*============================================================================
  21701. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  21702. Package, Release 3e, by John R. Hauser.
  21703. Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
  21704. California. All rights reserved.
  21705. Redistribution and use in source and binary forms, with or without
  21706. modification, are permitted provided that the following conditions are met:
  21707. 1. Redistributions of source code must retain the above copyright notice,
  21708. this list of conditions, and the following disclaimer.
  21709. 2. Redistributions in binary form must reproduce the above copyright notice,
  21710. this list of conditions, and the following disclaimer in the documentation
  21711. and/or other materials provided with the distribution.
  21712. 3. Neither the name of the University nor the names of its contributors may
  21713. be used to endorse or promote products derived from this software without
  21714. specific prior written permission.
  21715. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  21716. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21717. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  21718. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  21719. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21720. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  21721. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  21722. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  21723. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  21724. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  21725. =============================================================================*/
  21726. #include <stdbool.h>
  21727. #include <stdint.h>
  21728. /**** skipping file: platform.h ****/
  21729. /**** skipping file: internals.h ****/
  21730. /**** skipping file: specialize.h ****/
  21731. /**** skipping file: softfloat.h ****/
  21732. #ifdef SOFTFLOAT_FAST_INT64
  21733. void extF80M_sqrt( const extFloat80_t *aPtr, extFloat80_t *zPtr )
  21734. {
  21735. *zPtr = extF80_sqrt( *aPtr );
  21736. }
  21737. #else
  21738. void extF80M_sqrt( const extFloat80_t *aPtr, extFloat80_t *zPtr )
  21739. {
  21740. const struct extFloat80M *aSPtr;
  21741. struct extFloat80M *zSPtr;
  21742. uint_fast16_t uiA64, signUI64;
  21743. int32_t expA;
  21744. uint64_t rem64;
  21745. int32_t expZ;
  21746. uint32_t rem96[3], sig32A, recipSqrt32, sig32Z, q;
  21747. uint64_t sig64Z, x64;
  21748. uint32_t rem32, term[4], rem[4], extSigZ[3];
  21749. /*------------------------------------------------------------------------
  21750. *------------------------------------------------------------------------*/
  21751. aSPtr = (const struct extFloat80M *) aPtr;
  21752. zSPtr = (struct extFloat80M *) zPtr;
  21753. /*------------------------------------------------------------------------
  21754. *------------------------------------------------------------------------*/
  21755. uiA64 = aSPtr->signExp;
  21756. signUI64 = uiA64 & packToExtF80UI64( 1, 0 );
  21757. expA = expExtF80UI64( uiA64 );
  21758. rem64 = aSPtr->signif;
  21759. /*------------------------------------------------------------------------
  21760. *------------------------------------------------------------------------*/
  21761. if ( expA == 0x7FFF ) {
  21762. if ( rem64 & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
  21763. softfloat_propagateNaNExtF80M( aSPtr, 0, zSPtr );
  21764. return;
  21765. }
  21766. if ( signUI64 ) goto invalid;
  21767. rem64 = UINT64_C( 0x8000000000000000 );
  21768. goto copyA;
  21769. }
  21770. /*------------------------------------------------------------------------
  21771. *------------------------------------------------------------------------*/
  21772. if ( ! expA ) expA = 1;
  21773. if ( ! (rem64 & UINT64_C( 0x8000000000000000 )) ) {
  21774. if ( ! rem64 ) {
  21775. uiA64 = signUI64;
  21776. goto copyA;
  21777. }
  21778. expA += softfloat_normExtF80SigM( &rem64 );
  21779. }
  21780. if ( signUI64 ) goto invalid;
  21781. /*------------------------------------------------------------------------
  21782. *------------------------------------------------------------------------*/
  21783. expZ = ((expA - 0x3FFF)>>1) + 0x3FFF;
  21784. expA &= 1;
  21785. softfloat_shortShiftLeft64To96M( rem64, 30 - expA, rem96 );
  21786. sig32A = rem64>>32;
  21787. recipSqrt32 = softfloat_approxRecipSqrt32_1( expA, sig32A );
  21788. sig32Z = ((uint64_t) sig32A * recipSqrt32)>>32;
  21789. if ( expA ) sig32Z >>= 1;
  21790. rem64 =
  21791. ((uint64_t) rem96[indexWord( 3, 2 )]<<32 | rem96[indexWord( 3, 1 )])
  21792. - (uint64_t) sig32Z * sig32Z;
  21793. rem96[indexWord( 3, 2 )] = rem64>>32;
  21794. rem96[indexWord( 3, 1 )] = rem64;
  21795. /*------------------------------------------------------------------------
  21796. *------------------------------------------------------------------------*/
  21797. q = ((uint32_t) (rem64>>2) * (uint64_t) recipSqrt32)>>32;
  21798. sig64Z = ((uint64_t) sig32Z<<32) + ((uint64_t) q<<3);
  21799. term[indexWord( 3, 2 )] = 0;
  21800. /*------------------------------------------------------------------------
  21801. | (Repeating this loop is a rare occurrence.)
  21802. *------------------------------------------------------------------------*/
  21803. for (;;) {
  21804. x64 = ((uint64_t) sig32Z<<32) + sig64Z;
  21805. term[indexWord( 3, 1 )] = x64>>32;
  21806. term[indexWord( 3, 0 )] = x64;
  21807. softfloat_remStep96MBy32(
  21808. rem96, 29, term, q, &rem[indexMultiwordHi( 4, 3 )] );
  21809. rem32 = rem[indexWord( 4, 3 )];
  21810. if ( ! (rem32 & 0x80000000) ) break;
  21811. --q;
  21812. sig64Z -= 1<<3;
  21813. }
  21814. rem64 = (uint64_t) rem32<<32 | rem[indexWord( 4, 2 )];
  21815. /*------------------------------------------------------------------------
  21816. *------------------------------------------------------------------------*/
  21817. q = (((uint32_t) (rem64>>2) * (uint64_t) recipSqrt32)>>32) + 2;
  21818. if ( rem64>>34 ) q += recipSqrt32;
  21819. x64 = (uint64_t) q<<7;
  21820. extSigZ[indexWord( 3, 0 )] = x64;
  21821. x64 = (sig64Z<<1) + (x64>>32);
  21822. extSigZ[indexWord( 3, 2 )] = x64>>32;
  21823. extSigZ[indexWord( 3, 1 )] = x64;
  21824. /*------------------------------------------------------------------------
  21825. *------------------------------------------------------------------------*/
  21826. if ( (q & 0xFFFFFF) <= 2 ) {
  21827. q &= ~(uint32_t) 0xFFFF;
  21828. extSigZ[indexWordLo( 3 )] = q<<7;
  21829. x64 = sig64Z + (q>>27);
  21830. term[indexWord( 4, 3 )] = 0;
  21831. term[indexWord( 4, 2 )] = x64>>32;
  21832. term[indexWord( 4, 1 )] = x64;
  21833. term[indexWord( 4, 0 )] = q<<5;
  21834. rem[indexWord( 4, 0 )] = 0;
  21835. softfloat_remStep128MBy32( rem, 28, term, q, rem );
  21836. q = rem[indexWordHi( 4 )];
  21837. if ( q & 0x80000000 ) {
  21838. softfloat_sub1X96M( extSigZ );
  21839. } else {
  21840. if ( q || rem[indexWord( 4, 1 )] || rem[indexWord( 4, 2 )] ) {
  21841. extSigZ[indexWordLo( 3 )] |= 1;
  21842. }
  21843. }
  21844. }
  21845. softfloat_roundPackMToExtF80M(
  21846. 0, expZ, extSigZ, extF80_roundingPrecision, zSPtr );
  21847. return;
  21848. /*------------------------------------------------------------------------
  21849. *------------------------------------------------------------------------*/
  21850. invalid:
  21851. softfloat_invalidExtF80M( zSPtr );
  21852. return;
  21853. /*------------------------------------------------------------------------
  21854. *------------------------------------------------------------------------*/
  21855. copyA:
  21856. zSPtr->signExp = uiA64;
  21857. zSPtr->signif = rem64;
  21858. }
  21859. #endif
  21860. /**** ended inlining ../../source/extF80M_sqrt.c ****/
  21861. /**** start inlining ../../source/extF80M_eq.c ****/
  21862. /*============================================================================
  21863. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  21864. Package, Release 3e, by John R. Hauser.
  21865. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  21866. All rights reserved.
  21867. Redistribution and use in source and binary forms, with or without
  21868. modification, are permitted provided that the following conditions are met:
  21869. 1. Redistributions of source code must retain the above copyright notice,
  21870. this list of conditions, and the following disclaimer.
  21871. 2. Redistributions in binary form must reproduce the above copyright notice,
  21872. this list of conditions, and the following disclaimer in the documentation
  21873. and/or other materials provided with the distribution.
  21874. 3. Neither the name of the University nor the names of its contributors may
  21875. be used to endorse or promote products derived from this software without
  21876. specific prior written permission.
  21877. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  21878. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21879. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  21880. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  21881. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21882. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  21883. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  21884. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  21885. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  21886. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  21887. =============================================================================*/
  21888. #include <stdbool.h>
  21889. #include <stdint.h>
  21890. /**** skipping file: platform.h ****/
  21891. /**** skipping file: internals.h ****/
  21892. /**** skipping file: specialize.h ****/
  21893. /**** skipping file: softfloat.h ****/
  21894. #ifdef SOFTFLOAT_FAST_INT64
  21895. bool extF80M_eq( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
  21896. {
  21897. return extF80_eq( *aPtr, *bPtr );
  21898. }
  21899. #else
  21900. bool extF80M_eq( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
  21901. {
  21902. const struct extFloat80M *aSPtr, *bSPtr;
  21903. uint_fast16_t uiA64;
  21904. uint64_t uiA0;
  21905. uint_fast16_t uiB64;
  21906. uint64_t uiB0;
  21907. /*------------------------------------------------------------------------
  21908. *------------------------------------------------------------------------*/
  21909. aSPtr = (const struct extFloat80M *) aPtr;
  21910. bSPtr = (const struct extFloat80M *) bPtr;
  21911. /*------------------------------------------------------------------------
  21912. *------------------------------------------------------------------------*/
  21913. uiA64 = aSPtr->signExp;
  21914. uiA0 = aSPtr->signif;
  21915. uiB64 = bSPtr->signExp;
  21916. uiB0 = bSPtr->signif;
  21917. /*------------------------------------------------------------------------
  21918. *------------------------------------------------------------------------*/
  21919. if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
  21920. if (
  21921. softfloat_isSigNaNExtF80UI( uiA64, uiA0 )
  21922. || softfloat_isSigNaNExtF80UI( uiB64, uiB0 )
  21923. ) {
  21924. softfloat_raiseFlags( softfloat_flag_invalid );
  21925. }
  21926. return false;
  21927. }
  21928. /*------------------------------------------------------------------------
  21929. *------------------------------------------------------------------------*/
  21930. if ( uiA0 == uiB0 ) {
  21931. return (uiA64 == uiB64) || ! uiA0;
  21932. } else {
  21933. if ( ! ((uiA0 & uiB0) & UINT64_C( 0x8000000000000000 )) ) {
  21934. return ! softfloat_compareNonnormExtF80M( aSPtr, bSPtr );
  21935. }
  21936. return false;
  21937. }
  21938. }
  21939. #endif
  21940. /**** ended inlining ../../source/extF80M_eq.c ****/
  21941. /**** start inlining ../../source/extF80M_le.c ****/
  21942. /*============================================================================
  21943. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  21944. Package, Release 3e, by John R. Hauser.
  21945. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  21946. All rights reserved.
  21947. Redistribution and use in source and binary forms, with or without
  21948. modification, are permitted provided that the following conditions are met:
  21949. 1. Redistributions of source code must retain the above copyright notice,
  21950. this list of conditions, and the following disclaimer.
  21951. 2. Redistributions in binary form must reproduce the above copyright notice,
  21952. this list of conditions, and the following disclaimer in the documentation
  21953. and/or other materials provided with the distribution.
  21954. 3. Neither the name of the University nor the names of its contributors may
  21955. be used to endorse or promote products derived from this software without
  21956. specific prior written permission.
  21957. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  21958. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21959. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  21960. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  21961. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21962. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  21963. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  21964. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  21965. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  21966. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  21967. =============================================================================*/
  21968. #include <stdbool.h>
  21969. #include <stdint.h>
  21970. /**** skipping file: platform.h ****/
  21971. /**** skipping file: internals.h ****/
  21972. /**** skipping file: softfloat.h ****/
  21973. #ifdef SOFTFLOAT_FAST_INT64
  21974. bool extF80M_le( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
  21975. {
  21976. return extF80_le( *aPtr, *bPtr );
  21977. }
  21978. #else
  21979. bool extF80M_le( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
  21980. {
  21981. const struct extFloat80M *aSPtr, *bSPtr;
  21982. uint_fast16_t uiA64;
  21983. uint64_t uiA0;
  21984. uint_fast16_t uiB64;
  21985. uint64_t uiB0;
  21986. bool signA, ltMags;
  21987. /*------------------------------------------------------------------------
  21988. *------------------------------------------------------------------------*/
  21989. aSPtr = (const struct extFloat80M *) aPtr;
  21990. bSPtr = (const struct extFloat80M *) bPtr;
  21991. /*------------------------------------------------------------------------
  21992. *------------------------------------------------------------------------*/
  21993. uiA64 = aSPtr->signExp;
  21994. uiA0 = aSPtr->signif;
  21995. uiB64 = bSPtr->signExp;
  21996. uiB0 = bSPtr->signif;
  21997. /*------------------------------------------------------------------------
  21998. *------------------------------------------------------------------------*/
  21999. if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
  22000. softfloat_raiseFlags( softfloat_flag_invalid );
  22001. return false;
  22002. }
  22003. /*------------------------------------------------------------------------
  22004. *------------------------------------------------------------------------*/
  22005. signA = signExtF80UI64( uiA64 );
  22006. if ( (uiA64 ^ uiB64) & 0x8000 ) {
  22007. /*--------------------------------------------------------------------
  22008. | Signs are different.
  22009. *--------------------------------------------------------------------*/
  22010. return signA || ! (uiA0 | uiB0);
  22011. } else {
  22012. /*--------------------------------------------------------------------
  22013. | Signs are the same.
  22014. *--------------------------------------------------------------------*/
  22015. if ( ! ((uiA0 & uiB0) & UINT64_C( 0x8000000000000000 )) ) {
  22016. return (softfloat_compareNonnormExtF80M( aSPtr, bSPtr ) <= 0);
  22017. }
  22018. if ( uiA64 == uiB64 ) {
  22019. if ( uiA0 == uiB0 ) return true;
  22020. ltMags = (uiA0 < uiB0);
  22021. } else {
  22022. ltMags = (uiA64 < uiB64);
  22023. }
  22024. return signA ^ ltMags;
  22025. }
  22026. }
  22027. #endif
  22028. /**** ended inlining ../../source/extF80M_le.c ****/
  22029. /**** start inlining ../../source/extF80M_lt.c ****/
  22030. /*============================================================================
  22031. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  22032. Package, Release 3e, by John R. Hauser.
  22033. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  22034. All rights reserved.
  22035. Redistribution and use in source and binary forms, with or without
  22036. modification, are permitted provided that the following conditions are met:
  22037. 1. Redistributions of source code must retain the above copyright notice,
  22038. this list of conditions, and the following disclaimer.
  22039. 2. Redistributions in binary form must reproduce the above copyright notice,
  22040. this list of conditions, and the following disclaimer in the documentation
  22041. and/or other materials provided with the distribution.
  22042. 3. Neither the name of the University nor the names of its contributors may
  22043. be used to endorse or promote products derived from this software without
  22044. specific prior written permission.
  22045. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  22046. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  22047. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  22048. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  22049. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22050. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22051. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  22052. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22053. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  22054. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22055. =============================================================================*/
  22056. #include <stdbool.h>
  22057. #include <stdint.h>
  22058. /**** skipping file: platform.h ****/
  22059. /**** skipping file: internals.h ****/
  22060. /**** skipping file: softfloat.h ****/
  22061. #ifdef SOFTFLOAT_FAST_INT64
  22062. bool extF80M_lt( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
  22063. {
  22064. return extF80_lt( *aPtr, *bPtr );
  22065. }
  22066. #else
  22067. bool extF80M_lt( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
  22068. {
  22069. const struct extFloat80M *aSPtr, *bSPtr;
  22070. uint_fast16_t uiA64;
  22071. uint64_t uiA0;
  22072. uint_fast16_t uiB64;
  22073. uint64_t uiB0;
  22074. bool signA, ltMags;
  22075. /*------------------------------------------------------------------------
  22076. *------------------------------------------------------------------------*/
  22077. aSPtr = (const struct extFloat80M *) aPtr;
  22078. bSPtr = (const struct extFloat80M *) bPtr;
  22079. /*------------------------------------------------------------------------
  22080. *------------------------------------------------------------------------*/
  22081. uiA64 = aSPtr->signExp;
  22082. uiA0 = aSPtr->signif;
  22083. uiB64 = bSPtr->signExp;
  22084. uiB0 = bSPtr->signif;
  22085. /*------------------------------------------------------------------------
  22086. *------------------------------------------------------------------------*/
  22087. if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
  22088. softfloat_raiseFlags( softfloat_flag_invalid );
  22089. return false;
  22090. }
  22091. /*------------------------------------------------------------------------
  22092. *------------------------------------------------------------------------*/
  22093. signA = signExtF80UI64( uiA64 );
  22094. if ( (uiA64 ^ uiB64) & 0x8000 ) {
  22095. /*--------------------------------------------------------------------
  22096. | Signs are different.
  22097. *--------------------------------------------------------------------*/
  22098. return signA && ((uiA0 | uiB0) != 0);
  22099. } else {
  22100. /*--------------------------------------------------------------------
  22101. | Signs are the same.
  22102. *--------------------------------------------------------------------*/
  22103. if ( ! ((uiA0 & uiB0) & UINT64_C( 0x8000000000000000 )) ) {
  22104. return (softfloat_compareNonnormExtF80M( aSPtr, bSPtr ) < 0);
  22105. }
  22106. if ( uiA64 == uiB64 ) {
  22107. if ( uiA0 == uiB0 ) return false;
  22108. ltMags = (uiA0 < uiB0);
  22109. } else {
  22110. ltMags = (uiA64 < uiB64);
  22111. }
  22112. return signA ^ ltMags;
  22113. }
  22114. }
  22115. #endif
  22116. /**** ended inlining ../../source/extF80M_lt.c ****/
  22117. /**** start inlining ../../source/extF80M_eq_signaling.c ****/
  22118. /*============================================================================
  22119. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  22120. Package, Release 3e, by John R. Hauser.
  22121. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  22122. All rights reserved.
  22123. Redistribution and use in source and binary forms, with or without
  22124. modification, are permitted provided that the following conditions are met:
  22125. 1. Redistributions of source code must retain the above copyright notice,
  22126. this list of conditions, and the following disclaimer.
  22127. 2. Redistributions in binary form must reproduce the above copyright notice,
  22128. this list of conditions, and the following disclaimer in the documentation
  22129. and/or other materials provided with the distribution.
  22130. 3. Neither the name of the University nor the names of its contributors may
  22131. be used to endorse or promote products derived from this software without
  22132. specific prior written permission.
  22133. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  22134. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  22135. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  22136. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  22137. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22138. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22139. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  22140. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22141. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  22142. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22143. =============================================================================*/
  22144. #include <stdbool.h>
  22145. #include <stdint.h>
  22146. /**** skipping file: platform.h ****/
  22147. /**** skipping file: internals.h ****/
  22148. /**** skipping file: softfloat.h ****/
  22149. #ifdef SOFTFLOAT_FAST_INT64
  22150. bool extF80M_eq_signaling( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
  22151. {
  22152. return extF80_eq_signaling( *aPtr, *bPtr );
  22153. }
  22154. #else
  22155. bool extF80M_eq_signaling( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
  22156. {
  22157. const struct extFloat80M *aSPtr, *bSPtr;
  22158. uint_fast16_t uiA64;
  22159. uint64_t uiA0;
  22160. uint_fast16_t uiB64;
  22161. uint64_t uiB0;
  22162. /*------------------------------------------------------------------------
  22163. *------------------------------------------------------------------------*/
  22164. aSPtr = (const struct extFloat80M *) aPtr;
  22165. bSPtr = (const struct extFloat80M *) bPtr;
  22166. /*------------------------------------------------------------------------
  22167. *------------------------------------------------------------------------*/
  22168. uiA64 = aSPtr->signExp;
  22169. uiA0 = aSPtr->signif;
  22170. uiB64 = bSPtr->signExp;
  22171. uiB0 = bSPtr->signif;
  22172. /*------------------------------------------------------------------------
  22173. *------------------------------------------------------------------------*/
  22174. if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
  22175. softfloat_raiseFlags( softfloat_flag_invalid );
  22176. return false;
  22177. }
  22178. /*------------------------------------------------------------------------
  22179. *------------------------------------------------------------------------*/
  22180. if ( uiA0 == uiB0 ) {
  22181. return (uiA64 == uiB64) || ! uiA0;
  22182. } else {
  22183. if ( ! ((uiA0 & uiB0) & UINT64_C( 0x8000000000000000 )) ) {
  22184. return ! softfloat_compareNonnormExtF80M( aSPtr, bSPtr );
  22185. }
  22186. return false;
  22187. }
  22188. }
  22189. #endif
  22190. /**** ended inlining ../../source/extF80M_eq_signaling.c ****/
  22191. /**** start inlining ../../source/extF80M_le_quiet.c ****/
  22192. /*============================================================================
  22193. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  22194. Package, Release 3e, by John R. Hauser.
  22195. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  22196. All rights reserved.
  22197. Redistribution and use in source and binary forms, with or without
  22198. modification, are permitted provided that the following conditions are met:
  22199. 1. Redistributions of source code must retain the above copyright notice,
  22200. this list of conditions, and the following disclaimer.
  22201. 2. Redistributions in binary form must reproduce the above copyright notice,
  22202. this list of conditions, and the following disclaimer in the documentation
  22203. and/or other materials provided with the distribution.
  22204. 3. Neither the name of the University nor the names of its contributors may
  22205. be used to endorse or promote products derived from this software without
  22206. specific prior written permission.
  22207. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  22208. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  22209. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  22210. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  22211. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22212. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22213. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  22214. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22215. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  22216. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22217. =============================================================================*/
  22218. #include <stdbool.h>
  22219. #include <stdint.h>
  22220. /**** skipping file: platform.h ****/
  22221. /**** skipping file: internals.h ****/
  22222. /**** skipping file: specialize.h ****/
  22223. /**** skipping file: softfloat.h ****/
  22224. #ifdef SOFTFLOAT_FAST_INT64
  22225. bool extF80M_le_quiet( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
  22226. {
  22227. return extF80_le_quiet( *aPtr, *bPtr );
  22228. }
  22229. #else
  22230. bool extF80M_le_quiet( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
  22231. {
  22232. const struct extFloat80M *aSPtr, *bSPtr;
  22233. uint_fast16_t uiA64;
  22234. uint64_t uiA0;
  22235. uint_fast16_t uiB64;
  22236. uint64_t uiB0;
  22237. bool signA, ltMags;
  22238. /*------------------------------------------------------------------------
  22239. *------------------------------------------------------------------------*/
  22240. aSPtr = (const struct extFloat80M *) aPtr;
  22241. bSPtr = (const struct extFloat80M *) bPtr;
  22242. /*------------------------------------------------------------------------
  22243. *------------------------------------------------------------------------*/
  22244. uiA64 = aSPtr->signExp;
  22245. uiA0 = aSPtr->signif;
  22246. uiB64 = bSPtr->signExp;
  22247. uiB0 = bSPtr->signif;
  22248. /*------------------------------------------------------------------------
  22249. *------------------------------------------------------------------------*/
  22250. if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
  22251. if (
  22252. softfloat_isSigNaNExtF80UI( uiA64, uiA0 )
  22253. || softfloat_isSigNaNExtF80UI( uiB64, uiB0 )
  22254. ) {
  22255. softfloat_raiseFlags( softfloat_flag_invalid );
  22256. }
  22257. return false;
  22258. }
  22259. /*------------------------------------------------------------------------
  22260. *------------------------------------------------------------------------*/
  22261. signA = signExtF80UI64( uiA64 );
  22262. if ( (uiA64 ^ uiB64) & 0x8000 ) {
  22263. /*--------------------------------------------------------------------
  22264. | Signs are different.
  22265. *--------------------------------------------------------------------*/
  22266. return signA || ! (uiA0 | uiB0);
  22267. } else {
  22268. /*--------------------------------------------------------------------
  22269. | Signs are the same.
  22270. *--------------------------------------------------------------------*/
  22271. if ( ! ((uiA0 & uiB0) & UINT64_C( 0x8000000000000000 )) ) {
  22272. return (softfloat_compareNonnormExtF80M( aSPtr, bSPtr ) <= 0);
  22273. }
  22274. if ( uiA64 == uiB64 ) {
  22275. if ( uiA0 == uiB0 ) return true;
  22276. ltMags = (uiA0 < uiB0);
  22277. } else {
  22278. ltMags = (uiA64 < uiB64);
  22279. }
  22280. return signA ^ ltMags;
  22281. }
  22282. }
  22283. #endif
  22284. /**** ended inlining ../../source/extF80M_le_quiet.c ****/
  22285. /**** start inlining ../../source/extF80M_lt_quiet.c ****/
  22286. /*============================================================================
  22287. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  22288. Package, Release 3e, by John R. Hauser.
  22289. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  22290. All rights reserved.
  22291. Redistribution and use in source and binary forms, with or without
  22292. modification, are permitted provided that the following conditions are met:
  22293. 1. Redistributions of source code must retain the above copyright notice,
  22294. this list of conditions, and the following disclaimer.
  22295. 2. Redistributions in binary form must reproduce the above copyright notice,
  22296. this list of conditions, and the following disclaimer in the documentation
  22297. and/or other materials provided with the distribution.
  22298. 3. Neither the name of the University nor the names of its contributors may
  22299. be used to endorse or promote products derived from this software without
  22300. specific prior written permission.
  22301. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  22302. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  22303. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  22304. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  22305. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22306. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22307. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  22308. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22309. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  22310. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22311. =============================================================================*/
  22312. #include <stdbool.h>
  22313. #include <stdint.h>
  22314. /**** skipping file: platform.h ****/
  22315. /**** skipping file: internals.h ****/
  22316. /**** skipping file: specialize.h ****/
  22317. /**** skipping file: softfloat.h ****/
  22318. #ifdef SOFTFLOAT_FAST_INT64
  22319. bool extF80M_lt_quiet( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
  22320. {
  22321. return extF80_lt_quiet( *aPtr, *bPtr );
  22322. }
  22323. #else
  22324. bool extF80M_lt_quiet( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
  22325. {
  22326. const struct extFloat80M *aSPtr, *bSPtr;
  22327. uint_fast16_t uiA64;
  22328. uint64_t uiA0;
  22329. uint_fast16_t uiB64;
  22330. uint64_t uiB0;
  22331. bool signA, ltMags;
  22332. /*------------------------------------------------------------------------
  22333. *------------------------------------------------------------------------*/
  22334. aSPtr = (const struct extFloat80M *) aPtr;
  22335. bSPtr = (const struct extFloat80M *) bPtr;
  22336. /*------------------------------------------------------------------------
  22337. *------------------------------------------------------------------------*/
  22338. uiA64 = aSPtr->signExp;
  22339. uiA0 = aSPtr->signif;
  22340. uiB64 = bSPtr->signExp;
  22341. uiB0 = bSPtr->signif;
  22342. /*------------------------------------------------------------------------
  22343. *------------------------------------------------------------------------*/
  22344. if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
  22345. if (
  22346. softfloat_isSigNaNExtF80UI( uiA64, uiA0 )
  22347. || softfloat_isSigNaNExtF80UI( uiB64, uiB0 )
  22348. ) {
  22349. softfloat_raiseFlags( softfloat_flag_invalid );
  22350. }
  22351. return false;
  22352. }
  22353. /*------------------------------------------------------------------------
  22354. *------------------------------------------------------------------------*/
  22355. signA = signExtF80UI64( uiA64 );
  22356. if ( (uiA64 ^ uiB64) & 0x8000 ) {
  22357. /*--------------------------------------------------------------------
  22358. | Signs are different.
  22359. *--------------------------------------------------------------------*/
  22360. return signA && ((uiA0 | uiB0) != 0);
  22361. } else {
  22362. /*--------------------------------------------------------------------
  22363. | Signs are the same.
  22364. *--------------------------------------------------------------------*/
  22365. if ( ! ((uiA0 & uiB0) & UINT64_C( 0x8000000000000000 )) ) {
  22366. return (softfloat_compareNonnormExtF80M( aSPtr, bSPtr ) < 0);
  22367. }
  22368. if ( uiA64 == uiB64 ) {
  22369. if ( uiA0 == uiB0 ) return false;
  22370. ltMags = (uiA0 < uiB0);
  22371. } else {
  22372. ltMags = (uiA64 < uiB64);
  22373. }
  22374. return signA ^ ltMags;
  22375. }
  22376. }
  22377. #endif
  22378. /**** ended inlining ../../source/extF80M_lt_quiet.c ****/
  22379. /**** start inlining ../../source/f128_to_ui32.c ****/
  22380. /*============================================================================
  22381. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  22382. Package, Release 3e, by John R. Hauser.
  22383. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  22384. University of California. All rights reserved.
  22385. Redistribution and use in source and binary forms, with or without
  22386. modification, are permitted provided that the following conditions are met:
  22387. 1. Redistributions of source code must retain the above copyright notice,
  22388. this list of conditions, and the following disclaimer.
  22389. 2. Redistributions in binary form must reproduce the above copyright notice,
  22390. this list of conditions, and the following disclaimer in the documentation
  22391. and/or other materials provided with the distribution.
  22392. 3. Neither the name of the University nor the names of its contributors may
  22393. be used to endorse or promote products derived from this software without
  22394. specific prior written permission.
  22395. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  22396. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  22397. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  22398. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  22399. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22400. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22401. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  22402. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22403. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  22404. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22405. =============================================================================*/
  22406. #include <stdbool.h>
  22407. #include <stdint.h>
  22408. /**** skipping file: platform.h ****/
  22409. /**** skipping file: internals.h ****/
  22410. /**** skipping file: specialize.h ****/
  22411. /**** skipping file: softfloat.h ****/
  22412. uint_fast32_t
  22413. f128_to_ui32( float128_t a, uint_fast8_t roundingMode, bool exact )
  22414. {
  22415. union ui128_f128 uA;
  22416. uint_fast64_t uiA64, uiA0;
  22417. bool sign;
  22418. int_fast32_t exp;
  22419. uint_fast64_t sig64;
  22420. int_fast32_t shiftDist;
  22421. /*------------------------------------------------------------------------
  22422. *------------------------------------------------------------------------*/
  22423. uA.f = a;
  22424. uiA64 = uA.ui.v64;
  22425. uiA0 = uA.ui.v0;
  22426. sign = signF128UI64( uiA64 );
  22427. exp = expF128UI64( uiA64 );
  22428. sig64 = fracF128UI64( uiA64 ) | (uiA0 != 0);
  22429. /*------------------------------------------------------------------------
  22430. *------------------------------------------------------------------------*/
  22431. #if (ui32_fromNaN != ui32_fromPosOverflow) || (ui32_fromNaN != ui32_fromNegOverflow)
  22432. if ( (exp == 0x7FFF) && sig64 ) {
  22433. #if (ui32_fromNaN == ui32_fromPosOverflow)
  22434. sign = 0;
  22435. #elif (ui32_fromNaN == ui32_fromNegOverflow)
  22436. sign = 1;
  22437. #else
  22438. softfloat_raiseFlags( softfloat_flag_invalid );
  22439. return ui32_fromNaN;
  22440. #endif
  22441. }
  22442. #endif
  22443. /*------------------------------------------------------------------------
  22444. *------------------------------------------------------------------------*/
  22445. if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
  22446. shiftDist = 0x4023 - exp;
  22447. if ( 0 < shiftDist ) {
  22448. sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
  22449. }
  22450. return softfloat_roundToUI32( sign, sig64, roundingMode, exact );
  22451. }
  22452. /**** ended inlining ../../source/f128_to_ui32.c ****/
  22453. /**** start inlining ../../source/f128_to_ui64.c ****/
  22454. /*============================================================================
  22455. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  22456. Package, Release 3e, by John R. Hauser.
  22457. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  22458. University of California. All rights reserved.
  22459. Redistribution and use in source and binary forms, with or without
  22460. modification, are permitted provided that the following conditions are met:
  22461. 1. Redistributions of source code must retain the above copyright notice,
  22462. this list of conditions, and the following disclaimer.
  22463. 2. Redistributions in binary form must reproduce the above copyright notice,
  22464. this list of conditions, and the following disclaimer in the documentation
  22465. and/or other materials provided with the distribution.
  22466. 3. Neither the name of the University nor the names of its contributors may
  22467. be used to endorse or promote products derived from this software without
  22468. specific prior written permission.
  22469. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  22470. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  22471. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  22472. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  22473. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22474. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22475. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  22476. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22477. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  22478. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22479. =============================================================================*/
  22480. #include <stdbool.h>
  22481. #include <stdint.h>
  22482. /**** skipping file: platform.h ****/
  22483. /**** skipping file: internals.h ****/
  22484. /**** skipping file: specialize.h ****/
  22485. /**** skipping file: softfloat.h ****/
  22486. uint_fast64_t
  22487. f128_to_ui64( float128_t a, uint_fast8_t roundingMode, bool exact )
  22488. {
  22489. union ui128_f128 uA;
  22490. uint_fast64_t uiA64, uiA0;
  22491. bool sign;
  22492. int_fast32_t exp;
  22493. uint_fast64_t sig64, sig0;
  22494. int_fast32_t shiftDist;
  22495. struct uint128 sig128;
  22496. struct uint64_extra sigExtra;
  22497. /*------------------------------------------------------------------------
  22498. *------------------------------------------------------------------------*/
  22499. uA.f = a;
  22500. uiA64 = uA.ui.v64;
  22501. uiA0 = uA.ui.v0;
  22502. sign = signF128UI64( uiA64 );
  22503. exp = expF128UI64( uiA64 );
  22504. sig64 = fracF128UI64( uiA64 );
  22505. sig0 = uiA0;
  22506. /*------------------------------------------------------------------------
  22507. *------------------------------------------------------------------------*/
  22508. shiftDist = 0x402F - exp;
  22509. if ( shiftDist <= 0 ) {
  22510. /*--------------------------------------------------------------------
  22511. *--------------------------------------------------------------------*/
  22512. if ( shiftDist < -15 ) {
  22513. softfloat_raiseFlags( softfloat_flag_invalid );
  22514. return
  22515. (exp == 0x7FFF) && (sig64 | sig0) ? ui64_fromNaN
  22516. : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
  22517. }
  22518. /*--------------------------------------------------------------------
  22519. *--------------------------------------------------------------------*/
  22520. sig64 |= UINT64_C( 0x0001000000000000 );
  22521. if ( shiftDist ) {
  22522. sig128 = softfloat_shortShiftLeft128( sig64, sig0, -shiftDist );
  22523. sig64 = sig128.v64;
  22524. sig0 = sig128.v0;
  22525. }
  22526. } else {
  22527. /*--------------------------------------------------------------------
  22528. *--------------------------------------------------------------------*/
  22529. if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
  22530. sigExtra = softfloat_shiftRightJam64Extra( sig64, sig0, shiftDist );
  22531. sig64 = sigExtra.v;
  22532. sig0 = sigExtra.extra;
  22533. }
  22534. return softfloat_roundToUI64( sign, sig64, sig0, roundingMode, exact );
  22535. }
  22536. /**** ended inlining ../../source/f128_to_ui64.c ****/
  22537. /**** start inlining ../../source/f128_to_i32.c ****/
  22538. /*============================================================================
  22539. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  22540. Package, Release 3e, by John R. Hauser.
  22541. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  22542. University of California. All rights reserved.
  22543. Redistribution and use in source and binary forms, with or without
  22544. modification, are permitted provided that the following conditions are met:
  22545. 1. Redistributions of source code must retain the above copyright notice,
  22546. this list of conditions, and the following disclaimer.
  22547. 2. Redistributions in binary form must reproduce the above copyright notice,
  22548. this list of conditions, and the following disclaimer in the documentation
  22549. and/or other materials provided with the distribution.
  22550. 3. Neither the name of the University nor the names of its contributors may
  22551. be used to endorse or promote products derived from this software without
  22552. specific prior written permission.
  22553. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  22554. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  22555. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  22556. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  22557. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22558. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22559. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  22560. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22561. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  22562. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22563. =============================================================================*/
  22564. #include <stdbool.h>
  22565. #include <stdint.h>
  22566. /**** skipping file: platform.h ****/
  22567. /**** skipping file: internals.h ****/
  22568. /**** skipping file: specialize.h ****/
  22569. /**** skipping file: softfloat.h ****/
  22570. int_fast32_t f128_to_i32( float128_t a, uint_fast8_t roundingMode, bool exact )
  22571. {
  22572. union ui128_f128 uA;
  22573. uint_fast64_t uiA64, uiA0;
  22574. bool sign;
  22575. int_fast32_t exp;
  22576. uint_fast64_t sig64, sig0;
  22577. int_fast32_t shiftDist;
  22578. /*------------------------------------------------------------------------
  22579. *------------------------------------------------------------------------*/
  22580. uA.f = a;
  22581. uiA64 = uA.ui.v64;
  22582. uiA0 = uA.ui.v0;
  22583. sign = signF128UI64( uiA64 );
  22584. exp = expF128UI64( uiA64 );
  22585. sig64 = fracF128UI64( uiA64 );
  22586. sig0 = uiA0;
  22587. /*------------------------------------------------------------------------
  22588. *------------------------------------------------------------------------*/
  22589. #if (i32_fromNaN != i32_fromPosOverflow) || (i32_fromNaN != i32_fromNegOverflow)
  22590. if ( (exp == 0x7FFF) && (sig64 | sig0) ) {
  22591. #if (i32_fromNaN == i32_fromPosOverflow)
  22592. sign = 0;
  22593. #elif (i32_fromNaN == i32_fromNegOverflow)
  22594. sign = 1;
  22595. #else
  22596. softfloat_raiseFlags( softfloat_flag_invalid );
  22597. return i32_fromNaN;
  22598. #endif
  22599. }
  22600. #endif
  22601. /*------------------------------------------------------------------------
  22602. *------------------------------------------------------------------------*/
  22603. if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
  22604. sig64 |= (sig0 != 0);
  22605. shiftDist = 0x4023 - exp;
  22606. if ( 0 < shiftDist ) sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
  22607. return softfloat_roundToI32( sign, sig64, roundingMode, exact );
  22608. }
  22609. /**** ended inlining ../../source/f128_to_i32.c ****/
  22610. /**** start inlining ../../source/f128_to_i64.c ****/
  22611. /*============================================================================
  22612. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  22613. Package, Release 3e, by John R. Hauser.
  22614. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  22615. University of California. All rights reserved.
  22616. Redistribution and use in source and binary forms, with or without
  22617. modification, are permitted provided that the following conditions are met:
  22618. 1. Redistributions of source code must retain the above copyright notice,
  22619. this list of conditions, and the following disclaimer.
  22620. 2. Redistributions in binary form must reproduce the above copyright notice,
  22621. this list of conditions, and the following disclaimer in the documentation
  22622. and/or other materials provided with the distribution.
  22623. 3. Neither the name of the University nor the names of its contributors may
  22624. be used to endorse or promote products derived from this software without
  22625. specific prior written permission.
  22626. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  22627. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  22628. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  22629. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  22630. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22631. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22632. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  22633. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22634. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  22635. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22636. =============================================================================*/
  22637. #include <stdbool.h>
  22638. #include <stdint.h>
  22639. /**** skipping file: platform.h ****/
  22640. /**** skipping file: internals.h ****/
  22641. /**** skipping file: specialize.h ****/
  22642. /**** skipping file: softfloat.h ****/
  22643. int_fast64_t f128_to_i64( float128_t a, uint_fast8_t roundingMode, bool exact )
  22644. {
  22645. union ui128_f128 uA;
  22646. uint_fast64_t uiA64, uiA0;
  22647. bool sign;
  22648. int_fast32_t exp;
  22649. uint_fast64_t sig64, sig0;
  22650. int_fast32_t shiftDist;
  22651. struct uint128 sig128;
  22652. struct uint64_extra sigExtra;
  22653. /*------------------------------------------------------------------------
  22654. *------------------------------------------------------------------------*/
  22655. uA.f = a;
  22656. uiA64 = uA.ui.v64;
  22657. uiA0 = uA.ui.v0;
  22658. sign = signF128UI64( uiA64 );
  22659. exp = expF128UI64( uiA64 );
  22660. sig64 = fracF128UI64( uiA64 );
  22661. sig0 = uiA0;
  22662. /*------------------------------------------------------------------------
  22663. *------------------------------------------------------------------------*/
  22664. shiftDist = 0x402F - exp;
  22665. if ( shiftDist <= 0 ) {
  22666. /*--------------------------------------------------------------------
  22667. *--------------------------------------------------------------------*/
  22668. if ( shiftDist < -15 ) {
  22669. softfloat_raiseFlags( softfloat_flag_invalid );
  22670. return
  22671. (exp == 0x7FFF) && (sig64 | sig0) ? i64_fromNaN
  22672. : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
  22673. }
  22674. /*--------------------------------------------------------------------
  22675. *--------------------------------------------------------------------*/
  22676. sig64 |= UINT64_C( 0x0001000000000000 );
  22677. if ( shiftDist ) {
  22678. sig128 = softfloat_shortShiftLeft128( sig64, sig0, -shiftDist );
  22679. sig64 = sig128.v64;
  22680. sig0 = sig128.v0;
  22681. }
  22682. } else {
  22683. /*--------------------------------------------------------------------
  22684. *--------------------------------------------------------------------*/
  22685. if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
  22686. sigExtra = softfloat_shiftRightJam64Extra( sig64, sig0, shiftDist );
  22687. sig64 = sigExtra.v;
  22688. sig0 = sigExtra.extra;
  22689. }
  22690. return softfloat_roundToI64( sign, sig64, sig0, roundingMode, exact );
  22691. }
  22692. /**** ended inlining ../../source/f128_to_i64.c ****/
  22693. /**** start inlining ../../source/f128_to_ui32_r_minMag.c ****/
  22694. /*============================================================================
  22695. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  22696. Package, Release 3e, by John R. Hauser.
  22697. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  22698. California. All rights reserved.
  22699. Redistribution and use in source and binary forms, with or without
  22700. modification, are permitted provided that the following conditions are met:
  22701. 1. Redistributions of source code must retain the above copyright notice,
  22702. this list of conditions, and the following disclaimer.
  22703. 2. Redistributions in binary form must reproduce the above copyright notice,
  22704. this list of conditions, and the following disclaimer in the documentation
  22705. and/or other materials provided with the distribution.
  22706. 3. Neither the name of the University nor the names of its contributors may
  22707. be used to endorse or promote products derived from this software without
  22708. specific prior written permission.
  22709. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  22710. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  22711. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  22712. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  22713. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22714. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22715. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  22716. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22717. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  22718. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22719. =============================================================================*/
  22720. #include <stdbool.h>
  22721. #include <stdint.h>
  22722. /**** skipping file: platform.h ****/
  22723. /**** skipping file: internals.h ****/
  22724. /**** skipping file: specialize.h ****/
  22725. /**** skipping file: softfloat.h ****/
  22726. uint_fast32_t f128_to_ui32_r_minMag( float128_t a, bool exact )
  22727. {
  22728. union ui128_f128 uA;
  22729. uint_fast64_t uiA64, uiA0;
  22730. int_fast32_t exp;
  22731. uint_fast64_t sig64;
  22732. int_fast32_t shiftDist;
  22733. bool sign;
  22734. uint_fast32_t z;
  22735. /*------------------------------------------------------------------------
  22736. *------------------------------------------------------------------------*/
  22737. uA.f = a;
  22738. uiA64 = uA.ui.v64;
  22739. uiA0 = uA.ui.v0;
  22740. exp = expF128UI64( uiA64 );
  22741. sig64 = fracF128UI64( uiA64 ) | (uiA0 != 0);
  22742. /*------------------------------------------------------------------------
  22743. *------------------------------------------------------------------------*/
  22744. shiftDist = 0x402F - exp;
  22745. if ( 49 <= shiftDist ) {
  22746. if ( exact && (exp | sig64) ) {
  22747. softfloat_exceptionFlags |= softfloat_flag_inexact;
  22748. }
  22749. return 0;
  22750. }
  22751. /*------------------------------------------------------------------------
  22752. *------------------------------------------------------------------------*/
  22753. sign = signF128UI64( uiA64 );
  22754. if ( sign || (shiftDist < 17) ) {
  22755. softfloat_raiseFlags( softfloat_flag_invalid );
  22756. return
  22757. (exp == 0x7FFF) && sig64 ? ui32_fromNaN
  22758. : sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
  22759. }
  22760. /*------------------------------------------------------------------------
  22761. *------------------------------------------------------------------------*/
  22762. sig64 |= UINT64_C( 0x0001000000000000 );
  22763. z = sig64>>shiftDist;
  22764. if ( exact && ((uint_fast64_t) z<<shiftDist != sig64) ) {
  22765. softfloat_exceptionFlags |= softfloat_flag_inexact;
  22766. }
  22767. return z;
  22768. }
  22769. /**** ended inlining ../../source/f128_to_ui32_r_minMag.c ****/
  22770. /**** start inlining ../../source/f128_to_ui64_r_minMag.c ****/
  22771. /*============================================================================
  22772. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  22773. Package, Release 3e, by John R. Hauser.
  22774. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  22775. California. All rights reserved.
  22776. Redistribution and use in source and binary forms, with or without
  22777. modification, are permitted provided that the following conditions are met:
  22778. 1. Redistributions of source code must retain the above copyright notice,
  22779. this list of conditions, and the following disclaimer.
  22780. 2. Redistributions in binary form must reproduce the above copyright notice,
  22781. this list of conditions, and the following disclaimer in the documentation
  22782. and/or other materials provided with the distribution.
  22783. 3. Neither the name of the University nor the names of its contributors may
  22784. be used to endorse or promote products derived from this software without
  22785. specific prior written permission.
  22786. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  22787. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  22788. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  22789. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  22790. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22791. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22792. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  22793. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22794. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  22795. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22796. =============================================================================*/
  22797. #include <stdbool.h>
  22798. #include <stdint.h>
  22799. /**** skipping file: platform.h ****/
  22800. /**** skipping file: internals.h ****/
  22801. /**** skipping file: specialize.h ****/
  22802. /**** skipping file: softfloat.h ****/
  22803. uint_fast64_t f128_to_ui64_r_minMag( float128_t a, bool exact )
  22804. {
  22805. union ui128_f128 uA;
  22806. uint_fast64_t uiA64, uiA0;
  22807. bool sign;
  22808. int_fast32_t exp;
  22809. uint_fast64_t sig64, sig0;
  22810. int_fast32_t shiftDist;
  22811. int_fast8_t negShiftDist;
  22812. uint_fast64_t z;
  22813. /*------------------------------------------------------------------------
  22814. *------------------------------------------------------------------------*/
  22815. uA.f = a;
  22816. uiA64 = uA.ui.v64;
  22817. uiA0 = uA.ui.v0;
  22818. sign = signF128UI64( uiA64 );
  22819. exp = expF128UI64( uiA64 );
  22820. sig64 = fracF128UI64( uiA64 );
  22821. sig0 = uiA0;
  22822. /*------------------------------------------------------------------------
  22823. *------------------------------------------------------------------------*/
  22824. shiftDist = 0x402F - exp;
  22825. if ( shiftDist < 0 ) {
  22826. /*--------------------------------------------------------------------
  22827. *--------------------------------------------------------------------*/
  22828. if ( sign || (shiftDist < -15) ) goto invalid;
  22829. sig64 |= UINT64_C( 0x0001000000000000 );
  22830. negShiftDist = -shiftDist;
  22831. z = sig64<<negShiftDist | sig0>>(shiftDist & 63);
  22832. if ( exact && (uint64_t) (sig0<<negShiftDist) ) {
  22833. softfloat_exceptionFlags |= softfloat_flag_inexact;
  22834. }
  22835. } else {
  22836. /*--------------------------------------------------------------------
  22837. *--------------------------------------------------------------------*/
  22838. if ( 49 <= shiftDist ) {
  22839. if ( exact && (exp | sig64 | sig0) ) {
  22840. softfloat_exceptionFlags |= softfloat_flag_inexact;
  22841. }
  22842. return 0;
  22843. }
  22844. /*--------------------------------------------------------------------
  22845. *--------------------------------------------------------------------*/
  22846. if ( sign ) goto invalid;
  22847. sig64 |= UINT64_C( 0x0001000000000000 );
  22848. z = sig64>>shiftDist;
  22849. if ( exact && (sig0 || (z<<shiftDist != sig64)) ) {
  22850. softfloat_exceptionFlags |= softfloat_flag_inexact;
  22851. }
  22852. }
  22853. return z;
  22854. /*------------------------------------------------------------------------
  22855. *------------------------------------------------------------------------*/
  22856. invalid:
  22857. softfloat_raiseFlags( softfloat_flag_invalid );
  22858. return
  22859. (exp == 0x7FFF) && (sig64 | sig0) ? ui64_fromNaN
  22860. : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
  22861. }
  22862. /**** ended inlining ../../source/f128_to_ui64_r_minMag.c ****/
  22863. /**** start inlining ../../source/f128_to_i32_r_minMag.c ****/
  22864. /*============================================================================
  22865. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  22866. Package, Release 3e, by John R. Hauser.
  22867. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  22868. California. All rights reserved.
  22869. Redistribution and use in source and binary forms, with or without
  22870. modification, are permitted provided that the following conditions are met:
  22871. 1. Redistributions of source code must retain the above copyright notice,
  22872. this list of conditions, and the following disclaimer.
  22873. 2. Redistributions in binary form must reproduce the above copyright notice,
  22874. this list of conditions, and the following disclaimer in the documentation
  22875. and/or other materials provided with the distribution.
  22876. 3. Neither the name of the University nor the names of its contributors may
  22877. be used to endorse or promote products derived from this software without
  22878. specific prior written permission.
  22879. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  22880. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  22881. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  22882. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  22883. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22884. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22885. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  22886. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22887. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  22888. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22889. =============================================================================*/
  22890. #include <stdbool.h>
  22891. #include <stdint.h>
  22892. /**** skipping file: platform.h ****/
  22893. /**** skipping file: internals.h ****/
  22894. /**** skipping file: specialize.h ****/
  22895. /**** skipping file: softfloat.h ****/
  22896. int_fast32_t f128_to_i32_r_minMag( float128_t a, bool exact )
  22897. {
  22898. union ui128_f128 uA;
  22899. uint_fast64_t uiA64, uiA0;
  22900. int_fast32_t exp;
  22901. uint_fast64_t sig64;
  22902. int_fast32_t shiftDist;
  22903. bool sign;
  22904. int_fast32_t absZ;
  22905. /*------------------------------------------------------------------------
  22906. *------------------------------------------------------------------------*/
  22907. uA.f = a;
  22908. uiA64 = uA.ui.v64;
  22909. uiA0 = uA.ui.v0;
  22910. exp = expF128UI64( uiA64 );
  22911. sig64 = fracF128UI64( uiA64 ) | (uiA0 != 0);
  22912. /*------------------------------------------------------------------------
  22913. *------------------------------------------------------------------------*/
  22914. shiftDist = 0x402F - exp;
  22915. if ( 49 <= shiftDist ) {
  22916. if ( exact && (exp | sig64) ) {
  22917. softfloat_exceptionFlags |= softfloat_flag_inexact;
  22918. }
  22919. return 0;
  22920. }
  22921. /*------------------------------------------------------------------------
  22922. *------------------------------------------------------------------------*/
  22923. sign = signF128UI64( uiA64 );
  22924. if ( shiftDist < 18 ) {
  22925. if (
  22926. sign && (shiftDist == 17)
  22927. && (sig64 < UINT64_C( 0x0000000000020000 ))
  22928. ) {
  22929. if ( exact && sig64 ) {
  22930. softfloat_exceptionFlags |= softfloat_flag_inexact;
  22931. }
  22932. return -0x7FFFFFFF - 1;
  22933. }
  22934. softfloat_raiseFlags( softfloat_flag_invalid );
  22935. return
  22936. (exp == 0x7FFF) && sig64 ? i32_fromNaN
  22937. : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
  22938. }
  22939. /*------------------------------------------------------------------------
  22940. *------------------------------------------------------------------------*/
  22941. sig64 |= UINT64_C( 0x0001000000000000 );
  22942. absZ = sig64>>shiftDist;
  22943. if (
  22944. exact && ((uint_fast64_t) (uint_fast32_t) absZ<<shiftDist != sig64)
  22945. ) {
  22946. softfloat_exceptionFlags |= softfloat_flag_inexact;
  22947. }
  22948. return sign ? -absZ : absZ;
  22949. }
  22950. /**** ended inlining ../../source/f128_to_i32_r_minMag.c ****/
  22951. /**** start inlining ../../source/f128_to_i64_r_minMag.c ****/
  22952. /*============================================================================
  22953. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  22954. Package, Release 3e, by John R. Hauser.
  22955. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  22956. California. All rights reserved.
  22957. Redistribution and use in source and binary forms, with or without
  22958. modification, are permitted provided that the following conditions are met:
  22959. 1. Redistributions of source code must retain the above copyright notice,
  22960. this list of conditions, and the following disclaimer.
  22961. 2. Redistributions in binary form must reproduce the above copyright notice,
  22962. this list of conditions, and the following disclaimer in the documentation
  22963. and/or other materials provided with the distribution.
  22964. 3. Neither the name of the University nor the names of its contributors may
  22965. be used to endorse or promote products derived from this software without
  22966. specific prior written permission.
  22967. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  22968. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  22969. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  22970. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  22971. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22972. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22973. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  22974. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22975. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  22976. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22977. =============================================================================*/
  22978. #include <stdbool.h>
  22979. #include <stdint.h>
  22980. /**** skipping file: platform.h ****/
  22981. /**** skipping file: internals.h ****/
  22982. /**** skipping file: specialize.h ****/
  22983. /**** skipping file: softfloat.h ****/
  22984. int_fast64_t f128_to_i64_r_minMag( float128_t a, bool exact )
  22985. {
  22986. union ui128_f128 uA;
  22987. uint_fast64_t uiA64, uiA0;
  22988. bool sign;
  22989. int_fast32_t exp;
  22990. uint_fast64_t sig64, sig0;
  22991. int_fast32_t shiftDist;
  22992. int_fast8_t negShiftDist;
  22993. int_fast64_t absZ;
  22994. /*------------------------------------------------------------------------
  22995. *------------------------------------------------------------------------*/
  22996. uA.f = a;
  22997. uiA64 = uA.ui.v64;
  22998. uiA0 = uA.ui.v0;
  22999. sign = signF128UI64( uiA64 );
  23000. exp = expF128UI64( uiA64 );
  23001. sig64 = fracF128UI64( uiA64 );
  23002. sig0 = uiA0;
  23003. /*------------------------------------------------------------------------
  23004. *------------------------------------------------------------------------*/
  23005. shiftDist = 0x402F - exp;
  23006. if ( shiftDist < 0 ) {
  23007. /*--------------------------------------------------------------------
  23008. *--------------------------------------------------------------------*/
  23009. if ( shiftDist < -14 ) {
  23010. if (
  23011. (uiA64 == UINT64_C( 0xC03E000000000000 ))
  23012. && (sig0 < UINT64_C( 0x0002000000000000 ))
  23013. ) {
  23014. if ( exact && sig0 ) {
  23015. softfloat_exceptionFlags |= softfloat_flag_inexact;
  23016. }
  23017. return -INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1;
  23018. }
  23019. softfloat_raiseFlags( softfloat_flag_invalid );
  23020. return
  23021. (exp == 0x7FFF) && (sig64 | sig0) ? i64_fromNaN
  23022. : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
  23023. }
  23024. /*--------------------------------------------------------------------
  23025. *--------------------------------------------------------------------*/
  23026. sig64 |= UINT64_C( 0x0001000000000000 );
  23027. negShiftDist = -shiftDist;
  23028. absZ = sig64<<negShiftDist | sig0>>(shiftDist & 63);
  23029. if ( exact && (uint64_t) (sig0<<negShiftDist) ) {
  23030. softfloat_exceptionFlags |= softfloat_flag_inexact;
  23031. }
  23032. } else {
  23033. /*--------------------------------------------------------------------
  23034. *--------------------------------------------------------------------*/
  23035. if ( 49 <= shiftDist ) {
  23036. if ( exact && (exp | sig64 | sig0) ) {
  23037. softfloat_exceptionFlags |= softfloat_flag_inexact;
  23038. }
  23039. return 0;
  23040. }
  23041. /*--------------------------------------------------------------------
  23042. *--------------------------------------------------------------------*/
  23043. sig64 |= UINT64_C( 0x0001000000000000 );
  23044. absZ = sig64>>shiftDist;
  23045. if ( exact && (sig0 || (absZ<<shiftDist != sig64)) ) {
  23046. softfloat_exceptionFlags |= softfloat_flag_inexact;
  23047. }
  23048. }
  23049. return sign ? -absZ : absZ;
  23050. }
  23051. /**** ended inlining ../../source/f128_to_i64_r_minMag.c ****/
  23052. /**** start inlining ../../source/f128_to_f16.c ****/
  23053. /*============================================================================
  23054. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  23055. Package, Release 3e, by John R. Hauser.
  23056. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  23057. California. All rights reserved.
  23058. Redistribution and use in source and binary forms, with or without
  23059. modification, are permitted provided that the following conditions are met:
  23060. 1. Redistributions of source code must retain the above copyright notice,
  23061. this list of conditions, and the following disclaimer.
  23062. 2. Redistributions in binary form must reproduce the above copyright notice,
  23063. this list of conditions, and the following disclaimer in the documentation
  23064. and/or other materials provided with the distribution.
  23065. 3. Neither the name of the University nor the names of its contributors may
  23066. be used to endorse or promote products derived from this software without
  23067. specific prior written permission.
  23068. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  23069. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  23070. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  23071. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  23072. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23073. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23074. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23075. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23076. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  23077. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23078. =============================================================================*/
  23079. #include <stdbool.h>
  23080. #include <stdint.h>
  23081. /**** skipping file: platform.h ****/
  23082. /**** skipping file: internals.h ****/
  23083. /**** skipping file: specialize.h ****/
  23084. /**** skipping file: softfloat.h ****/
  23085. float16_t f128_to_f16( float128_t a )
  23086. {
  23087. union ui128_f128 uA;
  23088. uint_fast64_t uiA64, uiA0;
  23089. bool sign;
  23090. int_fast32_t exp;
  23091. uint_fast64_t frac64;
  23092. struct commonNaN commonNaN;
  23093. uint_fast16_t uiZ, frac16;
  23094. union ui16_f16 uZ;
  23095. /*------------------------------------------------------------------------
  23096. *------------------------------------------------------------------------*/
  23097. uA.f = a;
  23098. uiA64 = uA.ui.v64;
  23099. uiA0 = uA.ui.v0;
  23100. sign = signF128UI64( uiA64 );
  23101. exp = expF128UI64( uiA64 );
  23102. frac64 = fracF128UI64( uiA64 ) | (uiA0 != 0);
  23103. /*------------------------------------------------------------------------
  23104. *------------------------------------------------------------------------*/
  23105. if ( exp == 0x7FFF ) {
  23106. if ( frac64 ) {
  23107. softfloat_f128UIToCommonNaN( uiA64, uiA0, &commonNaN );
  23108. uiZ = softfloat_commonNaNToF16UI( &commonNaN );
  23109. } else {
  23110. uiZ = packToF16UI( sign, 0x1F, 0 );
  23111. }
  23112. goto uiZ;
  23113. }
  23114. /*------------------------------------------------------------------------
  23115. *------------------------------------------------------------------------*/
  23116. frac16 = softfloat_shortShiftRightJam64( frac64, 34 );
  23117. if ( ! (exp | frac16) ) {
  23118. uiZ = packToF16UI( sign, 0, 0 );
  23119. goto uiZ;
  23120. }
  23121. /*------------------------------------------------------------------------
  23122. *------------------------------------------------------------------------*/
  23123. exp -= 0x3FF1;
  23124. if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
  23125. if ( exp < -0x40 ) exp = -0x40;
  23126. }
  23127. return softfloat_roundPackToF16( sign, exp, frac16 | 0x4000 );
  23128. /*------------------------------------------------------------------------
  23129. *------------------------------------------------------------------------*/
  23130. uiZ:
  23131. uZ.ui = uiZ;
  23132. return uZ.f;
  23133. }
  23134. /**** ended inlining ../../source/f128_to_f16.c ****/
  23135. /**** start inlining ../../source/f128_to_f32.c ****/
  23136. /*============================================================================
  23137. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  23138. Package, Release 3e, by John R. Hauser.
  23139. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  23140. California. All rights reserved.
  23141. Redistribution and use in source and binary forms, with or without
  23142. modification, are permitted provided that the following conditions are met:
  23143. 1. Redistributions of source code must retain the above copyright notice,
  23144. this list of conditions, and the following disclaimer.
  23145. 2. Redistributions in binary form must reproduce the above copyright notice,
  23146. this list of conditions, and the following disclaimer in the documentation
  23147. and/or other materials provided with the distribution.
  23148. 3. Neither the name of the University nor the names of its contributors may
  23149. be used to endorse or promote products derived from this software without
  23150. specific prior written permission.
  23151. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  23152. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  23153. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  23154. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  23155. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23156. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23157. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23158. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23159. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  23160. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23161. =============================================================================*/
  23162. #include <stdbool.h>
  23163. #include <stdint.h>
  23164. /**** skipping file: platform.h ****/
  23165. /**** skipping file: internals.h ****/
  23166. /**** skipping file: specialize.h ****/
  23167. /**** skipping file: softfloat.h ****/
  23168. float32_t f128_to_f32( float128_t a )
  23169. {
  23170. union ui128_f128 uA;
  23171. uint_fast64_t uiA64, uiA0;
  23172. bool sign;
  23173. int_fast32_t exp;
  23174. uint_fast64_t frac64;
  23175. struct commonNaN commonNaN;
  23176. uint_fast32_t uiZ, frac32;
  23177. union ui32_f32 uZ;
  23178. /*------------------------------------------------------------------------
  23179. *------------------------------------------------------------------------*/
  23180. uA.f = a;
  23181. uiA64 = uA.ui.v64;
  23182. uiA0 = uA.ui.v0;
  23183. sign = signF128UI64( uiA64 );
  23184. exp = expF128UI64( uiA64 );
  23185. frac64 = fracF128UI64( uiA64 ) | (uiA0 != 0);
  23186. /*------------------------------------------------------------------------
  23187. *------------------------------------------------------------------------*/
  23188. if ( exp == 0x7FFF ) {
  23189. if ( frac64 ) {
  23190. softfloat_f128UIToCommonNaN( uiA64, uiA0, &commonNaN );
  23191. uiZ = softfloat_commonNaNToF32UI( &commonNaN );
  23192. } else {
  23193. uiZ = packToF32UI( sign, 0xFF, 0 );
  23194. }
  23195. goto uiZ;
  23196. }
  23197. /*------------------------------------------------------------------------
  23198. *------------------------------------------------------------------------*/
  23199. frac32 = softfloat_shortShiftRightJam64( frac64, 18 );
  23200. if ( ! (exp | frac32) ) {
  23201. uiZ = packToF32UI( sign, 0, 0 );
  23202. goto uiZ;
  23203. }
  23204. /*------------------------------------------------------------------------
  23205. *------------------------------------------------------------------------*/
  23206. exp -= 0x3F81;
  23207. if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
  23208. if ( exp < -0x1000 ) exp = -0x1000;
  23209. }
  23210. return softfloat_roundPackToF32( sign, exp, frac32 | 0x40000000 );
  23211. /*------------------------------------------------------------------------
  23212. *------------------------------------------------------------------------*/
  23213. uiZ:
  23214. uZ.ui = uiZ;
  23215. return uZ.f;
  23216. }
  23217. /**** ended inlining ../../source/f128_to_f32.c ****/
  23218. /**** start inlining ../../source/f128_to_extF80.c ****/
  23219. /*============================================================================
  23220. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  23221. Package, Release 3e, by John R. Hauser.
  23222. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  23223. California. All rights reserved.
  23224. Redistribution and use in source and binary forms, with or without
  23225. modification, are permitted provided that the following conditions are met:
  23226. 1. Redistributions of source code must retain the above copyright notice,
  23227. this list of conditions, and the following disclaimer.
  23228. 2. Redistributions in binary form must reproduce the above copyright notice,
  23229. this list of conditions, and the following disclaimer in the documentation
  23230. and/or other materials provided with the distribution.
  23231. 3. Neither the name of the University nor the names of its contributors may
  23232. be used to endorse or promote products derived from this software without
  23233. specific prior written permission.
  23234. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  23235. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  23236. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  23237. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  23238. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23239. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23240. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23241. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23242. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  23243. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23244. =============================================================================*/
  23245. #include <stdbool.h>
  23246. #include <stdint.h>
  23247. /**** skipping file: platform.h ****/
  23248. /**** skipping file: internals.h ****/
  23249. /**** skipping file: specialize.h ****/
  23250. /**** skipping file: softfloat.h ****/
  23251. extFloat80_t f128_to_extF80( float128_t a )
  23252. {
  23253. union ui128_f128 uA;
  23254. uint_fast64_t uiA64, uiA0;
  23255. bool sign;
  23256. int_fast32_t exp;
  23257. uint_fast64_t frac64, frac0;
  23258. struct commonNaN commonNaN;
  23259. struct uint128 uiZ;
  23260. uint_fast16_t uiZ64;
  23261. uint_fast64_t uiZ0;
  23262. struct exp32_sig128 normExpSig;
  23263. struct uint128 sig128;
  23264. union { struct extFloat80M s; extFloat80_t f; } uZ;
  23265. /*------------------------------------------------------------------------
  23266. *------------------------------------------------------------------------*/
  23267. uA.f = a;
  23268. uiA64 = uA.ui.v64;
  23269. uiA0 = uA.ui.v0;
  23270. sign = signF128UI64( uiA64 );
  23271. exp = expF128UI64( uiA64 );
  23272. frac64 = fracF128UI64( uiA64 );
  23273. frac0 = uiA0;
  23274. /*------------------------------------------------------------------------
  23275. *------------------------------------------------------------------------*/
  23276. if ( exp == 0x7FFF ) {
  23277. if ( frac64 | frac0 ) {
  23278. softfloat_f128UIToCommonNaN( uiA64, uiA0, &commonNaN );
  23279. uiZ = softfloat_commonNaNToExtF80UI( &commonNaN );
  23280. uiZ64 = uiZ.v64;
  23281. uiZ0 = uiZ.v0;
  23282. } else {
  23283. uiZ64 = packToExtF80UI64( sign, 0x7FFF );
  23284. uiZ0 = UINT64_C( 0x8000000000000000 );
  23285. }
  23286. goto uiZ;
  23287. }
  23288. /*------------------------------------------------------------------------
  23289. *------------------------------------------------------------------------*/
  23290. if ( ! exp ) {
  23291. if ( ! (frac64 | frac0) ) {
  23292. uiZ64 = packToExtF80UI64( sign, 0 );
  23293. uiZ0 = 0;
  23294. goto uiZ;
  23295. }
  23296. normExpSig = softfloat_normSubnormalF128Sig( frac64, frac0 );
  23297. exp = normExpSig.exp;
  23298. frac64 = normExpSig.sig.v64;
  23299. frac0 = normExpSig.sig.v0;
  23300. }
  23301. /*------------------------------------------------------------------------
  23302. *------------------------------------------------------------------------*/
  23303. sig128 =
  23304. softfloat_shortShiftLeft128(
  23305. frac64 | UINT64_C( 0x0001000000000000 ), frac0, 15 );
  23306. return softfloat_roundPackToExtF80( sign, exp, sig128.v64, sig128.v0, 80 );
  23307. /*------------------------------------------------------------------------
  23308. *------------------------------------------------------------------------*/
  23309. uiZ:
  23310. uZ.s.signExp = uiZ64;
  23311. uZ.s.signif = uiZ0;
  23312. return uZ.f;
  23313. }
  23314. /**** ended inlining ../../source/f128_to_extF80.c ****/
  23315. /**** start inlining ../../source/f128_to_f64.c ****/
  23316. /*============================================================================
  23317. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  23318. Package, Release 3e, by John R. Hauser.
  23319. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  23320. California. All rights reserved.
  23321. Redistribution and use in source and binary forms, with or without
  23322. modification, are permitted provided that the following conditions are met:
  23323. 1. Redistributions of source code must retain the above copyright notice,
  23324. this list of conditions, and the following disclaimer.
  23325. 2. Redistributions in binary form must reproduce the above copyright notice,
  23326. this list of conditions, and the following disclaimer in the documentation
  23327. and/or other materials provided with the distribution.
  23328. 3. Neither the name of the University nor the names of its contributors may
  23329. be used to endorse or promote products derived from this software without
  23330. specific prior written permission.
  23331. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  23332. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  23333. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  23334. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  23335. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23336. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23337. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23338. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23339. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  23340. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23341. =============================================================================*/
  23342. #include <stdbool.h>
  23343. #include <stdint.h>
  23344. /**** skipping file: platform.h ****/
  23345. /**** skipping file: internals.h ****/
  23346. /**** skipping file: specialize.h ****/
  23347. /**** skipping file: softfloat.h ****/
  23348. float64_t f128_to_f64( float128_t a )
  23349. {
  23350. union ui128_f128 uA;
  23351. uint_fast64_t uiA64, uiA0;
  23352. bool sign;
  23353. int_fast32_t exp;
  23354. uint_fast64_t frac64, frac0;
  23355. struct commonNaN commonNaN;
  23356. uint_fast64_t uiZ;
  23357. struct uint128 frac128;
  23358. union ui64_f64 uZ;
  23359. /*------------------------------------------------------------------------
  23360. *------------------------------------------------------------------------*/
  23361. uA.f = a;
  23362. uiA64 = uA.ui.v64;
  23363. uiA0 = uA.ui.v0;
  23364. sign = signF128UI64( uiA64 );
  23365. exp = expF128UI64( uiA64 );
  23366. frac64 = fracF128UI64( uiA64 );
  23367. frac0 = uiA0;
  23368. /*------------------------------------------------------------------------
  23369. *------------------------------------------------------------------------*/
  23370. if ( exp == 0x7FFF ) {
  23371. if ( frac64 | frac0 ) {
  23372. softfloat_f128UIToCommonNaN( uiA64, uiA0, &commonNaN );
  23373. uiZ = softfloat_commonNaNToF64UI( &commonNaN );
  23374. } else {
  23375. uiZ = packToF64UI( sign, 0x7FF, 0 );
  23376. }
  23377. goto uiZ;
  23378. }
  23379. /*------------------------------------------------------------------------
  23380. *------------------------------------------------------------------------*/
  23381. frac128 = softfloat_shortShiftLeft128( frac64, frac0, 14 );
  23382. frac64 = frac128.v64 | (frac128.v0 != 0);
  23383. if ( ! (exp | frac64) ) {
  23384. uiZ = packToF64UI( sign, 0, 0 );
  23385. goto uiZ;
  23386. }
  23387. /*------------------------------------------------------------------------
  23388. *------------------------------------------------------------------------*/
  23389. exp -= 0x3C01;
  23390. if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
  23391. if ( exp < -0x1000 ) exp = -0x1000;
  23392. }
  23393. return
  23394. softfloat_roundPackToF64(
  23395. sign, exp, frac64 | UINT64_C( 0x4000000000000000 ) );
  23396. /*------------------------------------------------------------------------
  23397. *------------------------------------------------------------------------*/
  23398. uiZ:
  23399. uZ.ui = uiZ;
  23400. return uZ.f;
  23401. }
  23402. /**** ended inlining ../../source/f128_to_f64.c ****/
  23403. /**** start inlining ../../source/f128_roundToInt.c ****/
  23404. /*============================================================================
  23405. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  23406. Package, Release 3e, by John R. Hauser.
  23407. Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
  23408. California. All rights reserved.
  23409. Redistribution and use in source and binary forms, with or without
  23410. modification, are permitted provided that the following conditions are met:
  23411. 1. Redistributions of source code must retain the above copyright notice,
  23412. this list of conditions, and the following disclaimer.
  23413. 2. Redistributions in binary form must reproduce the above copyright notice,
  23414. this list of conditions, and the following disclaimer in the documentation
  23415. and/or other materials provided with the distribution.
  23416. 3. Neither the name of the University nor the names of its contributors may
  23417. be used to endorse or promote products derived from this software without
  23418. specific prior written permission.
  23419. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  23420. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  23421. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  23422. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  23423. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23424. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23425. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23426. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23427. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  23428. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23429. =============================================================================*/
  23430. #include <stdbool.h>
  23431. #include <stdint.h>
  23432. /**** skipping file: platform.h ****/
  23433. /**** skipping file: internals.h ****/
  23434. /**** skipping file: specialize.h ****/
  23435. /**** skipping file: softfloat.h ****/
  23436. float128_t
  23437. f128_roundToInt( float128_t a, uint_fast8_t roundingMode, bool exact )
  23438. {
  23439. union ui128_f128 uA;
  23440. uint_fast64_t uiA64, uiA0;
  23441. int_fast32_t exp;
  23442. struct uint128 uiZ;
  23443. uint_fast64_t lastBitMask0, roundBitsMask;
  23444. bool roundNearEven;
  23445. uint_fast64_t lastBitMask64;
  23446. union ui128_f128 uZ;
  23447. /*------------------------------------------------------------------------
  23448. *------------------------------------------------------------------------*/
  23449. uA.f = a;
  23450. uiA64 = uA.ui.v64;
  23451. uiA0 = uA.ui.v0;
  23452. exp = expF128UI64( uiA64 );
  23453. /*------------------------------------------------------------------------
  23454. *------------------------------------------------------------------------*/
  23455. if ( 0x402F <= exp ) {
  23456. /*--------------------------------------------------------------------
  23457. *--------------------------------------------------------------------*/
  23458. if ( 0x406F <= exp ) {
  23459. if ( (exp == 0x7FFF) && (fracF128UI64( uiA64 ) | uiA0) ) {
  23460. uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, 0, 0 );
  23461. goto uiZ;
  23462. }
  23463. return a;
  23464. }
  23465. /*--------------------------------------------------------------------
  23466. *--------------------------------------------------------------------*/
  23467. lastBitMask0 = (uint_fast64_t) 2<<(0x406E - exp);
  23468. roundBitsMask = lastBitMask0 - 1;
  23469. uiZ.v64 = uiA64;
  23470. uiZ.v0 = uiA0;
  23471. roundNearEven = (roundingMode == softfloat_round_near_even);
  23472. if ( roundNearEven || (roundingMode == softfloat_round_near_maxMag) ) {
  23473. if ( exp == 0x402F ) {
  23474. if ( UINT64_C( 0x8000000000000000 ) <= uiZ.v0 ) {
  23475. ++uiZ.v64;
  23476. if (
  23477. roundNearEven
  23478. && (uiZ.v0 == UINT64_C( 0x8000000000000000 ))
  23479. ) {
  23480. uiZ.v64 &= ~1;
  23481. }
  23482. }
  23483. } else {
  23484. uiZ = softfloat_add128( uiZ.v64, uiZ.v0, 0, lastBitMask0>>1 );
  23485. if ( roundNearEven && !(uiZ.v0 & roundBitsMask) ) {
  23486. uiZ.v0 &= ~lastBitMask0;
  23487. }
  23488. }
  23489. } else if (
  23490. roundingMode
  23491. == (signF128UI64( uiZ.v64 ) ? softfloat_round_min
  23492. : softfloat_round_max)
  23493. ) {
  23494. uiZ = softfloat_add128( uiZ.v64, uiZ.v0, 0, roundBitsMask );
  23495. }
  23496. uiZ.v0 &= ~roundBitsMask;
  23497. lastBitMask64 = !lastBitMask0;
  23498. } else {
  23499. /*--------------------------------------------------------------------
  23500. *--------------------------------------------------------------------*/
  23501. if ( exp < 0x3FFF ) {
  23502. if ( !((uiA64 & UINT64_C( 0x7FFFFFFFFFFFFFFF )) | uiA0) ) return a;
  23503. if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
  23504. uiZ.v64 = uiA64 & packToF128UI64( 1, 0, 0 );
  23505. uiZ.v0 = 0;
  23506. switch ( roundingMode ) {
  23507. case softfloat_round_near_even:
  23508. if ( !(fracF128UI64( uiA64 ) | uiA0) ) break;
  23509. case softfloat_round_near_maxMag:
  23510. if ( exp == 0x3FFE ) uiZ.v64 |= packToF128UI64( 0, 0x3FFF, 0 );
  23511. break;
  23512. case softfloat_round_min:
  23513. if ( uiZ.v64 ) uiZ.v64 = packToF128UI64( 1, 0x3FFF, 0 );
  23514. break;
  23515. case softfloat_round_max:
  23516. if ( !uiZ.v64 ) uiZ.v64 = packToF128UI64( 0, 0x3FFF, 0 );
  23517. break;
  23518. #ifdef SOFTFLOAT_ROUND_ODD
  23519. case softfloat_round_odd:
  23520. uiZ.v64 |= packToF128UI64( 0, 0x3FFF, 0 );
  23521. break;
  23522. #endif
  23523. }
  23524. goto uiZ;
  23525. }
  23526. /*--------------------------------------------------------------------
  23527. *--------------------------------------------------------------------*/
  23528. uiZ.v64 = uiA64;
  23529. uiZ.v0 = 0;
  23530. lastBitMask64 = (uint_fast64_t) 1<<(0x402F - exp);
  23531. roundBitsMask = lastBitMask64 - 1;
  23532. if ( roundingMode == softfloat_round_near_maxMag ) {
  23533. uiZ.v64 += lastBitMask64>>1;
  23534. } else if ( roundingMode == softfloat_round_near_even ) {
  23535. uiZ.v64 += lastBitMask64>>1;
  23536. if ( !((uiZ.v64 & roundBitsMask) | uiA0) ) {
  23537. uiZ.v64 &= ~lastBitMask64;
  23538. }
  23539. } else if (
  23540. roundingMode
  23541. == (signF128UI64( uiZ.v64 ) ? softfloat_round_min
  23542. : softfloat_round_max)
  23543. ) {
  23544. uiZ.v64 = (uiZ.v64 | (uiA0 != 0)) + roundBitsMask;
  23545. }
  23546. uiZ.v64 &= ~roundBitsMask;
  23547. lastBitMask0 = 0;
  23548. }
  23549. if ( (uiZ.v64 != uiA64) || (uiZ.v0 != uiA0) ) {
  23550. #ifdef SOFTFLOAT_ROUND_ODD
  23551. if ( roundingMode == softfloat_round_odd ) {
  23552. uiZ.v64 |= lastBitMask64;
  23553. uiZ.v0 |= lastBitMask0;
  23554. }
  23555. #endif
  23556. if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
  23557. }
  23558. uiZ:
  23559. uZ.ui = uiZ;
  23560. return uZ.f;
  23561. }
  23562. /**** ended inlining ../../source/f128_roundToInt.c ****/
  23563. /**** start inlining ../../source/f128_add.c ****/
  23564. /*============================================================================
  23565. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  23566. Package, Release 3e, by John R. Hauser.
  23567. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  23568. All rights reserved.
  23569. Redistribution and use in source and binary forms, with or without
  23570. modification, are permitted provided that the following conditions are met:
  23571. 1. Redistributions of source code must retain the above copyright notice,
  23572. this list of conditions, and the following disclaimer.
  23573. 2. Redistributions in binary form must reproduce the above copyright notice,
  23574. this list of conditions, and the following disclaimer in the documentation
  23575. and/or other materials provided with the distribution.
  23576. 3. Neither the name of the University nor the names of its contributors may
  23577. be used to endorse or promote products derived from this software without
  23578. specific prior written permission.
  23579. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  23580. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  23581. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  23582. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  23583. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23584. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23585. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23586. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23587. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  23588. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23589. =============================================================================*/
  23590. #include <stdbool.h>
  23591. #include <stdint.h>
  23592. /**** skipping file: platform.h ****/
  23593. /**** skipping file: internals.h ****/
  23594. /**** skipping file: softfloat.h ****/
  23595. float128_t f128_add( float128_t a, float128_t b )
  23596. {
  23597. union ui128_f128 uA;
  23598. uint_fast64_t uiA64, uiA0;
  23599. bool signA;
  23600. union ui128_f128 uB;
  23601. uint_fast64_t uiB64, uiB0;
  23602. bool signB;
  23603. #if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
  23604. float128_t
  23605. (*magsFuncPtr)(
  23606. uint_fast64_t, uint_fast64_t, uint_fast64_t, uint_fast64_t, bool );
  23607. #endif
  23608. uA.f = a;
  23609. uiA64 = uA.ui.v64;
  23610. uiA0 = uA.ui.v0;
  23611. signA = signF128UI64( uiA64 );
  23612. uB.f = b;
  23613. uiB64 = uB.ui.v64;
  23614. uiB0 = uB.ui.v0;
  23615. signB = signF128UI64( uiB64 );
  23616. #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
  23617. if ( signA == signB ) {
  23618. return softfloat_addMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
  23619. } else {
  23620. return softfloat_subMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
  23621. }
  23622. #else
  23623. magsFuncPtr =
  23624. (signA == signB) ? softfloat_addMagsF128 : softfloat_subMagsF128;
  23625. return (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
  23626. #endif
  23627. }
  23628. /**** ended inlining ../../source/f128_add.c ****/
  23629. /**** start inlining ../../source/f128_sub.c ****/
  23630. /*============================================================================
  23631. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  23632. Package, Release 3e, by John R. Hauser.
  23633. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  23634. All rights reserved.
  23635. Redistribution and use in source and binary forms, with or without
  23636. modification, are permitted provided that the following conditions are met:
  23637. 1. Redistributions of source code must retain the above copyright notice,
  23638. this list of conditions, and the following disclaimer.
  23639. 2. Redistributions in binary form must reproduce the above copyright notice,
  23640. this list of conditions, and the following disclaimer in the documentation
  23641. and/or other materials provided with the distribution.
  23642. 3. Neither the name of the University nor the names of its contributors may
  23643. be used to endorse or promote products derived from this software without
  23644. specific prior written permission.
  23645. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  23646. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  23647. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  23648. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  23649. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23650. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23651. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23652. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23653. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  23654. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23655. =============================================================================*/
  23656. #include <stdbool.h>
  23657. #include <stdint.h>
  23658. /**** skipping file: platform.h ****/
  23659. /**** skipping file: internals.h ****/
  23660. /**** skipping file: softfloat.h ****/
  23661. float128_t f128_sub( float128_t a, float128_t b )
  23662. {
  23663. union ui128_f128 uA;
  23664. uint_fast64_t uiA64, uiA0;
  23665. bool signA;
  23666. union ui128_f128 uB;
  23667. uint_fast64_t uiB64, uiB0;
  23668. bool signB;
  23669. #if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
  23670. float128_t
  23671. (*magsFuncPtr)(
  23672. uint_fast64_t, uint_fast64_t, uint_fast64_t, uint_fast64_t, bool );
  23673. #endif
  23674. uA.f = a;
  23675. uiA64 = uA.ui.v64;
  23676. uiA0 = uA.ui.v0;
  23677. signA = signF128UI64( uiA64 );
  23678. uB.f = b;
  23679. uiB64 = uB.ui.v64;
  23680. uiB0 = uB.ui.v0;
  23681. signB = signF128UI64( uiB64 );
  23682. #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
  23683. if ( signA == signB ) {
  23684. return softfloat_subMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
  23685. } else {
  23686. return softfloat_addMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
  23687. }
  23688. #else
  23689. magsFuncPtr =
  23690. (signA == signB) ? softfloat_subMagsF128 : softfloat_addMagsF128;
  23691. return (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
  23692. #endif
  23693. }
  23694. /**** ended inlining ../../source/f128_sub.c ****/
  23695. /**** start inlining ../../source/f128_mul.c ****/
  23696. /*============================================================================
  23697. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  23698. Package, Release 3e, by John R. Hauser.
  23699. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  23700. All rights reserved.
  23701. Redistribution and use in source and binary forms, with or without
  23702. modification, are permitted provided that the following conditions are met:
  23703. 1. Redistributions of source code must retain the above copyright notice,
  23704. this list of conditions, and the following disclaimer.
  23705. 2. Redistributions in binary form must reproduce the above copyright notice,
  23706. this list of conditions, and the following disclaimer in the documentation
  23707. and/or other materials provided with the distribution.
  23708. 3. Neither the name of the University nor the names of its contributors may
  23709. be used to endorse or promote products derived from this software without
  23710. specific prior written permission.
  23711. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  23712. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  23713. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  23714. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  23715. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23716. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23717. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23718. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23719. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  23720. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23721. =============================================================================*/
  23722. #include <stdbool.h>
  23723. #include <stdint.h>
  23724. /**** skipping file: platform.h ****/
  23725. /**** skipping file: internals.h ****/
  23726. /**** skipping file: specialize.h ****/
  23727. /**** skipping file: softfloat.h ****/
  23728. float128_t f128_mul( float128_t a, float128_t b )
  23729. {
  23730. union ui128_f128 uA;
  23731. uint_fast64_t uiA64, uiA0;
  23732. bool signA;
  23733. int_fast32_t expA;
  23734. struct uint128 sigA;
  23735. union ui128_f128 uB;
  23736. uint_fast64_t uiB64, uiB0;
  23737. bool signB;
  23738. int_fast32_t expB;
  23739. struct uint128 sigB;
  23740. bool signZ;
  23741. uint_fast64_t magBits;
  23742. struct exp32_sig128 normExpSig;
  23743. int_fast32_t expZ;
  23744. uint64_t sig256Z[4];
  23745. uint_fast64_t sigZExtra;
  23746. struct uint128 sigZ;
  23747. struct uint128_extra sig128Extra;
  23748. struct uint128 uiZ;
  23749. union ui128_f128 uZ;
  23750. /*------------------------------------------------------------------------
  23751. *------------------------------------------------------------------------*/
  23752. uA.f = a;
  23753. uiA64 = uA.ui.v64;
  23754. uiA0 = uA.ui.v0;
  23755. signA = signF128UI64( uiA64 );
  23756. expA = expF128UI64( uiA64 );
  23757. sigA.v64 = fracF128UI64( uiA64 );
  23758. sigA.v0 = uiA0;
  23759. uB.f = b;
  23760. uiB64 = uB.ui.v64;
  23761. uiB0 = uB.ui.v0;
  23762. signB = signF128UI64( uiB64 );
  23763. expB = expF128UI64( uiB64 );
  23764. sigB.v64 = fracF128UI64( uiB64 );
  23765. sigB.v0 = uiB0;
  23766. signZ = signA ^ signB;
  23767. /*------------------------------------------------------------------------
  23768. *------------------------------------------------------------------------*/
  23769. if ( expA == 0x7FFF ) {
  23770. if (
  23771. (sigA.v64 | sigA.v0) || ((expB == 0x7FFF) && (sigB.v64 | sigB.v0))
  23772. ) {
  23773. goto propagateNaN;
  23774. }
  23775. magBits = expB | sigB.v64 | sigB.v0;
  23776. goto infArg;
  23777. }
  23778. if ( expB == 0x7FFF ) {
  23779. if ( sigB.v64 | sigB.v0 ) goto propagateNaN;
  23780. magBits = expA | sigA.v64 | sigA.v0;
  23781. goto infArg;
  23782. }
  23783. /*------------------------------------------------------------------------
  23784. *------------------------------------------------------------------------*/
  23785. if ( ! expA ) {
  23786. if ( ! (sigA.v64 | sigA.v0) ) goto zero;
  23787. normExpSig = softfloat_normSubnormalF128Sig( sigA.v64, sigA.v0 );
  23788. expA = normExpSig.exp;
  23789. sigA = normExpSig.sig;
  23790. }
  23791. if ( ! expB ) {
  23792. if ( ! (sigB.v64 | sigB.v0) ) goto zero;
  23793. normExpSig = softfloat_normSubnormalF128Sig( sigB.v64, sigB.v0 );
  23794. expB = normExpSig.exp;
  23795. sigB = normExpSig.sig;
  23796. }
  23797. /*------------------------------------------------------------------------
  23798. *------------------------------------------------------------------------*/
  23799. expZ = expA + expB - 0x4000;
  23800. sigA.v64 |= UINT64_C( 0x0001000000000000 );
  23801. sigB = softfloat_shortShiftLeft128( sigB.v64, sigB.v0, 16 );
  23802. softfloat_mul128To256M( sigA.v64, sigA.v0, sigB.v64, sigB.v0, sig256Z );
  23803. sigZExtra = sig256Z[indexWord( 4, 1 )] | (sig256Z[indexWord( 4, 0 )] != 0);
  23804. sigZ =
  23805. softfloat_add128(
  23806. sig256Z[indexWord( 4, 3 )], sig256Z[indexWord( 4, 2 )],
  23807. sigA.v64, sigA.v0
  23808. );
  23809. if ( UINT64_C( 0x0002000000000000 ) <= sigZ.v64 ) {
  23810. ++expZ;
  23811. sig128Extra =
  23812. softfloat_shortShiftRightJam128Extra(
  23813. sigZ.v64, sigZ.v0, sigZExtra, 1 );
  23814. sigZ = sig128Extra.v;
  23815. sigZExtra = sig128Extra.extra;
  23816. }
  23817. return
  23818. softfloat_roundPackToF128( signZ, expZ, sigZ.v64, sigZ.v0, sigZExtra );
  23819. /*------------------------------------------------------------------------
  23820. *------------------------------------------------------------------------*/
  23821. propagateNaN:
  23822. uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, uiB64, uiB0 );
  23823. goto uiZ;
  23824. /*------------------------------------------------------------------------
  23825. *------------------------------------------------------------------------*/
  23826. infArg:
  23827. if ( ! magBits ) {
  23828. softfloat_raiseFlags( softfloat_flag_invalid );
  23829. uiZ.v64 = defaultNaNF128UI64;
  23830. uiZ.v0 = defaultNaNF128UI0;
  23831. goto uiZ;
  23832. }
  23833. uiZ.v64 = packToF128UI64( signZ, 0x7FFF, 0 );
  23834. goto uiZ0;
  23835. /*------------------------------------------------------------------------
  23836. *------------------------------------------------------------------------*/
  23837. zero:
  23838. uiZ.v64 = packToF128UI64( signZ, 0, 0 );
  23839. uiZ0:
  23840. uiZ.v0 = 0;
  23841. uiZ:
  23842. uZ.ui = uiZ;
  23843. return uZ.f;
  23844. }
  23845. /**** ended inlining ../../source/f128_mul.c ****/
  23846. /**** start inlining ../../source/f128_mulAdd.c ****/
  23847. /*============================================================================
  23848. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  23849. Package, Release 3e, by John R. Hauser.
  23850. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  23851. All rights reserved.
  23852. Redistribution and use in source and binary forms, with or without
  23853. modification, are permitted provided that the following conditions are met:
  23854. 1. Redistributions of source code must retain the above copyright notice,
  23855. this list of conditions, and the following disclaimer.
  23856. 2. Redistributions in binary form must reproduce the above copyright notice,
  23857. this list of conditions, and the following disclaimer in the documentation
  23858. and/or other materials provided with the distribution.
  23859. 3. Neither the name of the University nor the names of its contributors may
  23860. be used to endorse or promote products derived from this software without
  23861. specific prior written permission.
  23862. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  23863. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  23864. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  23865. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  23866. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23867. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23868. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23869. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23870. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  23871. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23872. =============================================================================*/
  23873. #include <stdint.h>
  23874. /**** skipping file: platform.h ****/
  23875. /**** skipping file: internals.h ****/
  23876. /**** skipping file: softfloat.h ****/
  23877. float128_t f128_mulAdd( float128_t a, float128_t b, float128_t c )
  23878. {
  23879. union ui128_f128 uA;
  23880. uint_fast64_t uiA64, uiA0;
  23881. union ui128_f128 uB;
  23882. uint_fast64_t uiB64, uiB0;
  23883. union ui128_f128 uC;
  23884. uint_fast64_t uiC64, uiC0;
  23885. uA.f = a;
  23886. uiA64 = uA.ui.v64;
  23887. uiA0 = uA.ui.v0;
  23888. uB.f = b;
  23889. uiB64 = uB.ui.v64;
  23890. uiB0 = uB.ui.v0;
  23891. uC.f = c;
  23892. uiC64 = uC.ui.v64;
  23893. uiC0 = uC.ui.v0;
  23894. return softfloat_mulAddF128( uiA64, uiA0, uiB64, uiB0, uiC64, uiC0, 0 );
  23895. }
  23896. /**** ended inlining ../../source/f128_mulAdd.c ****/
  23897. /**** start inlining ../../source/f128_div.c ****/
  23898. /*============================================================================
  23899. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  23900. Package, Release 3e, by John R. Hauser.
  23901. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  23902. All rights reserved.
  23903. Redistribution and use in source and binary forms, with or without
  23904. modification, are permitted provided that the following conditions are met:
  23905. 1. Redistributions of source code must retain the above copyright notice,
  23906. this list of conditions, and the following disclaimer.
  23907. 2. Redistributions in binary form must reproduce the above copyright notice,
  23908. this list of conditions, and the following disclaimer in the documentation
  23909. and/or other materials provided with the distribution.
  23910. 3. Neither the name of the University nor the names of its contributors may
  23911. be used to endorse or promote products derived from this software without
  23912. specific prior written permission.
  23913. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  23914. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  23915. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  23916. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  23917. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23918. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23919. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23920. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23921. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  23922. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23923. =============================================================================*/
  23924. #include <stdbool.h>
  23925. #include <stdint.h>
  23926. /**** skipping file: platform.h ****/
  23927. /**** skipping file: internals.h ****/
  23928. /**** skipping file: specialize.h ****/
  23929. /**** skipping file: softfloat.h ****/
  23930. float128_t f128_div( float128_t a, float128_t b )
  23931. {
  23932. union ui128_f128 uA;
  23933. uint_fast64_t uiA64, uiA0;
  23934. bool signA;
  23935. int_fast32_t expA;
  23936. struct uint128 sigA;
  23937. union ui128_f128 uB;
  23938. uint_fast64_t uiB64, uiB0;
  23939. bool signB;
  23940. int_fast32_t expB;
  23941. struct uint128 sigB;
  23942. bool signZ;
  23943. struct exp32_sig128 normExpSig;
  23944. int_fast32_t expZ;
  23945. struct uint128 rem;
  23946. uint_fast32_t recip32;
  23947. int ix;
  23948. uint_fast64_t q64;
  23949. uint_fast32_t q;
  23950. struct uint128 term;
  23951. uint_fast32_t qs[3];
  23952. uint_fast64_t sigZExtra;
  23953. struct uint128 sigZ, uiZ;
  23954. union ui128_f128 uZ;
  23955. /*------------------------------------------------------------------------
  23956. *------------------------------------------------------------------------*/
  23957. uA.f = a;
  23958. uiA64 = uA.ui.v64;
  23959. uiA0 = uA.ui.v0;
  23960. signA = signF128UI64( uiA64 );
  23961. expA = expF128UI64( uiA64 );
  23962. sigA.v64 = fracF128UI64( uiA64 );
  23963. sigA.v0 = uiA0;
  23964. uB.f = b;
  23965. uiB64 = uB.ui.v64;
  23966. uiB0 = uB.ui.v0;
  23967. signB = signF128UI64( uiB64 );
  23968. expB = expF128UI64( uiB64 );
  23969. sigB.v64 = fracF128UI64( uiB64 );
  23970. sigB.v0 = uiB0;
  23971. signZ = signA ^ signB;
  23972. /*------------------------------------------------------------------------
  23973. *------------------------------------------------------------------------*/
  23974. if ( expA == 0x7FFF ) {
  23975. if ( sigA.v64 | sigA.v0 ) goto propagateNaN;
  23976. if ( expB == 0x7FFF ) {
  23977. if ( sigB.v64 | sigB.v0 ) goto propagateNaN;
  23978. goto invalid;
  23979. }
  23980. goto infinity;
  23981. }
  23982. if ( expB == 0x7FFF ) {
  23983. if ( sigB.v64 | sigB.v0 ) goto propagateNaN;
  23984. goto zero;
  23985. }
  23986. /*------------------------------------------------------------------------
  23987. *------------------------------------------------------------------------*/
  23988. if ( ! expB ) {
  23989. if ( ! (sigB.v64 | sigB.v0) ) {
  23990. if ( ! (expA | sigA.v64 | sigA.v0) ) goto invalid;
  23991. softfloat_raiseFlags( softfloat_flag_infinite );
  23992. goto infinity;
  23993. }
  23994. normExpSig = softfloat_normSubnormalF128Sig( sigB.v64, sigB.v0 );
  23995. expB = normExpSig.exp;
  23996. sigB = normExpSig.sig;
  23997. }
  23998. if ( ! expA ) {
  23999. if ( ! (sigA.v64 | sigA.v0) ) goto zero;
  24000. normExpSig = softfloat_normSubnormalF128Sig( sigA.v64, sigA.v0 );
  24001. expA = normExpSig.exp;
  24002. sigA = normExpSig.sig;
  24003. }
  24004. /*------------------------------------------------------------------------
  24005. *------------------------------------------------------------------------*/
  24006. expZ = expA - expB + 0x3FFE;
  24007. sigA.v64 |= UINT64_C( 0x0001000000000000 );
  24008. sigB.v64 |= UINT64_C( 0x0001000000000000 );
  24009. rem = sigA;
  24010. if ( softfloat_lt128( sigA.v64, sigA.v0, sigB.v64, sigB.v0 ) ) {
  24011. --expZ;
  24012. rem = softfloat_add128( sigA.v64, sigA.v0, sigA.v64, sigA.v0 );
  24013. }
  24014. recip32 = softfloat_approxRecip32_1( sigB.v64>>17 );
  24015. ix = 3;
  24016. for (;;) {
  24017. q64 = (uint_fast64_t) (uint32_t) (rem.v64>>19) * recip32;
  24018. q = (q64 + 0x80000000)>>32;
  24019. --ix;
  24020. if ( ix < 0 ) break;
  24021. rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
  24022. term = softfloat_mul128By32( sigB.v64, sigB.v0, q );
  24023. rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
  24024. if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
  24025. --q;
  24026. rem = softfloat_add128( rem.v64, rem.v0, sigB.v64, sigB.v0 );
  24027. }
  24028. qs[ix] = q;
  24029. }
  24030. /*------------------------------------------------------------------------
  24031. *------------------------------------------------------------------------*/
  24032. if ( ((q + 1) & 7) < 2 ) {
  24033. rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
  24034. term = softfloat_mul128By32( sigB.v64, sigB.v0, q );
  24035. rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
  24036. if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
  24037. --q;
  24038. rem = softfloat_add128( rem.v64, rem.v0, sigB.v64, sigB.v0 );
  24039. } else if ( softfloat_le128( sigB.v64, sigB.v0, rem.v64, rem.v0 ) ) {
  24040. ++q;
  24041. rem = softfloat_sub128( rem.v64, rem.v0, sigB.v64, sigB.v0 );
  24042. }
  24043. if ( rem.v64 | rem.v0 ) q |= 1;
  24044. }
  24045. /*------------------------------------------------------------------------
  24046. *------------------------------------------------------------------------*/
  24047. sigZExtra = (uint64_t) ((uint_fast64_t) q<<60);
  24048. term = softfloat_shortShiftLeft128( 0, qs[1], 54 );
  24049. sigZ =
  24050. softfloat_add128(
  24051. (uint_fast64_t) qs[2]<<19, ((uint_fast64_t) qs[0]<<25) + (q>>4),
  24052. term.v64, term.v0
  24053. );
  24054. return
  24055. softfloat_roundPackToF128( signZ, expZ, sigZ.v64, sigZ.v0, sigZExtra );
  24056. /*------------------------------------------------------------------------
  24057. *------------------------------------------------------------------------*/
  24058. propagateNaN:
  24059. uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, uiB64, uiB0 );
  24060. goto uiZ;
  24061. /*------------------------------------------------------------------------
  24062. *------------------------------------------------------------------------*/
  24063. invalid:
  24064. softfloat_raiseFlags( softfloat_flag_invalid );
  24065. uiZ.v64 = defaultNaNF128UI64;
  24066. uiZ.v0 = defaultNaNF128UI0;
  24067. goto uiZ;
  24068. /*------------------------------------------------------------------------
  24069. *------------------------------------------------------------------------*/
  24070. infinity:
  24071. uiZ.v64 = packToF128UI64( signZ, 0x7FFF, 0 );
  24072. goto uiZ0;
  24073. /*------------------------------------------------------------------------
  24074. *------------------------------------------------------------------------*/
  24075. zero:
  24076. uiZ.v64 = packToF128UI64( signZ, 0, 0 );
  24077. uiZ0:
  24078. uiZ.v0 = 0;
  24079. uiZ:
  24080. uZ.ui = uiZ;
  24081. return uZ.f;
  24082. }
  24083. /**** ended inlining ../../source/f128_div.c ****/
  24084. /**** start inlining ../../source/f128_rem.c ****/
  24085. /*============================================================================
  24086. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  24087. Package, Release 3e, by John R. Hauser.
  24088. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  24089. California. All rights reserved.
  24090. Redistribution and use in source and binary forms, with or without
  24091. modification, are permitted provided that the following conditions are met:
  24092. 1. Redistributions of source code must retain the above copyright notice,
  24093. this list of conditions, and the following disclaimer.
  24094. 2. Redistributions in binary form must reproduce the above copyright notice,
  24095. this list of conditions, and the following disclaimer in the documentation
  24096. and/or other materials provided with the distribution.
  24097. 3. Neither the name of the University nor the names of its contributors may
  24098. be used to endorse or promote products derived from this software without
  24099. specific prior written permission.
  24100. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  24101. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  24102. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  24103. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  24104. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24105. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24106. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24107. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24108. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  24109. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24110. =============================================================================*/
  24111. #include <stdbool.h>
  24112. #include <stdint.h>
  24113. /**** skipping file: platform.h ****/
  24114. /**** skipping file: internals.h ****/
  24115. /**** skipping file: specialize.h ****/
  24116. /**** skipping file: softfloat.h ****/
  24117. float128_t f128_rem( float128_t a, float128_t b )
  24118. {
  24119. union ui128_f128 uA;
  24120. uint_fast64_t uiA64, uiA0;
  24121. bool signA;
  24122. int_fast32_t expA;
  24123. struct uint128 sigA;
  24124. union ui128_f128 uB;
  24125. uint_fast64_t uiB64, uiB0;
  24126. int_fast32_t expB;
  24127. struct uint128 sigB;
  24128. struct exp32_sig128 normExpSig;
  24129. struct uint128 rem;
  24130. int_fast32_t expDiff;
  24131. uint_fast32_t q, recip32;
  24132. uint_fast64_t q64;
  24133. struct uint128 term, altRem, meanRem;
  24134. bool signRem;
  24135. struct uint128 uiZ;
  24136. union ui128_f128 uZ;
  24137. /*------------------------------------------------------------------------
  24138. *------------------------------------------------------------------------*/
  24139. uA.f = a;
  24140. uiA64 = uA.ui.v64;
  24141. uiA0 = uA.ui.v0;
  24142. signA = signF128UI64( uiA64 );
  24143. expA = expF128UI64( uiA64 );
  24144. sigA.v64 = fracF128UI64( uiA64 );
  24145. sigA.v0 = uiA0;
  24146. uB.f = b;
  24147. uiB64 = uB.ui.v64;
  24148. uiB0 = uB.ui.v0;
  24149. expB = expF128UI64( uiB64 );
  24150. sigB.v64 = fracF128UI64( uiB64 );
  24151. sigB.v0 = uiB0;
  24152. /*------------------------------------------------------------------------
  24153. *------------------------------------------------------------------------*/
  24154. if ( expA == 0x7FFF ) {
  24155. if (
  24156. (sigA.v64 | sigA.v0) || ((expB == 0x7FFF) && (sigB.v64 | sigB.v0))
  24157. ) {
  24158. goto propagateNaN;
  24159. }
  24160. goto invalid;
  24161. }
  24162. if ( expB == 0x7FFF ) {
  24163. if ( sigB.v64 | sigB.v0 ) goto propagateNaN;
  24164. return a;
  24165. }
  24166. /*------------------------------------------------------------------------
  24167. *------------------------------------------------------------------------*/
  24168. if ( ! expB ) {
  24169. if ( ! (sigB.v64 | sigB.v0) ) goto invalid;
  24170. normExpSig = softfloat_normSubnormalF128Sig( sigB.v64, sigB.v0 );
  24171. expB = normExpSig.exp;
  24172. sigB = normExpSig.sig;
  24173. }
  24174. if ( ! expA ) {
  24175. if ( ! (sigA.v64 | sigA.v0) ) return a;
  24176. normExpSig = softfloat_normSubnormalF128Sig( sigA.v64, sigA.v0 );
  24177. expA = normExpSig.exp;
  24178. sigA = normExpSig.sig;
  24179. }
  24180. /*------------------------------------------------------------------------
  24181. *------------------------------------------------------------------------*/
  24182. sigA.v64 |= UINT64_C( 0x0001000000000000 );
  24183. sigB.v64 |= UINT64_C( 0x0001000000000000 );
  24184. rem = sigA;
  24185. expDiff = expA - expB;
  24186. if ( expDiff < 1 ) {
  24187. if ( expDiff < -1 ) return a;
  24188. if ( expDiff ) {
  24189. --expB;
  24190. sigB = softfloat_add128( sigB.v64, sigB.v0, sigB.v64, sigB.v0 );
  24191. q = 0;
  24192. } else {
  24193. q = softfloat_le128( sigB.v64, sigB.v0, rem.v64, rem.v0 );
  24194. if ( q ) {
  24195. rem = softfloat_sub128( rem.v64, rem.v0, sigB.v64, sigB.v0 );
  24196. }
  24197. }
  24198. } else {
  24199. recip32 = softfloat_approxRecip32_1( sigB.v64>>17 );
  24200. expDiff -= 30;
  24201. for (;;) {
  24202. q64 = (uint_fast64_t) (uint32_t) (rem.v64>>19) * recip32;
  24203. if ( expDiff < 0 ) break;
  24204. q = (q64 + 0x80000000)>>32;
  24205. rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
  24206. term = softfloat_mul128By32( sigB.v64, sigB.v0, q );
  24207. rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
  24208. if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
  24209. rem = softfloat_add128( rem.v64, rem.v0, sigB.v64, sigB.v0 );
  24210. }
  24211. expDiff -= 29;
  24212. }
  24213. /*--------------------------------------------------------------------
  24214. | (`expDiff' cannot be less than -29 here.)
  24215. *--------------------------------------------------------------------*/
  24216. q = (uint32_t) (q64>>32)>>(~expDiff & 31);
  24217. rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, expDiff + 30 );
  24218. term = softfloat_mul128By32( sigB.v64, sigB.v0, q );
  24219. rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
  24220. if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
  24221. altRem = softfloat_add128( rem.v64, rem.v0, sigB.v64, sigB.v0 );
  24222. goto selectRem;
  24223. }
  24224. }
  24225. /*------------------------------------------------------------------------
  24226. *------------------------------------------------------------------------*/
  24227. do {
  24228. altRem = rem;
  24229. ++q;
  24230. rem = softfloat_sub128( rem.v64, rem.v0, sigB.v64, sigB.v0 );
  24231. } while ( ! (rem.v64 & UINT64_C( 0x8000000000000000 )) );
  24232. selectRem:
  24233. meanRem = softfloat_add128( rem.v64, rem.v0, altRem.v64, altRem.v0 );
  24234. if (
  24235. (meanRem.v64 & UINT64_C( 0x8000000000000000 ))
  24236. || (! (meanRem.v64 | meanRem.v0) && (q & 1))
  24237. ) {
  24238. rem = altRem;
  24239. }
  24240. signRem = signA;
  24241. if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
  24242. signRem = ! signRem;
  24243. rem = softfloat_sub128( 0, 0, rem.v64, rem.v0 );
  24244. }
  24245. return softfloat_normRoundPackToF128( signRem, expB - 1, rem.v64, rem.v0 );
  24246. /*------------------------------------------------------------------------
  24247. *------------------------------------------------------------------------*/
  24248. propagateNaN:
  24249. uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, uiB64, uiB0 );
  24250. goto uiZ;
  24251. /*------------------------------------------------------------------------
  24252. *------------------------------------------------------------------------*/
  24253. invalid:
  24254. softfloat_raiseFlags( softfloat_flag_invalid );
  24255. uiZ.v64 = defaultNaNF128UI64;
  24256. uiZ.v0 = defaultNaNF128UI0;
  24257. uiZ:
  24258. uZ.ui = uiZ;
  24259. return uZ.f;
  24260. }
  24261. /**** ended inlining ../../source/f128_rem.c ****/
  24262. /**** start inlining ../../source/f128_sqrt.c ****/
  24263. /*============================================================================
  24264. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  24265. Package, Release 3e, by John R. Hauser.
  24266. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  24267. University of California. All rights reserved.
  24268. Redistribution and use in source and binary forms, with or without
  24269. modification, are permitted provided that the following conditions are met:
  24270. 1. Redistributions of source code must retain the above copyright notice,
  24271. this list of conditions, and the following disclaimer.
  24272. 2. Redistributions in binary form must reproduce the above copyright notice,
  24273. this list of conditions, and the following disclaimer in the documentation
  24274. and/or other materials provided with the distribution.
  24275. 3. Neither the name of the University nor the names of its contributors may
  24276. be used to endorse or promote products derived from this software without
  24277. specific prior written permission.
  24278. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  24279. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  24280. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  24281. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  24282. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24283. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24284. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24285. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24286. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  24287. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24288. =============================================================================*/
  24289. #include <stdbool.h>
  24290. #include <stdint.h>
  24291. /**** skipping file: platform.h ****/
  24292. /**** skipping file: internals.h ****/
  24293. /**** skipping file: specialize.h ****/
  24294. /**** skipping file: softfloat.h ****/
  24295. float128_t f128_sqrt( float128_t a )
  24296. {
  24297. union ui128_f128 uA;
  24298. uint_fast64_t uiA64, uiA0;
  24299. bool signA;
  24300. int_fast32_t expA;
  24301. struct uint128 sigA, uiZ;
  24302. struct exp32_sig128 normExpSig;
  24303. int_fast32_t expZ;
  24304. uint_fast32_t sig32A, recipSqrt32, sig32Z;
  24305. struct uint128 rem;
  24306. uint32_t qs[3];
  24307. uint_fast32_t q;
  24308. uint_fast64_t x64, sig64Z;
  24309. struct uint128 y, term;
  24310. uint_fast64_t sigZExtra;
  24311. struct uint128 sigZ;
  24312. union ui128_f128 uZ;
  24313. /*------------------------------------------------------------------------
  24314. *------------------------------------------------------------------------*/
  24315. uA.f = a;
  24316. uiA64 = uA.ui.v64;
  24317. uiA0 = uA.ui.v0;
  24318. signA = signF128UI64( uiA64 );
  24319. expA = expF128UI64( uiA64 );
  24320. sigA.v64 = fracF128UI64( uiA64 );
  24321. sigA.v0 = uiA0;
  24322. /*------------------------------------------------------------------------
  24323. *------------------------------------------------------------------------*/
  24324. if ( expA == 0x7FFF ) {
  24325. if ( sigA.v64 | sigA.v0 ) {
  24326. uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, 0, 0 );
  24327. goto uiZ;
  24328. }
  24329. if ( ! signA ) return a;
  24330. goto invalid;
  24331. }
  24332. /*------------------------------------------------------------------------
  24333. *------------------------------------------------------------------------*/
  24334. if ( signA ) {
  24335. if ( ! (expA | sigA.v64 | sigA.v0) ) return a;
  24336. goto invalid;
  24337. }
  24338. /*------------------------------------------------------------------------
  24339. *------------------------------------------------------------------------*/
  24340. if ( ! expA ) {
  24341. if ( ! (sigA.v64 | sigA.v0) ) return a;
  24342. normExpSig = softfloat_normSubnormalF128Sig( sigA.v64, sigA.v0 );
  24343. expA = normExpSig.exp;
  24344. sigA = normExpSig.sig;
  24345. }
  24346. /*------------------------------------------------------------------------
  24347. | (`sig32Z' is guaranteed to be a lower bound on the square root of
  24348. | `sig32A', which makes `sig32Z' also a lower bound on the square root of
  24349. | `sigA'.)
  24350. *------------------------------------------------------------------------*/
  24351. expZ = ((expA - 0x3FFF)>>1) + 0x3FFE;
  24352. expA &= 1;
  24353. sigA.v64 |= UINT64_C( 0x0001000000000000 );
  24354. sig32A = sigA.v64>>17;
  24355. recipSqrt32 = softfloat_approxRecipSqrt32_1( expA, sig32A );
  24356. sig32Z = ((uint_fast64_t) sig32A * recipSqrt32)>>32;
  24357. if ( expA ) {
  24358. sig32Z >>= 1;
  24359. rem = softfloat_shortShiftLeft128( sigA.v64, sigA.v0, 12 );
  24360. } else {
  24361. rem = softfloat_shortShiftLeft128( sigA.v64, sigA.v0, 13 );
  24362. }
  24363. qs[2] = sig32Z;
  24364. rem.v64 -= (uint_fast64_t) sig32Z * sig32Z;
  24365. /*------------------------------------------------------------------------
  24366. *------------------------------------------------------------------------*/
  24367. q = ((uint32_t) (rem.v64>>2) * (uint_fast64_t) recipSqrt32)>>32;
  24368. x64 = (uint_fast64_t) sig32Z<<32;
  24369. sig64Z = x64 + ((uint_fast64_t) q<<3);
  24370. y = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
  24371. /*------------------------------------------------------------------------
  24372. | (Repeating this loop is a rare occurrence.)
  24373. *------------------------------------------------------------------------*/
  24374. for (;;) {
  24375. term = softfloat_mul64ByShifted32To128( x64 + sig64Z, q );
  24376. rem = softfloat_sub128( y.v64, y.v0, term.v64, term.v0 );
  24377. if ( ! (rem.v64 & UINT64_C( 0x8000000000000000 )) ) break;
  24378. --q;
  24379. sig64Z -= 1<<3;
  24380. }
  24381. qs[1] = q;
  24382. /*------------------------------------------------------------------------
  24383. *------------------------------------------------------------------------*/
  24384. q = ((rem.v64>>2) * recipSqrt32)>>32;
  24385. y = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
  24386. sig64Z <<= 1;
  24387. /*------------------------------------------------------------------------
  24388. | (Repeating this loop is a rare occurrence.)
  24389. *------------------------------------------------------------------------*/
  24390. for (;;) {
  24391. term = softfloat_shortShiftLeft128( 0, sig64Z, 32 );
  24392. term = softfloat_add128( term.v64, term.v0, 0, (uint_fast64_t) q<<6 );
  24393. term = softfloat_mul128By32( term.v64, term.v0, q );
  24394. rem = softfloat_sub128( y.v64, y.v0, term.v64, term.v0 );
  24395. if ( ! (rem.v64 & UINT64_C( 0x8000000000000000 )) ) break;
  24396. --q;
  24397. }
  24398. qs[0] = q;
  24399. /*------------------------------------------------------------------------
  24400. *------------------------------------------------------------------------*/
  24401. q = (((rem.v64>>2) * recipSqrt32)>>32) + 2;
  24402. sigZExtra = (uint64_t) ((uint_fast64_t) q<<59);
  24403. term = softfloat_shortShiftLeft128( 0, qs[1], 53 );
  24404. sigZ =
  24405. softfloat_add128(
  24406. (uint_fast64_t) qs[2]<<18, ((uint_fast64_t) qs[0]<<24) + (q>>5),
  24407. term.v64, term.v0
  24408. );
  24409. /*------------------------------------------------------------------------
  24410. *------------------------------------------------------------------------*/
  24411. if ( (q & 0xF) <= 2 ) {
  24412. q &= ~3;
  24413. sigZExtra = (uint64_t) ((uint_fast64_t) q<<59);
  24414. y = softfloat_shortShiftLeft128( sigZ.v64, sigZ.v0, 6 );
  24415. y.v0 |= sigZExtra>>58;
  24416. term = softfloat_sub128( y.v64, y.v0, 0, q );
  24417. y = softfloat_mul64ByShifted32To128( term.v0, q );
  24418. term = softfloat_mul64ByShifted32To128( term.v64, q );
  24419. term = softfloat_add128( term.v64, term.v0, 0, y.v64 );
  24420. rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 20 );
  24421. term = softfloat_sub128( term.v64, term.v0, rem.v64, rem.v0 );
  24422. /*--------------------------------------------------------------------
  24423. | The concatenation of `term' and `y.v0' is now the negative remainder
  24424. | (3 words altogether).
  24425. *--------------------------------------------------------------------*/
  24426. if ( term.v64 & UINT64_C( 0x8000000000000000 ) ) {
  24427. sigZExtra |= 1;
  24428. } else {
  24429. if ( term.v64 | term.v0 | y.v0 ) {
  24430. if ( sigZExtra ) {
  24431. --sigZExtra;
  24432. } else {
  24433. sigZ = softfloat_sub128( sigZ.v64, sigZ.v0, 0, 1 );
  24434. sigZExtra = ~0;
  24435. }
  24436. }
  24437. }
  24438. }
  24439. return softfloat_roundPackToF128( 0, expZ, sigZ.v64, sigZ.v0, sigZExtra );
  24440. /*------------------------------------------------------------------------
  24441. *------------------------------------------------------------------------*/
  24442. invalid:
  24443. softfloat_raiseFlags( softfloat_flag_invalid );
  24444. uiZ.v64 = defaultNaNF128UI64;
  24445. uiZ.v0 = defaultNaNF128UI0;
  24446. uiZ:
  24447. uZ.ui = uiZ;
  24448. return uZ.f;
  24449. }
  24450. /**** ended inlining ../../source/f128_sqrt.c ****/
  24451. /**** start inlining ../../source/f128_eq.c ****/
  24452. /*============================================================================
  24453. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  24454. Package, Release 3e, by John R. Hauser.
  24455. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  24456. All rights reserved.
  24457. Redistribution and use in source and binary forms, with or without
  24458. modification, are permitted provided that the following conditions are met:
  24459. 1. Redistributions of source code must retain the above copyright notice,
  24460. this list of conditions, and the following disclaimer.
  24461. 2. Redistributions in binary form must reproduce the above copyright notice,
  24462. this list of conditions, and the following disclaimer in the documentation
  24463. and/or other materials provided with the distribution.
  24464. 3. Neither the name of the University nor the names of its contributors may
  24465. be used to endorse or promote products derived from this software without
  24466. specific prior written permission.
  24467. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  24468. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  24469. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  24470. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  24471. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24472. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24473. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24474. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24475. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  24476. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24477. =============================================================================*/
  24478. #include <stdbool.h>
  24479. #include <stdint.h>
  24480. /**** skipping file: platform.h ****/
  24481. /**** skipping file: internals.h ****/
  24482. /**** skipping file: specialize.h ****/
  24483. /**** skipping file: softfloat.h ****/
  24484. bool f128_eq( float128_t a, float128_t b )
  24485. {
  24486. union ui128_f128 uA;
  24487. uint_fast64_t uiA64, uiA0;
  24488. union ui128_f128 uB;
  24489. uint_fast64_t uiB64, uiB0;
  24490. uA.f = a;
  24491. uiA64 = uA.ui.v64;
  24492. uiA0 = uA.ui.v0;
  24493. uB.f = b;
  24494. uiB64 = uB.ui.v64;
  24495. uiB0 = uB.ui.v0;
  24496. if ( isNaNF128UI( uiA64, uiA0 ) || isNaNF128UI( uiB64, uiB0 ) ) {
  24497. if (
  24498. softfloat_isSigNaNF128UI( uiA64, uiA0 )
  24499. || softfloat_isSigNaNF128UI( uiB64, uiB0 )
  24500. ) {
  24501. softfloat_raiseFlags( softfloat_flag_invalid );
  24502. }
  24503. return false;
  24504. }
  24505. return
  24506. (uiA0 == uiB0)
  24507. && ( (uiA64 == uiB64)
  24508. || (! uiA0 && ! ((uiA64 | uiB64) & UINT64_C( 0x7FFFFFFFFFFFFFFF )))
  24509. );
  24510. }
  24511. /**** ended inlining ../../source/f128_eq.c ****/
  24512. /**** start inlining ../../source/f128_le.c ****/
  24513. /*============================================================================
  24514. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  24515. Package, Release 3e, by John R. Hauser.
  24516. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  24517. All rights reserved.
  24518. Redistribution and use in source and binary forms, with or without
  24519. modification, are permitted provided that the following conditions are met:
  24520. 1. Redistributions of source code must retain the above copyright notice,
  24521. this list of conditions, and the following disclaimer.
  24522. 2. Redistributions in binary form must reproduce the above copyright notice,
  24523. this list of conditions, and the following disclaimer in the documentation
  24524. and/or other materials provided with the distribution.
  24525. 3. Neither the name of the University nor the names of its contributors may
  24526. be used to endorse or promote products derived from this software without
  24527. specific prior written permission.
  24528. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  24529. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  24530. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  24531. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  24532. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24533. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24534. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24535. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24536. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  24537. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24538. =============================================================================*/
  24539. #include <stdbool.h>
  24540. #include <stdint.h>
  24541. /**** skipping file: platform.h ****/
  24542. /**** skipping file: internals.h ****/
  24543. /**** skipping file: softfloat.h ****/
  24544. bool f128_le( float128_t a, float128_t b )
  24545. {
  24546. union ui128_f128 uA;
  24547. uint_fast64_t uiA64, uiA0;
  24548. union ui128_f128 uB;
  24549. uint_fast64_t uiB64, uiB0;
  24550. bool signA, signB;
  24551. uA.f = a;
  24552. uiA64 = uA.ui.v64;
  24553. uiA0 = uA.ui.v0;
  24554. uB.f = b;
  24555. uiB64 = uB.ui.v64;
  24556. uiB0 = uB.ui.v0;
  24557. if ( isNaNF128UI( uiA64, uiA0 ) || isNaNF128UI( uiB64, uiB0 ) ) {
  24558. softfloat_raiseFlags( softfloat_flag_invalid );
  24559. return false;
  24560. }
  24561. signA = signF128UI64( uiA64 );
  24562. signB = signF128UI64( uiB64 );
  24563. return
  24564. (signA != signB)
  24565. ? signA
  24566. || ! (((uiA64 | uiB64) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
  24567. | uiA0 | uiB0)
  24568. : ((uiA64 == uiB64) && (uiA0 == uiB0))
  24569. || (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
  24570. }
  24571. /**** ended inlining ../../source/f128_le.c ****/
  24572. /**** start inlining ../../source/f128_lt.c ****/
  24573. /*============================================================================
  24574. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  24575. Package, Release 3e, by John R. Hauser.
  24576. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  24577. All rights reserved.
  24578. Redistribution and use in source and binary forms, with or without
  24579. modification, are permitted provided that the following conditions are met:
  24580. 1. Redistributions of source code must retain the above copyright notice,
  24581. this list of conditions, and the following disclaimer.
  24582. 2. Redistributions in binary form must reproduce the above copyright notice,
  24583. this list of conditions, and the following disclaimer in the documentation
  24584. and/or other materials provided with the distribution.
  24585. 3. Neither the name of the University nor the names of its contributors may
  24586. be used to endorse or promote products derived from this software without
  24587. specific prior written permission.
  24588. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  24589. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  24590. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  24591. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  24592. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24593. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24594. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24595. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24596. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  24597. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24598. =============================================================================*/
  24599. #include <stdbool.h>
  24600. #include <stdint.h>
  24601. /**** skipping file: platform.h ****/
  24602. /**** skipping file: internals.h ****/
  24603. /**** skipping file: softfloat.h ****/
  24604. bool f128_lt( float128_t a, float128_t b )
  24605. {
  24606. union ui128_f128 uA;
  24607. uint_fast64_t uiA64, uiA0;
  24608. union ui128_f128 uB;
  24609. uint_fast64_t uiB64, uiB0;
  24610. bool signA, signB;
  24611. uA.f = a;
  24612. uiA64 = uA.ui.v64;
  24613. uiA0 = uA.ui.v0;
  24614. uB.f = b;
  24615. uiB64 = uB.ui.v64;
  24616. uiB0 = uB.ui.v0;
  24617. if ( isNaNF128UI( uiA64, uiA0 ) || isNaNF128UI( uiB64, uiB0 ) ) {
  24618. softfloat_raiseFlags( softfloat_flag_invalid );
  24619. return false;
  24620. }
  24621. signA = signF128UI64( uiA64 );
  24622. signB = signF128UI64( uiB64 );
  24623. return
  24624. (signA != signB)
  24625. ? signA
  24626. && (((uiA64 | uiB64) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
  24627. | uiA0 | uiB0)
  24628. : ((uiA64 != uiB64) || (uiA0 != uiB0))
  24629. && (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
  24630. }
  24631. /**** ended inlining ../../source/f128_lt.c ****/
  24632. /**** start inlining ../../source/f128_eq_signaling.c ****/
  24633. /*============================================================================
  24634. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  24635. Package, Release 3e, by John R. Hauser.
  24636. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  24637. All rights reserved.
  24638. Redistribution and use in source and binary forms, with or without
  24639. modification, are permitted provided that the following conditions are met:
  24640. 1. Redistributions of source code must retain the above copyright notice,
  24641. this list of conditions, and the following disclaimer.
  24642. 2. Redistributions in binary form must reproduce the above copyright notice,
  24643. this list of conditions, and the following disclaimer in the documentation
  24644. and/or other materials provided with the distribution.
  24645. 3. Neither the name of the University nor the names of its contributors may
  24646. be used to endorse or promote products derived from this software without
  24647. specific prior written permission.
  24648. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  24649. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  24650. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  24651. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  24652. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24653. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24654. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24655. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24656. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  24657. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24658. =============================================================================*/
  24659. #include <stdbool.h>
  24660. #include <stdint.h>
  24661. /**** skipping file: platform.h ****/
  24662. /**** skipping file: internals.h ****/
  24663. /**** skipping file: softfloat.h ****/
  24664. bool f128_eq_signaling( float128_t a, float128_t b )
  24665. {
  24666. union ui128_f128 uA;
  24667. uint_fast64_t uiA64, uiA0;
  24668. union ui128_f128 uB;
  24669. uint_fast64_t uiB64, uiB0;
  24670. uA.f = a;
  24671. uiA64 = uA.ui.v64;
  24672. uiA0 = uA.ui.v0;
  24673. uB.f = b;
  24674. uiB64 = uB.ui.v64;
  24675. uiB0 = uB.ui.v0;
  24676. if ( isNaNF128UI( uiA64, uiA0 ) || isNaNF128UI( uiB64, uiB0 ) ) {
  24677. softfloat_raiseFlags( softfloat_flag_invalid );
  24678. return false;
  24679. }
  24680. return
  24681. (uiA0 == uiB0)
  24682. && ( (uiA64 == uiB64)
  24683. || (! uiA0 && ! ((uiA64 | uiB64) & UINT64_C( 0x7FFFFFFFFFFFFFFF )))
  24684. );
  24685. }
  24686. /**** ended inlining ../../source/f128_eq_signaling.c ****/
  24687. /**** start inlining ../../source/f128_le_quiet.c ****/
  24688. /*============================================================================
  24689. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  24690. Package, Release 3e, by John R. Hauser.
  24691. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  24692. All rights reserved.
  24693. Redistribution and use in source and binary forms, with or without
  24694. modification, are permitted provided that the following conditions are met:
  24695. 1. Redistributions of source code must retain the above copyright notice,
  24696. this list of conditions, and the following disclaimer.
  24697. 2. Redistributions in binary form must reproduce the above copyright notice,
  24698. this list of conditions, and the following disclaimer in the documentation
  24699. and/or other materials provided with the distribution.
  24700. 3. Neither the name of the University nor the names of its contributors may
  24701. be used to endorse or promote products derived from this software without
  24702. specific prior written permission.
  24703. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  24704. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  24705. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  24706. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  24707. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24708. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24709. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24710. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24711. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  24712. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24713. =============================================================================*/
  24714. #include <stdbool.h>
  24715. #include <stdint.h>
  24716. /**** skipping file: platform.h ****/
  24717. /**** skipping file: internals.h ****/
  24718. /**** skipping file: specialize.h ****/
  24719. /**** skipping file: softfloat.h ****/
  24720. bool f128_le_quiet( float128_t a, float128_t b )
  24721. {
  24722. union ui128_f128 uA;
  24723. uint_fast64_t uiA64, uiA0;
  24724. union ui128_f128 uB;
  24725. uint_fast64_t uiB64, uiB0;
  24726. bool signA, signB;
  24727. uA.f = a;
  24728. uiA64 = uA.ui.v64;
  24729. uiA0 = uA.ui.v0;
  24730. uB.f = b;
  24731. uiB64 = uB.ui.v64;
  24732. uiB0 = uB.ui.v0;
  24733. if ( isNaNF128UI( uiA64, uiA0 ) || isNaNF128UI( uiB64, uiB0 ) ) {
  24734. if (
  24735. softfloat_isSigNaNF128UI( uiA64, uiA0 )
  24736. || softfloat_isSigNaNF128UI( uiB64, uiB0 )
  24737. ) {
  24738. softfloat_raiseFlags( softfloat_flag_invalid );
  24739. }
  24740. return false;
  24741. }
  24742. signA = signF128UI64( uiA64 );
  24743. signB = signF128UI64( uiB64 );
  24744. return
  24745. (signA != signB)
  24746. ? signA
  24747. || ! (((uiA64 | uiB64) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
  24748. | uiA0 | uiB0)
  24749. : ((uiA64 == uiB64) && (uiA0 == uiB0))
  24750. || (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
  24751. }
  24752. /**** ended inlining ../../source/f128_le_quiet.c ****/
  24753. /**** start inlining ../../source/f128_lt_quiet.c ****/
  24754. /*============================================================================
  24755. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  24756. Package, Release 3e, by John R. Hauser.
  24757. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  24758. All rights reserved.
  24759. Redistribution and use in source and binary forms, with or without
  24760. modification, are permitted provided that the following conditions are met:
  24761. 1. Redistributions of source code must retain the above copyright notice,
  24762. this list of conditions, and the following disclaimer.
  24763. 2. Redistributions in binary form must reproduce the above copyright notice,
  24764. this list of conditions, and the following disclaimer in the documentation
  24765. and/or other materials provided with the distribution.
  24766. 3. Neither the name of the University nor the names of its contributors may
  24767. be used to endorse or promote products derived from this software without
  24768. specific prior written permission.
  24769. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  24770. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  24771. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  24772. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  24773. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24774. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24775. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24776. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24777. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  24778. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24779. =============================================================================*/
  24780. #include <stdbool.h>
  24781. #include <stdint.h>
  24782. /**** skipping file: platform.h ****/
  24783. /**** skipping file: internals.h ****/
  24784. /**** skipping file: specialize.h ****/
  24785. /**** skipping file: softfloat.h ****/
  24786. bool f128_lt_quiet( float128_t a, float128_t b )
  24787. {
  24788. union ui128_f128 uA;
  24789. uint_fast64_t uiA64, uiA0;
  24790. union ui128_f128 uB;
  24791. uint_fast64_t uiB64, uiB0;
  24792. bool signA, signB;
  24793. uA.f = a;
  24794. uiA64 = uA.ui.v64;
  24795. uiA0 = uA.ui.v0;
  24796. uB.f = b;
  24797. uiB64 = uB.ui.v64;
  24798. uiB0 = uB.ui.v0;
  24799. if ( isNaNF128UI( uiA64, uiA0 ) || isNaNF128UI( uiB64, uiB0 ) ) {
  24800. if (
  24801. softfloat_isSigNaNF128UI( uiA64, uiA0 )
  24802. || softfloat_isSigNaNF128UI( uiB64, uiB0 )
  24803. ) {
  24804. softfloat_raiseFlags( softfloat_flag_invalid );
  24805. }
  24806. return false;
  24807. }
  24808. signA = signF128UI64( uiA64 );
  24809. signB = signF128UI64( uiB64 );
  24810. return
  24811. (signA != signB)
  24812. ? signA
  24813. && (((uiA64 | uiB64) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
  24814. | uiA0 | uiB0)
  24815. : ((uiA64 != uiB64) || (uiA0 != uiB0))
  24816. && (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
  24817. }
  24818. /**** ended inlining ../../source/f128_lt_quiet.c ****/
  24819. /**** start inlining ../../source/f128_isSignalingNaN.c ****/
  24820. /*============================================================================
  24821. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  24822. Package, Release 3e, by John R. Hauser.
  24823. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  24824. All rights reserved.
  24825. Redistribution and use in source and binary forms, with or without
  24826. modification, are permitted provided that the following conditions are met:
  24827. 1. Redistributions of source code must retain the above copyright notice,
  24828. this list of conditions, and the following disclaimer.
  24829. 2. Redistributions in binary form must reproduce the above copyright notice,
  24830. this list of conditions, and the following disclaimer in the documentation
  24831. and/or other materials provided with the distribution.
  24832. 3. Neither the name of the University nor the names of its contributors may
  24833. be used to endorse or promote products derived from this software without
  24834. specific prior written permission.
  24835. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  24836. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  24837. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  24838. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  24839. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24840. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24841. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24842. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24843. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  24844. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24845. =============================================================================*/
  24846. #include <stdbool.h>
  24847. /**** skipping file: platform.h ****/
  24848. /**** skipping file: internals.h ****/
  24849. /**** skipping file: specialize.h ****/
  24850. /**** skipping file: softfloat.h ****/
  24851. bool f128_isSignalingNaN( float128_t a )
  24852. {
  24853. union ui128_f128 uA;
  24854. uA.f = a;
  24855. return softfloat_isSigNaNF128UI( uA.ui.v64, uA.ui.v0 );
  24856. }
  24857. /**** ended inlining ../../source/f128_isSignalingNaN.c ****/
  24858. /**** start inlining ../../source/f128M_to_ui32.c ****/
  24859. /*============================================================================
  24860. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  24861. Package, Release 3e, by John R. Hauser.
  24862. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  24863. University of California. All rights reserved.
  24864. Redistribution and use in source and binary forms, with or without
  24865. modification, are permitted provided that the following conditions are met:
  24866. 1. Redistributions of source code must retain the above copyright notice,
  24867. this list of conditions, and the following disclaimer.
  24868. 2. Redistributions in binary form must reproduce the above copyright notice,
  24869. this list of conditions, and the following disclaimer in the documentation
  24870. and/or other materials provided with the distribution.
  24871. 3. Neither the name of the University nor the names of its contributors may
  24872. be used to endorse or promote products derived from this software without
  24873. specific prior written permission.
  24874. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  24875. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  24876. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  24877. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  24878. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24879. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24880. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24881. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24882. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  24883. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24884. =============================================================================*/
  24885. #include <stdbool.h>
  24886. #include <stdint.h>
  24887. /**** skipping file: platform.h ****/
  24888. /**** skipping file: internals.h ****/
  24889. /**** skipping file: specialize.h ****/
  24890. /**** skipping file: softfloat.h ****/
  24891. #ifdef SOFTFLOAT_FAST_INT64
  24892. uint_fast32_t
  24893. f128M_to_ui32( const float128_t *aPtr, uint_fast8_t roundingMode, bool exact )
  24894. {
  24895. return f128_to_ui32( *aPtr, roundingMode, exact );
  24896. }
  24897. #else
  24898. uint_fast32_t
  24899. f128M_to_ui32( const float128_t *aPtr, uint_fast8_t roundingMode, bool exact )
  24900. {
  24901. const uint32_t *aWPtr;
  24902. uint32_t uiA96;
  24903. bool sign;
  24904. int32_t exp;
  24905. uint64_t sig64;
  24906. int32_t shiftDist;
  24907. /*------------------------------------------------------------------------
  24908. *------------------------------------------------------------------------*/
  24909. aWPtr = (const uint32_t *) aPtr;
  24910. uiA96 = aWPtr[indexWordHi( 4 )];
  24911. sign = signF128UI96( uiA96 );
  24912. exp = expF128UI96( uiA96 );
  24913. sig64 = (uint64_t) fracF128UI96( uiA96 )<<32 | aWPtr[indexWord( 4, 2 )];
  24914. if ( aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )] ) sig64 |= 1;
  24915. /*------------------------------------------------------------------------
  24916. *------------------------------------------------------------------------*/
  24917. #if (ui32_fromNaN != ui32_fromPosOverflow) || (ui32_fromNaN != ui32_fromNegOverflow)
  24918. if ( (exp == 0x7FFF) && sig64 ) {
  24919. #if (ui32_fromNaN == ui32_fromPosOverflow)
  24920. sign = 0;
  24921. #elif (ui32_fromNaN == ui32_fromNegOverflow)
  24922. sign = 1;
  24923. #else
  24924. softfloat_raiseFlags( softfloat_flag_invalid );
  24925. return ui32_fromNaN;
  24926. #endif
  24927. }
  24928. #endif
  24929. /*------------------------------------------------------------------------
  24930. *------------------------------------------------------------------------*/
  24931. if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
  24932. shiftDist = 0x4023 - exp;
  24933. if ( 0 < shiftDist ) sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
  24934. return softfloat_roundToUI32( sign, sig64, roundingMode, exact );
  24935. }
  24936. #endif
  24937. /**** ended inlining ../../source/f128M_to_ui32.c ****/
  24938. /**** start inlining ../../source/f128M_to_ui64.c ****/
  24939. /*============================================================================
  24940. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  24941. Package, Release 3e, by John R. Hauser.
  24942. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  24943. University of California. All rights reserved.
  24944. Redistribution and use in source and binary forms, with or without
  24945. modification, are permitted provided that the following conditions are met:
  24946. 1. Redistributions of source code must retain the above copyright notice,
  24947. this list of conditions, and the following disclaimer.
  24948. 2. Redistributions in binary form must reproduce the above copyright notice,
  24949. this list of conditions, and the following disclaimer in the documentation
  24950. and/or other materials provided with the distribution.
  24951. 3. Neither the name of the University nor the names of its contributors may
  24952. be used to endorse or promote products derived from this software without
  24953. specific prior written permission.
  24954. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  24955. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  24956. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  24957. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  24958. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24959. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24960. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24961. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24962. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  24963. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24964. =============================================================================*/
  24965. #include <stdbool.h>
  24966. #include <stdint.h>
  24967. /**** skipping file: platform.h ****/
  24968. /**** skipping file: internals.h ****/
  24969. /**** skipping file: specialize.h ****/
  24970. /**** skipping file: softfloat.h ****/
  24971. #ifdef SOFTFLOAT_FAST_INT64
  24972. uint_fast64_t
  24973. f128M_to_ui64( const float128_t *aPtr, uint_fast8_t roundingMode, bool exact )
  24974. {
  24975. return f128_to_ui64( *aPtr, roundingMode, exact );
  24976. }
  24977. #else
  24978. uint_fast64_t
  24979. f128M_to_ui64( const float128_t *aPtr, uint_fast8_t roundingMode, bool exact )
  24980. {
  24981. const uint32_t *aWPtr;
  24982. uint32_t uiA96;
  24983. bool sign;
  24984. int32_t exp;
  24985. uint32_t sig96;
  24986. int32_t shiftDist;
  24987. uint32_t sig[4];
  24988. /*------------------------------------------------------------------------
  24989. *------------------------------------------------------------------------*/
  24990. aWPtr = (const uint32_t *) aPtr;
  24991. uiA96 = aWPtr[indexWordHi( 4 )];
  24992. sign = signF128UI96( uiA96 );
  24993. exp = expF128UI96( uiA96 );
  24994. sig96 = fracF128UI96( uiA96 );
  24995. /*------------------------------------------------------------------------
  24996. *------------------------------------------------------------------------*/
  24997. shiftDist = 0x404F - exp;
  24998. if ( shiftDist < 17 ) {
  24999. softfloat_raiseFlags( softfloat_flag_invalid );
  25000. return
  25001. (exp == 0x7FFF)
  25002. && (sig96
  25003. || (aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
  25004. | aWPtr[indexWord( 4, 0 )]))
  25005. ? ui64_fromNaN
  25006. : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
  25007. }
  25008. /*------------------------------------------------------------------------
  25009. *------------------------------------------------------------------------*/
  25010. if ( exp ) sig96 |= 0x00010000;
  25011. sig[indexWord( 4, 3 )] = sig96;
  25012. sig[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
  25013. sig[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
  25014. sig[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
  25015. softfloat_shiftRightJam128M( sig, shiftDist, sig );
  25016. return
  25017. softfloat_roundMToUI64(
  25018. sign, sig + indexMultiwordLo( 4, 3 ), roundingMode, exact );
  25019. }
  25020. #endif
  25021. /**** ended inlining ../../source/f128M_to_ui64.c ****/
  25022. /**** start inlining ../../source/f128M_to_i32.c ****/
  25023. /*============================================================================
  25024. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  25025. Package, Release 3e, by John R. Hauser.
  25026. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  25027. University of California. All rights reserved.
  25028. Redistribution and use in source and binary forms, with or without
  25029. modification, are permitted provided that the following conditions are met:
  25030. 1. Redistributions of source code must retain the above copyright notice,
  25031. this list of conditions, and the following disclaimer.
  25032. 2. Redistributions in binary form must reproduce the above copyright notice,
  25033. this list of conditions, and the following disclaimer in the documentation
  25034. and/or other materials provided with the distribution.
  25035. 3. Neither the name of the University nor the names of its contributors may
  25036. be used to endorse or promote products derived from this software without
  25037. specific prior written permission.
  25038. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  25039. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  25040. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  25041. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  25042. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  25043. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25044. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  25045. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25046. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25047. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25048. =============================================================================*/
  25049. #include <stdbool.h>
  25050. #include <stdint.h>
  25051. /**** skipping file: platform.h ****/
  25052. /**** skipping file: internals.h ****/
  25053. /**** skipping file: specialize.h ****/
  25054. /**** skipping file: softfloat.h ****/
  25055. #ifdef SOFTFLOAT_FAST_INT64
  25056. int_fast32_t
  25057. f128M_to_i32( const float128_t *aPtr, uint_fast8_t roundingMode, bool exact )
  25058. {
  25059. return f128_to_i32( *aPtr, roundingMode, exact );
  25060. }
  25061. #else
  25062. int_fast32_t
  25063. f128M_to_i32( const float128_t *aPtr, uint_fast8_t roundingMode, bool exact )
  25064. {
  25065. const uint32_t *aWPtr;
  25066. uint32_t uiA96;
  25067. bool sign;
  25068. int32_t exp;
  25069. uint64_t sig64;
  25070. int32_t shiftDist;
  25071. /*------------------------------------------------------------------------
  25072. *------------------------------------------------------------------------*/
  25073. aWPtr = (const uint32_t *) aPtr;
  25074. uiA96 = aWPtr[indexWordHi( 4 )];
  25075. sign = signF128UI96( uiA96 );
  25076. exp = expF128UI96( uiA96 );
  25077. sig64 = (uint64_t) fracF128UI96( uiA96 )<<32 | aWPtr[indexWord( 4, 2 )];
  25078. if ( aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )] ) sig64 |= 1;
  25079. /*------------------------------------------------------------------------
  25080. *------------------------------------------------------------------------*/
  25081. #if (i32_fromNaN != i32_fromPosOverflow) || (i32_fromNaN != i32_fromNegOverflow)
  25082. if ( (exp == 0x7FFF) && sig64 ) {
  25083. #if (i32_fromNaN == i32_fromPosOverflow)
  25084. sign = 0;
  25085. #elif (i32_fromNaN == i32_fromNegOverflow)
  25086. sign = 1;
  25087. #else
  25088. softfloat_raiseFlags( softfloat_flag_invalid );
  25089. return i32_fromNaN;
  25090. #endif
  25091. }
  25092. #endif
  25093. /*------------------------------------------------------------------------
  25094. *------------------------------------------------------------------------*/
  25095. if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
  25096. shiftDist = 0x4023 - exp;
  25097. if ( 0 < shiftDist ) sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
  25098. return softfloat_roundToI32( sign, sig64, roundingMode, exact );
  25099. }
  25100. #endif
  25101. /**** ended inlining ../../source/f128M_to_i32.c ****/
  25102. /**** start inlining ../../source/f128M_to_i64.c ****/
  25103. /*============================================================================
  25104. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  25105. Package, Release 3e, by John R. Hauser.
  25106. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  25107. University of California. All rights reserved.
  25108. Redistribution and use in source and binary forms, with or without
  25109. modification, are permitted provided that the following conditions are met:
  25110. 1. Redistributions of source code must retain the above copyright notice,
  25111. this list of conditions, and the following disclaimer.
  25112. 2. Redistributions in binary form must reproduce the above copyright notice,
  25113. this list of conditions, and the following disclaimer in the documentation
  25114. and/or other materials provided with the distribution.
  25115. 3. Neither the name of the University nor the names of its contributors may
  25116. be used to endorse or promote products derived from this software without
  25117. specific prior written permission.
  25118. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  25119. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  25120. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  25121. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  25122. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  25123. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25124. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  25125. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25126. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25127. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25128. =============================================================================*/
  25129. #include <stdbool.h>
  25130. #include <stdint.h>
  25131. /**** skipping file: platform.h ****/
  25132. /**** skipping file: internals.h ****/
  25133. /**** skipping file: specialize.h ****/
  25134. /**** skipping file: softfloat.h ****/
  25135. #ifdef SOFTFLOAT_FAST_INT64
  25136. int_fast64_t
  25137. f128M_to_i64( const float128_t *aPtr, uint_fast8_t roundingMode, bool exact )
  25138. {
  25139. return f128_to_i64( *aPtr, roundingMode, exact );
  25140. }
  25141. #else
  25142. int_fast64_t
  25143. f128M_to_i64( const float128_t *aPtr, uint_fast8_t roundingMode, bool exact )
  25144. {
  25145. const uint32_t *aWPtr;
  25146. uint32_t uiA96;
  25147. bool sign;
  25148. int32_t exp;
  25149. uint32_t sig96;
  25150. int32_t shiftDist;
  25151. uint32_t sig[4];
  25152. /*------------------------------------------------------------------------
  25153. *------------------------------------------------------------------------*/
  25154. aWPtr = (const uint32_t *) aPtr;
  25155. uiA96 = aWPtr[indexWordHi( 4 )];
  25156. sign = signF128UI96( uiA96 );
  25157. exp = expF128UI96( uiA96 );
  25158. sig96 = fracF128UI96( uiA96 );
  25159. /*------------------------------------------------------------------------
  25160. *------------------------------------------------------------------------*/
  25161. shiftDist = 0x404F - exp;
  25162. if ( shiftDist < 17 ) {
  25163. softfloat_raiseFlags( softfloat_flag_invalid );
  25164. return
  25165. (exp == 0x7FFF)
  25166. && (sig96
  25167. || (aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
  25168. | aWPtr[indexWord( 4, 0 )]))
  25169. ? i64_fromNaN
  25170. : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
  25171. }
  25172. /*------------------------------------------------------------------------
  25173. *------------------------------------------------------------------------*/
  25174. if ( exp ) sig96 |= 0x00010000;
  25175. sig[indexWord( 4, 3 )] = sig96;
  25176. sig[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
  25177. sig[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
  25178. sig[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
  25179. softfloat_shiftRightJam128M( sig, shiftDist, sig );
  25180. return
  25181. softfloat_roundMToI64(
  25182. sign, sig + indexMultiwordLo( 4, 3 ), roundingMode, exact );
  25183. }
  25184. #endif
  25185. /**** ended inlining ../../source/f128M_to_i64.c ****/
  25186. /**** start inlining ../../source/f128M_to_ui32_r_minMag.c ****/
  25187. /*============================================================================
  25188. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  25189. Package, Release 3e, by John R. Hauser.
  25190. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  25191. California. All rights reserved.
  25192. Redistribution and use in source and binary forms, with or without
  25193. modification, are permitted provided that the following conditions are met:
  25194. 1. Redistributions of source code must retain the above copyright notice,
  25195. this list of conditions, and the following disclaimer.
  25196. 2. Redistributions in binary form must reproduce the above copyright notice,
  25197. this list of conditions, and the following disclaimer in the documentation
  25198. and/or other materials provided with the distribution.
  25199. 3. Neither the name of the University nor the names of its contributors may
  25200. be used to endorse or promote products derived from this software without
  25201. specific prior written permission.
  25202. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  25203. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  25204. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  25205. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  25206. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  25207. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25208. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  25209. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25210. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25211. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25212. =============================================================================*/
  25213. #include <stdbool.h>
  25214. #include <stdint.h>
  25215. /**** skipping file: platform.h ****/
  25216. /**** skipping file: internals.h ****/
  25217. /**** skipping file: specialize.h ****/
  25218. /**** skipping file: softfloat.h ****/
  25219. #ifdef SOFTFLOAT_FAST_INT64
  25220. uint_fast32_t f128M_to_ui32_r_minMag( const float128_t *aPtr, bool exact )
  25221. {
  25222. return f128_to_ui32_r_minMag( *aPtr, exact );
  25223. }
  25224. #else
  25225. uint_fast32_t f128M_to_ui32_r_minMag( const float128_t *aPtr, bool exact )
  25226. {
  25227. const uint32_t *aWPtr;
  25228. uint32_t uiA96;
  25229. int32_t exp;
  25230. uint64_t sig64;
  25231. int32_t shiftDist;
  25232. bool sign;
  25233. uint32_t z;
  25234. /*------------------------------------------------------------------------
  25235. *------------------------------------------------------------------------*/
  25236. aWPtr = (const uint32_t *) aPtr;
  25237. uiA96 = aWPtr[indexWordHi( 4 )];
  25238. exp = expF128UI96( uiA96 );
  25239. sig64 = (uint64_t) fracF128UI96( uiA96 )<<32 | aWPtr[indexWord( 4, 2 )];
  25240. if ( aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )] ) sig64 |= 1;
  25241. /*------------------------------------------------------------------------
  25242. *------------------------------------------------------------------------*/
  25243. shiftDist = 0x402F - exp;
  25244. if ( 49 <= shiftDist ) {
  25245. if ( exact && (exp | sig64) ) {
  25246. softfloat_exceptionFlags |= softfloat_flag_inexact;
  25247. }
  25248. return 0;
  25249. }
  25250. /*------------------------------------------------------------------------
  25251. *------------------------------------------------------------------------*/
  25252. sign = signF128UI96( uiA96 );
  25253. if ( sign || (shiftDist < 17) ) {
  25254. softfloat_raiseFlags( softfloat_flag_invalid );
  25255. return
  25256. (exp == 0x7FFF) && sig64 ? ui32_fromNaN
  25257. : sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
  25258. }
  25259. /*------------------------------------------------------------------------
  25260. *------------------------------------------------------------------------*/
  25261. sig64 |= UINT64_C( 0x0001000000000000 );
  25262. z = sig64>>shiftDist;
  25263. if ( exact && ((uint64_t) z<<shiftDist != sig64) ) {
  25264. softfloat_exceptionFlags |= softfloat_flag_inexact;
  25265. }
  25266. return z;
  25267. }
  25268. #endif
  25269. /**** ended inlining ../../source/f128M_to_ui32_r_minMag.c ****/
  25270. /**** start inlining ../../source/f128M_to_ui64_r_minMag.c ****/
  25271. /*============================================================================
  25272. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  25273. Package, Release 3e, by John R. Hauser.
  25274. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  25275. California. All rights reserved.
  25276. Redistribution and use in source and binary forms, with or without
  25277. modification, are permitted provided that the following conditions are met:
  25278. 1. Redistributions of source code must retain the above copyright notice,
  25279. this list of conditions, and the following disclaimer.
  25280. 2. Redistributions in binary form must reproduce the above copyright notice,
  25281. this list of conditions, and the following disclaimer in the documentation
  25282. and/or other materials provided with the distribution.
  25283. 3. Neither the name of the University nor the names of its contributors may
  25284. be used to endorse or promote products derived from this software without
  25285. specific prior written permission.
  25286. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  25287. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  25288. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  25289. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  25290. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  25291. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25292. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  25293. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25294. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25295. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25296. =============================================================================*/
  25297. #include <stdbool.h>
  25298. #include <stdint.h>
  25299. /**** skipping file: platform.h ****/
  25300. /**** skipping file: internals.h ****/
  25301. /**** skipping file: specialize.h ****/
  25302. /**** skipping file: softfloat.h ****/
  25303. #ifdef SOFTFLOAT_FAST_INT64
  25304. uint_fast64_t f128M_to_ui64_r_minMag( const float128_t *aPtr, bool exact )
  25305. {
  25306. return f128_to_ui64_r_minMag( *aPtr, exact );
  25307. }
  25308. #else
  25309. uint_fast64_t f128M_to_ui64_r_minMag( const float128_t *aPtr, bool exact )
  25310. {
  25311. const uint32_t *aWPtr;
  25312. uint32_t uiA96;
  25313. bool sign;
  25314. int32_t exp;
  25315. uint32_t sig96;
  25316. int32_t shiftDist;
  25317. uint32_t sig[4];
  25318. uint64_t z;
  25319. /*------------------------------------------------------------------------
  25320. *------------------------------------------------------------------------*/
  25321. aWPtr = (const uint32_t *) aPtr;
  25322. uiA96 = aWPtr[indexWordHi( 4 )];
  25323. sign = signF128UI96( uiA96 );
  25324. exp = expF128UI96( uiA96 );
  25325. sig96 = fracF128UI96( uiA96 );
  25326. /*------------------------------------------------------------------------
  25327. *------------------------------------------------------------------------*/
  25328. shiftDist = 0x403E - exp;
  25329. if ( shiftDist < 0 ) goto invalid;
  25330. if ( exact ) {
  25331. if ( exp ) sig96 |= 0x00010000;
  25332. sig[indexWord( 4, 3 )] = sig96;
  25333. sig[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
  25334. sig[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
  25335. sig[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
  25336. softfloat_shiftRightJam128M( sig, shiftDist + 17, sig );
  25337. z = (uint64_t) sig[indexWord( 4, 2 )]<<32 | sig[indexWord( 4, 1 )];
  25338. if ( sign && z ) goto invalid;
  25339. if ( sig[indexWordLo( 4 )] ) {
  25340. softfloat_exceptionFlags |= softfloat_flag_inexact;
  25341. }
  25342. } else {
  25343. if ( 64 <= shiftDist ) return 0;
  25344. if ( sign ) goto invalid;
  25345. z = UINT64_C( 0x8000000000000000 )
  25346. | (uint64_t) sig96<<47
  25347. | (uint64_t) aWPtr[indexWord( 4, 2 )]<<15
  25348. | aWPtr[indexWord( 4, 1 )]>>17;
  25349. z >>= shiftDist;
  25350. }
  25351. return z;
  25352. /*------------------------------------------------------------------------
  25353. *------------------------------------------------------------------------*/
  25354. invalid:
  25355. softfloat_raiseFlags( softfloat_flag_invalid );
  25356. return
  25357. (exp == 0x7FFF)
  25358. && (sig96
  25359. || (aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
  25360. | aWPtr[indexWord( 4, 0 )]))
  25361. ? ui64_fromNaN
  25362. : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
  25363. }
  25364. #endif
  25365. /**** ended inlining ../../source/f128M_to_ui64_r_minMag.c ****/
  25366. /**** start inlining ../../source/f128M_to_i32_r_minMag.c ****/
  25367. /*============================================================================
  25368. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  25369. Package, Release 3e, by John R. Hauser.
  25370. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  25371. California. All rights reserved.
  25372. Redistribution and use in source and binary forms, with or without
  25373. modification, are permitted provided that the following conditions are met:
  25374. 1. Redistributions of source code must retain the above copyright notice,
  25375. this list of conditions, and the following disclaimer.
  25376. 2. Redistributions in binary form must reproduce the above copyright notice,
  25377. this list of conditions, and the following disclaimer in the documentation
  25378. and/or other materials provided with the distribution.
  25379. 3. Neither the name of the University nor the names of its contributors may
  25380. be used to endorse or promote products derived from this software without
  25381. specific prior written permission.
  25382. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  25383. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  25384. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  25385. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  25386. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  25387. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25388. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  25389. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25390. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25391. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25392. =============================================================================*/
  25393. #include <stdbool.h>
  25394. #include <stdint.h>
  25395. /**** skipping file: platform.h ****/
  25396. /**** skipping file: internals.h ****/
  25397. /**** skipping file: specialize.h ****/
  25398. /**** skipping file: softfloat.h ****/
  25399. #ifdef SOFTFLOAT_FAST_INT64
  25400. int_fast32_t f128M_to_i32_r_minMag( const float128_t *aPtr, bool exact )
  25401. {
  25402. return f128_to_i32_r_minMag( *aPtr, exact );
  25403. }
  25404. #else
  25405. int_fast32_t f128M_to_i32_r_minMag( const float128_t *aPtr, bool exact )
  25406. {
  25407. const uint32_t *aWPtr;
  25408. uint32_t uiA96;
  25409. bool sign;
  25410. int32_t exp;
  25411. uint64_t sig64;
  25412. int32_t shiftDist;
  25413. uint32_t absZ, uiZ;
  25414. union { uint32_t ui; int32_t i; } uZ;
  25415. /*------------------------------------------------------------------------
  25416. *------------------------------------------------------------------------*/
  25417. aWPtr = (const uint32_t *) aPtr;
  25418. uiA96 = aWPtr[indexWordHi( 4 )];
  25419. sign = signF128UI96( uiA96 );
  25420. exp = expF128UI96( uiA96 );
  25421. sig64 = (uint64_t) fracF128UI96( uiA96 )<<32 | aWPtr[indexWord( 4, 2 )];
  25422. if ( aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )] ) sig64 |= 1;
  25423. /*------------------------------------------------------------------------
  25424. *------------------------------------------------------------------------*/
  25425. if ( exp < 0x3FFF ) {
  25426. if ( exact && (exp | sig64) ) {
  25427. softfloat_exceptionFlags |= softfloat_flag_inexact;
  25428. }
  25429. return 0;
  25430. }
  25431. /*------------------------------------------------------------------------
  25432. *------------------------------------------------------------------------*/
  25433. if ( 0x401F <= exp ) goto invalid;
  25434. shiftDist = 0x402F - exp;
  25435. sig64 |= UINT64_C( 0x0001000000000000 );
  25436. absZ = sig64>>shiftDist;
  25437. uiZ = sign ? -absZ : absZ;
  25438. if ( uiZ>>31 != sign ) goto invalid;
  25439. if ( exact && ((uint64_t) absZ<<shiftDist != sig64) ) {
  25440. softfloat_exceptionFlags |= softfloat_flag_inexact;
  25441. }
  25442. uZ.ui = uiZ;
  25443. return uZ.i;
  25444. /*------------------------------------------------------------------------
  25445. *------------------------------------------------------------------------*/
  25446. invalid:
  25447. softfloat_raiseFlags( softfloat_flag_invalid );
  25448. return
  25449. (exp == 0x7FFF) && sig64 ? i32_fromNaN
  25450. : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
  25451. }
  25452. #endif
  25453. /**** ended inlining ../../source/f128M_to_i32_r_minMag.c ****/
  25454. /**** start inlining ../../source/f128M_to_i64_r_minMag.c ****/
  25455. /*============================================================================
  25456. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  25457. Package, Release 3e, by John R. Hauser.
  25458. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  25459. California. All rights reserved.
  25460. Redistribution and use in source and binary forms, with or without
  25461. modification, are permitted provided that the following conditions are met:
  25462. 1. Redistributions of source code must retain the above copyright notice,
  25463. this list of conditions, and the following disclaimer.
  25464. 2. Redistributions in binary form must reproduce the above copyright notice,
  25465. this list of conditions, and the following disclaimer in the documentation
  25466. and/or other materials provided with the distribution.
  25467. 3. Neither the name of the University nor the names of its contributors may
  25468. be used to endorse or promote products derived from this software without
  25469. specific prior written permission.
  25470. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  25471. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  25472. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  25473. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  25474. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  25475. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25476. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  25477. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25478. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25479. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25480. =============================================================================*/
  25481. #include <stdbool.h>
  25482. #include <stdint.h>
  25483. /**** skipping file: platform.h ****/
  25484. /**** skipping file: internals.h ****/
  25485. /**** skipping file: specialize.h ****/
  25486. /**** skipping file: softfloat.h ****/
  25487. #ifdef SOFTFLOAT_FAST_INT64
  25488. int_fast64_t f128M_to_i64_r_minMag( const float128_t *aPtr, bool exact )
  25489. {
  25490. return f128_to_i64_r_minMag( *aPtr, exact );
  25491. }
  25492. #else
  25493. int_fast64_t f128M_to_i64_r_minMag( const float128_t *aPtr, bool exact )
  25494. {
  25495. const uint32_t *aWPtr;
  25496. uint32_t uiA96;
  25497. bool sign;
  25498. int32_t exp;
  25499. uint32_t sig96;
  25500. int32_t shiftDist;
  25501. uint32_t sig[4];
  25502. uint64_t uiZ;
  25503. union { uint64_t ui; int64_t i; } uZ;
  25504. /*------------------------------------------------------------------------
  25505. *------------------------------------------------------------------------*/
  25506. aWPtr = (const uint32_t *) aPtr;
  25507. uiA96 = aWPtr[indexWordHi( 4 )];
  25508. sign = signF128UI96( uiA96 );
  25509. exp = expF128UI96( uiA96 );
  25510. sig96 = fracF128UI96( uiA96 );
  25511. /*------------------------------------------------------------------------
  25512. *------------------------------------------------------------------------*/
  25513. shiftDist = 0x403E - exp;
  25514. if ( shiftDist < 0 ) goto invalid;
  25515. if ( exact ) {
  25516. if ( exp ) sig96 |= 0x00010000;
  25517. sig[indexWord( 4, 3 )] = sig96;
  25518. sig[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
  25519. sig[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
  25520. sig[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
  25521. softfloat_shiftRightJam128M( sig, shiftDist + 17, sig );
  25522. uiZ = (uint64_t) sig[indexWord( 4, 2 )]<<32 | sig[indexWord( 4, 1 )];
  25523. if ( uiZ>>63 && (! sign || (uiZ != UINT64_C( 0x8000000000000000 ))) ) {
  25524. goto invalid;
  25525. }
  25526. if ( sig[indexWordLo( 4 )] ) {
  25527. softfloat_exceptionFlags |= softfloat_flag_inexact;
  25528. }
  25529. } else {
  25530. if ( 64 <= shiftDist ) return 0;
  25531. uiZ =
  25532. (uint64_t) sig96<<47
  25533. | (uint64_t) aWPtr[indexWord( 4, 2 )]<<15
  25534. | aWPtr[indexWord( 4, 1 )]>>17;
  25535. if ( shiftDist ) {
  25536. uiZ |= UINT64_C( 0x8000000000000000 );
  25537. uiZ >>= shiftDist;
  25538. } else {
  25539. if ( uiZ || ! sign ) goto invalid;
  25540. uiZ |= UINT64_C( 0x8000000000000000 );
  25541. }
  25542. }
  25543. if ( sign ) uiZ = -uiZ;
  25544. uZ.ui = uiZ;
  25545. return uZ.i;
  25546. /*------------------------------------------------------------------------
  25547. *------------------------------------------------------------------------*/
  25548. invalid:
  25549. softfloat_raiseFlags( softfloat_flag_invalid );
  25550. return
  25551. (exp == 0x7FFF)
  25552. && (sig96
  25553. || (aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
  25554. | aWPtr[indexWord( 4, 0 )]))
  25555. ? i64_fromNaN
  25556. : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
  25557. }
  25558. #endif
  25559. /**** ended inlining ../../source/f128M_to_i64_r_minMag.c ****/
  25560. /**** start inlining ../../source/f128M_to_f16.c ****/
  25561. /*============================================================================
  25562. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  25563. Package, Release 3e, by John R. Hauser.
  25564. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  25565. California. All rights reserved.
  25566. Redistribution and use in source and binary forms, with or without
  25567. modification, are permitted provided that the following conditions are met:
  25568. 1. Redistributions of source code must retain the above copyright notice,
  25569. this list of conditions, and the following disclaimer.
  25570. 2. Redistributions in binary form must reproduce the above copyright notice,
  25571. this list of conditions, and the following disclaimer in the documentation
  25572. and/or other materials provided with the distribution.
  25573. 3. Neither the name of the University nor the names of its contributors may
  25574. be used to endorse or promote products derived from this software without
  25575. specific prior written permission.
  25576. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  25577. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  25578. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  25579. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  25580. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  25581. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25582. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  25583. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25584. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25585. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25586. =============================================================================*/
  25587. #include <stdbool.h>
  25588. #include <stdint.h>
  25589. /**** skipping file: platform.h ****/
  25590. /**** skipping file: internals.h ****/
  25591. /**** skipping file: specialize.h ****/
  25592. /**** skipping file: softfloat.h ****/
  25593. #ifdef SOFTFLOAT_FAST_INT64
  25594. float16_t f128M_to_f16( const float128_t *aPtr )
  25595. {
  25596. return f128_to_f16( *aPtr );
  25597. }
  25598. #else
  25599. float16_t f128M_to_f16( const float128_t *aPtr )
  25600. {
  25601. const uint32_t *aWPtr;
  25602. uint32_t uiA96;
  25603. bool sign;
  25604. int32_t exp;
  25605. uint32_t frac32;
  25606. struct commonNaN commonNaN;
  25607. uint16_t uiZ, frac16;
  25608. union ui16_f16 uZ;
  25609. /*------------------------------------------------------------------------
  25610. *------------------------------------------------------------------------*/
  25611. aWPtr = (const uint32_t *) aPtr;
  25612. /*------------------------------------------------------------------------
  25613. *------------------------------------------------------------------------*/
  25614. uiA96 = aWPtr[indexWordHi( 4 )];
  25615. sign = signF128UI96( uiA96 );
  25616. exp = expF128UI96( uiA96 );
  25617. frac32 =
  25618. fracF128UI96( uiA96 )
  25619. | ((aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
  25620. | aWPtr[indexWord( 4, 0 )])
  25621. != 0);
  25622. /*------------------------------------------------------------------------
  25623. *------------------------------------------------------------------------*/
  25624. if ( exp == 0x7FFF ) {
  25625. if ( frac32 ) {
  25626. softfloat_f128MToCommonNaN( aWPtr, &commonNaN );
  25627. uiZ = softfloat_commonNaNToF16UI( &commonNaN );
  25628. } else {
  25629. uiZ = packToF16UI( sign, 0x1F, 0 );
  25630. }
  25631. goto uiZ;
  25632. }
  25633. /*------------------------------------------------------------------------
  25634. *------------------------------------------------------------------------*/
  25635. frac16 = frac32>>2 | (frac32 & 3);
  25636. if ( ! (exp | frac16) ) {
  25637. uiZ = packToF16UI( sign, 0, 0 );
  25638. goto uiZ;
  25639. }
  25640. /*------------------------------------------------------------------------
  25641. *------------------------------------------------------------------------*/
  25642. exp -= 0x3FF1;
  25643. if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
  25644. if ( exp < -0x40 ) exp = -0x40;
  25645. }
  25646. return softfloat_roundPackToF16( sign, exp, frac16 | 0x4000 );
  25647. /*------------------------------------------------------------------------
  25648. *------------------------------------------------------------------------*/
  25649. uiZ:
  25650. uZ.ui = uiZ;
  25651. return uZ.f;
  25652. }
  25653. #endif
  25654. /**** ended inlining ../../source/f128M_to_f16.c ****/
  25655. /**** start inlining ../../source/f128M_to_f32.c ****/
  25656. /*============================================================================
  25657. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  25658. Package, Release 3e, by John R. Hauser.
  25659. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  25660. California. All rights reserved.
  25661. Redistribution and use in source and binary forms, with or without
  25662. modification, are permitted provided that the following conditions are met:
  25663. 1. Redistributions of source code must retain the above copyright notice,
  25664. this list of conditions, and the following disclaimer.
  25665. 2. Redistributions in binary form must reproduce the above copyright notice,
  25666. this list of conditions, and the following disclaimer in the documentation
  25667. and/or other materials provided with the distribution.
  25668. 3. Neither the name of the University nor the names of its contributors may
  25669. be used to endorse or promote products derived from this software without
  25670. specific prior written permission.
  25671. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  25672. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  25673. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  25674. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  25675. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  25676. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25677. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  25678. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25679. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25680. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25681. =============================================================================*/
  25682. #include <stdbool.h>
  25683. #include <stdint.h>
  25684. /**** skipping file: platform.h ****/
  25685. /**** skipping file: internals.h ****/
  25686. /**** skipping file: specialize.h ****/
  25687. /**** skipping file: softfloat.h ****/
  25688. #ifdef SOFTFLOAT_FAST_INT64
  25689. float32_t f128M_to_f32( const float128_t *aPtr )
  25690. {
  25691. return f128_to_f32( *aPtr );
  25692. }
  25693. #else
  25694. float32_t f128M_to_f32( const float128_t *aPtr )
  25695. {
  25696. const uint32_t *aWPtr;
  25697. uint32_t uiA96;
  25698. bool sign;
  25699. int32_t exp;
  25700. uint64_t frac64;
  25701. struct commonNaN commonNaN;
  25702. uint32_t uiZ, frac32;
  25703. union ui32_f32 uZ;
  25704. /*------------------------------------------------------------------------
  25705. *------------------------------------------------------------------------*/
  25706. aWPtr = (const uint32_t *) aPtr;
  25707. uiA96 = aWPtr[indexWordHi( 4 )];
  25708. sign = signF128UI96( uiA96 );
  25709. exp = expF128UI96( uiA96 );
  25710. frac64 =
  25711. (uint64_t) fracF128UI96( uiA96 )<<32 | aWPtr[indexWord( 4, 2 )]
  25712. | ((aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )]) != 0);
  25713. /*------------------------------------------------------------------------
  25714. *------------------------------------------------------------------------*/
  25715. if ( exp == 0x7FFF ) {
  25716. if ( frac64 ) {
  25717. softfloat_f128MToCommonNaN( aWPtr, &commonNaN );
  25718. uiZ = softfloat_commonNaNToF32UI( &commonNaN );
  25719. } else {
  25720. uiZ = packToF32UI( sign, 0xFF, 0 );
  25721. }
  25722. goto uiZ;
  25723. }
  25724. /*------------------------------------------------------------------------
  25725. *------------------------------------------------------------------------*/
  25726. frac32 = softfloat_shortShiftRightJam64( frac64, 18 );
  25727. if ( ! (exp | frac32) ) {
  25728. uiZ = packToF32UI( sign, 0, 0 );
  25729. goto uiZ;
  25730. }
  25731. /*------------------------------------------------------------------------
  25732. *------------------------------------------------------------------------*/
  25733. exp -= 0x3F81;
  25734. if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
  25735. if ( exp < -0x1000 ) exp = -0x1000;
  25736. }
  25737. return softfloat_roundPackToF32( sign, exp, frac32 | 0x40000000 );
  25738. /*------------------------------------------------------------------------
  25739. *------------------------------------------------------------------------*/
  25740. uiZ:
  25741. uZ.ui = uiZ;
  25742. return uZ.f;
  25743. }
  25744. #endif
  25745. /**** ended inlining ../../source/f128M_to_f32.c ****/
  25746. /**** start inlining ../../source/f128M_to_extF80M.c ****/
  25747. /*============================================================================
  25748. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  25749. Package, Release 3e, by John R. Hauser.
  25750. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  25751. All rights reserved.
  25752. Redistribution and use in source and binary forms, with or without
  25753. modification, are permitted provided that the following conditions are met:
  25754. 1. Redistributions of source code must retain the above copyright notice,
  25755. this list of conditions, and the following disclaimer.
  25756. 2. Redistributions in binary form must reproduce the above copyright notice,
  25757. this list of conditions, and the following disclaimer in the documentation
  25758. and/or other materials provided with the distribution.
  25759. 3. Neither the name of the University nor the names of its contributors may
  25760. be used to endorse or promote products derived from this software without
  25761. specific prior written permission.
  25762. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  25763. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  25764. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  25765. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  25766. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  25767. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25768. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  25769. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25770. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25771. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25772. =============================================================================*/
  25773. #include <stdbool.h>
  25774. #include <stdint.h>
  25775. /**** skipping file: platform.h ****/
  25776. /**** skipping file: internals.h ****/
  25777. /**** skipping file: specialize.h ****/
  25778. /**** skipping file: softfloat.h ****/
  25779. #ifdef SOFTFLOAT_FAST_INT64
  25780. void f128M_to_extF80M( const float128_t *aPtr, extFloat80_t *zPtr )
  25781. {
  25782. *zPtr = f128_to_extF80( *aPtr );
  25783. }
  25784. #else
  25785. void f128M_to_extF80M( const float128_t *aPtr, extFloat80_t *zPtr )
  25786. {
  25787. const uint32_t *aWPtr;
  25788. struct extFloat80M *zSPtr;
  25789. uint32_t uiA96;
  25790. bool sign;
  25791. int32_t exp;
  25792. struct commonNaN commonNaN;
  25793. uint32_t sig[4];
  25794. /*------------------------------------------------------------------------
  25795. *------------------------------------------------------------------------*/
  25796. aWPtr = (const uint32_t *) aPtr;
  25797. zSPtr = (struct extFloat80M *) zPtr;
  25798. /*------------------------------------------------------------------------
  25799. *------------------------------------------------------------------------*/
  25800. uiA96 = aWPtr[indexWordHi( 4 )];
  25801. sign = signF128UI96( uiA96 );
  25802. exp = expF128UI96( uiA96 );
  25803. /*------------------------------------------------------------------------
  25804. *------------------------------------------------------------------------*/
  25805. if ( exp == 0x7FFF ) {
  25806. if ( softfloat_isNaNF128M( aWPtr ) ) {
  25807. softfloat_f128MToCommonNaN( aWPtr, &commonNaN );
  25808. softfloat_commonNaNToExtF80M( &commonNaN, zSPtr );
  25809. return;
  25810. }
  25811. zSPtr->signExp = packToExtF80UI64( sign, 0x7FFF );
  25812. zSPtr->signif = UINT64_C( 0x8000000000000000 );
  25813. return;
  25814. }
  25815. /*------------------------------------------------------------------------
  25816. *------------------------------------------------------------------------*/
  25817. exp = softfloat_shiftNormSigF128M( aWPtr, 15, sig );
  25818. if ( exp == -128 ) {
  25819. zSPtr->signExp = packToExtF80UI64( sign, 0 );
  25820. zSPtr->signif = 0;
  25821. return;
  25822. }
  25823. if ( sig[indexWord( 4, 0 )] ) sig[indexWord( 4, 1 )] |= 1;
  25824. softfloat_roundPackMToExtF80M(
  25825. sign, exp, &sig[indexMultiwordHi( 4, 3 )], 80, zSPtr );
  25826. }
  25827. #endif
  25828. /**** ended inlining ../../source/f128M_to_extF80M.c ****/
  25829. /**** start inlining ../../source/f128M_to_f64.c ****/
  25830. /*============================================================================
  25831. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  25832. Package, Release 3e, by John R. Hauser.
  25833. Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
  25834. California. All rights reserved.
  25835. Redistribution and use in source and binary forms, with or without
  25836. modification, are permitted provided that the following conditions are met:
  25837. 1. Redistributions of source code must retain the above copyright notice,
  25838. this list of conditions, and the following disclaimer.
  25839. 2. Redistributions in binary form must reproduce the above copyright notice,
  25840. this list of conditions, and the following disclaimer in the documentation
  25841. and/or other materials provided with the distribution.
  25842. 3. Neither the name of the University nor the names of its contributors may
  25843. be used to endorse or promote products derived from this software without
  25844. specific prior written permission.
  25845. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  25846. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  25847. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  25848. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  25849. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  25850. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25851. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  25852. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25853. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25854. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25855. =============================================================================*/
  25856. #include <stdbool.h>
  25857. #include <stdint.h>
  25858. /**** skipping file: platform.h ****/
  25859. /**** skipping file: internals.h ****/
  25860. /**** skipping file: specialize.h ****/
  25861. /**** skipping file: softfloat.h ****/
  25862. #ifdef SOFTFLOAT_FAST_INT64
  25863. float64_t f128M_to_f64( const float128_t *aPtr )
  25864. {
  25865. return f128_to_f64( *aPtr );
  25866. }
  25867. #else
  25868. float64_t f128M_to_f64( const float128_t *aPtr )
  25869. {
  25870. const uint32_t *aWPtr;
  25871. uint32_t uiA96;
  25872. bool sign;
  25873. int32_t exp;
  25874. uint64_t frac64;
  25875. struct commonNaN commonNaN;
  25876. uint64_t uiZ;
  25877. uint32_t frac32;
  25878. union ui64_f64 uZ;
  25879. /*------------------------------------------------------------------------
  25880. *------------------------------------------------------------------------*/
  25881. aWPtr = (const uint32_t *) aPtr;
  25882. uiA96 = aWPtr[indexWordHi( 4 )];
  25883. sign = signF128UI96( uiA96 );
  25884. exp = expF128UI96( uiA96 );
  25885. frac64 = (uint64_t) fracF128UI96( uiA96 )<<32 | aWPtr[indexWord( 4, 2 )];
  25886. /*------------------------------------------------------------------------
  25887. *------------------------------------------------------------------------*/
  25888. if ( exp == 0x7FFF ) {
  25889. if ( frac64 || aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )] ) {
  25890. softfloat_f128MToCommonNaN( aWPtr, &commonNaN );
  25891. uiZ = softfloat_commonNaNToF64UI( &commonNaN );
  25892. } else {
  25893. uiZ = packToF64UI( sign, 0x7FF, 0 );
  25894. }
  25895. goto uiZ;
  25896. }
  25897. /*------------------------------------------------------------------------
  25898. *------------------------------------------------------------------------*/
  25899. frac32 = aWPtr[indexWord( 4, 1 )];
  25900. frac64 = frac64<<14 | frac32>>18;
  25901. if ( (frac32 & 0x0003FFFF) || aWPtr[indexWord( 4, 0 )] ) frac64 |= 1;
  25902. if ( ! (exp | frac64) ) {
  25903. uiZ = packToF64UI( sign, 0, 0 );
  25904. goto uiZ;
  25905. }
  25906. /*------------------------------------------------------------------------
  25907. *------------------------------------------------------------------------*/
  25908. exp -= 0x3C01;
  25909. if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
  25910. if ( exp < -0x1000 ) exp = -0x1000;
  25911. }
  25912. return
  25913. softfloat_roundPackToF64(
  25914. sign, exp, frac64 | UINT64_C( 0x4000000000000000 ) );
  25915. /*------------------------------------------------------------------------
  25916. *------------------------------------------------------------------------*/
  25917. uiZ:
  25918. uZ.ui = uiZ;
  25919. return uZ.f;
  25920. }
  25921. #endif
  25922. /**** ended inlining ../../source/f128M_to_f64.c ****/
  25923. /**** start inlining ../../source/f128M_roundToInt.c ****/
  25924. /*============================================================================
  25925. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  25926. Package, Release 3e, by John R. Hauser.
  25927. Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
  25928. California. All rights reserved.
  25929. Redistribution and use in source and binary forms, with or without
  25930. modification, are permitted provided that the following conditions are met:
  25931. 1. Redistributions of source code must retain the above copyright notice,
  25932. this list of conditions, and the following disclaimer.
  25933. 2. Redistributions in binary form must reproduce the above copyright notice,
  25934. this list of conditions, and the following disclaimer in the documentation
  25935. and/or other materials provided with the distribution.
  25936. 3. Neither the name of the University nor the names of its contributors may
  25937. be used to endorse or promote products derived from this software without
  25938. specific prior written permission.
  25939. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  25940. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  25941. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  25942. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  25943. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  25944. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25945. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  25946. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25947. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25948. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25949. =============================================================================*/
  25950. #include <stdbool.h>
  25951. #include <stdint.h>
  25952. /**** skipping file: platform.h ****/
  25953. /**** skipping file: internals.h ****/
  25954. /**** skipping file: specialize.h ****/
  25955. /**** skipping file: softfloat.h ****/
  25956. #ifdef SOFTFLOAT_FAST_INT64
  25957. void
  25958. f128M_roundToInt(
  25959. const float128_t *aPtr,
  25960. uint_fast8_t roundingMode,
  25961. bool exact,
  25962. float128_t *zPtr
  25963. )
  25964. {
  25965. *zPtr = f128_roundToInt( *aPtr, roundingMode, exact );
  25966. }
  25967. #else
  25968. void
  25969. f128M_roundToInt(
  25970. const float128_t *aPtr,
  25971. uint_fast8_t roundingMode,
  25972. bool exact,
  25973. float128_t *zPtr
  25974. )
  25975. {
  25976. const uint32_t *aWPtr;
  25977. uint32_t *zWPtr;
  25978. uint32_t ui96;
  25979. int32_t exp;
  25980. uint32_t sigExtra;
  25981. bool sign;
  25982. uint_fast8_t bitPos;
  25983. bool roundNear;
  25984. unsigned int index, lastIndex;
  25985. bool extra;
  25986. uint32_t wordA, bit, wordZ;
  25987. uint_fast8_t carry;
  25988. uint32_t extrasMask;
  25989. /*------------------------------------------------------------------------
  25990. *------------------------------------------------------------------------*/
  25991. aWPtr = (const uint32_t *) aPtr;
  25992. zWPtr = (uint32_t *) zPtr;
  25993. /*------------------------------------------------------------------------
  25994. *------------------------------------------------------------------------*/
  25995. ui96 = aWPtr[indexWordHi( 4 )];
  25996. exp = expF128UI96( ui96 );
  25997. /*------------------------------------------------------------------------
  25998. *------------------------------------------------------------------------*/
  25999. if ( exp < 0x3FFF ) {
  26000. zWPtr[indexWord( 4, 2 )] = 0;
  26001. zWPtr[indexWord( 4, 1 )] = 0;
  26002. zWPtr[indexWord( 4, 0 )] = 0;
  26003. sigExtra = aWPtr[indexWord( 4, 2 )];
  26004. if ( !sigExtra ) {
  26005. sigExtra = aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )];
  26006. }
  26007. if ( !sigExtra && !(ui96 & 0x7FFFFFFF) ) goto ui96;
  26008. if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
  26009. sign = signF128UI96( ui96 );
  26010. switch ( roundingMode ) {
  26011. case softfloat_round_near_even:
  26012. if ( !fracF128UI96( ui96 ) && !sigExtra ) break;
  26013. case softfloat_round_near_maxMag:
  26014. if ( exp == 0x3FFE ) goto mag1;
  26015. break;
  26016. case softfloat_round_min:
  26017. if ( sign ) goto mag1;
  26018. break;
  26019. case softfloat_round_max:
  26020. if ( !sign ) goto mag1;
  26021. break;
  26022. #ifdef SOFTFLOAT_ROUND_ODD
  26023. case softfloat_round_odd:
  26024. goto mag1;
  26025. #endif
  26026. }
  26027. ui96 = packToF128UI96( sign, 0, 0 );
  26028. goto ui96;
  26029. mag1:
  26030. ui96 = packToF128UI96( sign, 0x3FFF, 0 );
  26031. goto ui96;
  26032. }
  26033. /*------------------------------------------------------------------------
  26034. *------------------------------------------------------------------------*/
  26035. if ( 0x406F <= exp ) {
  26036. if (
  26037. (exp == 0x7FFF)
  26038. && (fracF128UI96( ui96 )
  26039. || (aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
  26040. | aWPtr[indexWord( 4, 0 )]))
  26041. ) {
  26042. softfloat_propagateNaNF128M( aWPtr, 0, zWPtr );
  26043. return;
  26044. }
  26045. zWPtr[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
  26046. zWPtr[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
  26047. zWPtr[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
  26048. goto ui96;
  26049. }
  26050. /*------------------------------------------------------------------------
  26051. *------------------------------------------------------------------------*/
  26052. bitPos = 0x406F - exp;
  26053. roundNear =
  26054. (roundingMode == softfloat_round_near_maxMag)
  26055. || (roundingMode == softfloat_round_near_even);
  26056. bitPos -= roundNear;
  26057. index = indexWordLo( 4 );
  26058. lastIndex = indexWordHi( 4 );
  26059. extra = 0;
  26060. for (;;) {
  26061. wordA = aWPtr[index];
  26062. if ( bitPos < 32 ) break;
  26063. if ( wordA ) extra = 1;
  26064. zWPtr[index] = 0;
  26065. index += wordIncr;
  26066. bitPos -= 32;
  26067. }
  26068. bit = (uint32_t) 1<<bitPos;
  26069. if ( roundNear ) {
  26070. wordZ = wordA + bit;
  26071. carry = (wordZ < wordA);
  26072. bit <<= 1;
  26073. extrasMask = bit - 1;
  26074. if ( exact && (extra || (wordA & extrasMask)) ) {
  26075. softfloat_exceptionFlags |= softfloat_flag_inexact;
  26076. }
  26077. if (
  26078. (roundingMode == softfloat_round_near_even)
  26079. && !extra && !(wordZ & extrasMask)
  26080. ) {
  26081. if ( !bit ) {
  26082. zWPtr[index] = wordZ;
  26083. index += wordIncr;
  26084. wordZ = aWPtr[index] + carry;
  26085. carry &= !wordZ;
  26086. zWPtr[index] = wordZ & ~1;
  26087. goto propagateCarry;
  26088. }
  26089. wordZ &= ~bit;
  26090. }
  26091. } else {
  26092. wordZ = wordA;
  26093. carry = 0;
  26094. extrasMask = bit - 1;
  26095. if ( extra || (wordA & extrasMask) ) {
  26096. if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
  26097. if (
  26098. roundingMode
  26099. == (signF128UI96( ui96 ) ? softfloat_round_min
  26100. : softfloat_round_max)
  26101. ) {
  26102. wordZ += bit;
  26103. carry = (wordZ < wordA);
  26104. #ifdef SOFTFLOAT_ROUND_ODD
  26105. } else if ( roundingMode == softfloat_round_odd ) {
  26106. wordZ |= bit;
  26107. #endif
  26108. }
  26109. }
  26110. }
  26111. wordZ &= ~extrasMask;
  26112. zWPtr[index] = wordZ;
  26113. propagateCarry:
  26114. while ( index != lastIndex ) {
  26115. index += wordIncr;
  26116. wordZ = aWPtr[index] + carry;
  26117. zWPtr[index] = wordZ;
  26118. carry &= !wordZ;
  26119. }
  26120. return;
  26121. /*------------------------------------------------------------------------
  26122. *------------------------------------------------------------------------*/
  26123. ui96:
  26124. zWPtr[indexWordHi( 4 )] = ui96;
  26125. }
  26126. #endif
  26127. /**** ended inlining ../../source/f128M_roundToInt.c ****/
  26128. /**** start inlining ../../source/f128M_add.c ****/
  26129. /*============================================================================
  26130. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  26131. Package, Release 3e, by John R. Hauser.
  26132. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  26133. All rights reserved.
  26134. Redistribution and use in source and binary forms, with or without
  26135. modification, are permitted provided that the following conditions are met:
  26136. 1. Redistributions of source code must retain the above copyright notice,
  26137. this list of conditions, and the following disclaimer.
  26138. 2. Redistributions in binary form must reproduce the above copyright notice,
  26139. this list of conditions, and the following disclaimer in the documentation
  26140. and/or other materials provided with the distribution.
  26141. 3. Neither the name of the University nor the names of its contributors may
  26142. be used to endorse or promote products derived from this software without
  26143. specific prior written permission.
  26144. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  26145. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  26146. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  26147. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  26148. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  26149. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  26150. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  26151. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26152. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  26153. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26154. =============================================================================*/
  26155. #include <stdbool.h>
  26156. #include <stdint.h>
  26157. /**** skipping file: platform.h ****/
  26158. /**** skipping file: internals.h ****/
  26159. /**** skipping file: softfloat.h ****/
  26160. #ifdef SOFTFLOAT_FAST_INT64
  26161. void
  26162. f128M_add( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
  26163. {
  26164. const uint64_t *aWPtr, *bWPtr;
  26165. uint_fast64_t uiA64, uiA0;
  26166. bool signA;
  26167. uint_fast64_t uiB64, uiB0;
  26168. bool signB;
  26169. #if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
  26170. float128_t
  26171. (*magsFuncPtr)(
  26172. uint_fast64_t, uint_fast64_t, uint_fast64_t, uint_fast64_t, bool );
  26173. #endif
  26174. aWPtr = (const uint64_t *) aPtr;
  26175. bWPtr = (const uint64_t *) bPtr;
  26176. uiA64 = aWPtr[indexWord( 2, 1 )];
  26177. uiA0 = aWPtr[indexWord( 2, 0 )];
  26178. signA = signF128UI64( uiA64 );
  26179. uiB64 = bWPtr[indexWord( 2, 1 )];
  26180. uiB0 = bWPtr[indexWord( 2, 0 )];
  26181. signB = signF128UI64( uiB64 );
  26182. #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
  26183. if ( signA == signB ) {
  26184. *zPtr = softfloat_addMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
  26185. } else {
  26186. *zPtr = softfloat_subMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
  26187. }
  26188. #else
  26189. magsFuncPtr =
  26190. (signA == signB) ? softfloat_addMagsF128 : softfloat_subMagsF128;
  26191. *zPtr = (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
  26192. #endif
  26193. }
  26194. #else
  26195. void
  26196. f128M_add( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
  26197. {
  26198. softfloat_addF128M(
  26199. (const uint32_t *) aPtr,
  26200. (const uint32_t *) bPtr,
  26201. (uint32_t *) zPtr,
  26202. false
  26203. );
  26204. }
  26205. #endif
  26206. /**** ended inlining ../../source/f128M_add.c ****/
  26207. /**** start inlining ../../source/f128M_sub.c ****/
  26208. /*============================================================================
  26209. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  26210. Package, Release 3e, by John R. Hauser.
  26211. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  26212. All rights reserved.
  26213. Redistribution and use in source and binary forms, with or without
  26214. modification, are permitted provided that the following conditions are met:
  26215. 1. Redistributions of source code must retain the above copyright notice,
  26216. this list of conditions, and the following disclaimer.
  26217. 2. Redistributions in binary form must reproduce the above copyright notice,
  26218. this list of conditions, and the following disclaimer in the documentation
  26219. and/or other materials provided with the distribution.
  26220. 3. Neither the name of the University nor the names of its contributors may
  26221. be used to endorse or promote products derived from this software without
  26222. specific prior written permission.
  26223. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  26224. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  26225. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  26226. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  26227. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  26228. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  26229. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  26230. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26231. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  26232. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26233. =============================================================================*/
  26234. #include <stdbool.h>
  26235. #include <stdint.h>
  26236. /**** skipping file: platform.h ****/
  26237. /**** skipping file: internals.h ****/
  26238. /**** skipping file: softfloat.h ****/
  26239. #ifdef SOFTFLOAT_FAST_INT64
  26240. void
  26241. f128M_sub( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
  26242. {
  26243. const uint64_t *aWPtr, *bWPtr;
  26244. uint_fast64_t uiA64, uiA0;
  26245. bool signA;
  26246. uint_fast64_t uiB64, uiB0;
  26247. bool signB;
  26248. #if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
  26249. float128_t
  26250. (*magsFuncPtr)(
  26251. uint_fast64_t, uint_fast64_t, uint_fast64_t, uint_fast64_t, bool );
  26252. #endif
  26253. aWPtr = (const uint64_t *) aPtr;
  26254. bWPtr = (const uint64_t *) bPtr;
  26255. uiA64 = aWPtr[indexWord( 2, 1 )];
  26256. uiA0 = aWPtr[indexWord( 2, 0 )];
  26257. signA = signF128UI64( uiA64 );
  26258. uiB64 = bWPtr[indexWord( 2, 1 )];
  26259. uiB0 = bWPtr[indexWord( 2, 0 )];
  26260. signB = signF128UI64( uiB64 );
  26261. #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
  26262. if ( signA == signB ) {
  26263. *zPtr = softfloat_subMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
  26264. } else {
  26265. *zPtr = softfloat_addMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
  26266. }
  26267. #else
  26268. magsFuncPtr =
  26269. (signA == signB) ? softfloat_subMagsF128 : softfloat_addMagsF128;
  26270. *zPtr = (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
  26271. #endif
  26272. }
  26273. #else
  26274. void
  26275. f128M_sub( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
  26276. {
  26277. softfloat_addF128M(
  26278. (const uint32_t *) aPtr,
  26279. (const uint32_t *) bPtr,
  26280. (uint32_t *) zPtr,
  26281. true
  26282. );
  26283. }
  26284. #endif
  26285. /**** ended inlining ../../source/f128M_sub.c ****/
  26286. /**** start inlining ../../source/f128M_mul.c ****/
  26287. /*============================================================================
  26288. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  26289. Package, Release 3e, by John R. Hauser.
  26290. Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
  26291. California. All rights reserved.
  26292. Redistribution and use in source and binary forms, with or without
  26293. modification, are permitted provided that the following conditions are met:
  26294. 1. Redistributions of source code must retain the above copyright notice,
  26295. this list of conditions, and the following disclaimer.
  26296. 2. Redistributions in binary form must reproduce the above copyright notice,
  26297. this list of conditions, and the following disclaimer in the documentation
  26298. and/or other materials provided with the distribution.
  26299. 3. Neither the name of the University nor the names of its contributors may
  26300. be used to endorse or promote products derived from this software without
  26301. specific prior written permission.
  26302. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  26303. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  26304. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  26305. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  26306. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  26307. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  26308. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  26309. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26310. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  26311. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26312. =============================================================================*/
  26313. #include <stdbool.h>
  26314. #include <stdint.h>
  26315. /**** skipping file: platform.h ****/
  26316. /**** skipping file: internals.h ****/
  26317. /**** skipping file: specialize.h ****/
  26318. /**** skipping file: softfloat.h ****/
  26319. #ifdef SOFTFLOAT_FAST_INT64
  26320. void
  26321. f128M_mul( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
  26322. {
  26323. *zPtr = f128_mul( *aPtr, *bPtr );
  26324. }
  26325. #else
  26326. void
  26327. f128M_mul( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
  26328. {
  26329. const uint32_t *aWPtr, *bWPtr;
  26330. uint32_t *zWPtr;
  26331. uint32_t uiA96;
  26332. int32_t expA;
  26333. uint32_t uiB96;
  26334. int32_t expB;
  26335. bool signZ;
  26336. const uint32_t *ptr;
  26337. uint32_t uiZ96, sigA[4];
  26338. uint_fast8_t shiftDist;
  26339. uint32_t sigB[4];
  26340. int32_t expZ;
  26341. uint32_t sigProd[8], *extSigZPtr;
  26342. /*------------------------------------------------------------------------
  26343. *------------------------------------------------------------------------*/
  26344. aWPtr = (const uint32_t *) aPtr;
  26345. bWPtr = (const uint32_t *) bPtr;
  26346. zWPtr = (uint32_t *) zPtr;
  26347. /*------------------------------------------------------------------------
  26348. *------------------------------------------------------------------------*/
  26349. uiA96 = aWPtr[indexWordHi( 4 )];
  26350. expA = expF128UI96( uiA96 );
  26351. uiB96 = bWPtr[indexWordHi( 4 )];
  26352. expB = expF128UI96( uiB96 );
  26353. signZ = signF128UI96( uiA96 ) ^ signF128UI96( uiB96 );
  26354. /*------------------------------------------------------------------------
  26355. *------------------------------------------------------------------------*/
  26356. if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
  26357. if ( softfloat_tryPropagateNaNF128M( aWPtr, bWPtr, zWPtr ) ) return;
  26358. ptr = aWPtr;
  26359. if ( ! expA ) goto possiblyInvalid;
  26360. if ( ! expB ) {
  26361. ptr = bWPtr;
  26362. possiblyInvalid:
  26363. if (
  26364. ! fracF128UI96( ptr[indexWordHi( 4 )] )
  26365. && ! (ptr[indexWord( 4, 2 )] | ptr[indexWord( 4, 1 )]
  26366. | ptr[indexWord( 4, 0 )])
  26367. ) {
  26368. softfloat_invalidF128M( zWPtr );
  26369. return;
  26370. }
  26371. }
  26372. uiZ96 = packToF128UI96( signZ, 0x7FFF, 0 );
  26373. goto uiZ96;
  26374. }
  26375. /*------------------------------------------------------------------------
  26376. *------------------------------------------------------------------------*/
  26377. if ( expA ) {
  26378. sigA[indexWordHi( 4 )] = fracF128UI96( uiA96 ) | 0x00010000;
  26379. sigA[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
  26380. sigA[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
  26381. sigA[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
  26382. } else {
  26383. expA = softfloat_shiftNormSigF128M( aWPtr, 0, sigA );
  26384. if ( expA == -128 ) goto zero;
  26385. }
  26386. if ( expB ) {
  26387. sigB[indexWordHi( 4 )] = fracF128UI96( uiB96 ) | 0x00010000;
  26388. sigB[indexWord( 4, 2 )] = bWPtr[indexWord( 4, 2 )];
  26389. sigB[indexWord( 4, 1 )] = bWPtr[indexWord( 4, 1 )];
  26390. sigB[indexWord( 4, 0 )] = bWPtr[indexWord( 4, 0 )];
  26391. } else {
  26392. expB = softfloat_shiftNormSigF128M( bWPtr, 0, sigB );
  26393. if ( expB == -128 ) goto zero;
  26394. }
  26395. /*------------------------------------------------------------------------
  26396. *------------------------------------------------------------------------*/
  26397. expZ = expA + expB - 0x4000;
  26398. softfloat_mul128MTo256M( sigA, sigB, sigProd );
  26399. if (
  26400. sigProd[indexWord( 8, 2 )]
  26401. || (sigProd[indexWord( 8, 1 )] | sigProd[indexWord( 8, 0 )])
  26402. ) {
  26403. sigProd[indexWord( 8, 3 )] |= 1;
  26404. }
  26405. extSigZPtr = &sigProd[indexMultiwordHi( 8, 5 )];
  26406. shiftDist = 16;
  26407. if ( extSigZPtr[indexWordHi( 5 )] & 2 ) {
  26408. ++expZ;
  26409. shiftDist = 15;
  26410. }
  26411. softfloat_shortShiftLeft160M( extSigZPtr, shiftDist, extSigZPtr );
  26412. softfloat_roundPackMToF128M( signZ, expZ, extSigZPtr, zWPtr );
  26413. return;
  26414. /*------------------------------------------------------------------------
  26415. *------------------------------------------------------------------------*/
  26416. zero:
  26417. uiZ96 = packToF128UI96( signZ, 0, 0 );
  26418. uiZ96:
  26419. zWPtr[indexWordHi( 4 )] = uiZ96;
  26420. zWPtr[indexWord( 4, 2 )] = 0;
  26421. zWPtr[indexWord( 4, 1 )] = 0;
  26422. zWPtr[indexWord( 4, 0 )] = 0;
  26423. }
  26424. #endif
  26425. /**** ended inlining ../../source/f128M_mul.c ****/
  26426. /**** start inlining ../../source/f128M_mulAdd.c ****/
  26427. /*============================================================================
  26428. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  26429. Package, Release 3e, by John R. Hauser.
  26430. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  26431. All rights reserved.
  26432. Redistribution and use in source and binary forms, with or without
  26433. modification, are permitted provided that the following conditions are met:
  26434. 1. Redistributions of source code must retain the above copyright notice,
  26435. this list of conditions, and the following disclaimer.
  26436. 2. Redistributions in binary form must reproduce the above copyright notice,
  26437. this list of conditions, and the following disclaimer in the documentation
  26438. and/or other materials provided with the distribution.
  26439. 3. Neither the name of the University nor the names of its contributors may
  26440. be used to endorse or promote products derived from this software without
  26441. specific prior written permission.
  26442. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  26443. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  26444. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  26445. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  26446. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  26447. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  26448. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  26449. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26450. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  26451. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26452. =============================================================================*/
  26453. #include <stdint.h>
  26454. /**** skipping file: platform.h ****/
  26455. /**** skipping file: internals.h ****/
  26456. /**** skipping file: softfloat.h ****/
  26457. #ifdef SOFTFLOAT_FAST_INT64
  26458. void
  26459. f128M_mulAdd(
  26460. const float128_t *aPtr,
  26461. const float128_t *bPtr,
  26462. const float128_t *cPtr,
  26463. float128_t *zPtr
  26464. )
  26465. {
  26466. const uint64_t *aWPtr, *bWPtr, *cWPtr;
  26467. uint_fast64_t uiA64, uiA0;
  26468. uint_fast64_t uiB64, uiB0;
  26469. uint_fast64_t uiC64, uiC0;
  26470. aWPtr = (const uint64_t *) aPtr;
  26471. bWPtr = (const uint64_t *) bPtr;
  26472. cWPtr = (const uint64_t *) cPtr;
  26473. uiA64 = aWPtr[indexWord( 2, 1 )];
  26474. uiA0 = aWPtr[indexWord( 2, 0 )];
  26475. uiB64 = bWPtr[indexWord( 2, 1 )];
  26476. uiB0 = bWPtr[indexWord( 2, 0 )];
  26477. uiC64 = cWPtr[indexWord( 2, 1 )];
  26478. uiC0 = cWPtr[indexWord( 2, 0 )];
  26479. *zPtr = softfloat_mulAddF128( uiA64, uiA0, uiB64, uiB0, uiC64, uiC0, 0 );
  26480. }
  26481. #else
  26482. void
  26483. f128M_mulAdd(
  26484. const float128_t *aPtr,
  26485. const float128_t *bPtr,
  26486. const float128_t *cPtr,
  26487. float128_t *zPtr
  26488. )
  26489. {
  26490. softfloat_mulAddF128M(
  26491. (const uint32_t *) aPtr,
  26492. (const uint32_t *) bPtr,
  26493. (const uint32_t *) cPtr,
  26494. (uint32_t *) zPtr,
  26495. 0
  26496. );
  26497. }
  26498. #endif
  26499. /**** ended inlining ../../source/f128M_mulAdd.c ****/
  26500. /**** start inlining ../../source/f128M_div.c ****/
  26501. /*============================================================================
  26502. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  26503. Package, Release 3e, by John R. Hauser.
  26504. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  26505. All rights reserved.
  26506. Redistribution and use in source and binary forms, with or without
  26507. modification, are permitted provided that the following conditions are met:
  26508. 1. Redistributions of source code must retain the above copyright notice,
  26509. this list of conditions, and the following disclaimer.
  26510. 2. Redistributions in binary form must reproduce the above copyright notice,
  26511. this list of conditions, and the following disclaimer in the documentation
  26512. and/or other materials provided with the distribution.
  26513. 3. Neither the name of the University nor the names of its contributors may
  26514. be used to endorse or promote products derived from this software without
  26515. specific prior written permission.
  26516. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  26517. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  26518. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  26519. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  26520. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  26521. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  26522. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  26523. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26524. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  26525. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26526. =============================================================================*/
  26527. #include <stdbool.h>
  26528. #include <stdint.h>
  26529. /**** skipping file: platform.h ****/
  26530. /**** skipping file: internals.h ****/
  26531. /**** skipping file: specialize.h ****/
  26532. /**** skipping file: softfloat.h ****/
  26533. #ifdef SOFTFLOAT_FAST_INT64
  26534. void
  26535. f128M_div( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
  26536. {
  26537. *zPtr = f128_div( *aPtr, *bPtr );
  26538. }
  26539. #else
  26540. void
  26541. f128M_div( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
  26542. {
  26543. const uint32_t *aWPtr, *bWPtr;
  26544. uint32_t *zWPtr, uiA96;
  26545. bool signA;
  26546. int32_t expA;
  26547. uint32_t uiB96;
  26548. bool signB;
  26549. int32_t expB;
  26550. bool signZ;
  26551. uint32_t y[5], sigB[4];
  26552. int32_t expZ;
  26553. uint32_t recip32;
  26554. int ix;
  26555. uint64_t q64;
  26556. uint32_t q, qs[3], uiZ96;
  26557. /*------------------------------------------------------------------------
  26558. *------------------------------------------------------------------------*/
  26559. aWPtr = (const uint32_t *) aPtr;
  26560. bWPtr = (const uint32_t *) bPtr;
  26561. zWPtr = (uint32_t *) zPtr;
  26562. /*------------------------------------------------------------------------
  26563. *------------------------------------------------------------------------*/
  26564. uiA96 = aWPtr[indexWordHi( 4 )];
  26565. signA = signF128UI96( uiA96 );
  26566. expA = expF128UI96( uiA96 );
  26567. uiB96 = bWPtr[indexWordHi( 4 )];
  26568. signB = signF128UI96( uiB96 );
  26569. expB = expF128UI96( uiB96 );
  26570. signZ = signA ^ signB;
  26571. /*------------------------------------------------------------------------
  26572. *------------------------------------------------------------------------*/
  26573. if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
  26574. if ( softfloat_tryPropagateNaNF128M( aWPtr, bWPtr, zWPtr ) ) return;
  26575. if ( expA == 0x7FFF ) {
  26576. if ( expB == 0x7FFF ) goto invalid;
  26577. goto infinity;
  26578. }
  26579. goto zero;
  26580. }
  26581. /*------------------------------------------------------------------------
  26582. *------------------------------------------------------------------------*/
  26583. expA = softfloat_shiftNormSigF128M( aWPtr, 13, y );
  26584. expB = softfloat_shiftNormSigF128M( bWPtr, 13, sigB );
  26585. if ( expA == -128 ) {
  26586. if ( expB == -128 ) goto invalid;
  26587. goto zero;
  26588. }
  26589. if ( expB == -128 ) {
  26590. softfloat_raiseFlags( softfloat_flag_infinite );
  26591. goto infinity;
  26592. }
  26593. /*------------------------------------------------------------------------
  26594. *------------------------------------------------------------------------*/
  26595. expZ = expA - expB + 0x3FFE;
  26596. if ( softfloat_compare128M( y, sigB ) < 0 ) {
  26597. --expZ;
  26598. softfloat_add128M( y, y, y );
  26599. }
  26600. recip32 =
  26601. softfloat_approxRecip32_1(
  26602. ((uint64_t) sigB[indexWord( 4, 3 )]<<32 | sigB[indexWord( 4, 2 )])
  26603. >>30
  26604. );
  26605. ix = 3;
  26606. for (;;) {
  26607. q64 = (uint64_t) y[indexWordHi( 4 )] * recip32;
  26608. q = (q64 + 0x80000000)>>32;
  26609. --ix;
  26610. if ( ix < 0 ) break;
  26611. softfloat_remStep128MBy32( y, 29, sigB, q, y );
  26612. if ( y[indexWordHi( 4 )] & 0x80000000 ) {
  26613. --q;
  26614. softfloat_add128M( y, sigB, y );
  26615. }
  26616. qs[ix] = q;
  26617. }
  26618. /*------------------------------------------------------------------------
  26619. *------------------------------------------------------------------------*/
  26620. if ( ((q + 1) & 7) < 2 ) {
  26621. softfloat_remStep128MBy32( y, 29, sigB, q, y );
  26622. if ( y[indexWordHi( 4 )] & 0x80000000 ) {
  26623. --q;
  26624. softfloat_add128M( y, sigB, y );
  26625. } else if ( softfloat_compare128M( sigB, y ) <= 0 ) {
  26626. ++q;
  26627. softfloat_sub128M( y, sigB, y );
  26628. }
  26629. if (
  26630. y[indexWordLo( 4 )] || y[indexWord( 4, 1 )]
  26631. || (y[indexWord( 4, 2 )] | y[indexWord( 4, 3 )])
  26632. ) {
  26633. q |= 1;
  26634. }
  26635. }
  26636. /*------------------------------------------------------------------------
  26637. *------------------------------------------------------------------------*/
  26638. q64 = (uint64_t) q<<28;
  26639. y[indexWord( 5, 0 )] = q64;
  26640. q64 = ((uint64_t) qs[0]<<25) + (q64>>32);
  26641. y[indexWord( 5, 1 )] = q64;
  26642. q64 = ((uint64_t) qs[1]<<22) + (q64>>32);
  26643. y[indexWord( 5, 2 )] = q64;
  26644. q64 = ((uint64_t) qs[2]<<19) + (q64>>32);
  26645. y[indexWord( 5, 3 )] = q64;
  26646. y[indexWord( 5, 4 )] = q64>>32;
  26647. softfloat_roundPackMToF128M( signZ, expZ, y, zWPtr );
  26648. return;
  26649. /*------------------------------------------------------------------------
  26650. *------------------------------------------------------------------------*/
  26651. invalid:
  26652. softfloat_invalidF128M( zWPtr );
  26653. return;
  26654. /*------------------------------------------------------------------------
  26655. *------------------------------------------------------------------------*/
  26656. infinity:
  26657. uiZ96 = packToF128UI96( signZ, 0x7FFF, 0 );
  26658. goto uiZ96;
  26659. zero:
  26660. uiZ96 = packToF128UI96( signZ, 0, 0 );
  26661. uiZ96:
  26662. zWPtr[indexWordHi( 4 )] = uiZ96;
  26663. zWPtr[indexWord( 4, 2 )] = 0;
  26664. zWPtr[indexWord( 4, 1 )] = 0;
  26665. zWPtr[indexWord( 4, 0 )] = 0;
  26666. }
  26667. #endif
  26668. /**** ended inlining ../../source/f128M_div.c ****/
  26669. /**** start inlining ../../source/f128M_rem.c ****/
  26670. /*============================================================================
  26671. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  26672. Package, Release 3e, by John R. Hauser.
  26673. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  26674. All rights reserved.
  26675. Redistribution and use in source and binary forms, with or without
  26676. modification, are permitted provided that the following conditions are met:
  26677. 1. Redistributions of source code must retain the above copyright notice,
  26678. this list of conditions, and the following disclaimer.
  26679. 2. Redistributions in binary form must reproduce the above copyright notice,
  26680. this list of conditions, and the following disclaimer in the documentation
  26681. and/or other materials provided with the distribution.
  26682. 3. Neither the name of the University nor the names of its contributors may
  26683. be used to endorse or promote products derived from this software without
  26684. specific prior written permission.
  26685. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  26686. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  26687. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  26688. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  26689. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  26690. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  26691. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  26692. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26693. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  26694. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26695. =============================================================================*/
  26696. #include <stdbool.h>
  26697. #include <stdint.h>
  26698. /**** skipping file: platform.h ****/
  26699. /**** skipping file: internals.h ****/
  26700. /**** skipping file: specialize.h ****/
  26701. /**** skipping file: softfloat.h ****/
  26702. #ifdef SOFTFLOAT_FAST_INT64
  26703. void
  26704. f128M_rem( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
  26705. {
  26706. *zPtr = f128_rem( *aPtr, *bPtr );
  26707. }
  26708. #else
  26709. void
  26710. f128M_rem( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
  26711. {
  26712. const uint32_t *aWPtr, *bWPtr;
  26713. uint32_t *zWPtr, uiA96;
  26714. int32_t expA, expB;
  26715. uint32_t x[4], rem1[5], *remPtr;
  26716. bool signRem;
  26717. int32_t expDiff;
  26718. uint32_t q, recip32;
  26719. uint64_t q64;
  26720. uint32_t rem2[5], *altRemPtr, *newRemPtr, wordMeanRem;
  26721. /*------------------------------------------------------------------------
  26722. *------------------------------------------------------------------------*/
  26723. aWPtr = (const uint32_t *) aPtr;
  26724. bWPtr = (const uint32_t *) bPtr;
  26725. zWPtr = (uint32_t *) zPtr;
  26726. /*------------------------------------------------------------------------
  26727. *------------------------------------------------------------------------*/
  26728. uiA96 = aWPtr[indexWordHi( 4 )];
  26729. expA = expF128UI96( uiA96 );
  26730. expB = expF128UI96( bWPtr[indexWordHi( 4 )] );
  26731. /*------------------------------------------------------------------------
  26732. *------------------------------------------------------------------------*/
  26733. if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
  26734. if ( softfloat_tryPropagateNaNF128M( aWPtr, bWPtr, zWPtr ) ) return;
  26735. if ( expA == 0x7FFF ) goto invalid;
  26736. goto copyA;
  26737. }
  26738. /*------------------------------------------------------------------------
  26739. *------------------------------------------------------------------------*/
  26740. if ( expA < expB - 1 ) goto copyA;
  26741. /*------------------------------------------------------------------------
  26742. *------------------------------------------------------------------------*/
  26743. expB = softfloat_shiftNormSigF128M( bWPtr, 13, x );
  26744. if ( expB == -128 ) goto invalid;
  26745. remPtr = &rem1[indexMultiwordLo( 5, 4 )];
  26746. expA = softfloat_shiftNormSigF128M( aWPtr, 13, remPtr );
  26747. if ( expA == -128 ) goto copyA;
  26748. signRem = signF128UI96( uiA96 );
  26749. /*------------------------------------------------------------------------
  26750. *------------------------------------------------------------------------*/
  26751. expDiff = expA - expB;
  26752. if ( expDiff < 1 ) {
  26753. if ( expDiff < -1 ) goto copyA;
  26754. if ( expDiff ) {
  26755. --expB;
  26756. softfloat_add128M( x, x, x );
  26757. q = 0;
  26758. } else {
  26759. q = (softfloat_compare128M( x, remPtr ) <= 0);
  26760. if ( q ) softfloat_sub128M( remPtr, x, remPtr );
  26761. }
  26762. } else {
  26763. recip32 =
  26764. softfloat_approxRecip32_1(
  26765. ((uint64_t) x[indexWord( 4, 3 )]<<32 | x[indexWord( 4, 2 )])
  26766. >>30
  26767. );
  26768. expDiff -= 30;
  26769. for (;;) {
  26770. q64 = (uint64_t) remPtr[indexWordHi( 4 )] * recip32;
  26771. if ( expDiff < 0 ) break;
  26772. q = (q64 + 0x80000000)>>32;
  26773. softfloat_remStep128MBy32( remPtr, 29, x, q, remPtr );
  26774. if ( remPtr[indexWordHi( 4 )] & 0x80000000 ) {
  26775. softfloat_add128M( remPtr, x, remPtr );
  26776. }
  26777. expDiff -= 29;
  26778. }
  26779. /*--------------------------------------------------------------------
  26780. | (`expDiff' cannot be less than -29 here.)
  26781. *--------------------------------------------------------------------*/
  26782. q = (uint32_t) (q64>>32)>>(~expDiff & 31);
  26783. softfloat_remStep128MBy32( remPtr, expDiff + 30, x, q, remPtr );
  26784. if ( remPtr[indexWordHi( 4 )] & 0x80000000 ) {
  26785. altRemPtr = &rem2[indexMultiwordLo( 5, 4 )];
  26786. softfloat_add128M( remPtr, x, altRemPtr );
  26787. goto selectRem;
  26788. }
  26789. }
  26790. /*------------------------------------------------------------------------
  26791. *------------------------------------------------------------------------*/
  26792. altRemPtr = &rem2[indexMultiwordLo( 5, 4 )];
  26793. do {
  26794. ++q;
  26795. newRemPtr = altRemPtr;
  26796. softfloat_sub128M( remPtr, x, newRemPtr );
  26797. altRemPtr = remPtr;
  26798. remPtr = newRemPtr;
  26799. } while ( ! (remPtr[indexWordHi( 4 )] & 0x80000000) );
  26800. selectRem:
  26801. softfloat_add128M( remPtr, altRemPtr, x );
  26802. wordMeanRem = x[indexWordHi( 4 )];
  26803. if (
  26804. (wordMeanRem & 0x80000000)
  26805. || (! wordMeanRem && (q & 1) && ! x[indexWord( 4, 0 )]
  26806. && ! (x[indexWord( 4, 2 )] | x[indexWord( 4, 1 )]))
  26807. ) {
  26808. remPtr = altRemPtr;
  26809. }
  26810. if ( remPtr[indexWordHi( 4 )] & 0x80000000 ) {
  26811. signRem = ! signRem;
  26812. softfloat_negX128M( remPtr );
  26813. }
  26814. remPtr -= indexMultiwordLo( 5, 4 );
  26815. remPtr[indexWordHi( 5 )] = 0;
  26816. softfloat_normRoundPackMToF128M( signRem, expB + 18, remPtr, zWPtr );
  26817. return;
  26818. /*------------------------------------------------------------------------
  26819. *------------------------------------------------------------------------*/
  26820. invalid:
  26821. softfloat_invalidF128M( zWPtr );
  26822. return;
  26823. /*------------------------------------------------------------------------
  26824. *------------------------------------------------------------------------*/
  26825. copyA:
  26826. zWPtr[indexWordHi( 4 )] = uiA96;
  26827. zWPtr[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
  26828. zWPtr[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
  26829. zWPtr[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
  26830. }
  26831. #endif
  26832. /**** ended inlining ../../source/f128M_rem.c ****/
  26833. /**** start inlining ../../source/f128M_sqrt.c ****/
  26834. /*============================================================================
  26835. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  26836. Package, Release 3e, by John R. Hauser.
  26837. Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
  26838. California. All rights reserved.
  26839. Redistribution and use in source and binary forms, with or without
  26840. modification, are permitted provided that the following conditions are met:
  26841. 1. Redistributions of source code must retain the above copyright notice,
  26842. this list of conditions, and the following disclaimer.
  26843. 2. Redistributions in binary form must reproduce the above copyright notice,
  26844. this list of conditions, and the following disclaimer in the documentation
  26845. and/or other materials provided with the distribution.
  26846. 3. Neither the name of the University nor the names of its contributors may
  26847. be used to endorse or promote products derived from this software without
  26848. specific prior written permission.
  26849. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  26850. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  26851. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  26852. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  26853. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  26854. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  26855. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  26856. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26857. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  26858. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26859. =============================================================================*/
  26860. #include <stdbool.h>
  26861. #include <stdint.h>
  26862. /**** skipping file: platform.h ****/
  26863. /**** skipping file: internals.h ****/
  26864. /**** skipping file: specialize.h ****/
  26865. /**** skipping file: softfloat.h ****/
  26866. #ifdef SOFTFLOAT_FAST_INT64
  26867. void f128M_sqrt( const float128_t *aPtr, float128_t *zPtr )
  26868. {
  26869. *zPtr = f128_sqrt( *aPtr );
  26870. }
  26871. #else
  26872. void f128M_sqrt( const float128_t *aPtr, float128_t *zPtr )
  26873. {
  26874. const uint32_t *aWPtr;
  26875. uint32_t *zWPtr;
  26876. uint32_t uiA96;
  26877. bool signA;
  26878. int32_t rawExpA;
  26879. uint32_t rem[6];
  26880. int32_t expA, expZ;
  26881. uint64_t rem64;
  26882. uint32_t sig32A, recipSqrt32, sig32Z, qs[3], q;
  26883. uint64_t sig64Z;
  26884. uint32_t term[5];
  26885. uint64_t x64;
  26886. uint32_t y[5], rem32;
  26887. /*------------------------------------------------------------------------
  26888. *------------------------------------------------------------------------*/
  26889. aWPtr = (const uint32_t *) aPtr;
  26890. zWPtr = (uint32_t *) zPtr;
  26891. /*------------------------------------------------------------------------
  26892. *------------------------------------------------------------------------*/
  26893. uiA96 = aWPtr[indexWordHi( 4 )];
  26894. signA = signF128UI96( uiA96 );
  26895. rawExpA = expF128UI96( uiA96 );
  26896. /*------------------------------------------------------------------------
  26897. *------------------------------------------------------------------------*/
  26898. if ( rawExpA == 0x7FFF ) {
  26899. if (
  26900. fracF128UI96( uiA96 )
  26901. || (aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
  26902. | aWPtr[indexWord( 4, 0 )])
  26903. ) {
  26904. softfloat_propagateNaNF128M( aWPtr, 0, zWPtr );
  26905. return;
  26906. }
  26907. if ( ! signA ) goto copyA;
  26908. goto invalid;
  26909. }
  26910. /*------------------------------------------------------------------------
  26911. *------------------------------------------------------------------------*/
  26912. expA = softfloat_shiftNormSigF128M( aWPtr, 13 - (rawExpA & 1), rem );
  26913. if ( expA == -128 ) goto copyA;
  26914. if ( signA ) goto invalid;
  26915. /*------------------------------------------------------------------------
  26916. | (`sig32Z' is guaranteed to be a lower bound on the square root of
  26917. | `sig32A', which makes `sig32Z' also a lower bound on the square root of
  26918. | `sigA'.)
  26919. *------------------------------------------------------------------------*/
  26920. expZ = ((expA - 0x3FFF)>>1) + 0x3FFE;
  26921. expA &= 1;
  26922. rem64 = (uint64_t) rem[indexWord( 4, 3 )]<<32 | rem[indexWord( 4, 2 )];
  26923. if ( expA ) {
  26924. if ( ! rawExpA ) {
  26925. softfloat_shortShiftRight128M( rem, 1, rem );
  26926. rem64 >>= 1;
  26927. }
  26928. sig32A = rem64>>29;
  26929. } else {
  26930. sig32A = rem64>>30;
  26931. }
  26932. recipSqrt32 = softfloat_approxRecipSqrt32_1( expA, sig32A );
  26933. sig32Z = ((uint64_t) sig32A * recipSqrt32)>>32;
  26934. if ( expA ) sig32Z >>= 1;
  26935. qs[2] = sig32Z;
  26936. rem64 -= (uint64_t) sig32Z * sig32Z;
  26937. rem[indexWord( 4, 3 )] = rem64>>32;
  26938. rem[indexWord( 4, 2 )] = rem64;
  26939. /*------------------------------------------------------------------------
  26940. *------------------------------------------------------------------------*/
  26941. q = ((uint32_t) (rem64>>2) * (uint64_t) recipSqrt32)>>32;
  26942. sig64Z = ((uint64_t) sig32Z<<32) + ((uint64_t) q<<3);
  26943. term[indexWord( 4, 3 )] = 0;
  26944. term[indexWord( 4, 0 )] = 0;
  26945. /*------------------------------------------------------------------------
  26946. | (Repeating this loop is a rare occurrence.)
  26947. *------------------------------------------------------------------------*/
  26948. for (;;) {
  26949. x64 = ((uint64_t) sig32Z<<32) + sig64Z;
  26950. term[indexWord( 4, 2 )] = x64>>32;
  26951. term[indexWord( 4, 1 )] = x64;
  26952. softfloat_remStep128MBy32( rem, 29, term, q, y );
  26953. rem32 = y[indexWord( 4, 3 )];
  26954. if ( ! (rem32 & 0x80000000) ) break;
  26955. --q;
  26956. sig64Z -= 1<<3;
  26957. }
  26958. qs[1] = q;
  26959. rem64 = (uint64_t) rem32<<32 | y[indexWord( 4, 2 )];
  26960. /*------------------------------------------------------------------------
  26961. *------------------------------------------------------------------------*/
  26962. q = ((uint32_t) (rem64>>2) * (uint64_t) recipSqrt32)>>32;
  26963. if ( rem64>>34 ) q += recipSqrt32;
  26964. sig64Z <<= 1;
  26965. /*------------------------------------------------------------------------
  26966. | (Repeating this loop is a rare occurrence.)
  26967. *------------------------------------------------------------------------*/
  26968. for (;;) {
  26969. x64 = sig64Z + (q>>26);
  26970. term[indexWord( 4, 2 )] = x64>>32;
  26971. term[indexWord( 4, 1 )] = x64;
  26972. term[indexWord( 4, 0 )] = q<<6;
  26973. softfloat_remStep128MBy32(
  26974. y, 29, term, q, &rem[indexMultiwordHi( 6, 4 )] );
  26975. rem32 = rem[indexWordHi( 6 )];
  26976. if ( ! (rem32 & 0x80000000) ) break;
  26977. --q;
  26978. }
  26979. qs[0] = q;
  26980. rem64 = (uint64_t) rem32<<32 | rem[indexWord( 6, 4 )];
  26981. /*------------------------------------------------------------------------
  26982. *------------------------------------------------------------------------*/
  26983. q = (((uint32_t) (rem64>>2) * (uint64_t) recipSqrt32)>>32) + 2;
  26984. if ( rem64>>34 ) q += recipSqrt32;
  26985. x64 = (uint64_t) q<<27;
  26986. y[indexWord( 5, 0 )] = x64;
  26987. x64 = ((uint64_t) qs[0]<<24) + (x64>>32);
  26988. y[indexWord( 5, 1 )] = x64;
  26989. x64 = ((uint64_t) qs[1]<<21) + (x64>>32);
  26990. y[indexWord( 5, 2 )] = x64;
  26991. x64 = ((uint64_t) qs[2]<<18) + (x64>>32);
  26992. y[indexWord( 5, 3 )] = x64;
  26993. y[indexWord( 5, 4 )] = x64>>32;
  26994. /*------------------------------------------------------------------------
  26995. *------------------------------------------------------------------------*/
  26996. if ( (q & 0xF) <= 2 ) {
  26997. q &= ~3;
  26998. y[indexWordLo( 5 )] = q<<27;
  26999. term[indexWord( 5, 4 )] = 0;
  27000. term[indexWord( 5, 3 )] = 0;
  27001. term[indexWord( 5, 2 )] = 0;
  27002. term[indexWord( 5, 1 )] = q>>6;
  27003. term[indexWord( 5, 0 )] = q<<26;
  27004. softfloat_sub160M( y, term, term );
  27005. rem[indexWord( 6, 1 )] = 0;
  27006. rem[indexWord( 6, 0 )] = 0;
  27007. softfloat_remStep160MBy32(
  27008. &rem[indexMultiwordLo( 6, 5 )],
  27009. 14,
  27010. term,
  27011. q,
  27012. &rem[indexMultiwordLo( 6, 5 )]
  27013. );
  27014. rem32 = rem[indexWord( 6, 4 )];
  27015. if ( rem32 & 0x80000000 ) {
  27016. softfloat_sub1X160M( y );
  27017. } else {
  27018. if (
  27019. rem32 || rem[indexWord( 6, 0 )] || rem[indexWord( 6, 1 )]
  27020. || (rem[indexWord( 6, 3 )] | rem[indexWord( 6, 2 )])
  27021. ) {
  27022. y[indexWordLo( 5 )] |= 1;
  27023. }
  27024. }
  27025. }
  27026. softfloat_roundPackMToF128M( 0, expZ, y, zWPtr );
  27027. return;
  27028. /*------------------------------------------------------------------------
  27029. *------------------------------------------------------------------------*/
  27030. invalid:
  27031. softfloat_invalidF128M( zWPtr );
  27032. return;
  27033. /*------------------------------------------------------------------------
  27034. *------------------------------------------------------------------------*/
  27035. copyA:
  27036. zWPtr[indexWordHi( 4 )] = uiA96;
  27037. zWPtr[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
  27038. zWPtr[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
  27039. zWPtr[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
  27040. }
  27041. #endif
  27042. /**** ended inlining ../../source/f128M_sqrt.c ****/
  27043. /**** start inlining ../../source/f128M_eq.c ****/
  27044. /*============================================================================
  27045. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  27046. Package, Release 3e, by John R. Hauser.
  27047. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  27048. All rights reserved.
  27049. Redistribution and use in source and binary forms, with or without
  27050. modification, are permitted provided that the following conditions are met:
  27051. 1. Redistributions of source code must retain the above copyright notice,
  27052. this list of conditions, and the following disclaimer.
  27053. 2. Redistributions in binary form must reproduce the above copyright notice,
  27054. this list of conditions, and the following disclaimer in the documentation
  27055. and/or other materials provided with the distribution.
  27056. 3. Neither the name of the University nor the names of its contributors may
  27057. be used to endorse or promote products derived from this software without
  27058. specific prior written permission.
  27059. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  27060. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  27061. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  27062. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  27063. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  27064. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  27065. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  27066. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27067. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  27068. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27069. =============================================================================*/
  27070. #include <stdbool.h>
  27071. #include <stdint.h>
  27072. /**** skipping file: platform.h ****/
  27073. /**** skipping file: internals.h ****/
  27074. /**** skipping file: specialize.h ****/
  27075. /**** skipping file: softfloat.h ****/
  27076. #ifdef SOFTFLOAT_FAST_INT64
  27077. bool f128M_eq( const float128_t *aPtr, const float128_t *bPtr )
  27078. {
  27079. return f128_eq( *aPtr, *bPtr );
  27080. }
  27081. #else
  27082. bool f128M_eq( const float128_t *aPtr, const float128_t *bPtr )
  27083. {
  27084. const uint32_t *aWPtr, *bWPtr;
  27085. uint32_t wordA, wordB, uiA96, uiB96;
  27086. bool possibleOppositeZeros;
  27087. uint32_t mashWord;
  27088. aWPtr = (const uint32_t *) aPtr;
  27089. bWPtr = (const uint32_t *) bPtr;
  27090. wordA = aWPtr[indexWord( 4, 2 )];
  27091. wordB = bWPtr[indexWord( 4, 2 )];
  27092. if ( wordA != wordB ) goto false_checkSigNaNs;
  27093. uiA96 = aWPtr[indexWordHi( 4 )];
  27094. uiB96 = bWPtr[indexWordHi( 4 )];
  27095. possibleOppositeZeros = false;
  27096. if ( uiA96 != uiB96 ) {
  27097. possibleOppositeZeros = (((uiA96 | uiB96) & 0x7FFFFFFF) == 0);
  27098. if ( ! possibleOppositeZeros ) goto false_checkSigNaNs;
  27099. }
  27100. mashWord = wordA | wordB;
  27101. wordA = aWPtr[indexWord( 4, 1 )];
  27102. wordB = bWPtr[indexWord( 4, 1 )];
  27103. if ( wordA != wordB ) goto false_checkSigNaNs;
  27104. mashWord |= wordA | wordB;
  27105. wordA = aWPtr[indexWord( 4, 0 )];
  27106. wordB = bWPtr[indexWord( 4, 0 )];
  27107. if ( wordA != wordB ) goto false_checkSigNaNs;
  27108. if ( possibleOppositeZeros && ((mashWord | wordA | wordB) != 0) ) {
  27109. goto false_checkSigNaNs;
  27110. }
  27111. if ( ! softfloat_isNaNF128M( aWPtr ) && ! softfloat_isNaNF128M( bWPtr ) ) {
  27112. return true;
  27113. }
  27114. false_checkSigNaNs:
  27115. if (
  27116. f128M_isSignalingNaN( (const float128_t *) aWPtr )
  27117. || f128M_isSignalingNaN( (const float128_t *) bWPtr )
  27118. ) {
  27119. softfloat_raiseFlags( softfloat_flag_invalid );
  27120. }
  27121. return false;
  27122. }
  27123. #endif
  27124. /**** ended inlining ../../source/f128M_eq.c ****/
  27125. /**** start inlining ../../source/f128M_le.c ****/
  27126. /*============================================================================
  27127. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  27128. Package, Release 3e, by John R. Hauser.
  27129. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  27130. All rights reserved.
  27131. Redistribution and use in source and binary forms, with or without
  27132. modification, are permitted provided that the following conditions are met:
  27133. 1. Redistributions of source code must retain the above copyright notice,
  27134. this list of conditions, and the following disclaimer.
  27135. 2. Redistributions in binary form must reproduce the above copyright notice,
  27136. this list of conditions, and the following disclaimer in the documentation
  27137. and/or other materials provided with the distribution.
  27138. 3. Neither the name of the University nor the names of its contributors may
  27139. be used to endorse or promote products derived from this software without
  27140. specific prior written permission.
  27141. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  27142. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  27143. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  27144. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  27145. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  27146. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  27147. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  27148. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27149. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  27150. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27151. =============================================================================*/
  27152. #include <stdbool.h>
  27153. #include <stdint.h>
  27154. /**** skipping file: platform.h ****/
  27155. /**** skipping file: internals.h ****/
  27156. /**** skipping file: softfloat.h ****/
  27157. #ifdef SOFTFLOAT_FAST_INT64
  27158. bool f128M_le( const float128_t *aPtr, const float128_t *bPtr )
  27159. {
  27160. return f128_le( *aPtr, *bPtr );
  27161. }
  27162. #else
  27163. bool f128M_le( const float128_t *aPtr, const float128_t *bPtr )
  27164. {
  27165. const uint32_t *aWPtr, *bWPtr;
  27166. uint32_t uiA96, uiB96;
  27167. bool signA, signB;
  27168. uint32_t wordA, wordB;
  27169. aWPtr = (const uint32_t *) aPtr;
  27170. bWPtr = (const uint32_t *) bPtr;
  27171. if ( softfloat_isNaNF128M( aWPtr ) || softfloat_isNaNF128M( bWPtr ) ) {
  27172. softfloat_raiseFlags( softfloat_flag_invalid );
  27173. return false;
  27174. }
  27175. uiA96 = aWPtr[indexWordHi( 4 )];
  27176. uiB96 = bWPtr[indexWordHi( 4 )];
  27177. signA = signF128UI96( uiA96 );
  27178. signB = signF128UI96( uiB96 );
  27179. if ( signA != signB ) {
  27180. if ( signA ) return true;
  27181. if ( (uiA96 | uiB96) & 0x7FFFFFFF ) return false;
  27182. wordA = aWPtr[indexWord( 4, 2 )];
  27183. wordB = bWPtr[indexWord( 4, 2 )];
  27184. if ( wordA | wordB ) return false;
  27185. wordA = aWPtr[indexWord( 4, 1 )];
  27186. wordB = bWPtr[indexWord( 4, 1 )];
  27187. if ( wordA | wordB ) return false;
  27188. wordA = aWPtr[indexWord( 4, 0 )];
  27189. wordB = bWPtr[indexWord( 4, 0 )];
  27190. return ((wordA | wordB) == 0);
  27191. }
  27192. if ( signA ) {
  27193. aWPtr = (const uint32_t *) bPtr;
  27194. bWPtr = (const uint32_t *) aPtr;
  27195. }
  27196. return (softfloat_compare128M( aWPtr, bWPtr ) <= 0);
  27197. }
  27198. #endif
  27199. /**** ended inlining ../../source/f128M_le.c ****/
  27200. /**** start inlining ../../source/f128M_lt.c ****/
  27201. /*============================================================================
  27202. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  27203. Package, Release 3e, by John R. Hauser.
  27204. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  27205. All rights reserved.
  27206. Redistribution and use in source and binary forms, with or without
  27207. modification, are permitted provided that the following conditions are met:
  27208. 1. Redistributions of source code must retain the above copyright notice,
  27209. this list of conditions, and the following disclaimer.
  27210. 2. Redistributions in binary form must reproduce the above copyright notice,
  27211. this list of conditions, and the following disclaimer in the documentation
  27212. and/or other materials provided with the distribution.
  27213. 3. Neither the name of the University nor the names of its contributors may
  27214. be used to endorse or promote products derived from this software without
  27215. specific prior written permission.
  27216. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  27217. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  27218. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  27219. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  27220. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  27221. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  27222. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  27223. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27224. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  27225. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27226. =============================================================================*/
  27227. #include <stdbool.h>
  27228. #include <stdint.h>
  27229. /**** skipping file: platform.h ****/
  27230. /**** skipping file: internals.h ****/
  27231. /**** skipping file: softfloat.h ****/
  27232. #ifdef SOFTFLOAT_FAST_INT64
  27233. bool f128M_lt( const float128_t *aPtr, const float128_t *bPtr )
  27234. {
  27235. return f128_lt( *aPtr, *bPtr );
  27236. }
  27237. #else
  27238. bool f128M_lt( const float128_t *aPtr, const float128_t *bPtr )
  27239. {
  27240. const uint32_t *aWPtr, *bWPtr;
  27241. uint32_t uiA96, uiB96;
  27242. bool signA, signB;
  27243. uint32_t wordA, wordB;
  27244. aWPtr = (const uint32_t *) aPtr;
  27245. bWPtr = (const uint32_t *) bPtr;
  27246. if ( softfloat_isNaNF128M( aWPtr ) || softfloat_isNaNF128M( bWPtr ) ) {
  27247. softfloat_raiseFlags( softfloat_flag_invalid );
  27248. return false;
  27249. }
  27250. uiA96 = aWPtr[indexWordHi( 4 )];
  27251. uiB96 = bWPtr[indexWordHi( 4 )];
  27252. signA = signF128UI96( uiA96 );
  27253. signB = signF128UI96( uiB96 );
  27254. if ( signA != signB ) {
  27255. if ( signB ) return false;
  27256. if ( (uiA96 | uiB96) & 0x7FFFFFFF ) return true;
  27257. wordA = aWPtr[indexWord( 4, 2 )];
  27258. wordB = bWPtr[indexWord( 4, 2 )];
  27259. if ( wordA | wordB ) return true;
  27260. wordA = aWPtr[indexWord( 4, 1 )];
  27261. wordB = bWPtr[indexWord( 4, 1 )];
  27262. if ( wordA | wordB ) return true;
  27263. wordA = aWPtr[indexWord( 4, 0 )];
  27264. wordB = bWPtr[indexWord( 4, 0 )];
  27265. return ((wordA | wordB) != 0);
  27266. }
  27267. if ( signA ) {
  27268. aWPtr = (const uint32_t *) bPtr;
  27269. bWPtr = (const uint32_t *) aPtr;
  27270. }
  27271. return (softfloat_compare128M( aWPtr, bWPtr ) < 0);
  27272. }
  27273. #endif
  27274. /**** ended inlining ../../source/f128M_lt.c ****/
  27275. /**** start inlining ../../source/f128M_eq_signaling.c ****/
  27276. /*============================================================================
  27277. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  27278. Package, Release 3e, by John R. Hauser.
  27279. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  27280. All rights reserved.
  27281. Redistribution and use in source and binary forms, with or without
  27282. modification, are permitted provided that the following conditions are met:
  27283. 1. Redistributions of source code must retain the above copyright notice,
  27284. this list of conditions, and the following disclaimer.
  27285. 2. Redistributions in binary form must reproduce the above copyright notice,
  27286. this list of conditions, and the following disclaimer in the documentation
  27287. and/or other materials provided with the distribution.
  27288. 3. Neither the name of the University nor the names of its contributors may
  27289. be used to endorse or promote products derived from this software without
  27290. specific prior written permission.
  27291. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  27292. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  27293. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  27294. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  27295. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  27296. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  27297. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  27298. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27299. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  27300. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27301. =============================================================================*/
  27302. #include <stdbool.h>
  27303. #include <stdint.h>
  27304. /**** skipping file: platform.h ****/
  27305. /**** skipping file: internals.h ****/
  27306. /**** skipping file: specialize.h ****/
  27307. /**** skipping file: softfloat.h ****/
  27308. #ifdef SOFTFLOAT_FAST_INT64
  27309. bool f128M_eq_signaling( const float128_t *aPtr, const float128_t *bPtr )
  27310. {
  27311. return f128_eq_signaling( *aPtr, *bPtr );
  27312. }
  27313. #else
  27314. bool f128M_eq_signaling( const float128_t *aPtr, const float128_t *bPtr )
  27315. {
  27316. const uint32_t *aWPtr, *bWPtr;
  27317. uint32_t wordA, wordB, uiA96, uiB96;
  27318. bool possibleOppositeZeros;
  27319. uint32_t mashWord;
  27320. aWPtr = (const uint32_t *) aPtr;
  27321. bWPtr = (const uint32_t *) bPtr;
  27322. if ( softfloat_isNaNF128M( aWPtr ) || softfloat_isNaNF128M( bWPtr ) ) {
  27323. softfloat_raiseFlags( softfloat_flag_invalid );
  27324. return false;
  27325. }
  27326. wordA = aWPtr[indexWord( 4, 2 )];
  27327. wordB = bWPtr[indexWord( 4, 2 )];
  27328. if ( wordA != wordB ) return false;
  27329. uiA96 = aWPtr[indexWordHi( 4 )];
  27330. uiB96 = bWPtr[indexWordHi( 4 )];
  27331. possibleOppositeZeros = false;
  27332. if ( uiA96 != uiB96 ) {
  27333. possibleOppositeZeros = (((uiA96 | uiB96) & 0x7FFFFFFF) == 0);
  27334. if ( ! possibleOppositeZeros ) return false;
  27335. }
  27336. mashWord = wordA | wordB;
  27337. wordA = aWPtr[indexWord( 4, 1 )];
  27338. wordB = bWPtr[indexWord( 4, 1 )];
  27339. if ( wordA != wordB ) return false;
  27340. mashWord |= wordA | wordB;
  27341. wordA = aWPtr[indexWord( 4, 0 )];
  27342. wordB = bWPtr[indexWord( 4, 0 )];
  27343. return
  27344. (wordA == wordB)
  27345. && (! possibleOppositeZeros || ((mashWord | wordA | wordB) == 0));
  27346. }
  27347. #endif
  27348. /**** ended inlining ../../source/f128M_eq_signaling.c ****/
  27349. /**** start inlining ../../source/f128M_le_quiet.c ****/
  27350. /*============================================================================
  27351. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  27352. Package, Release 3e, by John R. Hauser.
  27353. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  27354. All rights reserved.
  27355. Redistribution and use in source and binary forms, with or without
  27356. modification, are permitted provided that the following conditions are met:
  27357. 1. Redistributions of source code must retain the above copyright notice,
  27358. this list of conditions, and the following disclaimer.
  27359. 2. Redistributions in binary form must reproduce the above copyright notice,
  27360. this list of conditions, and the following disclaimer in the documentation
  27361. and/or other materials provided with the distribution.
  27362. 3. Neither the name of the University nor the names of its contributors may
  27363. be used to endorse or promote products derived from this software without
  27364. specific prior written permission.
  27365. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  27366. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  27367. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  27368. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  27369. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  27370. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  27371. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  27372. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27373. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  27374. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27375. =============================================================================*/
  27376. #include <stdbool.h>
  27377. #include <stdint.h>
  27378. /**** skipping file: platform.h ****/
  27379. /**** skipping file: internals.h ****/
  27380. /**** skipping file: specialize.h ****/
  27381. /**** skipping file: softfloat.h ****/
  27382. #ifdef SOFTFLOAT_FAST_INT64
  27383. bool f128M_le_quiet( const float128_t *aPtr, const float128_t *bPtr )
  27384. {
  27385. return f128_le_quiet( *aPtr, *bPtr );
  27386. }
  27387. #else
  27388. bool f128M_le_quiet( const float128_t *aPtr, const float128_t *bPtr )
  27389. {
  27390. const uint32_t *aWPtr, *bWPtr;
  27391. uint32_t uiA96, uiB96;
  27392. bool signA, signB;
  27393. uint32_t wordA, wordB;
  27394. aWPtr = (const uint32_t *) aPtr;
  27395. bWPtr = (const uint32_t *) bPtr;
  27396. if ( softfloat_isNaNF128M( aWPtr ) || softfloat_isNaNF128M( bWPtr ) ) {
  27397. if ( f128M_isSignalingNaN( aPtr ) || f128M_isSignalingNaN( bPtr ) ) {
  27398. softfloat_raiseFlags( softfloat_flag_invalid );
  27399. }
  27400. return false;
  27401. }
  27402. uiA96 = aWPtr[indexWordHi( 4 )];
  27403. uiB96 = bWPtr[indexWordHi( 4 )];
  27404. signA = signF128UI96( uiA96 );
  27405. signB = signF128UI96( uiB96 );
  27406. if ( signA != signB ) {
  27407. if ( signA ) return true;
  27408. if ( (uiA96 | uiB96) & 0x7FFFFFFF ) return false;
  27409. wordA = aWPtr[indexWord( 4, 2 )];
  27410. wordB = bWPtr[indexWord( 4, 2 )];
  27411. if ( wordA | wordB ) return false;
  27412. wordA = aWPtr[indexWord( 4, 1 )];
  27413. wordB = bWPtr[indexWord( 4, 1 )];
  27414. if ( wordA | wordB ) return false;
  27415. wordA = aWPtr[indexWord( 4, 0 )];
  27416. wordB = bWPtr[indexWord( 4, 0 )];
  27417. return ((wordA | wordB) == 0);
  27418. }
  27419. if ( signA ) {
  27420. aWPtr = (const uint32_t *) bPtr;
  27421. bWPtr = (const uint32_t *) aPtr;
  27422. }
  27423. return (softfloat_compare128M( aWPtr, bWPtr ) <= 0);
  27424. }
  27425. #endif
  27426. /**** ended inlining ../../source/f128M_le_quiet.c ****/
  27427. /**** start inlining ../../source/f128M_lt_quiet.c ****/
  27428. /*============================================================================
  27429. This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
  27430. Package, Release 3e, by John R. Hauser.
  27431. Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
  27432. All rights reserved.
  27433. Redistribution and use in source and binary forms, with or without
  27434. modification, are permitted provided that the following conditions are met:
  27435. 1. Redistributions of source code must retain the above copyright notice,
  27436. this list of conditions, and the following disclaimer.
  27437. 2. Redistributions in binary form must reproduce the above copyright notice,
  27438. this list of conditions, and the following disclaimer in the documentation
  27439. and/or other materials provided with the distribution.
  27440. 3. Neither the name of the University nor the names of its contributors may
  27441. be used to endorse or promote products derived from this software without
  27442. specific prior written permission.
  27443. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  27444. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  27445. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  27446. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  27447. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  27448. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  27449. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  27450. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27451. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  27452. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27453. =============================================================================*/
  27454. #include <stdbool.h>
  27455. #include <stdint.h>
  27456. /**** skipping file: platform.h ****/
  27457. /**** skipping file: internals.h ****/
  27458. /**** skipping file: specialize.h ****/
  27459. /**** skipping file: softfloat.h ****/
  27460. #ifdef SOFTFLOAT_FAST_INT64
  27461. bool f128M_lt_quiet( const float128_t *aPtr, const float128_t *bPtr )
  27462. {
  27463. return f128_lt_quiet( *aPtr, *bPtr );
  27464. }
  27465. #else
  27466. bool f128M_lt_quiet( const float128_t *aPtr, const float128_t *bPtr )
  27467. {
  27468. const uint32_t *aWPtr, *bWPtr;
  27469. uint32_t uiA96, uiB96;
  27470. bool signA, signB;
  27471. uint32_t wordA, wordB;
  27472. aWPtr = (const uint32_t *) aPtr;
  27473. bWPtr = (const uint32_t *) bPtr;
  27474. if ( softfloat_isNaNF128M( aWPtr ) || softfloat_isNaNF128M( bWPtr ) ) {
  27475. if ( f128M_isSignalingNaN( aPtr ) || f128M_isSignalingNaN( bPtr ) ) {
  27476. softfloat_raiseFlags( softfloat_flag_invalid );
  27477. }
  27478. return false;
  27479. }
  27480. uiA96 = aWPtr[indexWordHi( 4 )];
  27481. uiB96 = bWPtr[indexWordHi( 4 )];
  27482. signA = signF128UI96( uiA96 );
  27483. signB = signF128UI96( uiB96 );
  27484. if ( signA != signB ) {
  27485. if ( signB ) return false;
  27486. if ( (uiA96 | uiB96) & 0x7FFFFFFF ) return true;
  27487. wordA = aWPtr[indexWord( 4, 2 )];
  27488. wordB = bWPtr[indexWord( 4, 2 )];
  27489. if ( wordA | wordB ) return true;
  27490. wordA = aWPtr[indexWord( 4, 1 )];
  27491. wordB = bWPtr[indexWord( 4, 1 )];
  27492. if ( wordA | wordB ) return true;
  27493. wordA = aWPtr[indexWord( 4, 0 )];
  27494. wordB = bWPtr[indexWord( 4, 0 )];
  27495. return ((wordA | wordB) != 0);
  27496. }
  27497. if ( signA ) {
  27498. aWPtr = (const uint32_t *) bPtr;
  27499. bWPtr = (const uint32_t *) aPtr;
  27500. }
  27501. return (softfloat_compare128M( aWPtr, bWPtr ) < 0);
  27502. }
  27503. #endif
  27504. /**** ended inlining ../../source/f128M_lt_quiet.c ****/