[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / compiler-rt / test / builtins / Unit / subvti3_test.c
blobaef66b93f73d58c0006dbe84e88e9e26c34e5d37
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_subvti3
3 // REQUIRES: int128
4 //===-- subvti3_test.c - Test __subvti3 -----------------------------------===//
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 __subvti3 for the compiler_rt library.
14 //===----------------------------------------------------------------------===//
16 #include "int_lib.h"
17 #include <stdio.h>
18 #include <stdlib.h>
20 #ifdef CRT_HAS_128BIT
22 // Returns: a - b
24 // Effects: aborts if a - b overflows
26 COMPILER_RT_ABI ti_int __subvti3(ti_int a, ti_int b);
28 int test__subvti3(ti_int a, ti_int b)
30 ti_int x = __subvti3(a, b);
31 ti_int expected = a - b;
32 if (x != expected)
34 twords at;
35 at.all = a;
36 twords bt;
37 bt.all = b;
38 twords xt;
39 xt.all = x;
40 twords expectedt;
41 expectedt.all = expected;
42 printf("error in test__subvsi3(0x%.16llX%.16llX, 0x%.16llX%.16llX) = "
43 "0x%.16llX%.16llX, expected 0x%.16llX%.16llX\n",
44 at.s.high, at.s.low, bt.s.high, bt.s.low, xt.s.high, xt.s.low,
45 expectedt.s.high, expectedt.s.low);
47 return x != expected;
50 #endif
52 int main()
54 #ifdef CRT_HAS_128BIT
55 // test__subvti3(make_ti(0x8000000000000000LL, 0), 1); // should abort
56 // test__subvti3(0, make_ti(0x8000000000000000LL, 0)); // should abort
57 // test__subvti3(1, make_ti(0x8000000000000000LL, 0)); // should abort
58 // test__subvti3(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL), -1); // should abort
59 // test__subvti3(-2, make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)); // should abort
61 if (test__subvti3(make_ti(0x8000000000000000LL, 0), -1))
62 return 1;
63 if (test__subvti3(make_ti(0x8000000000000000LL, 0), 0))
64 return 1;
65 if (test__subvti3(-1, make_ti(0x8000000000000000LL, 0)))
66 return 1;
67 if (test__subvti3(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL), 1))
68 return 1;
69 if (test__subvti3(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL), 0))
70 return 1;
71 if (test__subvti3(1, make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)))
72 return 1;
73 if (test__subvti3(0, make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)))
74 return 1;
75 if (test__subvti3(-1, make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)))
76 return 1;
78 #else
79 printf("skipped\n");
80 #endif
81 return 0;