18b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project/*
28b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project * ARMv6 integer SIMD operations.
38b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project *
48b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project * Copyright (c) 2007 CodeSourcery.
58b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project * Written by Paul Brook
68b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project *
78b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project * This code is licenced under the GPL.
88b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project */
98b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project
108b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#ifdef ARITH_GE
115d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define GE_ARG , void *gep
128b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#define DECLARE_GE uint32_t ge = 0
135d8f37ad78fc66901af50c762029a501561f3b23David 'Digit' Turner#define SET_GE *(uint32_t *)gep = ge
148b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#else
158b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#define GE_ARG
168b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#define DECLARE_GE do{}while(0)
178b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#define SET_GE do{}while(0)
188b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#endif
198b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project
208b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#define RESULT(val, n, width) \
218b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    res |= ((uint32_t)(glue(glue(uint,width),_t))(val)) << (n * width)
228b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project
238b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Projectuint32_t HELPER(glue(PFX,add16))(uint32_t a, uint32_t b GE_ARG)
248b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project{
258b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    uint32_t res = 0;
268b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    DECLARE_GE;
278b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project
288b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    ADD16(a, b, 0);
298b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    ADD16(a >> 16, b >> 16, 1);
308b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    SET_GE;
318b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    return res;
328b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project}
338b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project
348b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Projectuint32_t HELPER(glue(PFX,add8))(uint32_t a, uint32_t b GE_ARG)
358b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project{
368b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    uint32_t res = 0;
378b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    DECLARE_GE;
388b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project
398b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    ADD8(a, b, 0);
408b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    ADD8(a >> 8, b >> 8, 1);
418b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    ADD8(a >> 16, b >> 16, 2);
428b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    ADD8(a >> 24, b >> 24, 3);
438b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    SET_GE;
448b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    return res;
458b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project}
468b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project
478b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Projectuint32_t HELPER(glue(PFX,sub16))(uint32_t a, uint32_t b GE_ARG)
488b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project{
498b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    uint32_t res = 0;
508b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    DECLARE_GE;
518b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project
528b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    SUB16(a, b, 0);
538b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    SUB16(a >> 16, b >> 16, 1);
548b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    SET_GE;
558b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    return res;
568b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project}
578b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project
588b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Projectuint32_t HELPER(glue(PFX,sub8))(uint32_t a, uint32_t b GE_ARG)
598b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project{
608b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    uint32_t res = 0;
618b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    DECLARE_GE;
628b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project
638b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    SUB8(a, b, 0);
648b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    SUB8(a >> 8, b >> 8, 1);
658b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    SUB8(a >> 16, b >> 16, 2);
668b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    SUB8(a >> 24, b >> 24, 3);
678b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    SET_GE;
688b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    return res;
698b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project}
708b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project
718b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Projectuint32_t HELPER(glue(PFX,subaddx))(uint32_t a, uint32_t b GE_ARG)
728b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project{
738b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    uint32_t res = 0;
748b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    DECLARE_GE;
758b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project
765285864985be9077e58e42235af6582dee72e841David 'Digit' Turner    ADD16(a, b >> 16, 0);
775285864985be9077e58e42235af6582dee72e841David 'Digit' Turner    SUB16(a >> 16, b, 1);
788b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    SET_GE;
798b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    return res;
808b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project}
818b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project
828b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Projectuint32_t HELPER(glue(PFX,addsubx))(uint32_t a, uint32_t b GE_ARG)
838b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project{
848b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    uint32_t res = 0;
858b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    DECLARE_GE;
868b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project
875285864985be9077e58e42235af6582dee72e841David 'Digit' Turner    SUB16(a, b >> 16, 0);
885285864985be9077e58e42235af6582dee72e841David 'Digit' Turner    ADD16(a >> 16, b, 1);
898b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    SET_GE;
908b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project    return res;
918b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project}
928b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project
938b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#undef GE_ARG
948b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#undef DECLARE_GE
958b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#undef SET_GE
968b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#undef RESULT
978b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project
988b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#undef ARITH_GE
998b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#undef PFX
1008b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#undef ADD16
1018b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#undef SUB16
1028b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#undef ADD8
1038b23a6c7e1aee255004dd19098d4c2462b61b849The Android Open Source Project#undef SUB8
104