Commit graph

493 commits

Author SHA1 Message Date
Jan Nieuwenhuizen 4fbd16aaac mescc: Tinycc support: vsnprintf.
* module/language/c99/compiler.mes (ast-type->type): Support *p++ in test.
* mlibc/libc-mes+tcc.c (vsnprintf): Implement.
2017-08-01 13:24:23 +02:00
Jan Nieuwenhuizen 0b60a58809 mescc: Tinycc support: support foo.bar[baz], foo->bar[baz] for struct bar.
* module/language/c99/compiler.mes (struct-field): Use negative
  pointer for struct array fields.
  (expr->accu): support: support foo.bar[baz], foo->bar[baz] for struct bar.
* scaffold/tests/7c-dynarray.c: Test it.
2017-08-01 11:26:00 +02:00
Jan Nieuwenhuizen 1e37c9d9ea mescc: Tinycc support: ((foo*) p) + n.
* module/language/c99/compiler.mes init-declr->pointer, expr->pointer,
  expr->size): support: ((foo*) p) + n.
  (expr->accu*): Consider field size for foo.bar[baz].
* scaffold/tests/7b-struct-int-array.c: Test it.
* make.scm (add-scaffold-test): Build it.
2017-07-31 12:19:23 +02:00
Jan Nieuwenhuizen edb6bbcd9c mescc: Tinycc support: field size of foo.bar[baz], foo->bar[baz].
Inspired by a patch from rain1 for foo->bar[baz].

* module/language/c99/compiler.mes (expr->accu):
  (expr->accu*): Consider field size for foo.bar[baz].
* scaffold/tests/7a-struct-char-array.c: Test it.
* make.scm (add-scaffold-test): Build it.
2017-07-30 18:04:25 +02:00
rain1 ae9ce4e645 mescc: allow complicated enums expressions.
* module/language/c99/compiler.mes (p-expr->number): Support lshift, rshift, ash.
  (enum-def-list->constants): Refactor using p-expr->number.
2017-07-30 08:28:19 -04:00
rain1 3f188d7268 mescc: support \x00 strings in M1.
* module/mes/M1.mes (object->m1): Support \x00 strings.
2017-07-30 08:28:19 -04:00
Jan Nieuwenhuizen 9c4519af8d mescc: Tinycc support: int foo[bar] = {baz,...}.
* scaffold/tests/79-int-array.c: Test it.
* make.scm (add-scaffold-test): Build it.
* module/language/c99/compiler.mes (init-declr->count): New function.
  (decl->info): Support int foo[bar] = {baz,...}.
2017-07-30 08:27:05 +02:00
Jan Nieuwenhuizen bd3ab85e98 mescc: Tinycc support: union.struct.
* module/language/c99/compiler.mes (decl->info): Support struct inside union.
* scaffold/tests/78-union-struct.c: Test it.
* make.scm (add-scaffold-test): Build it.
2017-07-29 22:50:00 +02:00
Jan Nieuwenhuizen 042022419e mescc: Tinycc support: fix accu value after comparison.
* stage0/x86.M1 (setg___%al,, setge__%al, setl___%al, setle__%al): New
  defines.
* module/mes/as-i386.mes (i386:g?->accu, i386:ge?->accu,
  i386:l?->accu, i386:le?->accu, i386:jumpl, i386:jumple): New functions.
* module/mes/as-i386.scm: Export them.
* module/language/c99/compiler.mes (expr->accu): Use them to fix accu
  value after comparisons.
  (test-jump-label->info): Update comparison jumps.
2017-07-29 20:46:16 +02:00
Jan Nieuwenhuizen 7d0d3a2221 mescc: Tinycc support: bugfix *++foo,*--foo.
* module/language/c99/compiler.mes (c99-input->full-ast): Pre-define NULL.
  (expr->pointer, expr->size): Handle pre/post-inc/dec.
2017-07-29 10:45:16 +02:00
Jan Nieuwenhuizen f1d9a7a42c mescc: Tinycc support: uniquify strings per compilation unit.
* module/mes/M1.mes (object->M1): Add file-name to string id.
2017-07-29 09:08:44 +02:00
Jan Nieuwenhuizen 683d5bf1d2 mescc: Tinycc support: foo.bar = foo.baz = bla.
* module/language/c99/compiler.mes (expr->base*): New function.
 (expr->accu): Use it to have value in accu for assignments.
