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
190 std::vector<std::shared_ptr<const
Type>> types,
192 const
bool isLiteral)
193 : name_(std::move(name)),
194 types_(std::move(types)),
196 isLiteral_(isLiteral)
212 [[nodiscard]] std::size_t
216 Kind() const noexcept override;
219 numElements() const noexcept
221 return types_.size();
224 [[nodiscard]] std::shared_ptr<const Type>
228 return types_[index];
231 [[nodiscard]] std::string
244 return !name_.empty();
254 [[nodiscard]]
const std::string &
286 GetFieldOffset(
size_t fieldIndex)
const;
295 static std::shared_ptr<const StructType>
297 const std::string & name,
298 std::vector<std::shared_ptr<const Type>> types,
301 return std::make_shared<StructType>(name, std::move(types), isPacked,
false);
310 static std::shared_ptr<const StructType>
313 return CreateIdentified(
"", std::move(types), isPacked);
322 static std::shared_ptr<const StructType>
323 CreateLiteral(std::vector<std::shared_ptr<const Type>> types,
bool isPacked)
326 return std::make_shared<StructType>(
"", std::move(types), isPacked,
true);
331 std::vector<std::shared_ptr<const Type>> types_{};
341 type_(std::move(
type))
358 Kind() const noexcept override;
361 size() const noexcept
372 [[nodiscard]]
const std::shared_ptr<const rvsdg::Type> &
380 std::shared_ptr<const rvsdg::Type>
type_;
395 [[nodiscard]] std::size_t
398 [[nodiscard]] std::
string
404 return std::make_shared<FixedVectorType>(std::move(
type), size);
420 [[nodiscard]] std::size_t
423 [[nodiscard]] std::
string
429 return std::make_shared<ScalableVectorType>(std::move(
type), size);
445 operator==(const
jlm::rvsdg::
Type & other) const noexcept override;
447 [[nodiscard]] std::
size_t
450 [[nodiscard]] std::
string
454 Kind() const noexcept override;
472 [[nodiscard]] std::
string
476 operator==(const
jlm::rvsdg::
Type & other) const noexcept override;
478 [[nodiscard]] std::
size_t
482 Kind() const noexcept override;
488 template<class ELEMENTYPE>
492 if (jlm::rvsdg::is<ELEMENTYPE>(
type))
496 return IsOrContains<ELEMENTYPE>(arrayType->element_type());
498 if (
const auto structType =
dynamic_cast<const StructType *
>(&
type))
500 for (
size_t n = 0; n < structType->numElements(); n++)
501 if (IsOrContains<ELEMENTYPE>(*structType->getElementType(n)))
507 if (
const auto vectorType =
dynamic_cast<const VectorType *
>(&
type))
508 return IsOrContains<ELEMENTYPE>(vectorType->type());
522 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
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)
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)
static std::string type(const Node *n)
TypeKind
The kinds of types supported in rvsdg.