Skip to content

Commit

Permalink
Remove AST based C++/HIP translation
Browse files Browse the repository at this point in the history
We have created an issue lcompilers#323 with detailed instructions how to port this
prototype backend to use ASR which will make it scalable and production ready.

Source files and old tests were removed.
  • Loading branch information
certik committed Apr 6, 2021
1 parent 737fc41 commit 81ba61d
Show file tree
Hide file tree
Showing 16 changed files with 0 additions and 1,365 deletions.
4 changes: 0 additions & 4 deletions run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ def main():
run_test("ast_f90", "lfortran --show-ast-f90 --no-color {infile}",
filename, update_reference)

if ast_cpp_hip:
run_test("ast_cpp_hip", "cpptranslate --show-ast-cpp-hip {infile}",
filename, update_reference)

if ast_openmp:
run_test("ast_openmp", "cpptranslate --show-ast-openmp {infile}",
filename, update_reference)
Expand Down
34 changes: 0 additions & 34 deletions src/bin/cpptranslate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <lfortran/semantics/ast_to_asr.h>
#include <lfortran/ast_to_src.h>
#include <lfortran/ast_to_openmp.h>
#include <lfortran/ast_to_cpp_hip.h>
#include <lfortran/config.h>


Expand Down Expand Up @@ -169,34 +168,6 @@ int emit_ast_openmp(const std::string &infile)
return 0;
}

int emit_ast_cpp_hip(const std::string &infile)
{
std::string input = read_file(infile);

// Src -> AST
Allocator al(64*1024*1024);
LFortran::AST::TranslationUnit_t* ast;
try {
ast = LFortran::parse2(al, input);
} catch (const LFortran::TokenizerError &e) {
std::cerr << "Tokenizing error: " << e.msg() << std::endl;
return 1;
} catch (const LFortran::ParserError &e) {
std::cerr << "Parsing error: " << e.msg() << std::endl;
return 2;
} catch (const LFortran::LFortranException &e) {
std::cerr << "Other LFortran exception: " << e.msg() << std::endl;
return 3;
}

// AST -> C++
// FIXME: For now we only transform the first node in the list:
std::string source = LFortran::ast_to_cpp_hip(*ast->m_items[0]);

std::cout << source << std::endl;
return 0;
}

int main(int argc, char *argv[])
{
std::string arg_file;
Expand All @@ -206,7 +177,6 @@ int main(int argc, char *argv[])
bool show_asr = false;
bool show_ast_f90 = false;
bool show_ast_openmp = false;
bool show_ast_cpp_hip = false;

CLI::App app{"cpptranslate: Fortran to C++ translation"};
app.add_option("file", arg_file, "Source file");
Expand All @@ -217,7 +187,6 @@ int main(int argc, char *argv[])
app.add_flag("--show-asr", show_asr, "Show ASR for the given file and exit");
app.add_flag("--show-ast-f90", show_ast_f90, "Show AST -> Fortran for the given file and exit");
app.add_flag("--show-ast-openmp", show_ast_openmp, "Show AST -> Fortran with OpenMP for the given file and exit");
app.add_flag("--show-ast-cpp-hip", show_ast_cpp_hip, "Show AST -> C++ with HIP for the given file and exit");
CLI11_PARSE(app, argc, argv);

if (arg_version) {
Expand Down Expand Up @@ -246,9 +215,6 @@ int main(int argc, char *argv[])
if (show_ast_openmp) {
return emit_ast_openmp(arg_file);
}
if (show_ast_cpp_hip) {
return emit_ast_cpp_hip(arg_file);
}

return 0;
}
1 change: 0 additions & 1 deletion src/lfortran/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ set(SRC
cwrapper.cpp

ast_to_src.cpp
ast_to_cpp_hip.cpp
ast_to_openmp.cpp

mod_to_asr.cpp
Expand Down
Loading

0 comments on commit 81ba61d

Please sign in to comment.