* scaffold/tests/77-pointer-assign.c (test): Test it.
* stage0/x86.M1 (mov____%ecx,(%edx), mov___(%eax),%ecx): New define.
* module/mes/as-i386.mes (accu-mem->base->mem): New function.
  (i386:byte-base->accu-mem+n):
  (i386:byte-base->accu-mem):
  (i386:base-mem->accu-mem):
  (i386:base->accu-mem):
  (i386:value->accu-mem+n):
  (i386:value->accu-mem):
  (i386:accu->base-mem+n):
  (i386:byte-accu->base-mem):
  (i386:accu->base-mem): Rename from accu-address, base-address.
  Update callers.
* module/mes/as-i386.scm (mes): Update exports.
2017-07-28 22:45:32 +02:00
Jan Nieuwenhuizen b6375aa016 mescc: Tinycc support: workaround for nyacc "\0" bug.
* module/language/c99/compiler.mes (fix-null): Replace "\nul" with "\0".
  (initzer->data): Use it.
  (expr->global): Use it.
2017-07-28 21:39:39 +02:00
Jan Nieuwenhuizen 03eadd6fa6 mescc: Tinycc support: bugfix foo % bar.
* stage0/x86.M1 (mov____%edx,%ebx): Typo
  (idiv___%ebx): Replace div____%ebx.
* module/mes/as-i386.mes (i386:accu/base): Update.
  (i386:accu%base): Update.
2017-07-28 20:36:21 +02:00
Jan Nieuwenhuizen e102ef94ca mescc: Tinycc support: fix foo[bar]->baz.
* module/language/c99/compiler.mes (expr->accu*): Lose one indirection.
* scaffold/tests/72-typedef-struct-def.c: Test it.
2017-07-29 08:37:34 +02:00
Jan Nieuwenhuizen abd1272a31 mescc: Tinycc support: foo *bar[baz].
* module/language/c99/compiler.mes (decl->info): Support foo *bar[baz].
* module/language/c99/compiler.mes (push-global): Support push of -2,
  -1.  Change signature to take info.  Update callers.
  (push-global-address): Change signature to take info.  Update callers.
2017-07-28 18:04:39 +02:00
Jan Nieuwenhuizen 73148c6f78 mescc: Tinycc support: bugfix foo[bar] = baz, with foo*[].
* module/language/c99/compiler.mes (expr->accu): Support size for more expressions.
  (expr->pointer):
  (expr->size): Support more expressions.
* scaffold/tests/77-pointer-assign.c (add0): Test it.
2017-07-28 18:00:46 +02:00
Jan Nieuwenhuizen 17e0e0cab7 mescc: Tinycc support: bugfix *foo = bar.
* module/language/c99/compiler.mes (base->ident-address): Typo, fixes (non-char*)*x = y.
* scaffold/tests/77-pointer-assign.c (test): Test it.
2017-07-28 15:45:22 +02:00
Jan Nieuwenhuizen 2e0c1c0aff mescc: Tinycc support: bugfix *(cast)foo = bar.
* module/language/c99/compiler.mes (expr->accu): Thinko for de-ref assign.
* stage0/x86.M1: Fix typos.
* module/mes/as-i386.mes: Update for typos.
* scaffold/tests/77-pointer-assign.c: Test it.
* make.scm (add-scaffold-test): Build it.
2017-07-28 15:27:25 +02:00
Jan Nieuwenhuizen c7547dfd52 mescc: Tinycc support: pointer arithmetic.
* module/language/c99/compiler.mes (ident->size, expr->size): New function.
  (expr->accu): Use them for ++,--,add, sub.
  (i386:type-alist): Set void size to 1.
* scaffold/tests/71-struct-array.c (test):
* scaffold/tests/76-pointer-arithmetic.c: Test it.
* make.scm (add-scaffold-test): Build it.
2017-07-28 10:40:30 +02:00
Jan Nieuwenhuizen ce980c8239 mescc: Tinycc support: compile tcc with TCC_IS_NATIVE.
* mlibc/include/string.h (strcat): Declare.
* mlibc/libc-mes+tcc.c (dlclose, dlopen, mprotect, sigaction,
  sigemptyset, strcat, vfprintf): Move from libc-gcc+tcc.c.
