Sorted out CMake on x86-64 and fixed silly XMM# bug introduced when working on Win64...
authorJames Lyon <jamesly0n@hotmail.com>
Thu, 25 Apr 2013 21:30:53 +0000 (25 22:30 +0100)
committerJames Lyon <jamesly0n@hotmail.com>
Thu, 25 Apr 2013 21:30:53 +0000 (25 22:30 +0100)
I removed the XMM6/7 registers from the register list because they are not used
on Win64 however they are necessary for parameter passing on x86-64. I have now
restored them but not marked them with RC_FLOAT so they will not be used except
for parameter passing.

CMakeLists.txt
Makefile
config.h.in
lib/libtcc1.c
libtcc.c
tcclib.h [moved from include/tcclib.h with 100% similarity]
tests/CMakeLists.txt
tests/Makefile
tests/tests2/Makefile
x86_64-gen.c

index f50caf4..845a311 100644 (file)
@@ -43,6 +43,15 @@ else()
   set(DOC_PATH share/doc/tcc)
 endif()
 
+if(NOT WIN32)
+  if(EXISTS /usr/lib/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu/crti.o)
+    set(CONFIG_LDDIR lib/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu)
+    set(CONFIG_MULTIARCHDIR ${CMAKE_SYSTEM_PROCESSOR}-linux-gnu)
+  elseif(EXISTS /usr/lib64/crti.o)
+    set(CONFIG_LDDIR lib64)
+  endif()
+endif()
+
 # Use two variables to keep CMake configuration variable names consistent
 set(TCC_BCHECK OFF CACHE BOOL "Enable bounds checking")
 set(CONFIG_TCC_BCHECK ${TCC_BCHECK})
@@ -64,6 +73,12 @@ set(TCC_BUILD_C67 OFF CACHE BOOL "Build C67 cross compiler")
 set(TCC_ARM_VERSION ${TCC_ARM_VERSION_DEFAULT} CACHE STRING "ARM target CPU version")
 set_property(CACHE TCC_ARM_VERSION PROPERTY STRINGS 4 5 6 7)
 
+if(WIN32)
+  set(CONFIG_TCCDIR ${CMAKE_INSTALL_PREFIX})
+else()
+  set(CONFIG_TCCDIR ${CMAKE_INSTALL_PREFIX}/lib/tcc)
+endif()
+
 file(STRINGS "VERSION" TCC_VERSION)
 list(GET TCC_VERSION 0 TCC_VERSION)
 include_directories(${CMAKE_BINARY_DIR})
@@ -123,8 +138,16 @@ endmacro()
 
 macro(make_tcc native_name cross_name cross_enabled definitions tcc_sources libtcc_ar libtcc_sources libtcc_includes)
   if (xx${native_name} STREQUAL xx${TCC_NATIVE_TARGET})
+    set(TCC_NATIVE_DEFINITIONS ${definitions})
+    if("${CONFIG_MULTIARCHDIR}" STRGREATER "")
+      set(TCC_NATIVE_DEFINITIONS ${TCC_NATIVE_DEFINITIONS} CONFIG_MULTIARCHDIR="${CONFIG_MULTIARCHDIR}")
+    endif()
+    if("${CONFIG_LDDIR}" STRGREATER "")
+      set(TCC_NATIVE_DEFINITIONS ${TCC_NATIVE_DEFINITIONS} CONFIG_LDDIR="${CONFIG_LDDIR}")
+    endif()
+
     set(TCC_NATIVE_FLAGS)
-    foreach(make_tcc_def ${definitions})
+    foreach(make_tcc_def ${TCC_NATIVE_DEFINITIONS})
       set(TCC_NATIVE_FLAGS ${TCC_NATIVE_FLAGS} -D${make_tcc_def})
     endforeach()
     
