diff options
author | Ayke van Laethem <[email protected]> | 2018-11-01 11:41:24 +0100 |
---|---|---|
committer | Ayke van Laethem <[email protected]> | 2018-11-01 11:41:24 +0100 |
commit | c7cf6f0e828258aed269b75840dfe111f71eef05 (patch) | |
tree | 544be00def416833237794708f045e842e8d2284 /compiler/calls.go | |
parent | 85d5fe7643107b67f57ced5928b6c59163072d48 (diff) | |
download | tinygo-c7cf6f0e828258aed269b75840dfe111f71eef05.tar.gz tinygo-c7cf6f0e828258aed269b75840dfe111f71eef05.zip |
docs: move calling convention documentation here
Diffstat (limited to 'compiler/calls.go')
-rw-r--r-- | compiler/calls.go | 27 |
1 files changed, 3 insertions, 24 deletions
diff --git a/compiler/calls.go b/compiler/calls.go index 05cba1c35..18dd74aef 100644 --- a/compiler/calls.go +++ b/compiler/calls.go @@ -5,32 +5,11 @@ import ( "golang.org/x/tools/go/ssa" ) -// This file implements the calling convention used by Go. -// The calling convention is like the C calling convention (or, whatever LLVM -// makes of it) with the following modifications: -// * Struct parameters are fully expanded to individual fields (recursively), -// when the number of fields (combined) is 3 or less. -// Examples: -// {i8*, i32} -> i8*, i32 -// {{i8*, i32}, i16} -> i8*, i32, i16 -// {{i64}} -> i64 -// {} -> -// {i8*, i32, i8, i8} -> {i8*, i32, i8, i8} -// Note that all native Go data types that don't exist in LLVM (string, -// slice, interface, fat function pointer) can be expanded this way, making -// the work of LLVM optimizers easier. -// * Closures have an extra context paramter appended at the end of the -// argument list. -// * Blocking functions have a coroutine pointer prepended to the argument -// list, see src/runtime/scheduler.go for details. +// For a description of the calling convention in prose, see docs/internals.rst +// or the online version of this document: +// https://tinygo.readthedocs.io/en/latest/internals.html#calling-convention // // Some further notes: -// * Function pointers are lowered to either a raw function pointer or a -// closure struct: { i8*, function pointer } -// The function pointer type depends on whether the exact same signature is -// used anywhere else in the program for a call that needs a context -// (closures, bound methods). If it isn't, it is lowered to a raw function -// pointer. // * Defer statements are implemented by transforming the function in the // following way: // * Creating an alloca in the entry block that contains a pointer |