Path: blob/master/libs/compiler-rt/lib/builtins/arm/aeabi_idivmod.S
4396 views
//===-- aeabi_idivmod.S - EABI idivmod implementation ---------------------===//1//2// The LLVM Compiler Infrastructure3//4// This file is dual licensed under the MIT and the University of Illinois Open5// Source Licenses. See LICENSE.TXT for details.6//7//===----------------------------------------------------------------------===//89#include "../assembly.h"1011// struct { int quot, int rem} __aeabi_idivmod(int numerator, int denominator) {12// int rem, quot;13// quot = __divmodsi4(numerator, denominator, &rem);14// return {quot, rem};15// }1617#if defined(_WIN32)18#define __aeabi_idivmod __rt_sdiv19#endif2021.syntax unified22.text23DEFINE_CODE_STATE24.p2align 225DEFINE_COMPILERRT_FUNCTION(__aeabi_idivmod)26#if defined(USE_THUMB_1)27push {r0, r1, lr}28bl SYMBOL_NAME(__divsi3)29pop {r1, r2, r3} // now r0 = quot, r1 = num, r2 = denom30muls r2, r0, r2 // r2 = quot * denom31subs r1, r1, r232JMP (r3)33#else // defined(USE_THUMB_1)34push { lr }35sub sp, sp, #436mov r2, sp37#if defined(_WIN32)38mov r3, r039mov r0, r140mov r1, r341#endif42bl SYMBOL_NAME(__divmodsi4)43ldr r1, [sp]44add sp, sp, #445pop { pc }46#endif // defined(USE_THUMB_1)47END_COMPILERRT_FUNCTION(__aeabi_idivmod)4849NO_EXEC_STACK_DIRECTIVE505152