[PATCH] D33721: [ARM] Add support for target("arm") and target("thumb").
Florian Hahn via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 5 10:13:48 PDT 2017
fhahn updated this revision to Diff 101427.
fhahn marked an inline comment as done.
fhahn added a comment.
use else if
https://reviews.llvm.org/D33721
Files:
lib/Basic/Targets.cpp
test/CodeGen/arm-target-attr.c
Index: test/CodeGen/arm-target-attr.c
===================================================================
--- /dev/null
+++ test/CodeGen/arm-target-attr.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple thumb-apple-darwin -emit-llvm -o - %s | FileCheck --check-prefix CHECKPOS %s
+// RUN: %clang_cc1 -triple thumb-apple-darwin -emit-llvm -o - %s | FileCheck --check-prefix CHECKNEG %s
+// RUN: %clang_cc1 -triple arm-apple-darwin -emit-llvm -o - %s | FileCheck --check-prefix CHECKPOS %s
+// RUN: %clang_cc1 -triple arm-apple-darwin -emit-llvm -o - %s | FileCheck --check-prefix CHECKNEG %s
+
+__attribute__((target("arm"))) void test_target_arm() {
+ // CHECKPOS: define void @test_target_arm() [[ARM_ATTRS:#[0-9]+]]
+ // CHECKNEG: define void @test_target_arm() [[ARM_ATTRS:#[0-9]+]]
+}
+
+__attribute__((target("thumb"))) void test_target_thumb() {
+ // CHECKPOS: define void @test_target_thumb() [[THUMB_ATTRS:#[0-9]+]]
+ // CHECKNEG: define void @test_target_thumb() [[THUMB_ATTRS:#[0-9]+]]
+}
+
+// CHECKPOS: attributes [[ARM_ATTRS]] = { {{.*}} "target-features"="{{.*}}-thumb-mode{{.*}}"
+// CHECKPOS: attributes [[THUMB_ATTRS]] = { {{.*}} "target-features"="{{.*}}+thumb-mode{{.*}}"
+// CHECKNEG-NOT: attributes [[ARM_ATTRS]] = { {{.*}} "target-features"="{{.*}}+thumb-mode{{.*}}"
+// CHECKNEG-NOT: attributes [[THUMB_ATTRS]] = { {{.*}} "target-features"="{{.*}}-thumb-mode{{.*}}"
Index: lib/Basic/Targets.cpp
===================================================================
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -5438,7 +5438,17 @@
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,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33721.101427.patch
Type: text/x-patch
Size: 2272 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170605/3fd98004/attachment-0001.bin>
More information about the cfe-commits
mailing list