Implement __builtin_eh_return_data_regno for SPARC and SPARC64.
authorJoerg Sonnenberger <joerg@bec.de>
Mon, 7 Mar 2016 17:19:15 +0000 (17:19 +0000)
committerJoerg Sonnenberger <joerg@bec.de>
Mon, 7 Mar 2016 17:19:15 +0000 (17:19 +0000)
llvm-svn: 262838

clang/lib/Basic/Targets.cpp
clang/test/CodeGen/builtins-sparc.c [new file with mode: 0644]

index 05694cc..5d64aa8 100644 (file)
@@ -5952,6 +5952,12 @@ public:
   SparcTargetInfo(const llvm::Triple &Triple)
       : TargetInfo(Triple), SoftFloat(false) {}
 
+  int getEHDataRegisterNumber(unsigned RegNo) const override {
+    if (RegNo == 0) return 24;
+    if (RegNo == 1) return 25;
+    return -1;
+  }
+
   bool handleTargetFeatures(std::vector<std::string> &Features,
                             DiagnosticsEngine &Diags) override {
     // The backend doesn't actually handle soft float yet, but in case someone
diff --git a/clang/test/CodeGen/builtins-sparc.c b/clang/test/CodeGen/builtins-sparc.c
new file mode 100644 (file)
index 0000000..92cc767
--- /dev/null
@@ -0,0 +1,10 @@
+// REQUIRES: sparc-registered-target
+// RUN: %clang_cc1 -triple sparc-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple sparc64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+
+void test_eh_return_data_regno(void)
+{
+  volatile int res;
+  res = __builtin_eh_return_data_regno(0);  // CHECK: store volatile i32 24
+  res = __builtin_eh_return_data_regno(1);  // CHECK: store volatile i32 25
+}