aboutsummaryrefslogtreecommitdiff
path: root/i386-gen.c
Commit message (Collapse)AuthorAgeFilesLines
* make a bound checking more compatible with Windows 64seyko2015-03-261-7/+7
| | | | | | On Linux 32: sizeof(long)=32 == sizeof(void *)=32 on Linux 64: sizeof(long)=64 == sizeof(void *)=64 on Windows 64: sizeof(long)=32 != sizeof(void *)=64
* Fix stack overwrite on structure returnMichael Matz2015-03-091-1/+2
| | | | | | | | | The common code to move a returned structure packed into registers into memory on the caller side didn't take the register size into account when allocating local storage, so sometimes that lead to stack overwrites (e.g. in 73_arm64.c), on x86_64. This fixes it by generally making gfunc_sret also return the register size.
* partial revert of the commit 4ad186c5ef61seyko2015-03-041-0/+23
| | | | | | | | | | | | | | | A test program: /* result of the new version inroduced in 4ad186c5ef61: t2a = 44100312 */ #include<stdio.h> int main() { int t1 = 176401255; float f = 0.25f; int t2a = (int)(t1 * f); // must be 44100313 int t2b = (int)(t1 * (float)0.25f); printf("t2a=%d t2b=%d \n",t2a,t2b); return 0; }
* A partial reverse for commit eda2c756edc4dca004ba217d5bf361235dd9de1fseyko2015-03-031-1/+1
| | | | | | | | | | | | | | | Author: Thomas Preud'homme <robotux@celest.fr> Date: Tue Dec 31 23:51:20 2013 +0800 Move logic for if (int value) to tccgen.c Move the logic to do a test of an integer value (ex if (0)) out of arch-specific code to tccgen.c to avoid code duplication. This also fixes test of long long value which was only testing the bottom half of such values on 32 bits architectures. I don't understand why if () in gtst(i) was removed. This patch allows to compile a linux kernel v.2.4.26 W/o this patch a tcc simply crashes.
* be stricter with aliasinggrischka2014-01-071-2/+2
| | | | | | | | | | | | | | Refactoring (no logical changes): - use memcpy in tccgen.c:ieee_finite(double d) - use union to store attribute flags in Sym Makefile: "CFLAGS+=-fno-strict-aliasing" basically not necessary anymore but I left it for now because gcc sometimes behaves unexpectedly without. Also: - configure: back to mode 100755 - tcc.h: remove unused variables tdata/tbss_section - x86_64-gen.c: adjust gfunc_sret for prototype
* i386: use __fixdfdi instead of __tcc_cvt_ftolgrischka2014-01-061-16/+12
| | | | | | | | | | | | Variants __fixsfdi/__fixxfdi are not needed for now because the value is converted to double always. Also: - remove __tcc_fpinit for unix as it seems redundant by the __setfpucw call in the startup code - avoid reference to s->runtime_main in cross compilers - configure: fix --with-libgcc help - tcctok.h: cleanup
* Fix struct ret in variadic fct with ARM hardfloatThomas Preud'homme2014-01-061-1/+2
| | | | | | | | | | | | | The procedure calling standard for ARM architecture mandate the use of the base standard for variadic function. Therefore, hgen float aggregate must be returned via stack when greater than 4 bytes and via core registers else in case of variadic function. This patch improve gfunc_sret() to take into account whether the function is variadic or not and make use of gfunc_sret() return value to determine whether to pass a structure via stack in gfunc_prolog(). It also take advantage of knowing if a function is variadic or not move float result value from VFP register to core register in gfunc_epilog().
* Don't call __tcc_fpinit if using libgccThomas Preud'homme2014-01-061-0/+2
|
* Move logic for if (int value) to tccgen.cThomas Preud'homme2014-01-041-18/+1
| | | | | | | Move the logic to do a test of an integer value (ex if (0)) out of arch-specific code to tccgen.c to avoid code duplication. This also fixes test of long long value which was only testing the bottom half of such values on 32 bits architectures.
* Report error on NaN comparisonThomas Preud'homme2014-01-031-1/+4
| | | | | | | | Use comisd / fcompp for float comparison (except TOK_EQ and TOK_NE) instead of ucomisd / fucompp to detect NaN comparison. Thanks Vincent Lefèvre for the bug report and for also giving the solution.
* Fix "Add support for struct > 4B returned via registers"grischka2013-12-161-1/+1
| | | | | | | | | | | - avoid assumption "ret_align == register_size" which is false for non-arm targets - rename symbol "sret" to more descriptive "ret_nregs" This fixes commit dcec8673f21da86ae3dcf1ca3e9498127715b795 Also: - remove multiple definitions in win32/include/math.h
* Add support for struct > 4B returned via registersThomas Preud'homme2013-11-221-4/+5
| | | | | | | | On ARM with hardfloat calling convention, structure containing 4 fields or less of the same float type are returned via float registers. This means that a structure can be returned in up to 4 double registers in a structure is composed of 4 doubles. This commit adds support for return of structures in several registers.
* i386-gen: preserve fp control word in gen_cvt_ftoigrischka2013-08-281-63/+28
| | | | | | | | | | | | | | | | | | | | | | | - Use runtime function for conversion - Also initialize fp with tcc -run on windows This fixes a bug where double x = 1.0; double y = 1.0000000000000001; double z = x < y ? 0 : sqrt (x*x - y*y); caused a bad sqrt because rounding precision for the x < y comparison was different to the one used within the sqrt function. This also fixes a bug where printf("%d, %d", (int)pow(10, 2), (int)pow(10, 2)); would print 100, 99 Unrelated: win32: document relative include & lib lookup win32: normalize_slashes: do not mirror silly gcc behavior This reverts part of commit 8a81f9e1036637e21a47e14fb56bf64133546890 winapi: add missing WINAPI decl. for some functions
* Add support for load/store of _Bool valueThomas Preud'homme2013-06-141-1/+1
| | | | | Add support for loading _Bool value in i386, x86_64 and arm as well as support for storing _Bool value on arm.
* avoid "decl after statement" pleasegrischka2013-04-301-2/+5
| | | | for compiling tcc with msc
* Improved variable length array support.James Lyon2013-04-271-0/+39
| | | | | | | | | | | | | | | VLA storage is now freed when it goes out of scope. This makes it possible to use a VLA inside a loop without consuming an unlimited amount of memory. Combining VLAs with alloca() should work as in GCC - when a VLA is freed, memory allocated by alloca() after the VLA was created is also freed. There are some exceptions to this rule when using goto: if a VLA is in scope at the goto, jumping to a label will reset the stack pointer to where it was immediately after the last VLA was created prior to the label, or to what it was before the first VLA was created if the label is outside the scope of any VLA. This means that in some cases combining alloca() and VLAs will free alloca() memory where GCC would not.
* Fixed i386 calling convention issue and CMake build on i386.James Lyon2013-04-261-0/+8
| | | | | The i386 calling convention expects the callee to pop 1 word of the stack when performing a struct ret.
* Tests in abitest.c now work on Win32.James Lyon2013-04-181-8/+27
| | | | | | | I expect that Linux-x86 is probably fine. All other architectures except ARM are definitely broken since I haven't yet implemented gfunc_sret for these, although replicating the current behaviour should be straightforward.
* add version number to manpageUrs Janssen2013-02-171-1/+1
| | | | | | | avoid c++/c99 style comments in preprocessor directives avoid leadings whitespaces in preprocessor directives mention implemented variable length arrays in documentation fixed ambiguous option in texi2html call (Austin English)
* i386: We can change 'lea 0(%ebp),r' to 'mov %ebp,r'Kirill Smelkov2012-11-161-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Because that mov is 1 byte shorter, look: int *func() { return __builtin_frame_address(0); } before patch: 00000000 <func>: 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 81 ec 00 00 00 00 sub $0x0,%esp 9: 8d 45 00 lea 0x0(%ebp),%eax // <- here c: e9 00 00 00 00 jmp 11 <func+0x11> 11: c9 leave 12: c3 ret after patch: 00000000 <func>: 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 81 ec 00 00 00 00 sub $0x0,%esp 9: 89 e8 mov %ebp,%eax // <- here b: e9 00 00 00 00 jmp 10 <func+0x10> 10: c9 leave 11: c3 ret
* i386: fix loading of LLOCAL floatsDaniel Glöckner2012-01-231-1/+3
| | | | These loads clobbered ebx as TinyCC wanted to load the address into st0.
* s/derefencing/dereferencing/ in i386-gen.cThomas Preud'homme2012-01-081-1/+1
|
* rename error/warning -> tcc_(error/warning)grischka2011-08-111-1/+1
|
* chmod a-x i386-gen.cKirill Smelkov2010-06-161-0/+0
| | | | No need to keep executable bit on plain C source.
* generate inc and dec for smaller codeU-UNIT1\dennis2010-04-031-4/+10
|
* tccpe: improve dllimport/export and use for tcc_add_symbolgrischka2010-01-141-4/+6
|
* allow tcc be build from separate objectsgrischka2009-12-201-34/+44
| | | | If you want that, run: make NOTALLINONE=1
* win32: enable bounds checker & exception handlergrischka2009-12-191-1/+5
| | | | exception handler borrowed from k1w1. Thanks.
* fix uninitialized warnings with 'type.ref'grischka2009-12-191-0/+1
|
* tccpe: improve dllimportgrischka2009-12-191-29/+2
|
* integrate x86_64-asm.c into i386-asm.cgrischka2009-12-191-0/+13
| | | | | Also, disable 16bit support for now as it causes bugs in 32bit mode. #define I386_ASM_16 if you want it.
* win32: handle __declspec(dllimport)grischka2009-11-131-0/+34
|
* x86-64: Fix stab debug information.Shinichiro Hamaji2009-08-241-0/+1
| | | | | We need 32bit relocations for code and 64bit for debug info. Introduce a new macro R_DATA_PTR to distinguish the two usages.
* cleanup: constify some global datagrischka2009-07-181-1/+1
|
* win32: structure return GCC compatible (ret 4 with cdecl)grischka2009-06-171-0/+11
|
* move some global variables into TCCStategrischka2009-05-111-2/+3
|
* Set VT_LVAL_xxx flags for function arguments in gfunc_prolog (Daniel Glöckner)Daniel Glöckner2008-09-121-1/+1
|
* Switch to newer tccpe.c (includes support for resources)grischka2007-12-191-3/+3
|
* Bug fix: A long long value used as a test expression ignores the upper 32 ↵bellard2006-10-281-1/+2
| | | | bits at runtime (Dave Dodge)
* windows style fastcall (Filip Navara)bellard2005-09-031-4/+19
|
* _Bool type fixbellard2005-04-171-1/+1
|
* __chkstk supportbellard2005-04-101-5/+32
|
* copyright updatebellard2004-10-271-1/+1
|
* primitive fastcall functions supportbellard2004-10-181-9/+46
|
* faster (Daniel Glöckner)bellard2004-10-041-2/+2
|
* initial TMS320C67xx support (TK)bellard2004-10-041-0/+1
|
* ARM target support (Daniel Glockner) - allow unsigned char as default on ↵bellard2003-10-141-1/+11
| | | | ARM (Daniel Glockner) - fixed small ld script support (Daniel Glockner)
* changed license to LGPLbellard2003-05-241-12/+12
|
* simpler function call APIbellard2003-04-161-70/+58
|
* renamed registersbellard2002-12-081-18/+18
|