18 Commits

Author SHA1 Message Date
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
df86d51b37 [WebAssembly] Add more explicit pushes to the tests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252344 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-06 21:26:50 +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
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
a05446bfec [WebAssembly] Support calls marked as "tail", fastcc, and coldcc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249184 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-02 20:54:23 +00:00
Dan Gohman
ec9e44d1d4 [WebAssembly] Support for direct call and call_indirect.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@248716 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-28 16:22:39 +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
Dan Gohman
85ef3e393d [WebAssembly] Implement calls with void return types.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247158 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-09 16:13:47 +00:00
Dan Gohman
307756e77e [WebAssembly] Fix lowering of calls with more than one argument.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247118 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-09 01:52:45 +00:00
JF Bastien
0118969fbd WebAssembly: emit (func (param t) (result t)) s-expressions
Summary: Match spec format: https://github.com/WebAssembly/spec/blob/master/ml-proto/test/fac.wasm

Reviewers: sunfish

Subscribers: llvm-commits, jfb

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245986 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-25 22:58:05 +00:00
JF Bastien
3a9c43563b WebAssembly: Implement call
Summary: Support function calls.

Reviewers: sunfish, sunfishcode

Subscribers: sunfishcode, jfb, llvm-commits

Differential revision: http://reviews.llvm.org/D12219

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245887 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-24 22:16:48 +00:00
JF Bastien
9f728dbfdc Revert two bad commits.
Summary: I forgot to squash git commits before doing an svn dcommit of D12219. Reverting, and re-submitting.

Subscribers: jfb, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245886 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-24 22:07:33 +00:00
JF Bastien
b7a8e4c591 Missing print.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245883 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-24 22:00:04 +00:00
JF Bastien
03685a9bf4 call
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245882 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-24 21:59:51 +00:00