Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1307)

Issue 5127047: [pph] Add inline assembly test case (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 7 months ago by Diego Novillo
Modified:
12 years, 6 months ago
Reviewers:
CC:
Lawrence Crowl, gcc-patches_gcc.gnu.org
Visibility:
Public.

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+80 lines, -0 lines) Patch
A gcc/testsuite/g++.dg/pph/x0asm1.h View 1 chunk +69 lines, -0 lines 0 comments Download
A gcc/testsuite/g++.dg/pph/x1asm1.cc View 1 chunk +11 lines, -0 lines 0 comments Download

Messages

Total messages: 1
Diego Novillo
12 years, 7 months ago (2011-09-28 00:02:28 UTC) #1
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
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b