Commit Graph

107 Commits

Author SHA1 Message Date
Thomas Preud'homme
4760804dba Fix fct param passing of struct with size < 4 2014-02-03 11:13:42 +08:00
Thomas Preud'homme
9fc57302f8 Switch float abi to softfp for int <--> float conv
This improves commit 5cbe03b9c4 by
avoiding a double transfer when the default float ABI is already softfp.
It's also more clean by expliciting that the ABI is simply changed for
runtime ABI functions.
2014-02-02 20:29:24 +08:00
Thomas Preud'homme
5cbe03b9c4 Move result of itof double conv back to VFP reg
EABI functions to convert an int to a double register take the integer
value in core registers and also give the result in core registers.
It is thus necessary to move the result back to VFP register after the
function call. This only affected integer to double conversion because
integer to float conversion used a VFP instruction to do the conversion
and this obviously left the result in VFP register. Note that the
behavior is left untouched for !EABI as the correct behavior in this
case is unknown to the author of this patch.
2014-02-01 14:25:13 +08:00
Michael Matz
9c6ddbfe90 Fix compile on ARM non-eabi and non-vfp
Adjust arm_init prototype to match declaration.
2014-01-11 23:44:41 +01:00
Thomas Preud'homme
b6247d1f3c Add support for runtime selection of float ABI 2014-01-08 15:00:52 +08:00
Thomas Preud'homme
70a088af87 Explicit that EABI only supports VFP for now 2014-01-07 23:20:31 +08:00
Thomas Preud'homme
8efaa71190 Fix struct ret in variadic fct with ARM hardfloat
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().
2014-01-06 22:57:05 +08:00
Thomas Preud'homme
eda2c756ed 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.
2014-01-04 21:10:05 +08:00
Thomas Preud'homme
389c25c4b9 Support special calling convention for runtime ABI
Add infrastructure to support special calling convention for runtime ABI
function no matter what is the current calling convention. This involve
2 changes:
- behave as per base standard in gfunc_call
- move result back in VFP register in gen_cvt_itof1
2013-12-11 10:15:29 +08:00
Thomas Preud'homme
82b257c29c Add comment to explain the code added by 41ce391c
Add a comment in arm-gen.c to explain how commit
41ce391c86 solves the register corruption
when passing a structure in a function call.
2013-11-25 11:00:51 +08:00
Thomas Preud'homme
48fc746652 Fix structure passing in ARM calling convention
Fix the address on stack where a structure is copied when it is a
parameter of a function call. This address must be computed from the
stack pointer and a possible padding offset.
2013-11-25 10:58:00 +08:00
Thomas Preud'homme
dcec8673f2 Add support for struct > 4B returned via registers
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.
2013-11-22 09:27:15 +08:00
Thomas Preud'homme
d9d60a1ebd Remove code in arm-gen.c for struct packing in reg
Struct packing in register is now handled since commit 2bbfaf43 by
tccgen.c proper.
2013-11-22 00:15:34 +08:00
Thomas Preud'homme
63a84713ee Correctly identify homogeneous float aggregate
First related symbol of a structure justs indicate its size. This first
member is the second related symbol.
2013-11-22 00:13:05 +08:00
Thomas Preud'homme
c3e7c725b5 Fix counting of VFP regs in ARM's gfunc_prolog
Fix in gfunc_prolog for ARM the counting of the highest numbered VFP
float register used for parameter passing, rounded to 2. It can be
computed from the range of VFP float register with the highest range
start and adding the number of VFP float register occupied. This ensure
that parameter of type struct that spans over more than 2 float
registers are correctly taken into account.
2013-11-21 22:27:15 +08:00
Thomas Preud'homme
41ce391c86 Fix register corruption at function call on ARM
Prior to this commit, params could use some registers that do not appear
in the value stack. Therefore when generating function call, one of such
register could be reused, leading to wrong parameter content. This
happens when a structure is passed via core register, as only the first
register would appear in the value stack.
2013-11-21 21:09:44 +08:00
Thomas Preud'homme
0c40bc8982 Correctly align and reclaim stack at function call
* Correctly align stack in case of structure split between core
  registers and stack
* Correctly reclaim stack space after function call in the case where
  the stack needed padding to be aligned at function call.
