| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
| |
Our code generation assumes that it can load/store with the
bit-fields base type, so bit_pos/bit_size must be in range for this.
We could change the fields type or adjust offset/bit_pos; we do the
latter.
|
| |
|
|
|
|
| |
Checked the lcc testsuite for bitfield stuff (in cq.c and fields.c),
fixed one more error in initializing unnamed members (which have
to be skipped), removed the TODO.
|
| |
|
|
| |
See testcase.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
usage:
tcc -ar [rcsv] lib files...
tcc -impdef lib.dll [-v] [-o lib.def]
also:
- support more files with -c: tcc -c f1.c f2.c ...
- fix a bug which caused tcc f1.c f2.S to produce no asm
- allow tcc -ar @listfile too
- change prototype: _void_ tcc_set_options(...)
- apply -Wl,-whole-archive when a librariy is given
as libxxx.a also (not just for -lxxx)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
tests/Makefile: fix out-of-tree build issues
Also:
- win64: align(16) MEM_DEBUG user memory
on win64 the struct jmp_buf in the TCCState structure which we
allocate by tcc_malloc needs alignment 16 because the msvcrt
setjmp uses MMX instructions.
- libtcc_test.c: win32/64 need __attribute__((dllimport)) for
extern data objects
- tcctest.c: exclude stuff that gcc does not compile
except for relocation_test() the other issues are mostly ASM
related. We should probably check GCC versions but I have
no idea which mingw/gcc versions support what and which don't.
- lib/Makefile: use tcc to compile libtcc1.a (except on arm
which needs arm-asm
|
| |
|
|
|
|
|
|
|
|
| |
Some more subtle issues with code suppression:
- outputting asms but not their operand setup is broken
- but global asms must always be output
- statement expressions are transparent to code suppression
- vtop can't be transformed from VT_CMP/VT_JMP when nocode_wanted
Also remove .exe files from tests2 if they don't fail.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Also ...
tcctest.c:
- exclude stuff that gcc doesn't compile on windows.
libtcc.c/tccpp.c:
- use unsigned for memory sizes to avoid printf format warnings
- use "file:line: message" to make IDE error parsers happy.
tccgen.c: fix typo
|
| |
|
|
|
|
|
|
|
| |
on 32bit long long support was sometimes broken. This fixes
code-gen for long long values in switches, disables a x86-64 specific
testcase and avoid an undefined shift amount. It comments out
a bitfield test involving long long bitfields > 32 bit; with GCC layout
they can straddle multiple words and code generation isn't prepared
for this.
|
| |
|
|
|
|
| |
when an alignment is explicitely given on the member itself,
or on its types attributes then respect it always. Was only
allowed to increase before, but GCC is allowing it.
|
| |
|
|
|
|
|
|
| |
The linux kernel has some structures that are page aligned,
i.e. 4096. Instead of enlarging the bit fields to specify this,
use the fact that alignment is always power of two, and store only
the log2 minus 1 of it. The 5 bits are enough to specify an alignment
of 1 << 30.
|
| |
|
|
|
|
| |
Anonymous sub-sub-members weren't handled correctly. Bit-fields
neither: this implements PCC layout for now. It temporarily disables
MS-compatible bit-field layout.
|
| |
|
|
|
|
|
|
|
|
|
| |
Such struct decl:
struct S { char a; int i;} __attribute__((packed));
should be accepted and cause S to be five bytes long (i.e.
the packed attribute should matter). So we can't layout
the members during parsing already. Split off the offset
and alignment calculation for this.
|
| |
|
|
|
|
|
| |
See testcases. We now support 64bit case constants. At the same time
also 64bit enum constants on L64 platforms (otherwise the Sym struct
isn't large enough for now). The testcase also checks for various
cases where sign/zero extension was confused.
|
| |
|
|
|
|
|
|
| |
In certain very specific situations (involving switches
with asms inside dead statement expressions) we could generate
invalid code (clobbering the buffer so much that we generated
invalid instructions). Don't emit the decision table if the
switch itself is dead.
|
| |
|
|
|
|
| |
If a symbolic reference is offsetted by a constant > 32bit
the backends can't deal with that, so don't construct such
values.
|
| |
|
|
|
|
|
| |
The callee saved registers (among them r12-r15) really need
saving/restoring if mentioned in asm clobbers, even if TCC
itself doesn't use them. E.g. the linux kernel relies on that
in its switch_to() implementation.
|
| |
|
|
|
|
|
|
|
| |
Similar to GCC a local asm register variable enforces the use of a
specified register in asm operands (and doesn't otherwise
matter). Works only if the variable is directly mentioned as
operand. For that we now generally store a backpointer from
an SValue to a Sym when the SValue was the result of unary()
parsing a symbol identifier.
|
| |
|
|
| |
See testcase.
|
| |
|
|
|
| |
A pointer is 64 bit as well, so it needs a full
register for register operands.
|
| |
|
|
|
|
| |
If the destination is an indirect pointer access (which ends up
as VT_LLOCAL) the intermediate pointer must be loaded as VT_PTR,
not as whatever the pointed to type is.
|
| |
|
|
|
| |
Inside dead code don't regard inline functions as being
referenced.
|
| |
|
|
|
| |
Our architectures don't need anything special for this
builtin, just pass through the argument.
|
| |
|
|
|
|
| |
We didn't handle constants in logical expressions when they weren't
the first operand. Some reordering in the loop structure is enough
to handle them.
|
| |
|
|
|
| |
As we can optimize dead code a bit already it's fitting
to disable code emission after break and goto.
|
| |
|
|
|
|
|
| |
If a condition is always zero/non-zero we can omit the
then or else code. This is complicated a bit by having to
deal with labels that might make such code reachable without
us yet knowing during parsing.
|
| |
|
|
| |
Use correct width ELF structure.
|
| |
|
|
|
| |
The sizes of VLAs need to be evaluated even inside sizeof,
i.e. when nocode_wanted is set.
|
| |
|
|
|
| |
was incorrectly treated as constant because the vpop removed
all traces of non-constness.
|
| |
|
|
|
|
|
| |
This happens when e.g. string constants (or other static data)
are passed as operands to inline asm as immediates. The produced
symbol ref wouldn't be found. So tighten the connection between
C and asm-local symbol table even more.
|
| |
|
|
|
| |
VT_ENUM types use the .ref member and can be VT_BITFIELD,
so we need to copy it as well. Simply do it always.
|
| |
|
|
| |
Use this fact in some foldings of comparisons. See testcase.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
The return value of statement expressions might refer to local
symbols, so those can't be popped. The old error message always
was just a band-aid, and since disabling it for pointer types it
wasn't effective anyway. It also never considered that also the
vtop->sym member might have referred to such symbols (see the
testcase with the local static, that used to segfault).
For fixing this (can be seen better with valgrind and SYM_DEBUG)
simply leave local symbols of stmt exprs on the stack.
|
| |
|
|
|
|
| |
The include directive needs to be parsed as pp-tokens, not
as token (i.e. no conversion to TOK_STR or TOK_NUM). Also fix
parsing computed includes using quoted strings.
|
| |
|
|
|
|
| |
Register operands of type _Bool weren't correctly getting
the 8-bit sized registers (but rather used the default 32-bit
ones).
|
| |
|
|
|
|
| |
GCC allows register loads for asms based on type mode,
and correctly sized structs/union have an allowed mode
(basically 1,2,4,8 sized aggregates).
|
| |
|
|
|
| |
It's now possible to use symbols defined in C code to be used
from later inline asm blocks. See testcase.
|
| |
|
|
|
|
|
| |
But like GCC do warn about changes in signedness. The latter
leads to some changes in gen_assign_cast to not also warn about
unsigned* = int*
(where GCC warns, but only with extra warnings).
|
| | |
|
| | |
|
| |
|
|
| |
"int * __attribute__((something)) *" is supported by GCC.
|
| |
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
| |
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).
|
| |
|
|
|
| |
Like __FILE__ but always refers to the command line file name also
from inside headers.
|
| |
|
|
| |
Follows GCC implementation.
|
| |
|
|
|
|
|
|
|
|
|
| |
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).
|
| |
|
|
|
| |
This really should be handled implicitly in the preprocessor,
but for now this is enough.
|
| |
|
|
| |
Those should use long or long long type, and generate a 64bit reloc.
|
| |
|
|
|
| |
'p' is conservatively the same as 'r' and 'P' as template
modifier can be ignored in TCC.
|
| |
|
|
|
|
|
| |
struct S { /*nothing*/; int a; };
is an acceptable struct declaration, there may be stray semicolons
in the member list.
|
| |
|
|
| |
In inline extended asm '%q1' refers to the 64bit register of operand 1.
|