aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* struct-init: CleanupMichael Matz2016-12-154-103/+25
| | | | | | | 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-154-40/+226
| | | | | | 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.
* struct-init: ReimplementMichael Matz2016-12-151-78/+106
| | | | | | Start reimplementing the whole initializer handling to be conforming to ISO C. This patch just reimplements current functionality to prepare for further changes, all tests pass.
* Support attribute between double pointer starsMichael Matz2016-12-152-4/+12
| | | | "int * __attribute__((something)) *" is supported by GCC.
* Fix function to pointer conversionMichael Matz2016-12-152-0/+20
| | | | | | | | 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-152-0/+22
| | | | | | | | | | | 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-153-0/+22
| | | | | Like __FILE__ but always refers to the command line file name also from inside headers.
* Implement __builtin_choose_exprMichael Matz2016-12-153-0/+43
| | | | Follows GCC implementation.
* x86-asm: Implement prefetchw opcodeMichael Matz2016-12-152-0/+2
|
* x86-asm: Fix lar opcode operandsMichael Matz2016-12-155-3/+15
| | | | | | | 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.
* tcc-asm: Parse .size directive correctlyMichael Matz2016-12-151-1/+1
| | | | | When the .size directive was closed with a ';' tcc eat everything after it up to lineend.
* x86-asm: More opcodesMichael Matz2016-12-152-0/+23
| | | | | 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-152-4/+14
| | | | | GAS has alias lgdtq for lgdt (similar for saves and GDT). It doesn't have the same for LDT.
* inline asm: Accept 'R' constraintMichael Matz2016-12-151-0/+2
| | | | | This is like 'r' but only accepts the eight legacy regs. Currently that's the same as 'r' because we don't support the high ones.
* x86-asm: Implement fxrstorq and fxsaveqMichael Matz2016-12-152-0/+8
|
* Fix parsing attributes for struct declsMichael Matz2016-12-152-4/+35
| | | | | | | | | | | 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-152-0/+2
|
* inline asm: Accept "e" constraintMichael Matz2016-12-151-0/+2
| | | | | This is meant to be a (sign-extended) 32bit constant (possibly symbolic). We don't do any checks and simply regard it as "i".
* inline asm: accept concatenated strings in constraintsMichael Matz2016-12-154-7/+8
| | | | | This really should be handled implicitly in the preprocessor, but for now this is enough.
* inline asm: Fix 'P' and accept some r<nr> registersMichael Matz2016-12-152-5/+13
| | | | | | A 'P' template modifier should avoid adding a '$' to literal arguments. Also accept the numbered r8+ registers in an inline asm clobber list (ignoring them for now).
* Accept symbols in initializers also on 64 bitMichael Matz2016-12-152-3/+20
| | | | Those should use long or long long type, and generate a 64bit reloc.
* x86-64-asm: More opcodesMichael Matz2016-12-153-0/+22
| | | | Implement some more opcodes, syscall, sysret, lfence, mfence, sfence.
* tccasm: Implement compare expressionsMichael Matz2016-12-152-1/+51
| | | | | I.e. implement < > <= >= == !=. Comparisons are signed and result is -1 if true, 0 if false.
* x86-64-asm: Accept expressions for .quadMichael Matz2016-12-154-1/+14
| | | | | 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-153-1/+15
| | | | | 'p' is conservatively the same as 'r' and 'P' as template modifier can be ignored in TCC.
* tccasm: Accept .balignMichael Matz2016-12-153-1/+4
|
* Accept more asm expressionsMichael Matz2016-12-154-23/+60
| | | | | | 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-154-3/+40
|
* Accept empty struct member declsMichael Matz2016-12-152-1/+9
| | | | | | | 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-152-1/+12
| | | | In inline extended asm '%q1' refers to the 64bit register of operand 1.
* Accept concatenated strings in attributesMichael Matz2016-12-151-25/+29
| | | | | attribute(section("one" "two")) should be accepted (the section name being "onetwo"), it's normal string concatenation.
* Accept -Wp,argsMichael Matz2016-12-151-0/+6
| | | | | | | These are preprocessor cmdline arguments, but even in GCC they aren't specified but rather left as being subject to changes. Nobody should use them, but let's to a half-assed attempt at accepting them.
* Change dependency file format a bitMichael Matz2016-12-151-1/+1
| | | | | | | The linux fixdep parse is very stupid and only recognizes a target token when ':' is part of it. A space is permitted in Makefile syntax, but it's easier to change our emitter than all fixdep parsers out there.
* Add --param, reject -mARG if ARG not 32 or 64Michael Matz2016-12-151-0/+4
|
* Implement -include cmdline optionMichael Matz2016-12-153-0/+24
| | | | | | This option includes a file as if '#include "file"' is the first line of compiled files. It's processed after all -D/-U options and is processed per input file.
* Free defines before gen_inline_functionsMichael Matz2016-12-151-2/+2
| | | | | | | | gen_inline_functions uses the macro facilities of the preprocessor, which would interact when macros would still be defined in a different pre-processor implementation I'm working on. So always free defines before generating inline functions, they are all macro expanded already.
* tccpp: Fix macro_is_equalMichael Matz2016-12-153-4/+10
| | | | | | | 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.
* tccpp: free defines also with PP_BENCHMichael Matz2016-12-151-1/+3
| | | | | When benchmarking preprocessing of multiple files we need to free the defines like when not benchmarking.
* x86-asm: Get rid of OPC_JMP and OPC_SHORTJMPMichael Matz2016-12-153-28/+28
| | | | | Those two insn types are nicer to handle as operand types, because the pressure for bits on instr_type is higher than for operands.
* x86-64-asm: TidyMichael Matz2016-12-152-5/+3
|
* x86-asm: Correct mem64->xmm movqMichael Matz2016-12-153-11/+6
| | | | | | 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: Remove OPC_D16Michael Matz2016-12-153-10/+6
| | | | | Now that we can store prefixes even for 0x0fXX opcodes we can remove the OPC_D16 bit.
* x86-asm: Fix register orderMichael Matz2016-12-151-1/+1
| | | | | Inserting random registers in the middle of the 8-blocks breaks register assignment.
* x86-asm: Reorganize instr_typeMichael Matz2016-12-153-46/+65
| | | | | | | | | Disjoint instruction types don't need to be a bit field, so introduce an enumeration (3 bits). Also the 0x0f prefix can be expressed by a bit, doesn't need a byte in the opcode field. That enables to encode further prefixes still in 16 bit. To not have to touch all insns do some macro fiddling filtering out a 0x0f byte in the second position.
* x86-asm: move stats codeMichael Matz2016-12-152-32/+40
| | | | | The old place (tccasm.c) didn't have access to the variables anymore and was ifdefed out. Move it to i386-asm.c.
* x86-asm: Add more SSE2 instructionsMichael Matz2016-12-154-119/+257
| | | | | | | | 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-153-9/+23
| | | | | Also remove bitfield test from tcctest.c because gcc versions don't agree among each other.
* tccelf: some linker cleanupgrischka2016-12-159-441/+466
| | | | | | | | | | - 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)
* Use functions to get relocation infoThomas Preud'homme2016-12-107-109/+320
| | | | | | | MSVC does not support array designator so cannot compile source using relocs_info. This commit replace the relocs_info array into a set of functions, each returning the value given by a given field of the struct reloc_info.
* Remove now useless pltoff_addend reloc infoThomas Preud'homme2016-12-106-70/+69
| | | | | | Last use for pltoff_addend field of relocs_info array was removed in commit 25927df3b75c5ce2b64ab8acdcc5974b4e1c89c1. It is now useless so this commit removes it and all initialization related to it.