aboutsummaryrefslogtreecommitdiff
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* struct-init: Support range inits for local varsMichael Matz2016-12-152-0/+5
| | | | Implement missing support for range init for local variables.
* x86-64-asm: Support high registers %r8 - %r15Michael Matz2016-12-151-3/+37
| | | | | | | This requires correctly handling the REX prefix. As bonus we now also support the four 8bit registers spl,bpl,sil,dil, which are decoded as ah,ch,dh,bh in non-long-mode (and require a REX prefix as well).
* inline-asm: Accept "flags" clobberMichael Matz2016-12-151-1/+1
|
* struct-init: Allow member initialization from qualified lvaluesMichael Matz2016-12-152-3/+29
| | | | See testcase.
* struct-init: Correctly parse unnamed member initializersMichael Matz2016-12-152-0/+27
| | | | | | | | | | | | | For union U { struct {int a,b}; int c; }; union U u = {{ 1, 2, }}; The unnamed first member of union U needs to actually exist in the structure so initializer parsing isn't confused about the double braces. That means also the a and b members must be part of _that_, not of union U directly. Which in turn means we need to do a bit more work for field lookup. See the testcase extension for more things that need to work.
* struct-init: CleanupMichael Matz2016-12-153-1/+13
| | | | | | | Remove dead code and variables. Properly check for unions when skipping fields in initializers. Make tests2/*.expect depend on the .c files so they are automatically rebuilt when the latter change.
* struct-init: Implement initializing subaggregatesMichael Matz2016-12-153-1/+167
| | | | | | E.g. "struct { struct S s; int a;} = { others, 42 };" if 'others' is also a 'struct S'. Also when the value is a compound literal. See added testcases.
* Support attribute between double pointer starsMichael Matz2016-12-151-0/+7
| | | | "int * __attribute__((something)) *" is supported by GCC.
* Fix function to pointer conversionMichael Matz2016-12-151-0/+7
| | | | | | | | This snippet is valid: void foo(void); ... foo + 42 ... the function designator is converted to pointer to function implicitely. gen_op didn't do that and bailed out.
* Fix parsing array typedefs of unknown sizeMichael Matz2016-12-151-0/+14
| | | | | | | | | | | This must compile: typedef int arrtype1[]; arrtype1 sinit19 = {1}; arrtype1 sinit20 = {2,3}; and generate two arrays of one resp. two elements. Before the fix the determined size of the first array was encoded in the type directly, so sinit20 couldn't be parsed anymore (because arrtype1 was thought to be only one element long).
* tccpp: Implement __BASE_FILE__ macroMichael Matz2016-12-152-0/+16
| | | | | Like __FILE__ but always refers to the command line file name also from inside headers.
* Implement __builtin_choose_exprMichael Matz2016-12-151-0/+13
| | | | Follows GCC implementation.
* x86-asm: Implement prefetchw opcodeMichael Matz2016-12-151-0/+1
|
* x86-asm: Fix lar opcode operandsMichael Matz2016-12-151-0/+7
| | | | | | | lar can accept multiple sizes as well (wlx), like lsl. When using autosize it's important to look at the destination operand first; when it's a register that one determines the size, not the input operand.
* x86-asm: More opcodesMichael Matz2016-12-151-0/+11
| | | | | Some new opcodes and some aliases: ljmp[wl], prefetch{nta,t0,t1,t2}, bswap[lq], sysretq, swapgs.
* x86-asm: Add [sl][ig]dtq opcodesMichael Matz2016-12-151-4/+10
| | | | | GAS has alias lgdtq for lgdt (similar for saves and GDT). It doesn't have the same for LDT.
* x86-asm: Implement fxrstorq and fxsaveqMichael Matz2016-12-151-0/+2
|
* Fix parsing attributes for struct declsMichael Matz2016-12-151-0/+33
| | | | | | | | | | | Given this code: struct __attribute__((...)) Name {...}; TCC was eating "Name", hence generating an anonymous struct. It also didn't apply any packed attributes to the parsed members. Both fixed. The testcase also contains a case that isn't yet handled by TCC (under a BROKEN #define).
* x86-asm: Implement clflush opcodeMichael Matz2016-12-151-0/+1
|
* inline asm: accept concatenated strings in constraintsMichael Matz2016-12-151-1/+1
| | | | | This really should be handled implicitly in the preprocessor, but for now this is enough.
* Accept symbols in initializers also on 64 bitMichael Matz2016-12-151-0/+7
| | | | Those should use long or long long type, and generate a 64bit reloc.
* x86-64-asm: More opcodesMichael Matz2016-12-151-0/+7
| | | | Implement some more opcodes, syscall, sysret, lfence, mfence, sfence.
* tccasm: Implement compare expressionsMichael Matz2016-12-151-0/+6
| | | | | I.e. implement < > <= >= == !=. Comparisons are signed and result is -1 if true, 0 if false.
* x86-64-asm: Accept expressions for .quadMichael Matz2016-12-151-0/+1
| | | | | The x86-64 target has 64bit relocs, and hence can accept generic expressions for '.quad'.
* inline asm: Accept 'p' constraint and 'P' template modMichael Matz2016-12-151-0/+9
| | | | | 'p' is conservatively the same as 'r' and 'P' as template modifier can be ignored in TCC.
* tccasm: Accept .balignMichael Matz2016-12-151-0/+1
|
* Accept more asm expressionsMichael Matz2016-12-151-0/+13
| | | | | | In particular subtracting a defined symbol from current section makes the value PC relative, and .org accepts symbolic expressions as well, if the symbol is from the current section.
* tccasm: Implement .pushsection and .popsectionMichael Matz2016-12-151-0/+10
|
* Accept empty struct member declsMichael Matz2016-12-151-0/+5
| | | | | | | struct S { /*nothing*/; int a; }; is an acceptable struct declaration, there may be stray semicolons in the member list.
* x86-asm: Accept 'q' modifierMichael Matz2016-12-151-0/+11
| | | | In inline extended asm '%q1' refers to the 64bit register of operand 1.
* tccpp: Fix macro_is_equalMichael Matz2016-12-152-0/+5
| | | | | | | When tokens in macro definitions need cstr_buf inside get_tok_str, the second might overwrite the first (happens when tokens are multi-character non-identifiers, see testcase) in macro_is_equal, failing to diagnose a difference. Use a real local buffer.
* x86-64-asm: TidyMichael Matz2016-12-151-0/+1
|
* x86-asm: Correct mem64->xmm movqMichael Matz2016-12-151-0/+1
| | | | | | Now we can express prefixes with 0x0fxx opcodes we can correct the movq mem64->xmm opcode, and restrict the movq xmm->mem64 movq to not invalidly accept mmx.
* 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