aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--arm-gen.c32
-rw-r--r--c67-gen.c12
-rw-r--r--lib/Makefile3
-rw-r--r--libtcc.c11
-rw-r--r--tcc-doc.texi2
-rw-r--r--tcc.h53
-rw-r--r--tccelf.c14
-rw-r--r--tccgen.c18
-rw-r--r--win32/tcc-win32.txt55
-rw-r--r--x86_64-gen.c5
11 files changed, 100 insertions, 109 deletions
diff --git a/Makefile b/Makefile
index 23045eb..f81f97d 100644
--- a/Makefile
+++ b/Makefile
@@ -215,9 +215,9 @@ tiny_libmaker$(EXESUF): win32/tools/tiny_libmaker.c
# TinyCC runtime libraries
libtcc1.a : FORCE
- @$(MAKE) -C lib native
+ $(MAKE) -C lib native
lib/%/libtcc1.a : FORCE $(PROGS_CROSS)
- @$(MAKE) -C lib cross TARGET=$*
+ $(MAKE) -C lib cross TARGET=$*
FORCE:
diff --git a/arm-gen.c b/arm-gen.c
index 8dc6691..6981395 100644
--- a/arm-gen.c
+++ b/arm-gen.c
@@ -106,15 +106,6 @@ enum {
are directly pushed on stack. */
//#define FUNC_STRUCT_PARAM_AS_PTR
-#if defined(TCC_ARM_EABI) && defined(TCC_ARM_VFP)
-ST_DATA CType float_type, double_type, func_float_type, func_double_type;
-#define func_ldouble_type func_double_type
-#else
-#define func_float_type func_old_type
-#define func_double_type func_old_type
-#define func_ldouble_type func_old_type
-#endif
-
/* pointer size, in bytes */
#define PTR_SIZE 4
@@ -175,14 +166,27 @@ ST_DATA const int reg_classes[NB_REGS] = {
#endif
};
-/* keep in sync with line 104 above */
-#if defined(TCC_ARM_EABI) && defined(TCC_ARM_VFP)
-ST_DATA CType float_type, double_type, func_float_type, func_double_type;
-#endif
-
static int func_sub_sp_offset, last_itod_magic;
static int leaffunc;
+#if defined(TCC_ARM_EABI) && defined(TCC_ARM_VFP)
+static CType float_type, double_type, func_float_type, func_double_type;
+ST_FUNC void arm_init_types(void)
+{
+ float_type.t = VT_FLOAT;
+ double_type.t = VT_DOUBLE;
+ func_float_type.t = VT_FUNC;
+ func_float_type.ref = sym_push(SYM_FIELD, &float_type, FUNC_CDECL, FUNC_OLD);
+ func_double_type.t = VT_FUNC;
+ func_double_type.ref = sym_push(SYM_FIELD, &double_type, FUNC_CDECL, FUNC_OLD);
+}
+#else
+#define func_float_type func_old_type
+#define func_double_type func_old_type
+#define func_ldouble_type func_old_type
+ST_FUNC void arm_init_types(void) {}
+#endif
+
static int two2mask(int a,int b) {
return (reg_classes[a]|reg_classes[b])&~(RC_INT|RC_FLOAT);
}
diff --git a/c67-gen.c b/c67-gen.c
index b79b1bb..b423ba6 100644
--- a/c67-gen.c
+++ b/c67-gen.c
@@ -92,12 +92,6 @@ enum {
#define REG_LRET TREG_C67_A5 /* second word return register (for long long) */
#define REG_FRET TREG_C67_A4 /* float return register */
-#define ALWAYS_ASSERT(x) \
-do {\
- if (!(x))\
- tcc_error("internal compiler error file at %s:%d", __FILE__, __LINE__);\
-} while (0)
-
/* defined if function parameters must be evaluated in reverse order */
//#define INVERT_FUNC_PARAMS
@@ -182,6 +176,12 @@ int TotalBytesPushedOnStack;
#undef BOOL
#define BOOL int
+#define ALWAYS_ASSERT(x) \
+do {\
+ if (!(x))\
+ tcc_error("internal compiler error file at %s:%d", __FILE__, __LINE__);\
+} while (0)
+
/******************************************************/
static unsigned long func_sub_sp_offset;
static int func_ret_sub;
diff --git a/lib/Makefile b/lib/Makefile
index 9a029d2..945a94b 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -28,6 +28,7 @@ ifndef TARGET
endif
endif
endif
+ BCHECK_O = bcheck.o
endif
DIR = $(TARGET)
@@ -38,8 +39,6 @@ cross : $(DIR)/libtcc1.a
native : TCC = $(TOP)/tcc$(EXESUF)
cross : TCC = $(TOP)/$(TARGET)-tcc$(EXESUF)
-BCHECK_O = bcheck.o
-
I386_O = libtcc1.o alloca86.o alloca86-bt.o $(BCHECK_O)
X86_64_O = libtcc1.o alloca86_64.o
WIN32_O = $(I386_O) crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
diff --git a/libtcc.c b/libtcc.c
index 0242dc4..b0b2410 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -755,15 +755,8 @@ static int tcc_compile(TCCState *s1)
func_old_type.t = VT_FUNC;
func_old_type.ref = sym_push(SYM_FIELD, &int_type, FUNC_CDECL, FUNC_OLD);
-
-#if defined(TCC_ARM_EABI) && defined(TCC_ARM_VFP)
- float_type.t = VT_FLOAT;
- double_type.t = VT_DOUBLE;
-
- func_float_type.t = VT_FUNC;
- func_float_type.ref = sym_push(SYM_FIELD, &float_type, FUNC_CDECL, FUNC_OLD);
- func_double_type.t = VT_FUNC;
- func_double_type.ref = sym_push(SYM_FIELD, &double_type, FUNC_CDECL, FUNC_OLD);
+#ifdef TCC_TARGET_ARM
+ arm_init_types();
#endif
#if 0
diff --git a/tcc-doc.texi b/tcc-doc.texi
index 4d4a029..105c007 100644
--- a/tcc-doc.texi
+++ b/tcc-doc.texi
@@ -68,7 +68,7 @@ ports for the ARM (@code{arm-tcc}) and the TMS320C67xx targets
(@code{c67-tcc}). More information about the ARM port is available at
@url{http://lists.gnu.org/archive/html/tinycc-devel/2003-10/msg00044.html}.
-For usage on Windows, see also tcc-win32.txt.
+For usage on Windows, see also @url{tcc-win32.txt}.
@node Invoke
@chapter Command line invocation
diff --git a/tcc.h b/tcc.h
index 885951c..c5c7c41 100644
--- a/tcc.h
+++ b/tcc.h
@@ -113,9 +113,8 @@
//#define PP_DEBUG
/* include file debug */
//#define INC_DEBUG
-
+/* memory leak debug */
//#define MEM_DEBUG
-
/* assembler debug */
//#define ASM_DEBUG
@@ -236,6 +235,25 @@
#define TCC_LIBGCC CONFIG_SYSROOT "/" CONFIG_LDDIR "/libgcc_s.so.1"
/* -------------------------------------------- */
+/* include the target specific definitions */
+
+#define TARGET_DEFS_ONLY
+#ifdef TCC_TARGET_I386
+# include "i386-gen.c"
+#endif
+#ifdef TCC_TARGET_X86_64
+# include "x86_64-gen.c"
+#endif
+#ifdef TCC_TARGET_ARM
+# include "arm-gen.c"
+#endif
+#ifdef TCC_TARGET_C67
+# include "coff.h"
+# include "c67-gen.c"
+#endif
+#undef TARGET_DEFS_ONLY
+
+/* -------------------------------------------- */
#define INCLUDE_STACK_SIZE 32
#define IFDEF_STACK_SIZE 64
@@ -290,7 +308,7 @@ typedef union CValue {
unsigned long long ull;
struct CString *cstr;
void *ptr;
- int tab[2];
+ int tab[LDOUBLE_SIZE/4];
} CValue;
/* value on stack */
@@ -1240,6 +1258,12 @@ ST_FUNC int handle_eob(void);
/* ------------ xxx-gen.c ------------ */
+ST_DATA const int reg_classes[NB_REGS
+#ifdef TCC_TARGET_X86_64
+ + 7
+#endif
+];
+
ST_FUNC void gsym_addr(int t, int a);
ST_FUNC void gsym(int t);
ST_FUNC void load(int r, SValue *sv);
@@ -1280,10 +1304,12 @@ ST_FUNC void gen_bounded_ptr_deref(void);
/* ------------ x86_64-gen.c ------------ */
#ifdef TCC_TARGET_X86_64
ST_FUNC void gen_addr64(int r, Sym *sym, int64_t c);
+ST_FUNC void gen_opl(int op);
#endif
/* ------------ arm-gen.c ------------ */
#ifdef TCC_TARGET_ARM
+ST_FUNC void arm_init_types(void);
ST_FUNC uint32_t encbranch(int pos, int addr, int fail);
ST_FUNC void gen_cvt_itof1(int t);
#endif
@@ -1354,27 +1380,6 @@ PUB_FUNC void tcc_set_num_callers(int n);
#endif
/********************************************************/
-/* include the target specific definitions */
-
-#define TARGET_DEFS_ONLY
-#ifdef TCC_TARGET_I386
-#include "i386-gen.c"
-#endif
-#ifdef TCC_TARGET_X86_64
-#include "x86_64-gen.c"
-#endif
-#ifdef TCC_TARGET_ARM
-#include "arm-gen.c"
-#endif
-#ifdef TCC_TARGET_C67
-#include "coff.h"
-#include "c67-gen.c"
-#endif
-#undef TARGET_DEFS_ONLY
-
-ST_DATA const int reg_classes[];
-
-/********************************************************/
#undef ST_DATA
#ifdef ONE_SOURCE
#define ST_DATA static
diff --git a/tccelf.c b/tccelf.c
index 781c322..41bd1a5 100644
--- a/tccelf.c
+++ b/tccelf.c
@@ -1314,13 +1314,6 @@ static void add_init_array_defines(TCCState *s1, const char *section_name)
s->sh_num, sym_end);
}
-static int tcc_add_support(TCCState *s1, const char *filename)
-{
- char buf[1024];
- snprintf(buf, sizeof(buf), "%s/%s", s1->tcc_lib_path, filename);
- return tcc_add_file(s1, buf);
-}
-
ST_FUNC void tcc_add_bcheck(TCCState *s1)
{
#ifdef CONFIG_TCC_BCHECK
@@ -1353,6 +1346,13 @@ ST_FUNC void tcc_add_bcheck(TCCState *s1)
#endif
}
+static inline int tcc_add_support(TCCState *s1, const char *filename)
+{
+ char buf[1024];
+ snprintf(buf, sizeof(buf), "%s/%s", s1->tcc_lib_path, filename);
+ return tcc_add_file(s1, buf);
+}
+
/* add tcc runtime libraries */
ST_FUNC void tcc_add_runtime(TCCState *s1)
{
diff --git a/tccgen.c b/tccgen.c
index 9602d66..0a6250c 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -344,27 +344,23 @@ static void vpushs(long long v)
vsetc(&size_type, VT_CONST, &cval);
}
-/* push long long constant */
-static void vpushll(long long v)
-{
- CValue cval;
- CType ctype;
- ctype.t = VT_LLONG;
- ctype.ref = 0;
- cval.ull = v;
- vsetc(&ctype, VT_CONST, &cval);
-}
-
/* push arbitrary 64bit constant */
void vpush64(int ty, unsigned long long v)
{
CValue cval;
CType ctype;
ctype.t = ty;
+ ctype.ref = NULL;
cval.ull = v;
vsetc(&ctype, VT_CONST, &cval);
}
+/* push long long constant */
+static inline void vpushll(long long v)
+{
+ vpush64(VT_LLONG, v);
+}
+
/* Return a static symbol pointing to a section */
ST_FUNC Sym *get_sym_ref(CType *type, Section *sec, unsigned long offset, unsigned long size)
{
diff --git a/win32/tcc-win32.txt b/win32/tcc-win32.txt
index 891ac63..12f6ae7 100644
--- a/win32/tcc-win32.txt
+++ b/win32/tcc-win32.txt
@@ -7,35 +7,12 @@
- Compilation from source:
- ------------------------
- * You can use the MinGW and MSYS tools available at
-
- http://www.mingw.org
-
- Untar the TCC archive and type in the MSYS shell:
-
- ./configure
- make
- make install
-
- The default install location is c:\Program Files\tcc
-
-
- * Alternatively you can compile TCC with just GCC from MinGW using
-
- win32\build-tcc.bat
-
- To install, copy the entire contents of the win32 directory to
- where you want.
-
-
-
Installation from the binary ZIP package:
-----------------------------------------
Unzip the package to a directory of your choice.
+
Set the system PATH:
--------------------
To be able to invoke the compiler from everywhere on your computer by
@@ -114,6 +91,30 @@
+ Compilation from source:
+ ------------------------
+ * You can use the MinGW and MSYS tools available at
+
+ http://www.mingw.org
+
+ Untar the TCC archive and type in the MSYS shell:
+
+ ./configure
+ make
+ make install
+
+ The default install location is c:\Program Files\tcc
+
+
+ * Alternatively you can compile TCC with just GCC from MinGW using
+
+ win32\build-tcc.bat
+
+ To install, copy the entire contents of the win32 directory to
+ where you want.
+
+
+
Limitations:
------------
- On the object file level, currently TCC supports only the ELF format,
@@ -124,11 +125,7 @@
- No leading underscore is generated in the ELF symbols.
- - With DLLs, only functions (not data) can be im-/exported.
-
- - Bounds checking (option -b) is not supported currently.
-
- - 64-bit systems are not (yet) supported.
+ - Bounds checking (option -b) is not supported on 64-bit OS.
diff --git a/x86_64-gen.c b/x86_64-gen.c
index 1fa8dd5..f85cd01 100644
--- a/x86_64-gen.c
+++ b/x86_64-gen.c
@@ -83,9 +83,6 @@ enum {
/* maximum alignment (for aligned attribute support) */
#define MAX_ALIGN 8
-ST_FUNC void gen_opl(int op);
-ST_FUNC void gen_le64(int64_t c);
-
/******************************************************/
/* ELF defines */
@@ -106,7 +103,7 @@ ST_FUNC void gen_le64(int64_t c);
#include "tcc.h"
#include <assert.h>
-ST_DATA const int reg_classes[] = {
+ST_DATA const int reg_classes[NB_REGS+7] = {
/* eax */ RC_INT | RC_RAX,
/* ecx */ RC_INT | RC_RCX,
/* edx */ RC_INT | RC_RDX,