[llvm-commits] Patch to review: cmake support for build of ct-compiler tests
Vane, Edwin
edwin.vane at intel.com
Fri Jun 29 16:12:42 PDT 2012
Please review my initial work for supporting the build of ct-compiler unit tests including some warning removals in the unit tests themselves.
===================================================================
Initial support to build compiler-rt unit tests with cmake
Until this point, compiler-rt unit tests didn't build with cmake. To build
these tests one must un-comment the line in CMakeLists.txt which causes cmake
to descend into the 'test' directory. Tests build for i386 and x86_64.
TODO: Targets to run unit tests.
TODO: Timing tests
===================================================================
Index: test/Unit/absvti2_test.c
===================================================================
--- test/Unit/absvti2_test.c (revision 159279)
+++ test/Unit/absvti2_test.c (working copy)
@@ -11,10 +11,11 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if __x86_64
#include "int_lib.h"
-#include <stdio.h>
#include <stdlib.h>
// Returns: absolute value
Index: test/Unit/divtc3_test.c
===================================================================
--- test/Unit/divtc3_test.c (revision 159279)
+++ test/Unit/divtc3_test.c (working copy)
@@ -11,12 +11,13 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if _ARCH_PPC
#include "int_lib.h"
#include <math.h>
#include <complex.h>
-#include <stdio.h>
// Returns: the quotient of (a + ib) / (c + id)
Index: test/Unit/divti3_test.c
===================================================================
--- test/Unit/divti3_test.c (revision 159279)
+++ test/Unit/divti3_test.c (working copy)
@@ -11,10 +11,11 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if __x86_64
#include "int_lib.h"
-#include <stdio.h>
// Returns: a / b
Index: test/Unit/negvti2_test.c
===================================================================
--- test/Unit/negvti2_test.c (revision 159279)
+++ test/Unit/negvti2_test.c (working copy)
@@ -11,10 +11,11 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if __x86_64
#include "int_lib.h"
-#include <stdio.h>
// Returns: -a
Index: test/Unit/lshrti3_test.c
===================================================================
--- test/Unit/lshrti3_test.c (revision 159279)
+++ test/Unit/lshrti3_test.c (working copy)
@@ -11,10 +11,11 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if __x86_64
#include "int_lib.h"
-#include <stdio.h>
// Returns: logical a >> b
Index: test/Unit/powitf2_test.c
===================================================================
--- test/Unit/powitf2_test.c (revision 159279)
+++ test/Unit/powitf2_test.c (working copy)
@@ -11,10 +11,11 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if _ARCH_PPC
#include "int_lib.h"
-#include <stdio.h>
#include <math.h>
// Returns: a ^ b
Index: test/Unit/addvti3_test.c
===================================================================
--- test/Unit/addvti3_test.c (revision 159279)
+++ test/Unit/addvti3_test.c (working copy)
@@ -11,10 +11,11 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if __x86_64
#include "int_lib.h"
-#include <stdio.h>
// Returns: a + b
Index: test/Unit/ashrti3_test.c
===================================================================
--- test/Unit/ashrti3_test.c (revision 159279)
+++ test/Unit/ashrti3_test.c (working copy)
@@ -11,10 +11,11 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if __x86_64
#include "int_lib.h"
-#include <stdio.h>
// Returns: arithmetic a >> b
Index: test/Unit/ucmpti2_test.c
===================================================================
--- test/Unit/ucmpti2_test.c (revision 159279)
+++ test/Unit/ucmpti2_test.c (working copy)
@@ -11,10 +11,11 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if __x86_64
#include "int_lib.h"
-#include <stdio.h>
// Returns: if (a < b) returns 0
// if (a == b) returns 1
Index: test/Unit/ffsti2_test.c
===================================================================
--- test/Unit/ffsti2_test.c (revision 159279)
+++ test/Unit/ffsti2_test.c (working copy)
@@ -11,10 +11,11 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if __x86_64
#include "int_lib.h"
-#include <stdio.h>
// Returns: the index of the least significant 1-bit in a, or
// the value zero if a is zero. The least significant bit is index one.
Index: test/Unit/modti3_test.c
===================================================================
--- test/Unit/modti3_test.c (revision 159279)
+++ test/Unit/modti3_test.c (working copy)
@@ -11,10 +11,11 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if __x86_64
#include "int_lib.h"
-#include <stdio.h>
// Returns: a % b
Index: test/Unit/subvti3_test.c
===================================================================
--- test/Unit/subvti3_test.c (revision 159279)
+++ test/Unit/subvti3_test.c (working copy)
@@ -11,10 +11,11 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if __x86_64
#include "int_lib.h"
-#include <stdio.h>
#include <stdlib.h>
// Returns: a - b
Index: test/Unit/mulvti3_test.c
===================================================================
--- test/Unit/mulvti3_test.c (revision 159279)
+++ test/Unit/mulvti3_test.c (working copy)
@@ -11,10 +11,11 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if __x86_64
#include "int_lib.h"
-#include <stdio.h>
// Returns: a * b
Index: test/Unit/fixsfti_test.c
===================================================================
--- test/Unit/fixsfti_test.c (revision 159279)
+++ test/Unit/fixsfti_test.c (working copy)
@@ -11,10 +11,11 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if __x86_64
#include "int_lib.h"
-#include <stdio.h>
// Returns: convert a to a signed long long, rounding toward zero.
Index: test/Unit/muloti4_test.c
===================================================================
--- test/Unit/muloti4_test.c (revision 159279)
+++ test/Unit/muloti4_test.c (working copy)
@@ -11,10 +11,11 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if __x86_64
#include "int_lib.h"
-#include <stdio.h>
// Returns: a * b
Index: test/Unit/floattidf_test.c
===================================================================
--- test/Unit/floattidf_test.c (revision 159279)
+++ test/Unit/floattidf_test.c (working copy)
@@ -11,11 +11,12 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if __x86_64
#include "int_lib.h"
#include <float.h>
-#include <stdio.h>
// Returns: convert a to a double, rounding toward even.
Index: test/Unit/floattisf_test.c
===================================================================
--- test/Unit/floattisf_test.c (revision 159279)
+++ test/Unit/floattisf_test.c (working copy)
@@ -11,11 +11,12 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if __x86_64
#include "int_lib.h"
#include <float.h>
-#include <stdio.h>
// Returns: convert a to a float, rounding toward even.
Index: test/Unit/fixdfti_test.c
===================================================================
--- test/Unit/fixdfti_test.c (revision 159279)
+++ test/Unit/fixdfti_test.c (working copy)
@@ -11,10 +11,11 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if __x86_64
#include "int_lib.h"
-#include <stdio.h>
// Returns: convert a to a signed long long, rounding toward zero.
Index: test/Unit/floattixf_test.c
===================================================================
--- test/Unit/floattixf_test.c (revision 159279)
+++ test/Unit/floattixf_test.c (working copy)
@@ -11,11 +11,12 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if __x86_64
#include "int_lib.h"
#include <float.h>
-#include <stdio.h>
// Returns: convert a to a long double, rounding toward even.
Index: test/Unit/multc3_test.c
===================================================================
--- test/Unit/multc3_test.c (revision 159279)
+++ test/Unit/multc3_test.c (working copy)
@@ -11,12 +11,13 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if _ARCH_PPC
#include "int_lib.h"
#include <math.h>
#include <complex.h>
-#include <stdio.h>
// Returns: the product of a + ib and c + id
Index: test/Unit/multi3_test.c
===================================================================
--- test/Unit/multi3_test.c (revision 159279)
+++ test/Unit/multi3_test.c (working copy)
@@ -11,10 +11,11 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if __x86_64
#include "int_lib.h"
-#include <stdio.h>
ti_int __multi3(ti_int a, ti_int b);
Index: test/Unit/floatuntidf_test.c
===================================================================
--- test/Unit/floatuntidf_test.c (revision 159279)
+++ test/Unit/floatuntidf_test.c (working copy)
@@ -11,11 +11,12 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if __x86_64
#include "int_lib.h"
#include <float.h>
-#include <stdio.h>
// Returns: convert a to a double, rounding toward even.
Index: test/Unit/fixxfti_test.c
===================================================================
--- test/Unit/fixxfti_test.c (revision 159279)
+++ test/Unit/fixxfti_test.c (working copy)
@@ -11,10 +11,11 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if __x86_64
#include "int_lib.h"
-#include <stdio.h>
// Returns: convert a to a signed long long, rounding toward zero.
Index: test/Unit/udivti3_test.c
===================================================================
--- test/Unit/udivti3_test.c (revision 159279)
+++ test/Unit/udivti3_test.c (working copy)
@@ -11,10 +11,11 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if __x86_64
#include "int_lib.h"
-#include <stdio.h>
// Returns: a / b
Index: test/Unit/floatuntisf_test.c
===================================================================
--- test/Unit/floatuntisf_test.c (revision 159279)
+++ test/Unit/floatuntisf_test.c (working copy)
@@ -11,11 +11,12 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if __x86_64
#include "int_lib.h"
#include <float.h>
-#include <stdio.h>
// Returns: convert a to a float, rounding toward even.
Index: test/Unit/cmpti2_test.c
===================================================================
--- test/Unit/cmpti2_test.c (revision 159279)
+++ test/Unit/cmpti2_test.c (working copy)
@@ -11,10 +11,11 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if __x86_64
#include "int_lib.h"
-#include <stdio.h>
// Returns: if (a < b) returns 0
// if (a == b) returns 1
Index: test/Unit/floatuntixf_test.c
===================================================================
--- test/Unit/floatuntixf_test.c (revision 159279)
+++ test/Unit/floatuntixf_test.c (working copy)
@@ -11,11 +11,12 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if __x86_64
#include "int_lib.h"
#include <float.h>
-#include <stdio.h>
// Returns: convert a to a long double, rounding toward even.
Index: test/Unit/ashlti3_test.c
===================================================================
--- test/Unit/ashlti3_test.c (revision 159279)
+++ test/Unit/ashlti3_test.c (working copy)
@@ -11,10 +11,11 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if __x86_64
#include "int_lib.h"
-#include <stdio.h>
// Returns: a << b
Index: test/Unit/fixunstfdi_test.c
===================================================================
--- test/Unit/fixunstfdi_test.c (revision 159279)
+++ test/Unit/fixunstfdi_test.c (working copy)
@@ -11,10 +11,11 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if _ARCH_PPC
#include "int_lib.h"
-#include <stdio.h>
// Returns: convert a to a unsigned long long, rounding toward zero.
// Negative values all become zero.
Index: test/Unit/CMakeLists.txt
===================================================================
--- test/Unit/CMakeLists.txt (revision 0)
+++ test/Unit/CMakeLists.txt (revision 0)
@@ -0,0 +1,41 @@
+# The LLVM Compiler Infrastructure
+#
+# This file is dual licensed under the MIT and the University of Illinois Open
+# Source Licenses. See LICENSE.TXT for details.
+
+function(for_arch arch)
+ string(TOLOWER ${arch} arch_suffix)
+ string(TOUPPER ${arch} arch)
+
+ file(GLOB test_sources *.c)
+ foreach(test_src ${test_sources})
+
+ get_filename_component(bin_name ${test_src} NAME_WE)
+ set(bin_name ${bin_name}.${arch_suffix})
+ get_filename_component(filename ${test_src} NAME)
+
+ set(SOURCES ${test_src})
+ set(LIBS "-lc -lm")
+ set(CFLAGS "-Os -nodefaultlibs -I${CMAKE_CURRENT_SOURCE_DIR}/../../lib ${TARGET_${arch}_CFLAGS}")
+ set(EXTRA_CFLAGS "")
+
+ if ("gcc_personality_test.c" STREQUAL ${filename})
+ # This test has another source file.
+ set(SOURCES ${SOURCES} "gcc_personality_test_helper.cxx")
+ endif()
+
+ # Use C99 to compile all *.c files to avoid warnings about
+ # single-line comments.
+ set_source_files_properties(${test_src} PROPERTIES
+ COMPILE_FLAGS "-std=c99")
+ add_executable(${bin_name} ${SOURCES})
+ set_target_properties(${bin_name} PROPERTIES
+ COMPILE_FLAGS "${CFLAGS} ${EXTRA_CFLAGS}"
+ LINK_FLAGS "${TARGET_${arch}_CFLAGS} ${LIBS}")
+ target_link_libraries(${bin_name} clang_rt.${arch_suffix})
+
+ endforeach(test_src)
+endfunction()
+
+for_arch(i386)
+for_arch(x86_64)
Index: test/Unit/clzti2_test.c
===================================================================
--- test/Unit/clzti2_test.c (revision 159279)
+++ test/Unit/clzti2_test.c (working copy)
@@ -11,10 +11,11 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if __x86_64
#include "int_lib.h"
-#include <stdio.h>
// Returns: the number of leading 0-bits
Index: test/Unit/fixunsxfti_test.c
===================================================================
--- test/Unit/fixunsxfti_test.c (revision 159279)
+++ test/Unit/fixunsxfti_test.c (working copy)
@@ -11,10 +11,11 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if __x86_64
#include "int_lib.h"
-#include <stdio.h>
// Returns: convert a to a unsigned long long, rounding toward zero.
// Negative values all become zero.
Index: test/Unit/ctzti2_test.c
===================================================================
--- test/Unit/ctzti2_test.c (revision 159279)
+++ test/Unit/ctzti2_test.c (working copy)
@@ -11,10 +11,11 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if __x86_64
#include "int_lib.h"
-#include <stdio.h>
// Returns: the number of trailing 0-bits
Index: test/Unit/umodti3_test.c
===================================================================
--- test/Unit/umodti3_test.c (revision 159279)
+++ test/Unit/umodti3_test.c (working copy)
@@ -11,10 +11,11 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if __x86_64
#include "int_lib.h"
-#include <stdio.h>
// Returns: a % b
Index: test/Unit/popcountti2_test.c
===================================================================
--- test/Unit/popcountti2_test.c (revision 159279)
+++ test/Unit/popcountti2_test.c (working copy)
@@ -11,10 +11,11 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if __x86_64
#include "int_lib.h"
-#include <stdio.h>
#include <stdlib.h>
// Returns: count of 1 bits
Index: test/Unit/parityti2_test.c
===================================================================
--- test/Unit/parityti2_test.c (revision 159279)
+++ test/Unit/parityti2_test.c (working copy)
@@ -11,10 +11,11 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if __x86_64
#include "int_lib.h"
-#include <stdio.h>
#include <stdlib.h>
// Returns: 1 if number of bits is odd else returns 0
Index: test/Unit/negti2_test.c
===================================================================
--- test/Unit/negti2_test.c (revision 159279)
+++ test/Unit/negti2_test.c (working copy)
@@ -11,10 +11,11 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if __x86_64
#include "int_lib.h"
-#include <stdio.h>
// Returns: -a
Index: test/Unit/udivmodti4_test.c
===================================================================
--- test/Unit/udivmodti4_test.c (revision 159279)
+++ test/Unit/udivmodti4_test.c (working copy)
@@ -11,10 +11,11 @@
//
//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
#if __x86_64
#include "int_lib.h"
-#include <stdio.h>
// Effects: if rem != 0, *rem = a % b
// Returns: a / b
Index: test/CMakeLists.txt
===================================================================
--- test/CMakeLists.txt (revision 0)
+++ test/CMakeLists.txt (revision 0)
@@ -0,0 +1,7 @@
+# The LLVM Compiler Infrastructure
+#
+# This file is dual licensed under the MIT and the University of Illinois Open
+# Source Licenses. See LICENSE.TXT for details.
+
+add_subdirectory(Unit)
+#add_subdirectory(timing)
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt (revision 159279)
+++ CMakeLists.txt (working copy)
@@ -63,6 +63,5 @@
if(LLVM_INCLUDE_TESTS)
# Currently the tests have not been ported to CMake, so disable this
# directory.
- #
- #add_subdirectory(test)
+ add_subdirectory(test)
endif()
--
Edwin Vane
Software Developer
SSG/DPD/ECDL/DMP
Phone: +1 519 772 2567
iNET: 87722567
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120629/9dc284d4/attachment.html>
More information about the llvm-commits
mailing list