售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
Getting Started with LLVM Core Libraries
Table of Contents
Getting Started with LLVM Core Libraries
Credits
About the Authors
About the Reviewers
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. Build and Install LLVM
Understanding LLVM versions
Obtaining prebuilt packages
Obtaining the official prebuilt binaries
Using package managers
Staying updated with snapshot packages
Linux
Windows
Building from sources
System requirements
Obtaining sources
SVN
Git
Building and installing LLVM
Using the autotools-generated configure script
Building and configuring with Unix
Using CMake and Ninja
Building with Unix using CMake and Ninja
Solving build errors
Using other Unix approaches
Windows and Microsoft Visual Studio
Mac OS X and Xcode
Summary
2. External Projects
Introducing Clang extras
Building and installing Clang extra tools
Understanding Compiler-RT
Seeing Compiler-RT in action
Using the DragonEgg plugin
Building DragonEgg
Understanding the compilation pipeline with DragonEgg and LLVM tools
Understanding the LLVM test suite
Using LLDB
Exercising a debug session with LLDB
Introducing the libc++ standard library
Summary
3. Tools and Design
Introducing LLVM's basic design principles and its history
Understanding LLVM today
Interacting with the compiler driver
Using standalone tools
Delving into the LLVM internal design
Getting to know LLVM's basic libraries
Introducing LLVM's C++ practices
Seeing polymorphism in practice
Introducing C++ templates in LLVM
Enforcing C++ best practices in LLVM
Making string references lightweight in LLVM
Demonstrating the pluggable pass interface
Writing your first LLVM project
Writing the Makefile
Writing the code
Navigating the LLVM source – general advice
Understanding the code as a documentation
Asking the community for help
Coping with updates – using the SVN log as a documentation
Concluding remarks
Summary
4. The Frontend
Introducing Clang
Frontend actions
Libraries
Using libclang
Understanding Clang diagnostics
Reading diagnostics
Learning the frontend phases with Clang
Lexical analysis
Exercising lexical errors
Writing libclang code that uses the lexer
Preprocessing
Syntactic analysis
Understanding Clang AST nodes
Understanding the parser actions with a debugger
Exercising a parser error
Writing code that traverses the Clang AST
Serializing the AST with precompiled headers
Semantic analysis
Exercising a semantic error
Generating the LLVM IR code
Putting it together
Summary
5. The LLVM Intermediate Representation
Overview
Understanding the LLVM IR target dependency
Exercising basic tools to manipulate the IR formats
Introducing the LLVM IR language syntax
Introducing the LLVM IR in-memory model
Writing a custom LLVM IR generator
Building and running the IR generator
Learning how to write code to generate any IR construct with the C++ backend
Optimizing at the IR level
Compile-time and link-time optimizations
Discovering which passes matter
Understanding pass dependencies
Understanding the pass API
Writing a custom pass
Building and running your new pass with the LLVM build system
Building and running your new pass with your own Makefile
Summary
6. The Backend
Overview
Using the backend tools
Learning the backend code structure
Knowing the backend libraries
Learning how to use TableGen for LLVM backends
The language
Knowing the code generator .td files
Target properties
Registers
Instructions
Understanding the instruction selection phase
The SelectionDAG class
Lowering
DAG combine and legalization
DAG-to-DAG instruction selection
Pattern matching
Visualizing the instruction selection process
Fast instruction selection
Scheduler
Instruction itineraries
Hazard detection
Scheduling units
Machine instructions
Register allocation
Register coalescer
Virtual register rewrite
Target hooks
Prologue and epilogue
Frame indexes
Understanding the machine code framework
MC instructions
Code emission
Writing your own machine pass
Summary
7. The Just-in-Time Compiler
Getting to know the LLVM JIT engine basics
Introducing the execution engine
Memory management
Introducing the llvm::JIT framework
Writing blobs to memory
Using JITMemoryManager
Target code emitters
Target information
Learning how to use the JIT class
The generic value
Introducing the llvm::MCJIT framework
The MCJIT engine
Learning the module's states
Understanding how MCJIT compiles modules
The Object buffer, the cache, and the image
Dynamic linking
The memory manager
The MC code emission
Object finalization
Using the MCJIT engine
Using LLVM JIT compilation tools
Using the lli tool
Using the llvm-rtdyld tool
Other resources
Summary
8. Cross-platform Compilation
Comparing GCC and LLVM
Understanding target triples
Preparing your toolchain
Standard C and C++ libraries
Runtime libraries
The assembler and the linker
The Clang frontend
Multilib
Cross-compiling with Clang command-line arguments
Driver options for the target
Dependencies
Cross-compiling
Installing GCC
Potential problems
Changing the system root
Generating a Clang cross-compiler
Configuration options
Building and installing your Clang-based cross-compiler
Alternative build methods
Ninja
ELLCC
EmbToolkit
Testing
Development boards
Simulators
Additional resources
Summary
9. The Clang Static Analyzer
Understanding the role of a static analyzer
Comparing classic warnings versus the Clang Static Analyzer
The power of the symbolic execution engine
Testing the static analyzer
Using the driver versus using the compiler
Getting to know the available checkers
Using the static analyzer in the Xcode IDE
Generating graphical reports in HTML
Handling large projects
A real-world example – finding bugs in Apache
Extending the static analyzer with your own checkers
Getting familiar with the project architecture
Writing your own checker
Solving the problem with a custom checker
Writing the state class
Understanding ProgramState immutability
Dissecting the code
Defining the Checker subclass
Writing the Register macro
Implementing the Checker subclass
Adding registration code
Building and testing
More resources
Summary
10. Clang Tools with LibTooling
Generating a compile command database
The clang-tidy tool
Using clang-tidy to check your code
Refactoring tools
Clang Modernizer
Clang Apply Replacements
ClangFormat
Modularize
Understanding C/C++ APIs' Definitions
The linker job
The frontend counterpart
Problems of relying on the C/C++ preprocessor
Understanding the working of modules
Using modules
Understanding Modularize
Using Modularize
Module Map Checker
PPTrace
Clang Query
Clang Check
Remove c_str() calls
Writing your own tool
Problem definition – writing a C++ code refactoring tool
Configuring your source code location
Dissecting tooling boilerplate code
Using AST matchers
Composing matchers
Putting the AST matcher predicates in the code
Writing the callbacks
Testing your new refactoring tool
More resources
Summary
Index
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