[PATCH] D29553: [AVR] Implement stacksave/stackrestore by expanding (PR31342)

Florian Zeitz via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 5 06:37:23 PST 2017


Florob updated this revision to Diff 87141.
Florob added a comment.

I've added a basic CodeGen test. Since this is effectively expanded to a register read/write I'm not entirely sure doing this specifically for stacksave/stackrestore is ideal though.


https://reviews.llvm.org/D29553

Files:
  lib/Target/AVR/AVRISelLowering.cpp
  test/CodeGen/AVR/intrinsics/stacksave-restore.ll


Index: test/CodeGen/AVR/intrinsics/stacksave-restore.ll
===================================================================
--- /dev/null
+++ test/CodeGen/AVR/intrinsics/stacksave-restore.ll
@@ -0,0 +1,27 @@
+; RUN: llc -O0 < %s -march=avr | FileCheck %s
+
+; CHECK-LABEL: foo
+define void @foo() {
+entry:
+  br label %save
+
+; CHECK-LABEL: save
+; CHECK: in [[SREG1:r[0-9]+]], 61
+; CHECK-NEXT: in [[SREG2:r[0-9]+]], 62
+save:
+  %saved = call i8* @llvm.stacksave()
+  br label %restore
+
+; CHECK-LABEL: restore
+; CHECK: in r0, 63
+; CHECK-NEXT: cli
+; CHECK-NEXT: out 62, [[SREG2]]
+; CHECK-NEXT: out 63, r0
+; CHECK-NEXT: out 61, [[SREG1]]
+restore:
+  call void @llvm.stackrestore(i8* %saved)
+  ret void
+}
+
+declare i8* @llvm.stacksave()
+declare void @llvm.stackrestore(i8* %ptr)
Index: lib/Target/AVR/AVRISelLowering.cpp
===================================================================
--- lib/Target/AVR/AVRISelLowering.cpp
+++ lib/Target/AVR/AVRISelLowering.cpp
@@ -48,6 +48,8 @@
   setOperationAction(ISD::GlobalAddress, MVT::i16, Custom);
   setOperationAction(ISD::BlockAddress, MVT::i16, Custom);
 
+  setOperationAction(ISD::STACKSAVE, MVT::Other, Expand);
+  setOperationAction(ISD::STACKRESTORE, MVT::Other, Expand);
   setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i8, Expand);
   setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i16, Expand);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29553.87141.patch
Type: text/x-patch
Size: 1375 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170205/9aae588d/attachment.bin>


More information about the llvm-commits mailing list