initial TMS320C67xx support (TK)

tcc-xref
bellard 2004-10-04 21:57:35 +00:00
parent df36de6507
commit 79c72b2419
7 changed files with 87 additions and 7 deletions

View File

@ -2,9 +2,10 @@ version 0.9.21:
- ARM target support (Daniel Glöckner)
- added '-funsigned-char, '-fsigned-char' and
'-Wimplicit-function-declaration'.
- fixed assignment of const struct in struct.
'-Wimplicit-function-declaration'
- fixed assignment of const struct in struct
- line comment fix (reported by Bertram Felgenhauer)
- initial TMS320C67xx support (TK)
version 0.9.20:

View File

@ -114,6 +114,9 @@ tcc_g: tcc.c i386-gen.c tccelf.c tccasm.c i386-asm.c tcctok.h libtcc.h i386-asm.
tcc: tcc_g Makefile
strip -s -R .comment -R .note -o $@ $<
c67-tcc: tcc.c c67-gen.c tccelf.c tccasm.c tcctok.h libtcc.h Makefile
$(CC) $(CFLAGS) -DTCC_TARGET_C67 -o $@ $< $(LIBS)
# TinyCC runtime libraries
libtcc1.o: libtcc1.c
$(CC) -O2 -Wall -c -o $@ $<

View File

@ -710,6 +710,7 @@ void gfunc_prolog(CType *func_type)
addr += size;
}
last_itod_magic=0;
loc = 0;
}
/* generate function epilog */

18
elf.h
View File

@ -217,6 +217,7 @@ typedef struct
chances of collision with official or non-GNU unofficial values. */
#define EM_ALPHA 0x9026
#define EM_C60 0x9c60
/* Legal values for e_version (version). */
@ -1592,4 +1593,21 @@ typedef Elf32_Addr Elf32_Conflict;
/* Keep this the last entry. */
#define R_ARM_NUM 256
/* TMS320C67xx specific declarations */
/* XXX: no ELF standard yet */
/* TMS320C67xx relocs. */
#define R_C60_32 1
#define R_C60_GOT32 3 /* 32 bit GOT entry */
#define R_C60_PLT32 4 /* 32 bit PLT address */
#define R_C60_COPY 5 /* Copy symbol at runtime */
#define R_C60_GLOB_DAT 6 /* Create GOT entry */
#define R_C60_JMP_SLOT 7 /* Create PLT entry */
#define R_C60_RELATIVE 8 /* Adjust by program base */
#define R_C60_GOTOFF 9 /* 32 bit offset to GOT */
#define R_C60_GOTPC 10 /* 32 bit PC relative offset to GOT */
#define R_C60HI16 0x55 // high 16 bit MVKH embedded
#define R_C60LO16 0x54 // low 16 bit MVKL embedded
#endif /* elf.h */

View File

@ -427,6 +427,7 @@ void gfunc_prolog(CType *func_type)
oad(0xb8, 0); /* call to function */
func_bound_offset = lbounds_section->data_offset;
}
loc = 0;
}
/* generate function epilog */

35
tcc.c
View File

