Commit Graph

457 Commits

Author SHA1 Message Date
Nikolay Nikolov
6e4e3b8580 * fixed WebAssembly code generation in thlcgwasm.g_overflowCheck_loc (patch by Pierre) 2022-05-24 11:06:59 +03:00
Nikolay Nikolov
8bea5dd41e * WebAssembly code generation fix in thlcgwasm.a_op_reg_reg_reg_checkoverflow, based on patch by Pierre (but simplified, to use a single block) 2022-05-24 11:00:10 +03:00
Nikolay Nikolov
283c213a0c * patch by Pierre, which fixes WebAssembly code generation for signed div/mod with overflow checking 2022-05-24 10:47:38 +03:00
Nikolay Nikolov
f1cb5d8f71 + support intrinsic for the memory.atomic.notify WebAssembly instruction 2022-05-21 18:03:14 +03:00
Nikolay Nikolov
86643710c4 + support intrinsics for the WebAssembly memory.atomic.wait32 and memory.atomic.wait64 instructions 2022-05-21 17:53:38 +03:00
Nikolay Nikolov
3cfdf000a2 + support the new WebAssembly threads and atomics instructions in the internal assembler 2022-05-21 17:24:21 +03:00
Nikolay Nikolov
e03b920520 + added intrinsic support for the WebAssembly cmpxchg atomic operations as well 2022-05-21 02:52:31 +03:00
Nikolay Nikolov
d8f06aa4f1 + added instrinsic support for the all the 2-parameter read-modify-write
WebAssembly atomic operations (add, sub, and, or, xor, xchg). Note that they
  are not implemented in the internal assembler, yet.
2022-05-20 17:36:37 +03:00
Pierre Muller
be969205ad Do not alloc/dealloc NR_DEFAULTFLAGS for wasm32, as it is NR_NO 2022-05-17 22:47:13 +02:00
Nikolay Nikolov
812736bd41 + support the atomic.fence instruction in the WebAssembly internal object writer 2022-05-13 22:56:36 +03:00
Nikolay Nikolov
1d70437017 + added intrinsic (for RTL internal use) that emits the WebAssembly atomic.fence instruction 2022-05-13 22:46:27 +03:00
Nikolay Nikolov
ddab39dbdc + enable the atomics extension on the llvm-mc command line (extension appears
to be recognized since LLVM 8.0, so it should be safe to always enable this
  from the llvm-mc command line)
2022-05-13 21:15:54 +03:00
Nikolay Nikolov
5198e47e36 + added the atomic memory access WebAssembly instructions from the threading proposal for WebAssembly 2022-05-13 20:55:12 +03:00
florian
27fb9086aa * cleanup: cs_opt_loopunroll is a generic optimization for a long time already 2022-03-08 23:03:18 +01:00
Nikolay Nikolov
2c0f10d988 * when adding WebAssembly object info, traverse through current_module.used_units,
as well as the usedunits global. This resolves #39543
2022-02-12 08:32:48 +02:00
Nikolay Nikolov
c4f9ec91c9 + fix support for 8-byte records, held in a register pair on the WebAssembly target. This fixes #39524 2022-01-25 13:03:35 +02:00
florian
6404478ea4 * cleanup of VER3_0 defines 2021-11-17 22:19:57 +01:00
J. Gareth "Curious Kit" Moreton
2dc0995067 - Bug fix to new ADD/SUB optimisation where conditions are concerned
- Register allocation fixes for overflow checks
2021-11-17 20:18:57 +00:00
Yuriy Sydorov
b78761efd3 * Removed obsolete OLDREGVARS ifdefs. 2021-11-02 17:08:08 +02:00
florian
ff3acfb8cd * cleanup of 2.7.0 defines 2021-10-31 13:20:28 +01:00
Nikolay Nikolov
7f1050464a + added 'else' tracking for the if..end_if blocks 2021-10-23 11:56:25 +03:00
Nikolay Nikolov
7bef4d827d * keep track of the block stack, when resolving labels and check whether the
blocks match (i.e. block..end_block, if..end_if, loop..end_loop, try..end_try)
2021-10-23 11:25:44 +03:00
Nikolay Nikolov
12a2c56461 - removed thlcgwasm.incblock, .decblock and br_blocks, as branching is now done
entirely with labels
2021-10-22 17:42:29 +03:00
Nikolay Nikolov
3094f75690 * WebAssembly code generation for 'case' nodes changed to use labels 2021-10-22 17:31:04 +03:00
Nikolay Nikolov
6fe647ee3d * moved the default procedure CurrRaiseLabel to the end of the procedure, not
at the exit label. This fixes problems when using units with finalization
  code that contain classes with class destructors in branchful WebAssembly
  exceptions mode.
