[cranelift docs] Fix grammar code blocks and heap image (#1339)

* [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>
This commit is contained in:
Samrat Man Singh
2020-03-19 03:21:22 +05:30
committed by GitHub
parent 33b4750a64
commit 1958e8af96
3 changed files with 50 additions and 23 deletions

View File

@@ -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
@@ -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
@@ -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: