(libgccjit.info)Top


Next: Tutorial Up: (dir)
Enter node , (file) or (file)node

libgccjit Documentation
***********************

     libgccjit 11.0.0 (experimental 20210114), Jan 14, 2021

     David Malcolm

     Copyright © 2014-2021 Free Software Foundation, Inc.

This document describes libgccjit(1), an API for embedding GCC inside
programs and libraries.

There are actually two APIs for the library:

   * a pure C API: ‘libgccjit.h’

   * a C++ wrapper API: ‘libgccjit++.h’.  This is a collection of “thin”
     wrapper classes around the C API, to save typing.

Contents:

Tutorial
Topic Reference
C++ bindings for libgccjit
Internals
Indices and tables
Index
 — The Detailed Node Listing —

Tutorial

Tutorial part 1; “Hello world”
Tutorial part 1 “Hello world”.
Tutorial part 2; Creating a trivial machine code function
Tutorial part 2 Creating a trivial machine code function.
Tutorial part 3; Loops and variables
Tutorial part 3 Loops and variables.
Tutorial part 4; Adding JIT-compilation to a toy interpreter
Tutorial part 4 Adding JIT-compilation to a toy interpreter.
Tutorial part 5; Implementing an Ahead-of-Time compiler
Tutorial part 5 Implementing an Ahead-of-Time compiler.
Tutorial part 2: Creating a trivial machine code function

Error-handling
Options
Full example
Tutorial part 3: Loops and variables

Expressions; lvalues and rvalues
Expressions lvalues and rvalues.
Control flow
Visualizing the control flow graph
Full example
Full example<2>.
Tutorial part 4: Adding JIT-compilation to a toy interpreter

Our toy interpreter
Compiling to machine code
Setting things up
Populating the function
Verifying the control flow graph
Compiling the context
Single-stepping through the generated code
Examining the generated code
Putting it all together
Behind the curtain; How does our code get optimized?
Behind the curtain How does our code get optimized?.
Behind the curtain: How does our code get optimized?

Optimizing away stack manipulation
Elimination of tail recursion
Tutorial part 5: Implementing an Ahead-of-Time compiler

The “brainf” language
Converting a brainf script to libgccjit IR
Compiling a context to a file
Other forms of ahead-of-time-compilation
Topic Reference

Compilation contexts
Objects
Types
Expressions
Creating and using functions
Function pointers
Function pointers<2>.
Source Locations
Compiling a context
ABI and API compatibility
Performance
Using Assembly Language with libgccjit
Compilation contexts

Lifetime-management
Thread-safety
Error-handling
Error-handling<2>.
Debugging
Options
Options<2>.
Options

String Options
Boolean options
Integer options
Additional command-line options
Types

Standard types
Pointers, const, and volatile
Pointers const and volatile.
Vector types
Structures and unions
Function pointer types
Expressions

Rvalues
Lvalues
Working with pointers, structs and unions
Working with pointers structs and unions.
Rvalues

Simple expressions
Vector expressions
Unary Operations
Binary Operations
Comparisons
Function calls
Function pointers
Type-coercion
Lvalues

Global variables
Creating and using functions

Params
Functions
Blocks
Statements
Source Locations

Faking it
Compiling a context

In-memory compilation
Ahead-of-time compilation
ABI and API compatibility

Programmatically checking version
ABI symbol tags
ABI symbol tags

LIBGCCJIT_ABI_0
LIBGCCJIT_ABI_1
LIBGCCJIT_ABI_2
LIBGCCJIT_ABI_3
LIBGCCJIT_ABI_4
LIBGCCJIT_ABI_5
LIBGCCJIT_ABI_6
LIBGCCJIT_ABI_7
LIBGCCJIT_ABI_8
LIBGCCJIT_ABI_9
LIBGCCJIT_ABI_10
LIBGCCJIT_ABI_11
LIBGCCJIT_ABI_12
LIBGCCJIT_ABI_13
LIBGCCJIT_ABI_14
LIBGCCJIT_ABI_15
Performance

The timing API
Using Assembly Language with libgccjit

