OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [scal-to-vec1.c] - Blame information for rev 801

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 688 jeremybenn
#define vector(elcount, type)  \
2
__attribute__((vector_size((elcount)*sizeof(type)))) type
3
 
4
#define vidx(type, vec, idx) (*((type *) &(vec) + idx))
5
 
6
#define operl(a, b, op) (a op b)
7
#define operr(a, b, op) (b op a)
8
 
9
#define check(type, count, vec0, vec1, num, op, lr) \
10
do {\
11
    int __i; \
12
    for (__i = 0; __i < count; __i++) {\
13
        if (vidx (type, vec1, __i) != oper##lr (num, vidx (type, vec0, __i), op)) \
14
            __builtin_abort (); \
15
    }\
16
} while (0)
17
 
18
#define veccompare(type, count, v0, v1) \
19
do {\
20
    int __i; \
21
    for (__i = 0; __i < count; __i++) { \
22
        if (vidx (type, v0, __i) != vidx (type, v1, __i)) \
23
            __builtin_abort (); \
24
    } \
25
} while (0)
26
 
27
volatile int one = 1;
28
 
29
int main (int argc, char *argv[]) {
30
#define fvec_2 (vector(4, float)){2., 2., 2., 2.}
31
#define dvec_2 (vector(2, double)){2., 2.}
32
 
33
 
34
    vector(8, short) v0 = {one, 1, 2, 3, 4, 5, 6, 7};
35
    vector(8, short) v1;
36
 
37
    vector(4, float) f0 = {1., 2., 3., 4.};
38
    vector(4, float) f1, f2;
39
 
40
    vector(2, double) d0 = {1., 2.};
41
    vector(2, double) d1, d2;
42
 
43
 
44
 
45
    v1 = 2 + v0;   check (short, 8, v0, v1, 2, +, l);
46
    v1 = 2 - v0;   check (short, 8, v0, v1, 2, -, l);
47
    v1 = 2 * v0;   check (short, 8, v0, v1, 2, *, l);
48
    v1 = 2 / v0;   check (short, 8, v0, v1, 2, /, l);
49
    v1 = 2 % v0;   check (short, 8, v0, v1, 2, %, l);
50
    v1 = 2 ^ v0;   check (short, 8, v0, v1, 2, ^, l);
51
    v1 = 2 & v0;   check (short, 8, v0, v1, 2, &, l);
52
    v1 = 2 | v0;   check (short, 8, v0, v1, 2, |, l);
53
    v1 = 2 << v0;   check (short, 8, v0, v1, 2, <<, l);
54
    v1 = 2 >> v0;   check (short, 8, v0, v1, 2, >>, l);
55
 
56
    v1 = v0 + 2;   check (short, 8, v0, v1, 2, +, r);
57
    v1 = v0 - 2;   check (short, 8, v0, v1, 2, -, r);
58
    v1 = v0 * 2;   check (short, 8, v0, v1, 2, *, r);
59
    v1 = v0 / 2;   check (short, 8, v0, v1, 2, /, r);
60
    v1 = v0 % 2;   check (short, 8, v0, v1, 2, %, r);
61
    v1 = v0 ^ 2;   check (short, 8, v0, v1, 2, ^, r);
62
    v1 = v0 & 2;   check (short, 8, v0, v1, 2, &, r);
63
    v1 = v0 | 2;   check (short, 8, v0, v1, 2, |, r);
64
 
65
    f1 = 2. + f0;  f2 = fvec_2 + f0; veccompare (float, 4, f1, f2);
66
    f1 = 2. - f0;  f2 = fvec_2 - f0; veccompare (float, 4, f1, f2);
67
    f1 = 2. * f0;  f2 = fvec_2 * f0; veccompare (float, 4, f1, f2);
68
    f1 = 2. / f0;  f2 = fvec_2 / f0; veccompare (float, 4, f1, f2);
69
 
70
    f1 = f0 + 2.;  f2 = f0 + fvec_2; veccompare (float, 4, f1, f2);
71
    f1 = f0 - 2.;  f2 = f0 - fvec_2; veccompare (float, 4, f1, f2);
72
    f1 = f0 * 2.;  f2 = f0 * fvec_2; veccompare (float, 4, f1, f2);
73
    f1 = f0 / 2.;  f2 = f0 / fvec_2; veccompare (float, 4, f1, f2);
74
 
75
    d1 = 2. + d0;  d2 = dvec_2 + d0; veccompare (double, 2, d1, d2);
76
    d1 = 2. - d0;  d2 = dvec_2 - d0; veccompare (double, 2, d1, d2);
77
    d1 = 2. * d0;  d2 = dvec_2 * d0; veccompare (double, 2, d1, d2);
78
    d1 = 2. / d0;  d2 = dvec_2 / d0; veccompare (double, 2, d1, d2);
79
 
80
    d1 = d0 + 2.;  d2 = d0 + dvec_2; veccompare (double, 2, d1, d2);
81
    d1 = d0 - 2.;  d2 = d0 - dvec_2; veccompare (double, 2, d1, d2);
82
    d1 = d0 * 2.;  d2 = d0 * dvec_2; veccompare (double, 2, d1, d2);
83
    d1 = d0 / 2.;  d2 = d0 / dvec_2; veccompare (double, 2, d1, d2);
84
 
85
    return 0;
86
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.