2011-07-27 06:17:02 +08:00
|
|
|
// RUN: %clang_cc1 %s -triple x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
|
|
|
|
// Exercise various use cases for local asm "register variables".
|
|
|
|
|
|
|
|
int foo() {
|
2015-02-04 22:25:47 +08:00
|
|
|
// CHECK-LABEL: define i32 @foo()
|
2011-07-27 06:52:35 +08:00
|
|
|
// CHECK: [[A:%[a-zA-Z0-9]+]] = alloca i32
|
2011-07-27 06:17:02 +08:00
|
|
|
|
|
|
|
register int a asm("rsi")=5;
|
2011-07-27 06:52:35 +08:00
|
|
|
// CHECK: store i32 5, i32* [[A]]
|
2011-07-27 06:17:02 +08:00
|
|
|
|
|
|
|
asm volatile("; %0 This asm defines rsi" : "=r"(a));
|
2011-07-27 06:52:35 +08:00
|
|
|
// CHECK: [[Z:%[a-zA-Z0-9]+]] = call i32 asm sideeffect "; $0 This asm defines rsi", "={rsi},~{dirflag},~{fpsr},~{flags}"()
|
|
|
|
// CHECK: store i32 [[Z]], i32* [[A]]
|
2011-07-27 06:17:02 +08:00
|
|
|
|
|
|
|
a = 42;
|
2011-07-27 06:52:35 +08:00
|
|
|
// CHECK: store i32 42, i32* [[A]]
|
2011-07-27 06:17:02 +08:00
|
|
|
|
|
|
|
asm volatile("; %0 This asm uses rsi" : : "r"(a));
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK: [[TMP:%[a-zA-Z0-9]+]] = load i32, i32* [[A]]
|
2011-07-27 06:52:35 +08:00
|
|
|
// CHECK: call void asm sideeffect "; $0 This asm uses rsi", "{rsi},~{dirflag},~{fpsr},~{flags}"(i32 [[TMP]])
|
2011-07-27 06:17:02 +08:00
|
|
|
|
|
|
|
return a;
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK: [[TMP1:%[a-zA-Z0-9]+]] = load i32, i32* [[A]]
|
2011-07-27 06:52:35 +08:00
|
|
|
// CHECK: ret i32 [[TMP1]]
|
2011-07-27 06:17:02 +08:00
|
|
|
}
|
2015-02-04 22:25:47 +08:00
|
|
|
|
|
|
|
int earlyclobber() {
|
|
|
|
// CHECK-LABEL: define i32 @earlyclobber()
|
|
|
|
// CHECK: [[A:%[a-zA-Z0-9]+]] = alloca i32
|
|
|
|
|
|
|
|
register int a asm("rsi")=5;
|
|
|
|
// CHECK: store i32 5, i32* [[A]]
|
|
|
|
|
|
|
|
asm volatile("; %0 This asm defines rsi" : "=&r"(a));
|
|
|
|
// CHECK: [[Z:%[a-zA-Z0-9]+]] = call i32 asm sideeffect "; $0 This asm defines rsi", "=&{rsi},~{dirflag},~{fpsr},~{flags}"()
|
|
|
|
// CHECK: store i32 [[Z]], i32* [[A]]
|
|
|
|
|
|
|
|
a = 42;
|
|
|
|
// CHECK: store i32 42, i32* [[A]]
|
|
|
|
|
|
|
|
asm volatile("; %0 This asm uses rsi" : : "r"(a));
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK: [[TMP:%[a-zA-Z0-9]+]] = load i32, i32* [[A]]
|
2015-02-04 22:25:47 +08:00
|
|
|
// CHECK: call void asm sideeffect "; $0 This asm uses rsi", "{rsi},~{dirflag},~{fpsr},~{flags}"(i32 [[TMP]])
|
|
|
|
|
|
|
|
return a;
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK: [[TMP1:%[a-zA-Z0-9]+]] = load i32, i32* [[A]]
|
2015-02-04 22:25:47 +08:00
|
|
|
// CHECK: ret i32 [[TMP1]]
|
|
|
|
}
|