summaryrefslogtreecommitdiffstats
path: root/clang/lib/Basic
diff options
context:
space:
mode:
authorFlorian Hahn <florian.hahn@arm.com>2017-06-06 09:26:15 +0000
committerFlorian Hahn <florian.hahn@arm.com>2017-06-06 09:26:15 +0000
commit28f03bbcbb1e440fc52f0c2dfbd92f81e5e892c6 (patch)
treece95f16ca2467d347cc594603200dace347953b1 /clang/lib/Basic
parentb2781fb1865dc23fcbbf3aed0983bf79d3b6ad63 (diff)
downloadbcm5719-llvm-28f03bbcbb1e440fc52f0c2dfbd92f81e5e892c6.tar.gz
bcm5719-llvm-28f03bbcbb1e440fc52f0c2dfbd92f81e5e892c6.zip
[ARM] Add support for target("arm") and target("thumb").
Summary: This patch adds support for the target("arm") and target("thumb") attributes, which can be used to force the compiler to generated ARM or Thumb code for a function. In LLVM, ARM or Thumb code generation can be controlled by the thumb-mode target feature. But GCC already uses target("arm") and target("thumb"), so we have to substitute "arm" with -thumb-mode and "thumb" with +thumb-mode. Reviewers: echristo, pcc, kristof.beyls Reviewed By: echristo Subscribers: ahatanak, aemerson, javed.absar, kristof.beyls, cfe-commits Differential Revision: https://reviews.llvm.org/D33721 llvm-svn: 304781
Diffstat (limited to 'clang/lib/Basic')
-rw-r--r--clang/lib/Basic/Targets.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index 605f73802af..bb8d81858ad 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -5438,7 +5438,17 @@ public:
if (Feature[0] == '+')
Features[Feature.drop_front(1)] = true;
- return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
+ // Convert user-provided arm and thumb GNU target attributes to
+ // [-|+]thumb-mode target features respectively.
+ std::vector<std::string> UpdatedFeaturesVec(FeaturesVec);
+ for (auto &Feature : UpdatedFeaturesVec) {
+ if (Feature.compare("+arm") == 0)
+ Feature = "-thumb-mode";
+ else if (Feature.compare("+thumb") == 0)
+ Feature = "+thumb-mode";
+ }
+
+ return TargetInfo::initFeatureMap(Features, Diags, CPU, UpdatedFeaturesVec);
}
bool handleTargetFeatures(std::vector<std::string> &Features,
OpenPOWER on IntegriCloud