6 #ifndef JLM_LLVM_IR_OPERATORS_SEXT_HPP
7 #define JLM_LLVM_IR_OPERATORS_SEXT_HPP
22 std::shared_ptr<const rvsdg::BitType> otype,
23 std::shared_ptr<const rvsdg::BitType> rtype)
26 if (otype->nbits() >= rtype->nbits())
27 throw util::Error(
"expected operand's #bits to be smaller than results's #bits.");
31 std::shared_ptr<const rvsdg::Type> srctype,
32 std::shared_ptr<const rvsdg::Type> dsttype)
35 auto ot = std::dynamic_pointer_cast<const rvsdg::BitType>(srctype);
39 auto rt = std::dynamic_pointer_cast<const rvsdg::BitType>(dsttype);
43 if (ot->nbits() >= rt->nbits())
44 throw util::Error(
"expected operand's #bits to be smaller than results' #bits.");
48 operator==(
const Operation & other)
const noexcept
override;
50 [[nodiscard]] std::string
53 [[nodiscard]] std::unique_ptr<Operation>
54 copy()
const override;
65 return std::static_pointer_cast<const rvsdg::BitType>(
argument(0))->nbits();
71 return std::static_pointer_cast<const rvsdg::BitType>(
result(0))->nbits();
74 static std::unique_ptr<llvm::ThreeAddressCode>
77 auto ot = std::dynamic_pointer_cast<const rvsdg::BitType>(operand->
Type());
81 auto rt = std::dynamic_pointer_cast<const rvsdg::BitType>(
type);
85 auto op = std::make_unique<SExtOperation>(std::move(ot), std::move(rt));
92 auto ot = std::dynamic_pointer_cast<const rvsdg::BitType>(operand->
Type());
96 return rvsdg::CreateOpNode<SExtOperation>(
static std::unique_ptr< llvm::ThreeAddressCode > create(const Variable *operand, const std::shared_ptr< const rvsdg::Type > &type)
~SExtOperation() noexcept override
static rvsdg::Output * create(size_t ndstbits, rvsdg::Output *operand)
std::string debug_string() const override
rvsdg::unop_reduction_path_t can_reduce_operand(const rvsdg::Output *operand) const noexcept override
std::unique_ptr< Operation > copy() const override
size_t nsrcbits() const noexcept
rvsdg::Output * reduce_operand(rvsdg::unop_reduction_path_t path, rvsdg::Output *operand) const override
SExtOperation(std::shared_ptr< const rvsdg::Type > srctype, std::shared_ptr< const rvsdg::Type > dsttype)
size_t ndstbits() const noexcept
bool operator==(const Operation &other) const noexcept override
static std::unique_ptr< llvm::ThreeAddressCode > create(std::unique_ptr< rvsdg::SimpleOperation > operation, const std::vector< const Variable * > &operands)
const std::shared_ptr< const jlm::rvsdg::Type > Type() const noexcept
static std::shared_ptr< const BitType > Create(std::size_t nbits)
Creates bit type of specified width.
const std::shared_ptr< const rvsdg::Type > & Type() 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
UnaryOperation(std::shared_ptr< const jlm::rvsdg::Type > operand, std::shared_ptr< const jlm::rvsdg::Type > result)
Global memory state passed between functions.
size_t unop_reduction_path_t
static std::string type(const Node *n)