1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
extern void abort (void);
extern void exit (int);
typedef short __v2hi __attribute ((vector_size(4)));
typedef __v2hi fract2x16;
typedef short fract16;
#define GETVECT(HILO1,HILO2,IN1,IN2) \
__builtin_bfin_compose_2x16 ((HILO2) ? __builtin_bfin_extract_hi (IN1) : __builtin_bfin_extract_lo (IN1), \
(HILO1) ? __builtin_bfin_extract_hi (IN2) : __builtin_bfin_extract_lo (IN2))
#define DOTEST(IN1, IN2, HL1, HL2, HL3, HL4) \
__builtin_bfin_multr_fr2x16 (GETVECT (HL1, HL2, IN1, IN1), \
GETVECT (HL3, HL4, IN2, IN2))
#define FUNC(HL1, HL2, HL3, HL4) \
fract2x16 foo ## HL1 ## HL2 ## HL3 ## HL4 (fract2x16 a, fract2x16 b)\
{ \
return DOTEST(a, b, HL1, HL2, HL3, HL4);\
}
FUNC (0, 0, 0, 0)
FUNC (1, 0, 0, 0)
FUNC (0, 1, 0, 0)
FUNC (1, 1, 0, 0)
FUNC (0, 0, 1, 0)
FUNC (1, 0, 1, 0)
FUNC (0, 1, 1, 0)
FUNC (1, 1, 1, 0)
FUNC (0, 0, 0, 1)
FUNC (1, 0, 0, 1)
FUNC (0, 1, 0, 1)
FUNC (1, 1, 0, 1)
FUNC (0, 0, 1, 1)
FUNC (1, 0, 1, 1)
FUNC (0, 1, 1, 1)
FUNC (1, 1, 1, 1)
#define RES1 0x1400
#define RES2 0x1e00
#define RES3 0x1c00
#define RES4 0x2a00
int main ()
{
fract2x16 a, b, c;
fract16 t1, t2;
a = __builtin_bfin_compose_2x16 (0x3000, 0x2000);
b = __builtin_bfin_compose_2x16 (0x7000, 0x5000);
c = foo0000 (a, b);
t1 = __builtin_bfin_extract_lo (c);
t2 = __builtin_bfin_extract_hi (c);
if (t1 != RES1 || t2 != RES1)
abort ();
c = foo1000 (a, b);
t1 = __builtin_bfin_extract_lo (c);
t2 = __builtin_bfin_extract_hi (c);
if (t1 != RES2 || t2 != RES1)
abort ();
c = foo0100 (a, b);
t1 = __builtin_bfin_extract_lo (c);
t2 = __builtin_bfin_extract_hi (c);
if (t1 != RES1 || t2 != RES2)
abort ();
c = foo1100 (a, b);
t1 = __builtin_bfin_extract_lo (c);
t2 = __builtin_bfin_extract_hi (c);
if (t1 != RES2 || t2 != RES2)
abort ();
c = foo0010 (a, b);
t1 = __builtin_bfin_extract_lo (c);
t2 = __builtin_bfin_extract_hi (c);
if (t1 != RES3 || t2 != RES1)
abort ();
c = foo1010 (a, b);
t1 = __builtin_bfin_extract_lo (c);
t2 = __builtin_bfin_extract_hi (c);
if (t1 != RES4 || t2 != RES1)
abort ();
c = foo0110 (a, b);
t1 = __builtin_bfin_extract_lo (c);
t2 = __builtin_bfin_extract_hi (c);
if (t1 != RES3 || t2 != RES2)
abort ();
c = foo1110 (a, b);
t1 = __builtin_bfin_extract_lo (c);
t2 = __builtin_bfin_extract_hi (c);
if (t1 != RES4 || t2 != RES2)
abort ();
c = foo0001 (a, b);
t1 = __builtin_bfin_extract_lo (c);
t2 = __builtin_bfin_extract_hi (c);
if (t1 != RES1 || t2 != RES3)
abort ();
c = foo1001 (a, b);
t1 = __builtin_bfin_extract_lo (c);
t2 = __builtin_bfin_extract_hi (c);
if (t1 != RES2 || t2 != RES3)
abort ();
c = foo0101 (a, b);
t1 = __builtin_bfin_extract_lo (c);
t2 = __builtin_bfin_extract_hi (c);
if (t1 != RES1 || t2 != RES4)
abort ();
c = foo1101 (a, b);
t1 = __builtin_bfin_extract_lo (c);
t2 = __builtin_bfin_extract_hi (c);
if (t1 != RES2 || t2 != RES4)
abort ();
c = foo0011 (a, b);
t1 = __builtin_bfin_extract_lo (c);
t2 = __builtin_bfin_extract_hi (c);
if (t1 != RES3 || t2 != RES3)
abort ();
c = foo1011 (a, b);
t1 = __builtin_bfin_extract_lo (c);
t2 = __builtin_bfin_extract_hi (c);
if (t1 != RES4 || t2 != RES3)
abort ();
c = foo0111 (a, b);
t1 = __builtin_bfin_extract_lo (c);
t2 = __builtin_bfin_extract_hi (c);
if (t1 != RES3 || t2 != RES4)
abort ();
c = foo1111 (a, b);
t1 = __builtin_bfin_extract_lo (c);
t2 = __builtin_bfin_extract_hi (c);
if (t1 != RES4 || t2 != RES4)
abort ();
exit (0);
}
|