Skip to content

Commit

Permalink
[cranelift docs] Fix grammar code blocks and heap image (#1339)
Browse files Browse the repository at this point in the history
* [cranelift docs] Move grammar segments in IR docs to code blocks

* [cranelift docs] Replace dot code in IR docs with generated image.

This is how the image was generated

$ cat > heap.dot << EOF
digraph {
        node [
              shape=record,
              fontsize=10,
              fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans"
              ]
        "static" [label="mapped\npages|unmapped\npages|offset_guard\npages"]
}
EOF

$ dot -Tsvg -O heap.dot

* [cranelift docs] Fix indentation in grammar block

Co-Authored-By: bjorn3 <bjorn3@users.noreply.github.com>

Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
  • Loading branch information
samrat and bjorn3 authored Mar 18, 2020
1 parent 33b4750 commit 1958e8a
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 23 deletions.
8 changes: 8 additions & 0 deletions cranelift/docs/heap.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
digraph {
node [
shape=record,
fontsize=10,
fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans"
]
"static" [label="mapped\npages|unmapped\npages|offset_guard\npages"]
}
26 changes: 26 additions & 0 deletions cranelift/docs/heap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 16 additions & 23 deletions cranelift/docs/ir.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,12 @@ execution can never fall through to the next EBB without an explicit branch.
A `.clif` file consists of a sequence of independent function definitions:
.. productionlist::
function_list : { function }
function : "function" function_name signature "{" preamble function_body "}"
preamble : { preamble_decl }
function_body : { extended_basic_block }
```
function_list : { function }
function : "function" function_name signature "{" preamble function_body "}"
preamble : { preamble_decl }
function_body : { extended_basic_block }
```
### Static single assignment form
Expand Down Expand Up @@ -397,14 +398,15 @@ be known when the function call is compiled. The function signature describes
how to call the function, including parameters, return values, and the calling
convention:
.. productionlist::
signature : "(" [paramlist] ")" ["->" retlist] [call_conv]
paramlist : param { "," param }
retlist : paramlist
param : type [paramext] [paramspecial]
paramext : "uext" | "sext"
paramspecial : "sret" | "link" | "fp" | "csr" | "vmctx" | "sigid" | "stack_limit"
callconv : "fast" | "cold" | "system_v" | "fastcall" | "baldrdash_system_v" | "baldrdash_windows"
```
signature : "(" [paramlist] ")" ["->" retlist] [call_conv]
paramlist : param { "," param }
retlist : paramlist
param : type [paramext] [paramspecial]
paramext : "uext" | "sext"
paramspecial : "sret" | "link" | "fp" | "csr" | "vmctx" | "sigid" | "stack_limit"
callconv : "fast" | "cold" | "system_v" | "fastcall" | "baldrdash_system_v" | "baldrdash_windows"
```
A function's calling convention determines exactly how arguments and return
values are passed, and how stack frames are managed. Since all of these details
Expand Down Expand Up @@ -620,16 +622,7 @@ returns a pointer that is guaranteed to trap. Heap addresses can be smaller than
the native pointer size, for example unsigned `i32` offsets on a 64-bit
architecture.
.. digraph:: static
:align: center
:caption: Heap address space layout
node [
shape=record,
fontsize=10,
fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans"
]
"static" [label="mapped\npages|unmapped\npages|offset_guard\npages"]
![Heap address space layout](./heap.svg)
A heap appears as three consecutive ranges of address space:
Expand Down

0 comments on commit 1958e8a

Please sign in to comment.