diff options
| author | Renato Golin <renato.golin@linaro.org> | 2014-05-06 16:51:25 +0000 |
|---|---|---|
| committer | Renato Golin <renato.golin@linaro.org> | 2014-05-06 16:51:25 +0000 |
| commit | c7aea40ec67592a6be8314c509a9eae807daed5f (patch) | |
| tree | f67c4be5aeb15e4b55d183401d904adb6fb84b16 /llvm/test/CodeGen/X86/stackpointer.ll | |
| parent | 52dc5d828fd75c7ec3ae82c5d5737e34a2a1b938 (diff) | |
| download | bcm5719-llvm-c7aea40ec67592a6be8314c509a9eae807daed5f.tar.gz bcm5719-llvm-c7aea40ec67592a6be8314c509a9eae807daed5f.zip | |
Implememting named register intrinsics
This patch implements the infrastructure to use named register constructs in
programs that need access to specific registers (bare metal, kernels, etc).
So far, only the stack pointer is supported as a technology preview, but as it
is, the intrinsic can already support all non-allocatable registers from any
architecture.
llvm-svn: 208104
Diffstat (limited to 'llvm/test/CodeGen/X86/stackpointer.ll')
| -rw-r--r-- | llvm/test/CodeGen/X86/stackpointer.ll | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/X86/stackpointer.ll b/llvm/test/CodeGen/X86/stackpointer.ll new file mode 100644 index 00000000000..26f9999fd5d --- /dev/null +++ b/llvm/test/CodeGen/X86/stackpointer.ll @@ -0,0 +1,25 @@ +; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck %s +; RUN: llc < %s -mtriple=x86_64-linux-gnueabi | FileCheck %s + +define i64 @get_stack() nounwind { +entry: +; CHECK-LABEL: get_stack: +; CHECK: movq %rsp, %rax + %sp = call i64 @llvm.read_register.i64(metadata !0) + ret i64 %sp +} + +define void @set_stack(i64 %val) nounwind { +entry: +; CHECK-LABEL: set_stack: +; CHECK: movq %rdi, %rsp + call void @llvm.write_register.i64(metadata !0, i64 %val) + 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("rsp"); +; CHECK-NOT: .asciz "rsp" +!0 = metadata !{metadata !"rsp\00"} |

