19 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
35d7235fd8 [WebAssembly] Implement the rotate instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264076 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-22 18:01:49 +00:00
Dan Gohman
c13556c771 [WebAssembly] Implement the eqz instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@263976 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-21 19:54:41 +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
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
19dfe052ee [WebAssembly] Emit .param, .result, and .local through MC.
This eliminates one of the main remaining uses of EmitRawText.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253878 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-23 16:50:18 +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
b9615b21ea [WebAssembly] Use more explicit types in testcases.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252345 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-06 21:32:42 +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
Derek Schuff
f284162906 [WebAssembly] Rename ior operator to or to match the spec
Summary: The spec uses "or" for inclusive-or and "xor" for exclusive-or

Reviewers: sunfish

Subscribers: jfb, llvm-commits, dschuff

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252174 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-05 17:08:11 +00:00
JF Bastien
55a57a7674 WebAssembly: fix more syntax
br_if shouldn't start with a dot.
div and rem went from prefix u/s to suffix.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250972 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-22 02:32:50 +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
e2adff7685 [WebAssembly] Rename test files to match platform naming conventions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@248783 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-29 08:13:58 +00:00