Skip to content

Commit

Permalink
RISC-V: use forward declarations in OMRLinkage.hpp
Browse files Browse the repository at this point in the history
Refactor code to use forward declaration in OMRLinkage.hpp rather
than `#include`s to short-circuit dependencies when extending by
OMR consumer.

Signed-off-by: Jan Vrany <jan.vrany@fit.cvut.cz>
  • Loading branch information
janvrany committed Dec 4, 2020
1 parent 5080dab commit 90b02e8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 24 deletions.
4 changes: 2 additions & 2 deletions compiler/riscv/codegen/OMRLinkage.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019, 2019 IBM Corp. and others
* Copyright (c) 2019, 2020 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -161,4 +161,4 @@ OMR::RV::Linkage::numArgumentRegisters(TR_RegisterKinds kind)
default:
return 0;
}
}
}
24 changes: 2 additions & 22 deletions compiler/riscv/codegen/OMRLinkage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,42 +35,22 @@ namespace OMR { typedef OMR::RV::Linkage LinkageConnector; }

#include <stddef.h>
#include <stdint.h>
#include "codegen/CodeGenerator.hpp"
#include "codegen/InstOpCode.hpp"
#include "codegen/RealRegister.hpp"
#include "codegen/Register.hpp"
#include "codegen/RegisterDependency.hpp"
#include "env/TRMemory.hpp"

class TR_FrontEnd;
namespace TR { class AutomaticSymbol; }
namespace TR { class CodeGenerator; }
namespace TR { class Compilation; }
namespace TR { class Instruction; }
namespace TR { class MemoryReference; }
namespace TR { class Node; }
namespace TR { class ParameterSymbol; }
namespace TR { class RegisterDependencyConditions; }
namespace TR { class ResolvedMethodSymbol; }

/**
* @brief Adds dependency
*/
inline void
addDependency(
TR::RegisterDependencyConditions *dep,
TR::Register *vreg,
TR::RealRegister::RegNum rnum,
TR_RegisterKinds rk,
TR::CodeGenerator *cg)
{
if (vreg == NULL)
{
vreg = cg->allocateRegister(rk);
}

dep->addPreCondition(vreg, rnum);
dep->addPostCondition(vreg, rnum);
}

namespace TR {

class RVMemoryArgument
Expand Down
21 changes: 21 additions & 0 deletions compiler/riscv/codegen/RVSystemLinkage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "codegen/Linkage.hpp"
#include "codegen/Linkage_inlines.hpp"
#include "codegen/MemoryReference.hpp"
#include "codegen/RegisterDependency.hpp"
#include "env/StackMemoryRegion.hpp"
#include "il/Node_inlines.hpp"
#include "il/AutomaticSymbol.hpp"
Expand Down Expand Up @@ -61,6 +62,26 @@
{ block; } \
)

/**
* @brief Adds dependency
*/
inline void
addDependency(
TR::RegisterDependencyConditions *dep,
TR::Register *vreg,
TR::RealRegister::RegNum rnum,
TR_RegisterKinds rk,
TR::CodeGenerator *cg)
{
if (vreg == NULL)
{
vreg = cg->allocateRegister(rk);
}

dep->addPreCondition(vreg, rnum);
dep->addPostCondition(vreg, rnum);
}

TR::RVSystemLinkage::RVSystemLinkage(TR::CodeGenerator *cg)
: TR::Linkage(cg)
{
Expand Down

0 comments on commit 90b02e8

Please sign in to comment.