[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / compiler-rt / test / builtins / Unit / udivti3_test.c
blob8cb4ac19e03f02c417841789c8fc074b1caec983
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_udivti3
3 // REQUIRES: int128
4 //===-- udivti3_test.c - Test __udivti3 -----------------------------------===//
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 __udivti3 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 __udivti3(tu_int a, tu_int b);
25 int test__udivti3(tu_int a, tu_int b, tu_int expected_q)
27 tu_int q = __udivti3(a, b);
28 if (q != expected_q)
30 utwords at;
31 at.all = a;
32 utwords bt;
33 bt.all = b;
34 utwords qt;
35 qt.all = q;
36 utwords expected_qt;
37 expected_qt.all = expected_q;
38 printf("error in __udivti3: 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, qt.s.high, qt.s.low,
41 expected_qt.s.high, expected_qt.s.low);
43 return q != expected_q;
46 #endif
48 int main()
50 #ifdef CRT_HAS_128BIT
51 if (test__udivti3(0, 1, 0))
52 return 1;
53 if (test__udivti3(2, 1, 2))
54 return 1;
55 if (test__udivti3(make_tu(0x8000000000000000uLL, 0), 1,
56 make_tu(0x8000000000000000uLL, 0)))
57 return 1;
58 if (test__udivti3(make_tu(0x8000000000000000uLL, 0), 2,
59 make_tu(0x4000000000000000uLL, 0)))
60 return 1;
61 if (test__udivti3(make_tu(0xFFFFFFFFFFFFFFFFuLL, 0xFFFFFFFFFFFFFFFFuLL), 2,
62 make_tu(0x7FFFFFFFFFFFFFFFuLL, 0xFFFFFFFFFFFFFFFFuLL)))
63 return 1;
65 #else
66 printf("skipped\n");
67 #endif
68 return 0;