[PATCH] D10977: Allow {e, r}bp as the target of {read, write}_register.

Pat Gavlin pagavlin at microsoft.com
Mon Jul 6 19:40:00 PDT 2015


pgavlin removed rL LLVM as the repository for this revision.

Address CR feedback.


http://reviews.llvm.org/D10977

Files:
  lib/Target/X86/X86ISelLowering.cpp
  test/CodeGen/X86/frameregister.ll

Index: test/CodeGen/X86/frameregister.ll
===================================================================
--- /dev/null
+++ test/CodeGen/X86/frameregister.ll
@@ -0,0 +1,30 @@
+; RUN: llc < %s -mtriple=x86_64-apple-darwin  | FileCheck %s
+; RUN: llc < %s -mtriple=x86_64-linux-gnueabi | FileCheck %s
+; RUN: opt < %s -O3 -S -mtriple=x86_64-linux-gnueabi | FileCheck %s --check-prefix=OPT
+
+define i64 @get_frame() #0 {
+entry:
+; CHECK-LABEL: get_frame:
+; CHECK: movq	%rbp, %rax
+  %sp = call i64 @llvm.read_register.i64(metadata !0)
+; OPT: @llvm.read_register.i64
+  ret i64 %sp
+}
+
+define void @set_frame(i64 %val) #0 {
+entry:
+; CHECK-LABEL: set_frame:
+; CHECK: movq	%rdi, %rbp
+  call void @llvm.write_register.i64(metadata !0, i64 %val)
+; OPT: @llvm.write_register.i64
+  ret void
+}
+
+declare i64 @llvm.read_register.i64(metadata) nounwind
+declare void @llvm.write_register.i64(metadata, i64) nounwind
+
+; register unsigned long current_stack_pointer asm("rbp");
+; CHECK-NOT: .asciz  "rbp"
+!0 = !{!"rbp\00"}
+
+attributes #0 = { nounwind "no-frame-pointer-elim"="true" }
Index: lib/Target/X86/X86ISelLowering.cpp
===================================================================
--- lib/Target/X86/X86ISelLowering.cpp
+++ lib/Target/X86/X86ISelLowering.cpp
@@ -16207,9 +16207,13 @@
   unsigned Reg = StringSwitch<unsigned>(RegName)
                        .Case("esp", X86::ESP)
                        .Case("rsp", X86::RSP)
+                       .Case("ebp", X86::EBP)
+                       .Case("rbp", X86::RBP)
                        .Default(0);
+
   if (Reg)
     return Reg;
+
   report_fatal_error("Invalid register name global variable");
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10977.29145.patch
Type: text/x-patch
Size: 1682 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150707/e9f13e0a/attachment.bin>


More information about the llvm-commits mailing list