[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / compiler-rt / test / builtins / Unit / umodti3_test.c
blob5bbe1c3c1bb19364bf1506ba6d9535a8d9c345a7
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_umodti3
3 // REQUIRES: int128
4 //===-- umodti3_test.c - Test __umodti3 -----------------------------------===//
5 //
6 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
7 // See https://llvm.org/LICENSE.txt for license information.
8 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
9 //
10 //===----------------------------------------------------------------------===//
12 // This file tests __umodti3 for the compiler_rt library.
14 //===----------------------------------------------------------------------===//
16 #include "int_lib.h"
17 #include <stdio.h>
19 #ifdef CRT_HAS_128BIT
21 // Returns: a % b
23 COMPILER_RT_ABI tu_int __umodti3(tu_int a, tu_int b);
25 int test__umodti3(tu_int a, tu_int b, tu_int expected_r)
27 tu_int r = __umodti3(a, b);
28 if (r != expected_r)
30 utwords at;
31 at.all = a;
32 utwords bt;
33 bt.all = b;
34 utwords rt;
35 rt.all = r;
36 utwords expected_rt;
37 expected_rt.all = expected_r;
38 printf("error in __umodti3: 0x%llX%.16llX %% 0x%llX%.16llX = "
39 "0x%llX%.16llX, expected 0x%llX%.16llX\n",
40 at.s.high, at.s.low, bt.s.high, bt.s.low, rt.s.high, rt.s.low,
41 expected_rt.s.high, expected_rt.s.low);
43 return r != expected_r;
46 #endif
48 int main()
50 #ifdef CRT_HAS_128BIT
51 if (test__umodti3(0, 1, 0))
52 return 1;
53 if (test__umodti3(2, 1, 0))
54 return 1;
55 if (test__umodti3(make_tu(0x8000000000000000uLL, 0), 1, 0x0uLL))
56 return 1;
57 if (test__umodti3(make_tu(0x8000000000000000uLL, 0), 2, 0x0uLL))
58 return 1;
59 if (test__umodti3(make_tu(0xFFFFFFFFFFFFFFFFuLL, 0xFFFFFFFFFFFFFFFFuLL),
60 2, 0x1uLL))
61 return 1;
63 #else
64 printf("skipped\n");
65 #endif
66 return 0;