Skip to content

Commit

Permalink
Rename iostatetype class to IOStateType (#779)
Browse files Browse the repository at this point in the history
  • Loading branch information
phate authored Jan 28, 2025
1 parent e866509 commit d5aac63
Show file tree
Hide file tree
Showing 34 changed files with 311 additions and 314 deletions.
14 changes: 7 additions & 7 deletions jlm/hls/backend/rvsdg2rhls/instrument-ref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,16 @@ instrument_ref(llvm::RvsdgModule & rm)
}
// The function should always have an IO state if it has a memory state
auto ioStateArgumentIndex = numArguments - 2;
JLM_ASSERT(rvsdg::is<llvm::iostatetype>(functionType.ArgumentType(ioStateArgumentIndex)));
JLM_ASSERT(rvsdg::is<llvm::IOStateType>(functionType.ArgumentType(ioStateArgumentIndex)));

// TODO: make this less hacky by using the correct state types
// addr, width, memstate
auto loadFunctionType = jlm::rvsdg::FunctionType::Create(
{ jlm::llvm::PointerType::Create(),
jlm::rvsdg::bittype::Create(64),
llvm::iostatetype::Create(),
llvm::IOStateType::Create(),
llvm::MemoryStateType::Create() },
{ llvm::iostatetype::Create(), llvm::MemoryStateType::Create() });
{ llvm::IOStateType::Create(), llvm::MemoryStateType::Create() });
auto & reference_load = llvm::GraphImport::Create(
graph,
loadFunctionType,
Expand All @@ -102,9 +102,9 @@ instrument_ref(llvm::RvsdgModule & rm)
{ jlm::llvm::PointerType::Create(),
jlm::rvsdg::bittype::Create(64),
jlm::rvsdg::bittype::Create(64),
llvm::iostatetype::Create(),
llvm::IOStateType::Create(),
jlm::llvm::MemoryStateType::Create() },
{ llvm::iostatetype::Create(), jlm::llvm::MemoryStateType::Create() });
{ llvm::IOStateType::Create(), jlm::llvm::MemoryStateType::Create() });
auto & reference_store = llvm::GraphImport::Create(
graph,
storeFunctionType,
Expand All @@ -115,9 +115,9 @@ instrument_ref(llvm::RvsdgModule & rm)
auto allocaFunctionType = jlm::rvsdg::FunctionType::Create(
{ jlm::llvm::PointerType::Create(),
jlm::rvsdg::bittype::Create(64),
llvm::iostatetype::Create(),
llvm::IOStateType::Create(),
jlm::llvm::MemoryStateType::Create() },
{ llvm::iostatetype::Create(), jlm::llvm::MemoryStateType::Create() });
{ llvm::IOStateType::Create(), jlm::llvm::MemoryStateType::Create() });
auto & reference_alloca = llvm::GraphImport::Create(
graph,
allocaFunctionType,
Expand Down
2 changes: 1 addition & 1 deletion jlm/llvm/backend/dot/DotWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ AttachNodeInput(util::Port & inputPort, const rvsdg::input & rvsdgInput)
auto & edge = graph.CreateDirectedEdge(*originPort, inputPort);
if (rvsdg::is<MemoryStateType>(rvsdgInput.type()))
edge.SetAttribute("color", util::Colors::Red);
if (rvsdg::is<iostatetype>(rvsdgInput.type()))
if (rvsdg::is<IOStateType>(rvsdgInput.type()))
edge.SetAttribute("color", util::Colors::Green);
}
}
Expand Down
4 changes: 2 additions & 2 deletions jlm/llvm/backend/jlm2llvm/instruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ convert(
{
auto argument = args[n];

if (rvsdg::is<iostatetype>(argument->type()))
if (rvsdg::is<IOStateType>(argument->type()))
continue;
if (rvsdg::is<MemoryStateType>(argument->type()))
continue;
Expand Down Expand Up @@ -288,7 +288,7 @@ convert_phi(
auto & llvmContext = ctx.llvm_module().getContext();
auto & typeConverter = ctx.GetTypeConverter();

if (rvsdg::is<iostatetype>(phi.type()))
if (rvsdg::is<IOStateType>(phi.type()))
return nullptr;
if (rvsdg::is<MemoryStateType>(phi.type()))
return nullptr;
Expand Down
2 changes: 1 addition & 1 deletion jlm/llvm/backend/jlm2llvm/jlm2llvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ convert_cfg(llvm::cfg & cfg, ::llvm::Function & f, context & ctx)
if (!is<phi_op>(tac->operation()))
continue;

if (rvsdg::is<iostatetype>(tac->result(0)->type()))
if (rvsdg::is<IOStateType>(tac->result(0)->type()))
continue;
if (rvsdg::is<MemoryStateType>(tac->result(0)->type()))
continue;
Expand Down
6 changes: 3 additions & 3 deletions jlm/llvm/ir/TypeConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ TypeConverter::ConvertFunctionType(
continue;
}

if (rvsdg::is<iostatetype>(argumentType))
if (rvsdg::is<IOStateType>(argumentType))
continue;
if (rvsdg::is<MemoryStateType>(argumentType))
continue;
Expand All @@ -82,14 +82,14 @@ TypeConverter::ConvertFunctionType(const ::llvm::FunctionType & functionType)
argumentTypes.push_back(ConvertLlvmType(*functionType.getParamType(n)));
if (functionType.isVarArg())
argumentTypes.push_back(create_varargtype());
argumentTypes.push_back(iostatetype::Create());
argumentTypes.push_back(IOStateType::Create());
argumentTypes.push_back(MemoryStateType::Create());

// Results
std::vector<std::shared_ptr<const rvsdg::Type>> resultTypes;
if (functionType.getReturnType()->getTypeID() != ::llvm::Type::VoidTyID)
resultTypes.push_back(ConvertLlvmType(*functionType.getReturnType()));
resultTypes.push_back(iostatetype::Create());
resultTypes.push_back(IOStateType::Create());
resultTypes.push_back(MemoryStateType::Create());

return rvsdg::FunctionType::Create(std::move(argumentTypes), std::move(resultTypes));
Expand Down
8 changes: 4 additions & 4 deletions jlm/llvm/ir/operators/Load.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class LoadVolatileOperation final : public LoadOperation
CreateOperandTypes(size_t numMemoryStates)
{
std::vector<std::shared_ptr<const rvsdg::Type>> types(
{ PointerType::Create(), iostatetype::Create() });
{ PointerType::Create(), IOStateType::Create() });
std::vector<std::shared_ptr<const rvsdg::Type>> states(
numMemoryStates,
MemoryStateType::Create());
Expand All @@ -139,7 +139,7 @@ class LoadVolatileOperation final : public LoadOperation
CreateResultTypes(std::shared_ptr<const rvsdg::ValueType> loadedType, size_t numMemoryStates)
{
std::vector<std::shared_ptr<const rvsdg::Type>> types(
{ std::move(loadedType), iostatetype::Create() });
{ std::move(loadedType), IOStateType::Create() });
std::vector<std::shared_ptr<const rvsdg::Type>> states(
numMemoryStates,
MemoryStateType::Create());
Expand Down Expand Up @@ -273,15 +273,15 @@ class LoadVolatileNode final : public LoadNode
GetIoStateInput() const noexcept
{
auto ioInput = input(1);
JLM_ASSERT(is<iostatetype>(ioInput->type()));
JLM_ASSERT(is<IOStateType>(ioInput->type()));
return *ioInput;
}

[[nodiscard]] rvsdg::output &
GetIoStateOutput() const noexcept
{
auto ioOutput = output(1);
JLM_ASSERT(is<iostatetype>(ioOutput->type()));
JLM_ASSERT(is<IOStateType>(ioOutput->type()));
return *ioOutput;
}

Expand Down
4 changes: 2 additions & 2 deletions jlm/llvm/ir/operators/MemCpy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,15 @@ class MemCpyVolatileOperation final : public MemCpyOperation
std::vector<std::shared_ptr<const rvsdg::Type>> types = { pointerType,
pointerType,
std::move(lengthType),
iostatetype::Create() };
IOStateType::Create() };
types.insert(types.end(), numMemoryStates, MemoryStateType::Create());
return types;
}

static std::vector<std::shared_ptr<const rvsdg::Type>>
CreateResultTypes(size_t numMemoryStates)
{
std::vector<std::shared_ptr<const rvsdg::Type>> types(1, iostatetype::Create());
std::vector<std::shared_ptr<const rvsdg::Type>> types(1, IOStateType::Create());
types.insert(types.end(), numMemoryStates, MemoryStateType::Create());
return types;
}
Expand Down
8 changes: 4 additions & 4 deletions jlm/llvm/ir/operators/Store.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ class StoreVolatileOperation final : public StoreOperation
CreateOperandTypes(std::shared_ptr<const rvsdg::ValueType> storedType, size_t numMemoryStates)
{
std::vector<std::shared_ptr<const rvsdg::Type>> types(
{ PointerType::Create(), std::move(storedType), iostatetype::Create() });
{ PointerType::Create(), std::move(storedType), IOStateType::Create() });
std::vector<std::shared_ptr<const rvsdg::Type>> states(
numMemoryStates,
MemoryStateType::Create());
Expand All @@ -403,7 +403,7 @@ class StoreVolatileOperation final : public StoreOperation
static std::vector<std::shared_ptr<const rvsdg::Type>>
CreateResultTypes(size_t numMemoryStates)
{
std::vector<std::shared_ptr<const rvsdg::Type>> types({ iostatetype::Create() });
std::vector<std::shared_ptr<const rvsdg::Type>> types({ IOStateType::Create() });
std::vector<std::shared_ptr<const rvsdg::Type>> memoryStates(
numMemoryStates,
MemoryStateType::Create());
Expand Down Expand Up @@ -441,15 +441,15 @@ class StoreVolatileNode final : public StoreNode
GetIoStateInput() const noexcept
{
auto ioStateInput = input(2);
JLM_ASSERT(is<iostatetype>(ioStateInput->type()));
JLM_ASSERT(is<IOStateType>(ioStateInput->type()));
return *ioStateInput;
}

[[nodiscard]] rvsdg::output &
GetIoStateOutput() const noexcept
{
auto ioStateOutput = output(0);
JLM_ASSERT(is<iostatetype>(ioStateOutput->type()));
JLM_ASSERT(is<IOStateType>(ioStateOutput->type()));
return *ioStateOutput;
}

Expand Down
8 changes: 4 additions & 4 deletions jlm/llvm/ir/operators/call.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ class CallNode final : public jlm::rvsdg::SimpleNode
GetIoStateInput() const noexcept
{
auto iOState = input(ninputs() - 2);
JLM_ASSERT(is<iostatetype>(iOState->type()));
JLM_ASSERT(is<IOStateType>(iOState->type()));
return iOState;
}

Expand All @@ -393,7 +393,7 @@ class CallNode final : public jlm::rvsdg::SimpleNode
GetIoStateOutput() const noexcept
{
auto iOState = output(noutputs() - 2);
JLM_ASSERT(is<iostatetype>(iOState->type()));
JLM_ASSERT(is<IOStateType>(iOState->type()));
return iOState;
}

Expand Down Expand Up @@ -541,7 +541,7 @@ class CallNode final : public jlm::rvsdg::SimpleNode
if (!is<MemoryStateType>(functionType.ArgumentType(memoryStateArgumentIndex)))
throw jlm::util::error("Expected memory state type.");

if (!is<iostatetype>(functionType.ArgumentType(iOStateArgumentIndex)))
if (!is<IOStateType>(functionType.ArgumentType(iOStateArgumentIndex)))
throw jlm::util::error("Expected IO state type.");
};

Expand All @@ -556,7 +556,7 @@ class CallNode final : public jlm::rvsdg::SimpleNode
if (!is<MemoryStateType>(functionType.ResultType(memoryStateResultIndex)))
throw jlm::util::error("Expected memory state type.");

if (!is<iostatetype>(functionType.ResultType(iOStateResultIndex)))
if (!is<IOStateType>(functionType.ResultType(iOStateResultIndex)))
throw jlm::util::error("Expected IO state type.");
};