* mlibc/libc-gcc+tcc.c: Remove them.
* module/language/c99/compiler.mes (c99-input->full-ast): Define __i386__=1.
  (i386:type-alist): Parse `long long int', `unsigned short int',
  `unsigned long long int'.
  (struct-field): Support void**.
  (init-declr->name):
  (init-declr->pointer): Support function declaration.
2017-07-28 08:07:41 +02:00
Jan Nieuwenhuizen 28f056fdde mescc: bump default maximum for M1-strings to 80.
* module/mes/M1.mes (object->M1): bump default maximum for M1-strings to 80.
2017-08-26 13:40:30 +02:00
Jan Nieuwenhuizen c52b16daf5 mescc: Bugfix: output M1-strings if possible.
* module/mes/M1.mes (object->M1): Typo.  Also disallow \return in M1-strings.
2017-07-27 00:02:54 +02:00
Jan Nieuwenhuizen e1e8f03735 doc: Release udpate.
* HACKING: Update.
* INSTALL: Update.
* NEWS: Update.
* README: Update.
* doc/ANNOUNCE-0.9: New file.
* make.scm: Install it.
* guix.scm (mescc-tools): Bump to 0.2.
2017-07-26 15:57:38 +02:00
Jan Nieuwenhuizen 4b1de28449 build: Install and installed-run fixes.
* guile/mescc.scm (%datadir,%docdir,%moduledir,%version): Remove.
* scripts/mescc.mes: Likewise.
* module/language/c99/compiler.mes: Likewise.
 (%prefix): Prefer environment setting.
 (c99-input->full-ast): Remove unnecessary includes.
 Remove unnecessary defines.
* make.scm (%scm-files): Add mes/guile.scm.
 (src/mes.gcc, src/mes.mlibc-gcc, src/mes.guile):  Update  MODULEDIR,
 add -I src.
* src/mes.c (load_env): Use temporary variable for MODULEDIR concatenation.
  (bload_env): Likewise.
2017-07-26 15:57:38 +02:00
Jan Nieuwenhuizen b7cc9d375d mescc: Tinycc support: bugfix struct.array.
* module/language/c99/compiler.mes (struct-field): Update pointer
  info.
  (field:name,field:pointer,field:size,field:type): Rely on pointer
  info.
  (field:pointer): New function.
 (expr->accu): Use it.
* scaffold/tests/71-struct-array.c (test): Test it.
2017-07-26 11:36:45 +02:00
Jan Nieuwenhuizen d2f701b825 mescc: Tinycc support: bugfix struct pointer.
* module/language/c99/compiler.mes (decl->info): Only set non-pointer struct to -1.
* scaffold/tests/23-pointer.c (test): Test it.
2017-07-26 11:36:45 +02:00
Jan Nieuwenhuizen 10e65b35ce mescc: Tinycc support: more function stack space.
* module/mes/as-i386.mes (function-locals): Increase local space from
  64 (16 vars) to 2*1025 + 80 (20 vars).
2017-07-26 11:36:45 +02:00
Jan Nieuwenhuizen 7e795763f3 mescc: Tinycc support: bugfix for char **pp = *p.
* module/language/c99/compiler.mes (ptr-declr->pointer): Grok ***.
  (decl->info): Bugfix for char **pp = *p, cleanup.
* mlibc/libc-mes.c (getenv): Update for bugfix.
* scaffold/tests/23-pointer.c (test): Test it.
2017-07-26 11:36:45 +02:00
Jan Nieuwenhuizen a13b2ad28c mescc: Tinycc support: function parameters.
* module/language/c99/compiler.mes (.name): Handle function parameters.
2017-07-26 11:36:45 +02:00
Jan Nieuwenhuizen 97164b473d mescc: Tinycc support: jump 32.
* module/mes/as-i386.mes (i386:jump-byte-z): Use jne32 (was: jne8).
2017-07-26 11:36:45 +02:00
Jan Nieuwenhuizen ee4471058f mescc: Tinycc support: arithmetic in initializes.
* module/language/c99/compiler.mes (p-expr->number): Handle
  bitwise-or, constants.
  (initzer-data): Refactor, use p-expr->number.
2017-07-26 11:36:44 +02:00
Jan Nieuwenhuizen accf4159a4 mescc: Tinycc support: multi-byte [local] offsets.
* stage0/x86.M1: Add 32bit variants for all 8bit instructions.
* module/mes/as-i386.mes: Use them, switch on size.
2017-07-26 11:36:44 +02:00
Jan Nieuwenhuizen af626da19a mescc: Naming fix.
* stage0/x86.M1 (je8): Rename from jne8.
* module/mes/as-i386.mes (i386:jump-byte-z): Update.
2017-07-26 11:36:44 +02:00
Jan Nieuwenhuizen 31758dd03c mescc: Tinycc support: remove warnings for foo (void), foo (...).
* module/language/c99/compiler.mes (.name, .type): Expect foo (void), foo (...).
2017-07-26 11:36:44 +02:00
Jan Nieuwenhuizen 4ec2532ad5 mescc: Tinycc support: multiple statements in default case.
* module/language/c99/compiler.mes (clause->info): Support multiple
  statements in default case.
2017-07-26 11:36:44 +02:00
Jan Nieuwenhuizen a7a3de05f6 mescc: Tinycc support: array[<const-expr>].
* module/language/c99/compiler.mes (p-expr->number): New function.
  (struct-field, decl->info): Use it to support const expressions in array size.
2017-07-26 11:36:44 +02:00
Jan Nieuwenhuizen d1a7527eaf mescc: Use "tag" for tag namespace.
* module/language/c99/compiler.mes: Use "tag" for tag namespace (WAS: "struct").
  Move enums to "tag" namespace.
2017-07-26 11:36:44 +02:00
Jan Nieuwenhuizen 2756dd9071 mescc: Tinycc support: sizeof (struct.field).
* module/language/c99/compiler.mes (expr->accu): Support sizeof (struct.field).
2017-07-26 11:36:08 +02:00
Jan Nieuwenhuizen 1d996c7131 mescc: Tinycc support: struct.union.
* module/language/c99/compiler.mes (struct-field): Add struct tag to
  struct/union types.
  (field-type, field-size, field-offset, field-field, ast-type->type):
  Ascertain struct tag with type.
* (expr->accu*): Do not add struct tag.
* scaffold/tests/75-struct-union.c: Test it.
* scaffold/tests/71-struct-array.c: Update.
2017-07-26 11:36:08 +02:00
Jan Nieuwenhuizen 1c01a65d8b mescc: Tinycc support: sizeof ("foo").
* module/language/c99/compiler.mes (expr->accu): Support sizeof (string).
2017-07-26 11:36:08 +02:00
Jan Nieuwenhuizen ce3233f998 mescc: Tinycc support: struct foo {int bar; int baz} = {0}.
* module/language/c99/compiler.mes (decl->info): struct foo {int bar; int baz} = {0}.
* scaffold/tests/72-typedef-struct-def.c (test):
2017-07-26 11:36:08 +02:00
Jan Nieuwenhuizen dcce4bae8a mescc: Tinycc support: generalize neg.
* module/language/c99/compiler.mes (expr->accu): Generalize neg.
2017-07-26 11:36:08 +02:00
Jan Nieuwenhuizen fd4f4f87be mescc: Tinycc support: >>=, <<=.
* module/language/c99/compiler.mes (expr->accu): Support >>= <<=.
2017-07-26 11:36:08 +02:00
Jan Nieuwenhuizen b44825a035 mescc: Bugfix non-char* *x x[] test.
* module/language/c99/compiler.mes (expr->pointer): New function.
  (test-jump-label->info): Use it to fix non char* while (*x | x[i]).
2017-07-26 11:36:08 +02:00
Jan Nieuwenhuizen 3af652a4d0 mescc: Tinycc support: foo[i].bar.baz.
* module/language/c99/compiler.mes (init-declr->pointer): Use -1 for array.
 (expr->accu): Implement foo[i].bar.baz.
* scaffold/tests/72-typedef-struct-def.c (test): Test it.
2017-07-26 11:36:08 +02:00
Jan Nieuwenhuizen 137547afa7 mescc: Tinycc support: *global =.
* module/language/c99/compiler.mes (base->ident-address):
  Support *global = ...
* scaffold/tests/74-multi-line-string.c: Test it.
2017-07-26 11:36:08 +02:00
Jan Nieuwenhuizen 73726b2e27 mescc: Tinycc support: anonymous union.
* module/language/c99/compiler.mes (field:name): New function.
  (decl->info): Use it.
  (struct-field): Support anonymous union.
  (field:size): Update.
  (field-field): Update.
  (field-offset): Update.
2017-07-26 11:36:08 +02:00
Jan Nieuwenhuizen ef4868eb13 mescc: Tinycc support: ignore [ULL], UL, LL, L.
* module/language/c99/compiler.mes (cstring->number): Drop suffix.
2017-07-26 11:36:08 +02:00
Jan Nieuwenhuizen eff1e97cdf mescc: Tinycc support: ~, ^=.
* module/mes/as-i386.mes (i386:accu-not): New function.
  (i386:accu-negate): Rename from i386:accu-not.
* module/mes/as-i386.scm (mes): Export them.
* module/language/c99/compiler.mes (expr->accu): Support ~, ^=.
* scaffold/tests/60-math.c (test): Test it.
* stage0/x86.M1 (not____%eax): New define.
2017-07-26 11:36:08 +02:00