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
22
33 - ARM target support (Daniel Glöckner)
44 - added '-funsigned-char, '-fsigned-char' and
5− '-Wimplicit-function-declaration'.
6−- fixed assignment of const struct in struct.
5+ '-Wimplicit-function-declaration'
6+- fixed assignment of const struct in struct
77 - line comment fix (reported by Bertram Felgenhauer)
8+- initial TMS320C67xx support (TK)
89
910 version 0.9.20:
1011
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
114114 tcc: tcc_g Makefile
115115 strip -s -R .comment -R .note -o $@ $<
116116
117+c67-tcc: tcc.c c67-gen.c tccelf.c tccasm.c tcctok.h libtcc.h Makefile
118+ $(CC) $(CFLAGS) -DTCC_TARGET_C67 -o $@ $< $(LIBS)
119+
117120 # TinyCC runtime libraries
118121 libtcc1.o: libtcc1.c
119122 $(CC) -O2 -Wall -c -o $@ $<
arm-gen.c+1−0
@@ -710,6 +710,7 @@ void gfunc_prolog(CType *func_type) · 709 unmodified lines
710710 addr += size;
711711 }
712712 last_itod_magic=0;
713+ loc = 0;
713714 }
714715
715716 /* generate function epilog */
elf.h+18−0
@@ -217,6 +217,7 @@ typedef struct · 216 unmodified lines
217217 chances of collision with official or non-GNU unofficial values. */
218218
219219 #define EM_ALPHA 0x9026
220+#define EM_C60 0x9c60
220221
221222 /* Legal values for e_version (version). */
222223
@@ -1592,4 +1593,21 @@ typedef Elf32_Addr Elf32_Conflict; · 1369 unmodified lines
15921593 /* Keep this the last entry. */
15931594 #define R_ARM_NUM 256
15941595
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+
15951613 #endif /* elf.h */
i386-gen.c+1−0
@@ -427,6 +427,7 @@ void gfunc_prolog(CType *func_type) · 426 unmodified lines
427427 oad(0xb8, 0); /* call to function */
428428 func_bound_offset = lbounds_section->data_offset;
429429 }
430+ loc = 0;
430431 }
431432
432433 /* generate function epilog */
tcc.c+30−5
@@ -62,21 +62,32 @@ · 61 unmodified lines
6262 /* target selection */
6363 //#define TCC_TARGET_I386 /* i386 code generator */
6464 //#define TCC_TARGET_ARM /* ARMv4 code generator */
65+//#define TCC_TARGET_C67 /* TMS320C67xx code generator */
6566
6667 /* 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)
6870 #define TCC_TARGET_I386
6971 #endif
7072
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)
7275 #define CONFIG_TCC_BCHECK /* enable bound checking code */
7376 #endif
7477
7578 /* define it to include assembler support */
76−#if !defined(TCC_TARGET_ARM)
79+#if !defined(TCC_TARGET_ARM) && !defined(TCC_TARGET_C67)
7780 #define CONFIG_TCC_ASM
7881 #endif
7982
83+#if !defined(WIN32)
84+#define FALSE 0
85+#define false 0
86+#define TRUE 1
87+#define true 1
88+typedef int BOOL;
89+#endif
90+
8091 /* path to find crt1.o, crti.o and crtn.o. Only needed when generating
8192 executables or dlls */
8293 #define CONFIG_TCC_CRT_PREFIX "/usr/lib"
@@ -801,6 +812,10 @@ static inline int is_float(int t) · 718 unmodified lines
801812 #include "arm-gen.c"
802813 #endif
803814
815+#ifdef TCC_TARGET_C67
816+#include "c67-gen.c"
817+#endif
818+
804819 #ifdef CONFIG_TCC_STATIC
805820
806821 #define RTLD_LAZY 0x001
@@ -4614,6 +4629,11 @@ int gv(int rc) · 3807 unmodified lines
46144629 }
46154630 }
46164631 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
46174637 }
46184638 return r;
46194639 }
@@ -4964,6 +4984,8 @@ void gen_opl(int op) · 344 unmodified lines
49644984 #elif defined(TCC_TARGET_ARM)
49654985 b = ind;
49664986 o(0x1A000000 | encbranch(ind, 0, 1));
4987+#elif defined(TCC_TARGET_C67)
4988+ error("not implemented");
49674989 #else
49684990 #error not supported
49694991 #endif
@@ -5624,7 +5646,11 @@ static int type_size(CType *type, int *a) · 654 unmodified lines
56245646 *a = LDOUBLE_ALIGN;
56255647 return LDOUBLE_SIZE;
56265648 } 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
56285654 return 8;
56295655 } else if (bt == VT_INT || bt == VT_ENUM || bt == VT_FLOAT) {
56305656 *a = 4;
@@ -8673,7 +8699,6 @@ static void decl(int l) · 3042 unmodified lines
86738699 /* push a dummy symbol to enable local sym storage */
86748700 sym_push2(&local_stack, SYM_FIELD, 0, 0);
86758701 gfunc_prolog(&type);
8676− loc = 0;
86778702 rsym = 0;
86788703 #ifdef CONFIG_REG_VARS
86798704 macro_ptr = func_str.str;
tccelf.c+31−0
@@ -548,6 +548,14 @@ static void relocate_section(TCCState *s1, Section *s) · 547 unmodified lines
548548 fprintf(stderr,"FIXME: handle reloc type %x at %lx [%.8x] to %lx\n",
549549 type,addr,(unsigned int )ptr,val);
550550 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;
551559 #else
552560 #error unsupported processor
553561 #endif
@@ -754,6 +762,8 @@ static void put_got_entry(TCCState *s1, · 200 unmodified lines
754762 if (s1->output_type == TCC_OUTPUT_EXE)
755763 offset = plt->data_offset - 16;
756764 }
765+#elif defined(TCC_TARGET_C67)
766+ error("C67 got not implemented");
757767 #else
758768 #error unsupported CPU
759769 #endif
@@ -828,6 +838,25 @@ static void build_got_entries(TCCState *s1) · 68 unmodified lines
828838 sym_index);
829839 }
830840 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;
831860 #else
832861 #error unsupported CPU
833862 #endif
@@ -1415,6 +1444,8 @@ int tcc_output_file(TCCState *s1, const char *filename) · 581 unmodified lines
14151444 put32(p + 12, x + get32(p + 12) + s1->plt->data - p);
14161445 p += 16;
14171446 }
1447+#elif defined(TCC_TARGET_C67)
1448+ /* XXX: TODO */
14181449 #else
14191450 #error unsupported CPU
14201451 #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