4 #define VECTOR __attribute__ ((vector_size (16)))
6 typedef char VECTOR char_v
;
9 static const char *hex_digit
= "0123456789abcdef";
11 static char_v
to_char_vec(const char *str
, char_v
*maskp
)
17 for (int i
= 0; i
< sizeof(buf
); i
++) {
24 } else if (ch
!= '~') {
34 static void test_vistr_char(const char *str
, const char *expect_res
,
39 char_v v2
= to_char_vec(str
, &mask
);
40 char_v exp_v1
= to_char_vec(expect_res
, &mask
);
44 "cr 0,0\n\t" /* Clear CC */
45 "vistr %[v1],%[v2],0,1\n\t"
53 *(char_v
*) equal
= (v1
& mask
) == (exp_v1
& mask
);
54 if (memchr(equal
, 0, sizeof(equal
)))
55 printf("Result doesn't match `%s'\n", expect_res
);
58 for (int i
= 0; i
< 16; i
++) {
59 if (v1
[i
] == 0) count
++;
61 tmp
= hex_digit
[count
];
63 tmp
= hex_digit
[cc
& 0xf];
64 if (expect_cc
>= 0 && cc
!= expect_cc
)
65 printf("CC %d != %d\n", cc
, expect_cc
);
70 test_vistr_char("terminated$====~", "terminated$$$$$$", 0);
71 test_vistr_char("undef~~~~~~~~~~~", "undef", -1);
72 test_vistr_char("undef, 2nd half~", "undef, 2nd half", -1);
73 test_vistr_char("Not. Terminated.", "Not. Terminated.", 3);
74 test_vistr_char("partiallyOK~~$~~", "partiallyOK~~$$$", 0);