6#ifndef JLM_LLVM_IR_TYPES_HPP
7#define JLM_LLVM_IR_TYPES_HPP
31 [[nodiscard]] std::
string
35 operator==(const
jlm::rvsdg::
Type & other) const noexcept override;
37 [[nodiscard]] std::
size_t
41 Kind() const noexcept override;
53 : nelements_(nelements),
54 type_(std::move(type))
67 [[nodiscard]] std::string
73 [[nodiscard]] std::size_t
77 Kind() const noexcept override;
80 nelements() const noexcept
91 [[nodiscard]]
const std::shared_ptr<const rvsdg::Type> &
97 static std::shared_ptr<const ArrayType>
98 Create(std::shared_ptr<const Type> type,
size_t nelements)
100 return std::make_shared<ArrayType>(std::move(type), nelements);
105 std::shared_ptr<const rvsdg::Type>
type_;
128 [[nodiscard]] std::string
129 debug_string()
const override;
134 [[nodiscard]] std::size_t
135 ComputeHash() const noexcept override;
138 Kind() const noexcept override;
141 size() const noexcept
146 static std::shared_ptr<const FloatingPointType>
161 operator==(const
jlm::rvsdg::Type & other) const noexcept override;
163 [[nodiscard]] std::
size_t
164 ComputeHash() const noexcept override;
167 Kind() const noexcept override;
169 [[nodiscard]] std::
string
170 debug_string() const override;
193 std::vector<std::shared_ptr<const Type>> types,
195 const
bool isLiteral)
196 : name_(std::move(name)),
197 types_(std::move(types)),
199 isLiteral_(isLiteral)
213 operator==(
const Type & other)
const noexcept override;
215 [[nodiscard]] std::size_t
216 ComputeHash() const noexcept override;
219 Kind() const noexcept override;
222 elementTypes() const noexcept
232 return types_.size();
235 [[nodiscard]] std::shared_ptr<const Type>
239 return types_[index];
242 [[nodiscard]] std::string
243 debug_string()
const override;
255 return !name_.empty();
265 [[nodiscard]]
const std::string &
297 GetFieldOffset(
size_t fieldIndex)
const;
306 static std::shared_ptr<const StructType>
308 const std::string & name,
309 std::vector<std::shared_ptr<const Type>> types,
312 return std::make_shared<StructType>(name, std::move(types), isPacked,
false);
321 static std::shared_ptr<const StructType>
324 return CreateIdentified(
"", std::move(types), isPacked);
333 static std::shared_ptr<const StructType>
334 CreateLiteral(std::vector<std::shared_ptr<const Type>> types,
bool isPacked)
337 return std::make_shared<StructType>(
"", std::move(types), isPacked,
true);
342 std::vector<std::shared_ptr<const Type>> types_{};
352 type_(std::move(type))
369 Kind() const noexcept override;
372 size() const noexcept
383 [[nodiscard]]
const std::shared_ptr<const rvsdg::Type> &
391 std::shared_ptr<const rvsdg::Type>
type_;
406 [[nodiscard]] std::size_t
407 ComputeHash() const noexcept override;
409 [[nodiscard]] std::
string
410 debug_string() const override;
413 Create(std::shared_ptr<const rvsdg::Type> type,
size_t size)
415 return std::make_shared<FixedVectorType>(std::move(type), size);
431 [[nodiscard]] std::size_t
432 ComputeHash() const noexcept override;
434 [[nodiscard]] std::
string
435 debug_string() const override;
438 Create(std::shared_ptr<const rvsdg::Type> type,
size_t size)
440 return std::make_shared<ScalableVectorType>(std::move(type), size);
456 operator==(const
jlm::rvsdg::Type & other) const noexcept override;
458 [[nodiscard]] std::
size_t
459 ComputeHash() const noexcept override;
461 [[nodiscard]] std::
string
462 debug_string() const override;
465 Kind() const noexcept override;
483 [[nodiscard]] std::
string
484 debug_string() const override;
487 operator==(const
jlm::rvsdg::Type & other) const noexcept override;
489 [[nodiscard]] std::
size_t
490 ComputeHash() const noexcept override;
493 Kind() const noexcept override;
499template<class ELEMENTYPE>
501IsOrContains(const
jlm::rvsdg::Type & type)
506 if (
auto arrayType =
dynamic_cast<const ArrayType *
>(&type))
507 return IsOrContains<ELEMENTYPE>(arrayType->element_type());
509 if (
const auto structType =
dynamic_cast<const StructType *
>(&type))
511 for (
size_t n = 0; n < structType->numElements(); n++)
512 if (IsOrContains<ELEMENTYPE>(*structType->getElementType(n)))
518 if (
const auto vectorType =
dynamic_cast<const VectorType *
>(&type))
519 return IsOrContains<ELEMENTYPE>(vectorType->type());
548 std::is_base_of_v<rvsdg::Type, T>,
549 "Template parameter T must be derived from jlm::rvsdg::Type.");
551 auto vectorType =
dynamic_cast<const VectorType *
>(&type);
552 return vectorType && rvsdg::is<T>(vectorType->Type());
568 std::is_base_of_v<rvsdg::Type, T>,
569 "Template parameter T must be derived from jlm::rvsdg::Type.");
571 auto vectorType =
dynamic_cast<const VectorType *
>(&type);
572 return vectorType && rvsdg::is<T>(vectorType->Type()) && vectorType->
size() == size;
ArrayType(const ArrayType &other)=default
const std::shared_ptr< const rvsdg::Type > & GetElementType() const noexcept
ArrayType & operator=(const ArrayType &)=delete
ArrayType & operator=(ArrayType &&)=delete
const rvsdg::Type & element_type() const noexcept
ArrayType(ArrayType &&other)=default
std::shared_ptr< const rvsdg::Type > type_
static std::shared_ptr< const ArrayType > Create(std::shared_ptr< const Type > type, size_t nelements)
~ArrayType() noexcept override
~FixedVectorType() noexcept override
~FloatingPointType() noexcept override
~IOStateType() noexcept override
~MemoryStateType() noexcept override
static std::shared_ptr< const PointerType > Create()
~PointerType() noexcept override
bool operator==(const jlm::rvsdg::Type &other) const noexcept override
std::string debug_string() const override
std::size_t ComputeHash() const noexcept override
rvsdg::TypeKind Kind() const noexcept override
Return the kind of this type.
~ScalableVectorType() noexcept override
size_t numElements() const noexcept
static std::shared_ptr< const StructType > CreateLiteral(std::vector< std::shared_ptr< const Type > > types, bool isPacked)
StructType(const StructType &)=delete
static std::shared_ptr< const StructType > CreateIdentified(std::vector< std::shared_ptr< const Type > > types, bool isPacked)
bool IsLiteral() const noexcept
static std::shared_ptr< const StructType > CreateIdentified(const std::string &name, std::vector< std::shared_ptr< const Type > > types, bool isPacked)
const std::string & GetName() const noexcept
StructType(StructType &&)=delete
std::shared_ptr< const Type > getElementType(const size_t index) const noexcept
bool IsPacked() const noexcept
bool HasName() const noexcept
StructType & operator=(const StructType &)=delete
std::vector< std::shared_ptr< const Type > >::const_iterator ElementTypeConstIterator
StructType & operator=(StructType &&)=delete
~StructType() noexcept override
~VariableArgumentType() noexcept override
size_t size() const noexcept
VectorType(std::shared_ptr< const Type > type, size_t size)
const std::shared_ptr< const rvsdg::Type > & Type() const noexcept
VectorType(VectorType &&other)=default
const rvsdg::Type & type() const noexcept
VectorType & operator=(VectorType &&other)=default
VectorType & operator=(const VectorType &other)=default
std::shared_ptr< const rvsdg::Type > type_
VectorType(const VectorType &other)=default
constexpr Type() noexcept
Global memory state passed between functions.
bool isVectorOfSize(const rvsdg::Type &type, const size_t size)
bool isVectorOf(const rvsdg::Type &type)
bool IsAggregateType(const jlm::rvsdg::Type &type)
TypeKind
The kinds of types supported in rvsdg.
NodeType * TryGetOwnerNode(const rvsdg::Input &input) noexcept
Checks if this is an input to a node of specified type.