@ -62,21 +62,32 @@
/* target selection */
//#define TCC_TARGET_I386 /* i386 code generator */
//#define TCC_TARGET_ARM /* ARMv4 code generator */
//#define TCC_TARGET_C67 /* TMS320C67xx code generator */
/* default target is I386 */
#if !defined(TCC_TARGET_I386) && !defined(TCC_TARGET_ARM)
#if !defined(TCC_TARGET_I386) && !defined(TCC_TARGET_ARM) && \
!defined(TCC_TARGET_C67)
#define TCC_TARGET_I386
#endif
#if !defined(WIN32) && !defined(TCC_UCLIBC) && !defined(TCC_TARGET_ARM)
#if !defined(WIN32) && !defined(TCC_UCLIBC) && !defined(TCC_TARGET_ARM) && \
!defined(TCC_TARGET_C67)
#define CONFIG_TCC_BCHECK /* enable bound checking code */
#endif
/* define it to include assembler support */
#if !defined(TCC_TARGET_ARM)
#if !defined(TCC_TARGET_ARM) && !defined(TCC_TARGET_C67)
#define CONFIG_TCC_ASM
#endif
#if !defined(WIN32)
#define FALSE 0
#define false 0
#define TRUE 1
#define true 1
typedef int BOOL;
#endif
/* path to find crt1.o, crti.o and crtn.o. Only needed when generating
executables or dlls */
#define CONFIG_TCC_CRT_PREFIX "/usr/lib"
@ -801,6 +812,10 @@ static inline int is_float(int t)
#include "arm-gen.c"
#endif
#ifdef TCC_TARGET_C67
#include "c67-gen.c"
#endif
#ifdef CONFIG_TCC_STATIC
#define RTLD_LAZY 0x001
@ -4614,6 +4629,11 @@ int gv(int rc)
}
}
vtop->r = r;
#ifdef TCC_TARGET_C67
/* uses register pairs for doubles */
if ((vtop->type.t & VT_BTYPE) == VT_DOUBLE)
vtop->r2 = r+1;
#endif
}
return r;
}
@ -4964,6 +4984,8 @@ void gen_opl(int op)
#elif defined(TCC_TARGET_ARM)
b = ind;
o(0x1A000000 | encbranch(ind, 0, 1));
#elif defined(TCC_TARGET_C67)
error("not implemented");
#else
#error not supported
#endif
@ -5624,7 +5646,11 @@ static int type_size(CType *type, int *a)
*a = LDOUBLE_ALIGN;
return LDOUBLE_SIZE;
} else if (bt == VT_DOUBLE || bt == VT_LLONG) {
*a = 4; /* XXX: i386 specific */
#ifdef TCC_TARGET_I386
*a = 4;
#else
*a = 8;
#endif
return 8;
} else if (bt == VT_INT || bt == VT_ENUM || bt == VT_FLOAT) {
*a = 4;
@ -8673,7 +8699,6 @@ static void decl(int l)
/* push a dummy symbol to enable local sym storage */
sym_push2(&local_stack, SYM_FIELD, 0, 0);
gfunc_prolog(&type);
loc = 0;
rsym = 0;
#ifdef CONFIG_REG_VARS
macro_ptr = func_str.str;

View File

@ -548,6 +548,14 @@ static void relocate_section(TCCState *s1, Section *s)
fprintf(stderr,"FIXME: handle reloc type %x at %lx [%.8x] to %lx\n",
type,addr,(unsigned int )ptr,val);
break;
#elif defined(TCC_TARGET_C67)
case R_C60_32:
*(int *)ptr += val;
break;
default:
fprintf(stderr,"FIXME: handle reloc type %x at %lx [%.8x] to %lx\n",
type,addr,(unsigned int )ptr,val);
break;
#else
#error unsupported processor
#endif
@ -754,6 +762,8 @@ static void put_got_entry(TCCState *s1,
if (s1->output_type == TCC_OUTPUT_EXE)
offset = plt->data_offset - 16;
}
#elif defined(TCC_TARGET_C67)
error("C67 got not implemented");
#else
#error unsupported CPU
#endif
@ -828,6 +838,25 @@ static void build_got_entries(TCCState *s1)
sym_index);
}
break;
#elif defined(TCC_TARGET_C67)
case R_C60_GOT32:
case R_C60_GOTOFF:
case R_C60_GOTPC:
case R_C60_PLT32:
if (!s1->got)
build_got(s1);
if (type == R_C60_GOT32 || type == R_C60_PLT32) {
sym_index = ELF32_R_SYM(rel->r_info);
sym = &((Elf32_Sym *)symtab_section->data)[sym_index];
/* look at the symbol got offset. If none, then add one */
if (type == R_C60_GOT32)
reloc_type = R_C60_GLOB_DAT;
else
reloc_type = R_C60_JMP_SLOT;
put_got_entry(s1, reloc_type, sym->st_size, sym->st_info,
sym_index);
}
break;
#else
#error unsupported CPU
#endif
@ -1415,6 +1444,8 @@ int tcc_output_file(TCCState *s1, const char *filename)
put32(p + 12, x + get32(p + 12) + s1->plt->data - p);
p += 16;
}
#elif defined(TCC_TARGET_C67)
/* XXX: TODO */
#else
#error unsupported CPU
#endif