Instruction selection

In computer science, instruction selection is the stage of a compiler backend that transforms its middle-level intermediate representation (IR) into a low-level IR. In a typical compiler, instruction selection precedes both instruction scheduling and register allocation; hence its output IR has an infinite set of pseudo-registers (often known as temporaries) and may still be – and typically is – subject to peephole optimization. Otherwise, it closely resembles the target machine code, bytecode, or assembly language.

For example, for the following sequence of middle-level IR code

t1 = a
t2 = b
t3 = t1 + t2
a = t3
b = t1

a good instruction sequence for the x86 architecture is

MOV EAX, a
XCHG EAX, b
ADD a, EAX

For a comprehensive survey on instruction selection, see. [1] [2]

Macro expansion

The simplest approach to instruction selection is known as macro expansion[3] or interpretative code generation.[4][5][6] A macro-expanding instruction selector operates by matching templates over the middle-level IR. Upon a match the corresponding macro is executed, using the matched portion of the IR as input, which emits the appropriate target instructions. Macro expansion can be done either directly on the textual representation of the middle-level IR,[7][8] or the IR can first be transformed into a graphical representation which is then traversed depth-first.[9] In the latter, a template matches one or more adjacent nodes in the graph.

Unless the target machine is very simple, macro expansion in isolation typically generates inefficient code. To mitigate this limitation, compilers that apply this approach typically combine it with peephole optimization to replace combinations of simple instructions with more complex equivalents that increase performance and reduce code size. This is known as the Davidson-Fraser approach and is currently applied in GCC.[10]

Graph covering

Another approach is to first transform the middle-level IR into a graph and then cover the graph using patterns. A pattern is a template that matches a portion of the graph and can be implemented with a single instruction provided by the target machine. The goal is to cover the graph such that the total cost of the selected patterns is minimized, where the cost typically represents the number of cycles it takes to execute the instruction. For tree-shaped graphs, the least-cost cover can be found in linear time using dynamic programming,[11] but for DAGs and full-fledged graphs the problem becomes NP-complete and thus is most often solved using either greedy algorithms or methods from combinatorial optimization.[12] [13] [14]

