Commit Graph

3171 Commits

Author SHA1 Message Date
Danny Milosavljevic
9c0760a4d4 riscv64-asm: Add lb, lh, lw, lbu, lhu, ld, lwu, sb, sh, sw, sd 2021-04-23 20:23:45 +02:00
Danny Milosavljevic
1e37ec4917 riscv64-asm: Add add, addi, sub, addw, addd, addiw, addid, subw, subd, xor, xori, or, ori, and, andi, slt, slti, sltu, sltiu 2021-04-23 20:23:45 +02:00
Danny Milosavljevic
8b1a89fbdf riscv64-asm: Add sll, slli, srl, srli, sra, srai, sllw, slld, slliw, sllid, srlw, srld, srliw, srlid, sraw, srad, sraiw, sraid 2021-04-23 20:23:45 +02:00
Danny Milosavljevic
0b1cc489e1 riscv64-asm: Add lui, auipc 2021-04-23 20:23:45 +02:00
Danny Milosavljevic
e5a898e510 riscv64-asm: Add rdcycle, rdcycleh, rdtime, rdtimeh, rdinstret, rdinstreth 2021-04-23 20:23:45 +02:00
Danny Milosavljevic
4891ab71a0 riscv64-asm: Add fence, fence.i, scall, sbreak, ecall, ebreak, wfi 2021-04-23 20:23:45 +02:00
Danny Milosavljevic
7f3114ebba riscv64-asm: Remove asm_error 2021-04-23 20:23:45 +02:00
herman ten brugge
1432574b2b Fix make lib/stdatomic.c gcc compatible 2021-04-14 12:22:18 +02:00
herman ten brugge
f8e50d23f5 Make lib/stdatomic.c gcc compatible 2021-04-14 11:59:57 +02:00
herman ten brugge
0f0f701212 Fix va_arg fox x86_64 2021-04-13 09:23:13 +02:00
herman ten brugge
d64923c7b4 Fix testcase 125 fox x86_64 2021-04-13 09:13:25 +02:00
Christian Jullien
035ae7d735 Fix Makefile as suggested by Urs Janßen 2021-04-09 14:21:36 +02:00
grischka
48df89e10e stdatomics: tidy & cleanup
- remove any error messages that were just for debugging the
  templates really
- don't use c99 in tcc (array designators etc.)
- remove memory model type (cannot be an own type really)
  and move memory model defines from built-in to stdatomics.h
- apply normal casts to non-pointer atomic_function arguments
- tidy the library support
- add some tests for errors/warnings

Also:
- Makefile: move GIT_HASH stuff from CFLAGS to DEFINES and into
  main section (away from what is included by tests for example)
- tccelf.c/tccgen.c: avoid some warnings with newer GCC
2021-04-09 10:47:35 +02:00
Dmitry Selyutin
4bb3b3cec7 stdatomic: simple counter test 2021-04-05 20:57:05 +03:00
herman ten brugge
aa7727964b plt-reloc fix for macos 2021-04-02 12:51:38 +02:00
Christian Jullien
affd736f19 Add 'modified' before hash when tcc is built from a patched mob version. 2021-04-02 08:00:31 +02:00
Christian Jullien
f68b39b922 Surround hash code with double quotes 2021-03-31 23:15:47 +02:00
Christian Jullien
65d00b13d5 tcc -v displays short hash to ease detection of source version used to compile tcc 2021-03-31 22:24:29 +02:00
Dmitry Selyutin
47da8e450e stdatomic: ld/st/xchg/cmpxchg on simple types
Some complex types can still be small and simple enough to fit into
register. Other compilers allow some operations on these types, and it
seems to be quite a reasonable choice. From now on, we should be able
to compile the following artificial example:

    struct combo {
        uint16_t lo;
        uint16_t hi;
    };

    struct combo load(const _Atomic(struct combo) *atom)
    {
        return atomic_load(atom);
    }

    void store(_Atomic(struct combo) *atom, struct combo value)
    {
        atomic_store(atom, value);
    }

    struct combo xchg(_Atomic(struct combo) *atom, struct combo value)
    {
        return atomic_exchange(atom, value);
    }

    bool cmpxchg(_Atomic(struct combo) *atom,
            struct combo *cmp, struct combo xchg)
    {
        return atomic_compare_exchange_strong(atom, cmp, xchg);
    }

