Nikolay Nikolov
557e823734
+ introduced trefaddr.addr_got_tls, to be used for generating WebAssembly threadvar access, when WASM multithreading is turned on
2022-07-14 00:28:03 +03:00
Nikolay Nikolov
b821b9d502
+ WebAssembly multithreading: also declare threadvar sections as TLS and prefix their name with '.tbss' when using the external assembler
2022-07-13 23:50:48 +03:00
Nikolay Nikolov
b923613ead
+ make use of the unsigned remainder instructions in WebAssembly (i32.rem_s, i64.rem_u)
2022-06-22 03:37:36 +03:00
Nikolay Nikolov
9b16fafc52
+ generate exception checks after calls to fpc_overflow class in WebAssembly
...
branchful exceptions mode, because fpc_overflow can raise an exception in case
unit SysUtils is included.
2022-06-22 03:21:21 +03:00
Nikolay Nikolov
b2350d90ea
* fixed typo in comment
2022-06-22 02:09:05 +03:00
Nikolay Nikolov
90e43e055b
* fixed WebAssembly code generation for integer unary minus with overflow checking
2022-06-22 01:47:07 +03:00
Nikolay Nikolov
b11434a6f8
+ WebAssembly: use the 64-bit div instruction, instead of an RTL helper for 64-bit division
2022-06-22 01:10:02 +03:00
Nikolay Nikolov
4d6e3b4e1a
* Don't call secondpass(left) in twasmtypeconvnode.second_int_to_real, this fixes bug #39735 .
2022-06-21 23:59:25 +03:00
Nikolay Nikolov
bc6ab39ea2
* WebAssembly exceptions fix: fixed raise without parameters in except..end
...
blocks in WebAssembly native and branchful exceptions mode. Fixes #39752
2022-06-21 05:43:35 +03:00
Pierre Muller
2307dc8f26
Try to fix real constant problems for llvm compiler
2022-06-07 23:51:27 +02:00
Nikolay Nikolov
d378240134
+ added the WebAssembly saturating truncation instructions to the internal assembler
2022-05-28 17:41:28 +03:00
Nikolay Nikolov
0ba7ef98b3
+ support the memory.init and the data.drop instructions in the internal asm writer for WebAssembly
2022-05-28 16:00:43 +03:00
Nikolay Nikolov
3a095f5ed5
+ support all the new types in encode_wasm_basic_type
2022-05-28 00:30:43 +03:00
Nikolay Nikolov
907e8402ab
+ added the WebAssembly reference and vector types to TWasmBasicType
2022-05-28 00:16:51 +03:00
Nikolay Nikolov
2888710594
+ added the WebAssembly table instructions
2022-05-28 00:02:27 +03:00
Nikolay Nikolov
534383f686
+ added the WebAssembly reference instructions ref.null, ref.is_null and ref.func
2022-05-27 23:58:27 +03:00
Nikolay Nikolov
e2eadc51a3
+ added the memory.init and data.drop instructions
2022-05-27 23:38:49 +03:00
Nikolay Nikolov
dbba2d2746
+ implemented popcnt via the popcnt instruction in WebAssembly
2022-05-27 23:23:27 +03:00
Nikolay Nikolov
66b471e516
+ support different versions of llvm-mc (version 10 seems to be the earliest that works)
2022-05-26 15:06:35 +03:00
Nikolay Nikolov
16f5863847
+ added WebAssembly atomic store intrinsics
2022-05-25 19:22:45 +03:00
Nikolay Nikolov
0103964250
+ implemented WebAssembly atomic load intrinsics
2022-05-25 18:55:41 +03:00
Nikolay Nikolov
9274f17c52
+ reserved inline numbers for the WebAssembly atomic loads and stores
2022-05-24 16:06:05 +03:00
Nikolay Nikolov
e74797d411
* replaced several internal errors, related to the WebAssembly labels
...
resolution with more meaningful error messages, in order to ease the
debugging of the compiler. Based on patch by Pierre.
2022-05-24 11:44:15 +03:00
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
Nikolay Nikolov
cf7ad98dbf
+ support exception object cleanup, when 'exit', 'break' or 'continue' is used
...
in the except 'on' statements, in branchful WebAssembly exceptions mode
2021-10-05 06:25:32 +03:00
Nikolay Nikolov
7110d1e48e
* use 'br_if' instead of 'if br end_if' sequence in the code, generated by
...
thlcgwasm.g_checkexceptions
2021-10-05 05:29:10 +03:00
Nikolay Nikolov
f7b1ec2435
+ call g_checkexceptions after calls to fpc_reraise and fpc_raise_nested in
...
branchful exceptions mode
2021-10-05 03:38:33 +03:00
Nikolay Nikolov
464b3ebbed
+ implemented the 'on' node code generation (try except 'on' ...) for the
...
branchful exceptions mode
2021-10-05 03:25:03 +03:00
Nikolay Nikolov
a5dcd1c44d
+ initial implementation of try..except in branchful exceptions mode
2021-10-05 03:14:58 +03:00
Nikolay Nikolov
7ce19c1ad7
+ implemented try..finally in branchful exceptions mode
2021-10-05 02:47:49 +03:00
Nikolay Nikolov
7afb665c92
+ insert exception flag check and branch after each function call, when
...
compiling in WebAssembly branchful exceptions mode
2021-10-05 02:26:13 +03:00
Nikolay Nikolov
5be1bfeeca
+ added comment that states that raiseBr is only used in branchful exceptions mode
2021-10-05 01:11:31 +03:00
Nikolay Nikolov
d02921d66b
+ introduced raiseBr, similar to exitBr, but will point to the current
...
innermost exception handler, if there is such a handler in the current
procedure, otherwise it will be the same as exitBr.
2021-10-05 01:07:37 +03:00
Nikolay Nikolov
6599f1d898
- don't generate any WebAssembly native exception handling instructions, nor
...
relocations, when compiling in branchful exceptions mode. This produces a
currently not working, but accepted by wasmtime binary (otherwise, it
complains it doesn't support exceptions and refuses to try to run it).
2021-10-05 01:01:24 +03:00
Nikolay Nikolov
5124ab2521
* cloned the WebAssembly native exceptions code generation and rtl support into
...
the branchful exceptions (which will be modified later, but we're using this
as their starting point, because we can get a snapshot built, without compiler
internal errors)
2021-10-05 00:37:20 +03:00
Nikolay Nikolov
41db71c21c
+ implemented the <= operator for smallsets for WebAssembly
2021-10-03 04:37:13 +03:00
Nikolay Nikolov
5adec3ca98
+ workaround for WebAssembly treating the stack parameter of the store and load
...
instructions as unsigned. This caused an 'out of bounds memory access' trap
when accessing arrays with negative offset index, e.g. in test/cg/tvec.pp
2021-10-03 03:16:34 +03:00
Nikolay Nikolov
0a383d8c0f
* fixed WebAssembly method pointer assignment
2021-10-03 02:27:19 +03:00
Nikolay Nikolov
6f88919f37
- don't set casmdata in wasm32/aasmcpu.pas, so that the aasmdef unit can override it
2021-10-03 00:59:11 +03:00
Nikolay Nikolov
c1eeb8beda
+ use the aasmdef unit in wasm32/cpunode.pas
2021-10-03 00:49:53 +03:00
Nikolay Nikolov
cc2fa67dfa
* fixed OS_S8 to OS_16 conversion for WebAssembly. This fixes test/cg/tcnvint6
2021-10-02 22:10:34 +03:00
Nikolay Nikolov
3258937d97
+ implemented move() for WebAssembly via the memory.copy instruction
2021-10-02 21:33:28 +03:00
Nikolay Nikolov
2e3e3edb5f
+ implemented FillChar for WebAssembly via the memory.fill instruction
2021-10-02 20:31:37 +03:00
Nikolay Nikolov
85207e94f8
+ added inline numbers for a memory.copy and a memory.fill intrinsic
2021-10-02 19:40:36 +03:00
Nikolay Nikolov
026d23632a
+ added the memory.copy and memory.fill WebAssembly instructions
2021-10-02 19:35:26 +03:00
Nikolay Nikolov
d2726c2406
* fixed WebAssembly code generation for not(cbool64)
2021-10-01 05:17:12 +03:00
Nikolay Nikolov
4fc763ac50
* fixed WebAssembly cbool support for OP_NOT
2021-10-01 04:54:17 +03:00
Nikolay Nikolov
baf5ff4e05
* another WebAssembly cbool fix in twasmtypeconvnode.second_int_to_bool
2021-10-01 04:40:50 +03:00
Nikolay Nikolov
968e23546c
* fixed second_int_to_bool for cbool types for WebAssembly
2021-10-01 04:20:02 +03:00
Nikolay Nikolov
188a21bbfd
* fixed 'not(boolean64)' for WebAssembly
2021-10-01 03:01:55 +03:00
Nikolay Nikolov
c6a549eb48
* int64/boolean64 fix in twasmtypeconvnode.second_int_to_bool
2021-10-01 02:57:04 +03:00