mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
6a3ab92a9d
Several components in both pipeline YAMLs are slated for removal. Prepend a legacy prefix to their names, and to the matching c++ code, so they are clearly distinguished from the new Clift-based pipeline until they are dropped.
71 lines
2.4 KiB
C++
71 lines
2.4 KiB
C++
//
|
|
// This file is distributed under the MIT License. See LICENSE.md for details.
|
|
//
|
|
|
|
#include "revng/HeadersGeneration/ConfigurationHelpers.h"
|
|
#include "revng/HeadersGeneration/PTMLHeaderBuilder.h"
|
|
#include "revng/Pipeline/AllRegistries.h"
|
|
#include "revng/Pipeline/RegisterContainerFactory.h"
|
|
#include "revng/Pipes/FileContainer.h"
|
|
#include "revng/Pipes/Kinds.h"
|
|
|
|
namespace revng::pipes {
|
|
|
|
inline constexpr char HelpersHeaderFactoryMIMEType[] = "text/x.c+ptml";
|
|
inline constexpr char HelpersHeaderFactorySuffix[] = ".h";
|
|
inline constexpr char HelpersHeaderFactoryName[] = "legacy-helpers-header";
|
|
using HelpersHeaderFileContainer = FileContainer<&kinds::LegacyHelpersHeader,
|
|
HelpersHeaderFactoryName,
|
|
HelpersHeaderFactoryMIMEType,
|
|
HelpersHeaderFactorySuffix>;
|
|
|
|
class HelpersToHeader {
|
|
public:
|
|
static constexpr auto Name = "legacy-helpers-to-header";
|
|
|
|
std::array<pipeline::ContractGroup, 1> getContract() const {
|
|
using namespace pipeline;
|
|
using namespace revng::kinds;
|
|
|
|
return { ContractGroup{ Contract(StackAccessesSegregated,
|
|
0,
|
|
LegacyHelpersHeader,
|
|
1,
|
|
InputPreservation::Preserve) } };
|
|
}
|
|
|
|
void run(pipeline::ExecutionContext &EC,
|
|
pipeline::LLVMContainer &IRContainer,
|
|
HelpersHeaderFileContainer &HeaderFile) {
|
|
if (EC.getRequestedTargetsFor(HeaderFile).empty())
|
|
return;
|
|
|
|
std::error_code ErrorCode;
|
|
llvm::raw_fd_ostream Header(HeaderFile.getOrCreatePath(), ErrorCode);
|
|
if (ErrorCode)
|
|
revng_abort(ErrorCode.message().c_str());
|
|
|
|
const auto &Model = *revng::getModelFromContext(EC);
|
|
|
|
ptml::ModelCBuilder
|
|
B(Header,
|
|
Model,
|
|
/* EnableTaglessMode = */ false,
|
|
{ .ExplicitTargetPointerSize = getExplicitPointerSize(Model) });
|
|
ptml::HeaderBuilder(B).printHelpersHeader(IRContainer.getModule());
|
|
Header.flush();
|
|
ErrorCode = Header.error();
|
|
if (ErrorCode)
|
|
revng_abort(ErrorCode.message().c_str());
|
|
|
|
EC.commitUniqueTarget(HeaderFile);
|
|
}
|
|
};
|
|
|
|
using namespace pipeline;
|
|
static RegisterDefaultConstructibleContainer<HelpersHeaderFileContainer> Reg;
|
|
|
|
} // end namespace revng::pipes
|
|
|
|
static pipeline::RegisterPipe<revng::pipes::HelpersToHeader> Y;
|