mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
dfb9a36bb2
Implement compression of objects before they are saved into the storage provider. Each container type can specify which algorithm to use (currently `none` or `zstd`) and the compression level.
100 lines
3.0 KiB
C++
100 lines
3.0 KiB
C++
#pragma once
|
|
|
|
//
|
|
// This file is distributed under the MIT License. See LICENSE.md for details.
|
|
//
|
|
|
|
#include <string>
|
|
|
|
#include "llvm/ADT/ArrayRef.h"
|
|
|
|
#include "revng/PipeboxCommon/LLVMContainer.h"
|
|
#include "revng/PipeboxCommon/Model.h"
|
|
#include "revng/PipeboxCommon/RawContainer.h"
|
|
#include "revng/Pipeline/ContainerSet.h"
|
|
#include "revng/Pipeline/Context.h"
|
|
#include "revng/Pipeline/Contract.h"
|
|
#include "revng/Pipeline/GenericLLVMPipe.h"
|
|
#include "revng/Pipeline/LLVMContainer.h"
|
|
#include "revng/Pipeline/LLVMKind.h"
|
|
#include "revng/Pipeline/Target.h"
|
|
#include "revng/Pipes/FileContainer.h"
|
|
#include "revng/Pipes/Kinds.h"
|
|
#include "revng/Pipes/RootKind.h"
|
|
#include "revng/Pipes/TaggedFunctionKind.h"
|
|
|
|
namespace revng::pipes {
|
|
|
|
class CompileModule {
|
|
public:
|
|
static constexpr auto Name = "compile";
|
|
|
|
std::array<pipeline::ContractGroup, 1> getContract() const {
|
|
return { pipeline::ContractGroup(kinds::Root, 0, kinds::Object, 1) };
|
|
}
|
|
void run(pipeline::ExecutionContext &,
|
|
pipeline::LLVMContainer &ModuleContainer,
|
|
ObjectFileContainer &TargetBinary);
|
|
};
|
|
|
|
class CompileIsolatedModule {
|
|
public:
|
|
static constexpr auto Name = "compile-isolated";
|
|
|
|
std::array<pipeline::ContractGroup, 1> getContract() const {
|
|
return { pipeline::ContractGroup(kinds::IsolatedRoot,
|
|
0,
|
|
kinds::Object,
|
|
1,
|
|
pipeline::InputPreservation::Preserve) };
|
|
}
|
|
|
|
void run(pipeline::ExecutionContext &,
|
|
pipeline::LLVMContainer &ModuleContainer,
|
|
ObjectFileContainer &TargetBinary);
|
|
};
|
|
|
|
} // namespace revng::pipes
|
|
|
|
namespace revng::pypeline {
|
|
|
|
class ObjectFileContainer : public BytesContainer {
|
|
public:
|
|
static constexpr llvm::StringRef Name = "ObjectFileContainer";
|
|
static constexpr llvm::StringRef MimeType = "application/x-object";
|
|
static constexpr llvm::StringRef Compression = "zstd;level=1";
|
|
};
|
|
|
|
namespace piperuns {
|
|
|
|
class CompileRootModule {
|
|
private:
|
|
const model::Binary &Binary;
|
|
LLVMRootContainer &Input;
|
|
ObjectFileContainer &Output;
|
|
|
|
public:
|
|
static constexpr llvm::StringRef Name = "compile-root-module";
|
|
using Arguments = TypeList<PipeRunArgument<LLVMRootContainer,
|
|
"Input",
|
|
"The LLVM module that will be "
|
|
"compiled",
|
|
Access::Read>,
|
|
PipeRunArgument<ObjectFileContainer,
|
|
"Output",
|
|
"The compiled object file",
|
|
Access::Write>>;
|
|
|
|
CompileRootModule(const Model &TheModel,
|
|
llvm::StringRef StaticConfig,
|
|
llvm::StringRef DynamicConfig,
|
|
LLVMRootContainer &Input,
|
|
ObjectFileContainer &Output);
|
|
|
|
void run();
|
|
};
|
|
|
|
} // namespace piperuns
|
|
|
|
} // namespace revng::pypeline
|