@@ -144,16 +167,17 @@ macro(make_tcc native_name cross_name cross_enabled definitions tcc_sources libt
       set_target_properties(libtcc PROPERTIES OUTPUT_NAME tcc PREFIX lib LINK_FLAGS "-Wl,--output-def,libtcc.def")
       add_executable(tcc tcc.c)
       target_link_libraries(tcc libtcc)
-      install(TARGETS tcc libtcc RUNTIME DESTINATION ${EXE_PATH} LIBRARY DESTINATION ${NATIVE_LIB_PATH})
-      set_target_properties(tcc libtcc PROPERTIES COMPILE_DEFINITIONS "${definitions}")
+      if(NOT WIN32)
+        target_link_libraries(tcc dl)
+      endif()
+      install(TARGETS tcc libtcc RUNTIME DESTINATION ${EXE_PATH} LIBRARY DESTINATION ${NATIVE_LIB_PATH} ARCHIVE DESTINATION ${NATIVE_LIB_PATH})
+      set_target_properties(tcc libtcc PROPERTIES COMPILE_DEFINITIONS "${TCC_NATIVE_DEFINITIONS}")
       
       if("${libtcc_sources}" STRGREATER "")
-        make_libtcc1("" tcc "${libtcc_ar}" "${definitions}" "${libtcc_includes}" "${libtcc_sources}")
+        make_libtcc1("" tcc "${libtcc_ar}" "${TCC_NATIVE_DEFINITIONS}" "${libtcc_includes}" "${libtcc_sources}")
       endif()
     endif()
-  endif()
-  
-  if(${cross_enabled})
+  elseif(${cross_enabled})
     add_executable(${cross_name}-tcc tcc.c)
     set_target_properties(${cross_name}-tcc PROPERTIES COMPILE_DEFINITIONS "ONE_SOURCE;${definitions}")
     install(TARGETS ${cross_name}-tcc RUNTIME DESTINATION ${EXE_PATH})
@@ -250,6 +274,7 @@ endif()
 if(WIN32)
   file(GLOB WIN32_DEFS win32/lib/*.def)
   install(FILES ${WIN32_DEFS} DESTINATION lib)
+  install(FILES tcclib.h DESTINATION include)
   install(DIRECTORY include/ DESTINATION include)
   install(DIRECTORY win32/include/ DESTINATION include)
   install(DIRECTORY win32/examples/ DESTINATION examples)
@@ -258,7 +283,7 @@ if(WIN32)
   install(FILES ${CMAKE_BINARY_DIR}/libtcc.dll.a DESTINATION libtcc RENAME libtcc.a)
   install(FILES libtcc.h DESTINATION libtcc)
 else()
-  install(FILES libtcc.h DESTINATION include)
+  install(FILES libtcc.h tcclib.h DESTINATION include)
   install(DIRECTORY include/ DESTINATION lib/tcc/include)
   install(DIRECTORY win32/include/ DESTINATION lib/tcc/win32/include)
   install(DIRECTORY include/ DESTINATION lib/tcc/win32/include)
index f487fbf..9b9d787 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -221,7 +221,7 @@ lib/%/libtcc1.a : FORCE $(PROGS_CROSS)
 FORCE:
 
 # install
-TCC_INCLUDES = stdarg.h stddef.h stdbool.h float.h varargs.h tcclib.h
+TCC_INCLUDES = stdarg.h stddef.h stdbool.h float.h varargs.h
 INSTALL=install
 ifdef STRIP_BINARIES
 INSTALLBIN=$(INSTALL) -s
@@ -246,7 +246,7 @@ endif
 ifneq ($(LIBTCC1),)
        $(INSTALL) -m644 $(LIBTCC1) "$(tccdir)"
 endif
-       $(INSTALL) -m644 $(addprefix $(top_srcdir)/include/,$(TCC_INCLUDES)) "$(tccdir)/include"
+       $(INSTALL) -m644 $(addprefix $(top_srcdir)/include/,$(TCC_INCLUDES)) $(top_srcdir)/tcclib.h "$(tccdir)/include"
        mkdir -p "$(libdir)"
        $(INSTALL) -m755 $(LIBTCC) "$(libdir)"
 ifdef DISABLE_STATIC
@@ -265,17 +265,18 @@ ifeq ($(ARCH),x86-64)
        $(INSTALL) -m644 lib/i386/libtcc1.a "$(tccdir)/i386"
        cp -r "$(tccdir)/include" "$(tccdir)/i386"
 endif
-       $(INSTALL) -m644 win32/lib/*.def "$(tccdir)/win32/lib"
+       $(INSTALL) -m644 $(top_srcdir)/win32/lib/*.def "$(tccdir)/win32/lib"
        $(INSTALL) -m644 lib/i386-win32/libtcc1.a "$(tccdir)/win32/lib/32"
        $(INSTALL) -m644 lib/x86_64-win32/libtcc1.a "$(tccdir)/win32/lib/64"
-       cp -r win32/include/. "$(tccdir)/win32/include"
-       cp -r include/. "$(tccdir)/win32/include"
+       cp -r $(top_srcdir)/win32/include/. "$(tccdir)/win32/include"
+       cp -r $(top_srcdir)/include/. "$(tccdir)/win32/include"
 endif
 
 uninstall:
        rm -fv $(foreach P,$(PROGS),"$(bindir)/$P")
        rm -fv $(foreach P,$(LIBTCC1),"$(tccdir)/$P")
        rm -fv $(foreach P,$(TCC_INCLUDES),"$(tccdir)/include/$P")
+       rm -fv "$(tccdir)/include/tcclib.h"
        rm -fv "$(docdir)/tcc-doc.html" "$(mandir)/man1/tcc.1" "$(infodir)/tcc-doc.info"
        rm -fv "$(libdir)/$(LIBTCC)" "$(includedir)/libtcc.h"
        rm -fv "$(libdir)/libtcc.so*"
@@ -297,7 +298,7 @@ install: $(PROGS) $(TCCLIBS) $(TCCDOCS)
        $(INSTALL) -m644 $(LIBTCC1) $(top_srcdir)/win32/lib/*.def "$(tccdir)/lib"
        cp -r $(top_srcdir)/win32/include/. "$(tccdir)/include"
        cp -r $(top_srcdir)/win32/examples/. "$(tccdir)/examples"
-       $(INSTALL) -m644 $(addprefix $(top_srcdir)/include/,$(TCC_INCLUDES)) "$(tccdir)/include"
+       $(INSTALL) -m644 $(addprefix $(top_srcdir)/include/,$(TCC_INCLUDES)) $(top_srcdir)/tcclib.h "$(tccdir)/include"
        $(INSTALL) -m644 tcc-doc.html $(top_srcdir)/win32/tcc-win32.txt "$(tccdir)/doc"
        $(INSTALL) -m644 $(top_srcdir)/libtcc.h $(LIBTCC_EXTRA) "$(tccdir)/libtcc"
        $(INSTALL) -m644 $(LIBTCC) $(tccdir)
index 79640fd..16393e9 100644 (file)
@@ -1,4 +1,4 @@
-#define CONFIG_TCCDIR "${CMAKE_INSTALL_PREFIX}"
+#define CONFIG_TCCDIR "${CONFIG_TCCDIR}"
 #define TCC_VERSION "${TCC_VERSION}"
 
 #cmakedefine CONFIG_WIN32
index 1f246be..159c401 100644 (file)
@@ -607,9 +607,16 @@ unsigned long long __fixunsxfdi (long double a1)
 
 #if defined(__x86_64__) && !defined(_WIN64)
 
+#ifndef __TINYC__
+#include <stdlib.h>
+#include <stdio.h>
+#else
 /* Avoid including stdlib.h because it is not easily available when
    cross compiling */
 extern void *malloc(unsigned long long);
+extern void free(void*);
+extern void abort(void);
+#endif
 
 enum __va_arg_type {
     __va_gen_reg, __va_float_reg, __va_stack
index bf88cc9..f691218 100644 (file)
--- a/libtcc.c
+++ b/libtcc.c
@@ -1052,11 +1052,13 @@ LIBTCCAPI void tcc_delete(TCCState *s1)
     dynarray_reset(&s1->priv_sections, &s1->nb_priv_sections);
         
     /* free any loaded DLLs */
+#ifdef TCC_IS_NATIVE
     for ( i = 0; i < s1->nb_loaded_dlls; i++) {
         DLLReference *ref = s1->loaded_dlls[i];
         if ( ref->handle )
             dlclose(ref->handle);
     }
+#endif
     
     /* free loaded dlls array */
     dynarray_reset(&s1->loaded_dlls, &s1->nb_loaded_dlls);
similarity index 100%
rename from include/tcclib.h
rename to tcclib.h
index 4c11c8d..07c9897 100644 (file)
@@ -1,17 +1,22 @@
-include_directories(${CMAKE_SOURCE_DIR})
+include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
 
-set(TCC_CFLAGS -I${CMAKE_SOURCE_DIR})
+set(TCC_CFLAGS -I${CMAKE_SOURCE_DIR} -I${CMAKE_SOURCE_DIR}/include -B${CMAKE_BINARY_DIR})
 if(WIN32)
-  set(TCC_CFLAGS ${TCC_CFLAGS} -I${CMAKE_SOURCE_DIR}/include -I${CMAKE_SOURCE_DIR}/win32/include)
+  set(TCC_CFLAGS ${TCC_CFLAGS} -I${CMAKE_SOURCE_DIR}/win32/include)
+else()
+  set(TCC_MATH_LDFLAGS -lm)
+  set(LIBTCC_LDFLAGS -ldl -lm)
 endif()
 
 add_executable(abitest-cc abitest.c)
-target_link_libraries(abitest-cc libtcc)
+if(NOT WIN32)
+  target_link_libraries(abitest-cc libtcc dl)
+endif()
 add_test(NAME abitest-cc WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND abitest-cc lib_path=${CMAKE_BINARY_DIR} include=${CMAKE_SOURCE_DIR}/include)
 
 set(ABITEST_TCC abitest-tcc${CMAKE_EXECUTABLE_SUFFIX})
 get_property(LIBTCC_LIB TARGET libtcc PROPERTY LOCATION)
-add_custom_command(OUTPUT ${ABITEST_TCC} COMMAND tcc ${TCC_CFLAGS} -g -I${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/abitest.c ${LIBTCC_LIB} -o ${ABITEST_TCC} DEPENDS abitest.c)
+add_custom_command(OUTPUT ${ABITEST_TCC} COMMAND tcc ${TCC_CFLAGS} -g ${CMAKE_CURRENT_SOURCE_DIR}/abitest.c ${LIBTCC_LDFLAGS} ${LIBTCC_LIB} -o ${ABITEST_TCC} DEPENDS tcc abitest.c)
 add_custom_target(abitest-tcc-exe ALL DEPENDS ${ABITEST_TCC})
 
 add_test(NAME abitest-tcc WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${ABITEST_TCC} lib_path=${CMAKE_BINARY_DIR} include=${CMAKE_SOURCE_DIR}/include)
@@ -19,9 +24,6 @@ add_test(NAME abitest-tcc WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND ${CMAKE_
 add_executable(tcctest-cc tcctest.c)
 target_link_libraries(tcctest-cc libtcc)
 set_target_properties(tcctest-cc PROPERTIES COMPILE_FLAGS -std=gnu99)
-if(WIN32)
-  set_target_properties(tcctest-cc PROPERTIES INCLUDE_DIRECTORIES "${CMAKE_BINARY_DIR};${CMAKE_SOURCE_DIR}/include")
-endif()
 
 find_package(PythonInterp)
 if(PYTHONINTERP_FOUND)
@@ -29,14 +31,43 @@ if(PYTHONINTERP_FOUND)
   if(WIN32)
     set(TCC_TEST_CFLAGS ${TCC_TEST_CFLAGS} -I${CMAKE_SOURCE_DIR}/win32/include/winapi)
   endif()
-  set(TCC_TEST_SOURCE ${TCC_TEST_CFLAGS} -run ${CMAKE_CURRENT_SOURCE_DIR}/tcctest.c)
+  set(TCC_TEST_SOURCE ${TCC_TEST_CFLAGS} ${TCC_MATH_LDFLAGS} -run ${CMAKE_CURRENT_SOURCE_DIR}/tcctest.c)
   set(TCC_TEST_RUN ${TCC_TEST_CFLAGS} ${TCC_NATIVE_FLAGS} -DONE_SOURCE -run ${CMAKE_SOURCE_DIR}/tcc.c)
   get_property(TCC TARGET tcc PROPERTY LOCATION)
   get_property(TCCTESTCC TARGET tcctest-cc PROPERTY LOCATION)
-  set(TCCTEST_PY ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tcctest.py ${TCCTESTCC} ${TCC})
-  add_test(test1 ${TCCTEST_PY} ${TCC_TEST_SOURCE})
-  add_test(test2 ${TCCTEST_PY} ${TCC_TEST_RUN} ${TCC_TEST_SOURCE})
-  add_test(test3 ${TCCTEST_PY} ${TCC_TEST_RUN} ${TCC_TEST_RUN} ${TCC_TEST_SOURCE})
+  set(TCCTEST_PY ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tcctest.py ${TCCTESTCC})
+  add_test(test1 ${TCCTEST_PY} ${TCC} ${TCC_TEST_SOURCE})
+  add_test(test2 ${TCCTEST_PY} ${TCC} ${TCC_TEST_RUN} ${TCC_TEST_SOURCE})
+  add_test(test3 ${TCCTEST_PY} ${TCC} ${TCC_TEST_RUN} ${TCC_TEST_RUN} ${TCC_TEST_SOURCE})
+
+  # Object + link output
+  set(TEST4 test4${CMAKE_EXECUTABLE_SUFFIX})
+  add_custom_command(OUTPUT test4.o COMMAND tcc ${TCC_TEST_CFLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/tcctest.c -c -o test4.o DEPENDS tcc tcctest.c)
+  add_custom_command(OUTPUT ${TEST4} COMMAND tcc ${TCC_TEST_CFLAGS} test4.o -o ${TEST4} DEPENDS tcc test4.o)
+  add_custom_target(test4-exe ALL DEPENDS ${TEST4})
+  add_test(test4 ${TCCTEST_PY} ${CMAKE_CURRENT_BINARY_DIR}/${TEST4})
+
+  # Dynamic output
+  set(TEST5 test5${CMAKE_EXECUTABLE_SUFFIX})
+  add_custom_command(OUTPUT ${TEST5} COMMAND tcc ${TCC_TEST_CFLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/tcctest.c -o ${TEST5} DEPENDS tcc tcctest.c)
+  add_custom_target(test5-exe ALL DEPENDS ${TEST5})
+  add_test(test5 ${TCCTEST_PY} ${CMAKE_CURRENT_BINARY_DIR}/${TEST5})
+
+  if(TCC_BCHECK)
+    # Dynamic output + bound check
+    set(TEST6 test6${CMAKE_EXECUTABLE_SUFFIX})
+    add_custom_command(OUTPUT ${TEST5} COMMAND tcc ${TCC_TEST_CFLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/tcctest.c -b -o ${TEST6} DEPENDS tcc tcctest.c)
+    add_custom_target(test6-exe ALL DEPENDS ${TEST6})
+    add_test(test6 ${TCCTEST_PY} ${CMAKE_CURRENT_BINARY_DIR}/${TEST6})
+  endif()
+
+  if(NOT WIN32 AND NOT TCC_NATIVE_TARGET STREQUAL "x86_64")
+    # Static output
+    set(TEST7 test7${CMAKE_EXECUTABLE_SUFFIX})
+    add_custom_command(OUTPUT ${TEST7} COMMAND tcc ${TCC_TEST_CFLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/tcctest.c -static -o ${TEST7} DEPENDS tcc tcctest.c)
+    add_custom_target(test7-exe ALL DEPENDS ${TEST7})
+    add_test(test7 ${TCCTEST_PY} ${CMAKE_CURRENT_BINARY_DIR}/${TEST7})
+  endif()
 endif()
 
 set(MORETESTS
@@ -99,5 +130,5 @@ if(WIN32)
 endif()
 foreach(testfile ${MORETESTS})
   add_test(NAME ${testfile} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests2
-           COMMAND tcc ${TCC_CFLAGS} -run ${testfile}.c - arg1 arg2 arg3 arg4 | ${DIFF} - ${testfile}.expect)
+           COMMAND tcc ${TCC_CFLAGS} ${TCC_MATH_LDFLAGS} -run ${testfile}.c - arg1 arg2 arg3 arg4 | ${DIFF} - ${testfile}.expect)
 endforeach()
index 9c8a433..edb581c 100644 (file)
@@ -43,9 +43,9 @@ ifeq ($(TARGETOS),Darwin)
 endif
 
 # run local version of tcc with local libraries and includes
-TCCFLAGS = -B$(TOP) -I$(TOP)
+TCCFLAGS = -B$(TOP) -I$(TOP) -I$(top_srcdir) -I$(top_srcdir)/include
 ifdef CONFIG_WIN32
- TCCFLAGS = -B$(top_srcdir)/win32 -I$(top_srcdir)/include -I$(TOP) -L$(TOP)
+ TCCFLAGS = -B$(top_srcdir)/win32 -I$(top_srcdir) -I$(top_srcdir)/include -I$(TOP) -L$(TOP)
 endif
 
 TCC = $(TOP)/tcc $(TCCFLAGS)
@@ -82,8 +82,7 @@ moretests:
 # test.ref - generate using gcc
 # copy only tcclib.h so GCC's stddef and stdarg will be used
 test.ref: tcctest.c
-       cp $(top_srcdir)/include/tcclib.h .
-       gcc -o tcctest.gcc $< -I. $(CPPFLAGS) -w $(CFLAGS) $(NATIVE_DEFINES) -std=gnu99 -O0 -fno-omit-frame-pointer $(LDFLAGS)
+       gcc -o tcctest.gcc $< -I$(top_srcdir) $(CPPFLAGS) -w $(CFLAGS) $(NATIVE_DEFINES) -std=gnu99 -O0 -fno-omit-frame-pointer $(LDFLAGS)
        ./tcctest.gcc > $@
 
 # auto test
index 9c2e70f..369ed47 100644 (file)
@@ -2,7 +2,7 @@ TOP = ../..
 include $(TOP)/Makefile
 VPATH = $(top_srcdir)/tests/tests2
 
-TCCFLAGS = -B$(TOP)
+TCCFLAGS = -B$(TOP) -I$(top_srcdir)/include
 ifdef CONFIG_WIN32
  TCCFLAGS = -B$(top_srcdir)/win32 -I$(top_srcdir)/include -L$(TOP)
 endif
index 1cf3bbc..3e892e3 100644 (file)
@@ -23,7 +23,7 @@
 #ifdef TARGET_DEFS_ONLY
 
 /* number of available registers */
-#define NB_REGS         22
+#define NB_REGS         24
 #define NB_ASM_REGS     8
 
 /* a register can belong to several classes. The classes must be
@@ -45,6 +45,8 @@
 #define RC_XMM3    0x8000
 #define RC_XMM4    0x10000
 #define RC_XMM5    0x20000
+#define RC_XMM6    0x40000
+#define RC_XMM7    0x80000
 #define RC_IRET    RC_RAX /* function return: integer register */
 #define RC_LRET    RC_RDX /* function return: second integer register */
 #define RC_FRET    RC_XMM0 /* function return: float register */
@@ -140,7 +142,12 @@ ST_DATA const int reg_classes[NB_REGS] = {
     /* xmm2 */ RC_FLOAT | RC_XMM2,
     /* xmm3 */ RC_FLOAT | RC_XMM3,
     /* xmm4 */ RC_FLOAT | RC_XMM4,
-    /* xmm5 */ RC_FLOAT | RC_XMM5 /* only up to xmm5: xmm6-15 must be callee saved on Win64 */
+    /* xmm5 */ RC_FLOAT | RC_XMM5,
+    /* xmm6 an xmm7 are included so gv() can be used on them,
+       but they are not tagged with RC_FLOAT because they are
+       callee saved on Windows */
+    RC_XMM6,
+    RC_XMM7 
 };
 
 static unsigned long func_sub_sp_offset;
@@ -499,7 +506,7 @@ void load(int r, SValue *sv)
                     o(0xc0 + REG_VALUE(v) + REG_VALUE(r)*8);
                 }
             } else if (r == TREG_ST0) {
-                assert((v == TREG_XMM0) || (v == TREG_XMM1));
+                assert((v >= TREG_XMM0) || (v <= TREG_XMM7));
                 /* gen_cvt_ftof(VT_LDOUBLE); */
                 /* movsd %xmmN,-0x10(%rsp) */
                 o(0x110ff2);
@@ -1173,7 +1180,7 @@ void gfunc_call(int nb_args)
                 --sse_reg;
                 r = gv(RC_FLOAT);
                 o(0x50); /* push $rax */
-                /* movq %xmm0, (%rsp) */
+                /* movq %xmmN, (%rsp) */
                 o(0xd60f66);
                 o(0x04 + REG_VALUE(r)*8);
                 o(0x24);