Subject: [bug#64188] [PATCH 7/8] guix: cpu: Add gcc-architecture->generic-architecture mapping.

From: Efraim Flashner <[email-masked]>
Date: Tue, 20 Jun 2023 10:51:08 +0300

* guix/cpu.scm (gcc-architecture->generic-architecture): New variable.
---
 guix/cpu.scm | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/guix/cpu.scm b/guix/cpu.scm
index ddfa4f20bb..af26e2280b 100644
--- a/guix/cpu.scm
+++ b/guix/cpu.scm
@@ -33,7 +33,8 @@ (define-module (guix cpu)
             cpu-flags
 
             cpu->gcc-architecture
-            cpu->generic-architecture))
+            cpu->generic-architecture
+            gcc-architecture->generic-architecture))
 
 ;;; Commentary:
 ;;;
@@ -284,3 +285,21 @@ (define (cpu->generic-architecture cpu)
     (architecture
      ;; TODO: More architectures
      architecture)))
+
+(define (gcc-architecture->generic-architecture gcc-architecture)
+  "Return a generalized micro-architecture, using an inexact matching to provide
+'good enough' optimizations."
+  (match gcc-architecture
+    ((or "grandridge" "graniterapids" "sierraforest" "tigerlake"
+         "sapphirerapids" "cooperlake" "icelake-server" "icelake-client"
+         "cannonlake" "knm" "knl" "skylake-avx512" "alderlake" "skylake"
+         "broadwell" "haswell"
+         "znver4" "znver3" "znver2" "znver1" "bdver4")
+     "x86_64-v3")
+    ((or "sandybridge" "tremont" "goldmont-plus" "goldmont" "silvermont"
+         "nehalem" "bonnell" "core2"
+         "btver2" "athalon" "k8-sse3" "k8" "bdver3" "bdver2" "bdver1" "btver1"
+         "amdfam10"
+         "lujiazui" "x86-64")
+     "x86_64-v1")
+    (_ gcc-architecture)))
-- 
Efraim Flashner   <[email-masked]>   רנשלפ םירפא
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted