LLVMcookbook
LLVM Cookbook pdfLLVM CookbookCopyright c 2015 Packt PublishingAll rights reserved No part of this book may be reproduced, stored in a retrieval system, ortransmitted in any form or by any means, without the prior written permission of the publisherexcept in the case of brief quotations embedded in critical articles or reviews.Every effort has been made in the preparation of this book to ensure the accuracy of theinformation presented, However, the information contained in this book is sold withoutwarranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealersand distributors will be held liable for any damages caused or alleged to be caused directly orindirectly by this book.Packt Publishing has endeavored to provide trademark information about all of the companiesand products mentioned in this book by the appropriate use of capitals. However, PacktPublishing cannot guarantee the accuracy of this informationFirst published: May 2015Production reference: 1270515Published by Packt Publishing LtdLivery Place35 Livery StreetBirmingham B3 2PB, UKSBN978-1-78528-598-1www.packtpub.comCreditsAuthorsProject CoordinateMayur PandeyShipra chashanSuyog SardaProofreaderReviewersStephen Copestakegan chicEditingMichael haidDave(Jing) TianIndexercommissioning editNadeem N. BarbanGraphicsDisha hariaAcquisition EdiVivek AnantharamanProduction coordinatorMelwyn D'saContent Development Editorleta pantCover workD'sTechnical editorsPrajakta MhatreRohith RajanRupali shravanCopy EditorsVikrant phadkeSameen SiddiquiAbout the uthorsMayur Pandey is a professional software engineer and an open source enthusiast. Hefocuses on compiler development and compiler tools. He is an active contributor to the Llvmopen source community. He has been part of the compiler team for the Tizen project, and hashands-on experience with other proprietary compilersMayur earned a bachelor's degree in information technology from Motilal Nehru NationalInstitute of Technology Allahabad, India. Currently, he lives in Bengaluru, IndiaI would like to thank my family and friends. they made it possible for meto complete the book by taking care of my other commitments and alwaysencouraging meSuyog sarda is a professional software engineer and an open source enthusiast. Hefocuses on compiler development and compiler tools. He is an active contributor to the LlvMopen source community. He has been part of the compiler team for the Tizen project. Suyogwas also involved in code performance improvements for the arm and the x86 architectureHe has hands-on experience in other proprietary compilers. His interest in compilerdevelopment lies more in code optimization and vectorizationApart trom compilers, Suyog is also interested in Linux kernel development. He has publisheda technical paper titled Secure Co-resident virtualization in Multicore Systems by vM Pinningand Page coloring at the IeEE Proceedings of the 2012 International Conference on cloudComputing, Technologies, Applications, and Management at birla Institute of Technology,Dubai. He earned a bachelor's degree in computer technology from college of Engineering,Pune, India. currently, he lives in bengaluru IndiaI would like to thank my family and friends. I would also like to thank theLLVM open-source community for always being helpfulAbout the reviewersLogan Chien received his master's degree in computer science from National TaiwanUniversity. His research interests include compiler design, compiler optimization, and virtualmachines. He is a full-time software engineer. In his free time he works on several opensource projects, such as LLVM and android. Logan has participated in the LlvM projectsince 2012Michael Haidl is a high performance computing engineer with focus on many corearchitectures that consist of Graphics Processing Units (GPUs)and Intel Xeon Phi acceleratorsHe has been a C++ developer for more than 14 years, and has gained many skills in parallelprogramming, exploiting various programming models(CUDA) over the years. He has adiploma in computer science and physics. Currently, Michael is employed as a researchassociate at the University of munster, Germany, and is writing his Phd thesis with focuscompilationiques for GPUs utilizing the llvM infrastructureI would like to thank my wife for supportingvery day with her smilesand love,i would also like to thank the entire llvmity for all thehard work they have put into LlvM Clang and other LlvM projects It isamazing to see how fast LLVM evolvesDave ing tian is a graduate research fellow and phd student in the department ofComputer& Information Science Engineering(CISE)at the University of Florida. He is afounding member of the sEnsel center. His research direction involves system security,embedded system security, trusted computing, static code analysis for security, andvirtualization. He is interested in Linux kernel hacking and compiler hackingDave spent a year on al and machine learning, and taught Python and operating systemsat the University of oregon Before that, he worked as a software developer in the LCP(Linux control platform) group in research and development at Alcatel-Lucent(formerlyLucent Technologies), for approximately 4 years. He holds a bachelor's degree in scienceand a master's degree in electronics engineering in China. You can reach him at root@davejingtian.organdvisithiswebsitehttp://davejingtian.orgI would like to thank the author of this book, who has done a good job.Thanks to the editors of the book at packt Publishing, who made this bookperfect and offered me the opportunity to review such a nice bookwww.packtpub.comSupport files, eBooks, discount offers, and moreForsupportfilesanddownloadsrelatedtoyourbookpleasevisitwww.Packtpub.comDid you know that Packt offers eBook versions of every book published, with PDF and ePubfilesavailableYoucanupgradetotheebooKversionatwww.Packtpub.comandasaprintbook customer, you are entitled to a discount on the e Book copy. Get in touch with us atservice@packtpub com for more detailsAtwww.packtpub.comyoucanalsoreadacollectionoffreetechnicalarticlessignupfor a range of free newsletters and receive exclusive discounts and offers on Packt booksand e booksPACKTLiBhttps://www2.packtpub.com/books/subscription/packtlibDo you need instant solutions to your It questions? PacktLib is Packt's online digital booklibrary. Here, you can search, access, and read Packt's entire library of books.Why Subscribe?Fully searchable across every book published by packtCopy and paste, print, and bookmark contentOn demand and accessible via a web browserFree Access for packt account holdersIfyouhaveanaccountwithPacktatwww.Packtpub.comyoucanusethistoaccessPacktLib today and view 9 entirely free books simply use your login credentials formmediate accessTable of contentsPrefaceChapter 1: LLVM Design and UseIntroduction1Understanding modular design2Cross-complling clangyLLVM5Converting a c source code to LLVM assemblyConverting ir to LLVM bitcode9Converting lLvM bitcode to target machine assembly11Converting LLVM bitcode back to LLVM assembly13Transforming LLVM IR14Linking LLVM bitcodeExecuting LLVM bitcode18Using the C frontend clang19Using the GO frontend23Using Dragon Egg24Chapter 2: Steps in Writing a Frontend27Introduction2Defining a TOY language28Implementing a lexer29Defining Abstract Syntax Tree32Implementing a parser35Parsing simple expressions36Parsing binary expressions38Invoking a driver for parsing41Running lexer and parser on our TOY language42DefInIng IR code generation methods for each AST class43Generating IR code for expressions45
下载地址
用户评论
比较清楚,可以看