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