Commit Graph

7 Commits

Author SHA1 Message Date
Jakob Stoklund Olesen
7f3b807597 Add a calling convention to all function signatures.
A CallConv enum on every function signature makes it possible to
generate calls to functions with different calling conventions within
the same ISA / within a single function.

The calling conventions also serve as a way of customizing Cretonne's
behavior when embedded inside a VM. As an example, the SpiderWASM
calling convention is used to compile WebAssembly functions that run
inside the SpiderMonkey virtual machine.

All function signatures must have a calling convention at the end, so
this changes the textual IL syntax.

Before:

    sig1 = signature(i32, f64) -> f64

After

    sig1 = (i32, f64) -> f64 native
    sig2 = (i32) spiderwasm

When printing functions, the signature goes after the return types:

    function %r1() -> i32, f32 spiderwasm {
    ebb1:
        ...
    }

In the parser, this calling convention is optional and defaults to
"native". This is mostly to avoid updating all the existing test cases
under filetests/. When printing a function, the calling convention is
always included, including for "native" functions.
2017-08-03 11:40:24 -07:00
Aleksey Kuznetsov
8b484b1c77 Binary function names (#91)
* Function names should start with %

* Create FunctionName from string

* Implement displaying of FunctionName as %nnnn with fallback to #xxxx

* Run rustfmt and fix FunctionName::with_string in parser

* Implement FunctionName::new as a generic function

* Binary function names should start with #

* Implement NameRepr for function name

* Fix examples in docs to reflect that function names start with %

* Rebase and fix filecheck tests
2017-06-10 10:30:37 -07:00
Jakob Stoklund Olesen
23ae70cacf Flatten the Value reference representation.
All values are now references into the value table, so drop the
distinction between direct and table values. Direct values don't exist
any more.

Also remove the parser support for the 'vxNN' syntax. Only 'vNN' values
can be parsed now.
2017-04-12 14:45:22 -07:00
Jakob Stoklund Olesen
0be78f970c Make tests less sensitive to specific value numbers. 2017-04-12 14:32:13 -07:00
Jakob Stoklund Olesen
af29fee5d2 Wrap FunctionName in a newtype struct.
Function names display differently than normal strings since they need
quotes and escaping.

Move the FunctionName type into its own module.
2016-09-19 15:09:25 -07:00
Jakob Stoklund Olesen
88218440a3 Make the source map available as filecheck variables.
This makes it possible to refer to entities defined in the source file,
using the source names prefixed with $.

For example, $v20 refers to the value by that name in the sources, even
if it was renumbered to 'vx0' in the parsed file.
2016-09-16 12:59:05 -07:00
Jakob Stoklund Olesen
0b7f87b14c Convert parser tests to filetests.
Create a new directory hierarchy under 'filetests' for all the tests
that are run by 'cton-util test'.

Convert the parser tests under 'tests/parser' to use 'test cat' and
filecheck directives.
2016-09-15 15:50:47 -07:00