This new test works already, but we had no coverage for inline assembly. Committed to branch. * g++.dg/pph/x0asm1.h: New. * g++.dg/pph/x1asm1.cc: New. diff --git a/gcc/testsuite/g++.dg/pph/x0asm1.h b/gcc/testsuite/g++.dg/pph/x0asm1.h new file mode 100644 index 0000000..82e191f --- /dev/null +++ b/gcc/testsuite/g++.dg/pph/x0asm1.h @@ -0,0 +1,69 @@ +#ifndef __X0ASM1_H +#define __X0ASM1_H + +struct arg1 { + int value; + static const int info = 99; +}; + +struct arg2 { + int value; + static const int info = 11; +}; + +template<int j> +int foo (void) +{ + int i; + asm ("# foo on %[third] %[second] %[fourth] %[first]" + : [first] "=r" (i) + : [second] "i" (j), + [third] "i" (j + 2), + [fourth] "i" (100)); + return i; +} + +template<class TYPE> +TYPE bar (TYPE t) +{ + asm ("# bar on %[first] %[second] %[third]" + : [first] "=r" (t.value) + : [second] "i[first]" (t.value), + [third] "i" (t.info)); + return t; +} + +template<class TYPE> +struct S { + static void frob (TYPE t) + { + asm ("# frob on %[arg]" :: [arg] "i" (t.info)); + } +}; + +void test () +{ + arg1 x; + arg2 y; + + foo<42> (); + bar (x); + bar (y); + S<arg1>::frob (x); +} + +template <class T> class I { +public: + void f() { asm ("# mov %edi, %esi" ); } +}; + +inline int cas(volatile int* ptr, int old_value, int new_value) +{ + int prev; + __asm__ __volatile__("lock; cmpxchgl %1,%2" + : "=a" (prev) + : "q" (new_value), "m" (*ptr), "0" (old_value) + : "memory"); + return prev; +} +#endif diff --git a/gcc/testsuite/g++.dg/pph/x1asm1.cc b/gcc/testsuite/g++.dg/pph/x1asm1.cc new file mode 100644 index 0000000..0ed65cb --- /dev/null +++ b/gcc/testsuite/g++.dg/pph/x1asm1.cc @@ -0,0 +1,11 @@ +// { dg-do compile { target x86*-*-* } } +#include "x0asm1.h" + +int X; + +int foo () { + I<int> x; + x.f(); + if (cas(&X, 0, 1)) + return 0; +} -- This patch is available for review at http://codereview.appspot.com/5127047