Jlm
operators.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2014 2015 Nico Reißmann <nico.reissmann@gmail.com>
3  * See COPYING for terms of redistribution.
4  */
5 
8 #include <jlm/rvsdg/Trace.hpp>
10 
11 #include <llvm/ADT/SmallVector.h>
12 #include <llvm/IR/InstrTypes.h>
13 #include <stdexcept>
14 
15 namespace jlm::llvm
16 {
17 
18 SsaPhiOperation::~SsaPhiOperation() noexcept = default;
19 
20 bool
21 SsaPhiOperation::operator==(const Operation & other) const noexcept
22 {
23  const auto op = dynamic_cast<const SsaPhiOperation *>(&other);
24  return op && op->IncomingNodes_ == IncomingNodes_ && op->result(0) == result(0);
25 }
26 
27 std::string
29 {
30  std::string str("[");
31  for (size_t n = 0; n < narguments(); n++)
32  {
33  str += util::strfmt(GetIncomingNode(n));
34  if (n != narguments() - 1)
35  str += ", ";
36  }
37  str += "]";
38 
39  return "PHI" + str;
40 }
41 
42 std::unique_ptr<rvsdg::Operation>
44 {
45  return std::make_unique<SsaPhiOperation>(*this);
46 }
47 
49 
50 bool
51 AssignmentOperation::operator==(const Operation & other) const noexcept
52 {
53  const auto op = dynamic_cast<const AssignmentOperation *>(&other);
54  return op && op->argument(0) == argument(0);
55 }
56 
57 std::string
59 {
60  return "ASSIGN";
61 }
62 
63 std::unique_ptr<rvsdg::Operation>
65 {
66  return std::make_unique<AssignmentOperation>(*this);
67 }
68 
69 SelectOperation::~SelectOperation() noexcept = default;
70 
71 bool
72 SelectOperation::operator==(const Operation & other) const noexcept
73 {
74  const auto op = dynamic_cast<const SelectOperation *>(&other);
75  return op && op->result(0) == result(0);
76 }
77 
78 std::string
80 {
81  return "Select";
82 }
83 
84 std::unique_ptr<rvsdg::Operation>
86 {
87  return std::make_unique<SelectOperation>(*this);
88 }
89 
91 
92 bool
93 VectorSelectOperation::operator==(const Operation & other) const noexcept
94 {
95  const auto op = dynamic_cast<const VectorSelectOperation *>(&other);
96  return op && op->type() == type();
97 }
98 
99 std::string
101 {
102  return "VectorSelect";
103 }
104 
105 std::unique_ptr<rvsdg::Operation>
107 {
108  return std::make_unique<VectorSelectOperation>(*this);
109 }
110 
112  default;
113 
114 bool
115 FloatingPointToUnsignedIntegerOperation::operator==(const Operation & other) const noexcept
116 {
117  const auto op = dynamic_cast<const FloatingPointToUnsignedIntegerOperation *>(&other);
118  return op && op->argument(0) == argument(0) && op->result(0) == result(0);
119 }
120 
121 std::string
123 {
124  return "FpToUInt";
125 }
126 
127 std::unique_ptr<rvsdg::Operation>
129 {
130  return std::make_unique<FloatingPointToUnsignedIntegerOperation>(*this);
131 }
132 
135 {
137 }
138 
142  rvsdg::Output *) const
143 {
144  JLM_UNREACHABLE("Not implemented");
145 }
146 
148 
149 bool
150 FloatingPointToSignedIntegerOperation::operator==(const Operation & other) const noexcept
151 {
152  const auto op = dynamic_cast<const FloatingPointToSignedIntegerOperation *>(&other);
153  return op && op->argument(0) == argument(0) && op->result(0) == result(0);
154 }
155 
156 std::string
158 {
159  return "FpToSInt";
160 }
161 
162 std::unique_ptr<rvsdg::Operation>
164 {
165  return std::make_unique<FloatingPointToSignedIntegerOperation>(*this);
166 }
167 
170 {
172 }
173 
176  const
177 {
178  JLM_UNREACHABLE("Not implemented!");
179 }
180 
182 
183 bool
184 ControlToIntOperation::operator==(const Operation & other) const noexcept
185 {
186  auto op = dynamic_cast<const ControlToIntOperation *>(&other);
187  return op && op->argument(0) == argument(0) && op->result(0) == result(0);
188 }
189 
190 std::string
192 {
193  return "ControlToInt";
194 }
195 
196 std::unique_ptr<rvsdg::Operation>
198 {
199  return std::make_unique<ControlToIntOperation>(*this);
200 }
201 
202 BranchOperation::~BranchOperation() noexcept = default;
203 
204 bool
205 BranchOperation::operator==(const Operation & other) const noexcept
206 {
207  const auto op = dynamic_cast<const BranchOperation *>(&other);
208  return op && op->argument(0) == argument(0);
209 }
210 
211 std::string
213 {
214  return "Branch";
215 }
216 
217 std::unique_ptr<rvsdg::Operation>
219 {
220  return std::make_unique<BranchOperation>(*this);
221 }
222 
224 
225 bool
226 ConstantPointerNullOperation::operator==(const Operation & other) const noexcept
227 {
228  auto op = dynamic_cast<const ConstantPointerNullOperation *>(&other);
229  return op && op->GetPointerType() == GetPointerType();
230 }
231 
232 std::string
234 {
235  return "ConstantPointerNull";
236 }
237 
238 std::unique_ptr<rvsdg::Operation>
240 {
241  return std::make_unique<ConstantPointerNullOperation>(*this);
242 }
243 
245 
246 bool
247 IntegerToPointerOperation::operator==(const Operation & other) const noexcept
248 {
249  const auto op = dynamic_cast<const IntegerToPointerOperation *>(&other);
250  return op && op->argument(0) == argument(0) && op->result(0) == result(0);
251 }
252 
253 std::string
255 {
256  return "IntToPtr";
257 }
258 
259 std::unique_ptr<rvsdg::Operation>
261 {
262  return std::make_unique<IntegerToPointerOperation>(*this);
263 }
264 
267 {
269 }
270 
273 {
274  JLM_UNREACHABLE("Not implemented!");
275 }
276 
277 PtrToIntOperation::~PtrToIntOperation() noexcept = default;
278 
279 bool
280 PtrToIntOperation::operator==(const Operation & other) const noexcept
281 {
282  const auto op = dynamic_cast<const PtrToIntOperation *>(&other);
283  return op && op->argument(0) == argument(0) && op->result(0) == result(0);
284 }
285 
286 std::string
288 {
289  return "PtrToInt";
290 }
291 
292 std::unique_ptr<rvsdg::Operation>
294 {
295  return std::make_unique<PtrToIntOperation>(*this);
296 }
297 
300 {
302 }
303 
306 {
307  JLM_UNREACHABLE("Not implemented!");
308 }
309 
310 ConstantDataArray::~ConstantDataArray() noexcept = default;
311 
312 bool
313 ConstantDataArray::operator==(const Operation & other) const noexcept
314 {
315  auto op = dynamic_cast<const ConstantDataArray *>(&other);
316  return op && op->result(0) == result(0);
317 }
318 
319 std::string
321 {
322  return "ConstantDataArray";
323 }
324 
325 std::unique_ptr<rvsdg::Operation>
327 {
328  return std::make_unique<ConstantDataArray>(*this);
329 }
330 
333 {
335  { ::llvm::CmpInst::ICMP_EQ, ICmpPredicate::Eq },
336  { ::llvm::CmpInst::ICMP_NE, ICmpPredicate::Ne },
337  { ::llvm::CmpInst::ICMP_UGT, ICmpPredicate::Ugt },
338  { ::llvm::CmpInst::ICMP_UGE, ICmpPredicate::Uge },
339  { ::llvm::CmpInst::ICMP_ULT, ICmpPredicate::Ult },
340  { ::llvm::CmpInst::ICMP_ULE, ICmpPredicate::Ule },
341  { ::llvm::CmpInst::ICMP_SGT, ICmpPredicate::Sgt },
342  { ::llvm::CmpInst::ICMP_SGE, ICmpPredicate::Sge },
343  { ::llvm::CmpInst::ICMP_SLT, ICmpPredicate::Slt },
344  { ::llvm::CmpInst::ICMP_SLE, ICmpPredicate::Sle },
345  };
346  return map;
347 }
348 
350 convertICmpPredicateToJlm(::llvm::CmpInst::Predicate predicate)
351 {
352  const auto & map = getICmpPredicateMap();
353  return map.LookupKey(predicate);
354 }
355 
356 [[nodiscard]] ::llvm::CmpInst::Predicate
358 {
359  const auto & map = getICmpPredicateMap();
360  return map.LookupValue(predicate);
361 }
362 
363 [[nodiscard]] std::string_view
365 {
366  switch (predicate)
367  {
368  case ICmpPredicate::Eq:
369  return "eq";
370  case ICmpPredicate::Ne:
371  return "ne";
372  case ICmpPredicate::Ugt:
373  return "ugt";
374  case ICmpPredicate::Uge:
375  return "uge";
376  case ICmpPredicate::Ult:
377  return "ult";
378  case ICmpPredicate::Ule:
379  return "ule";
380  case ICmpPredicate::Sgt:
381  return "sgt";
382  case ICmpPredicate::Sge:
383  return "sge";
384  case ICmpPredicate::Slt:
385  return "slt";
386  case ICmpPredicate::Sle:
387  return "sle";
388  default:
389  throw std::runtime_error("Unknown ICmpPredicate");
390  }
391 }
392 
393 PtrCmpOperation::~PtrCmpOperation() noexcept = default;
394 
395 bool
396 PtrCmpOperation::operator==(const Operation & other) const noexcept
397 {
398  auto op = dynamic_cast<const PtrCmpOperation *>(&other);
399  return op && op->argument(0) == argument(0) && op->predicate_ == predicate_;
400 }
401 
402 std::string
404 {
405  return util::strfmt("PtrCmp[", iCmpPredicateToString(predicate_), "]");
406 }
407 
408 std::unique_ptr<rvsdg::Operation>
410 {
411  return std::make_unique<PtrCmpOperation>(*this);
412 }
413 
416  const noexcept
417 {
419 }
420 
424  rvsdg::Output *,
425  rvsdg::Output *) const
426 {
427  JLM_UNREACHABLE("Not implemented!");
428 }
429 
430 ZExtOperation::~ZExtOperation() noexcept = default;
431 
432 bool
433 ZExtOperation::operator==(const Operation & other) const noexcept
434 {
435  const auto op = dynamic_cast<const ZExtOperation *>(&other);
436  return op && op->argument(0) == argument(0) && op->result(0) == result(0);
437 }
438 
439 std::string
441 {
442  return util::strfmt("ZExt[", nsrcbits(), " -> ", ndstbits(), "]");
443 }
444 
445 std::unique_ptr<rvsdg::Operation>
447 {
448  return std::make_unique<ZExtOperation>(*this);
449 }
450 
452 ZExtOperation::can_reduce_operand(const rvsdg::Output * operand) const noexcept
453 {
454  auto & tracedOperand = rvsdg::traceOutputIntraProcedurally(*operand);
455  if (rvsdg::IsOwnerNodeOperation<rvsdg::BitConstantOperation>(tracedOperand))
457 
459 }
460 
463 {
464  if (path == rvsdg::unop_reduction_constant)
465  {
466  auto & tracedOperand = rvsdg::traceOutputIntraProcedurally(*operand);
467  auto [_, constantOperation] =
468  rvsdg::TryGetSimpleNodeAndOptionalOp<rvsdg::BitConstantOperation>(tracedOperand);
469  JLM_ASSERT(constantOperation);
471  *rvsdg::TryGetOwnerNode<rvsdg::Node>(*operand)->region(),
472  constantOperation->value().zext(ndstbits() - nsrcbits()));
473  }
474 
475  return nullptr;
476 }
477 
478 ConstantFP::~ConstantFP() noexcept = default;
479 
480 bool
481 ConstantFP::operator==(const Operation & other) const noexcept
482 {
483  auto op = dynamic_cast<const ConstantFP *>(&other);
484  return op && size() == op->size() && constant().bitwiseIsEqual(op->constant());
485 }
486 
487 std::string
489 {
490  ::llvm::SmallVector<char, 32> v;
491  constant().toString(v, 32, 0);
492 
493  std::string s("FP(");
494  for (const auto & c : v)
495  s += c;
496  s += ")";
497 
498  return s;
499 }
500 
501 std::unique_ptr<rvsdg::Operation>
503 {
504  return std::make_unique<ConstantFP>(*this);
505 }
506 
507 FCmpOperation::~FCmpOperation() noexcept = default;
508 
509 bool
510 FCmpOperation::operator==(const Operation & other) const noexcept
511 {
512  auto op = dynamic_cast<const FCmpOperation *>(&other);
513  return op && op->argument(0) == argument(0) && op->cmp_ == cmp_;
514 }
515 
516 std::string
518 {
519  static std::unordered_map<fpcmp, std::string> map({ { fpcmp::oeq, "oeq" },
520  { fpcmp::ogt, "ogt" },
521  { fpcmp::oge, "oge" },
522  { fpcmp::olt, "olt" },
523  { fpcmp::ole, "ole" },
524  { fpcmp::one, "one" },
525  { fpcmp::ord, "ord" },
526  { fpcmp::ueq, "ueq" },
527  { fpcmp::ugt, "ugt" },
528  { fpcmp::uge, "uge" },
529  { fpcmp::ult, "ult" },
530  { fpcmp::ule, "ule" },
531  { fpcmp::une, "une" },
532  { fpcmp::uno, "uno" } });
533 
534  JLM_ASSERT(map.find(cmp()) != map.end());
535  return "FCmp " + map[cmp()];
536 }
537 
538 std::unique_ptr<rvsdg::Operation>
540 {
541  return std::make_unique<FCmpOperation>(*this);
542 }
543 
546 {
548 }
549 
552  const
553 {
554  JLM_UNREACHABLE("Not implemented!");
555 }
556 
557 UndefValueOperation::~UndefValueOperation() noexcept = default;
558 
559 bool
560 UndefValueOperation::operator==(const Operation & other) const noexcept
561 {
562  auto op = dynamic_cast<const UndefValueOperation *>(&other);
563  return op && op->GetType() == GetType();
564 }
565 
566 std::string
568 {
569  return "undef";
570 }
571 
572 std::unique_ptr<rvsdg::Operation>
574 {
575  return std::make_unique<UndefValueOperation>(*this);
576 }
577 
579 
580 bool
581 PoisonValueOperation::operator==(const Operation & other) const noexcept
582 {
583  auto operation = dynamic_cast<const PoisonValueOperation *>(&other);
584  return operation && operation->GetType() == GetType();
585 }
586 
587 std::string
589 {
590  return "poison";
591 }
592 
593 std::unique_ptr<rvsdg::Operation>
595 {
596  return std::make_unique<PoisonValueOperation>(*this);
597 }
598 
599 FreezeOperation::~FreezeOperation() noexcept = default;
600 
601 bool
602 FreezeOperation::operator==(const Operation & other) const noexcept
603 {
604  auto operation = dynamic_cast<const FreezeOperation *>(&other);
605  return operation && operation->getType() == getType();
606 }
607 
609 FreezeOperation::can_reduce_operand([[maybe_unused]] const jlm::rvsdg::Output * arg) const noexcept
610 {
612 }
613 
616  [[maybe_unused]] rvsdg::unop_reduction_path_t path,
617  [[maybe_unused]] jlm::rvsdg::Output * arg) const
618 {
619  throw std::runtime_error("FreezeOperation does not support reductions");
620 }
621 
622 std::string
624 {
625  return "freeze";
626 }
627 
628 std::unique_ptr<rvsdg::Operation>
630 {
631  return std::make_unique<FreezeOperation>(*this);
632 }
633 
634 FBinaryOperation::~FBinaryOperation() noexcept = default;
635 
636 bool
637 FBinaryOperation::operator==(const Operation & other) const noexcept
638 {
639  auto op = dynamic_cast<const FBinaryOperation *>(&other);
640  return op && op->fpop() == fpop() && op->size() == size();
641 }
642 
643 std::string
645 {
646  static std::unordered_map<llvm::fpop, std::string> map({ { fpop::add, "add" },
647  { fpop::sub, "sub" },
648  { fpop::mul, "mul" },
649  { fpop::div, "div" },
650  { fpop::mod, "mod" } });
651 
652  JLM_ASSERT(map.find(fpop()) != map.end());
653  return "FPOP " + map[fpop()];
654 }
655 
656 std::unique_ptr<rvsdg::Operation>
658 {
659  return std::make_unique<FBinaryOperation>(*this);
660 }
661 
664  const noexcept
665 {
667 }
668 
672  rvsdg::Output *,
673  rvsdg::Output *) const
674 {
675  JLM_UNREACHABLE("Not implemented!");
676 }
677 
678 FPExtOperation::~FPExtOperation() noexcept = default;
679 
680 bool
681 FPExtOperation::operator==(const Operation & other) const noexcept
682 {
683  const auto op = dynamic_cast<const FPExtOperation *>(&other);
684  return op && op->srcsize() == srcsize() && op->dstsize() == dstsize();
685 }
686 
687 std::string
689 {
690  return "FPExt";
691 }
692 
693 std::unique_ptr<rvsdg::Operation>
695 {
696  return std::make_unique<FPExtOperation>(*this);
697 }
698 
701 {
703 }
704 
707 {
708  JLM_UNREACHABLE("Not implemented!");
709 }
710 
711 FNegOperation::~FNegOperation() noexcept = default;
712 
713 bool
714 FNegOperation::operator==(const Operation & other) const noexcept
715 {
716  const auto op = dynamic_cast<const FNegOperation *>(&other);
717  return op && op->size() == size();
718 }
719 
720 std::string
722 {
723  return "FNeg";
724 }
725 
726 std::unique_ptr<rvsdg::Operation>
728 {
729  return std::make_unique<FNegOperation>(*this);
730 }
731 
734 {
736 }
737 
740 {
741  JLM_UNREACHABLE("Not implemented!");
742 }
743 
744 FPTruncOperation::~FPTruncOperation() noexcept = default;
745 
746 bool
747 FPTruncOperation::operator==(const Operation & other) const noexcept
748 {
749  const auto op = dynamic_cast<const FPTruncOperation *>(&other);
750  return op && op->srcsize() == srcsize() && op->dstsize() == dstsize();
751 }
752 
753 std::string
755 {
756  return "FPTrunc";
757 }
758 
759 std::unique_ptr<rvsdg::Operation>
761 {
762  return std::make_unique<FPTruncOperation>(*this);
763 }
764 
767 {
769 }
770 
773 {
774  JLM_UNREACHABLE("Not implemented!");
775 }
776 
778 
779 bool
780 VariadicArgumentListOperation::operator==(const Operation & other) const noexcept
781 {
782  auto op = dynamic_cast<const VariadicArgumentListOperation *>(&other);
783  if (!op || op->narguments() != narguments())
784  return false;
785 
786  for (size_t n = 0; n < narguments(); n++)
787  {
788  if (op->argument(n) != argument(n))
789  return false;
790  }
791 
792  return true;
793 }
794 
795 std::string
797 {
798  return "VariadicArguments";
799 }
800 
801 std::unique_ptr<rvsdg::Operation>
803 {
804  return std::make_unique<VariadicArgumentListOperation>(*this);
805 }
806 
807 BitCastOperation::~BitCastOperation() noexcept = default;
808 
809 bool
810 BitCastOperation::operator==(const Operation & other) const noexcept
811 {
812  auto op = dynamic_cast<const BitCastOperation *>(&other);
813  return op && op->argument(0) == argument(0) && op->result(0) == result(0);
814 }
815 
816 std::string
818 {
819  return util::strfmt(
820  "BitCast[",
821  argument(0)->debug_string(),
822  " -> ",
823  result(0)->debug_string(),
824  "]");
825 }
826 
827 std::unique_ptr<rvsdg::Operation>
829 {
830  return std::make_unique<BitCastOperation>(*this);
831 }
832 
835 {
837 }
838 
841 {
842  JLM_UNREACHABLE("Not implemented!");
843 }
844 
845 /* ConstantStruct operator */
846 
848 {}
849 
850 bool
851 ConstantStruct::operator==(const Operation & other) const noexcept
852 {
853  auto op = dynamic_cast<const ConstantStruct *>(&other);
854  return op && op->result(0) == result(0);
855 }
856 
857 std::string
859 {
860  return "ConstantStruct";
861 }
862 
863 std::unique_ptr<rvsdg::Operation>
865 {
866  return std::make_unique<ConstantStruct>(*this);
867 }
868 
869 TruncOperation::~TruncOperation() noexcept = default;
870 
871 bool
872 TruncOperation::operator==(const Operation & other) const noexcept
873 {
874  const auto op = dynamic_cast<const TruncOperation *>(&other);
875  return op && op->argument(0) == argument(0) && op->result(0) == result(0);
876 }
877 
878 std::string
880 {
881  return util::strfmt("Trunc[", nsrcbits(), " -> ", ndstbits(), "]");
882 }
883 
884 std::unique_ptr<rvsdg::Operation>
886 {
887  return std::make_unique<TruncOperation>(*this);
888 }
889 
892 {
894 }
895 
898 {
899  JLM_UNREACHABLE("Not implemented!");
900 }
901 
902 UIToFPOperation::~UIToFPOperation() noexcept = default;
903 
904 bool
905 UIToFPOperation::operator==(const Operation & other) const noexcept
906 {
907  const auto op = dynamic_cast<const UIToFPOperation *>(&other);
908  return op && op->argument(0) == argument(0) && op->result(0) == result(0);
909 }
910 
911 std::string
913 {
914  return "UIToFP";
915 }
916 
917 std::unique_ptr<rvsdg::Operation>
919 {
920  return std::make_unique<UIToFPOperation>(*this);
921 }
922 
925 {
927 }
928 
931 {
932  JLM_UNREACHABLE("Not implemented!");
933 }
934 
935 SIToFPOperation::~SIToFPOperation() noexcept = default;
936 
937 bool
938 SIToFPOperation::operator==(const Operation & other) const noexcept
939 {
940  const auto op = dynamic_cast<const SIToFPOperation *>(&other);
941  return op && op->argument(0) == argument(0) && op->result(0) == result(0);
942 }
943 
944 std::string
946 {
947  return "SIToFP";
948 }
949 
950 std::unique_ptr<rvsdg::Operation>
952 {
953  return std::make_unique<SIToFPOperation>(*this);
954 }
955 
958 {
960 }
961 
964 {
965  JLM_UNREACHABLE("Not implemented!");
966 }
967 
969 
970 bool
971 ConstantArrayOperation::operator==(const Operation & other) const noexcept
972 {
973  const auto op = dynamic_cast<const ConstantArrayOperation *>(&other);
974  return op && op->result(0) == result(0);
975 }
976 
977 std::string
979 {
980  return "ConstantArray";
981 }
982 
983 std::unique_ptr<rvsdg::Operation>
985 {
986  return std::make_unique<ConstantArrayOperation>(*this);
987 }
988 
990 
991 bool
992 ConstantAggregateZeroOperation::operator==(const Operation & other) const noexcept
993 {
994  const auto op = dynamic_cast<const ConstantAggregateZeroOperation *>(&other);
995  return op && op->result(0) == result(0);
996 }
997 
998 std::string
1000 {
1001  return "ConstantAggregateZero";
1002 }
1003 
1004 std::unique_ptr<rvsdg::Operation>
1006 {
1007  return std::make_unique<ConstantAggregateZeroOperation>(*this);
1008 }
1009 
1011 
1012 bool
1013 ExtractElementOperation::operator==(const Operation & other) const noexcept
1014 {
1015  auto op = dynamic_cast<const ExtractElementOperation *>(&other);
1016  return op && op->argument(0) == argument(0) && op->argument(1) == argument(1);
1017 }
1018 
1019 std::string
1021 {
1022  return "ExtractElement";
1023 }
1024 
1025 std::unique_ptr<rvsdg::Operation>
1027 {
1028  return std::make_unique<ExtractElementOperation>(*this);
1029 }
1030 
1032 
1033 bool
1034 ShuffleVectorOperation::operator==(const Operation & other) const noexcept
1035 {
1036  auto op = dynamic_cast<const ShuffleVectorOperation *>(&other);
1037  return op && op->argument(0) == argument(0) && op->Mask() == Mask();
1038 }
1039 
1040 std::string
1042 {
1043  return "ShuffleVector";
1044 }
1045 
1046 std::unique_ptr<rvsdg::Operation>
1048 {
1049  return std::make_unique<ShuffleVectorOperation>(*this);
1050 }
1051 
1053 
1054 bool
1055 ConstantVectorOperation::operator==(const Operation & other) const noexcept
1056 {
1057  auto op = dynamic_cast<const ConstantVectorOperation *>(&other);
1058  return op && op->result(0) == result(0);
1059 }
1060 
1061 std::string
1063 {
1064  return "ConstantVector";
1065 }
1066 
1067 std::unique_ptr<rvsdg::Operation>
1069 {
1070  return std::make_unique<ConstantVectorOperation>(*this);
1071 }
1072 
1074 
1075 bool
1076 InsertElementOperation::operator==(const Operation & other) const noexcept
1077 {
1078  auto op = dynamic_cast<const InsertElementOperation *>(&other);
1079  return op && op->argument(0) == argument(0) && op->argument(1) == argument(1)
1080  && op->argument(2) == argument(2);
1081 }
1082 
1083 std::string
1085 {
1086  return "InsertElement";
1087 }
1088 
1089 std::unique_ptr<rvsdg::Operation>
1091 {
1092  return std::make_unique<InsertElementOperation>(*this);
1093 }
1094 
1095 VectorUnaryOperation::~VectorUnaryOperation() noexcept = default;
1096 
1097 bool
1098 VectorUnaryOperation::operator==(const Operation & other) const noexcept
1099 {
1100  auto op = dynamic_cast<const VectorUnaryOperation *>(&other);
1101  return op && op->operation() == operation();
1102 }
1103 
1104 std::string
1106 {
1107  return util::strfmt("Vector", operation().debug_string());
1108 }
1109 
1110 std::unique_ptr<rvsdg::Operation>
1112 {
1113  return std::make_unique<VectorUnaryOperation>(*this);
1114 }
1115 
1117 
1118 bool
1119 VectorBinaryOperation::operator==(const Operation & other) const noexcept
1120 {
1121  auto op = dynamic_cast<const VectorBinaryOperation *>(&other);
1122  return op && op->operation() == operation();
1123 }
1124 
1125 std::string
1127 {
1128  return util::strfmt("Vector", operation().debug_string());
1129 }
1130 
1131 std::unique_ptr<rvsdg::Operation>
1133 {
1134  return std::make_unique<VectorBinaryOperation>(*this);
1135 }
1136 
1138 
1139 bool
1140 ConstantDataVectorOperation::operator==(const Operation & other) const noexcept
1141 {
1142  auto op = dynamic_cast<const ConstantDataVectorOperation *>(&other);
1143  return op && op->result(0) == result(0);
1144 }
1145 
1146 std::string
1148 {
1149  return "ConstantDataVector";
1150 }
1151 
1152 std::unique_ptr<rvsdg::Operation>
1154 {
1155  return std::make_unique<ConstantDataVectorOperation>(*this);
1156 }
1157 
1158 MallocOperation::~MallocOperation() noexcept = default;
1159 
1160 bool
1161 MallocOperation::operator==(const Operation & other) const noexcept
1162 {
1163  // Avoid CNE for malloc operator
1164  return this == &other;
1165 }
1166 
1167 std::string
1169 {
1170  return "Malloc";
1171 }
1172 
1173 std::unique_ptr<rvsdg::Operation>
1175 {
1176  return std::make_unique<MallocOperation>(*this);
1177 }
1178 
1179 /* free operator */
1180 
1181 FreeOperation::~FreeOperation() noexcept = default;
1182 
1183 bool
1184 FreeOperation::operator==(const Operation & other) const noexcept
1185 {
1186  // Avoid CNE for free operator
1187  return this == &other;
1188 }
1189 
1190 std::string
1192 {
1193  return "FREE";
1194 }
1195 
1196 std::unique_ptr<rvsdg::Operation>
1198 {
1199  return std::make_unique<FreeOperation>(*this);
1200 }
1201 }
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:64
~AssignmentOperation() noexcept override
std::string debug_string() const override
Definition: operators.cpp:58
std::string debug_string() const override
Definition: operators.cpp:817
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:828
jlm::rvsdg::Output * reduce_operand(jlm::rvsdg::unop_reduction_path_t path, jlm::rvsdg::Output *output) const override
Definition: operators.cpp:840
jlm::rvsdg::unop_reduction_path_t can_reduce_operand(const jlm::rvsdg::Output *output) const noexcept override
Definition: operators.cpp:834
~BitCastOperation() noexcept override
std::string debug_string() const override
Definition: operators.cpp:212
~BranchOperation() noexcept override
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:218
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:1005
~ConstantAggregateZeroOperation() noexcept override
std::string debug_string() const override
Definition: operators.cpp:999
~ConstantArrayOperation() noexcept override
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:984
std::string debug_string() const override
Definition: operators.cpp:978
~ConstantDataArray() noexcept override
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:326
std::string debug_string() const override
Definition: operators.cpp:320
~ConstantDataVectorOperation() noexcept override
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:1153
std::string debug_string() const override
Definition: operators.cpp:1147
~ConstantFP() noexcept override
const fpsize & size() const noexcept
Definition: operators.hpp:911
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:502
const ::llvm::APFloat & constant() const noexcept
Definition: operators.hpp:905
std::string debug_string() const override
Definition: operators.cpp:488
ConstantPointerNullOperation class.
Definition: operators.hpp:432
std::string debug_string() const override
Definition: operators.cpp:233
const PointerType & GetPointerType() const noexcept
Definition: operators.hpp:450
~ConstantPointerNullOperation() noexcept override
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:239
bool operator==(const Operation &other) const noexcept override
Definition: operators.cpp:851
std::string debug_string() const override
Definition: operators.cpp:858
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:864
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:1068
~ConstantVectorOperation() noexcept override
std::string debug_string() const override
Definition: operators.cpp:1062
std::string debug_string() const override
Definition: operators.cpp:191
~ControlToIntOperation() noexcept override
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:197
std::string debug_string() const override
Definition: operators.cpp:1020
~ExtractElementOperation() noexcept override
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:1026
const llvm::fpop & fpop() const noexcept
Definition: operators.hpp:1254
std::string debug_string() const override
Definition: operators.cpp:644
jlm::rvsdg::binop_reduction_path_t can_reduce_operand_pair(const jlm::rvsdg::Output *op1, const jlm::rvsdg::Output *op2) const noexcept override
Definition: operators.cpp:663
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:657
jlm::rvsdg::Output * reduce_operand_pair(jlm::rvsdg::binop_reduction_path_t path, jlm::rvsdg::Output *op1, jlm::rvsdg::Output *op2) const override
Definition: operators.cpp:670
~FBinaryOperation() noexcept override
jlm::rvsdg::binop_reduction_path_t can_reduce_operand_pair(const jlm::rvsdg::Output *op1, const jlm::rvsdg::Output *op2) const noexcept override
Definition: operators.cpp:545
const fpcmp & cmp() const noexcept
Definition: operators.hpp:992
~FCmpOperation() noexcept override
std::string debug_string() const override
Definition: operators.cpp:517
jlm::rvsdg::Output * reduce_operand_pair(jlm::rvsdg::binop_reduction_path_t path, jlm::rvsdg::Output *op1, jlm::rvsdg::Output *op2) const override
Definition: operators.cpp:551
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:539
const fpsize & size() const noexcept
Definition: operators.hpp:1392
jlm::rvsdg::Output * reduce_operand(jlm::rvsdg::unop_reduction_path_t path, jlm::rvsdg::Output *output) const override
Definition: operators.cpp:739
jlm::rvsdg::unop_reduction_path_t can_reduce_operand(const jlm::rvsdg::Output *output) const noexcept override
Definition: operators.cpp:733
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:727
~FNegOperation() noexcept override
std::string debug_string() const override
Definition: operators.cpp:721
~FPExtOperation() noexcept override
std::string debug_string() const override
Definition: operators.cpp:688
jlm::rvsdg::Output * reduce_operand(jlm::rvsdg::unop_reduction_path_t path, jlm::rvsdg::Output *output) const override
Definition: operators.cpp:706
jlm::rvsdg::unop_reduction_path_t can_reduce_operand(const jlm::rvsdg::Output *output) const noexcept override
Definition: operators.cpp:700
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:694
const fpsize & srcsize() const noexcept
Definition: operators.hpp:1335
const fpsize & srcsize() const noexcept
Definition: operators.hpp:1466
jlm::rvsdg::unop_reduction_path_t can_reduce_operand(const jlm::rvsdg::Output *output) const noexcept override
Definition: operators.cpp:766
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:760
std::string debug_string() const override
Definition: operators.cpp:754
~FPTruncOperation() noexcept override
jlm::rvsdg::Output * reduce_operand(jlm::rvsdg::unop_reduction_path_t path, jlm::rvsdg::Output *output) const override
Definition: operators.cpp:772
jlm::rvsdg::Output * reduce_operand(jlm::rvsdg::unop_reduction_path_t path, jlm::rvsdg::Output *output) const override
Definition: operators.cpp:175
jlm::rvsdg::unop_reduction_path_t can_reduce_operand(const jlm::rvsdg::Output *output) const noexcept override
Definition: operators.cpp:169
std::string debug_string() const override
Definition: operators.cpp:157
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:163
jlm::rvsdg::Output * reduce_operand(jlm::rvsdg::unop_reduction_path_t path, jlm::rvsdg::Output *output) const override
Definition: operators.cpp:140
jlm::rvsdg::unop_reduction_path_t can_reduce_operand(const jlm::rvsdg::Output *output) const noexcept override
Definition: operators.cpp:134
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:128
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:1197
~FreeOperation() noexcept override
std::string debug_string() const override
Definition: operators.cpp:1191
FreezeOperation class.
Definition: operators.hpp:1160
std::string debug_string() const override
Definition: operators.cpp:623
~FreezeOperation() noexcept override
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:629
jlm::rvsdg::Output * reduce_operand(rvsdg::unop_reduction_path_t path, jlm::rvsdg::Output *arg) const override
Definition: operators.cpp:615
rvsdg::unop_reduction_path_t can_reduce_operand(const jlm::rvsdg::Output *arg) const noexcept override
Definition: operators.cpp:609
const jlm::rvsdg::Type & getType() const noexcept
Definition: operators.hpp:1187
std::string debug_string() const override
Definition: operators.cpp:1084
~InsertElementOperation() noexcept override
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:1090
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:260
std::string debug_string() const override
Definition: operators.cpp:254
jlm::rvsdg::unop_reduction_path_t can_reduce_operand(const jlm::rvsdg::Output *output) const noexcept override
Definition: operators.cpp:266
~IntegerToPointerOperation() noexcept override
jlm::rvsdg::Output * reduce_operand(jlm::rvsdg::unop_reduction_path_t path, jlm::rvsdg::Output *output) const override
Definition: operators.cpp:272
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:1174
std::string debug_string() const override
Definition: operators.cpp:1168
~MallocOperation() noexcept override
PoisonValueOperation class.
Definition: operators.hpp:1092
~PoisonValueOperation() noexcept override
std::string debug_string() const override
Definition: operators.cpp:588
const jlm::rvsdg::Type & GetType() const noexcept
Definition: operators.hpp:1120
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:594
~PtrCmpOperation() noexcept override
jlm::rvsdg::binop_reduction_path_t can_reduce_operand_pair(const jlm::rvsdg::Output *op1, const jlm::rvsdg::Output *op2) const noexcept override
Definition: operators.cpp:415
std::string debug_string() const override
Definition: operators.cpp:403
jlm::rvsdg::Output * reduce_operand_pair(jlm::rvsdg::binop_reduction_path_t path, jlm::rvsdg::Output *op1, jlm::rvsdg::Output *op2) const override
Definition: operators.cpp:422
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:409
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:293
std::string debug_string() const override
Definition: operators.cpp:287
jlm::rvsdg::unop_reduction_path_t can_reduce_operand(const jlm::rvsdg::Output *output) const noexcept override
Definition: operators.cpp:299
jlm::rvsdg::Output * reduce_operand(jlm::rvsdg::unop_reduction_path_t path, jlm::rvsdg::Output *output) const override
Definition: operators.cpp:305
~PtrToIntOperation() noexcept override
~SIToFPOperation() noexcept override
jlm::rvsdg::unop_reduction_path_t can_reduce_operand(const jlm::rvsdg::Output *output) const noexcept override
Definition: operators.cpp:957
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:951
jlm::rvsdg::Output * reduce_operand(jlm::rvsdg::unop_reduction_path_t path, jlm::rvsdg::Output *output) const override
Definition: operators.cpp:963
std::string debug_string() const override
Definition: operators.cpp:945
std::string debug_string() const override
Definition: operators.cpp:79
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:85
~SelectOperation() noexcept override
std::string debug_string() const override
Definition: operators.cpp:1041
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:1047
~ShuffleVectorOperation() noexcept override
ControlFlowGraphNode * GetIncomingNode(size_t n) const noexcept
Definition: operators.hpp:69
std::string debug_string() const override
Definition: operators.cpp:28
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:43
~SsaPhiOperation() noexcept override
std::vector< ControlFlowGraphNode * > IncomingNodes_
Definition: operators.hpp:93
std::string debug_string() const override
Definition: operators.cpp:879
~TruncOperation() noexcept override
jlm::rvsdg::unop_reduction_path_t can_reduce_operand(const jlm::rvsdg::Output *operand) const noexcept override
Definition: operators.cpp:891
size_t ndstbits() const noexcept
Definition: operators.hpp:1739
jlm::rvsdg::Output * reduce_operand(jlm::rvsdg::unop_reduction_path_t path, jlm::rvsdg::Output *operand) const override
Definition: operators.cpp:897
size_t nsrcbits() const noexcept
Definition: operators.hpp:1733
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:885
std::string debug_string() const override
Definition: operators.cpp:912
jlm::rvsdg::unop_reduction_path_t can_reduce_operand(const jlm::rvsdg::Output *operand) const noexcept override
Definition: operators.cpp:924
jlm::rvsdg::Output * reduce_operand(jlm::rvsdg::unop_reduction_path_t path, jlm::rvsdg::Output *operand) const override
Definition: operators.cpp:930
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:918
~UIToFPOperation() noexcept override
UndefValueOperation class.
Definition: operators.hpp:1023
~UndefValueOperation() noexcept override
std::string debug_string() const override
Definition: operators.cpp:567
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:573
const rvsdg::Type & GetType() const noexcept
Definition: operators.hpp:1049
std::string debug_string() const override
Definition: operators.cpp:796
~VariadicArgumentListOperation() noexcept override
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:802
std::string debug_string() const override
Definition: operators.cpp:1126
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:1132
const rvsdg::BinaryOperation & operation() const noexcept
Definition: operators.hpp:2318
~VectorBinaryOperation() noexcept override
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:106
const rvsdg::Type & type() const noexcept
Definition: operators.hpp:190
std::string debug_string() const override
Definition: operators.cpp:100
~VectorSelectOperation() noexcept override
~VectorUnaryOperation() noexcept override
std::string debug_string() const override
Definition: operators.cpp:1105
const rvsdg::UnaryOperation & operation() const noexcept
Definition: operators.hpp:2225
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:1111
std::string debug_string() const override
Definition: operators.cpp:440
size_t nsrcbits() const noexcept
Definition: operators.hpp:830
jlm::rvsdg::Output * reduce_operand(jlm::rvsdg::unop_reduction_path_t path, jlm::rvsdg::Output *operand) const override
Definition: operators.cpp:462
~ZExtOperation() noexcept override
std::unique_ptr< Operation > copy() const override
Definition: operators.cpp:446
jlm::rvsdg::unop_reduction_path_t can_reduce_operand(const jlm::rvsdg::Output *operand) const noexcept override
Definition: operators.cpp:452
size_t ndstbits() const noexcept
Definition: operators.hpp:836
static Output & create(Region &region, BitValueRepresentation value)
Definition: constant.hpp:44
const std::shared_ptr< const rvsdg::Type > & argument(size_t index) const noexcept
Definition: operation.cpp:23
const std::shared_ptr< const rvsdg::Type > & result(size_t index) const noexcept
Definition: operation.cpp:36
size_t narguments() const noexcept
Definition: operation.cpp:17
#define JLM_ASSERT(x)
Definition: common.hpp:16
#define JLM_UNREACHABLE(msg)
Definition: common.hpp:43
Global memory state passed between functions.
ICmpPredicate convertICmpPredicateToJlm(::llvm::CmpInst::Predicate predicate)
Definition: operators.cpp:350
std::string_view iCmpPredicateToString(ICmpPredicate predicate)
Definition: operators.cpp:364
static const util::BijectiveMap<::llvm::CmpInst::Predicate, ICmpPredicate > & getICmpPredicateMap()
Definition: operators.cpp:332
::llvm::CmpInst::Predicate convertICmpPredicateToLlvm(ICmpPredicate predicate)
Definition: operators.cpp:357
size_t unop_reduction_path_t
Definition: unary.hpp:18
size_t binop_reduction_path_t
Definition: binary.hpp:19
static const unop_reduction_path_t unop_reduction_constant
Definition: unary.hpp:45
static const unop_reduction_path_t unop_reduction_none
Definition: unary.hpp:43
Output & traceOutputIntraProcedurally(Output &output)
Definition: Trace.cpp:283
static const binop_reduction_path_t binop_reduction_none
Definition: binary.hpp:203
static std::string strfmt(Args... args)
Definition: strfmt.hpp:35