Commit Graph

171 Commits

Author SHA1 Message Date
nickysn
9e95895a9b * get rid of the internal error in thlcgwasm.a_cmp_ref_reg_stack by using swap_opcmp
git-svn-id: branches/wasm@48332 -
2021-01-22 16:31:31 +00:00
nickysn
5a84c4db61 - get rid of FRAME_POINTER_SYM and BASE_POINTER_SYM - they should not be used anymore
git-svn-id: branches/wasm@48331 -
2021-01-22 16:24:56 +00:00
nickysn
4d99fb3352 * allocate locals in a better way, so that we don't get 2 extra wasted locals per function
git-svn-id: branches/wasm@48330 -
2021-01-22 16:22:49 +00:00
nickysn
e0dffb1c2c * fixes to the type conversions in thlcgwasm.resize_stack_int_val
git-svn-id: branches/wasm@48329 -
2021-01-22 16:05:03 +00:00
nickysn
f03245e05c - get rid of maybe_adjust_cmp_stackval - it is unnecessary for WebAssembly,
because it has unsigned comparison instructions, unlike the JVM, and using it
  with the unsigned instructions even produced incorrect code

git-svn-id: branches/wasm@48328 -
2021-01-22 15:41:50 +00:00
nickysn
a9264cc608 - removed commented out method g_copyvalueparas
git-svn-id: branches/wasm@48327 -
2021-01-22 15:29:34 +00:00
nickysn
3a0d84fde2 - removed outdated comment from thlcgwasm.a_cmp_stack_stack
git-svn-id: branches/wasm@48326 -
2021-01-22 15:26:30 +00:00
nickysn
f3482acbf9 - removed commented out code from thlcgwasm.g_proc_entry
git-svn-id: branches/wasm@48325 -
2021-01-22 15:24:11 +00:00
nickysn
83f88e515b * renamed the a_get/set/tee_local/global asm ops a_local/global_set/get/tee
git-svn-id: branches/wasm@48324 -
2021-01-22 15:21:40 +00:00
nickysn
d8f55ebb48 * renamed the a_iXX_extendYYYY family of asm ops to their modern versions
git-svn-id: branches/wasm@48323 -
2021-01-22 15:08:43 +00:00
nickysn
910bbc6b37 * override is_pushleftright for WebAssembly and make it return true
git-svn-id: branches/wasm@48312 -
2021-01-22 02:59:13 +00:00
nickysn
61ba4869ae * quick and dirty fix for the move parameter order passing in g_concatcopy
git-svn-id: branches/wasm@48295 -
2021-01-22 00:02:12 +00:00
nickysn
4d933d74b9 + call the inherited methods for generating the standard entry/exit code, so that units are initialized/finalized
git-svn-id: branches/wasm@48286 -
2021-01-21 22:15:50 +00:00
nickysn
7e958e0a35 + introduced the discardresult directive and declared the UniqueString()
overloads, using this directive

