Skip to content

Commit

Permalink
[DPWBS-1446] feat(TriCore): add HighTec specific vendor defines
Browse files Browse the repository at this point in the history
Define __HIGHTEC__ macro as vendor identification.

This macro is needed to build libcxx with HighTec modifications.
  • Loading branch information
gargaroff committed May 14, 2020
1 parent 2840fe5 commit a186905
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions clang/lib/Basic/Targets.cpp
Expand Up @@ -99,6 +99,11 @@ void addCygMingDefines(const LangOptions &Opts, MacroBuilder &Builder) {
}
}

void addHighTecDefines(const LangOptions &Opts, MacroBuilder &Builder) {
// All HighTec compilers define __HIGHTEC__ as vendor identification
Builder.defineMacro("__HIGHTEC__");
}

//===----------------------------------------------------------------------===//
// Driver code
//===----------------------------------------------------------------------===//
Expand Down
4 changes: 4 additions & 0 deletions clang/lib/Basic/Targets.h
Expand Up @@ -41,6 +41,10 @@ void defineCPUMacros(clang::MacroBuilder &Builder, llvm::StringRef CPUName,
LLVM_LIBRARY_VISIBILITY
void addCygMingDefines(const clang::LangOptions &Opts,
clang::MacroBuilder &Builder);

LLVM_LIBRARY_VISIBILITY
void addHighTecDefines(const clang::LangOptions &Opts,
clang::MacroBuilder &Builder);
} // namespace targets
} // namespace clang
#endif // LLVM_CLANG_LIB_BASIC_TARGETS_H
4 changes: 4 additions & 0 deletions clang/lib/Basic/Targets/TriCore.cpp
Expand Up @@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//

#include "TriCore.h"
#include "Targets.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/MacroBuilder.h"
#include "llvm/ADT/StringRef.h"
Expand Down Expand Up @@ -153,6 +154,9 @@ void TriCoreTargetInfo::getTargetDefines(const LangOptions &Opts,
break;
}
Builder.defineMacro("__TRICORE_NAME__", TriCoreName);

// Vendor macros
addHighTecDefines(Opts, Builder);
}

bool TriCoreTargetInfo::isValidCPUName(StringRef Name) const {
Expand Down
3 changes: 2 additions & 1 deletion clang/test/Preprocessor/tricore-defines.c
Expand Up @@ -11,8 +11,9 @@
// RUN: %clang -target tricore -mcpu=tc39xx -E -dM %s -o - | FileCheck %s --check-prefixes=COMMON,TC161,TC162 -DARCH=0x162 -DCPU=0x3900
// RUN: %clang -target tricore -mcpu=tc4xx -E -dM %s -o - | FileCheck %s --check-prefixes=COMMON,TC161,TC162,TC18 -DARCH=0x18 -DCPU=0x4000

// Check target, architecture and CPU specific defines
// Check vendor, target, architecture and CPU specific defines

// COMMON-DAG: #define __HIGHTEC__ 1
// COMMON-DAG: #define __tricore 1
// COMMON-DAG: #define __tricore__ 1
// COMMON-DAG: #define __TRICORE__ 1
Expand Down

0 comments on commit a186905

Please sign in to comment.