History

get rid of trailing whitespace

Sigrid Solveig Haflínudóttir committed 10 months ago

Commit bbe19211 parent 3c1ac7030 files · +348 −348Browse files

Unified · Split

30 files
  1. c67-gen.c +40 −40
  2. coff.h +15 −15
  3. i386-asm.h +5 −5
  4. i386-gen.c +4 −4
  5. il-gen.c +7 −7
  6. il-opcodes.h +1 −1
  7. lib/bcheck.c +15 −15
  8. lib/builtin.c +2 −2
  9. lib/libtcc1.c +12 −12
  10. lib/tcov.c +5 −5
  11. stab.def +2 −2
  12. tcc-doc.texi +23 −23
  13. tcc.c +1 −1
  14. tccasm.c +22 −22
  15. tcccoff.c +2 −2
  16. tccgen.c +32 −32
  17. tcclib.h +3 −3
  18. tccmacho.c +8 −8
  19. tccpe.c +1 −1
  20. tccpp.c +19 −19
  21. tccrun.c +2 −2
  22. tests/abitest.c +15 −15
  23. tests/asmtest.S +30 −30
  24. tests/boundtest.c +2 −2
  25. tests/tcctest.c +51 −51
  26. tests/vla_test.c +2 −2
  27. texi2pod.pl +1 −1
  28. win32/tcc-win32.txt +1 −1
  29. x86_64-asm.h +1 −1
  30. x86_64-gen.c +24 −24
