blob: ca4a1893c3fc366d93f2ccd6c447a735a06d6a41 [file] [log] [blame]
pbrook9ee6e8b2007-11-11 00:04:49 +00001/*
2 * ARMv6 integer SIMD operations.
3 *
4 * Copyright (c) 2007 CodeSourcery.
5 * Written by Paul Brook
6 *
Matthew Fernandez8e31bf32011-06-26 12:21:35 +10007 * This code is licensed under the GPL.
pbrook9ee6e8b2007-11-11 00:04:49 +00008 */
9
10#ifdef ARITH_GE
pbrooka7812ae2008-11-17 14:43:54 +000011#define GE_ARG , void *gep
pbrook9ee6e8b2007-11-11 00:04:49 +000012#define DECLARE_GE uint32_t ge = 0
pbrooka7812ae2008-11-17 14:43:54 +000013#define SET_GE *(uint32_t *)gep = ge
pbrook9ee6e8b2007-11-11 00:04:49 +000014#else
pbrook6ddbc6e2008-03-31 03:46:33 +000015#define GE_ARG
pbrook9ee6e8b2007-11-11 00:04:49 +000016#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
pbrook6ddbc6e2008-03-31 03:46:33 +000023uint32_t HELPER(glue(PFX,add16))(uint32_t a, uint32_t b GE_ARG)
pbrook9ee6e8b2007-11-11 00:04:49 +000024{
25 uint32_t res = 0;
26 DECLARE_GE;
27
pbrook6ddbc6e2008-03-31 03:46:33 +000028 ADD16(a, b, 0);
29 ADD16(a >> 16, b >> 16, 1);
pbrook9ee6e8b2007-11-11 00:04:49 +000030 SET_GE;
pbrook6ddbc6e2008-03-31 03:46:33 +000031 return res;
pbrook9ee6e8b2007-11-11 00:04:49 +000032}
33
pbrook6ddbc6e2008-03-31 03:46:33 +000034uint32_t HELPER(glue(PFX,add8))(uint32_t a, uint32_t b GE_ARG)
pbrook9ee6e8b2007-11-11 00:04:49 +000035{
36 uint32_t res = 0;
37 DECLARE_GE;
38
pbrook6ddbc6e2008-03-31 03:46:33 +000039 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);
pbrook9ee6e8b2007-11-11 00:04:49 +000043 SET_GE;
pbrook6ddbc6e2008-03-31 03:46:33 +000044 return res;
pbrook9ee6e8b2007-11-11 00:04:49 +000045}
46
pbrook6ddbc6e2008-03-31 03:46:33 +000047uint32_t HELPER(glue(PFX,sub16))(uint32_t a, uint32_t b GE_ARG)
pbrook9ee6e8b2007-11-11 00:04:49 +000048{
49 uint32_t res = 0;
50 DECLARE_GE;
51
pbrook6ddbc6e2008-03-31 03:46:33 +000052 SUB16(a, b, 0);
53 SUB16(a >> 16, b >> 16, 1);
pbrook9ee6e8b2007-11-11 00:04:49 +000054 SET_GE;
pbrook6ddbc6e2008-03-31 03:46:33 +000055 return res;
pbrook9ee6e8b2007-11-11 00:04:49 +000056}
57
pbrook6ddbc6e2008-03-31 03:46:33 +000058uint32_t HELPER(glue(PFX,sub8))(uint32_t a, uint32_t b GE_ARG)
pbrook9ee6e8b2007-11-11 00:04:49 +000059{
60 uint32_t res = 0;
61 DECLARE_GE;
62
pbrook6ddbc6e2008-03-31 03:46:33 +000063 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);
pbrook9ee6e8b2007-11-11 00:04:49 +000067 SET_GE;
pbrook6ddbc6e2008-03-31 03:46:33 +000068 return res;
pbrook9ee6e8b2007-11-11 00:04:49 +000069}
70
pbrook6ddbc6e2008-03-31 03:46:33 +000071uint32_t HELPER(glue(PFX,subaddx))(uint32_t a, uint32_t b GE_ARG)
pbrook9ee6e8b2007-11-11 00:04:49 +000072{
73 uint32_t res = 0;
74 DECLARE_GE;
75
Chih-Min Chaobb42e282010-06-28 23:54:04 +080076 ADD16(a, b >> 16, 0);
77 SUB16(a >> 16, b, 1);
pbrook9ee6e8b2007-11-11 00:04:49 +000078 SET_GE;
pbrook6ddbc6e2008-03-31 03:46:33 +000079 return res;
pbrook9ee6e8b2007-11-11 00:04:49 +000080}
81
pbrook6ddbc6e2008-03-31 03:46:33 +000082uint32_t HELPER(glue(PFX,addsubx))(uint32_t a, uint32_t b GE_ARG)
pbrook9ee6e8b2007-11-11 00:04:49 +000083{
84 uint32_t res = 0;
85 DECLARE_GE;
86
Chih-Min Chaobb42e282010-06-28 23:54:04 +080087 SUB16(a, b >> 16, 0);
88 ADD16(a >> 16, b, 1);
pbrook9ee6e8b2007-11-11 00:04:49 +000089 SET_GE;
pbrook6ddbc6e2008-03-31 03:46:33 +000090 return res;
pbrook9ee6e8b2007-11-11 00:04:49 +000091}
92
pbrook6ddbc6e2008-03-31 03:46:33 +000093#undef GE_ARG
pbrook9ee6e8b2007-11-11 00:04:49 +000094#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