forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 100
/
riscv64-abi.c
2052 lines (1778 loc) · 73.2 KB
/
riscv64-abi.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --filter "^define |^entry:" --version 2
// RUN: %clang_cc1 -triple riscv64 -emit-llvm %s -o - \
// RUN: | FileCheck -check-prefixes=LP64-LP64F-LP64D,LP64-LP64F,LP64 %s
// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-abi lp64f -emit-llvm %s -o - \
// RUN: | FileCheck -check-prefixes=LP64-LP64F-LP64D,LP64F-LP64D,LP64-LP64F,LP64F %s
// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d -target-abi lp64d -emit-llvm %s -o - \
// RUN: | FileCheck -check-prefixes=LP64-LP64F-LP64D,LP64F-LP64D,LP64D %s
// RUN: %clang_cc1 -triple riscv64 -emit-llvm -target-abi lp64e %s -o - \
// RUN: | FileCheck -check-prefixes=LP64-LP64F-LP64D,LP64-LP64F,LP64,LP64E %s
#include <stddef.h>
#include <stdint.h>
// LP64-LP64F-LP64D-LABEL: define dso_local void @f_void
// LP64-LP64F-LP64D-SAME: () #[[ATTR0:[0-9]+]] {
// LP64-LP64F-LP64D: entry:
//
void f_void(void) {}
// Scalar arguments and return values smaller than the word size are extended
// according to the sign of their type, up to 32 bits
// LP64-LP64F-LP64D-LABEL: define dso_local zeroext i1 @f_scalar_0
// LP64-LP64F-LP64D-SAME: (i1 noundef zeroext [[X:%.*]]) #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
_Bool f_scalar_0(_Bool x) { return x; }
// LP64-LP64F-LP64D-LABEL: define dso_local signext i8 @f_scalar_1
// LP64-LP64F-LP64D-SAME: (i8 noundef signext [[X:%.*]]) #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
int8_t f_scalar_1(int8_t x) { return x; }
// LP64-LP64F-LP64D-LABEL: define dso_local zeroext i8 @f_scalar_2
// LP64-LP64F-LP64D-SAME: (i8 noundef zeroext [[X:%.*]]) #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
uint8_t f_scalar_2(uint8_t x) { return x; }
// LP64-LP64F-LP64D-LABEL: define dso_local signext i32 @f_scalar_3
// LP64-LP64F-LP64D-SAME: (i32 noundef signext [[X:%.*]]) #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
uint32_t f_scalar_3(int32_t x) { return x; }
// LP64-LP64F-LP64D-LABEL: define dso_local i64 @f_scalar_4
// LP64-LP64F-LP64D-SAME: (i64 noundef [[X:%.*]]) #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
int64_t f_scalar_4(int64_t x) { return x; }
// LP64-LP64F-LP64D-LABEL: define dso_local float @f_fp_scalar_1
// LP64-LP64F-LP64D-SAME: (float noundef [[X:%.*]]) #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
float f_fp_scalar_1(float x) { return x; }
// LP64-LP64F-LP64D-LABEL: define dso_local double @f_fp_scalar_2
// LP64-LP64F-LP64D-SAME: (double noundef [[X:%.*]]) #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
double f_fp_scalar_2(double x) { return x; }
// LP64-LP64F-LP64D-LABEL: define dso_local fp128 @f_fp_scalar_3
// LP64-LP64F-LP64D-SAME: (fp128 noundef [[X:%.*]]) #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
long double f_fp_scalar_3(long double x) { return x; }
// LP64-LP64F-LP64D-LABEL: define dso_local half @f_fp_scalar_4
// LP64-LP64F-LP64D-SAME: (half noundef [[X:%.*]]) #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
_Float16 f_fp_scalar_4(_Float16 x) { return x; }
// Empty structs or unions are ignored.
struct empty_s {};
// LP64-LP64F-LP64D-LABEL: define dso_local void @f_agg_empty_struct
// LP64-LP64F-LP64D-SAME: () #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
struct empty_s f_agg_empty_struct(struct empty_s x) {
return x;
}
union empty_u {};
// LP64-LP64F-LP64D-LABEL: define dso_local void @f_agg_empty_union
// LP64-LP64F-LP64D-SAME: () #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
union empty_u f_agg_empty_union(union empty_u x) {
return x;
}
// Aggregates <= 2*xlen may be passed in registers, so will be coerced to
// integer arguments. The rules for return are the same.
struct tiny {
uint16_t a, b, c, d;
};
// LP64-LP64F-LP64D-LABEL: define dso_local void @f_agg_tiny
// LP64-LP64F-LP64D-SAME: (i64 [[X_COERCE:%.*]]) #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
void f_agg_tiny(struct tiny x) {
x.a += x.b;
x.c += x.d;
}
// LP64-LP64F-LP64D-LABEL: define dso_local i64 @f_agg_tiny_ret
// LP64-LP64F-LP64D-SAME: () #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
struct tiny f_agg_tiny_ret(void) {
return (struct tiny){1, 2, 3, 4};
}
typedef uint16_t v4i16 __attribute__((vector_size(8)));
typedef int64_t v1i64 __attribute__((vector_size(8)));
// LP64-LP64F-LP64D-LABEL: define dso_local void @f_vec_tiny_v4i16
// LP64-LP64F-LP64D-SAME: (i64 noundef [[X_COERCE:%.*]]) #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
void f_vec_tiny_v4i16(v4i16 x) {
x[0] = x[1];
x[2] = x[3];
}
// LP64-LP64F-LP64D-LABEL: define dso_local i64 @f_vec_tiny_v4i16_ret
// LP64-LP64F-LP64D-SAME: () #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
v4i16 f_vec_tiny_v4i16_ret(void) {
return (v4i16){1, 2, 3, 4};
}
// LP64-LP64F-LP64D-LABEL: define dso_local void @f_vec_tiny_v1i64
// LP64-LP64F-LP64D-SAME: (i64 noundef [[X_COERCE:%.*]]) #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
void f_vec_tiny_v1i64(v1i64 x) {
x[0] = 114;
}
// LP64-LP64F-LP64D-LABEL: define dso_local i64 @f_vec_tiny_v1i64_ret
// LP64-LP64F-LP64D-SAME: () #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
v1i64 f_vec_tiny_v1i64_ret(void) {
return (v1i64){1};
}
struct small {
int64_t a, *b;
};
// LP64-LP64F-LP64D-LABEL: define dso_local void @f_agg_small
// LP64-LP64F-LP64D-SAME: ([2 x i64] [[X_COERCE:%.*]]) #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
void f_agg_small(struct small x) {
x.a += *x.b;
x.b = &x.a;
}
// LP64-LP64F-LP64D-LABEL: define dso_local [2 x i64] @f_agg_small_ret
// LP64-LP64F-LP64D-SAME: () #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
struct small f_agg_small_ret(void) {
return (struct small){1, 0};
}
typedef uint16_t v8i16 __attribute__((vector_size(16)));
typedef __int128_t v1i128 __attribute__((vector_size(16)));
// LP64-LP64F-LP64D-LABEL: define dso_local void @f_vec_small_v8i16
// LP64-LP64F-LP64D-SAME: (i128 noundef [[X_COERCE:%.*]]) #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
void f_vec_small_v8i16(v8i16 x) {
x[0] = x[7];
}
// LP64-LP64F-LP64D-LABEL: define dso_local i128 @f_vec_small_v8i16_ret
// LP64-LP64F-LP64D-SAME: () #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
v8i16 f_vec_small_v8i16_ret(void) {
return (v8i16){1, 2, 3, 4, 5, 6, 7, 8};
}
// LP64-LP64F-LP64D-LABEL: define dso_local void @f_vec_small_v1i128
// LP64-LP64F-LP64D-SAME: (i128 noundef [[X_COERCE:%.*]]) #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
void f_vec_small_v1i128(v1i128 x) {
x[0] = 114;
}
// LP64-LP64F-LP64D-LABEL: define dso_local i128 @f_vec_small_v1i128_ret
// LP64-LP64F-LP64D-SAME: () #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
v1i128 f_vec_small_v1i128_ret(void) {
return (v1i128){1};
}
// Aggregates of 2*xlen size and 2*xlen alignment should be coerced to a
// single 2*xlen-sized argument, to ensure that alignment can be maintained if
// passed on the stack.
struct small_aligned {
__int128_t a;
};
// LP64-LP64F-LP64D-LABEL: define dso_local void @f_agg_small_aligned
// LP64-LP64F-LP64D-SAME: (i128 [[X_COERCE:%.*]]) #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
void f_agg_small_aligned(struct small_aligned x) {
x.a += x.a;
}
// LP64-LP64F-LP64D-LABEL: define dso_local i128 @f_agg_small_aligned_ret
// LP64-LP64F-LP64D-SAME: (i128 [[X_COERCE:%.*]]) #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
struct small_aligned f_agg_small_aligned_ret(struct small_aligned x) {
return (struct small_aligned){10};
}
// Aggregates greater > 2*xlen will be passed and returned indirectly
struct large {
int64_t a, b, c, d;
};
// LP64-LP64F-LP64D-LABEL: define dso_local void @f_agg_large
// LP64-LP64F-LP64D-SAME: (ptr noundef [[X:%.*]]) #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
void f_agg_large(struct large x) {
x.a = x.b + x.c + x.d;
}
// The address where the struct should be written to will be the first
// argument
// LP64-LP64F-LP64D-LABEL: define dso_local void @f_agg_large_ret
// LP64-LP64F-LP64D-SAME: (ptr dead_on_unwind noalias writable sret([[STRUCT_LARGE:%.*]]) align 8 [[AGG_RESULT:%.*]], i32 noundef signext [[I:%.*]], i8 noundef signext [[J:%.*]]) #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
struct large f_agg_large_ret(int32_t i, int8_t j) {
return (struct large){1, 2, 3, 4};
}
typedef unsigned char v32i8 __attribute__((vector_size(32)));
// LP64-LP64F-LP64D-LABEL: define dso_local void @f_vec_large_v32i8
// LP64-LP64F-LP64D-SAME: (ptr noundef [[TMP0:%.*]]) #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
void f_vec_large_v32i8(v32i8 x) {
x[0] = x[7];
}
// LP64-LP64F-LP64D-LABEL: define dso_local void @f_vec_large_v32i8_ret
// LP64-LP64F-LP64D-SAME: (ptr dead_on_unwind noalias writable sret(<32 x i8>) align 32 [[AGG_RESULT:%.*]]) #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
v32i8 f_vec_large_v32i8_ret(void) {
return (v32i8){1, 2, 3, 4, 5, 6, 7, 8};
}
// Scalars passed on the stack should have signext/zeroext attributes, just as
// if they were passed in registers.
// LP64-LP64F-LP64D-LABEL: define dso_local signext i32 @f_scalar_stack_1
// LP64-LP64F-LP64D-SAME: (i64 [[A_COERCE:%.*]], [2 x i64] [[B_COERCE:%.*]], i128 [[C_COERCE:%.*]], ptr noundef [[D:%.*]], i8 noundef zeroext [[E:%.*]], i8 noundef signext [[F:%.*]], i8 noundef zeroext [[G:%.*]], i8 noundef signext [[H:%.*]]) #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
int f_scalar_stack_1(struct tiny a, struct small b, struct small_aligned c,
struct large d, uint8_t e, int8_t f, uint8_t g, int8_t h) {
return g + h;
}
// LP64-LP64F-LP64D-LABEL: define dso_local signext i32 @f_scalar_stack_2
// LP64-LP64F-LP64D-SAME: (i32 noundef signext [[A:%.*]], i128 noundef [[B:%.*]], i64 noundef [[C:%.*]], fp128 noundef [[D:%.*]], ptr noundef [[TMP0:%.*]], i8 noundef zeroext [[F:%.*]], i8 noundef signext [[G:%.*]], i8 noundef zeroext [[H:%.*]]) #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
int f_scalar_stack_2(int32_t a, __int128_t b, int64_t c, long double d, v32i8 e,
uint8_t f, int8_t g, uint8_t h) {
return g + h;
}
// LP64-LP64F-LP64D-LABEL: define dso_local signext i32 @f_scalar_stack_3
// LP64-LP64F-LP64D-SAME: (i32 noundef signext [[A:%.*]], i128 noundef [[B:%.*]], double noundef [[C:%.*]], fp128 noundef [[D:%.*]], ptr noundef [[TMP0:%.*]], i8 noundef zeroext [[F:%.*]], i8 noundef signext [[G:%.*]], i8 noundef zeroext [[H:%.*]]) #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
int f_scalar_stack_3(int32_t a, __int128_t b, double c, long double d, v32i8 e,
uint8_t f, int8_t g, uint8_t h) {
return g + h;
}
// Ensure that scalars passed on the stack are still determined correctly in
// the presence of large return values that consume a register due to the need
// to pass a pointer.
// LP64-LP64F-LP64D-LABEL: define dso_local void @f_scalar_stack_4
// LP64-LP64F-LP64D-SAME: (ptr dead_on_unwind noalias writable sret([[STRUCT_LARGE:%.*]]) align 8 [[AGG_RESULT:%.*]], i32 noundef signext [[A:%.*]], i128 noundef [[B:%.*]], fp128 noundef [[C:%.*]], ptr noundef [[TMP0:%.*]], i8 noundef zeroext [[E:%.*]], i8 noundef signext [[F:%.*]], i8 noundef zeroext [[G:%.*]]) #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
struct large f_scalar_stack_4(uint32_t a, __int128_t b, long double c, v32i8 d,
uint8_t e, int8_t f, uint8_t g) {
return (struct large){a, e, f, g};
}
// LP64-LP64F-LP64D-LABEL: define dso_local void @f_scalar_stack_5
// LP64-LP64F-LP64D-SAME: (ptr dead_on_unwind noalias writable sret([[STRUCT_LARGE:%.*]]) align 8 [[AGG_RESULT:%.*]], double noundef [[A:%.*]], i128 noundef [[B:%.*]], fp128 noundef [[C:%.*]], ptr noundef [[TMP0:%.*]], i8 noundef zeroext [[E:%.*]], i8 noundef signext [[F:%.*]], i8 noundef zeroext [[G:%.*]]) #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
struct large f_scalar_stack_5(double a, __int128_t b, long double c, v32i8 d,
uint8_t e, int8_t f, uint8_t g) {
return (struct large){a, e, f, g};
}
// LP64-LP64F-LP64D-LABEL: define dso_local signext i32 @f_scalar_stack_6
// LP64-LP64F-LP64D-SAME: (i32 noundef signext [[A:%.*]], i128 noundef [[B:%.*]], float noundef [[C:%.*]], fp128 noundef [[D:%.*]], ptr noundef [[TMP0:%.*]], i8 noundef zeroext [[F:%.*]], i8 noundef signext [[G:%.*]], i8 noundef zeroext [[H:%.*]], half noundef [[I:%.*]]) #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
int f_scalar_stack_6(int32_t a, __int128_t b, float c, long double d, v32i8 e,
uint8_t f, int8_t g, uint8_t h, _Float16 i) {
return g + h;
}
// LP64-LP64F-LP64D-LABEL: define dso_local void @f_fpr_tracking
// LP64-LP64F-LP64D-SAME: (float noundef [[A:%.*]], float noundef [[B:%.*]], float noundef [[C:%.*]], float noundef [[D:%.*]], float noundef [[E:%.*]], float noundef [[F:%.*]], float noundef [[G:%.*]], float noundef [[H:%.*]], i8 noundef zeroext [[I:%.*]]) #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
void f_fpr_tracking(float a, float b, float c, float d, float e, float f,
float g, float h, uint8_t i) {}
// Check that fp, fp+fp, and int+fp structs are lowered correctly. These will
// be passed in FPR, FPR+FPR, or GPR+FPR regs if sufficient registers are
// available the widths are <= XLEN and FLEN, and should be expanded to
// separate arguments in IR. They are passed by the same rules for returns,
// but will be lowered to simple two-element structs if necessary (as LLVM IR
// functions cannot return multiple values).
// A struct containing just one floating-point real is passed as though it
// were a standalone floating-point real.
struct float_s { float f; };
// LP64-LABEL: define dso_local void @f_float_s_arg
// LP64-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local void @f_float_s_arg
// LP64F-LP64D-SAME: (float [[TMP0:%.*]]) #[[ATTR0]] {
// LP64F-LP64D: entry:
//
void f_float_s_arg(struct float_s a) {}
// LP64-LABEL: define dso_local i64 @f_ret_float_s
// LP64-SAME: () #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local float @f_ret_float_s
// LP64F-LP64D-SAME: () #[[ATTR0]] {
// LP64F-LP64D: entry:
//
struct float_s f_ret_float_s(void) {
return (struct float_s){1.0};
}
// A struct containing a float and any number of zero-width bitfields is
// passed as though it were a standalone floating-point real.
struct zbf_float_s { int : 0; float f; };
struct zbf_float_zbf_s { int : 0; float f; int : 0; };
// LP64-LABEL: define dso_local void @f_zbf_float_s_arg
// LP64-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local void @f_zbf_float_s_arg
// LP64F-LP64D-SAME: (float [[TMP0:%.*]]) #[[ATTR0]] {
// LP64F-LP64D: entry:
//
void f_zbf_float_s_arg(struct zbf_float_s a) {}
// LP64-LABEL: define dso_local i64 @f_ret_zbf_float_s
// LP64-SAME: () #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local float @f_ret_zbf_float_s
// LP64F-LP64D-SAME: () #[[ATTR0]] {
// LP64F-LP64D: entry:
//
struct zbf_float_s f_ret_zbf_float_s(void) {
return (struct zbf_float_s){1.0};
}
// LP64-LABEL: define dso_local void @f_zbf_float_zbf_s_arg
// LP64-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local void @f_zbf_float_zbf_s_arg
// LP64F-LP64D-SAME: (float [[TMP0:%.*]]) #[[ATTR0]] {
// LP64F-LP64D: entry:
//
void f_zbf_float_zbf_s_arg(struct zbf_float_zbf_s a) {}
// LP64-LABEL: define dso_local i64 @f_ret_zbf_float_zbf_s
// LP64-SAME: () #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local float @f_ret_zbf_float_zbf_s
// LP64F-LP64D-SAME: () #[[ATTR0]] {
// LP64F-LP64D: entry:
//
struct zbf_float_zbf_s f_ret_zbf_float_zbf_s(void) {
return (struct zbf_float_zbf_s){1.0};
}
// Check that structs containing two float values (FLEN <= width) are expanded
// provided sufficient FPRs are available.
struct float_float_s { float f; float g; };
// LP64-LABEL: define dso_local void @f_float_float_s_arg
// LP64-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local void @f_float_float_s_arg
// LP64F-LP64D-SAME: (float [[TMP0:%.*]], float [[TMP1:%.*]]) #[[ATTR0]] {
// LP64F-LP64D: entry:
//
void f_float_float_s_arg(struct float_float_s a) {}
// LP64-LABEL: define dso_local i64 @f_ret_float_float_s
// LP64-SAME: () #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local { float, float } @f_ret_float_float_s
// LP64F-LP64D-SAME: () #[[ATTR0]] {
// LP64F-LP64D: entry:
//
struct float_float_s f_ret_float_float_s(void) {
return (struct float_float_s){1.0, 2.0};
}
// LP64-LP64F-LP64D-LABEL: define dso_local void @f_float_float_s_arg_insufficient_fprs
// LP64-LP64F-LP64D-SAME: (float noundef [[A:%.*]], float noundef [[B:%.*]], float noundef [[C:%.*]], float noundef [[D:%.*]], float noundef [[E:%.*]], float noundef [[F:%.*]], float noundef [[G:%.*]], i64 [[H_COERCE:%.*]]) #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
void f_float_float_s_arg_insufficient_fprs(float a, float b, float c, float d,
float e, float f, float g, struct float_float_s h) {}
// Check that structs containing int+float values are expanded, provided
// sufficient FPRs and GPRs are available. The integer components are neither
// sign or zero-extended.
struct float_int8_s { float f; int8_t i; };
struct float_uint8_s { float f; uint8_t i; };
struct float_int32_s { float f; int32_t i; };
struct float_int64_s { float f; int64_t i; };
struct float_int128bf_s { float f; __int128_t i : 64; };
struct float_int8_zbf_s { float f; int8_t i; int : 0; };
// LP64-LABEL: define dso_local void @f_float_int8_s_arg
// LP64-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local void @f_float_int8_s_arg
// LP64F-LP64D-SAME: (float [[TMP0:%.*]], i8 [[TMP1:%.*]]) #[[ATTR0]] {
// LP64F-LP64D: entry:
//
void f_float_int8_s_arg(struct float_int8_s a) {}
// LP64-LABEL: define dso_local i64 @f_ret_float_int8_s
// LP64-SAME: () #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local { float, i8 } @f_ret_float_int8_s
// LP64F-LP64D-SAME: () #[[ATTR0]] {
// LP64F-LP64D: entry:
//
struct float_int8_s f_ret_float_int8_s(void) {
return (struct float_int8_s){1.0, 2};
}
// LP64-LABEL: define dso_local void @f_float_uint8_s_arg
// LP64-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local void @f_float_uint8_s_arg
// LP64F-LP64D-SAME: (float [[TMP0:%.*]], i8 [[TMP1:%.*]]) #[[ATTR0]] {
// LP64F-LP64D: entry:
//
void f_float_uint8_s_arg(struct float_uint8_s a) {}
// LP64-LABEL: define dso_local i64 @f_ret_float_uint8_s
// LP64-SAME: () #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local { float, i8 } @f_ret_float_uint8_s
// LP64F-LP64D-SAME: () #[[ATTR0]] {
// LP64F-LP64D: entry:
//
struct float_uint8_s f_ret_float_uint8_s(void) {
return (struct float_uint8_s){1.0, 2};
}
// LP64-LABEL: define dso_local void @f_float_int32_s_arg
// LP64-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local void @f_float_int32_s_arg
// LP64F-LP64D-SAME: (float [[TMP0:%.*]], i32 [[TMP1:%.*]]) #[[ATTR0]] {
// LP64F-LP64D: entry:
//
void f_float_int32_s_arg(struct float_int32_s a) {}
// LP64-LABEL: define dso_local i64 @f_ret_float_int32_s
// LP64-SAME: () #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local { float, i32 } @f_ret_float_int32_s
// LP64F-LP64D-SAME: () #[[ATTR0]] {
// LP64F-LP64D: entry:
//
struct float_int32_s f_ret_float_int32_s(void) {
return (struct float_int32_s){1.0, 2};
}
// LP64-LABEL: define dso_local void @f_float_int64_s_arg
// LP64-SAME: ([2 x i64] [[A_COERCE:%.*]]) #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local void @f_float_int64_s_arg
// LP64F-LP64D-SAME: (float [[TMP0:%.*]], i64 [[TMP1:%.*]]) #[[ATTR0]] {
// LP64F-LP64D: entry:
//
void f_float_int64_s_arg(struct float_int64_s a) {}
// LP64-LABEL: define dso_local [2 x i64] @f_ret_float_int64_s
// LP64-SAME: () #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local { float, i64 } @f_ret_float_int64_s
// LP64F-LP64D-SAME: () #[[ATTR0]] {
// LP64F-LP64D: entry:
//
struct float_int64_s f_ret_float_int64_s(void) {
return (struct float_int64_s){1.0, 2};
}
// LP64-LABEL: define dso_local void @f_float_int128bf_s_arg
// LP64-SAME: (i128 [[A_COERCE:%.*]]) #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local void @f_float_int128bf_s_arg
// LP64F-LP64D-SAME: (float [[TMP0:%.*]], i64 [[TMP1:%.*]]) #[[ATTR0]] {
// LP64F-LP64D: entry:
//
void f_float_int128bf_s_arg(struct float_int128bf_s a) {}
// LP64-LABEL: define dso_local i128 @f_ret_float_int128bf_s
// LP64-SAME: () #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local <{ float, i64 }> @f_ret_float_int128bf_s
// LP64F-LP64D-SAME: () #[[ATTR0]] {
// LP64F-LP64D: entry:
//
struct float_int128bf_s f_ret_float_int128bf_s(void) {
return (struct float_int128bf_s){1.0, 2};
}
// The zero-width bitfield means the struct can't be passed according to the
// floating point calling convention.
// LP64-LABEL: define dso_local void @f_float_int8_zbf_s
// LP64-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local void @f_float_int8_zbf_s
// LP64F-LP64D-SAME: (float [[TMP0:%.*]], i8 [[TMP1:%.*]]) #[[ATTR0]] {
// LP64F-LP64D: entry:
//
void f_float_int8_zbf_s(struct float_int8_zbf_s a) {}
// LP64-LABEL: define dso_local i64 @f_ret_float_int8_zbf_s
// LP64-SAME: () #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local { float, i8 } @f_ret_float_int8_zbf_s
// LP64F-LP64D-SAME: () #[[ATTR0]] {
// LP64F-LP64D: entry:
//
struct float_int8_zbf_s f_ret_float_int8_zbf_s(void) {
return (struct float_int8_zbf_s){1.0, 2};
}
// LP64-LP64F-LP64D-LABEL: define dso_local void @f_float_int8_s_arg_insufficient_gprs
// LP64-LP64F-LP64D-SAME: (i32 noundef signext [[A:%.*]], i32 noundef signext [[B:%.*]], i32 noundef signext [[C:%.*]], i32 noundef signext [[D:%.*]], i32 noundef signext [[E:%.*]], i32 noundef signext [[F:%.*]], i32 noundef signext [[G:%.*]], i32 noundef signext [[H:%.*]], i64 [[I_COERCE:%.*]]) #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
void f_float_int8_s_arg_insufficient_gprs(int a, int b, int c, int d, int e,
int f, int g, int h, struct float_int8_s i) {}
// LP64-LP64F-LP64D-LABEL: define dso_local void @f_struct_float_int8_insufficient_fprs
// LP64-LP64F-LP64D-SAME: (float noundef [[A:%.*]], float noundef [[B:%.*]], float noundef [[C:%.*]], float noundef [[D:%.*]], float noundef [[E:%.*]], float noundef [[F:%.*]], float noundef [[G:%.*]], float noundef [[H:%.*]], i64 [[I_COERCE:%.*]]) #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
void f_struct_float_int8_insufficient_fprs(float a, float b, float c, float d,
float e, float f, float g, float h, struct float_int8_s i) {}
// Complex floating-point values or structs containing a single complex
// floating-point value should be passed as if it were an fp+fp struct.
// LP64-LABEL: define dso_local void @f_floatcomplex
// LP64-SAME: (i64 noundef [[A_COERCE:%.*]]) #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local void @f_floatcomplex
// LP64F-LP64D-SAME: (float noundef [[A_COERCE0:%.*]], float noundef [[A_COERCE1:%.*]]) #[[ATTR0]] {
// LP64F-LP64D: entry:
//
void f_floatcomplex(float __complex__ a) {}
// LP64-LABEL: define dso_local i64 @f_ret_floatcomplex
// LP64-SAME: () #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local { float, float } @f_ret_floatcomplex
// LP64F-LP64D-SAME: () #[[ATTR0]] {
// LP64F-LP64D: entry:
//
float __complex__ f_ret_floatcomplex(void) {
return 1.0;
}
struct floatcomplex_s { float __complex__ c; };
// LP64-LABEL: define dso_local void @f_floatcomplex_s_arg
// LP64-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local void @f_floatcomplex_s_arg
// LP64F-LP64D-SAME: (float [[TMP0:%.*]], float [[TMP1:%.*]]) #[[ATTR0]] {
// LP64F-LP64D: entry:
//
void f_floatcomplex_s_arg(struct floatcomplex_s a) {}
// LP64-LABEL: define dso_local i64 @f_ret_floatcomplex_s
// LP64-SAME: () #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local { float, float } @f_ret_floatcomplex_s
// LP64F-LP64D-SAME: () #[[ATTR0]] {
// LP64F-LP64D: entry:
//
struct floatcomplex_s f_ret_floatcomplex_s(void) {
return (struct floatcomplex_s){1.0};
}
// Complex floating-point values or structs containing a single complex
// floating-point value should be passed in GPRs if no two FPRs is available.
// LP64-LABEL: define dso_local void @f_floatcomplex_insufficient_fprs1
// LP64-SAME: (i64 noundef [[A_COERCE:%.*]], i64 noundef [[B_COERCE:%.*]], i64 noundef [[C_COERCE:%.*]], i64 noundef [[D_COERCE:%.*]], i64 noundef [[E_COERCE:%.*]]) #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local void @f_floatcomplex_insufficient_fprs1
// LP64F-LP64D-SAME: (float noundef [[A_COERCE0:%.*]], float noundef [[A_COERCE1:%.*]], float noundef [[B_COERCE0:%.*]], float noundef [[B_COERCE1:%.*]], float noundef [[C_COERCE0:%.*]], float noundef [[C_COERCE1:%.*]], float noundef [[D_COERCE0:%.*]], float noundef [[D_COERCE1:%.*]], i64 noundef [[E_COERCE:%.*]]) #[[ATTR0]] {
// LP64F-LP64D: entry:
//
void f_floatcomplex_insufficient_fprs1(float __complex__ a, float __complex__ b,
float __complex__ c, float __complex__ d,
float __complex__ e) {}
// LP64-LABEL: define dso_local void @f_floatcomplex_s_arg_insufficient_fprs1
// LP64-SAME: (i64 [[A_COERCE:%.*]], i64 [[B_COERCE:%.*]], i64 [[C_COERCE:%.*]], i64 [[D_COERCE:%.*]], i64 [[E_COERCE:%.*]]) #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local void @f_floatcomplex_s_arg_insufficient_fprs1
// LP64F-LP64D-SAME: (float [[TMP0:%.*]], float [[TMP1:%.*]], float [[TMP2:%.*]], float [[TMP3:%.*]], float [[TMP4:%.*]], float [[TMP5:%.*]], float [[TMP6:%.*]], float [[TMP7:%.*]], i64 [[E_COERCE:%.*]]) #[[ATTR0]] {
// LP64F-LP64D: entry:
//
void f_floatcomplex_s_arg_insufficient_fprs1(struct floatcomplex_s a,
struct floatcomplex_s b,
struct floatcomplex_s c,
struct floatcomplex_s d,
struct floatcomplex_s e) {}
// LP64-LABEL: define dso_local void @f_floatcomplex_insufficient_fprs2
// LP64-SAME: (float noundef [[A:%.*]], i64 noundef [[B_COERCE:%.*]], i64 noundef [[C_COERCE:%.*]], i64 noundef [[D_COERCE:%.*]], i64 noundef [[E_COERCE:%.*]]) #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local void @f_floatcomplex_insufficient_fprs2
// LP64F-LP64D-SAME: (float noundef [[A:%.*]], float noundef [[B_COERCE0:%.*]], float noundef [[B_COERCE1:%.*]], float noundef [[C_COERCE0:%.*]], float noundef [[C_COERCE1:%.*]], float noundef [[D_COERCE0:%.*]], float noundef [[D_COERCE1:%.*]], i64 noundef [[E_COERCE:%.*]]) #[[ATTR0]] {
// LP64F-LP64D: entry:
//
void f_floatcomplex_insufficient_fprs2(float a,
float __complex__ b, float __complex__ c,
float __complex__ d, float __complex__ e) {}
// LP64-LABEL: define dso_local void @f_floatcomplex_s_arg_insufficient_fprs2
// LP64-SAME: (float noundef [[A:%.*]], i64 [[B_COERCE:%.*]], i64 [[C_COERCE:%.*]], i64 [[D_COERCE:%.*]], i64 [[E_COERCE:%.*]]) #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local void @f_floatcomplex_s_arg_insufficient_fprs2
// LP64F-LP64D-SAME: (float noundef [[A:%.*]], float [[TMP0:%.*]], float [[TMP1:%.*]], float [[TMP2:%.*]], float [[TMP3:%.*]], float [[TMP4:%.*]], float [[TMP5:%.*]], i64 [[E_COERCE:%.*]]) #[[ATTR0]] {
// LP64F-LP64D: entry:
//
void f_floatcomplex_s_arg_insufficient_fprs2(float a,
struct floatcomplex_s b,
struct floatcomplex_s c,
struct floatcomplex_s d,
struct floatcomplex_s e) {}
// Test single or two-element structs that need flattening. e.g. those
// containing nested structs, floats in small arrays, zero-length structs etc.
struct floatarr1_s { float a[1]; };
// LP64-LABEL: define dso_local void @f_floatarr1_s_arg
// LP64-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local void @f_floatarr1_s_arg
// LP64F-LP64D-SAME: (float [[TMP0:%.*]]) #[[ATTR0]] {
// LP64F-LP64D: entry:
//
void f_floatarr1_s_arg(struct floatarr1_s a) {}
// LP64-LABEL: define dso_local i64 @f_ret_floatarr1_s
// LP64-SAME: () #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local float @f_ret_floatarr1_s
// LP64F-LP64D-SAME: () #[[ATTR0]] {
// LP64F-LP64D: entry:
//
struct floatarr1_s f_ret_floatarr1_s(void) {
return (struct floatarr1_s){{1.0}};
}
struct floatarr2_s { float a[2]; };
// LP64-LABEL: define dso_local void @f_floatarr2_s_arg
// LP64-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local void @f_floatarr2_s_arg
// LP64F-LP64D-SAME: (float [[TMP0:%.*]], float [[TMP1:%.*]]) #[[ATTR0]] {
// LP64F-LP64D: entry:
//
void f_floatarr2_s_arg(struct floatarr2_s a) {}
// LP64-LABEL: define dso_local i64 @f_ret_floatarr2_s
// LP64-SAME: () #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local { float, float } @f_ret_floatarr2_s
// LP64F-LP64D-SAME: () #[[ATTR0]] {
// LP64F-LP64D: entry:
//
struct floatarr2_s f_ret_floatarr2_s(void) {
return (struct floatarr2_s){{1.0, 2.0}};
}
struct floatarr2_tricky1_s { struct { float f[1]; } g[2]; };
// LP64-LABEL: define dso_local void @f_floatarr2_tricky1_s_arg
// LP64-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local void @f_floatarr2_tricky1_s_arg
// LP64F-LP64D-SAME: (float [[TMP0:%.*]], float [[TMP1:%.*]]) #[[ATTR0]] {
// LP64F-LP64D: entry:
//
void f_floatarr2_tricky1_s_arg(struct floatarr2_tricky1_s a) {}
// LP64-LABEL: define dso_local i64 @f_ret_floatarr2_tricky1_s
// LP64-SAME: () #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local { float, float } @f_ret_floatarr2_tricky1_s
// LP64F-LP64D-SAME: () #[[ATTR0]] {
// LP64F-LP64D: entry:
//
struct floatarr2_tricky1_s f_ret_floatarr2_tricky1_s(void) {
return (struct floatarr2_tricky1_s){{{{1.0}}, {{2.0}}}};
}
struct floatarr2_tricky2_s { struct {}; struct { float f[1]; } g[2]; };
// LP64-LABEL: define dso_local void @f_floatarr2_tricky2_s_arg
// LP64-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local void @f_floatarr2_tricky2_s_arg
// LP64F-LP64D-SAME: (float [[TMP0:%.*]], float [[TMP1:%.*]]) #[[ATTR0]] {
// LP64F-LP64D: entry:
//
void f_floatarr2_tricky2_s_arg(struct floatarr2_tricky2_s a) {}
// LP64-LABEL: define dso_local i64 @f_ret_floatarr2_tricky2_s
// LP64-SAME: () #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local { float, float } @f_ret_floatarr2_tricky2_s
// LP64F-LP64D-SAME: () #[[ATTR0]] {
// LP64F-LP64D: entry:
//
struct floatarr2_tricky2_s f_ret_floatarr2_tricky2_s(void) {
return (struct floatarr2_tricky2_s){{}, {{{1.0}}, {{2.0}}}};
}
struct floatarr2_tricky3_s { union {}; struct { float f[1]; } g[2]; };
// LP64-LABEL: define dso_local void @f_floatarr2_tricky3_s_arg
// LP64-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local void @f_floatarr2_tricky3_s_arg
// LP64F-LP64D-SAME: (float [[TMP0:%.*]], float [[TMP1:%.*]]) #[[ATTR0]] {
// LP64F-LP64D: entry:
//
void f_floatarr2_tricky3_s_arg(struct floatarr2_tricky3_s a) {}
// LP64-LABEL: define dso_local i64 @f_ret_floatarr2_tricky3_s
// LP64-SAME: () #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local { float, float } @f_ret_floatarr2_tricky3_s
// LP64F-LP64D-SAME: () #[[ATTR0]] {
// LP64F-LP64D: entry:
//
struct floatarr2_tricky3_s f_ret_floatarr2_tricky3_s(void) {
return (struct floatarr2_tricky3_s){{}, {{{1.0}}, {{2.0}}}};
}
struct floatarr2_tricky4_s { union {}; struct { struct {}; float f[1]; } g[2]; };
// LP64-LABEL: define dso_local void @f_floatarr2_tricky4_s_arg
// LP64-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local void @f_floatarr2_tricky4_s_arg
// LP64F-LP64D-SAME: (float [[TMP0:%.*]], float [[TMP1:%.*]]) #[[ATTR0]] {
// LP64F-LP64D: entry:
//
void f_floatarr2_tricky4_s_arg(struct floatarr2_tricky4_s a) {}
// LP64-LABEL: define dso_local i64 @f_ret_floatarr2_tricky4_s
// LP64-SAME: () #[[ATTR0]] {
// LP64: entry:
//
// LP64F-LP64D-LABEL: define dso_local { float, float } @f_ret_floatarr2_tricky4_s
// LP64F-LP64D-SAME: () #[[ATTR0]] {
// LP64F-LP64D: entry:
//
struct floatarr2_tricky4_s f_ret_floatarr2_tricky4_s(void) {
return (struct floatarr2_tricky4_s){{}, {{{}, {1.0}}, {{}, {2.0}}}};
}
// Test structs that should be passed according to the normal integer calling
// convention.
struct int_float_int_s { int a; float b; int c; };
// LP64-LP64F-LP64D-LABEL: define dso_local void @f_int_float_int_s_arg
// LP64-LP64F-LP64D-SAME: ([2 x i64] [[A_COERCE:%.*]]) #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
void f_int_float_int_s_arg(struct int_float_int_s a) {}
// LP64-LP64F-LP64D-LABEL: define dso_local [2 x i64] @f_ret_int_float_int_s
// LP64-LP64F-LP64D-SAME: () #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
struct int_float_int_s f_ret_int_float_int_s(void) {
return (struct int_float_int_s){1, 2.0, 3};
}
struct char_char_float_s { char a; char b; float c; };
// LP64-LP64F-LP64D-LABEL: define dso_local void @f_char_char_float_s_arg
// LP64-LP64F-LP64D-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
void f_char_char_float_s_arg(struct char_char_float_s a) {}
// LP64-LP64F-LP64D-LABEL: define dso_local i64 @f_ret_char_char_float_s
// LP64-LP64F-LP64D-SAME: () #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
struct char_char_float_s f_ret_char_char_float_s(void) {
return (struct char_char_float_s){1, 2, 3.0};
}
// Unions are always passed according to the integer calling convention, even
// if they can only contain a float.
union float_u { float a; };
// LP64-LP64F-LP64D-LABEL: define dso_local void @f_float_u_arg
// LP64-LP64F-LP64D-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
void f_float_u_arg(union float_u a) {}
// LP64-LP64F-LP64D-LABEL: define dso_local i64 @f_ret_float_u
// LP64-LP64F-LP64D-SAME: () #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
union float_u f_ret_float_u(void) {
return (union float_u){1.0};
}
// LP64-LP64F-LP64D-LABEL: define dso_local void @f_fpr_tracking2
// LP64-LP64F-LP64D-SAME: (double noundef [[A:%.*]], double noundef [[B:%.*]], double noundef [[C:%.*]], double noundef [[D:%.*]], double noundef [[E:%.*]], double noundef [[F:%.*]], double noundef [[G:%.*]], double noundef [[H:%.*]], i8 noundef zeroext [[I:%.*]]) #[[ATTR0]] {
// LP64-LP64F-LP64D: entry:
//
void f_fpr_tracking2(double a, double b, double c, double d, double e, double f,
double g, double h, uint8_t i) {}
// Check that fp, fp+fp, and int+fp structs are lowered correctly. These will
// be passed in FPR, FPR+FPR, or GPR+FPR regs if sufficient registers are
// available the widths are <= XLEN and FLEN, and should be expanded to
// separate arguments in IR. They are passed by the same rules for returns,
// but will be lowered to simple two-element structs if necessary (as LLVM IR
// functions cannot return multiple values).
// A struct containing just one floating-point real is passed as though it
// were a standalone floating-point real.
struct double_s { double f; };
// LP64-LP64F-LABEL: define dso_local void @f_double_s_arg
// LP64-LP64F-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0]] {
// LP64-LP64F: entry:
//
// LP64D-LABEL: define dso_local void @f_double_s_arg
// LP64D-SAME: (double [[TMP0:%.*]]) #[[ATTR0]] {
// LP64D: entry:
//
void f_double_s_arg(struct double_s a) {}
// LP64-LP64F-LABEL: define dso_local i64 @f_ret_double_s
// LP64-LP64F-SAME: () #[[ATTR0]] {
// LP64-LP64F: entry:
//
// LP64D-LABEL: define dso_local double @f_ret_double_s
// LP64D-SAME: () #[[ATTR0]] {
// LP64D: entry:
//
struct double_s f_ret_double_s(void) {
return (struct double_s){1.0};
}
// A struct containing a double and any number of zero-width bitfields is
// passed as though it were a standalone floating-point real.
struct zbf_double_s { int : 0; double f; };
struct zbf_double_zbf_s { int : 0; double f; int : 0; };
// LP64-LP64F-LABEL: define dso_local void @f_zbf_double_s_arg
// LP64-LP64F-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0]] {
// LP64-LP64F: entry:
//
// LP64D-LABEL: define dso_local void @f_zbf_double_s_arg
// LP64D-SAME: (double [[TMP0:%.*]]) #[[ATTR0]] {
// LP64D: entry:
//
void f_zbf_double_s_arg(struct zbf_double_s a) {}
// LP64-LP64F-LABEL: define dso_local i64 @f_ret_zbf_double_s
// LP64-LP64F-SAME: () #[[ATTR0]] {
// LP64-LP64F: entry:
//
// LP64D-LABEL: define dso_local double @f_ret_zbf_double_s
// LP64D-SAME: () #[[ATTR0]] {
// LP64D: entry:
//
struct zbf_double_s f_ret_zbf_double_s(void) {
return (struct zbf_double_s){1.0};
}