c67-gen.c+40−40
@@ -1,6 +1,6 @@
1/*1/*
2 * TMS320C67xx code generator for TCC2 * TMS320C67xx code generator for TCC
3 * 3 *
4 * Copyright (c) 2001, 2002 Fabrice Bellard4 * Copyright (c) 2001, 2002 Fabrice Bellard
5 *5 *
6 * This library is free software; you can redistribute it and/or6 * This library is free software; you can redistribute it and/or
@@ -152,7 +152,7 @@ ST_DATA const int reg_classes[NB_REGS] = { · 145 unmodified lines
152// although tcc thinks it is passing parameters on the stack,152// although tcc thinks it is passing parameters on the stack,
153// the C67 really passes up to the first 10 params in special153// the C67 really passes up to the first 10 params in special
154// regs or regs pairs (for 64 bit params). So keep track of154// regs or regs pairs (for 64 bit params). So keep track of
155// the stack offsets so we can translate to the appropriate 155// the stack offsets so we can translate to the appropriate
156// reg (pair)156// reg (pair)
157 157
158#define NoCallArgsPassedOnStack 10158#define NoCallArgsPassedOnStack 10
@@ -233,7 +233,7 @@ void gsym_addr(int t, int a) · 74 unmodified lines
233 }233 }
234}234}
235 235
236// these are regs that tcc doesn't really know about, 236// these are regs that tcc doesn't really know about,
237// but assign them unique values so the mapping routines237// but assign them unique values so the mapping routines
238// can distinguish them238// can distinguish them
239 239
@@ -285,7 +285,7 @@ int C67_map_regn(int r) · 45 unmodified lines
285 return 0;285 return 0;
286}286}
287 287
288// mapping from tcc reg number to 288// mapping from tcc reg number to
289// C67 register to condition code field289// C67 register to condition code field
290//290//
291// valid condition code regs are:291// valid condition code regs are:
@@ -330,15 +330,15 @@ int C67_map_regs(int r) · 38 unmodified lines
330 else if (r >= TREG_C67_A4 && r <= TREG_C67_B13) // these form a pattern of alt pairs330 else if (r >= TREG_C67_A4 && r <= TREG_C67_B13) // these form a pattern of alt pairs
331 return (r & 2) >> 1;331 return (r & 2) >> 1;
332 else if (r == C67_A0)332 else if (r == C67_A0)
333 return 0; // set to A side 333 return 0; // set to A side
334 else if (r == C67_B2)334 else if (r == C67_B2)
335 return 1; // set to B side 335 return 1; // set to B side
336 else if (r == C67_B3)336 else if (r == C67_B3)
337 return 1; // set to B side337 return 1; // set to B side
338 else if (r == C67_SP)338 else if (r == C67_SP)
339 return 0x1; // set to SP (B15) B side 339 return 0x1; // set to SP (B15) B side
340 else if (r == C67_FP)340 else if (r == C67_FP)
341 return 0x0; // set to FP (A15) A side 341 return 0x0; // set to FP (A15) A side
342 else342 else
343 ALWAYS_ASSERT(FALSE);343 ALWAYS_ASSERT(FALSE);
344 344
@@ -407,7 +407,7 @@ void C67_asm(const char *s, int a, int b, int c) · 62 unmodified lines
407 (5 << 9) | //mode 5 = pos offset, base reg + off reg407 (5 << 9) | //mode 5 = pos offset, base reg + off reg
408 (0 << 8) | //r (LDDW bit 0)408 (0 << 8) | //r (LDDW bit 0)
409 (0 << 7) | //y D1/D2 A side409 (0 << 7) | //y D1/D2 A side
410 (3 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 410 (3 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
411 (1 << 2) | //opcode411 (1 << 2) | //opcode
412 (C67_map_regs(a) << 1) | //side of src412 (C67_map_regs(a) << 1) | //side of src
413 (0 << 0)); //parallel413 (0 << 0)); //parallel
@@ -429,7 +429,7 @@ void C67_asm(const char *s, int a, int b, int c) · 15 unmodified lines
429 (5 << 9) | //mode 5 = pos offset, base reg + off reg429 (5 << 9) | //mode 5 = pos offset, base reg + off reg
430 (0 << 8) | //r (LDDW bit 0)430 (0 << 8) | //r (LDDW bit 0)
431 (0 << 7) | //y D1/D2 A side431 (0 << 7) | //y D1/D2 A side
432 (3 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 432 (3 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
433 (1 << 2) | //opcode433 (1 << 2) | //opcode
434 (C67_map_regs(a) << 1) | //side of src434 (C67_map_regs(a) << 1) | //side of src
435 (0 << 0)); //parallel435 (0 << 0)); //parallel
@@ -451,7 +451,7 @@ void C67_asm(const char *s, int a, int b, int c) · 15 unmodified lines
451 (5 << 9) | //mode 5 = pos offset, base reg + off reg451 (5 << 9) | //mode 5 = pos offset, base reg + off reg
452 (0 << 8) | //r (LDDW bit 0)452 (0 << 8) | //r (LDDW bit 0)
453 (0 << 7) | //y D1/D2 A side453 (0 << 7) | //y D1/D2 A side
454 (7 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 454 (7 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
455 (1 << 2) | //opcode455 (1 << 2) | //opcode
456 (C67_map_regs(a) << 1) | //side of src456 (C67_map_regs(a) << 1) | //side of src
457 (0 << 0)); //parallel457 (0 << 0)); //parallel
@@ -462,7 +462,7 @@ void C67_asm(const char *s, int a, int b, int c) · 4 unmodified lines
462 (1 << 9) | //mode 1 = pos cst offset462 (1 << 9) | //mode 1 = pos cst offset
463 (0 << 8) | //r (LDDW bit 0)463 (0 << 8) | //r (LDDW bit 0)
464 (C67_map_regs(b) << 7) | //y D1/D2 base reg side464 (C67_map_regs(b) << 7) | //y D1/D2 base reg side
465 (7 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 465 (7 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
466 (1 << 2) | //opcode466 (1 << 2) | //opcode
467 (C67_map_regs(a) << 1) | //side of src467 (C67_map_regs(a) << 1) | //side of src
468 (0 << 0)); //parallel468 (0 << 0)); //parallel
@@ -473,7 +473,7 @@ void C67_asm(const char *s, int a, int b, int c) · 4 unmodified lines
473 (1 << 9) | //mode 1 = pos cst offset473 (1 << 9) | //mode 1 = pos cst offset
474 (0 << 8) | //r (LDDW bit 0)474 (0 << 8) | //r (LDDW bit 0)
475 (C67_map_regs(b) << 7) | //y D1/D2 base reg side475 (C67_map_regs(b) << 7) | //y D1/D2 base reg side
476 (5 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 476 (5 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
477 (1 << 2) | //opcode477 (1 << 2) | //opcode
478 (C67_map_regs(a) << 1) | //side of src478 (C67_map_regs(a) << 1) | //side of src
479 (0 << 0)); //parallel479 (0 << 0)); //parallel
@@ -484,7 +484,7 @@ void C67_asm(const char *s, int a, int b, int c) · 4 unmodified lines
484 (1 << 9) | //mode 1 = pos cst offset484 (1 << 9) | //mode 1 = pos cst offset
485 (0 << 8) | //r (LDDW bit 0)485 (0 << 8) | //r (LDDW bit 0)
486 (C67_map_regs(b) << 7) | //y D1/D2 base reg side486 (C67_map_regs(b) << 7) | //y D1/D2 base reg side
487 (3 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 487 (3 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
488 (1 << 2) | //opcode488 (1 << 2) | //opcode
489 (C67_map_regs(a) << 1) | //side of src489 (C67_map_regs(a) << 1) | //side of src
490 (0 << 0)); //parallel490 (0 << 0)); //parallel
@@ -496,7 +496,7 @@ void C67_asm(const char *s, int a, int b, int c) · 5 unmodified lines
496 (1 << 9) | //mode 1 = pos cst offset496 (1 << 9) | //mode 1 = pos cst offset
497 (0 << 8) | //r (LDDW bit 0)497 (0 << 8) | //r (LDDW bit 0)
498 (C67_map_regs(b) << 7) | //y D1/D2 base reg side498 (C67_map_regs(b) << 7) | //y D1/D2 base reg side
499 (7 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 499 (7 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
500 (1 << 2) | //opcode500 (1 << 2) | //opcode
501 (C67_map_regs(a) << 1) | //side of src501 (C67_map_regs(a) << 1) | //side of src
502 (0 << 0)); //parallel502 (0 << 0)); //parallel
@@ -628,7 +628,7 @@ void C67_asm(const char *s, int a, int b, int c) · 125 unmodified lines
628 (1 << 9) | //mode 1 = pos cst offset628 (1 << 9) | //mode 1 = pos cst offset
629 (0 << 8) | //r (LDDW bit 0)629 (0 << 8) | //r (LDDW bit 0)
630 (C67_map_regs(a) << 7) | //y D1/D2 src side630 (C67_map_regs(a) << 7) | //y D1/D2 src side
631 (2 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 631 (2 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
632 (1 << 2) | //opcode632 (1 << 2) | //opcode
633 (C67_map_regs(b) << 1) | //side of dst633 (C67_map_regs(b) << 1) | //side of dst
634 (0 << 0)); //parallel634 (0 << 0)); //parallel
@@ -639,7 +639,7 @@ void C67_asm(const char *s, int a, int b, int c) · 4 unmodified lines
639 (1 << 9) | //mode 1 = pos cst offset639 (1 << 9) | //mode 1 = pos cst offset
640 (0 << 8) | //r (LDDW bit 0)640 (0 << 8) | //r (LDDW bit 0)
641 (C67_map_regs(a) << 7) | //y D1/D2 src side641 (C67_map_regs(a) << 7) | //y D1/D2 src side
642 (0 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 642 (0 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
643 (1 << 2) | //opcode643 (1 << 2) | //opcode
644 (C67_map_regs(b) << 1) | //side of dst644 (C67_map_regs(b) << 1) | //side of dst
645 (0 << 0)); //parallel645 (0 << 0)); //parallel
@@ -661,7 +661,7 @@ void C67_asm(const char *s, int a, int b, int c) · 15 unmodified lines
661 (1 << 9) | //mode 1 = pos cst offset661 (1 << 9) | //mode 1 = pos cst offset
662 (0 << 8) | //r (LDDW bit 0)662 (0 << 8) | //r (LDDW bit 0)
663 (C67_map_regs(a) << 7) | //y D1/D2 src side663 (C67_map_regs(a) << 7) | //y D1/D2 src side
664 (6 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU 664 (6 << 4) | //ldst 3=STB, 5=STH 5, 7=STW, 6=LDW 4=LDH 2=LDB 0=LDHU 1=LDBU
665 (1 << 2) | //opcode665 (1 << 2) | //opcode
666 (C67_map_regs(b) << 1) | //side of dst666 (C67_map_regs(b) << 1) | //side of dst
667 (0 << 0)); //parallel667 (0 << 0)); //parallel
@@ -864,7 +864,7 @@ void C67_asm(const char *s, int a, int b, int c) · 196 unmodified lines
864 C67_g((0 << 29) | //creg864 C67_g((0 << 29) | //creg
865 (0 << 28) | //inv865 (0 << 28) | //inv
866 (C67_map_regn(c) << 23) | //dst866 (C67_map_regn(c) << 23) | //dst
867 (C67_map_regn(b) << 18) | //src2 867 (C67_map_regn(b) << 18) | //src2
868 (0 << 13) | //src1 NA868 (0 << 13) | //src1 NA
869 (xpath << 12) | //x cross path if opposite sides869 (xpath << 12) | //x cross path if opposite sides
870 (0x4a << 5) | //opcode870 (0x4a << 5) | //opcode
@@ -877,7 +877,7 @@ void C67_asm(const char *s, int a, int b, int c) · 6 unmodified lines
877 C67_g((0 << 29) | //creg877 C67_g((0 << 29) | //creg
878 (0 << 28) | //inv878 (0 << 28) | //inv
879 (C67_map_regn(c) << 23) | //dst879 (C67_map_regn(c) << 23) | //dst
880 (C67_map_regn(b) << 18) | //src2 880 (C67_map_regn(b) << 18) | //src2
881 (0 << 13) | //src1 NA881 (0 << 13) | //src1 NA
882 (xpath << 12) | //x cross path if opposite sides882 (xpath << 12) | //x cross path if opposite sides
883 (0x49 << 5) | //opcode883 (0x49 << 5) | //opcode
@@ -890,7 +890,7 @@ void C67_asm(const char *s, int a, int b, int c) · 6 unmodified lines
890 C67_g((0 << 29) | //creg890 C67_g((0 << 29) | //creg
891 (0 << 28) | //inv891 (0 << 28) | //inv
892 (C67_map_regn(c) << 23) | //dst892 (C67_map_regn(c) << 23) | //dst
893 (C67_map_regn(b) << 18) | //src2 893 (C67_map_regn(b) << 18) | //src2
894 (0 << 13) | //src1 NA894 (0 << 13) | //src1 NA
895 (xpath << 12) | //x cross path if opposite sides895 (xpath << 12) | //x cross path if opposite sides
896 (0x39 << 5) | //opcode896 (0x39 << 5) | //opcode
@@ -945,7 +945,7 @@ void C67_asm(const char *s, int a, int b, int c) · 48 unmodified lines
945 (0 << 28) | //inv945 (0 << 28) | //inv
946 (C67_map_regn(c) << 23) | //dst946 (C67_map_regn(c) << 23) | //dst
947 (C67_map_regn(b) << 18) | //src2 (possible x path)947 (C67_map_regn(b) << 18) | //src2 (possible x path)
948 (C67_map_regn(a) << 13) | //src1 948 (C67_map_regn(a) << 13) | //src1
949 (xpath << 12) | //x cross path if opposite sides949 (xpath << 12) | //x cross path if opposite sides
950 (0x3 << 5) | //opcode950 (0x3 << 5) | //opcode
951 (0x6 << 2) | //opcode fixed951 (0x6 << 2) | //opcode fixed
@@ -960,7 +960,7 @@ void C67_asm(const char *s, int a, int b, int c) · 8 unmodified lines
960 (0 << 28) | //inv960 (0 << 28) | //inv
961 (C67_map_regn(c) << 23) | //dst961 (C67_map_regn(c) << 23) | //dst
962 (C67_map_regn(b) << 18) | //src2 (possible x path)962 (C67_map_regn(b) << 18) | //src2 (possible x path)
963 (C67_map_regn(a) << 13) | //src1 963 (C67_map_regn(a) << 13) | //src1
964 (xpath << 12) | //x cross path if opposite sides964 (xpath << 12) | //x cross path if opposite sides
965 (0x7 << 5) | //opcode965 (0x7 << 5) | //opcode
966 (0x6 << 2) | //opcode fixed966 (0x6 << 2) | //opcode fixed
@@ -975,7 +975,7 @@ void C67_asm(const char *s, int a, int b, int c) · 8 unmodified lines
975 (0 << 28) | //inv975 (0 << 28) | //inv
976 (C67_map_regn(c) << 23) | //dst976 (C67_map_regn(c) << 23) | //dst
977 (C67_map_regn(b) << 18) | //src2 (possible x path)977 (C67_map_regn(b) << 18) | //src2 (possible x path)
978 (C67_map_regn(a) << 13) | //src1 978 (C67_map_regn(a) << 13) | //src1
979 (xpath << 12) | //x cross path if opposite sides979 (xpath << 12) | //x cross path if opposite sides
980 (0x7f << 5) | //opcode980 (0x7f << 5) | //opcode
981 (0x6 << 2) | //opcode fixed981 (0x6 << 2) | //opcode fixed
@@ -990,7 +990,7 @@ void C67_asm(const char *s, int a, int b, int c) · 8 unmodified lines
990 (0 << 28) | //inv990 (0 << 28) | //inv
991 (C67_map_regn(c) << 23) | //dst991 (C67_map_regn(c) << 23) | //dst
992 (C67_map_regn(b) << 18) | //src2 (possible x path)992 (C67_map_regn(b) << 18) | //src2 (possible x path)
993 (C67_map_regn(a) << 13) | //src1 993 (C67_map_regn(a) << 13) | //src1
994 (xpath << 12) | //x cross path if opposite sides994 (xpath << 12) | //x cross path if opposite sides
995 (0x7b << 5) | //opcode995 (0x7b << 5) | //opcode
996 (0x6 << 2) | //opcode fixed996 (0x6 << 2) | //opcode fixed
@@ -1005,7 +1005,7 @@ void C67_asm(const char *s, int a, int b, int c) · 8 unmodified lines
1005 (0 << 28) | //inv1005 (0 << 28) | //inv
1006 (C67_map_regn(c) << 23) | //dst1006 (C67_map_regn(c) << 23) | //dst
1007 (C67_map_regn(b) << 18) | //src2 (possible x path)1007 (C67_map_regn(b) << 18) | //src2 (possible x path)
1008 (C67_map_regn(a) << 13) | //src1 1008 (C67_map_regn(a) << 13) | //src1
1009 (xpath << 12) | //x cross path if opposite sides1009 (xpath << 12) | //x cross path if opposite sides
1010 (0x6f << 5) | //opcode1010 (0x6f << 5) | //opcode
1011 (0x6 << 2) | //opcode fixed1011 (0x6 << 2) | //opcode fixed
@@ -1020,7 +1020,7 @@ void C67_asm(const char *s, int a, int b, int c) · 8 unmodified lines
1020 (0 << 28) | //inv1020 (0 << 28) | //inv
1021 (C67_map_regn(c) << 23) | //dst1021 (C67_map_regn(c) << 23) | //dst
1022 (C67_map_regn(b) << 18) | //src2 (possible x path)1022 (C67_map_regn(b) << 18) | //src2 (possible x path)
1023 (C67_map_regn(a) << 13) | //src1 1023 (C67_map_regn(a) << 13) | //src1
1024 (xpath << 12) | //x cross path if opposite sides1024 (xpath << 12) | //x cross path if opposite sides
1025 (0x10 << 5) | //opcode1025 (0x10 << 5) | //opcode
1026 (0x6 << 2) | //opcode fixed1026 (0x6 << 2) | //opcode fixed
@@ -1035,7 +1035,7 @@ void C67_asm(const char *s, int a, int b, int c) · 8 unmodified lines
1035 (0 << 28) | //inv1035 (0 << 28) | //inv
1036 (C67_map_regn(c) << 23) | //dst1036 (C67_map_regn(c) << 23) | //dst
1037 (C67_map_regn(b) << 18) | //src2 (possible x path)1037 (C67_map_regn(b) << 18) | //src2 (possible x path)
1038 (C67_map_regn(a) << 13) | //src1 1038 (C67_map_regn(a) << 13) | //src1
1039 (xpath << 12) | //x cross path if opposite sides1039 (xpath << 12) | //x cross path if opposite sides
1040 (0x18 << 5) | //opcode1040 (0x18 << 5) | //opcode
1041 (0x6 << 2) | //opcode fixed1041 (0x6 << 2) | //opcode fixed
@@ -1050,7 +1050,7 @@ void C67_asm(const char *s, int a, int b, int c) · 8 unmodified lines
1050 (0 << 28) | //inv1050 (0 << 28) | //inv
1051 (C67_map_regn(c) << 23) | //dst1051 (C67_map_regn(c) << 23) | //dst
1052 (C67_map_regn(b) << 18) | //src2 (possible x path)1052 (C67_map_regn(b) << 18) | //src2 (possible x path)
1053 (C67_map_regn(a) << 13) | //src1 1053 (C67_map_regn(a) << 13) | //src1
1054 (xpath << 12) | //x cross path if opposite sides1054 (xpath << 12) | //x cross path if opposite sides
1055 (0x11 << 5) | //opcode1055 (0x11 << 5) | //opcode
1056 (0x6 << 2) | //opcode fixed1056 (0x6 << 2) | //opcode fixed
@@ -1065,7 +1065,7 @@ void C67_asm(const char *s, int a, int b, int c) · 8 unmodified lines
1065 (0 << 28) | //inv1065 (0 << 28) | //inv
1066 (C67_map_regn(c) << 23) | //dst1066 (C67_map_regn(c) << 23) | //dst
1067 (C67_map_regn(b) << 18) | //src2 (possible x path)1067 (C67_map_regn(b) << 18) | //src2 (possible x path)
1068 (C67_map_regn(a) << 13) | //src1 1068 (C67_map_regn(a) << 13) | //src1
1069 (xpath << 12) | //x cross path if opposite sides1069 (xpath << 12) | //x cross path if opposite sides
1070 (0x19 << 5) | //opcode1070 (0x19 << 5) | //opcode
1071 (0x6 << 2) | //opcode fixed1071 (0x6 << 2) | //opcode fixed
@@ -1080,7 +1080,7 @@ void C67_asm(const char *s, int a, int b, int c) · 8 unmodified lines
1080 (0 << 28) | //inv1080 (0 << 28) | //inv
1081 (C67_map_regn(c) << 23) | //dst1081 (C67_map_regn(c) << 23) | //dst
1082 (C67_map_regn(b) << 18) | //src2 (possible x path)1082 (C67_map_regn(b) << 18) | //src2 (possible x path)
1083 (C67_map_regn(a) << 13) | //src1 1083 (C67_map_regn(a) << 13) | //src1
1084 (xpath << 12) | //x cross path if opposite sides1084 (xpath << 12) | //x cross path if opposite sides
1085 (0x1c << 7) | //opcode1085 (0x1c << 7) | //opcode
1086 (0x0 << 2) | //opcode fixed1086 (0x0 << 2) | //opcode fixed
@@ -1095,7 +1095,7 @@ void C67_asm(const char *s, int a, int b, int c) · 8 unmodified lines
1095 (0 << 28) | //inv1095 (0 << 28) | //inv
1096 (C67_map_regn(c) << 23) | //dst1096 (C67_map_regn(c) << 23) | //dst
1097 (C67_map_regn(b) << 18) | //src2 (possible x path)1097 (C67_map_regn(b) << 18) | //src2 (possible x path)
1098 (C67_map_regn(a) << 13) | //src1 1098 (C67_map_regn(a) << 13) | //src1
1099 (xpath << 12) | //x cross path if opposite sides1099 (xpath << 12) | //x cross path if opposite sides
1100 (0x0e << 7) | //opcode1100 (0x0e << 7) | //opcode
1101 (0x0 << 2) | //opcode fixed1101 (0x0 << 2) | //opcode fixed
@@ -1125,7 +1125,7 @@ void C67_asm(const char *s, int a, int b, int c) · 23 unmodified lines
1125 (0 << 28) | //inv1125 (0 << 28) | //inv
1126 (C67_map_regn(c) << 23) | //dst1126 (C67_map_regn(c) << 23) | //dst
1127 (C67_map_regn(b) << 18) | //src21127 (C67_map_regn(b) << 18) | //src2
1128 (C67_map_regn(a) << 13) | //src1 1128 (C67_map_regn(a) << 13) | //src1
1129 (xpath << 12) | //x cross path if opposite sides1129 (xpath << 12) | //x cross path if opposite sides
1130 (0x37 << 6) | //opcode1130 (0x37 << 6) | //opcode
1131 (0x8 << 2) | //opcode fixed1131 (0x8 << 2) | //opcode fixed
@@ -1140,7 +1140,7 @@ void C67_asm(const char *s, int a, int b, int c) · 8 unmodified lines
1140 (0 << 28) | //inv1140 (0 << 28) | //inv
1141 (C67_map_regn(c) << 23) | //dst1141 (C67_map_regn(c) << 23) | //dst
1142 (C67_map_regn(b) << 18) | //src21142 (C67_map_regn(b) << 18) | //src2
1143 (C67_map_regn(a) << 13) | //src1 1143 (C67_map_regn(a) << 13) | //src1
1144 (xpath << 12) | //x cross path if opposite sides1144 (xpath << 12) | //x cross path if opposite sides
1145 (0x27 << 6) | //opcode1145 (0x27 << 6) | //opcode
1146 (0x8 << 2) | //opcode fixed1146 (0x8 << 2) | //opcode fixed
@@ -1155,7 +1155,7 @@ void C67_asm(const char *s, int a, int b, int c) · 8 unmodified lines
1155 (0 << 28) | //inv1155 (0 << 28) | //inv
1156 (C67_map_regn(c) << 23) | //dst1156 (C67_map_regn(c) << 23) | //dst
1157 (C67_map_regn(b) << 18) | //src21157 (C67_map_regn(b) << 18) | //src2
1158 (C67_map_regn(a) << 13) | //src1 1158 (C67_map_regn(a) << 13) | //src1
1159 (xpath << 12) | //x cross path if opposite sides1159 (xpath << 12) | //x cross path if opposite sides
1160 (0x33 << 6) | //opcode1160 (0x33 << 6) | //opcode
1161 (0x8 << 2) | //opcode fixed1161 (0x8 << 2) | //opcode fixed
@@ -1584,7 +1584,7 @@ void load(int r, SValue * sv) · 422 unmodified lines
1584 size = 4;1584 size = 4;
1585 }1585 }
1586 1586
1587 // check if fc is a positive reference on the stack, 1587 // check if fc is a positive reference on the stack,
1588 // if it is tcc is referencing what it thinks is a parameter1588 // if it is tcc is referencing what it thinks is a parameter
1589 // on the stack, so check if it is really in a register.1589 // on the stack, so check if it is really in a register.
1590 1590
@@ -1942,7 +1942,7 @@ void gfunc_call(int nb_args) · 351 unmodified lines
1942// ending with B12:B13.1942// ending with B12:B13.
1943//1943//
1944// When a call is made, if the caller has its parameters1944// When a call is made, if the caller has its parameters
1945// in regs A4-B13 these must be saved before/as the call 1945// in regs A4-B13 these must be saved before/as the call
1946// parameters are loaded and restored upon return (or if/when needed).1946// parameters are loaded and restored upon return (or if/when needed).
1947 1947
1948/* generate function prolog of type 't' */1948/* generate function prolog of type 't' */
@@ -2012,7 +2012,7 @@ void gfunc_prolog(Sym *func_sym) · 63 unmodified lines
2012 2012
2013 TotalBytesPushedOnStack = -loc;2013 TotalBytesPushedOnStack = -loc;
2014 2014
2015 func_sub_sp_offset = ind; // remember where we put the stack instruction 2015 func_sub_sp_offset = ind; // remember where we put the stack instruction
2016 C67_ADDK(0, C67_SP); // ADDK.L2 loc,SP (just put zero temporarily)2016 C67_ADDK(0, C67_SP); // ADDK.L2 loc,SP (just put zero temporarily)
2017 2017
2018 C67_PUSH(C67_A0);2018 C67_PUSH(C67_A0);
@@ -2028,11 +2028,11 @@ void gfunc_epilog(void) · 9 unmodified lines
2028 C67_NOP(4); // NOP wait for load2028 C67_NOP(4); // NOP wait for load
2029 C67_IREG_B_REG(0, C67_CREG_ZERO, C67_B3); // B.S2 B32029 C67_IREG_B_REG(0, C67_CREG_ZERO, C67_B3); // B.S2 B3
2030 C67_POP(C67_FP);2030 C67_POP(C67_FP);
2031 C67_ADDK(local, C67_SP); // ADDK.L2 loc,SP 2031 C67_ADDK(local, C67_SP); // ADDK.L2 loc,SP
2032 C67_Adjust_ADDK((int *) (cur_text_section->data +2032 C67_Adjust_ADDK((int *) (cur_text_section->data +
2033 func_sub_sp_offset),2033 func_sub_sp_offset),
2034 -local + TotalBytesPushedOnStack);2034 -local + TotalBytesPushedOnStack);
2035 C67_NOP(3); // NOP 2035 C67_NOP(3); // NOP
2036 }2036 }
2037}2037}
2038 2038
coff.h+15−15
@@ -31,9 +31,9 @@ struct filehdr { · 30 unmodified lines
31#define F_LITTLE 0x100 /* byte ordering of an AR32WR (vax) */31#define F_LITTLE 0x100 /* byte ordering of an AR32WR (vax) */
32#define F_BIG 0x200 /* byte ordering of an AR32W (3B, maxi) */32#define F_BIG 0x200 /* byte ordering of an AR32W (3B, maxi) */
33#define F_PATCH 0x400 /* contains "patch" list in optional header */33#define F_PATCH 0x400 /* contains "patch" list in optional header */
34#define F_NODF 0x400 34#define F_NODF 0x400
35 35
36#define F_VERSION (F_GSP10 | F_GSP20) 36#define F_VERSION (F_GSP10 | F_GSP20)
37#define F_BYTE_ORDER (F_LITTLE | F_BIG)37#define F_BYTE_ORDER (F_LITTLE | F_BIG)
38#define FILHDR struct filehdr38#define FILHDR struct filehdr
39 39
@@ -49,7 +49,7 @@ struct filehdr { · 9 unmodified lines
49#define ISARCHIVE(x) ((((unsigned short)(x))==(unsigned short)ARTYPE))49#define ISARCHIVE(x) ((((unsigned short)(x))==(unsigned short)ARTYPE))
50#define BADMAGIC(x) (((unsigned short)(x) & 0x8080) && !ISMAGIC(x))50#define BADMAGIC(x) (((unsigned short)(x) & 0x8080) && !ISMAGIC(x))
51 51
52 52
53/*------------------------------------------------------------------------*/53/*------------------------------------------------------------------------*/
54/* OPTIONAL FILE HEADER */54/* OPTIONAL FILE HEADER */
55/*------------------------------------------------------------------------*/55/*------------------------------------------------------------------------*/
@@ -68,7 +68,7 @@ typedef struct aouthdr { · 12 unmodified lines
68 68
69/*----------------------------------------------------------------------*/69/*----------------------------------------------------------------------*/
70/* When a UNIX aout header is to be built in the optional header, */70/* When a UNIX aout header is to be built in the optional header, */
71/* the following magic numbers can appear in that header: */ 71/* the following magic numbers can appear in that header: */
72/* */72/* */
73/* AOUT1MAGIC : default : readonly sharable text segment */73/* AOUT1MAGIC : default : readonly sharable text segment */
74/* AOUT2MAGIC: : writable text segment */74/* AOUT2MAGIC: : writable text segment */
@@ -78,7 +78,7 @@ typedef struct aouthdr { · 3 unmodified lines
78#define AOUT2MAGIC 040778#define AOUT2MAGIC 0407
79#define PAGEMAGIC 041379#define PAGEMAGIC 0413
80 80
81 81
82/*------------------------------------------------------------------------*/82/*------------------------------------------------------------------------*/
83/* COMMON ARCHIVE FILE STRUCTURES */83/* COMMON ARCHIVE FILE STRUCTURES */
84/* */84/* */
@@ -125,7 +125,7 @@ struct ar_hdr /* archive file member header - printable ascii */ · 40 unmodified lines
125 char ar_fmag[2]; /* ARFMAG - string to end header */125 char ar_fmag[2]; /* ARFMAG - string to end header */
126};126};
127 127
128 128
129/*------------------------------------------------------------------------*/129/*------------------------------------------------------------------------*/
130/* SECTION HEADER */130/* SECTION HEADER */
131/*------------------------------------------------------------------------*/131/*------------------------------------------------------------------------*/
@@ -164,7 +164,7 @@ struct scnhdr { · 32 unmodified lines
164#define STYP_NOLOAD 0x02 /* "noload" : allocated, relocated, not loaded */164#define STYP_NOLOAD 0x02 /* "noload" : allocated, relocated, not loaded */
165#define STYP_GROUP 0x04 /* "grouped" : formed of input sections */165#define STYP_GROUP 0x04 /* "grouped" : formed of input sections */
166#define STYP_PAD 0x08 /* "padding" : not allocated, not relocated, loaded */166#define STYP_PAD 0x08 /* "padding" : not allocated, not relocated, loaded */
167#define STYP_COPY 0x10 /* "copy" : used for C init tables - 167#define STYP_COPY 0x10 /* "copy" : used for C init tables -
168 not allocated, relocated,168 not allocated, relocated,
169 loaded; reloc & lineno169 loaded; reloc & lineno
170 entries processed normally */170 entries processed normally */
@@ -176,7 +176,7 @@ struct scnhdr { · 5 unmodified lines
176#define ALIGN_MASK 0x0F00 /* part of s_flags that is used for align vals */176#define ALIGN_MASK 0x0F00 /* part of s_flags that is used for align vals */
177#define ALIGNSIZE(x) (1 << ((x & ALIGN_MASK) >> 8))177#define ALIGNSIZE(x) (1 << ((x & ALIGN_MASK) >> 8))
178 178
179 179
180/*------------------------------------------------------------------------*/180/*------------------------------------------------------------------------*/
181/* RELOCATION ENTRIES */181/* RELOCATION ENTRIES */
182/*------------------------------------------------------------------------*/182/*------------------------------------------------------------------------*/
@@ -216,7 +216,7 @@ struct reloc · 33 unmodified lines
216#define R_PARTMS9 051 /* DSP: 9 bit page of 16 bit address */216#define R_PARTMS9 051 /* DSP: 9 bit page of 16 bit address */
217#define R_REL13 052 /* DSP: 13 bits, direct */217#define R_REL13 052 /* DSP: 13 bits, direct */
218 218
219 219
220/*------------------------------------------------------------------------*/220/*------------------------------------------------------------------------*/
221/* LINE NUMBER ENTRIES */221/* LINE NUMBER ENTRIES */
222/*------------------------------------------------------------------------*/222/*------------------------------------------------------------------------*/
@@ -234,7 +234,7 @@ struct lineno · 11 unmodified lines
234#define LINENO struct lineno234#define LINENO struct lineno
235#define LINESZ 6 /* sizeof(LINENO) */235#define LINESZ 6 /* sizeof(LINENO) */
236 236
237 237
238/*------------------------------------------------------------------------*/238/*------------------------------------------------------------------------*/
239/* STORAGE CLASSES */239/* STORAGE CLASSES */
240/*------------------------------------------------------------------------*/240/*------------------------------------------------------------------------*/
@@ -267,7 +267,7 @@ struct lineno · 26 unmodified lines
267#define C_ALIAS 105 /* duplicate tag */267#define C_ALIAS 105 /* duplicate tag */
268#define C_HIDDEN 106 /* special storage class for external */268#define C_HIDDEN 106 /* special storage class for external */
269 /* symbols in dmert public libraries */269 /* symbols in dmert public libraries */
270 270
271/*------------------------------------------------------------------------*/271/*------------------------------------------------------------------------*/
272/* SYMBOL TABLE ENTRIES */272/* SYMBOL TABLE ENTRIES */
273/*------------------------------------------------------------------------*/273/*------------------------------------------------------------------------*/
@@ -312,7 +312,7 @@ struct syment · 38 unmodified lines
312#define N_TV (unsigned short)-3 /* needs transfer vector (preload) */312#define N_TV (unsigned short)-3 /* needs transfer vector (preload) */
313#define P_TV (unsigned short)-4 /* needs transfer vector (postload) */313#define P_TV (unsigned short)-4 /* needs transfer vector (postload) */
314 314
315 315
316/*------------------------------------------------------------------------*/316/*------------------------------------------------------------------------*/
317/* The fundamental type of a symbol packed into the low */317/* The fundamental type of a symbol packed into the low */
318/* 4 bits of the word. */318/* 4 bits of the word. */
@@ -358,11 +358,11 @@ struct syment · 39 unmodified lines
358#define N_BTSHFT_COFF 4358#define N_BTSHFT_COFF 4
359#define N_TSHIFT_COFF 2359#define N_TSHIFT_COFF 2
360 360
361#define BTYPE_COFF(x) ((x) & N_BTMASK_COFF) 361#define BTYPE_COFF(x) ((x) & N_BTMASK_COFF)
362#define ISINT(x) (((x) >= T_CHAR && (x) <= T_LONG) || \362#define ISINT(x) (((x) >= T_CHAR && (x) <= T_LONG) || \
363 ((x) >= T_UCHAR && (x) <= T_ULONG) || (x) == T_ENUM)363 ((x) >= T_UCHAR && (x) <= T_ULONG) || (x) == T_ENUM)
364#define ISFLT_COFF(x) ((x) == T_DOUBLE || (x) == T_FLOAT)364#define ISFLT_COFF(x) ((x) == T_DOUBLE || (x) == T_FLOAT)
365#define ISPTR_COFF(x) (((x) & N_TMASK_COFF) == (DT_PTR << N_BTSHFT_COFF)) 365#define ISPTR_COFF(x) (((x) & N_TMASK_COFF) == (DT_PTR << N_BTSHFT_COFF))
366#define ISFCN_COFF(x) (((x) & N_TMASK_COFF) == (DT_FCN << N_BTSHFT_COFF))366#define ISFCN_COFF(x) (((x) & N_TMASK_COFF) == (DT_FCN << N_BTSHFT_COFF))
367#define ISARY_COFF(x) (((x) & N_TMASK_COFF) == (DT_ARY << N_BTSHFT_COFF))367#define ISARY_COFF(x) (((x) & N_TMASK_COFF) == (DT_ARY << N_BTSHFT_COFF))
368#define ISTAG_COFF(x) ((x)==C_STRTAG || (x)==C_UNTAG || (x)==C_ENTAG)368#define ISTAG_COFF(x) ((x)==C_STRTAG || (x)==C_UNTAG || (x)==C_ENTAG)
@@ -370,7 +370,7 @@ struct syment · 1 unmodified line
370#define INCREF_COFF(x) ((((x)&~N_BTMASK_COFF)<<N_TSHIFT_COFF)|(DT_PTR<<N_BTSHFT_COFF)|(x&N_BTMASK_COFF))370#define INCREF_COFF(x) ((((x)&~N_BTMASK_COFF)<<N_TSHIFT_COFF)|(DT_PTR<<N_BTSHFT_COFF)|(x&N_BTMASK_COFF))
371#define DECREF_COFF(x) ((((x)>>N_TSHIFT_COFF)&~N_BTMASK_COFF)|((x)&N_BTMASK_COFF))371#define DECREF_COFF(x) ((((x)>>N_TSHIFT_COFF)&~N_BTMASK_COFF)|((x)&N_BTMASK_COFF))
372 372
373 373
374/*------------------------------------------------------------------------*/374/*------------------------------------------------------------------------*/
375/* AUXILIARY SYMBOL ENTRY */375/* AUXILIARY SYMBOL ENTRY */
376/*------------------------------------------------------------------------*/376/*------------------------------------------------------------------------*/
i386-asm.h+5−5
@@ -60,7 +60,7 @@ ALT(DEF_ASM_OP0L(stosb, 0xaa, 0, OPC_BWLX)) · 59 unmodified lines
60ALT(DEF_ASM_OP0L(sstob, 0xaa, 0, OPC_BWLX))60ALT(DEF_ASM_OP0L(sstob, 0xaa, 0, OPC_BWLX))
61 61
62 /* bits */62 /* bits */
63 63
64ALT(DEF_ASM_OP2(bsfw, 0x0fbc, 0, OPC_MODRM | OPC_WLX, OPT_REGW | OPT_EA, OPT_REGW))64ALT(DEF_ASM_OP2(bsfw, 0x0fbc, 0, OPC_MODRM | OPC_WLX, OPT_REGW | OPT_EA, OPT_REGW))
65ALT(DEF_ASM_OP2(bsrw, 0x0fbd, 0, OPC_MODRM | OPC_WLX, OPT_REGW | OPT_EA, OPT_REGW))65ALT(DEF_ASM_OP2(bsrw, 0x0fbd, 0, OPC_MODRM | OPC_WLX, OPT_REGW | OPT_EA, OPT_REGW))
66 66
@@ -94,7 +94,7 @@ ALT(DEF_ASM_OP2(lzcntw, 0xf30fbd, 0, OPC_MODRM | OPC_WLX, OPT_REGW | OPT_EA, OPT · 27 unmodified lines
94 DEF_ASM_OP0(repz, 0xf3)94 DEF_ASM_OP0(repz, 0xf3)
95 DEF_ASM_OP0(repne, 0xf2)95 DEF_ASM_OP0(repne, 0xf2)
96 DEF_ASM_OP0(repnz, 0xf2)96 DEF_ASM_OP0(repnz, 0xf2)
97 97
98 DEF_ASM_OP0(invd, 0x0f08)98 DEF_ASM_OP0(invd, 0x0f08)
99 DEF_ASM_OP0(wbinvd, 0x0f09)99 DEF_ASM_OP0(wbinvd, 0x0f09)
100 DEF_ASM_OP0(cpuid, 0x0fa2)100 DEF_ASM_OP0(cpuid, 0x0fa2)
@@ -236,7 +236,7 @@ ALT(DEF_ASM_OP1(jo, 0x70, 0, OPC_TEST, OPT_DISP8)) · 135 unmodified lines
236 DEF_ASM_OP1(loopz, 0xe1, 0, 0, OPT_DISP8)236 DEF_ASM_OP1(loopz, 0xe1, 0, 0, OPT_DISP8)
237 DEF_ASM_OP1(loop, 0xe2, 0, 0, OPT_DISP8)237 DEF_ASM_OP1(loop, 0xe2, 0, 0, OPT_DISP8)
238 DEF_ASM_OP1(jecxz, 0xe3, 0, 0, OPT_DISP8)238 DEF_ASM_OP1(jecxz, 0xe3, 0, 0, OPT_DISP8)
239 239
240 /* float */240 /* float */
241 /* specific fcomp handling */241 /* specific fcomp handling */
242ALT(DEF_ASM_OP0L(fcomp, 0xd8d9, 0, 0))242ALT(DEF_ASM_OP0L(fcomp, 0xd8d9, 0, 0))
@@ -298,7 +298,7 @@ ALT(DEF_ASM_OP1(fldl, 0xdd, 0, OPC_MODRM, OPT_EA)) · 55 unmodified lines
298 DEF_ASM_OP1(fildll, 0xdf, 5, OPC_MODRM,OPT_EA)298 DEF_ASM_OP1(fildll, 0xdf, 5, OPC_MODRM,OPT_EA)
299 DEF_ASM_OP1(fldt, 0xdb, 5, OPC_MODRM, OPT_EA)299 DEF_ASM_OP1(fldt, 0xdb, 5, OPC_MODRM, OPT_EA)
300 DEF_ASM_OP1(fbld, 0xdf, 4, OPC_MODRM, OPT_EA)300 DEF_ASM_OP1(fbld, 0xdf, 4, OPC_MODRM, OPT_EA)
301 301
302 /* fp store */302 /* fp store */
303 DEF_ASM_OP1(fst, 0xddd0, 0, OPC_REG, OPT_ST)303 DEF_ASM_OP1(fst, 0xddd0, 0, OPC_REG, OPT_ST)
304 DEF_ASM_OP1(fstl, 0xddd0, 0, OPC_REG, OPT_ST)304 DEF_ASM_OP1(fstl, 0xddd0, 0, OPC_REG, OPT_ST)
@@ -375,7 +375,7 @@ ALT(DEF_ASM_OP2(cmpxchgb, 0x0fb0, 0, OPC_MODRM | OPC_BWLX, OPT_REG, OPT_REG | OP · 70 unmodified lines
375 375
376 /* pentium */376 /* pentium */
377 DEF_ASM_OP1(cmpxchg8b, 0x0fc7, 1, OPC_MODRM, OPT_EA )377 DEF_ASM_OP1(cmpxchg8b, 0x0fc7, 1, OPC_MODRM, OPT_EA )
378 378
379 /* pentium pro */379 /* pentium pro */
380ALT(DEF_ASM_OP2(cmovo, 0x0f40, 0, OPC_MODRM | OPC_TEST | OPC_WLX, OPT_REGW | OPT_EA, OPT_REGW))380ALT(DEF_ASM_OP2(cmovo, 0x0f40, 0, OPC_MODRM | OPC_TEST | OPC_WLX, OPT_REGW | OPT_EA, OPT_REGW))
381 DEF_ASM_OP2(fcmovb, 0xdac0, 0, OPC_REG, OPT_ST, OPT_ST0 )381 DEF_ASM_OP2(fcmovb, 0xdac0, 0, OPC_REG, OPT_ST, OPT_ST0 )
i386-gen.c+4−4
@@ -1,6 +1,6 @@
1/*1/*
2 * X86 code generator for TCC2 * X86 code generator for TCC
3 * 3 *
4 * Copyright (c) 2001-2004 Fabrice Bellard4 * Copyright (c) 2001-2004 Fabrice Bellard
5 *5 *
6 * This library is free software; you can redistribute it and/or6 * This library is free software; you can redistribute it and/or
@@ -857,7 +857,7 @@ ST_FUNC void gen_opi(int op) · 850 unmodified lines
857 r = vtop[-1].r;857 r = vtop[-1].r;
858 fr = vtop[0].r;858 fr = vtop[0].r;
859 o((opc << 3) | 0x01);859 o((opc << 3) | 0x01);
860 o(0xc0 + r + fr * 8); 860 o(0xc0 + r + fr * 8);
861 }861 }
862 vtop--;862 vtop--;
863 if (op >= TOK_ULT && op <= TOK_GT)863 if (op >= TOK_ULT && op <= TOK_GT)
@@ -1032,7 +1032,7 @@ ST_FUNC void gen_opf(int op) · 168 unmodified lines
1032 load(TREG_ST0, vtop);1032 load(TREG_ST0, vtop);
1033 swapped = !swapped;1033 swapped = !swapped;
1034 }1034 }
1035 1035
1036 switch(op) {1036 switch(op) {
1037 default:1037 default:
1038 case '+':1038 case '+':
@@ -1092,7 +1092,7 @@ ST_FUNC void gen_cvt_itof(int t) · 53 unmodified lines
1092 o(0x242cdf); /* fildll (%esp) */1092 o(0x242cdf); /* fildll (%esp) */
1093 o(0x08c483); /* add $8, %esp */1093 o(0x08c483); /* add $8, %esp */
1094 vtop->r2 = VT_CONST;1094 vtop->r2 = VT_CONST;
1095 } else if ((vtop->type.t & (VT_BTYPE | VT_UNSIGNED)) == 1095 } else if ((vtop->type.t & (VT_BTYPE | VT_UNSIGNED)) ==
1096 (VT_INT | VT_UNSIGNED)) {1096 (VT_INT | VT_UNSIGNED)) {
1097 /* unsigned int to float/double/long double */1097 /* unsigned int to float/double/long double */
1098 o(0x6a); /* push $0 */1098 o(0x6a); /* push $0 */
il-gen.c+7−7
@@ -1,6 +1,6 @@
1/*1/*
2 * CIL code generator for TCC2 * CIL code generator for TCC
3 * 3 *
4 * Copyright (c) 2002 Fabrice Bellard4 * Copyright (c) 2002 Fabrice Bellard
5 *5 *
6 * This library is free software; you can redistribute it and/or6 * This library is free software; you can redistribute it and/or
@@ -114,7 +114,7 @@ static void init_outfile(void) · 107 unmodified lines
114{114{
115 if (!il_outfile) {115 if (!il_outfile) {
116 il_outfile = stdout;116 il_outfile = stdout;
117 fprintf(il_outfile, 117 fprintf(il_outfile,
118 ".assembly extern mscorlib\n"118 ".assembly extern mscorlib\n"
119 "{\n"119 "{\n"
120 ".ver 1:0:2411:0\n"120 ".ver 1:0:2411:0\n"
@@ -151,7 +151,7 @@ static void out_opi(int op, int c) · 30 unmodified lines
151}151}
152 152
153/* XXX: not complete */153/* XXX: not complete */
154static void il_type_to_str(char *buf, int buf_size, 154static void il_type_to_str(char *buf, int buf_size,
155 int t, const char *varstr)155 int t, const char *varstr)
156{156{
157 int bt;157 int bt;
@@ -303,12 +303,12 @@ void load(int r, SValue *sv) · 145 unmodified lines
303 out_op(IL_OP_LDIND_U2);303 out_op(IL_OP_LDIND_U2);
304 else304 else
305 out_op(IL_OP_LDIND_I4);305 out_op(IL_OP_LDIND_I4);
306 } 306 }
307 } else {307 } else {
308 if (v == VT_CONST) {308 if (v == VT_CONST) {
309 /* XXX: handle globals */309 /* XXX: handle globals */
310 if (fc >= -1 && fc <= 8) {310 if (fc >= -1 && fc <= 8) {
311 out_op(IL_OP_LDC_I4_M1 + fc + 1); 311 out_op(IL_OP_LDC_I4_M1 + fc + 1);
312 } else {312 } else {
313 out_opi(IL_OP_LDC_I4, fc);313 out_opi(IL_OP_LDC_I4, fc);
314 }314 }
@@ -432,10 +432,10 @@ void gfunc_prolog(int t) · 117 unmodified lines
432 /* XXX: cannot do better now */432 /* XXX: cannot do better now */
433 fprintf(il_outfile, " .maxstack %d\n", NB_REGS);433 fprintf(il_outfile, " .maxstack %d\n", NB_REGS);
434 fprintf(il_outfile, " .locals (int32, int32, int32, int32, int32, int32, int32, int32)\n");434 fprintf(il_outfile, " .locals (int32, int32, int32, int32, int32, int32, int32, int32)\n");
435 435
436 if (!strcmp(funcname, "main"))436 if (!strcmp(funcname, "main"))
437 fprintf(il_outfile, " .entrypoint\n");437 fprintf(il_outfile, " .entrypoint\n");
438 438
439 sym = sym_find((unsigned)t >> VT_STRUCT_SHIFT);439 sym = sym_find((unsigned)t >> VT_STRUCT_SHIFT);
440 func_call = sym->r;440 func_call = sym->r;
441 441
il-opcodes.h+1−1
@@ -1,6 +1,6 @@
1/*1/*
2 * CIL opcode definition2 * CIL opcode definition
3 * 3 *
4 * Copyright (c) 2002 Fabrice Bellard4 * Copyright (c) 2002 Fabrice Bellard
5 *5 *
6 * This program is free software; you can redistribute it and/or modify6 * This program is free software; you can redistribute it and/or modify
lib/bcheck.c+15−15
@@ -1,6 +1,6 @@
1/*1/*
2 * Tiny C Memory and bounds checker2 * Tiny C Memory and bounds checker
3 * 3 *
4 * Copyright (c) 2002 Fabrice Bellard4 * Copyright (c) 2002 Fabrice Bellard
5 *5 *
6 * This library is free software; you can redistribute it and/or6 * This library is free software; you can redistribute it and/or
@@ -51,7 +51,7 @@ · 44 unmodified lines
51 51
52#ifdef __attribute__52#ifdef __attribute__
53 /* an __attribute__ macro is defined in the system headers */53 /* an __attribute__ macro is defined in the system headers */
54 #undef __attribute__ 54 #undef __attribute__
55#endif55#endif
56#define FASTCALL __attribute__((regparm(3)))56#define FASTCALL __attribute__((regparm(3)))
57 57
@@ -391,11 +391,11 @@ static pthread_key_t no_checking_key; · 333 unmodified lines
391#elif HAVE_TLS_VAR391#elif HAVE_TLS_VAR
392static __thread int no_checking = 0;392static __thread int no_checking = 0;
393#define NO_CHECKING_GET() no_checking393#define NO_CHECKING_GET() no_checking
394#define NO_CHECKING_SET(v) no_checking = v 394#define NO_CHECKING_SET(v) no_checking = v
395#else395#else
396static _Atomic int no_checking = 0;396static _Atomic int no_checking = 0;
397#define NO_CHECKING_GET() no_checking397#define NO_CHECKING_GET() no_checking
398#define NO_CHECKING_SET(v) no_checking = v 398#define NO_CHECKING_SET(v) no_checking = v
399#endif399#endif
400static char exec[100];400static char exec[100];
401 401
@@ -632,7 +632,7 @@ BOUND_PTR_INDIR(16) · 230 unmodified lines
632}632}
633 633
634/* called when entering a function to add all the local regions */634/* called when entering a function to add all the local regions */
635void FASTCALL __bound_local_new(void *p1) 635void FASTCALL __bound_local_new(void *p1)
636{636{
637 size_t addr, fp, *p = p1;637 size_t addr, fp, *p = p1;
638 638
@@ -662,7 +662,7 @@ void FASTCALL __bound_local_new(void *p1) · 23 unmodified lines
662}662}
663 663
664/* called when leaving a function to delete all the local regions */664/* called when leaving a function to delete all the local regions */
665void FASTCALL __bound_local_delete(void *p1) 665void FASTCALL __bound_local_delete(void *p1)
666{666{
667 size_t addr, fp, *p = p1;667 size_t addr, fp, *p = p1;
668 668
@@ -1035,7 +1035,7 @@ void __bound_init(size_t *p, int mode) · 366 unmodified lines
1035 strcat (exec, ":");1035 strcat (exec, ":");
1036 fclose (fp);1036 fclose (fp);
1037 }1037 }
1038 /* check if dlopen is used (is threre a better way?) */ 1038 /* check if dlopen is used (is threre a better way?) */
1039 found = 0;1039 found = 0;
1040 fp = fopen ("/proc/self/maps", "r");1040 fp = fopen ("/proc/self/maps", "r");
1041 if (fp) {1041 if (fp) {
@@ -1305,7 +1305,7 @@ static void *bound_thread_create(void *bdata) · 263 unmodified lines
1305 void *retval;1305 void *retval;
1306#if HAVE_TLS_FUNC1306#if HAVE_TLS_FUNC
1307 int *p = (int *) BOUND_MALLOC(sizeof(int));1307 int *p = (int *) BOUND_MALLOC(sizeof(int));
1308 1308
1309 if (!p) bound_alloc_error("bound_thread_create malloc");1309 if (!p) bound_alloc_error("bound_thread_create malloc");
1310 *p = 0;1310 *p = 0;
1311 pthread_setspecific(no_checking_key, p);1311 pthread_setspecific(no_checking_key, p);
@@ -1327,7 +1327,7 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr, · 15 unmodified lines
1327 bound_thread_create_type *data;1327 bound_thread_create_type *data;
1328 sigset_t mask;1328 sigset_t mask;
1329 sigset_t old_mask;1329 sigset_t old_mask;
1330 1330
1331 use_sem = 1;1331 use_sem = 1;
1332 dprintf (stderr, "%s, %s()\n", __FILE__, __FUNCTION__);1332 dprintf (stderr, "%s, %s()\n", __FILE__, __FUNCTION__);
1333 sigfillset(&mask);1333 sigfillset(&mask);
@@ -1465,7 +1465,7 @@ void *__bound_malloc(size_t size, const void *caller) · 131 unmodified lines
1465#endif1465#endif
1466{1466{
1467 void *ptr;1467 void *ptr;
1468 1468
1469#if MALLOC_REDIR1469#if MALLOC_REDIR
1470 /* This will catch the first dlsym call from __bound_init */1470 /* This will catch the first dlsym call from __bound_init */
1471 if (malloc_redir == NULL) {1471 if (malloc_redir == NULL) {
@@ -1487,7 +1487,7 @@ void *__bound_malloc(size_t size, const void *caller) · 15 unmodified lines
1487 ptr = BOUND_MALLOC (size + 1);1487 ptr = BOUND_MALLOC (size + 1);
1488 dprintf(stderr, "%s, %s(): %p, 0x%lx\n",1488 dprintf(stderr, "%s, %s(): %p, 0x%lx\n",
1489 __FILE__, __FUNCTION__, ptr, (unsigned long)size);1489 __FILE__, __FUNCTION__, ptr, (unsigned long)size);
1490 1490
1491 if (inited && NO_CHECKING_GET() == 0) {1491 if (inited && NO_CHECKING_GET() == 0) {
1492 WAIT_SEM ();1492 WAIT_SEM ();
1493 INCR_COUNT(bound_malloc_count);1493 INCR_COUNT(bound_malloc_count);
@@ -2074,12 +2074,12 @@ static Tree * splay (size_t addr, Tree *t) · 580 unmodified lines
2074{2074{
2075 Tree N, *l, *r, *y;2075 Tree N, *l, *r, *y;
2076 int comp;2076 int comp;
2077 2077
2078 INCR_COUNT_SPLAY(bound_splay);2078 INCR_COUNT_SPLAY(bound_splay);
2079 if (t == NULL) return t;2079 if (t == NULL) return t;
2080 N.left = N.right = NULL;2080 N.left = N.right = NULL;
2081 l = r = &N;2081 l = r = &N;
2082 2082
2083 for (;;) {2083 for (;;) {
2084 comp = compare(addr, t->start, t->size);2084 comp = compare(addr, t->start, t->size);
2085 if (comp < 0) {2085 if (comp < 0) {
@@ -2127,12 +2127,12 @@ static Tree * splay_end (size_t addr, Tree *t) · 41 unmodified lines
2127{2127{
2128 Tree N, *l, *r, *y;2128 Tree N, *l, *r, *y;
2129 int comp;2129 int comp;
2130 2130
2131 INCR_COUNT_SPLAY(bound_splay_end);2131 INCR_COUNT_SPLAY(bound_splay_end);
2132 if (t == NULL) return t;2132 if (t == NULL) return t;
2133 N.left = N.right = NULL;2133 N.left = N.right = NULL;
2134 l = r = &N;2134 l = r = &N;
2135 2135
2136 for (;;) {2136 for (;;) {
2137 comp = compare_end(addr, t->start + t->size);2137 comp = compare_end(addr, t->start + t->size);
2138 if (comp < 0) {2138 if (comp < 0) {
lib/builtin.c+2−2
@@ -19,7 +19,7 @@ · 18 unmodified lines
19 */19 */
20 20
21static const unsigned char table_1_32[] = {21static const unsigned char table_1_32[] = {
22 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 22 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
23 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 923 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9
24};24};
25static const unsigned char table_2_32[32] = {25static const unsigned char table_2_32[32] = {
@@ -66,7 +66,7 @@ static const unsigned char table_2_64[] = { · 40 unmodified lines
66 x = x - ((x >> 1) & 0x55555555); \66 x = x - ((x >> 1) & 0x55555555); \
67 x = (x & 0x33333333) + ((x >> 2) & 0x33333333); \67 x = (x & 0x33333333) + ((x >> 2) & 0x33333333); \
68 x = (x + (x >> 4)) & 0xf0f0f0f; \68 x = (x + (x >> 4)) & 0xf0f0f0f; \
69 return ((x * 0x01010101) >> 24) & m; 69 return ((x * 0x01010101) >> 24) & m;
70#define POPCOUNTL(x, m) \70#define POPCOUNTL(x, m) \
71 x = x - ((x >> 1) & 0x5555555555555555ull); \71 x = x - ((x >> 1) & 0x5555555555555555ull); \
72 x = (x & 0x3333333333333333ull) + ((x >> 2) & 0x3333333333333333ull); \72 x = (x & 0x3333333333333333ull) + ((x >> 2) & 0x3333333333333333ull); \
lib/libtcc1.c+12−12
@@ -1,5 +1,5 @@
1/* TCC runtime library. 1/* TCC runtime library.
2 Parts of this code are (c) 2002 Fabrice Bellard 2 Parts of this code are (c) 2002 Fabrice Bellard
3 3
4 Copyright (C) 1987, 1988, 1992, 1994, 1995 Free Software Foundation, Inc.4 Copyright (C) 1987, 1988, 1992, 1994, 1995 Free Software Foundation, Inc.
5 5
@@ -25,7 +25,7 @@ General Public License for more details. · 19 unmodified lines
25You should have received a copy of the GNU General Public License25You should have received a copy of the GNU General Public License
26along with this program; see the file COPYING. If not, write to26along with this program; see the file COPYING. If not, write to
27the Free Software Foundation, 59 Temple Place - Suite 330,27the Free Software Foundation, 59 Temple Place - Suite 330,
28Boston, MA 02111-1307, USA. 28Boston, MA 02111-1307, USA.
29*/29*/
30 30
31#define W_TYPE_SIZE 3231#define W_TYPE_SIZE 32
@@ -364,10 +364,10 @@ long long __divdi3(long long u, long long v) · 332 unmodified lines
364 int c = 0;364 int c = 0;
365 DWunion uu, vv;365 DWunion uu, vv;
366 DWtype w;366 DWtype w;
367 367
368 uu.ll = u;368 uu.ll = u;
369 vv.ll = v;369 vv.ll = v;
370 370
371 if (uu.s.high < 0) {371 if (uu.s.high < 0) {
372 c = ~c;372 c = ~c;
373 uu.ll = __negdi2 (uu.ll);373 uu.ll = __negdi2 (uu.ll);
@@ -387,17 +387,17 @@ long long __moddi3(long long u, long long v) · 13 unmodified lines
387 int c = 0;387 int c = 0;
388 DWunion uu, vv;388 DWunion uu, vv;
389 DWtype w;389 DWtype w;
390 390
391 uu.ll = u;391 uu.ll = u;
392 vv.ll = v;392 vv.ll = v;
393 393
394 if (uu.s.high < 0) {394 if (uu.s.high < 0) {
395 c = ~c;395 c = ~c;
396 uu.ll = __negdi2 (uu.ll);396 uu.ll = __negdi2 (uu.ll);
397 }397 }
398 if (vv.s.high < 0)398 if (vv.s.high < 0)
399 vv.ll = __negdi2 (vv.ll);399 vv.ll = __negdi2 (vv.ll);
400 400
401 __udivmoddi4 (uu.ll, vv.ll, (UDWtype *) &w);401 __udivmoddi4 (uu.ll, vv.ll, (UDWtype *) &w);
402 if (c)402 if (c)
403 w = __negdi2 (w);403 w = __negdi2 (w);
@@ -412,7 +412,7 @@ unsigned long long __udivdi3(unsigned long long u, unsigned long long v) · 8 unmodified lines
412unsigned long long __umoddi3(unsigned long long u, unsigned long long v)412unsigned long long __umoddi3(unsigned long long u, unsigned long long v)
413{413{
414 UDWtype w;414 UDWtype w;
415 415
416 __udivmoddi4 (u, v, &w);416 __udivmoddi4 (u, v, &w);
417 return w;417 return w;
418}418}
@@ -479,7 +479,7 @@ long long __ashldi3(long long a, int b) · 60 unmodified lines
479/* XXX: fix tcc's code generator to do this instead */479/* XXX: fix tcc's code generator to do this instead */
480float __floatundisf(unsigned long long a)480float __floatundisf(unsigned long long a)
481{481{
482 DWunion uu; 482 DWunion uu;
483 XFtype r;483 XFtype r;
484 484
485 uu.ll = a;485 uu.ll = a;
@@ -494,7 +494,7 @@ float __floatundisf(unsigned long long a) · 8 unmodified lines
494 494
495double __floatundidf(unsigned long long a)495double __floatundidf(unsigned long long a)
496{496{
497 DWunion uu; 497 DWunion uu;
498 XFtype r;498 XFtype r;
499 499
500 uu.ll = a;500 uu.ll = a;
@@ -509,7 +509,7 @@ double __floatundidf(unsigned long long a) · 8 unmodified lines
509 509
510long double __floatundixf(unsigned long long a)510long double __floatundixf(unsigned long long a)
511{511{
512 DWunion uu; 512 DWunion uu;
513 XFtype r;513 XFtype r;
514 514
515 uu.ll = a;515 uu.ll = a;
lib/tcov.c+5−5
@@ -61,7 +61,7 @@ static FILE *open_tcov_file (char *cov_filename) · 60 unmodified lines
61 fd = open (cov_filename, O_RDWR | O_CREAT, 0666);61 fd = open (cov_filename, O_RDWR | O_CREAT, 0666);
62 if (fd < 0)62 if (fd < 0)
63 return NULL;63 return NULL;
64 64
65#ifndef _WIN3265#ifndef _WIN32
66 while (fcntl (fd, F_SETLKW, &lock) && errno == EINTR)66 while (fcntl (fd, F_SETLKW, &lock) && errno == EINTR)
67 continue;67 continue;
@@ -221,13 +221,13 @@ static void merge_test_coverage (tcov_file *file, FILE *fp, · 153 unmodified lines
221 unsigned int runs;221 unsigned int runs;
222 char *p;222 char *p;
223 char str[10000];223 char str[10000];
224 224
225 *pruns = 1;225 *pruns = 1;
226 if (fp == NULL)226 if (fp == NULL)
227 return;227 return;
228 if (fgets(str, sizeof(str), fp) &&228 if (fgets(str, sizeof(str), fp) &&
229 (p = strrchr (str, ':')) &&229 (p = strrchr (str, ':')) &&
230 (sscanf (p + 1, "%u", &runs) == 1)) 230 (sscanf (p + 1, "%u", &runs) == 1))
231 *pruns = runs + 1;231 *pruns = runs + 1;
232 while (file) {232 while (file) {
233 int i;233 int i;
@@ -339,7 +339,7 @@ void __store_test_coverage (unsigned char * p) · 105 unmodified lines
339 nfile->filename, funcs, 100.0 * (double) blocks_run / blocks);339 nfile->filename, funcs, 100.0 * (double) blocks_run / blocks);
340 for (i = 0; i < nfile->n_func; i++) {340 for (i = 0; i < nfile->n_func; i++) {
341 func = &nfile->func[i];341 func = &nfile->func[i];
342 342
343 while (curline < func->first_line &&343 while (curline < func->first_line &&
344 fgets(str, sizeof(str), src))344 fgets(str, sizeof(str), src))
345 fprintf (fp, " -:%5u:%s", curline++, str);345 fprintf (fp, " -:%5u:%s", curline++, str);
@@ -399,7 +399,7 @@ void __store_test_coverage (unsigned char * p) · 53 unmodified lines
399 fprintf (fp, " #####:%5u:%s",399 fprintf (fp, " #####:%5u:%s",
400 curline, str);400 curline, str);
401 else if (has_zero)401 else if (has_zero)
402 fprintf (fp, "%8llu*:%5u:%s", 402 fprintf (fp, "%8llu*:%5u:%s",
403 count, curline, str);403 count, curline, str);
404 else404 else
405 fprintf (fp, "%9llu:%5u:%s",405 fprintf (fp, "%9llu:%5u:%s",
stab.def+2−2
@@ -18,7 +18,7 @@ · 17 unmodified lines
18 Boston, MA 02111-1307, USA. */18 Boston, MA 02111-1307, USA. */
19 19
20/* This contains contribution from Cygnus Support. */20/* This contains contribution from Cygnus Support. */
21 21
22/* Global variable. Only the name is significant.22/* Global variable. Only the name is significant.
23 To find the address, look in the corresponding external symbol. */23 To find the address, look in the corresponding external symbol. */
24__define_stab (N_GSYM, 0x20, "GSYM")24__define_stab (N_GSYM, 0x20, "GSYM")
@@ -178,7 +178,7 @@ __define_stab (N_NBLCS, 0xF8, "NBLCS") · 153 unmodified lines
178/* Second symbol entry containing a length-value for the preceding entry.178/* Second symbol entry containing a length-value for the preceding entry.
179 The value is the length. */179 The value is the length. */
180__define_stab (N_LENG, 0xfe, "LENG")180__define_stab (N_LENG, 0xfe, "LENG")
181 181
182/* The above information, in matrix format.182/* The above information, in matrix format.
183 183
184 STAB MATRIX184 STAB MATRIX
tcc-doc.texi+23−23
@@ -99,9 +99,9 @@ the @code{main()} of a.c. · 98 unmodified lines
99 99
100@item @samp{tcc a.c -run b.c arg1}100@item @samp{tcc a.c -run b.c arg1}
101Compile @file{a.c} and @file{b.c}, link them together and execute them. arg1 is given101Compile @file{a.c} and @file{b.c}, link them together and execute them. arg1 is given
102as first argument to the @code{main()} of the resulting program. 102as first argument to the @code{main()} of the resulting program.
103@ignore 103@ignore
104Because multiple C files are specified, @option{--} are necessary to clearly 104Because multiple C files are specified, @option{--} are necessary to clearly
105separate the program arguments from the TCC options.105separate the program arguments from the TCC options.
106@end ignore106@end ignore
107 107
@@ -136,14 +136,14 @@ need to add @code{#!/usr/local/bin/tcc -run} at the start of your C source: · 28 unmodified lines
136#!/usr/local/bin/tcc -run136#!/usr/local/bin/tcc -run
137#include <stdio.h>137#include <stdio.h>
138 138
139int main() 139int main()
140@{140@{
141 printf("Hello World\n");141 printf("Hello World\n");
142 return 0;142 return 0;
143@}143@}
144@end example144@end example
145 145
146TCC can read C source code from @emph{standard input} when @option{-} is used in 146TCC can read C source code from @emph{standard input} when @option{-} is used in
147place of @option{infile}. Example:147place of @option{infile}. Example:
148 148
149@example149@example
@@ -305,7 +305,7 @@ Abort compilation if a warning is issued. Can be given an option to enable · 155 unmodified lines
305the specified warning and turn it into an error, for example305the specified warning and turn it into an error, for example
306@option{-Werror=unsupported}.306@option{-Werror=unsupported}.
307 307
308@item -Wall 308@item -Wall
309Activate some useful warnings (@option{-Wimplicit-function-declaration},309Activate some useful warnings (@option{-Wimplicit-function-declaration},
310@option{-Wdiscard-qualifiers}).310@option{-Wdiscard-qualifiers}).
311 311
@@ -574,7 +574,7 @@ function name. · 262 unmodified lines
574 574
575 int tab[10] = @{ 1, 2, [5] = 5, [9] = 9@};575 int tab[10] = @{ 1, 2, [5] = 5, [9] = 9@};
576@end example576@end example
577 577
578@item Compound initializers are supported:578@item Compound initializers are supported:
579@example579@example
580 int *p = (int [])@{ 1, 2, 3 @};580 int *p = (int [])@{ 1, 2, 3 @};
@@ -588,7 +588,7 @@ works for structures and strings. · 7 unmodified lines
588@end example588@end example
589 589
590@noindent590@noindent
591is the same as writing 591is the same as writing
592@example592@example
593 double d = 4771840.0;593 double d = 4771840.0;
594@end example594@end example
@@ -604,12 +604,12 @@ TCC implements some GNU C extensions: · 9 unmodified lines
604 604
605@itemize605@itemize
606 606
607@item array designators can be used without '=': 607@item array designators can be used without '=':
608@example608@example
609 int a[10] = @{ [0] 1, [5] 2, 3, 4 @};609 int a[10] = @{ [0] 1, [5] 2, 3, 4 @};
610@end example610@end example
611 611
612@item Structure field designators can be a label: 612@item Structure field designators can be a label:
613@example613@example
614 struct @{ int x, y; @} st = @{ x: 1, y: 1@};614 struct @{ int x, y; @} st = @{ x: 1, y: 1@};
615@end example615@end example
@@ -681,7 +681,7 @@ Here are some examples: · 65 unmodified lines
681align variable @code{a} to 8 bytes and put it in section @code{.mysection}.681align variable @code{a} to 8 bytes and put it in section @code{.mysection}.
682 682
683@example683@example
684 int my_add(int a, int b) __attribute__ ((section(".mycodesection"))) 684 int my_add(int a, int b) __attribute__ ((section(".mycodesection")))
685 @{685 @{
686 return a + b;686 return a + b;
687 @}687 @}
@@ -698,17 +698,17 @@ generate function @code{my_add} in section @code{.mycodesection}. · 10 unmodified lines
698 dprintf("one arg %d\n", 1);698 dprintf("one arg %d\n", 1);
699@end example699@end example
700 700
701@item @code{__FUNCTION__} is interpreted as C99 @code{__func__} 701@item @code{__FUNCTION__} is interpreted as C99 @code{__func__}
702(so it has not exactly the same semantics as string literal GNUC702(so it has not exactly the same semantics as string literal GNUC
703where it is a string literal).703where it is a string literal).
704 704
705@item The @code{__alignof__} keyword can be used as @code{sizeof} 705@item The @code{__alignof__} keyword can be used as @code{sizeof}
706to get the alignment of a type or an expression.706to get the alignment of a type or an expression.
707 707
708@item The @code{typeof(x)} returns the type of @code{x}. 708@item The @code{typeof(x)} returns the type of @code{x}.
709@code{x} is an expression or a type.709@code{x} is an expression or a type.
710 710
711@item Computed gotos: @code{&&label} returns a pointer of type 711@item Computed gotos: @code{&&label} returns a pointer of type
712@code{void *} on the goto label @code{label}. @code{goto *expr} can be712@code{void *} on the goto label @code{label}. @code{goto *expr} can be
713used to jump on the pointer resulting from @code{expr}.713used to jump on the pointer resulting from @code{expr}.
714 714
@@ -742,7 +742,7 @@ TCC includes its own x86 inline assembler with a @code{gas}-like (GNU · 27 unmodified lines
742assembler) syntax. No intermediate files are generated. GCC 3.x named742assembler) syntax. No intermediate files are generated. GCC 3.x named
743operands are supported.743operands are supported.
744 744
745@item @code{__builtin_types_compatible_p()} and @code{__builtin_constant_p()} 745@item @code{__builtin_types_compatible_p()} and @code{__builtin_constant_p()}
746are supported.746are supported.
747 747
748@item @code{#pragma pack} is supported for win32 compatibility.748@item @code{#pragma pack} is supported for win32 compatibility.
@@ -805,7 +805,7 @@ same as C. · 56 unmodified lines
805@item +, -805@item +, -
806@end enumerate806@end enumerate
807 807
808@item A value is either an absolute number or a label plus an offset. 808@item A value is either an absolute number or a label plus an offset.
809All operators accept absolute values except '+' and '-'. '+' or '-' can be809All operators accept absolute values except '+' and '-'. '+' or '-' can be
810used to add an offset to a label. '-' supports two labels only if they810used to add an offset to a label. '-' supports two labels only if they
811are the same or if they are both defined and in the same section.811are the same or if they are both defined and in the same section.
@@ -818,7 +818,7 @@ are the same or if they are both defined and in the same section. · 6 unmodified lines
818 818
819@item All labels are considered as local, except undefined ones.819@item All labels are considered as local, except undefined ones.
820 820
821@item Numeric labels can be used as local @code{gas}-like labels. 821@item Numeric labels can be used as local @code{gas}-like labels.
822They can be defined several times in the same source. Use 'b'822They can be defined several times in the same source. Use 'b'
823(backward) or 'f' (forward) as suffix to reference them:823(backward) or 'f' (forward) as suffix to reference them:
824 824
@@ -1075,7 +1075,7 @@ For more information about the ideas behind this method, see · 250 unmodified lines
1075@chapter The @code{libtcc} library1075@chapter The @code{libtcc} library
1076 1076
1077The @code{libtcc} library enables you to use TCC as a backend for1077The @code{libtcc} library enables you to use TCC as a backend for
1078dynamic code generation. 1078dynamic code generation.
1079 1079
1080Read the @file{libtcc.h} to have an overview of the API. Read1080Read the @file{libtcc.h} to have an overview of the API. Read
1081@file{libtcc_test.c} to have a very simple example.1081@file{libtcc_test.c} to have a very simple example.
@@ -1115,10 +1115,10 @@ except: · 33 unmodified lines
1115 1115
1116@itemize1116@itemize
1117 1117
1118@item For initialized arrays with unknown size, a first pass 1118@item For initialized arrays with unknown size, a first pass
1119is done to count the number of elements.1119is done to count the number of elements.
1120 1120
1121@item For architectures where arguments are evaluated in 1121@item For architectures where arguments are evaluated in
1122reverse order, a first pass is done to reverse the argument order.1122reverse order, a first pass is done to reverse the argument order.
1123 1123
1124@end itemize1124@end itemize
@@ -1330,7 +1330,7 @@ stack. · 205 unmodified lines
1330@item VT_CMP1330@item VT_CMP
1331indicates that the value is actually stored in the CPU flags (i.e. the1331indicates that the value is actually stored in the CPU flags (i.e. the
1332value is the consequence of a test). The value is either 0 or 1. The1332value is the consequence of a test). The value is either 0 or 1. The
1333actual CPU flags used is indicated in @code{SValue.c.i}. 1333actual CPU flags used is indicated in @code{SValue.c.i}.
1334 1334
1335If any code is generated which destroys the CPU flags, this value MUST be1335If any code is generated which destroys the CPU flags, this value MUST be
1336put in a normal register.1336put in a normal register.
@@ -1350,7 +1350,7 @@ taken. · 13 unmodified lines
1350@item VT_LVAL1350@item VT_LVAL
1351is a flag indicating that the value is actually an lvalue (left value of1351is a flag indicating that the value is actually an lvalue (left value of
1352an assignment). It means that the value stored is actually a pointer to1352an assignment). It means that the value stored is actually a pointer to
1353the wanted value. 1353the wanted value.
1354 1354
1355Understanding the use @code{VT_LVAL} is very important if you want to1355Understanding the use @code{VT_LVAL} is very important if you want to
1356understand how TCC works.1356understand how TCC works.
tcc.c+1−1
@@ -1,6 +1,6 @@
1/*1/*
2 * TCC - Tiny C Compiler2 * TCC - Tiny C Compiler
3 * 3 *
4 * Copyright (c) 2001-2004 Fabrice Bellard4 * Copyright (c) 2001-2004 Fabrice Bellard
5 *5 *
6 * This library is free software; you can redistribute it and/or6 * This library is free software; you can redistribute it and/or
tccasm.c+22−22
@@ -1,6 +1,6 @@
1/*1/*
2 * GAS like assembler for TCC2 * GAS like assembler for TCC
3 * 3 *
4 * Copyright (c) 2001-2004 Fabrice Bellard4 * Copyright (c) 2001-2004 Fabrice Bellard
5 *5 *
6 * This library is free software; you can redistribute it and/or6 * This library is free software; you can redistribute it and/or
@@ -236,7 +236,7 @@ static void asm_expr_unary(TCCState *s1, ExprValue *pe) · 229 unmodified lines
236 break;236 break;
237 }237 }
238}238}
239 239
240static void asm_expr_prod(TCCState *s1, ExprValue *pe)240static void asm_expr_prod(TCCState *s1, ExprValue *pe)
241{241{
242 int op;242 int op;
@@ -245,7 +245,7 @@ static void asm_expr_prod(TCCState *s1, ExprValue *pe) · 2 unmodified lines
245 asm_expr_unary(s1, pe);245 asm_expr_unary(s1, pe);
246 for(;;) {246 for(;;) {
247 op = tok;247 op = tok;
248 if (op != '*' && op != '/' && op != '%' && 248 if (op != '*' && op != '/' && op != '%' &&
249 op != TOK_SHL && op != TOK_SAR)249 op != TOK_SHL && op != TOK_SAR)
250 break;250 break;
251 next();251 next();
@@ -256,14 +256,14 @@ static void asm_expr_prod(TCCState *s1, ExprValue *pe) · 4 unmodified lines
256 case '*':256 case '*':
257 pe->v *= e2.v;257 pe->v *= e2.v;
258 break;258 break;
259 case '/': 259 case '/':
260 if (e2.v == 0) {260 if (e2.v == 0) {
261 div_error:261 div_error:
262 tcc_error("division by zero");262 tcc_error("division by zero");
263 }263 }
264 pe->v /= e2.v;264 pe->v /= e2.v;
265 break;265 break;
266 case '%': 266 case '%':
267 if (e2.v == 0)267 if (e2.v == 0)
268 goto div_error;268 goto div_error;
269 pe->v %= e2.v;269 pe->v %= e2.v;
@@ -297,7 +297,7 @@ static void asm_expr_logic(TCCState *s1, ExprValue *pe) · 27 unmodified lines
297 case '&':297 case '&':
298 pe->v &= e2.v;298 pe->v &= e2.v;
299 break;299 break;
300 case '|': 300 case '|':
301 pe->v |= e2.v;301 pe->v |= e2.v;
302 break;302 break;
303 default:303 default:
@@ -332,7 +332,7 @@ static inline void asm_expr_sum(TCCState *s1, ExprValue *pe) · 28 unmodified lines
332 because we store only one symbol in the expression */332 because we store only one symbol in the expression */
333 if (!e2.sym) {333 if (!e2.sym) {
334 /* OK */334 /* OK */
335 } else if (pe->sym == e2.sym) { 335 } else if (pe->sym == e2.sym) {
336 /* OK */336 /* OK */
337 pe->sym = NULL; /* same symbols can be subtracted to NULL */337 pe->sym = NULL; /* same symbols can be subtracted to NULL */
338 } else {338 } else {
@@ -734,7 +734,7 @@ static void asm_parse_directive(TCCState *s1, int global) · 395 unmodified lines
734 case TOK_ASMDIR_weak:734 case TOK_ASMDIR_weak:
735 case TOK_ASMDIR_hidden:735 case TOK_ASMDIR_hidden:
736 tok1 = tok;736 tok1 = tok;
737 do { 737 do {
738 Sym *sym;738 Sym *sym;
739 next();739 next();
740 if (tok < TOK_IDENT)740 if (tok < TOK_IDENT)
@@ -780,7 +780,7 @@ static void asm_parse_directive(TCCState *s1, int global) · 39 unmodified lines
780 case TOK_ASMDIR_text:780 case TOK_ASMDIR_text:
781 case TOK_ASMDIR_data:781 case TOK_ASMDIR_data:
782 case TOK_ASMDIR_bss:782 case TOK_ASMDIR_bss:
783 { 783 {
784 char sname[64];784 char sname[64];
785 tok1 = tok;785 tok1 = tok;
786 n = 0;786 n = 0;
@@ -831,7 +831,7 @@ static void asm_parse_directive(TCCState *s1, int global) · 44 unmodified lines
831 }831 }
832 break;832 break;
833 case TOK_ASMDIR_size:833 case TOK_ASMDIR_size:
834 { 834 {
835 Sym *sym;835 Sym *sym;
836 ElfSym *esym;836 ElfSym *esym;
837 837
@@ -853,7 +853,7 @@ static void asm_parse_directive(TCCState *s1, int global) · 15 unmodified lines
853 }853 }
854 break;854 break;
855 case TOK_ASMDIR_type:855 case TOK_ASMDIR_type:
856 { 856 {
857 Sym *sym;857 Sym *sym;
858 const char *newtype;858 const char *newtype;
859 int st_type;859 int st_type;
@@ -948,7 +948,7 @@ static void asm_parse_directive(TCCState *s1, int global) · 88 unmodified lines
948 }948 }
949 break;949 break;
950 case TOK_ASMDIR_previous:950 case TOK_ASMDIR_previous:
951 { 951 {
952 Section *sec;952 Section *sec;
953 next();953 next();
954 if (!last_text_section)954 if (!last_text_section)
@@ -1171,7 +1171,7 @@ static void tcc_assemble_inline(TCCState *s1, const char *str, int len, int glob · 216 unmodified lines
1171/* find a constraint by its number or id (gcc 3 extended1171/* find a constraint by its number or id (gcc 3 extended
1172 syntax). return -1 if not found. Return in *pp in char after the1172 syntax). return -1 if not found. Return in *pp in char after the
1173 constraint */1173 constraint */
1174ST_FUNC int find_constraint(ASMOperand *operands, int nb_operands, 1174ST_FUNC int find_constraint(ASMOperand *operands, int nb_operands,
1175 const char *name, const char **pp)1175 const char *name, const char **pp)
1176{1176{
1177 int index;1177 int index;
@@ -1209,7 +1209,7 @@ ST_FUNC int find_constraint(ASMOperand *operands, int nb_operands, · 31 unmodified lines
1209 return index;1209 return index;
1210}1210}
1211 1211
1212static void subst_asm_operands(ASMOperand *operands, int nb_operands, 1212static void subst_asm_operands(ASMOperand *operands, int nb_operands,
1213 CString *out_str, const char *str)1213 CString *out_str, const char *str)
1214{1214{
1215 int c, index, modifier;1215 int c, index, modifier;
@@ -1421,12 +1421,12 @@ ST_FUNC void asm_instr(void) · 205 unmodified lines
1421 token after the assembler parsing */1421 token after the assembler parsing */
1422 if (tok != ';')1422 if (tok != ';')
1423 expect("';'");1423 expect("';'");
1424 1424
1425 /* save all values in the memory */1425 /* save all values in the memory */
1426 save_regs(0);1426 save_regs(0);
1427 1427
1428 /* compute constraints */1428 /* compute constraints */
1429 asm_compute_constraints(operands, nb_operands, nb_outputs, 1429 asm_compute_constraints(operands, nb_operands, nb_outputs,
1430 clobber_regs, &out_reg);1430 clobber_regs, &out_reg);
1431 1431
1432 /* substitute the operands in the asm string. No substitution is1432 /* substitute the operands in the asm string. No substitution is
@@ -1446,8 +1446,8 @@ ST_FUNC void asm_instr(void) · 13 unmodified lines
1446#endif1446#endif
1447 1447
1448 /* generate loads */1448 /* generate loads */
1449 asm_gen_code(operands, nb_operands, nb_outputs, 0, 1449 asm_gen_code(operands, nb_operands, nb_outputs, 0,
1450 clobber_regs, out_reg); 1450 clobber_regs, out_reg);
1451 1451
1452 /* We don't allow switching section within inline asm to1452 /* We don't allow switching section within inline asm to
1453 bleed out to surrounding code. */1453 bleed out to surrounding code. */
@@ -1464,9 +1464,9 @@ ST_FUNC void asm_instr(void) · 10 unmodified lines
1464 next();1464 next();
1465 1465
1466 /* store the output values if needed */1466 /* store the output values if needed */
1467 asm_gen_code(operands, nb_operands, nb_outputs, 1, 1467 asm_gen_code(operands, nb_operands, nb_outputs, 1,
1468 clobber_regs, out_reg);1468 clobber_regs, out_reg);
1469 1469
1470 /* free everything */1470 /* free everything */
1471 for(i=0;i<nb_operands;i++) {1471 for(i=0;i<nb_operands;i++) {
1472 vpop();1472 vpop();
@@ -1488,7 +1488,7 @@ ST_FUNC void asm_global_instr(void) · 15 unmodified lines
1488 token after the assembler parsing */1488 token after the assembler parsing */
1489 if (tok != ';')1489 if (tok != ';')
1490 expect("';'");1490 expect("';'");
1491 1491
1492#ifdef ASM_DEBUG1492#ifdef ASM_DEBUG
1493 printf("asm_global: \"%s\"\n", (char *)astr->data);1493 printf("asm_global: \"%s\"\n", (char *)astr->data);
1494#endif1494#endif
@@ -1497,7 +1497,7 @@ ST_FUNC void asm_global_instr(void) · 2 unmodified lines
1497 1497
1498 /* assemble the string with tcc internal assembler */1498 /* assemble the string with tcc internal assembler */
1499 tcc_assemble_inline(tcc_state, astr->data, astr->size - 1, 1);1499 tcc_assemble_inline(tcc_state, astr->data, astr->size - 1, 1);
1500 1500
1501 cur_text_section->data_offset = ind;1501 cur_text_section->data_offset = ind;
1502 1502
1503 /* restore the current C token */1503 /* restore the current C token */
tcccoff.c+2−2
@@ -1,6 +1,6 @@
1/*1/*
2 * COFF file handling for TCC2 * COFF file handling for TCC
3 * 3 *
4 * Copyright (c) 2003, 2004 TK4 * Copyright (c) 2003, 2004 TK
5 * Copyright (c) 2004 Fabrice Bellard5 * Copyright (c) 2004 Fabrice Bellard
6 *6 *
@@ -609,7 +609,7 @@ ST_FUNC int tcc_output_coff(TCCState *s1, FILE *f) · 602 unmodified lines
609 // put a .ef609 // put a .ef
610 610
611 strcpy(csym._n._n_name, ".ef");611 strcpy(csym._n._n_name, ".ef");
612 csym.n_value = EndAddress[k]; // physical address 612 csym.n_value = EndAddress[k]; // physical address
613 csym.n_scnum = CoffTextSectionNo;613 csym.n_scnum = CoffTextSectionNo;
614 csym.n_type = 0;614 csym.n_type = 0;
615 csym.n_sclass = C_FCN;615 csym.n_sclass = C_FCN;
tccgen.c+32−32
@@ -1138,7 +1138,7 @@ ST_FUNC Sym *get_sym_ref(CType *type, Section *sec, unsigned long offset, unsign · 1137 unmodified lines
1138/* push a reference to a section offset by adding a dummy symbol */1138/* push a reference to a section offset by adding a dummy symbol */
1139static void vpush_ref(CType *type, Section *sec, unsigned long offset, unsigned long size)1139static void vpush_ref(CType *type, Section *sec, unsigned long offset, unsigned long size)
1140{1140{
1141 vpushsym(type, get_sym_ref(type, sec, offset, size)); 1141 vpushsym(type, get_sym_ref(type, sec, offset, size));
1142}1142}
1143 1143
1144/* define a new external reference to a symbol 'v' of type 'u' */1144/* define a new external reference to a symbol 'v' of type 'u' */
@@ -1467,7 +1467,7 @@ ST_FUNC int get_reg_ex(int rc, int rc2) · 322 unmodified lines
1467{1467{
1468 int r;1468 int r;
1469 SValue *p;1469 SValue *p;
1470 1470
1471 for(r=0;r<NB_REGS;r++) {1471 for(r=0;r<NB_REGS;r++) {
1472 if (reg_classes[r] & rc2) {1472 if (reg_classes[r] & rc2) {
1473 int n;1473 int n;
@@ -1505,7 +1505,7 @@ ST_FUNC int get_reg(int rc) · 31 unmodified lines
1505 }1505 }
1506 notfound: ;1506 notfound: ;
1507 }1507 }
1508 1508
1509 /* no register left : free the first one on the stack (VERY1509 /* no register left : free the first one on the stack (VERY
1510 IMPORTANT to start from the bottom to ensure that we don't1510 IMPORTANT to start from the bottom to ensure that we don't
1511 spill registers used in gen_opi()) */1511 spill registers used in gen_opi()) */
@@ -1884,7 +1884,7 @@ ST_FUNC int gv(int rc) · 372 unmodified lines
1884 }1884 }
1885 r = gv(rc);1885 r = gv(rc);
1886 } else {1886 } else {
1887 if (is_float(vtop->type.t) && 1887 if (is_float(vtop->type.t) &&
1888 (vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {1888 (vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {
1889 /* CPUs usually cannot use float constants, so we store them1889 /* CPUs usually cannot use float constants, so we store them
1890 generically in data segment */1890 generically in data segment */
@@ -1900,7 +1900,7 @@ ST_FUNC int gv(int rc) · 9 unmodified lines
1900 vtop->r |= VT_LVAL;1900 vtop->r |= VT_LVAL;
1901 }1901 }
1902#ifdef CONFIG_TCC_BCHECK1902#ifdef CONFIG_TCC_BCHECK
1903 if (vtop->r & VT_MUSTBOUND) 1903 if (vtop->r & VT_MUSTBOUND)
1904 gbound();1904 gbound();
1905#endif1905#endif
1906 1906
@@ -2426,7 +2426,7 @@ static void gen_opic(int op) · 519 unmodified lines
2426 vtop--;2426 vtop--;
2427 } else {2427 } else {
2428 /* if commutative ops, put c2 as constant */2428 /* if commutative ops, put c2 as constant */
2429 if (c1 && (op == '+' || op == '&' || op == '^' || 2429 if (c1 && (op == '+' || op == '&' || op == '^' ||
2430 op == '|' || op == '*' || op == TOK_EQ || op == TOK_NE)) {2430 op == '|' || op == '*' || op == TOK_EQ || op == TOK_NE)) {
2431 vswap();2431 vswap();
2432 c2 = c1; //c = c1, c1 = c2, c2 = c;2432 c2 = c1; //c = c1, c1 = c2, c2 = c;
@@ -2585,7 +2585,7 @@ static void gen_opif(int op) · 152 unmodified lines
2585 case '+': f1 += f2; break;2585 case '+': f1 += f2; break;
2586 case '-': f1 -= f2; break;2586 case '-': f1 -= f2; break;
2587 case '*': f1 *= f2; break;2587 case '*': f1 *= f2; break;
2588 case '/': 2588 case '/':
2589 if (f2 == 0.0) {2589 if (f2 == 0.0) {
2590 union { float f; unsigned u; } x1, x2, y;2590 union { float f; unsigned u; } x1, x2, y;
2591 /* If not in initializer we need to potentially generate2591 /* If not in initializer we need to potentially generate
@@ -3057,7 +3057,7 @@ redo: · 465 unmodified lines
3057 t2 = vtop[0].type.t;3057 t2 = vtop[0].type.t;
3058 bt1 = t1 & VT_BTYPE;3058 bt1 = t1 & VT_BTYPE;
3059 bt2 = t2 & VT_BTYPE;3059 bt2 = t2 & VT_BTYPE;
3060 3060
3061 if (bt1 == VT_FUNC || bt2 == VT_FUNC) {3061 if (bt1 == VT_FUNC || bt2 == VT_FUNC) {
3062 if (bt2 == VT_FUNC) {3062 if (bt2 == VT_FUNC) {
3063 mk_pointer(&vtop->type);3063 mk_pointer(&vtop->type);
@@ -3185,7 +3185,7 @@ op_err: · 121 unmodified lines
3185/* generic itof for unsigned long long case */3185/* generic itof for unsigned long long case */
3186static void gen_cvt_itof1(int t)3186static void gen_cvt_itof1(int t)
3187{3187{
3188 if ((vtop->type.t & (VT_BTYPE | VT_UNSIGNED)) == 3188 if ((vtop->type.t & (VT_BTYPE | VT_UNSIGNED)) ==
3189 (VT_LLONG | VT_UNSIGNED)) {3189 (VT_LLONG | VT_UNSIGNED)) {
3190 3190
3191 if (t == VT_FLOAT)3191 if (t == VT_FLOAT)
@@ -3577,7 +3577,7 @@ ST_FUNC void mk_pointer(CType *type) · 385 unmodified lines
3577}3577}
3578 3578
3579/* return true if type1 and type2 are exactly the same (including3579/* return true if type1 and type2 are exactly the same (including
3580 qualifiers). 3580 qualifiers).
3581*/3581*/
3582static int is_compatible_types(CType *type1, CType *type2)3582static int is_compatible_types(CType *type1, CType *type2)
3583{3583{
@@ -3872,7 +3872,7 @@ ST_FUNC void inc(int post, int c) · 288 unmodified lines
3872 vrotb(3);3872 vrotb(3);
3873 }3873 }
3874 /* add constant */3874 /* add constant */
3875 vpushi(c - TOK_MID); 3875 vpushi(c - TOK_MID);
3876 gen_op('+');3876 gen_op('+');
3877 vstore(); /* store value */3877 vstore(); /* store value */
3878 if (post)3878 if (post)
@@ -3918,7 +3918,7 @@ static void parse_attribute(AttributeDef *ad) · 39 unmodified lines
3918 int t, n;3918 int t, n;
3919 char *astr;3919 char *astr;
3920 AttributeDef ad_tmp;3920 AttributeDef ad_tmp;
3921 3921
3922redo:3922redo:
3923 if (tok != TOK_ATTRIBUTE1 && tok != TOK_ATTRIBUTE2)3923 if (tok != TOK_ATTRIBUTE1 && tok != TOK_ATTRIBUTE2)
3924 return;3924 return;
@@ -4000,7 +4000,7 @@ redo: · 75 unmodified lines
4000 if (tok == '(') {4000 if (tok == '(') {
4001 next();4001 next();
4002 n = expr_const();4002 n = expr_const();
4003 if (n <= 0 || (n & (n - 1)) != 0) 4003 if (n <= 0 || (n & (n - 1)) != 0)
4004 tcc_error("alignment must be a positive power of two");4004 tcc_error("alignment must be a positive power of two");
4005 skip(')');4005 skip(')');
4006 } else {4006 } else {
@@ -4062,7 +4062,7 @@ redo: · 55 unmodified lines
4062 case TOK_REGPARM2:4062 case TOK_REGPARM2:
4063 skip('(');4063 skip('(');
4064 n = expr_const();4064 n = expr_const();
4065 if (n > 3) 4065 if (n > 3)
4066 n = 3;4066 n = 3;
4067 else if (n < 0)4067 else if (n < 0)
4068 n = 0;4068 n = 0;
@@ -4120,9 +4120,9 @@ skip_param: · 51 unmodified lines
4120 if (tok == '(') {4120 if (tok == '(') {
4121 int parenthesis = 0;4121 int parenthesis = 0;
4122 do {4122 do {
4123 if (tok == '(') 4123 if (tok == '(')
4124 parenthesis++;4124 parenthesis++;
4125 else if (tok == ')') 4125 else if (tok == ')')
4126 parenthesis--;4126 parenthesis--;
4127 next();4127 next();
4128 } while (parenthesis && tok != -1);4128 } while (parenthesis && tok != -1);
@@ -4621,7 +4621,7 @@ do_decl: · 492 unmodified lines
4621 if ((type1.t & VT_BTYPE) == VT_FUNC ||4621 if ((type1.t & VT_BTYPE) == VT_FUNC ||
4622 (type1.t & VT_BTYPE) == VT_VOID ||4622 (type1.t & VT_BTYPE) == VT_VOID ||
4623 (type1.t & VT_STORAGE))4623 (type1.t & VT_STORAGE))
4624 tcc_error("invalid type for '%s'", 4624 tcc_error("invalid type for '%s'",
4625 get_tok_str(v, NULL));4625 get_tok_str(v, NULL));
4626 }4626 }
4627 if (tok == ':') {4627 if (tok == ':') {
@@ -4629,18 +4629,18 @@ do_decl: · 1 unmodified line
4629 bit_size = expr_const();4629 bit_size = expr_const();
4630 /* XXX: handle v = 0 case for messages */4630 /* XXX: handle v = 0 case for messages */
4631 if (bit_size < 0)4631 if (bit_size < 0)
4632 tcc_error("negative width in bit-field '%s'", 4632 tcc_error("negative width in bit-field '%s'",
4633 get_tok_str(v, NULL));4633 get_tok_str(v, NULL));
4634 if (v && bit_size == 0)4634 if (v && bit_size == 0)
4635 tcc_error("zero width for bit-field '%s'", 4635 tcc_error("zero width for bit-field '%s'",
4636 get_tok_str(v, NULL));4636 get_tok_str(v, NULL));
4637 parse_attribute(&ad1);4637 parse_attribute(&ad1);
4638 }4638 }
4639 size = type_size(&type1, &align);4639 size = type_size(&type1, &align);
4640 if (bit_size >= 0) {4640 if (bit_size >= 0) {
4641 bt = type1.t & VT_BTYPE;4641 bt = type1.t & VT_BTYPE;
4642 if (bt != VT_INT && 4642 if (bt != VT_INT &&
4643 bt != VT_BYTE && 4643 bt != VT_BYTE &&
4644 bt != VT_SHORT &&4644 bt != VT_SHORT &&
4645 bt != VT_BOOL &&4645 bt != VT_BOOL &&
4646 bt != VT_LLONG)4646 bt != VT_LLONG)
@@ -4718,7 +4718,7 @@ static void parse_btype_qualify(CType *type, int qualifiers) · 71 unmodified lines
4718}4718}
4719 4719
4720/* return 0 if no type declaration. otherwise, return the basic type4720/* return 0 if no type declaration. otherwise, return the basic type
4721 and skip it. 4721 and skip it.
4722 */4722 */
4723static int parse_btype(CType *type, AttributeDef *ad, int ignore_label)4723static int parse_btype(CType *type, AttributeDef *ad, int ignore_label)
4724{4724{
@@ -5106,9 +5106,9 @@ static int post_type(CType *type, AttributeDef *ad, int storage, int td) · 381 unmodified lines
5106 skip(')');5106 skip(')');
5107 /* NOTE: const is ignored in returned type as it has a special5107 /* NOTE: const is ignored in returned type as it has a special
5108 meaning in gcc / C++ */5108 meaning in gcc / C++ */
5109 type->t &= ~VT_CONSTANT; 5109 type->t &= ~VT_CONSTANT;
5110 /* some ancient pre-K&R C allows a function to return an array5110 /* some ancient pre-K&R C allows a function to return an array
5111 and the array brackets to be put after the arguments, such 5111 and the array brackets to be put after the arguments, such
5112 that "int c()[]" means something like "int[] c()" */5112 that "int c()[]" means something like "int[] c()" */
5113 if (tok == '[') {5113 if (tok == '[') {
5114 next();5114 next();
@@ -5219,7 +5219,7 @@ check: · 104 unmodified lines
5219 if (n != -1)5219 if (n != -1)
5220 vpop();5220 vpop();
5221 nocode_wanted = saved_nocode_wanted;5221 nocode_wanted = saved_nocode_wanted;
5222 5222
5223 /* we push an anonymous symbol which will contain the array5223 /* we push an anonymous symbol which will contain the array
5224 element type */5224 element type */
5225 s = sym_push(SYM_FIELD, type, 0, n);5225 s = sym_push(SYM_FIELD, type, 0, n);
@@ -5617,7 +5617,7 @@ ST_FUNC void unary(void) · 391 unmodified lines
5617 goto push_tokc;5617 goto push_tokc;
5618#endif5618#endif
5619 case TOK_CINT:5619 case TOK_CINT:
5620 case TOK_CCHAR: 5620 case TOK_CCHAR:
5621 t = VT_INT;5621 t = VT_INT;
5622 push_tokc:5622 push_tokc:
5623 type.t = t;5623 type.t = t;
@@ -6165,7 +6165,7 @@ special_math_val: · 541 unmodified lines
6165 }6165 }
6166 break;6166 break;
6167 }6167 }
6168 6168
6169 /* post operations */6169 /* post operations */
6170 while (1) {6170 while (1) {
6171 if (tok == TOK_INC || tok == TOK_DEC) {6171 if (tok == TOK_INC || tok == TOK_DEC) {
@@ -6173,8 +6173,8 @@ special_math_val: · 1 unmodified line
6173 next();6173 next();
6174 } else if (tok == '.' || tok == TOK_ARROW) {6174 } else if (tok == '.' || tok == TOK_ARROW) {
6175 int qualifiers, cumofs;6175 int qualifiers, cumofs;
6176 /* field */ 6176 /* field */
6177 if (tok == TOK_ARROW) 6177 if (tok == TOK_ARROW)
6178 indir();6178 indir();
6179 qualifiers = vtop->type.t & (VT_CONSTANT | VT_VOLATILE);6179 qualifiers = vtop->type.t & (VT_CONSTANT | VT_VOLATILE);
6180 test_lvalue();6180 test_lvalue();
@@ -6738,7 +6738,7 @@ static void expr_cond(void) · 557 unmodified lines
6738static void expr_eq(void)6738static void expr_eq(void)
6739{6739{
6740 int t;6740 int t;
6741 6741
6742 expr_cond();6742 expr_cond();
6743 if ((t = tok) == '=' || TOK_ASSIGN(t)) {6743 if ((t = tok) == '=' || TOK_ASSIGN(t)) {
6744 test_lvalue();6744 test_lvalue();
@@ -8061,7 +8061,7 @@ static void decl_initializer(init_params *p, CType *type, unsigned long c, int f · 1316 unmodified lines
8061 8061
8062 /* only parse strings here if correct type (otherwise: handle8062 /* only parse strings here if correct type (otherwise: handle
8063 them as ((w)char *) expressions */8063 them as ((w)char *) expressions */
8064 if ((tok == TOK_LSTR && 8064 if ((tok == TOK_LSTR &&
8065#ifdef TCC_TARGET_PE8065#ifdef TCC_TARGET_PE
8066 (t1->t & VT_BTYPE) == VT_SHORT && (t1->t & VT_UNSIGNED)8066 (t1->t & VT_BTYPE) == VT_SHORT && (t1->t & VT_UNSIGNED)
8067#else8067#else
@@ -8240,7 +8240,7 @@ static void decl_initializer(init_params *p, CType *type, unsigned long c, int f · 172 unmodified lines
8240 are parsed. If 'v' is zero, then a reference to the new object8240 are parsed. If 'v' is zero, then a reference to the new object
8241 is put in the value stack. If 'has_init' is 2, a special parsing8241 is put in the value stack. If 'has_init' is 2, a special parsing
8242 is done to handle string constants. */8242 is done to handle string constants. */
8243static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, 8243static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r,
8244 int has_init, int v, int scope)8244 int has_init, int v, int scope)
8245{8245{
8246 int size, align, addr;8246 int size, align, addr;
tcclib.h+3−3
@@ -1,8 +1,8 @@
1/* Simple libc header for TCC 1/* Simple libc header for TCC
2 * 2 *
3 * Add any function you want from the libc there. This file is here3 * Add any function you want from the libc there. This file is here
4 * only for your convenience so that you do not need to put the whole4 * only for your convenience so that you do not need to put the whole
5 * glibc include files on your floppy disk 5 * glibc include files on your floppy disk
6 */6 */
7#ifndef _TCCLIB_H7#ifndef _TCCLIB_H
8#define _TCCLIB_H8#define _TCCLIB_H
tccmacho.c+8−8
@@ -450,19 +450,19 @@ struct macho { · 449 unmodified lines
450 Section *stub_helper, *la_symbol_ptr;450 Section *stub_helper, *la_symbol_ptr;
451 struct dyld_info_command *dyldinfo;451 struct dyld_info_command *dyldinfo;
452 int helpsym, lasym, dyld_private, dyld_stub_binder;452 int helpsym, lasym, dyld_private, dyld_stub_binder;
453 int n_lazy_bind; 453 int n_lazy_bind;
454 struct s_lazy_bind {454 struct s_lazy_bind {
455 int section;455 int section;
456 int bind_offset;456 int bind_offset;
457 int la_symbol_offset;457 int la_symbol_offset;
458 ElfW_Rel rel;458 ElfW_Rel rel;
459 } *s_lazy_bind;459 } *s_lazy_bind;
460 int n_rebase; 460 int n_rebase;
461 struct s_rebase {461 struct s_rebase {
462 int section;462 int section;
463 ElfW_Rel rel;463 ElfW_Rel rel;
464 } *s_rebase;464 } *s_rebase;
465 int n_bind; 465 int n_bind;
466 struct bind {466 struct bind {
467 int section;467 int section;
468 ElfW_Rel rel;468 ElfW_Rel rel;
@@ -565,7 +565,7 @@ static void tcc_macho_add_destructor(TCCState *s1) · 96 unmodified lines
565 text_section->sh_num, "__mh_execute_header");565 text_section->sh_num, "__mh_execute_header");
566 s = find_section(s1, ".fini_array");566 s = find_section(s1, ".fini_array");
567 if (s->data_offset == 0)567 if (s->data_offset == 0)
568 return; 568 return;
569 init_sym = put_elf_sym(s1->symtab, text_section->data_offset, 0,569 init_sym = put_elf_sym(s1->symtab, text_section->data_offset, 0,
570 ELFW(ST_INFO)(STB_LOCAL, STT_FUNC), 0,570 ELFW(ST_INFO)(STB_LOCAL, STT_FUNC), 0,
571 text_section->sh_num, "___GLOBAL_init_65535");571 text_section->sh_num, "___GLOBAL_init_65535");
@@ -585,7 +585,7 @@ static void tcc_macho_add_destructor(TCCState *s1) · 13 unmodified lines
585 ptr[0] = 0x48; // lea destructor(%rip),%rax585 ptr[0] = 0x48; // lea destructor(%rip),%rax
586 ptr[1] = 0x8d;586 ptr[1] = 0x8d;
587 ptr[2] = 0x05;587 ptr[2] = 0x05;
588 put_elf_reloca(s1->symtab, text_section, 588 put_elf_reloca(s1->symtab, text_section,
589 text_section->data_offset - 23,589 text_section->data_offset - 23,
590 R_X86_64_PC32, sym_index, -4);590 R_X86_64_PC32, sym_index, -4);
591 ptr[7] = 0x48; // mov %rax,%rdi591 ptr[7] = 0x48; // mov %rax,%rdi
@@ -617,7 +617,7 @@ static void tcc_macho_add_destructor(TCCState *s1) · 25 unmodified lines
617 int sym_index = ELFW(R_SYM)(rel->r_info);617 int sym_index = ELFW(R_SYM)(rel->r_info);
618 618
619 ptr = section_ptr_add(text_section, 24);619 ptr = section_ptr_add(text_section, 24);
620 put_elf_reloc(s1->symtab, text_section, 620 put_elf_reloc(s1->symtab, text_section,
621 text_section->data_offset - 24,621 text_section->data_offset - 24,
622 R_AARCH64_ADR_PREL_PG_HI21, sym_index);622 R_AARCH64_ADR_PREL_PG_HI21, sym_index);
623 write32le(ptr, 0x90000000); // adrp x0, destructor@page623 write32le(ptr, 0x90000000); // adrp x0, destructor@page
@@ -626,7 +626,7 @@ static void tcc_macho_add_destructor(TCCState *s1) · 2 unmodified lines
626 R_AARCH64_LDST8_ABS_LO12_NC, sym_index);626 R_AARCH64_LDST8_ABS_LO12_NC, sym_index);
627 write32le(ptr + 4, 0x91000000); // add x0,x0,destructor@pageoff627 write32le(ptr + 4, 0x91000000); // add x0,x0,destructor@pageoff
628 write32le(ptr + 8, 0xd2800001); // mov x1, #0628 write32le(ptr + 8, 0xd2800001); // mov x1, #0
629 put_elf_reloc(s1->symtab, text_section, 629 put_elf_reloc(s1->symtab, text_section,
630 text_section->data_offset - 12,630 text_section->data_offset - 12,
631 R_AARCH64_ADR_PREL_PG_HI21, mh_execute_header);631 R_AARCH64_ADR_PREL_PG_HI21, mh_execute_header);
632 write32le(ptr + 12, 0x90000002); // adrp x2, mh_execute_header@page632 write32le(ptr + 12, 0x90000002); // adrp x2, mh_execute_header@page
@@ -828,7 +828,7 @@ static void check_relocs(TCCState *s1, struct macho *mo) · 195 unmodified lines
828 write32le(jmp + 16, 0xf9400210); // ldr x16,[x16,dyld_stub_binder@pageoff]828 write32le(jmp + 16, 0xf9400210); // ldr x16,[x16,dyld_stub_binder@pageoff]
829 write32le(jmp + 20, 0xd61f0200); // br x16829 write32le(jmp + 20, 0xd61f0200); // br x16
830#endif830#endif
831 831
832 goti = NULL;832 goti = NULL;
833 mo->nr_plt = mo->n_got = 0;833 mo->nr_plt = mo->n_got = 0;
834 for (i = 1; i < s1->nb_sections; i++) {834 for (i = 1; i < s1->nb_sections; i++) {
tccpe.c+1−1
@@ -1422,7 +1422,7 @@ static int pe_check_symbols(struct pe_info *pe) · 1421 unmodified lines
1422#ifdef TCC_TARGET_X86_641422#ifdef TCC_TARGET_X86_64
1423 write32le(p + 2, (DWORD)-4);1423 write32le(p + 2, (DWORD)-4);
1424#endif1424#endif
1425 put_elf_reloc(symtab_section, text_section, 1425 put_elf_reloc(symtab_section, text_section,
1426 offset + 2, R_XXX_THUNKFIX, is->iat_index);1426 offset + 2, R_XXX_THUNKFIX, is->iat_index);
1427#endif1427#endif
1428 }1428 }
tccpp.c+19−19
@@ -1,6 +1,6 @@
1/*1/*
2 * TCC - Tiny C Compiler2 * TCC - Tiny C Compiler
3 * 3 *
4 * Copyright (c) 2001-2004 Fabrice Bellard4 * Copyright (c) 2001-2004 Fabrice Bellard
5 *5 *
6 * This library is free software; you can redistribute it and/or6 * This library is free software; you can redistribute it and/or
@@ -76,7 +76,7 @@ static struct TinyAlloc *tokstr_alloc; · 69 unmodified lines
76 76
77static TokenString *macro_stack;77static TokenString *macro_stack;
78 78
79static const char tcc_keywords[] = 79static const char tcc_keywords[] =
80#define DEF(id, str) str "\0"80#define DEF(id, str) str "\0"
81#include "tcctok.h"81#include "tcctok.h"
82#undef DEF82#undef DEF
@@ -480,7 +480,7 @@ static TokenSym *tok_alloc_new(TokenSym **pts, const char *str, int len) · 397 unmodified lines
480 TokenSym *ts, **ptable;480 TokenSym *ts, **ptable;
481 int i;481 int i;
482 482
483 if (tok_ident >= SYM_FIRST_ANOM) 483 if (tok_ident >= SYM_FIRST_ANOM)
484 tcc_error("memory full (symbols)");484 tcc_error("memory full (symbols)");
485 485
486 /* expand token table if needed */486 /* expand token table if needed */
@@ -515,7 +515,7 @@ ST_FUNC TokenSym *tok_alloc(const char *str, int len) · 28 unmodified lines
515 TokenSym *ts, **pts;515 TokenSym *ts, **pts;
516 int i;516 int i;
517 unsigned int h;517 unsigned int h;
518 518
519 h = TOK_HASH_INIT;519 h = TOK_HASH_INIT;
520 for(i=0;i<len;i++)520 for(i=0;i<len;i++)
521 h = TOK_HASH_FUNC(h, ((unsigned char *)str)[i]);521 h = TOK_HASH_FUNC(h, ((unsigned char *)str)[i]);
@@ -943,7 +943,7 @@ redo_start: · 421 unmodified lines
943 file->buf_ptr = p;943 file->buf_ptr = p;
944 next_nomacro();944 next_nomacro();
945 p = file->buf_ptr;945 p = file->buf_ptr;
946 if (a == 0 && 946 if (a == 0 &&
947 (tok == TOK_ELSE || tok == TOK_ELIF || tok == TOK_ENDIF))947 (tok == TOK_ELSE || tok == TOK_ELIF || tok == TOK_ENDIF))
948 goto the_end;948 goto the_end;
949 if (tok == TOK_IF || tok == TOK_IFDEF || tok == TOK_IFNDEF)949 if (tok == TOK_IF || tok == TOK_IFDEF || tok == TOK_IFNDEF)
@@ -1444,7 +1444,7 @@ static int expr_preprocess(TCCState *s1) · 494 unmodified lines
1444 int c, t;1444 int c, t;
1445 int t0 = tok;1445 int t0 = tok;
1446 TokenString *str;1446 TokenString *str;
1447 1447
1448 str = tok_str_alloc();1448 str = tok_str_alloc();
1449 pp_expr = 1;1449 pp_expr = 1;
1450 while (1) {1450 while (1) {
@@ -1460,7 +1460,7 @@ static int expr_preprocess(TCCState *s1) · 9 unmodified lines
1460 parse_flags &= ~PARSE_FLAG_PREPROCESS; /* no macro subst */1460 parse_flags &= ~PARSE_FLAG_PREPROCESS; /* no macro subst */
1461 next();1461 next();
1462 t = tok;1462 t = tok;
1463 if (t == '(') 1463 if (t == '(')
1464 next();1464 next();
1465 parse_flags |= PARSE_FLAG_PREPROCESS;1465 parse_flags |= PARSE_FLAG_PREPROCESS;
1466 if (tok < TOK_IDENT)1466 if (tok < TOK_IDENT)
@@ -2079,7 +2079,7 @@ static void parse_escape_string(CString *outstr, const uint8_t *buf, int is_long · 612 unmodified lines
2079 break;2079 break;
2080 case '\'':2080 case '\'':
2081 case '\"':2081 case '\"':
2082 case '\\': 2082 case '\\':
2083 case '?':2083 case '?':
2084 break;2084 break;
2085 default:2085 default:
@@ -2307,7 +2307,7 @@ static void parse_number(const char *p) · 221 unmodified lines
2307 *q = '\0';2307 *q = '\0';
2308 if (b == 16)2308 if (b == 16)
2309 shift = 4;2309 shift = 4;
2310 else 2310 else
2311 shift = 1;2311 shift = 1;
2312 bn_zero(bn);2312 bn_zero(bn);
2313 q = token_buf;2313 q = token_buf;
@@ -2629,7 +2629,7 @@ maybe_newline: · 315 unmodified lines
2629 case '#':2629 case '#':
2630 /* XXX: simplify */2630 /* XXX: simplify */
2631 PEEKC(c, p);2631 PEEKC(c, p);
2632 if ((tok_flags & TOK_FLAG_BOL) && 2632 if ((tok_flags & TOK_FLAG_BOL) &&
2633 (parse_flags & PARSE_FLAG_PREPROCESS)) {2633 (parse_flags & PARSE_FLAG_PREPROCESS)) {
2634 tok_flags &= ~TOK_FLAG_BOL;2634 tok_flags &= ~TOK_FLAG_BOL;
2635 file->buf_ptr = p;2635 file->buf_ptr = p;
@@ -2653,7 +2653,7 @@ maybe_newline: · 17 unmodified lines
2653 }2653 }
2654 }2654 }
2655 break;2655 break;
2656 2656
2657 /* dollar is allowed to start identifiers when not parsing asm */2657 /* dollar is allowed to start identifiers when not parsing asm */
2658 case '$':2658 case '$':
2659 if (!(isidnum_table['$' - CH_EOF] & IS_ID)2659 if (!(isidnum_table['$' - CH_EOF] & IS_ID)
@@ -2666,14 +2666,14 @@ maybe_newline: · 6 unmodified lines
2666 case 'm': case 'n': case 'o': case 'p':2666 case 'm': case 'n': case 'o': case 'p':
2667 case 'q': case 'r': case 's': case 't':2667 case 'q': case 'r': case 's': case 't':
2668 case 'u': case 'v': case 'w': case 'x':2668 case 'u': case 'v': case 'w': case 'x':
2669 case 'y': case 'z': 2669 case 'y': case 'z':
2670 case 'A': case 'B': case 'C': case 'D':2670 case 'A': case 'B': case 'C': case 'D':
2671 case 'E': case 'F': case 'G': case 'H':2671 case 'E': case 'F': case 'G': case 'H':
2672 case 'I': case 'J': case 'K': 2672 case 'I': case 'J': case 'K':
2673 case 'M': case 'N': case 'O': case 'P':2673 case 'M': case 'N': case 'O': case 'P':
2674 case 'Q': case 'R': case 'S': case 'T':2674 case 'Q': case 'R': case 'S': case 'T':
2675 case 'U': case 'V': case 'W': case 'X':2675 case 'U': case 'V': case 'W': case 'X':
2676 case 'Y': case 'Z': 2676 case 'Y': case 'Z':
2677 case '_':2677 case '_':
2678 parse_ident_fast:2678 parse_ident_fast:
2679 p1 = p;2679 p1 = p;
@@ -2830,7 +2830,7 @@ maybe_newline: · 150 unmodified lines
2830 tok = TOK_GT;2830 tok = TOK_GT;
2831 }2831 }
2832 break;2832 break;
2833 2833
2834 case '&':2834 case '&':
2835 PEEKC(c, p);2835 PEEKC(c, p);
2836 if (c == '&') {2836 if (c == '&') {
@@ -2843,7 +2843,7 @@ maybe_newline: · 6 unmodified lines
2843 tok = '&';2843 tok = '&';
2844 }2844 }
2845 break;2845 break;
2846 2846
2847 case '|':2847 case '|':
2848 PEEKC(c, p);2848 PEEKC(c, p);
2849 if (c == '|') {2849 if (c == '|') {
@@ -2869,7 +2869,7 @@ maybe_newline: · 19 unmodified lines
2869 tok = '+';2869 tok = '+';
2870 }2870 }
2871 break;2871 break;
2872 2872
2873 case '-':2873 case '-':
2874 PEEKC(c, p);2874 PEEKC(c, p);
2875 if (c == '-') {2875 if (c == '-') {
@@ -2891,7 +2891,7 @@ maybe_newline: · 15 unmodified lines
2891 PARSE2('*', '*', '=', TOK_A_MUL)2891 PARSE2('*', '*', '=', TOK_A_MUL)
2892 PARSE2('%', '%', '=', TOK_A_MOD)2892 PARSE2('%', '%', '=', TOK_A_MOD)
2893 PARSE2('^', '^', '=', TOK_A_XOR)2893 PARSE2('^', '^', '=', TOK_A_XOR)
2894 2894
2895 /* comments or operator */2895 /* comments or operator */
2896 case '/':2896 case '/':
2897 PEEKC(c, p);2897 PEEKC(c, p);
@@ -2911,7 +2911,7 @@ maybe_newline: · 13 unmodified lines
2911 tok = '/';2911 tok = '/';
2912 }2912 }
2913 break;2913 break;
2914 2914
2915 /* simple tokens */2915 /* simple tokens */
2916 case '@': /* only used in assembler */2916 case '@': /* only used in assembler */
2917#ifdef TCC_TARGET_ARM /* comment on arm asm */2917#ifdef TCC_TARGET_ARM /* comment on arm asm */
tccrun.c+2−2
@@ -916,7 +916,7 @@ static addr_t rt_printline_dwarf (rt_context *rc, addr_t wanted_pc, bt_info *bi) · 915 unmodified lines
916 : dwarf_read_8(ln, end);916 : dwarf_read_8(ln, end);
917#endif917#endif
918 }918 }
919 else 919 else
920 dwarf_ignore_type(ln, end);920 dwarf_ignore_type(ln, end);
921 }921 }
922 }922 }
@@ -948,7 +948,7 @@ static addr_t rt_printline_dwarf (rt_context *rc, addr_t wanted_pc, bt_info *bi) · 25 unmodified lines
948 if (i < FILE_TABLE_SIZE)948 if (i < FILE_TABLE_SIZE)
949 filename_table[i].dir_entry = value;949 filename_table[i].dir_entry = value;
950 }950 }
951 else 951 else
952 dwarf_ignore_type(ln, end);952 dwarf_ignore_type(ln, end);
953 }953 }
954 }954 }
tests/abitest.c+15−15
@@ -41,7 +41,7 @@ static int run_callback(const char *src, callback_type callback) { · 40 unmodified lines
41 TCCState *s;41 TCCState *s;
42 int result;42 int result;
43 void *ptr;43 void *ptr;
44 44
45 s = tcc_new();45 s = tcc_new();
46 if (!s)46 if (!s)
47 return -1;47 return -1;
@@ -54,14 +54,14 @@ static int run_callback(const char *src, callback_type callback) { · 6 unmodified lines
54 return -1;54 return -1;
55 if (tcc_relocate(s) == -1)55 if (tcc_relocate(s) == -1)
56 return -1;56 return -1;
57 57
58 ptr = tcc_get_symbol(s, "f");58 ptr = tcc_get_symbol(s, "f");
59 if (!ptr)59 if (!ptr)
60 return -1;60 return -1;
61 result = callback(ptr);61 result = callback(ptr);
62 62
63 tcc_delete(s);63 tcc_delete(s);
64 64
65 return result;65 return result;
66}66}
67 67
@@ -89,7 +89,7 @@ RET_PRIMITIVE_TEST(longdouble, LONG_DOUBLE, LONG_DOUBLE_LITERAL(378943892.0)) · 21 unmodified lines
89 89
90/*90/*
91 * ret_2float_test:91 * ret_2float_test:
92 * 92 *
93 * On x86-64, a struct with 2 floats should be packed into a single93 * On x86-64, a struct with 2 floats should be packed into a single
94 * SSE register (VT_DOUBLE is used for this purpose).94 * SSE register (VT_DOUBLE is used for this purpose).
95 */95 */
@@ -117,7 +117,7 @@ static int ret_2float_test(void) { · 21 unmodified lines
117 117
118/*118/*
119 * ret_2double_test:119 * ret_2double_test:
120 * 120 *
121 * On x86-64, a struct with 2 doubles should be passed in two SSE121 * On x86-64, a struct with 2 doubles should be passed in two SSE
122 * registers.122 * registers.
123 */123 */
@@ -281,7 +281,7 @@ static int reg_pack_test(void) { · 157 unmodified lines
281 " reg_pack_test_type r = {a.x*5, a.y*3};\n"281 " reg_pack_test_type r = {a.x*5, a.y*3};\n"
282 " return r;\n"282 " return r;\n"
283 "}\n";283 "}\n";
284 284
285 return run_callback(src, reg_pack_test_callback);285 return run_callback(src, reg_pack_test_callback);
286}286}
287 287
@@ -307,7 +307,7 @@ static int reg_pack_longlong_test(void) { · 19 unmodified lines
307 " reg_pack_longlong_test_type r = {a.x*5, a.y*3};\n"307 " reg_pack_longlong_test_type r = {a.x*5, a.y*3};\n"
308 " return r;\n"308 " return r;\n"
309 "}\n";309 "}\n";
310 310
311 return run_callback(src, reg_pack_longlong_test_callback);311 return run_callback(src, reg_pack_longlong_test_callback);
312}312}
313 313
@@ -365,13 +365,13 @@ static int sret_test(void) { · 51 unmodified lines
365 " sret_test_type r = {x.a*35, x.b*19, x.c*21};\n"365 " sret_test_type r = {x.a*35, x.b*19, x.c*21};\n"
366 " return r;\n"366 " return r;\n"
367 "}\n";367 "}\n";
368 368
369 return run_callback(src, sret_test_callback);369 return run_callback(src, sret_test_callback);
370}370}
371 371
372/*372/*
373 * one_member_union_test:373 * one_member_union_test:
374 * 374 *
375 * In the x86-64 ABI a union should always be passed on the stack. However375 * In the x86-64 ABI a union should always be passed on the stack. However
376 * it appears that a single member union is treated by GCC as its member.376 * it appears that a single member union is treated by GCC as its member.
377 */377 */
@@ -399,7 +399,7 @@ static int one_member_union_test(void) { · 21 unmodified lines
399 399
400/*400/*
401 * two_member_union_test:401 * two_member_union_test:
402 * 402 *
403 * In the x86-64 ABI a union should always be passed on the stack.403 * In the x86-64 ABI a union should always be passed on the stack.
404 */404 */
405typedef union two_member_union_test_type_u {int x; long y;} two_member_union_test_type;405typedef union two_member_union_test_type_u {int x; long y;} two_member_union_test_type;
@@ -430,7 +430,7 @@ static int two_member_union_test(void) { · 24 unmodified lines
430 430
431typedef struct many_struct_test_type_s {long long a, b, c;} many_struct_test_type;431typedef struct many_struct_test_type_s {long long a, b, c;} many_struct_test_type;
432typedef many_struct_test_type (*many_struct_test_function_type) (many_struct_test_type,many_struct_test_type,many_struct_test_type,many_struct_test_type,many_struct_test_type,many_struct_test_type);432typedef many_struct_test_type (*many_struct_test_function_type) (many_struct_test_type,many_struct_test_type,many_struct_test_type,many_struct_test_type,many_struct_test_type,many_struct_test_type);
433 433
434static int many_struct_test_callback(void *ptr) {434static int many_struct_test_callback(void *ptr) {
435 many_struct_test_function_type f = (many_struct_test_function_type)ptr;435 many_struct_test_function_type f = (many_struct_test_function_type)ptr;
436 many_struct_test_type v = {1, 2, 3};436 many_struct_test_type v = {1, 2, 3};
@@ -457,7 +457,7 @@ static int many_struct_test(void) { · 20 unmodified lines
457 457
458typedef struct many_struct_test_2_type_s {int a, b;} many_struct_test_2_type;458typedef struct many_struct_test_2_type_s {int a, b;} many_struct_test_2_type;
459typedef many_struct_test_2_type (*many_struct_test_2_function_type) (many_struct_test_2_type,many_struct_test_2_type,many_struct_test_2_type,many_struct_test_2_type,many_struct_test_2_type,many_struct_test_2_type);459typedef many_struct_test_2_type (*many_struct_test_2_function_type) (many_struct_test_2_type,many_struct_test_2_type,many_struct_test_2_type,many_struct_test_2_type,many_struct_test_2_type,many_struct_test_2_type);
460 460
461static int many_struct_test_2_callback(void *ptr) {461static int many_struct_test_2_callback(void *ptr) {
462 many_struct_test_2_function_type f = (many_struct_test_2_function_type)ptr;462 many_struct_test_2_function_type f = (many_struct_test_2_function_type)ptr;
463 many_struct_test_2_type v = {1,2};463 many_struct_test_2_type v = {1,2};
@@ -628,7 +628,7 @@ static int arg_align_test_callback(void *ptr) { · 164 unmodified lines
628}628}
629 629
630static int arg_align_test(void) {630static int arg_align_test(void) {
631 const char *src = 631 const char *src =
632 "long double f(long double a, int b, long double c, int d, long double e) {\n"632 "long double f(long double a, int b, long double c, int d, long double e) {\n"
633 " return a + c + e;\n"633 " return a + c + e;\n"
634 "}\n";634 "}\n";
@@ -651,7 +651,7 @@ int main(int argc, char **argv) { · 16 unmodified lines
651 int i;651 int i;
652 const char *testname = NULL;652 const char *testname = NULL;
653 int retval = EXIT_SUCCESS;653 int retval = EXIT_SUCCESS;
654 654
655 /* if tcclib.h and libtcc1.a are not installed, where can we find them */655 /* if tcclib.h and libtcc1.a are not installed, where can we find them */
656 for (i = 1; i < argc; ++i) {656 for (i = 1; i < argc; ++i) {
657 if (!memcmp(argv[i], "run_test=", 9))657 if (!memcmp(argv[i], "run_test=", 9))
tests/asmtest.S+30−30
@@ -43,7 +43,7 @@ mov 0x10000, %eax · 42 unmodified lines
43mov 0x10000, %ax43mov 0x10000, %ax
44mov 0x10000, %al44mov 0x10000, %al
45mov %al, 0x1000045mov %al, 0x10000
46 46
47mov $1, %edx47mov $1, %edx
48mov $1, %dx48mov $1, %dx
49mov $1, %cl49mov $1, %cl
@@ -67,7 +67,7 @@ movl $0x11334455,(%rbx) · 17 unmodified lines
67#endif67#endif
68 68
69mov %eax, 0x12(,%edx,2)69mov %eax, 0x12(,%edx,2)
70 70
71#ifdef __i386__71#ifdef __i386__
72mov %cr3, %edx72mov %cr3, %edx
73mov %ecx, %cr373mov %ecx, %cr3
@@ -110,10 +110,10 @@ notl %r15d · 36 unmodified lines
110 movzbl 0x1000, %eax110 movzbl 0x1000, %eax
111 movzbw 0x1000, %ax111 movzbw 0x1000, %ax
112 movzwl 0x1000, %eax112 movzwl 0x1000, %eax
113 113
114 movzb 0x1000, %eax114 movzb 0x1000, %eax
115 movzb 0x1000, %ax115 movzb 0x1000, %ax
116 116
117 mov $0x12345678,%eax117 mov $0x12345678,%eax
118 118
119#ifdef __x86_64__119#ifdef __x86_64__
@@ -130,7 +130,7 @@ notl %r15d · 10 unmodified lines
130 mov $0x123456789abcdef0,%rcx130 mov $0x123456789abcdef0,%rcx
131 mov $0x123456789abcdef0,%r11131 mov $0x123456789abcdef0,%r11
132#endif132#endif
133 133
134#ifdef __i386__134#ifdef __i386__
135 pushl %eax135 pushl %eax
136 push %eax136 push %eax
@@ -145,7 +145,7 @@ notl %r15d · 8 unmodified lines
145 push $100145 push $100
146 push 0x42(%eax)146 push 0x42(%eax)
147 pop 0x43(%esi)147 pop 0x43(%esi)
148 148
149#ifdef __i386__149#ifdef __i386__
150 popl %eax150 popl %eax
151 pop %eax151 pop %eax
@@ -156,31 +156,31 @@ notl %r15d · 4 unmodified lines
156#endif156#endif
157 popw %ax157 popw %ax
158 pop %fs158 pop %fs
159 159
160 xchg %eax, %ecx160 xchg %eax, %ecx
161 xchg %edx, %eax161 xchg %edx, %eax
162 xchg %bx, 0x10000162 xchg %bx, 0x10000
163 xchg 0x10000, %ebx163 xchg 0x10000, %ebx
164 xchg 0x10000, %dl164 xchg 0x10000, %dl
165 165
166 in $100, %al 166 in $100, %al
167 in $100, %ax 167 in $100, %ax
168 in $100, %eax168 in $100, %eax
169 in %dx, %al169 in %dx, %al
170 in %dx, %ax 170 in %dx, %ax
171 in %dx, %eax171 in %dx, %eax
172 inb %dx172 inb %dx
173 inw %dx 173 inw %dx
174 inl %dx174 inl %dx
175 175
176 out %al, $100 176 out %al, $100
177 out %ax, $100 177 out %ax, $100
178 out %eax, $100 178 out %eax, $100
179 179
180 /* NOTE: gas is bugged here, so size must be added */180 /* NOTE: gas is bugged here, so size must be added */
181 outb %al, %dx 181 outb %al, %dx
182 outw %ax, %dx 182 outw %ax, %dx
183 outl %eax, %dx 183 outl %eax, %dx
184 184
185 leal 0x1000(%ebx), %ecx185 leal 0x1000(%ebx), %ecx
186 lea 0x1000(%ebx), %ecx186 lea 0x1000(%ebx), %ecx
@@ -242,10 +242,10 @@ movb $15, %r12b · 55 unmodified lines
242 242
243add %eax, (%ebx)243add %eax, (%ebx)
244add (%ebx), %eax244add (%ebx), %eax
245 245
246or %dx, (%ebx)246or %dx, (%ebx)
247or (%ebx), %si247or (%ebx), %si
248 248
249add %cl, (%ebx)249add %cl, (%ebx)
250add (%ebx), %dl250add (%ebx), %dl
251 251
@@ -253,7 +253,7 @@ add (%ebx), %dl · 1 unmodified line
253 incl 0x10000253 incl 0x10000
254 incb 0x10000254 incb 0x10000
255 dec %dx255 dec %dx
256 256
257 test $1, %al257 test $1, %al
258 test $1, %cl258 test $1, %cl
259 259
@@ -285,7 +285,7 @@ add (%ebx), %dl · 25 unmodified lines
285 imul $10, %eax285 imul $10, %eax
286 imul $0x1100000, %eax286 imul $0x1100000, %eax
287 imul $1, %eax287 imul $1, %eax
288 288
289 idivw 0x1000289 idivw 0x1000
290 div %ecx290 div %ecx
291 div %bl291 div %bl
@@ -381,7 +381,7 @@ L3: · 89 unmodified lines
381 loop L3381 loop L3
382 jecxz L3382 jecxz L3
383 383
384 384
385 seto %al385 seto %al
386 setc %al386 setc %al
387 setcb %al387 setcb %al
@@ -509,7 +509,7 @@ L3: · 121 unmodified lines
509 frstor 0x1000509 frstor 0x1000
510 ffree %st(7)510 ffree %st(7)
511 ffreep %st(6)511 ffreep %st(6)
512 512
513 ftst513 ftst
514 fxam514 fxam
515 fld1515 fld1
@@ -675,7 +675,7 @@ int $0x10 · 159 unmodified lines
675 repz cmpsb675 repz cmpsb
676 repne movsb676 repne movsb
677 repnz outsb677 repnz outsb
678 678
679 invd679 invd
680 wbinvd680 wbinvd
681 cpuid681 cpuid
@@ -721,13 +721,13 @@ int $0x10 · 39 unmodified lines
721 movd 0x1000, %mm2721 movd 0x1000, %mm2
722 movd %mm4, %ecx722 movd %mm4, %ecx
723 movd %mm5, 0x1000723 movd %mm5, 0x1000
724 724
725 movq 0x1000, %mm2725 movq 0x1000, %mm2
726 movq %mm4, 0x1000726 movq %mm4, 0x1000
727 727
728 pand 0x1000, %mm3728 pand 0x1000, %mm3
729 pand %mm4, %mm5729 pand %mm4, %mm5
730 730
731 psllw $1, %mm6731 psllw $1, %mm6
732 psllw 0x1000, %mm7732 psllw 0x1000, %mm7
733 psllw %mm2, %mm7733 psllw %mm2, %mm7
@@ -827,10 +827,10 @@ int $0x10 · 93 unmodified lines
827 str 0x1000827 str 0x1000
828 str %ecx828 str %ecx
829 str %dx829 str %dx
830 830
831 verr 0x1000831 verr 0x1000
832 verw 0x1000832 verw 0x1000
833 833
834#ifdef __i386__834#ifdef __i386__
835 push %ds835 push %ds
836 pushw %ds836 pushw %ds
@@ -947,7 +947,7 @@ overrideme: · 110 unmodified lines
947 movq %rdx, %xmm2947 movq %rdx, %xmm2
948 movq %r13, %xmm3948 movq %r13, %xmm3
949 /* movq mem64->xmm is encoded as f30f7e by GAS, but as949 /* movq mem64->xmm is encoded as f30f7e by GAS, but as
950 660f6e by tcc (which really is a movd and would need 950 660f6e by tcc (which really is a movd and would need
951 a REX.W prefix to be movq). */951 a REX.W prefix to be movq). */
952 movq (%rsi), %xmm3952 movq (%rsi), %xmm3
953 movq %mm1, %rdx953 movq %mm1, %rdx
tests/boundtest.c+2−2
@@ -79,7 +79,7 @@ int test6(void) · 78 unmodified lines
79{79{
80 int i, sum = 0;80 int i, sum = 0;
81 int *tab4;81 int *tab4;
82 82
83 tab4 = malloc(20 * sizeof(int));83 tab4 = malloc(20 * sizeof(int));
84 free(tab4);84 free(tab4);
85 for(i=0;i<21;i++) {85 for(i=0;i<21;i++) {
@@ -294,4 +294,4 @@ int main(int argc, char **argv) · 208 unmodified lines
294/*294/*
295 * without bound 0.77 s295 * without bound 0.77 s
296 * with bounds 4.73296 * with bounds 4.73
297 */ 297 */
tests/tcctest.c+51−51
@@ -249,7 +249,7 @@ void macro_test(void) · 248 unmodified lines
249 glue(a <, <= 2);249 glue(a <, <= 2);
250 printf("a=%d\n", a);250 printf("a=%d\n", a);
251 }251 }
252 252
253 /* macro function with argument outside the macro string */253 /* macro function with argument outside the macro string */
254#define MF_s MF_hello254#define MF_s MF_hello
255#define MF_hello(msg) printf("%s\n",msg)255#define MF_hello(msg) printf("%s\n",msg)
@@ -258,7 +258,7 @@ void macro_test(void) · 2 unmodified lines
258 258
259 MF_s("hi");259 MF_s("hi");
260 MF_t("hi");260 MF_t("hi");
261 261
262 /* test macro substitution inside args (should not eat stream) */262 /* test macro substitution inside args (should not eat stream) */
263 printf("qq=%d\n", qq(qq)(2));263 printf("qq=%d\n", qq(qq)(2));
264 264
@@ -322,7 +322,7 @@ void recursive_macro_test(void) · 57 unmodified lines
322 printf("%d\n", ELFW(ST_INFO)(STB_WEAK, ELFW(ST_TYPE)(123)));322 printf("%d\n", ELFW(ST_INFO)(STB_WEAK, ELFW(ST_TYPE)(123)));
323 323
324#define WRAP(x) x324#define WRAP(x) x
325 325
326#define print_num(x) print_num(__FILE__,__LINE__,x)326#define print_num(x) print_num(__FILE__,__LINE__,x)
327 print_num(123);327 print_num(123);
328 WRAP(print_num(123));328 WRAP(print_num(123));
@@ -566,7 +566,7 @@ void goto_test() · 237 unmodified lines
566 /* This needs to parse as label, not as start of decl. */566 /* This needs to parse as label, not as start of decl. */
567 typedef_and_label:567 typedef_and_label:
568 s_loop:568 s_loop:
569 if (i >= 10) 569 if (i >= 10)
570 goto s_end;570 goto s_end;
571 printf("%d", i);571 printf("%d", i);
572 i++;572 i++;
@@ -829,10 +829,10 @@ void expr_test() · 256 unmodified lines
829 printf("%d\n", ~12);829 printf("%d\n", ~12);
830 printf("%d\n", -12);830 printf("%d\n", -12);
831 printf("%d\n", +12);831 printf("%d\n", +12);
832 printf("%d %d %d %d\n", 832 printf("%d %d %d %d\n",
833 isid('a'), 833 isid('a'),
834 isid('g'), 834 isid('g'),
835 isid('T'), 835 isid('T'),
836 isid('('));836 isid('('));
837}837}
838 838
@@ -1120,7 +1120,7 @@ void struct_test() · 281 unmodified lines
1120 sizeof(altest6), __alignof__(altest6));1120 sizeof(altest6), __alignof__(altest6));
1121 printf("altest7 sizeof=%d alignof=%d\n",1121 printf("altest7 sizeof=%d alignof=%d\n",
1122 sizeof(altest7), __alignof__(altest7));1122 sizeof(altest7), __alignof__(altest7));
1123 1123
1124 /* empty structures (GCC extension) */1124 /* empty structures (GCC extension) */
1125#if !(defined _WIN32 && CC_NAME == CC_clang)1125#if !(defined _WIN32 && CC_NAME == CC_clang)
1126 printf("sizeof(struct empty) = %d\n", sizeof(struct empty));1126 printf("sizeof(struct empty) = %d\n", sizeof(struct empty));
@@ -1147,17 +1147,17 @@ void char_short_test() · 20 unmodified lines
1147 1147
1148 var1 = 0x01020304;1148 var1 = 0x01020304;
1149 var2 = 0xfffefdfc;1149 var2 = 0xfffefdfc;
1150 printf("s8=%d %d\n", 1150 printf("s8=%d %d\n",
1151 *(signed char *)&var1, *(signed char *)&var2);1151 *(signed char *)&var1, *(signed char *)&var2);
1152 printf("u8=%d %d\n", 1152 printf("u8=%d %d\n",
1153 *(unsigned char *)&var1, *(unsigned char *)&var2);1153 *(unsigned char *)&var1, *(unsigned char *)&var2);
1154 printf("s16=%d %d\n", 1154 printf("s16=%d %d\n",
1155 *(short *)&var1, *(short *)&var2);1155 *(short *)&var1, *(short *)&var2);
1156 printf("u16=%d %d\n", 1156 printf("u16=%d %d\n",
1157 *(unsigned short *)&var1, *(unsigned short *)&var2);1157 *(unsigned short *)&var1, *(unsigned short *)&var2);
1158 printf("s32=%d %d\n", 1158 printf("s32=%d %d\n",
1159 *(int *)&var1, *(int *)&var2);1159 *(int *)&var1, *(int *)&var2);
1160 printf("u32=%d %d\n", 1160 printf("u32=%d %d\n",
1161 *(unsigned int *)&var1, *(unsigned int *)&var2);1161 *(unsigned int *)&var1, *(unsigned int *)&var2);
1162 *(signed char *)&var1 = 0x08;1162 *(signed char *)&var1 = 0x08;
1163 printf("var1=%x\n", var1);1163 printf("var1=%x\n", var1);
@@ -1304,7 +1304,7 @@ void bool_test() · 140 unmodified lines
1304 static int v1 = 34 ? : -1; /* constant case */1304 static int v1 = 34 ? : -1; /* constant case */
1305 static int v2 = 0 ? : -1; /* constant case */1305 static int v2 = 0 ? : -1; /* constant case */
1306 int a = 30;1306 int a = 30;
1307 1307
1308 printf("%d %d\n", v1, v2);1308 printf("%d %d\n", v1, v2);
1309 printf("%d %d\n", a - 30 ? : a * 2, a + 1 ? : a * 2);1309 printf("%d %d\n", a - 30 ? : a * 2, a + 1 ? : a * 2);
1310 }1310 }
@@ -1467,7 +1467,7 @@ static int tentative_ar[]; · 156 unmodified lines
1467static int tentative_ar[] = {1,2,3};1467static int tentative_ar[] = {1,2,3};
1468 1468
1469int cinit1; /* a global variable can be defined several times without error ! */1469int cinit1; /* a global variable can be defined several times without error ! */
1470int cinit1; 1470int cinit1;
1471int cinit1 = 0;1471int cinit1 = 0;
1472int *cinit2 = (int []){3, 2, 1};1472int *cinit2 = (int []){3, 2, 1};
1473uintptr_t cinit3 = (uintptr_t)"AA";1473uintptr_t cinit3 = (uintptr_t)"AA";
@@ -1526,7 +1526,7 @@ void compound_literal_test(void) · 52 unmodified lines
1526 1526
1527 for(i=0;i<3;i++) {1527 for(i=0;i<3;i++) {
1528 p = (int []){1, 2, 4 + i};1528 p = (int []){1, 2, 4 + i};
1529 printf("%d %d %d\n", 1529 printf("%d %d %d\n",
1530 p[0],1530 p[0],
1531 p[1],1531 p[1],
1532 p[2]);1532 p[2]);
@@ -1566,7 +1566,7 @@ char invalid_function_def()[] {return 0;} · 33 unmodified lines
1566void num(int n)1566void num(int n)
1567{1567{
1568 char *tab, *p;1568 char *tab, *p;
1569 tab = (char*)malloc(20); 1569 tab = (char*)malloc(20);
1570 p = tab;1570 p = tab;
1571 while (1) {1571 while (1) {
1572 *p = 48 + (n % 10);1572 *p = 48 + (n % 10);
@@ -1607,7 +1607,7 @@ void struct_assign_test(void) · 34 unmodified lines
1607 struct structa1 lsta1, lsta2;1607 struct structa1 lsta1, lsta2;
1608 int i;1608 int i;
1609 } s = {{1,2}, {3,4}}, *ps;1609 } s = {{1,2}, {3,4}}, *ps;
1610 1610
1611 ps = &s;1611 ps = &s;
1612 ps->i = 4;1612 ps->i = 4;
1613 1613
@@ -1667,9 +1667,9 @@ void cast_test() · 53 unmodified lines
1667 printf("%d\n", a);1667 printf("%d\n", a);
1668 a = (scast = 65536) + 1;1668 a = (scast = 65536) + 1;
1669 printf("%d\n", a);1669 printf("%d\n", a);
1670 1670
1671 printf("sizeof(c) = %d, sizeof((int)c) = %d\n", sizeof(c), sizeof((int)c));1671 printf("sizeof(c) = %d, sizeof((int)c) = %d\n", sizeof(c), sizeof((int)c));
1672 1672
1673 /* test cast from unsigned to signed short to int */1673 /* test cast from unsigned to signed short to int */
1674 b = 0xf000;1674 b = 0xf000;
1675 d = (short)b;1675 d = (short)b;
@@ -1677,7 +1677,7 @@ void cast_test() · 1 unmodified line
1677 b = 0xf0f0;1677 b = 0xf0f0;
1678 d = (char)b;1678 d = (char)b;
1679 printf("((unsigned)(char)0x%08x) = 0x%08x\n", b, d);1679 printf("((unsigned)(char)0x%08x) = 0x%08x\n", b, d);
1680 1680
1681 /* test implicit int casting for array accesses */1681 /* test implicit int casting for array accesses */
1682 c = 0;1682 c = 0;
1683 tab[1] = 2;1683 tab[1] = 2;
@@ -1724,7 +1724,7 @@ char sinit8[] = "hello" "trala"; · 40 unmodified lines
1724 1724
1725struct structinit1 sinit9 = { 1, 2, 3 };1725struct structinit1 sinit9 = { 1, 2, 3 };
1726struct structinit1 sinit10 = { .f2 = 2, 3, .f1 = 1 };1726struct structinit1 sinit10 = { .f2 = 2, 3, .f1 = 1 };
1727struct structinit1 sinit11 = { .f2 = 2, 3, .f1 = 1, 1727struct structinit1 sinit11 = { .f2 = 2, 3, .f1 = 1,
1728#ifdef ALL_ISOC991728#ifdef ALL_ISOC99
1729 .farray[0] = 10,1729 .farray[0] = 10,
1730 .farray[1] = 11,1730 .farray[1] = 11,
@@ -1849,34 +1849,34 @@ void init_test(void) · 118 unmodified lines
1849 struct bf_SS bfaa_finit[3] = { [1].bit = 1 };1849 struct bf_SS bfaa_finit[3] = { [1].bit = 1 };
1850 struct bf_SS bfaa_fvinit[] = { [2].bit = 1 };1850 struct bf_SS bfaa_fvinit[] = { [2].bit = 1 };
1851 struct b2_SS bf_finit2 = {0xFFF000FFF000FLL, 0x123};1851 struct b2_SS bf_finit2 = {0xFFF000FFF000FLL, 0x123};
1852 1852
1853 printf("sinit1=%d\n", sinit1);1853 printf("sinit1=%d\n", sinit1);
1854 printf("sinit2=%d\n", sinit2);1854 printf("sinit2=%d\n", sinit2);
1855 printf("sinit3=%d %d %d %d\n", 1855 printf("sinit3=%d %d %d %d\n",
1856 sizeof(sinit3),1856 sizeof(sinit3),
1857 sinit3[0],1857 sinit3[0],
1858 sinit3[1],1858 sinit3[1],
1859 sinit3[2]1859 sinit3[2]
1860 );1860 );
1861 printf("sinit6=%d\n", sizeof(sinit6));1861 printf("sinit6=%d\n", sizeof(sinit6));
1862 printf("sinit7=%d %d %d %d\n", 1862 printf("sinit7=%d %d %d %d\n",
1863 sizeof(sinit7),1863 sizeof(sinit7),
1864 sinit7[0],1864 sinit7[0],
1865 sinit7[1],1865 sinit7[1],
1866 sinit7[2]1866 sinit7[2]
1867 );1867 );
1868 printf("sinit8=%s\n", sinit8);1868 printf("sinit8=%s\n", sinit8);
1869 printf("sinit9=%d %d %d\n", 1869 printf("sinit9=%d %d %d\n",
1870 sinit9.f1,1870 sinit9.f1,
1871 sinit9.f2,1871 sinit9.f2,
1872 sinit9.f31872 sinit9.f3
1873 );1873 );
1874 printf("sinit10=%d %d %d\n", 1874 printf("sinit10=%d %d %d\n",
1875 sinit10.f1,1875 sinit10.f1,
1876 sinit10.f2,1876 sinit10.f2,
1877 sinit10.f31877 sinit10.f3
1878 );1878 );
1879 printf("sinit11=%d %d %d %d %d %d\n", 1879 printf("sinit11=%d %d %d %d %d %d\n",
1880 sinit11.f1,1880 sinit11.f1,
1881 sinit11.f2,1881 sinit11.f2,
1882 sinit11.f3,1882 sinit11.f3,
@@ -1887,7 +1887,7 @@ void init_test(void) · 4 unmodified lines
1887 1887
1888 for(i=0;i<3;i++)1888 for(i=0;i<3;i++)
1889 for(j=0;j<2;j++)1889 for(j=0;j<2;j++)
1890 printf("[%d][%d] = %d %d %d\n", 1890 printf("[%d][%d] = %d %d %d\n",
1891 i, j, sinit4[i][j], sinit5[i][j], linit4[i][j]);1891 i, j, sinit4[i][j], sinit5[i][j], linit4[i][j]);
1892 printf("linit1=%d\n", linit1);1892 printf("linit1=%d\n", linit1);
1893 printf("linit2=%d\n", linit2);1893 printf("linit2=%d\n", linit2);
@@ -1896,7 +1896,7 @@ void init_test(void) · 2 unmodified lines
1896 1896
1897 printf("sinit12=%s\n", sinit12);1897 printf("sinit12=%s\n", sinit12);
1898 printf("sinit13=%d %s %s %s\n",1898 printf("sinit13=%d %s %s %s\n",
1899 sizeof(sinit13), 1899 sizeof(sinit13),
1900 sinit13[0],1900 sinit13[0],
1901 sinit13[1],1901 sinit13[1],
1902 sinit13[2]);1902 sinit13[2]);
@@ -1910,7 +1910,7 @@ void init_test(void) · 7 unmodified lines
1910 printf("\n");1910 printf("\n");
1911 for(i=0;i<10;i++) printf(" %d", linit15[i]);1911 for(i=0;i<10;i++) printf(" %d", linit15[i]);
1912 printf("\n");1912 printf("\n");
1913 printf("%d %d %d %d\n", 1913 printf("%d %d %d %d\n",
1914 linit16.a1,1914 linit16.a1,
1915 linit16.a2,1915 linit16.a2,
1916 linit16.a3,1916 linit16.a3,
@@ -2129,13 +2129,13 @@ void bitfield_test(void) · 212 unmodified lines
2129 printf("%d %d\n", sa, ca);2129 printf("%d %d\n", sa, ca);
2130 2130
2131 st1.f1 = 7;2131 st1.f1 = 7;
2132 if (st1.f1 == -1) 2132 if (st1.f1 == -1)
2133 printf("st1.f1 == -1\n");2133 printf("st1.f1 == -1\n");
2134 else 2134 else
2135 printf("st1.f1 != -1\n");2135 printf("st1.f1 != -1\n");
2136 if (st1.f2 == -1) 2136 if (st1.f2 == -1)
2137 printf("st1.f2 == -1\n");2137 printf("st1.f2 == -1\n");
2138 else 2138 else
2139 printf("st1.f2 != -1\n");2139 printf("st1.f2 != -1\n");
2140 2140
2141 struct sbf2 {2141 struct sbf2 {
@@ -2447,7 +2447,7 @@ void lloptest(long long a, long long b) · 305 unmodified lines
2447 a + b,2447 a + b,
2448 a - b,2448 a - b,
2449 a * b);2449 a * b);
2450 2450
2451 if (b != 0) {2451 if (b != 0) {
2452 printf("arith1: " LONG_LONG_FORMAT " " LONG_LONG_FORMAT "\n",2452 printf("arith1: " LONG_LONG_FORMAT " " LONG_LONG_FORMAT "\n",
2453 a / b,2453 a / b,
@@ -2468,7 +2468,7 @@ void lloptest(long long a, long long b) · 14 unmodified lines
2468 a > b,2468 a > b,
2469 a >= b,2469 a >= b,
2470 a <= b);2470 a <= b);
2471 2471
2472 printf("utest: %d %d %d %d %d %d\n",2472 printf("utest: %d %d %d %d %d %d\n",
2473 ua == ub,2473 ua == ub,
2474 ua != ub,2474 ua != ub,
@@ -2544,7 +2544,7 @@ long long llfunc1(int a) · 69 unmodified lines
2544}2544}
2545 2545
2546struct S {2546struct S {
2547 int id; 2547 int id;
2548 char item;2548 char item;
2549};2549};
2550 2550
@@ -2701,7 +2701,7 @@ void vprintf1(const char *fmt, ...) · 150 unmodified lines
2701 2701
2702 va_start(aq, fmt);2702 va_start(aq, fmt);
2703 va_copy(ap, aq);2703 va_copy(ap, aq);
2704 2704
2705 p = fmt;2705 p = fmt;
2706 for(;;) {2706 for(;;) {
2707 c = *p;2707 c = *p;
@@ -2987,10 +2987,10 @@ void c99_vla_test_1(int size1, int size2) · 279 unmodified lines
2987 int tab1[size][2], tab2[10][2];2987 int tab1[size][2], tab2[10][2];
2988 void *tab1_ptr, *tab2_ptr, *bad_ptr;2988 void *tab1_ptr, *tab2_ptr, *bad_ptr;
2989 2989
2990 /* "size" should have been 'captured' at tab1 declaration, 2990 /* "size" should have been 'captured' at tab1 declaration,
2991 so modifying it should have no effect on VLA behaviour. */2991 so modifying it should have no effect on VLA behaviour. */
2992 size = size-1;2992 size = size-1;
2993 2993
2994 printf("Test C99 VLA 1 (sizeof): ");2994 printf("Test C99 VLA 1 (sizeof): ");
2995 printf("%s\n", (sizeof tab1 == size1 * size2 * 2 * sizeof(int)) ? "PASSED" : "FAILED");2995 printf("%s\n", (sizeof tab1 == size1 * size2 * 2 * sizeof(int)) ? "PASSED" : "FAILED");
2996 tab1_ptr = tab1;2996 tab1_ptr = tab1;
@@ -3143,7 +3143,7 @@ void sizeof_test(void) · 146 unmodified lines
3143 t <<= 16;3143 t <<= 16;
3144 t <<= 16;3144 t <<= 16;
3145 t++;3145 t++;
3146 /* This checks that sizeof really can be used to manipulate 3146 /* This checks that sizeof really can be used to manipulate
3147 uintptr_t objects, without truncation. */3147 uintptr_t objects, without truncation. */
3148 t2 = t & -sizeof(uintptr_t);3148 t2 = t & -sizeof(uintptr_t);
3149 printf ("%lu %lu\n", t, t2);3149 printf ("%lu %lu\n", t, t2);
@@ -3209,15 +3209,15 @@ void statement_expr_test(void) · 59 unmodified lines
3209 /* Basic stmt expr test */3209 /* Basic stmt expr test */
3210 a = 0;3210 a = 0;
3211 for(i=0;i<10;i++) {3211 for(i=0;i<10;i++) {
3212 a += 1 + 3212 a += 1 +
3213 ( { int b, j; 3213 ( { int b, j;
3214 b = 0; 3214 b = 0;
3215 for(j=0;j<5;j++) 3215 for(j=0;j<5;j++)
3216 b += j; b; 3216 b += j; b;
3217 } );3217 } );
3218 }3218 }
3219 printf("a=%d\n", a);3219 printf("a=%d\n", a);
3220 3220
3221 /* Test that symbols aren't freed prematurely.3221 /* Test that symbols aren't freed prematurely.
3222 With SYM_DEBUG valgrind will show a read from a freed3222 With SYM_DEBUG valgrind will show a read from a freed
3223 symbol, and tcc will show an (invalid) warning on the initialization3223 symbol, and tcc will show an (invalid) warning on the initialization
@@ -4062,7 +4062,7 @@ void __attribute__((weak)) weak_test(void) · 838 unmodified lines
4062 printf("weak_fpa=%d\n",&weak_fpa ? weak_fpa() : 123);4062 printf("weak_fpa=%d\n",&weak_fpa ? weak_fpa() : 123);
4063 printf("weak_fpb=%d\n",&weak_fpb ? weak_fpb() : 123);4063 printf("weak_fpb=%d\n",&weak_fpb ? weak_fpb() : 123);
4064 printf("weak_fpc=%d\n",&weak_fpc ? weak_fpc() : 123);4064 printf("weak_fpc=%d\n",&weak_fpc ? weak_fpc() : 123);
4065 4065
4066 printf("weak_asm_f1=%d\n", weak_asm_f1 != NULL);4066 printf("weak_asm_f1=%d\n", weak_asm_f1 != NULL);
4067 printf("weak_asm_f2=%d\n", weak_asm_f2 != NULL);4067 printf("weak_asm_f2=%d\n", weak_asm_f2 != NULL);
4068 printf("weak_asm_f3=%d\n", weak_asm_f3 != NULL);4068 printf("weak_asm_f3=%d\n", weak_asm_f3 != NULL);
tests/vla_test.c+2−2
@@ -18,13 +18,13 @@ void smash(char *p, int n) { · 17 unmodified lines
18int test1(int n) {18int test1(int n) {
19 int i;19 int i;
20 char *array_ptrs[LOOP_COUNT];20 char *array_ptrs[LOOP_COUNT];
21 21
22 for (i = 0; i < LOOP_COUNT; ++i) {22 for (i = 0; i < LOOP_COUNT; ++i) {
23 char test[n];23 char test[n];
24 smash(test, n);24 smash(test, n);
25 array_ptrs[i] = test;25 array_ptrs[i] = test;
26 }26 }
27 27
28 return (array_ptrs[0]-array_ptrs[LOOP_COUNT-1] < n) ? 0 : 1;28 return (array_ptrs[0]-array_ptrs[LOOP_COUNT-1] < n) ? 0 : 1;
29}29}
30 30
texi2pod.pl+1−1
@@ -229,7 +229,7 @@ while(<$inf>) { · 228 unmodified lines
229 $inf = gensym();229 $inf = gensym();
230 230
231 # Try cwd and $ibase.231 # Try cwd and $ibase.
232 open($inf, "<" . $1) 232 open($inf, "<" . $1)
233 or open($inf, "<" . $ibase . "/" . $1)233 or open($inf, "<" . $ibase . "/" . $1)
234 or die "cannot open $1 or $ibase/$1: $!\n";234 or die "cannot open $1 or $ibase/$1: $!\n";
235 next;235 next;
win32/tcc-win32.txt+1−1
@@ -9,7 +9,7 @@ · 8 unmodified lines
9 Installation from the binary ZIP package:9 Installation from the binary ZIP package:
10 -----------------------------------------10 -----------------------------------------
11 Unzip the package to a directory of your choice.11 Unzip the package to a directory of your choice.
12 12
13 13
14 Set the system PATH:14 Set the system PATH:
15 --------------------15 --------------------
x86_64-asm.h+1−1
@@ -108,7 +108,7 @@ ALT(DEF_ASM_OP2(lzcntw, 0xf30fbd, 0, OPC_MODRM | OPC_WLX, OPT_REGW | OPT_EA, OPT · 107 unmodified lines
108 DEF_ASM_OP0(ud2, 0x0f0b)108 DEF_ASM_OP0(ud2, 0x0f0b)
109 109
110 /* NOTE: we took the same order as gas opcode definition order */110 /* NOTE: we took the same order as gas opcode definition order */
111/* Right now we can't express the fact that 0xa1/0xa3 can't use $eax and a 111/* Right now we can't express the fact that 0xa1/0xa3 can't use $eax and a
112 32 bit moffset as operands.112 32 bit moffset as operands.
113ALT(DEF_ASM_OP2(movb, 0xa0, 0, OPC_BWLX, OPT_ADDR, OPT_EAX))113ALT(DEF_ASM_OP2(movb, 0xa0, 0, OPC_BWLX, OPT_ADDR, OPT_EAX))
114ALT(DEF_ASM_OP2(movb, 0xa2, 0, OPC_BWLX, OPT_EAX, OPT_ADDR)) */114ALT(DEF_ASM_OP2(movb, 0xa2, 0, OPC_BWLX, OPT_EAX, OPT_ADDR)) */
x86_64-gen.c+24−24
@@ -670,7 +670,7 @@ static void gen_bounds_epilog(void) · 669 unmodified lines
670 bounds_ptr = section_ptr_add(lbounds_section, sizeof(addr_t));670 bounds_ptr = section_ptr_add(lbounds_section, sizeof(addr_t));
671 *bounds_ptr = 0;671 *bounds_ptr = 0;
672 672
673 sym_data = get_sym_ref(&char_pointer_type, lbounds_section, 673 sym_data = get_sym_ref(&char_pointer_type, lbounds_section,
674 func_bound_offset, PTR_SIZE);674 func_bound_offset, PTR_SIZE);
675 675
676 /* generate bound local allocation */676 /* generate bound local allocation */
@@ -795,7 +795,7 @@ void gfunc_call(int nb_args) · 118 unmodified lines
795 struct_size = args_size;795 struct_size = args_size;
796 for(i = 0; i < nb_args; i++) {796 for(i = 0; i < nb_args; i++) {
797 SValue *sv;797 SValue *sv;
798 798
799 --arg;799 --arg;
800 sv = &vtop[-i];800 sv = &vtop[-i];
801 bt = (sv->type.t & VT_BTYPE);801 bt = (sv->type.t & VT_BTYPE);
@@ -870,7 +870,7 @@ void gfunc_call(int nb_args) · 68 unmodified lines
870 vtop->type.t = size > 4 ? VT_LLONG : size > 2 ? VT_INT870 vtop->type.t = size > 4 ? VT_LLONG : size > 2 ? VT_INT
871 : size > 1 ? VT_SHORT : VT_BYTE;871 : size > 1 ? VT_SHORT : VT_BYTE;
872 }872 }
873 873
874 r = gv(RC_INT);874 r = gv(RC_INT);
875 if (arg >= REGN) {875 if (arg >= REGN) {
876 gen_offs_sp(0x89, r, arg*8);876 gen_offs_sp(0x89, r, arg*8);
@@ -891,7 +891,7 @@ void gfunc_call(int nb_args) · 14 unmodified lines
891 o(0xda894c); /* mov %r11, %rdx */891 o(0xda894c); /* mov %r11, %rdx */
892 }892 }
893 }893 }
894 894
895 gcall_or_jmp(0);895 gcall_or_jmp(0);
896 896
897 if ((vtop->r & VT_SYM) && vtop->sym->v == TOK_alloca) {897 if ((vtop->r & VT_SYM) && vtop->sym->v == TOK_alloca) {
@@ -1066,10 +1066,10 @@ static X86_64_Mode classify_x86_64_inner(CType *ty) · 168 unmodified lines
1066{1066{
1067 X86_64_Mode mode;1067 X86_64_Mode mode;
1068 Sym *f;1068 Sym *f;
1069 1069
1070 switch (ty->t & VT_BTYPE) {1070 switch (ty->t & VT_BTYPE) {
1071 case VT_VOID: return x86_64_mode_none;1071 case VT_VOID: return x86_64_mode_none;
1072 1072
1073 case VT_INT:1073 case VT_INT:
1074 case VT_BYTE:1074 case VT_BYTE:
1075 case VT_SHORT:1075 case VT_SHORT:
@@ -1078,19 +1078,19 @@ static X86_64_Mode classify_x86_64_inner(CType *ty) · 2 unmodified lines
1078 case VT_PTR:1078 case VT_PTR:
1079 case VT_FUNC:1079 case VT_FUNC:
1080 return x86_64_mode_integer;1080 return x86_64_mode_integer;
1081 1081
1082 case VT_FLOAT:1082 case VT_FLOAT:
1083 case VT_DOUBLE: return x86_64_mode_sse;1083 case VT_DOUBLE: return x86_64_mode_sse;
1084 1084
1085 case VT_LDOUBLE: return x86_64_mode_x87;1085 case VT_LDOUBLE: return x86_64_mode_x87;
1086 1086
1087 case VT_STRUCT:1087 case VT_STRUCT:
1088 f = ty->ref;1088 f = ty->ref;
1089 1089
1090 mode = x86_64_mode_none;1090 mode = x86_64_mode_none;
1091 for (f = f->next; f; f = f->next)1091 for (f = f->next; f; f = f->next)
1092 mode = classify_x86_64_merge(mode, classify_x86_64_inner(&f->type));1092 mode = classify_x86_64_merge(mode, classify_x86_64_inner(&f->type));
1093 1093
1094 return mode;1094 return mode;
1095 }1095 }
1096 assert(0);1096 assert(0);
@@ -1101,7 +1101,7 @@ static X86_64_Mode classify_x86_64_arg(CType *ty, CType *ret, int *psize, int *p · 4 unmodified lines
1101{1101{
1102 X86_64_Mode mode;1102 X86_64_Mode mode;
1103 int size, align, ret_t = 0;1103 int size, align, ret_t = 0;
1104 1104
1105 if (ty->t & (VT_BITFIELD|VT_ARRAY)) {1105 if (ty->t & (VT_BITFIELD|VT_ARRAY)) {
1106 *psize = 8;1106 *psize = 8;
1107 *palign = 8;1107 *palign = 8;
@@ -1137,7 +1137,7 @@ static X86_64_Mode classify_x86_64_arg(CType *ty, CType *ret, int *psize, int *p · 29 unmodified lines
1137 ret_t |= VT_UNSIGNED;1137 ret_t |= VT_UNSIGNED;
1138 }1138 }
1139 break;1139 break;
1140 1140
1141 case x86_64_mode_x87:1141 case x86_64_mode_x87:
1142 *reg_count = 1;1142 *reg_count = 1;
1143 ret_t = VT_LDOUBLE;1143 ret_t = VT_LDOUBLE;
@@ -1156,12 +1156,12 @@ static X86_64_Mode classify_x86_64_arg(CType *ty, CType *ret, int *psize, int *p · 12 unmodified lines
1156 }1156 }
1157 }1157 }
1158 }1158 }
1159 1159
1160 if (ret) {1160 if (ret) {
1161 ret->ref = NULL;1161 ret->ref = NULL;
1162 ret->t = ret_t;1162 ret->t = ret_t;
1163 }1163 }
1164 1164
1165 return mode;1165 return mode;
1166}1166}
1167 1167
@@ -1446,13 +1446,13 @@ void gfunc_prolog(Sym *func_sym) · 278 unmodified lines
1446 stack_arg:1446 stack_arg:
1447 seen_stack_size = ((seen_stack_size + align - 1) & -align) + size;1447 seen_stack_size = ((seen_stack_size + align - 1) & -align) + size;
1448 break;1448 break;
1449 1449
1450 case x86_64_mode_integer:1450 case x86_64_mode_integer:
1451 if (seen_reg_num + reg_count > REGN)1451 if (seen_reg_num + reg_count > REGN)
1452 goto stack_arg;1452 goto stack_arg;
1453 seen_reg_num += reg_count;1453 seen_reg_num += reg_count;
1454 break;1454 break;
1455 1455
1456 case x86_64_mode_sse:1456 case x86_64_mode_sse:
1457 if (seen_sse_num + reg_count > 8)1457 if (seen_sse_num + reg_count > 8)
1458 goto stack_arg;1458 goto stack_arg;
@@ -1529,14 +1529,14 @@ void gfunc_prolog(Sym *func_sym) · 70 unmodified lines
1529 addr += size;1529 addr += size;
1530 }1530 }
1531 break;1531 break;
1532 1532
1533 case x86_64_mode_memory:1533 case x86_64_mode_memory:
1534 case x86_64_mode_x87:1534 case x86_64_mode_x87:
1535 addr = (addr + align - 1) & -align;1535 addr = (addr + align - 1) & -align;
1536 param_addr = addr;1536 param_addr = addr;
1537 addr += size;1537 addr += size;
1538 break;1538 break;
1539 1539
1540 case x86_64_mode_integer: {1540 case x86_64_mode_integer: {
1541 if (reg_param_index + reg_count <= REGN) {1541 if (reg_param_index + reg_count <= REGN) {
1542 /* save arguments passed by register */1542 /* save arguments passed by register */
@@ -1931,7 +1931,7 @@ void gen_opf(int op) · 388 unmodified lines
1931 vswap();1931 vswap();
1932 }1932 }
1933 assert(!(vtop[-1].r & VT_LVAL));1933 assert(!(vtop[-1].r & VT_LVAL));
1934 1934
1935 if ((vtop->r & VT_SYM) && (vtop->sym->type.t & VT_TLS))1935 if ((vtop->r & VT_SYM) && (vtop->sym->type.t & VT_TLS))
1936 o(0x64); /* fs segment prefix */1936 o(0x64); /* fs segment prefix */
1937 1937
@@ -1966,7 +1966,7 @@ void gen_opf(int op) · 28 unmodified lines
1966 ft = vtop->type.t;1966 ft = vtop->type.t;
1967 fc = vtop->c.i;1967 fc = vtop->c.i;
1968 assert((ft & VT_BTYPE) != VT_LDOUBLE);1968 assert((ft & VT_BTYPE) != VT_LDOUBLE);
1969 1969
1970 /* if saved lvalue, then we must reload it */1970 /* if saved lvalue, then we must reload it */
1971 if ((vtop->r & VT_VALMASK) == VT_LLOCAL) {1971 if ((vtop->r & VT_VALMASK) == VT_LLOCAL) {
1972 SValue v1;1972 SValue v1;
@@ -1979,7 +1979,7 @@ void gen_opf(int op) · 6 unmodified lines
1979 fc = 0;1979 fc = 0;
1980 vtop->r = r | VT_LVAL;1980 vtop->r = r | VT_LVAL;
1981 }1981 }
1982 1982
1983 assert(!(vtop[-1].r & VT_LVAL));1983 assert(!(vtop[-1].r & VT_LVAL));
1984 if (swapped) {1984 if (swapped) {
1985 assert(vtop->r & VT_LVAL);1985 assert(vtop->r & VT_LVAL);
@@ -1987,7 +1987,7 @@ void gen_opf(int op) · 1 unmodified line
1987 vswap();1987 vswap();
1988 fc = vtop->c.i; /* bcheck may have saved previous vtop[-1] */1988 fc = vtop->c.i; /* bcheck may have saved previous vtop[-1] */
1989 }1989 }
1990 1990
1991 if ((ft & VT_BTYPE) == VT_DOUBLE) {1991 if ((ft & VT_BTYPE) == VT_DOUBLE) {
1992 o(0xf2);1992 o(0xf2);
1993 } else {1993 } else {
@@ -1995,7 +1995,7 @@ void gen_opf(int op) · 1 unmodified line
1995 }1995 }
1996 o(0x0f);1996 o(0x0f);
1997 opc = 0x58 + a;1997 opc = 0x58 + a;
1998 1998
1999 gen_modrm32(opc, vtop[-1].r, vtop->r, vtop->sym, fc);1999 gen_modrm32(opc, vtop[-1].r, vtop->r, vtop->sym, fc);
2000 vtop--;2000 vtop--;
2001 }2001 }
@@ -2053,7 +2053,7 @@ void gen_cvt_ftof(int t) · 51 unmodified lines
2053 ft = vtop->type.t;2053 ft = vtop->type.t;
2054 bt = ft & VT_BTYPE;2054 bt = ft & VT_BTYPE;
2055 tbt = t & VT_BTYPE;2055 tbt = t & VT_BTYPE;
2056 2056
2057 if (bt == VT_FLOAT) {2057 if (bt == VT_FLOAT) {
2058 gv(RC_FLOAT);2058 gv(RC_FLOAT);
2059 if (tbt == VT_DOUBLE) {2059 if (tbt == VT_DOUBLE) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t