Commit Graph

107 Commits

Author SHA1 Message Date
Andrius Štikonas a900bc6632 Implement C99 negation.
!a is 1 if a == 0 and 0 otherwise.
2021-10-29 00:52:29 +01:00
Andrius Štikonas 56ee526c4c Implement support for large immediates on RISC-V. 2021-10-03 11:37:03 +01:00
Jeremiah Orians 5e74995c13
Catch truncated function calls and truncated array statements 2021-10-02 22:02:39 -04:00
Jeremiah Orians 0577243444
Fix Problem with global arrays #18 2021-10-02 10:38:04 -04:00
Andrius Štikonas ae48dbd6cb Add riscv64 port. 2021-10-02 11:59:21 +01:00
Jeremiah Orians 745998ac13
Fix global array initialization to allocate the correct amount of memory 2021-06-26 11:58:13 -04:00
Jeremiah Orians 99df87bc0d
Breakup program to reduce complexity and risk of errors 2021-06-26 11:51:54 -04:00
Jeremiah Orians b37dfc7b12
Report proper error message for negative global array values. Thank you melg8 2021-06-26 10:53:45 -04:00
Jeremiah Orians 8bc09f2b2e
Fixed hang on large global arrays. Thanks melg8 2021-06-23 07:32:40 -04:00
Jeremiah Orians d80d8a652b
Move more functionality into M2libc 2021-04-03 22:41:52 -04:00
Jeremiah Orians 46cf81af83
Replace file_print with fputs 2021-04-03 18:56:55 -04:00
Jeremiah Orians 6f8e2eb905
Removed need for fixup 2021-02-02 23:39:27 -05:00
Jeremiah Orians c5068b227a
Add support for &global_variable 2021-01-28 22:22:08 -05:00
Sanne Wouda 0e3d5b609a Add support for global char foo[12]; definitions
- only enabled in --bootstrap-mode

- allocates space for both the char array and the pointer to the start of
  the array
2021-01-10 23:01:08 +00:00
Sanne Wouda 49fbe8942f Add error checking for unexpected #endif 2021-01-05 22:56:30 +00:00
Sanne Wouda cd96f65a23 Add macro directives to token_list
- change the lexer to not remove preprocessor directives
- preprocess() removes any lines starting with a macro directive that it
  doesn't understand (which is currently all of them)
2021-01-05 22:53:39 +00:00
Sanne Wouda 7b8a99db3c Add a preprocessor-only mode
- Very useful for testing and debugging
- Add preprocess() stub and skip compilation in preprocessor mode
2021-01-05 22:53:04 +00:00
Sanne Wouda a18e0c1782 Add newline tokens to parse stream
- needed to determine start and end of macro directives
- the main parser doesn't need them, so strip out the newline tokens
  before parsing to avoid changing it
