Skip to content

Commit

Permalink
[VE] Support STACKSAVE and STACKRESTORE
Browse files Browse the repository at this point in the history
Change to use default expanded code.  Add regression tests also.

Reviewed By: simoll

Differential Revision: https://reviews.llvm.org/D93539
  • Loading branch information
kaz7 committed Dec 21, 2020
1 parent d99e4a4 commit 5e273b8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions llvm/lib/Target/VE/VEISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ void VETargetLowering::initSPUActions() {
/// Stack {
setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i32, Custom);
setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i64, Custom);

// Use the default implementation.
setOperationAction(ISD::STACKSAVE, MVT::Other, Expand);
setOperationAction(ISD::STACKRESTORE, MVT::Other, Expand);
/// } Stack

/// Branch {
Expand Down
26 changes: 26 additions & 0 deletions llvm/test/CodeGen/VE/Scalar/stacksave.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
; RUN: llc < %s -mtriple=ve | FileCheck %s

; Function Attrs: noinline nounwind optnone
define i8* @stacksave() {
; CHECK-LABEL: stacksave:
; CHECK: .LBB{{[0-9]+}}_2:
; CHECK-NEXT: or %s0, 0, %s11
; CHECK-NEXT: or %s11, 0, %s9
%ret = call i8* @llvm.stacksave()
ret i8* %ret
}

; Function Attrs: noinline nounwind optnone
define void @stackrestore(i8* %ptr) {
; CHECK-LABEL: stackrestore:
; CHECK: .LBB{{[0-9]+}}_2:
; CHECK-NEXT: or %s11, 0, %s0
; CHECK-NEXT: or %s11, 0, %s9
call void @llvm.stackrestore(i8* %ptr)
ret void
}

; Function Attrs: nounwind
declare i8* @llvm.stacksave()
; Function Attrs: nounwind
declare void @llvm.stackrestore(i8*)

0 comments on commit 5e273b8

Please sign in to comment.