Skip to content

Commit

Permalink
Merge branch 'master' into Rename-ScalableVectorType
Browse files Browse the repository at this point in the history
  • Loading branch information
haved authored Jan 28, 2025
2 parents 67c4522 + f3b773a commit 33ecff5
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 27 deletions.
5 changes: 3 additions & 2 deletions jlm/llvm/backend/jlm2llvm/instruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -883,9 +883,10 @@ convert_cast(
auto dsttype = std::dynamic_pointer_cast<const rvsdg::ValueType>(op.result(0));
auto operand = operands[0];

if (auto vt = dynamic_cast<const fixedvectortype *>(&operand->type()))
if (const auto vt = dynamic_cast<const FixedVectorType *>(&operand->type()))
{
auto type = typeConverter.ConvertJlmType(fixedvectortype(dsttype, vt->size()), llvmContext);
const auto type =
typeConverter.ConvertJlmType(FixedVectorType(dsttype, vt->size()), llvmContext);
return builder.CreateCast(OPCODE, ctx.value(operand), type);
}

Expand Down
4 changes: 2 additions & 2 deletions jlm/llvm/ir/TypeConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ TypeConverter::ConvertJlmType(const rvsdg::Type & type, ::llvm::LLVMContext & co
return ConvertStructType(*structType, context);
}

if (const auto fixedVectorType = dynamic_cast<const fixedvectortype *>(&type))
if (const auto fixedVectorType = dynamic_cast<const FixedVectorType *>(&type))
{
return ::llvm::VectorType::get(
ConvertJlmType(fixedVectorType->type(), context),
Expand Down Expand Up @@ -259,7 +259,7 @@ TypeConverter::ConvertLlvmType(::llvm::Type & type)
case ::llvm::Type::FixedVectorTyID:
{
auto scalarType = ConvertLlvmType(*type.getScalarType());
return fixedvectortype::Create(
return FixedVectorType::Create(
std::move(scalarType),
::llvm::cast<::llvm::FixedVectorType>(&type)->getNumElements());
}
Expand Down
12 changes: 6 additions & 6 deletions jlm/llvm/ir/operators/operators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ class vectorselect_op final : public rvsdg::SimpleOperation
static std::unique_ptr<llvm::tac>
create(const variable * p, const variable * t, const variable * f)
{
if (is<fixedvectortype>(p->type()) && is<fixedvectortype>(t->type()))
return createVectorSelectTac<fixedvectortype>(p, t, f);
if (is<FixedVectorType>(p->type()) && is<FixedVectorType>(t->type()))
return createVectorSelectTac<FixedVectorType>(p, t, f);

if (is<ScalableVectorType>(p->type()) && is<ScalableVectorType>(t->type()))
return createVectorSelectTac<ScalableVectorType>(p, t, f);
Expand Down Expand Up @@ -1996,7 +1996,7 @@ class shufflevector_op final : public rvsdg::SimpleOperation
public:
~shufflevector_op() override;

shufflevector_op(const std::shared_ptr<const fixedvectortype> & v, const std::vector<int> & mask)
shufflevector_op(const std::shared_ptr<const FixedVectorType> & v, const std::vector<int> & mask)
: SimpleOperation({ v, v }, { v }),
Mask_(mask)
{}
Expand Down Expand Up @@ -2026,8 +2026,8 @@ class shufflevector_op final : public rvsdg::SimpleOperation
static std::unique_ptr<llvm::tac>
create(const variable * v1, const variable * v2, const std::vector<int> & mask)
{
if (is<fixedvectortype>(v1->type()) && is<fixedvectortype>(v2->type()))
return CreateShuffleVectorTac<fixedvectortype>(v1, v2, mask);
if (is<FixedVectorType>(v1->type()) && is<FixedVectorType>(v2->type()))
return CreateShuffleVectorTac<FixedVectorType>(v1, v2, mask);

if (is<ScalableVectorType>(v1->type()) && is<ScalableVectorType>(v2->type()))
return CreateShuffleVectorTac<ScalableVectorType>(v1, v2, mask);
Expand Down Expand Up @@ -2364,7 +2364,7 @@ class constant_data_vector_op final : public rvsdg::SimpleOperation
if (!vt)
throw jlm::util::error("Expected value type.");

constant_data_vector_op op(fixedvectortype::Create(vt, elements.size()));
constant_data_vector_op op(FixedVectorType::Create(vt, elements.size()));
return tac::create(op, elements);
}
};
Expand Down
13 changes: 5 additions & 8 deletions jlm/llvm/ir/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,27 +189,24 @@ VectorType::operator==(const rvsdg::Type & other) const noexcept
return type && type->size_ == size_ && *type->type_ == *type_;
}

/* fixedvectortype */

fixedvectortype::~fixedvectortype()
{}
FixedVectorType::~FixedVectorType() noexcept = default;

bool
fixedvectortype::operator==(const jlm::rvsdg::Type & other) const noexcept
FixedVectorType::operator==(const jlm::rvsdg::Type & other) const noexcept
{
return VectorType::operator==(other);
}

std::size_t
fixedvectortype::ComputeHash() const noexcept
FixedVectorType::ComputeHash() const noexcept
{
auto typeHash = typeid(fixedvectortype).hash_code();
auto typeHash = typeid(FixedVectorType).hash_code();
auto sizeHash = std::hash<size_t>()(size());
return util::CombineHashes(typeHash, sizeHash, Type()->ComputeHash());
}

std::string
fixedvectortype::debug_string() const
FixedVectorType::debug_string() const
{
return util::strfmt("fixedvector[", type().debug_string(), ":", size(), "]");
}
Expand Down
10 changes: 5 additions & 5 deletions jlm/llvm/ir/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,12 +362,12 @@ class VectorType : public rvsdg::ValueType
std::shared_ptr<const rvsdg::ValueType> type_;
};

class fixedvectortype final : public VectorType
class FixedVectorType final : public VectorType
{
public:
~fixedvectortype() override;
~FixedVectorType() noexcept override;

fixedvectortype(std::shared_ptr<const rvsdg::ValueType> type, size_t size)
FixedVectorType(std::shared_ptr<const ValueType> type, size_t size)
: VectorType(std::move(type), size)
{}

Expand All @@ -380,10 +380,10 @@ class fixedvectortype final : public VectorType
virtual std::string
debug_string() const override;

static std::shared_ptr<const fixedvectortype>
static std::shared_ptr<const FixedVectorType>
Create(std::shared_ptr<const rvsdg::ValueType> type, size_t size)
{
return std::make_shared<fixedvectortype>(std::move(type), size);
return std::make_shared<FixedVectorType>(std::move(type), size);
}
};

Expand Down
2 changes: 1 addition & 1 deletion tests/jlm/llvm/ir/TestTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ TestIsOrContains()

// Vector types are weird, as LLVM does not consider them to be aggregate types,
// but they still contain other types
auto vectorType = fixedvectortype::Create(structType, 20);
const auto vectorType = FixedVectorType::Create(structType, 20);
assert(!IsAggregateType(*vectorType));
assert(IsOrContains<VectorType>(*vectorType));
assert(IsOrContains<StructType>(*vectorType));
Expand Down
6 changes: 3 additions & 3 deletions tests/jlm/llvm/ir/TypeConverterTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ LlvmVectorTypeConversion()
const auto vectorType2Llvm = ::llvm::VectorType::get(halfType, 9, true);

// Act
const auto vectorType1Jlm = std::dynamic_pointer_cast<const fixedvectortype>(
const auto vectorType1Jlm = std::dynamic_pointer_cast<const FixedVectorType>(
typeConverter.ConvertLlvmType(*vectorType1Llvm));
const auto vectorType2Jlm = std::dynamic_pointer_cast<const ScalableVectorType>(
typeConverter.ConvertLlvmType(*vectorType2Llvm));
Expand Down Expand Up @@ -652,8 +652,8 @@ JlmFixedVectorTypeConversion()
TypeConverter typeConverter;

const auto bit32Type = bittype::Create(32);
const auto fixedVectorType1 = fixedvectortype::Create(bit32Type, 2);
const auto fixedVectorType2 = fixedvectortype::Create(bit32Type, 4);
const auto fixedVectorType1 = FixedVectorType::Create(bit32Type, 2);
const auto fixedVectorType2 = FixedVectorType::Create(bit32Type, 4);

// Act
const auto vectorType1 =
Expand Down

0 comments on commit 33ecff5

Please sign in to comment.