Commit Graph

17 Commits

Author SHA1 Message Date
Dan Gohman
1a513a6964 [WebAssembly] Optimize away return instructions using fallthroughs.
This saves a small amount of code size, and is a first small step toward
passing values on the stack across block boundaries.

Differential Review: http://reviews.llvm.org/D20450


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270294 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-21 00:21:56 +00:00
Dan Gohman
3d5f22734f [WebAssembly] Add -m:e to the target triple.
This enables ELF-style name mangling, which primarily means using ".L" for
private symbols.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257020 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-07 03:19:23 +00:00
Derek Schuff
a9143d4647 [WebAssembly] Support constant offsets on loads and stores
This is just prototype for load/store for i32 types. I'll add them to
the rest of the types if we like this direction.

Differential Revision: http://reviews.llvm.org/D15197

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254807 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-05 00:26:39 +00:00
Dan Gohman
dcdd1c138c [WebAssembly] Support for register stackifying with load and store instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254076 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-25 16:55:01 +00:00
Dan Gohman
789af34864 [WebAssembly] Suffix output operands with '='.
This distinguishes input operands from output operands. This is something of
a syntactic experiment to see whether the mild amount of clutter this adds is
outweighed by the extra information it conveys to the reader.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253922 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-23 21:55:57 +00:00
Dan Gohman
94401ce9c8 [WebAssembly] Enable register coloring and register stackifying.
This also takes the push/pop syntax another step forward, introducing stack
slot numbers to make it easier to see how expressions are connected. For
example, the value pushed in $push7 is popped in $pop7.

And, this begins an experiment with making get_local and set_local implicit
when an operation directly uses or defines a register. This greatly reduces
clutter. If this experiment succeeds, it may make sense to do this for
const instructions as well.

And, this introduces more special code for ARGUMENTS; hopefully this code
will soon be obviated by proper support for live-in virtual registers.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253465 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-18 16:12:01 +00:00
Dan Gohman
d39c38d2bc [WebAssembly] Reapply r252858, with svn add for the new file.
Switch to MC for instruction printing.

This encompasses several changes which are all interconnected:
 - Use the MC framework for printing almost all instructions.
 - AsmStrings are now live.
 - This introduces an indirection between LLVM vregs and WebAssembly registers,
   and a new pass, WebAssemblyRegNumbering, for computing a basic the mapping.
   This addresses some basic issues with argument registers and unused registers.
 - The way ARGUMENT instructions are handled no longer generates redundant
   get_local+set_local for every argument.

This also changes the assembly syntax somewhat; most notably, MC's printing
does not use sigils on label names, so those are no longer present, and
push/pop now have a sigil to keep them unambiguous.

The usage of set_local/get_local/$push/$pop will continue to evolve
significantly. This patch is just one step of a larger change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252910 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-12 17:04:33 +00:00
Hans Wennborg
e8073938cf Revert r252858: "[WebAssembly] Switch to MC for instruction printing."
It broke the CMake build:

"Cannot find source file: WebAssemblyRegNumbering.cpp"

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252897 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-12 14:37:56 +00:00
Dan Gohman
41e2c98842 [WebAssembly] Switch to MC for instruction printing.
This encompasses several changes which are all interconnected:
 - Use the MC framework for printing almost all instructions.
 - AsmStrings are now live.
 - This introduces an indirection between LLVM vregs and WebAssembly registers,
   and a new pass, WebAssemblyRegNumbering, for computing a basic the mapping.
   This addresses some basic issues with argument registers and unused registers.
 - The way ARGUMENT instructions are handled no longer generates redundant
   get_local+set_local for every argument.

This also changes the assembly syntax somewhat; most notably, MC's printing
use sigils on label names, so those are no longer present, and push/pop now
have a sigil to keep them unambiguous.

The usage of set_local/get_local/$push/$pop will continue to evolve
significantly. This patch is just one step of a larger change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252858 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-12 06:10:03 +00:00
Dan Gohman
11228e360e [WebAssembly] Make expression-stack pushing explicit
Modelling of the expression stack is evolving. This patch takes another
step by making pushes explicit.

Differential Revision: http://reviews.llvm.org/D14338


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252334 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-06 19:45:01 +00:00
JF Bastien
d433cde1a1 WebAssembly: fix load/store syntax
Summary: The syntax has changed a bit recently.

Reviewers: binji

Subscribers: llvm-commits, jfb, sunfish, dschuff

Differential Revision: http://reviews.llvm.org/D13821

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250535 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-16 18:24:42 +00:00
JF Bastien
8cafdf539b WebAssembly: update syntax
Summary:
Follow the same syntax as for the spec repo. Both have evolved slightly
independently and need to converge again.

This, along with wasmate changes, allows me to do the following:

  echo "int add(int a, int b) { return a + b; }" > add.c
  ./out/bin/clang -O2 -S --target=wasm32-unknown-unknown add.c -o add.wack
  ./experimental/prototype-wasmate/wasmate.py add.wack > add.wast
  ./sexpr-wasm-prototype/out/sexpr-wasm add.wast -o add.wasm
  ./sexpr-wasm-prototype/third_party/v8-native-prototype/v8/v8/out/Release/d8 -e "print(WASM.instantiateModule(readbuffer('add.wasm'), {print:print}).add(42, 1337));"

As you'd expect, the d8 shell prints out the right value.

Reviewers: sunfish

Subscribers: jfb, llvm-commits, dschuff

Differential Revision: http://reviews.llvm.org/D13712

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250480 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-16 00:53:49 +00:00
Dan Gohman
2d3e3ef1c7 [WebAssembly] Switch to a more traditional assembly syntax
This new syntax is built around putting each instruction on its own line
in a "mnemonic op, op, op" like syntax. It also uses conventional data
section directives like ".byte" and so on rather than requiring everything
to be in hierarchical S-expression format. This is a more natural syntax
for a ".s" file format from the perspective of LLVM MC and related tools,
while remaining easy to translate into other forms as needed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249364 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-06 00:27:55 +00:00
Dan Gohman
de786c9b89 [WebAssembly] Rename setlocal to set_local to match the spec.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249218 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-03 00:01:53 +00:00
Dan Gohman
24b507c2c1 [WebAssembly] Rename several functions and types according to the new spec.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@248644 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-26 01:09:44 +00:00
Dan Gohman
6859e58f5b [WebAssembly] Update target datalayout strings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247187 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-09 20:54:31 +00:00
JF Bastien
456ed8978e WebAssembly: generate load/store
Summary: This handles all load/store operations that WebAssembly defines, and handles those necessary for C++ such as i1. I left a FIXME for outstanding features which aren't required for now.

Reviewers: sunfish

Subscribers: jfb, llvm-commits, dschuff

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@246500 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-31 22:24:11 +00:00