2021-10-22 13:54:55 +03:00
Nikolay Nikolov
470e77a572 + added sanity check when resolving labels to ensure we don't get any jumps with
negative nesting depth
2021-10-22 13:54:55 +03:00
Nikolay Nikolov
5a0956d805 * use WebAssembly asm labels for the raise branch instruction in branchful
exceptions mode
2021-10-22 13:54:55 +03:00
Nikolay Nikolov
4e3a6aa5a8 * match the label to the wider block, if it is adjacent to both the brevious
and the next instruction
2021-10-20 14:35:52 +03:00
Nikolay Nikolov
c96e203780 * moved the 'end_block' WebAssembly instruction before the 'exit' label right
before the procedure finalization code. This fixes compilation errors in
  procedures with implicit finalization code (e.g. for ansistring local vars,
  etc).
2021-10-20 14:35:52 +03:00
Nikolay Nikolov
bb30958665 + wrap block nodes with exit in a_block..a_end_block instructions. This fixes
'exit' in inlined procedures on the WebAssembly target.
2021-10-20 14:35:51 +03:00
Nikolay Nikolov
703ae75ba6 * if a label cannot be associated with the previous block instruction, try
matching it with the next instruction
2021-10-20 14:35:51 +03:00
Nikolay Nikolov
9f077d4ac0 * leave unresolved branches in the asm output, when the compiler is compiled with -dEXTDEBUG 2021-10-20 14:35:51 +03:00
Nikolay Nikolov
1ce2fb8a4a * use WebAssembly asm labels for generating code for the 'exit' statement 2021-10-20 14:35:51 +03:00
Nikolay Nikolov
dc9090e67f * fixed some more warnings 2021-10-20 10:23:02 +03:00
Nikolay Nikolov
b3a9c36cbb * fixed some warnings 2021-10-20 10:03:14 +03:00
Nikolay Nikolov
0662a0bd44 + use WebAssembly asm labels for the code generation of 'break' statements as well 2021-10-20 09:59:54 +03:00
Nikolay Nikolov
01dc62b127 + introduced the use of asm labels for WebAssembly. Resolve them in
tcpuprocinfo.postprocess_code. Use them when generating code for the
  'continue' label jumps.
2021-10-20 09:39:44 +03:00
Nikolay Nikolov
0da5d57c1e * replaced the 'if br end_if' sequence with the 'br_if' instruction, when
generating WebAssembly code for try..finally blocks (in all exception modes)
2021-10-14 14:19:13 +03:00
Nikolay Nikolov
dcae87bd52 + support cdecl and stdcall on the WebAssembly target. They are essentially the
same, the only difference is that cdecl creates an unmangled alias
2021-10-14 12:29:59 +03:00
Nikolay Nikolov
b91fc3a0d3 * fixed passing of singleton record parameters, containing a float in WebAssembly 2021-10-14 10:53:55 +03:00
Nikolay Nikolov
df92d88f39 + added support for the handling of singleton record and array types in
defToWasmBasic
2021-10-14 10:53:55 +03:00
Nikolay Nikolov
3511b80972 * fixed formatting in defToWasmBasic 2021-10-14 10:53:55 +03:00
Nikolay Nikolov
ee387f7c66 * C ABI fixes for the passing of records in WebAssembly 2021-10-14 10:53:55 +03:00
Nikolay Nikolov
236e10d03a + pass 64-bit structures by address in WebAssembly for compatibility with LLVM's C ABI 2021-10-14 10:53:55 +03:00
Nikolay Nikolov
3c58f26e83 * thlcgwasm.g_checkexceptions renamed .g_maybe_checkforexceptions, added also as
an empty virtual method in thlcgobj and modified the WebAssembly
  implementation, so that it can be called from any exceptions mode (so it
  emits no code in exception modes that don't require it, instead of generating
  an internal error). This will allow .g_maybe_checkforexceptions to be called
  from the generic parts of the code generator, after calls to systemprocs that
  could raise an exceptions.
2021-10-05 17:54:35 +03:00
Nikolay Nikolov
fab4ca449b * twasmexceptionstatehandler_nativeexceptions.handle_nested_exception and
twasmexceptionstatehandler_bfexceptions.handle_nested_exception should not be
  called, so now they cause an internal error
2021-10-05 07:54:57 +03:00
Nikolay Nikolov
04a41fa5b0 - removed duplicated assignment 2021-10-05 07:43:47 +03:00
Nikolay Nikolov
99ab6bd56d + proper exception object cleanup when using break, continue or exit in try
except blocks in WebAssembly native exceptions mode
2021-10-05 07:41:42 +03:00
Nikolay Nikolov
ddbdc529b1 + proper exception cleanup for try except blocks that use exit, break or
continue in WebAssembly branchful exceptions mode
2021-10-05 07:19:24 +03:00
Nikolay Nikolov
023f08d54b + exception cleanup when break, continue or exit is used inside a
try .. except 'on' block, in WebAssembly native exceptions mode
2021-10-05 06:45:31 +03:00