From patchwork Tue Jun 20 07:51:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Efraim Flashner X-Patchwork-Id: 51100 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 155FA27BBE9; Tue, 20 Jun 2023 08:52:52 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 8689427BBE2 for ; Tue, 20 Jun 2023 08:52:51 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qBW9n-0003my-Cr; Tue, 20 Jun 2023 03:52:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qBW9m-0003mJ-9E for guix-patches@gnu.org; Tue, 20 Jun 2023 03:52:06 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qBW9l-0006Nl-G3; Tue, 20 Jun 2023 03:52:05 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qBW9j-00056H-5C; Tue, 20 Jun 2023 03:52:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#64188] [PATCH 4/8] guix: cpu: Refactor cpu->gcc-architecture. Resent-From: Efraim Flashner Original-Sender: "Debbugs-submit" Resent-CC: mail@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Tue, 20 Jun 2023 07:52:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64188 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 64188@debbugs.gnu.org Cc: Efraim Flashner , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 64188-submit@debbugs.gnu.org id=B64188.168724748019475 (code B ref 64188); Tue, 20 Jun 2023 07:52:03 +0000 Received: (at 64188) by debbugs.gnu.org; 20 Jun 2023 07:51:20 +0000 Received: from localhost ([127.0.0.1]:57955 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qBW91-000542-Qm for submit@debbugs.gnu.org; Tue, 20 Jun 2023 03:51:20 -0400 Received: from mail-wr1-f48.google.com ([209.85.221.48]:44089) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qBW8z-00053H-Pe for 64188@debbugs.gnu.org; Tue, 20 Jun 2023 03:51:18 -0400 Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-311183ef595so4158801f8f.0 for <64188@debbugs.gnu.org>; Tue, 20 Jun 2023 00:51:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687247472; x=1689839472; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=e3Ue99nDYZ4Z89xMaS87vUllvGH8q1VmDDTQRWV3pDE=; b=ClZZ7Wgy5Puo20ozW1C+KuM+B6sEwEODsJnWkGpQ/QOaOG2bGuaz6G2yCu9J8dbJgU TaFFqRruD3YnxkLrxNQf92BbLAbx+Vy0P7O1/LBKBy8Kqeqy36NDbdt3au4KvkxdKhli K4EOJqEHx88rAl6MUGtUYKLSAKPiq23zV2AJPG9joViGDClOoMsZgAfKYwgFlLxWQ5Zh 30vb2kpNUxVKEyQ4qWIJUjgKs+dR+hdsQcSB7tUl6chjGQ5TOGrnRvhzKHR9k1jIjdU/ bTy70KvZc9SKuBm3daXxr5mQ3GLydYM+Il7vE/SlKOiNdDrKr2rKphMYZdrJ8BdIUsHj Nvkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687247472; x=1689839472; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=e3Ue99nDYZ4Z89xMaS87vUllvGH8q1VmDDTQRWV3pDE=; b=eluAw55wkdIA0W8matjEZgWN3qZItySi3cZ+MAwAoZIu/oO4ipNxRT0U59+9jhWXZJ e29XIeCe5Mgcq5RB/6f8N+FdgNNoKeUdCKhFRMGGbam/SdxuiCNxdBlwROL4UXbG7RQN fu4OMu7r2TpoSBp7NweLDEUWVMkVEjgU8lfDyxdm33QuqPUm7wNnal7Ydw9N27QtnxRY 8lN4hAm6pCbpkKj9RTfDwEqSFXGzAPLUzRYTGchItGvkEq6gFJFO6mxjBKCHSFYTeyWs 3icGteHuETLrdaHH3mT4ZJUEjgUJP8Tvd8U8qAV5i7meCrfnc4Qlp+vHBP570SZhbt4W /Peg== X-Gm-Message-State: AC+VfDz3Rw57abgQ2w/VhM+41yLsenW+drK5ESyV0DkwFJyzm6mA5BqV vleYifDsvWVCuPPPtNtZvHhEnd9THzu9mmVB X-Google-Smtp-Source: ACHHUZ7q30IXsrJqzMLqtk809m86xaZ/CUrr9VWno7K9eZT0AX5NZS1aoIFCAgUDG8dFCl29UobcMw== X-Received: by 2002:a5d:46c5:0:b0:30f:ce77:434c with SMTP id g5-20020a5d46c5000000b0030fce77434cmr9103293wrs.62.1687247472177; Tue, 20 Jun 2023 00:51:12 -0700 (PDT) Received: from localhost ([188.120.129.124]) by smtp.gmail.com with ESMTPSA id i15-20020a5d55cf000000b0030633152664sm1329284wrw.87.2023.06.20.00.51.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 00:51:11 -0700 (PDT) From: Efraim Flashner Date: Tue, 20 Jun 2023 10:51:05 +0300 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/cpu.scm (cpu->gcc-architecture): Refactor to wrap all the x86_64 options inside a common letrec-syntax. --- guix/cpu.scm | 59 +++++++++++++++++----------------------------------- 1 file changed, 19 insertions(+), 40 deletions(-) diff --git a/guix/cpu.scm b/guix/cpu.scm index e500664503..ddfa4f20bb 100644 --- a/guix/cpu.scm +++ b/guix/cpu.scm @@ -115,19 +115,19 @@ (define (cpu->gcc-architecture cpu) (match (cpu-architecture cpu) ("x86_64" ;; Transcribed from GCC's 'host_detect_local_cpu' in driver-i386.cc. - (or (and (equal? "GenuineIntel" (cpu-vendor cpu)) - (= 6 (cpu-family cpu)) ;the "Pentium Pro" family - (letrec-syntax ((if-flags (syntax-rules (=>) - ((_) - #f) - ((_ (flags ... => name) rest ...) - (if (every (lambda (flag) - (set-contains? (cpu-flags cpu) - flag)) - '(flags ...)) - name - (if-flags rest ...)))))) + (letrec-syntax ((if-flags (syntax-rules (=>) + ((_) + #f) + ((_ (flags ... => name) rest ...) + (if (every (lambda (flag) + (set-contains? (cpu-flags cpu) + flag)) + '(flags ...)) + name + (if-flags rest ...)))))) + (or (and (equal? "GenuineIntel" (cpu-vendor cpu)) + (= 6 (cpu-family cpu)) ;the "Pentium Pro" family (if-flags ("avx" "raoint" => "grandridge") ("avx" "amx_fp16" => "graniterapids") ("avx" "avxvnniint8" => "sierraforest") @@ -153,20 +153,9 @@ (define (cpu->gcc-architecture cpu) ("ssse3" "movbe" => "bonnell") ("ssse3" => "core2") ("longmode" => "x86-64") - ("lm" => "x86-64")))) - - (and (equal? "AuthenticAMD" (cpu-vendor cpu)) - (letrec-syntax ((if-flags (syntax-rules (=>) - ((_) - #f) - ((_ (flags ... => name) rest ...) - (if (every (lambda (flag) - (set-contains? (cpu-flags cpu) - flag)) - '(flags ...)) - name - (if-flags rest ...)))))) + ("lm" => "x86-64"))) + (and (equal? "AuthenticAMD" (cpu-vendor cpu)) (or (and (= 22 (cpu-family cpu)) (if-flags ("movbe" => "btver2"))) (and (= 6 (cpu-family cpu)) @@ -193,28 +182,18 @@ (define (cpu->gcc-architecture cpu) ("lm" => "k8") ("mmx" "3dnow" => "k6-3") ("mmx" => "k6") - (_ => "pentium"))))) + (_ => "pentium")))) - ;; Fallback case for non-Intel processors or for Intel processors not - ;; recognized above. - (letrec-syntax ((if-flags (syntax-rules (=>) - ((_) - #f) - ((_ (flags ... => name) rest ...) - (if (every (lambda (flag) - (set-contains? (cpu-flags cpu) - flag)) - '(flags ...)) - name - (if-flags rest ...)))))) + ;; Fallback case for non-Intel processors or for processors not + ;; recognized above. (if (and (= 7 (cpu-family cpu)) (= #x3b (cpu-model cpu))) "lujiazui" - (cpu->generic-architecture cpu))) + (cpu->generic-architecture cpu)) ;; TODO: Recognize CENTAUR/CYRIX/NSC? - "x86_64")) + "x86_64"))) ("aarch64" ;; Transcribed from GCC's list of aarch64 processors in aarch64-cores.def ;; What to do with big.LITTLE cores?