[llvm] r357538 - [GlobalISel] Add IRTranslator support for llvm.stacksave and llvm.stackrestore
Jessica Paquette via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 2 15:46:31 PDT 2019
Author: paquette
Date: Tue Apr 2 15:46:31 2019
New Revision: 357538
URL: http://llvm.org/viewvc/llvm-project?rev=357538&view=rev
Log:
[GlobalISel] Add IRTranslator support for llvm.stacksave and llvm.stackrestore
Also update arm64-irtranslator.ll.
Differential Revision: https://reviews.llvm.org/D60140
Modified:
llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp
llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll
Modified: llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp?rev=357538&r1=357537&r2=357538&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp Tue Apr 2 15:46:31 2019
@@ -1046,6 +1046,34 @@ bool IRTranslator::translateKnownIntrins
PtrTy.getSizeInBits() / 8, 8));
return true;
}
+ case Intrinsic::stacksave: {
+ // Save the stack pointer to the location provided by the intrinsic.
+ unsigned Reg = getOrCreateVReg(CI);
+ unsigned StackPtr = MF->getSubtarget()
+ .getTargetLowering()
+ ->getStackPointerRegisterToSaveRestore();
+
+ // If the target doesn't specify a stack pointer, then fall back.
+ if (!StackPtr)
+ return false;
+
+ MIRBuilder.buildCopy(Reg, StackPtr);
+ return true;
+ }
+ case Intrinsic::stackrestore: {
+ // Restore the stack pointer from the location provided by the intrinsic.
+ unsigned Reg = getOrCreateVReg(*CI.getArgOperand(0));
+ unsigned StackPtr = MF->getSubtarget()
+ .getTargetLowering()
+ ->getStackPointerRegisterToSaveRestore();
+
+ // If the target doesn't specify a stack pointer, then fall back.
+ if (!StackPtr)
+ return false;
+
+ MIRBuilder.buildCopy(StackPtr, Reg);
+ return true;
+ }
case Intrinsic::cttz:
case Intrinsic::ctlz: {
ConstantInt *Cst = cast<ConstantInt>(CI.getArgOperand(1));
Modified: llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll?rev=357538&r1=357537&r2=357538&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll (original)
+++ llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll Tue Apr 2 15:46:31 2019
@@ -2359,3 +2359,15 @@ define void @test_i1_arg_zext(void (i1)*
call void %f(i1 true)
ret void
}
+
+declare i8* @llvm.stacksave()
+declare void @llvm.stackrestore(i8*)
+define void @test_stacksaverestore() {
+ ; CHECK-LABEL: name: test_stacksaverestore
+ ; CHECK: [[SAVE:%[0-9]+]]:_(p0) = COPY $sp
+ ; CHECK-NEXT: $sp = COPY [[SAVE]](p0)
+ ; CHECK-NEXT: RET_ReallyLR
+ %sp = call i8* @llvm.stacksave()
+ call void @llvm.stackrestore(i8* %sp)
+ ret void
+}
More information about the llvm-commits
mailing list