git-svn-id: branches/wasm@48283 -
2021-01-21 21:42:07 +00:00
nickysn
187659ff02 + more accurate stack tracking in thlcgwasm.a_loadaddr_ref_stack
git-svn-id: branches/wasm@48281 -
2021-01-21 18:26:07 +00:00
nickysn
84e2299399 * fixed getting of float function result after call
git-svn-id: branches/wasm@48280 -
2021-01-21 18:17:00 +00:00
nickysn
545c949586 * fixed thlcgwasm.a_op_ref_stack - it was not emitting the actual operation opcode
git-svn-id: branches/wasm@48279 -
2021-01-21 17:40:01 +00:00
nickysn
4fa09a6f8b - removed the trunc32 parameter of thlcgwasm.a_op_stack, because it is no longer used, nor necessary
git-svn-id: branches/wasm@48277 -
2021-01-21 17:28:20 +00:00
nickysn
3bdf0938c0 - removed thlcgwasm.maybepreparedivu32, because it is not needed - WebAssembly has 32-bit unsigned division, unlike the JVM
git-svn-id: branches/wasm@48276 -
2021-01-21 17:26:38 +00:00
nickysn
ffebab9691 * fixed byte/word to int64 conversion in thlcgwasm.resize_stack_int_val
git-svn-id: branches/wasm@48275 -
2021-01-21 17:09:03 +00:00
nickysn
dc9feba435 - removed thlcgwasm.loadstoreopc and replaced it with direct code - this actually improves code readability now
git-svn-id: branches/wasm@48274 -
2021-01-21 17:03:49 +00:00
nickysn
aaf28ca259 - removed commented out code
git-svn-id: branches/wasm@48273 -
2021-01-21 16:57:35 +00:00
nickysn
72abf6f472 + add "fingerprints" in the beginning of each routine for easier debugging (this
will be disabled later, and only enabled with -g or some other target flag,
  but for now, it's always on)

git-svn-id: branches/wasm@48272 -
2021-01-21 16:34:39 +00:00
nickysn
cb12a91936 * both stack parameters of 64-bit SHL/SHR/SAR in WebAssembly should be 64-bit, unlike the JVM
git-svn-id: branches/wasm@48267 -
2021-01-21 14:28:27 +00:00
nickysn
a6410fae90 * fixes to the type conversions in thlcgwasm.resize_stack_int_val
git-svn-id: branches/wasm@48266 -
2021-01-21 14:22:19 +00:00
nickysn
17bfdee158 * decstack after call_indirect
git-svn-id: branches/wasm@48265 -
2021-01-21 14:05:19 +00:00
nickysn
e4c9f030af * more precise stack tracking in thlcgwasm.prepare_stack_for_ref
git-svn-id: branches/wasm@48264 -
2021-01-21 13:55:42 +00:00
nickysn
2bdd089645 - removed unused parameters from g_adjust_stack_after_call for WebAssembly
git-svn-id: branches/wasm@48259 -
2021-01-21 04:41:48 +00:00
nickysn
b3eca0e4f9 + produce a warning for values, remaining on top of stack at end of function
git-svn-id: branches/wasm@48258 -
2021-01-21 04:38:01 +00:00
nickysn
dd00619e1a * improved the accuracy of the stack tracking in g_adjust_stack_after_call
git-svn-id: branches/wasm@48257 -
2021-01-21 04:34:43 +00:00
nickysn
fdf1f7d966 * adjust stack correctly in a_op_stack
git-svn-id: branches/wasm@48256 -
2021-01-21 04:12:20 +00:00
nickysn
8697fb4822 * write the WebAssembly procdefs in the standard way, instead of using the special JVM way
git-svn-id: branches/wasm@48251 -
2021-01-21 02:44:43 +00:00
nickysn
f8361cb5dd * fixed internal error with functions with ret_in_param result types and unitialized result
git-svn-id: branches/wasm@48234 -
2021-01-20 21:13:58 +00:00
nickysn
0f235f38ab + introduced thlcgwasm.a_loadaddr_ref_stack
git-svn-id: branches/wasm@48212 -
2021-01-19 19:11:17 +00:00
nickysn
cc94ab3ab8 + implemented length() code generation for WebAssembly
git-svn-id: branches/wasm@48198 -
2021-01-19 14:32:23 +00:00
nickysn
aafc6423f0 + introduced a_cmp_loc_reg_br, a_cmp_reg_loc_br and a_cmp_ref_loc_br
git-svn-id: branches/wasm@48195 -
2021-01-19 13:09:08 +00:00
nickysn
fe5dee892f + introduced a_cmp_subsetreg_reg_br and a_cmp_subsetref_reg_br
git-svn-id: branches/wasm@48194 -
2021-01-19 13:05:50 +00:00
nickysn
db4c786059 + introduced a_cmp_const_loc_br
git-svn-id: branches/wasm@48193 -
2021-01-19 13:03:03 +00:00
nickysn
f9d1a9b8e3 * decstack after each br_if in the a_cmp_XXX_br methods
git-svn-id: branches/wasm@48192 -
2021-01-19 13:00:42 +00:00
nickysn
af41eee9d1 + support references with only index reg, and no base reg in thlcgwasm.prepare_stack_for_ref
git-svn-id: branches/wasm@48179 -
2021-01-18 22:35:56 +00:00
nickysn
374882455b - disallow (i.e. generate internal errors) the use of a_cmp_*_label functions
for the WebAssembly target, because it doesn't support jumps to labels
* the previous implementation of a_cmp_*_label was a hack, that ignored the
  label parameter. These functions are now moved to the newly introduced
  a_cmp_*_stack functions.

git-svn-id: branches/wasm@48175 -
2021-01-18 21:32:35 +00:00
nickysn
c781e03edf + implemented WebAssembly code generation for case statements
git-svn-id: branches/wasm@48173 -
2021-01-18 20:57:05 +00:00
nickysn
627d5580db * fixed bug in thlcgwasm.a_op_ref_stack
git-svn-id: branches/wasm@48078 -
2021-01-05 08:00:44 +00:00
nickysn
af9cc646a9 * use regular loads instead of calling MOVE for 1,2,4 and 8-byte sized g_concatcopy
git-svn-id: branches/wasm@48075 -
2021-01-05 06:30:08 +00:00
nickysn
bdb972cec6 + support OP_NEG in thlcgwasm.a_op_stack
* improvements to OP_NOT in thlcgwasm.a_op_stack

git-svn-id: branches/wasm@48074 -
2021-01-05 06:28:07 +00:00
nickysn
d9b76dc00f + implemented g_concatcopy via calling MOVE
git-svn-id: branches/wasm@48072 -
2021-01-05 05:53:51 +00:00
nickysn
29ee9a648d - more JVM cleanup
git-svn-id: branches/wasm@48065 -
2021-01-04 16:51:13 +00:00
nickysn
d7695db80e - don't override def2regtyp
git-svn-id: branches/wasm@48064 -
2021-01-04 16:49:15 +00:00
nickysn
e04c1221a2 - don't override thlcgwasm.gen_load_return_value
git-svn-id: branches/wasm@48063 -
2021-01-04 16:47:43 +00:00
nickysn
e7ce1feed0 - more JVM leftovers cleanup
git-svn-id: branches/wasm@48062 -
2021-01-04 16:45:32 +00:00
nickysn
1f3ff5f496 - clean up more JVM stuff
git-svn-id: branches/wasm@48061 -
2021-01-04 16:44:01 +00:00
nickysn
542c3fca3e - more JVM methods removed
git-svn-id: branches/wasm@48060 -
2021-01-04 16:42:04 +00:00
nickysn
db1a4d57a2 - removed some more unneeded for WASM methods, copied from the JVM hl codegen
git-svn-id: branches/wasm@48059 -
2021-01-04 16:37:33 +00:00
nickysn
5b961c4125 - removed several JVM methods that aren't necessary for WebAssembly
git-svn-id: branches/wasm@48058 -
2021-01-04 16:34:28 +00:00
nickysn
f95b74f929 * fixed stack tracking in thlcgwasm.a_op_reg_reg_reg_checkoverflow
git-svn-id: branches/wasm@48054 -
2021-01-04 15:02:00 +00:00
nickysn
92ac6bace9 * stack tracking fix for trunc32 in thlcgwasm.a_op_stack
git-svn-id: branches/wasm@48053 -
2021-01-04 15:00:05 +00:00
nickysn
b84bb3e9c4 * fixed stack tracking in thlcgwasm.resizestackfpuval
git-svn-id: branches/wasm@48052 -
2021-01-04 14:59:10 +00:00
nickysn
c6aecf184b * fixed stack tracking in thlcgwasm.gen_load_uninitialized_function_result
git-svn-id: branches/wasm@48051 -
2021-01-04 14:57:54 +00:00
nickysn
bdaeda27c2 * fixed stack tracking in thlcgwasm.a_loadfpu_const_stack
git-svn-id: branches/wasm@48050 -
2021-01-04 14:57:07 +00:00
nickysn
0e395a0d06 * handle addresses just like integers in thlcgwasm.a_load_const_stack
git-svn-id: branches/wasm@48049 -
2021-01-04 14:53:35 +00:00
nickysn
450883ea2b * fixed stack tracking for 64-bit operations in thlcgwasm.a_op_stack
git-svn-id: branches/wasm@48048 -
2021-01-04 14:51:44 +00:00
nickysn
3719383b94 + added stack tracking in the entry and exit code
git-svn-id: branches/wasm@48046 -
2021-01-04 14:36:32 +00:00
nickysn
d85e70bbb4 * fixed the decstack balancing in thlcgwasm.a_cmp_stack_stack
git-svn-id: branches/wasm@48042 -
2021-01-04 13:51:14 +00:00
nickysn
d7b1d67cc6 - removed commented out code from thlcgwasm.a_cmp_stack_stack
git-svn-id: branches/wasm@48041 -
2021-01-04 13:50:18 +00:00
nickysn
68693b2890 + support <,<=,> and >= comparisons of address register types in thlcgwasm.a_cmp_stack_stack
git-svn-id: branches/wasm@48040 -
2021-01-04 13:49:14 +00:00
nickysn
11ae8e54a1 - removed the unused label parameter from a_cmp_stack_stack
git-svn-id: branches/wasm@48039 -
2021-01-04 13:35:24 +00:00
nickysn
5145681ccd * a_cmp_stack_label renamed a_cmp_stack_stack
git-svn-id: branches/wasm@48038 -
2021-01-04 13:33:40 +00:00
nickysn
0cdd7d4d22 + support exit()
git-svn-id: branches/wasm@48035 -
2021-01-04 12:17:50 +00:00
nickysn
c92d27dadb * fixed formatting in thlcgwasm.a_jmp_always
git-svn-id: branches/wasm@48034 -
2021-01-04 12:01:10 +00:00
nickysn
aa102564c5 * fixed the break and continue br depth calculation
git-svn-id: branches/wasm@48032 -
2021-01-04 11:55:01 +00:00
nickysn
3cc9ba9302 - don't push dummy zeros (they are useless and will be discarded), before branching for break/continue
git-svn-id: branches/wasm@48031 -
2021-01-04 11:36:32 +00:00
nickysn
07c1783e24 * refactored call_indirect to use a 'functype' operand type. This type will be reused for block instructions as well.
git-svn-id: branches/wasm@48027 -
2021-01-04 10:50:06 +00:00
nickysn
ade8003fb5 * thlcgwasm.blocks renamed br_blocks, to ensure searching for it in the compiler
sources only finds this identifier (the word 'blocks' is used in too many
  other places and comments). No functional changes.

git-svn-id: branches/wasm@48023 -
2021-01-04 06:47:40 +00:00
nickysn
5524de3be8 - removed redundant comment
git-svn-id: branches/wasm@47994 -
2021-01-02 23:09:43 +00:00
nickysn
5c4e4228f6 + handle all cases in hlcgcpu.pas to avoid warning with -Sew
git-svn-id: branches/wasm@47990 -
2021-01-02 22:43:52 +00:00
nickysn
fc95e7f22d * fixes in thlcgwasm.resize_stack_int_val
git-svn-id: branches/wasm@47974 -
2021-01-02 14:42:10 +00:00
nickysn
189c4025c2 - removed spurious decstack/incstack in thlcgwasm.resize_stack_int_val
git-svn-id: branches/wasm@47972 -
2021-01-02 13:47:53 +00:00
nickysn
0e23b9288c * fixed thlcgwasm.a_load_loc_stack for LOC_REFERENCE
git-svn-id: branches/wasm@47971 -
2021-01-02 13:39:16 +00:00
nickysn
5a2a9f1dcc * simplified a_call_name and avoid internal errors, inherited from the jvm code generator
git-svn-id: branches/wasm@47969 -
2021-01-02 12:44:34 +00:00
nickysn
35489718f3 * fixed call_indirect for the llvm-mc asm writer
git-svn-id: branches/wasm@47965 -
2021-01-02 12:21:30 +00:00
nickysn
56f65799d3 + functype creation moved to tcpuprocdef.create_functype
git-svn-id: branches/wasm@47964 -
2021-01-02 12:06:05 +00:00
nickysn
763ca253c1 + introduced the TWasmFuncType class - used to hold a Wasm function signature
git-svn-id: branches/wasm@47963 -
2021-01-02 11:54:41 +00:00
nickysn
64a02834ff - commented out thlcgwasm.g_copyvalueparas
git-svn-id: branches/wasm@47950 -
2021-01-02 07:22:01 +00:00
nickysn
91ed9f12ac - removed unused local var from thlcgwasm.prepare_stack_for_ref
git-svn-id: branches/wasm@47949 -
2021-01-02 06:55:44 +00:00
nickysn
c470e851ba + generic implementation of thlcgwasm.a_loadaddr_ref_reg that should handle all possible combinations of base, index
and scalefactor

git-svn-id: branches/wasm@47945 -
2021-01-02 06:08:38 +00:00
nickysn
e4f4f25c44 + handle any base and no index in the second if case in thlcgwasm.a_loadaddr_ref_reg
git-svn-id: branches/wasm@47944 -
2021-01-02 05:52:19 +00:00
nickysn
2084fede95 + handle all constant address (regardless of whether they are relative to a symbol or not) in thlcgwasm.a_loadaddr_ref_reg
git-svn-id: branches/wasm@47943 -
2021-01-02 05:48:40 +00:00
nickysn
ded9afb787 + check and generate an internal error if you attempt to take the address of a reference that exists in the local
stack in thlcgwasm.a_loadaddr_ref_reg

git-svn-id: branches/wasm@47942 -
2021-01-02 05:44:19 +00:00
nickysn
a1f5b57070 + also check for ref.index and ref.symbol in the NR_LOCAL_FRAME_POINTER_REG base case in thlcgwasm.a_loadaddr_ref_reg
git-svn-id: branches/wasm@47941 -
2021-01-02 05:40:17 +00:00
nickysn
46bf123fcd + also ensure that ref.base and ref.index are not set for symbols in thlcgwasm.a_loadaddr_ref_reg
git-svn-id: branches/wasm@47940 -
2021-01-02 05:35:31 +00:00
nickysn
15387514b4 * changed the formatting in thlcgwasm.a_loadaddr_ref_reg to fit the style of the other compiler code
git-svn-id: branches/wasm@47939 -
2021-01-02 05:30:22 +00:00
nickysn
88d42344db - removed comment thlcgwasm.a_loadaddr_ref_reg that is not true for wasm
git-svn-id: branches/wasm@47938 -
2021-01-02 05:25:32 +00:00
nickysn
acb13602ea * fixed getting the address of local variables
git-svn-id: branches/wasm@47929 -
2020-12-31 18:36:45 +00:00
nickysn
31bc357c1b * fixed internal error 2019083002 with e.g. inc(local)
git-svn-id: branches/wasm@47927 -
2020-12-31 18:23:49 +00:00
nickysn
46a09bd8e4 * fixed thlcgwasm.a_load_ref_ref for NR_EVAL_STACK_BASE source references
git-svn-id: branches/wasm@47921 -
2020-12-31 08:11:55 +00:00
nickysn
08580ed628 + introduced ttgwasm(tg).allocframepointer and .allocbasepointer
git-svn-id: branches/wasm@47888 -
2020-12-29 06:08:40 +00:00
nickysn
90251d7050 * allocate the base and frame pointer correctly as locals after the previous commit
git-svn-id: branches/wasm@47876 -
2020-12-28 18:44:26 +00:00
nickysn
bfb13fb848 - get rid of treference.islocal. Instead, use checks whether treference.base
is equal to NR_LOCAL_STACK_POINTER_REG

git-svn-id: branches/wasm@47779 -
2020-12-14 23:27:27 +00:00
nickysn
2c56514135 - removed thlcgwasm.a_load_const_stack_intern - it comes from the JVM code
generator and serves no purpose in WebAssembly

git-svn-id: branches/wasm@47195 -
2020-10-25 13:17:54 +00:00
nickysn
c0bbe6d8c0 * 64-bit constants take a single stack slot in WebAssembly. Don't incstack a
second time for 64-bit consts in thlcgwasm.a_load_const_stack

git-svn-id: branches/wasm@47194 -
2020-10-25 12:37:51 +00:00