Skip to content

Commit 77d4a8f

Browse files
committed
[RISCV] Specify registers used for exception handling
Implements the handling of __builtin_eh_return_regno(). Differential Revision: https://reviews.llvm.org/D63417 Patch by Edward Jones. llvm-svn: 365305
1 parent d0e1d00 commit 77d4a8f

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

clang/lib/Basic/Targets/RISCV.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ class RISCVTargetInfo : public TargetInfo {
5757

5858
ArrayRef<const char *> getGCCRegNames() const override;
5959

60+
int getEHDataRegisterNumber(unsigned RegNo) const override {
61+
if (RegNo == 0)
62+
return 10;
63+
else if (RegNo == 1)
64+
return 11;
65+
else
66+
return -1;
67+
}
68+
6069
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override;
6170

6271
bool validateAsmConstraint(const char *&Name,

clang/test/CodeGen/builtins-riscv.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: %clang_cc1 -Wall -Werror -triple riscv32 -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
2+
// RUN: %clang_cc1 -Wall -Werror -triple riscv64 -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
3+
4+
void test_eh_return_data_regno() {
5+
// CHECK: store volatile i32 10
6+
// CHECK: store volatile i32 11
7+
volatile int res;
8+
res = __builtin_eh_return_data_regno(0);
9+
res = __builtin_eh_return_data_regno(1);
10+
}

0 commit comments

Comments
 (0)