2013-11-17 18:26:56 +08:00
Thomas Preud'homme
1528a08540 Refactor and simplify gfunc_call() on arm 2013-11-15 17:57:31 +08:00
Joseph Poirier
0650ab01c8 struct variable behind guard, proper macro check, and remove some whitespace.
Wrap runtime_main as per its declaration in tcc.h.
Fix preprocessor check for TCC_ARM_EABI macro definition.

Signed-off-by: Joseph Poirier <jdpoirier@gmail.com>
2013-11-08 13:24:15 -06:00
Thomas Preud'homme
b7d017dec8 Fix allocation of struct in registers on ARM
Allocation of struct in core and/or VFP registers on ARM is made by
manipulating the value stack to create 3 distinct zones: parameters
allocated on stack, parameters of type struct allocated in core
registers and parameters of type struct allocated in VFP registers.
Parameters of primitive type can be in any zone. This commit change the
order of the zones from stack, VFP, core to stack, core, VFP (from
highest addresses to lowest ones) in order to correctly deal the
situation when structures are allocated both in core and VFP registers.
2013-11-05 17:50:30 +08:00
Thomas Preud'homme
f6b50558fc Add support for load/store of _Bool value
Add support for loading _Bool value in i386, x86_64 and arm as well as
support for storing _Bool value on arm.
2013-06-14 16:19:51 +02:00
Daniel Glöckner
4d86b20701 ARM hardfloat: fix struct return with float/double args
Fixes the case where the structure is not returned in registers.
2013-05-01 16:17:54 +02:00
James Lyon
41b3c7a507 Improved variable length array support.
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.
2013-04-27 22:58:52 +01:00
James Lyon
55ea6d3fc1 x86-64 ABI fixes.
abitest now passes; however test1-3 fail in init_test. All other tests
pass. I need to re-test Win32 and Linux-x86.

I've added a dummy implementation of gfunc_sret to c67-gen.c so it
should now compile, and I think it should behave as before I created
gfunc_sret.
2013-04-19 00:46:49 +01:00
James Lyon
2bbfaf436f Tests in abitest.c now work on Win32.
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.
2013-04-18 17:27:34 +01:00
Urs Janssen
0bdbd49eac add version number to manpage
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)
2013-02-17 00:48:51 +01:00
grischka
d6d7686b60 tcc.h: declare CValue.tab[LDOUBLE_SIZE/4]
Should fix some warnings wrt. access out of array bounds.

tccelf.c: fix "static function unused" warning
x86_64-gen.c: fix "ctype.ref uninitialzed" warning and cleanup
tcc-win32.txt: remove obsolete limitation notes.
2013-02-08 19:07:11 +01:00
Thomas Preud'homme
6c4d3244da Align on 4n bytes when copying fct args on stack
When copying function arguments on stack in prolog, use multiple of 4
bytes for alignment.
2013-02-05 10:48:42 +01:00
Thomas Preud'homme
f715207249 arm-gen.c: fix var initialization in gfunc_call
Fix initialization of args_size before doing register allocation.
When adding hardfloat calling convention the initialization stopped
being performed when !defined (TCC_ARM_EABI).
2013-02-04 11:01:58 +01:00
Daniel Glöckner
61a4fd1d6e arm: force rounding towards zero on cast to integer with VFP
Cast to integer should not be affected by the current rounding mode
as set by fesetround.
2013-02-04 09:17:01 +01:00
Daniel Glöckner
f7f6025bd1 arm: fix conversion from float/double to signed integer with VFP
The signed flag was not encoded in the instruction.
2013-02-03 23:47:52 +01:00
Daniel Glöckner
506193724f arm: fix conversion from integer to float/double with VFP
The source register was not encoded in the instruction.
2013-02-03 17:51:33 +01:00
grischka
828ccde9fc arm: define TCC_ARM_VERSION for cross compiler 2013-01-30 18:39:36 +01:00
Thomas Preud'homme
6ccee6edb3 Add my copyright for changes in arm-gen.c 2013-01-30 17:34:19 +01:00
Thomas Preud'homme
0f81512d7d Fix stack alignment on 8 bytes at function call
Ensure stack pointer is correctly adjusted in prolog to be aligned on 8
bytes after the change of frame linking.
2013-01-27 01:08:01 +01:00
Thomas Preud'homme
f63c750942 Organize frames in a real linked list on ARM
Change the linking of the frames on ARM. Instead of having fp points 12
bytes above where the old fp is stored, let fp points where the old fp
is stored. That is, we switch from:

|   .    |
|   .    |
|   .    |
|        |
| params | <-- fp
 --------
| oldlr  |
 --------
