Skip to content

Commit

Permalink
[RISCV] Specify registers used for exception handling
Browse files Browse the repository at this point in the history
Implements the handling of __builtin_eh_return_regno().

Differential Revision: https://reviews.llvm.org/D63417
Patch by Edward Jones.

llvm-svn: 365305
  • Loading branch information
asb committed Jul 8, 2019
1 parent d0e1d00 commit 77d4a8f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions clang/lib/Basic/Targets/RISCV.h
Expand Up @@ -57,6 +57,15 @@ class RISCVTargetInfo : public TargetInfo {

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

int getEHDataRegisterNumber(unsigned RegNo) const override {
if (RegNo == 0)
return 10;
else if (RegNo == 1)
return 11;
else
return -1;
}

ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override;

bool validateAsmConstraint(const char *&Name,
Expand Down
10 changes: 10 additions & 0 deletions clang/test/CodeGen/builtins-riscv.c
@@ -0,0 +1,10 @@
// RUN: %clang_cc1 -Wall -Werror -triple riscv32 -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
// RUN: %clang_cc1 -Wall -Werror -triple riscv64 -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s

void test_eh_return_data_regno() {
// CHECK: store volatile i32 10
// CHECK: store volatile i32 11
volatile int res;
res = __builtin_eh_return_data_regno(0);
res = __builtin_eh_return_data_regno(1);
}

0 comments on commit 77d4a8f

Please sign in to comment.