Commit Graph

544 Commits

Author SHA1 Message Date
Daniel Glöckner
deb410710c Rewrote '?' for constants
The condition is now cast to _Bool and it now works with return
types bigger than 32 bit.
2008-11-30 07:21:42 +01:00
Daniel Glöckner
1b599ea7f8 Cast parameter of '!' to _Bool 2008-11-30 07:21:35 +01:00
Daniel Glöckner
2d9b5e0bb8 Rewrote casts
Casting of constants was done only inside functions.
I restructured the code and used intermediate types (long double/long long)
for most conversions to have less ifs.

Please review.
There are lots of cases to take care of and lots of mistakes to make.
2008-11-30 07:21:30 +01:00
grischka
83466c6151 line-numbers output for TCC -E 2008-11-30 07:21:01 +01:00
grischka
78f288bc87 win32/build-tcc.bat: define CONFIG_SYSROOT 2008-11-30 03:16:43 +01:00
grischka
7bebf1f59a was hash, not link 2008-09-15 02:07:55 +02:00
grischka
7f51aa13e7 update changelog 2008-09-15 00:12:10 +02:00
Daniel Glöckner
a80acab4fc Display error on statement expressions with complex return type
The return type of a statement expression (a GCC extention) may
involve elements on the symbol stack that have been put there by
the expression. These will be freed at the end of the expression
so that the calling block can not use them.

Contrary to the comment (written in 2003), this bug no longer shows
up in Valgrind, as freed symbols are now put onto a stack for later
reuse.
2008-09-12 22:23:02 +02:00
Daniel Glöckner
3783b33508 Fix bitfields with non-int types and in unions
The ISO C draft allow only signed/unsigned int and _Bool as base type
for bitfields. TinyCC ever since allowed a wider range of types, but
there were many bugs that shifted values when they shouldn't, etc..
The patch introduces a restriction to the layout of bitfields with
mixed types that makes it incompatible with GCC. In

struct {
  typeA x:1;
  typeB y:1;
};

y is combined with x in the same byte iff typeA is typeB (neglecting
signedness). This is done to avoid alignment issues and exceeding the
width of typeA.
2008-09-12 22:23:01 +02:00
Daniel Glöckner
43a34d354a Force null pointer exception for code outside of a function
TinyCC sometimes has problems to evaluate constant expressions at
compile time. This leads to code being generated outside of functions.
Without this patch some of these bugs are not caught, because
cur_text_section still points to the section of the last function.
Before the first function cur_text_section is uninitialized.
Setting cur_text_section to a null pointer should make TinyCC die in
all cases.
2008-09-12 22:23:00 +02:00
Daniel Glöckner
5a92536cea Optimize arithmetic with pointer to value on stack + constant 2008-09-12 22:23:00 +02:00
Daniel Glöckner
e263ee3cbf Fix gv for long longs
long long a();
long long b() {
  return a();
}

At the end of b there will be some useless register shuffling.
This is because return wants to have the result of a in REG_IRET.
gv checks if this is the case for BOTH registers of the long long.
After this test it uses REG_LRET for the second register if the
first is supposed to be REG_IRET. In other cases it uses RC_INT.

The patch compares the second register against the class it will
have in the end instead of the register class the first register
will have.

At this point I would like to remind those who pick up the patches
that there are two other mails by me with uncommitted fixes:
http://lists.gnu.org/archive/html/tinycc-devel/2003-10/msg00044.html
http://lists.gnu.org/archive/html/tinycc-devel/2008-08/msg00007.html

  Daniel
2008-09-12 22:22:59 +02:00
Daniel Glöckner
15e0dc08a6 Allow to use libgcc instead of libtcc1
This patch adds a switch --with-libgcc to configure.
When passed it prevents libtcc1.a from being built and links to
/lib/libgcc_s.so.1 instead of PREFIX/lib/tcc/libtcc1.a.

It will work on ARM when using libgcc from GCC >= 4.2.0.
Prior versions don't have the __floatun[sd]i[sdx]f functions.

It won't work on i386 because of two missing symbols emitted when
floats are cast to integers, but users can provide those symbols
(global short constants) in their code if needed.

  Daniel
2008-09-12 22:22:58 +02:00
Daniel Glöckner
256f6e6200 A prefix for default library/include search paths
This patch is useful for cross compilers. Without this patch tcc
tries to use the host's libraries, crt*.o and include files.
The patch prepends a string to all default paths. The string can
be passed to configure with --sysroot=string.

  Daniel
2008-09-12 22:22:58 +02:00
Daniel Glöckner
e8039673ad ARM related Makefile changes
- Builds all four possible ARM targets when cross compiling

- Adds some auto detection to select the target for native ARM builds

The auto detection will select EABI if it finds /lib/ld-linux.so.3.
It will select VFP floating point support when /proc/cpuinfo lists
a VFP or iWMMXt coprocessor. Intel Wireless MMX does not imply VFP,
but it conflicts with FPA, so VFP is the only choice (apart from
yet unsupported soft-float).

  Daniel
2008-09-12 22:22:57 +02:00
Daniel Glöckner
12265da6cd Runtime lib functions
Yesterday I felt the urge to change a few things in TinyCC.
This is the first and biggest change of all of them.