Expand Down
4 changes: 2 additions & 2 deletions jlm/llvm/ir/operators/operators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2572,7 +2572,7 @@ class FreeOperation final : public rvsdg::SimpleOperation

std::vector<std::shared_ptr<const rvsdg::Type>> types({ PointerType::Create() });
types.insert(types.end(), memoryStates.begin(), memoryStates.end());
types.emplace_back(iostatetype::Create());
types.emplace_back(IOStateType::Create());

return types;
}
Expand All @@ -2583,7 +2583,7 @@ class FreeOperation final : public rvsdg::SimpleOperation
std::vector<std::shared_ptr<const rvsdg::Type>> types(
numMemoryStates,
MemoryStateType::Create());
types.emplace_back(iostatetype::Create());
types.emplace_back(IOStateType::Create());

return types;
}
Expand Down
23 changes: 10 additions & 13 deletions jlm/llvm/ir/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,34 +239,31 @@ scalablevectortype::debug_string() const
return util::strfmt("scalablevector[", type().debug_string(), ":", size(), "]");
}

/* I/O state type */

iostatetype::~iostatetype()
{}
IOStateType::~IOStateType() noexcept = default;

bool
iostatetype::operator==(const jlm::rvsdg::Type & other) const noexcept
IOStateType::operator==(const Type & other) const noexcept
{
return jlm::rvsdg::is<iostatetype>(other);
return jlm::rvsdg::is<IOStateType>(other);
}

