Use a custom FrontendAction to simplify identifier translation

Most of what hipify does is really just replacing CUDA idenitifers
with HIP ones. CUDA function calls, preprocessor macro calls,
enum references, types, etc.

This is problematic: calls/types/enum-refs require name resolution
for the AST matcher to work. This fails in the presence of code
deleted by the preprocessor, and in two-pass template compilation.

Instead, we can simply hook the lexer and have it rewrite the
identifiers for us.

This approach means identifier transformations will work correctly
regardless of where they appear (and we get to delete lots of code)

- Fixes #260
- Helps a bit with #207 - it will still fail to translate kernel
calls in preprocessor-ignored code, but everything except kerel
launches should translate correctly now, even in
preprocessor-deleted code.
Tento commit je obsažen v:
Chris Kitching
2017-10-30 03:47:50 +00:00
rodič 9165df3848
revize 24cdc5e1d3
8 změnil soubory, kde provedl 782 přidání a 862 odebrání
-1
Zobrazit soubor
@@ -2677,7 +2677,6 @@ const std::map<llvm::StringRef, hipCounter>& CUDA_RENAMES_MAP() {
// First run, so compute the union map.
ret = CUDA_IDENTIFIER_MAP;
ret.insert(CUDA_INCLUDE_MAP.begin(), CUDA_INCLUDE_MAP.end());
ret.insert(CUDA_TYPE_NAME_MAP.begin(), CUDA_TYPE_NAME_MAP.end());
return ret;