- use __aeabi_*divmod functions in ARM EABI to make binaries depend
  solely on standardized library functions

- refactor ARM floating point <-> integer conversion a bit

- rename long long->float and shift library functions to correspond to
  the names used by GCC

- compile more tokens conditionally to reduce the size of TinyCC

The intention is primarily to allow users of the ARM target to use
libgcc (which is usually available as a shared library) instead of
libtcc1 (which can't be compiled for ARM due to lack of an inline
assembler).

Changing the EABI target to use the divmod functions in theory allows
to use it without libtcc1 on any (not necessarily GCC based) ARM EABI
system.

  Daniel
2008-09-12 22:22:36 +02:00
Daniel Glöckner
2c657f6608 Set VT_LVAL_xxx flags for function arguments in gfunc_prolog (Daniel Glöckner) 2008-09-12 02:36:32 +02:00
Adam Sampson
8f7e3f325d Patch for DESTDIR installation (Adam Sampson) 2008-09-12 02:36:26 +02:00
grischka
2c6cd08bcc fix isidnum_table for CH_EOF (-1) 2008-09-12 02:36:05 +02:00
grischka
1300cec38c free_section bugfix 2008-09-12 02:36:01 +02:00
grischka
f9bf48d643 release loaded dlls cleanly (Sam K) 2008-05-05 22:40:49 +00:00
grischka
96bd8f2b25 enable pe-output from libtcc (Shmuel Zeigerman) 2008-05-05 22:39:43 +00:00
grischka
f2698687fb fix options in C scripts after -run 2008-04-27 18:50:35 +00:00
grischka
5247bbc2f0 fix stabstr with linked objects 2008-04-27 18:49:31 +00:00
grischka
0d598aca08 fix bogus relocations with TCC_OUTPUT_DLL 2008-04-27 18:48:19 +00:00
grischka
23594b6980 enable multiple states and fix minor memory leaks 2008-04-27 18:47:35 +00:00
grischka
f22e961f80 update manual, changelog 2008-03-31 19:50:58 +00:00
grischka
a327c7a552 added verbosity levels (-vv -vvv) 2008-03-31 19:49:14 +00:00
grischka
4d9aaacc85 Accept standard input as an inputstream (Hanzac Chen) 2008-03-31 18:42:56 +00:00
grischka
cd24bd05b4 get rid of a warning and fix .bat 2008-03-25 21:05:48 +00:00
grischka
9bcc0b970b Add -soname linker option (Marc Andre Tanner) 2008-03-25 21:04:47 +00:00
grischka
88b3cb570e Comply to c89 compilers other than gcc (Hanzac Chen) 2008-03-25 20:58:37 +00:00
grischka
6ed868c51c Enable -B option for library path on win32 2008-03-08 20:00:56 +00:00
grischka
e2c89576c7 Fix 'tcc -static' with recent glibc 2008-03-08 19:58:57 +00:00
grischka
c6537d11cb Get rid of one warning 2008-03-08 19:57:26 +00:00
grischka
2eaa1104f7 Checkin tiny_libmaker (ar replacement) by Timovj Lahde 2008-03-08 19:55:47 +00:00
grischka
265dddbecf Udated and cleaned up TODO. 2008-01-16 22:33:56 +00:00
grischka
3667408a57 Just warn about unknown directives, define __STDC_VERSION__=199901L 2008-01-16 20:16:35 +00:00
grischka
5342b32eef Switch to newer tccpe.c (includes support for resources) 2007-12-19 17:36:42 +00:00
grischka
adb1456472 Handle backslashes within #include, #error, #warning 2007-12-17 19:35:15 +00:00
grischka
6c96c41ee4 Import changesets (part 4) 428,457,460,467: defines for openbsd etc. 2007-12-16 18:24:44 +00:00
grischka
f466577673 Disable singnedness warnings with newer gcc. 2007-12-13 19:17:45 +00:00
grischka
34140dd627 Use _WIN32 for a windows hosted tcc and define it for the PE target. 2007-12-13 19:07:19 +00:00
grischka
b0d40c12da tiny_impdef.c - converted to LF line-endings (and slight cleanup) 2007-12-09 18:55:18 +00:00
grischka
f99d3de221 Import 409,410: ARM EABI by Daniel Glckner 2007-12-04 20:38:09 +00:00
grischka
2de1b2d14c Some in-between fixes (See Changelog for details). 2007-11-25 22:14:35 +00:00
grischka
2bcb964694 Fixed:
- Hanging tcc -E
- Crashes witn global 'int g_i = 1LL;'
- include & lib search paths on win32
Added quick build batch file for mingw
Reverted case label optimization
(See Changelog for details).
2007-11-25 22:13:08 +00:00
grischka
3e8b9e6d10 New files: alloca86.S alloca86-bt.S 2007-11-23 00:03:03 +00:00
grischka
d778bde7f9 Import more changesets from Rob Landley's fork (part 2) 2007-11-21 17:16:31 +00:00
grischka
54bf8c0556 Import some changesets from Rob Landley's fork (part 1) 2007-11-14 17:34:30 +00:00