std::size_t
iostatetype::ComputeHash() const noexcept
IOStateType::ComputeHash() const noexcept
{
return typeid(iostatetype).hash_code();
return typeid(IOStateType).hash_code();
}

std::string
iostatetype::debug_string() const
IOStateType::debug_string() const
{
return "iostate";
}

std::shared_ptr<const iostatetype>
iostatetype::Create()
std::shared_ptr<const IOStateType>
IOStateType::Create()
{
static const iostatetype instance;
return std::shared_ptr<const iostatetype>(std::shared_ptr<void>(), &instance);
static const IOStateType instance;
return std::shared_ptr<const IOStateType>(std::shared_ptr<void>(), &instance);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions jlm/llvm/ir/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,12 +416,12 @@ class scalablevectortype final : public VectorType
*
* This type is used for state edges that sequentialize input/output operations.
*/
class iostatetype final : public rvsdg::StateType
class IOStateType final : public rvsdg::StateType
{
public:
~iostatetype() override;
~IOStateType() noexcept override;

constexpr iostatetype() noexcept = default;
constexpr IOStateType() noexcept = default;

virtual bool
operator==(const jlm::rvsdg::Type & other) const noexcept override;
Expand All @@ -432,7 +432,7 @@ class iostatetype final : public rvsdg::StateType
virtual std::string
debug_string() const override;

static std::shared_ptr<const iostatetype>
static std::shared_ptr<const IOStateType>
Create();
};

Expand Down
2 changes: 1 addition & 1 deletion jlm/llvm/opt/InvariantValueRedirection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ InvariantValueRedirection::RedirectThetaOutputs(rvsdg::ThetaNode & thetaNode)
{
// FIXME: In order to also redirect I/O state type variables, we need to know whether a loop
// terminates.
if (rvsdg::is<iostatetype>(loopVar.input->type()))
if (rvsdg::is<IOStateType>(loopVar.input->type()))
continue;

if (rvsdg::ThetaLoopVarIsInvariant(loopVar))
Expand Down
2 changes: 1 addition & 1 deletion jlm/mlir/backend/JlmToMlirConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ JlmToMlirConverter::ConvertType(const rvsdg::Type & type)
{
return Builder_->getIntegerType(bt->nbits());
}
else if (rvsdg::is<llvm::iostatetype>(type))
else if (rvsdg::is<llvm::IOStateType>(type))
{
return Builder_->getType<::mlir::rvsdg::IOStateEdgeType>();
}
Expand Down
2 changes: 1 addition & 1 deletion jlm/mlir/frontend/MlirToJlmConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ MlirToJlmConverter::ConvertType(::mlir::Type & type)
}
else if (::mlir::isa<::mlir::rvsdg::IOStateEdgeType>(type))
{
return std::make_unique<llvm::iostatetype>();
return std::make_unique<llvm::IOStateType>();
}
else
{
Expand Down
Loading

0 comments on commit d5aac63

Please sign in to comment.