root / target-arm / op_addsub.h @ 6e68e076
History | View | Annotate | Download (1.8 kB)
1 | 9ee6e8bb | pbrook | /*
|
---|---|---|---|
2 | 9ee6e8bb | pbrook | * ARMv6 integer SIMD operations.
|
3 | 9ee6e8bb | pbrook | *
|
4 | 9ee6e8bb | pbrook | * Copyright (c) 2007 CodeSourcery.
|
5 | 9ee6e8bb | pbrook | * Written by Paul Brook
|
6 | 9ee6e8bb | pbrook | *
|
7 | 9ee6e8bb | pbrook | * This code is licenced under the GPL.
|
8 | 9ee6e8bb | pbrook | */
|
9 | 9ee6e8bb | pbrook | |
10 | 9ee6e8bb | pbrook | #ifdef ARITH_GE
|
11 | 6ddbc6e4 | pbrook | #define GE_ARG , uint32_t *gep
|
12 | 9ee6e8bb | pbrook | #define DECLARE_GE uint32_t ge = 0 |
13 | 6ddbc6e4 | pbrook | #define SET_GE *gep = ge
|
14 | 9ee6e8bb | pbrook | #else
|
15 | 6ddbc6e4 | pbrook | #define GE_ARG
|
16 | 9ee6e8bb | pbrook | #define DECLARE_GE do{}while(0) |
17 | 9ee6e8bb | pbrook | #define SET_GE do{}while(0) |
18 | 9ee6e8bb | pbrook | #endif
|
19 | 9ee6e8bb | pbrook | |
20 | 9ee6e8bb | pbrook | #define RESULT(val, n, width) \
|
21 | 9ee6e8bb | pbrook | res |= ((uint32_t)(glue(glue(uint,width),_t))(val)) << (n * width) |
22 | 9ee6e8bb | pbrook | |
23 | 6ddbc6e4 | pbrook | uint32_t HELPER(glue(PFX,add16))(uint32_t a, uint32_t b GE_ARG) |
24 | 9ee6e8bb | pbrook | { |
25 | 9ee6e8bb | pbrook | uint32_t res = 0;
|
26 | 9ee6e8bb | pbrook | DECLARE_GE; |
27 | 9ee6e8bb | pbrook | |
28 | 6ddbc6e4 | pbrook | ADD16(a, b, 0);
|
29 | 6ddbc6e4 | pbrook | ADD16(a >> 16, b >> 16, 1); |
30 | 9ee6e8bb | pbrook | SET_GE; |
31 | 6ddbc6e4 | pbrook | return res;
|
32 | 9ee6e8bb | pbrook | } |
33 | 9ee6e8bb | pbrook | |
34 | 6ddbc6e4 | pbrook | uint32_t HELPER(glue(PFX,add8))(uint32_t a, uint32_t b GE_ARG) |
35 | 9ee6e8bb | pbrook | { |
36 | 9ee6e8bb | pbrook | uint32_t res = 0;
|
37 | 9ee6e8bb | pbrook | DECLARE_GE; |
38 | 9ee6e8bb | pbrook | |
39 | 6ddbc6e4 | pbrook | ADD8(a, b, 0);
|
40 | 6ddbc6e4 | pbrook | ADD8(a >> 8, b >> 8, 1); |
41 | 6ddbc6e4 | pbrook | ADD8(a >> 16, b >> 16, 2); |
42 | 6ddbc6e4 | pbrook | ADD8(a >> 24, b >> 24, 3); |
43 | 9ee6e8bb | pbrook | SET_GE; |
44 | 6ddbc6e4 | pbrook | return res;
|
45 | 9ee6e8bb | pbrook | } |
46 | 9ee6e8bb | pbrook | |
47 | 6ddbc6e4 | pbrook | uint32_t HELPER(glue(PFX,sub16))(uint32_t a, uint32_t b GE_ARG) |
48 | 9ee6e8bb | pbrook | { |
49 | 9ee6e8bb | pbrook | uint32_t res = 0;
|
50 | 9ee6e8bb | pbrook | DECLARE_GE; |
51 | 9ee6e8bb | pbrook | |
52 | 6ddbc6e4 | pbrook | SUB16(a, b, 0);
|
53 | 6ddbc6e4 | pbrook | SUB16(a >> 16, b >> 16, 1); |
54 | 9ee6e8bb | pbrook | SET_GE; |
55 | 6ddbc6e4 | pbrook | return res;
|
56 | 9ee6e8bb | pbrook | } |
57 | 9ee6e8bb | pbrook | |
58 | 6ddbc6e4 | pbrook | uint32_t HELPER(glue(PFX,sub8))(uint32_t a, uint32_t b GE_ARG) |
59 | 9ee6e8bb | pbrook | { |
60 | 9ee6e8bb | pbrook | uint32_t res = 0;
|
61 | 9ee6e8bb | pbrook | DECLARE_GE; |
62 | 9ee6e8bb | pbrook | |
63 | 6ddbc6e4 | pbrook | SUB8(a, b, 0);
|
64 | 6ddbc6e4 | pbrook | SUB8(a >> 8, b >> 8, 1); |
65 | 6ddbc6e4 | pbrook | SUB8(a >> 16, b >> 16, 2); |
66 | 6ddbc6e4 | pbrook | SUB8(a >> 24, b >> 24, 3); |
67 | 9ee6e8bb | pbrook | SET_GE; |
68 | 6ddbc6e4 | pbrook | return res;
|
69 | 9ee6e8bb | pbrook | } |
70 | 9ee6e8bb | pbrook | |
71 | 6ddbc6e4 | pbrook | uint32_t HELPER(glue(PFX,subaddx))(uint32_t a, uint32_t b GE_ARG) |
72 | 9ee6e8bb | pbrook | { |
73 | 9ee6e8bb | pbrook | uint32_t res = 0;
|
74 | 9ee6e8bb | pbrook | DECLARE_GE; |
75 | 9ee6e8bb | pbrook | |
76 | 6ddbc6e4 | pbrook | ADD16(a, b, 0);
|
77 | 6ddbc6e4 | pbrook | SUB16(a >> 16, b >> 16, 1); |
78 | 9ee6e8bb | pbrook | SET_GE; |
79 | 6ddbc6e4 | pbrook | return res;
|
80 | 9ee6e8bb | pbrook | } |
81 | 9ee6e8bb | pbrook | |
82 | 6ddbc6e4 | pbrook | uint32_t HELPER(glue(PFX,addsubx))(uint32_t a, uint32_t b GE_ARG) |
83 | 9ee6e8bb | pbrook | { |
84 | 9ee6e8bb | pbrook | uint32_t res = 0;
|
85 | 9ee6e8bb | pbrook | DECLARE_GE; |
86 | 9ee6e8bb | pbrook | |
87 | 6ddbc6e4 | pbrook | SUB16(a, b, 0);
|
88 | 6ddbc6e4 | pbrook | ADD16(a >> 16, b >> 16, 1); |
89 | 9ee6e8bb | pbrook | SET_GE; |
90 | 6ddbc6e4 | pbrook | return res;
|
91 | 9ee6e8bb | pbrook | } |
92 | 9ee6e8bb | pbrook | |
93 | 6ddbc6e4 | pbrook | #undef GE_ARG
|
94 | 9ee6e8bb | pbrook | #undef DECLARE_GE
|
95 | 9ee6e8bb | pbrook | #undef SET_GE
|
96 | 9ee6e8bb | pbrook | #undef RESULT
|
97 | 9ee6e8bb | pbrook | |
98 | 9ee6e8bb | pbrook | #undef ARITH_GE
|
99 | 9ee6e8bb | pbrook | #undef PFX
|
100 | 9ee6e8bb | pbrook | #undef ADD16
|
101 | 9ee6e8bb | pbrook | #undef SUB16
|
102 | 9ee6e8bb | pbrook | #undef ADD8
|
103 | 9ee6e8bb | pbrook | #undef SUB8 |