-
Notifications
You must be signed in to change notification settings - Fork 4.8k
/
EmptyStructs.cs
2233 lines (1900 loc) · 82.3 KB
/
EmptyStructs.cs
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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Note: this test checks passing empty struct fields in .NET; confronting it against C++ on native compilers is just
// a means to assert compliance to the platform calling convention. The native part is using C++ because it defines
// empty structs as 1 byte like in .NET. Empty structs in C are undefined (it's a GCC extension to define them as 0
// bytes) and .NET managed/unmanaged interop follows the C ABI, not C++, so signatures with empty struct fields should
// not be used in any real-world interop calls.
using System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using Xunit;
public static class Program
{
public static bool IsSystemV =>
(RuntimeInformation.ProcessArchitecture == Architecture.X64) &&
!RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
public static bool IsRiscV64 => RuntimeInformation.ProcessArchitecture is Architecture.RiscV64;
public static bool IsArm32 => RuntimeInformation.ProcessArchitecture is Architecture.Arm;
public static bool IsArm64Or32 =>
RuntimeInformation.ProcessArchitecture is Architecture.Arm64 or Architecture.Arm;
public static bool IsArm64 => RuntimeInformation.ProcessArchitecture is Architecture.Arm64;
public const string SystemVPassNoClassEightbytes = "https://github.com/dotnet/runtime/issues/104098";
public const string RiscVClangEmptyStructsIgnored = "https://github.com/llvm/llvm-project/issues/97285";
public const string Arm32ClangEmptyStructsIgnored = "https://github.com/llvm/llvm-project/issues/98159";
public const string ProblemsWithEmptyStructPassing = "https://github.com/dotnet/runtime/issues/104369";
public struct Empty
{
}
#region Empty_SanityTests
[DllImport("EmptyStructsLib")]
public static extern int Echo_Empty_Sanity(int i0, float f0, Empty e, int i1, float f1);
[MethodImpl(MethodImplOptions.NoInlining)]
public static int Echo_Empty_Sanity_Managed(int i0, float f0, Empty e, int i1, float f1)
{
return i0 + (int)f0 + i1 + (int)f1;
}
[Fact]
[ActiveIssue(RiscVClangEmptyStructsIgnored, typeof(Program), nameof(IsRiscV64))]
[ActiveIssue(Arm32ClangEmptyStructsIgnored, typeof(Program), nameof(IsArm32))]
[ActiveIssue(SystemVPassNoClassEightbytes, typeof(Program), nameof(IsSystemV))]
[ActiveIssue(ProblemsWithEmptyStructPassing, typeof(Program), nameof(IsArm64))]
public static void Test_Empty_Sanity()
{
Empty empty = new Empty{};
int native = Echo_Empty_Sanity(-2, 3f, empty, -3, 2f);
int managed = Echo_Empty_Sanity_Managed(-2, 3f, empty, -3, 2f);
Assert.Equal(0, native);
Assert.Equal(0, managed);
}
[Fact]
[ActiveIssue(RiscVClangEmptyStructsIgnored, typeof(Program), nameof(IsRiscV64))]
[ActiveIssue(Arm32ClangEmptyStructsIgnored, typeof(Program), nameof(IsArm32))]
[ActiveIssue(SystemVPassNoClassEightbytes, typeof(Program), nameof(IsSystemV))]
[ActiveIssue(ProblemsWithEmptyStructPassing, typeof(Program), nameof(IsArm64))]
public static void Test_Empty_ByReflection_Sanity()
{
Empty empty = new Empty{};
int native = (int)typeof(Program).GetMethod("Echo_Empty_Sanity").Invoke(
null, new object[] {-2, 3f, empty, -3, 2f});
int managed = (int)typeof(Program).GetMethod("Echo_Empty_Sanity_Managed").Invoke(
null, new object[] {-2, 3f, empty, -3, 2f});
Assert.Equal(0, native);
Assert.Equal(0, managed);
}
#endregion
#region IntEmpty_SystemVTests
public struct IntEmpty
{
public int Int0;
public Empty Empty0;
public static IntEmpty Get()
=> new IntEmpty { Int0 = 0xBabc1a };
public override bool Equals(object other)
=> other is IntEmpty o && Int0 == o.Int0;
public override string ToString()
=> $"{{Int0:{Int0:x}}}";
}
[DllImport("EmptyStructsLib")]
public static extern IntEmpty Echo_IntEmpty_SysV(int i0, float f0, IntEmpty val, int i1, float f1);
[MethodImpl(MethodImplOptions.NoInlining)]
public static IntEmpty Echo_IntEmpty_SysV_Managed(int i0, float f0, IntEmpty val, int i1, float f1)
{
val.Int0 += i1 + (int)f1;
return val;
}
[Fact]
public static void Test_IntEmpty_SysV()
{
IntEmpty expected = IntEmpty.Get();
IntEmpty native = Echo_IntEmpty_SysV(0, 0f, expected, 1, -1f);
IntEmpty managed = Echo_IntEmpty_SysV_Managed(0, 0f, expected, 1, -1f);
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
[Fact]
public static void Test_IntEmpty_ByReflection_SysV()
{
var expected = (IntEmpty)typeof(IntEmpty).GetMethod("Get").Invoke(null, new object[] {});
var native = (IntEmpty)typeof(Program).GetMethod("Echo_IntEmpty_SysV").Invoke(
null, new object[] {0, 0f, expected, 1, -1f});
var managed = (IntEmpty)typeof(Program).GetMethod("Echo_IntEmpty_SysV_Managed").Invoke(
null, new object[] {0, 0f, expected, 1, -1f});
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
#endregion
#region IntEmptyPair_SystemVTests
public struct IntEmptyPair
{
public IntEmpty IntEmpty0;
public IntEmpty IntEmpty1;
public static IntEmptyPair Get()
=> new IntEmptyPair { IntEmpty0 = IntEmpty.Get(), IntEmpty1 = IntEmpty.Get() };
public override bool Equals(object other)
=> other is IntEmptyPair o && IntEmpty0.Equals(o.IntEmpty0) && IntEmpty1.Equals(o.IntEmpty1);
public override string ToString()
=> $"{{IntEmpty0:{IntEmpty0}, IntEmpty1:{IntEmpty1}}}";
}
[DllImport("EmptyStructsLib")]
public static extern IntEmptyPair Echo_IntEmptyPair_SysV(int i0, float f0, IntEmptyPair val, int i1, float f1);
[MethodImpl(MethodImplOptions.NoInlining)]
public static IntEmptyPair Echo_IntEmptyPair_SysV_Managed(int i0, float f0, IntEmptyPair val, int i1, float f1)
{
val.IntEmpty0.Int0 += i1 + (int)f1;
return val;
}
[Fact]
public static void Test_IntEmptyPair_SysV()
{
IntEmptyPair expected = IntEmptyPair.Get();
IntEmptyPair native = Echo_IntEmptyPair_SysV(0, 0f, expected, 1, -1f);
IntEmptyPair managed = Echo_IntEmptyPair_SysV_Managed(0, 0f, expected, 1, -1f);
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
[Fact]
public static void Test_IntEmptyPair_ByReflection_SysV()
{
var expected = IntEmptyPair.Get();
var native = (IntEmptyPair)typeof(Program).GetMethod("Echo_IntEmptyPair_SysV").Invoke(
null, new object[] {0, 0f, expected, 1, -1f});
var managed = (IntEmptyPair)typeof(Program).GetMethod("Echo_IntEmptyPair_SysV_Managed").Invoke(
null, new object[] {0, 0f, expected, 1, -1f});
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
#endregion
#region EmptyFloatIntInt_SystemVTests
public struct EmptyFloatIntInt
{
public Empty Empty0;
public float Float0;
public int Int0;
public int Int1;
public static EmptyFloatIntInt Get()
=> new EmptyFloatIntInt { Float0 = 2.71828f, Int0 = 0xBabc1a, Int1 = 0xC10c1a };
public override bool Equals(object other)
=> other is EmptyFloatIntInt o && Float0 == o.Float0 && Int0 == o.Int0 && Int1 == o.Int1;
public override string ToString()
=> $"{{Float0:{Float0}, Int0:{Int0:x}, Int1:{Int1:x}}}";
}
[DllImport("EmptyStructsLib")]
public static extern EmptyFloatIntInt Echo_EmptyFloatIntInt_SysV(
int i0, float f0, EmptyFloatIntInt val, int i1, float f1);
[MethodImpl(MethodImplOptions.NoInlining)]
public static EmptyFloatIntInt Echo_EmptyFloatIntInt_SysV_Managed(
int i0, float f0, EmptyFloatIntInt val, int i1, float f1)
{
val.Float0 += (float)i1 + f1;
return val;
}
[Fact]
public static void Test_EmptyFloatIntInt_SysV()
{
EmptyFloatIntInt expected = EmptyFloatIntInt.Get();
EmptyFloatIntInt native = Echo_EmptyFloatIntInt_SysV(0, 0f, expected, 1, -1f);
EmptyFloatIntInt managed = Echo_EmptyFloatIntInt_SysV_Managed(0, 0f, expected, 1, -1f);
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
[Fact]
public static void Test_EmptyFloatIntInt_ByReflection_SysV()
{
var expected = EmptyFloatIntInt.Get();
var native = (EmptyFloatIntInt)typeof(Program).GetMethod("Echo_EmptyFloatIntInt_SysV").Invoke(
null, new object[] {0, 0f, expected, 1, -1f});
var managed = (EmptyFloatIntInt)typeof(Program).GetMethod("Echo_EmptyFloatIntInt_SysV_Managed").Invoke(
null, new object[] {0, 0f, expected, 1, -1f});
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
#endregion
#region FloatFloatEmptyFloat_SystemVTests
public struct FloatFloatEmptyFloat
{
public float Float0;
public float Float1;
public Empty Empty0;
public float Float2;
public static FloatFloatEmptyFloat Get()
=> new FloatFloatEmptyFloat { Float0 = 2.71828f, Float1 = 3.14159f, Float2 = 1.61803f };
public override bool Equals(object other)
=> other is FloatFloatEmptyFloat o && Float0 == o.Float0 && Float1 == o.Float1 && Float2 == o.Float2;
public override string ToString()
=> $"{{Float0:{Float0}, Float1:{Float1}, Float2:{Float2}}}";
}
[DllImport("EmptyStructsLib")]
public static extern FloatFloatEmptyFloat Echo_FloatFloatEmptyFloat_SysV(
int i0, float f0, FloatFloatEmptyFloat val, int i1, float f1);
[MethodImpl(MethodImplOptions.NoInlining)]
public static FloatFloatEmptyFloat Echo_FloatFloatEmptyFloat_SysV_Managed(
int i0, float f0, FloatFloatEmptyFloat val, int i1, float f1)
{
val.Float2 += (float)i1 + f1;
return val;
}
[Fact]
public static void Test_FloatFloatEmptyFloat_SysV()
{
FloatFloatEmptyFloat expected = FloatFloatEmptyFloat.Get();
FloatFloatEmptyFloat native = Echo_FloatFloatEmptyFloat_SysV(0, 0f, expected, 1, -1f);
FloatFloatEmptyFloat managed = Echo_FloatFloatEmptyFloat_SysV_Managed(0, 0f, expected, 1, -1f);
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
[Fact]
public static void Test_FloatFloatEmptyFloat_ByReflection_SysV()
{
var expected = FloatFloatEmptyFloat.Get();
var native = (FloatFloatEmptyFloat)typeof(Program).GetMethod("Echo_FloatFloatEmptyFloat_SysV").Invoke(
null, new object[] {0, 0f, expected, 1, -1f});
var managed = (FloatFloatEmptyFloat)typeof(Program).GetMethod("Echo_FloatFloatEmptyFloat_SysV_Managed").Invoke(
null, new object[] {0, 0f, expected, 1, -1f});
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
#endregion
public struct Eight<T>
{
public T E0, E1, E2, E3, E4, E5, E6, E7;
}
#region Empty8Float_RiscVTests
public struct Empty8Float
{
public Eight<Empty> EightEmpty0;
public float Float0;
public static Empty8Float Get()
=> new Empty8Float { Float0 = 2.71828f };
public override bool Equals(object other)
=> other is Empty8Float o && Float0 == o.Float0;
public override string ToString()
=> $"{{Float0:{Float0}}}";
}
[DllImport("EmptyStructsLib")]
public static extern Empty8Float Echo_Empty8Float_RiscV(
int a0, float fa0, Empty8Float fa1, int a1, float fa2);
[MethodImpl(MethodImplOptions.NoInlining)]
public static Empty8Float Echo_Empty8Float_RiscV_Managed(
int a0, float fa0, Empty8Float fa1, int a1, float fa2)
{
fa1.Float0 += (float)a1 + fa2;
return fa1;
}
[Fact, ActiveIssue(SystemVPassNoClassEightbytes, typeof(Program), nameof(IsSystemV))]
public static void Test_Empty8Float_RiscV()
{
Empty8Float expected = Empty8Float.Get();
Empty8Float native = Echo_Empty8Float_RiscV(0, 0f, expected, -1, 1f);
Empty8Float managed = Echo_Empty8Float_RiscV_Managed(0, 0f, expected, -1, 1f);
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
[Fact, ActiveIssue(SystemVPassNoClassEightbytes, typeof(Program), nameof(IsSystemV))]
public static void Test_Empty8Float_ByReflection_RiscV()
{
var expected = Empty8Float.Get();
var native = (Empty8Float)typeof(Program).GetMethod("Echo_Empty8Float_RiscV").Invoke(
null, new object[] {0, 0f, expected, -1, 1f});
var managed = (Empty8Float)typeof(Program).GetMethod("Echo_Empty8Float_RiscV_Managed").Invoke(
null, new object[] {0, 0f, expected, -1, 1f});
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
[DllImport("EmptyStructsLib")]
public static extern Empty8Float Echo_Empty8Float_InIntegerRegs_RiscV(
int a0,
float fa0, float fa1, float fa2, float fa3, float fa4, float fa5, float fa6, float fa7,
Empty8Float a1_a2, int a3, float a4);
[MethodImpl(MethodImplOptions.NoInlining)]
public static Empty8Float Echo_Empty8Float_InIntegerRegs_RiscV_Managed(
int a0,
float fa0, float fa1, float fa2, float fa3, float fa4, float fa5, float fa6, float fa7,
Empty8Float a1_a2, int a3, float a4)
{
a1_a2.Float0 += (float)a3 + a4;
return a1_a2;
}
[Fact, ActiveIssue(SystemVPassNoClassEightbytes, typeof(Program), nameof(IsSystemV))]
public static void Test_Empty8Float_InIntegerRegs_RiscV()
{
Empty8Float expected = Empty8Float.Get();
Empty8Float native = Echo_Empty8Float_InIntegerRegs_RiscV(
0, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 1, -1f);
Empty8Float managed = Echo_Empty8Float_InIntegerRegs_RiscV_Managed(
0, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 1, -1f);
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
[Fact, ActiveIssue(SystemVPassNoClassEightbytes, typeof(Program), nameof(IsSystemV))]
public static void Test_Empty8Float_InIntegerRegs_ByReflection_RiscV()
{
var expected = Empty8Float.Get();
var native = (Empty8Float)typeof(Program).GetMethod("Echo_Empty8Float_InIntegerRegs_RiscV").Invoke(
null, new object[] {0, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 1, -1f});
var managed = (Empty8Float)typeof(Program).GetMethod("Echo_Empty8Float_InIntegerRegs_RiscV_Managed").Invoke(
null, new object[] {0, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 1, -1f});
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
[DllImport("EmptyStructsLib")]
public static extern Empty8Float Echo_Empty8Float_Split_RiscV(
int a0, int a1, int a2, int a3, int a4, int a5, int a6,
float fa0, float fa1, float fa2, float fa3, float fa4, float fa5, float fa6, float fa7,
Empty8Float a7_stack0, int stack1, float stack2);
[MethodImpl(MethodImplOptions.NoInlining)]
public static Empty8Float Echo_Empty8Float_Split_RiscV_Managed(
int a0, int a1, int a2, int a3, int a4, int a5, int a6,
float fa0, float fa1, float fa2, float fa3, float fa4, float fa5, float fa6, float fa7,
Empty8Float a7_stack0, int stack1, float stack2)
{
a7_stack0.Float0 += (float)stack1 + stack2;
return a7_stack0;
}
[Fact, ActiveIssue(SystemVPassNoClassEightbytes, typeof(Program), nameof(IsSystemV))]
public static void Test_Empty8Float_Split_RiscV()
{
Empty8Float expected = Empty8Float.Get();
Empty8Float native = Echo_Empty8Float_Split_RiscV(
0, 1, 2, 3, 4, 5, 6, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 1, -1f);
Empty8Float managed = Echo_Empty8Float_Split_RiscV_Managed(
0, 1, 2, 3, 4, 5, 6, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 1, -1f);
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
[Fact, ActiveIssue(SystemVPassNoClassEightbytes, typeof(Program), nameof(IsSystemV))]
public static void Test_Empty8Float_Split_ByReflection_RiscV()
{
var expected = Empty8Float.Get();
var native = (Empty8Float)typeof(Program).GetMethod("Echo_Empty8Float_Split_RiscV").Invoke(
null, new object[] {0, 1, 2, 3, 4, 5, 6, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 1, -1f});
var managed = (Empty8Float)typeof(Program).GetMethod("Echo_Empty8Float_Split_RiscV_Managed").Invoke(
null, new object[] {0, 1, 2, 3, 4, 5, 6, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 1, -1f});
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
[DllImport("EmptyStructsLib")]
public static extern Empty8Float Echo_Empty8Float_OnStack_RiscV(
int a0, int a1, int a2, int a3, int a4, int a5, int a6, int a7,
float fa0, float fa1, float fa2, float fa3, float fa4, float fa5, float fa6, float fa7,
Empty8Float stack0_stack1, int stack2, float stack3);
[MethodImpl(MethodImplOptions.NoInlining)]
public static Empty8Float Echo_Empty8Float_OnStack_RiscV_Managed(
int a0, int a1, int a2, int a3, int a4, int a5, int a6, int a7,
float fa0, float fa1, float fa2, float fa3, float fa4, float fa5, float fa6, float fa7,
Empty8Float stack0_stack1, int stack2, float stack3)
{
stack0_stack1.Float0 += (float)stack2 + stack3;
return stack0_stack1;
}
[Fact, ActiveIssue(SystemVPassNoClassEightbytes, typeof(Program), nameof(IsSystemV))]
public static void Test_Empty8Float_OnStack_RiscV()
{
Empty8Float expected = Empty8Float.Get();
Empty8Float native = Echo_Empty8Float_OnStack_RiscV(
0, 1, 2, 3, 4, 5, 6, 7, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 1, -1f);
Empty8Float managed = Echo_Empty8Float_OnStack_RiscV_Managed(
0, 1, 2, 3, 4, 5, 6, 7, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 1, -1f);
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
[Fact, ActiveIssue(SystemVPassNoClassEightbytes, typeof(Program), nameof(IsSystemV))]
public static void Test_Empty8Float_OnStack_ByReflection_RiscV()
{
var expected = Empty8Float.Get();
var native = (Empty8Float)typeof(Program).GetMethod("Echo_Empty8Float_OnStack_RiscV").Invoke(
null, new object[] {0, 1, 2, 3, 4, 5, 6, 7, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 1, -1f});
var managed = (Empty8Float)typeof(Program).GetMethod("Echo_Empty8Float_OnStack_RiscV_Managed").Invoke(
null, new object[] {0, 1, 2, 3, 4, 5, 6, 7, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 1, -1f});
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
#endregion
#region FloatEmpty8Float_RiscVTests
public struct FloatEmpty8Float
{
public float Float0;
public Eight<Empty> EightEmpty0;
public float Float1;
public static FloatEmpty8Float Get()
=> new FloatEmpty8Float { Float0 = 2.71828f, Float1 = 3.14159f };
public override bool Equals(object other)
=> other is FloatEmpty8Float o && Float0 == o.Float0 && Float1 == o.Float1;
public override string ToString()
=> $"{{Float0:{Float0}, Float1:{Float1}}}";
}
[DllImport("EmptyStructsLib")]
public static extern FloatEmpty8Float Echo_FloatEmpty8Float_RiscV(
int a0, float fa0, FloatEmpty8Float fa1_fa2, int a1, float fa3);
[MethodImpl(MethodImplOptions.NoInlining)]
public static FloatEmpty8Float Echo_FloatEmpty8Float_RiscV_Managed(
int a0, float fa0, FloatEmpty8Float fa1_fa2, int a1, float fa3)
{
fa1_fa2.Float1 += (float)a1 + fa3;
return fa1_fa2;
}
[Fact]
public static void Test_FloatEmpty8Float_RiscV()
{
FloatEmpty8Float expected = FloatEmpty8Float.Get();
FloatEmpty8Float native = Echo_FloatEmpty8Float_RiscV(0, 0f, expected, -1, 1f);
FloatEmpty8Float managed = Echo_FloatEmpty8Float_RiscV_Managed(0, 0f, expected, -1, 1f);
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
[Fact]
public static void Test_FloatEmpty8Float_ByReflection_RiscV()
{
var expected = FloatEmpty8Float.Get();
var native = (FloatEmpty8Float)typeof(Program).GetMethod("Echo_FloatEmpty8Float_RiscV").Invoke(
null, new object[] {0, 0f, expected, -1, 1f});
var managed = (FloatEmpty8Float)typeof(Program).GetMethod("Echo_FloatEmpty8Float_RiscV_Managed").Invoke(
null, new object[] {0, 0f, expected, -1, 1f});
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
[DllImport("EmptyStructsLib")]
public static extern FloatEmpty8Float Echo_FloatEmpty8Float_InIntegerRegs_RiscV(
int a0,
float fa0, float fa1, float fa2, float fa3, float fa4, float fa5, float fa6, float fa7,
FloatEmpty8Float a1_a2, int a3, float a4);
[MethodImpl(MethodImplOptions.NoInlining)]
public static FloatEmpty8Float Echo_FloatEmpty8Float_InIntegerRegs_RiscV_Managed(
int a0,
float fa0, float fa1, float fa2, float fa3, float fa4, float fa5, float fa6, float fa7,
FloatEmpty8Float a1_a2, int a3, float a4)
{
a1_a2.Float0 += (float)a3 + a4;
return a1_a2;
}
[Fact]
public static void Test_FloatEmpty8Float_InIntegerRegs_RiscV()
{
FloatEmpty8Float expected = FloatEmpty8Float.Get();
FloatEmpty8Float native = Echo_FloatEmpty8Float_InIntegerRegs_RiscV(
0, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 1, -1f);
FloatEmpty8Float managed = Echo_FloatEmpty8Float_InIntegerRegs_RiscV_Managed(
0, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 1, -1f);
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
[Fact]
public static void Test_FloatEmpty8Float_InIntegerRegs_ByReflection_RiscV()
{
var expected = FloatEmpty8Float.Get();
var native = (FloatEmpty8Float)typeof(Program).GetMethod("Echo_FloatEmpty8Float_InIntegerRegs_RiscV").Invoke(
null, new object[] {0, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 1, -1f});
var managed = (FloatEmpty8Float)typeof(Program).GetMethod("Echo_FloatEmpty8Float_InIntegerRegs_RiscV_Managed").Invoke(
null, new object[] {0, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 1, -1f});
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
[DllImport("EmptyStructsLib")]
public static extern FloatEmpty8Float Echo_FloatEmpty8Float_Split_RiscV(
int a0, int a1, int a2, int a3, int a4, int a5, int a6,
float fa0, float fa1, float fa2, float fa3, float fa4, float fa5, float fa6, float fa7,
FloatEmpty8Float a7_stack0, int stack1, float stack2);
[MethodImpl(MethodImplOptions.NoInlining)]
public static FloatEmpty8Float Echo_FloatEmpty8Float_Split_RiscV_Managed(
int a0, int a1, int a2, int a3, int a4, int a5, int a6,
float fa0, float fa1, float fa2, float fa3, float fa4, float fa5, float fa6, float fa7,
FloatEmpty8Float a7_stack0, int stack1, float stack2)
{
a7_stack0.Float0 += (float)stack1 + stack2;
return a7_stack0;
}
[Fact]
public static void Test_FloatEmpty8Float_Split_RiscV()
{
FloatEmpty8Float expected = FloatEmpty8Float.Get();
FloatEmpty8Float native = Echo_FloatEmpty8Float_Split_RiscV(
0, 1, 2, 3, 4, 5, 6, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, -2, 2f);
FloatEmpty8Float managed = Echo_FloatEmpty8Float_Split_RiscV_Managed(
0, 1, 2, 3, 4, 5, 6, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, -2, 2f);
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
[Fact]
public static void Test_FloatEmpty8Float_Split_ByReflection_RiscV()
{
var expected = FloatEmpty8Float.Get();
var native = (FloatEmpty8Float)typeof(Program).GetMethod("Echo_FloatEmpty8Float_Split_RiscV").Invoke(
null, new object[] {0, 1, 2, 3, 4, 5, 6, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, -2, 2f});
var managed = (FloatEmpty8Float)typeof(Program).GetMethod("Echo_FloatEmpty8Float_Split_RiscV_Managed").Invoke(
null, new object[] {0, 1, 2, 3, 4, 5, 6, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, -2, 2f});
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
[DllImport("EmptyStructsLib")]
public static extern FloatEmpty8Float Echo_FloatEmpty8Float_OnStack_RiscV(
int a0, int a1, int a2, int a3, int a4, int a5, int a6, int a7,
float fa0, float fa1, float fa2, float fa3, float fa4, float fa5, float fa6, float fa7,
FloatEmpty8Float stack0_stack1, int stack2, float stack3);
[MethodImpl(MethodImplOptions.NoInlining)]
public static FloatEmpty8Float Echo_FloatEmpty8Float_OnStack_RiscV_Managed(
int a0, int a1, int a2, int a3, int a4, int a5, int a6, int a7,
float fa0, float fa1, float fa2, float fa3, float fa4, float fa5, float fa6, float fa7,
FloatEmpty8Float stack0_stack1, int stack2, float stack3)
{
stack0_stack1.Float1 += (float)stack2 + stack3;
return stack0_stack1;
}
[Fact]
public static void Test_FloatEmpty8Float_OnStack_RiscV()
{
FloatEmpty8Float expected = FloatEmpty8Float.Get();
FloatEmpty8Float native = Echo_FloatEmpty8Float_OnStack_RiscV(
0, 1, 2, 3, 4, 5, 6, 7, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 3, -3f);
FloatEmpty8Float managed = Echo_FloatEmpty8Float_OnStack_RiscV_Managed(
0, 1, 2, 3, 4, 5, 6, 7, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 3, -3f);
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
[Fact]
public static void Test_FloatEmpty8Float_OnStack_ByReflection_RiscV()
{
var expected = FloatEmpty8Float.Get();
var native = (FloatEmpty8Float)typeof(Program).GetMethod("Echo_FloatEmpty8Float_OnStack_RiscV").Invoke(
null, new object[] {0, 1, 2, 3, 4, 5, 6, 7, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 3, -3f});
var managed = (FloatEmpty8Float)typeof(Program).GetMethod("Echo_FloatEmpty8Float_OnStack_RiscV_Managed").Invoke(
null, new object[] {0, 1, 2, 3, 4, 5, 6, 7, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 3, -3f});
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
#endregion
#region FloatEmptyShort_RiscVTests
public struct FloatEmptyShort
{
public float Float0;
public Empty Empty0;
public short Short0;
public static FloatEmptyShort Get()
=> new FloatEmptyShort { Float0 = 2.71828f, Short0 = 0x1dea };
public override bool Equals(object other)
=> other is FloatEmptyShort o && Float0 == o.Float0 && Short0 == o.Short0;
public override string ToString()
=> $"{{Float0:{Float0}, Short0:{Short0}}}";
}
[DllImport("EmptyStructsLib")]
public static extern FloatEmptyShort Echo_FloatEmptyShort_RiscV(
int a0, float fa0, FloatEmptyShort fa1_a1, int a1, float fa2);
[MethodImpl(MethodImplOptions.NoInlining)]
public static FloatEmptyShort Echo_FloatEmptyShort_RiscV_Managed(
int a0, float fa0, FloatEmptyShort fa1_a1, int a1, float fa2)
{
fa1_a1.Short0 += (short)(a1 + (int)fa2);
return fa1_a1;
}
[Fact]
public static void Test_FloatEmptyShort_RiscV()
{
FloatEmptyShort expected = FloatEmptyShort.Get();
FloatEmptyShort native = Echo_FloatEmptyShort_RiscV(0, 0f, expected, -1, 1f);
FloatEmptyShort managed = Echo_FloatEmptyShort_RiscV_Managed(0, 0f, expected, -1, 1f);
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
[Fact]
public static void Test_FloatEmptyShort_ByReflection_RiscV()
{
var expected = FloatEmptyShort.Get();
var native = (FloatEmptyShort)typeof(Program).GetMethod("Echo_FloatEmptyShort_RiscV").Invoke(
null, new object[] {0, 0f, expected, -1, 1f});
var managed = (FloatEmptyShort)typeof(Program).GetMethod("Echo_FloatEmptyShort_RiscV_Managed").Invoke(
null, new object[] {0, 0f, expected, -1, 1f});
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
[DllImport("EmptyStructsLib")]
public static extern FloatEmptyShort Echo_FloatEmptyShort_InIntegerRegs_RiscV(
int a0,
float fa0, float fa1, float fa2, float fa3, float fa4, float fa5, float fa6, float fa7,
FloatEmptyShort a1_a2, int a3, float a4);
[MethodImpl(MethodImplOptions.NoInlining)]
public static FloatEmptyShort Echo_FloatEmptyShort_InIntegerRegs_RiscV_Managed(
int a0,
float fa0, float fa1, float fa2, float fa3, float fa4, float fa5, float fa6, float fa7,
FloatEmptyShort a1_a2, int a3, float a4)
{
a1_a2.Short0 += (short)(a3 + (int)a4);
return a1_a2;
}
[Fact]
public static void Test_FloatEmptyShort_InIntegerRegs_RiscV()
{
FloatEmptyShort expected = FloatEmptyShort.Get();
FloatEmptyShort native = Echo_FloatEmptyShort_InIntegerRegs_RiscV(
0, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 1, -1f);
FloatEmptyShort managed = Echo_FloatEmptyShort_InIntegerRegs_RiscV_Managed(
0, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 1, -1f);
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
[Fact]
public static void Test_FloatEmptyShort_InIntegerRegs_ByReflection_RiscV()
{
var expected = FloatEmptyShort.Get();
var native = (FloatEmptyShort)typeof(Program).GetMethod("Echo_FloatEmptyShort_InIntegerRegs_RiscV").Invoke(
null, new object[] {0, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 1, -1f});
var managed = (FloatEmptyShort)typeof(Program).GetMethod("Echo_FloatEmptyShort_InIntegerRegs_RiscV_Managed").Invoke(
null, new object[] {0, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 1, -1f});
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
[DllImport("EmptyStructsLib")]
public static extern FloatEmptyShort Echo_FloatEmptyShort_OnStack_RiscV(
int a0, int a1, int a2, int a3, int a4, int a5, int a6, int a7,
float fa0, float fa1, float fa2, float fa3, float fa4, float fa5, float fa6, float fa7,
FloatEmptyShort stack0, int stack1, float stack2);
[MethodImpl(MethodImplOptions.NoInlining)]
public static FloatEmptyShort Echo_FloatEmptyShort_OnStack_RiscV_Managed(
int a0, int a1, int a2, int a3, int a4, int a5, int a6, int a7,
float fa0, float fa1, float fa2, float fa3, float fa4, float fa5, float fa6, float fa7,
FloatEmptyShort stack0, int stack1, float stack2)
{
stack0.Short0 += (short)(stack1 + (int)stack2);
return stack0;
}
[Fact]
public static void Test_FloatEmptyShort_OnStack_RiscV()
{
FloatEmptyShort expected = FloatEmptyShort.Get();
FloatEmptyShort native = Echo_FloatEmptyShort_OnStack_RiscV(
0, 1, 2, 3, 4, 5, 6, 7, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 2, -2f);
FloatEmptyShort managed = Echo_FloatEmptyShort_OnStack_RiscV_Managed(
0, 1, 2, 3, 4, 5, 6, 7, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 2, -2f);
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
[Fact]
public static void Test_FloatEmptyShort_OnStack_ByReflection_RiscV()
{
var expected = FloatEmptyShort.Get();
var native = (FloatEmptyShort)typeof(Program).GetMethod("Echo_FloatEmptyShort_OnStack_RiscV").Invoke(
null, new object[] {0, 1, 2, 3, 4, 5, 6, 7, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 2, -2f});
var managed = (FloatEmptyShort)typeof(Program).GetMethod("Echo_FloatEmptyShort_OnStack_RiscV_Managed").Invoke(
null, new object[] {0, 1, 2, 3, 4, 5, 6, 7, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 2, -2f});
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
#endregion
#region EmptyFloatEmpty5Sbyte_RiscVTests
public struct EmptyFloatEmpty5Sbyte
{
public Empty Empty0;
public float Float0;
public Empty Empty1, Empty2, Empty3, Empty4, Empty5;
public sbyte Sbyte0;
public static EmptyFloatEmpty5Sbyte Get()
=> new EmptyFloatEmpty5Sbyte { Float0 = 2.71828f, Sbyte0 = -123 };
public override bool Equals(object other)
=> other is EmptyFloatEmpty5Sbyte o && Float0 == o.Float0 && Sbyte0 == o.Sbyte0;
public override string ToString()
=> $"{{Float0:{Float0}, Sbyte0:{Sbyte0}}}";
}
[DllImport("EmptyStructsLib")]
public static extern EmptyFloatEmpty5Sbyte Echo_EmptyFloatEmpty5Sbyte_RiscV(int a0, float fa0,
EmptyFloatEmpty5Sbyte fa1_a1, int a2, float fa2);
[MethodImpl(MethodImplOptions.NoInlining)]
public static EmptyFloatEmpty5Sbyte Echo_EmptyFloatEmpty5Sbyte_RiscV_Managed(int a0, float fa0,
EmptyFloatEmpty5Sbyte fa1_a1, int a2, float fa2)
{
fa1_a1.Float0 += (float)a2 + fa2;
return fa1_a1;
}
[Fact]
public static void Test_EmptyFloatEmpty5Sbyte_RiscV()
{
EmptyFloatEmpty5Sbyte expected = EmptyFloatEmpty5Sbyte.Get();
EmptyFloatEmpty5Sbyte native = Echo_EmptyFloatEmpty5Sbyte_RiscV(0, 0f, expected, -1, 1f);
EmptyFloatEmpty5Sbyte managed = Echo_EmptyFloatEmpty5Sbyte_RiscV_Managed(0, 0f, expected, -1, 1f);
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
[Fact]
public static void Test_EmptyFloatEmpty5Sbyte_ByReflection_RiscV()
{
var expected = EmptyFloatEmpty5Sbyte.Get();
var native = (EmptyFloatEmpty5Sbyte)typeof(Program).GetMethod("Echo_EmptyFloatEmpty5Sbyte_RiscV").Invoke(
null, new object[] {0, 0f, expected, -1, 1f});
var managed = (EmptyFloatEmpty5Sbyte)typeof(Program).GetMethod("Echo_EmptyFloatEmpty5Sbyte_RiscV_Managed").Invoke(
null, new object[] {0, 0f, expected, -1, 1f});
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
#endregion
#region EmptyFloatEmpty5Byte_RiscVTests
public struct EmptyFloatEmpty5Byte
{
public Empty Empty0;
public float Float0;
public Empty Empty1, Empty2, Empty3, Empty4, Empty5;
public byte Byte0;
public static EmptyFloatEmpty5Byte Get()
=> new EmptyFloatEmpty5Byte { Float0 = 2.71828f, Byte0 = 123 };
public override bool Equals(object other)
=> other is EmptyFloatEmpty5Byte o && Float0 == o.Float0 && Byte0 == o.Byte0;
public override string ToString()
=> $"{{Float0:{Float0}, Byte0:{Byte0}}}";
}
[DllImport("EmptyStructsLib")]
public static extern EmptyFloatEmpty5Byte Echo_EmptyFloatEmpty5Byte_RiscV(int a0, float fa0,
EmptyFloatEmpty5Byte fa1_a1, int a2, float fa2);
[MethodImpl(MethodImplOptions.NoInlining)]
public static EmptyFloatEmpty5Byte Echo_EmptyFloatEmpty5Byte_RiscV_Managed(int a0, float fa0,
EmptyFloatEmpty5Byte fa1_a1, int a2, float fa2)
{
fa1_a1.Float0 += (float)a2 + fa2;
return fa1_a1;
}
[Fact]
public static void Test_EmptyFloatEmpty5Byte_RiscV()
{
EmptyFloatEmpty5Byte expected = EmptyFloatEmpty5Byte.Get();
EmptyFloatEmpty5Byte native = Echo_EmptyFloatEmpty5Byte_RiscV(0, 0f, expected, -1, 1f);
EmptyFloatEmpty5Byte managed = Echo_EmptyFloatEmpty5Byte_RiscV_Managed(0, 0f, expected, -1, 1f);
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
[Fact]
public static void Test_EmptyFloatEmpty5Byte_ByReflection_RiscV()
{
var expected = EmptyFloatEmpty5Byte.Get();
var native = (EmptyFloatEmpty5Byte)typeof(Program).GetMethod("Echo_EmptyFloatEmpty5Byte_RiscV").Invoke(
null, new object[] {0, 0f, expected, -1, 1f});
var managed = (EmptyFloatEmpty5Byte)typeof(Program).GetMethod("Echo_EmptyFloatEmpty5Byte_RiscV_Managed").Invoke(
null, new object[] {0, 0f, expected, -1, 1f});
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
[DllImport("EmptyStructsLib")]
public static extern EmptyFloatEmpty5Byte Echo_EmptyFloatEmpty5Byte_InIntegerRegs_RiscV(
int a0,
float fa0, float fa1, float fa2, float fa3, float fa4, float fa5, float fa6, float fa7,
EmptyFloatEmpty5Byte a1_a2, int a3, float a4);
[MethodImpl(MethodImplOptions.NoInlining)]
public static EmptyFloatEmpty5Byte Echo_EmptyFloatEmpty5Byte_InIntegerRegs_RiscV_Managed(
int a0,
float fa0, float fa1, float fa2, float fa3, float fa4, float fa5, float fa6, float fa7,
EmptyFloatEmpty5Byte a1_a2, int a3, float a4)
{
a1_a2.Float0 += (float)a3 + a4;
return a1_a2;
}
[Fact]
public static void Test_EmptyFloatEmpty5Byte_InIntegerRegs_RiscV()
{
EmptyFloatEmpty5Byte expected = EmptyFloatEmpty5Byte.Get();
EmptyFloatEmpty5Byte native = Echo_EmptyFloatEmpty5Byte_InIntegerRegs_RiscV(
0, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 1, -1f);
EmptyFloatEmpty5Byte managed = Echo_EmptyFloatEmpty5Byte_InIntegerRegs_RiscV_Managed(
0, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 1, -1f);
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
[Fact]
public static void Test_EmptyFloatEmpty5Byte_InIntegerRegs_ByReflection_RiscV()
{
var expected = EmptyFloatEmpty5Byte.Get();
var native = (EmptyFloatEmpty5Byte)typeof(Program).GetMethod("Echo_EmptyFloatEmpty5Byte_InIntegerRegs_RiscV").Invoke(
null, new object[] {0, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 1, -1f});
var managed = (EmptyFloatEmpty5Byte)typeof(Program).GetMethod("Echo_EmptyFloatEmpty5Byte_InIntegerRegs_RiscV_Managed").Invoke(
null, new object[] {0, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 1, -1f});
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
[DllImport("EmptyStructsLib")]
public static extern EmptyFloatEmpty5Byte Echo_EmptyFloatEmpty5Byte_Split_RiscV(
int a0, int a1, int a2, int a3, int a4, int a5, int a6,
float fa0, float fa1, float fa2, float fa3, float fa4, float fa5, float fa6, float fa7,
EmptyFloatEmpty5Byte a7_stack0, int stack1, float stack2);
[MethodImpl(MethodImplOptions.NoInlining)]
public static EmptyFloatEmpty5Byte Echo_EmptyFloatEmpty5Byte_Split_RiscV_Managed(
int a0, int a1, int a2, int a3, int a4, int a5, int a6,
float fa0, float fa1, float fa2, float fa3, float fa4, float fa5, float fa6, float fa7,
EmptyFloatEmpty5Byte a7_stack0, int stack1, float stack2)
{
a7_stack0.Float0 += (float)stack1 + stack2;
return a7_stack0;
}
[Fact]
public static void Test_EmptyFloatEmpty5Byte_Split_RiscV()
{
EmptyFloatEmpty5Byte expected = EmptyFloatEmpty5Byte.Get();
EmptyFloatEmpty5Byte native = Echo_EmptyFloatEmpty5Byte_Split_RiscV(
0, 1, 2, 3, 4, 5, 6, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 1, -1f);
EmptyFloatEmpty5Byte managed = Echo_EmptyFloatEmpty5Byte_Split_RiscV_Managed(
0, 1, 2, 3, 4, 5, 6, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 1, -1f);
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
[Fact]
public static void Test_EmptyFloatEmpty5Byte_Split_ByReflection_RiscV()
{
var expected = EmptyFloatEmpty5Byte.Get();
var native = (EmptyFloatEmpty5Byte)typeof(Program).GetMethod("Echo_EmptyFloatEmpty5Byte_Split_RiscV").Invoke(
null, new object[] {0, 1, 2, 3, 4, 5, 6, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 1, -1f});
var managed = (EmptyFloatEmpty5Byte)typeof(Program).GetMethod("Echo_EmptyFloatEmpty5Byte_Split_RiscV_Managed").Invoke(
null, new object[] {0, 1, 2, 3, 4, 5, 6, 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, expected, 1, -1f});
Assert.Equal(expected, native);
Assert.Equal(expected, managed);
}
[DllImport("EmptyStructsLib")]
public static extern EmptyFloatEmpty5Byte Echo_EmptyFloatEmpty5Byte_OnStack_RiscV(
int a0, int a1, int a2, int a3, int a4, int a5, int a6, int a7,
float fa0, float fa1, float fa2, float fa3, float fa4, float fa5, float fa6, float fa7,
EmptyFloatEmpty5Byte stack0_stack1, int stack2, float stack3);
[MethodImpl(MethodImplOptions.NoInlining)]
public static EmptyFloatEmpty5Byte Echo_EmptyFloatEmpty5Byte_OnStack_RiscV_Managed(
int a0, int a1, int a2, int a3, int a4, int a5, int a6, int a7,
float fa0, float fa1, float fa2, float fa3, float fa4, float fa5, float fa6, float fa7,
EmptyFloatEmpty5Byte stack0_stack1, int stack2, float stack3)
{
stack0_stack1.Float0 += (float)stack2 + stack3;
return stack0_stack1;
}
[Fact]