4 #define VECTOR __attribute__ ((vector_size (16)))
6 typedef char VECTOR char_v
;
8 struct vstrc_char_rng
{
9 unsigned char range
[16];
10 unsigned char flags
[16];
13 #define RNG_FLAG_EQ 0x80
14 #define RNG_FLAG_LT 0x40
15 #define RNG_FLAG_GT 0x20
16 #define RNG_FLAG_ANY 0xe0
17 #define RNG_FLAG_NONE 0x00
20 static const char *hex_digit
= "0123456789abcdefGHIJKLMNOPQRSTUV";
22 static void test_vstrc_char(const char *str
, const struct vstrc_char_rng
*rng
,
23 int expect_res
, int expect_cc
)
27 char_v v2
= *(const char_v
*) str
;
28 char_v v3
= *(const char_v
*) rng
->range
;
29 char_v v4
= *(const char_v
*) rng
->flags
;
32 "cr 0,0\n\t" /* Clear CC */
33 "vstrc %[v1],%[v2],%[v3],%[v4],0,3\n\t"
43 tmp
= hex_digit
[v1
[7] & 0x1f];
44 if (expect_res
>= 0 && v1
[7] != expect_res
)
45 printf("result %u != %d\n", v1
[7], expect_res
);
47 tmp
= hex_digit
[cc
& 0xf];
48 if (expect_cc
>= 0 && cc
!= expect_cc
)
49 printf("CC %d != %d\n", cc
, expect_cc
);
54 struct vstrc_char_rng rng
;
57 memset(rng
.flags
, RNG_FLAG_NONE
, 16);
60 rng
.flags
[4] = RNG_FLAG_GT
| RNG_FLAG_EQ
;
61 rng
.flags
[5] = RNG_FLAG_ANY
;
62 /* OK: match at the 'z' */
63 test_vstrc_char("find the z", &rng
, 9, 2);
65 rng
.flags
[12] = RNG_FLAG_GT
| RNG_FLAG_EQ
;
66 rng
.flags
[13] = RNG_FLAG_LT
| RNG_FLAG_EQ
;
67 /* Bad: undefined range */
68 test_vstrc_char("undefined", &rng
, -1, -1);
72 /* OK: match at the 'a' */
73 test_vstrc_char("get the abc", &rng
, 8, 2);
75 rng
.flags
[12] = RNG_FLAG_LT
;
76 rng
.flags
[13] = RNG_FLAG_GT
;
77 /* OK: no match up to null terminator */
78 test_vstrc_char("no match", &rng
, 8, 0);
80 /* OK: no match, no null terminator */
81 test_vstrc_char("0123456789abcdef", &rng
, 16, 3);
84 /* Bad: undefined string */
85 test_vstrc_char(buf
, &rng
, -1, -1);
88 /* Bad: valid match, but CC undefined */
89 test_vstrc_char(buf
, &rng
, 1, -1);