op_addsub.h (1841B)
1/* 2 * ARMv6 integer SIMD operations. 3 * 4 * Copyright (c) 2007 CodeSourcery. 5 * Written by Paul Brook 6 * 7 * This code is licensed under the GPL. 8 */ 9 10#ifdef ARITH_GE 11#define GE_ARG , void *gep 12#define DECLARE_GE uint32_t ge = 0 13#define SET_GE *(uint32_t *)gep = ge 14#else 15#define GE_ARG 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 23uint32_t HELPER(glue(PFX,add16))(uint32_t a, uint32_t b GE_ARG) 24{ 25 uint32_t res = 0; 26 DECLARE_GE; 27 28 ADD16(a, b, 0); 29 ADD16(a >> 16, b >> 16, 1); 30 SET_GE; 31 return res; 32} 33 34uint32_t HELPER(glue(PFX,add8))(uint32_t a, uint32_t b GE_ARG) 35{ 36 uint32_t res = 0; 37 DECLARE_GE; 38 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); 43 SET_GE; 44 return res; 45} 46 47uint32_t HELPER(glue(PFX,sub16))(uint32_t a, uint32_t b GE_ARG) 48{ 49 uint32_t res = 0; 50 DECLARE_GE; 51 52 SUB16(a, b, 0); 53 SUB16(a >> 16, b >> 16, 1); 54 SET_GE; 55 return res; 56} 57 58uint32_t HELPER(glue(PFX,sub8))(uint32_t a, uint32_t b GE_ARG) 59{ 60 uint32_t res = 0; 61 DECLARE_GE; 62 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); 67 SET_GE; 68 return res; 69} 70 71uint32_t HELPER(glue(PFX,subaddx))(uint32_t a, uint32_t b GE_ARG) 72{ 73 uint32_t res = 0; 74 DECLARE_GE; 75 76 ADD16(a, b >> 16, 0); 77 SUB16(a >> 16, b, 1); 78 SET_GE; 79 return res; 80} 81 82uint32_t HELPER(glue(PFX,addsubx))(uint32_t a, uint32_t b GE_ARG) 83{ 84 uint32_t res = 0; 85 DECLARE_GE; 86 87 SUB16(a, b >> 16, 0); 88 ADD16(a >> 16, b, 1); 89 SET_GE; 90 return res; 91} 92 93#undef GE_ARG 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