llvm-project/clang/test/CodeGen/mips-constraints-mem.c
Toma Tabacu 9941195a9f [mips] Always clobber $1 for MIPS inline asm.
Summary:
Because GCC doesn't use $1 for code generation, inline assembly code can use $1 without having to add it to the clobbers list.

LLVM, on the other hand, does not shy away from using $1, and this can cause conflicts with inline assembly which assumes GCC-like code generation.

A solution to this problem is to make Clang automatically clobber $1 for all MIPS inline assembly.
This is not the optimal solution, but it seems like a necessary compromise, for now.

Reviewers: dsanders

Reviewed By: dsanders

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D6638

llvm-svn: 224428
2014-12-17 12:02:58 +00:00

27 lines
674 B
C

// RUN: %clang -target mipsel-unknown-linux -S -o - -emit-llvm %s \
// RUN: | FileCheck %s
// This checks that the frontend will accept inline asm memory constraints.
int foo()
{
// 'R': An address that can be used in a non-macro load or stor'
// This test will result in the higher and lower nibbles being
// switched due to the lwl/lwr instruction pairs.
// CHECK: %{{[0-9]+}} = call i32 asm sideeffect "lwl $0, 1 + $1\0A\09lwr $0, 2 + $1\0A\09", "=r,*R,~{$1}"(i32* %{{[0-9,a-f]+}}) #1,
int c = 0xffbbccdd;
int *p = &c;
int out = 0;
__asm volatile (
"lwl %0, 1 + %1\n\t"
"lwr %0, 2 + %1\n\t"
: "=r"(out)
: "R"(*p)
);
return 0;
}