From d0be8dcbf847710c71bcbbc0188c72f1c6a5cfcb Mon Sep 17 00:00:00 2001 From: Joerg Sonnenberger Date: Mon, 7 Mar 2016 17:19:15 +0000 Subject: [PATCH] Implement __builtin_eh_return_data_regno for SPARC and SPARC64. llvm-svn: 262838 --- clang/lib/Basic/Targets.cpp | 6 ++++++ clang/test/CodeGen/builtins-sparc.c | 10 ++++++++++ 2 files changed, 16 insertions(+) create mode 100644 clang/test/CodeGen/builtins-sparc.c diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index 05694cc..5d64aa8 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -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 &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 index 0000000..92cc767 --- /dev/null +++ b/clang/test/CodeGen/builtins-sparc.c @@ -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 +} -- 2.7.4