Commit Graph

115 Commits

Author SHA1 Message Date
Rui Ueyama 11bdd08cff Add L and LL prefixes 2019-09-21 16:17:40 +09:00
Rui Ueyama 06d3190515 Add `signed` keyword 2019-08-27 00:21:23 +09:00
Rui Ueyama d1e7d1e88d Self-host: except the C preprocessor, chibicc can now build itself 2019-08-25 18:00:17 +09:00
Rui Ueyama 27745e5157 Add __builtin_va_start to support variadic functions
Using self.sh helper script, chibicc is now able to self-host.
2019-08-25 11:48:44 +09:00
Rui Ueyama 308dc70609 Allow variadic functions to be called 2019-08-25 10:06:54 +09:00
Rui Ueyama d85319fa28 Fix an API of a function returning bool
x86-64 psABI says that only the least significant 8 bits are
significant if RAX has a return value of a function returning bool.
2019-08-24 16:22:25 +09:00
Rui Ueyama 8c7071a10b Add parse.c and codegen.c to frankenbuild 2019-08-24 16:10:51 +09:00
Rui Ueyama b1526d8ab7 Add do ... while 2019-08-24 16:09:46 +09:00
Rui Ueyama c5e0c1e7a8 Add &=, |= and ^= 2019-08-24 12:21:54 +09:00
Rui Ueyama ed1e26670a Add a script for frankenbuild
self.sh modifies source files for chibicc so that they are
more friendly for self-hosting. The script is used to create
a chibicc binary that consists of object files partly genearted
by gcc and the others by chibicc.

chibicc can now compile main.c and type.c with the script.
2019-08-24 12:08:12 +09:00
Rui Ueyama ac88c3b38a Add static global variables 2019-08-24 11:22:02 +09:00
Rui Ueyama 3eaf84bf16 Add return that doesn't take any value 2019-08-24 08:26:37 +09:00
Rui Ueyama a554dff9d1 Add compound literals 2019-08-24 07:45:14 +09:00
Rui Ueyama a4a0a84848 Add static local variables 2019-08-21 21:05:01 +09:00
Rui Ueyama 1fb5091f75 Add _Alignof 2019-08-21 20:18:08 +09:00
Rui Ueyama 876374e5aa Add empty statement 2019-08-21 20:04:06 +09:00
Rui Ueyama 6c06b451af Allow top-level typename-only declarations 2019-08-21 09:51:25 +09:00
Rui Ueyama f92ef39970 Add extern 2019-08-21 08:14:15 +09:00
Rui Ueyama 342e5b8b13 Align global variables 2019-08-20 21:37:13 +09:00
Rui Ueyama 5c6e15506a Emit uninitialized global data to .bss instead of .data 2019-08-20 21:32:32 +09:00
Rui Ueyama 4bc98b4ec4 Accept `void` as a parameter list
`foo(void)` indicate that function foo does not take a parameter.
2019-08-20 08:30:43 +09:00
Rui Ueyama 8f296f307e Allow global variable initializer to have an addend
A global variable can be initialized with an address of other global
variable, so the following code is legal.

  int x[3];
  int &y = x;

In addition to that, an address can have an addend, so the following
code is also legal

  int x[3];
  int &y = x+2;
2019-08-20 07:27:31 +09:00
Rui Ueyama aada5f04d2 Add string literal initializer for global variable 2019-08-19 21:40:11 +09:00
Rui Ueyama 2f218ca269 Skip excess initializer elements 2019-08-19 08:35:11 +09:00
Rui Ueyama 490f01b935 Allow parentheses in initializers to be omitted 2019-08-19 06:53:50 +09:00
Rui Ueyama 042d671cd9 Add array and struct initializers for global variables 2019-08-18 20:35:17 +09:00
Rui Ueyama 5b0e79f99a Add scalar global initializer 2019-08-18 19:12:02 +09:00
Rui Ueyama 4fc741d109 Handle struct initializers for local variables 2019-08-18 17:56:36 +09:00
Rui Ueyama b15b929b53 Allow array length to be omitted if an initializer is given
So that you can write something like `int x[] = {1, 2, 3}`
instead of `int x[3] = {1, 2, 3}`.
2019-08-18 16:47:44 +09:00
Rui Ueyama 15ee521156 Add string literal initializer 2019-08-18 16:34:39 +09:00
Rui Ueyama e3331d8cb3 Initialize excess array elements with zero 2019-08-18 16:11:11 +09:00
Rui Ueyama e1b12f2c3d Support local variable initializers 2019-08-18 12:01:02 +09:00
Rui Ueyama 8a90e2c51f Add constant expression 2019-08-17 10:38:20 +09:00
Rui Ueyama 0f367201b1 Add ?: operator 2019-08-17 10:27:35 +09:00
Rui Ueyama 55d24d049b Add <<, >>, <<= and >>= 2019-08-16 13:45:24 +09:00
Rui Ueyama 8a207a4dc7 Allow functions returning void 2019-08-15 17:21:15 +09:00
Rui Ueyama f3bdaefbc8 Add switch-case 2019-08-15 16:43:24 +09:00
Rui Ueyama 3ccdb2974f Add goto and labeled statement 2019-08-15 14:57:36 +09:00
Rui Ueyama 08f3970c58 Add continue statement 2019-08-15 14:04:51 +09:00
Rui Ueyama afd829689f Add break statement 2019-08-15 13:48:41 +09:00
Rui Ueyama 6f59ac376a Add a notion of an incomplete struct type 2019-08-15 11:28:03 +09:00
Rui Ueyama ed316955a8 Implement array-to-pointer decay in the func param context 2019-08-14 11:00:05 +09:00
Rui Ueyama 6f24dbde5b Add a notion of an incomplete array type 2019-08-13 21:03:20 +09:00
Rui Ueyama 42f6075787 Add && and || operators 2019-08-13 20:10:23 +09:00
Rui Ueyama 2586416967 Add |, & and ^ operators 2019-08-13 19:54:37 +09:00
Rui Ueyama 03acdd2ed9 Add ~ operator 2019-08-13 19:41:11 +09:00
Rui Ueyama 5ec5e38289 Add ! operator 2019-08-13 19:31:04 +09:00
Rui Ueyama f78c409856 Add hexadecimal, octal and binary number literals 2019-08-13 18:39:56 +09:00
Rui Ueyama 05e907d2b8 Add +=, -=, *= and /= operators 2019-08-13 18:04:08 +09:00
Rui Ueyama 7d718c983f Add ++ and -- operators 2019-08-12 12:12:42 +09:00