History

initial TMS320C67xx support (TK)

bellard committed 22 years ago

Commit 79c72b21 parent df36de67 files · +87 −7Browse files

Unified · Split

7 files
  1. Changelog +3 −2
  2. Makefile +3 −0
  3. arm-gen.c +1 −0
  4. elf.h +18 −0
  5. i386-gen.c +1 −0
  6. tcc.c +30 −5
  7. tccelf.c +31 −0
Changelog+3−2
@@ -2,9 +2,10 @@ version 0.9.21: · 1 unmodified line
2 2
3- ARM target support (Daniel Glöckner)3- ARM target support (Daniel Glöckner)
4- added '-funsigned-char, '-fsigned-char' and4- added '-funsigned-char, '-fsigned-char' and
5 '-Wimplicit-function-declaration'.5 '-Wimplicit-function-declaration'
6- fixed assignment of const struct in struct.6- fixed assignment of const struct in struct
7- line comment fix (reported by Bertram Felgenhauer)7- line comment fix (reported by Bertram Felgenhauer)
8- initial TMS320C67xx support (TK)
8 9
9version 0.9.20:10version 0.9.20:
10 11
Makefile+3−0
@@ -114,6 +114,9 @@ tcc_g: tcc.c i386-gen.c tccelf.c tccasm.c i386-asm.c tcctok.h libtcc.h i386-asm. · 113 unmodified lines
114tcc: tcc_g Makefile114tcc: tcc_g Makefile
115 strip -s -R .comment -R .note -o $@ $<115 strip -s -R .comment -R .note -o $@ $<
116 116
117c67-tcc: tcc.c c67-gen.c tccelf.c tccasm.c tcctok.h libtcc.h Makefile
118 $(CC) $(CFLAGS) -DTCC_TARGET_C67 -o $@ $< $(LIBS)
119
117# TinyCC runtime libraries120# TinyCC runtime libraries
118libtcc1.o: libtcc1.c121libtcc1.o: libtcc1.c
119 $(CC) -O2 -Wall -c -o $@ $<122 $(CC) -O2 -Wall -c -o $@ $<
arm-gen.c+1−0
@@ -710,6 +710,7 @@ void gfunc_prolog(CType *func_type) · 709 unmodified lines
710 addr += size;710 addr += size;
711 }711 }
712 last_itod_magic=0;712 last_itod_magic=0;
713 loc = 0;
713}714}
714 715
715/* generate function epilog */716/* generate function epilog */
elf.h+18−0
@@ -217,6 +217,7 @@ typedef struct · 216 unmodified lines
217 chances of collision with official or non-GNU unofficial values. */217 chances of collision with official or non-GNU unofficial values. */
218 218
219#define EM_ALPHA 0x9026219#define EM_ALPHA 0x9026
220#define EM_C60 0x9c60
220 221
221/* Legal values for e_version (version). */222/* Legal values for e_version (version). */
222 223
@@ -1592,4 +1593,21 @@ typedef Elf32_Addr Elf32_Conflict; · 1369 unmodified lines
1592/* Keep this the last entry. */1593/* Keep this the last entry. */
1593#define R_ARM_NUM 2561594#define R_ARM_NUM 256
1594 1595
1596/* TMS320C67xx specific declarations */
1597/* XXX: no ELF standard yet */
1598
1599/* TMS320C67xx relocs. */
1600#define R_C60_32 1
1601#define R_C60_GOT32 3 /* 32 bit GOT entry */
1602#define R_C60_PLT32 4 /* 32 bit PLT address */
1603#define R_C60_COPY 5 /* Copy symbol at runtime */
1604#define R_C60_GLOB_DAT 6 /* Create GOT entry */
1605#define R_C60_JMP_SLOT 7 /* Create PLT entry */
1606#define R_C60_RELATIVE 8 /* Adjust by program base */
1607#define R_C60_GOTOFF 9 /* 32 bit offset to GOT */
1608#define R_C60_GOTPC 10 /* 32 bit PC relative offset to GOT */
1609
1610#define R_C60HI16 0x55 // high 16 bit MVKH embedded
1611#define R_C60LO16 0x54 // low 16 bit MVKL embedded
1612
1595#endif /* elf.h */1613#endif /* elf.h */
i386-gen.c+1−0
@@ -427,6 +427,7 @@ void gfunc_prolog(CType *func_type) · 426 unmodified lines
427 oad(0xb8, 0); /* call to function */427 oad(0xb8, 0); /* call to function */
428 func_bound_offset = lbounds_section->data_offset;428 func_bound_offset = lbounds_section->data_offset;
429 }429 }
430 loc = 0;
430}431}
431 432
432/* generate function epilog */433/* generate function epilog */
tcc.c+30−5
@@ -62,21 +62,32 @@ · 61 unmodified lines
62/* target selection */62/* target selection */
63//#define TCC_TARGET_I386 /* i386 code generator */63//#define TCC_TARGET_I386 /* i386 code generator */
64//#define TCC_TARGET_ARM /* ARMv4 code generator */64//#define TCC_TARGET_ARM /* ARMv4 code generator */
65//#define TCC_TARGET_C67 /* TMS320C67xx code generator */
65 66
66/* default target is I386 */67/* default target is I386 */
67#if !defined(TCC_TARGET_I386) && !defined(TCC_TARGET_ARM)68#if !defined(TCC_TARGET_I386) && !defined(TCC_TARGET_ARM) && \
69 !defined(TCC_TARGET_C67)
68#define TCC_TARGET_I38670#define TCC_TARGET_I386
69#endif71#endif
70 72
71#if !defined(WIN32) && !defined(TCC_UCLIBC) && !defined(TCC_TARGET_ARM)73#if !defined(WIN32) && !defined(TCC_UCLIBC) && !defined(TCC_TARGET_ARM) && \
74 !defined(TCC_TARGET_C67)
72#define CONFIG_TCC_BCHECK /* enable bound checking code */75#define CONFIG_TCC_BCHECK /* enable bound checking code */
73#endif76#endif
74 77
75/* define it to include assembler support */78/* define it to include assembler support */
76#if !defined(TCC_TARGET_ARM)79#if !defined(TCC_TARGET_ARM) && !defined(TCC_TARGET_C67)
77#define CONFIG_TCC_ASM80#define CONFIG_TCC_ASM
78#endif81#endif
79 82
83#if !defined(WIN32)
84#define FALSE 0
85#define false 0
86#define TRUE 1
87#define true 1
88typedef int BOOL;
89#endif
90
80/* path to find crt1.o, crti.o and crtn.o. Only needed when generating91/* path to find crt1.o, crti.o and crtn.o. Only needed when generating
81 executables or dlls */92 executables or dlls */
82#define CONFIG_TCC_CRT_PREFIX "/usr/lib"93#define CONFIG_TCC_CRT_PREFIX "/usr/lib"
@@ -801,6 +812,10 @@ static inline int is_float(int t) · 718 unmodified lines
801#include "arm-gen.c"812#include "arm-gen.c"
802#endif813#endif
803 814
815#ifdef TCC_TARGET_C67
816#include "c67-gen.c"
817#endif
818
804#ifdef CONFIG_TCC_STATIC819#ifdef CONFIG_TCC_STATIC
805 820
806#define RTLD_LAZY 0x001821#define RTLD_LAZY 0x001
@@ -4614,6 +4629,11 @@ int gv(int rc) · 3807 unmodified lines
4614 }4629 }
4615 }4630 }
4616 vtop->r = r;4631 vtop->r = r;
4632#ifdef TCC_TARGET_C67
4633 /* uses register pairs for doubles */
4634 if ((vtop->type.t & VT_BTYPE) == VT_DOUBLE)
4635 vtop->r2 = r+1;
4636#endif
4617 }4637 }
4618 return r;4638 return r;
4619}4639}
@@ -4964,6 +4984,8 @@ void gen_opl(int op) · 344 unmodified lines
4964#elif defined(TCC_TARGET_ARM)4984#elif defined(TCC_TARGET_ARM)
4965 b = ind;4985 b = ind;
4966 o(0x1A000000 | encbranch(ind, 0, 1));4986 o(0x1A000000 | encbranch(ind, 0, 1));
4987#elif defined(TCC_TARGET_C67)
4988 error("not implemented");
4967#else4989#else
4968#error not supported4990#error not supported
4969#endif4991#endif
@@ -5624,7 +5646,11 @@ static int type_size(CType *type, int *a) · 654 unmodified lines
5624 *a = LDOUBLE_ALIGN;5646 *a = LDOUBLE_ALIGN;
5625 return LDOUBLE_SIZE;5647 return LDOUBLE_SIZE;
5626 } else if (bt == VT_DOUBLE || bt == VT_LLONG) {5648 } else if (bt == VT_DOUBLE || bt == VT_LLONG) {
5627 *a = 4; /* XXX: i386 specific */5649#ifdef TCC_TARGET_I386
5650 *a = 4;
5651#else
5652 *a = 8;
5653#endif
5628 return 8;5654 return 8;
5629 } else if (bt == VT_INT || bt == VT_ENUM || bt == VT_FLOAT) {5655 } else if (bt == VT_INT || bt == VT_ENUM || bt == VT_FLOAT) {
5630 *a = 4;5656 *a = 4;
@@ -8673,7 +8699,6 @@ static void decl(int l) · 3042 unmodified lines
8673 /* push a dummy symbol to enable local sym storage */8699 /* push a dummy symbol to enable local sym storage */
8674 sym_push2(&local_stack, SYM_FIELD, 0, 0);8700 sym_push2(&local_stack, SYM_FIELD, 0, 0);
8675 gfunc_prolog(&type);8701 gfunc_prolog(&type);
8676 loc = 0;
8677 rsym = 0;8702 rsym = 0;
8678#ifdef CONFIG_REG_VARS8703#ifdef CONFIG_REG_VARS
8679 macro_ptr = func_str.str;8704 macro_ptr = func_str.str;
tccelf.c+31−0
@@ -548,6 +548,14 @@ static void relocate_section(TCCState *s1, Section *s) · 547 unmodified lines
548 fprintf(stderr,"FIXME: handle reloc type %x at %lx [%.8x] to %lx\n",548 fprintf(stderr,"FIXME: handle reloc type %x at %lx [%.8x] to %lx\n",
549 type,addr,(unsigned int )ptr,val);549 type,addr,(unsigned int )ptr,val);
550 break;550 break;
551#elif defined(TCC_TARGET_C67)
552 case R_C60_32:
553 *(int *)ptr += val;
554 break;
555 default:
556 fprintf(stderr,"FIXME: handle reloc type %x at %lx [%.8x] to %lx\n",
557 type,addr,(unsigned int )ptr,val);
558 break;
551#else559#else
552#error unsupported processor560#error unsupported processor
553#endif561#endif
@@ -754,6 +762,8 @@ static void put_got_entry(TCCState *s1, · 200 unmodified lines
754 if (s1->output_type == TCC_OUTPUT_EXE)762 if (s1->output_type == TCC_OUTPUT_EXE)
755 offset = plt->data_offset - 16;763 offset = plt->data_offset - 16;
756 }764 }
765#elif defined(TCC_TARGET_C67)
766 error("C67 got not implemented");
757#else767#else
758#error unsupported CPU768#error unsupported CPU
759#endif769#endif
@@ -828,6 +838,25 @@ static void build_got_entries(TCCState *s1) · 68 unmodified lines
828 sym_index);838 sym_index);
829 }839 }
830 break;840 break;
841#elif defined(TCC_TARGET_C67)
842 case R_C60_GOT32:
843 case R_C60_GOTOFF:
844 case R_C60_GOTPC:
845 case R_C60_PLT32:
846 if (!s1->got)
847 build_got(s1);
848 if (type == R_C60_GOT32 || type == R_C60_PLT32) {
849 sym_index = ELF32_R_SYM(rel->r_info);
850 sym = &((Elf32_Sym *)symtab_section->data)[sym_index];
851 /* look at the symbol got offset. If none, then add one */
852 if (type == R_C60_GOT32)
853 reloc_type = R_C60_GLOB_DAT;
854 else
855 reloc_type = R_C60_JMP_SLOT;
856 put_got_entry(s1, reloc_type, sym->st_size, sym->st_info,
857 sym_index);
858 }
859 break;
831#else860#else
832#error unsupported CPU861#error unsupported CPU
833#endif862#endif
@@ -1415,6 +1444,8 @@ int tcc_output_file(TCCState *s1, const char *filename) · 581 unmodified lines
1415 put32(p + 12, x + get32(p + 12) + s1->plt->data - p);1444 put32(p + 12, x + get32(p + 12) + s1->plt->data - p);
1416 p += 16;1445 p += 16;
1417 }1446 }
1447#elif defined(TCC_TARGET_C67)
1448 /* XXX: TODO */
1418#else1449#else
1419#error unsupported CPU1450#error unsupported CPU
1420#endif1451#endif

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