Parsing and sema support for #pragma omp target data
Details
Diff Detail
Event Timeline
include/clang/AST/OpenMPClause.h | ||
---|---|---|
21 ↗ | (On Diff #28530) | Header file is not required, remove |
131 ↗ | (On Diff #28530) | Method is not used, so it must be removed |
include/clang/AST/StmtOpenMP.h | ||
1821 | Some of your changes are not formatted, use clang-format tool. | |
include/clang/Sema/Sema.h | ||
7860–7862 | Format | |
lib/CodeGen/CGStmtOpenMP.cpp | ||
2103 | I think all target related directives should just emit original code at first, so the user could use them. | |
lib/Parse/ParseOpenMP.cpp | ||
46–58 | This code is copied from clang-omp, we're using another solution in official clang. See the patch for 'declare simd' construct (http://reviews.llvm.org/D10599) |
lib/Parse/ParseOpenMP.cpp | ||
---|---|---|
46–58 | Perhaps I misunderstand it. The issue of the suggested approach is that it treats 'data' as a directive in order to have { OMPD_target, OMPD_data, OMPD_target_data }. Creating a fake OMPD_data may be confusing. That is why I took this approach. |
Kelvin, you don't need fake OMPD_data, instead mark it as OMPD_unknown
and check explicitly that 'data' identifier is expected
Best regards,
Alexey Bataev
Software Engineer
Intel Compiler Team
01.07.2015 18:03, Kelvin Li пишет:
Comment at: lib/Parse/ParseOpenMP.cpp:43-55
@@ -42,2 +42,15 @@: getOpenMPDirectiveKind(P.getPreprocessor().getSpelling(Tok));+
+ switch (DKind) {
+ case OMPD_target: {
+ auto SavedToken = P.getPreprocessor().LookAhead(0);
+ if (!SavedToken.isAnnotation()) {
+ if (P.getPreprocessor().getSpelling(SavedToken) == "data") {
+ DKind = OMPD_target_data;
+ P.ConsumeToken();
+ }
+ }
+ break;
+ }
+ default:for (unsigned i = 0; i < llvm::array_lengthof(F); ++i) {
ABataev wrote:
This code is copied from clang-omp, we're using another solution in official clang. See the patch for 'declare simd' construct (http://reviews.llvm.org/D10599)
Perhaps I misunderstand it. The issue of the suggested approach is that it treats 'data' as a directive in order to have { OMPD_target, OMPD_data, OMPD_target_data }. Creating a fake OMPD_data may be confusing. That is why I took this approach.
http://reviews.llvm.org/D10765
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
Revised based on comments.
- Fixed format
- Added code not to assert in EmitOMPTargetDataDirective
- Incorporated 'target data' parsing in the current framework
Seems to me, the updated patch is not correct. It is missing a lot of required things. Besides, new tests were removed from updated patch
include/clang-c/Index.h | ||
---|---|---|
2230 | Add a cursor for TargetData directive | |
include/clang/AST/DataRecursiveASTVisitor.h | ||
2407–2410 | Add recursive visitor for the new directive | |
include/clang/AST/RecursiveASTVisitor.h | ||
2439–2442 | Add recursive visitor for the new directive | |
include/clang/Basic/OpenMPKinds.def | ||
95 | Add definition of the target data directive | |
274 | There is support for if clause, but macro OPENMP_TARGET_DATA_CLAUSE() is not defined and if clause is not associated with target data directive | |
include/clang/Basic/StmtNodes.td | ||
206–207 | Add a node for target data directive | |
include/clang/Serialization/ASTBitCodes.h | ||
1399–1400 | Add a serialization code for target data directive | |
lib/CodeGen/CGExpr.cpp | ||
1961 ↗ | (On Diff #29206) | Bad solution, restore original code. Instead you should capture variables used in the target data directive |
lib/CodeGen/CGStmtOpenMP.cpp | ||
2103–2105 | Remove braces | |
2104–2121 | In general, this a bad solution. Look at static void emitOMPIfClause() in CGOpenMPRuntime.cpp for better codegen. Your solution won't work with cleanups and exceptions. | |
lib/CodeGen/CodeGenFunction.h | ||
2218 | This one may be just a static function in CGStmtOpenMP.cpp | |
lib/Parse/ParseOpenMP.cpp | ||
34 | Move it to the beginning of the array. | |
76 | Update your patch to the latest revision and sync it with it |
- this is the full diff
- sync up the code in ParseOpenMPDirectiveKind
- use the existing infrastructure for generating if clause on target data
Thanks.
lib/CodeGen/CGExpr.cpp | ||
---|---|---|
1963 ↗ | (On Diff #29959) | Restore original file |
lib/CodeGen/CGOpenMPRuntime.cpp | ||
1099 ↗ | (On Diff #29959) |
|
lib/CodeGen/CGStmtOpenMP.cpp | ||
2124–2152 | As the first commit we can ignore all clauses, just call EmitStmt(cast<CapturedStmt>(S.getAssociateStmt())->getCapturedStmt()); | |
lib/Parse/ParseOpenMP.cpp | ||
65 | SDKind == OMPD_unknown | |
68–69 | TokenMatched = (i == 0) && !P.getPreprocessor().getSpelling(Tok).compare("point") || (i == 1) && !P.getPreprocessor().getSpelling(Tok).compare("data"); |
lib/CodeGen/CGOpenMPRuntime.cpp | ||
---|---|---|
1099 ↗ | (On Diff #29959) | Ok. I will leave the changes for the codegen patch. |
- excluded the codegen code in EmitOMPTargetDataDirective, it currently just emits the code inside the construct
- updated ParseOpenMPDirectiveKind for handling "target data"
This has been committed for Kelvin Li.
Command: Commit
Modified: D:\llvmtrunk\tools\clang\include\clang\AST\DataRecursiveASTVisitor.h
Modified: D:\llvmtrunk\tools\clang\include\clang\AST\RecursiveASTVisitor.h
Modified: D:\llvmtrunk\tools\clang\include\clang\AST\StmtOpenMP.h
Modified: D:\llvmtrunk\tools\clang\include\clang\Basic\OpenMPKinds.def
Modified: D:\llvmtrunk\tools\clang\include\clang\Basic\StmtNodes.td
Modified: D:\llvmtrunk\tools\clang\include\clang\Sema\Sema.h
Modified: D:\llvmtrunk\tools\clang\include\clang\Serialization\ASTBitCodes.h
Modified: D:\llvmtrunk\tools\clang\include\clang-c\Index.h
Modified: D:\llvmtrunk\tools\clang\lib\AST\Stmt.cpp
Modified: D:\llvmtrunk\tools\clang\lib\AST\StmtPrinter.cpp
Modified: D:\llvmtrunk\tools\clang\lib\AST\StmtProfile.cpp
Modified: D:\llvmtrunk\tools\clang\lib\Basic\OpenMPKinds.cpp
Modified: D:\llvmtrunk\tools\clang\lib\CodeGen\CGStmt.cpp
Modified: D:\llvmtrunk\tools\clang\lib\CodeGen\CGStmtOpenMP.cpp
Modified: D:\llvmtrunk\tools\clang\lib\CodeGen\CodeGenFunction.h
Modified: D:\llvmtrunk\tools\clang\lib\Parse\ParseOpenMP.cpp
Modified: D:\llvmtrunk\tools\clang\lib\Sema\SemaOpenMP.cpp
Modified: D:\llvmtrunk\tools\clang\lib\Sema\TreeTransform.h
Modified: D:\llvmtrunk\tools\clang\lib\Serialization\ASTReaderStmt.cpp
Modified: D:\llvmtrunk\tools\clang\lib\Serialization\ASTWriterStmt.cpp
Modified: D:\llvmtrunk\tools\clang\lib\StaticAnalyzer\Core\ExprEngine.cpp
Adding: D:\llvmtrunk\tools\clang\test\OpenMP\target_data_ast_print.cpp
Adding: D:\llvmtrunk\tools\clang\test\OpenMP\target_data_if_messages.cpp
Adding: D:\llvmtrunk\tools\clang\test\OpenMP\target_data_messages.c
Modified: D:\llvmtrunk\tools\clang\tools\libclang\CIndex.cpp
Modified: D:\llvmtrunk\tools\clang\tools\libclang\CXCursor.cpp
Sending content: D:\llvmtrunk\tools\clang\lib\AST\StmtPrinter.cpp
Sending content: D:\llvmtrunk\tools\clang\lib\CodeGen\CodeGenFunction.h
Sending content: D:\llvmtrunk\tools\clang\lib\CodeGen\CGStmtOpenMP.cpp
Sending content: D:\llvmtrunk\tools\clang\include\clang\Basic\OpenMPKinds.def
Sending content: D:\llvmtrunk\tools\clang\lib\Sema\TreeTransform.h
Sending content: D:\llvmtrunk\tools\clang\include\clang\AST\DataRecursiveASTVisitor.h
Sending content: D:\llvmtrunk\tools\clang\include\clang\Serialization\ASTBitCodes.h
Sending content: D:\llvmtrunk\tools\clang\include\clang\Basic\StmtNodes.td
Sending content: D:\llvmtrunk\tools\clang\lib\Sema\SemaOpenMP.cpp
Sending content: D:\llvmtrunk\tools\clang\lib\StaticAnalyzer\Core\ExprEngine.cpp
Sending content: D:\llvmtrunk\tools\clang\test\OpenMP\target_data_if_messages.cpp
Sending content: D:\llvmtrunk\tools\clang\include\clang\AST\RecursiveASTVisitor.h
Sending content: D:\llvmtrunk\tools\clang\include\clang-c\Index.h
Sending content: D:\llvmtrunk\tools\clang\lib\AST\StmtProfile.cpp
Sending content: D:\llvmtrunk\tools\clang\lib\Serialization\ASTReaderStmt.cpp
Sending content: D:\llvmtrunk\tools\clang\lib\Parse\ParseOpenMP.cpp
Sending content: D:\llvmtrunk\tools\clang\include\clang\AST\StmtOpenMP.h
Sending content: D:\llvmtrunk\tools\clang\lib\CodeGen\CGStmt.cpp
Sending content: D:\llvmtrunk\tools\clang\lib\Basic\OpenMPKinds.cpp
Sending content: D:\llvmtrunk\tools\clang\lib\Serialization\ASTWriterStmt.cpp
Sending content: D:\llvmtrunk\tools\clang\test\OpenMP\target_data_ast_print.cpp
Sending content: D:\llvmtrunk\tools\clang\test\OpenMP\target_data_messages.c
Sending content: D:\llvmtrunk\tools\clang\tools\libclang\CXCursor.cpp
Sending content: D:\llvmtrunk\tools\clang\lib\AST\Stmt.cpp
Sending content: D:\llvmtrunk\tools\clang\tools\libclang\CIndex.cpp
Sending content: D:\llvmtrunk\tools\clang\include\clang\Sema\Sema.h
Completed: At revision: 242785
Add a cursor for TargetData directive