Adding assembler instructions within a function
Adding top-level assembler statements
C++ bindings for libgccjit

Tutorial
Tutorial<2>.
Topic Reference
Topic Reference<2>.
Tutorial

Tutorial part 1; “Hello world”
Tutorial part 1 “Hello world”<2>.
Tutorial part 2; Creating a trivial machine code function
Tutorial part 2 Creating a trivial machine code function<2>.
Tutorial part 3; Loops and variables
Tutorial part 3 Loops and variables<2>.
Tutorial part 4; Adding JIT-compilation to a toy interpreter
Tutorial part 4 Adding JIT-compilation to a toy interpreter<2>.
Tutorial part 2: Creating a trivial machine code function

Options
Options<3>.
Full example
Full example<3>.
Tutorial part 3: Loops and variables

Expressions; lvalues and rvalues
Expressions lvalues and rvalues<2>.
Control flow
Control flow<2>.
Visualizing the control flow graph
Visualizing the control flow graph<2>.
Full example
Full example<4>.
Tutorial part 4: Adding JIT-compilation to a toy interpreter

Our toy interpreter
Our toy interpreter<2>.
Compiling to machine code
Compiling to machine code<2>.
Setting things up
Setting things up<2>.
Populating the function
Populating the function<2>.
Verifying the control flow graph
Verifying the control flow graph<2>.
Compiling the context
Compiling the context<2>.
Single-stepping through the generated code
Single-stepping through the generated code<2>.
Examining the generated code
Examining the generated code<2>.
Putting it all together
Putting it all together<2>.
Behind the curtain; How does our code get optimized?
Behind the curtain How does our code get optimized?<2>.
Behind the curtain: How does our code get optimized?

Optimizing away stack manipulation
Optimizing away stack manipulation<2>.
Elimination of tail recursion
Elimination of tail recursion<2>.
Topic Reference

Compilation contexts
Compilation contexts<2>.
Objects
Objects<2>.
Types
Types<2>.
Expressions
Expressions<2>.
Creating and using functions
Creating and using functions<2>.
Source Locations
Source Locations<2>.
Compiling a context
Compiling a context<2>.
Using Assembly Language with libgccjit++
Compilation contexts

Lifetime-management
Lifetime-management<2>.
Thread-safety
Thread-safety<2>.
Error-handling
Error-handling<3>.
Debugging
Debugging<2>.
Options
Options<4>.
Options

String Options
String Options<2>.
Boolean options
Boolean options<2>.
Integer options
Integer options<2>.
Additional command-line options
Additional command-line options<2>.
Types

Standard types
Standard types<2>.
Pointers, const, and volatile
Pointers const and volatile<2>.
Vector types
Vector types<2>.
Structures and unions
Structures and unions<2>.
Expressions

Rvalues
Rvalues<2>.
Lvalues
Lvalues<2>.
Working with pointers, structs and unions
Working with pointers structs and unions<2>.
Rvalues

Simple expressions
Simple expressions<2>.
Vector expressions
Vector expressions<2>.
Unary Operations
Unary Operations<2>.
Binary Operations
Binary Operations<2>.
Comparisons
Comparisons<2>.
Function calls
Function calls<2>.
Function pointers
Function pointers<3>.
Type-coercion
Type-coercion<2>.
Lvalues

Global variables
Global variables<2>.
Creating and using functions

Params
Params<2>.
Functions
Functions<2>.
Blocks
Blocks<2>.
Statements
Statements<2>.
Source Locations

Faking it
Faking it<2>.
Compiling a context

In-memory compilation
In-memory compilation<2>.
Ahead-of-time compilation
Ahead-of-time compilation<2>.
Using Assembly Language with libgccjit++

Adding assembler instructions within a function
Adding assembler instructions within a function<2>.
Adding top-level assembler statements
Adding top-level assembler statements<2>.
Internals

Working on the JIT library
Running the test suite
Environment variables
Packaging notes
Overview of code structure
Design notes
Submitting patches
Running the test suite

Running under valgrind
   ---------- Footnotes ----------

   (1) http://gcc.gnu.org/wiki/JIT