| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837 |
- // https://github.com/LDj3SNuD/ARM_v8-A_AArch64_Instructions_Tester/blob/master/Tester/Instructions.cs
- // https://developer.arm.com/products/architecture/a-profile/exploration-tools
- // ..\A64_v83A_ISA_xml_00bet6.1\ISA_v83A_A64_xml_00bet6.1_OPT\xhtml\
- using System.Numerics;
- namespace Ryujinx.Tests.Cpu.Tester
- {
- using Types;
- using static AArch64;
- using static Shared;
- // index.html
- internal static class Base
- {
- #region "Alu"
- // cls_int.html
- public static void Cls(bool sf, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int datasize = (sf ? 64 : 32);
- /* Operation */
- Bits operand1 = X(datasize, n);
- BigInteger result = (BigInteger)CountLeadingSignBits(operand1);
- X(d, result.SubBigInteger(datasize - 1, 0));
- }
- // clz_int.html
- public static void Clz(bool sf, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int datasize = (sf ? 64 : 32);
- /* Operation */
- Bits operand1 = X(datasize, n);
- BigInteger result = (BigInteger)CountLeadingZeroBits(operand1);
- X(d, result.SubBigInteger(datasize - 1, 0));
- }
- // rbit_int.html
- public static void Rbit(bool sf, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int datasize = (sf ? 64 : 32);
- /* Operation */
- Bits result = new Bits(datasize);
- Bits operand = X(datasize, n);
- for (int i = 0; i <= datasize - 1; i++)
- {
- result[datasize - 1 - i] = operand[i];
- }
- X(d, result);
- }
- // rev16_int.html
- public static void Rev16(bool sf, Bits Rn, Bits Rd)
- {
- /* Bits opc = "01"; */
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int datasize = (sf ? 64 : 32);
- int container_size = 16;
- /* Operation */
- Bits result = new Bits(datasize);
- Bits operand = X(datasize, n);
- int containers = datasize / container_size;
- int elements_per_container = container_size / 8;
- int index = 0;
- int rev_index;
- for (int c = 0; c <= containers - 1; c++)
- {
- rev_index = index + ((elements_per_container - 1) * 8);
- for (int e = 0; e <= elements_per_container - 1; e++)
- {
- result[rev_index + 7, rev_index] = operand[index + 7, index];
- index = index + 8;
- rev_index = rev_index - 8;
- }
- }
- X(d, result);
- }
- // rev32_int.html
- // (rev.html)
- public static void Rev32(bool sf, Bits Rn, Bits Rd)
- {
- /* Bits opc = "10"; */
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int datasize = (sf ? 64 : 32);
- int container_size = 32;
- /* Operation */
- Bits result = new Bits(datasize);
- Bits operand = X(datasize, n);
- int containers = datasize / container_size;
- int elements_per_container = container_size / 8;
- int index = 0;
- int rev_index;
- for (int c = 0; c <= containers - 1; c++)
- {
- rev_index = index + ((elements_per_container - 1) * 8);
- for (int e = 0; e <= elements_per_container - 1; e++)
- {
- result[rev_index + 7, rev_index] = operand[index + 7, index];
- index = index + 8;
- rev_index = rev_index - 8;
- }
- }
- X(d, result);
- }
- // rev64_rev.html
- // (rev.html)
- public static void Rev64(Bits Rn, Bits Rd)
- {
- /* Bits opc = "11"; */
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int container_size = 64;
- /* Operation */
- Bits result = new Bits(64);
- Bits operand = X(64, n);
- int containers = 64 / container_size;
- int elements_per_container = container_size / 8;
- int index = 0;
- int rev_index;
- for (int c = 0; c <= containers - 1; c++)
- {
- rev_index = index + ((elements_per_container - 1) * 8);
- for (int e = 0; e <= elements_per_container - 1; e++)
- {
- result[rev_index + 7, rev_index] = operand[index + 7, index];
- index = index + 8;
- rev_index = rev_index - 8;
- }
- }
- X(d, result);
- }
- #endregion
- #region "AluImm"
- // add_addsub_imm.html
- public static void Add_Imm(bool sf, Bits shift, Bits imm12, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int datasize = (sf ? 64 : 32);
- Bits imm;
- switch (shift)
- {
- default:
- case Bits bits when bits == "00":
- imm = ZeroExtend(imm12, datasize);
- break;
- case Bits bits when bits == "01":
- imm = ZeroExtend(Bits.Concat(imm12, Zeros(12)), datasize);
- break;
- /* when '1x' ReservedValue(); */
- }
- /* Operation */
- Bits result;
- Bits operand1 = (n == 31 ? SP(datasize) : X(datasize, n));
- (result, _) = AddWithCarry(datasize, operand1, imm, false);
- if (d == 31)
- {
- SP(result);
- }
- else
- {
- X(d, result);
- }
- }
- // adds_addsub_imm.html
- public static void Adds_Imm(bool sf, Bits shift, Bits imm12, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int datasize = (sf ? 64 : 32);
- Bits imm;
- switch (shift)
- {
- default:
- case Bits bits when bits == "00":
- imm = ZeroExtend(imm12, datasize);
- break;
- case Bits bits when bits == "01":
- imm = ZeroExtend(Bits.Concat(imm12, Zeros(12)), datasize);
- break;
- /* when '1x' ReservedValue(); */
- }
- /* Operation */
- Bits result;
- Bits operand1 = (n == 31 ? SP(datasize) : X(datasize, n));
- Bits nzcv;
- (result, nzcv) = AddWithCarry(datasize, operand1, imm, false);
- PSTATE.NZCV(nzcv);
- X(d, result);
- }
- // and_log_imm.html
- public static void And_Imm(bool sf, bool N, Bits immr, Bits imms, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int datasize = (sf ? 64 : 32);
- Bits imm;
- /* if sf == '0' && N != '0' then ReservedValue(); */
- (imm, _) = DecodeBitMasks(datasize, N, imms, immr, true);
- /* Operation */
- Bits operand1 = X(datasize, n);
- Bits result = AND(operand1, imm);
- if (d == 31)
- {
- SP(result);
- }
- else
- {
- X(d, result);
- }
- }
- // ands_log_imm.html
- public static void Ands_Imm(bool sf, bool N, Bits immr, Bits imms, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int datasize = (sf ? 64 : 32);
- Bits imm;
- /* if sf == '0' && N != '0' then ReservedValue(); */
- (imm, _) = DecodeBitMasks(datasize, N, imms, immr, true);
- /* Operation */
- Bits operand1 = X(datasize, n);
- Bits result = AND(operand1, imm);
- PSTATE.NZCV(result[datasize - 1], IsZeroBit(result), false, false);
- X(d, result);
- }
- // eor_log_imm.html
- public static void Eor_Imm(bool sf, bool N, Bits immr, Bits imms, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int datasize = (sf ? 64 : 32);
- Bits imm;
- /* if sf == '0' && N != '0' then ReservedValue(); */
- (imm, _) = DecodeBitMasks(datasize, N, imms, immr, true);
- /* Operation */
- Bits operand1 = X(datasize, n);
- Bits result = EOR(operand1, imm);
- if (d == 31)
- {
- SP(result);
- }
- else
- {
- X(d, result);
- }
- }
- // orr_log_imm.html
- public static void Orr_Imm(bool sf, bool N, Bits immr, Bits imms, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int datasize = (sf ? 64 : 32);
- Bits imm;
- /* if sf == '0' && N != '0' then ReservedValue(); */
- (imm, _) = DecodeBitMasks(datasize, N, imms, immr, true);
- /* Operation */
- Bits operand1 = X(datasize, n);
- Bits result = OR(operand1, imm);
- if (d == 31)
- {
- SP(result);
- }
- else
- {
- X(d, result);
- }
- }
- // sub_addsub_imm.html
- public static void Sub_Imm(bool sf, Bits shift, Bits imm12, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int datasize = (sf ? 64 : 32);
- Bits imm;
- switch (shift)
- {
- default:
- case Bits bits when bits == "00":
- imm = ZeroExtend(imm12, datasize);
- break;
- case Bits bits when bits == "01":
- imm = ZeroExtend(Bits.Concat(imm12, Zeros(12)), datasize);
- break;
- /* when '1x' ReservedValue(); */
- }
- /* Operation */
- Bits result;
- Bits operand1 = (n == 31 ? SP(datasize) : X(datasize, n));
- Bits operand2 = NOT(imm);
- (result, _) = AddWithCarry(datasize, operand1, operand2, true);
- if (d == 31)
- {
- SP(result);
- }
- else
- {
- X(d, result);
- }
- }
- // subs_addsub_imm.html
- public static void Subs_Imm(bool sf, Bits shift, Bits imm12, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int datasize = (sf ? 64 : 32);
- Bits imm;
- switch (shift)
- {
- default:
- case Bits bits when bits == "00":
- imm = ZeroExtend(imm12, datasize);
- break;
- case Bits bits when bits == "01":
- imm = ZeroExtend(Bits.Concat(imm12, Zeros(12)), datasize);
- break;
- /* when '1x' ReservedValue(); */
- }
- /* Operation */
- Bits result;
- Bits operand1 = (n == 31 ? SP(datasize) : X(datasize, n));
- Bits operand2 = NOT(imm);
- Bits nzcv;
- (result, nzcv) = AddWithCarry(datasize, operand1, operand2, true);
- PSTATE.NZCV(nzcv);
- X(d, result);
- }
- #endregion
- #region "AluRs"
- // adc.html
- public static void Adc(bool sf, Bits Rm, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (sf ? 64 : 32);
- /* Operation */
- Bits result;
- Bits operand1 = X(datasize, n);
- Bits operand2 = X(datasize, m);
- (result, _) = AddWithCarry(datasize, operand1, operand2, PSTATE.C);
- X(d, result);
- }
- // adcs.html
- public static void Adcs(bool sf, Bits Rm, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (sf ? 64 : 32);
- /* Operation */
- Bits result;
- Bits operand1 = X(datasize, n);
- Bits operand2 = X(datasize, m);
- Bits nzcv;
- (result, nzcv) = AddWithCarry(datasize, operand1, operand2, PSTATE.C);
- PSTATE.NZCV(nzcv);
- X(d, result);
- }
- // add_addsub_shift.html
- public static void Add_Rs(bool sf, Bits shift, Bits Rm, Bits imm6, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (sf ? 64 : 32);
- /* if shift == '11' then ReservedValue(); */
- /* if sf == '0' && imm6<5> == '1' then ReservedValue(); */
- ShiftType shift_type = DecodeShift(shift);
- int shift_amount = (int)UInt(imm6);
- /* Operation */
- Bits result;
- Bits operand1 = X(datasize, n);
- Bits operand2 = ShiftReg(datasize, m, shift_type, shift_amount);
- (result, _) = AddWithCarry(datasize, operand1, operand2, false);
- X(d, result);
- }
- // adds_addsub_shift.html
- public static void Adds_Rs(bool sf, Bits shift, Bits Rm, Bits imm6, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (sf ? 64 : 32);
- /* if shift == '11' then ReservedValue(); */
- /* if sf == '0' && imm6<5> == '1' then ReservedValue(); */
- ShiftType shift_type = DecodeShift(shift);
- int shift_amount = (int)UInt(imm6);
- /* Operation */
- Bits result;
- Bits operand1 = X(datasize, n);
- Bits operand2 = ShiftReg(datasize, m, shift_type, shift_amount);
- Bits nzcv;
- (result, nzcv) = AddWithCarry(datasize, operand1, operand2, false);
- PSTATE.NZCV(nzcv);
- X(d, result);
- }
- // and_log_shift.html
- public static void And_Rs(bool sf, Bits shift, Bits Rm, Bits imm6, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (sf ? 64 : 32);
- /* if sf == '0' && imm6<5> == '1' then ReservedValue(); */
- ShiftType shift_type = DecodeShift(shift);
- int shift_amount = (int)UInt(imm6);
- /* Operation */
- Bits operand1 = X(datasize, n);
- Bits operand2 = ShiftReg(datasize, m, shift_type, shift_amount);
- Bits result = AND(operand1, operand2);
- X(d, result);
- }
- // ands_log_shift.html
- public static void Ands_Rs(bool sf, Bits shift, Bits Rm, Bits imm6, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (sf ? 64 : 32);
- /* if sf == '0' && imm6<5> == '1' then ReservedValue(); */
- ShiftType shift_type = DecodeShift(shift);
- int shift_amount = (int)UInt(imm6);
- /* Operation */
- Bits operand1 = X(datasize, n);
- Bits operand2 = ShiftReg(datasize, m, shift_type, shift_amount);
- Bits result = AND(operand1, operand2);
- PSTATE.NZCV(result[datasize - 1], IsZeroBit(result), false, false);
- X(d, result);
- }
- // asrv.html
- public static void Asrv(bool sf, Bits Rm, Bits Rn, Bits Rd)
- {
- /*readonly */Bits op2 = "10";
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (sf ? 64 : 32);
- ShiftType shift_type = DecodeShift(op2);
- /* Operation */
- Bits operand2 = X(datasize, m);
- Bits result = ShiftReg(datasize, n, shift_type, (int)(UInt(operand2) % datasize)); // BigInteger.Modulus Operator (BigInteger, BigInteger)
- X(d, result);
- }
- // bic_log_shift.html
- public static void Bic(bool sf, Bits shift, Bits Rm, Bits imm6, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (sf ? 64 : 32);
- /* if sf == '0' && imm6<5> == '1' then ReservedValue(); */
- ShiftType shift_type = DecodeShift(shift);
- int shift_amount = (int)UInt(imm6);
- /* Operation */
- Bits operand1 = X(datasize, n);
- Bits operand2 = ShiftReg(datasize, m, shift_type, shift_amount);
- operand2 = NOT(operand2);
- Bits result = AND(operand1, operand2);
- X(d, result);
- }
- // bics.html
- public static void Bics(bool sf, Bits shift, Bits Rm, Bits imm6, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (sf ? 64 : 32);
- /* if sf == '0' && imm6<5> == '1' then ReservedValue(); */
- ShiftType shift_type = DecodeShift(shift);
- int shift_amount = (int)UInt(imm6);
- /* Operation */
- Bits operand1 = X(datasize, n);
- Bits operand2 = ShiftReg(datasize, m, shift_type, shift_amount);
- operand2 = NOT(operand2);
- Bits result = AND(operand1, operand2);
- PSTATE.NZCV(result[datasize - 1], IsZeroBit(result), false, false);
- X(d, result);
- }
- // crc32.html
- public static void Crc32(bool sf, Bits Rm, Bits sz, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- /* if sf == '1' && sz != '11' then UnallocatedEncoding(); */
- /* if sf == '0' && sz == '11' then UnallocatedEncoding(); */
- int size = 8 << (int)UInt(sz);
- /* Operation */
- /* if !HaveCRCExt() then UnallocatedEncoding(); */
- Bits acc = X(32, n); // accumulator
- Bits val = X(size, m); // input value
- Bits poly = new Bits(0x04C11DB7u);
- Bits tempacc = Bits.Concat(BitReverse(acc), Zeros(size));
- Bits tempval = Bits.Concat(BitReverse(val), Zeros(32));
- // Poly32Mod2 on a bitstring does a polynomial Modulus over {0,1} operation
- X(d, BitReverse(Poly32Mod2(EOR(tempacc, tempval), poly)));
- }
- // crc32c.html
- public static void Crc32c(bool sf, Bits Rm, Bits sz, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- /* if sf == '1' && sz != '11' then UnallocatedEncoding(); */
- /* if sf == '0' && sz == '11' then UnallocatedEncoding(); */
- int size = 8 << (int)UInt(sz);
- /* Operation */
- /* if !HaveCRCExt() then UnallocatedEncoding(); */
- Bits acc = X(32, n); // accumulator
- Bits val = X(size, m); // input value
- Bits poly = new Bits(0x1EDC6F41u);
- Bits tempacc = Bits.Concat(BitReverse(acc), Zeros(size));
- Bits tempval = Bits.Concat(BitReverse(val), Zeros(32));
- // Poly32Mod2 on a bitstring does a polynomial Modulus over {0,1} operation
- X(d, BitReverse(Poly32Mod2(EOR(tempacc, tempval), poly)));
- }
- // eon.html
- public static void Eon(bool sf, Bits shift, Bits Rm, Bits imm6, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (sf ? 64 : 32);
- /* if sf == '0' && imm6<5> == '1' then ReservedValue(); */
- ShiftType shift_type = DecodeShift(shift);
- int shift_amount = (int)UInt(imm6);
- /* Operation */
- Bits operand1 = X(datasize, n);
- Bits operand2 = ShiftReg(datasize, m, shift_type, shift_amount);
- operand2 = NOT(operand2);
- Bits result = EOR(operand1, operand2);
- X(d, result);
- }
- // eor_log_shift.html
- public static void Eor_Rs(bool sf, Bits shift, Bits Rm, Bits imm6, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (sf ? 64 : 32);
- /* if sf == '0' && imm6<5> == '1' then ReservedValue(); */
- ShiftType shift_type = DecodeShift(shift);
- int shift_amount = (int)UInt(imm6);
- /* Operation */
- Bits operand1 = X(datasize, n);
- Bits operand2 = ShiftReg(datasize, m, shift_type, shift_amount);
- Bits result = EOR(operand1, operand2);
- X(d, result);
- }
- // extr.html
- public static void Extr(bool sf, bool N, Bits Rm, Bits imms, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (sf ? 64 : 32);
- /* if N != sf then UnallocatedEncoding(); */
- /* if sf == '0' && imms<5> == '1' then ReservedValue(); */
- int lsb = (int)UInt(imms);
- /* Operation */
- Bits operand1 = X(datasize, n);
- Bits operand2 = X(datasize, m);
- Bits concat = Bits.Concat(operand1, operand2);
- Bits result = concat[lsb + datasize - 1, lsb];
- X(d, result);
- }
- // lslv.html
- public static void Lslv(bool sf, Bits Rm, Bits Rn, Bits Rd)
- {
- /*readonly */Bits op2 = "00";
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (sf ? 64 : 32);
- ShiftType shift_type = DecodeShift(op2);
- /* Operation */
- Bits operand2 = X(datasize, m);
- Bits result = ShiftReg(datasize, n, shift_type, (int)(UInt(operand2) % datasize)); // BigInteger.Modulus Operator (BigInteger, BigInteger)
- X(d, result);
- }
- // lsrv.html
- public static void Lsrv(bool sf, Bits Rm, Bits Rn, Bits Rd)
- {
- /*readonly */Bits op2 = "01";
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (sf ? 64 : 32);
- ShiftType shift_type = DecodeShift(op2);
- /* Operation */
- Bits operand2 = X(datasize, m);
- Bits result = ShiftReg(datasize, n, shift_type, (int)(UInt(operand2) % datasize)); // BigInteger.Modulus Operator (BigInteger, BigInteger)
- X(d, result);
- }
- // orn_log_shift.html
- public static void Orn(bool sf, Bits shift, Bits Rm, Bits imm6, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (sf ? 64 : 32);
- /* if sf == '0' && imm6<5> == '1' then ReservedValue(); */
- ShiftType shift_type = DecodeShift(shift);
- int shift_amount = (int)UInt(imm6);
- /* Operation */
- Bits operand1 = X(datasize, n);
- Bits operand2 = ShiftReg(datasize, m, shift_type, shift_amount);
- operand2 = NOT(operand2);
- Bits result = OR(operand1, operand2);
- X(d, result);
- }
- // orr_log_shift.html
- public static void Orr_Rs(bool sf, Bits shift, Bits Rm, Bits imm6, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (sf ? 64 : 32);
- /* if sf == '0' && imm6<5> == '1' then ReservedValue(); */
- ShiftType shift_type = DecodeShift(shift);
- int shift_amount = (int)UInt(imm6);
- /* Operation */
- Bits operand1 = X(datasize, n);
- Bits operand2 = ShiftReg(datasize, m, shift_type, shift_amount);
- Bits result = OR(operand1, operand2);
- X(d, result);
- }
- // rorv.html
- public static void Rorv(bool sf, Bits Rm, Bits Rn, Bits Rd)
- {
- /*readonly */Bits op2 = "11";
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (sf ? 64 : 32);
- ShiftType shift_type = DecodeShift(op2);
- /* Operation */
- Bits operand2 = X(datasize, m);
- Bits result = ShiftReg(datasize, n, shift_type, (int)(UInt(operand2) % datasize)); // BigInteger.Modulus Operator (BigInteger, BigInteger)
- X(d, result);
- }
- // sbc.html
- public static void Sbc(bool sf, Bits Rm, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (sf ? 64 : 32);
- /* Operation */
- Bits result;
- Bits operand1 = X(datasize, n);
- Bits operand2 = X(datasize, m);
- operand2 = NOT(operand2);
- (result, _) = AddWithCarry(datasize, operand1, operand2, PSTATE.C);
- X(d, result);
- }
- // sbcs.html
- public static void Sbcs(bool sf, Bits Rm, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (sf ? 64 : 32);
- /* Operation */
- Bits result;
- Bits operand1 = X(datasize, n);
- Bits operand2 = X(datasize, m);
- Bits nzcv;
- operand2 = NOT(operand2);
- (result, nzcv) = AddWithCarry(datasize, operand1, operand2, PSTATE.C);
- PSTATE.NZCV(nzcv);
- X(d, result);
- }
- // sdiv.html
- public static void Sdiv(bool sf, Bits Rm, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (sf ? 64 : 32);
- /* Operation */
- BigInteger result;
- Bits operand1 = X(datasize, n);
- Bits operand2 = X(datasize, m);
- if (IsZero(operand2))
- {
- result = (BigInteger)0m;
- }
- else
- {
- result = RoundTowardsZero(Real(Int(operand1, false)) / Real(Int(operand2, false)));
- }
- X(d, result.SubBigInteger(datasize - 1, 0));
- }
- // sub_addsub_shift.html
- public static void Sub_Rs(bool sf, Bits shift, Bits Rm, Bits imm6, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (sf ? 64 : 32);
- /* if shift == '11' then ReservedValue(); */
- /* if sf == '0' && imm6<5> == '1' then ReservedValue(); */
- ShiftType shift_type = DecodeShift(shift);
- int shift_amount = (int)UInt(imm6);
- /* Operation */
- Bits result;
- Bits operand1 = X(datasize, n);
- Bits operand2 = ShiftReg(datasize, m, shift_type, shift_amount);
- operand2 = NOT(operand2);
- (result, _) = AddWithCarry(datasize, operand1, operand2, true);
- X(d, result);
- }
- // subs_addsub_shift.html
- public static void Subs_Rs(bool sf, Bits shift, Bits Rm, Bits imm6, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (sf ? 64 : 32);
- /* if shift == '11' then ReservedValue(); */
- /* if sf == '0' && imm6<5> == '1' then ReservedValue(); */
- ShiftType shift_type = DecodeShift(shift);
- int shift_amount = (int)UInt(imm6);
- /* Operation */
- Bits result;
- Bits operand1 = X(datasize, n);
- Bits operand2 = ShiftReg(datasize, m, shift_type, shift_amount);
- Bits nzcv;
- operand2 = NOT(operand2);
- (result, nzcv) = AddWithCarry(datasize, operand1, operand2, true);
- PSTATE.NZCV(nzcv);
- X(d, result);
- }
- // udiv.html
- public static void Udiv(bool sf, Bits Rm, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (sf ? 64 : 32);
- /* Operation */
- BigInteger result;
- Bits operand1 = X(datasize, n);
- Bits operand2 = X(datasize, m);
- if (IsZero(operand2))
- {
- result = (BigInteger)0m;
- }
- else
- {
- result = RoundTowardsZero(Real(Int(operand1, true)) / Real(Int(operand2, true)));
- }
- X(d, result.SubBigInteger(datasize - 1, 0));
- }
- #endregion
- #region "AluRx"
- // add_addsub_ext.html
- public static void Add_Rx(bool sf, Bits Rm, Bits option, Bits imm3, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (sf ? 64 : 32);
- ExtendType extend_type = DecodeRegExtend(option);
- int shift = (int)UInt(imm3);
- /* if shift > 4 then ReservedValue(); */
- /* Operation */
- Bits result;
- Bits operand1 = (n == 31 ? SP(datasize) : X(datasize, n));
- Bits operand2 = ExtendReg(datasize, m, extend_type, shift);
- (result, _) = AddWithCarry(datasize, operand1, operand2, false);
- if (d == 31)
- {
- SP(result);
- }
- else
- {
- X(d, result);
- }
- }
- // adds_addsub_ext.html
- public static void Adds_Rx(bool sf, Bits Rm, Bits option, Bits imm3, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (sf ? 64 : 32);
- ExtendType extend_type = DecodeRegExtend(option);
- int shift = (int)UInt(imm3);
- /* if shift > 4 then ReservedValue(); */
- /* Operation */
- Bits result;
- Bits operand1 = (n == 31 ? SP(datasize) : X(datasize, n));
- Bits operand2 = ExtendReg(datasize, m, extend_type, shift);
- Bits nzcv;
- (result, nzcv) = AddWithCarry(datasize, operand1, operand2, false);
- PSTATE.NZCV(nzcv);
- X(d, result);
- }
- // sub_addsub_ext.html
- public static void Sub_Rx(bool sf, Bits Rm, Bits option, Bits imm3, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (sf ? 64 : 32);
- ExtendType extend_type = DecodeRegExtend(option);
- int shift = (int)UInt(imm3);
- /* if shift > 4 then ReservedValue(); */
- /* Operation */
- Bits result;
- Bits operand1 = (n == 31 ? SP(datasize) : X(datasize, n));
- Bits operand2 = ExtendReg(datasize, m, extend_type, shift);
- operand2 = NOT(operand2);
- (result, _) = AddWithCarry(datasize, operand1, operand2, true);
- if (d == 31)
- {
- SP(result);
- }
- else
- {
- X(d, result);
- }
- }
- // subs_addsub_ext.html
- public static void Subs_Rx(bool sf, Bits Rm, Bits option, Bits imm3, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (sf ? 64 : 32);
- ExtendType extend_type = DecodeRegExtend(option);
- int shift = (int)UInt(imm3);
- /* if shift > 4 then ReservedValue(); */
- /* Operation */
- Bits result;
- Bits operand1 = (n == 31 ? SP(datasize) : X(datasize, n));
- Bits operand2 = ExtendReg(datasize, m, extend_type, shift);
- Bits nzcv;
- operand2 = NOT(operand2);
- (result, nzcv) = AddWithCarry(datasize, operand1, operand2, true);
- PSTATE.NZCV(nzcv);
- X(d, result);
- }
- #endregion
- #region "Bfm"
- // bfm.html
- public static void Bfm(bool sf, bool N, Bits immr, Bits imms, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int datasize = (sf ? 64 : 32);
- int R;
- Bits wmask;
- Bits tmask;
- /* if sf == '1' && N != '1' then ReservedValue(); */
- /* if sf == '0' && (N != '0' || immr<5> != '0' || imms<5> != '0') then ReservedValue(); */
- R = (int)UInt(immr);
- (wmask, tmask) = DecodeBitMasks(datasize, N, imms, immr, false);
- /* Operation */
- Bits dst = X(datasize, d);
- Bits src = X(datasize, n);
- // perform bitfield move on low bits
- Bits bot = OR(AND(dst, NOT(wmask)), AND(ROR(src, R), wmask));
- // combine extension bits and result bits
- X(d, OR(AND(dst, NOT(tmask)), AND(bot, tmask)));
- }
- // sbfm.html
- public static void Sbfm(bool sf, bool N, Bits immr, Bits imms, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int datasize = (sf ? 64 : 32);
- int R;
- int S;
- Bits wmask;
- Bits tmask;
- /* if sf == '1' && N != '1' then ReservedValue(); */
- /* if sf == '0' && (N != '0' || immr<5> != '0' || imms<5> != '0') then ReservedValue(); */
- R = (int)UInt(immr);
- S = (int)UInt(imms);
- (wmask, tmask) = DecodeBitMasks(datasize, N, imms, immr, false);
- /* Operation */
- Bits src = X(datasize, n);
- // perform bitfield move on low bits
- Bits bot = AND(ROR(src, R), wmask);
- // determine extension bits (sign, zero or dest register)
- Bits top = Replicate(datasize, src[S]);
- // combine extension bits and result bits
- X(d, OR(AND(top, NOT(tmask)), AND(bot, tmask)));
- }
- // ubfm.html
- public static void Ubfm(bool sf, bool N, Bits immr, Bits imms, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int datasize = (sf ? 64 : 32);
- int R;
- Bits wmask;
- Bits tmask;
- /* if sf == '1' && N != '1' then ReservedValue(); */
- /* if sf == '0' && (N != '0' || immr<5> != '0' || imms<5> != '0') then ReservedValue(); */
- R = (int)UInt(immr);
- (wmask, tmask) = DecodeBitMasks(datasize, N, imms, immr, false);
- /* Operation */
- Bits src = X(datasize, n);
- // perform bitfield move on low bits
- Bits bot = AND(ROR(src, R), wmask);
- // combine extension bits and result bits
- X(d, AND(bot, tmask));
- }
- #endregion
- #region "CcmpImm"
- // ccmn_imm.html
- public static void Ccmn_Imm(bool sf, Bits imm5, Bits cond, Bits Rn, Bits nzcv)
- {
- /* Decode */
- int n = (int)UInt(Rn);
- int datasize = (sf ? 64 : 32);
- Bits flags = nzcv;
- Bits imm = ZeroExtend(imm5, datasize);
- /* Operation */
- Bits operand1 = X(datasize, n);
- if (ConditionHolds(cond))
- {
- (_, flags) = AddWithCarry(datasize, operand1, imm, false);
- }
- PSTATE.NZCV(flags);
- }
- // ccmp_imm.html
- public static void Ccmp_Imm(bool sf, Bits imm5, Bits cond, Bits Rn, Bits nzcv)
- {
- /* Decode */
- int n = (int)UInt(Rn);
- int datasize = (sf ? 64 : 32);
- Bits flags = nzcv;
- Bits imm = ZeroExtend(imm5, datasize);
- /* Operation */
- Bits operand1 = X(datasize, n);
- Bits operand2;
- if (ConditionHolds(cond))
- {
- operand2 = NOT(imm);
- (_, flags) = AddWithCarry(datasize, operand1, operand2, true);
- }
- PSTATE.NZCV(flags);
- }
- #endregion
- #region "CcmpReg"
- // ccmn_reg.html
- public static void Ccmn_Reg(bool sf, Bits Rm, Bits cond, Bits Rn, Bits nzcv)
- {
- /* Decode */
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (sf ? 64 : 32);
- Bits flags = nzcv;
- /* Operation */
- Bits operand1 = X(datasize, n);
- Bits operand2 = X(datasize, m);
- if (ConditionHolds(cond))
- {
- (_, flags) = AddWithCarry(datasize, operand1, operand2, false);
- }
- PSTATE.NZCV(flags);
- }
- // ccmp_reg.html
- public static void Ccmp_Reg(bool sf, Bits Rm, Bits cond, Bits Rn, Bits nzcv)
- {
- /* Decode */
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (sf ? 64 : 32);
- Bits flags = nzcv;
- /* Operation */
- Bits operand1 = X(datasize, n);
- Bits operand2 = X(datasize, m);
- if (ConditionHolds(cond))
- {
- operand2 = NOT(operand2);
- (_, flags) = AddWithCarry(datasize, operand1, operand2, true);
- }
- PSTATE.NZCV(flags);
- }
- #endregion
- #region "Csel"
- // csel.html
- public static void Csel(bool sf, Bits Rm, Bits cond, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (sf ? 64 : 32);
- /* Operation */
- Bits result;
- Bits operand1 = X(datasize, n);
- Bits operand2 = X(datasize, m);
- if (ConditionHolds(cond))
- {
- result = operand1;
- }
- else
- {
- result = operand2;
- }
- X(d, result);
- }
- // csinc.html
- public static void Csinc(bool sf, Bits Rm, Bits cond, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (sf ? 64 : 32);
- /* Operation */
- Bits result;
- Bits operand1 = X(datasize, n);
- Bits operand2 = X(datasize, m);
- if (ConditionHolds(cond))
- {
- result = operand1;
- }
- else
- {
- result = operand2 + 1;
- }
- X(d, result);
- }
- // csinv.html
- public static void Csinv(bool sf, Bits Rm, Bits cond, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (sf ? 64 : 32);
- /* Operation */
- Bits result;
- Bits operand1 = X(datasize, n);
- Bits operand2 = X(datasize, m);
- if (ConditionHolds(cond))
- {
- result = operand1;
- }
- else
- {
- result = NOT(operand2);
- }
- X(d, result);
- }
- // csneg.html
- public static void Csneg(bool sf, Bits Rm, Bits cond, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (sf ? 64 : 32);
- /* Operation */
- Bits result;
- Bits operand1 = X(datasize, n);
- Bits operand2 = X(datasize, m);
- if (ConditionHolds(cond))
- {
- result = operand1;
- }
- else
- {
- result = NOT(operand2);
- result = result + 1;
- }
- X(d, result);
- }
- #endregion
- #region "Mov"
- // movk.html
- public static void Movk(bool sf, Bits hw, Bits imm16, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int datasize = (sf ? 64 : 32);
- /* if sf == '0' && hw<1> == '1' then UnallocatedEncoding(); */
- int pos = (int)UInt(Bits.Concat(hw, "0000"));
- /* Operation */
- Bits result = X(datasize, d);
- result[pos + 15, pos] = imm16;
- X(d, result);
- }
- // movn.html
- public static void Movn(bool sf, Bits hw, Bits imm16, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int datasize = (sf ? 64 : 32);
- /* if sf == '0' && hw<1> == '1' then UnallocatedEncoding(); */
- int pos = (int)UInt(Bits.Concat(hw, "0000"));
- /* Operation */
- Bits result = Zeros(datasize);
- result[pos + 15, pos] = imm16;
- result = NOT(result);
- X(d, result);
- }
- // movz.html
- public static void Movz(bool sf, Bits hw, Bits imm16, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int datasize = (sf ? 64 : 32);
- /* if sf == '0' && hw<1> == '1' then UnallocatedEncoding(); */
- int pos = (int)UInt(Bits.Concat(hw, "0000"));
- /* Operation */
- Bits result = Zeros(datasize);
- result[pos + 15, pos] = imm16;
- X(d, result);
- }
- #endregion
- #region "Mul"
- // madd.html
- public static void Madd(bool sf, Bits Rm, Bits Ra, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int a = (int)UInt(Ra);
- int datasize = (sf ? 64 : 32);
- /* Operation */
- Bits operand1 = X(datasize, n);
- Bits operand2 = X(datasize, m);
- Bits operand3 = X(datasize, a);
- BigInteger result = UInt(operand3) + (UInt(operand1) * UInt(operand2));
- X(d, result.SubBigInteger(datasize - 1, 0));
- }
- // msub.html
- public static void Msub(bool sf, Bits Rm, Bits Ra, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int a = (int)UInt(Ra);
- int datasize = (sf ? 64 : 32);
- /* Operation */
- Bits operand1 = X(datasize, n);
- Bits operand2 = X(datasize, m);
- Bits operand3 = X(datasize, a);
- BigInteger result = UInt(operand3) - (UInt(operand1) * UInt(operand2));
- X(d, result.SubBigInteger(datasize - 1, 0));
- }
- // smaddl.html
- public static void Smaddl(Bits Rm, Bits Ra, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int a = (int)UInt(Ra);
- /* Operation */
- Bits operand1 = X(32, n);
- Bits operand2 = X(32, m);
- Bits operand3 = X(64, a);
- BigInteger result = Int(operand3, false) + (Int(operand1, false) * Int(operand2, false));
- X(d, result.SubBigInteger(63, 0));
- }
- // umaddl.html
- public static void Umaddl(Bits Rm, Bits Ra, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int a = (int)UInt(Ra);
- /* Operation */
- Bits operand1 = X(32, n);
- Bits operand2 = X(32, m);
- Bits operand3 = X(64, a);
- BigInteger result = Int(operand3, true) + (Int(operand1, true) * Int(operand2, true));
- X(d, result.SubBigInteger(63, 0));
- }
- // smsubl.html
- public static void Smsubl(Bits Rm, Bits Ra, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int a = (int)UInt(Ra);
- /* Operation */
- Bits operand1 = X(32, n);
- Bits operand2 = X(32, m);
- Bits operand3 = X(64, a);
- BigInteger result = Int(operand3, false) - (Int(operand1, false) * Int(operand2, false));
- X(d, result.SubBigInteger(63, 0));
- }
- // umsubl.html
- public static void Umsubl(Bits Rm, Bits Ra, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int a = (int)UInt(Ra);
- /* Operation */
- Bits operand1 = X(32, n);
- Bits operand2 = X(32, m);
- Bits operand3 = X(64, a);
- BigInteger result = Int(operand3, true) - (Int(operand1, true) * Int(operand2, true));
- X(d, result.SubBigInteger(63, 0));
- }
- // smulh.html
- public static void Smulh(Bits Rm, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- /* Operation */
- Bits operand1 = X(64, n);
- Bits operand2 = X(64, m);
- BigInteger result = Int(operand1, false) * Int(operand2, false);
- X(d, result.SubBigInteger(127, 64));
- }
- // umulh.html
- public static void Umulh(Bits Rm, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- /* Operation */
- Bits operand1 = X(64, n);
- Bits operand2 = X(64, m);
- BigInteger result = Int(operand1, true) * Int(operand2, true);
- X(d, result.SubBigInteger(127, 64));
- }
- #endregion
- }
- // fpsimdindex.html
- internal static class SimdFp
- {
- #region "Simd"
- // abs_advsimd.html#ABS_asisdmisc_R
- public static void Abs_S(Bits size, Bits Rn, Bits Rd)
- {
- const bool U = false;
- /* Decode Scalar */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- /* if size != '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = esize;
- int elements = 1;
- bool neg = (U == true);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand = V(datasize, n);
- BigInteger element;
- for (int e = 0; e <= elements - 1; e++)
- {
- element = SInt(Elem(operand, e, esize));
- if (neg)
- {
- element = -element;
- }
- else
- {
- element = Abs(element);
- }
- Elem(result, e, esize, element.SubBigInteger(esize - 1, 0));
- }
- V(d, result);
- }
- // abs_advsimd.html#ABS_asimdmisc_R
- public static void Abs_V(bool Q, Bits size, Bits Rn, Bits Rd)
- {
- const bool U = false;
- /* Decode Vector */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- /* if size:Q == '110' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = (Q ? 128 : 64);
- int elements = datasize / esize;
- bool neg = (U == true);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand = V(datasize, n);
- BigInteger element;
- for (int e = 0; e <= elements - 1; e++)
- {
- element = SInt(Elem(operand, e, esize));
- if (neg)
- {
- element = -element;
- }
- else
- {
- element = Abs(element);
- }
- Elem(result, e, esize, element.SubBigInteger(esize - 1, 0));
- }
- V(d, result);
- }
- // addp_advsimd_pair.html
- public static void Addp_S(Bits size, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- /* if size != '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = esize * 2;
- // int elements = 2;
- ReduceOp op = ReduceOp.ReduceOp_ADD;
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits operand = V(datasize, n);
- V(d, Reduce(op, operand, esize));
- }
- // addv_advsimd.html
- public static void Addv_V(bool Q, Bits size, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- /* if size:Q == '100' then ReservedValue(); */
- /* if size == '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = (Q ? 128 : 64);
- // int elements = datasize / esize;
- ReduceOp op = ReduceOp.ReduceOp_ADD;
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits operand = V(datasize, n);
- V(d, Reduce(op, operand, esize));
- }
- // cls_advsimd.html
- public static void Cls_V(bool Q, Bits size, Bits Rn, Bits Rd)
- {
- const bool U = false;
- /* Decode Vector */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- /* if size == '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = (Q ? 128 : 64);
- int elements = datasize / esize;
- CountOp countop = (U ? CountOp.CountOp_CLZ : CountOp.CountOp_CLS);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand = V(datasize, n);
- BigInteger count;
- for (int e = 0; e <= elements - 1; e++)
- {
- if (countop == CountOp.CountOp_CLS)
- {
- count = (BigInteger)CountLeadingSignBits(Elem(operand, e, esize));
- }
- else
- {
- count = (BigInteger)CountLeadingZeroBits(Elem(operand, e, esize));
- }
- Elem(result, e, esize, count.SubBigInteger(esize - 1, 0));
- }
- V(d, result);
- }
- // clz_advsimd.html
- public static void Clz_V(bool Q, Bits size, Bits Rn, Bits Rd)
- {
- const bool U = true;
- /* Decode Vector */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- /* if size == '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = (Q ? 128 : 64);
- int elements = datasize / esize;
- CountOp countop = (U ? CountOp.CountOp_CLZ : CountOp.CountOp_CLS);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand = V(datasize, n);
- BigInteger count;
- for (int e = 0; e <= elements - 1; e++)
- {
- if (countop == CountOp.CountOp_CLS)
- {
- count = (BigInteger)CountLeadingSignBits(Elem(operand, e, esize));
- }
- else
- {
- count = (BigInteger)CountLeadingZeroBits(Elem(operand, e, esize));
- }
- Elem(result, e, esize, count.SubBigInteger(esize - 1, 0));
- }
- V(d, result);
- }
- // cmeq_advsimd_zero.html#CMEQ_asisdmisc_Z
- public static void Cmeq_Zero_S(Bits size, Bits Rn, Bits Rd)
- {
- const bool U = false;
- const bool op = true;
- /* Decode Scalar */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- /* if size != '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = esize;
- int elements = 1;
- CompareOp comparison;
- switch (Bits.Concat(op, U))
- {
- case Bits bits when bits == "00":
- comparison = CompareOp.CompareOp_GT;
- break;
- case Bits bits when bits == "01":
- comparison = CompareOp.CompareOp_GE;
- break;
- default:
- case Bits bits when bits == "10":
- comparison = CompareOp.CompareOp_EQ;
- break;
- case Bits bits when bits == "11":
- comparison = CompareOp.CompareOp_LE;
- break;
- }
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand = V(datasize, n);
- BigInteger element;
- bool test_passed;
- for (int e = 0; e <= elements - 1; e++)
- {
- element = SInt(Elem(operand, e, esize));
- switch (comparison)
- {
- case CompareOp.CompareOp_GT:
- test_passed = (element > (BigInteger)0);
- break;
- case CompareOp.CompareOp_GE:
- test_passed = (element >= (BigInteger)0);
- break;
- default:
- case CompareOp.CompareOp_EQ:
- test_passed = (element == (BigInteger)0);
- break;
- case CompareOp.CompareOp_LE:
- test_passed = (element <= (BigInteger)0);
- break;
- case CompareOp.CompareOp_LT:
- test_passed = (element < (BigInteger)0);
- break;
- }
- Elem(result, e, esize, test_passed ? Ones(esize) : Zeros(esize));
- }
- V(d, result);
- }
- // cmeq_advsimd_zero.html#CMEQ_asimdmisc_Z
- public static void Cmeq_Zero_V(bool Q, Bits size, Bits Rn, Bits Rd)
- {
- const bool U = false;
- const bool op = true;
- /* Decode Vector */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- /* if size:Q == '110' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = (Q ? 128 : 64);
- int elements = datasize / esize;
- CompareOp comparison;
- switch (Bits.Concat(op, U))
- {
- case Bits bits when bits == "00":
- comparison = CompareOp.CompareOp_GT;
- break;
- case Bits bits when bits == "01":
- comparison = CompareOp.CompareOp_GE;
- break;
- default:
- case Bits bits when bits == "10":
- comparison = CompareOp.CompareOp_EQ;
- break;
- case Bits bits when bits == "11":
- comparison = CompareOp.CompareOp_LE;
- break;
- }
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand = V(datasize, n);
- BigInteger element;
- bool test_passed;
- for (int e = 0; e <= elements - 1; e++)
- {
- element = SInt(Elem(operand, e, esize));
- switch (comparison)
- {
- case CompareOp.CompareOp_GT:
- test_passed = (element > (BigInteger)0);
- break;
- case CompareOp.CompareOp_GE:
- test_passed = (element >= (BigInteger)0);
- break;
- default:
- case CompareOp.CompareOp_EQ:
- test_passed = (element == (BigInteger)0);
- break;
- case CompareOp.CompareOp_LE:
- test_passed = (element <= (BigInteger)0);
- break;
- case CompareOp.CompareOp_LT:
- test_passed = (element < (BigInteger)0);
- break;
- }
- Elem(result, e, esize, test_passed ? Ones(esize) : Zeros(esize));
- }
- V(d, result);
- }
- // cmge_advsimd_zero.html#CMGE_asisdmisc_Z
- public static void Cmge_Zero_S(Bits size, Bits Rn, Bits Rd)
- {
- const bool U = true;
- const bool op = false;
- /* Decode Scalar */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- /* if size != '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = esize;
- int elements = 1;
- CompareOp comparison;
- switch (Bits.Concat(op, U))
- {
- case Bits bits when bits == "00":
- comparison = CompareOp.CompareOp_GT;
- break;
- default:
- case Bits bits when bits == "01":
- comparison = CompareOp.CompareOp_GE;
- break;
- case Bits bits when bits == "10":
- comparison = CompareOp.CompareOp_EQ;
- break;
- case Bits bits when bits == "11":
- comparison = CompareOp.CompareOp_LE;
- break;
- }
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand = V(datasize, n);
- BigInteger element;
- bool test_passed;
- for (int e = 0; e <= elements - 1; e++)
- {
- element = SInt(Elem(operand, e, esize));
- switch (comparison)
- {
- case CompareOp.CompareOp_GT:
- test_passed = (element > (BigInteger)0);
- break;
- default:
- case CompareOp.CompareOp_GE:
- test_passed = (element >= (BigInteger)0);
- break;
- case CompareOp.CompareOp_EQ:
- test_passed = (element == (BigInteger)0);
- break;
- case CompareOp.CompareOp_LE:
- test_passed = (element <= (BigInteger)0);
- break;
- case CompareOp.CompareOp_LT:
- test_passed = (element < (BigInteger)0);
- break;
- }
- Elem(result, e, esize, test_passed ? Ones(esize) : Zeros(esize));
- }
- V(d, result);
- }
- // cmge_advsimd_zero.html#CMGE_asimdmisc_Z
- public static void Cmge_Zero_V(bool Q, Bits size, Bits Rn, Bits Rd)
- {
- const bool U = true;
- const bool op = false;
- /* Decode Vector */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- /* if size:Q == '110' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = (Q ? 128 : 64);
- int elements = datasize / esize;
- CompareOp comparison;
- switch (Bits.Concat(op, U))
- {
- case Bits bits when bits == "00":
- comparison = CompareOp.CompareOp_GT;
- break;
- default:
- case Bits bits when bits == "01":
- comparison = CompareOp.CompareOp_GE;
- break;
- case Bits bits when bits == "10":
- comparison = CompareOp.CompareOp_EQ;
- break;
- case Bits bits when bits == "11":
- comparison = CompareOp.CompareOp_LE;
- break;
- }
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand = V(datasize, n);
- BigInteger element;
- bool test_passed;
- for (int e = 0; e <= elements - 1; e++)
- {
- element = SInt(Elem(operand, e, esize));
- switch (comparison)
- {
- case CompareOp.CompareOp_GT:
- test_passed = (element > (BigInteger)0);
- break;
- default:
- case CompareOp.CompareOp_GE:
- test_passed = (element >= (BigInteger)0);
- break;
- case CompareOp.CompareOp_EQ:
- test_passed = (element == (BigInteger)0);
- break;
- case CompareOp.CompareOp_LE:
- test_passed = (element <= (BigInteger)0);
- break;
- case CompareOp.CompareOp_LT:
- test_passed = (element < (BigInteger)0);
- break;
- }
- Elem(result, e, esize, test_passed ? Ones(esize) : Zeros(esize));
- }
- V(d, result);
- }
- // cmgt_advsimd_zero.html#CMGT_asisdmisc_Z
- public static void Cmgt_Zero_S(Bits size, Bits Rn, Bits Rd)
- {
- const bool U = false;
- const bool op = false;
- /* Decode Scalar */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- /* if size != '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = esize;
- int elements = 1;
- CompareOp comparison;
- switch (Bits.Concat(op, U))
- {
- default:
- case Bits bits when bits == "00":
- comparison = CompareOp.CompareOp_GT;
- break;
- case Bits bits when bits == "01":
- comparison = CompareOp.CompareOp_GE;
- break;
- case Bits bits when bits == "10":
- comparison = CompareOp.CompareOp_EQ;
- break;
- case Bits bits when bits == "11":
- comparison = CompareOp.CompareOp_LE;
- break;
- }
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand = V(datasize, n);
- BigInteger element;
- bool test_passed;
- for (int e = 0; e <= elements - 1; e++)
- {
- element = SInt(Elem(operand, e, esize));
- switch (comparison)
- {
- default:
- case CompareOp.CompareOp_GT:
- test_passed = (element > (BigInteger)0);
- break;
- case CompareOp.CompareOp_GE:
- test_passed = (element >= (BigInteger)0);
- break;
- case CompareOp.CompareOp_EQ:
- test_passed = (element == (BigInteger)0);
- break;
- case CompareOp.CompareOp_LE:
- test_passed = (element <= (BigInteger)0);
- break;
- case CompareOp.CompareOp_LT:
- test_passed = (element < (BigInteger)0);
- break;
- }
- Elem(result, e, esize, test_passed ? Ones(esize) : Zeros(esize));
- }
- V(d, result);
- }
- // cmgt_advsimd_zero.html#CMGT_asimdmisc_Z
- public static void Cmgt_Zero_V(bool Q, Bits size, Bits Rn, Bits Rd)
- {
- const bool U = false;
- const bool op = false;
- /* Decode Vector */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- /* if size:Q == '110' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = (Q ? 128 : 64);
- int elements = datasize / esize;
- CompareOp comparison;
- switch (Bits.Concat(op, U))
- {
- default:
- case Bits bits when bits == "00":
- comparison = CompareOp.CompareOp_GT;
- break;
- case Bits bits when bits == "01":
- comparison = CompareOp.CompareOp_GE;
- break;
- case Bits bits when bits == "10":
- comparison = CompareOp.CompareOp_EQ;
- break;
- case Bits bits when bits == "11":
- comparison = CompareOp.CompareOp_LE;
- break;
- }
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand = V(datasize, n);
- BigInteger element;
- bool test_passed;
- for (int e = 0; e <= elements - 1; e++)
- {
- element = SInt(Elem(operand, e, esize));
- switch (comparison)
- {
- default:
- case CompareOp.CompareOp_GT:
- test_passed = (element > (BigInteger)0);
- break;
- case CompareOp.CompareOp_GE:
- test_passed = (element >= (BigInteger)0);
- break;
- case CompareOp.CompareOp_EQ:
- test_passed = (element == (BigInteger)0);
- break;
- case CompareOp.CompareOp_LE:
- test_passed = (element <= (BigInteger)0);
- break;
- case CompareOp.CompareOp_LT:
- test_passed = (element < (BigInteger)0);
- break;
- }
- Elem(result, e, esize, test_passed ? Ones(esize) : Zeros(esize));
- }
- V(d, result);
- }
- // cmle_advsimd.html#CMLE_asisdmisc_Z
- public static void Cmle_S(Bits size, Bits Rn, Bits Rd)
- {
- const bool U = true;
- const bool op = true;
- /* Decode Scalar */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- /* if size != '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = esize;
- int elements = 1;
- CompareOp comparison;
- switch (Bits.Concat(op, U))
- {
- case Bits bits when bits == "00":
- comparison = CompareOp.CompareOp_GT;
- break;
- case Bits bits when bits == "01":
- comparison = CompareOp.CompareOp_GE;
- break;
- case Bits bits when bits == "10":
- comparison = CompareOp.CompareOp_EQ;
- break;
- default:
- case Bits bits when bits == "11":
- comparison = CompareOp.CompareOp_LE;
- break;
- }
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand = V(datasize, n);
- BigInteger element;
- bool test_passed;
- for (int e = 0; e <= elements - 1; e++)
- {
- element = SInt(Elem(operand, e, esize));
- switch (comparison)
- {
- case CompareOp.CompareOp_GT:
- test_passed = (element > (BigInteger)0);
- break;
- case CompareOp.CompareOp_GE:
- test_passed = (element >= (BigInteger)0);
- break;
- case CompareOp.CompareOp_EQ:
- test_passed = (element == (BigInteger)0);
- break;
- default:
- case CompareOp.CompareOp_LE:
- test_passed = (element <= (BigInteger)0);
- break;
- case CompareOp.CompareOp_LT:
- test_passed = (element < (BigInteger)0);
- break;
- }
- Elem(result, e, esize, test_passed ? Ones(esize) : Zeros(esize));
- }
- V(d, result);
- }
- // cmle_advsimd.html#CMLE_asimdmisc_Z
- public static void Cmle_V(bool Q, Bits size, Bits Rn, Bits Rd)
- {
- const bool U = true;
- const bool op = true;
- /* Decode Vector */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- /* if size:Q == '110' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = (Q ? 128 : 64);
- int elements = datasize / esize;
- CompareOp comparison;
- switch (Bits.Concat(op, U))
- {
- case Bits bits when bits == "00":
- comparison = CompareOp.CompareOp_GT;
- break;
- case Bits bits when bits == "01":
- comparison = CompareOp.CompareOp_GE;
- break;
- case Bits bits when bits == "10":
- comparison = CompareOp.CompareOp_EQ;
- break;
- default:
- case Bits bits when bits == "11":
- comparison = CompareOp.CompareOp_LE;
- break;
- }
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand = V(datasize, n);
- BigInteger element;
- bool test_passed;
- for (int e = 0; e <= elements - 1; e++)
- {
- element = SInt(Elem(operand, e, esize));
- switch (comparison)
- {
- case CompareOp.CompareOp_GT:
- test_passed = (element > (BigInteger)0);
- break;
- case CompareOp.CompareOp_GE:
- test_passed = (element >= (BigInteger)0);
- break;
- case CompareOp.CompareOp_EQ:
- test_passed = (element == (BigInteger)0);
- break;
- default:
- case CompareOp.CompareOp_LE:
- test_passed = (element <= (BigInteger)0);
- break;
- case CompareOp.CompareOp_LT:
- test_passed = (element < (BigInteger)0);
- break;
- }
- Elem(result, e, esize, test_passed ? Ones(esize) : Zeros(esize));
- }
- V(d, result);
- }
- // cmlt_advsimd.html#CMLT_asisdmisc_Z
- public static void Cmlt_S(Bits size, Bits Rn, Bits Rd)
- {
- /* Decode Scalar */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- /* if size != '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = esize;
- int elements = 1;
- CompareOp comparison = CompareOp.CompareOp_LT;
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand = V(datasize, n);
- BigInteger element;
- bool test_passed;
- for (int e = 0; e <= elements - 1; e++)
- {
- element = SInt(Elem(operand, e, esize));
- switch (comparison)
- {
- case CompareOp.CompareOp_GT:
- test_passed = (element > (BigInteger)0);
- break;
- case CompareOp.CompareOp_GE:
- test_passed = (element >= (BigInteger)0);
- break;
- case CompareOp.CompareOp_EQ:
- test_passed = (element == (BigInteger)0);
- break;
- case CompareOp.CompareOp_LE:
- test_passed = (element <= (BigInteger)0);
- break;
- default:
- case CompareOp.CompareOp_LT:
- test_passed = (element < (BigInteger)0);
- break;
- }
- Elem(result, e, esize, test_passed ? Ones(esize) : Zeros(esize));
- }
- V(d, result);
- }
- // cmlt_advsimd.html#CMLT_asimdmisc_Z
- public static void Cmlt_V(bool Q, Bits size, Bits Rn, Bits Rd)
- {
- /* Decode Vector */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- /* if size:Q == '110' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = (Q ? 128 : 64);
- int elements = datasize / esize;
- CompareOp comparison = CompareOp.CompareOp_LT;
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand = V(datasize, n);
- BigInteger element;
- bool test_passed;
- for (int e = 0; e <= elements - 1; e++)
- {
- element = SInt(Elem(operand, e, esize));
- switch (comparison)
- {
- case CompareOp.CompareOp_GT:
- test_passed = (element > (BigInteger)0);
- break;
- case CompareOp.CompareOp_GE:
- test_passed = (element >= (BigInteger)0);
- break;
- case CompareOp.CompareOp_EQ:
- test_passed = (element == (BigInteger)0);
- break;
- case CompareOp.CompareOp_LE:
- test_passed = (element <= (BigInteger)0);
- break;
- default:
- case CompareOp.CompareOp_LT:
- test_passed = (element < (BigInteger)0);
- break;
- }
- Elem(result, e, esize, test_passed ? Ones(esize) : Zeros(esize));
- }
- V(d, result);
- }
- // cnt_advsimd.html
- public static void Cnt_V(bool Q, Bits size, Bits Rn, Bits Rd)
- {
- /* Decode Vector */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- /* if size != '00' then ReservedValue(); */
- int esize = 8;
- int datasize = (Q ? 128 : 64);
- int elements = datasize / 8;
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand = V(datasize, n);
- BigInteger count;
- for (int e = 0; e <= elements - 1; e++)
- {
- count = (BigInteger)BitCount(Elem(operand, e, esize));
- Elem(result, e, esize, count.SubBigInteger(esize - 1, 0));
- }
- V(d, result);
- }
- // neg_advsimd.html#NEG_asisdmisc_R
- public static void Neg_S(Bits size, Bits Rn, Bits Rd)
- {
- const bool U = true;
- /* Decode Scalar */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- /* if size != '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = esize;
- int elements = 1;
- bool neg = (U == true);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand = V(datasize, n);
- BigInteger element;
- for (int e = 0; e <= elements - 1; e++)
- {
- element = SInt(Elem(operand, e, esize));
- if (neg)
- {
- element = -element;
- }
- else
- {
- element = Abs(element);
- }
- Elem(result, e, esize, element.SubBigInteger(esize - 1, 0));
- }
- V(d, result);
- }
- // neg_advsimd.html#NEG_asimdmisc_R
- public static void Neg_V(bool Q, Bits size, Bits Rn, Bits Rd)
- {
- const bool U = true;
- /* Decode Vector */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- /* if size:Q == '110' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = (Q ? 128 : 64);
- int elements = datasize / esize;
- bool neg = (U == true);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand = V(datasize, n);
- BigInteger element;
- for (int e = 0; e <= elements - 1; e++)
- {
- element = SInt(Elem(operand, e, esize));
- if (neg)
- {
- element = -element;
- }
- else
- {
- element = Abs(element);
- }
- Elem(result, e, esize, element.SubBigInteger(esize - 1, 0));
- }
- V(d, result);
- }
- // not_advsimd.html
- public static void Not_V(bool Q, Bits Rn, Bits Rd)
- {
- /* Decode Vector */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int esize = 8;
- int datasize = (Q ? 128 : 64);
- int elements = datasize / 8;
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand = V(datasize, n);
- Bits element;
- for (int e = 0; e <= elements - 1; e++)
- {
- element = Elem(operand, e, esize);
- Elem(result, e, esize, NOT(element));
- }
- V(d, result);
- }
- // rbit_advsimd.html
- public static void Rbit_V(bool Q, Bits Rn, Bits Rd)
- {
- /* Decode Vector */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int esize = 8;
- int datasize = (Q ? 128 : 64);
- int elements = datasize / 8;
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand = V(datasize, n);
- Bits element;
- Bits rev = new Bits(esize);
- for (int e = 0; e <= elements - 1; e++)
- {
- element = Elem(operand, e, esize);
- for (int i = 0; i <= esize - 1; i++)
- {
- rev[esize - 1 - i] = element[i];
- }
- Elem(result, e, esize, rev);
- }
- V(d, result);
- }
- // rev16_advsimd.html
- public static void Rev16_V(bool Q, Bits size, Bits Rn, Bits Rd)
- {
- const bool U = false;
- const bool o0 = true;
- /* Decode Vector */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- // size=esize: B(0), H(1), S(1), D(S)
- int esize = 8 << (int)UInt(size);
- int datasize = (Q ? 128 : 64);
- // op=REVx: 64(0), 32(1), 16(2)
- Bits op = Bits.Concat(o0, U);
- // => op+size:
- // 64+B = 0, 64+H = 1, 64+S = 2, 64+D = X
- // 32+B = 1, 32+H = 2, 32+S = X, 32+D = X
- // 16+B = 2, 16+H = X, 16+S = X, 16+D = X
- // 8+B = X, 8+H = X, 8+S = X, 8+D = X
- // => 3-(op+size) (index bits in group)
- // 64/B = 3, 64+H = 2, 64+S = 1, 64+D = X
- // 32+B = 2, 32+H = 1, 32+S = X, 32+D = X
- // 16+B = 1, 16+H = X, 16+S = X, 16+D = X
- // 8+B = X, 8+H = X, 8+S = X, 8+D = X
- // index bits within group: 1, 2, 3
- /* if UInt(op) + UInt(size) >= 3 then UnallocatedEncoding(); */
- int container_size;
- switch (op)
- {
- default:
- case Bits bits when bits == "10":
- container_size = 16;
- break;
- case Bits bits when bits == "01":
- container_size = 32;
- break;
- case Bits bits when bits == "00":
- container_size = 64;
- break;
- }
- int containers = datasize / container_size;
- int elements_per_container = container_size / esize;
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand = V(datasize, n);
- int element = 0;
- int rev_element;
- for (int c = 0; c <= containers - 1; c++)
- {
- rev_element = element + elements_per_container - 1;
- for (int e = 0; e <= elements_per_container - 1; e++)
- {
- Elem(result, rev_element, esize, Elem(operand, element, esize));
- element = element + 1;
- rev_element = rev_element - 1;
- }
- }
- V(d, result);
- }
- // rev32_advsimd.html
- public static void Rev32_V(bool Q, Bits size, Bits Rn, Bits Rd)
- {
- const bool U = true;
- const bool o0 = false;
- /* Decode Vector */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- // size=esize: B(0), H(1), S(1), D(S)
- int esize = 8 << (int)UInt(size);
- int datasize = (Q ? 128 : 64);
- // op=REVx: 64(0), 32(1), 16(2)
- Bits op = Bits.Concat(o0, U);
- // => op+size:
- // 64+B = 0, 64+H = 1, 64+S = 2, 64+D = X
- // 32+B = 1, 32+H = 2, 32+S = X, 32+D = X
- // 16+B = 2, 16+H = X, 16+S = X, 16+D = X
- // 8+B = X, 8+H = X, 8+S = X, 8+D = X
- // => 3-(op+size) (index bits in group)
- // 64/B = 3, 64+H = 2, 64+S = 1, 64+D = X
- // 32+B = 2, 32+H = 1, 32+S = X, 32+D = X
- // 16+B = 1, 16+H = X, 16+S = X, 16+D = X
- // 8+B = X, 8+H = X, 8+S = X, 8+D = X
- // index bits within group: 1, 2, 3
- /* if UInt(op) + UInt(size) >= 3 then UnallocatedEncoding(); */
- int container_size;
- switch (op)
- {
- case Bits bits when bits == "10":
- container_size = 16;
- break;
- default:
- case Bits bits when bits == "01":
- container_size = 32;
- break;
- case Bits bits when bits == "00":
- container_size = 64;
- break;
- }
- int containers = datasize / container_size;
- int elements_per_container = container_size / esize;
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand = V(datasize, n);
- int element = 0;
- int rev_element;
- for (int c = 0; c <= containers - 1; c++)
- {
- rev_element = element + elements_per_container - 1;
- for (int e = 0; e <= elements_per_container - 1; e++)
- {
- Elem(result, rev_element, esize, Elem(operand, element, esize));
- element = element + 1;
- rev_element = rev_element - 1;
- }
- }
- V(d, result);
- }
- // rev64_advsimd.html
- public static void Rev64_V(bool Q, Bits size, Bits Rn, Bits Rd)
- {
- const bool U = false;
- const bool o0 = false;
- /* Decode Vector */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- // size=esize: B(0), H(1), S(1), D(S)
- int esize = 8 << (int)UInt(size);
- int datasize = (Q ? 128 : 64);
- // op=REVx: 64(0), 32(1), 16(2)
- Bits op = Bits.Concat(o0, U);
- // => op+size:
- // 64+B = 0, 64+H = 1, 64+S = 2, 64+D = X
- // 32+B = 1, 32+H = 2, 32+S = X, 32+D = X
- // 16+B = 2, 16+H = X, 16+S = X, 16+D = X
- // 8+B = X, 8+H = X, 8+S = X, 8+D = X
- // => 3-(op+size) (index bits in group)
- // 64/B = 3, 64+H = 2, 64+S = 1, 64+D = X
- // 32+B = 2, 32+H = 1, 32+S = X, 32+D = X
- // 16+B = 1, 16+H = X, 16+S = X, 16+D = X
- // 8+B = X, 8+H = X, 8+S = X, 8+D = X
- // index bits within group: 1, 2, 3
- /* if UInt(op) + UInt(size) >= 3 then UnallocatedEncoding(); */
- int container_size;
- switch (op)
- {
- case Bits bits when bits == "10":
- container_size = 16;
- break;
- case Bits bits when bits == "01":
- container_size = 32;
- break;
- default:
- case Bits bits when bits == "00":
- container_size = 64;
- break;
- }
- int containers = datasize / container_size;
- int elements_per_container = container_size / esize;
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand = V(datasize, n);
- int element = 0;
- int rev_element;
- for (int c = 0; c <= containers - 1; c++)
- {
- rev_element = element + elements_per_container - 1;
- for (int e = 0; e <= elements_per_container - 1; e++)
- {
- Elem(result, rev_element, esize, Elem(operand, element, esize));
- element = element + 1;
- rev_element = rev_element - 1;
- }
- }
- V(d, result);
- }
- // sqxtn_advsimd.html#SQXTN_asisdmisc_N
- public static void Sqxtn_S(Bits size, Bits Rn, Bits Rd)
- {
- const bool U = false;
- /* Decode Scalar */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- /* if size == '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = esize;
- int part = 0;
- int elements = 1;
- bool unsigned = (U == true);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand = V(2 * datasize, n);
- Bits element;
- bool sat;
- for (int e = 0; e <= elements - 1; e++)
- {
- element = Elem(operand, e, 2 * esize);
- (Bits _result, bool _sat) = SatQ(Int(element, unsigned), esize, unsigned);
- Elem(result, e, esize, _result);
- sat = _sat;
- if (sat)
- {
- /* FPSR.QC = '1'; */
- FPSR[27] = true; // TODO: Add named fields.
- }
- }
- Vpart(d, part, result);
- }
- // sqxtn_advsimd.html#SQXTN_asimdmisc_N
- public static void Sqxtn_V(bool Q, Bits size, Bits Rn, Bits Rd)
- {
- const bool U = false;
- /* Decode Vector */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- /* if size == '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = 64;
- int part = (int)UInt(Q);
- int elements = datasize / esize;
- bool unsigned = (U == true);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand = V(2 * datasize, n);
- Bits element;
- bool sat;
- for (int e = 0; e <= elements - 1; e++)
- {
- element = Elem(operand, e, 2 * esize);
- (Bits _result, bool _sat) = SatQ(Int(element, unsigned), esize, unsigned);
- Elem(result, e, esize, _result);
- sat = _sat;
- if (sat)
- {
- /* FPSR.QC = '1'; */
- FPSR[27] = true; // TODO: Add named fields.
- }
- }
- Vpart(d, part, result);
- }
- // sqxtun_advsimd.html#SQXTUN_asisdmisc_N
- public static void Sqxtun_S(Bits size, Bits Rn, Bits Rd)
- {
- /* Decode Scalar */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- /* if size == '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = esize;
- int part = 0;
- int elements = 1;
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand = V(2 * datasize, n);
- Bits element;
- bool sat;
- for (int e = 0; e <= elements - 1; e++)
- {
- element = Elem(operand, e, 2 * esize);
- (Bits _result, bool _sat) = UnsignedSatQ(SInt(element), esize);
- Elem(result, e, esize, _result);
- sat = _sat;
- if (sat)
- {
- /* FPSR.QC = '1'; */
- FPSR[27] = true; // TODO: Add named fields.
- }
- }
- Vpart(d, part, result);
- }
- // sqxtun_advsimd.html#SQXTUN_asimdmisc_N
- public static void Sqxtun_V(bool Q, Bits size, Bits Rn, Bits Rd)
- {
- /* Decode Vector */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- /* if size == '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = 64;
- int part = (int)UInt(Q);
- int elements = datasize / esize;
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand = V(2 * datasize, n);
- Bits element;
- bool sat;
- for (int e = 0; e <= elements - 1; e++)
- {
- element = Elem(operand, e, 2 * esize);
- (Bits _result, bool _sat) = UnsignedSatQ(SInt(element), esize);
- Elem(result, e, esize, _result);
- sat = _sat;
- if (sat)
- {
- /* FPSR.QC = '1'; */
- FPSR[27] = true; // TODO: Add named fields.
- }
- }
- Vpart(d, part, result);
- }
- // uqxtn_advsimd.html#UQXTN_asisdmisc_N
- public static void Uqxtn_S(Bits size, Bits Rn, Bits Rd)
- {
- const bool U = true;
- /* Decode Scalar */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- /* if size == '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = esize;
- int part = 0;
- int elements = 1;
- bool unsigned = (U == true);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand = V(2 * datasize, n);
- Bits element;
- bool sat;
- for (int e = 0; e <= elements - 1; e++)
- {
- element = Elem(operand, e, 2 * esize);
- (Bits _result, bool _sat) = SatQ(Int(element, unsigned), esize, unsigned);
- Elem(result, e, esize, _result);
- sat = _sat;
- if (sat)
- {
- /* FPSR.QC = '1'; */
- FPSR[27] = true; // TODO: Add named fields.
- }
- }
- Vpart(d, part, result);
- }
- // uqxtn_advsimd.html#UQXTN_asimdmisc_N
- public static void Uqxtn_V(bool Q, Bits size, Bits Rn, Bits Rd)
- {
- const bool U = true;
- /* Decode Vector */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- /* if size == '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = 64;
- int part = (int)UInt(Q);
- int elements = datasize / esize;
- bool unsigned = (U == true);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand = V(2 * datasize, n);
- Bits element;
- bool sat;
- for (int e = 0; e <= elements - 1; e++)
- {
- element = Elem(operand, e, 2 * esize);
- (Bits _result, bool _sat) = SatQ(Int(element, unsigned), esize, unsigned);
- Elem(result, e, esize, _result);
- sat = _sat;
- if (sat)
- {
- /* FPSR.QC = '1'; */
- FPSR[27] = true; // TODO: Add named fields.
- }
- }
- Vpart(d, part, result);
- }
- #endregion
- #region "SimdReg"
- // add_advsimd.html#ADD_asisdsame_only
- public static void Add_S(Bits size, Bits Rm, Bits Rn, Bits Rd)
- {
- const bool U = false;
- /* Decode Scalar */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- /* if size != '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = esize;
- int elements = 1;
- bool sub_op = (U == true);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand1 = V(datasize, n);
- Bits operand2 = V(datasize, m);
- Bits element1;
- Bits element2;
- for (int e = 0; e <= elements - 1; e++)
- {
- element1 = Elem(operand1, e, esize);
- element2 = Elem(operand2, e, esize);
- if (sub_op)
- {
- Elem(result, e, esize, element1 - element2);
- }
- else
- {
- Elem(result, e, esize, element1 + element2);
- }
- }
- V(d, result);
- }
- // add_advsimd.html#ADD_asimdsame_only
- public static void Add_V(bool Q, Bits size, Bits Rm, Bits Rn, Bits Rd)
- {
- const bool U = false;
- /* Decode Vector */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- /* if size:Q == '110' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = (Q ? 128 : 64);
- int elements = datasize / esize;
- bool sub_op = (U == true);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand1 = V(datasize, n);
- Bits operand2 = V(datasize, m);
- Bits element1;
- Bits element2;
- for (int e = 0; e <= elements - 1; e++)
- {
- element1 = Elem(operand1, e, esize);
- element2 = Elem(operand2, e, esize);
- if (sub_op)
- {
- Elem(result, e, esize, element1 - element2);
- }
- else
- {
- Elem(result, e, esize, element1 + element2);
- }
- }
- V(d, result);
- }
- // addhn_advsimd.html
- public static void Addhn_V(bool Q, Bits size, Bits Rm, Bits Rn, Bits Rd)
- {
- const bool U = false;
- const bool o1 = false;
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- /* if size == '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = 64;
- int part = (int)UInt(Q);
- int elements = datasize / esize;
- bool sub_op = (o1 == true);
- bool round = (U == true);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand1 = V(2 * datasize, n);
- Bits operand2 = V(2 * datasize, m);
- BigInteger round_const = (round ? (BigInteger)1 << (esize - 1) : 0);
- Bits sum;
- Bits element1;
- Bits element2;
- for (int e = 0; e <= elements - 1; e++)
- {
- element1 = Elem(operand1, e, 2 * esize);
- element2 = Elem(operand2, e, 2 * esize);
- if (sub_op)
- {
- sum = element1 - element2;
- }
- else
- {
- sum = element1 + element2;
- }
- sum = sum + round_const;
- Elem(result, e, esize, sum[2 * esize - 1, esize]);
- }
- Vpart(d, part, result);
- }
- // addp_advsimd_vec.html
- public static void Addp_V(bool Q, Bits size, Bits Rm, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- /* if size:Q == '110' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = (Q ? 128 : 64);
- int elements = datasize / esize;
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand1 = V(datasize, n);
- Bits operand2 = V(datasize, m);
- Bits concat = Bits.Concat(operand2, operand1);
- Bits element1;
- Bits element2;
- for (int e = 0; e <= elements - 1; e++)
- {
- element1 = Elem(concat, 2 * e, esize);
- element2 = Elem(concat, (2 * e) + 1, esize);
- Elem(result, e, esize, element1 + element2);
- }
- V(d, result);
- }
- // and_advsimd.html
- public static void And_V(bool Q, Bits Rm, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (Q ? 128 : 64);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits operand1 = V(datasize, n);
- Bits operand2 = V(datasize, m);
- Bits result = AND(operand1, operand2);
- V(d, result);
- }
- // bic_advsimd_reg.html
- public static void Bic_V(bool Q, Bits Rm, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (Q ? 128 : 64);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits operand1 = V(datasize, n);
- Bits operand2 = V(datasize, m);
- operand2 = NOT(operand2);
- Bits result = AND(operand1, operand2);
- V(d, result);
- }
- // bif_advsimd.html
- public static void Bif_V(bool Q, Bits Rm, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (Q ? 128 : 64);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits operand1;
- Bits operand3;
- Bits operand4 = V(datasize, n);
- operand1 = V(datasize, d);
- operand3 = NOT(V(datasize, m));
- V(d, EOR(operand1, AND(EOR(operand1, operand4), operand3)));
- }
- // bit_advsimd.html
- public static void Bit_V(bool Q, Bits Rm, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (Q ? 128 : 64);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits operand1;
- Bits operand3;
- Bits operand4 = V(datasize, n);
- operand1 = V(datasize, d);
- operand3 = V(datasize, m);
- V(d, EOR(operand1, AND(EOR(operand1, operand4), operand3)));
- }
- // bsl_advsimd.html
- public static void Bsl_V(bool Q, Bits Rm, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (Q ? 128 : 64);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits operand1;
- Bits operand3;
- Bits operand4 = V(datasize, n);
- operand1 = V(datasize, m);
- operand3 = V(datasize, d);
- V(d, EOR(operand1, AND(EOR(operand1, operand4), operand3)));
- }
- // cmeq_advsimd_reg.html#CMEQ_asisdsame_only
- public static void Cmeq_Reg_S(Bits size, Bits Rm, Bits Rn, Bits Rd)
- {
- const bool U = true;
- /* Decode Scalar */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- /* if size != '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = esize;
- int elements = 1;
- bool and_test = (U == false);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand1 = V(datasize, n);
- Bits operand2 = V(datasize, m);
- Bits element1;
- Bits element2;
- bool test_passed;
- for (int e = 0; e <= elements - 1; e++)
- {
- element1 = Elem(operand1, e, esize);
- element2 = Elem(operand2, e, esize);
- if (and_test)
- {
- test_passed = !IsZero(AND(element1, element2));
- }
- else
- {
- test_passed = (element1 == element2);
- }
- Elem(result, e, esize, test_passed ? Ones(esize) : Zeros(esize));
- }
- V(d, result);
- }
- // cmeq_advsimd_reg.html#CMEQ_asimdsame_only
- public static void Cmeq_Reg_V(bool Q, Bits size, Bits Rm, Bits Rn, Bits Rd)
- {
- const bool U = true;
- /* Decode Vector */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- /* if size:Q == '110' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = (Q ? 128 : 64);
- int elements = datasize / esize;
- bool and_test = (U == false);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand1 = V(datasize, n);
- Bits operand2 = V(datasize, m);
- Bits element1;
- Bits element2;
- bool test_passed;
- for (int e = 0; e <= elements - 1; e++)
- {
- element1 = Elem(operand1, e, esize);
- element2 = Elem(operand2, e, esize);
- if (and_test)
- {
- test_passed = !IsZero(AND(element1, element2));
- }
- else
- {
- test_passed = (element1 == element2);
- }
- Elem(result, e, esize, test_passed ? Ones(esize) : Zeros(esize));
- }
- V(d, result);
- }
- // cmge_advsimd_reg.html#CMGE_asisdsame_only
- public static void Cmge_Reg_S(Bits size, Bits Rm, Bits Rn, Bits Rd)
- {
- const bool U = false;
- const bool eq = true;
- /* Decode Scalar */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- /* if size != '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = esize;
- int elements = 1;
- bool unsigned = (U == true);
- bool cmp_eq = (eq == true);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand1 = V(datasize, n);
- Bits operand2 = V(datasize, m);
- BigInteger element1;
- BigInteger element2;
- bool test_passed;
- for (int e = 0; e <= elements - 1; e++)
- {
- element1 = Int(Elem(operand1, e, esize), unsigned);
- element2 = Int(Elem(operand2, e, esize), unsigned);
- test_passed = (cmp_eq ? element1 >= element2 : element1 > element2);
- Elem(result, e, esize, test_passed ? Ones(esize) : Zeros(esize));
- }
- V(d, result);
- }
- // cmge_advsimd_reg.html#CMGE_asimdsame_only
- public static void Cmge_Reg_V(bool Q, Bits size, Bits Rm, Bits Rn, Bits Rd)
- {
- const bool U = false;
- const bool eq = true;
- /* Decode Vector */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- /* if size:Q == '110' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = (Q ? 128 : 64);
- int elements = datasize / esize;
- bool unsigned = (U == true);
- bool cmp_eq = (eq == true);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand1 = V(datasize, n);
- Bits operand2 = V(datasize, m);
- BigInteger element1;
- BigInteger element2;
- bool test_passed;
- for (int e = 0; e <= elements - 1; e++)
- {
- element1 = Int(Elem(operand1, e, esize), unsigned);
- element2 = Int(Elem(operand2, e, esize), unsigned);
- test_passed = (cmp_eq ? element1 >= element2 : element1 > element2);
- Elem(result, e, esize, test_passed ? Ones(esize) : Zeros(esize));
- }
- V(d, result);
- }
- // cmgt_advsimd_reg.html#CMGT_asisdsame_only
- public static void Cmgt_Reg_S(Bits size, Bits Rm, Bits Rn, Bits Rd)
- {
- const bool U = false;
- const bool eq = false;
- /* Decode Scalar */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- /* if size != '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = esize;
- int elements = 1;
- bool unsigned = (U == true);
- bool cmp_eq = (eq == true);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand1 = V(datasize, n);
- Bits operand2 = V(datasize, m);
- BigInteger element1;
- BigInteger element2;
- bool test_passed;
- for (int e = 0; e <= elements - 1; e++)
- {
- element1 = Int(Elem(operand1, e, esize), unsigned);
- element2 = Int(Elem(operand2, e, esize), unsigned);
- test_passed = (cmp_eq ? element1 >= element2 : element1 > element2);
- Elem(result, e, esize, test_passed ? Ones(esize) : Zeros(esize));
- }
- V(d, result);
- }
- // cmgt_advsimd_reg.html#CMGT_asimdsame_only
- public static void Cmgt_Reg_V(bool Q, Bits size, Bits Rm, Bits Rn, Bits Rd)
- {
- const bool U = false;
- const bool eq = false;
- /* Decode Vector */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- /* if size:Q == '110' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = (Q ? 128 : 64);
- int elements = datasize / esize;
- bool unsigned = (U == true);
- bool cmp_eq = (eq == true);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand1 = V(datasize, n);
- Bits operand2 = V(datasize, m);
- BigInteger element1;
- BigInteger element2;
- bool test_passed;
- for (int e = 0; e <= elements - 1; e++)
- {
- element1 = Int(Elem(operand1, e, esize), unsigned);
- element2 = Int(Elem(operand2, e, esize), unsigned);
- test_passed = (cmp_eq ? element1 >= element2 : element1 > element2);
- Elem(result, e, esize, test_passed ? Ones(esize) : Zeros(esize));
- }
- V(d, result);
- }
- // cmhi_advsimd.html#CMHI_asisdsame_only
- public static void Cmhi_S(Bits size, Bits Rm, Bits Rn, Bits Rd)
- {
- const bool U = true;
- const bool eq = false;
- /* Decode Scalar */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- /* if size != '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = esize;
- int elements = 1;
- bool unsigned = (U == true);
- bool cmp_eq = (eq == true);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand1 = V(datasize, n);
- Bits operand2 = V(datasize, m);
- BigInteger element1;
- BigInteger element2;
- bool test_passed;
- for (int e = 0; e <= elements - 1; e++)
- {
- element1 = Int(Elem(operand1, e, esize), unsigned);
- element2 = Int(Elem(operand2, e, esize), unsigned);
- test_passed = (cmp_eq ? element1 >= element2 : element1 > element2);
- Elem(result, e, esize, test_passed ? Ones(esize) : Zeros(esize));
- }
- V(d, result);
- }
- // cmhi_advsimd.html#CMHI_asimdsame_only
- public static void Cmhi_V(bool Q, Bits size, Bits Rm, Bits Rn, Bits Rd)
- {
- const bool U = true;
- const bool eq = false;
- /* Decode Vector */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- /* if size:Q == '110' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = (Q ? 128 : 64);
- int elements = datasize / esize;
- bool unsigned = (U == true);
- bool cmp_eq = (eq == true);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand1 = V(datasize, n);
- Bits operand2 = V(datasize, m);
- BigInteger element1;
- BigInteger element2;
- bool test_passed;
- for (int e = 0; e <= elements - 1; e++)
- {
- element1 = Int(Elem(operand1, e, esize), unsigned);
- element2 = Int(Elem(operand2, e, esize), unsigned);
- test_passed = (cmp_eq ? element1 >= element2 : element1 > element2);
- Elem(result, e, esize, test_passed ? Ones(esize) : Zeros(esize));
- }
- V(d, result);
- }
- // cmhs_advsimd.html#CMHS_asisdsame_only
- public static void Cmhs_S(Bits size, Bits Rm, Bits Rn, Bits Rd)
- {
- const bool U = true;
- const bool eq = true;
- /* Decode Scalar */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- /* if size != '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = esize;
- int elements = 1;
- bool unsigned = (U == true);
- bool cmp_eq = (eq == true);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand1 = V(datasize, n);
- Bits operand2 = V(datasize, m);
- BigInteger element1;
- BigInteger element2;
- bool test_passed;
- for (int e = 0; e <= elements - 1; e++)
- {
- element1 = Int(Elem(operand1, e, esize), unsigned);
- element2 = Int(Elem(operand2, e, esize), unsigned);
- test_passed = (cmp_eq ? element1 >= element2 : element1 > element2);
- Elem(result, e, esize, test_passed ? Ones(esize) : Zeros(esize));
- }
- V(d, result);
- }
- // cmhs_advsimd.html#CMHS_asimdsame_only
- public static void Cmhs_V(bool Q, Bits size, Bits Rm, Bits Rn, Bits Rd)
- {
- const bool U = true;
- const bool eq = true;
- /* Decode Vector */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- /* if size:Q == '110' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = (Q ? 128 : 64);
- int elements = datasize / esize;
- bool unsigned = (U == true);
- bool cmp_eq = (eq == true);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand1 = V(datasize, n);
- Bits operand2 = V(datasize, m);
- BigInteger element1;
- BigInteger element2;
- bool test_passed;
- for (int e = 0; e <= elements - 1; e++)
- {
- element1 = Int(Elem(operand1, e, esize), unsigned);
- element2 = Int(Elem(operand2, e, esize), unsigned);
- test_passed = (cmp_eq ? element1 >= element2 : element1 > element2);
- Elem(result, e, esize, test_passed ? Ones(esize) : Zeros(esize));
- }
- V(d, result);
- }
- // cmtst_advsimd.html#CMTST_asisdsame_only
- public static void Cmtst_S(Bits size, Bits Rm, Bits Rn, Bits Rd)
- {
- const bool U = false;
- /* Decode Scalar */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- /* if size != '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = esize;
- int elements = 1;
- bool and_test = (U == false);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand1 = V(datasize, n);
- Bits operand2 = V(datasize, m);
- Bits element1;
- Bits element2;
- bool test_passed;
- for (int e = 0; e <= elements - 1; e++)
- {
- element1 = Elem(operand1, e, esize);
- element2 = Elem(operand2, e, esize);
- if (and_test)
- {
- test_passed = !IsZero(AND(element1, element2));
- }
- else
- {
- test_passed = (element1 == element2);
- }
- Elem(result, e, esize, test_passed ? Ones(esize) : Zeros(esize));
- }
- V(d, result);
- }
- // cmtst_advsimd.html#CMTST_asimdsame_only
- public static void Cmtst_V(bool Q, Bits size, Bits Rm, Bits Rn, Bits Rd)
- {
- const bool U = false;
- /* Decode Vector */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- /* if size:Q == '110' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = (Q ? 128 : 64);
- int elements = datasize / esize;
- bool and_test = (U == false);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand1 = V(datasize, n);
- Bits operand2 = V(datasize, m);
- Bits element1;
- Bits element2;
- bool test_passed;
- for (int e = 0; e <= elements - 1; e++)
- {
- element1 = Elem(operand1, e, esize);
- element2 = Elem(operand2, e, esize);
- if (and_test)
- {
- test_passed = !IsZero(AND(element1, element2));
- }
- else
- {
- test_passed = (element1 == element2);
- }
- Elem(result, e, esize, test_passed ? Ones(esize) : Zeros(esize));
- }
- V(d, result);
- }
- // eor_advsimd.html
- public static void Eor_V(bool Q, Bits Rm, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (Q ? 128 : 64);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits operand1 = V(datasize, m);
- Bits operand2 = Zeros(datasize);
- Bits operand3 = Ones(datasize);
- Bits operand4 = V(datasize, n);
- Bits result = EOR(operand1, AND(EOR(operand2, operand4), operand3));
- V(d, result);
- }
- // orn_advsimd.html
- public static void Orn_V(bool Q, Bits Rm, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (Q ? 128 : 64);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits operand1 = V(datasize, n);
- Bits operand2 = V(datasize, m);
- operand2 = NOT(operand2);
- Bits result = OR(operand1, operand2);
- V(d, result);
- }
- // orr_advsimd_reg.html
- public static void Orr_V(bool Q, Bits Rm, Bits Rn, Bits Rd)
- {
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- int datasize = (Q ? 128 : 64);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits operand1 = V(datasize, n);
- Bits operand2 = V(datasize, m);
- Bits result = OR(operand1, operand2);
- V(d, result);
- }
- // raddhn_advsimd.html
- public static void Raddhn_V(bool Q, Bits size, Bits Rm, Bits Rn, Bits Rd)
- {
- const bool U = true;
- const bool o1 = false;
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- /* if size == '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = 64;
- int part = (int)UInt(Q);
- int elements = datasize / esize;
- bool sub_op = (o1 == true);
- bool round = (U == true);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand1 = V(2 * datasize, n);
- Bits operand2 = V(2 * datasize, m);
- BigInteger round_const = (round ? (BigInteger)1 << (esize - 1) : 0);
- Bits sum;
- Bits element1;
- Bits element2;
- for (int e = 0; e <= elements - 1; e++)
- {
- element1 = Elem(operand1, e, 2 * esize);
- element2 = Elem(operand2, e, 2 * esize);
- if (sub_op)
- {
- sum = element1 - element2;
- }
- else
- {
- sum = element1 + element2;
- }
- sum = sum + round_const;
- Elem(result, e, esize, sum[2 * esize - 1, esize]);
- }
- Vpart(d, part, result);
- }
- // rsubhn_advsimd.html
- public static void Rsubhn_V(bool Q, Bits size, Bits Rm, Bits Rn, Bits Rd)
- {
- const bool U = true;
- const bool o1 = true;
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- /* if size == '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = 64;
- int part = (int)UInt(Q);
- int elements = datasize / esize;
- bool sub_op = (o1 == true);
- bool round = (U == true);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand1 = V(2 * datasize, n);
- Bits operand2 = V(2 * datasize, m);
- BigInteger round_const = (round ? (BigInteger)1 << (esize - 1) : 0);
- Bits sum;
- Bits element1;
- Bits element2;
- for (int e = 0; e <= elements - 1; e++)
- {
- element1 = Elem(operand1, e, 2 * esize);
- element2 = Elem(operand2, e, 2 * esize);
- if (sub_op)
- {
- sum = element1 - element2;
- }
- else
- {
- sum = element1 + element2;
- }
- sum = sum + round_const;
- Elem(result, e, esize, sum[2 * esize - 1, esize]);
- }
- Vpart(d, part, result);
- }
- // saba_advsimd.html
- public static void Saba_V(bool Q, Bits size, Bits Rm, Bits Rn, Bits Rd)
- {
- const bool U = false;
- const bool ac = true;
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- /* if size == '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = (Q ? 128 : 64);
- int elements = datasize / esize;
- bool unsigned = (U == true);
- bool accumulate = (ac == true);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits operand1 = V(datasize, n);
- Bits operand2 = V(datasize, m);
- BigInteger element1;
- BigInteger element2;
- Bits absdiff;
- Bits result = (accumulate ? V(datasize, d) : Zeros(datasize));
- for (int e = 0; e <= elements - 1; e++)
- {
- element1 = Int(Elem(operand1, e, esize), unsigned);
- element2 = Int(Elem(operand2, e, esize), unsigned);
- absdiff = Abs(element1 - element2).SubBigInteger(esize - 1, 0);
- Elem(result, e, esize, Elem(result, e, esize) + absdiff);
- }
- V(d, result);
- }
- // sabal_advsimd.html
- public static void Sabal_V(bool Q, Bits size, Bits Rm, Bits Rn, Bits Rd)
- {
- const bool U = false;
- const bool op = false;
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- /* if size == '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = 64;
- int part = (int)UInt(Q);
- int elements = datasize / esize;
- bool unsigned = (U == true);
- bool accumulate = (op == false);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits operand1 = Vpart(datasize, n, part);
- Bits operand2 = Vpart(datasize, m, part);
- BigInteger element1;
- BigInteger element2;
- Bits absdiff;
- Bits result = (accumulate ? V(2 * datasize, d) : Zeros(2 * datasize));
- for (int e = 0; e <= elements - 1; e++)
- {
- element1 = Int(Elem(operand1, e, esize), unsigned);
- element2 = Int(Elem(operand2, e, esize), unsigned);
- absdiff = Abs(element1 - element2).SubBigInteger(2 * esize - 1, 0);
- Elem(result, e, 2 * esize, Elem(result, e, 2 * esize) + absdiff);
- }
- V(d, result);
- }
- // sabd_advsimd.html
- public static void Sabd_V(bool Q, Bits size, Bits Rm, Bits Rn, Bits Rd)
- {
- const bool U = false;
- const bool ac = false;
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- /* if size == '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = (Q ? 128 : 64);
- int elements = datasize / esize;
- bool unsigned = (U == true);
- bool accumulate = (ac == true);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits operand1 = V(datasize, n);
- Bits operand2 = V(datasize, m);
- BigInteger element1;
- BigInteger element2;
- Bits absdiff;
- Bits result = (accumulate ? V(datasize, d) : Zeros(datasize));
- for (int e = 0; e <= elements - 1; e++)
- {
- element1 = Int(Elem(operand1, e, esize), unsigned);
- element2 = Int(Elem(operand2, e, esize), unsigned);
- absdiff = Abs(element1 - element2).SubBigInteger(esize - 1, 0);
- Elem(result, e, esize, Elem(result, e, esize) + absdiff);
- }
- V(d, result);
- }
- // sabdl_advsimd.html
- public static void Sabdl_V(bool Q, Bits size, Bits Rm, Bits Rn, Bits Rd)
- {
- const bool U = false;
- const bool op = true;
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- /* if size == '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = 64;
- int part = (int)UInt(Q);
- int elements = datasize / esize;
- bool unsigned = (U == true);
- bool accumulate = (op == false);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits operand1 = Vpart(datasize, n, part);
- Bits operand2 = Vpart(datasize, m, part);
- BigInteger element1;
- BigInteger element2;
- Bits absdiff;
- Bits result = (accumulate ? V(2 * datasize, d) : Zeros(2 * datasize));
- for (int e = 0; e <= elements - 1; e++)
- {
- element1 = Int(Elem(operand1, e, esize), unsigned);
- element2 = Int(Elem(operand2, e, esize), unsigned);
- absdiff = Abs(element1 - element2).SubBigInteger(2 * esize - 1, 0);
- Elem(result, e, 2 * esize, Elem(result, e, 2 * esize) + absdiff);
- }
- V(d, result);
- }
- // sub_advsimd.html#SUB_asisdsame_only
- public static void Sub_S(Bits size, Bits Rm, Bits Rn, Bits Rd)
- {
- const bool U = true;
- /* Decode Scalar */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- /* if size != '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = esize;
- int elements = 1;
- bool sub_op = (U == true);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand1 = V(datasize, n);
- Bits operand2 = V(datasize, m);
- Bits element1;
- Bits element2;
- for (int e = 0; e <= elements - 1; e++)
- {
- element1 = Elem(operand1, e, esize);
- element2 = Elem(operand2, e, esize);
- if (sub_op)
- {
- Elem(result, e, esize, element1 - element2);
- }
- else
- {
- Elem(result, e, esize, element1 + element2);
- }
- }
- V(d, result);
- }
- // sub_advsimd.html#SUB_asimdsame_only
- public static void Sub_V(bool Q, Bits size, Bits Rm, Bits Rn, Bits Rd)
- {
- const bool U = true;
- /* Decode Vector */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- /* if size:Q == '110' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = (Q ? 128 : 64);
- int elements = datasize / esize;
- bool sub_op = (U == true);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand1 = V(datasize, n);
- Bits operand2 = V(datasize, m);
- Bits element1;
- Bits element2;
- for (int e = 0; e <= elements - 1; e++)
- {
- element1 = Elem(operand1, e, esize);
- element2 = Elem(operand2, e, esize);
- if (sub_op)
- {
- Elem(result, e, esize, element1 - element2);
- }
- else
- {
- Elem(result, e, esize, element1 + element2);
- }
- }
- V(d, result);
- }
- // subhn_advsimd.html
- public static void Subhn_V(bool Q, Bits size, Bits Rm, Bits Rn, Bits Rd)
- {
- const bool U = false;
- const bool o1 = true;
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- /* if size == '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = 64;
- int part = (int)UInt(Q);
- int elements = datasize / esize;
- bool sub_op = (o1 == true);
- bool round = (U == true);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits result = new Bits(datasize);
- Bits operand1 = V(2 * datasize, n);
- Bits operand2 = V(2 * datasize, m);
- BigInteger round_const = (round ? (BigInteger)1 << (esize - 1) : 0);
- Bits sum;
- Bits element1;
- Bits element2;
- for (int e = 0; e <= elements - 1; e++)
- {
- element1 = Elem(operand1, e, 2 * esize);
- element2 = Elem(operand2, e, 2 * esize);
- if (sub_op)
- {
- sum = element1 - element2;
- }
- else
- {
- sum = element1 + element2;
- }
- sum = sum + round_const;
- Elem(result, e, esize, sum[2 * esize - 1, esize]);
- }
- Vpart(d, part, result);
- }
- // uaba_advsimd.html
- public static void Uaba_V(bool Q, Bits size, Bits Rm, Bits Rn, Bits Rd)
- {
- const bool U = true;
- const bool ac = true;
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- /* if size == '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = (Q ? 128 : 64);
- int elements = datasize / esize;
- bool unsigned = (U == true);
- bool accumulate = (ac == true);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits operand1 = V(datasize, n);
- Bits operand2 = V(datasize, m);
- BigInteger element1;
- BigInteger element2;
- Bits absdiff;
- Bits result = (accumulate ? V(datasize, d) : Zeros(datasize));
- for (int e = 0; e <= elements - 1; e++)
- {
- element1 = Int(Elem(operand1, e, esize), unsigned);
- element2 = Int(Elem(operand2, e, esize), unsigned);
- absdiff = Abs(element1 - element2).SubBigInteger(esize - 1, 0);
- Elem(result, e, esize, Elem(result, e, esize) + absdiff);
- }
- V(d, result);
- }
- // uabal_advsimd.html
- public static void Uabal_V(bool Q, Bits size, Bits Rm, Bits Rn, Bits Rd)
- {
- const bool U = true;
- const bool op = false;
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- /* if size == '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = 64;
- int part = (int)UInt(Q);
- int elements = datasize / esize;
- bool unsigned = (U == true);
- bool accumulate = (op == false);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits operand1 = Vpart(datasize, n, part);
- Bits operand2 = Vpart(datasize, m, part);
- BigInteger element1;
- BigInteger element2;
- Bits absdiff;
- Bits result = (accumulate ? V(2 * datasize, d) : Zeros(2 * datasize));
- for (int e = 0; e <= elements - 1; e++)
- {
- element1 = Int(Elem(operand1, e, esize), unsigned);
- element2 = Int(Elem(operand2, e, esize), unsigned);
- absdiff = Abs(element1 - element2).SubBigInteger(2 * esize - 1, 0);
- Elem(result, e, 2 * esize, Elem(result, e, 2 * esize) + absdiff);
- }
- V(d, result);
- }
- // uabd_advsimd.html
- public static void Uabd_V(bool Q, Bits size, Bits Rm, Bits Rn, Bits Rd)
- {
- const bool U = true;
- const bool ac = false;
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- /* if size == '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = (Q ? 128 : 64);
- int elements = datasize / esize;
- bool unsigned = (U == true);
- bool accumulate = (ac == true);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits operand1 = V(datasize, n);
- Bits operand2 = V(datasize, m);
- BigInteger element1;
- BigInteger element2;
- Bits absdiff;
- Bits result = (accumulate ? V(datasize, d) : Zeros(datasize));
- for (int e = 0; e <= elements - 1; e++)
- {
- element1 = Int(Elem(operand1, e, esize), unsigned);
- element2 = Int(Elem(operand2, e, esize), unsigned);
- absdiff = Abs(element1 - element2).SubBigInteger(esize - 1, 0);
- Elem(result, e, esize, Elem(result, e, esize) + absdiff);
- }
- V(d, result);
- }
- // uabdl_advsimd.html
- public static void Uabdl_V(bool Q, Bits size, Bits Rm, Bits Rn, Bits Rd)
- {
- const bool U = true;
- const bool op = true;
- /* Decode */
- int d = (int)UInt(Rd);
- int n = (int)UInt(Rn);
- int m = (int)UInt(Rm);
- /* if size == '11' then ReservedValue(); */
- int esize = 8 << (int)UInt(size);
- int datasize = 64;
- int part = (int)UInt(Q);
- int elements = datasize / esize;
- bool unsigned = (U == true);
- bool accumulate = (op == false);
- /* Operation */
- /* CheckFPAdvSIMDEnabled64(); */
- Bits operand1 = Vpart(datasize, n, part);
- Bits operand2 = Vpart(datasize, m, part);
- BigInteger element1;
- BigInteger element2;
- Bits absdiff;
- Bits result = (accumulate ? V(2 * datasize, d) : Zeros(2 * datasize));
- for (int e = 0; e <= elements - 1; e++)
- {
- element1 = Int(Elem(operand1, e, esize), unsigned);
- element2 = Int(Elem(operand2, e, esize), unsigned);
- absdiff = Abs(element1 - element2).SubBigInteger(2 * esize - 1, 0);
- Elem(result, e, 2 * esize, Elem(result, e, 2 * esize) + absdiff);
- }
- V(d, result);
- }
- #endregion
- }
- }
|