From 9ddc316fa733734d1dfd00d79a64bd41c2b698ce Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Wed, 8 May 2019 15:25:06 +0300 Subject: [PATCH] [HIPIFY][perl] Support of hipify-perl generation from hipify-clang: next steps + Generate transformation map sorted by entity type. + Add a generation of supported header files. --- hipify-clang/src/main.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/hipify-clang/src/main.cpp b/hipify-clang/src/main.cpp index 3af20e6ffe..c92fbe3cad 100644 --- a/hipify-clang/src/main.cpp +++ b/hipify-clang/src/main.cpp @@ -125,11 +125,26 @@ bool generatePerl(bool Generate = true) { } *perlStreamPtr.get() << "\"" << counterNames[NUM_CONV_TYPES - 1] << "\");\n\n"; *perlStreamPtr.get() << sConv << "$ft{'" << counterNames[NUM_CONV_TYPES - 1] << "'};\n\n"; - for (auto& ma : CUDA_RENAMES_MAP()) { - if (Statistics::isUnsupported(ma.second)) { - continue; + for (int i = 0; i < NUM_CONV_TYPES; i++) { + if (i == CONV_INCLUDE_CUDA_MAIN_H || i == CONV_INCLUDE) { + for (auto& ma : CUDA_INCLUDE_MAP) { + if (Statistics::isUnsupported(ma.second)) { + continue; + } + if (i == ma.second.type) { + *perlStreamPtr.get() << "$ft{'" + std::string(counterNames[ma.second.type]) + "'} += s/\\b" + std::string(ma.first) + "\\b/" + std::string(ma.second.hipName) + "/g;\n"; + } + } + } else { + for (auto& ma : CUDA_RENAMES_MAP()) { + if (Statistics::isUnsupported(ma.second)) { + continue; + } + if (i == ma.second.type) { + *perlStreamPtr.get() << "$ft{'" + std::string(counterNames[ma.second.type]) + "'} += s/\\b" + std::string(ma.first) + "\\b/" + std::string(ma.second.hipName) + "/g;\n"; + } + } } - *perlStreamPtr.get() << "$ft{'" + std::string(counterNames[ma.second.type]) + "'} += s/\\b" + std::string(ma.first) + "\\b/" + std::string(ma.second.hipName) + "/g;\n"; } perlStreamPtr.get()->flush(); bool ret = true;