ROSE Compiler Framework
Total Page:16
File Type:pdf, Size:1020Kb
ROSE Compiler Framework Wikibooks.org March 17, 2013 On the 28th of April 2012 the contents of the English as well as German Wikibooks and Wikipedia projects were licensed under Creative Commons Attribution-ShareAlike 3.0 Unported license. An URI to this license is given in the list of figures on page 213. If this document is a derived work from the contents of one of these projects and the content was still licensed by the project under this license at the time of derivation this document has to be licensed under the same, a similar or a compatible license, as stated in section 4b of the license. The list of contributors is included in chapter Contributors on page 211. The licenses GPL, LGPL and GFDL are included in chapter Licenses on page 217, since this book and/or parts of it may or may not be licensed under one or more of these licenses, and thus require inclusion of these licenses. The licenses of the figures are given in the list of figures on page 213. This PDF was generated by the LATEX typesetting software. The LATEX source code is included as an attachment (source.7z.txt) in this PDF file. To extract the source from the PDF file, we recommend the use of http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/ utility or clicking the paper clip attachment symbol on the lower left of your PDF Viewer, selecting Save Attachment. After extracting it from the PDF file you have to rename it to source.7z. To uncompress the resulting archive we recommend the use of http://www.7-zip.org/. The LATEX source itself was generated by a program written by Dirk Hünniger, which is freely available under an open source license from http://de.wikibooks.org/wiki/Benutzer:Dirk_Huenniger/wb2pdf. This distribution also contains a configured version of the pdflatex compiler with all necessary packages and fonts needed to compile the LATEX source included in this PDF file. Contents 1 About the Book 3 1.1 Goal . 3 1.2 How To Contribute . 3 1.3 Tracking Wiki Changes . 4 1.4 Wikibook Writing Tips . 5 2 ROSE's Documentations 7 3 Obtaining ROSE 9 3.1 Git Repositories . 9 3.2 Virtual Machine Image . 10 3.3 git 1.7.10 or later for github.com . 10 3.4 EDG source code . 11 3.5 EDG tarball . 12 4 Installation 15 4.1 Platform Requirement . 15 4.2 Software Requirement . 15 4.3 ./build . 17 4.4 configure . 17 4.5 make . 17 4.6 make check . 18 4.7 make install . 18 4.8 set environment variables . 18 4.9 try out a rose translator . 18 4.10 Trouble shooting . 19 5 Virtual machine image 21 5.1 How to use the virtual machine image . 21 5.2 How was the virtual machine made . 22 5.3 How to create a new virtual image . 23 6 ROSE tools 25 6.1 prerequisites . 25 6.2 identityTranslator . 25 6.3 AST dot graph generators . 26 6.4 call graph generator . 28 6.5 Control flow graph generator . 28 6.6 TODO . 28 III Contents 7 Supported Programming Languages 29 7.1 OpenMP . 29 7.2 UPC . 29 7.3 CUDA . 30 7.4 OpenCL . 30 8 Abstract Syntax Tree (Intermediate Representation) 31 8.1 Sanity Check . 31 8.2 Visualization of AST . 32 8.3 Text Output of an AST . 32 8.4 Preprocessing Information . 32 8.5 AST Construction . 33 9 Program Translation 35 9.1 Documentation . 35 9.2 Expected behavior of a ROSE Translator . 35 9.3 SageBuilder and SageInterface . 35 9.4 Steps for writing translators . 35 9.5 Order to traverse AST . 36 9.6 Example translators . 36 9.7 Trouble shooting . 37 10 Program Analysis 39 10.1 control flow graph . 39 10.2 Virtual Function Analysis . 43 10.3 Def-use analysis . 43 10.4 Pointer Analysis . 44 10.5 SSA . 45 10.6 Side Effect Analysis . 46 10.7 Generic Dataflow Framework . 46 10.8 Dependence analysis . 46 11 Generic Dataflow Framework 49 11.1 Introduction . 49 11.2 Implemented analysis . 49 11.3 Function, nodeState and FunctionState . 50 11.4 Lattices . 53 11.5 Transfer Function . 55 11.6 Control flow graph and call graph . 58 11.7 Analysis Driver . 59 11.8 Inter-procedural analysis . 69 11.9 How to use one analysis . 71 11.10 Testing . 73 11.11 How to debug . 74 11.12 TODO . 77 12 Program Optimizations 79 IV Contents 13 ROSE Projects 81 13.1 minitermite . 82 14 Developer's Guide 83 14.1 Basic skills for ROSE developers . 83 14.2 Valued Contributions . 83 14.3 Milestones for a ROSE developers . 84 14.4 Termination checklist . 85 14.5 code review . 85 14.6 Working from a Lab machine . 86 15 Workflow 87 15.1 Motivation and Goals . 87 15.2 Development Guide . 87 15.3 High Level Workflow . 88 15.4 Proposing Workflow Changes . 89 15.5 Reviewing Workflow Change Proposals . 90 16 Coding Standard 91 16.1 What to Expect and What to Avoid . 91 16.2 Git Convention . 93 16.3 Design Document . 94 16.4 Testing . 96 16.5 Programming Languages . 97 16.6 Naming Conventions . 97 16.7 Directories . 102 16.8 Files . 103 16.9 README . 105 16.10 Source Code Documentation . 106 16.11 Functions . 109 16.12 Comments . 109 16.13 Coding . 109 16.14 Classes . 109 16.15 Statements . ..