aboutsummaryrefslogtreecommitdiff
path: root/arm-gen.c
Commit message (Collapse)AuthorAgeFilesLines
* configure: --config-musl/-uClibc switch & misc cleanupsgrischka2017-05-131-6/+2
| | | | | | | | | | | | | | | - configure: - add --config-uClibc,-musl switch and suggest to use it if uClibc/musl is detected - make warning options magic clang compatible - simplify (use $confvars instead of individual options) - Revert "Remove some unused-parameter lint" 7443db0d5f841b81a55e918bf8c228dd20f9ddb2 rather use -Wno-unused-parameter (or just not -Wextra) - #ifdef functions that are unused on some targets - tccgen.c: use PTR_SIZE==8 instead of (X86_64 || ARM64) - tccpe.c: fix some warnings - integrate dummy arm-asm better
* C string litteral is const, fix return type of default_elfinterp. Remove ↵Christian Jullien2017-05-081-3/+3
| | | | #ifndef TCC_IS_NATIVE in arm-gen.c as suggested by grischka.
* Spelling fixes in C comments onlyLarry Doolittle2017-05-071-3/+3
|
* more minor fixesgrischka2017-05-071-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | * tccgen: re-allow long double constants for x87 cross sizeof (long double) may be 12 or 16 depending on host platform (i386/x86_64 on unix/windows). Except that it's 8 if the host is on windows and not gcc was used to compile tcc. * win64: fix builtin_va_start after VT_REF removal See also a8b83ce43a95fa519dacfe7690a3a0098af7909c * tcctest.c: remove outdated limitation for ll-bitfield test It always worked, there is no reason why it should not work in future. * libtcc1.c: exclude long double conversion on ARM * Makefile: remove CFLAGS from link recipes * lib/Makefile: use target DEFINES as passed from main Makefile * lib/armflush.c lib/va_list.c: factor out from libtcc1.c * arm-gen.c: disable "depreciated" warnings for now
* cross-compilers: allow individual configurationgrischka2017-02-231-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | since configure supports only native configuration a file 'cross-tcc.mak' needs to be created manually. It is included in the Makefile if present. # ---------------------------------------------------- # Example config-cross.mak: # # windows -> i386-linux cross-compiler # (it expects the linux files in <prefix>/i386-linux) ROOT-i386 = {B}/i386-linux CRT-i386 = $(ROOT-i386)/usr/lib LIB-i386 = $(ROOT-i386)/lib:$(ROOT-i386)/usr/lib INC-i386 = {B}/lib/include:$(ROOT-i386)/usr/include DEF-i386 += -D__linux__ # ---------------------------------------------------- Also: - use libtcc1-<target>.a instead of directories - add dummy arm assembler - remove include dependencies from armeabi.c/lib-arm64.c - tccelf/ld_add_file: add SYSROOT (when defined) to absolute filenames coming from ld-scripts
* fixes & cleanupsgrischka2017-02-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - tccgen.c/tcc.h: allow function declaration after use: int f() { return g(); } int g() { return 1; } may be a warning but not an error see also 76cb1144ef91924c53c57ea71e6f67ce73ce1cc6 - tccgen.c: redundant code related to inline functions removed (functions used anywhere have sym->c set automatically) - tccgen.c: make 32bit llop non-equal test portable (probably not on C67) - dynarray_add: change prototype to possibly avoid aliasing problems or at least warnings - lib/alloca*.S: ".section .note.GNU-stack,"",%progbits" removed (has no effect) - tccpe: set SizeOfCode field (for correct upx decompression) - libtcc.c: fixed alternative -run invocation tcc "-run -lxxx ..." file.c (meant to load the library after file). Also supported now: tcc files ... options ... -run @ arguments ...
* tccgen: nocode_wanted alternativelygrischka2016-12-181-2/+9
| | | | | | | | | | | | | | | tccgen.c: remove any 'nocode_wanted' checks, except in - greloca(), disables output elf symbols and relocs - get_reg(), will return just the first suitable reg) - save_regs(), will do nothing Some minor adjustments were made where nocode_wanted is set. xxx-gen.c: disable code output directly where it happens in functions: - g(), output disabled - gjmp(), will do nothing - gtst(), dto.
* Fix relocs_info declaration in tcc.hThomas Preud'homme2016-12-051-20/+0
| | | | | | | | | C standard specifies that array should be declared with a non null size or with * for standard array. Declaration of relocs_info in tcc.h was not respecting this rule. This commit add a R_NUM macro that maps to the R_<ARCH>_NUM macros and declare relocs_info using it. This commit also moves all linker-related macros from <arch>-gen.c files to <arch>-link.c ones.
* Make build_got_entries more target independentThomas Preud'homme2016-12-031-0/+1
| | | | | Factor most of common logic between targets in build_got_entries by defining target specific info into structures in the backends.
* arm-gen.c: support VLAsDaniel Glöckner2016-10-091-3/+23
|
* arm-gen.c: replace register constants with enum valuesDaniel Glöckner2016-10-091-10/+17
| | | | and support sp in intr
* arm-gen.c: detect long double structures as HFADaniel Glöckner2016-10-081-2/+11
| | | | when long double is equal to double
* tccgen: arm/i386: save_reg_upstackgrischka2016-10-041-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | tccgen.c:gv() when loading long long from lvalue, before was saving all registers which caused problems in the arm function call register parameter preparation, as with void foo(long long y, int x); int main(void) { unsigned int *xx[1], x; unsigned long long *yy[1], y; foo(**yy, **xx); return 0; } Now only the modified register is saved if necessary, as in this case where it is used to store the result of the post-inc: long long *p, v, **pp; v = 1; p = &v; p[0]++; printf("another long long spill test : %lld\n", *p); i386-gen.c : - found a similar problem with TOK_UMULL caused by the vstack juggle in tccgen:gen_opl() (bug seen only when using EBX as 4th register)
* Alternative fix for "Incorrect function call code on ARMv6"grischka2016-10-031-0/+11
| | | | | | | | | | | "make test" crashes without that "save_regs()". This partially reverts commit 49d3118621a68f6583228f123efd16f0f803d908. Found another solution: In a 2nd pass Just look if any of the argument registers has been saved again, and restore if so.
* Merge the integer members of union CValue into "uint64_t i".Edmund Grimley Evans2015-11-171-14/+14
|
* Revert "fix-mixed-struct (patch by Pip Cet)"gus knight2015-07-291-16/+6
| | | | This reverts commit 4e04f67c94c97b4f28a4d73759a0ad38fb3a10f7. Requested by grischka.
* Revert all of my changes to directories & codingstyle.gus knight2015-07-291-0/+2123
|
* Reorganize the source tree.gus knight2015-07-271-2162/+0
| | | | | | | | | | * Documentation is now in "docs". * Source code is now in "src". * Misc. fixes here and there so that everything still works. I think I got everything in this commit, but I only tested this on Linux (Make) and Windows (CMake), so I might've messed something up on other platforms...
* clang-format on arm-gen.c and tcccoff.c.gus knight2015-07-271-1457/+1496
| | | | They now mostly follow the same coding style as everything else.
* fix-mixed-struct (patch by Pip Cet)seyko2015-05-141-6/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Jsut for testing. It works for me (don't break anything) Small fixes for x86_64-gen.c in "tccpp: fix issues, add tests" are dropped in flavor of this patch. Pip Cet: Okay, here's a first patch that fixes the problem (but I've found another bug, yet unfixed, in the process), though it's not particularly pretty code (I tried hard to keep the changes to the minimum necessary). If we decide to actually get rid of VT_QLONG and VT_QFLOAT (please, can we?), there are some further simplifications in tccgen.c that might offset some of the cost of this patch. The idea is that an integer is no longer enough to describe how an argument is stored in registers. There are a number of possibilities (none, integer register, two integer registers, float register, two float registers, integer register plus float register, float register plus integer register), and instead of enumerating them I've introduced a RegArgs type that stores the offsets for each of our registers (for the other architectures, it's simply an int specifying the number of registers). If someone strongly prefers an enum, we could do that instead, but I believe this is a place where keeping things general is worth it, because this way it should be doable to add SSE or AVX support. There is one line in the patch that looks suspicious: } else { addr = (addr + align - 1) & -align; param_addr = addr; addr += size; - sse_param_index += reg_count; } break; However, this actually fixes one half of a bug we have when calling a function with eight double arguments "interrupted" by a two-double structure after the seventh double argument: f(double,double,double,double,double,double,double,struct { double x,y; },double); In this case, the last argument should be passed in %xmm7. This patch fixes the problem in gfunc_prolog, but not the corresponding problem in gfunc_call, which I'll try tackling next.
* Convert some lines from ISO-8859-1 to UTF-8.Edmund Grimley Evans2015-03-111-1/+1
| | | | | | | | perl -i -pe 'use Text::Iconv; $c1 = Text::Iconv->new("utf-8", "utf-8"); $c2 = Text::Iconv->new("iso-8859-1", "utf-8"); if (!$c1->convert($_)) { $_ = $c2->convert($_); }' \ `find * -type f`
* Fix stack overwrite on structure returnMichael Matz2015-03-091-3/+5
| | | | | | | | | 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.
* arm-unused-warnings: remove problems with defined but unused wariablesseyko2015-03-031-4/+9
| | | | | | | | | arm-gen.c: In function `gfunc_call': arm-gen.c:1202: warning: unused variable `variadic' arm-gen.c: In function `gfunc_prolog': arm-gen.c:1258: warning: unused variable `avregs' arm-gen.c:1340: warning: label `from_stack' defined but not used arm-gen.c:222: warning: 'default_elfinterp' defined but not used
* 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.
* Corrected spelling mistakes in comments and stringsVincent Lefevre2014-04-071-2/+2
|
* ARM: Fix passing arrays to varadic functionsDaniel Glöckner2014-03-291-1/+3
| | | | | | | | | | | | | | | | TinyCC miscompiled void g(int,...); void f(void) { char b[4000]; g(1, 2, 3, 4, b); } in two ways: 1. It didn't align the stack to 8 bytes before the call 2. It added sizeof(b) to the stack pointer after the call
* Warn about soft float ABI not being supportedThomas Preud'homme2014-03-251-0/+3
| | | | | | For ARM target, tcc uses the soft float ABI when not asked to use hard float ABI. This means machine without a VFP co-processor generate code that they cannot run. This commit add a warning for such cases.
* Deprecate FPA and OABI support for ARMThomas Preud'homme2014-03-251-1/+11
|
* Define float_eabi only in arm-gen.oThomas Preud'homme2014-02-091-2/+2
|
* Fix fct param passing of struct with size < 4Thomas Preud'homme2014-02-031-2/+3
|
* Switch float abi to softfp for int <--> float convThomas Preud'homme2014-02-021-17/+9
| | | | | | | This improves commit 5cbe03b9c47e676e045b4978c384087433bd6042 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.
* Move result of itof double conv back to VFP regThomas Preud'homme2014-02-011-0/+9
| | | | | | | | | | | 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.
* Fix compile on ARM non-eabi and non-vfpMichael Matz2014-01-111-1/+1
| | | | Adjust arm_init prototype to match declaration.
* Add support for runtime selection of float ABIThomas Preud'homme2014-01-081-60/+71
|
* Explicit that EABI only supports VFP for nowThomas Preud'homme2014-01-071-4/+2
|
* Fix struct ret in variadic fct with ARM hardfloatThomas Preud'homme2014-01-061-16/+18
| | | | | | | | | | | | | 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().
* Move logic for if (int value) to tccgen.cThomas Preud'homme2014-01-041-24/+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.
* Support special calling convention for runtime ABIThomas Preud'homme2013-12-111-15/+34
| | | | | | | | 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
* Add comment to explain the code added by 41ce391cThomas Preud'homme2013-11-251-1/+4
| | | | | | Add a comment in arm-gen.c to explain how commit 41ce391c86df135609af33658414d4d452c5beb3 solves the register corruption when passing a structure in a function call.
* Fix structure passing in ARM calling conventionThomas Preud'homme2013-11-251-3/+6
| | | | | | 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.
* Add support for struct > 4B returned via registersThomas Preud'homme2013-11-221-18/+30
| | | | | | | | 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.
* Remove code in arm-gen.c for struct packing in regThomas Preud'homme2013-11-221-21/+3
| | | | | Struct packing in register is now handled since commit 2bbfaf43 by tccgen.c proper.
* Correctly identify homogeneous float aggregateThomas Preud'homme2013-11-221-1/+1
| | | | | First related symbol of a structure justs indicate its size. This first member is the second related symbol.
* Fix counting of VFP regs in ARM's gfunc_prologThomas Preud'homme2013-11-211-1/+2
| | | | | | | | | 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.
* Fix register corruption at function call on ARMThomas Preud'homme2013-11-211-6/+16
| | | | | | | | 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.
* Correctly align and reclaim stack at function callThomas Preud'homme2013-11-171-6/+8
| | | | | | | * 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.
* Refactor and simplify gfunc_call() on armThomas Preud'homme2013-11-151-296/+328
|
* struct variable behind guard, proper macro check, and remove some whitespace.Joseph Poirier2013-11-081-17/+17
| | | | | | | 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>
* Fix allocation of struct in registers on ARMThomas Preud'homme2013-11-051-46/+44
| | | | | | | | | | | 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.
* Add support for load/store of _Bool valueThomas Preud'homme2013-06-141-2/+2
| | | | | Add support for loading _Bool value in i386, x86_64 and arm as well as support for storing _Bool value on arm.