This might be useful for some corner cases, though it is quite likely
that many programmers will prefer operating on a single 32-bit value
instead of using the structure consisting of 16-bit pair.

Things will work as long as the overall structure size happens to be
the same as for any integer type we support in atomics.
2021-03-25 22:45:58 +03:00
Michael Wilder
82b0af7450 Fix empty initializer compile error on win32 2021-03-18 18:45:28 -04:00
Dmitry Selyutin
9ed3de91a2 stdatomic: i386/x86_64 support 2021-03-17 00:33:59 +03:00
Dmitry Selyutin
806b3f987e stdatomic: fix warnings 2021-03-17 00:29:57 +03:00
Dmitry Selyutin
1ff8679e79 stdatomic: refactor parser and generator 2021-03-09 12:24:08 +03:00
Christian Jullien
d0d0c8b688 [macOS]: arm64, define both __aarch64__ and __arm64__ which are tested by standard include files. WIP 2021-02-21 11:56:16 +01:00
Christian Jullien
310d49668e [macOS]: arm64, add OBJ-arm64-osx lib object list. 2021-02-21 11:32:59 +01:00
Christian Jullien
ac8af47d7f [macOS]: arm64, correctly find clang which is not a symblink from cc 2021-02-21 10:54:49 +01:00
Christian Jullien
e8bff295f9 [macOS]: arm64, very early stage of Big Sur M1 native port. 2021-02-21 08:38:39 +01:00
grischka
97800177c9 tccgen: gen_cast(): detect 'cast from void' error 2021-02-19 09:55:40 +01:00
grischka
72f1dea537 tccelf: use rodata_section, use more rodata in tcc itself
libtcc.c: add -Wwrite-strings to -Wall
tccgen.c: ro float-consts, string-consts, ro arrays if base type is
tccpe.c: merge IAT with rodata
tccrun.c: mprotect rodata accordingly. free section data after copy
x86_64.c: do not use got for static data.
tcc -bench: show data.rw/ro

Probably STB_LOCAL should never get to put_got_entry(), and currently
it doesn't seem to happen (See "Hack Alarm" there)

Other files: use more ro-data in tinycc
2021-02-18 14:43:34 +01:00
grischka
02795106e1 tccelf: use plt-reloc instead of relocplt 2021-02-18 14:42:59 +01:00
grischka
e4f151c4cd tccgen: fix "Allow declared arrays to be initialized..."
See 355897a920
2021-02-18 14:04:53 +01:00
CodeHz
a1d10c8bde
Fix unnecessary symbol collision 2021-02-18 20:41:47 +08:00
Michael Matz
5201312cb2 Fix segfault with nested flex array structs
when used with string initialization the size of nested struct flex
array member was tested too late for < 0.

GCC accepts but discards such initializers (the flex array member will
become zero sized).  TCC supports flex arrays members only in
top-level structs and gives an error in this case.
2021-02-16 00:01:28 +01:00
herman ten brugge
3658c29b43 Add config pie option
Allow configure --config-pie for netbsd arm
2021-02-15 19:14:48 +01:00
herman ten brugge
87dcba16eb Fix tcov align and lock 2021-02-15 19:10:13 +01:00
herman ten brugge
f5b8444739 Fix declared arrays without size 2021-02-15 19:05:26 +01:00
Dmitry Selyutin
dd5b546bf7 stdatomic: atomic_init routine 2021-02-14 22:22:27 +03:00
Arthur Williams
355897a920 Allow declared arrays to be initialized without an explicit size
When defining an array with non-explicit size, one would get
"incompatible types for redefinition of 'array' if the array was already
declared with a different size.
For example:

    extern int array[2];
    int array[] = {1};

