summaryrefslogtreecommitdiffstats
path: root/clang/lib/Basic/Targets/X86.cpp
diff options
context:
space:
mode:
authorAli Tamur <tamur@google.com>2018-10-08 22:25:20 +0000
committerAli Tamur <tamur@google.com>2018-10-08 22:25:20 +0000
commitbc1cd929bf9f4a65911c85bdc45b51a5ad6d5449 (patch)
tree4b6431c4b44c8a7457cd793aab1d6d518734cd6e /clang/lib/Basic/Targets/X86.cpp
parente2877ad3b9a30ffdc2e7de48abdb90b9d22cab8f (diff)
downloadbcm5719-llvm-bc1cd929bf9f4a65911c85bdc45b51a5ad6d5449.tar.gz
bcm5719-llvm-bc1cd929bf9f4a65911c85bdc45b51a5ad6d5449.zip
Introduce code_model macros
Summary: gcc defines macros such as __code_model_small_ based on the user passed command line flag -mcmodel. clang accepts a flag with the same name and similar effects, but does not generate any macro that the user can use. This cl narrows the gap between gcc and clang behaviour. However, achieving full compatibility with gcc is not trivial: The set of valid values for mcmodel in gcc and clang are not equal. Also, gcc defines different macros for different architectures. In this cl, we only tackle an easy part of the problem and define the macro only for x64 architecture. When the user does not specify a mcmodel, the macro for small code model is produced, as is the case with gcc. Reviewers: compnerd, MaskRay Reviewed By: MaskRay Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D52920 llvm-svn: 344000
Diffstat (limited to 'clang/lib/Basic/Targets/X86.cpp')
-rw-r--r--clang/lib/Basic/Targets/X86.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 94d1112401c..b986ea35a28 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -860,6 +860,11 @@ bool X86TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
/// definitions for this particular subtarget.
void X86TargetInfo::getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const {
+ std::string CodeModel = getTargetOpts().CodeModel;
+ if (CodeModel == "default")
+ CodeModel = "small";
+ Builder.defineMacro("__code_model_" + CodeModel + "_");
+
// Target identification.
if (getTriple().getArch() == llvm::Triple::x86_64) {
Builder.defineMacro("__amd64__");
OpenPOWER on IntegriCloud