aboutsummaryrefslogtreecommitdiff
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* x86-asm: Add more SSE2 instructionsMichael Matz2016-12-151-0/+102
| | | | | | | | In particular those that are extensions of existing mmx (or sse1) instructions by a simple 0x66 prefix. There's one caveat for x86-64: as we don't yet correctly handle the 0xf3 prefix the movq mem64->xmm is wrong (tested in asmtest.S). Needs some refactoring of the instr_type member.
* tests: add .so/.dll creation testgrischka2016-12-152-9/+20
| | | | | Also remove bitfield test from tcctest.c because gcc versions don't agree among each other.
* tccelf: some linker cleanupgrischka2016-12-151-2/+6
| | | | | | | | | | - generate and use SYM@PLT for plt addresses - get rid of patch_dynsym_undef hack (no idea what it did on FreeBSD) - use sym_attrs instead of symtab_to_dynsym - special case for function pointers into .so on i386 - libtcc_test: test tcc_add_symbol with data object - move target specicic code to *-link.c files - add R_XXX_RELATIVE (needed for PE)
* Implement gcc bitfield algorithm; add -mms-bitfieldsDavid Mertens2016-11-281-0/+9
|
* x86_64-asm: =m operand fixesgrischka2016-11-201-3/+25
| | | | | | | | | | | | | | | | | | | | | | The problem was with tcctest.c: unsigned set; __asm__("btsl %1,%0" : "=m"(set) : "Ir"(20) : "cc"); when with tcc compiled with the HAVE_SELINUX option, run with tcc -run, it would use large addresses far beyond the 32bits range when tcc did not use the pc-relative mode for accessing 'set' in global data memory. In fact the assembler did not know about %rip at all. Changes: - memory operands use (%rax) not (%eax) - conversion from VT_LLOCAL: use type VT_PTR - support 'k' modifier - support %rip register - support X(%rip) pc-relative addresses The test in tcctest.c is from Michael Matz.
* OpenBSD does not support -v option in rm command.Christian Jullien2016-10-151-1/+1
|
* tccgen: 32bits: fix PTR +/- long longgrischka2016-10-132-0/+16
| | | | | | | | | | | | | | | | | | | | | | | Previously in order to perform a ll+ll operation tcc was trying to 'lexpand' PTR in gen_opl which did not work well. The case: int printf(const char *, ...); char t[] = "012345678"; int main(void) { char *data = t; unsigned long long r = 4; unsigned a = 5; unsigned long long b = 12; *(unsigned*)(data + r) += a - b; printf("data %s\n", data); return 0; }
* Use ISO C string functions instead of obsolete BSD ones that used to be in ↵Christian Jullien2016-10-122-8/+3
| | | | strings.h. It allows more systems -- i.e. Windows -- to use those tests
* tccpp : "tcc -E -P" : suppress empty linesgrischka2016-10-096-8/+33
| | | | | | | | | Also: - regenerate all tests/pp/*.expect with gcc - test "insert one space" feature - test "0x1E-1" in asm mode case - PARSE_FLAG_SPACES: ignore \f\v\r better - tcc.h: move some things
* tccgen: arm/i386: save_reg_upstackgrischka2016-10-041-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* switch: fix label sortingPavlas, Zdenek2016-10-031-0/+3
|
* tccgen: fix long long -> char/short castgrischka2016-10-022-3/+8
| | | | | | | | | | | | | | | | | | | | | | | This was causing assembler bugs in a tcc compiled by itself at i386-asm.c:352 when ExprValue.v was changed to uint64_t: if (op->e.v == (int8_t)op->e.v) op->type |= OP_IM8S; A general test case: #include <stdio.h> int main(int argc, char **argv) { long long ll = 4000; int i = (char)ll; printf("%d\n", i); return 0; } Output was "4000", now "-96". Also: add "asmtest2" as asmtest with tcc compiled by itself
* Incorrect function call code on ARMv6Balazs Kezes2016-10-011-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On 2016-08-11 09:24 +0100, Balazs Kezes wrote: > I think it's just that that copy_params() never restores the spilled > registers. Maybe it needs some extra code at the end to see if any > parameters have been spilled to stack and then restore them? I've spent some time on this and I've found an alternative solution. Although I'm not entirely sure about it but I've attached a patch nevertheless. And while poking at that I've found another problem affecting the unsigned long long division on arm and I've attached a patch for that too. More details in the patches themselves. Please review and consider them for merging! Thank you! -- Balazs [PATCH 1/2] Fix slow unsigned long long division on ARM The macro AEABI_UXDIVMOD expands to this bit: #define AEABI_UXDIVMOD(name,type, rettype, typemacro) \ ... while (num >= den) { \ ... while ((q << 1) * den <= num && q * den <= typemacro ## _MAX / 2) \ q <<= 1; \ ... With the current ULONG_MAX version the inner loop goes only until 4 billion so the outer loop will progress very slowly if num is large. With ULLONG_MAX the inner loop works as expected. The current version is probably a result of a typo. The following bash snippet demonstrates the bug: $ uname -a Linux eper 4.4.16-2-ARCH #1 Wed Aug 10 20:03:13 MDT 2016 armv6l GNU/Linux $ cat div.c int printf(const char *, ...); int main(void) { unsigned long long num, denom; num = 12345678901234567ULL; denom = 7; printf("%lld\n", num / denom); return 0; } $ time tcc -run div.c 1763668414462081 real 0m16.291s user 0m15.860s sys 0m0.020s [PATCH 2/2] Fix long long dereference during argument passing on ARMv6 For some reason the code spills the register to the stack. copy_params in arm-gen.c doesn't expect this so bad code is generated. It's not entirely clear why the saving part is necessary. It was added in commit 59c35638 with the comment "fixed long long code gen bug" with no further clarification. Given that tcctest.c passes without this, maybe it's no longer needed? Let's remove it. Also add a new testcase just for this. After I've managed to make the tests compile on a raspberry pi, I get the following diff without this patch: --- test.ref 2016-08-22 22:12:43.380000000 +0100 +++ test.out3 2016-08-22 22:12:49.990000000 +0100 @@ -499,7 +499,7 @@ 2 1 0 1 0 4886718345 -shift: 9 9 9312 +shift: 291 291 291 shiftc: 36 36 2328 shiftc: 0 0 9998683865088 manyarg_test: More discussion on this thread: https://lists.nongnu.org/archive/html/tinycc-devel/2016-08/msg00004.html
* build: restore out-of-tree supportgrischka2016-10-013-22/+27
|
* build: revert Makefiles to 0.9.26 state (mostly)grischka2016-10-013-89/+53
| | | | | | | | | | | | Except - that libtcc1.a is now installed in subdirs i386/ etc. - the support for arm and arm64 - some of the "Darwin" fixes - tests are mosly unchanged Also - removed the "legacy links for cross compilers" (was total mess) - removed "out-of-tree" build support (was broken anyway)
* test/pp: cleanupgrischka2016-10-016-74/+20
|
* Remove misc. filesgrischka2016-10-012-138/+510
| | | | | | | | | | | | - from win32/include/winapi: various .h The winapi header set cannot be complete no matter what. So lets have just the minimal set necessary to compile the examples. - remove CMake support (hard to keep up to date) - some other files Also, drop useless changes in win32/lib/(win)crt1.c
* Fix test for __*LP*__ predefined macrosChristian Jullien2016-09-251-11/+11
|
* Add test for __*LP*__ predefined macrosChristian Jullien2016-09-252-0/+39
|
* win64: fix va_arggrischka2016-07-101-0/+9
| | | | | | | | | | | fixes 5c35ba66c5ade4713bbd9c005e66889f6d7db293 Implementation was consistent within tcc but incompatible with the ABI (for example library functions vprintf etc) Also: - tccpp.c/get_tok_str() : avoid "unknown format "%llu" warning - x86_64_gen.c/gen_vla_alloc() : fix vstack leak
* x86-asm: Reject some invalid arith imm8 instructionMichael Matz2016-05-161-0/+16
| | | | | | | There were two errors in the arithmetic imm8 instruction. They accept only REGW, and in case the user write a xxxb opcode that variant needs to be rejected as well (it's not automatically rejected by REGW in case the destination is memory).
* x86-asm: Add .fill testMichael Matz2016-05-141-0/+1
|
* x86-asm: Fix signed constants and opcode orderMichael Matz2016-05-141-0/+7
| | | | | | | | Two things: negative constants were rejected (e.g. "add $-15,%eax"). Second the insn order was such that the arithmetic IM8S forms weren't used (always the IM32 ones). Switching them prefers those but requires a fix for size calculation in case the opcodes were OPC_ARITH and OPC_WLX (whose size starts with 1, not zero).
* x86-64-asm: Add mov[sz]xq opcodesMichael Matz2016-05-121-0/+7
| | | | This adds the zero/sign-extending opcodes with 64bit destinations.
* x86-64-asm: Clean up 64bit immediate supportMichael Matz2016-05-111-0/+10
| | | | | | | | | Fix it to actually be able to parse 64bit immediates (enlarge operand value type). Then, generally there's no need for accepting IM64 anywhere, except in the 0xba+r mov opcodes, so OP_IM is unnecessary, as is OPT_IMNO64. Improve the generated code a bit by preferring the 0xc7 opcode for im32->reg64, instead of the im64->reg64 form (which we therefore hardcode).
* x86-64: Run asmtest as wellMichael Matz2016-05-111-13/+27
| | | | | This fixes and activates the asm test that's part of tcctest.c also on x86-64, requiring a small fix for the 'm' constraint.
* tests: Compile asmtest.S without -m32Michael Matz2016-05-111-1/+1
| | | | | Don't hardcode that option, if you want it do make CC="gcc -m32". The test assembles with -m64 as well now.
* x86-64 asm: Remove useless jmp opcodeMichael Matz2016-05-111-0/+1
| | | | | Also remove the hacky mod/rm byte emission during disp/imm writing.
* x86: Improve cmov handlingMichael Matz2016-05-111-0/+4
| | | | | cmov can accept multi sizes, but is also a OPC_TEST opcode, deal with this.
* [x86] Fix some asm problemsMichael Matz2016-05-091-8/+67
| | | | | | | | | | | A bag of assembler fixes, to be either compatible with GAS (e.g. order of 'test' operands), accept more instructions, count correct foo{bwlq} variants on x86_64, fix modrm/sib bytes on x86_64 to not use %rip relative addressing mode, to not use invalid insns in tests/asmtest.S for x86_64. Result is that now output of GAS and of tcc on tests/asmtest.S is mostly the same.
* Insert spaces between certain tokens when tcc is invoked with -E.Edmund Grimley Evans2016-05-092-0/+25
| | | | | | Insert a space when it is required to prevent mistokenisation of the output, and also in a few cases where it is not strictly required, imitating GCC's behaviour.
* tccgen: scopes levels for local symbols (update 2)grischka2016-05-062-6/+7
| | | | | | | allow typedef int xxx; typedef int xxx; in the same scope as long as it is the same type
* tccgen: scopes levels for local symbols (update 1)grischka2016-05-051-0/+2
| | | | | | | Catch top level redeclarations too. Also fix mistakes in tcctest.c and the tcc sources (win32) showing up now.
* tests/tests2/Makefile: Make 85-asm-outside-function Intel-only.Edmund Grimley Evans2016-05-041-0/+3
|
* __asm__() outside functionseyko2016-05-012-0/+7
| | | | | | | | gcc/pcc allow __asm__() outside a function body: extern void vide(void); __asm__("vide: ret"); There is many such code in the Linux kernels.
* output space after TOK_PPNUM which followed by '+' or '-'seyko2016-05-018-5/+65
| | | | | | * correct -E output for the case ++ + ++ concatenation do this only for expanded from macro string and only when tcc_state->output_type == TCC_OUTPUT_PREPROCESS
* Run testcases in sorted orderMichael Matz2016-04-221-1/+1
| | | | | Without sorting they run in whatever order readdir returns, I like it better when the order is reliable (and alphanumeric).
* Revert "Fix tests Makefiles on Windows"Vlad Vissoultchev2016-04-173-14/+2
| | | | This reverts commit fa2472c17246206ce6947475782de17245eceeea.
* fix preprocessing *.S with ` ' chars in #commentsseyko2016-04-142-0/+12
| | | | | with a test program. Problem detected when trying to compile linux-2.4.37.9 with tcc.
* tccgen.c: Allow type attributes to prefix enum/struct/union nameVlad Vissoultchev2016-04-062-0/+14
| | | | | | From gcc docs: "You may also specify attributes between the enum, struct or union tag and the name of the type rather than after the closing brace." Adds `82_attribs_position.c` in `tests/tests2`
* utf8 in identifiersseyko2016-04-052-0/+11
| | | | | | | | | | | | | | made like in pcc (pcc.ludd.ltu.se/ftp/pub/pcc-docs/pcc-utf8-ver3.pdf) We treat all chars with high bit set as alphabetic. This allow code like #include <stdio.h> int Lefèvre=2; int main() { printf("Lefèvre=%d\n",Lefèvre); return 0; }
* nocode_wanted with while/for inside ({})seyko2016-04-052-0/+90
| | | | a test included.
* Identifiers can start and/or contain '.' in *.Sseyko2016-04-054-2/+26
| | | | | | | | | | | | | | | | | modified version of the old one which don't allow '.' in #define Identifiers. This allow correctly preprocess the following code in *.S #define SRC(y...) \ 9999: y; \ .section __ex_table, "a"; \ .long 9999b, 6001f ; \ // .previous SRC(1: movw (%esi), %bx) 6001: A test included.
* Fix assignment to/from volatile typesMichael Matz2016-03-261-0/+11
| | | | | | | | | Code like this was broken: char volatile vi = i; See testcase, happens in ideosyncratic legacy code sprinkling volatile all over.
* Fix tokenization of TOK_DOTSMichael Matz2016-03-241-0/+5
| | | | | We really need to use PEEKC during tokenization so as to skip line continuations automatically.
* Fix type parsingMichael Matz2016-03-243-1/+10
| | | | | | the check on incomplete struct/union/enum types was too early, disallowing mixed specifiers and qualifiers. Simply rely on the size (->c) field for that. See testcases.
* Fix tests Makefiles on WindowsVlad Vissoultchev2016-03-143-2/+14
| | | | Compiled tcc.exe location is under $(top_srcdir)/win32
* tccgen.c: Fix flex array members some moreMichael Matz2016-03-112-0/+25
| | | | Last fix didn't work for function f1int in the added testcase.
* tccgen.c: In parse_btype, handle type qualifiers applied to arrays.Edmund Grimley Evans2016-01-111-0/+16
| | | | Also add some test cases in tests/tests2/39_typedef.c.
* tccgen.c: Try to make sizeof(!x) work.Edmund Grimley Evans2015-11-222-0/+3
| | | | tests/tests2/27_sizeof.*: Add test.