2021-01-05 22:23:15 +00:00
Jeremiah Orians 921cc86ce6
First generation implemention of typedef 2021-01-02 22:00:02 -05:00
Jeremiah Orians 358b6cfb96
Fix modulus behavior that is wrong.
Thank you janneke
2021-01-01 16:39:27 -05:00
Jeremiah Orians c220d14928
Catching some segfaults 2020-12-31 09:53:05 -05:00
Jeremiah Orians e25c1995aa
Make types more proper 2020-12-27 21:51:46 -05:00
Jeremiah Orians 6fe6f44a29
Make type information localized to the inside of statements 2020-12-19 16:35:33 -05:00
Jeremiah Orians d9504e3872
Allow M2-Planet to support larger outputs without hitting a segfault 2020-12-19 06:50:11 -05:00
Sanne Wouda 968fdfea65 AArch64 support for unsigned comparison 2020-12-17 00:01:17 +00:00
Jeremiah Orians e5befc4fee
armv7l support for unsigned comparisons 2020-12-15 21:09:26 -05:00
Jeremiah Orians f2cae3d501
AMD64 support for unsigned comparisons 2020-12-15 20:28:04 -05:00
Jeremiah Orians 132e685f97
Fix x86 behavior on unsigned compares 2020-12-15 17:46:45 -05:00
Jeremiah Orians 9da48c5ece
match gcc behavior in regards to if(-1 > 0) 2020-12-15 07:24:07 -05:00
Jeremiah Orians 5c22aac02d
Change knight-posix HEAP behavior and leverage better relational choices for knight-posix 2020-12-15 06:02:38 -05:00
Sanne Wouda a63b8837c0 [AArch64] Use arithmetic right shift for signed
- as discussed with deesix, this is the proper fix
- the test1000 checksum changes as it uses the M2-Planet source as input
2020-12-05 14:59:16 +00:00
Jeremiah Orians 67dbbbdcfc
Enable support for C multi-strings 2020-11-15 18:58:25 -05:00
Jeremiah Orians 57264eb157
Catch potential segfaulting behavior in generated binaries 2020-11-08 21:13:12 -05:00
Jeremiah Orians 39915de931
harmonize integer behavior when reading strings 2020-10-17 13:50:25 -04:00
Jeremiah Orians c4a636c99d
Fix shift behavior to better match C standard 2020-10-16 22:07:06 -04:00
Jeremiah Orians 09783ac089
Fixed continue behavior and added a test to verify correct behavior 2020-02-28 18:48:58 -05:00
deesix b2ece54864 aarch64: do not generate a wasteful stack anymore
Until now, each element on the compiled program stack was 128 bits long,
half of them unused because only one 64 bits value was stored.

Now it's 64 bits long, so we don't waste all that memory.

We workaround the architectural alignment restriction of the SP register by
using a free regular register. X18 is for platform use so it seems a good
candidate for this task.

At _start we copy the value of SP into X18. SP is not used anymore. When a
definition refers to SP it doesn't mean it literaly now, because here we
redefine (without renaming) the involved M1 macro definitions to operate
on X18 (easier transition; abstraction). INIT_SP is introduced.

The function arguments are passed via stack, so the offset from the Base
Pointer ("depth") to each of them is different now. Changes both to
compiler code (cc_core.c) and libc reflect that the arguments are 8 bytes
(instead of 16 bytes) apart now. Note that SUB_X0_32 and SUB_X0_48 are
removed, because we only need 8, 16 and 24 bytes subtraction to reach the
arguments from asm libc functions. SUB_X0_8 and SUB_X0_24 are introduced.
2020-02-08 00:16:54 +01:00
deesix fbc2bf3333 aarch64: statement 2020-02-01 21:23:49 +01:00
deesix 803cf4ffa3 aarch64: flow control 2020-02-01 21:23:49 +01:00
deesix ebb0e4a3f9 aarch64: expression 2020-02-01 21:23:49 +01:00
deesix c32cb92daa aarch64: arithmetic, relational and bitwise expressions 2020-02-01 21:23:49 +01:00
deesix 39936d81cb aarch64: primary, postfix and unary expressions 2020-02-01 21:23:49 +01:00
deesix b581244df0 aarch64: load of function, constant, global and variable 2020-02-01 21:23:49 +01:00
deesix 02bac66940 aarch64: function, function call, arguments, locals and return 2020-02-01 21:23:49 +01:00
deesix 0737a2acf0 aarch64: common recursion 2020-02-01 21:23:49 +01:00
Jeremiah Orians 095664e680
Fix knight-native to be able to support much larger binaries 2020-01-31 22:43:51 -05:00
Jeremiah Orians 5c4c6aee71
prevent void foo () { if(0) {} class of segfaults 2020-01-30 18:40:45 -05:00
Jeremiah Orians 0709770730
Enabled forgotten cleanup scripts and add logic to catch ?alloc errors 2020-01-25 14:15:45 -05:00
Jeremiah Orians 4b2a048f14
Start reducing number of segfaults possible in M2-Planet 2020-01-22 18:03:28 -05:00
Jeremiah Orians 1221a5e6dc
Replace NOP with NULL because that is what is really ment by it 2020-01-06 20:21:26 -05:00