| oldip  |
 --------
| oldfp  |
 --------

to:

|   .    |
|   .    |
|   .    |
|        |
| params |
 --------
| oldlr  |
 --------
| oldip  |
 --------
| oldfp  | <-- fp
 --------
2013-01-26 20:09:04 +01:00
Thomas Preud'homme
8d90205fd9 Fix OABI calling convention
OABI calling convention was broken since the addition of the hardfloat
calling convention in commit 7f6095bfec.
This commit fixes the breakage.
2012-11-28 22:26:39 +01:00
Thomas Preud'homme
05b02a5581 arm-gen.c: Invalid operator test always false
Invalid operator test is always false in gen_opf for arm (found with
cppcheck). This patch fixes the issue.
2012-11-28 22:26:39 +01:00
Thomas Preud'homme
6eec931038 Only reference vfpr when available
A line in gfunc_call in arm-gen.c is referencing vfpr unconditionally.
Yet, this function is only available when TCC_ARM_VFP is set. While this
code is only triggered when TCC_ARM_VFP, it fails at compile time. This
commit fix the problem.
2012-11-21 12:21:51 +01:00
Thomas Preud'homme
7f6095bfec Add support for arm hardfloat calling convention
See Procedure Call Standard for the ARM Architecture (AAPCS) for more
details.
2012-06-05 23:09:55 +02:00
Thomas Preud'homme
53c5715cca Remove vnrott (duplicate vrotb) 2012-03-14 15:39:16 +01:00
grischka
bf374a5f23 rename error/warning -> tcc_(error/warning) 2011-08-11 17:07:56 +02:00
grischka
5280293d6b make: create native tcc from separate objects
This was already possible using
    make NOTALLINONE=1
and is now the default.

To build as previously from one big source, use
    make ONE_SOURCE=1

Cross compilers are still build from one source because using
separate objects requires separate build directories one per
platform which currently is not (yet) supported by the makefile.

We could probably use gnu-makeish target variables like
    $(I386_CROSS): OUTDIR=build/i386
    $(X64_CROSS): OUTDIR=build/x86-64
and so on ...

Also NEED_FLOAT_TYPES for arm-gen is removed.  It was about
variables that are referenced from outside (libtcc, tccgen).
We could declare them in tcc.h (as with reg_classes) or have
them twice in arm-gen.c.  I chose option 2.
2011-07-14 18:45:37 +02:00
Daniel Glöckner
28a5b702f4 Fix calling ARM EABI functions returning big structures
The wrong type was tested to determine the size of the structure.
2011-05-17 02:24:45 +02:00
Thomas Preud'homme
66d992d883 Remove unused variables
Declare float type conditionally to not declare them conditionally when
they are not used.
2011-05-16 15:21:25 +02:00
Daniel Glöckner
3de023b6c6 ARM: use uint32_t for opcodes
fixes cross compiling on x86_64
2010-05-13 22:17:09 +02:00
grischka
88a3ccab9f allow tcc be build from separate objects
If you want that, run: make NOTALLINONE=1
2009-12-20 01:53:49 +01:00
Shinichiro Hamaji
5dadff3de5 x86-64: Fix stab debug information.
We need 32bit relocations for code and 64bit for debug info.
Introduce a new macro R_DATA_PTR to distinguish the two usages.
2009-08-24 13:30:03 +02:00
grischka
c998985c74 cleanup: constify some global data 2009-07-18 22:07:42 +02:00
Daniel Glöckner
530b77e365 ARM: fix big immediate offset construction
The loop constructs to iterate over the non-overlapping, even
positions of two or three bytes in a word were broken.

This patch fixes the loops. It has been verified to generate the
72 combinations for two and the 80 combinations for three bytes.
2009-05-11 18:54:14 +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
grischka
f99d3de221 Import 409,410: ARM EABI by Daniel Glckner 2007-12-04 20:38:09 +00:00
bellard
6bbfb8f610 removed warnings 2004-11-07 15:43:15 +00:00
bellard
6e5b1cc43a ARM fixes (Daniel Glockner) 2004-10-04 22:19:21 +00:00
bellard
79c72b2419 initial TMS320C67xx support (TK) 2004-10-04 21:57:35 +00:00
bellard
4df5bd2eb0 ARM target support (Daniel Glockner) - allow unsigned char as default on ARM (Daniel Glockner) - fixed small ld script support (Daniel Glockner) 2003-10-14 22:15:56 +00:00