diff options
author | Tim Northover <Tim.Northover@arm.com> | 2013-01-31 12:13:10 +0000 |
---|---|---|
committer | Tim Northover <Tim.Northover@arm.com> | 2013-01-31 12:13:10 +0000 |
commit | 9bb857a4f1aec1c33d599672defb46b98d792719 (patch) | |
tree | ec0be5d95a2c1cabd91de9536dba0c135f4c019a /clang/test/CodeGen/aarch64-inline-asm.c | |
parent | e0e3aefdd3affa427693ce6434599af38fcb7a13 (diff) | |
download | bcm5719-llvm-9bb857a4f1aec1c33d599672defb46b98d792719.tar.gz bcm5719-llvm-9bb857a4f1aec1c33d599672defb46b98d792719.zip |
Add support for AArch64 target.
In cooperation with the LLVM patch, this should implement all scalar front-end
parts of the C and C++ ABIs for AArch64.
This patch excludes the NEON support also reviewed due to an outbreak of
batshit insanity in our legal department. That will be committed soon bringing
the changes to precisely what has been approved.
Further reviews would be gratefully received.
llvm-svn: 174055
Diffstat (limited to 'clang/test/CodeGen/aarch64-inline-asm.c')
-rw-r--r-- | clang/test/CodeGen/aarch64-inline-asm.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/clang/test/CodeGen/aarch64-inline-asm.c b/clang/test/CodeGen/aarch64-inline-asm.c new file mode 100644 index 00000000000..ca39c6e7ff2 --- /dev/null +++ b/clang/test/CodeGen/aarch64-inline-asm.c @@ -0,0 +1,56 @@ +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -emit-llvm -o - %s | FileCheck %s + +// The only part clang really deals with is the lvalue/rvalue +// distinction on constraints. It's sufficient to emit llvm and make +// sure that's sane. + +long var; + +void test_generic_constraints(int var32, long var64) { + asm("add %0, %1, %1" : "=r"(var32) : "0"(var32)); +// CHECK: [[R32_ARG:%[a-zA-Z0-9]+]] = load i32* +// CHECK: call i32 asm "add $0, $1, $1", "=r,0"(i32 [[R32_ARG]]) + + asm("add %0, %1, %1" : "=r"(var64) : "0"(var64)); +// CHECK: [[R32_ARG:%[a-zA-Z0-9]+]] = load i64* +// CHECK: call i64 asm "add $0, $1, $1", "=r,0"(i64 [[R32_ARG]]) + + asm("ldr %0, %1" : "=r"(var32) : "m"(var)); + asm("ldr %0, [%1]" : "=r"(var64) : "r"(&var)); +// CHECK: call i32 asm "ldr $0, $1", "=r,*m"(i64* @var) +// CHECK: call i64 asm "ldr $0, [$1]", "=r,r"(i64* @var) +} + +float f; +double d; +void test_constraint_w() { + asm("fadd %s0, %s1, %s1" : "=w"(f) : "w"(f)); +// CHECK: [[FLT_ARG:%[a-zA-Z_0-9]+]] = load float* @f +// CHECK: call float asm "fadd ${0:s}, ${1:s}, ${1:s}", "=w,w"(float [[FLT_ARG]]) + + asm("fadd %d0, %d1, %d1" : "=w"(d) : "w"(d)); +// CHECK: [[DBL_ARG:%[a-zA-Z_0-9]+]] = load double* @d +// CHECK: call double asm "fadd ${0:d}, ${1:d}, ${1:d}", "=w,w"(double [[DBL_ARG]]) +} + +void test_constraints_immed(void) { + asm("add x0, x0, %0" : : "I"(4095) : "x0"); + asm("and w0, w0, %0" : : "K"(0xaaaaaaaa) : "w0"); + asm("and x0, x0, %0" : : "L"(0xaaaaaaaaaaaaaaaa) : "x0"); +// CHECK: call void asm sideeffect "add x0, x0, $0", "I,~{x0}"(i32 4095) +// CHECK: call void asm sideeffect "and w0, w0, $0", "K,~{w0}"(i32 -1431655766) +// CHECK: call void asm sideeffect "and x0, x0, $0", "L,~{x0}"(i64 -6148914691236517206) +} + +void test_constraint_S(void) { + int *addr; + asm("adrp %0, %A1\n\t" + "add %0, %0, %L1" : "=r"(addr) : "S"(&var)); +// CHECK: call i32* asm "adrp $0, ${1:A}\0A\09add $0, $0, ${1:L}", "=r,S"(i64* @var) +} + +void test_constraint_Q(void) { + int val; + asm("ldxr %0, %1" : "=r"(val) : "Q"(var)); +// CHECK: call i32 asm "ldxr $0, $1", "=r,*Q"(i64* @var) +} |