Jlm
Loading...
Searching...
No Matches
slice.hpp
Go to the documentation of this file.
1/*
2 * Copyright 2014 Helge Bahmann <hcb@chaoticmind.net>
3 * Copyright 2011 2012 2013 2014 Nico Reißmann <nico.reissmann@gmail.com>
4 * See COPYING for terms of redistribution.
5 */
6
7#ifndef JLM_RVSDG_BITSTRING_SLICE_HPP
8#define JLM_RVSDG_BITSTRING_SLICE_HPP
9
11#include <jlm/rvsdg/node.hpp>
12#include <jlm/rvsdg/unary.hpp>
13
14namespace jlm::rvsdg
15{
16
18{
19public:
21
24 size_t low,
25 size_t high) noexcept
26 : UnaryOperation(argument, BitType::Create(high - low)),
27 low_(low)
28 {}
29
30 bool
31 operator==(const Operation & other) const noexcept override;
32
33 [[nodiscard]] std::string
34 debug_string() const override;
35
36 inline size_t
38 {
39 return low_;
40 }
41
42 inline size_t
44 {
45 return low_ + std::static_pointer_cast<const BitType>(result(0))->nbits();
46 }
47
48 [[nodiscard]] std::unique_ptr<Operation>
49 copy() const override;
50
51 inline const Type &
53 {
54 return *std::static_pointer_cast<const BitType>(argument(0));
55 }
56
67 static std::optional<std::vector<Output *>>
68 normalizeIdempotent(const BitSliceOperation & operation, const std::vector<Output *> & operands);
69
86 static std::optional<std::vector<Output *>>
87 distributeSlice(const BitSliceOperation & operation, const std::vector<Output *> & operands);
88
103 static std::optional<std::vector<Output *>>
104 narrowSlice(const BitSliceOperation & operation, const std::vector<Output *> & operands);
105
116 static std::optional<std::vector<Output *>>
117 foldConstant(const BitSliceOperation & operation, const std::vector<Output *> & operands);
118
119private:
120 size_t low_;
121};
122
134bitslice(jlm::rvsdg::Output * operand, size_t low, size_t high);
135
136}
137
138#endif
const Type & argument_type() const noexcept
Definition slice.hpp:52
bool operator==(const Operation &other) const noexcept override
Definition slice.cpp:18
static std::optional< std::vector< Output * > > normalizeIdempotent(const BitSliceOperation &operation, const std::vector< Output * > &operands)
Definition slice.cpp:31
static std::optional< std::vector< Output * > > narrowSlice(const BitSliceOperation &operation, const std::vector< Output * > &operands)
Definition slice.cpp:67
static std::optional< std::vector< Output * > > foldConstant(const BitSliceOperation &operation, const std::vector< Output * > &operands)
Definition slice.cpp:48
std::unique_ptr< Operation > copy() const override
Definition slice.cpp:124
static std::optional< std::vector< Output * > > distributeSlice(const BitSliceOperation &operation, const std::vector< Output * > &operands)
Definition slice.cpp:87
~BitSliceOperation() noexcept override
std::string debug_string() const override
Definition slice.cpp:25
size_t high() const noexcept
Definition slice.hpp:43
size_t low() const noexcept
Definition slice.hpp:37
const std::shared_ptr< const rvsdg::Type > & argument(size_t index) const noexcept
Definition operation.cpp:23
const std::shared_ptr< const rvsdg::Type > & result(size_t index) const noexcept
Definition operation.cpp:36
Unary operator.
Definition unary.hpp:24
static std::vector< jlm::rvsdg::Output * > operands(const Node *node)
Definition node.hpp:1049
NodeType * TryGetOwnerNode(const rvsdg::Input &input) noexcept
Checks if this is an input to a node of specified type.
Definition node.hpp:872
jlm::rvsdg::Output * bitslice(jlm::rvsdg::Output *argument, size_t low, size_t high)
Create bitslice.
Definition slice.cpp:130