changeset 305:db91cc43c90a

[project @ 2004-10-04 21:57:35 by bellard] initial TMS320C67xx support (TK)
author bellard
date Mon, 04 Oct 2004 21:57:35 +0000
parents 173cc6152248
children e0ce0072f659
files Changelog Makefile arm-gen.c elf.h i386-gen.c tcc.c tccelf.c
diffstat 7 files changed, 87 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/Changelog	Sat Oct 02 14:11:28 2004 +0000
+++ b/Changelog	Mon Oct 04 21:57:35 2004 +0000
@@ -2,9 +2,10 @@
 
 - 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:
 
--- a/Makefile	Sat Oct 02 14:11:28 2004 +0000
+++ b/Makefile	Mon Oct 04 21:57:35 2004 +0000
@@ -114,6 +114,9 @@
 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 $@ $<
--- a/arm-gen.c	Sat Oct 02 14:11:28 2004 +0000
+++ b/arm-gen.c	Mon Oct 04 21:57:35 2004 +0000
@@ -710,6 +710,7 @@
     addr += size;
   }
   last_itod_magic=0;
+  loc = 0;
 }
 
 /* generate function epilog */
--- a/elf.h	Sat Oct 02 14:11:28 2004 +0000
+++ b/elf.h	Mon Oct 04 21:57:35 2004 +0000
@@ -217,6 +217,7 @@
    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 @@
 /* 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 */
--- a/i386-gen.c	Sat Oct 02 14:11:28 2004 +0000
+++ b/i386-gen.c	Mon Oct 04 21:57:35 2004 +0000
@@ -427,6 +427,7 @@
         oad(0xb8, 0); /* call to function */
         func_bound_offset = lbounds_section->data_offset;
     }
+    loc = 0;
 }
 
 /* generate function epilog */
--- a/tcc.c	Sat Oct 02 14:11:28 2004 +0000
+++ b/tcc.c	Mon Oct 04 21:57:35 2004 +0000
@@ -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 @@
 #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 @@
             }
         }
         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 @@
 #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 @@
         *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 @@
                 /* 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;
--- a/tccelf.c	Sat Oct 02 14:11:28 2004 +0000
+++ b/tccelf.c	Mon Oct 04 21:57:35 2004 +0000
@@ -548,6 +548,14 @@
 	    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 @@
             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 @@
                                   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 @@
 		        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