Skip to content

Commit

Permalink
Rename statetype class to StateType (phate#645)
Browse files Browse the repository at this point in the history
  • Loading branch information
phate authored Oct 3, 2024
1 parent f1b2f15 commit 08d3362
Show file tree
Hide file tree
Showing 20 changed files with 44 additions and 53 deletions.
2 changes: 1 addition & 1 deletion jlm/hls/backend/rhls2firrtl/base-hls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ BaseHLS::JlmSize(const jlm::rvsdg::Type * type)
{
return ceil(log2(ct->nalternatives()));
}
else if (dynamic_cast<const jlm::rvsdg::statetype *>(type))
else if (dynamic_cast<const rvsdg::StateType *>(type))
{
return 1;
}
Expand Down
17 changes: 7 additions & 10 deletions jlm/hls/backend/rhls2firrtl/verilator-harness-hls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ VerilatorHarnessHLS::get_text(llvm::RvsdgModule & rm)
size_t register_ix = 0;
for (size_t i = 0; i < ln->type().NumArguments(); ++i)
{
if (dynamic_cast<const jlm::rvsdg::statetype *>(&ln->type().ArgumentType(i)))
if (dynamic_cast<const rvsdg::StateType *>(&ln->type().ArgumentType(i)))
{
register_ix++;
continue;
Expand Down Expand Up @@ -552,8 +552,7 @@ VerilatorHarnessHLS::get_text(llvm::RvsdgModule & rm)
" hls_loads.erase(hls_loads.begin(), hls_loads.end());\n"
" hls_stores.erase(hls_stores.begin(), hls_stores.end());\n"
" mem_access_ctr = 0;\n";
if (ln->type().NumResults()
&& !dynamic_cast<const jlm::rvsdg::statetype *>(&ln->type().ResultType(0)))
if (ln->type().NumResults() && !dynamic_cast<const rvsdg::StateType *>(&ln->type().ResultType(0)))
{
cpp << " return top->o_data_0;\n";
}
Expand Down Expand Up @@ -607,8 +606,7 @@ VerilatorHarnessHLS::get_text(llvm::RvsdgModule & rm)
" close(fd[0]);\n"
" }\n";

if (ln->type().NumResults()
&& !dynamic_cast<const jlm::rvsdg::statetype *>(&ln->type().ResultType(0)))
if (ln->type().NumResults() && !dynamic_cast<const rvsdg::StateType *>(&ln->type().ResultType(0)))
{
cpp << " return 0;\n";
}
Expand All @@ -618,8 +616,7 @@ VerilatorHarnessHLS::get_text(llvm::RvsdgModule & rm)
" ";
call_function(cpp, ln, "run_ref");
cpp << "\n";
if (ln->type().NumResults()
&& !dynamic_cast<const jlm::rvsdg::statetype *>(&ln->type().ResultType(0)))
if (ln->type().NumResults() && !dynamic_cast<const rvsdg::StateType *>(&ln->type().ResultType(0)))
{
cpp << " return ";
}
Expand All @@ -643,7 +640,7 @@ VerilatorHarnessHLS::call_function(
cpp << function_name << "(";
for (size_t i = 0; i < ln->type().NumArguments(); ++i)
{
if (dynamic_cast<const jlm::rvsdg::statetype *>(&ln->type().ArgumentType(i)))
if (dynamic_cast<const rvsdg::StateType *>(&ln->type().ArgumentType(i)))
{
continue;
}
Expand Down Expand Up @@ -674,7 +671,7 @@ VerilatorHarnessHLS::get_function_header(
else
{
auto type = &ln->type().ResultType(0);
if (dynamic_cast<const jlm::rvsdg::statetype *>(type))
if (dynamic_cast<const rvsdg::StateType *>(type))
{
return_type = "void";
}
Expand All @@ -690,7 +687,7 @@ VerilatorHarnessHLS::get_function_header(
cpp << return_type << " " << function_name << "(\n";
for (size_t i = 0; i < ln->type().NumArguments(); ++i)
{
if (dynamic_cast<const jlm::rvsdg::statetype *>(&ln->type().ArgumentType(i)))
if (dynamic_cast<const rvsdg::StateType *>(&ln->type().ArgumentType(i)))
{
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion jlm/hls/backend/rvsdg2rhls/GammaConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ CanGammaNodeBeSpeculative(const rvsdg::GammaNode & gammaNode)
for (size_t i = 0; i < gammaNode.noutputs(); ++i)
{
auto gammaOutput = gammaNode.output(i);
if (rvsdg::is<rvsdg::statetype>(gammaOutput->type()))
if (rvsdg::is<rvsdg::StateType>(gammaOutput->type()))
{
// don't allow state outputs since they imply operations with side effects
return false;
Expand Down
4 changes: 2 additions & 2 deletions jlm/hls/ir/hls.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,14 +457,14 @@ class buffer_op final : public jlm::rvsdg::simple_op
private:
};

class triggertype final : public jlm::rvsdg::statetype
class triggertype final : public rvsdg::StateType
{
public:
virtual ~triggertype()
{}

triggertype()
: jlm::rvsdg::statetype()
: rvsdg::StateType()
{}

std::string
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 @@ -36,7 +36,7 @@ GetOrCreateTypeGraphNode(const rvsdg::Type & type, util::Graph & typeGraph)
node.SetLabel(type.debug_string());

// Some types get special handling, such as adding incoming edges from aggregate types
if (rvsdg::is<rvsdg::statetype>(type) || rvsdg::is<rvsdg::bittype>(type)
if (rvsdg::is<rvsdg::StateType>(type) || rvsdg::is<rvsdg::bittype>(type)
|| rvsdg::is<PointerType>(type) || rvsdg::is<fptype>(type) || rvsdg::is<varargtype>(type))
{
// No need to provide any information beyond the debug string
Expand Down
2 changes: 1 addition & 1 deletion jlm/llvm/backend/jlm2llvm/instruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ convert_select(
JLM_ASSERT(is<select_op>(op));
auto & select = *static_cast<const select_op *>(&op);

if (rvsdg::is<rvsdg::statetype>(select.type()))
if (rvsdg::is<rvsdg::StateType>(select.type()))
return nullptr;

auto c = ctx.value(operands[0]);
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 @@ -344,7 +344,7 @@ convert_attributes(const function_node & f, context & ctx)
{
auto argument = f.cfg()->entry()->argument(n);

if (rvsdg::is<rvsdg::statetype>(argument->type()))
if (rvsdg::is<rvsdg::StateType>(argument->type()))
continue;

argsets.push_back(convert_attributes(argument->attributes(), ctx));
Expand Down
4 changes: 2 additions & 2 deletions jlm/llvm/backend/jlm2llvm/type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ convert(const FunctionType & functionType, context & ctx)
}

/*
The return type can either be (ValueType, statetype, statetype, ...) if the function has
a return value, or (statetype, statetype, ...) if the function returns void.
The return type can either be (ValueType, StateType, StateType, ...) if the function has
a return value, or (StateType, StateType, ...) if the function returns void.
*/
auto resultType = ::llvm::Type::getVoidTy(lctx);
if (functionType.NumResults() > 0 && rvsdg::is<rvsdg::ValueType>(functionType.ResultType(0)))
Expand Down
2 changes: 1 addition & 1 deletion jlm/llvm/ir/operators/Load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ perform_load_load_state_reduction(
rvsdg::output *(size_t, rvsdg::output *, std::vector<std::vector<rvsdg::output *>> &)>
reduce_state = [&](size_t index, rvsdg::output * operand, auto & mxstates)
{
JLM_ASSERT(rvsdg::is<rvsdg::statetype>(operand->type()));
JLM_ASSERT(rvsdg::is<rvsdg::StateType>(operand->type()));

if (!is<LoadNonVolatileOperation>(rvsdg::node_output::node(operand)))
return operand;
Expand Down
2 changes: 1 addition & 1 deletion jlm/llvm/ir/operators/Load.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class LoadOperation : public rvsdg::simple_op
auto & operandType = *operandTypes[n];
auto & resultType = *resultTypes[n];
JLM_ASSERT(operandType == resultType);
JLM_ASSERT(is<rvsdg::statetype>(operandType));
JLM_ASSERT(is<rvsdg::StateType>(operandType));
}
}

Expand Down
2 changes: 1 addition & 1 deletion jlm/llvm/ir/operators/Store.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class StoreOperation : public rvsdg::simple_op
auto & operandType = *operandTypes[n + 2];
auto & resultType = *resultTypes[n];
JLM_ASSERT(operandType == resultType);
JLM_ASSERT(is<rvsdg::statetype>(operandType));
JLM_ASSERT(is<rvsdg::StateType>(operandType));
}
}

Expand Down
17 changes: 6 additions & 11 deletions jlm/llvm/ir/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,12 @@ class fptype final : public rvsdg::ValueType

/* vararg type */

class varargtype final : public jlm::rvsdg::statetype
class varargtype final : public rvsdg::StateType
{
public:
virtual ~varargtype();

inline constexpr varargtype()
: jlm::rvsdg::statetype()
{}
constexpr varargtype() = default;

virtual bool
operator==(const jlm::rvsdg::Type & other) const noexcept override;
Expand Down Expand Up @@ -498,13 +496,12 @@ class scalablevectortype final : public vectortype
*
* This type is used for state edges that sequentialize input/output operations.
*/
class iostatetype final : public jlm::rvsdg::statetype
class iostatetype final : public rvsdg::StateType
{
public:
~iostatetype() override;

constexpr iostatetype() noexcept
{}
constexpr iostatetype() noexcept = default;

virtual bool
operator==(const jlm::rvsdg::Type & other) const noexcept override;
Expand All @@ -524,14 +521,12 @@ class iostatetype final : public jlm::rvsdg::statetype
* Represents the type of abstract memory locations and is used in state edges for sequentialiazing
* memory operations, such as load and store operations.
*/
class MemoryStateType final : public jlm::rvsdg::statetype
class MemoryStateType final : public rvsdg::StateType
{
public:
~MemoryStateType() noexcept override;

constexpr MemoryStateType() noexcept
: jlm::rvsdg::statetype()
{}
constexpr MemoryStateType() noexcept = default;

std::string
debug_string() const override;
Expand Down
2 changes: 1 addition & 1 deletion jlm/llvm/opt/push.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ has_side_effects(const jlm::rvsdg::node * node)
{
for (size_t n = 0; n < node->noutputs(); n++)
{
if (dynamic_cast<const jlm::rvsdg::statetype *>(&node->output(n)->type()))
if (dynamic_cast<const rvsdg::StateType *>(&node->output(n)->type()))
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion jlm/rvsdg/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ctltype::~ctltype() noexcept
{}

ctltype::ctltype(size_t nalternatives)
: jlm::rvsdg::statetype(),
: StateType(),
nalternatives_(nalternatives)
{}

Expand Down
2 changes: 1 addition & 1 deletion jlm/rvsdg/control.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace jlm::rvsdg

/* control type */

class ctltype final : public jlm::rvsdg::statetype
class ctltype final : public StateType
{
public:
virtual ~ctltype() noexcept;
Expand Down
4 changes: 2 additions & 2 deletions jlm/rvsdg/statemux.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class mux_op final : public simple_op
public:
virtual ~mux_op() noexcept;

inline mux_op(std::shared_ptr<const statetype> type, size_t narguments, size_t nresults)
inline mux_op(std::shared_ptr<const StateType> type, size_t narguments, size_t nresults)
: simple_op({ narguments, type }, { nresults, type })
{}

Expand Down Expand Up @@ -100,7 +100,7 @@ create_state_mux(
if (operands.empty())
throw jlm::util::error("Insufficient number of operands.");

auto st = std::dynamic_pointer_cast<const jlm::rvsdg::statetype>(type);
auto st = std::dynamic_pointer_cast<const StateType>(type);
if (!st)
throw jlm::util::error("Expected state type.");

Expand Down
3 changes: 1 addition & 2 deletions jlm/rvsdg/type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ Type::~Type() noexcept = default;

ValueType::~ValueType() noexcept = default;

statetype::~statetype() noexcept
{}
StateType::~StateType() noexcept = default;

}
8 changes: 4 additions & 4 deletions jlm/rvsdg/type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ class ValueType : public Type
{}
};

class statetype : public jlm::rvsdg::Type
class StateType : public Type
{
public:
virtual ~statetype() noexcept;
~StateType() noexcept override;

protected:
inline constexpr statetype() noexcept
: jlm::rvsdg::Type()
constexpr StateType() noexcept
: Type()
{}
};

Expand Down
14 changes: 7 additions & 7 deletions tests/jlm/llvm/ir/TestTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ TestIsOrContains()
assert(IsOrContains<jlm::rvsdg::ValueType>(*pointerType));
assert(!IsOrContains<jlm::rvsdg::ValueType>(*memoryStateType));
assert(!IsOrContains<jlm::rvsdg::ValueType>(*ioStateType));
assert(!IsOrContains<jlm::rvsdg::statetype>(*pointerType));
assert(IsOrContains<jlm::rvsdg::statetype>(*memoryStateType));
assert(IsOrContains<jlm::rvsdg::statetype>(*ioStateType));
assert(!IsOrContains<jlm::rvsdg::StateType>(*pointerType));
assert(IsOrContains<jlm::rvsdg::StateType>(*memoryStateType));
assert(IsOrContains<jlm::rvsdg::StateType>(*ioStateType));

// Function types are not aggregate types
auto functionType = FunctionType::Create(
Expand All @@ -42,23 +42,23 @@ TestIsOrContains()
assert(!IsAggregateType(*functionType));
assert(IsOrContains<FunctionType>(*functionType));
assert(!IsOrContains<PointerType>(*functionType));
assert(!IsOrContains<jlm::rvsdg::statetype>(*functionType));
assert(!IsOrContains<jlm::rvsdg::StateType>(*functionType));

// Struct types are aggregates that can contain other types
auto declaration = StructType::Declaration::Create({ valueType, pointerType });
auto structType = StructType::Create(false, *declaration);
assert(IsAggregateType(*structType));
assert(IsOrContains<StructType>(*structType));
assert(IsOrContains<PointerType>(*structType));
assert(!IsOrContains<jlm::rvsdg::statetype>(*structType));
assert(!IsOrContains<jlm::rvsdg::StateType>(*structType));

// Create an array containing the atruct type
auto arrayType = arraytype::Create(structType, 20);
assert(IsAggregateType(*arrayType));
assert(IsOrContains<arraytype>(*arrayType));
assert(IsOrContains<StructType>(*arrayType));
assert(IsOrContains<PointerType>(*arrayType));
assert(!IsOrContains<jlm::rvsdg::statetype>(*arrayType));
assert(!IsOrContains<jlm::rvsdg::StateType>(*arrayType));

// Vector types are weird, as LLVM does not consider them to be aggregate types,
// but they still contain other types
Expand All @@ -67,7 +67,7 @@ TestIsOrContains()
assert(IsOrContains<vectortype>(*vectorType));
assert(IsOrContains<StructType>(*vectorType));
assert(IsOrContains<PointerType>(*vectorType));
assert(!IsOrContains<jlm::rvsdg::statetype>(*vectorType));
assert(!IsOrContains<jlm::rvsdg::StateType>(*vectorType));

return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/test-types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ class valuetype final : public rvsdg::ValueType
Create();
};

class statetype final : public rvsdg::statetype
class statetype final : public rvsdg::StateType
{
public:
virtual ~statetype();

inline constexpr statetype() noexcept
: rvsdg::statetype()
: rvsdg::StateType()
{}

virtual std::string
Expand Down

0 comments on commit 08d3362

Please sign in to comment.