[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / compiler-rt / test / builtins / Unit / udivmodsi4_test.c
blob0e582549c96db97df573ae94bd5ff58343fb17f5
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_udivmodsi4
3 //===-- udivmodsi4_test.c - Test __udivmodsi4 -----------------------------===//
4 //
5 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
6 // See https://llvm.org/LICENSE.txt for license information.
7 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //
9 //===----------------------------------------------------------------------===//
11 // This file tests __udivmodsi4 for the compiler_rt library.
13 //===----------------------------------------------------------------------===//
15 #include "int_lib.h"
16 #include <stdio.h>
18 // Returns: a / b
20 extern COMPILER_RT_ABI su_int __udivmodsi4(su_int a, su_int b, su_int* rem);
22 int test__udivmodsi4(su_int a, su_int b,
23 su_int expected_result, su_int expected_rem)
25 su_int rem;
26 su_int result = __udivmodsi4(a, b, &rem);
27 if (result != expected_result) {
28 printf("error in __udivmodsi4: %u / %u = %u, expected %u\n",
29 a, b, result, expected_result);
30 return 1;
32 if (rem != expected_rem) {
33 printf("error in __udivmodsi4: %u mod %u = %u, expected %u\n",
34 a, b, rem, expected_rem);
35 return 1;
38 return 0;
42 int main()
44 if (test__udivmodsi4(0, 1, 0, 0))
45 return 1;
47 if (test__udivmodsi4(2, 1, 2, 0))
48 return 1;
50 if (test__udivmodsi4(19, 5, 3, 4))
51 return 1;
53 if (test__udivmodsi4(0x80000000, 8, 0x10000000, 0))
54 return 1;
56 if (test__udivmodsi4(0x80000003, 8, 0x10000000, 3))
57 return 1;
59 return 0;