Jlm
Loading...
Searching...
No Matches
IntegerOperations.hpp
Go to the documentation of this file.
1/*
2 * Copyright 2025 Nico Reißmann <nico.reissmann@gmail.com>
3 * See COPYING for terms of redistribution.
4 */
5
6#ifndef JLM_LLVM_IR_OPERATORS_INTEGEROPERATIONS_HPP
7#define JLM_LLVM_IR_OPERATORS_INTEGEROPERATIONS_HPP
8
12#include <jlm/rvsdg/nullary.hpp>
13
14namespace jlm::llvm
15{
16
17// FIXME: Implement our own value representation instead of re-using the bitstring value
18// representation
20
25{
26public:
28
30 : NullaryOperation(rvsdg::BitType::Create(representation.nbits())),
31 Representation_(std::move(representation))
32 {}
33
34 std::unique_ptr<Operation>
35 copy() const override;
36
37 std::string
38 debug_string() const override;
39
40 bool
41 operator==(const Operation & other) const noexcept override;
42
43 [[nodiscard]] const IntegerValueRepresentation &
44 Representation() const noexcept
45 {
46 return Representation_;
47 }
48
49 static rvsdg::Node &
51 {
52 return rvsdg::CreateOpNode<IntegerConstantOperation>(region, std::move(representation));
53 }
54
55 static rvsdg::Node &
56 Create(rvsdg::Region & region, std::size_t numBits, std::int64_t value)
57 {
58 return Create(region, { numBits, value });
59 }
60
61private:
63};
64
69{
70public:
71 ~IntegerBinaryOperation() noexcept override;
72
74 const std::size_t numArgumentBits,
75 const std::size_t numResultBits) noexcept
77 { rvsdg::BitType::Create(numArgumentBits), rvsdg::BitType::Create(numArgumentBits) },
78 rvsdg::BitType::Create(numResultBits))
79 {}
80
81 [[nodiscard]] const rvsdg::BitType &
82 Type() const noexcept
83 {
84 return *util::assertedCast<const rvsdg::BitType>(argument(0).get());
85 }
86};
87
94{
95public:
96 ~IntegerAddOperation() noexcept override;
97
98 explicit IntegerAddOperation(const std::size_t numBits)
99 : IntegerBinaryOperation(numBits, numBits)
100 {}
101
102 bool
103 operator==(const Operation & other) const noexcept override;
104
105 std::string
106 debug_string() const override;
107
108 [[nodiscard]] std::unique_ptr<Operation>
109 copy() const override;
110
112 can_reduce_operand_pair(const rvsdg::Output * op1, const rvsdg::Output * op2)
113 const noexcept override;
114
117 const override;
118
119 enum flags
120 flags() const noexcept override;
121
122 static rvsdg::Node &
123 createNode(const size_t numBits, rvsdg::Output & operand1, rvsdg::Output & operand2)
124 {
125 return rvsdg::CreateOpNode<IntegerAddOperation>({ &operand1, &operand2 }, numBits);
126 }
127
138 static std::optional<std::vector<rvsdg::Output *>>
140 const IntegerAddOperation & operation,
141 const std::vector<rvsdg::Output *> & operands);
142};
143
150{
151public:
152 ~IntegerSubOperation() noexcept override;
153
154 explicit IntegerSubOperation(const std::size_t numBits)
155 : IntegerBinaryOperation(numBits, numBits)
156 {}
157
158 bool
159 operator==(const Operation & other) const noexcept override;
160
161 std::string
162 debug_string() const override;
163
164 [[nodiscard]] std::unique_ptr<Operation>
165 copy() const override;
166
168 can_reduce_operand_pair(const rvsdg::Output * op1, const rvsdg::Output * op2)
169 const noexcept override;
170
173 const override;
174
175 enum flags
176 flags() const noexcept override;
177
178 static rvsdg::Node &
179 createNode(const size_t numBits, rvsdg::Output & operand1, rvsdg::Output & operand2)
180 {
181 return rvsdg::CreateOpNode<IntegerSubOperation>({ &operand1, &operand2 }, numBits);
182 }
183
196 static std::optional<std::vector<rvsdg::Output *>>
198 const IntegerSubOperation & operation,
199 const std::vector<rvsdg::Output *> & operands);
200
211 static std::optional<std::vector<rvsdg::Output *>>
213 const IntegerSubOperation & operation,
214 const std::vector<rvsdg::Output *> & operands);
215};
216
223{
224public:
225 ~IntegerMulOperation() noexcept override;
226
227 explicit IntegerMulOperation(const std::size_t numBits)
228 : IntegerBinaryOperation(numBits, numBits)
229 {}
230
231 bool
232 operator==(const Operation & other) const noexcept override;
233
234 std::string
235 debug_string() const override;
236
237 [[nodiscard]] std::unique_ptr<Operation>
238 copy() const override;
239
241 can_reduce_operand_pair(const rvsdg::Output * op1, const rvsdg::Output * op2)
242 const noexcept override;
243
246 const override;
247
248 enum flags
249 flags() const noexcept override;
250
251 static rvsdg::Node &
252 createNode(const size_t numBits, rvsdg::Output & operand1, rvsdg::Output & operand2)
253 {
254 return rvsdg::CreateOpNode<IntegerMulOperation>({ &operand1, &operand2 }, numBits);
255 }
256
267 static std::optional<std::vector<rvsdg::Output *>>
269 const IntegerMulOperation & operation,
270 const std::vector<rvsdg::Output *> & operands);
271};
272
279{
280public:
281 ~IntegerSDivOperation() noexcept override;
282
283 explicit IntegerSDivOperation(const std::size_t numBits)
284 : IntegerBinaryOperation(numBits, numBits)
285 {}
286
287 bool
288 operator==(const Operation & other) const noexcept override;
289
290 std::string
291 debug_string() const override;
292
293 [[nodiscard]] std::unique_ptr<Operation>
294 copy() const override;
295
297 can_reduce_operand_pair(const rvsdg::Output * op1, const rvsdg::Output * op2)
298 const noexcept override;
299
302 const override;
303
304 enum flags
305 flags() const noexcept override;
306
307 static rvsdg::Node &
308 createNode(const size_t numBits, rvsdg::Output & operand1, rvsdg::Output & operand2)
309 {
310 return rvsdg::CreateOpNode<IntegerSDivOperation>({ &operand1, &operand2 }, numBits);
311 }
312
323 static std::optional<std::vector<rvsdg::Output *>>
325 const IntegerSDivOperation & operation,
326 const std::vector<rvsdg::Output *> & operands);
327};
328
335{
336public:
337 ~IntegerUDivOperation() noexcept override;
338
339 explicit IntegerUDivOperation(const std::size_t numBits)
340 : IntegerBinaryOperation(numBits, numBits)
341 {}
342
343 bool
344 operator==(const Operation & other) const noexcept override;
345
346 std::string
347 debug_string() const override;
348
349 [[nodiscard]] std::unique_ptr<Operation>
350 copy() const override;
351
353 can_reduce_operand_pair(const rvsdg::Output * op1, const rvsdg::Output * op2)
354 const noexcept override;
355
358 const override;
359
360 enum flags
361 flags() const noexcept override;
362
363 static rvsdg::Node &
364 createNode(const size_t numBits, rvsdg::Output & operand1, rvsdg::Output & operand2)
365 {
366 return rvsdg::CreateOpNode<IntegerUDivOperation>({ &operand1, &operand2 }, numBits);
367 }
368
379 static std::optional<std::vector<rvsdg::Output *>>
381 const IntegerUDivOperation & operation,
382 const std::vector<rvsdg::Output *> & operands);
383};
384
391{
392public:
393 ~IntegerSRemOperation() noexcept override;
394
395 explicit IntegerSRemOperation(const std::size_t numBits)
396 : IntegerBinaryOperation(numBits, numBits)
397 {}
398
399 bool
400 operator==(const Operation & other) const noexcept override;
401
402 std::string
403 debug_string() const override;
404
405 [[nodiscard]] std::unique_ptr<Operation>
406 copy() const override;
407
409 can_reduce_operand_pair(const rvsdg::Output * op1, const rvsdg::Output * op2)
410 const noexcept override;
411
414 const override;
415
416 enum flags
417 flags() const noexcept override;
418
419 static rvsdg::Node &
420 createNode(const size_t numBits, rvsdg::Output & operand1, rvsdg::Output & operand2)
421 {
422 return rvsdg::CreateOpNode<IntegerSRemOperation>({ &operand1, &operand2 }, numBits);
423 }
424
435 static std::optional<std::vector<rvsdg::Output *>>
437 const IntegerSRemOperation & operation,
438 const std::vector<rvsdg::Output *> & operands);
439};
440
447{
448public:
449 ~IntegerURemOperation() noexcept override;
450
451 explicit IntegerURemOperation(const std::size_t numBits)
452 : IntegerBinaryOperation(numBits, numBits)
453 {}
454
455 bool
456 operator==(const Operation & other) const noexcept override;
457
458 std::string
459 debug_string() const override;
460
461 [[nodiscard]] std::unique_ptr<Operation>
462 copy() const override;
463
465 can_reduce_operand_pair(const rvsdg::Output * op1, const rvsdg::Output * op2)
466 const noexcept override;
467
470 const override;
471
472 enum flags
473 flags() const noexcept override;
474
475 static rvsdg::Node &
476 createNode(const size_t numBits, rvsdg::Output & operand1, rvsdg::Output & operand2)
477 {
478 return rvsdg::CreateOpNode<IntegerURemOperation>({ &operand1, &operand2 }, numBits);
479 }
480
491 static std::optional<std::vector<rvsdg::Output *>>
493 const IntegerURemOperation & operation,
494 const std::vector<rvsdg::Output *> & operands);
495};
496
503{
504public:
505 ~IntegerAShrOperation() noexcept override;
506
507 explicit IntegerAShrOperation(const std::size_t numBits)
508 : IntegerBinaryOperation(numBits, numBits)
509 {}
510
511 bool
512 operator==(const Operation & other) const noexcept override;
513
514 std::string
515 debug_string() const override;
516
517 [[nodiscard]] std::unique_ptr<Operation>
518 copy() const override;
519
521 can_reduce_operand_pair(const rvsdg::Output * op1, const rvsdg::Output * op2)
522 const noexcept override;
523
526 const override;
527
528 enum flags
529 flags() const noexcept override;
530
531 static rvsdg::Node &
532 createNode(const size_t numBits, rvsdg::Output & operand1, rvsdg::Output & operand2)
533 {
534 return rvsdg::CreateOpNode<IntegerAShrOperation>({ &operand1, &operand2 }, numBits);
535 }
536
547 static std::optional<std::vector<rvsdg::Output *>>
549 const IntegerAShrOperation & operation,
550 const std::vector<rvsdg::Output *> & operands);
551};
552
559{
560public:
561 ~IntegerShlOperation() noexcept override;
562
563 explicit IntegerShlOperation(const std::size_t numBits)
564 : IntegerBinaryOperation(numBits, numBits)
565 {}
566
567 bool
568 operator==(const Operation & other) const noexcept override;
569
570 std::string
571 debug_string() const override;
572
573 [[nodiscard]] std::unique_ptr<Operation>
574 copy() const override;
575
577 can_reduce_operand_pair(const rvsdg::Output * op1, const rvsdg::Output * op2)
578 const noexcept override;
579
582 const override;
583
584 enum flags
585 flags() const noexcept override;
586
587 static rvsdg::Node &
588 createNode(const size_t numBits, rvsdg::Output & operand1, rvsdg::Output & operand2)
589 {
590 return rvsdg::CreateOpNode<IntegerShlOperation>({ &operand1, &operand2 }, numBits);
591 }
592
603 static std::optional<std::vector<rvsdg::Output *>>
605 const IntegerShlOperation & operation,
606 const std::vector<rvsdg::Output *> & operands);
607};
608
615{
616public:
617 ~IntegerLShrOperation() noexcept override;
618
619 explicit IntegerLShrOperation(const std::size_t numBits)
620 : IntegerBinaryOperation(numBits, numBits)
621 {}
622
623 bool
624 operator==(const Operation & other) const noexcept override;
625
626 std::string
627 debug_string() const override;
628
629 [[nodiscard]] std::unique_ptr<Operation>
630 copy() const override;
631
633 can_reduce_operand_pair(const rvsdg::Output * op1, const rvsdg::Output * op2)
634 const noexcept override;
635
638 const override;
639
640 enum flags
641 flags() const noexcept override;
642
643 static rvsdg::Node &
644 createNode(const size_t numBits, rvsdg::Output & operand1, rvsdg::Output & operand2)
645 {
646 return rvsdg::CreateOpNode<IntegerLShrOperation>({ &operand1, &operand2 }, numBits);
647 }
648
659 static std::optional<std::vector<rvsdg::Output *>>
661 const IntegerLShrOperation & operation,
662 const std::vector<rvsdg::Output *> & operands);
663};
664
671{
672public:
673 ~IntegerAndOperation() noexcept override;
674
675 explicit IntegerAndOperation(const std::size_t numBits)
676 : IntegerBinaryOperation(numBits, numBits)
677 {}
678
679 bool
680 operator==(const Operation & other) const noexcept override;
681
682 std::string
683 debug_string() const override;
684
685 [[nodiscard]] std::unique_ptr<Operation>
686 copy() const override;
687
689 can_reduce_operand_pair(const rvsdg::Output * op1, const rvsdg::Output * op2)
690 const noexcept override;
691
694 const override;
695
696 enum flags
697 flags() const noexcept override;
698
699 static rvsdg::Node &
700 createNode(const size_t numBits, rvsdg::Output & operand1, rvsdg::Output & operand2)
701 {
702 return rvsdg::CreateOpNode<IntegerAndOperation>({ &operand1, &operand2 }, numBits);
703 }
704
715 static std::optional<std::vector<rvsdg::Output *>>
717 const IntegerAndOperation & operation,
718 const std::vector<rvsdg::Output *> & operands);
719};
720
727{
728public:
729 ~IntegerOrOperation() noexcept override;
730
731 explicit IntegerOrOperation(const std::size_t numBits)
732 : IntegerBinaryOperation(numBits, numBits)
733 {}
734
735 bool
736 operator==(const Operation & other) const noexcept override;
737
738 std::string
739 debug_string() const override;
740
741 [[nodiscard]] std::unique_ptr<Operation>
742 copy() const override;
743
745 can_reduce_operand_pair(const rvsdg::Output * op1, const rvsdg::Output * op2)
746 const noexcept override;
747
750 const override;
751
752 enum flags
753 flags() const noexcept override;
754
755 static rvsdg::Node &
756 createNode(const size_t numBits, rvsdg::Output & operand1, rvsdg::Output & operand2)
757 {
758 return rvsdg::CreateOpNode<IntegerOrOperation>({ &operand1, &operand2 }, numBits);
759 }
760
771 static std::optional<std::vector<rvsdg::Output *>>
773 const IntegerOrOperation & operation,
774 const std::vector<rvsdg::Output *> & operands);
775};
776
783{
784public:
785 ~IntegerXorOperation() noexcept override;
786
787 explicit IntegerXorOperation(const std::size_t numBits)
788 : IntegerBinaryOperation(numBits, numBits)
789 {}
790
791 bool
792 operator==(const Operation & other) const noexcept override;
793
794 std::string
795 debug_string() const override;
796
797 [[nodiscard]] std::unique_ptr<Operation>
798 copy() const override;
799
801 can_reduce_operand_pair(const rvsdg::Output * op1, const rvsdg::Output * op2)
802 const noexcept override;
803
806 const override;
807
808 enum flags
809 flags() const noexcept override;
810
811 static rvsdg::Node &
812 createNode(const size_t numBits, rvsdg::Output & operand1, rvsdg::Output & operand2)
813 {
814 return rvsdg::CreateOpNode<IntegerXorOperation>({ &operand1, &operand2 }, numBits);
815 }
816
827 static std::optional<std::vector<rvsdg::Output *>>
829 const IntegerXorOperation & operation,
830 const std::vector<rvsdg::Output *> & operands);
831};
832
839{
840public:
841 ~IntegerEqOperation() noexcept override;
842
843 explicit IntegerEqOperation(const std::size_t numBits)
844 : IntegerBinaryOperation(numBits, 1)
845 {}
846
847 bool
848 operator==(const Operation & other) const noexcept override;
849
850 std::string
851 debug_string() const override;
852
853 [[nodiscard]] std::unique_ptr<Operation>
854 copy() const override;
855
857 can_reduce_operand_pair(const rvsdg::Output * op1, const rvsdg::Output * op2)
858 const noexcept override;
859
862 const override;
863
864 enum flags
865 flags() const noexcept override;
866
867 static rvsdg::Node &
868 createNode(const size_t numBits, rvsdg::Output & operand1, rvsdg::Output & operand2)
869 {
870 return rvsdg::CreateOpNode<IntegerEqOperation>({ &operand1, &operand2 }, numBits);
871 }
872
883 static std::optional<std::vector<rvsdg::Output *>>
885 const IntegerEqOperation & operation,
886 const std::vector<rvsdg::Output *> & operands);
887};
888
895{
896public:
897 ~IntegerNeOperation() noexcept override;
898
899 explicit IntegerNeOperation(const std::size_t numBits)
900 : IntegerBinaryOperation(numBits, 1)
901 {}
902
903 bool
904 operator==(const Operation & other) const noexcept override;
905
906 std::string
907 debug_string() const override;
908
909 [[nodiscard]] std::unique_ptr<Operation>
910 copy() const override;
911
913 can_reduce_operand_pair(const rvsdg::Output * op1, const rvsdg::Output * op2)
914 const noexcept override;
915
918 const override;
919
920 enum flags
921 flags() const noexcept override;
922
923 static rvsdg::Node &
924 createNode(const size_t numBits, rvsdg::Output & operand1, rvsdg::Output & operand2)
925 {
926 return rvsdg::CreateOpNode<IntegerNeOperation>({ &operand1, &operand2 }, numBits);
927 }
928
939 static std::optional<std::vector<rvsdg::Output *>>
941 const IntegerNeOperation & operation,
942 const std::vector<rvsdg::Output *> & operands);
943};
944
951{
952public:
953 ~IntegerSgeOperation() noexcept override;
954
955 explicit IntegerSgeOperation(const std::size_t numBits)
956 : IntegerBinaryOperation(numBits, 1)
957 {}
958
959 bool
960 operator==(const Operation & other) const noexcept override;
961
962 std::string
963 debug_string() const override;
964
965 [[nodiscard]] std::unique_ptr<Operation>
966 copy() const override;
967
969 can_reduce_operand_pair(const rvsdg::Output * op1, const rvsdg::Output * op2)
970 const noexcept override;
971
974 const override;
975
976 enum flags
977 flags() const noexcept override;
978
979 static rvsdg::Node &
980 createNode(const size_t numBits, rvsdg::Output & operand1, rvsdg::Output & operand2)
981 {
982 return rvsdg::CreateOpNode<IntegerSgeOperation>({ &operand1, &operand2 }, numBits);
983 }
984
995 static std::optional<std::vector<rvsdg::Output *>>
997 const IntegerSgeOperation & operation,
998 const std::vector<rvsdg::Output *> & operands);
999};
1000
1007{
1008public:
1009 ~IntegerSgtOperation() noexcept override;
1010
1011 explicit IntegerSgtOperation(const std::size_t numBits)
1012 : IntegerBinaryOperation(numBits, 1)
1013 {}
1014
1015 bool
1016 operator==(const Operation & other) const noexcept override;
1017
1018 std::string
1019 debug_string() const override;
1020
1021 [[nodiscard]] std::unique_ptr<Operation>
1022 copy() const override;
1023
1025 can_reduce_operand_pair(const rvsdg::Output * op1, const rvsdg::Output * op2)
1026 const noexcept override;
1027
1030 const override;
1031
1032 enum flags
1033 flags() const noexcept override;
1034
1035 static rvsdg::Node &
1036 createNode(const size_t numBits, rvsdg::Output & operand1, rvsdg::Output & operand2)
1037 {
1038 return rvsdg::CreateOpNode<IntegerSgtOperation>({ &operand1, &operand2 }, numBits);
1039 }
1040
1051 static std::optional<std::vector<rvsdg::Output *>>
1053 const IntegerSgtOperation & operation,
1054 const std::vector<rvsdg::Output *> & operands);
1055};
1056
1063{
1064public:
1065 ~IntegerSleOperation() noexcept override;
1066
1067 explicit IntegerSleOperation(const std::size_t numBits)
1068 : IntegerBinaryOperation(numBits, 1)
1069 {}
1070
1071 bool
1072 operator==(const Operation & other) const noexcept override;
1073
1074 std::string
1075 debug_string() const override;
1076
1077 [[nodiscard]] std::unique_ptr<Operation>
1078 copy() const override;
1079
1081 can_reduce_operand_pair(const rvsdg::Output * op1, const rvsdg::Output * op2)
1082 const noexcept override;
1083
1086 const override;
1087
1088 enum flags
1089 flags() const noexcept override;
1090
1091 static rvsdg::Node &
1092 createNode(const size_t numBits, rvsdg::Output & operand1, rvsdg::Output & operand2)
1093 {
1094 return rvsdg::CreateOpNode<IntegerSleOperation>({ &operand1, &operand2 }, numBits);
1095 }
1096
1107 static std::optional<std::vector<rvsdg::Output *>>
1109 const IntegerSleOperation & operation,
1110 const std::vector<rvsdg::Output *> & operands);
1111};
1112
1119{
1120public:
1121 ~IntegerSltOperation() noexcept override;
1122
1123 explicit IntegerSltOperation(const std::size_t numBits)
1124 : IntegerBinaryOperation(numBits, 1)
1125 {}
1126
1127 bool
1128 operator==(const Operation & other) const noexcept override;
1129
1130 std::string
1131 debug_string() const override;
1132
1133 [[nodiscard]] std::unique_ptr<Operation>
1134 copy() const override;
1135
1137 can_reduce_operand_pair(const rvsdg::Output * op1, const rvsdg::Output * op2)
1138 const noexcept override;
1139
1142 const override;
1143
1144 enum flags
1145 flags() const noexcept override;
1146
1147 static rvsdg::Node &
1148 createNode(const size_t numBits, rvsdg::Output & operand1, rvsdg::Output & operand2)
1149 {
1150 return rvsdg::CreateOpNode<IntegerSltOperation>({ &operand1, &operand2 }, numBits);
1151 }
1152
1163 static std::optional<std::vector<rvsdg::Output *>>
1165 const IntegerSltOperation & operation,
1166 const std::vector<rvsdg::Output *> & operands);
1167};
1168
1175{
1176public:
1177 ~IntegerUgeOperation() noexcept override;
1178
1179 explicit IntegerUgeOperation(const std::size_t numBits)
1180 : IntegerBinaryOperation(numBits, 1)
1181 {}
1182
1183 bool
1184 operator==(const Operation & other) const noexcept override;
1185
1186 std::string
1187 debug_string() const override;
1188
1189 [[nodiscard]] std::unique_ptr<Operation>
1190 copy() const override;
1191
1193 can_reduce_operand_pair(const rvsdg::Output * op1, const rvsdg::Output * op2)
1194 const noexcept override;
1195
1198 const override;
1199
1200 enum flags
1201 flags() const noexcept override;
1202
1203 static rvsdg::Node &
1204 createNode(const size_t numBits, rvsdg::Output & operand1, rvsdg::Output & operand2)
1205 {
1206 return rvsdg::CreateOpNode<IntegerUgeOperation>({ &operand1, &operand2 }, numBits);
1207 }
1208
1219 static std::optional<std::vector<rvsdg::Output *>>
1221 const IntegerUgeOperation & operation,
1222 const std::vector<rvsdg::Output *> & operands);
1223};
1224
1231{
1232public:
1233 ~IntegerUgtOperation() noexcept override;
1234
1235 explicit IntegerUgtOperation(const std::size_t numBits)
1236 : IntegerBinaryOperation(numBits, 1)
1237 {}
1238
1239 bool
1240 operator==(const Operation & other) const noexcept override;
1241
1242 std::string
1243 debug_string() const override;
1244
1245 [[nodiscard]] std::unique_ptr<Operation>
1246 copy() const override;
1247
1249 can_reduce_operand_pair(const rvsdg::Output * op1, const rvsdg::Output * op2)
1250 const noexcept override;
1251
1254 const override;
1255
1256 enum flags
1257 flags() const noexcept override;
1258
1259 static rvsdg::Node &
1260 createNode(const size_t numBits, rvsdg::Output & operand1, rvsdg::Output & operand2)
1261 {
1262 return rvsdg::CreateOpNode<IntegerUgtOperation>({ &operand1, &operand2 }, numBits);
1263 }
1264
1275 static std::optional<std::vector<rvsdg::Output *>>
1277 const IntegerUgtOperation & operation,
1278 const std::vector<rvsdg::Output *> & operands);
1279};
1280
1287{
1288public:
1289 ~IntegerUleOperation() noexcept override;
1290
1291 explicit IntegerUleOperation(const std::size_t numBits)
1292 : IntegerBinaryOperation(numBits, 1)
1293 {}
1294
1295 bool
1296 operator==(const Operation & other) const noexcept override;
1297
1298 std::string
1299 debug_string() const override;
1300
1301 [[nodiscard]] std::unique_ptr<Operation>
1302 copy() const override;
1303
1305 can_reduce_operand_pair(const rvsdg::Output * op1, const rvsdg::Output * op2)
1306 const noexcept override;
1307
1310 const override;
1311
1312 enum flags
1313 flags() const noexcept override;
1314
1315 static rvsdg::Node &
1316 createNode(const size_t numBits, rvsdg::Output & operand1, rvsdg::Output & operand2)
1317 {
1318 return rvsdg::CreateOpNode<IntegerUleOperation>({ &operand1, &operand2 }, numBits);
1319 }
1320
1331 static std::optional<std::vector<rvsdg::Output *>>
1333 const IntegerUleOperation & operation,
1334 const std::vector<rvsdg::Output *> & operands);
1335};
1336
1343{
1344public:
1345 ~IntegerUltOperation() noexcept override;
1346
1347 explicit IntegerUltOperation(const std::size_t numBits)
1348 : IntegerBinaryOperation(numBits, 1)
1349 {}
1350
1351 bool
1352 operator==(const Operation & other) const noexcept override;
1353
1354 std::string
1355 debug_string() const override;
1356
1357 [[nodiscard]] std::unique_ptr<Operation>
1358 copy() const override;
1359
1361 can_reduce_operand_pair(const rvsdg::Output * op1, const rvsdg::Output * op2)
1362 const noexcept override;
1363
1366 const override;
1367
1368 enum flags
1369 flags() const noexcept override;
1370
1371 static rvsdg::Node &
1372 createNode(const size_t numBits, rvsdg::Output & operand1, rvsdg::Output & operand2)
1373 {
1374 return rvsdg::CreateOpNode<IntegerUltOperation>({ &operand1, &operand2 }, numBits);
1375 }
1376
1387 static std::optional<std::vector<rvsdg::Output *>>
1389 const IntegerUltOperation & operation,
1390 const std::vector<rvsdg::Output *> & operands);
1391};
1392
1393}
1394
1395#endif // JLM_LLVM_IR_OPERATORS_INTEGEROPERATIONS_HPP
std::unique_ptr< Operation > copy() const override
rvsdg::binop_reduction_path_t can_reduce_operand_pair(const rvsdg::Output *op1, const rvsdg::Output *op2) const noexcept override
static std::optional< std::vector< rvsdg::Output * > > foldConstants(const IntegerAShrOperation &operation, const std::vector< rvsdg::Output * > &operands)
bool operator==(const Operation &other) const noexcept override
std::string debug_string() const override
enum flags flags() const noexcept override
rvsdg::Output * reduce_operand_pair(rvsdg::binop_reduction_path_t path, rvsdg::Output *op1, rvsdg::Output *op2) const override
~IntegerAShrOperation() noexcept override
static rvsdg::Node & createNode(const size_t numBits, rvsdg::Output &operand1, rvsdg::Output &operand2)
rvsdg::Output * reduce_operand_pair(rvsdg::binop_reduction_path_t path, rvsdg::Output *op1, rvsdg::Output *op2) const override
bool operator==(const Operation &other) const noexcept override
rvsdg::binop_reduction_path_t can_reduce_operand_pair(const rvsdg::Output *op1, const rvsdg::Output *op2) const noexcept override
enum flags flags() const noexcept override
~IntegerAddOperation() noexcept override
std::string debug_string() const override
static std::optional< std::vector< rvsdg::Output * > > foldConstants(const IntegerAddOperation &operation, const std::vector< rvsdg::Output * > &operands)
std::unique_ptr< Operation > copy() const override
static rvsdg::Node & createNode(const size_t numBits, rvsdg::Output &operand1, rvsdg::Output &operand2)
rvsdg::Output * reduce_operand_pair(rvsdg::binop_reduction_path_t path, rvsdg::Output *op1, rvsdg::Output *op2) const override
std::unique_ptr< Operation > copy() const override
enum flags flags() const noexcept override
static std::optional< std::vector< rvsdg::Output * > > foldConstants(const IntegerAndOperation &operation, const std::vector< rvsdg::Output * > &operands)
std::string debug_string() const override
rvsdg::binop_reduction_path_t can_reduce_operand_pair(const rvsdg::Output *op1, const rvsdg::Output *op2) const noexcept override
bool operator==(const Operation &other) const noexcept override
~IntegerAndOperation() noexcept override
static rvsdg::Node & createNode(const size_t numBits, rvsdg::Output &operand1, rvsdg::Output &operand2)
~IntegerBinaryOperation() noexcept override
const rvsdg::BitType & Type() const noexcept
static rvsdg::Node & Create(rvsdg::Region &region, IntegerValueRepresentation representation)
bool operator==(const Operation &other) const noexcept override
IntegerValueRepresentation Representation_
static rvsdg::Node & Create(rvsdg::Region &region, std::size_t numBits, std::int64_t value)
IntegerConstantOperation(IntegerValueRepresentation representation)
const IntegerValueRepresentation & Representation() const noexcept
std::unique_ptr< Operation > copy() const override
std::string debug_string() const override
enum flags flags() const noexcept override
std::string debug_string() const override
static std::optional< std::vector< rvsdg::Output * > > foldConstants(const IntegerEqOperation &operation, const std::vector< rvsdg::Output * > &operands)
std::unique_ptr< Operation > copy() const override
rvsdg::binop_reduction_path_t can_reduce_operand_pair(const rvsdg::Output *op1, const rvsdg::Output *op2) const noexcept override
rvsdg::Output * reduce_operand_pair(rvsdg::binop_reduction_path_t path, rvsdg::Output *op1, rvsdg::Output *op2) const override
static rvsdg::Node & createNode(const size_t numBits, rvsdg::Output &operand1, rvsdg::Output &operand2)
~IntegerEqOperation() noexcept override
bool operator==(const Operation &other) const noexcept override
~IntegerLShrOperation() noexcept override
bool operator==(const Operation &other) const noexcept override
static std::optional< std::vector< rvsdg::Output * > > foldConstants(const IntegerLShrOperation &operation, const std::vector< rvsdg::Output * > &operands)
std::string debug_string() const override
std::unique_ptr< Operation > copy() const override
enum flags flags() const noexcept override
static rvsdg::Node & createNode(const size_t numBits, rvsdg::Output &operand1, rvsdg::Output &operand2)
rvsdg::binop_reduction_path_t can_reduce_operand_pair(const rvsdg::Output *op1, const rvsdg::Output *op2) const noexcept override
rvsdg::Output * reduce_operand_pair(rvsdg::binop_reduction_path_t path, rvsdg::Output *op1, rvsdg::Output *op2) const override
bool operator==(const Operation &other) const noexcept override
~IntegerMulOperation() noexcept override
std::string debug_string() const override
rvsdg::Output * reduce_operand_pair(rvsdg::binop_reduction_path_t path, rvsdg::Output *op1, rvsdg::Output *op2) const override
static std::optional< std::vector< rvsdg::Output * > > foldConstants(const IntegerMulOperation &operation, const std::vector< rvsdg::Output * > &operands)
std::unique_ptr< Operation > copy() const override
static rvsdg::Node & createNode(const size_t numBits, rvsdg::Output &operand1, rvsdg::Output &operand2)
rvsdg::binop_reduction_path_t can_reduce_operand_pair(const rvsdg::Output *op1, const rvsdg::Output *op2) const noexcept override
enum flags flags() const noexcept override
bool operator==(const Operation &other) const noexcept override
std::string debug_string() const override
static std::optional< std::vector< rvsdg::Output * > > foldConstants(const IntegerNeOperation &operation, const std::vector< rvsdg::Output * > &operands)
std::unique_ptr< Operation > copy() const override
rvsdg::Output * reduce_operand_pair(rvsdg::binop_reduction_path_t path, rvsdg::Output *op1, rvsdg::Output *op2) const override
static rvsdg::Node & createNode(const size_t numBits, rvsdg::Output &operand1, rvsdg::Output &operand2)
enum flags flags() const noexcept override
~IntegerNeOperation() noexcept override
rvsdg::binop_reduction_path_t can_reduce_operand_pair(const rvsdg::Output *op1, const rvsdg::Output *op2) const noexcept override
bool operator==(const Operation &other) const noexcept override
static std::optional< std::vector< rvsdg::Output * > > foldConstants(const IntegerOrOperation &operation, const std::vector< rvsdg::Output * > &operands)
std::unique_ptr< Operation > copy() const override
rvsdg::Output * reduce_operand_pair(rvsdg::binop_reduction_path_t path, rvsdg::Output *op1, rvsdg::Output *op2) const override
~IntegerOrOperation() noexcept override
static rvsdg::Node & createNode(const size_t numBits, rvsdg::Output &operand1, rvsdg::Output &operand2)
enum flags flags() const noexcept override
std::string debug_string() const override
rvsdg::binop_reduction_path_t can_reduce_operand_pair(const rvsdg::Output *op1, const rvsdg::Output *op2) const noexcept override
static std::optional< std::vector< rvsdg::Output * > > foldConstants(const IntegerSDivOperation &operation, const std::vector< rvsdg::Output * > &operands)
std::string debug_string() const override
rvsdg::binop_reduction_path_t can_reduce_operand_pair(const rvsdg::Output *op1, const rvsdg::Output *op2) const noexcept override
~IntegerSDivOperation() noexcept override
rvsdg::Output * reduce_operand_pair(rvsdg::binop_reduction_path_t path, rvsdg::Output *op1, rvsdg::Output *op2) const override
std::unique_ptr< Operation > copy() const override
bool operator==(const Operation &other) const noexcept override
enum flags flags() const noexcept override
static rvsdg::Node & createNode(const size_t numBits, rvsdg::Output &operand1, rvsdg::Output &operand2)
static rvsdg::Node & createNode(const size_t numBits, rvsdg::Output &operand1, rvsdg::Output &operand2)
rvsdg::binop_reduction_path_t can_reduce_operand_pair(const rvsdg::Output *op1, const rvsdg::Output *op2) const noexcept override
static std::optional< std::vector< rvsdg::Output * > > foldConstants(const IntegerSRemOperation &operation, const std::vector< rvsdg::Output * > &operands)
std::string debug_string() const override
rvsdg::Output * reduce_operand_pair(rvsdg::binop_reduction_path_t path, rvsdg::Output *op1, rvsdg::Output *op2) const override
bool operator==(const Operation &other) const noexcept override
~IntegerSRemOperation() noexcept override
std::unique_ptr< Operation > copy() const override
enum flags flags() const noexcept override
rvsdg::Output * reduce_operand_pair(rvsdg::binop_reduction_path_t path, rvsdg::Output *op1, rvsdg::Output *op2) const override
rvsdg::binop_reduction_path_t can_reduce_operand_pair(const rvsdg::Output *op1, const rvsdg::Output *op2) const noexcept override
static rvsdg::Node & createNode(const size_t numBits, rvsdg::Output &operand1, rvsdg::Output &operand2)
static std::optional< std::vector< rvsdg::Output * > > foldConstants(const IntegerSgeOperation &operation, const std::vector< rvsdg::Output * > &operands)
enum flags flags() const noexcept override
bool operator==(const Operation &other) const noexcept override
std::unique_ptr< Operation > copy() const override
std::string debug_string() const override
~IntegerSgeOperation() noexcept override
static std::optional< std::vector< rvsdg::Output * > > foldConstants(const IntegerSgtOperation &operation, const std::vector< rvsdg::Output * > &operands)
rvsdg::Output * reduce_operand_pair(rvsdg::binop_reduction_path_t path, rvsdg::Output *op1, rvsdg::Output *op2) const override
bool operator==(const Operation &other) const noexcept override
std::string debug_string() const override
static rvsdg::Node & createNode(const size_t numBits, rvsdg::Output &operand1, rvsdg::Output &operand2)
std::unique_ptr< Operation > copy() const override
enum flags flags() const noexcept override
rvsdg::binop_reduction_path_t can_reduce_operand_pair(const rvsdg::Output *op1, const rvsdg::Output *op2) const noexcept override
~IntegerSgtOperation() noexcept override
std::unique_ptr< Operation > copy() const override
~IntegerShlOperation() noexcept override
enum flags flags() const noexcept override
static rvsdg::Node & createNode(const size_t numBits, rvsdg::Output &operand1, rvsdg::Output &operand2)
rvsdg::binop_reduction_path_t can_reduce_operand_pair(const rvsdg::Output *op1, const rvsdg::Output *op2) const noexcept override
std::string debug_string() const override
static std::optional< std::vector< rvsdg::Output * > > foldConstants(const IntegerShlOperation &operation, const std::vector< rvsdg::Output * > &operands)
bool operator==(const Operation &other) const noexcept override
rvsdg::Output * reduce_operand_pair(rvsdg::binop_reduction_path_t path, rvsdg::Output *op1, rvsdg::Output *op2) const override
std::string debug_string() const override
enum flags flags() const noexcept override
~IntegerSleOperation() noexcept override
std::unique_ptr< Operation > copy() const override
static rvsdg::Node & createNode(const size_t numBits, rvsdg::Output &operand1, rvsdg::Output &operand2)
static std::optional< std::vector< rvsdg::Output * > > foldConstants(const IntegerSleOperation &operation, const std::vector< rvsdg::Output * > &operands)
rvsdg::binop_reduction_path_t can_reduce_operand_pair(const rvsdg::Output *op1, const rvsdg::Output *op2) const noexcept override
bool operator==(const Operation &other) const noexcept override
rvsdg::Output * reduce_operand_pair(rvsdg::binop_reduction_path_t path, rvsdg::Output *op1, rvsdg::Output *op2) const override
bool operator==(const Operation &other) const noexcept override
static rvsdg::Node & createNode(const size_t numBits, rvsdg::Output &operand1, rvsdg::Output &operand2)
std::unique_ptr< Operation > copy() const override
rvsdg::binop_reduction_path_t can_reduce_operand_pair(const rvsdg::Output *op1, const rvsdg::Output *op2) const noexcept override
rvsdg::Output * reduce_operand_pair(rvsdg::binop_reduction_path_t path, rvsdg::Output *op1, rvsdg::Output *op2) const override
std::string debug_string() const override
static std::optional< std::vector< rvsdg::Output * > > foldConstants(const IntegerSltOperation &operation, const std::vector< rvsdg::Output * > &operands)
enum flags flags() const noexcept override
~IntegerSltOperation() noexcept override
~IntegerSubOperation() noexcept override
bool operator==(const Operation &other) const noexcept override
rvsdg::binop_reduction_path_t can_reduce_operand_pair(const rvsdg::Output *op1, const rvsdg::Output *op2) const noexcept override
rvsdg::Output * reduce_operand_pair(rvsdg::binop_reduction_path_t path, rvsdg::Output *op1, rvsdg::Output *op2) const override
static rvsdg::Node & createNode(const size_t numBits, rvsdg::Output &operand1, rvsdg::Output &operand2)
std::string debug_string() const override
enum flags flags() const noexcept override
static std::optional< std::vector< rvsdg::Output * > > foldConstants(const IntegerSubOperation &operation, const std::vector< rvsdg::Output * > &operands)
static std::optional< std::vector< rvsdg::Output * > > normalizeAdditiveInverse(const IntegerSubOperation &operation, const std::vector< rvsdg::Output * > &operands)
std::unique_ptr< Operation > copy() const override
bool operator==(const Operation &other) const noexcept override
static std::optional< std::vector< rvsdg::Output * > > foldConstants(const IntegerUDivOperation &operation, const std::vector< rvsdg::Output * > &operands)
std::string debug_string() const override
~IntegerUDivOperation() noexcept override
rvsdg::binop_reduction_path_t can_reduce_operand_pair(const rvsdg::Output *op1, const rvsdg::Output *op2) const noexcept override
static rvsdg::Node & createNode(const size_t numBits, rvsdg::Output &operand1, rvsdg::Output &operand2)
enum flags flags() const noexcept override
std::unique_ptr< Operation > copy() const override
rvsdg::Output * reduce_operand_pair(rvsdg::binop_reduction_path_t path, rvsdg::Output *op1, rvsdg::Output *op2) const override
bool operator==(const Operation &other) const noexcept override
std::unique_ptr< Operation > copy() const override
std::string debug_string() const override
static rvsdg::Node & createNode(const size_t numBits, rvsdg::Output &operand1, rvsdg::Output &operand2)
rvsdg::Output * reduce_operand_pair(rvsdg::binop_reduction_path_t path, rvsdg::Output *op1, rvsdg::Output *op2) const override
enum flags flags() const noexcept override
~IntegerURemOperation() noexcept override
rvsdg::binop_reduction_path_t can_reduce_operand_pair(const rvsdg::Output *op1, const rvsdg::Output *op2) const noexcept override
static std::optional< std::vector< rvsdg::Output * > > foldConstants(const IntegerURemOperation &operation, const std::vector< rvsdg::Output * > &operands)
static std::optional< std::vector< rvsdg::Output * > > foldConstants(const IntegerUgeOperation &operation, const std::vector< rvsdg::Output * > &operands)
std::string debug_string() const override
static rvsdg::Node & createNode(const size_t numBits, rvsdg::Output &operand1, rvsdg::Output &operand2)
std::unique_ptr< Operation > copy() const override
rvsdg::binop_reduction_path_t can_reduce_operand_pair(const rvsdg::Output *op1, const rvsdg::Output *op2) const noexcept override
rvsdg::Output * reduce_operand_pair(rvsdg::binop_reduction_path_t path, rvsdg::Output *op1, rvsdg::Output *op2) const override
~IntegerUgeOperation() noexcept override
bool operator==(const Operation &other) const noexcept override
enum flags flags() const noexcept override
bool operator==(const Operation &other) const noexcept override
enum flags flags() const noexcept override
rvsdg::Output * reduce_operand_pair(rvsdg::binop_reduction_path_t path, rvsdg::Output *op1, rvsdg::Output *op2) const override
rvsdg::binop_reduction_path_t can_reduce_operand_pair(const rvsdg::Output *op1, const rvsdg::Output *op2) const noexcept override
std::string debug_string() const override
std::unique_ptr< Operation > copy() const override
~IntegerUgtOperation() noexcept override
static std::optional< std::vector< rvsdg::Output * > > foldConstants(const IntegerUgtOperation &operation, const std::vector< rvsdg::Output * > &operands)
static rvsdg::Node & createNode(const size_t numBits, rvsdg::Output &operand1, rvsdg::Output &operand2)
rvsdg::Output * reduce_operand_pair(rvsdg::binop_reduction_path_t path, rvsdg::Output *op1, rvsdg::Output *op2) const override
enum flags flags() const noexcept override
std::string debug_string() const override
bool operator==(const Operation &other) const noexcept override
~IntegerUleOperation() noexcept override
static rvsdg::Node & createNode(const size_t numBits, rvsdg::Output &operand1, rvsdg::Output &operand2)
std::unique_ptr< Operation > copy() const override
rvsdg::binop_reduction_path_t can_reduce_operand_pair(const rvsdg::Output *op1, const rvsdg::Output *op2) const noexcept override
static std::optional< std::vector< rvsdg::Output * > > foldConstants(const IntegerUleOperation &operation, const std::vector< rvsdg::Output * > &operands)
std::unique_ptr< Operation > copy() const override
enum flags flags() const noexcept override
std::string debug_string() const override
~IntegerUltOperation() noexcept override
rvsdg::binop_reduction_path_t can_reduce_operand_pair(const rvsdg::Output *op1, const rvsdg::Output *op2) const noexcept override
static rvsdg::Node & createNode(const size_t numBits, rvsdg::Output &operand1, rvsdg::Output &operand2)
rvsdg::Output * reduce_operand_pair(rvsdg::binop_reduction_path_t path, rvsdg::Output *op1, rvsdg::Output *op2) const override
bool operator==(const Operation &other) const noexcept override
static std::optional< std::vector< rvsdg::Output * > > foldConstants(const IntegerUltOperation &operation, const std::vector< rvsdg::Output * > &operands)
static rvsdg::Node & createNode(const size_t numBits, rvsdg::Output &operand1, rvsdg::Output &operand2)
std::string debug_string() const override
rvsdg::Output * reduce_operand_pair(rvsdg::binop_reduction_path_t path, rvsdg::Output *op1, rvsdg::Output *op2) const override
~IntegerXorOperation() noexcept override
enum flags flags() const noexcept override
bool operator==(const Operation &other) const noexcept override
static std::optional< std::vector< rvsdg::Output * > > foldConstants(const IntegerXorOperation &operation, const std::vector< rvsdg::Output * > &operands)
std::unique_ptr< Operation > copy() const override
rvsdg::binop_reduction_path_t can_reduce_operand_pair(const rvsdg::Output *op1, const rvsdg::Output *op2) const noexcept override
static std::shared_ptr< const BitType > Create(std::size_t nbits)
Creates bit type of specified width.
Definition type.cpp:45
Nullary operator (operator taking no formal arguments)
Definition nullary.hpp:22
NullaryOperation(std::shared_ptr< const Type > resultType)
Definition nullary.hpp:26
Represent acyclic RVSDG subgraphs.
Definition region.hpp:213
const std::shared_ptr< const rvsdg::Type > & argument(size_t index) const noexcept
Definition operation.cpp:23
Global memory state passed between functions.
size_t binop_reduction_path_t
Definition binary.hpp:19
NodeType * TryGetOwnerNode(const rvsdg::Input &input) noexcept
Checks if this is an input to a node of specified type.
Definition node.hpp:872