6 #ifndef JLM_LLVM_IR_OPERATORS_OPERATORS_HPP
7 #define JLM_LLVM_IR_OPERATORS_OPERATORS_HPP
19 #include <llvm/ADT/APFloat.h>
20 #include <llvm/IR/InstrTypes.h>
40 const std::shared_ptr<const
jlm::rvsdg::
Type> & type)
54 operator==(
const Operation & other)
const noexcept
override;
59 [[nodiscard]] std::unique_ptr<Operation>
60 copy()
const override;
62 const std::shared_ptr<const rvsdg::Type> &
75 static std::unique_ptr<llvm::ThreeAddressCode>
77 const std::vector<std::pair<const Variable *, ControlFlowGraphNode *>> & arguments,
78 std::shared_ptr<const jlm::rvsdg::Type> type)
80 std::vector<ControlFlowGraphNode *> basicBlocks;
81 std::vector<const Variable *>
operands;
82 for (
const auto &
argument : arguments)
84 basicBlocks.push_back(
argument.second);
88 auto phi = std::make_unique<SsaPhiOperation>(std::move(basicBlocks), std::move(type));
110 operator==(
const Operation & other)
const noexcept
override;
112 [[nodiscard]] std::string
115 [[nodiscard]] std::unique_ptr<Operation>
116 copy()
const override;
118 static std::unique_ptr<llvm::ThreeAddressCode>
122 throw util::Error(
"LHS and RHS of assignment must have same type.");
124 auto operation = std::make_unique<AssignmentOperation>(rhs->
Type());
139 operator==(
const Operation & other)
const noexcept
override;
144 [[nodiscard]] std::unique_ptr<Operation>
145 copy()
const override;
153 [[nodiscard]]
const std::shared_ptr<const jlm::rvsdg::Type> &
159 static std::unique_ptr<llvm::ThreeAddressCode>
162 auto op = std::make_unique<SelectOperation>(t->
Type());
181 operator==(
const Operation & other)
const noexcept
override;
183 [[nodiscard]] std::string
186 [[nodiscard]] std::unique_ptr<Operation>
187 copy()
const override;
189 [[nodiscard]]
const rvsdg::Type &
195 [[nodiscard]]
const std::shared_ptr<const rvsdg::Type> &
207 static std::unique_ptr<llvm::ThreeAddressCode>
210 if (is<FixedVectorType>(p->
type()) && is<FixedVectorType>(t->
type()))
211 return createVectorSelectTac<FixedVectorType>(p, t, f);
213 if (is<ScalableVectorType>(p->
type()) && is<ScalableVectorType>(t->
type()))
214 return createVectorSelectTac<ScalableVectorType>(p, t, f);
216 throw util::Error(
"Expected vector types as operands.");
221 static std::unique_ptr<ThreeAddressCode>
224 auto fvt =
static_cast<const T *
>(&t->
type());
226 auto vt = T::Create(fvt->Type(), fvt->size());
239 std::shared_ptr<const rvsdg::BitType> type)
244 std::shared_ptr<const FloatingPointType> fpt,
245 std::shared_ptr<const jlm::rvsdg::BitType> type)
250 std::shared_ptr<const jlm::rvsdg::Type> srctype,
251 std::shared_ptr<const jlm::rvsdg::Type> dsttype)
256 throw util::Error(
"expected floating point type.");
264 operator==(
const Operation & other)
const noexcept
override;
266 [[nodiscard]] std::string
269 [[nodiscard]] std::unique_ptr<Operation>
270 copy()
const override;
279 static std::unique_ptr<llvm::ThreeAddressCode>
280 create(
const Variable * operand,
const std::shared_ptr<const jlm::rvsdg::Type> & type)
282 auto st = std::dynamic_pointer_cast<const FloatingPointType>(operand->
Type());
284 throw util::Error(
"expected floating point type.");
286 auto dt = std::dynamic_pointer_cast<const jlm::rvsdg::BitType>(type);
291 std::make_unique<FloatingPointToUnsignedIntegerOperation>(std::move(st), std::move(dt));
303 std::shared_ptr<const
jlm::rvsdg::BitType> type)
308 std::shared_ptr<const FloatingPointType> fpt,
309 std::shared_ptr<const jlm::rvsdg::BitType> type)
314 std::shared_ptr<const jlm::rvsdg::Type> srctype,
315 std::shared_ptr<const jlm::rvsdg::Type> dsttype)
320 throw util::Error(
"expected floating point type.");
328 operator==(
const Operation & other)
const noexcept
override;
330 [[nodiscard]] std::string
333 [[nodiscard]] std::unique_ptr<Operation>
334 copy()
const override;
343 static std::unique_ptr<llvm::ThreeAddressCode>
344 create(
const Variable * operand,
const std::shared_ptr<const jlm::rvsdg::Type> & type)
346 auto st = std::dynamic_pointer_cast<const FloatingPointType>(operand->
Type());
348 throw util::Error(
"expected floating point type.");
350 auto dt = std::dynamic_pointer_cast<const jlm::rvsdg::BitType>(type);
354 auto op = std::make_unique<FloatingPointToSignedIntegerOperation>(std::move(st), std::move(dt));
365 std::shared_ptr<const rvsdg::ControlType> srctype,
366 std::shared_ptr<const
jlm::rvsdg::BitType> dsttype)
371 operator==(
const Operation & other)
const noexcept
override;
373 [[nodiscard]] std::string
376 [[nodiscard]] std::unique_ptr<Operation>
377 copy()
const override;
379 static std::unique_ptr<llvm::ThreeAddressCode>
380 create(
const Variable * operand,
const std::shared_ptr<const jlm::rvsdg::Type> & type)
382 auto st = std::dynamic_pointer_cast<const rvsdg::ControlType>(operand->
Type());
386 auto dt = std::dynamic_pointer_cast<const jlm::rvsdg::BitType>(type);
390 auto op = std::make_unique<ControlToIntOperation>(std::move(st), std::move(dt));
405 operator==(
const Operation & other)
const noexcept
override;
407 [[nodiscard]] std::string
410 [[nodiscard]] std::unique_ptr<Operation>
411 copy()
const override;
416 return std::static_pointer_cast<const rvsdg::ControlType>(
argument(0))->nalternatives();
419 static std::unique_ptr<llvm::ThreeAddressCode>
441 operator==(
const Operation & other)
const noexcept
override;
443 [[nodiscard]] std::string
446 [[nodiscard]] std::unique_ptr<Operation>
447 copy()
const override;
449 [[nodiscard]]
const PointerType &
452 return *util::assertedCast<const PointerType>(
result(0).get());
455 static std::unique_ptr<llvm::ThreeAddressCode>
456 Create(std::shared_ptr<const rvsdg::Type> type)
458 auto operation = std::make_unique<ConstantPointerNullOperation>(
CheckAndExtractType(type));
465 return rvsdg::CreateOpNode<ConstantPointerNullOperation>(*region,
CheckAndExtractType(type))
470 static const std::shared_ptr<const PointerType>
473 if (
auto pointerType = std::dynamic_pointer_cast<const PointerType>(type))
486 std::shared_ptr<const
jlm::rvsdg::BitType> btype,
492 std::shared_ptr<const jlm::rvsdg::Type> srctype,
493 std::shared_ptr<const jlm::rvsdg::Type> dsttype)
500 auto pt =
dynamic_cast<const PointerType *
>(dsttype.get());
506 operator==(
const Operation & other)
const noexcept
override;
508 [[nodiscard]] std::string
511 [[nodiscard]] std::unique_ptr<Operation>
512 copy()
const override;
524 return std::static_pointer_cast<const jlm::rvsdg::BitType>(
argument(0))->nbits();
527 static std::unique_ptr<llvm::ThreeAddressCode>
530 auto at = std::dynamic_pointer_cast<const jlm::rvsdg::BitType>(
argument->Type());
534 auto pt = std::dynamic_pointer_cast<const PointerType>(type);
538 auto op = std::make_unique<IntegerToPointerOperation>(at, pt);
545 auto ot = std::dynamic_pointer_cast<const jlm::rvsdg::BitType>(operand->
Type());
549 auto pt = std::dynamic_pointer_cast<const PointerType>(type);
553 return rvsdg::CreateOpNode<IntegerToPointerOperation>({ operand }, ot, pt).output(0);
564 std::shared_ptr<const
jlm::rvsdg::BitType> btype)
569 std::shared_ptr<const jlm::rvsdg::Type> srctype,
570 std::shared_ptr<const jlm::rvsdg::Type> dsttype)
573 auto pt =
dynamic_cast<const PointerType *
>(srctype.get());
583 operator==(
const Operation & other)
const noexcept
override;
585 [[nodiscard]] std::string
588 [[nodiscard]] std::unique_ptr<Operation>
589 copy()
const override;
601 return std::static_pointer_cast<const rvsdg::BitType>(
result(0))->nbits();
604 static std::unique_ptr<llvm::ThreeAddressCode>
607 auto pt = std::dynamic_pointer_cast<const PointerType>(
argument->Type());
611 auto bt = std::dynamic_pointer_cast<const jlm::rvsdg::BitType>(type);
615 auto op = std::make_unique<PtrToIntOperation>(std::move(pt), std::move(bt));
635 operator==(
const Operation & other)
const noexcept
override;
637 [[nodiscard]] std::string
640 [[nodiscard]] std::unique_ptr<Operation>
641 copy()
const override;
646 return std::static_pointer_cast<const ArrayType>(
result(0))->nelements();
652 return std::static_pointer_cast<const ArrayType>(
result(0))->element_type();
655 static std::unique_ptr<llvm::ThreeAddressCode>
656 create(
const std::vector<const Variable *> & elements)
658 if (elements.size() == 0)
659 throw util::Error(
"expected at least one element.");
661 auto vt = elements[0]->Type();
665 auto op = std::make_unique<ConstantDataArray>(std::move(
vt), elements.size());
670 Create(
const std::vector<jlm::rvsdg::Output *> & elements)
672 if (elements.empty())
673 throw util::Error(
"Expected at least one element.");
675 auto valueType = elements[0]->Type();
681 return rvsdg::CreateOpNode<ConstantDataArray>(elements, std::move(valueType), elements.size())
715 [[nodiscard]] ::llvm::CmpInst::Predicate
722 [[nodiscard]] std::string_view
736 operator==(
const Operation & other)
const noexcept
override;
738 [[nodiscard]] std::string
741 [[nodiscard]] std::unique_ptr<Operation>
742 copy()
const override;
746 const noexcept
override;
760 static std::unique_ptr<llvm::ThreeAddressCode>
763 auto pt = std::dynamic_pointer_cast<const PointerType>(op1->
Type());
767 auto op = std::make_unique<PtrCmpOperation>(std::move(pt), predicateKind);
784 throw util::Error(
"# destination bits must be greater than # source bits.");
788 const std::shared_ptr<const jlm::rvsdg::BitType> & srctype,
789 const std::shared_ptr<const jlm::rvsdg::BitType> & dsttype)
792 if (dsttype->nbits() < srctype->nbits())
793 throw util::Error(
"# destination bits must be greater than # source bits.");
797 std::shared_ptr<const jlm::rvsdg::Type> srctype,
798 std::shared_ptr<const jlm::rvsdg::Type> dsttype)
809 if (dt->nbits() < st->nbits())
810 throw util::Error(
"# destination bits must be greater than # source bits.");
814 operator==(
const Operation & other)
const noexcept
override;
816 [[nodiscard]] std::string
819 [[nodiscard]] std::unique_ptr<Operation>
820 copy()
const override;
832 return std::static_pointer_cast<const rvsdg::BitType>(
argument(0))->nbits();
838 return std::static_pointer_cast<const rvsdg::BitType>(
result(0))->nbits();
841 static std::unique_ptr<llvm::ThreeAddressCode>
842 create(
const Variable * operand,
const std::shared_ptr<const jlm::rvsdg::Type> & type)
848 std::make_unique<ZExtOperation>(std::move(operandBitType), std::move(resultBitType));
858 return *rvsdg::CreateOpNode<ZExtOperation>(
860 std::move(operandBitType),
861 std::move(resultBitType))
866 static std::shared_ptr<const rvsdg::BitType>
869 if (
auto bitType = std::dynamic_pointer_cast<const rvsdg::BitType>(type))
896 operator==(
const Operation & other)
const noexcept
override;
898 [[nodiscard]] std::string
901 [[nodiscard]] std::unique_ptr<Operation>
902 copy()
const override;
904 inline const ::llvm::APFloat &
913 return std::static_pointer_cast<const FloatingPointType>(
result(0))->size();
916 static std::unique_ptr<llvm::ThreeAddressCode>
917 create(const ::llvm::APFloat &
constant,
const std::shared_ptr<const jlm::rvsdg::Type> & type)
919 auto ft = std::dynamic_pointer_cast<const FloatingPointType>(type);
921 throw util::Error(
"expected floating point type.");
923 auto op = std::make_unique<ConstantFP>(std::move(ft),
constant);
973 operator==(
const Operation & other)
const noexcept
override;
975 [[nodiscard]] std::string
978 [[nodiscard]] std::unique_ptr<Operation>
979 copy()
const override;
983 const noexcept
override;
1000 return std::static_pointer_cast<const FloatingPointType>(
argument(0))->size();
1003 static std::unique_ptr<llvm::ThreeAddressCode>
1006 auto ft = std::dynamic_pointer_cast<const FloatingPointType>(op1->
Type());
1008 throw util::Error(
"expected floating point type.");
1010 auto op = std::make_unique<FCmpOperation>(
cmp, std::move(ft));
1040 operator==(
const Operation & other)
const noexcept
override;
1042 [[nodiscard]] std::string
1045 [[nodiscard]] std::unique_ptr<Operation>
1046 copy()
const override;
1057 return rvsdg::CreateOpNode<UndefValueOperation>(region, std::move(type)).output(0);
1060 static std::unique_ptr<llvm::ThreeAddressCode>
1061 Create(std::shared_ptr<const jlm::rvsdg::Type> type)
1063 auto operation = std::make_unique<UndefValueOperation>(std::move(type));
1067 static std::unique_ptr<llvm::ThreeAddressCode>
1068 Create(std::shared_ptr<const jlm::rvsdg::Type> type,
const std::string & name)
1070 auto operation = std::make_unique<UndefValueOperation>(std::move(type));
1074 static std::unique_ptr<llvm::ThreeAddressCode>
1077 auto & type =
result->Type();
1079 std::vector<std::unique_ptr<ThreeAddressCodeVariable>> results;
1080 results.push_back(std::move(
result));
1082 auto operation = std::make_unique<UndefValueOperation>(type);
1111 operator==(
const Operation & other)
const noexcept
override;
1116 [[nodiscard]] std::unique_ptr<Operation>
1117 copy()
const override;
1125 static std::unique_ptr<llvm::ThreeAddressCode>
1126 Create(
const std::shared_ptr<const jlm::rvsdg::Type> & type)
1130 auto operation = std::make_unique<PoisonValueOperation>(std::move(valueType));
1139 return rvsdg::CreateOpNode<PoisonValueOperation>(*region, std::move(valueType)).output(0);
1143 static std::shared_ptr<const jlm::rvsdg::Type>
1168 throw std::runtime_error(
"FreezeOperation given non-value type");
1172 operator==(
const Operation & other)
const noexcept
override;
1183 [[nodiscard]] std::unique_ptr<Operation>
1184 copy()
const override;
1192 static std::unique_ptr<llvm::ThreeAddressCode>
1195 auto operation = std::make_unique<FreezeOperation>(operand.
Type());
1202 return rvsdg::CreateOpNode<FreezeOperation>({ &operand }, operand.
Type());
1235 operator==(
const Operation & other)
const noexcept
override;
1237 [[nodiscard]] std::string
1240 [[nodiscard]] std::unique_ptr<Operation>
1241 copy()
const override;
1245 const noexcept
override;
1262 return std::static_pointer_cast<const FloatingPointType>(
result(0))->size();
1265 static std::unique_ptr<llvm::ThreeAddressCode>
1268 auto ft = std::dynamic_pointer_cast<const FloatingPointType>(op1->
Type());
1270 throw util::Error(
"expected floating point type.");
1272 auto op = std::make_unique<FBinaryOperation>(
fpop, ft);
1289 throw util::Error(
"destination type size must be bigger than source type size.");
1293 const std::shared_ptr<const FloatingPointType> & srctype,
1294 const std::shared_ptr<const FloatingPointType> & dsttype)
1298 throw util::Error(
"destination type size must be bigger than source type size.");
1302 std::shared_ptr<const jlm::rvsdg::Type> srctype,
1303 std::shared_ptr<const jlm::rvsdg::Type> dsttype)
1308 throw util::Error(
"expected floating point type.");
1312 throw util::Error(
"expected floating point type.");
1315 throw util::Error(
"destination type size must be bigger than source type size.");
1319 operator==(
const Operation & other)
const noexcept
override;
1321 [[nodiscard]] std::string
1324 [[nodiscard]] std::unique_ptr<Operation>
1325 copy()
const override;
1337 return std::static_pointer_cast<const FloatingPointType>(
argument(0))->size();
1343 return std::static_pointer_cast<const FloatingPointType>(
result(0))->size();
1346 static std::unique_ptr<llvm::ThreeAddressCode>
1347 create(
const Variable * operand,
const std::shared_ptr<const jlm::rvsdg::Type> & type)
1349 auto st = std::dynamic_pointer_cast<const FloatingPointType>(operand->
Type());
1351 throw util::Error(
"expected floating point type.");
1353 auto dt = std::dynamic_pointer_cast<const FloatingPointType>(type);
1355 throw util::Error(
"expected floating point type.");
1357 auto op = std::make_unique<FPExtOperation>(std::move(st), std::move(dt));
1376 operator==(
const Operation & other)
const noexcept
override;
1378 [[nodiscard]] std::string
1381 [[nodiscard]] std::unique_ptr<Operation>
1382 copy()
const override;
1394 return std::static_pointer_cast<const FloatingPointType>(
argument(0))->size();
1397 static std::unique_ptr<llvm::ThreeAddressCode>
1400 auto type = std::dynamic_pointer_cast<const FloatingPointType>(operand->
Type());
1402 throw util::Error(
"expected floating point type.");
1404 auto op = std::make_unique<FNegOperation>(std::move(type));
1419 throw util::Error(
"destination tpye size must be smaller than source size type.");
1423 const std::shared_ptr<const FloatingPointType> & srctype,
1424 const std::shared_ptr<const FloatingPointType> & dsttype)
1428 throw util::Error(
"destination type size must be bigger than source type size.");
1432 std::shared_ptr<const jlm::rvsdg::Type> srctype,
1433 std::shared_ptr<const jlm::rvsdg::Type> dsttype)
1438 throw util::Error(
"expected floating point type.");
1442 throw util::Error(
"expected floating point type.");
1446 throw util::Error(
"destination type size must be smaller than source size type.");
1450 operator==(
const Operation & other)
const noexcept
override;
1452 [[nodiscard]] std::string
1455 [[nodiscard]] std::unique_ptr<Operation>
1456 copy()
const override;
1468 return std::static_pointer_cast<const FloatingPointType>(
argument(0))->size();
1474 return std::static_pointer_cast<const FloatingPointType>(
result(0))->size();
1477 static std::unique_ptr<llvm::ThreeAddressCode>
1480 auto st = std::dynamic_pointer_cast<const FloatingPointType>(operand->
Type());
1482 throw util::Error(
"expected floating point type.");
1484 auto dt = std::dynamic_pointer_cast<const FloatingPointType>(type);
1486 throw util::Error(
"expected floating point type.");
1488 auto op = std::make_unique<FPTruncOperation>(std::move(st), std::move(dt));
1511 operator==(
const Operation & other)
const noexcept
override;
1513 [[nodiscard]] std::string
1516 [[nodiscard]] std::unique_ptr<Operation>
1517 copy()
const override;
1519 static std::unique_ptr<llvm::ThreeAddressCode>
1520 create(
const std::vector<const Variable *> & arguments)
1522 std::vector<std::shared_ptr<const jlm::rvsdg::Type>>
operands;
1523 for (
const auto &
argument : arguments)
1526 auto op = std::make_unique<VariadicArgumentListOperation>(std::move(
operands));
1533 std::vector<std::shared_ptr<const rvsdg::Type>> operandTypes;
1534 operandTypes.reserve(
operands.size());
1536 operandTypes.emplace_back(operand->Type());
1539 ? rvsdg::CreateOpNode<VariadicArgumentListOperation>(region, std::move(operandTypes))
1541 : rvsdg::CreateOpNode<VariadicArgumentListOperation>(
operands, std::move(operandTypes))
1552 std::shared_ptr<const
jlm::rvsdg::Type> srctype,
1553 std::shared_ptr<const
jlm::rvsdg::Type> dsttype)
1570 operator==(
const Operation & other)
const noexcept
override;
1572 [[nodiscard]] std::string
1575 [[nodiscard]] std::unique_ptr<Operation>
1576 copy()
const override;
1585 static std::unique_ptr<llvm::ThreeAddressCode>
1590 auto op = std::make_unique<BitCastOperation>(pair.first, pair.second);
1598 return rvsdg::CreateOpNode<BitCastOperation>({ operand }, pair.first, pair.second).output(0);
1602 static std::pair<std::shared_ptr<const jlm::rvsdg::Type>, std::shared_ptr<const jlm::rvsdg::Type>>
1604 const std::shared_ptr<const jlm::rvsdg::Type> & otype,
1605 const std::shared_ptr<const jlm::rvsdg::Type> & rtype)
1613 return std::make_pair(otype, rtype);
1627 operator==(
const Operation & other)
const noexcept
override;
1629 [[nodiscard]] std::string
1632 [[nodiscard]] std::unique_ptr<Operation>
1633 copy()
const override;
1638 return *std::static_pointer_cast<const StructType>(
result(0));
1641 static std::unique_ptr<llvm::ThreeAddressCode>
1643 const std::vector<const Variable *> & elements,
1644 const std::shared_ptr<const jlm::rvsdg::Type> &
type)
1648 auto op = std::make_unique<ConstantStruct>(std::move(structType));
1655 const std::vector<rvsdg::Output *> &
operands,
1656 std::shared_ptr<const rvsdg::Type> resultType)
1659 return *rvsdg::CreateOpNode<ConstantStruct>(
operands, std::move(structType)).output(0);
1663 static inline std::vector<std::shared_ptr<const rvsdg::Type>>
1666 std::vector<std::shared_ptr<const rvsdg::Type>> types;
1673 static std::shared_ptr<const StructType>
1676 if (
auto structType = std::dynamic_pointer_cast<const StructType>(
type))
1691 const std::shared_ptr<const
jlm::rvsdg::BitType> & otype,
1692 const std::shared_ptr<const
jlm::rvsdg::BitType> & rtype)
1695 if (otype->nbits() < rtype->nbits())
1696 throw util::Error(
"expected operand's #bits to be larger than results' #bits.");
1700 std::shared_ptr<const jlm::rvsdg::Type> optype,
1701 std::shared_ptr<const jlm::rvsdg::Type> restype)
1712 if (ot->nbits() < rt->nbits())
1713 throw util::Error(
"expected operand's #bits to be larger than results' #bits.");
1717 operator==(
const Operation & other)
const noexcept
override;
1719 [[nodiscard]] std::string
1722 [[nodiscard]] std::unique_ptr<Operation>
1723 copy()
const override;
1735 return std::static_pointer_cast<const rvsdg::BitType>(
argument(0))->nbits();
1741 return std::static_pointer_cast<const rvsdg::BitType>(
result(0))->nbits();
1744 static std::unique_ptr<llvm::ThreeAddressCode>
1745 create(
const Variable * operand,
const std::shared_ptr<const jlm::rvsdg::Type> & type)
1747 auto ot = std::dynamic_pointer_cast<const jlm::rvsdg::BitType>(operand->
Type());
1751 auto rt = std::dynamic_pointer_cast<const jlm::rvsdg::BitType>(type);
1755 auto op = std::make_unique<TruncOperation>(std::move(ot), std::move(rt));
1762 auto ot = std::dynamic_pointer_cast<const jlm::rvsdg::BitType>(operand->
Type());
1766 return rvsdg::CreateOpNode<TruncOperation>(
1780 std::shared_ptr<const
jlm::rvsdg::BitType> srctype,
1786 std::shared_ptr<const jlm::rvsdg::Type> optype,
1787 std::shared_ptr<const jlm::rvsdg::Type> restype)
1796 throw util::Error(
"expected floating point type.");
1800 operator==(
const Operation & other)
const noexcept
override;
1802 [[nodiscard]] std::string
1805 [[nodiscard]] std::unique_ptr<Operation>
1806 copy()
const override;
1815 static std::unique_ptr<llvm::ThreeAddressCode>
1816 create(
const Variable * operand,
const std::shared_ptr<const jlm::rvsdg::Type> & type)
1818 auto st = std::dynamic_pointer_cast<const jlm::rvsdg::BitType>(operand->
Type());
1822 auto rt = std::dynamic_pointer_cast<const FloatingPointType>(type);
1824 throw util::Error(
"expected floating point type.");
1826 auto op = std::make_unique<UIToFPOperation>(std::move(st), std::move(rt));
1837 std::shared_ptr<const
jlm::rvsdg::BitType> srctype,
1843 std::shared_ptr<const jlm::rvsdg::Type> srctype,
1844 std::shared_ptr<const jlm::rvsdg::Type> dsttype)
1853 throw util::Error(
"expected floating point type.");
1857 operator==(
const Operation & other)
const noexcept
override;
1859 [[nodiscard]] std::string
1862 [[nodiscard]] std::unique_ptr<Operation>
1863 copy()
const override;
1872 static std::unique_ptr<llvm::ThreeAddressCode>
1873 create(
const Variable * operand,
const std::shared_ptr<const jlm::rvsdg::Type> & type)
1875 auto st = std::dynamic_pointer_cast<const jlm::rvsdg::BitType>(operand->
Type());
1879 auto rt = std::dynamic_pointer_cast<const FloatingPointType>(type);
1881 throw util::Error(
"expected floating point type.");
1883 auto op = std::make_unique<SIToFPOperation>(std::move(st), std::move(rt));
1901 operator==(
const Operation & other)
const noexcept
override;
1903 [[nodiscard]] std::string
1906 [[nodiscard]] std::unique_ptr<Operation>
1907 copy()
const override;
1912 return std::static_pointer_cast<const ArrayType>(
result(0))->nelements();
1918 return std::static_pointer_cast<const ArrayType>(
result(0))->element_type();
1921 static std::unique_ptr<llvm::ThreeAddressCode>
1922 create(
const std::vector<const Variable *> & elements)
1924 if (elements.size() == 0)
1925 throw util::Error(
"expected at least one element.\n");
1927 auto vt = elements[0]->Type();
1931 auto op = std::make_unique<ConstantArrayOperation>(
vt, elements.size());
1939 throw util::Error(
"Expected at least one element.\n");
1941 auto valueType =
operands[0]->Type();
1947 return rvsdg::CreateOpNode<ConstantArrayOperation>(
operands, valueType,
operands.size())
1960 auto st =
dynamic_cast<const StructType *
>(type.get());
1961 auto at =
dynamic_cast<const ArrayType *
>(type.get());
1962 auto vt =
dynamic_cast<const VectorType *
>(type.get());
1963 if (!st && !at && !
vt)
1964 throw util::Error(
"expected array, struct, or vector type.\n");
1968 operator==(
const Operation & other)
const noexcept
override;
1970 [[nodiscard]] std::string
1973 [[nodiscard]] std::unique_ptr<Operation>
1974 copy()
const override;
1976 static std::unique_ptr<llvm::ThreeAddressCode>
1977 create(std::shared_ptr<const jlm::rvsdg::Type> type)
1979 auto op = std::make_unique<ConstantAggregateZeroOperation>(std::move(type));
1986 return rvsdg::CreateOpNode<ConstantAggregateZeroOperation>(region, std::move(type)).output(0);
1996 const std::shared_ptr<const
VectorType> & vtype,
1997 const std::shared_ptr<const
jlm::rvsdg::BitType> & btype)
2002 operator==(
const Operation & other)
const noexcept
override;
2004 [[nodiscard]] std::string
2007 [[nodiscard]] std::unique_ptr<Operation>
2008 copy()
const override;
2010 static inline std::unique_ptr<llvm::ThreeAddressCode>
2013 auto vt = std::dynamic_pointer_cast<const VectorType>(vector->
Type());
2017 auto bt = std::dynamic_pointer_cast<const jlm::rvsdg::BitType>(index->
Type());
2021 auto op = std::make_unique<ExtractElementOperation>(
vt, bt);
2033 const std::vector<
int> & mask)
2039 const std::shared_ptr<const ScalableVectorType> & v,
2040 const std::vector<int> & mask)
2046 operator==(
const Operation & other)
const noexcept
override;
2048 [[nodiscard]] std::string
2051 [[nodiscard]] std::unique_ptr<Operation>
2052 copy()
const override;
2054 const ::llvm::ArrayRef<int>
2060 static std::unique_ptr<llvm::ThreeAddressCode>
2063 if (is<FixedVectorType>(v1->
type()) && is<FixedVectorType>(v2->
type()))
2064 return CreateShuffleVectorTac<FixedVectorType>(v1, v2, mask);
2066 if (is<ScalableVectorType>(v1->
type()) && is<ScalableVectorType>(v2->
type()))
2067 return CreateShuffleVectorTac<ScalableVectorType>(v1, v2, mask);
2069 throw util::Error(
"Expected vector types as operands.");
2073 template<
typename T>
2074 static std::unique_ptr<ThreeAddressCode>
2077 auto vt = std::static_pointer_cast<const T>(v1->
Type());
2078 auto op = std::make_unique<ShuffleVectorOperation>(
vt, mask);
2095 operator==(
const Operation & other)
const noexcept
override;
2097 [[nodiscard]] std::string
2100 [[nodiscard]] std::unique_ptr<Operation>
2101 copy()
const override;
2103 static inline std::unique_ptr<llvm::ThreeAddressCode>
2105 const std::vector<const Variable *> &
operands,
2106 const std::shared_ptr<const jlm::rvsdg::Type> & type)
2108 auto vt = std::dynamic_pointer_cast<const VectorType>(type);
2112 auto op = std::make_unique<ConstantVectorOperation>(
vt);
2123 const std::shared_ptr<const
VectorType> & vectype,
2124 const std::shared_ptr<const
jlm::rvsdg::Type> & vtype,
2125 const std::shared_ptr<const
jlm::rvsdg::BitType> & btype)
2128 if (vectype->type() != *vtype)
2130 auto received = vtype->debug_string();
2131 auto expected = vectype->type().debug_string();
2137 operator==(
const Operation & other)
const noexcept
override;
2139 [[nodiscard]] std::string
2142 [[nodiscard]] std::unique_ptr<Operation>
2143 copy()
const override;
2145 static inline std::unique_ptr<llvm::ThreeAddressCode>
2148 auto vct = std::dynamic_pointer_cast<const VectorType>(vector->
Type());
2156 auto bt = std::dynamic_pointer_cast<const jlm::rvsdg::BitType>(index->
Type());
2160 auto op = std::make_unique<InsertElementOperation>(vct,
vt, bt);
2172 const std::shared_ptr<const
VectorType> & operand,
2181 if (operand->type() != *op.argument(0))
2183 auto received = operand->type().debug_string();
2184 auto expected = op.argument(0)->debug_string();
2188 if (
result->type() != *op.result(0))
2190 auto received =
result->type().debug_string();
2191 auto expected = op.result(0)->debug_string();
2192 throw util::Error(
jlm::util::strfmt(
"expected ", expected,
", got ", received));
2203 op_(std::move(other.op_))
2219 op_ = std::move(other.op_);
2231 operator==(
const Operation & other)
const noexcept
override;
2233 [[nodiscard]] std::string
2236 [[nodiscard]] std::unique_ptr<Operation>
2237 copy()
const override;
2239 static inline std::unique_ptr<llvm::ThreeAddressCode>
2243 const std::shared_ptr<const jlm::rvsdg::Type> & type)
2245 auto vct1 = std::dynamic_pointer_cast<const VectorType>(operand->
Type());
2246 auto vct2 = std::dynamic_pointer_cast<const VectorType>(type);
2250 auto op = std::make_unique<VectorUnaryOperation>(unop, vct1, vct2);
2255 std::unique_ptr<Operation>
op_;
2265 const std::shared_ptr<const
VectorType> & op1,
2266 const std::shared_ptr<const
VectorType> & op2,
2272 throw util::Error(
"expected the same vector types.");
2274 if (op1->type() != *binop.argument(0))
2276 auto received = op1->type().debug_string();
2277 auto expected = binop.argument(0)->debug_string();
2281 if (
result->type() != *binop.result(0))
2283 auto received =
result->type().debug_string();
2284 auto expected = binop.result(0)->debug_string();
2285 throw util::Error(
jlm::util::strfmt(
"expected ", expected,
", got ", received));
2296 op_(std::move(other.op_))
2312 op_ = std::move(other.op_);
2324 operator==(
const Operation & other)
const noexcept
override;
2326 [[nodiscard]] std::string
2329 [[nodiscard]] std::unique_ptr<Operation>
2330 copy()
const override;
2332 static inline std::unique_ptr<llvm::ThreeAddressCode>
2337 const std::shared_ptr<const jlm::rvsdg::Type> & type)
2339 auto vct1 = std::dynamic_pointer_cast<const VectorType>(op1->
Type());
2340 auto vct2 = std::dynamic_pointer_cast<const VectorType>(op2->
Type());
2341 auto vct3 = std::dynamic_pointer_cast<const VectorType>(type);
2342 if (!vct1 || !vct2 || !vct3)
2345 auto op = std::make_unique<VectorBinaryOperation>(binop, vct1, vct2, vct3);
2350 std::unique_ptr<Operation>
op_;
2365 operator==(
const Operation & other)
const noexcept
override;
2367 [[nodiscard]] std::string
2370 [[nodiscard]] std::unique_ptr<Operation>
2371 copy()
const override;
2376 return std::static_pointer_cast<const VectorType>(
result(0))->size();
2382 return std::static_pointer_cast<const VectorType>(
result(0))->type();
2385 static std::unique_ptr<ThreeAddressCode>
2386 Create(
const std::vector<const Variable *> & elements)
2388 if (elements.empty())
2389 throw util::Error(
"Expected at least one element.");
2391 auto vt = elements[0]->Type();
2395 auto op = std::unique_ptr<ConstantDataVectorOperation>(
2418 operator==(
const Operation & other)
const noexcept
override;
2420 [[nodiscard]] std::string
2423 [[nodiscard]] std::unique_ptr<Operation>
2424 copy()
const override;
2426 const rvsdg::BitType &
2429 return *std::static_pointer_cast<const rvsdg::BitType>(
argument(0));
2443 auto & size = *node.
input(0);
2452 auto & ioState = *node.
input(1);
2461 auto & address = *node.
output(0);
2470 auto & ioState = *node.
output(1);
2479 auto & memoryState = *node.
output(2);
2480 JLM_ASSERT(is<MemoryStateType>(memoryState.Type()));
2484 static std::unique_ptr<ThreeAddressCode>
2488 auto op = std::make_unique<MallocOperation>(std::move(bitType));
2496 return rvsdg::CreateOpNode<MallocOperation>({ &size, &ioState }, std::move(bitType));
2500 static std::shared_ptr<const rvsdg::BitType>
2503 if (
auto bitType = std::dynamic_pointer_cast<const rvsdg::BitType>(type))
2506 throw std::runtime_error(
"Expected bits type.");
2525 operator==(
const Operation & other)
const noexcept
override;
2527 [[nodiscard]] std::string
2530 [[nodiscard]] std::unique_ptr<Operation>
2531 copy()
const override;
2541 const auto input = node.input(0);
2549 JLM_ASSERT(is<MemoryStateType>(output.Type()));
2550 auto [freeNode, freeOperation] = rvsdg::TryGetSimpleNodeAndOptionalOp<FreeOperation>(output);
2552 const auto input = freeNode->input(output.index() + 1);
2553 JLM_ASSERT(is<MemoryStateType>(input->Type()));
2557 static std::unique_ptr<llvm::ThreeAddressCode>
2560 const std::vector<const Variable *> & memoryStates,
2563 std::vector<const Variable *>
operands;
2568 auto operation = std::make_unique<FreeOperation>(memoryStates.size());
2572 static std::vector<jlm::rvsdg::Output *>
2575 const std::vector<jlm::rvsdg::Output *> & memoryStates,
2578 std::vector<jlm::rvsdg::Output *>
operands;
2583 return outputs(&rvsdg::CreateOpNode<FreeOperation>(
operands, memoryStates.size()));
2587 static std::vector<std::shared_ptr<const rvsdg::Type>>
2590 std::vector<std::shared_ptr<const rvsdg::Type>> memoryStates(
2595 types.insert(types.end(), memoryStates.begin(), memoryStates.end());
2601 static std::vector<std::shared_ptr<const rvsdg::Type>>
2604 std::vector<std::shared_ptr<const rvsdg::Type>> types(
static std::shared_ptr< const ArrayType > Create(std::shared_ptr< const Type > type, size_t nelements)
std::unique_ptr< Operation > copy() const override
static std::unique_ptr< llvm::ThreeAddressCode > create(const Variable *rhs, const Variable *lhs)
~AssignmentOperation() noexcept override
std::string debug_string() const override
AssignmentOperation(const AssignmentOperation &)=default
AssignmentOperation(AssignmentOperation &&)=default
bool operator==(const Operation &other) const noexcept override
bool operator==(const Operation &other) const noexcept override
std::string debug_string() const override
static std::pair< std::shared_ptr< const jlm::rvsdg::Type >, std::shared_ptr< const jlm::rvsdg::Type > > check_types(const std::shared_ptr< const jlm::rvsdg::Type > &otype, const std::shared_ptr< const jlm::rvsdg::Type > &rtype)
BitCastOperation(const BitCastOperation &)=default
BitCastOperation(Operation &&)=delete
std::unique_ptr< Operation > copy() const override
static jlm::rvsdg::Output * create(jlm::rvsdg::Output *operand, std::shared_ptr< const jlm::rvsdg::Type > rtype)
jlm::rvsdg::Output * reduce_operand(jlm::rvsdg::unop_reduction_path_t path, jlm::rvsdg::Output *output) const override
BitCastOperation & operator=(Operation &&)=delete
jlm::rvsdg::unop_reduction_path_t can_reduce_operand(const jlm::rvsdg::Output *output) const noexcept override
BitCastOperation & operator=(const Operation &)=delete
~BitCastOperation() noexcept override
static std::unique_ptr< llvm::ThreeAddressCode > create(const Variable *operand, std::shared_ptr< const jlm::rvsdg::Type > type)
std::string debug_string() const override
size_t nalternatives() const noexcept
~BranchOperation() noexcept override
static std::unique_ptr< llvm::ThreeAddressCode > create(size_t nalternatives, const Variable *operand)
std::unique_ptr< Operation > copy() const override
bool operator==(const Operation &other) const noexcept override
static std::unique_ptr< llvm::ThreeAddressCode > create(std::shared_ptr< const jlm::rvsdg::Type > type)
std::unique_ptr< Operation > copy() const override
~ConstantAggregateZeroOperation() noexcept override
static jlm::rvsdg::Output * Create(rvsdg::Region ®ion, std::shared_ptr< const jlm::rvsdg::Type > type)
bool operator==(const Operation &other) const noexcept override
std::string debug_string() const override
const jlm::rvsdg::Type & type() const noexcept
~ConstantArrayOperation() noexcept override
std::unique_ptr< Operation > copy() const override
bool operator==(const Operation &other) const noexcept override
std::string debug_string() const override
static rvsdg::Output * Create(const std::vector< rvsdg::Output * > &operands)
static std::unique_ptr< llvm::ThreeAddressCode > create(const std::vector< const Variable * > &elements)
size_t size() const noexcept
static jlm::rvsdg::Output * Create(const std::vector< jlm::rvsdg::Output * > &elements)
static std::unique_ptr< llvm::ThreeAddressCode > create(const std::vector< const Variable * > &elements)
const jlm::rvsdg::Type & type() const noexcept
size_t size() const noexcept
~ConstantDataArray() noexcept override
std::unique_ptr< Operation > copy() const override
std::string debug_string() const override
bool operator==(const Operation &other) const noexcept override
bool operator==(const Operation &other) const noexcept override
static std::unique_ptr< ThreeAddressCode > Create(const std::vector< const Variable * > &elements)
const jlm::rvsdg::Type & type() const noexcept
~ConstantDataVectorOperation() noexcept override
std::unique_ptr< Operation > copy() const override
size_t size() const noexcept
ConstantDataVectorOperation(const std::shared_ptr< const VectorType > &vt)
std::string debug_string() const override
~ConstantFP() noexcept override
const fpsize & size() const noexcept
ConstantFP(std::shared_ptr< const FloatingPointType > fpt, const ::llvm::APFloat &constant)
std::unique_ptr< Operation > copy() const override
::llvm::APFloat constant_
bool operator==(const Operation &other) const noexcept override
const ::llvm::APFloat & constant() const noexcept
std::string debug_string() const override
static std::unique_ptr< llvm::ThreeAddressCode > create(const ::llvm::APFloat &constant, const std::shared_ptr< const jlm::rvsdg::Type > &type)
ConstantPointerNullOperation class.
std::string debug_string() const override
static jlm::rvsdg::Output * Create(rvsdg::Region *region, std::shared_ptr< const rvsdg::Type > type)
static const std::shared_ptr< const PointerType > CheckAndExtractType(std::shared_ptr< const jlm::rvsdg::Type > type)
static std::unique_ptr< llvm::ThreeAddressCode > Create(std::shared_ptr< const rvsdg::Type > type)
const PointerType & GetPointerType() const noexcept
bool operator==(const Operation &other) const noexcept override
~ConstantPointerNullOperation() noexcept override
std::unique_ptr< Operation > copy() const override
static rvsdg::Output & Create(rvsdg::Region &, const std::vector< rvsdg::Output * > &operands, std::shared_ptr< const rvsdg::Type > resultType)
static std::vector< std::shared_ptr< const rvsdg::Type > > create_srctypes(const StructType &type)
bool operator==(const Operation &other) const noexcept override
static std::shared_ptr< const StructType > CheckAndExtractStructType(std::shared_ptr< const rvsdg::Type > type)
std::string debug_string() const override
~ConstantStruct() override
std::unique_ptr< Operation > copy() const override
ConstantStruct(std::shared_ptr< const StructType > type)
static std::unique_ptr< llvm::ThreeAddressCode > create(const std::vector< const Variable * > &elements, const std::shared_ptr< const jlm::rvsdg::Type > &type)
const StructType & type() const noexcept
bool operator==(const Operation &other) const noexcept override
std::unique_ptr< Operation > copy() const override
static std::unique_ptr< llvm::ThreeAddressCode > create(const std::vector< const Variable * > &operands, const std::shared_ptr< const jlm::rvsdg::Type > &type)
~ConstantVectorOperation() noexcept override
std::string debug_string() const override
bool operator==(const Operation &other) const noexcept override
std::string debug_string() const override
~ControlToIntOperation() noexcept override
static std::unique_ptr< llvm::ThreeAddressCode > create(const Variable *operand, const std::shared_ptr< const jlm::rvsdg::Type > &type)
std::unique_ptr< Operation > copy() const override
const fpsize & size() const noexcept
const llvm::fpop & fpop() const noexcept
std::string debug_string() const override
jlm::rvsdg::binop_reduction_path_t can_reduce_operand_pair(const jlm::rvsdg::Output *op1, const jlm::rvsdg::Output *op2) const noexcept override
std::unique_ptr< Operation > copy() const override
static std::unique_ptr< llvm::ThreeAddressCode > create(const llvm::fpop &fpop, const Variable *op1, const Variable *op2)
FBinaryOperation(const llvm::fpop &op, const std::shared_ptr< const FloatingPointType > &fpt)
jlm::rvsdg::Output * reduce_operand_pair(jlm::rvsdg::binop_reduction_path_t path, jlm::rvsdg::Output *op1, jlm::rvsdg::Output *op2) const override
~FBinaryOperation() noexcept override
bool operator==(const Operation &other) const 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
const fpcmp & cmp() const noexcept
~FCmpOperation() noexcept override
FCmpOperation(const fpcmp &cmp, const std::shared_ptr< const FloatingPointType > &fpt)
std::string debug_string() const override
bool operator==(const Operation &other) const noexcept override
jlm::rvsdg::Output * reduce_operand_pair(jlm::rvsdg::binop_reduction_path_t path, jlm::rvsdg::Output *op1, jlm::rvsdg::Output *op2) const override
std::unique_ptr< Operation > copy() const override
static std::unique_ptr< llvm::ThreeAddressCode > create(const fpcmp &cmp, const Variable *op1, const Variable *op2)
const fpsize & size() const noexcept
const fpsize & size() const noexcept
jlm::rvsdg::Output * reduce_operand(jlm::rvsdg::unop_reduction_path_t path, jlm::rvsdg::Output *output) const override
bool operator==(const Operation &other) const noexcept override
jlm::rvsdg::unop_reduction_path_t can_reduce_operand(const jlm::rvsdg::Output *output) const noexcept override
std::unique_ptr< Operation > copy() const override
static std::unique_ptr< llvm::ThreeAddressCode > create(const Variable *operand)
~FNegOperation() noexcept override
std::string debug_string() const override
FNegOperation(const std::shared_ptr< const FloatingPointType > &fpt)
FPExtOperation(std::shared_ptr< const jlm::rvsdg::Type > srctype, std::shared_ptr< const jlm::rvsdg::Type > dsttype)
const fpsize & dstsize() const noexcept
~FPExtOperation() noexcept override
std::string debug_string() const override
jlm::rvsdg::Output * reduce_operand(jlm::rvsdg::unop_reduction_path_t path, jlm::rvsdg::Output *output) const override
jlm::rvsdg::unop_reduction_path_t can_reduce_operand(const jlm::rvsdg::Output *output) const noexcept override
bool operator==(const Operation &other) const noexcept override
std::unique_ptr< Operation > copy() const override
const fpsize & srcsize() const noexcept
FPExtOperation(const std::shared_ptr< const FloatingPointType > &srctype, const std::shared_ptr< const FloatingPointType > &dsttype)
static std::unique_ptr< llvm::ThreeAddressCode > create(const Variable *operand, const std::shared_ptr< const jlm::rvsdg::Type > &type)
bool operator==(const Operation &other) const noexcept override
FPTruncOperation(const std::shared_ptr< const FloatingPointType > &srctype, const std::shared_ptr< const FloatingPointType > &dsttype)
const fpsize & dstsize() const noexcept
static std::unique_ptr< llvm::ThreeAddressCode > create(const Variable *operand, std::shared_ptr< const jlm::rvsdg::Type > type)
const fpsize & srcsize() const noexcept
jlm::rvsdg::unop_reduction_path_t can_reduce_operand(const jlm::rvsdg::Output *output) const noexcept override
std::unique_ptr< Operation > copy() const override
std::string debug_string() const override
~FPTruncOperation() noexcept override
jlm::rvsdg::Output * reduce_operand(jlm::rvsdg::unop_reduction_path_t path, jlm::rvsdg::Output *output) const override
FPTruncOperation(std::shared_ptr< const jlm::rvsdg::Type > srctype, std::shared_ptr< const jlm::rvsdg::Type > dsttype)
static std::shared_ptr< const FixedVectorType > Create(std::shared_ptr< const rvsdg::Type > type, size_t size)
jlm::rvsdg::Output * reduce_operand(jlm::rvsdg::unop_reduction_path_t path, jlm::rvsdg::Output *output) const override
jlm::rvsdg::unop_reduction_path_t can_reduce_operand(const jlm::rvsdg::Output *output) const noexcept override
FloatingPointToSignedIntegerOperation(std::shared_ptr< const jlm::rvsdg::Type > srctype, std::shared_ptr< const jlm::rvsdg::Type > dsttype)
bool operator==(const Operation &other) const noexcept override
static std::unique_ptr< llvm::ThreeAddressCode > create(const Variable *operand, const std::shared_ptr< const jlm::rvsdg::Type > &type)
FloatingPointToSignedIntegerOperation(std::shared_ptr< const FloatingPointType > fpt, std::shared_ptr< const jlm::rvsdg::BitType > type)
~FloatingPointToSignedIntegerOperation() noexcept override
std::string debug_string() const override
std::unique_ptr< Operation > copy() const override
bool operator==(const Operation &other) const noexcept override
FloatingPointToUnsignedIntegerOperation(std::shared_ptr< const jlm::rvsdg::Type > srctype, std::shared_ptr< const jlm::rvsdg::Type > dsttype)
jlm::rvsdg::Output * reduce_operand(jlm::rvsdg::unop_reduction_path_t path, jlm::rvsdg::Output *output) const override
std::string debug_string() const override
static std::unique_ptr< llvm::ThreeAddressCode > create(const Variable *operand, const std::shared_ptr< const jlm::rvsdg::Type > &type)
jlm::rvsdg::unop_reduction_path_t can_reduce_operand(const jlm::rvsdg::Output *output) const noexcept override
FloatingPointToUnsignedIntegerOperation(std::shared_ptr< const FloatingPointType > fpt, std::shared_ptr< const jlm::rvsdg::BitType > type)
std::unique_ptr< Operation > copy() const override
~FloatingPointToUnsignedIntegerOperation() noexcept override
static std::shared_ptr< const FloatingPointType > Create(fpsize size)
static rvsdg::Input & addressInput(const rvsdg::Node &node) noexcept
bool operator==(const Operation &other) const noexcept override
static std::vector< std::shared_ptr< const rvsdg::Type > > CreateResultTypes(size_t numMemoryStates)
std::unique_ptr< Operation > copy() const override
static std::vector< std::shared_ptr< const rvsdg::Type > > CreateOperandTypes(size_t numMemoryStates)
static std::unique_ptr< llvm::ThreeAddressCode > Create(const Variable *pointer, const std::vector< const Variable * > &memoryStates, const Variable *iOState)
static rvsdg::Input & mapMemoryStateOutputToInput(rvsdg::Output &output) noexcept
~FreeOperation() noexcept override
static std::vector< jlm::rvsdg::Output * > Create(jlm::rvsdg::Output *pointer, const std::vector< jlm::rvsdg::Output * > &memoryStates, jlm::rvsdg::Output *iOState)
std::string debug_string() const override
std::string debug_string() const override
~FreezeOperation() noexcept override
std::unique_ptr< Operation > copy() const override
static std::unique_ptr< llvm::ThreeAddressCode > createTac(const Variable &operand)
jlm::rvsdg::Output * reduce_operand(rvsdg::unop_reduction_path_t path, jlm::rvsdg::Output *arg) const override
rvsdg::unop_reduction_path_t can_reduce_operand(const jlm::rvsdg::Output *arg) const noexcept override
const jlm::rvsdg::Type & getType() const noexcept
bool operator==(const Operation &other) const noexcept override
static jlm::rvsdg::Node & createNode(jlm::rvsdg::Output &operand)
static std::shared_ptr< const IOStateType > Create()
bool operator==(const Operation &other) const noexcept override
std::string debug_string() const override
~InsertElementOperation() noexcept override
static std::unique_ptr< llvm::ThreeAddressCode > create(const llvm::Variable *vector, const llvm::Variable *value, const llvm::Variable *index)
std::unique_ptr< Operation > copy() const override
std::unique_ptr< Operation > copy() const override
std::string debug_string() const override
size_t nbits() const noexcept
jlm::rvsdg::unop_reduction_path_t can_reduce_operand(const jlm::rvsdg::Output *output) const noexcept override
~IntegerToPointerOperation() noexcept override
static jlm::rvsdg::Output * create(jlm::rvsdg::Output *operand, std::shared_ptr< const jlm::rvsdg::Type > type)
bool operator==(const Operation &other) const noexcept override
jlm::rvsdg::Output * reduce_operand(jlm::rvsdg::unop_reduction_path_t path, jlm::rvsdg::Output *output) const override
IntegerToPointerOperation(std::shared_ptr< const jlm::rvsdg::Type > srctype, std::shared_ptr< const jlm::rvsdg::Type > dsttype)
static std::unique_ptr< llvm::ThreeAddressCode > create(const Variable *argument, std::shared_ptr< const jlm::rvsdg::Type > type)
bool operator==(const Operation &other) const noexcept override
std::unique_ptr< Operation > copy() const override
static rvsdg::Output & ioStateOutput(const rvsdg::Node &node)
static rvsdg::Input & ioStateInput(const rvsdg::Node &node)
static std::unique_ptr< ThreeAddressCode > createTac(const Variable *size, const Variable *ioState)
std::string debug_string() const override
~MallocOperation() noexcept override
static rvsdg::Input & sizeInput(const rvsdg::Node &node)
static rvsdg::SimpleNode & createNode(rvsdg::Output &size, rvsdg::Output &ioState)
static rvsdg::Output & addressOutput(const rvsdg::Node &node)
static rvsdg::Output & memoryStateOutput(const rvsdg::Node &node)
static std::shared_ptr< const rvsdg::BitType > checkAndExtractSizeType(const std::shared_ptr< const rvsdg::Type > &type)
const rvsdg::BitType & getSizeType() const noexcept
rvsdg::FunctionType getFunctionType() const
static std::shared_ptr< const MemoryStateType > Create()
static std::shared_ptr< const PointerType > Create()
PoisonValueOperation class.
bool operator==(const Operation &other) const noexcept override
static std::shared_ptr< const jlm::rvsdg::Type > CheckAndConvertType(const std::shared_ptr< const jlm::rvsdg::Type > &type)
PoisonValueOperation(PoisonValueOperation &&)=delete
~PoisonValueOperation() noexcept override
PoisonValueOperation & operator=(PoisonValueOperation &&)=delete
std::string debug_string() const override
const jlm::rvsdg::Type & GetType() const noexcept
PoisonValueOperation & operator=(const PoisonValueOperation &)=delete
static std::unique_ptr< llvm::ThreeAddressCode > Create(const std::shared_ptr< const jlm::rvsdg::Type > &type)
PoisonValueOperation(const PoisonValueOperation &)=default
std::unique_ptr< Operation > copy() const override
static jlm::rvsdg::Output * Create(rvsdg::Region *region, const std::shared_ptr< const jlm::rvsdg::Type > &type)
~PtrCmpOperation() noexcept override
static std::unique_ptr< llvm::ThreeAddressCode > create(ICmpPredicate predicateKind, const Variable *op1, const Variable *op2)
bool operator==(const Operation &other) const noexcept override
ICmpPredicate predicate() const noexcept
jlm::rvsdg::binop_reduction_path_t can_reduce_operand_pair(const jlm::rvsdg::Output *op1, const jlm::rvsdg::Output *op2) const noexcept override
std::string debug_string() const override
jlm::rvsdg::Output * reduce_operand_pair(jlm::rvsdg::binop_reduction_path_t path, jlm::rvsdg::Output *op1, jlm::rvsdg::Output *op2) const override
std::unique_ptr< Operation > copy() const override
std::unique_ptr< Operation > copy() const override
PtrToIntOperation(std::shared_ptr< const jlm::rvsdg::Type > srctype, std::shared_ptr< const jlm::rvsdg::Type > dsttype)
std::string debug_string() const override
jlm::rvsdg::unop_reduction_path_t can_reduce_operand(const jlm::rvsdg::Output *output) const noexcept override
jlm::rvsdg::Output * reduce_operand(jlm::rvsdg::unop_reduction_path_t path, jlm::rvsdg::Output *output) const override
static std::unique_ptr< llvm::ThreeAddressCode > create(const Variable *argument, const std::shared_ptr< const jlm::rvsdg::Type > &type)
bool operator==(const Operation &other) const noexcept override
~PtrToIntOperation() noexcept override
size_t nbits() const noexcept
~SIToFPOperation() noexcept override
jlm::rvsdg::unop_reduction_path_t can_reduce_operand(const jlm::rvsdg::Output *output) const noexcept override
static std::unique_ptr< llvm::ThreeAddressCode > create(const Variable *operand, const std::shared_ptr< const jlm::rvsdg::Type > &type)
std::unique_ptr< Operation > copy() const override
jlm::rvsdg::Output * reduce_operand(jlm::rvsdg::unop_reduction_path_t path, jlm::rvsdg::Output *output) const override
bool operator==(const Operation &other) const noexcept override
std::string debug_string() const override
SIToFPOperation(std::shared_ptr< const jlm::rvsdg::Type > srctype, std::shared_ptr< const jlm::rvsdg::Type > dsttype)
bool operator==(const Operation &other) const noexcept override
const std::shared_ptr< const jlm::rvsdg::Type > & Type() const noexcept
std::string debug_string() const override
std::unique_ptr< Operation > copy() const override
static std::unique_ptr< llvm::ThreeAddressCode > create(const llvm::Variable *p, const llvm::Variable *t, const llvm::Variable *f)
~SelectOperation() noexcept override
const jlm::rvsdg::Type & type() const noexcept
const ::llvm::ArrayRef< int > Mask() const
std::string debug_string() const override
std::unique_ptr< Operation > copy() const override
static std::unique_ptr< llvm::ThreeAddressCode > create(const Variable *v1, const Variable *v2, const std::vector< int > &mask)
ShuffleVectorOperation(const std::shared_ptr< const ScalableVectorType > &v, const std::vector< int > &mask)
static std::unique_ptr< ThreeAddressCode > CreateShuffleVectorTac(const Variable *v1, const Variable *v2, const std::vector< int > &mask)
bool operator==(const Operation &other) const noexcept override
~ShuffleVectorOperation() noexcept override
ControlFlowGraphNode * GetIncomingNode(size_t n) const noexcept
SsaPhiOperation(const SsaPhiOperation &)=default
static std::unique_ptr< llvm::ThreeAddressCode > create(const std::vector< std::pair< const Variable *, ControlFlowGraphNode * >> &arguments, std::shared_ptr< const jlm::rvsdg::Type > type)
const std::shared_ptr< const rvsdg::Type > & Type() const noexcept
std::string debug_string() const override
SsaPhiOperation & operator=(SsaPhiOperation &&)=delete
bool operator==(const Operation &other) const noexcept override
SsaPhiOperation & operator=(const SsaPhiOperation &)=delete
std::unique_ptr< Operation > copy() const override
~SsaPhiOperation() noexcept override
std::vector< ControlFlowGraphNode * > IncomingNodes_
std::string debug_string() const override
size_t numElements() const noexcept
std::shared_ptr< const Type > getElementType(const size_t index) const noexcept
static std::unique_ptr< llvm::ThreeAddressCode > create(std::unique_ptr< rvsdg::SimpleOperation > operation, const std::vector< const Variable * > &operands)
std::string debug_string() const override
~TruncOperation() noexcept override
jlm::rvsdg::unop_reduction_path_t can_reduce_operand(const jlm::rvsdg::Output *operand) const noexcept override
bool operator==(const Operation &other) const noexcept override
size_t ndstbits() const noexcept
static std::unique_ptr< llvm::ThreeAddressCode > create(const Variable *operand, const std::shared_ptr< const jlm::rvsdg::Type > &type)
jlm::rvsdg::Output * reduce_operand(jlm::rvsdg::unop_reduction_path_t path, jlm::rvsdg::Output *operand) const override
TruncOperation(std::shared_ptr< const jlm::rvsdg::Type > optype, std::shared_ptr< const jlm::rvsdg::Type > restype)
static jlm::rvsdg::Output * create(size_t ndstbits, jlm::rvsdg::Output *operand)
size_t nsrcbits() const noexcept
std::unique_ptr< Operation > copy() const override
bool operator==(const Operation &other) const noexcept override
std::string debug_string() const override
UIToFPOperation(std::shared_ptr< const jlm::rvsdg::Type > optype, std::shared_ptr< const jlm::rvsdg::Type > restype)
jlm::rvsdg::unop_reduction_path_t can_reduce_operand(const jlm::rvsdg::Output *operand) const noexcept override
static std::unique_ptr< llvm::ThreeAddressCode > create(const Variable *operand, const std::shared_ptr< const jlm::rvsdg::Type > &type)
jlm::rvsdg::Output * reduce_operand(jlm::rvsdg::unop_reduction_path_t path, jlm::rvsdg::Output *operand) const override
std::unique_ptr< Operation > copy() const override
~UIToFPOperation() noexcept override
UndefValueOperation class.
UndefValueOperation & operator=(UndefValueOperation &&)=delete
~UndefValueOperation() noexcept override
static jlm::rvsdg::Output * Create(rvsdg::Region ®ion, std::shared_ptr< const jlm::rvsdg::Type > type)
std::string debug_string() const override
static std::unique_ptr< llvm::ThreeAddressCode > Create(std::shared_ptr< const jlm::rvsdg::Type > type, const std::string &name)
UndefValueOperation(const UndefValueOperation &)=default
std::unique_ptr< Operation > copy() const override
static std::unique_ptr< llvm::ThreeAddressCode > Create(std::unique_ptr< ThreeAddressCodeVariable > result)
bool operator==(const Operation &other) const noexcept override
const rvsdg::Type & GetType() const noexcept
UndefValueOperation & operator=(const UndefValueOperation &)=delete
static std::unique_ptr< llvm::ThreeAddressCode > Create(std::shared_ptr< const jlm::rvsdg::Type > type)
static std::shared_ptr< const VariableArgumentType > Create()
const jlm::rvsdg::Type & type() const noexcept
const std::shared_ptr< const jlm::rvsdg::Type > Type() const noexcept
static rvsdg::Output * Create(rvsdg::Region ®ion, const std::vector< rvsdg::Output * > &operands)
VariadicArgumentListOperation(const VariadicArgumentListOperation &)=default
static std::unique_ptr< llvm::ThreeAddressCode > create(const std::vector< const Variable * > &arguments)
std::string debug_string() const override
~VariadicArgumentListOperation() noexcept override
std::unique_ptr< Operation > copy() const override
VariadicArgumentListOperation & operator=(VariadicArgumentListOperation &&)=delete
VariadicArgumentListOperation & operator=(const VariadicArgumentListOperation &)=delete
bool operator==(const Operation &other) const noexcept override
bool operator==(const Operation &other) const noexcept override
std::string debug_string() const override
static std::unique_ptr< llvm::ThreeAddressCode > create(const rvsdg::BinaryOperation &binop, const llvm::Variable *op1, const llvm::Variable *op2, const std::shared_ptr< const jlm::rvsdg::Type > &type)
std::unique_ptr< Operation > copy() const override
VectorBinaryOperation(const VectorBinaryOperation &other)
const rvsdg::BinaryOperation & operation() const noexcept
std::unique_ptr< Operation > op_
~VectorBinaryOperation() noexcept override
VectorBinaryOperation & operator=(const VectorBinaryOperation &other)
VectorBinaryOperation & operator=(VectorBinaryOperation &&other) noexcept
VectorBinaryOperation(VectorBinaryOperation &&other) noexcept
size_t size() const noexcept
std::unique_ptr< Operation > copy() const override
const rvsdg::Type & type() const noexcept
const std::shared_ptr< const rvsdg::Type > & Type() const noexcept
static std::unique_ptr< ThreeAddressCode > createVectorSelectTac(const Variable *p, const Variable *t, const Variable *f)
std::string debug_string() const override
VectorSelectOperation(const std::shared_ptr< const VectorType > &pt, const std::shared_ptr< const VectorType > &vt)
bool operator==(const Operation &other) const noexcept override
~VectorSelectOperation() noexcept override
static std::unique_ptr< llvm::ThreeAddressCode > create(const Variable *p, const Variable *t, const Variable *f)
std::unique_ptr< Operation > op_
bool operator==(const Operation &other) const noexcept override
~VectorUnaryOperation() noexcept override
VectorUnaryOperation(const VectorUnaryOperation &other)
static std::unique_ptr< llvm::ThreeAddressCode > create(const rvsdg::UnaryOperation &unop, const llvm::Variable *operand, const std::shared_ptr< const jlm::rvsdg::Type > &type)
VectorUnaryOperation & operator=(VectorUnaryOperation &&other) noexcept
VectorUnaryOperation & operator=(const VectorUnaryOperation &other)
std::string debug_string() const override
VectorUnaryOperation(VectorUnaryOperation &&other) noexcept
const rvsdg::UnaryOperation & operation() const noexcept
std::unique_ptr< Operation > copy() const override
std::string debug_string() const override
size_t nsrcbits() const noexcept
jlm::rvsdg::Output * reduce_operand(jlm::rvsdg::unop_reduction_path_t path, jlm::rvsdg::Output *operand) const override
static std::unique_ptr< llvm::ThreeAddressCode > create(const Variable *operand, const std::shared_ptr< const jlm::rvsdg::Type > &type)
bool operator==(const Operation &other) const noexcept override
ZExtOperation(std::shared_ptr< const jlm::rvsdg::Type > srctype, std::shared_ptr< const jlm::rvsdg::Type > dsttype)
~ZExtOperation() noexcept override
ZExtOperation(const std::shared_ptr< const jlm::rvsdg::BitType > &srctype, const std::shared_ptr< const jlm::rvsdg::BitType > &dsttype)
static std::shared_ptr< const rvsdg::BitType > CheckAndExtractBitType(const std::shared_ptr< const rvsdg::Type > &type)
static rvsdg::Output & Create(rvsdg::Output &operand, const std::shared_ptr< const rvsdg::Type > &resultType)
std::unique_ptr< Operation > copy() const override
jlm::rvsdg::unop_reduction_path_t can_reduce_operand(const jlm::rvsdg::Output *operand) const noexcept override
size_t ndstbits() const noexcept
static std::shared_ptr< const BitType > Create(std::size_t nbits)
Creates bit type of specified width.
static std::shared_ptr< const ControlType > Create(std::size_t nalternatives)
Instantiates control type.
virtual const Operation & GetOperation() const noexcept=0
NodeInput * input(size_t index) const noexcept
NodeOutput * output(size_t index) const noexcept
const std::shared_ptr< const rvsdg::Type > & Type() const noexcept
Represent acyclic RVSDG subgraphs.
const std::shared_ptr< const rvsdg::Type > & argument(size_t index) const noexcept
const std::shared_ptr< const rvsdg::Type > & result(size_t index) const noexcept
size_t nresults() const noexcept
SimpleOperation(std::vector< std::shared_ptr< const jlm::rvsdg::Type >> operands, std::vector< std::shared_ptr< const jlm::rvsdg::Type >> results)
size_t narguments() const noexcept
Global memory state passed between functions.
ICmpPredicate convertICmpPredicateToJlm(::llvm::CmpInst::Predicate predicate)
std::string_view iCmpPredicateToString(ICmpPredicate predicate)
::llvm::CmpInst::Predicate convertICmpPredicateToLlvm(ICmpPredicate predicate)
size_t unop_reduction_path_t
size_t binop_reduction_path_t
@ Value
Designate a value type.
static std::vector< jlm::rvsdg::Output * > operands(const Node *node)
static std::vector< jlm::rvsdg::Output * > outputs(const Node *node)
static std::string strfmt(Args... args)