1; RUN: llc < %s -mtriple=x86_64-apple-darwin  | FileCheck %s
2; RUN: llc < %s -mtriple=x86_64-linux-gnueabi | FileCheck %s
3; RUN: opt < %s -O3 -S -mtriple=x86_64-linux-gnueabi | FileCheck %s --check-prefix=OPT
4
5define i64 @get_stack() nounwind {
6entry:
7; CHECK-LABEL: get_stack:
8; CHECK: movq	%rsp, %rax
9	%sp = call i64 @llvm.read_register.i64(metadata !0)
10; OPT: @llvm.read_register.i64
11  ret i64 %sp
12}
13
14define void @set_stack(i64 %val) nounwind {
15entry:
16; CHECK-LABEL: set_stack:
17; CHECK: movq	%rdi, %rsp
18  call void @llvm.write_register.i64(metadata !0, i64 %val)
19; OPT: @llvm.write_register.i64
20  ret void
21}
22
23declare i64 @llvm.read_register.i64(metadata) nounwind
24declare void @llvm.write_register.i64(metadata, i64) nounwind
25
26; register unsigned long current_stack_pointer asm("rsp");
27; CHECK-NOT: .asciz  "rsp"
28!0 = !{!"rsp\00"}
29