Skip to content

Commit 9b17e0e

Browse files
committed
Add basic ABI tests for _Float16 type
Just very trivial argument passing, but it can still go wrong in some cases. I've seen the compiler generating instructions invalid for the target architecture, for example.
1 parent f6d8e56 commit 9b17e0e

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include <stdio.h>
2+
3+
4+
#ifdef __FLT16_DIG__
5+
6+
typedef _Float16 fp16_t;
7+
__attribute__((noinline))
8+
void printArg(fp16_t a0) {
9+
printf("printArg: %a\n", (double)a0);
10+
}
11+
12+
fp16_t g_fp16 = 1.0;
13+
14+
int main(int argc, char** argv) {
15+
printArg((fp16_t)0.0);
16+
printArg((fp16_t)0x1p0);
17+
printArg((fp16_t)-0x1p-8);
18+
printArg(g_fp16 + (fp16_t)0x1p0);
19+
20+
return 0;
21+
}
22+
23+
#else
24+
25+
int main() {
26+
printf("printArg: 0x0p+0\n");
27+
printf("printArg: 0x1p+0\n");
28+
printf("printArg: -0x1p-8\n");
29+
printf("printArg: 0x1p+1\n");
30+
return 0;
31+
}
32+
33+
#endif
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
printArg: 0x0p+0
2+
printArg: 0x1p+0
3+
printArg: -0x1p-8
4+
printArg: 0x1p+1
5+
exit 0

0 commit comments

Comments
 (0)