Eric Christopher | 3883e66 | 2011-07-26 22:17:02 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -triple x86_64-apple-darwin -emit-llvm -o - | FileCheck %s |
| 2 | // Exercise various use cases for local asm "register variables". |
| 3 | |
| 4 | int foo() { |
Eric Christopher | d579a88 | 2011-07-26 22:52:35 +0000 | [diff] [blame^] | 5 | // CHECK: [[A:%[a-zA-Z0-9]+]] = alloca i32 |
Eric Christopher | 3883e66 | 2011-07-26 22:17:02 +0000 | [diff] [blame] | 6 | |
| 7 | register int a asm("rsi")=5; |
Eric Christopher | d579a88 | 2011-07-26 22:52:35 +0000 | [diff] [blame^] | 8 | // CHECK: store i32 5, i32* [[A]] |
Eric Christopher | 3883e66 | 2011-07-26 22:17:02 +0000 | [diff] [blame] | 9 | |
| 10 | asm volatile("; %0 This asm defines rsi" : "=r"(a)); |
Eric Christopher | d579a88 | 2011-07-26 22:52:35 +0000 | [diff] [blame^] | 11 | // CHECK: [[Z:%[a-zA-Z0-9]+]] = call i32 asm sideeffect "; $0 This asm defines rsi", "={rsi},~{dirflag},~{fpsr},~{flags}"() |
| 12 | // CHECK: store i32 [[Z]], i32* [[A]] |
Eric Christopher | 3883e66 | 2011-07-26 22:17:02 +0000 | [diff] [blame] | 13 | |
| 14 | a = 42; |
Eric Christopher | d579a88 | 2011-07-26 22:52:35 +0000 | [diff] [blame^] | 15 | // CHECK: store i32 42, i32* [[A]] |
Eric Christopher | 3883e66 | 2011-07-26 22:17:02 +0000 | [diff] [blame] | 16 | |
| 17 | asm volatile("; %0 This asm uses rsi" : : "r"(a)); |
Eric Christopher | d579a88 | 2011-07-26 22:52:35 +0000 | [diff] [blame^] | 18 | // CHECK: [[TMP:%[a-zA-Z0-9]+]] = load i32* [[A]] |
| 19 | // CHECK: call void asm sideeffect "; $0 This asm uses rsi", "{rsi},~{dirflag},~{fpsr},~{flags}"(i32 [[TMP]]) |
Eric Christopher | 3883e66 | 2011-07-26 22:17:02 +0000 | [diff] [blame] | 20 | |
| 21 | return a; |
Eric Christopher | d579a88 | 2011-07-26 22:52:35 +0000 | [diff] [blame^] | 22 | // CHECK: [[TMP1:%[a-zA-Z0-9]+]] = load i32* [[A]] |
| 23 | // CHECK: ret i32 [[TMP1]] |
Eric Christopher | 3883e66 | 2011-07-26 22:17:02 +0000 | [diff] [blame] | 24 | } |