LLVM essentials become familiar with the LLVM infrastructure and start using LLVM libraries to design a compiler (Suyog Sarda, Mayur Pandey) (z-library.sk, 1lib.sk, z-lib.sk)

Author: Suyog Sarda, Mayur Pandey

后端

Annotation Become familiar with the LLVM infrastructure and start using LLVM libraries to design a compiler About This Book Learn to use the LLVM libraries to emit intermediate representation (IR) from high-level language Build your own optimization pass for better code generation Understand AST generation and use it in a meaningful wayWho This Book Is ForThis book is intended for those who already know some of the concepts of compilers and want to quickly get familiar with the LLVM infrastructure and the rich set of libraries that it provides.What You Will Learn Get an introduction to LLVM modular design and LLVM tools Convert frontend code to LLVM IR Implement advanced LLVM IR paradigms Understand the LLVM IR Optimization Pass Manager infrastructure and write an optimization pass Absorb LLVM IR transformations Understand the steps involved in converting LLVM IR to Selection DAG Implement a custom target using the LLVM infrastructure Get a grasp of C's frontend clang, an AST dump, and static analysisIn DetailLLVM is currently the point of interest for many firms, and has a very active open source community. It provides us with a compiler infrastructure that can be used to write a compiler for a language. It provides us with a set of reusable libraries that can be used to optimize code, and a target-independent code generator to generate code for different backends. It also provides us with a lot of other utility tools that can be easily integrated into compiler projects.This book details how you can use the LLVM compiler infrastructure libraries effectively, and will enable you to design your own custom compiler with LLVM in a snap.We start with the basics, where you'll get to know all about LLVM. We then cover how you can use LLVM library calls to emit intermediate representation (IR) of simple and complex high-level language paradigms. Moving on, we show you how to implement optimizations at different levels, write an optimization pass, generate code that is inde

📄 File Format: PDF
💾 File Size: 1.4 MB
3
Views
0
Downloads
0.00
Total Donations

📄 Text Preview (First 20 pages)

ℹ️

Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

📄 Page 1
(This page has no text content)
📄 Page 2
(This page has no text content)
📄 Page 3
LLVM Essentials
📄 Page 4
Table of Contents LLVM Essentials Credits About the Authors About the Reviewer www.PacktPub.com Support files, eBooks, discount offers, and more Why subscribe? Free access for Packt account holders Preface What this book covers What you need for this book Who this book is for Conventions Reader feedback Customer support Downloading the example code Errata Piracy Questions 1. Playing with LLVM Modular design and collection of libraries Getting familiar with LLVM IR LLVM tools and using them in the command line Summary 2. Building LLVM IR Creating an LLVM module Emitting a function in a module Adding a block to a function Emitting a global variable
📄 Page 5
Emitting a return statement Emitting function arguments Emitting a simple arithmetic statement in a basic block Emitting if-else condition IR Emitting LLVM IR for loop Summary 3. Advanced LLVM IR Memory access operations Getting the address of an element Reading from the memory Writing into a memory location Inserting a scalar into a vector Extracting a scalar from a vector Summary 4. Basic IR Transformations Opt Tool Pass and Pass Manager Using other Pass info in current Pass AnalysisUsage::addRequired<> method AnalysisUsage:addRequiredTransitive<> method AnalysisUsage::addPreserved<> method Instruction simplification example Instruction Combining Summary 5. Advanced IR Block Transformations Loop processing Scalar evolution LLVM intrinsics Vectorization Summary 6. IR to Selection DAG phase
📄 Page 6
Converting IR to selectionDAG Legalizing SelectionDAG Optimizing SelectionDAG Instruction Selection Scheduling and emitting machine instructions Register allocation Code Emission Summary 7. Generating Code for Target Architecture Sample backend Defining registers and register sets Defining the calling convention Defining the instruction set Implementing frame lowering Lowering instructions Printing an instruction Summary Index
📄 Page 7
(This page has no text content)
📄 Page 8
LLVM Essentials
📄 Page 9
(This page has no text content)
📄 Page 10
LLVM Essentials Copyright © 2015 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except 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 the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: December 2015 Production reference: 1021215 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78528-080-1 www.packtpub.com
📄 Page 11
(This page has no text content)
📄 Page 12
Credits Authors Suyog Sarda Mayur Pandey Reviewer Renato Golin Commissioning Editor Nadeem Bagban Acquisition Editor Harsha Bharwani Content Development Editor Priyanka Mehta Technical Editor Ryan Kochery Copy Editor Imon Biswas Project Coordinator Izzat Contractor Proofreader Safis Editing Indexer Tejal Daruwale Soni Production Coordinator Aparna Bhagat Cover Work Aparna Bhagat
📄 Page 13
(This page has no text content)
📄 Page 14
About the Authors Suyog Sarda is a professional software engineer and an open source enthusiast. He focuses on compiler development and compiler tools. He is an active contributor to the LLVM open source community. Suyog was also involved in code performance improvements for the ARM and X86 architectures. He has been a part of the compiler team for the Tizen project. His interest in compiler development lies more in code optimization and vectorization. Previously, he has authored a book on LLVM, titled LLVM Cookbook by Packt Publishing. Apart from compilers, Suyog is also interested in Linux Kernel Development. He has published a technical paper titled Secure Co-resident Virtualization in Multicore Systems by VM Pinning and Page Coloring at the IEEE Proceedings of the 2012 International Conference on Cloud Computing, Technologies, Applications, and Management at the Birla Institute of Technology, Dubai. He has earned a bachelor’s degree in computer technology from the College of Engineering, Pune, India. I would like to thank my family and friends for encouraging me to write this book. I am thankful to my co-author and reviewers who did a tremendous job of refining the contents. I would also like to thank the LLVM open source community for always being helpful. It has been a great experience to interact with the community. It is amazing to see how fast LLVM has evolved. Mayur Pandey is a professional software engineer and open source enthusiast focused on compiler development and tools. He is an active contributor to the LLVM open source community. He has been a part of the compiler team for the Tizen project and has hands- on experience of other proprietary compilers. He has earned a bachelor’s degree in Information Technology from Motilal Nehru National Institute of Technology, Allahabad, India. Currently, he lives in Bengaluru, India. I would like to thank my family and friends who made it possible for me to complete the book by taking care of my other commitments, and who have always being encouraging.
📄 Page 15
(This page has no text content)
📄 Page 16
About the Reviewer Renato Golin has worked with toolchains since 2008, developing debuggers and compilers for multiple languages and platforms, and has also been LLVM Tech Lead at ARM and Linaro, focusing on code generation, correctness, performance, and providing a complete toolchain solution based on LLVM for the diverse ARM platforms. Before that, he spent a decade moving between web back-ends, databases, distributed systems, big data and bioinformatics, always working on and with open source projects.
📄 Page 17
(This page has no text content)
📄 Page 18
www.PacktPub.com
📄 Page 19
Support files, eBooks, discount offers, and more For support files and downloads related to your book, please visit www.PacktPub.com. Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <service@packtpub.com> for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks. https://www2.packtpub.com/books/subscription/packtlib Do you need instant solutions to your IT questions? PacktLib is Packt’s online digital book library. Here, you can search, access, and read Packt’s entire library of books.
📄 Page 20
Why subscribe? Fully searchable across every book published by Packt Copy and paste, print, and bookmark content On demand and accessible via a web browser
The above is a preview of the first 20 pages. Register to read the complete e-book.

💝 Support Author

0.00
Total Amount (¥)
0
Donation Count

Login to support the author

Login Now

Recommended for You

Loading recommended books...
Failed to load, please try again later
Back to List