References

  1. ^ Blindell, Gabriel S. Hjort (2013). Survey on Instruction Selection: An Extensive and Modern Literature Review (Report). arXiv:1306.4898. ISBN 978-91-7501-898-0.
  2. ^ Blindell, Gabriel S. Hjort (2016). Instruction Selection: Principles, Methods, & Applications. Springer. doi:10.1007/978-3-319-34019-7. ISBN 978-3-319-34017-3. S2CID 13390131.
  3. ^ Brown, P. (1969). "A Survey of Macro Processors". Annual Review in Automatic Programming. 6 (2): 37–88. doi:10.1016/0066-4138(69)90001-9. ISSN 0066-4138.
  4. ^ Cattell, R. G. G. (1979). "A Survey and Critique of Some Models of Code Generation" (PDF). School of Computer Science, Carnegie Mellon University (Technical report). Archived (PDF) from the original on May 23, 2019.
  5. ^ Ganapathi, M.; Fischer, C. N.; Hennessy, J. L. (1982). "Retargetable Compiler Code Generation". Computing Surveys. 14 (4): 573–592. doi:10.1145/356893.356897. ISSN 0360-0300. S2CID 2361347.
  6. ^ Lunell, H. (1983). Code Generator Writing Systems (Doctoral thesis). Linköping, Sweden: Linköping University.
  7. ^ Ammann, U.; Nori, K. V.; Jensen, K.; Nägeli, H. (1974). "The PASCAL (P) Compiler Implementation Notes". Instituts für Informatik (Technical report).
  8. ^ Orgass, R. J.; Waite, W. M. (1969). "A Base for a Mobile Programming System". Communications of the ACM. 12 (9): 507–510. doi:10.1145/363219.363226. S2CID 8164996.
  9. ^ Wilcox, T. R. (1971). Generating Machine Code for High-Level Programming Languages (Doctoral thesis). Ithaca, New York, USA: Cornell University.
  10. ^ Davidson, J. W.; Fraser, C. W. (1984). "Code Selection Through Object Code Optimization". ACM Transactions on Programming Languages and Systems. 6 (4): 505–526. CiteSeerX 10.1.1.76.3796. doi:10.1145/1780.1783. ISSN 0164-0925. S2CID 10315537.
  11. ^ Aho, A. V.; Ganapathi, M.; Tjiang, S. W. K. (1989). "Code Generation Using Tree Matching and Dynamic Programming". ACM Transactions on Programming Languages and Systems. 11 (4): 491–516. CiteSeerX 10.1.1.456.9102. doi:10.1145/69558.75700. S2CID 1165995.
  12. ^ Wilson, T.; Grewal, G.; Halley, B.; Banerji, D. (1994). "An integrated approach to retargetable code generation". Proceedings of 7th International Symposium on High-Level Synthesis. pp. 70–75. CiteSeerX 10.1.1.521.8288. doi:10.1109/ISHLS.1994.302339. ISBN 978-0-8186-5785-6. S2CID 14384424.
  13. ^ Bashford, Steven; Leupers, Rainer (1999). "Constraint driven code selection for fixed-point DSPS". Proceedings of the 36th ACM/IEEE conference on Design automation conference - DAC '99. pp. 817–822. CiteSeerX 10.1.1.331.390. doi:10.1145/309847.310076. ISBN 978-1581331097. S2CID 5513238.
  14. ^ Floch, A.; Wolinski, C.; Kuchcinski, K. (2010). "Combined Scheduling and Instruction Selection for Processors with Reconfigurable Cell Fabric". Proceedings of the 21st International Conference on Application-Specific Architectures and Processors (ASAP'10): 167–174.

Read other articles:

Handewitter Forest in Schleswig-Holstein, North Germany Białowieża Forest, Poland Křivoklátsko forest in central Bohemia, Czech Republic The history of the forest in Central Europe is characterised by thousands of years of exploitation by people. Thus a distinction needs to be made between the botanical natural history of the forest in pre- and proto-historical times—which falls mainly into the fields of natural history and Paleobotany—and the onset of the period of sedentary ...

 

جامع خالد بن الوليد جامع خالد بن الوليد. إحداثيات 34°44′12″N 36°42′56″E / 34.736780555556°N 36.715588888889°E / 34.736780555556; 36.715588888889  معلومات عامة القرية أو المدينة حمص ،  سوريا الدولة سوريا  سنة التأسيس 1908  تاريخ بدء البناء القرن السابع الهجري المواصفات عدد القباب 9 التصميم...

 

هذه المقالة يتيمة إذ تصل إليها مقالات أخرى قليلة جدًا. فضلًا، ساعد بإضافة وصلة إليها في مقالات متعلقة بها. (مايو 2021) فرانكلين خانالمناصب عضو مجلس نواب ترينيداد وتوباغو بيانات شخصيةالوفاة 17 أبريل 2021 بلد المواطنة ترينيداد وتوباغو[1] المهنة سياسي بيانات أخرىالحزب السياسي ...

Season of television series Season of television series The X-FilesSeason 5DVD coverStarring David Duchovny Gillian Anderson Country of originUnited StatesNo. of episodes20ReleaseOriginal networkFoxOriginal releaseNovember 2, 1997 (1997-11-02) –May 17, 1998 (1998-05-17)Season chronology← PreviousSeason 4Next →Season 6List of episodes The fifth season of the science fiction television series The X-Files commenced airing on the Fox network in the United States on ...

 

Церква пророка Іллі Церква пророка Іллі у Галичі, варіант реконструкції південного фасаду. 49°05′01″ пн. ш. 24°42′20″ сх. д. / 49.083715° пн. ш. 24.705523° сх. д. / 49.083715; 24.705523Координати: 49°05′01″ пн. ш. 24°42′20″ сх. д. / 49.083715° пн. ш. 24.70...

 

Jesuit history research center in Goa, India Xavier Centre of Historical ResearchAbbreviationXCHRFormation1977PurposeHistoriographyLocationAlto Porvorim, GoaDirectorDr. Anthony da Silva SJKey peopleTeotónio de Souza, Charles Borges, Delio Mendonca, Savio Abreu, Rinald D'SouzaAffiliationsGoa UniversityAward(s)Best Cultural Institution Award (2011)WebsiteXavier Centre of Historical Research Part of a series onChristianity JesusChrist Nativity Baptism Ministry Crucifixion Resurrection Ascension...

Shopping centre in Northampton, England The Grosvenor Centre, Northampton. Market Square entrance. The Grosvenor Centre is a shopping centre in the town centre of Northampton, England. Work started in 1972 and the building opened in 1976. The two-level centre is located adjacent to Market Square, and is owned by Evolve Estates, after purchasing the centre from Legal & General in 2022 for an undisclosed sum. In 2014 it underwent a £3 million refurbishment. Location The Grosvenor Centre is...

 

The following highways are numbered 288: Japan Japan National Route 288 Sweden Länsväg 288 [sv] between Uppsala, Gimo and Östhammar United States Arizona State Route 288 Georgia State Route 288 Kentucky Route 288 Maryland Route 288 Minnesota State Highway 288 (former) Montana Secondary Highway 288 New Mexico State Road 288 New York State Route 288 (former) Ohio State Route 288 Pennsylvania Route 288 South Carolina Highway 288 Tennessee State Route 288 Texas State Highway 288 T...

 

This article may overuse or misuse colour, making it hard to understand for colour-blind users. Please remove or fix instances of distracting or hard-to-read colours or remove coloured links that may impede user ability to distinguish links from regular text, or colour links for purely aesthetic reasons. See the guides to editing for accessibility at contrast and colours. (March 2018) Monarchy of MecklenburgStateGrand ducal coat of arms of Mecklenburg-SchwerinFrederick Francis IV of Mecklenbu...

Chemical compound AnitrazafenClinical dataATC codenoneIdentifiers IUPAC name 5,6-bis(4-methoxyphenyl)-3-methyl-1,2,4-triazine CAS Number63119-27-7PubChem CID44410ChemSpider40409 YUNII2Y065P7MYRKEGGD02948 YChEMBLChEMBL2105947CompTox Dashboard (EPA)DTXSID50212454 Chemical and physical dataFormulaC18H17N3O2Molar mass307.353 g·mol−13D model (JSmol)Interactive image SMILES n2c(nnc(c1ccc(OC)cc1)c2c3ccc(OC)cc3)C InChI InChI=1S/C18H17N3O2/c1-12-19-17(13-4-8-15(22-2)9-5-13)18(21-20-1...

 

2014 single by Ed SheeranSingSingle by Ed Sheeranfrom the album × B-sideFriendsReleased7 April 2014 (2014-04-07)GenreR&B[1][2]Length3:55LabelAsylum UKSongwriter(s)Ed SheeranPharrell WilliamsProducer(s)Pharrell WilliamsEd Sheeran singles chronology I See Fire (2013) Sing (2014) Don't (2014) Audio sampleSingfilehelp Sing is a song written and recorded by English singer-songwriter, Ed Sheeran. It was produced by Pharrell Williams, who also provided backing voc...

 

CBS/CW affiliate in Jackson, Mississippi Not to be confused with WTVJ. WJTV Jackson, MississippiUnited StatesChannelsDigital: 12 (VHF)Virtual: 12BrandingWJTV 12 (general)WJTV 12 News (newscasts)Mississippi's CW (on DT2)ProgrammingAffiliations12.1: CBS12.2: The CWfor others, see § SubchannelsOwnershipOwnerNexstar Media Group(Nexstar Media Inc.)HistoryFirst air dateJanuary 20, 1953 (70 years ago) (1953-01-20)Former call signsWSLI-TV (on channel 12, 1954–1955)Former channel...

ThaioilNative nameไทยออยล์TypePublicTraded asSET: TOPIndustryOil and GasFounded3 August 1961HeadquartersBangkok, ThailandArea servedThailandKey peopleWirat Uanarumit (President & CEO)Pattaralada Sa-Ngasang (CFO)Revenue 390,090 million baht (2014)[1]Net income (4,026) million baht (2014) [1]Total assets 192,802 million baht (2014) [2]ParentPTT GroupWebsiteOfficial website Thai Oil Public Company Limited or simply Thaioil (Thai: ไทยออ...

 

1955 film by Earl Bellamy Seminole UprisingTheatrical release posterDirected byEarl BellamyScreenplay byRobert E. KentBased onBugle's Wakeby Curt BrandonProduced bySam KatzmanStarringGeorge MontgomeryCinematographyHenry FreulichEdited byJerome ThomsMusic byMischa BakaleinikoffColor processTechnicolorProductioncompanySam Katzman ProductionsDistributed byColumbia PicturesRelease date May 1, 1955 (1955-05-01) Running time72 minutesCountryUnited StatesLanguageEnglish Seminole Upris...

 

2014 soundtrack album by Justin HurwitzWhiplash (Original Motion Picture Soundtrack)Soundtrack album by Justin HurwitzReleasedOctober 7, 2014Recorded2014GenreJazzclassicalLength54:59LabelVarèse SarabandeProducerJustin HurwitzTim Simonec Whiplash (Original Motion Picture Soundtrack) is the soundtrack album to the 2014 film Whiplash, directed by Damien Chazelle. The soundtrack was released on October 7, 2014, by Varèse Sarabande and features 24 tracks, which were split into three part...

Hospital in Conwy County Borough, WalesLlandudno General HospitalBetsi Cadwaladr University Health BoardLlandudno General HospitalShown in Conwy County BoroughGeographyLocationLlandudno, Conwy County Borough, WalesCoordinates53°18′40″N 3°49′41″W / 53.3112°N 3.8281°W / 53.3112; -3.8281OrganisationCare systemLocal authority and private subscription to 1948; NHS from 1948TypeGeneral hospitalHistoryOpened1939LinksWebsitewww.wales.nhs.uk/sitesplus/861/tudalen/42...

 

Lawyers Collective is a non-governmental organization in India which promotes human rights, especially on issues relating to women's rights, HIV, tobacco, LGBT and parliamentary corruption in India. On 1 June 2016, Govt of India suspended the FCRA registration of the NGO for alleged violation of FCRA norms.[1] This revoking of the license was challenged in the Bombay High Court and the case is currently pending.[2] The Central Bureau of Investigation filed a first information ...

 

Public transit hub in Los Angeles, California Harbor Gateway Transit Center Harbor Gateway Transit Center platformGeneral informationLocation731 West 182nd StreetGardena, CaliforniaCoordinates33°52′11″N 118°17′16″W / 33.86973°N 118.28790°W / 33.86973; -118.28790Operated byLos Angeles County Metropolitan Transportation AuthorityLine(s)See Services sectionPlatforms1 island platformBus stands12ConstructionStructure typeAt-gradeParking980 spaces[1]...

2014 studio album by LordiScare Force OneStudio album by LordiReleased31 October 2014 (2014-10-31)Genre Hard rock heavy metal shock rock Length48:08LabelAFM RecordsProducerMikko KarmilaLordi chronology To Beast or Not to Beast(2013) Scare Force One(2014) Monstereophonic (Theaterror vs. Demonarchy)(2016) Singles from Scare Force One Nailed by the Hammer of FrankensteinReleased: 19 September 2014 Scare Force One is the seventh studio album by Finnish rock band Lordi. It w...

 

Light, hydrocarbon-based emollient Aqueous Cream BP, also known as sorbolene, is a light, hydrocarbon-based emulsion, which is officially registered in the British Pharmacopoeia and categorised by the British National Formulary as a non-proprietary emollient preparation.[1] It is used as a topical, external medicine, emollient moisturiser, and general-purpose substitute for toiletries such as soap, shower gel, shaving cream, and lip salve. Aqueous cream B.P. Ingredients The common ing...

 

Strategi Solo vs Squad di Free Fire: Cara Menang Mudah!