Commit Graph

84 Commits

Author SHA1 Message Date
Rui Ueyama
9c36dd727c Make "main" to implicitly return 0 2020-12-07 12:00:06 +09:00
Rui Ueyama
5257ee0f20 Make an array of at least 16 bytes long to have alignment of at least 16 bytes
Quote from AMD64 System V ABI: "An array uses the same alignment as
its elements, except that a local or global array variable of length
at least 16 bytes or a C99 variable-length array variable always has
alignment of at least 16 bytes."
2020-12-07 12:00:06 +09:00
Rui Ueyama
54c2b3b18f Handle op=-style assignments to bitfields 2020-12-07 12:00:06 +09:00
Rui Ueyama
cc852fe99d Add bitfield 2020-12-07 12:00:06 +09:00
Rui Ueyama
b6d3cd00df Allow variadic function to take more than 6 parameters 2020-12-07 12:00:06 +09:00
Rui Ueyama
d7bad96114 Allow to define a function returning a struct 2020-12-07 12:00:06 +09:00
Rui Ueyama
c72df1c9be Allow to call a fucntion returning a struct 2020-12-07 12:00:06 +09:00
Rui Ueyama
d63b1f410a Allow struct argument 2020-12-07 12:00:06 +09:00
Rui Ueyama
5e0f8c47e3 Allow struct parameter 2020-12-07 12:00:06 +09:00
Rui Ueyama
9021f7f5de Support passed-on-stack parameters 2020-12-07 12:00:06 +09:00
Rui Ueyama
b29f052102 Support passed-on-stack arguments 2020-12-07 12:00:06 +09:00
Rui Ueyama
d367510fcc Add #include "..." 2020-12-07 12:00:06 +09:00
Rui Ueyama
d06a8ac6e6 Add function pointer 2020-12-07 12:00:06 +09:00
Rui Ueyama
e452cf7215 Support variadic function with floating-point parameters 2020-12-07 12:00:06 +09:00
Rui Ueyama
c6b30568b4 Allow to define a function that takes/returns flonums 2020-12-07 12:00:06 +09:00
Rui Ueyama
8ec1ebf176 Allow to call a function that takes/returns flonums 2020-12-07 12:00:06 +09:00
Rui Ueyama
0ce1093027 Handle flonum for if, while, do, !, ?:, || and && 2020-12-07 12:00:06 +09:00
Rui Ueyama
83f76ebb66 Add flonum +, -, * and / 2020-12-07 12:00:06 +09:00
Rui Ueyama
cf9ceecb2f Add flonum ==, !=, < and <= 2020-12-07 12:00:06 +09:00
Rui Ueyama
29de46aed4 Add "float" and "double" local variables and casts 2020-12-07 12:00:06 +09:00
Rui Ueyama
1e57f72d8a Add floating-point constant 2020-12-07 12:00:06 +09:00
Rui Ueyama
34ab83bdf4 Add unsigned integral types 2020-12-07 12:00:06 +09:00
Rui Ueyama
754a24fafc Add va_start to support variadic functions 2020-12-07 12:00:06 +09:00
Rui Ueyama
dcd4579226 Handle a function returning bool, char or short
x86-64 psABI says that only the least significant 8 bits are
significant if RAX has a return value of a function returning bool.
Likewise, it looks like only the least significant 1 or 2 bytes
are guaranteed to have a correct value for char and short return
values, respectively.
2020-12-07 12:00:06 +09:00
Rui Ueyama
6a0ed71107 Align stack frame to 16 byte boundaries 2020-12-07 12:00:06 +09:00
Rui Ueyama
ee252e6ce7 Add do ... while 2020-12-07 12:00:06 +09:00
Rui Ueyama
eb85527656 Add static global variables 2020-12-07 12:00:06 +09:00
Rui Ueyama
30b3e216cd Add return that doesn't take any value 2020-12-07 12:00:06 +09:00
Rui Ueyama
9df51789e7 Add _Alignof and _Alignas 2020-12-07 12:00:06 +09:00
Rui Ueyama
006a45ccd4 Add extern 2020-12-07 12:00:06 +09:00
Rui Ueyama
157356c769 Align global variables 2020-12-07 12:00:06 +09:00
Rui Ueyama
3d216e3e06 Emit uninitialized global data to .bss instead of .data 2020-12-07 12:00:06 +09:00
Rui Ueyama
1eae5ae367 Handle union initializers for global variable 2020-12-07 12:00:06 +09:00
Rui Ueyama
ae0a37dc4b Initialize excess array elements with zero 2020-12-07 12:00:06 +09:00
Rui Ueyama
22dd560ecf Support local variable initializers 2020-12-07 12:00:06 +09:00
Rui Ueyama
447ee098c5 Add ?: operator 2020-12-07 12:00:06 +09:00
Rui Ueyama
d0c0cb74b2 Add <<, >>, <<= and >>= 2020-12-07 12:00:06 +09:00
Rui Ueyama
044d9ae07b Add switch-case 2020-12-07 12:00:06 +09:00
Rui Ueyama
3c83dfd8af Add continue statement 2020-12-07 12:00:06 +09:00
Rui Ueyama
b3047f2317 Add break statement 2020-12-07 12:00:06 +09:00
Rui Ueyama
6116cae4c4 Add goto and labeled statement 2020-12-07 12:00:06 +09:00
Rui Ueyama
f30f78175c Add && and || 2020-12-07 12:00:06 +09:00
Rui Ueyama
86440068b4 Add &, |, ^, &=, |= and ^= 2020-12-07 12:00:06 +09:00
Rui Ueyama
daa739817c Add % and %= 2020-12-07 12:00:06 +09:00
Rui Ueyama
46a96d6862 Add ~ operator 2020-12-07 12:00:06 +09:00
Rui Ueyama
6b88bcb306 Add ! operator 2020-12-07 12:00:06 +09:00
Rui Ueyama
736232f3d6 Support file-scope functions 2020-12-07 12:00:05 +09:00
Rui Ueyama
44bba965cb Add _Bool type
_Bool isn't just a 1-bit integer because when you convert a value
to bool, the result is 1 if the original value is non-zero. This
is contrary to the other small integral types, e.g. char, as you
can see below:

  char x  = 256; // x is 0
  _Bool y = 256; // y is 1
2020-12-07 12:00:05 +09:00
Rui Ueyama
8b430a6c5f Implement usual arithmetic conversion 2020-12-07 12:00:05 +09:00
Rui Ueyama
cfc4fa94c1 Add type cast 2020-12-07 12:00:05 +09:00