would fail to compile with tcc. Instead the above is now equivalent to:
    int array[] = {1, 0};
2021-02-13 19:18:08 -08:00
Michael Matz
d7f2775af8 Fix endless recursion due to type scoping
this change fixes building of invalid types.  The inner scope
struct P is return type of the forward decl foobar.  The outer scope
foobar() call implicitely declares that function again, with int
return type; overall this leads to access within the sym free list,
effectively building up a type directly referring to itself, leading
to endless recursion later.  The testcase is:

void n(void)
{
    {
      struct P {
          int __val;
      };
      struct P foobar(); // 1
    }
  foobar();  // 2
}

I've not included it in tests2 for now, because tcc accepts this.
Ideally we would like to reject it (as 'int foobar();' is incompatible
with the earlier decl).  clang also accepts it, but only because it's
not handling (1) above as an implicit decl of foobar (it warns, and
with -pedantic also warns about the type incompatiblity).  GCC rejects
this.

Implementing that in tcc requires some surgery, as we need to differ
between these cases:

  {  struct P foo(int); // 1
     foo();        // no implicit decl, call to foo from 1
  }

and

  { { struct P foo(int); // 2 }
    foo();         // implicit decl, _incompatible_ with 2
  }
2021-02-13 03:29:43 +01:00
Danny Milosavljevic
24c94fff09
arm-asm: Add vcvt 2021-02-13 01:03:41 +01:00
Danny Milosavljevic
f1fb23a661
arm-asm: Update comment 2021-02-13 01:03:39 +01:00
Michael Matz
30814dfacf Don't use stale section data pointers
put_elf_reloca might reallocate the section into which we point,
so don't remember the pointer just the offset.
2021-02-13 00:37:12 +01:00
Michael Matz
468e59206b Clear vtop.sym if saving on stack
normally the sym slot is meaningful only with VT_SYM.  But we also
use it when mentioning a decl for inline asms with register vars,
conditional on being a VT_LOCAL entry.  So when generating VT_LOCAL we
need to reset .sym as it might contain stale entries from the cmp_op
fields.
2021-02-13 00:24:29 +01:00
Michael Matz
ce8814cdd6 Avoid array overflow
with fuzzed source code we might run into this with idx out of bounds.
We're going to error out on this later, but let's not access
out-of-bounds elements.
2021-02-12 23:46:21 +01:00
Michael Matz
c4ae326a1d Revert "Long double Constant problem"
This reverts commit 405aef9155.
It doesn't compile (init_putv has no 'f1') and isn't necessary with a
compiler doing proper value initialization.
2021-02-12 22:52:05 +01:00
ayush-varshney
405aef9155 Long double Constant problem 2021-02-11 08:49:58 +01:00
Michael Matz
fbef90a703 Fix a VLA problem
see testcase, reduced example of a situation reported by
Kyryl Melekhin in https://github.com/kyx0r/neatvi/ .
Problem is that setting up the VLA sp-save in a scope that isn't
entered at runtime leaves traces of it in outer scopes that then
try to restore the stack pointer from uninitialized slots.
2021-02-03 04:30:11 +01:00
Danny Milosavljevic
d6f2d58158
Relicensing TinyCC 2021-02-02 14:07:43 +01:00
Riccardo Schirone
ad16628c9e Make sure to escape paths in generated make dependencies
If spaces are not escaped when generating the make dependencies file,
then if one of the dependencies has a space it would be interpreted as
two separate targets by Make, instead of just one.
2021-01-30 00:51:15 +01:00
Danny Milosavljevic
2ac8568503
arm-asm: Support immediate values without "#" (Unified Assembly Language) 2021-01-28 16:32:31 +01:00