summaryrefslogtreecommitdiff
path: root/test/CodeGen/arm-thumb-mode-target-feature.c
diff options
context:
space:
mode:
authorFlorian Hahn <florian.hahn@arm.com>2017-06-07 11:50:45 +0000
committerFlorian Hahn <florian.hahn@arm.com>2017-06-07 11:50:45 +0000
commit54a73f97584724c131f71d7a6f56c1a1dffdea2a (patch)
tree92040b59ebea2751fdd1c208951824600c918b84 /test/CodeGen/arm-thumb-mode-target-feature.c
parent1741b26b00397c62ce7fb95250b37268484ac140 (diff)
downloadclang-54a73f97584724c131f71d7a6f56c1a1dffdea2a.tar.gz
[CodeGen] Add thumb-mode to target-features for arm/thumb triples.
Summary: The thumb-mode target feature is used to force Thumb or ARM code generation on a per-function basis. Explicitly adding +thumb-mode to functions for thumbxx triples enables mixed ARM/Thumb code generation in places where compilation units with thumbxx and armxx triples are merged together (e.g. the IR linker or LTO). For armxx triples, -thumb-mode is added in a similar fashion. Reviewers: echristo, t.p.northover, kristof.beyls, rengolin Reviewed By: echristo Subscribers: rinon, aemerson, mehdi_amini, javed.absar, cfe-commits Differential Revision: https://reviews.llvm.org/D33448 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304897 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/arm-thumb-mode-target-feature.c')
-rw-r--r--test/CodeGen/arm-thumb-mode-target-feature.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/CodeGen/arm-thumb-mode-target-feature.c b/test/CodeGen/arm-thumb-mode-target-feature.c
new file mode 100644
index 0000000000..5c41d0b16f
--- /dev/null
+++ b/test/CodeGen/arm-thumb-mode-target-feature.c
@@ -0,0 +1,33 @@
+// REQUIRES: arm-registered-target
+
+// RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -emit-llvm -o - %s | FileCheck --check-prefix THUMB %s
+// RUN: %clang_cc1 -triple thumbv7eb-linux-gnueabihf -emit-llvm -o - %s | FileCheck --check-prefix THUMB %s
+// RUN: %clang -target armv7-linux-gnueabihf -mthumb -S -emit-llvm -o - %s | FileCheck --check-prefix THUMB-CLANG %s
+// RUN: %clang_cc1 -triple armv7-linux-gnueabihf -emit-llvm -o - %s | FileCheck --check-prefix ARM %s
+// RUN: %clang_cc1 -triple armv7eb-linux-gnueabihf -emit-llvm -o - %s | FileCheck --check-prefix ARM %s
+
+void t1() {}
+
+ __attribute__((target("no-thumb-mode")))
+void t2() {}
+
+ __attribute__((target("thumb-mode")))
+void t3() {}
+
+// THUMB: void @t1() [[ThumbAttr:#[0-7]]]
+// THUMB: void @t2() [[NoThumbAttr:#[0-7]]]
+// THUMB: void @t3() [[ThumbAttr:#[0-7]]]
+// THUMB: attributes [[ThumbAttr]] = { {{.*}} "target-features"="+thumb-mode"
+// THUMB: attributes [[NoThumbAttr]] = { {{.*}} "target-features"="-thumb-mode"
+//
+// THUMB-CLANG: void @t1() [[ThumbAttr:#[0-7]]]
+// THUMB-CLANG: void @t2() [[NoThumbAttr:#[0-7]]]
+// THUMB-CLANG: void @t3() [[ThumbAttr:#[0-7]]]
+// THUMB-CLANG: attributes [[ThumbAttr]] = { {{.*}} "target-features"="{{.*}}+thumb-mode
+// THUMB-CLANG: attributes [[NoThumbAttr]] = { {{.*}} "target-features"="{{.*}}-thumb-mode
+
+// ARM: void @t1() [[NoThumbAtr:#[0-7]]]
+// ARM: void @t2() [[NoThumbAttr:#[0-7]]]
+// ARM: void @t3() [[ThumbAttr:#[0-7]]]
+// ARM: attributes [[NoThumbAttr]] = { {{.*}} "target-features"="-thumb-mode"
+// ARM: attributes [[ThumbAttr]] = { {{.*}} "target-features"="+thumb-mode"