[og12] Come up with {,UN}LIKELY macros (was: [Patch][2/3][v2] nvptx: libgomp+mkoffload.cc: Prepare for reverse offload fn lookup)

Message ID 878rmaqetf.fsf@euler.schwinge.homeip.net
State New, archived
Headers
Series [og12] Come up with {,UN}LIKELY macros (was: [Patch][2/3][v2] nvptx: libgomp+mkoffload.cc: Prepare for reverse offload fn lookup) |

Commit Message

Thomas Schwinge Sept. 23, 2022, 3:40 p.m. UTC
  Hi!

Since the 2022-09-12 backport of this:

On 2022-08-29T20:43:26+0200, Tobias Burnus <tobias@codesourcery.com> wrote:
> nvptx: libgomp+mkoffload.cc: Prepare for reverse offload fn lookup

... to og12 in commit 2b6ad53fd76c7bb9605be417d137a7d9a18f2117, the og12
branch didn't build anymore:

    [...]/gcc/config/nvptx/mkoffload.cc: In function 'void process(FILE*, FILE*, uint32_t)':
    [...]/gcc/config/nvptx/mkoffload.cc:284:59: error: 'UNLIKELY' was not declared in this scope
            if (UNLIKELY (startswith (input + i, ".target sm_")))
                                                               ^
    [...]/gcc/config/nvptx/mkoffload.cc:289:57: error: 'UNLIKELY' was not declared in this scope
            if (UNLIKELY (startswith (input + i, ".version ")))
                                                             ^
    make[2]: *** [[...]/gcc/config/nvptx/t-nvptx:8: mkoffload.o] Error 1

> --- a/gcc/config/nvptx/mkoffload.cc
> +++ b/gcc/config/nvptx/mkoffload.cc

> @@ -261,6 +281,16 @@ process (FILE *in, FILE *out, uint32_t omp_requires)
>           case '\n':
>             fprintf (out, "\\n\"\n\t\"");
>             /* Look for mappings on subsequent lines.  */
> +           if (UNLIKELY (startswith (input + i, ".target sm_")))
> +             {
> +               sm_ver = input + i + strlen (".target sm_");
> +               continue;
> +             }
> +           if (UNLIKELY (startswith (input + i, ".version ")))
> +             {
> +               version = input + i + strlen (".version ");
> +               continue;
> +             }

To fix this, I've pushed a (very much reduced) partial cherry-pick of
commit r13-171-g22d9c8802add09a93308319fc37dd3a0f1125393
"Come up with {,UN}LIKELY macros" to og12 branch in
commit 44b77201a5431450f608b4538fefb1319127de13, see attached.


Grüße
 Thomas


-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
  

Patch

From 44b77201a5431450f608b4538fefb1319127de13 Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Thu, 3 Feb 2022 10:58:18 +0100
Subject: [PATCH] Come up with {,UN}LIKELY macros.

gcc/ChangeLog:

	* system.h (LIKELY): Define.
	(UNLIKELY): Likewise.

(cherry picked from commit 22d9c8802add09a93308319fc37dd3a0f1125393, partial)
---
 gcc/ChangeLog.omp | 8 ++++++++
 gcc/system.h      | 3 +++
 2 files changed, 11 insertions(+)

diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index 4f80bcbd356..30c3abfc15b 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,3 +1,11 @@ 
+2022-09-23  Thomas Schwinge  <thomas@codesourcery.com>
+
+	Backport from master branch:
+	2022-05-09  Martin Liska  <mliska@suse.cz>
+
+	* system.h (LIKELY): Define.
+	(UNLIKELY): Likewise.
+
 2022-09-12  Tobias Burnus  <tobias@codesourcery.com>
 
 	Backport from mainline:
diff --git a/gcc/system.h b/gcc/system.h
index e10c34f70ec..6b6868d0bbf 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -736,6 +736,9 @@  extern int vsnprintf (char *, size_t, const char *, va_list);
 #define __builtin_expect(a, b) (a)
 #endif
 
+#define LIKELY(x) (__builtin_expect ((x), 1))
+#define UNLIKELY(x) (__builtin_expect ((x), 0))
+
 /* Some of the headers included by <memory> can use "abort" within a
    namespace, e.g. "_VSTD::abort();", which fails after we use the
    preprocessor to redefine "abort" as "fancy_abort" below.  */
-- 
2.35.1