summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [WebAssembly] Switch to MC for instruction printing.Dan Gohman2015-11-121-145/+36
| | | | | | | | | | | | | | | | | | | | 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. llvm-svn: 252858
* [WebAssembly] Support non-legal argument and return types.Dan Gohman2015-11-111-62/+88
| | | | llvm-svn: 252687
* [WebAssembly] Remove special cases for things that are no longer special. NFC.Dan Gohman2015-11-101-16/+0
| | | | llvm-svn: 252656
* [WebAssembly] Make expression-stack pushing explicitDan Gohman2015-11-061-7/+19
| | | | | | | | | Modelling of the expression stack is evolving. This patch takes another step by making pushes explicit. Differential Revision: http://reviews.llvm.org/D14338 llvm-svn: 252334
* [WebAssembly] Rename Immediate instructions to Const.Dan Gohman2015-11-051-4/+4
| | | | | | This more closely reflects the naming convention in the spec. llvm-svn: 252204
* [WebAssembly] Fix import statementJF Bastien2015-10-301-9/+10
| | | | | | | | | | Summary: Imports should be generated like (param i32 f32...) not (param i32) (param f32) ... Author: binji Reviewers: jfb Subscribers: jfb, dschuff llvm-svn: 251714
* [WebAssembly] Update opcode name format for conversionsJF Bastien2015-10-291-2/+10
| | | | | | | | | | | | Summary: Conversion opcode name format should be f64.convert_u/i64 not f64_convert_u Author: s3ththompson Reviewers: jfb Subscribers: sunfish, jfb, llvm-commits, dschuff Differential Revision: http://reviews.llvm.org/D14160 llvm-svn: 251613
* WebAssembly: fix more syntaxJF Bastien2015-10-221-1/+1
| | | | | | | br_if shouldn't start with a dot. div and rem went from prefix u/s to suffix. llvm-svn: 250972
* WebAssembly: support importsJF Bastien2015-10-211-1/+23
| | | | | | C/C++ code can declare an extern function, which will show up as an import in WebAssembly's output. It's expected that the linker will resolve these, and mark unresolved imports as call_import (I have a patch which does this in wasmate). llvm-svn: 250875
* WebAssembly: fix call/return syntax.JF Bastien2015-10-201-1/+6
| | | | | | They are now typeless, unlike other operations. llvm-svn: 250793
* WebAssembly: don't omit dead vregs from localsJF Bastien2015-10-171-2/+4
| | | | | | | | | | | | | | | | | | Summary: This is a temporary hack until we get around to remapping the vreg numbers to local numbers. Dead vregs cause bad numbering and make consumers sad. We could also just look at debug info an use named locals instead, but vregs have to work properly anyways so there! Reviewers: binji, sunfish Subscribers: jfb, llvm-commits, dschuff Differential Revision: http://reviews.llvm.org/D13839 llvm-svn: 250594
* WebAssembly: update syntaxJF Bastien2015-10-161-31/+59
| | | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 250480
* [WebAssembly] Switch to a more traditional assembly syntaxDan Gohman2015-10-061-132/+100
| | | | | | | | | | | 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. llvm-svn: 249364
* [WebAssembly] Rename setlocal to set_local to match the spec.Dan Gohman2015-10-031-1/+1
| | | | llvm-svn: 249218
* [WebAssembly] Fix hasAddr64 being used before being initializer.Dan Gohman2015-09-231-20/+36
| | | | | | | | | | This reverts r248388 and fixes the underlying bug: hasAddr64 was initialized in runOnMachineFunction, but runOnMachineFunction isn't ever called in CodeGen/WebAssembly/global.ll since that testcase has no functions. The fix here is to use AsmPrinter's getPointerSize() as needed to determine the pointer size instead. llvm-svn: 248394
* Fix CodeGen/WebAssembly/global.ll test under ASAN.Alexander Kornienko2015-09-231-1/+1
| | | | llvm-svn: 248388
* [WebAssembly] Check in an initial CFG Stackifier passDan Gohman2015-09-161-0/+8
| | | | | | | | | | | | This pass implements a simple algorithm for conversion from CFG to wasm's structured control flow. It doesn't yet handle multiple-entry loops; that will be added in a future patch. It also adds initial support for switch statements. Differential Revision: http://reviews.llvm.org/D12735 llvm-svn: 247818
* [WebAssembly] Tidy up some unneeded newline characters.Dan Gohman2015-09-091-10/+9
| | | | llvm-svn: 247152
* [WebAssembly] Implement WebAssemblyInstrInfo::copyPhysRegDan Gohman2015-09-091-22/+26
| | | | llvm-svn: 247110
* WebAssembly: generate load/storeJF Bastien2015-08-311-21/+30
| | | | | | | | | 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 llvm-svn: 246500
* WebAssembly: NFC comment updateJF Bastien2015-08-261-1/+1
| | | | llvm-svn: 246101
* WebAssembly: handle private/internal globals.JF Bastien2015-08-261-22/+96
| | | | | | | | | | | | Things of note: - Other linkage types aren't handled yet. We'll figure it out with dynamic linking. - Special LLVM globals are either ignored, or error out for now. - TLS isn't supported yet (WebAssembly will have threads later). - There currently isn't a syntax for alignment, I left it in a comment so it's easy to hook up. - Undef is convereted to whatever the type's appropriate null value is. - assert versus report_fatal_error: follow what other AsmPrinters do, and assert only on what should have been caught elsewhere. llvm-svn: 246092
* WebAssembly: assert that there aren't any constant poolsJF Bastien2015-08-251-0/+7
| | | | | | WebAssembly will either use globals or immediates, since it's a virtual ISA. llvm-svn: 245989
* WebAssembly: emit `(func (param t) (result t))` s-expressionsJF Bastien2015-08-251-0/+61
| | | | | | | | | | | | 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 llvm-svn: 245986
* WebAssembly: Implement callJF Bastien2015-08-241-0/+6
| | | | | | | | | | | | Summary: Support function calls. Reviewers: sunfish, sunfishcode Subscribers: sunfishcode, jfb, llvm-commits Differential revision: http://reviews.llvm.org/D12219 llvm-svn: 245887
* Revert two bad commits.JF Bastien2015-08-241-1/+0
| | | | | | | | | | 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 llvm-svn: 245886
* Missing print.JF Bastien2015-08-241-0/+1
| | | | llvm-svn: 245883
* [WebAssembly] Make the assembly printer indent instructions.Dan Gohman2015-08-241-0/+2
| | | | llvm-svn: 245875
* [WebAssembly] CodeGen support for __builtin_wasm_page_size()Dan Gohman2015-08-241-1/+1
| | | | llvm-svn: 245872
* [WebAssembly] Use the checked form of MachineFunction::getSubtarget. NFC.Dan Gohman2015-08-241-2/+1
| | | | llvm-svn: 245852
* WebAssembly: NFC fix release build break, unused variable.JF Bastien2015-08-111-0/+1
| | | | | | | | | | Summary: Caused by D11914, pointed out by blaikie. Subscribers: llvm-commits, jfb, dblaikie Differential Revision: http://reviews.llvm.org/D11929 llvm-svn: 244570
* WebAssembly: simply assert on SNaN and NaNs with payloadsJF Bastien2015-08-111-4/+5
| | | | | | | | | | Summary: convertToHexString doesn't represent them correctly at this point in time. This is a follow-up to sunfish's suggestion in D11914. Subscribers: llvm-commits, sunfish, jfb Differential Revision: http://reviews.llvm.org/D11925 llvm-svn: 244551
* WebAssembly: print immediatesJF Bastien2015-08-101-19/+27
| | | | | | | | | | | | | | | Summary: For now output using C99's hexadecimal floating-point representation. This patch also cleans up how machine operands are printed: instead of special-casing per type of machine instruction, the code now handles operands generically. Reviewers: sunfish Subscribers: llvm-commits, jfb Differential Revision: http://reviews.llvm.org/D11914 llvm-svn: 244520
* WebAssembly: textual emission uses expected opcode namesJF Bastien2015-08-071-12/+13
| | | | | | | | | | | | Summary: WebAssembly's tablegen instructions have the names WebAssembly expects, but by LLVM convention they're uppercase and suffixed with their type after an underscore. Leave the C++ code that way, but print outt he names WebAssembly expects (lowercase, no type). We could teach tablegen to do this later, maybe by using `!cast<string>(node)` in the .td files. Reviewers: sunfish Subscribers: jfb, llvm-commits Differential Revision: http://reviews.llvm.org/D11776 llvm-svn: 244305
* WebAssembly: handle more than int32 argument/returnJF Bastien2015-08-011-1/+14
| | | | | | | | | | | | Summary: Also test 64-bit integers, except shifts for now which are broken because isel dislikes the 32-bit truncate that precedes them. Reviewers: sunfish Subscribers: llvm-commits, jfb Differential Revision: http://reviews.llvm.org/D11699 llvm-svn: 243822
* WebAssembly: print basic integer assembly.JF Bastien2015-07-311-5/+39
| | | | | | | | | | | | | | | | | | | Summary: This prints assembly for int32 integer operations defined in WebAssemblyInstrInteger.td only, with major caveats: - The operation names are currently incorrect. - Other integer and floating-point types will be added later. - The printer isn't factored out to handle recursive AST code yet, since it can't even handle control flow anyways. - The assembly format isn't full s-expressions yet either, this will be added later. - This currently disables PrologEpilogCodeInserter as well as MachineCopyPropagation becasue they don't like virtual registers, which WebAssembly likes quite a bit. This will be fixed by factoring out NVPTX's change (currently a fork of PrologEpilogCodeInserter). Reviewers: sunfish Subscribers: llvm-commits, jfb Differential Revision: http://reviews.llvm.org/D11671 llvm-svn: 243763
* WebAssembly: basic bitcode → assembly CodeGen testJF Bastien2015-07-221-0/+91
Summary: Add a basic CodeGen bitcode test which (for now) only prints out the function name and nothing else. The current code merely implements the basic needed for the test run to not crash / assert. Getting to that point required: - Basic InstPrinter. - Basic AsmPrinter. - DiagnosticInfoUnsupported (not strictly required, but nice to have, duplicated from AMDGPU/BPF's ISelLowering). - Some SP and register setup in WebAssemblyTargetLowering. - Basic LowerFormalArguments. - GenInstrInfo. - Placeholder LowerFormalArguments. - Placeholder CanLowerReturn and LowerReturn. - Basic DAGToDAGISel::Select, which requiresGenDAGISel.inc as well as GET_INSTRINFO_ENUM with GenInstrInfo.inc. - Remove WebAssemblyFrameLowering::determineCalleeSaves and rely on default. - Implement WebAssemblyFrameLowering::hasFP, same as AArch64's implementation. Follow-up patches will implement a real AsmPrinter, which will require adding MI opcodes specific to WebAssembly. Reviewers: sunfish Subscribers: aemerson, jfb, llvm-commits Differential Revision: http://reviews.llvm.org/D11369 llvm-svn: 242939
OpenPOWER on IntegriCloud