Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: Chen, Sheng S <[email protected]>
  • Loading branch information
ShengchenJ committed May 30, 2024
1 parent 8e77bba commit 9c085eb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
9 changes: 6 additions & 3 deletions clang/lib/Lex/PPExpressions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,14 @@ static bool EvaluateValue(PPValue &Result, Token &PeekTok, DefinedTracker &DT,
}
Result.Val = 0;
#ifdef SYCLomatic_CUSTOMIZATION
// If macro name is '__CUDA_ARCH__' and is inside analysis-scope-path folder, handle
// it as defined '900'
// If macro name is '__CUDA_ARCH__' and is inside analysis-scope-path
// folder, handle it as defined '900'
if (II->getName() == "__CUDA_ARCH__" &&
IsInAnalysisScopeFunc(PeekTok.getLocation())) {
Result.Val = 900;
if (GetRunRound() == 0)
Result.Val = 900;
else
Result.Val = 0;
}
#endif // SYCLomatic_CUSTOMIZATION
Result.Val.setIsUnsigned(false); // "0" is signed intmax_t 0.
Expand Down
5 changes: 2 additions & 3 deletions clang/lib/Lex/Preprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -836,15 +836,14 @@ bool Preprocessor::HandleIdentifier(Token &Identifier) {
}
#ifdef SYCLomatic_CUSTOMIZATION
else if (LangOpts.CUDA && II.getName() == "__CUDA_ARCH__" &&
IsInAnalysisScopeFunc(Identifier.getLocation())) {
IsInAnalysisScopeFunc(Identifier.getLocation()) && GetRunRound() == 0) {
// Make a MacroDefinition for __CUDA_ARCH__
MacroInfo *MI = AllocateMacroInfo(SourceLocation());
MI->setIsBuiltinMacro();
DefMacroDirective DMD(MI, SourceLocation());
ArrayRef<ModuleMacro *> MMs;
MacroDefinition MD(&DMD, MMs, false);
if (GetRunRound() == 0)
appendDefMacroDirective(&II, MI);
appendDefMacroDirective(&II, MI);
if (!DisableMacroExpansion) {
if (!Identifier.isExpandDisabled() && MI->isEnabled()) {
// C99 6.10.3p10: If the preprocessing token immediately after the
Expand Down
2 changes: 1 addition & 1 deletion clang/test/dpct/cuda_arch_test/test.cu
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ __host__ __device__ int test(T a, T b){
// CHECK-NEXT: int test1_host_ct{{[0-9]+}}(){
// CHECK-NEXT: #if !DPCT_COMPATIBILITY_TEMP > 800
// CHECK-NEXT: return threadIdx.x > 8;
// CHECK-NEXT: #elif !DPCT_COMPATIBILITY_TEMP > 700
// CHECK-NEXT: #elif __CUDA_ARCH__ > 700
// CHECK-NEXT: return threadIdx.x > 7;
// CHECK-NEXT: #elif !DPCT_COMPATIBILITY_TEMP > 600
// CHECK-NEXT: return threadIdx.x > 6;
Expand Down

0 comments on commit 9c085eb

Please sign in to comment.