15#include <llvm/ADT/SmallVector.h>
16#include <llvm/IR/InstrTypes.h>
28 return op && op->
IncomingNodes_ == IncomingNodes_ && op->result(0) == result(0);
46std::unique_ptr<rvsdg::Operation>
49 return std::make_unique<SsaPhiOperation>(*
this);
58 return op && op->
argument(0) == argument(0);
67std::unique_ptr<rvsdg::Operation>
70 return std::make_unique<AssignmentOperation>(*
this);
79 return op && op->
result(0) == result(0);
88std::unique_ptr<rvsdg::Operation>
91 return std::make_unique<SelectOperation>(*
this);
100 return op && op->
type() == type();
106 return "VectorSelect";
109std::unique_ptr<rvsdg::Operation>
112 return std::make_unique<VectorSelectOperation>(*
this);
121 return op && op->
argument(0) == argument(0);
130std::unique_ptr<rvsdg::Operation>
133 return std::make_unique<BranchOperation>(*
this);
147 return "ConstantPointerNull";
150std::unique_ptr<rvsdg::Operation>
153 return std::make_unique<ConstantPointerNullOperation>(*
this);
162 return op && op->
result(0) == result(0);
168 return "ConstantDataArray";
171std::unique_ptr<rvsdg::Operation>
174 return std::make_unique<ConstantDataArrayOperation>(*
this);
199 return map.LookupKey(predicate);
202[[nodiscard]] ::llvm::CmpInst::Predicate
206 return map.LookupValue(predicate);
209[[nodiscard]] std::string_view
235 throw std::runtime_error(
"Unknown ICmpPredicate");
245 return op && op->
argument(0) == argument(0) && op->predicate_ == predicate_;
254std::unique_ptr<rvsdg::Operation>
257 return std::make_unique<PtrCmpOperation>(*
this);
276template<
typename TOperation>
281 return operation !=
nullptr;
287 if (isOutputOf<AllocaOperation>(output))
302 auto [fnToPtrNode, fnToPtrOperation] =
304 if (fnToPtrOperation !=
nullptr)
306 const auto & tracedOutput =
317std::optional<std::vector<rvsdg::Output *>>
320 const std::vector<rvsdg::Output *> & operands)
330 const bool hasRequiredOperands =
331 (isOutputOf<ConstantPointerNullOperation>(tracedOperand1) &&
isAllocationSide(tracedOperand2))
332 || (isOutputOf<ConstantPointerNullOperation>(tracedOperand2)
334 if (hasRequiredOperands)
336 auto & region = *operands[0]->region();
342 return std::vector<rvsdg::Output *>{
346 throw std::logic_error(
"Unhandled predicate!");
356ConstantFP::operator==(const Operation & other) const noexcept
358 auto op =
dynamic_cast<const ConstantFP *
>(&other);
359 return op && size() == op->
size() && constant().bitwiseIsEqual(op->constant());
365 ::llvm::SmallVector<char, 32> v;
368 std::string s(
"FP(");
369 for (
const auto & c : v)
376std::unique_ptr<rvsdg::Operation>
379 return std::make_unique<ConstantFP>(*
this);
388 return op && op->
argument(0) == argument(0) && op->cmp_ == cmp_;
394 static std::unordered_map<fpcmp, std::string> map({ {
fpcmp::oeq,
"oeq" },
410 return "FCmp " + map[
cmp()];
413std::unique_ptr<rvsdg::Operation>
416 return std::make_unique<FCmpOperation>(*
this);
438 return op && op->
GetType() == GetType();
447std::unique_ptr<rvsdg::Operation>
450 return std::make_unique<UndefValueOperation>(*
this);
459 return operation && operation->
GetType() == GetType();
468std::unique_ptr<rvsdg::Operation>
471 return std::make_unique<PoisonValueOperation>(*
this);
480 return operation && operation->
getType() == getType();
489std::unique_ptr<rvsdg::Operation>
492 return std::make_unique<FreezeOperation>(*
this);
501 return op && op->
fpop() ==
fpop() && op->size() == size();
507 static std::unordered_map<llvm::fpop, std::string> map({ {
fpop::add,
"add" },
514 return "FPOP " + map[
fpop()];
517std::unique_ptr<rvsdg::Operation>
520 return std::make_unique<FBinaryOperation>(*
this);
545 return op && op->
size() == size();
554std::unique_ptr<rvsdg::Operation>
557 return std::make_unique<FNegOperation>(*
this);
566 if (!op || op->narguments() != narguments())
569 for (
size_t n = 0; n < narguments(); n++)
571 if (op->argument(n) != argument(n))
581 return "VariadicArguments";
584std::unique_ptr<rvsdg::Operation>
587 return std::make_unique<VariadicArgumentListOperation>(*
this);
596 return op && op->
result(0) == result(0);
606std::unique_ptr<rvsdg::Operation>
609 return std::make_unique<ConstantStructOperation>(*
this);
618 return op && op->
result(0) == result(0);
624 return "ConstantArray";
627std::unique_ptr<rvsdg::Operation>
630 return std::make_unique<ConstantArrayOperation>(*
this);
639 return op && op->
result(0) == result(0);
645 return "ConstantAggregateZero";
648std::unique_ptr<rvsdg::Operation>
651 return std::make_unique<ConstantAggregateZeroOperation>(*
this);
660 return op && op->
argument(0) == argument(0) && op->argument(1) == argument(1);
666 return "ExtractElement";
669std::unique_ptr<rvsdg::Operation>
672 return std::make_unique<ExtractElementOperation>(*
this);
681 return op && op->
argument(0) == argument(0) && op->Mask() == Mask();
687 return "ShuffleVector";
690std::unique_ptr<rvsdg::Operation>
693 return std::make_unique<ShuffleVectorOperation>(*
this);
702 return op && op->
result(0) == result(0);
708 return "ConstantVector";
711std::unique_ptr<rvsdg::Operation>
714 return std::make_unique<ConstantVectorOperation>(*
this);
723 return op && op->
argument(0) == argument(0) && op->argument(1) == argument(1)
724 && op->argument(2) == argument(2);
730 return "InsertElement";
733std::unique_ptr<rvsdg::Operation>
736 return std::make_unique<InsertElementOperation>(*
this);
745 return op && op->
operation() == operation();
754std::unique_ptr<rvsdg::Operation>
757 return std::make_unique<VectorUnaryOperation>(*
this);
766 return op && op->
operation() == operation();
775std::unique_ptr<rvsdg::Operation>
778 return std::make_unique<VectorBinaryOperation>(*
this);
787 return op && op->
result(0) == result(0);
793 return "ConstantDataVector";
796std::unique_ptr<rvsdg::Operation>
799 return std::make_unique<ConstantDataVectorOperation>(*
this);
808 return this == &other;
817std::unique_ptr<rvsdg::Operation>
820 return std::make_unique<MallocOperation>(*
this);
831 return this == &other;
840std::unique_ptr<rvsdg::Operation>
843 return std::make_unique<FreeOperation>(*
this);
std::unique_ptr< Operation > copy() const override
~AssignmentOperation() noexcept override
std::string debug_string() const override
std::string debug_string() const override
~BranchOperation() noexcept override
std::unique_ptr< Operation > copy() const override
std::unique_ptr< Operation > copy() const override
~ConstantAggregateZeroOperation() noexcept override
std::string debug_string() const override
~ConstantArrayOperation() noexcept override
std::unique_ptr< Operation > copy() const override
std::string debug_string() const override
~ConstantDataArrayOperation() noexcept override
std::unique_ptr< Operation > copy() const override
std::string debug_string() const override
~ConstantDataVectorOperation() noexcept override
std::unique_ptr< Operation > copy() const override
std::string debug_string() const override
~ConstantFP() noexcept override
const fpsize & size() const noexcept
std::unique_ptr< Operation > copy() const override
std::string debug_string() const override
const ::llvm::APFloat & constant() const noexcept
ConstantPointerNullOperation class.
std::string debug_string() const override
~ConstantPointerNullOperation() noexcept override
std::unique_ptr< Operation > copy() const override
std::unique_ptr< Operation > copy() const override
~ConstantStructOperation() noexcept override
std::string debug_string() const override
const StructType & type() const noexcept
std::unique_ptr< Operation > copy() const override
~ConstantVectorOperation() noexcept override
std::string debug_string() const override
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
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
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
~FCmpOperation() 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
~FNegOperation() noexcept override
std::string debug_string() const override
const fpsize & size() const noexcept
std::unique_ptr< Operation > copy() const override
~FreeOperation() noexcept override
std::string debug_string() const override
std::string debug_string() const override
~FreezeOperation() noexcept override
std::unique_ptr< Operation > copy() const override
const jlm::rvsdg::Type & getType() const noexcept
std::string debug_string() const override
~InsertElementOperation() noexcept override
std::unique_ptr< Operation > copy() const override
static rvsdg::Node & Create(rvsdg::Region ®ion, IntegerValueRepresentation representation)
std::unique_ptr< Operation > copy() const override
std::string debug_string() const override
~MallocOperation() noexcept override
PoisonValueOperation class.
~PoisonValueOperation() noexcept override
const jlm::rvsdg::Type & GetType() const noexcept
std::string debug_string() const override
std::unique_ptr< Operation > copy() const override
~PtrCmpOperation() 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
static std::optional< std::vector< rvsdg::Output * > > normalizeNullPointerComparison(const PtrCmpOperation &ptrCmpOperation, const std::vector< rvsdg::Output * > &operands)
std::string debug_string() const override
std::unique_ptr< Operation > copy() const override
~SelectOperation() noexcept override
std::string debug_string() const override
std::unique_ptr< Operation > copy() const override
~ShuffleVectorOperation() noexcept override
ControlFlowGraphNode * GetIncomingNode(size_t n) const noexcept
std::string debug_string() const override
std::unique_ptr< Operation > copy() const override
~SsaPhiOperation() noexcept override
std::vector< ControlFlowGraphNode * > IncomingNodes_
bool IsLiteral() const noexcept
const std::string & GetName() const noexcept
UndefValueOperation class.
~UndefValueOperation() noexcept override
std::string debug_string() const override
const rvsdg::Type & GetType() const noexcept
std::unique_ptr< Operation > copy() const override
std::string debug_string() const override
~VariadicArgumentListOperation() noexcept override
std::unique_ptr< Operation > copy() const override
std::string debug_string() const override
std::unique_ptr< Operation > copy() const override
const rvsdg::BinaryOperation & operation() const noexcept
~VectorBinaryOperation() noexcept override
std::unique_ptr< Operation > copy() const override
std::string debug_string() const override
const rvsdg::Type & type() const noexcept
~VectorSelectOperation() noexcept override
~VectorUnaryOperation() noexcept override
std::string debug_string() const override
const rvsdg::UnaryOperation & operation() const noexcept
std::unique_ptr< Operation > copy() const override
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 narguments() const noexcept
#define JLM_UNREACHABLE(msg)
Global memory state passed between functions.
ICmpPredicate convertICmpPredicateToJlm(::llvm::CmpInst::Predicate predicate)
std::string_view iCmpPredicateToString(ICmpPredicate predicate)
static bool isOutputOf(rvsdg::Output &operand)
static const util::BijectiveMap<::llvm::CmpInst::Predicate, ICmpPredicate > & getICmpPredicateMap()
static bool isAllocationSide(rvsdg::Output &output)
::llvm::CmpInst::Predicate convertICmpPredicateToLlvm(ICmpPredicate predicate)
static std::vector< jlm::rvsdg::Output * > outputs(const Node *node)
size_t binop_reduction_path_t
NodeType * TryGetOwnerNode(const rvsdg::Input &input) noexcept
Checks if this is an input to a node of specified type.
Output & traceOutputIntraProcedurally(Output &output)
static const binop_reduction_path_t binop_reduction_none
static std::string strfmt(Args... args)