[llvm-commits] CVS: llvm-test/SingleSource/UnitTests/Integer/bit_set.c bit_set.reference_output bit_set_cpp.cpp bit_set_cpp.reference_output constval.cpp constval.reference_output arith.c array.c bigint.c bit_concat.c bit_concat_cpp.cpp bit_select.c bit_select_cpp.cpp bitbit.c bitlogic.c bits.h cppfield2.cpp matrix.c part_select.c part_select_cpp.cpp part_select_cpp.reference_output arith.h array.h bigint.h bitbit.h bitlogic.h matrix.h
Reid Spencer
reid at x10sys.com
Tue Apr 17 17:54:07 PDT 2007
Changes in directory llvm-test/SingleSource/UnitTests/Integer:
bit_set.c added (r1.1)
bit_set.reference_output added (r1.1)
bit_set_cpp.cpp added (r1.1)
bit_set_cpp.reference_output added (r1.1)
constval.cpp added (r1.1)
constval.reference_output added (r1.1)
arith.c updated: 1.8 -> 1.9
array.c updated: 1.6 -> 1.7
bigint.c updated: 1.6 -> 1.7
bit_concat.c updated: 1.3 -> 1.4
bit_concat_cpp.cpp updated: 1.2 -> 1.3
bit_select.c updated: 1.3 -> 1.4
bit_select_cpp.cpp updated: 1.1 -> 1.2
bitbit.c updated: 1.6 -> 1.7
bitlogic.c updated: 1.6 -> 1.7
bits.h updated: 1.1 -> 1.2
cppfield2.cpp updated: 1.1 -> 1.2
matrix.c updated: 1.8 -> 1.9
part_select.c updated: 1.3 -> 1.4
part_select_cpp.cpp updated: 1.1 -> 1.2
part_select_cpp.reference_output updated: 1.1 -> 1.2
arith.h (r1.1) removed
array.h (r1.1) removed
bigint.h (r1.1) removed
bitbit.h (r1.1) removed
bitlogic.h (r1.1) removed
matrix.h (r1.2) removed
---
Log message:
Clean this test suite up. Remove unnecessary header files. Make all the
bit tests use standard typenaming conventions and macros for builtins.
Add more tests for other bit manipulation intrinsics.
---
Diffs of the changes: (+329 -121)
arith.c | 2
array.c | 2
bigint.c | 3 -
bit_concat.c | 10 ++--
bit_concat_cpp.cpp | 6 +-
bit_select.c | 6 +-
bit_select_cpp.cpp | 2
bit_set.c | 37 +++++++++++++++
bit_set.reference_output | 49 ++++++++++++++++++++
bit_set_cpp.cpp | 34 +++++++++++++
bit_set_cpp.reference_output | 49 ++++++++++++++++++++
bitbit.c | 2
bitlogic.c | 2
bits.h | 58 +++++++++++++++--------
constval.cpp | 28 +++++++++++
constval.reference_output | 3 +
cppfield2.cpp | 13 ++---
matrix.c | 2
part_select.c | 20 ++------
part_select_cpp.cpp | 27 ++++-------
part_select_cpp.reference_output | 95 +++++++++++++++++++--------------------
21 files changed, 329 insertions(+), 121 deletions(-)
Index: llvm-test/SingleSource/UnitTests/Integer/bit_set.c
diff -c /dev/null llvm-test/SingleSource/UnitTests/Integer/bit_set.c:1.1
*** /dev/null Tue Apr 17 19:54:00 2007
--- llvm-test/SingleSource/UnitTests/Integer/bit_set.c Tue Apr 17 19:53:49 2007
***************
*** 0 ****
--- 1,37 ----
+ //===--- bit_select.c --- Test The bit_select builtin ---------------------===//
+ //
+ // This file was developed by Reid Spencer and is distributed under the
+ // University of Illinois Open Source License. See LICENSE.TXT for details.
+ //
+ //===----------------------------------------------------------------------===//
+ //
+ // This test case tests the __builtin_bit_select builtin function llvm-gcc.
+ // bit_select selects one bit out of a larger
+ //
+ //===----------------------------------------------------------------------===//
+
+ #include <stdio.h>
+ #include "bits.h"
+
+ #ifdef ENABLE_LARGE_INTEGERS
+ typedef uint250 BitType;
+ BitType X = 0;
+ #else
+ typedef uint47 BitType;
+ BitType X = 0;
+ #endif
+
+ int main(int argc, char** argv)
+ {
+
+ int i;
+
+ printBits(X);
+ printf("\n");
+ for (i = bitwidthof(BitType); i > 0; --i) {
+ X = bit_set(X, 1, i-1);
+ printBits(X);
+ printf("\n");
+ }
+ return 0;
+ }
Index: llvm-test/SingleSource/UnitTests/Integer/bit_set.reference_output
diff -c /dev/null llvm-test/SingleSource/UnitTests/Integer/bit_set.reference_output:1.1
*** /dev/null Tue Apr 17 19:54:07 2007
--- llvm-test/SingleSource/UnitTests/Integer/bit_set.reference_output Tue Apr 17 19:53:49 2007
***************
*** 0 ****
--- 1,49 ----
+ 00000000000000000000000000000000000000000000000
+ 10000000000000000000000000000000000000000000000
+ 11000000000000000000000000000000000000000000000
+ 11100000000000000000000000000000000000000000000
+ 11110000000000000000000000000000000000000000000
+ 11111000000000000000000000000000000000000000000
+ 11111100000000000000000000000000000000000000000
+ 11111110000000000000000000000000000000000000000
+ 11111111000000000000000000000000000000000000000
+ 11111111100000000000000000000000000000000000000
+ 11111111110000000000000000000000000000000000000
+ 11111111111000000000000000000000000000000000000
+ 11111111111100000000000000000000000000000000000
+ 11111111111110000000000000000000000000000000000
+ 11111111111111000000000000000000000000000000000
+ 11111111111111100000000000000000000000000000000
+ 11111111111111110000000000000000000000000000000
+ 11111111111111111000000000000000000000000000000
+ 11111111111111111100000000000000000000000000000
+ 11111111111111111110000000000000000000000000000
+ 11111111111111111111000000000000000000000000000
+ 11111111111111111111100000000000000000000000000
+ 11111111111111111111110000000000000000000000000
+ 11111111111111111111111000000000000000000000000
+ 11111111111111111111111100000000000000000000000
+ 11111111111111111111111110000000000000000000000
+ 11111111111111111111111111000000000000000000000
+ 11111111111111111111111111100000000000000000000
+ 11111111111111111111111111110000000000000000000
+ 11111111111111111111111111111000000000000000000
+ 11111111111111111111111111111100000000000000000
+ 11111111111111111111111111111110000000000000000
+ 11111111111111111111111111111111000000000000000
+ 11111111111111111111111111111111100000000000000
+ 11111111111111111111111111111111110000000000000
+ 11111111111111111111111111111111111000000000000
+ 11111111111111111111111111111111111100000000000
+ 11111111111111111111111111111111111110000000000
+ 11111111111111111111111111111111111111000000000
+ 11111111111111111111111111111111111111100000000
+ 11111111111111111111111111111111111111110000000
+ 11111111111111111111111111111111111111111000000
+ 11111111111111111111111111111111111111111100000
+ 11111111111111111111111111111111111111111110000
+ 11111111111111111111111111111111111111111111000
+ 11111111111111111111111111111111111111111111100
+ 11111111111111111111111111111111111111111111110
+ 11111111111111111111111111111111111111111111111
+ exit 0
Index: llvm-test/SingleSource/UnitTests/Integer/bit_set_cpp.cpp
diff -c /dev/null llvm-test/SingleSource/UnitTests/Integer/bit_set_cpp.cpp:1.1
*** /dev/null Tue Apr 17 19:54:07 2007
--- llvm-test/SingleSource/UnitTests/Integer/bit_set_cpp.cpp Tue Apr 17 19:53:49 2007
***************
*** 0 ****
--- 1,34 ----
+ //===--- bit_select.c --- Test The bit_select builtin ---------------------===//
+ //
+ // This file was developed by Reid Spencer and is distributed under the
+ // University of Illinois Open Source License. See LICENSE.TXT for details.
+ //
+ //===----------------------------------------------------------------------===//
+ //
+ // This test case tests the __builtin_bit_select builtin function llvm-gcc.
+ // bit_select selects one bit out of a larger
+ //
+ //===----------------------------------------------------------------------===//
+
+ #include <stdio.h>
+ #include "bits.h"
+
+ #ifdef ENABLE_LARGE_INTEGERS
+ typedef uint250 BitType;
+ BitType X = 0;
+ #else
+ typedef uint47 BitType;
+ BitType X = 0;
+ #endif
+
+ int main(int argc, char** argv)
+ {
+ printBits(X);
+ printf("\n");
+ for (int i = bitwidthof(BitType); i > 0; --i) {
+ X = bit_set(X, 1, i-1);
+ printBits(X);
+ printf("\n");
+ }
+ return 0;
+ }
Index: llvm-test/SingleSource/UnitTests/Integer/bit_set_cpp.reference_output
diff -c /dev/null llvm-test/SingleSource/UnitTests/Integer/bit_set_cpp.reference_output:1.1
*** /dev/null Tue Apr 17 19:54:07 2007
--- llvm-test/SingleSource/UnitTests/Integer/bit_set_cpp.reference_output Tue Apr 17 19:53:49 2007
***************
*** 0 ****
--- 1,49 ----
+ 00000000000000000000000000000000000000000000000
+ 10000000000000000000000000000000000000000000000
+ 11000000000000000000000000000000000000000000000
+ 11100000000000000000000000000000000000000000000
+ 11110000000000000000000000000000000000000000000
+ 11111000000000000000000000000000000000000000000
+ 11111100000000000000000000000000000000000000000
+ 11111110000000000000000000000000000000000000000
+ 11111111000000000000000000000000000000000000000
+ 11111111100000000000000000000000000000000000000
+ 11111111110000000000000000000000000000000000000
+ 11111111111000000000000000000000000000000000000
+ 11111111111100000000000000000000000000000000000
+ 11111111111110000000000000000000000000000000000
+ 11111111111111000000000000000000000000000000000
+ 11111111111111100000000000000000000000000000000
+ 11111111111111110000000000000000000000000000000
+ 11111111111111111000000000000000000000000000000
+ 11111111111111111100000000000000000000000000000
+ 11111111111111111110000000000000000000000000000
+ 11111111111111111111000000000000000000000000000
+ 11111111111111111111100000000000000000000000000
+ 11111111111111111111110000000000000000000000000
+ 11111111111111111111111000000000000000000000000
+ 11111111111111111111111100000000000000000000000
+ 11111111111111111111111110000000000000000000000
+ 11111111111111111111111111000000000000000000000
+ 11111111111111111111111111100000000000000000000
+ 11111111111111111111111111110000000000000000000
+ 11111111111111111111111111111000000000000000000
+ 11111111111111111111111111111100000000000000000
+ 11111111111111111111111111111110000000000000000
+ 11111111111111111111111111111111000000000000000
+ 11111111111111111111111111111111100000000000000
+ 11111111111111111111111111111111110000000000000
+ 11111111111111111111111111111111111000000000000
+ 11111111111111111111111111111111111100000000000
+ 11111111111111111111111111111111111110000000000
+ 11111111111111111111111111111111111111000000000
+ 11111111111111111111111111111111111111100000000
+ 11111111111111111111111111111111111111110000000
+ 11111111111111111111111111111111111111111000000
+ 11111111111111111111111111111111111111111100000
+ 11111111111111111111111111111111111111111110000
+ 11111111111111111111111111111111111111111111000
+ 11111111111111111111111111111111111111111111100
+ 11111111111111111111111111111111111111111111110
+ 11111111111111111111111111111111111111111111111
+ exit 0
Index: llvm-test/SingleSource/UnitTests/Integer/constval.cpp
diff -c /dev/null llvm-test/SingleSource/UnitTests/Integer/constval.cpp:1.1
*** /dev/null Tue Apr 17 19:54:07 2007
--- llvm-test/SingleSource/UnitTests/Integer/constval.cpp Tue Apr 17 19:53:49 2007
***************
*** 0 ****
--- 1,28 ----
+ //===--- constval.c - Test constant APInt values --------------------------===//
+ //
+ // This file was developed by Reid Spencer and is distributed under the
+ // University of Illinois Open Source License. See LICENSE.TXT for details.
+ //
+ //===----------------------------------------------------------------------===//
+ //
+ // This is a general test parsing constant APInt values
+ //
+ //===----------------------------------------------------------------------===//
+
+ #include "bits.h"
+ #include <stdio.h>
+
+ void my_test()
+ {
+ uint21 x = bitsFromString("123456", 21);
+ uint16 y = bitsFromString("123456", 16);
+ printf( "x = %d\n", int(x));
+ printf( "y = %d\n", int(y));
+ }
+
+ int main(int argc, char** argv)
+ {
+ my_test();
+ return 0;
+ }
+
Index: llvm-test/SingleSource/UnitTests/Integer/constval.reference_output
diff -c /dev/null llvm-test/SingleSource/UnitTests/Integer/constval.reference_output:1.1
*** /dev/null Tue Apr 17 19:54:07 2007
--- llvm-test/SingleSource/UnitTests/Integer/constval.reference_output Tue Apr 17 19:53:49 2007
***************
*** 0 ****
--- 1,3 ----
+ x = 123456
+ y = 57920
+ exit 0
Index: llvm-test/SingleSource/UnitTests/Integer/arith.c
diff -u llvm-test/SingleSource/UnitTests/Integer/arith.c:1.8 llvm-test/SingleSource/UnitTests/Integer/arith.c:1.9
--- llvm-test/SingleSource/UnitTests/Integer/arith.c:1.8 Fri Jan 26 21:02:13 2007
+++ llvm-test/SingleSource/UnitTests/Integer/arith.c Tue Apr 17 19:53:49 2007
@@ -9,7 +9,7 @@
//
//===----------------------------------------------------------------------===//
-#include "arith.h"
+#include "bits.h"
#include <stdio.h>
Index: llvm-test/SingleSource/UnitTests/Integer/array.c
diff -u llvm-test/SingleSource/UnitTests/Integer/array.c:1.6 llvm-test/SingleSource/UnitTests/Integer/array.c:1.7
--- llvm-test/SingleSource/UnitTests/Integer/array.c:1.6 Mon Jan 22 18:17:21 2007
+++ llvm-test/SingleSource/UnitTests/Integer/array.c Tue Apr 17 19:53:49 2007
@@ -9,7 +9,7 @@
//
//===----------------------------------------------------------------------===//
-#include "array.h"
+#include "bits.h"
#include <stdio.h>
typedef enum bool{false=0, true=1} bool;
Index: llvm-test/SingleSource/UnitTests/Integer/bigint.c
diff -u llvm-test/SingleSource/UnitTests/Integer/bigint.c:1.6 llvm-test/SingleSource/UnitTests/Integer/bigint.c:1.7
--- llvm-test/SingleSource/UnitTests/Integer/bigint.c:1.6 Mon Jan 22 18:17:21 2007
+++ llvm-test/SingleSource/UnitTests/Integer/bigint.c Tue Apr 17 19:53:49 2007
@@ -8,7 +8,8 @@
// This is a general test for big integer type.
//
//===----------------------------------------------------------------------===//
-#include "bigint.h"
+
+#include "bits.h"
#include <stdio.h>
typedef enum bool{false=0, true=1} bool;
Index: llvm-test/SingleSource/UnitTests/Integer/bit_concat.c
diff -u llvm-test/SingleSource/UnitTests/Integer/bit_concat.c:1.3 llvm-test/SingleSource/UnitTests/Integer/bit_concat.c:1.4
--- llvm-test/SingleSource/UnitTests/Integer/bit_concat.c:1.3 Tue Apr 17 18:12:36 2007
+++ llvm-test/SingleSource/UnitTests/Integer/bit_concat.c Tue Apr 17 19:53:49 2007
@@ -17,9 +17,9 @@
int main(int argc, char** argv)
{
- Int17 X = 0;
- Int19 Y = 0;
- Int36 Z = 0;
+ uint17 X = 0;
+ uint19 Y = 0;
+ uint36 Z = 0;
int i, j;
int count = (argc > 1 ? atoi(argv[1]) % 128 : 128);
@@ -27,11 +27,11 @@
for (i = 0; i < count; i++) {
Y = X = 0;
- for (j = 0; j < bitwidthof(Int17); j++) {
+ for (j = 0; j < bitwidthof(uint17); j++) {
X <<= 1;
X += (rand() % 2 == 0 ? 0 : 1);
}
- for (j = 0; j < bitwidthof(Int19); j++) {
+ for (j = 0; j < bitwidthof(uint19); j++) {
Y <<= 1;
Y += (rand() % 2 == 0 ? 0 : 1);
}
Index: llvm-test/SingleSource/UnitTests/Integer/bit_concat_cpp.cpp
diff -u llvm-test/SingleSource/UnitTests/Integer/bit_concat_cpp.cpp:1.2 llvm-test/SingleSource/UnitTests/Integer/bit_concat_cpp.cpp:1.3
--- llvm-test/SingleSource/UnitTests/Integer/bit_concat_cpp.cpp:1.2 Tue Apr 17 18:12:36 2007
+++ llvm-test/SingleSource/UnitTests/Integer/bit_concat_cpp.cpp Tue Apr 17 19:53:49 2007
@@ -18,9 +18,9 @@
{
int count = (argc > 1 ? atoi(argv[1]) % 128 : 128);
- Int17 X = 0;
- Int19 Y = 0;
- Int36 Z = 0;
+ uint17 X = 0;
+ uint19 Y = 0;
+ uint36 Z = 0;
srand(count);
Index: llvm-test/SingleSource/UnitTests/Integer/bit_select.c
diff -u llvm-test/SingleSource/UnitTests/Integer/bit_select.c:1.3 llvm-test/SingleSource/UnitTests/Integer/bit_select.c:1.4
--- llvm-test/SingleSource/UnitTests/Integer/bit_select.c:1.3 Tue Apr 17 18:18:07 2007
+++ llvm-test/SingleSource/UnitTests/Integer/bit_select.c Tue Apr 17 19:53:49 2007
@@ -11,13 +11,13 @@
//===----------------------------------------------------------------------===//
#include <stdio.h>
-#include <bits.h>
+#include "bits.h"
#ifdef ENABLE_LARGE_INTEGERS
-typedef Int250 BitType;
+typedef uint250 BitType;
const BitType X = 0xAAAAAAAAAAAAAAAAULL;
#else
-typedef Int47 BitType;
+typedef uint47 BitType;
const BitType X = 0xAAAAAAAAAAAAULL;
#endif
Index: llvm-test/SingleSource/UnitTests/Integer/bit_select_cpp.cpp
diff -u llvm-test/SingleSource/UnitTests/Integer/bit_select_cpp.cpp:1.1 llvm-test/SingleSource/UnitTests/Integer/bit_select_cpp.cpp:1.2
--- llvm-test/SingleSource/UnitTests/Integer/bit_select_cpp.cpp:1.1 Wed Mar 28 11:31:50 2007
+++ llvm-test/SingleSource/UnitTests/Integer/bit_select_cpp.cpp Tue Apr 17 19:53:49 2007
@@ -34,7 +34,7 @@
BitType i;
for (i = numbits-1; i >= 0; --i) {
- if (__builtin_bit_select(Y, i))
+ if (__builtin_bit_select(&Y, i))
printf("1");
else
printf("0");
Index: llvm-test/SingleSource/UnitTests/Integer/bitbit.c
diff -u llvm-test/SingleSource/UnitTests/Integer/bitbit.c:1.6 llvm-test/SingleSource/UnitTests/Integer/bitbit.c:1.7
--- llvm-test/SingleSource/UnitTests/Integer/bitbit.c:1.6 Mon Jan 22 18:17:21 2007
+++ llvm-test/SingleSource/UnitTests/Integer/bitbit.c Tue Apr 17 19:53:49 2007
@@ -9,7 +9,7 @@
//
//===----------------------------------------------------------------------===//
-#include "bitbit.h"
+#include "bits.h"
#include <stdio.h>
Index: llvm-test/SingleSource/UnitTests/Integer/bitlogic.c
diff -u llvm-test/SingleSource/UnitTests/Integer/bitlogic.c:1.6 llvm-test/SingleSource/UnitTests/Integer/bitlogic.c:1.7
--- llvm-test/SingleSource/UnitTests/Integer/bitlogic.c:1.6 Mon Jan 22 18:17:21 2007
+++ llvm-test/SingleSource/UnitTests/Integer/bitlogic.c Tue Apr 17 19:53:49 2007
@@ -9,7 +9,7 @@
//
//===----------------------------------------------------------------------===//
-#include "bitlogic.h"
+#include "bits.h"
#include <stdio.h>
Index: llvm-test/SingleSource/UnitTests/Integer/bits.h
diff -u llvm-test/SingleSource/UnitTests/Integer/bits.h:1.1 llvm-test/SingleSource/UnitTests/Integer/bits.h:1.2
--- llvm-test/SingleSource/UnitTests/Integer/bits.h:1.1 Tue Apr 17 18:10:20 2007
+++ llvm-test/SingleSource/UnitTests/Integer/bits.h Tue Apr 17 19:53:49 2007
@@ -13,25 +13,38 @@
#include <stdio.h>
#include <stdlib.h>
-typedef unsigned int __attribute__((bitwidth(1))) Int1;
-typedef unsigned int __attribute__((bitwidth(2))) Int2;
-typedef unsigned int __attribute__((bitwidth(3))) Int3;
-typedef unsigned int __attribute__((bitwidth(4))) Int4;
-typedef unsigned int __attribute__((bitwidth(5))) Int5;
-typedef unsigned int __attribute__((bitwidth(6))) Int6;
-typedef unsigned int __attribute__((bitwidth(7))) Int7;
-typedef unsigned int __attribute__((bitwidth(8))) Int8;
-typedef unsigned int __attribute__((bitwidth(16))) Int16;
-typedef unsigned int __attribute__((bitwidth(17))) Int17;
-typedef unsigned int __attribute__((bitwidth(19))) Int19;
-typedef unsigned int __attribute__((bitwidth(17))) Int32;
-typedef unsigned int __attribute__((bitwidth(36))) Int36;
-typedef unsigned int __attribute__((bitwidth(47))) Int47;
-typedef unsigned int __attribute__((bitwidth(48))) Int48;
-typedef unsigned int __attribute__((bitwidth(64))) Int64;
-typedef unsigned int __attribute__((bitwidth(65))) Int65;
-typedef unsigned int __attribute__((bitwidth(128))) Int128;
-/*typedef unsigned int __attribute__((bitwidth(256))) Int256; */
+typedef unsigned int __attribute__((bitwidth(1))) uint1;
+typedef unsigned int __attribute__((bitwidth(2))) uint2;
+typedef unsigned int __attribute__((bitwidth(3))) uint3;
+typedef unsigned int __attribute__((bitwidth(4))) uint4;
+typedef unsigned int __attribute__((bitwidth(5))) uint5;
+typedef unsigned int __attribute__((bitwidth(6))) uint6;
+typedef unsigned int __attribute__((bitwidth(7))) uint7;
+typedef unsigned int __attribute__((bitwidth(8))) uint8;
+typedef unsigned int __attribute__((bitwidth(9))) uint9;
+typedef unsigned int __attribute__((bitwidth(10))) uint10;
+typedef unsigned int __attribute__((bitwidth(16))) uint16;
+typedef unsigned int __attribute__((bitwidth(17))) uint17;
+typedef unsigned int __attribute__((bitwidth(19))) uint19;
+typedef unsigned int __attribute__((bitwidth(21))) uint21;
+typedef unsigned int __attribute__((bitwidth(17))) uint32;
+typedef unsigned int __attribute__((bitwidth(36))) uint36;
+typedef unsigned int __attribute__((bitwidth(47))) uint47;
+typedef unsigned int __attribute__((bitwidth(48))) uint48;
+typedef unsigned int __attribute__((bitwidth(64))) uint64;
+typedef unsigned int __attribute__((bitwidth(65))) uint65;
+typedef unsigned int __attribute__((bitwidth(128))) uint128;
+
+typedef int __attribute__ ((bitwidth(9))) int9;
+typedef int __attribute__((bitwidth(10))) int10;
+typedef int __attribute__((bitwidth(21))) int21;
+typedef int __attribute__((bitwidth(24))) int24;
+typedef int __attribute__((bitwidth(32))) int32;
+typedef int __attribute__((bitwidth(33))) int33;
+
+typedef int __attribute__((bitwidth(169))) int169;
+typedef unsigned int __attribute__((bitwidth(250))) Int250;
+typedef unsigned int __attribute__((bitwidth(256))) Int256;
#define bitwidthof(TORV) (__bitwidthof__(typeof(TORV)))
@@ -52,7 +65,7 @@
typeof(Val) Result = 0; \
typeof(Val) Val2 = Val; \
typeof(Repl) Repl2 = Repl; \
- __builtin_bit_set(&Result, &Val2, &Repl, Bit); \
+ __builtin_bit_set(&Result, &Val2, &Repl2, Bit); \
Result; \
})
@@ -87,3 +100,8 @@
} \
}
+#define bitsFromString(str,bits) ({ \
+ int __attribute__((bitwidth(bits))) Result; \
+ __builtin_bit_from_string(&Result, str, 10); \
+ Result; \
+})
Index: llvm-test/SingleSource/UnitTests/Integer/cppfield2.cpp
diff -u llvm-test/SingleSource/UnitTests/Integer/cppfield2.cpp:1.1 llvm-test/SingleSource/UnitTests/Integer/cppfield2.cpp:1.2
--- llvm-test/SingleSource/UnitTests/Integer/cppfield2.cpp:1.1 Mon Jan 29 18:48:44 2007
+++ llvm-test/SingleSource/UnitTests/Integer/cppfield2.cpp Tue Apr 17 19:53:49 2007
@@ -10,11 +10,8 @@
#include <stdio.h>
+#include "bits.h"
-typedef unsigned char __attribute__ ((bitwidth(7))) int7;
-typedef unsigned int __attribute__ ((bitwidth(17))) int17;
-typedef unsigned int __attribute__ ((bitwidth(32))) int32;
-typedef unsigned int __attribute__ ((bitwidth(8))) int8;
class bitFieldStruct {
public:
@@ -26,10 +23,10 @@
class bitAccurateStruct {
public:
- int32 i;
- int7 c : 7;
- int17 s : 17;
- int8 c2;
+ uint32 i;
+ uint7 c : 7;
+ uint17 s : 17;
+ uint8 c2;
};
int main()
Index: llvm-test/SingleSource/UnitTests/Integer/matrix.c
diff -u llvm-test/SingleSource/UnitTests/Integer/matrix.c:1.8 llvm-test/SingleSource/UnitTests/Integer/matrix.c:1.9
--- llvm-test/SingleSource/UnitTests/Integer/matrix.c:1.8 Thu Jan 25 21:10:17 2007
+++ llvm-test/SingleSource/UnitTests/Integer/matrix.c Tue Apr 17 19:53:49 2007
@@ -13,7 +13,7 @@
//===----------------------------------------------------------------------===//
-#include "matrix.h"
+#include "bits.h"
#include <stdio.h>
#include <stdlib.h>
Index: llvm-test/SingleSource/UnitTests/Integer/part_select.c
diff -u llvm-test/SingleSource/UnitTests/Integer/part_select.c:1.3 llvm-test/SingleSource/UnitTests/Integer/part_select.c:1.4
--- llvm-test/SingleSource/UnitTests/Integer/part_select.c:1.3 Mon Feb 12 17:17:34 2007
+++ llvm-test/SingleSource/UnitTests/Integer/part_select.c Tue Apr 17 19:53:49 2007
@@ -13,15 +13,14 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
+#include "bits.h"
#ifdef ENABLE_LARGE_INTEGERS
-typedef unsigned __attribute__((bitwidth(256))) BitType;
+typedef uint256 BitType;
const BitType X = 0xFEDCBA9876543210ULL;
-unsigned numbits = 256;
#else
-typedef unsigned __attribute__((bitwidth(47))) BitType;
+typedef uint47 BitType;
const BitType X = 0xFEDCBA9876543210ULL;
-unsigned numbits = 47;
#endif
int main(int argc, char** argv)
@@ -37,17 +36,12 @@
unsigned i, j;
- for (i = 0; i < numbits; ++i) {
- BitType left = rand() % numbits;
+ for (i = 0; i < bitwidthof(BitType); ++i) {
+ BitType left = rand() % bitwidthof(BitType);
BitType right = i;
printf("part_select(Y, %3u, %3u) = ", (unsigned)left, (unsigned)right);
- BitType Z = __builtin_bit_part_select(Y, left, right);
- for (j = numbits; j > 0; --j) {
- if (__builtin_bit_select(Z, j-1))
- printf("1");
- else
- printf("0");
- }
+ BitType Z = part_select(Y, right, left );
+ printBits(Z);
uint64_t val = Z;
printf(" (%lx)", val);
printf("\n");
Index: llvm-test/SingleSource/UnitTests/Integer/part_select_cpp.cpp
diff -u llvm-test/SingleSource/UnitTests/Integer/part_select_cpp.cpp:1.1 llvm-test/SingleSource/UnitTests/Integer/part_select_cpp.cpp:1.2
--- llvm-test/SingleSource/UnitTests/Integer/part_select_cpp.cpp:1.1 Wed Mar 28 11:31:50 2007
+++ llvm-test/SingleSource/UnitTests/Integer/part_select_cpp.cpp Tue Apr 17 19:53:49 2007
@@ -13,15 +13,14 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
+#include "bits.h"
#ifdef ENABLE_LARGE_INTEGERS
-typedef unsigned __attribute__((bitwidth(256))) BitType;
+typedef uint256 BitType;
const BitType X = 0xFEDCBA9876543210ULL;
-unsigned numbits = 256;
#else
-typedef unsigned __attribute__((bitwidth(47))) BitType;
+typedef uint47 BitType;
const BitType X = 0xFEDCBA9876543210ULL;
-unsigned numbits = 47;
#endif
int main(int argc, char** argv)
@@ -37,19 +36,17 @@
unsigned i, j;
- for (i = 0; i < numbits; ++i) {
- BitType left = rand() % numbits;
+ printf("Selecting bits from: ");
+ printBits(X);
+ printf("\n");
+ for (i = 0; i < bitwidthof(BitType); ++i) {
+ BitType left = rand() % bitwidthof(BitType);
BitType right = i;
- printf("part_select(Y, %3u, %3u) = ", (unsigned)left, (unsigned)right);
- BitType Z = __builtin_bit_part_select(Y, left, right);
- for (j = numbits; j > 0; --j) {
- if (__builtin_bit_select(Z, j-1))
- printf("1");
- else
- printf("0");
- }
+ printf("part_select(Y,%3u,%3u) = ", (unsigned)right, (unsigned)left);
+ BitType Z = part_select(Y, right, left);
+ printBits(Z);
uint64_t val = Z;
- printf(" (%lx)", val);
+ printf(" (%llx)", val);
printf("\n");
}
Index: llvm-test/SingleSource/UnitTests/Integer/part_select_cpp.reference_output
diff -u llvm-test/SingleSource/UnitTests/Integer/part_select_cpp.reference_output:1.1 llvm-test/SingleSource/UnitTests/Integer/part_select_cpp.reference_output:1.2
--- llvm-test/SingleSource/UnitTests/Integer/part_select_cpp.reference_output:1.1 Wed Mar 28 11:31:50 2007
+++ llvm-test/SingleSource/UnitTests/Integer/part_select_cpp.reference_output Tue Apr 17 19:53:49 2007
@@ -1,48 +1,49 @@
-part_select(Y, 38, 0) = 00000000001100001110110010101000011001000010000 (76543210)
-part_select(Y, 4, 1) = 00000000000000000000000000000000000000000001000 (8)
-part_select(Y, 18, 2) = 00000000000000000000000000000010000110010000100 (10c84)
-part_select(Y, 23, 3) = 00000000000000000000000000010101000011001000010 (a8642)
-part_select(Y, 17, 4) = 00000000000000000000000000000000000001100100001 (321)
-part_select(Y, 26, 5) = 00000000000000000000000001100101010000110010000 (32a190)
-part_select(Y, 16, 6) = 00000000000000000000000000000000000000011001000 (c8)
-part_select(Y, 3, 7) = 00000000000000000000000000000000000000000001000 (8)
-part_select(Y, 28, 8) = 00000000000000000000000000101100101010000110010 (165432)
-part_select(Y, 28, 9) = 00000000000000000000000000010110010101000011001 (b2a19)
-part_select(Y, 10, 10) = 00000000000000000000000000000000000000000000000 (0)
-part_select(Y, 17, 11) = 00000000000000000000000000000000000000000000110 (6)
-part_select(Y, 44, 12) = 00000000000000110101001100001110110010101000011 (a9876543)
-part_select(Y, 28, 13) = 00000000000000000000000000000001011001010100001 (b2a1)
-part_select(Y, 2, 14) = 00000000000000000000000000000000000010000100110 (426)
-part_select(Y, 20, 15) = 00000000000000000000000000000000000000000101000 (28)
-part_select(Y, 22, 16) = 00000000000000000000000000000000000000001010100 (54)
-part_select(Y, 21, 17) = 00000000000000000000000000000000000000000001010 (a)
-part_select(Y, 18, 18) = 00000000000000000000000000000000000000000000001 (1)
-part_select(Y, 36, 19) = 00000000000000000000000000000110000111011001010 (30eca)
-part_select(Y, 34, 20) = 00000000000000000000000000000000000011101100101 (765)
-part_select(Y, 37, 21) = 00000000000000000000000000000001100001110110010 (c3b2)
-part_select(Y, 18, 22) = 00000000000000000000000000000000000000000010101 (15)
-part_select(Y, 38, 23) = 00000000000000000000000000000000011000011101100 (30ec)
-part_select(Y, 20, 24) = 00000000000000000000000000000000000000000010100 (14)
-part_select(Y, 1, 25) = 00000000000000000000000001000010011000010101001 (2130a9)
-part_select(Y, 31, 26) = 00000000000000000000000000000000000000000011101 (1d)
-part_select(Y, 17, 27) = 00000000000000000000000000000000000001010100110 (2a6)
-part_select(Y, 20, 28) = 00000000000000000000000000000000000000101001101 (14d)
-part_select(Y, 6, 29) = 00000000000000000000000000100110000101010011011 (130a9b)
-part_select(Y, 27, 30) = 00000000000000000000000000000000000000000000111 (7)
-part_select(Y, 37, 31) = 00000000000000000000000000000000000000000110000 (30)
-part_select(Y, 11, 32) = 00000000000000000000000000110000101010011011100 (1854dc)
-part_select(Y, 24, 33) = 00000000000000000000000000000000000000110111000 (1b8)
-part_select(Y, 39, 34) = 00000000000000000000000000000000000000000100110 (26)
-part_select(Y, 7, 35) = 00000000000000000000100110000101010011011100001 (4c2a6e1)
-part_select(Y, 3, 36) = 00000000000000100001001100001010100110111000011 (9854dc3)
-part_select(Y, 9, 37) = 00000000000000000010011000010101001101110000110 (130a9b86)
-part_select(Y, 36, 38) = 00000000000000000000000000000000000000000000100 (4)
-part_select(Y, 31, 39) = 00000000000000000000000000000000000000000011001 (19)
-part_select(Y, 16, 40) = 00000000000000000000000010101001101110000110010 (54dc32)
-part_select(Y, 46, 41) = 00000000000000000000000000000000000000000011101 (1d)
-part_select(Y, 27, 42) = 00000000000000000000000000000000111000011001010 (70ca)
-part_select(Y, 13, 43) = 00000000000000001000010101001101110000110010101 (42a6e195)
-part_select(Y, 6, 44) = 00000000000100110000101010011011100001100101011 (854dc32b)
-part_select(Y, 9, 45) = 00000000001001100001010100110111000011001010111 (a9b8657)
-part_select(Y, 13, 46) = 00000000000001000010101001101110000110010101110 (15370cae)
+Selecting bits from: 01110101001100001110110010101000011001000010000
+part_select(Y, 0, 38) = 00000000001100001110110010101000011001000010000 (1876543210)
+part_select(Y, 1, 4) = 00000000000000000000000000000000000000000001000 (8)
+part_select(Y, 2, 18) = 00000000000000000000000000000010000110010000100 (10c84)
+part_select(Y, 3, 23) = 00000000000000000000000000010101000011001000010 (a8642)
+part_select(Y, 4, 17) = 00000000000000000000000000000000000001100100001 (321)
+part_select(Y, 5, 26) = 00000000000000000000000001100101010000110010000 (32a190)
+part_select(Y, 6, 16) = 00000000000000000000000000000000000000011001000 (c8)
+part_select(Y, 7, 3) = 00000000000000000000000000000000000000000001000 (8)
+part_select(Y, 8, 28) = 00000000000000000000000000101100101010000110010 (165432)
+part_select(Y, 9, 28) = 00000000000000000000000000010110010101000011001 (b2a19)
+part_select(Y, 10, 10) = 00000000000000000000000000000000000000000000000 (0)
+part_select(Y, 11, 17) = 00000000000000000000000000000000000000000000110 (6)
+part_select(Y, 12, 44) = 00000000000000110101001100001110110010101000011 (1a9876543)
+part_select(Y, 13, 28) = 00000000000000000000000000000001011001010100001 (b2a1)
+part_select(Y, 14, 2) = 00000000000000000000000000000000000010000100110 (426)
+part_select(Y, 15, 20) = 00000000000000000000000000000000000000000101000 (28)
+part_select(Y, 16, 22) = 00000000000000000000000000000000000000001010100 (54)
+part_select(Y, 17, 21) = 00000000000000000000000000000000000000000001010 (a)
+part_select(Y, 18, 18) = 00000000000000000000000000000000000000000000001 (1)
+part_select(Y, 19, 36) = 00000000000000000000000000000110000111011001010 (30eca)
+part_select(Y, 20, 34) = 00000000000000000000000000000000000011101100101 (765)
+part_select(Y, 21, 37) = 00000000000000000000000000000001100001110110010 (c3b2)
+part_select(Y, 22, 18) = 00000000000000000000000000000000000000000010101 (15)
+part_select(Y, 23, 38) = 00000000000000000000000000000000011000011101100 (30ec)
+part_select(Y, 24, 20) = 00000000000000000000000000000000000000000010100 (14)
+part_select(Y, 25, 1) = 00000000000000000000000001000010011000010101001 (2130a9)
+part_select(Y, 26, 31) = 00000000000000000000000000000000000000000011101 (1d)
+part_select(Y, 27, 17) = 00000000000000000000000000000000000001010100110 (2a6)
+part_select(Y, 28, 20) = 00000000000000000000000000000000000000101001101 (14d)
+part_select(Y, 29, 6) = 00000000000000000000000000100110000101010011011 (130a9b)
+part_select(Y, 30, 27) = 00000000000000000000000000000000000000000000111 (7)
+part_select(Y, 31, 37) = 00000000000000000000000000000000000000000110000 (30)
+part_select(Y, 32, 11) = 00000000000000000000000000110000101010011011100 (1854dc)
+part_select(Y, 33, 24) = 00000000000000000000000000000000000000110111000 (1b8)
+part_select(Y, 34, 39) = 00000000000000000000000000000000000000000100110 (26)
+part_select(Y, 35, 7) = 00000000000000000000100110000101010011011100001 (4c2a6e1)
+part_select(Y, 36, 3) = 00000000000000100001001100001010100110111000011 (109854dc3)
+part_select(Y, 37, 9) = 00000000000000000010011000010101001101110000110 (130a9b86)
+part_select(Y, 38, 36) = 00000000000000000000000000000000000000000000100 (4)
+part_select(Y, 39, 31) = 00000000000000000000000000000000000000000011001 (19)
+part_select(Y, 40, 16) = 00000000000000000000000010101001101110000110010 (54dc32)
+part_select(Y, 41, 46) = 00000000000000000000000000000000000000000011101 (1d)
+part_select(Y, 42, 27) = 00000000000000000000000000000000111000011001010 (70ca)
+part_select(Y, 43, 13) = 00000000000000001000010101001101110000110010101 (42a6e195)
+part_select(Y, 44, 6) = 00000000000100110000101010011011100001100101011 (9854dc32b)
+part_select(Y, 45, 9) = 00000000001001100001010100110111000011001010111 (130a9b8657)
+part_select(Y, 46, 13) = 00000000000001000010101001101110000110010101110 (215370cae)
exit 0
More information about the llvm-commits
mailing list