6#ifndef JLM_LLVM_IR_OPERATORS_OPERATORS_HPP
7#define JLM_LLVM_IR_OPERATORS_OPERATORS_HPP
20#include <llvm/ADT/APFloat.h>
21#include <llvm/IR/InstrTypes.h>
41 const std::shared_ptr<const
jlm::rvsdg::
Type> & type)
55 operator==(
const Operation & other)
const noexcept override;
60 [[nodiscard]] std::unique_ptr<Operation>
61 copy()
const override;
63 const std::shared_ptr<const rvsdg::Type> &
76 static std::unique_ptr<llvm::ThreeAddressCode>
78 const std::vector<std::pair<const Variable *, ControlFlowGraphNode *>> &
arguments,
79 std::shared_ptr<const jlm::rvsdg::Type> type)
81 std::vector<ControlFlowGraphNode *> basicBlocks;
82 std::vector<const Variable *> operands;
85 basicBlocks.push_back(
argument.second);
89 auto phi = std::make_unique<SsaPhiOperation>(std::move(basicBlocks), std::move(type));
111 operator==(
const Operation & other)
const noexcept override;
113 [[nodiscard]] std::string
116 [[nodiscard]] std::unique_ptr<Operation>
117 copy()
const override;
119 static std::unique_ptr<llvm::ThreeAddressCode>
123 throw util::Error(
"LHS and RHS of assignment must have same type.");
125 auto operation = std::make_unique<AssignmentOperation>(rhs->
Type());
140 operator==(
const Operation & other)
const noexcept override;
145 [[nodiscard]] std::unique_ptr<Operation>
146 copy()
const override;
154 [[nodiscard]]
const std::shared_ptr<const jlm::rvsdg::Type> &
160 static std::unique_ptr<llvm::ThreeAddressCode>
163 auto op = std::make_unique<SelectOperation>(t->
Type());
182 operator==(
const Operation & other)
const noexcept override;
184 [[nodiscard]] std::string
187 [[nodiscard]] std::unique_ptr<Operation>
188 copy()
const override;
190 [[nodiscard]]
const rvsdg::Type &
196 [[nodiscard]]
const std::shared_ptr<const rvsdg::Type> &
208 static std::unique_ptr<llvm::ThreeAddressCode>
211 if (is<FixedVectorType>(p->
type()) && is<FixedVectorType>(t->
type()))
212 return createVectorSelectTac<FixedVectorType>(p, t, f);
214 if (is<ScalableVectorType>(p->
type()) && is<ScalableVectorType>(t->
type()))
215 return createVectorSelectTac<ScalableVectorType>(p, t, f);
217 throw util::Error(
"Expected vector types as operands.");
222 static std::unique_ptr<ThreeAddressCode>
225 auto fvt =
static_cast<const T *
>(&t->
type());
227 auto vt = T::Create(fvt->Type(), fvt->size());
243 operator==(
const Operation & other)
const noexcept override;
245 [[nodiscard]] std::string
248 [[nodiscard]] std::unique_ptr<Operation>
249 copy()
const override;
254 return std::static_pointer_cast<const rvsdg::ControlType>(
argument(0))->nalternatives();
257 static std::unique_ptr<llvm::ThreeAddressCode>
279 operator==(
const Operation & other)
const noexcept override;
281 [[nodiscard]] std::string
284 [[nodiscard]] std::unique_ptr<Operation>
285 copy()
const override;
287 static std::unique_ptr<ThreeAddressCode>
316 operator==(
const Operation & other)
const noexcept override;
318 [[nodiscard]] std::string
321 [[nodiscard]] std::unique_ptr<Operation>
322 copy()
const override;
327 return std::static_pointer_cast<const ArrayType>(
result(0))->nelements();
330 [[nodiscard]] std::shared_ptr<const ArrayType>
334 return std::static_pointer_cast<const ArrayType>(
result(0));
337 static std::unique_ptr<ThreeAddressCode>
338 create(
const std::vector<const Variable *> & elements)
340 if (elements.size() == 0)
341 throw util::Error(
"expected at least one element.");
343 auto vt = elements[0]->Type();
347 auto op = std::make_unique<ConstantDataArrayOperation>(std::move(
vt), elements.size());
352 Create(
const std::vector<rvsdg::Output *> & elements)
354 if (elements.empty())
355 throw util::Error(
"Expected at least one element.");
357 auto valueType = elements[0]->Type();
365 std::move(valueType),
400[[nodiscard]] ::llvm::CmpInst::Predicate
407[[nodiscard]] std::string_view
421 operator==(
const Operation & other)
const noexcept override;
423 [[nodiscard]] std::string
426 [[nodiscard]] std::unique_ptr<Operation>
427 copy()
const override;
431 const noexcept override;
445 static std::unique_ptr<llvm::ThreeAddressCode>
448 auto pt = std::dynamic_pointer_cast<const PointerType>(op1->
Type());
452 auto op = std::make_unique<PtrCmpOperation>(std::move(pt), predicateKind);
460 { &operand1, &operand2 },
476 static std::optional<std::vector<rvsdg::Output *>>
479 const std::vector<rvsdg::Output *> & operands);
503 operator==(
const Operation & other)
const noexcept override;
505 [[nodiscard]] std::string
508 [[nodiscard]] std::unique_ptr<Operation>
509 copy()
const override;
511 inline const ::llvm::APFloat &
520 return std::static_pointer_cast<const FloatingPointType>(
result(0))->size();
523 [[nodiscard]]
static std::unique_ptr<ConstantFP>
524 create(const ::llvm::APFloat &
constant,
const std::shared_ptr<const jlm::rvsdg::Type> & type)
526 auto ft = std::dynamic_pointer_cast<const FloatingPointType>(type);
528 throw util::Error(
"expected floating point type.");
530 return std::make_unique<ConstantFP>(std::move(ft),
constant);
533 [[nodiscard]]
static std::unique_ptr<llvm::ThreeAddressCode>
534 createTac(const ::llvm::APFloat &
constant,
const std::shared_ptr<const jlm::rvsdg::Type> & type)
548 [[nodiscard]] static ::llvm::APFloat
554 return ::llvm::APFloat::getZero(::llvm::APFloat::IEEEhalf());
556 return ::llvm::APFloat::getZero(::llvm::APFloat::IEEEsingle());
558 return ::llvm::APFloat::getZero(::llvm::APFloat::IEEEdouble());
560 return ::llvm::APFloat::getZero(::llvm::APFloat::x87DoubleExtended());
562 return ::llvm::APFloat::getZero(::llvm::APFloat::IEEEquad());
614 operator==(
const Operation & other)
const noexcept override;
616 [[nodiscard]] std::string
619 [[nodiscard]] std::unique_ptr<Operation>
620 copy()
const override;
624 const noexcept override;
641 return std::static_pointer_cast<const FloatingPointType>(
argument(0))->size();
644 static std::unique_ptr<llvm::ThreeAddressCode>
647 auto ft = std::dynamic_pointer_cast<const FloatingPointType>(op1->
Type());
649 throw util::Error(
"expected floating point type.");
651 auto op = std::make_unique<FCmpOperation>(
cmp, std::move(ft));
681 operator==(
const Operation & other)
const noexcept override;
683 [[nodiscard]] std::string
686 [[nodiscard]] std::unique_ptr<Operation>
687 copy()
const override;
701 static std::unique_ptr<llvm::ThreeAddressCode>
702 Create(std::shared_ptr<const jlm::rvsdg::Type> type)
704 auto operation = std::make_unique<UndefValueOperation>(std::move(type));
708 static std::unique_ptr<llvm::ThreeAddressCode>
709 Create(std::shared_ptr<const jlm::rvsdg::Type> type,
const std::string & name)
711 auto operation = std::make_unique<UndefValueOperation>(std::move(type));
715 static std::unique_ptr<llvm::ThreeAddressCode>
718 auto & type =
result->Type();
720 std::vector<std::unique_ptr<ThreeAddressCodeVariable>> results;
721 results.push_back(std::move(
result));
723 auto operation = std::make_unique<UndefValueOperation>(type);
752 operator==(
const Operation & other)
const noexcept override;
757 [[nodiscard]] std::unique_ptr<Operation>
758 copy()
const override;
766 static std::unique_ptr<llvm::ThreeAddressCode>
767 Create(
const std::shared_ptr<const jlm::rvsdg::Type> & type)
771 auto operation = std::make_unique<PoisonValueOperation>(std::move(valueType));
784 static std::shared_ptr<const jlm::rvsdg::Type>
809 throw std::runtime_error(
"FreezeOperation given non-value type");
813 operator==(
const Operation & other)
const noexcept override;
818 [[nodiscard]] std::unique_ptr<Operation>
819 copy()
const override;
827 static std::unique_ptr<llvm::ThreeAddressCode>
830 auto operation = std::make_unique<FreezeOperation>(operand.
Type());
870 operator==(
const Operation & other)
const noexcept override;
872 [[nodiscard]] std::string
875 [[nodiscard]] std::unique_ptr<Operation>
876 copy()
const override;
880 const noexcept override;
897 return std::static_pointer_cast<const FloatingPointType>(
result(0))->size();
900 static std::unique_ptr<llvm::ThreeAddressCode>
903 auto ft = std::dynamic_pointer_cast<const FloatingPointType>(op1->
Type());
905 throw util::Error(
"expected floating point type.");
907 auto op = std::make_unique<FBinaryOperation>(
fpop, ft);
924 explicit FNegOperation(
const std::shared_ptr<const FloatingPointType> & fpt)
929 operator==(
const Operation & other)
const noexcept override;
931 [[nodiscard]] std::string
934 [[nodiscard]] std::unique_ptr<Operation>
935 copy()
const override;
940 return std::static_pointer_cast<const FloatingPointType>(
argument(0))->size();
943 static std::unique_ptr<llvm::ThreeAddressCode>
946 auto type = std::dynamic_pointer_cast<const FloatingPointType>(operand->
Type());
948 throw util::Error(
"expected floating point type.");
950 auto op = std::make_unique<FNegOperation>(std::move(type));
973 operator==(
const Operation & other)
const noexcept override;
975 [[nodiscard]] std::string
978 [[nodiscard]] std::unique_ptr<Operation>
979 copy()
const override;
981 static std::unique_ptr<llvm::ThreeAddressCode>
984 std::vector<std::shared_ptr<const jlm::rvsdg::Type>> operands;
986 operands.push_back(
argument->Type());
988 auto op = std::make_unique<VariadicArgumentListOperation>(std::move(operands));
995 std::vector<std::shared_ptr<const rvsdg::Type>> operandTypes;
996 operandTypes.reserve(operands.size());
997 for (
auto & operand : operands)
998 operandTypes.emplace_back(operand->Type());
1000 return operands.empty()
1018 operator==(
const Operation & other)
const noexcept override;
1020 [[nodiscard]] std::string
1023 [[nodiscard]] std::unique_ptr<Operation>
1024 copy()
const override;
1029 return *std::static_pointer_cast<const StructType>(
result(0));
1032 static std::unique_ptr<ThreeAddressCode>
1034 const std::vector<const Variable *> & elements,
1035 const std::shared_ptr<const rvsdg::Type> &
type)
1039 auto op = std::make_unique<ConstantStructOperation>(std::move(structType));
1046 const std::vector<rvsdg::Output *> & operands,
1047 std::shared_ptr<const rvsdg::Type> resultType)
1054 static std::vector<std::shared_ptr<const rvsdg::Type>>
1057 std::vector<std::shared_ptr<const rvsdg::Type>> types;
1064 static std::shared_ptr<const StructType>
1067 if (
auto structType = std::dynamic_pointer_cast<const StructType>(
type))
1089 operator==(
const Operation & other)
const noexcept override;
1091 [[nodiscard]] std::string
1094 [[nodiscard]] std::unique_ptr<Operation>
1095 copy()
const override;
1100 return std::static_pointer_cast<const ArrayType>(
result(0))->nelements();
1103 [[nodiscard]] std::shared_ptr<const ArrayType>
1107 return std::static_pointer_cast<const ArrayType>(
result(0));
1110 static std::unique_ptr<llvm::ThreeAddressCode>
1111 create(
const std::vector<const Variable *> & elements)
1113 if (elements.size() == 0)
1114 throw util::Error(
"expected at least one element.\n");
1116 auto vt = elements[0]->Type();
1120 auto op = std::make_unique<ConstantArrayOperation>(
vt, elements.size());
1125 Create(
const std::vector<rvsdg::Output *> & operands)
1127 if (operands.empty())
1128 throw util::Error(
"Expected at least one element.\n");
1130 auto valueType = operands[0]->Type();
1149 auto st =
dynamic_cast<const StructType *
>(type.get());
1150 auto at =
dynamic_cast<const ArrayType *
>(type.get());
1151 auto vt =
dynamic_cast<const VectorType *
>(type.get());
1152 if (!st && !at && !
vt)
1153 throw util::Error(
"expected array, struct, or vector type.\n");
1157 operator==(
const Operation & other)
const noexcept override;
1159 [[nodiscard]] std::string
1162 [[nodiscard]] std::unique_ptr<Operation>
1163 copy()
const override;
1165 static std::unique_ptr<llvm::ThreeAddressCode>
1166 create(std::shared_ptr<const jlm::rvsdg::Type> type)
1168 auto op = std::make_unique<ConstantAggregateZeroOperation>(std::move(type));
1191 const std::shared_ptr<const
VectorType> & vtype,
1192 const std::shared_ptr<const
jlm::rvsdg::BitType> & btype)
1197 operator==(
const Operation & other)
const noexcept override;
1199 [[nodiscard]] std::string
1202 [[nodiscard]] std::unique_ptr<Operation>
1203 copy()
const override;
1205 static inline std::unique_ptr<llvm::ThreeAddressCode>
1208 auto vt = std::dynamic_pointer_cast<const VectorType>(vector->
Type());
1212 auto bt = std::dynamic_pointer_cast<const jlm::rvsdg::BitType>(index->
Type());
1216 auto op = std::make_unique<ExtractElementOperation>(
vt, bt);
1228 const std::vector<
int> & mask)
1234 const std::shared_ptr<const ScalableVectorType> & v,
1235 const std::vector<int> & mask)
1241 operator==(
const Operation & other)
const noexcept override;
1243 [[nodiscard]] std::string
1246 [[nodiscard]] std::unique_ptr<Operation>
1247 copy()
const override;
1249 const ::llvm::ArrayRef<int>
1255 static std::unique_ptr<llvm::ThreeAddressCode>
1258 if (is<FixedVectorType>(v1->
type()) && is<FixedVectorType>(v2->
type()))
1259 return CreateShuffleVectorTac<FixedVectorType>(v1, v2, mask);
1261 if (is<ScalableVectorType>(v1->
type()) && is<ScalableVectorType>(v2->
type()))
1262 return CreateShuffleVectorTac<ScalableVectorType>(v1, v2, mask);
1264 throw util::Error(
"Expected vector types as operands.");
1268 template<
typename T>
1269 static std::unique_ptr<ThreeAddressCode>
1272 auto vt = std::static_pointer_cast<const T>(v1->
Type());
1273 auto op = std::make_unique<ShuffleVectorOperation>(
vt, mask);
1290 operator==(
const Operation & other)
const noexcept override;
1292 [[nodiscard]] std::string
1295 [[nodiscard]] std::unique_ptr<Operation>
1296 copy()
const override;
1298 static inline std::unique_ptr<llvm::ThreeAddressCode>
1300 const std::vector<const Variable *> & operands,
1301 const std::shared_ptr<const jlm::rvsdg::Type> & type)
1303 auto vt = std::dynamic_pointer_cast<const VectorType>(type);
1307 auto op = std::make_unique<ConstantVectorOperation>(
vt);
1318 const std::shared_ptr<const
VectorType> & vectype,
1319 const std::shared_ptr<const
jlm::rvsdg::Type> & vtype,
1320 const std::shared_ptr<const
jlm::rvsdg::BitType> & btype)
1323 if (vectype->type() != *vtype)
1326 auto expected = vectype->type().debug_string();
1332 operator==(
const Operation & other)
const noexcept override;
1334 [[nodiscard]] std::string
1337 [[nodiscard]] std::unique_ptr<Operation>
1338 copy()
const override;
1340 static inline std::unique_ptr<llvm::ThreeAddressCode>
1343 auto vct = std::dynamic_pointer_cast<const VectorType>(vector->
Type());
1351 auto bt = std::dynamic_pointer_cast<const jlm::rvsdg::BitType>(index->
Type());
1355 auto op = std::make_unique<InsertElementOperation>(vct,
vt, bt);
1366 const rvsdg::UnaryOperation & op,
1367 const std::shared_ptr<const
VectorType> & operand,
1376 if (operand->type() != *op.argument(0))
1378 auto received = operand->type().debug_string();
1379 auto expected = op.argument(0)->debug_string();
1383 if (
result->type() != *op.result(0))
1385 auto received =
result->type().debug_string();
1386 auto expected = op.result(0)->debug_string();
1398 op_(std::move(other.op_))
1414 op_ = std::move(other.op_);
1426 operator==(
const Operation & other)
const noexcept override;
1428 [[nodiscard]] std::string
1431 [[nodiscard]] std::unique_ptr<Operation>
1432 copy()
const override;
1434 static inline std::unique_ptr<llvm::ThreeAddressCode>
1438 const std::shared_ptr<const jlm::rvsdg::Type> & type)
1440 auto vct1 = std::dynamic_pointer_cast<const VectorType>(operand->
Type());
1441 auto vct2 = std::dynamic_pointer_cast<const VectorType>(type);
1445 auto op = std::make_unique<VectorUnaryOperation>(unop, vct1, vct2);
1450 std::unique_ptr<Operation>
op_;
1460 const std::shared_ptr<const
VectorType> & op1,
1461 const std::shared_ptr<const
VectorType> & op2,
1467 throw util::Error(
"expected the same vector types.");
1469 if (op1->type() != *binop.argument(0))
1471 auto received = op1->type().debug_string();
1472 auto expected = binop.argument(0)->debug_string();
1476 if (
result->type() != *binop.result(0))
1478 auto received =
result->type().debug_string();
1479 auto expected = binop.result(0)->debug_string();
1491 op_(std::move(other.op_))
1507 op_ = std::move(other.op_);
1519 operator==(
const Operation & other)
const noexcept override;
1521 [[nodiscard]] std::string
1524 [[nodiscard]] std::unique_ptr<Operation>
1525 copy()
const override;
1527 static inline std::unique_ptr<llvm::ThreeAddressCode>
1532 const std::shared_ptr<const jlm::rvsdg::Type> & type)
1534 auto vct1 = std::dynamic_pointer_cast<const VectorType>(op1->
Type());
1535 auto vct2 = std::dynamic_pointer_cast<const VectorType>(op2->
Type());
1536 auto vct3 = std::dynamic_pointer_cast<const VectorType>(type);
1537 if (!vct1 || !vct2 || !vct3)
1540 auto op = std::make_unique<VectorBinaryOperation>(binop, vct1, vct2, vct3);
1545 std::unique_ptr<Operation>
op_;
1560 operator==(
const Operation & other)
const noexcept override;
1562 [[nodiscard]] std::string
1565 [[nodiscard]] std::unique_ptr<Operation>
1566 copy()
const override;
1571 return std::static_pointer_cast<const VectorType>(
result(0))->size();
1577 return std::static_pointer_cast<const VectorType>(
result(0))->type();
1580 static std::unique_ptr<ThreeAddressCode>
1581 Create(
const std::vector<const Variable *> & elements)
1583 if (elements.empty())
1584 throw util::Error(
"Expected at least one element.");
1586 auto vt = elements[0]->Type();
1590 auto op = std::unique_ptr<ConstantDataVectorOperation>(
1613 operator==(
const Operation & other)
const noexcept override;
1615 [[nodiscard]] std::string
1618 [[nodiscard]] std::unique_ptr<Operation>
1619 copy()
const override;
1621 const rvsdg::BitType &
1624 return *std::static_pointer_cast<const rvsdg::BitType>(
argument(0));
1638 auto & size = *node.
input(0);
1647 auto & ioState = *node.
input(1);
1656 auto & address = *node.
output(0);
1665 auto & ioState = *node.
output(1);
1674 auto & memoryState = *node.
output(2);
1675 JLM_ASSERT(is<MemoryStateType>(memoryState.Type()));
1679 static std::unique_ptr<ThreeAddressCode>
1683 auto op = std::make_unique<MallocOperation>(std::move(bitType));
1695 static std::shared_ptr<const rvsdg::BitType>
1698 if (
auto bitType = std::dynamic_pointer_cast<const rvsdg::BitType>(type))
1701 throw std::runtime_error(
"Expected bits type.");
1720 operator==(
const Operation & other)
const noexcept override;
1722 [[nodiscard]] std::string
1725 [[nodiscard]] std::unique_ptr<Operation>
1726 copy()
const override;
1736 const auto input = node.input(0);
1744 JLM_ASSERT(is<MemoryStateType>(output.Type()));
1747 const auto input = freeNode->input(output.index() + 1);
1748 JLM_ASSERT(is<MemoryStateType>(input->Type()));
1752 static std::unique_ptr<llvm::ThreeAddressCode>
1755 const std::vector<const Variable *> & memoryStates,
1758 std::vector<const Variable *> operands;
1759 operands.push_back(pointer);
1760 operands.insert(operands.end(), memoryStates.begin(), memoryStates.end());
1761 operands.push_back(iOState);
1763 auto operation = std::make_unique<FreeOperation>(memoryStates.size());
1767 static std::vector<jlm::rvsdg::Output *>
1770 const std::vector<jlm::rvsdg::Output *> & memoryStates,
1773 std::vector<jlm::rvsdg::Output *> operands;
1774 operands.push_back(pointer);
1775 operands.insert(operands.end(), memoryStates.begin(), memoryStates.end());
1776 operands.push_back(iOState);
1782 static std::vector<std::shared_ptr<const rvsdg::Type>>
1785 std::vector<std::shared_ptr<const rvsdg::Type>> memoryStates(
1790 types.insert(types.end(), memoryStates.begin(), memoryStates.end());
1796 static std::vector<std::shared_ptr<const rvsdg::Type>>
1799 std::vector<std::shared_ptr<const rvsdg::Type>> types(
util::HashSet< rvsdg::Output * > arguments
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
std::string debug_string() const override
size_t nalternatives() const noexcept
~BranchOperation() noexcept override
std::unique_ptr< Operation > copy() const override
static std::unique_ptr< llvm::ThreeAddressCode > create(size_t nalternatives, const Variable *operand)
bool operator==(const Operation &other) const noexcept override
static rvsdg::SimpleNode & createNode(rvsdg::Region ®ion, std::shared_ptr< const rvsdg::Type > type)
std::unique_ptr< Operation > copy() const override
static rvsdg::Output * Create(rvsdg::Region ®ion, const std::shared_ptr< const rvsdg::Type > &type)
static std::unique_ptr< llvm::ThreeAddressCode > create(std::shared_ptr< const jlm::rvsdg::Type > type)
~ConstantAggregateZeroOperation() noexcept override
bool operator==(const Operation &other) const noexcept override
std::string debug_string() const override
~ConstantArrayOperation() noexcept override
std::unique_ptr< Operation > copy() const override
static std::unique_ptr< llvm::ThreeAddressCode > create(const std::vector< const Variable * > &elements)
bool operator==(const Operation &other) const noexcept override
std::string debug_string() const override
static rvsdg::Output * Create(const std::vector< rvsdg::Output * > &operands)
std::shared_ptr< const ArrayType > type() const noexcept
size_t size() const noexcept
~ConstantDataArrayOperation() noexcept override
static rvsdg::Output * Create(const std::vector< rvsdg::Output * > &elements)
std::unique_ptr< Operation > copy() const override
size_t size() const noexcept
std::string debug_string() const override
static std::unique_ptr< ThreeAddressCode > create(const std::vector< const Variable * > &elements)
bool operator==(const Operation &other) const noexcept override
std::shared_ptr< const ArrayType > type() const noexcept
bool operator==(const Operation &other) const noexcept override
~ConstantDataVectorOperation() noexcept override
std::unique_ptr< Operation > copy() const override
size_t size() const noexcept
const jlm::rvsdg::Type & type() const noexcept
static std::unique_ptr< ThreeAddressCode > Create(const std::vector< const Variable * > &elements)
std::string debug_string() const override
~ConstantFP() noexcept override
static std::unique_ptr< ConstantFP > create(const ::llvm::APFloat &constant, const std::shared_ptr< const jlm::rvsdg::Type > &type)
static std::unique_ptr< llvm::ThreeAddressCode > createTac(const ::llvm::APFloat &constant, const std::shared_ptr< const jlm::rvsdg::Type > &type)
static rvsdg::Node & createNode(rvsdg::Region ®ion, fpsize size, const ::llvm::APFloat &constant)
ConstantFP(std::shared_ptr< const FloatingPointType > fpt, const ::llvm::APFloat &constant)
const fpsize & size() const noexcept
std::unique_ptr< Operation > copy() const override
::llvm::APFloat constant_
bool operator==(const Operation &other) const noexcept override
std::string debug_string() const override
const ::llvm::APFloat & constant() const noexcept
static ::llvm::APFloat getZeroRepresentation(fpsize size)
ConstantPointerNullOperation class.
std::string debug_string() const override
static rvsdg::Node & createNode(rvsdg::Region ®ion)
static std::unique_ptr< ThreeAddressCode > createTac()
bool operator==(const Operation &other) const noexcept override
~ConstantPointerNullOperation() noexcept override
std::unique_ptr< Operation > copy() const override
std::unique_ptr< Operation > copy() const override
static std::unique_ptr< ThreeAddressCode > create(const std::vector< const Variable * > &elements, const std::shared_ptr< const rvsdg::Type > &type)
static std::vector< std::shared_ptr< const rvsdg::Type > > create_srctypes(const StructType &type)
static rvsdg::Output & Create(rvsdg::Region &, const std::vector< rvsdg::Output * > &operands, std::shared_ptr< const rvsdg::Type > resultType)
static std::shared_ptr< const StructType > CheckAndExtractStructType(std::shared_ptr< const rvsdg::Type > type)
~ConstantStructOperation() noexcept override
std::string debug_string() const override
const StructType & type() const noexcept
bool operator==(const Operation &other) const noexcept override
bool operator==(const Operation &other) const noexcept override
std::unique_ptr< Operation > copy() const override
~ConstantVectorOperation() noexcept override
std::string debug_string() const override
static std::unique_ptr< llvm::ThreeAddressCode > create(const std::vector< const Variable * > &operands, const std::shared_ptr< const jlm::rvsdg::Type > &type)
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
const llvm::fpop & fpop() const noexcept
std::unique_ptr< Operation > copy() const override
static std::unique_ptr< llvm::ThreeAddressCode > create(const llvm::fpop &fpop, const Variable *op1, const Variable *op2)
const fpsize & size() const noexcept
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
const fpcmp & cmp() 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
static std::unique_ptr< llvm::ThreeAddressCode > create(const fpcmp &cmp, const Variable *op1, const Variable *op2)
const fpsize & size() 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
bool operator==(const Operation &other) 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
const fpsize & size() const noexcept
FNegOperation(const std::shared_ptr< const FloatingPointType > &fpt)
static std::shared_ptr< const FixedVectorType > Create(std::shared_ptr< const rvsdg::Type > type, size_t size)
static std::shared_ptr< const FloatingPointType > Create(fpsize size)
static std::vector< std::shared_ptr< const rvsdg::Type > > CreateResultTypes(size_t numMemoryStates)
static std::vector< std::shared_ptr< const rvsdg::Type > > CreateOperandTypes(size_t numMemoryStates)
static rvsdg::Input & mapMemoryStateOutputToInput(rvsdg::Output &output) noexcept
bool operator==(const Operation &other) const noexcept override
std::unique_ptr< Operation > copy() const override
static std::unique_ptr< llvm::ThreeAddressCode > Create(const Variable *pointer, const std::vector< const Variable * > &memoryStates, const Variable *iOState)
~FreeOperation() noexcept override
static rvsdg::Input & addressInput(const rvsdg::Node &node) noexcept
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
static std::unique_ptr< llvm::ThreeAddressCode > createTac(const Variable &operand)
std::string debug_string() const override
~FreezeOperation() noexcept override
std::unique_ptr< Operation > copy() const override
static jlm::rvsdg::Node & createNode(jlm::rvsdg::Output &operand)
const jlm::rvsdg::Type & getType() const noexcept
bool operator==(const Operation &other) const noexcept override
static std::shared_ptr< const IOStateType > Create()
static std::unique_ptr< llvm::ThreeAddressCode > create(const llvm::Variable *vector, const llvm::Variable *value, const llvm::Variable *index)
bool operator==(const Operation &other) const noexcept override
std::string debug_string() const override
~InsertElementOperation() noexcept override
std::unique_ptr< Operation > copy() const override
bool operator==(const Operation &other) const noexcept override
std::unique_ptr< Operation > copy() const override
std::string debug_string() const override
~MallocOperation() noexcept override
static std::unique_ptr< ThreeAddressCode > createTac(const Variable *size, const Variable *ioState)
static rvsdg::Output & addressOutput(const rvsdg::Node &node)
const rvsdg::BitType & getSizeType() const noexcept
static rvsdg::Input & sizeInput(const rvsdg::Node &node)
static rvsdg::Output & memoryStateOutput(const rvsdg::Node &node)
static rvsdg::SimpleNode & createNode(rvsdg::Output &size, rvsdg::Output &ioState)
static std::shared_ptr< const rvsdg::BitType > checkAndExtractSizeType(const std::shared_ptr< const rvsdg::Type > &type)
static rvsdg::Input & ioStateInput(const rvsdg::Node &node)
rvsdg::FunctionType getFunctionType() const
static rvsdg::Output & ioStateOutput(const rvsdg::Node &node)
static std::shared_ptr< const MemoryStateType > Create()
static std::shared_ptr< const PointerType > Create()
PoisonValueOperation class.
bool operator==(const Operation &other) const noexcept override
PoisonValueOperation(PoisonValueOperation &&)=delete
~PoisonValueOperation() noexcept override
const jlm::rvsdg::Type & GetType() const noexcept
std::string debug_string() const override
PoisonValueOperation & operator=(const PoisonValueOperation &)=delete
static std::unique_ptr< llvm::ThreeAddressCode > Create(const std::shared_ptr< const jlm::rvsdg::Type > &type)
static jlm::rvsdg::Output * Create(rvsdg::Region *region, const std::shared_ptr< const jlm::rvsdg::Type > &type)
static std::shared_ptr< const jlm::rvsdg::Type > CheckAndConvertType(const std::shared_ptr< const jlm::rvsdg::Type > &type)
PoisonValueOperation & operator=(PoisonValueOperation &&)=delete
PoisonValueOperation(const PoisonValueOperation &)=default
std::unique_ptr< Operation > copy() const override
~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
static rvsdg::SimpleNode & createNode(const ICmpPredicate kind, rvsdg::Output &operand1, rvsdg::Output &operand2)
std::unique_ptr< Operation > copy() const override
static std::optional< std::vector< rvsdg::Output * > > normalizeNullPointerComparison(const PtrCmpOperation &ptrCmpOperation, const std::vector< rvsdg::Output * > &operands)
const std::shared_ptr< const jlm::rvsdg::Type > & Type() const noexcept
bool operator==(const Operation &other) const noexcept override
static std::unique_ptr< llvm::ThreeAddressCode > create(const llvm::Variable *p, const llvm::Variable *t, const llvm::Variable *f)
const jlm::rvsdg::Type & type() const noexcept
std::string debug_string() const override
std::unique_ptr< Operation > copy() const override
~SelectOperation() noexcept override
std::string debug_string() const override
static std::unique_ptr< ThreeAddressCode > CreateShuffleVectorTac(const Variable *v1, const Variable *v2, const std::vector< int > &mask)
std::unique_ptr< Operation > copy() const override
ShuffleVectorOperation(const std::shared_ptr< const ScalableVectorType > &v, const std::vector< int > &mask)
static std::unique_ptr< llvm::ThreeAddressCode > create(const Variable *v1, const Variable *v2, const std::vector< int > &mask)
const ::llvm::ArrayRef< int > Mask() const
bool operator==(const Operation &other) const noexcept override
~ShuffleVectorOperation() noexcept override
SsaPhiOperation & operator=(SsaPhiOperation &&)=delete
SsaPhiOperation & operator=(const SsaPhiOperation &)=delete
SsaPhiOperation(const SsaPhiOperation &)=default
ControlFlowGraphNode * GetIncomingNode(size_t n) const noexcept
static std::unique_ptr< llvm::ThreeAddressCode > create(const std::vector< std::pair< const Variable *, ControlFlowGraphNode * > > &arguments, std::shared_ptr< const jlm::rvsdg::Type > type)
std::string debug_string() const override
bool operator==(const Operation &other) const noexcept override
std::unique_ptr< Operation > copy() const override
~SsaPhiOperation() noexcept override
const std::shared_ptr< const rvsdg::Type > & Type() const noexcept
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)
UndefValueOperation class.
~UndefValueOperation() noexcept override
std::string debug_string() const override
const rvsdg::Type & GetType() const noexcept
UndefValueOperation(const UndefValueOperation &)=default
std::unique_ptr< Operation > copy() const override
static std::unique_ptr< llvm::ThreeAddressCode > Create(std::unique_ptr< ThreeAddressCodeVariable > result)
static std::unique_ptr< llvm::ThreeAddressCode > Create(std::shared_ptr< const jlm::rvsdg::Type > type, const std::string &name)
bool operator==(const Operation &other) const noexcept override
UndefValueOperation & operator=(UndefValueOperation &&)=delete
UndefValueOperation & operator=(const UndefValueOperation &)=delete
static std::unique_ptr< llvm::ThreeAddressCode > Create(std::shared_ptr< const jlm::rvsdg::Type > type)
static jlm::rvsdg::Output * Create(rvsdg::Region ®ion, 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
VariadicArgumentListOperation & operator=(const VariadicArgumentListOperation &)=delete
std::string debug_string() const override
~VariadicArgumentListOperation() noexcept override
std::unique_ptr< Operation > copy() const override
static std::unique_ptr< llvm::ThreeAddressCode > create(const std::vector< const Variable * > &arguments)
VariadicArgumentListOperation & operator=(VariadicArgumentListOperation &&)=delete
bool operator==(const Operation &other) const noexcept override
bool operator==(const Operation &other) const noexcept override
std::string debug_string() const override
VectorBinaryOperation & operator=(const VectorBinaryOperation &other)
std::unique_ptr< Operation > copy() const override
VectorBinaryOperation(const VectorBinaryOperation &other)
const rvsdg::BinaryOperation & operation() const noexcept
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 > op_
~VectorBinaryOperation() noexcept override
VectorBinaryOperation(VectorBinaryOperation &&other) noexcept
VectorBinaryOperation & operator=(VectorBinaryOperation &&other) noexcept
size_t size() const noexcept
std::unique_ptr< Operation > copy() const override
static std::unique_ptr< ThreeAddressCode > createVectorSelectTac(const Variable *p, const Variable *t, const Variable *f)
const std::shared_ptr< const rvsdg::Type > & Type() const noexcept
std::string debug_string() const override
const rvsdg::Type & type() const noexcept
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_
VectorUnaryOperation & operator=(VectorUnaryOperation &&other) noexcept
bool operator==(const Operation &other) const noexcept override
~VectorUnaryOperation() noexcept override
VectorUnaryOperation(const VectorUnaryOperation &other)
std::string debug_string() const override
const rvsdg::UnaryOperation & operation() const noexcept
VectorUnaryOperation(VectorUnaryOperation &&other) noexcept
std::unique_ptr< Operation > copy() const override
VectorUnaryOperation & operator=(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)
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.
NodeInput * input(size_t index) const noexcept
NodeOutput * output(size_t index) const noexcept
virtual const Operation & GetOperation() const noexcept=0
const std::shared_ptr< const rvsdg::Type > & Type() const noexcept
Represent acyclic RVSDG subgraphs.
NodeOutput * output(size_t index) const noexcept
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
UnaryOperation(std::shared_ptr< const Type > operand, std::shared_ptr< const Type > result)
#define JLM_UNREACHABLE(msg)
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 binop_reduction_path_t
@ Value
Designate a value type.
NodeType * TryGetOwnerNode(const rvsdg::Input &input) noexcept
Checks if this is an input to a node of specified type.
static std::string strfmt(Args... args)