CuPBoP/compilation/HostTranslation.cpp

42 lines
1.0 KiB
C++
Raw Normal View History

2022-05-04 20:59:38 +08:00
#include "RemoveCudaBuiltin.h"
2022-09-08 07:38:21 +08:00
#include "RemoveMetadata.h"
2022-05-04 20:59:38 +08:00
#include "ReplaceConstantMemory.h"
#include "ReplaceCudaBuiltin.h"
#include "ReplaceKernelArgs.h"
#include "tool.h"
#include <assert.h>
using namespace llvm;
2022-05-04 20:59:38 +08:00
std::string PATH = "kernel_meta.log";
int main(int argc, char **argv) {
assert(argc == 3 && "incorrect number of arguments\n");
char *input_host_path = argv[1];
char *output_host_path = argv[2];
2022-05-04 20:59:38 +08:00
std::ifstream fin;
fin.open(PATH);
// load LLVM module(s)
llvm::Module *hostModule = LoadModuleFromFilr(input_host_path);
VerifyModule(hostModule);
2022-06-26 02:44:50 +08:00
// remove metadata
RemoveMetadata(hostModule);
2022-05-04 20:59:38 +08:00
// replace const memory
ReplaceConstantMemory(hostModule, fin);
// process host module
2022-05-04 20:59:38 +08:00
ReplaceCudaBuiltin(hostModule);
// remove builtin unuse functions and variables
RemoveCudaBuiltin(hostModule);
// replace arguments in kernel_arg, from alloc to malloc
ReplaceKernelArg(hostModule);
VerifyModule(hostModule);
DumpModule(hostModule, output_host_path);
2022-05-04 20:59:38 +08:00
fin.close();
return 0;
}