-
Notifications
You must be signed in to change notification settings - Fork 4.9k
/
Copy pathhwintrinsic.cpp
2408 lines (2157 loc) · 129 KB
/
hwintrinsic.cpp
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.
#include "jitpch.h"
#include "hwintrinsic.h"
#ifdef FEATURE_HW_INTRINSICS
static const HWIntrinsicInfo hwIntrinsicInfoArray[] = {
// clang-format off
#if defined(TARGET_XARCH)
#define HARDWARE_INTRINSIC(isa, name, size, numarg, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, category, flag) \
{ \
/* name */ #name, \
/* flags */ static_cast<HWIntrinsicFlag>(flag), \
/* id */ NI_##isa##_##name, \
/* ins */ t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, \
/* isa */ InstructionSet_##isa, \
/* simdSize */ size, \
/* numArgs */ numarg, \
/* category */ category \
},
#include "hwintrinsiclistxarch.h"
#elif defined (TARGET_ARM64)
#define HARDWARE_INTRINSIC(isa, name, size, numarg, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, category, flag) \
{ \
/* name */ #name, \
/* flags */ static_cast<HWIntrinsicFlag>(flag), \
/* id */ NI_##isa##_##name, \
/* ins */ t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, \
/* isa */ InstructionSet_##isa, \
/* simdSize */ size, \
/* numArgs */ numarg, \
/* category */ category \
},
#include "hwintrinsiclistarm64.h"
#else
#error Unsupported platform
#endif
// clang-format on
};
//------------------------------------------------------------------------
// lookup: Gets the HWIntrinsicInfo associated with a given NamedIntrinsic
//
// Arguments:
// id -- The NamedIntrinsic associated with the HWIntrinsic to lookup
//
// Return Value:
// The HWIntrinsicInfo associated with id
const HWIntrinsicInfo& HWIntrinsicInfo::lookup(NamedIntrinsic id)
{
assert(id != NI_Illegal);
assert(id > NI_HW_INTRINSIC_START);
assert(id < NI_HW_INTRINSIC_END);
return hwIntrinsicInfoArray[id - NI_HW_INTRINSIC_START - 1];
}
#if defined(TARGET_XARCH)
const TernaryLogicInfo& TernaryLogicInfo::lookup(uint8_t control)
{
// This table is 768 bytes and is about as small as we can make it.
//
// The way the constants work is we have three keys:
// * A: 0xF0
// * B: 0xCC
// * C: 0xAA
//
// To compute the correct control byte, you simply perform the corresponding operation on these keys. So, if you
// wanted to do (A & B) ^ C, you would compute (0xF0 & 0xCC) ^ 0xAA or 0x6A.
//
// This table allows us to compute the inverse information, that is given a control, what are the operations it
// performs. This allows us to determine things like what operands are actually used (so we can correctly compute
// isRMW) and what operations are performed and in what order (such that we can do constant folding in the future).
//
// The total set of operations supported are:
// * true: AllBitsSet
// * false: Zero
// * not: ~value
// * and: left & right
// * nand: ~(left & right)
// * or: left | right
// * nor: ~(left | right)
// * xor: left ^ right
// * xnor: ~(left ^ right)
// * cndsel: a ? b : c; aka (B & A) | (C & ~A)
// * major: 0 if two+ input bits are 0
// * minor: 1 if two+ input bits are 0
// clang-format off
static const TernaryLogicInfo ternaryLogicFlags[256] = {
/* FALSE */ { TernaryLogicOperKind::False, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* norABC */ { TernaryLogicOperKind::Nor, TernaryLogicUseFlags::ABC, TernaryLogicOperKind::None, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* andCnorBA */ { TernaryLogicOperKind::Nor, TernaryLogicUseFlags::AB, TernaryLogicOperKind::And, TernaryLogicUseFlags::C, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* norBA */ { TernaryLogicOperKind::Nor, TernaryLogicUseFlags::AB, TernaryLogicOperKind::None, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* andBnorAC */ { TernaryLogicOperKind::Nor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::And, TernaryLogicUseFlags::B, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* norCA */ { TernaryLogicOperKind::Nor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::None, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* norAxnorBC */ { TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Nor, TernaryLogicUseFlags::A, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* norAandBC */ { TernaryLogicOperKind::And, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Nor, TernaryLogicUseFlags::A, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* norAnandBC */ { TernaryLogicOperKind::Nand, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Nor, TernaryLogicUseFlags::A, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* norAxorBC */ { TernaryLogicOperKind::Xor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Nor, TernaryLogicUseFlags::A, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* andC!A */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::A, TernaryLogicOperKind::And, TernaryLogicUseFlags::C, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* C?!A:norBA */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::A, TernaryLogicOperKind::Nor, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* andB!A */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::A, TernaryLogicOperKind::And, TernaryLogicUseFlags::B, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* B?!A:norAC */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::A, TernaryLogicOperKind::Nor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* norAnorBC */ { TernaryLogicOperKind::Nor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Nor, TernaryLogicUseFlags::A, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* !A */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::A, TernaryLogicOperKind::None, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* andAnorBC */ { TernaryLogicOperKind::Nor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::And, TernaryLogicUseFlags::A, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* norCB */ { TernaryLogicOperKind::Nor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::None, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* norBxnorAC */ { TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Nor, TernaryLogicUseFlags::B, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* norBandAC */ { TernaryLogicOperKind::And, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Nor, TernaryLogicUseFlags::B, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* norCxnorBA */ { TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Nor, TernaryLogicUseFlags::C, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* norCandBA */ { TernaryLogicOperKind::And, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Nor, TernaryLogicUseFlags::C, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* A?norBC:xorBC */ { TernaryLogicOperKind::Nor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Xor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* minorABC */ { TernaryLogicOperKind::Minor, TernaryLogicUseFlags::ABC, TernaryLogicOperKind::None, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* A?norBC:andBC */ { TernaryLogicOperKind::Nor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::And, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* A?norBC:xnorBC */ { TernaryLogicOperKind::Nor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* A?norBC:C */ { TernaryLogicOperKind::Nor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Select, TernaryLogicUseFlags::C, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* C?!A:!B */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::A, TernaryLogicOperKind::Not, TernaryLogicUseFlags::B, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* A?norBC:B */ { TernaryLogicOperKind::Nor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Select, TernaryLogicUseFlags::B, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* B?!A:!C */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::A, TernaryLogicOperKind::Not, TernaryLogicUseFlags::C, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* xorAorBC */ { TernaryLogicOperKind::Or, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Xor, TernaryLogicUseFlags::A, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* nandAorBC */ { TernaryLogicOperKind::Or, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Nand, TernaryLogicUseFlags::A, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* norBnandAC */ { TernaryLogicOperKind::Nand, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Nor, TernaryLogicUseFlags::B, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* norBxorAC */ { TernaryLogicOperKind::Xor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Nor, TernaryLogicUseFlags::B, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* andC!B */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::B, TernaryLogicOperKind::And, TernaryLogicUseFlags::C, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* C?!B:norBA */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::B, TernaryLogicOperKind::Nor, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* B?norAC:andAC */ { TernaryLogicOperKind::Nor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::And, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* B?norAC:xnorAC */ { TernaryLogicOperKind::Nor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* B?norAC:C */ { TernaryLogicOperKind::Nor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Select, TernaryLogicUseFlags::C, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* C?!B:!A */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::B, TernaryLogicOperKind::Not, TernaryLogicUseFlags::A, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* andCxorBA */ { TernaryLogicOperKind::Xor, TernaryLogicUseFlags::AB, TernaryLogicOperKind::And, TernaryLogicUseFlags::C, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* C?xorBA:norBA */ { TernaryLogicOperKind::Xor, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Nor, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* andCnandBA */ { TernaryLogicOperKind::Nand, TernaryLogicUseFlags::AB, TernaryLogicOperKind::And, TernaryLogicUseFlags::C, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* C?nandBA:norBA */ { TernaryLogicOperKind::Nand, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Nor, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* B?!A:andAC */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::A, TernaryLogicOperKind::And, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* B?!A:xnorAC */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::A, TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* B?!A:C */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::A, TernaryLogicOperKind::Select, TernaryLogicUseFlags::C, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* C?nandBA:!A */ { TernaryLogicOperKind::Nand, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Not, TernaryLogicUseFlags::A, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* andA!B */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::B, TernaryLogicOperKind::And, TernaryLogicUseFlags::A, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* A?!B:norBC */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::B, TernaryLogicOperKind::Nor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* norBnorAC */ { TernaryLogicOperKind::Nor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Nor, TernaryLogicUseFlags::B, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* !B */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::B, TernaryLogicOperKind::None, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* B?norAC:A */ { TernaryLogicOperKind::Nor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Select, TernaryLogicUseFlags::A, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* A?!B:!C */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::B, TernaryLogicOperKind::Not, TernaryLogicUseFlags::C, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* xorBorAC */ { TernaryLogicOperKind::Or, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Xor, TernaryLogicUseFlags::B, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* nandBorAC */ { TernaryLogicOperKind::Or, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Nand, TernaryLogicUseFlags::B, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* A?!B:andBC */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::B, TernaryLogicOperKind::And, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* A?!B:xnorBC */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::B, TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* A?!B:C */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::B, TernaryLogicOperKind::Select, TernaryLogicUseFlags::C, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* C?nandBA:!B */ { TernaryLogicOperKind::Nand, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Not, TernaryLogicUseFlags::B, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* xorBA */ { TernaryLogicOperKind::Xor, TernaryLogicUseFlags::AB, TernaryLogicOperKind::None, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* C?xorBA:nandBA */ { TernaryLogicOperKind::Xor, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Nand, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* A?!B:orBC */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::B, TernaryLogicOperKind::Or, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* nandBA */ { TernaryLogicOperKind::Nand, TernaryLogicUseFlags::AB, TernaryLogicOperKind::None, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* norCnandBA */ { TernaryLogicOperKind::Nand, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Nor, TernaryLogicUseFlags::C, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* norCxorBA */ { TernaryLogicOperKind::Xor, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Nor, TernaryLogicUseFlags::C, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* C?norBA:andBA */ { TernaryLogicOperKind::Nor, TernaryLogicUseFlags::AB, TernaryLogicOperKind::And, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* C?norBA:xnorBA */ { TernaryLogicOperKind::Nor, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* andB!C */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::C, TernaryLogicOperKind::And, TernaryLogicUseFlags::B, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* B?!C:norAC */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::C, TernaryLogicOperKind::Nor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* C?norBA:B */ { TernaryLogicOperKind::Nor, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Select, TernaryLogicUseFlags::B, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* B?!C:!A */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::C, TernaryLogicOperKind::Not, TernaryLogicUseFlags::A, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* andBxorAC */ { TernaryLogicOperKind::Xor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::And, TernaryLogicUseFlags::B, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* B?xorAC:norAC */ { TernaryLogicOperKind::Xor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Nor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* C?!A:andBA */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::A, TernaryLogicOperKind::And, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* B?xorAC:!A */ { TernaryLogicOperKind::Xor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Not, TernaryLogicUseFlags::A, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* andBnandAC */ { TernaryLogicOperKind::Nand, TernaryLogicUseFlags::AC, TernaryLogicOperKind::And, TernaryLogicUseFlags::B, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* B?nandAC:norAC */ { TernaryLogicOperKind::Nand, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Nor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* C?!A:B */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::A, TernaryLogicOperKind::Select, TernaryLogicUseFlags::B, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* B?nandAC:!A */ { TernaryLogicOperKind::Nand, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Not, TernaryLogicUseFlags::A, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* andA!C */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::C, TernaryLogicOperKind::And, TernaryLogicUseFlags::A, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* A?!C:norBC */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::C, TernaryLogicOperKind::Nor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* C?norBA:A */ { TernaryLogicOperKind::Nor, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Select, TernaryLogicUseFlags::A, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* A?!C:!B */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::C, TernaryLogicOperKind::Not, TernaryLogicUseFlags::B, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* norCnorBA */ { TernaryLogicOperKind::Nor, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Nor, TernaryLogicUseFlags::C, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* !C */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::C, TernaryLogicOperKind::None, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* xorCorBA */ { TernaryLogicOperKind::Or, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Xor, TernaryLogicUseFlags::C, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* nandCorBA */ { TernaryLogicOperKind::Or, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Nand, TernaryLogicUseFlags::C, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* A?!C:andBC */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::C, TernaryLogicOperKind::And, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* A?!C:xnorBC */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::C, TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* xorCA */ { TernaryLogicOperKind::Xor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::None, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* B?xorAC:nandAC */ { TernaryLogicOperKind::Xor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Nand, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* A?!C:B */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::C, TernaryLogicOperKind::Select, TernaryLogicUseFlags::B, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* B?nandAC:!C */ { TernaryLogicOperKind::Nand, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Not, TernaryLogicUseFlags::C, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* A?!C:orBC */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::C, TernaryLogicOperKind::Or, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* nandCA */ { TernaryLogicOperKind::Nand, TernaryLogicUseFlags::AC, TernaryLogicOperKind::None, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* andAxorBC */ { TernaryLogicOperKind::Xor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::And, TernaryLogicUseFlags::A, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* A?xorBC:norBC */ { TernaryLogicOperKind::Xor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Nor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* C?!B:andBA */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::B, TernaryLogicOperKind::And, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* A?xorBC:!B */ { TernaryLogicOperKind::Xor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Not, TernaryLogicUseFlags::B, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* B?!C:andAC */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::C, TernaryLogicOperKind::And, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* A?xorBC:!C */ { TernaryLogicOperKind::Xor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Not, TernaryLogicUseFlags::C, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* xorCB */ { TernaryLogicOperKind::Xor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::None, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* A?xorBC:nandBC */ { TernaryLogicOperKind::Xor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Nand, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* A?xorBC:andBC */ { TernaryLogicOperKind::Xor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::And, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* xnorABC */ { TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::ABC, TernaryLogicOperKind::None, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* xorCandBA */ { TernaryLogicOperKind::And, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Xor, TernaryLogicUseFlags::C, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* C?nandBA:xnorBA */ { TernaryLogicOperKind::Nand, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* xorBandAC */ { TernaryLogicOperKind::And, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Xor, TernaryLogicUseFlags::B, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* B?nandAC:xnorAC */ { TernaryLogicOperKind::Nand, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* B?nandAC:C */ { TernaryLogicOperKind::Nand, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Select, TernaryLogicUseFlags::C, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* nandAxnorBC */ { TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Nand, TernaryLogicUseFlags::A, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* andAnandBC */ { TernaryLogicOperKind::Nand, TernaryLogicUseFlags::BC, TernaryLogicOperKind::And, TernaryLogicUseFlags::A, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* A?nandBC:norBC */ { TernaryLogicOperKind::Nand, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Nor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* C?!B:A */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::B, TernaryLogicOperKind::Select, TernaryLogicUseFlags::A, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* A?nandBC:!B */ { TernaryLogicOperKind::Nand, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Not, TernaryLogicUseFlags::B, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* B?!C:A */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::C, TernaryLogicOperKind::Select, TernaryLogicUseFlags::A, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* A?nandBC:!C */ { TernaryLogicOperKind::Nand, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Not, TernaryLogicUseFlags::C, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* B?!C:orAC */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::C, TernaryLogicOperKind::Or, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* nandCB */ { TernaryLogicOperKind::Nand, TernaryLogicUseFlags::BC, TernaryLogicOperKind::None, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* xorAandBC */ { TernaryLogicOperKind::And, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Xor, TernaryLogicUseFlags::A, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* A?nandBC:xnorBC */ { TernaryLogicOperKind::Nand, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* A?nandBC:C */ { TernaryLogicOperKind::Nand, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Select, TernaryLogicUseFlags::C, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* nandBxnorAC */ { TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Nand, TernaryLogicUseFlags::B, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* A?nandBC:B */ { TernaryLogicOperKind::Nand, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Select, TernaryLogicUseFlags::B, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* nandCxnorBA */ { TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Nand, TernaryLogicUseFlags::C, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* A?nandBC:orBC */ { TernaryLogicOperKind::Nand, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Or, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* nandABC */ { TernaryLogicOperKind::Nand, TernaryLogicUseFlags::ABC, TernaryLogicOperKind::None, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* andABC */ { TernaryLogicOperKind::And, TernaryLogicUseFlags::ABC, TernaryLogicOperKind::None, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* A?andBC:norBC */ { TernaryLogicOperKind::And, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Nor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* andCxnorBA */ { TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::AB, TernaryLogicOperKind::And, TernaryLogicUseFlags::C, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* A?andBC:!B */ { TernaryLogicOperKind::And, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Not, TernaryLogicUseFlags::B, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* andBxnorAC */ { TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::And, TernaryLogicUseFlags::B, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* A?andBC:!C */ { TernaryLogicOperKind::And, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Not, TernaryLogicUseFlags::C, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* A?andBC:xorBC */ { TernaryLogicOperKind::And, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Xor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* xnorAandBC */ { TernaryLogicOperKind::And, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::A, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* andCB */ { TernaryLogicOperKind::And, TernaryLogicUseFlags::BC, TernaryLogicOperKind::None, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* B?C:norAC */ { TernaryLogicOperKind::Select, TernaryLogicUseFlags::C, TernaryLogicOperKind::Nor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* A?andBC:C */ { TernaryLogicOperKind::And, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Select, TernaryLogicUseFlags::C, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* B?C:!A */ { TernaryLogicOperKind::Select, TernaryLogicUseFlags::C, TernaryLogicOperKind::Not, TernaryLogicUseFlags::A, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* A?andBC:B */ { TernaryLogicOperKind::And, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Select, TernaryLogicUseFlags::B, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* C?B:!A */ { TernaryLogicOperKind::Select, TernaryLogicUseFlags::B, TernaryLogicOperKind::Not, TernaryLogicUseFlags::A, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* A?andBC:orBC */ { TernaryLogicOperKind::And, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Or, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* nandAnandBC */ { TernaryLogicOperKind::Nand, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Nand, TernaryLogicUseFlags::A, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* andAxnorBC */ { TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::And, TernaryLogicUseFlags::A, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* B?andAC:!C */ { TernaryLogicOperKind::And, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Not, TernaryLogicUseFlags::C, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* B?andAC:xorAC */ { TernaryLogicOperKind::And, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Xor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* xnorBandAC */ { TernaryLogicOperKind::And, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::B, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* C?andBA:xorBA */ { TernaryLogicOperKind::And, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Xor, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* xnorCandBA */ { TernaryLogicOperKind::And, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::C, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* xorABC */ { TernaryLogicOperKind::Xor, TernaryLogicUseFlags::ABC, TernaryLogicOperKind::None, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* A?xnorBC:nandBC */ { TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Nand, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* A?xnorBC:andBC */ { TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::And, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* xnorCB */ { TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::None, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* A?xnorBC:C */ { TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Select, TernaryLogicUseFlags::C, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* B?C:nandAC */ { TernaryLogicOperKind::Select, TernaryLogicUseFlags::C, TernaryLogicOperKind::Nand, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* A?xnorBC:B */ { TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Select, TernaryLogicUseFlags::B, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* C?B:nandBA */ { TernaryLogicOperKind::Select, TernaryLogicUseFlags::B, TernaryLogicOperKind::Nand, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* A?xnorBC:orBC */ { TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Or, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* nandAxorBC */ { TernaryLogicOperKind::Xor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Nand, TernaryLogicUseFlags::A, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* andCA */ { TernaryLogicOperKind::And, TernaryLogicUseFlags::AC, TernaryLogicOperKind::None, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* A?C:norBC */ { TernaryLogicOperKind::Select, TernaryLogicUseFlags::C, TernaryLogicOperKind::Nor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* B?andAC:C */ { TernaryLogicOperKind::And, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Select, TernaryLogicUseFlags::C, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* A?C:!B */ { TernaryLogicOperKind::Select, TernaryLogicUseFlags::C, TernaryLogicOperKind::Not, TernaryLogicUseFlags::B, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* B?xnorAC:andAC */ { TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::And, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* xnorCA */ { TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::None, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* A?C:xorBC */ { TernaryLogicOperKind::Select, TernaryLogicUseFlags::C, TernaryLogicOperKind::Xor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* A?C:nandBC */ { TernaryLogicOperKind::Select, TernaryLogicUseFlags::C, TernaryLogicOperKind::Nand, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* andCorAB */ { TernaryLogicOperKind::Or, TernaryLogicUseFlags::AB, TernaryLogicOperKind::And, TernaryLogicUseFlags::C, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* xnorCorBA */ { TernaryLogicOperKind::Or, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::C, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* C */ { TernaryLogicOperKind::Select, TernaryLogicUseFlags::C, TernaryLogicOperKind::None, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* orCnorBA */ { TernaryLogicOperKind::Nor, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Or, TernaryLogicUseFlags::C, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* A?C:B */ { TernaryLogicOperKind::Select, TernaryLogicUseFlags::C, TernaryLogicOperKind::Select, TernaryLogicUseFlags::B, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* C?orBA:!A */ { TernaryLogicOperKind::Or, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Not, TernaryLogicUseFlags::A, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* A?C:orBC */ { TernaryLogicOperKind::Select, TernaryLogicUseFlags::C, TernaryLogicOperKind::Or, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* orC!A */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::A, TernaryLogicOperKind::Or, TernaryLogicUseFlags::C, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* B?andAC:A */ { TernaryLogicOperKind::And, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Select, TernaryLogicUseFlags::A, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* C?A:!B */ { TernaryLogicOperKind::Select, TernaryLogicUseFlags::A, TernaryLogicOperKind::Not, TernaryLogicUseFlags::B, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* B?andAC:orAC */ { TernaryLogicOperKind::And, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Or, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* nandBnandAC */ { TernaryLogicOperKind::Nand, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Nand, TernaryLogicUseFlags::B, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* B?xnorAC:A */ { TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Select, TernaryLogicUseFlags::A, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* C?A:nandBA */ { TernaryLogicOperKind::Select, TernaryLogicUseFlags::A, TernaryLogicOperKind::Nand, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* B?xnorAC:orAC */ { TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Or, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* nandBxorAC */ { TernaryLogicOperKind::Xor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Nand, TernaryLogicUseFlags::B, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* B?C:A */ { TernaryLogicOperKind::Select, TernaryLogicUseFlags::C, TernaryLogicOperKind::Select, TernaryLogicUseFlags::A, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* C?orBA:!B */ { TernaryLogicOperKind::Or, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Not, TernaryLogicUseFlags::B, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* B?C:orAC */ { TernaryLogicOperKind::Select, TernaryLogicUseFlags::C, TernaryLogicOperKind::Or, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* orC!B */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::B, TernaryLogicOperKind::Or, TernaryLogicUseFlags::C, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* C?orBA:xorBA */ { TernaryLogicOperKind::Or, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Xor, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* C?orBA:nandBA */ { TernaryLogicOperKind::Or, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Nand, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* orCxorBA */ { TernaryLogicOperKind::Xor, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Or, TernaryLogicUseFlags::C, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* orCnandBA */ { TernaryLogicOperKind::Nand, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Or, TernaryLogicUseFlags::C, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* andBA */ { TernaryLogicOperKind::And, TernaryLogicUseFlags::AB, TernaryLogicOperKind::None, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* A?B:norBC */ { TernaryLogicOperKind::Select, TernaryLogicUseFlags::B, TernaryLogicOperKind::Nor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* C?xnorBA:andBA */ { TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::AB, TernaryLogicOperKind::And, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* xnorBA */ { TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::AB, TernaryLogicOperKind::None, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* C?andBA:B */ { TernaryLogicOperKind::And, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Select, TernaryLogicUseFlags::B, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* A?B:!C */ { TernaryLogicOperKind::Select, TernaryLogicUseFlags::B, TernaryLogicOperKind::Not, TernaryLogicUseFlags::C, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* A?B:xorBC */ { TernaryLogicOperKind::Select, TernaryLogicUseFlags::B, TernaryLogicOperKind::Xor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* A?B:nandBC */ { TernaryLogicOperKind::Select, TernaryLogicUseFlags::B, TernaryLogicOperKind::Nand, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* andBorAC */ { TernaryLogicOperKind::Or, TernaryLogicUseFlags::AC, TernaryLogicOperKind::And, TernaryLogicUseFlags::B, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* xnorBorAC */ { TernaryLogicOperKind::Or, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::B, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* A?B:C */ { TernaryLogicOperKind::Select, TernaryLogicUseFlags::B, TernaryLogicOperKind::Select, TernaryLogicUseFlags::C, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* B?orAC:!A */ { TernaryLogicOperKind::Or, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Not, TernaryLogicUseFlags::A, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* B */ { TernaryLogicOperKind::Select, TernaryLogicUseFlags::B, TernaryLogicOperKind::None, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* orBnorAC */ { TernaryLogicOperKind::Nor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Or, TernaryLogicUseFlags::B, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* A?B:orBC */ { TernaryLogicOperKind::Select, TernaryLogicUseFlags::B, TernaryLogicOperKind::Or, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* orB!A */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::A, TernaryLogicOperKind::Or, TernaryLogicUseFlags::B, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* C?andBA:A */ { TernaryLogicOperKind::And, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Select, TernaryLogicUseFlags::A, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* B?A:!C */ { TernaryLogicOperKind::Select, TernaryLogicUseFlags::A, TernaryLogicOperKind::Not, TernaryLogicUseFlags::C, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* B?A:xorAC */ { TernaryLogicOperKind::Select, TernaryLogicUseFlags::A, TernaryLogicOperKind::Xor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* B?A:nandAC */ { TernaryLogicOperKind::Select, TernaryLogicUseFlags::A, TernaryLogicOperKind::Nand, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* C?andBA:orBA */ { TernaryLogicOperKind::And, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Or, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* nandCnandBA */ { TernaryLogicOperKind::Nand, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Nand, TernaryLogicUseFlags::C, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* C?xnorBA:orBA */ { TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Or, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* nandCxorBA */ { TernaryLogicOperKind::Xor, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Nand, TernaryLogicUseFlags::C, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* C?B:A */ { TernaryLogicOperKind::Select, TernaryLogicUseFlags::B, TernaryLogicOperKind::Select, TernaryLogicUseFlags::A, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* B?orAC:!C */ { TernaryLogicOperKind::Or, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Not, TernaryLogicUseFlags::C, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* B?orAC:xorAC */ { TernaryLogicOperKind::Or, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Xor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* B?orAC:nandAC */ { TernaryLogicOperKind::Or, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Nand, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* C?B:orBA */ { TernaryLogicOperKind::Select, TernaryLogicUseFlags::B, TernaryLogicOperKind::Or, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* orB!C */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::C, TernaryLogicOperKind::Or, TernaryLogicUseFlags::B, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* orBxorAC */ { TernaryLogicOperKind::Xor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Or, TernaryLogicUseFlags::B, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* orBnandAC */ { TernaryLogicOperKind::Nand, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Or, TernaryLogicUseFlags::B, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* andAorBC */ { TernaryLogicOperKind::Or, TernaryLogicUseFlags::BC, TernaryLogicOperKind::And, TernaryLogicUseFlags::A, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* xnorAorBC */ { TernaryLogicOperKind::Or, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::A, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* B?A:C */ { TernaryLogicOperKind::Select, TernaryLogicUseFlags::A, TernaryLogicOperKind::Select, TernaryLogicUseFlags::C, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* A?orBC:!B */ { TernaryLogicOperKind::Or, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Not, TernaryLogicUseFlags::B, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* C?A:B */ { TernaryLogicOperKind::Select, TernaryLogicUseFlags::A, TernaryLogicOperKind::Select, TernaryLogicUseFlags::B, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* A?orBC:!C */ { TernaryLogicOperKind::Or, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Not, TernaryLogicUseFlags::C, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* A?orBC:xorBC */ { TernaryLogicOperKind::Or, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Xor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* A?orBC:nandBC */ { TernaryLogicOperKind::Or, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Nand, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* majorABC */ { TernaryLogicOperKind::Major, TernaryLogicUseFlags::ABC, TernaryLogicOperKind::None, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* A?orBC:xnorBC */ { TernaryLogicOperKind::Or, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::A },
/* orCandBA */ { TernaryLogicOperKind::And, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Or, TernaryLogicUseFlags::C, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* orCxnorBA */ { TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Or, TernaryLogicUseFlags::C, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* orBandAC */ { TernaryLogicOperKind::And, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Or, TernaryLogicUseFlags::B, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* orBxnorAC */ { TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Or, TernaryLogicUseFlags::B, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* orCB */ { TernaryLogicOperKind::Or, TernaryLogicUseFlags::BC, TernaryLogicOperKind::None, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* nandAnorBC */ { TernaryLogicOperKind::Nor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Nand, TernaryLogicUseFlags::A, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* A */ { TernaryLogicOperKind::Select, TernaryLogicUseFlags::A, TernaryLogicOperKind::None, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* orAnorBC */ { TernaryLogicOperKind::Nor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Or, TernaryLogicUseFlags::A, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* B?A:orAC */ { TernaryLogicOperKind::Select, TernaryLogicUseFlags::A, TernaryLogicOperKind::Or, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::B },
/* orA!B */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::B, TernaryLogicOperKind::Or, TernaryLogicUseFlags::A, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* C?A:orBA */ { TernaryLogicOperKind::Select, TernaryLogicUseFlags::A, TernaryLogicOperKind::Or, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Cond, TernaryLogicUseFlags::C },
/* orA!C */ { TernaryLogicOperKind::Not, TernaryLogicUseFlags::C, TernaryLogicOperKind::Or, TernaryLogicUseFlags::A, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* orAxorBC */ { TernaryLogicOperKind::Xor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Or, TernaryLogicUseFlags::A, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* orAnandBC */ { TernaryLogicOperKind::Nand, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Or, TernaryLogicUseFlags::A, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* orAandBC */ { TernaryLogicOperKind::And, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Or, TernaryLogicUseFlags::A, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* orAxnorBC */ { TernaryLogicOperKind::Xnor, TernaryLogicUseFlags::BC, TernaryLogicOperKind::Or, TernaryLogicUseFlags::A, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* orCA */ { TernaryLogicOperKind::Or, TernaryLogicUseFlags::AC, TernaryLogicOperKind::None, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* nandBnorAC */ { TernaryLogicOperKind::Nor, TernaryLogicUseFlags::AC, TernaryLogicOperKind::Nand, TernaryLogicUseFlags::B, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* orBA */ { TernaryLogicOperKind::Or, TernaryLogicUseFlags::AB, TernaryLogicOperKind::None, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* nandCnorBA */ { TernaryLogicOperKind::Nor, TernaryLogicUseFlags::AB, TernaryLogicOperKind::Nand, TernaryLogicUseFlags::C, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* orABC */ { TernaryLogicOperKind::Or, TernaryLogicUseFlags::ABC, TernaryLogicOperKind::None, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
/* TRUE */ { TernaryLogicOperKind::True, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None, TernaryLogicOperKind::None, TernaryLogicUseFlags::None },
};
// clang-format on
return ternaryLogicFlags[control];
}
//------------------------------------------------------------------------
// GetTernaryControlByte: Get the control byte for a TernaryLogic operation
// given the oper and two existing control bytes
//
// Arguments:
// oper -- the operation being performed
// op1 -- the control byte for op1
// op2 -- the control byte for op2
//
// Return Value:
// The new control byte evaluated from performing oper on op1 and op2
//
uint8_t TernaryLogicInfo::GetTernaryControlByte(genTreeOps oper, uint8_t op1, uint8_t op2)
{
switch (oper)
{
case GT_AND:
{
return static_cast<uint8_t>(op1 & op2);
}
case GT_AND_NOT:
{
return static_cast<uint8_t>(~op1 & op2);
}
case GT_OR:
{
return static_cast<uint8_t>(op1 | op2);
}
case GT_XOR:
{
return static_cast<uint8_t>(op1 ^ op2);
}
default:
{
unreached();
}
}
}
//------------------------------------------------------------------------
// GetTernaryControlByte: Get the control byte for a TernaryLogic operation
// given a ternary logic oper and two inputs
//
// Arguments:
// oper -- the operation being performed
// op1 -- the control byte for op1, this is ignored for unary oper
// op2 -- the control byte for op2
//
// Return Value:
// The new control byte evaluated from performing oper on op1 and op2
//
uint8_t TernaryLogicInfo::GetTernaryControlByte(TernaryLogicOperKind oper, uint8_t op1, uint8_t op2)
{
switch (oper)
{
case TernaryLogicOperKind::Select:
{
return op2;
}
case TernaryLogicOperKind::Not:
{
return ~op2;
}
case TernaryLogicOperKind::And:
{
return op1 & op2;
}
case TernaryLogicOperKind::Nand:
{
return ~(op1 & op2);
}
case TernaryLogicOperKind::Or:
{
return op1 | op2;
}
case TernaryLogicOperKind::Nor:
{
return ~(op1 | op2);
}
case TernaryLogicOperKind::Xor:
{
return op1 ^ op2;
}
case TernaryLogicOperKind::Xnor:
{
return ~(op1 ^ op2);
}
default:
{
unreached();
}
}
}
//------------------------------------------------------------------------
// GetTernaryControlByte: Get the control byte for a TernaryLogic operation
// given an existing info and three control bytes
//
// Arguments:
// info -- the info describing the operation being performed
// op1 -- the control byte for op1
// op2 -- the control byte for op2
// op3 -- the control byte for op3
//
// Return Value:
// The new control byte evaluated from performing info on op1, op2, and op3
//
uint8_t TernaryLogicInfo::GetTernaryControlByte(const TernaryLogicInfo& info, uint8_t op1, uint8_t op2, uint8_t op3)
{
uint8_t oper1Result;
switch (info.oper1Use)
{
case TernaryLogicUseFlags::None:
{
assert(info.oper2 == TernaryLogicOperKind::None);
assert(info.oper2Use == TernaryLogicUseFlags::None);
assert(info.oper3 == TernaryLogicOperKind::None);
assert(info.oper3Use == TernaryLogicUseFlags::None);
switch (info.oper1)
{
case TernaryLogicOperKind::False:
{
oper1Result = 0x00;
break;
}
case TernaryLogicOperKind::True:
{
oper1Result = 0xFF;
break;
}
default:
{
unreached();
}
}
break;
}
case TernaryLogicUseFlags::A:
{
oper1Result = GetTernaryControlByte(info.oper1, 0x00, op1);
break;
}
case TernaryLogicUseFlags::B:
{
oper1Result = GetTernaryControlByte(info.oper1, 0x00, op2);
break;
}
case TernaryLogicUseFlags::C:
{
oper1Result = GetTernaryControlByte(info.oper1, 0x00, op3);
break;
}
case TernaryLogicUseFlags::AB:
{
oper1Result = GetTernaryControlByte(info.oper1, op1, op2);
break;
}
case TernaryLogicUseFlags::AC:
{
oper1Result = GetTernaryControlByte(info.oper1, op1, op3);
break;
}
case TernaryLogicUseFlags::BC:
{
oper1Result = GetTernaryControlByte(info.oper1, op2, op3);
break;
}
case TernaryLogicUseFlags::ABC:
{
assert(info.oper2 == TernaryLogicOperKind::None);
assert(info.oper2Use == TernaryLogicUseFlags::None);
assert(info.oper3 == TernaryLogicOperKind::None);
assert(info.oper3Use == TernaryLogicUseFlags::None);
switch (info.oper1)
{
case TernaryLogicOperKind::Nor:
{
oper1Result = ~(op1 | op2 | op3);
break;
}
case TernaryLogicOperKind::Minor:
{
oper1Result = 0x17;
break;
}
case TernaryLogicOperKind::Xnor:
{
oper1Result = ~(op1 ^ op2 ^ op3);
break;
}
case TernaryLogicOperKind::Nand:
{
oper1Result = ~(op1 & op2 & op3);
break;
}
case TernaryLogicOperKind::And:
{
oper1Result = op1 & op2 & op3;
break;
}
case TernaryLogicOperKind::Xor:
{
oper1Result = op1 ^ op2 ^ op3;
break;
}
case TernaryLogicOperKind::Major:
{
oper1Result = 0xE8;
break;
}
case TernaryLogicOperKind::Or:
{
oper1Result = op1 | op2 | op3;
break;
}
default:
{
unreached();
}
}
break;
}
default:
{
unreached();
}
}
uint8_t oper2Result;
switch (info.oper2Use)
{
case TernaryLogicUseFlags::None:
{
assert(info.oper3 == TernaryLogicOperKind::None);
assert(info.oper3Use == TernaryLogicUseFlags::None);
oper2Result = oper1Result;
break;
}
case TernaryLogicUseFlags::A:
{
oper2Result = GetTernaryControlByte(info.oper2, oper1Result, op1);
break;
}
case TernaryLogicUseFlags::B:
{
oper2Result = GetTernaryControlByte(info.oper2, oper1Result, op2);
break;
}
case TernaryLogicUseFlags::C:
{
oper2Result = GetTernaryControlByte(info.oper2, oper1Result, op3);
break;
}
case TernaryLogicUseFlags::AB:
{
oper2Result = GetTernaryControlByte(info.oper2, op1, op2);
break;
}
case TernaryLogicUseFlags::AC:
{
oper2Result = GetTernaryControlByte(info.oper2, op1, op3);
break;
}
case TernaryLogicUseFlags::BC:
{
oper2Result = GetTernaryControlByte(info.oper2, op2, op3);
break;
}
default:
{
unreached();
}
}
uint8_t oper3Result;
switch (info.oper3Use)
{
case TernaryLogicUseFlags::None:
{
assert(info.oper3 == TernaryLogicOperKind::None);
oper3Result = oper2Result;
break;
}
case TernaryLogicUseFlags::A:
{
assert(info.oper3 == TernaryLogicOperKind::Cond);
oper3Result = (oper1Result & op1) | (oper2Result & ~op1);
break;
}
case TernaryLogicUseFlags::B:
{
assert(info.oper3 == TernaryLogicOperKind::Cond);
oper3Result = (oper1Result & op2) | (oper2Result & ~op2);
break;
}
case TernaryLogicUseFlags::C:
{
assert(info.oper3 == TernaryLogicOperKind::Cond);
oper3Result = (oper1Result & op3) | (oper2Result & ~op3);
break;
}
default:
{
unreached();
}
}
return oper3Result;
}
#endif // TARGET_XARCH
//------------------------------------------------------------------------
// getBaseJitTypeFromArgIfNeeded: Get simdBaseJitType of intrinsic from 1st or 2nd argument depending on the flag
//
// Arguments:
// intrinsic -- id of the intrinsic function.
// method -- method handle of the intrinsic function.
// sig -- signature of the intrinsic call.
// simdBaseJitType -- Predetermined simdBaseJitType, could be CORINFO_TYPE_UNDEF
//
// Return Value:
// The basetype of intrinsic of it can be fetched from 1st or 2nd argument, else return baseType unmodified.
//
CorInfoType Compiler::getBaseJitTypeFromArgIfNeeded(NamedIntrinsic intrinsic,
CORINFO_SIG_INFO* sig,
CorInfoType simdBaseJitType)
{
if (HWIntrinsicInfo::BaseTypeFromSecondArg(intrinsic) || HWIntrinsicInfo::BaseTypeFromFirstArg(intrinsic))
{
CORINFO_ARG_LIST_HANDLE arg = sig->args;
if (HWIntrinsicInfo::BaseTypeFromSecondArg(intrinsic))
{
arg = info.compCompHnd->getArgNext(arg);
}
CORINFO_CLASS_HANDLE argClass = info.compCompHnd->getArgClass(sig, arg);
simdBaseJitType = getBaseJitTypeAndSizeOfSIMDType(argClass);
if (simdBaseJitType == CORINFO_TYPE_UNDEF) // the argument is not a vector
{
CORINFO_CLASS_HANDLE tmpClass;
simdBaseJitType = strip(info.compCompHnd->getArgType(sig, arg, &tmpClass));
if (simdBaseJitType == CORINFO_TYPE_PTR)
{
simdBaseJitType = info.compCompHnd->getChildType(argClass, &tmpClass);
}
}
assert(simdBaseJitType != CORINFO_TYPE_UNDEF);
}
return simdBaseJitType;
}
struct HWIntrinsicIsaRange
{
NamedIntrinsic FirstId;
NamedIntrinsic LastId;
};
static const HWIntrinsicIsaRange hwintrinsicIsaRangeArray[] = {
// clang-format off
#if defined(TARGET_XARCH)
{ FIRST_NI_X86Base, LAST_NI_X86Base },
{ FIRST_NI_SSE, LAST_NI_SSE },
{ FIRST_NI_SSE2, LAST_NI_SSE2 },
{ FIRST_NI_SSE3, LAST_NI_SSE3 },
{ FIRST_NI_SSSE3, LAST_NI_SSSE3 },
{ FIRST_NI_SSE41, LAST_NI_SSE41 },
{ FIRST_NI_SSE42, LAST_NI_SSE42 },
{ FIRST_NI_AVX, LAST_NI_AVX },
{ FIRST_NI_AVX2, LAST_NI_AVX2 },
{ FIRST_NI_AES, LAST_NI_AES },
{ FIRST_NI_BMI1, LAST_NI_BMI1 },
{ FIRST_NI_BMI2, LAST_NI_BMI2 },
{ FIRST_NI_FMA, LAST_NI_FMA },
{ FIRST_NI_LZCNT, LAST_NI_LZCNT },
{ FIRST_NI_PCLMULQDQ, LAST_NI_PCLMULQDQ },
{ FIRST_NI_PCLMULQDQ_V256, LAST_NI_PCLMULQDQ_V256 },
{ FIRST_NI_PCLMULQDQ_V512, LAST_NI_PCLMULQDQ_V512 },
{ FIRST_NI_POPCNT, LAST_NI_POPCNT },
{ FIRST_NI_Vector128, LAST_NI_Vector128 },
{ FIRST_NI_Vector256, LAST_NI_Vector256 },
{ FIRST_NI_Vector512, LAST_NI_Vector512 },
{ FIRST_NI_AVXVNNI, LAST_NI_AVXVNNI },
{ NI_Illegal, NI_Illegal }, // MOVBE
{ FIRST_NI_X86Serialize, LAST_NI_X86Serialize },
{ NI_Illegal, NI_Illegal }, // EVEX
{ FIRST_NI_AVX512F, LAST_NI_AVX512F },
{ FIRST_NI_AVX512F_VL, LAST_NI_AVX512F_VL },
{ FIRST_NI_AVX512BW, LAST_NI_AVX512BW },
{ FIRST_NI_AVX512BW_VL, LAST_NI_AVX512BW_VL },
{ FIRST_NI_AVX512CD, LAST_NI_AVX512CD },
{ FIRST_NI_AVX512CD_VL, LAST_NI_AVX512CD_VL },
{ FIRST_NI_AVX512DQ, LAST_NI_AVX512DQ },
{ FIRST_NI_AVX512DQ_VL, LAST_NI_AVX512DQ_VL },
{ FIRST_NI_AVX512VBMI, LAST_NI_AVX512VBMI },
{ FIRST_NI_AVX512VBMI_VL, LAST_NI_AVX512VBMI_VL },
{ FIRST_NI_AVX10v1, LAST_NI_AVX10v1 },
{ FIRST_NI_AVX10v1_V512, LAST_NI_AVX10v1_V512 },
{ NI_Illegal, NI_Illegal }, // VectorT128
{ NI_Illegal, NI_Illegal }, // VectorT256
{ NI_Illegal, NI_Illegal }, // VectorT512
{ NI_Illegal, NI_Illegal }, // APX
{ FIRST_NI_AVX10v2, LAST_NI_AVX10v2 }, // AVX10v2
{ FIRST_NI_AVX10v2_V512, LAST_NI_AVX10v2_V512 }, // AVX10v2_V512
{ FIRST_NI_GFNI, LAST_NI_GFNI },
{ FIRST_NI_GFNI_V256, LAST_NI_GFNI_V256 },
{ FIRST_NI_GFNI_V512, LAST_NI_GFNI_V512 },
{ FIRST_NI_X86Base_X64, LAST_NI_X86Base_X64 },
{ FIRST_NI_SSE_X64, LAST_NI_SSE_X64 },
{ FIRST_NI_SSE2_X64, LAST_NI_SSE2_X64 },
{ NI_Illegal, NI_Illegal }, // SSE3_X64
{ NI_Illegal, NI_Illegal }, // SSSE3_X64
{ FIRST_NI_SSE41_X64, LAST_NI_SSE41_X64 },
{ FIRST_NI_SSE42_X64, LAST_NI_SSE42_X64 },
{ NI_Illegal, NI_Illegal }, // AVX_X64
{ NI_Illegal, NI_Illegal }, // AVX2_X64
{ NI_Illegal, NI_Illegal }, // AES_X64
{ FIRST_NI_BMI1_X64, LAST_NI_BMI1_X64 },
{ FIRST_NI_BMI2_X64, LAST_NI_BMI2_X64 },
{ NI_Illegal, NI_Illegal }, // FMA_X64
{ FIRST_NI_LZCNT_X64, LAST_NI_LZCNT_X64 },
{ NI_Illegal, NI_Illegal }, // PCLMULQDQ_X64
{ FIRST_NI_POPCNT_X64, LAST_NI_POPCNT_X64 },
{ NI_Illegal, NI_Illegal }, // AVXVNNI_X64
{ NI_Illegal, NI_Illegal }, // X86Serialize_X64
{ FIRST_NI_AVX512F_X64, LAST_NI_AVX512F_X64 },
{ NI_Illegal, NI_Illegal }, // AVX512BW_X64
{ NI_Illegal, NI_Illegal }, // AVX512CD_X64
{ NI_Illegal, NI_Illegal }, // AVX512DQ_X64
{ NI_Illegal, NI_Illegal }, // AVX512VBMI_X64
{ FIRST_NI_AVX10v1_X64, LAST_NI_AVX10v1_X64 },
{ NI_Illegal, NI_Illegal }, // AVX10v1_V512_X64
{ NI_Illegal, NI_Illegal }, // AVX10v2_X64
{ NI_Illegal, NI_Illegal }, // AVX10v2_V512_X64
{ NI_Illegal, NI_Illegal }, // GFNI_X64
#elif defined (TARGET_ARM64)
{ FIRST_NI_ArmBase, LAST_NI_ArmBase },
{ FIRST_NI_AdvSimd, LAST_NI_AdvSimd },
{ FIRST_NI_Aes, LAST_NI_Aes },
{ FIRST_NI_Crc32, LAST_NI_Crc32 },
{ FIRST_NI_Dp, LAST_NI_Dp },
{ FIRST_NI_Rdm, LAST_NI_Rdm },
{ FIRST_NI_Sha1, LAST_NI_Sha1 },
{ FIRST_NI_Sha256, LAST_NI_Sha256 },
{ NI_Illegal, NI_Illegal }, // Atomics
{ FIRST_NI_Vector64, LAST_NI_Vector64 },
{ FIRST_NI_Vector128, LAST_NI_Vector128 },
{ NI_Illegal, NI_Illegal }, // Dczva
{ NI_Illegal, NI_Illegal }, // Rcpc
{ NI_Illegal, NI_Illegal }, // VectorT128
{ NI_Illegal, NI_Illegal }, // Rcpc2
{ FIRST_NI_Sve, LAST_NI_Sve },
{ FIRST_NI_ArmBase_Arm64, LAST_NI_ArmBase_Arm64 },
{ FIRST_NI_AdvSimd_Arm64, LAST_NI_AdvSimd_Arm64 },
{ NI_Illegal, NI_Illegal }, // Aes_Arm64
{ FIRST_NI_Crc32_Arm64, LAST_NI_Crc32_Arm64 },
{ NI_Illegal, NI_Illegal }, // Dp_Arm64
{ FIRST_NI_Rdm_Arm64, LAST_NI_Rdm_Arm64 },
{ NI_Illegal, NI_Illegal }, // Sha1_Arm64
{ NI_Illegal, NI_Illegal }, // Sha256_Arm64
{ NI_Illegal, NI_Illegal }, // Sve_Arm64
#else
#error Unsupported platform
#endif
// clang-format on
};
#if defined(DEBUG)
static void ValidateHWIntrinsicInfo(CORINFO_InstructionSet isa, NamedIntrinsic ni, const HWIntrinsicInfo& info)
{
// We should have found the entry we expected to find here
assert(info.id == ni);
// It should belong to the expected ISA
assert(info.isa == isa);
if ((info.simdSize != -1) && (info.simdSize != 0))
{
// We should only have known SIMD sizes
#if defined(TARGET_ARM64)
assert((info.simdSize == 8) || (info.simdSize == 16));
#elif defined(TARGET_XARCH)
assert((info.simdSize == 16) || (info.simdSize == 32) || (info.simdSize == 64));
#else
unreached();
#endif
}
if (info.numArgs != -1)
{
// We should only have an expected number of arguments
#if defined(TARGET_ARM64) || defined(TARGET_XARCH)
assert((info.numArgs >= 0) && (info.numArgs <= 5));
#else
unreached();
#endif
}
// TODO: There's more we could validate here in terms of flags, instructions used, etc.
// Some of this is already done ad-hoc elsewhere throughout the JIT
}
static void ValidateHWIntrinsicIsaRange(CORINFO_InstructionSet isa, const HWIntrinsicIsaRange& isaRange)
{
// Both entries should be illegal if either is
if (isaRange.FirstId == NI_Illegal)
{
assert(isaRange.LastId == NI_Illegal);
return;
}
assert(isaRange.LastId != NI_Illegal);
// Both entries should belong to the expected ISA
assert(HWIntrinsicInfo::lookupIsa(isaRange.FirstId) == isa);
assert(HWIntrinsicInfo::lookupIsa(isaRange.LastId) == isa);
// The last ID should be the same as or after the first ID
assert(isaRange.FirstId <= isaRange.LastId);
// The ID before the range should not be part of the expected ISA
NamedIntrinsic prevId = static_cast<NamedIntrinsic>(isaRange.FirstId - 1);
assert((prevId == NI_HW_INTRINSIC_START) || (HWIntrinsicInfo::lookupIsa(prevId) != isa));
// The ID after the range should not be part of the expected ISA
NamedIntrinsic nextId = static_cast<NamedIntrinsic>(isaRange.LastId + 1);
#if defined(TARGET_ARM64)
assert((nextId == NI_HW_INTRINSIC_END) || (HWIntrinsicInfo::lookupIsa(nextId) != isa) ||
(nextId == SPECIAL_NI_Sve));
#else
assert((nextId == NI_HW_INTRINSIC_END) || (HWIntrinsicInfo::lookupIsa(nextId) != isa));
#endif
NamedIntrinsic ni = static_cast<NamedIntrinsic>(isaRange.FirstId);
const HWIntrinsicInfo* prevInfo = &HWIntrinsicInfo::lookup(ni);
ValidateHWIntrinsicInfo(isa, ni, *prevInfo);
size_t count = (isaRange.LastId - isaRange.FirstId) + 1;
for (size_t i = 1; i < count; i++)
{
ni = static_cast<NamedIntrinsic>(isaRange.FirstId + i);
const HWIntrinsicInfo* info = &HWIntrinsicInfo::lookup(ni);
ValidateHWIntrinsicInfo(isa, ni, *info);
// The current name should be sorted after the previous
assert(strcmp(info->name, prevInfo->name) > 0);
prevInfo = info;
}
}
static void ValidateHWIntrinsicIsaRangeArray()
{
for (size_t i = 0; i < ARRAY_SIZE(hwintrinsicIsaRangeArray); i++)
{
CORINFO_InstructionSet isa = static_cast<CORINFO_InstructionSet>(i + 1);
ValidateHWIntrinsicIsaRange(isa, hwintrinsicIsaRangeArray[i]);
}
}
#endif
//------------------------------------------------------------------------
// lookupId: Gets the NamedIntrinsic for a given method name and InstructionSet
//
// Arguments:
// comp -- The compiler
// sig -- The signature of the intrinsic
// className -- The name of the class associated with the HWIntrinsic to lookup
// methodName -- The name of the method associated with the HWIntrinsic to lookup
// enclosingClassName -- The name of the enclosing class of X64 classes
//
// Return Value:
// The NamedIntrinsic associated with methodName and isa
NamedIntrinsic HWIntrinsicInfo::lookupId(Compiler* comp,
CORINFO_SIG_INFO* sig,
const char* className,
const char* methodName,
const char* innerEnclosingClassName,
const char* outerEnclosingClassName)
{
#if defined(DEBUG)
static bool validationCompleted = false;
if (!validationCompleted)
{
ValidateHWIntrinsicIsaRangeArray();
validationCompleted = true;
}
#endif // DEBUG
// Signatures that have a 'this' parameter are illegal intrinsics.
if (sig->hasThis())
{