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
134 [[nodiscard]] std::size_t
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
167 Kind() const noexcept override;
169 [[nodiscard]] std::
string
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)
215 [[nodiscard]] std::size_t
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
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
409 [[nodiscard]] std::
string
415 return std::make_shared<FixedVectorType>(std::move(type), size);
431 [[nodiscard]] std::size_t
434 [[nodiscard]] std::
string
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
461 [[nodiscard]] std::
string
465 Kind() const noexcept override;
483 [[nodiscard]] std::
string
487 operator==(const
jlm::rvsdg::
Type & other) const noexcept override;
489 [[nodiscard]] std::
size_t
493 Kind() const noexcept override;
499 template<class ELEMENTYPE>
503 if (jlm::rvsdg::is<ELEMENTYPE>(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());
533 return jlm::rvsdg::is<ArrayType>(type) || jlm::rvsdg::is<StructType>(type);
ArrayType(const ArrayType &other)=default
ArrayType & operator=(ArrayType &&)=delete
ArrayType & operator=(const ArrayType &)=delete
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
const std::shared_ptr< const rvsdg::Type > & GetElementType() const noexcept
const rvsdg::Type & element_type() const noexcept
~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
std::shared_ptr< const Type > getElementType(const size_t index) const noexcept
StructType & operator=(StructType &&)=delete
StructType(const StructType &)=delete
bool IsLiteral() const noexcept
StructType(StructType &&)=delete
bool IsPacked() const noexcept
bool HasName() const noexcept
static std::shared_ptr< const StructType > CreateIdentified(std::vector< std::shared_ptr< const Type >> types, bool isPacked)
std::vector< std::shared_ptr< const Type > >::const_iterator ElementTypeConstIterator
static std::shared_ptr< const StructType > CreateIdentified(const std::string &name, std::vector< std::shared_ptr< const Type >> types, bool isPacked)
static std::shared_ptr< const StructType > CreateLiteral(std::vector< std::shared_ptr< const Type >> types, bool isPacked)
StructType & operator=(const StructType &)=delete
const std::string & GetName() const noexcept
~StructType() noexcept override
~VariableArgumentType() noexcept override
const rvsdg::Type & type() const noexcept
VectorType(std::shared_ptr< const Type > type, size_t size)
VectorType & operator=(const VectorType &other)=default
VectorType(VectorType &&other)=default
const std::shared_ptr< const rvsdg::Type > & Type() const noexcept
std::shared_ptr< const rvsdg::Type > type_
VectorType(const VectorType &other)=default
VectorType & operator=(VectorType &&other)=default
constexpr Type() noexcept
Global memory state passed between functions.
size_t GetTypeAlignment(const rvsdg::Type &type)
bool IsOrContains(const jlm::rvsdg::Type &type)
size_t GetTypeAllocSize(const rvsdg::Type &type)
size_t GetTypeStoreSize(const rvsdg::Type &type)
bool IsAggregateType(const jlm::rvsdg::Type &type)
TypeKind
The kinds of types supported in rvsdg.