From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from omta037.useast.a.cloudfilter.net (omta037.useast.a.cloudfilter.net [44.202.169.36]) by sourceware.org (Postfix) with ESMTPS id 8A7C43858D28 for ; Tue, 22 Aug 2023 18:52:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8A7C43858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from eig-obgw-6007a.ext.cloudfilter.net ([10.0.30.247]) by cmsmtp with ESMTP id Y9fPqQhUlWU1cYWTyqIZwo; Tue, 22 Aug 2023 18:52:02 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id YWTwqJGbqNdJPYWTwqqz5p; Tue, 22 Aug 2023 18:52:00 +0000 X-Authority-Analysis: v=2.4 cv=L+sO/sf8 c=1 sm=1 tr=0 ts=64e503d1 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=UttIx32zK-AA:10 a=Qbun_eYptAEA:10 a=IX3ET3Vm5SnRfwbthoAA:9 a=F4_GSqmFzeSpiTP5:21 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject: Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=OpjyDyt7OSVAOoEwiZR00URiyyRLK3s1zmqOkvnH0Hk=; b=KXzSPhAcKGC6d0EeciKavfVVJk hjKia/QtTKsbxrMDOZKwQSBRwZqI582csut2vM/cOS0wIsSxMR3+XVLGvHEFZ9cA0fE8il1zY/BV3 vC/m8q9OCrs7I4/ZgVK++VaNb; Received: from 75-166-142-177.hlrn.qwest.net ([75.166.142.177]:55234 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qYWTw-002737-0F; Tue, 22 Aug 2023 12:52:00 -0600 From: Tom Tromey To: cgen@sourceware.org Cc: Tom Tromey Subject: [PATCH] Enable the Guile compiler Date: Tue, 22 Aug 2023 12:51:53 -0600 Message-ID: <20230822185153.1291550-1-tom@tromey.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.142.177 X-Source-L: No X-Exim-ID: 1qYWTw-002737-0F X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-142-177.hlrn.qwest.net (localhost.localdomain) [75.166.142.177]:55234 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfGbz6+g6QBBnJ7l3mR43Cl0KJaS7j/cUw4+8ypPoyjCkX1ZuLE+ChIGTOi5bpXLo5A8+dNUY290kqeGruqwJdCUWpZLfsxGoGkm2OPnyp18jaJqSX7dM M7vcZoTvrDh77wFmPNxgRTidzymRk2wmaDEcSa1GfdG/miurHoTGuAMR69IbJwZpdhcErHQx4rqSAQ== X-Spam-Status: No, score=-3024.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,JMQ_SPF_NEUTRAL,KAM_ASCII_DIVIDERS,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This patch changes cgen so that the Guile compiler can be used. Mainly this is done by using eval-when to ensure that files are loaded during the compilation process. However, "-s" handling and srcdir-setting are also cleaned up, using Guile's (current-filename) feature. The main benefit of using the compiler is that it is much faster, once the scripts have been compiled. Also it simplifies the use of cgen, as users don't need to remember to set an environment variable before invoking it. --- cgen-doc.scm | 47 +++++------------------------- cgen-gas.scm | 56 +++++++++-------------------------- cgen-intrinsics.scm | 47 +++++------------------------- cgen-opc.scm | 55 ++++++++--------------------------- cgen-sid.scm | 51 +++++++------------------------- cgen-sim.scm | 53 +++++++-------------------------- cgen-stest.scm | 57 ++++++++++-------------------------- cgen-testsuite.scm | 49 +++++++------------------------ dev-utils.scm | 4 +-- dev.scm | 10 +++---- guile.scm | 2 -- read.scm | 71 +++++++++++++++++++++++---------------------- 12 files changed, 131 insertions(+), 371 deletions(-) diff --git a/cgen-doc.scm b/cgen-doc.scm index 83af463..5aa751b 100644 --- a/cgen-doc.scm +++ b/cgen-doc.scm @@ -2,18 +2,16 @@ ; This is invoked to build: $arch.html. ; Copyright (C) 2003, 2009 Doug Evans ; This file is part of CGEN. -; -; This is a standalone script, we don't load anything until we parse the -; -s argument (keeps reliance off of environment variables, etc.). -; Load the various support routines. +(eval-when (expand load eval) + ;; Kept global so it's available to the other .scm files. + (define srcdir (dirname (current-filename))) + (add-to-load-path srcdir) -(define (load-files srcdir) - (load (string-append srcdir "/read.scm")) - (load (string-append srcdir "/desc.scm")) - (load (string-append srcdir "/desc-cpu.scm")) - (load (string-append srcdir "/html.scm")) -) + (load-from-path "read") + (load-from-path "desc") + (load-from-path "desc-cpu") + (load-from-path "html")) (define doc-arguments (list @@ -29,40 +27,11 @@ ) ) -; Kept global so it's available to the other .scm files. -(define srcdir ".") - -; Scan argv for -s srcdir. -; We can't process any other args until we find the cgen source dir. -; The result is srcdir. -; We assume "-s" isn't the argument to another option. Unwise, yes. -; Alternatives are to require it to be the first argument or at least preceed -; any option with a "-s" argument, or to put knowledge of the common argument -; set and common argument parsing code in every top level file. - -(define (find-srcdir argv) - (let loop ((argv argv)) - (if (null? argv) - (error "`-s srcdir' not present, can't load cgen")) - (if (string=? "-s" (car argv)) - (begin - (if (null? (cdr argv)) - (error "missing srcdir arg to `-s'")) - (cadr argv)) - (loop (cdr argv)))) -) - ; Main routine, parses options and calls generators. (define (cgen-doc argv) (let () - ; Find and set srcdir, then load all Scheme code. - ; Drop the first argument, it is the script name (i.e. argv[0]). - (set! srcdir (find-srcdir (cdr argv))) - (set! %load-path (cons srcdir %load-path)) - (load-files srcdir) - (display-argv argv) (cgen #:argv argv diff --git a/cgen-gas.scm b/cgen-gas.scm index 3d33e92..1e12819 100644 --- a/cgen-gas.scm +++ b/cgen-gas.scm @@ -5,19 +5,20 @@ ; This is invoked to build several .s files and a "build script", ; which generates the .d files and .exp DejaGNU test case. -; Load the various support routines. - -(define (load-files srcdir) - (load (string-append srcdir "/read.scm")) - (load (string-append srcdir "/desc.scm")) - (load (string-append srcdir "/desc-cpu.scm")) - (load (string-append srcdir "/opcodes.scm")) - (load (string-append srcdir "/opc-asmdis.scm")) - (load (string-append srcdir "/opc-ibld.scm")) - (load (string-append srcdir "/opc-itab.scm")) - (load (string-append srcdir "/opc-opinst.scm")) - (load (string-append srcdir "/gas-test.scm")) -) +(eval-when (expand load eval) + ;; Kept global so it's available to the other .scm files. + (define srcdir (dirname (current-filename))) + (add-to-load-path srcdir) + + (load-from-path "read") + (load-from-path "desc") + (load-from-path "desc-cpu") + (load-from-path "opcodes") + (load-from-path "opc-asmdis") + (load-from-path "opc-ibld") + (load-from-path "opc-itab") + (load-from-path "opc-opinst") + (load-from-path "gas-test")) (define gas-arguments (list @@ -30,40 +31,11 @@ ) ) -; Kept global so it's available to the other .scm files. -(define srcdir ".") - -; Scan argv for -s srcdir. -; We can't process any other args until we find the cgen source dir. -; The result is srcdir. -; We assume "-s" isn't the argument to another option. Unwise, yes. -; Alternatives are to require it to be the first argument or at least preceed -; any option with a "-s" argument, or to put knowledge of the common argument -; set and common argument parsing code in every top level file. - -(define (find-srcdir argv) - (let loop ((argv argv)) - (if (null? argv) - (error "`-s srcdir' not present, can't load cgen")) - (if (string=? "-s" (car argv)) - (begin - (if (null? (cdr argv)) - (error "missing srcdir arg to `-s'")) - (cadr argv)) - (loop (cdr argv)))) -) - ; Main routine, parses options and calls generators. (define (cgen-gas argv) (let () - ; Find and set srcdir, then load all Scheme code. - ; Drop the first argument, it is the script name (i.e. argv[0]). - (set! srcdir (find-srcdir (cdr argv))) - (set! %load-path (cons srcdir %load-path)) - (load-files srcdir) - (display-argv argv) (cgen #:argv argv diff --git a/cgen-intrinsics.scm b/cgen-intrinsics.scm index 16e0338..1e5f882 100644 --- a/cgen-intrinsics.scm +++ b/cgen-intrinsics.scm @@ -6,19 +6,15 @@ ; ; Copyright (C) 2000, 2009 Red Hat, Inc. ; This file is part of CGEN. -; -; This is a standalone script, we don't load anything until we parse the -; -s argument (keeps reliance off of environment variables, etc.). - -; Load the various support routines. -(define (load-files srcdir) - ; Fix up Scheme to be what we use (guile is always in flux). - (primitive-load-path (string-append srcdir "/guile.scm")) +(eval-when (expand load eval) + ;; Kept global so it's available to the other .scm files. + (define srcdir (dirname (current-filename))) + (add-to-load-path srcdir) - (load (string-append srcdir "/read.scm")) - (load (string-append srcdir "/intrinsics.scm")) -) + (load-from-path "guile") + (load-from-path "read") + (load-from-path "intrinsics")) (define intrinsics-isas '()) @@ -38,40 +34,11 @@ (list "-T" "file" "generate intrinsic-testsuite.c in " #f (lambda (arg) (file-write arg intrinsic-testsuite.c))))) -; Kept global so it's available to the other .scm files. -(define srcdir ".") - -; Scan argv for -s srcdir. -; We can't process any other args until we find the cgen source dir. -; The result is srcdir. -; We assume "-s" isn't the argument to another option. Unwise, yes. -; Alternatives are to require it to be the first argument or at least preceed -; any option with a "-s" argument, or to put knowledge of the common argument -; set and common argument parsing code in every top level file. - -(define (find-srcdir argv) - (let loop ((argv argv)) - (if (null? argv) - (error "`-s srcdir' not present, can't load cgen")) - (if (string=? "-s" (car argv)) - (begin - (if (null? (cdr argv)) - (error "missing srcdir arg to `-s'")) - (cadr argv)) - (loop (cdr argv)))) -) - ; Main routine, parses options and calls generators. (define (cgen-intrinsics argv) (let () - ; Find and set srcdir, then load all Scheme code. - ; Drop the first argument, it is the script name (i.e. argv[0]). - (set! srcdir (find-srcdir (cdr argv))) - (set! %load-path (cons srcdir %load-path)) - (load-files srcdir) - (display-argv argv) (cgen #:argv argv diff --git a/cgen-opc.scm b/cgen-opc.scm index 276fdb8..cac5115 100644 --- a/cgen-opc.scm +++ b/cgen-opc.scm @@ -3,22 +3,20 @@ ; $arch-opc.h, $arch-opc.c, $arch-asm.in, $arch-dis.in, and $arch-ibld.[ch]. ; Copyright (C) 2000, 2009 Red Hat, Inc. ; This file is part of CGEN. -; -; This is a standalone script, we don't load anything until we parse the -; -s argument (keeps reliance off of environment variables, etc.). -; Load the various support routines. +(eval-when (expand load eval) + ;; Kept global so it's available to the other .scm files. + (define srcdir (dirname (current-filename))) + (add-to-load-path srcdir) -(define (load-files srcdir) - (load (string-append srcdir "/read.scm")) - (load (string-append srcdir "/desc.scm")) - (load (string-append srcdir "/desc-cpu.scm")) - (load (string-append srcdir "/opcodes.scm")) - (load (string-append srcdir "/opc-asmdis.scm")) - (load (string-append srcdir "/opc-ibld.scm")) - (load (string-append srcdir "/opc-itab.scm")) - (load (string-append srcdir "/opc-opinst.scm")) -) + (load-from-path "read") + (load-from-path "desc") + (load-from-path "desc-cpu") + (load-from-path "opcodes") + (load-from-path "opc-asmdis") + (load-from-path "opc-ibld") + (load-from-path "opc-itab") + (load-from-path "opc-opinst")) (define opc-arguments (list @@ -60,40 +58,11 @@ ; ((-R) (file-write *arg* cgen-reloc.c)) ; ((-S) (file-write *arg* cgen-bfdcpu.c)) -; Kept global so it's available to the other .scm files. -(define srcdir ".") - -; Scan argv for -s srcdir. -; We can't process any other args until we find the cgen source dir. -; The result is srcdir. -; We assume "-s" isn't the argument to another option. Unwise, yes. -; Alternatives are to require it to be the first argument or at least preceed -; any option with a "-s" argument, or to put knowledge of the common argument -; set and common argument parsing code in every top level file. - -(define (find-srcdir argv) - (let loop ((argv argv)) - (if (null? argv) - (error "`-s srcdir' not present, can't load cgen")) - (if (string=? "-s" (car argv)) - (begin - (if (null? (cdr argv)) - (error "missing srcdir arg to `-s'")) - (cadr argv)) - (loop (cdr argv)))) -) - ; Main routine, parses options and calls generators. (define (cgen-opc argv) (let () - ; Find and set srcdir, then load all Scheme code. - ; Drop the first argument, it is the script name (i.e. argv[0]). - (set! srcdir (find-srcdir (cdr argv))) - (set! %load-path (cons srcdir %load-path)) - (load-files srcdir) - (display-argv argv) (cgen #:argv argv diff --git a/cgen-sid.scm b/cgen-sid.scm index bb74a7b..ab9e505 100644 --- a/cgen-sid.scm +++ b/cgen-sid.scm @@ -3,20 +3,18 @@ ; semantics.cxx, sem-switch.cxx, model.h, model.cxx ; Copyright (C) 2000, 2003, 2009 Red Hat, Inc. ; This file is part of CGEN. -; -; This is a standalone script, we don't load anything until we parse the -; -s argument (keeps reliance off of environment variables, etc.). -; Load the various support routines. +(eval-when (expand load eval) + ;; Kept global so it's available to the other .scm files. + (define srcdir (dirname (current-filename))) + (add-to-load-path srcdir) -(define (load-files srcdir) - (load (string-append srcdir "/read.scm")) - (load (string-append srcdir "/utils-sim.scm")) - (load (string-append srcdir "/sid.scm")) - (load (string-append srcdir "/sid-cpu.scm")) - (load (string-append srcdir "/sid-model.scm")) - (load (string-append srcdir "/sid-decode.scm")) -) + (load-from-path "read") + (load-from-path "utils-sim") + (load-from-path "sid") + (load-from-path "sid-cpu") + (load-from-path "sid-model") + (load-from-path "sid-decode")) (define sim-arguments (list @@ -53,40 +51,11 @@ ) ) -; Kept global so it's available to the other .scm files. -(define srcdir ".") - -; Scan argv for -s srcdir. -; We can't process any other args until we find the cgen source dir. -; The result is srcdir. -; We assume "-s" isn't the argument to another option. Unwise, yes. -; Alternatives are to require it to be the first argument or at least preceed -; any option with a "-s" argument, or to put knowledge of the common argument -; set and common argument parsing code in every top level file. - -(define (find-srcdir argv) - (let loop ((argv argv)) - (if (null? argv) - (error "`-s srcdir' not present, can't load cgen")) - (if (string=? "-s" (car argv)) - (begin - (if (null? (cdr argv)) - (error "missing srcdir arg to `-s'")) - (cadr argv)) - (loop (cdr argv)))) -) - ; Main routine, parses options and calls generators. (define (cgen-sim argv) (let () - ; Find and set srcdir, then load all Scheme code. - ; Drop the first argument, it is the script name (i.e. argv[0]). - (set! srcdir (find-srcdir (cdr argv))) - (set! %load-path (cons srcdir %load-path)) - (load-files srcdir) - (display-argv argv) (cgen #:argv argv diff --git a/cgen-sim.scm b/cgen-sim.scm index 2b9f962..ec7b84c 100644 --- a/cgen-sim.scm +++ b/cgen-sim.scm @@ -6,21 +6,19 @@ ; ; Copyright (C) 2000, 2009 Red Hat, Inc. ; This file is part of CGEN. -; -; This is a standalone script, we don't load anything until we parse the -; -s argument (keeps reliance off of environment variables, etc.). -; Load the various support routines. +(eval-when (expand load eval) + ;; Kept global so it's available to the other .scm files. + (define srcdir (dirname (current-filename))) + (add-to-load-path srcdir) -(define (load-files srcdir) - (load (string-append srcdir "/read.scm")) - (load (string-append srcdir "/utils-sim.scm")) - (load (string-append srcdir "/sim.scm")) - (load (string-append srcdir "/sim-arch.scm")) - (load (string-append srcdir "/sim-cpu.scm")) - (load (string-append srcdir "/sim-model.scm")) - (load (string-append srcdir "/sim-decode.scm")) -) + (load-from-path "read") + (load-from-path "utils-sim") + (load-from-path "sim") + (load-from-path "sim-arch") + (load-from-path "sim-cpu") + (load-from-path "sim-model") + (load-from-path "sim-decode")) (define sim-arguments (list @@ -81,40 +79,11 @@ ) ) -; Kept global so it's available to the other .scm files. -(define srcdir ".") - -; Scan argv for -s srcdir. -; We can't process any other args until we find the cgen source dir. -; The result is srcdir. -; We assume "-s" isn't the argument to another option. Unwise, yes. -; Alternatives are to require it to be the first argument or at least preceed -; any option with a "-s" argument, or to put knowledge of the common argument -; set and common argument parsing code in every top level file. - -(define (find-srcdir argv) - (let loop ((argv argv)) - (if (null? argv) - (error "`-s srcdir' not present, can't load cgen")) - (if (string=? "-s" (car argv)) - (begin - (if (null? (cdr argv)) - (error "missing srcdir arg to `-s'")) - (cadr argv)) - (loop (cdr argv)))) -) - ; Main routine, parses options and calls generators. (define (cgen-sim argv) (let () - ; Find and set srcdir, then load all Scheme code. - ; Drop the first argument, it is the script name (i.e. argv[0]). - (set! srcdir (find-srcdir (cdr argv))) - (set! %load-path (cons srcdir %load-path)) - (load-files srcdir) - (display-argv argv) (cgen #:argv argv diff --git a/cgen-stest.scm b/cgen-stest.scm index 10f62a8..7214f82 100644 --- a/cgen-stest.scm +++ b/cgen-stest.scm @@ -6,18 +6,22 @@ ; generate the .d files and .exp file. ; This is invoked to build: tmp-build.sh cpu-cpu.exp -; Load the various support routines -(define (load-files srcdir) - (load (string-append srcdir "/read.scm")) - (load (string-append srcdir "/desc.scm")) - (load (string-append srcdir "/desc-cpu.scm")) - (load (string-append srcdir "/opcodes.scm")) - (load (string-append srcdir "/opc-asmdis.scm")) - (load (string-append srcdir "/opc-ibld.scm")) - (load (string-append srcdir "/opc-itab.scm")) - (load (string-append srcdir "/opc-opinst.scm")) - (load (string-append srcdir "/sim-test.scm")) -) +(use-modules (ice-9 slib)) + +(eval-when (expand load eval) + ;; Kept global so it's available to the other .scm files. + (define srcdir (dirname (current-filename))) + (add-to-load-path srcdir) + + (load-from-path "read") + (load-from-path "desc") + (load-from-path "desc-cpu") + (load-from-path "opcodes") + (load-from-path "opc-asmdis") + (load-from-path "opc-ibld") + (load-from-path "opc-itab") + (load-from-path "opc-opinst") + (load-from-path "sim-test")) (define stest-arguments (list @@ -30,40 +34,11 @@ ) ) -; Kept global so it's available to the other .scm files. -(define srcdir ".") - -; Scan argv for -s srcdir. -; We can't process any other args until we find the cgen source dir. -; The result is srcdir. -; We assume "-s" isn't the argument to another option. Unwise, yes. -; Alternatives are to require it to be the first argument or at least preceed -; any option with a "-s" argument, or to put knowledge of the common argument -; set and common argument parsing code in every top level file. - -(define (find-srcdir argv) - (let loop ((argv argv)) - (if (null? argv) - (error "`-s srcdir' not present, can't load cgen")) - (if (string=? "-s" (car argv)) - (begin - (if (null? (cdr argv)) - (error "missing srcdir arg to `-s'")) - (cadr argv)) - (loop (cdr argv)))) -) - ; Main routine, parses options and calls generators. (define (cgen-stest argv) (let () - ; Find and set srcdir, then load all Scheme code. - ; Drop the first argument, it is the script name (i.e. argv[0]). - (set! srcdir (find-srcdir (cdr argv))) - (set! %load-path (cons srcdir %load-path)) - (load-files srcdir) - (display-argv argv) (cgen #:argv argv diff --git a/cgen-testsuite.scm b/cgen-testsuite.scm index 0c37be3..ae78cff 100644 --- a/cgen-testsuite.scm +++ b/cgen-testsuite.scm @@ -1,18 +1,18 @@ ; CGEN testsuite driver. ; Copyright (C) 2009 Doug Evans ; This file is part of CGEN. -; -; This is a standalone script, we don't load anything until we parse the -; -s argument (keeps reliance off of environment variables, etc.). -; Load the various support routines. +(eval-when (expand load eval) + ;; Kept global so it's available to the other .scm files. + (define srcdir (dirname (current-filename))) + (add-to-load-path srcdir) -(define (load-files srcdir) - (load (string-append srcdir "/read.scm")) - (load (string-append srcdir "/desc.scm")) - (load (string-append srcdir "/desc-cpu.scm")) - (load (string-append srcdir "/testsuite.scm")) -) + (use-modules (ice-9 slib)) + + (load-from-path "read") + (load-from-path "desc") + (load-from-path "desc-cpu") + (load-from-path "testsuite")) (define testsuite-arguments (list @@ -22,40 +22,11 @@ ) ) -; Kept global so it's available to the other .scm files. -(define srcdir ".") - -; Scan argv for -s srcdir. -; We can't process any other args until we find the cgen source dir. -; The result is srcdir. -; We assume "-s" isn't the argument to another option. Unwise, yes. -; Alternatives are to require it to be the first argument or at least preceed -; any option with a "-s" argument, or to put knowledge of the common argument -; set and common argument parsing code in every top level file. - -(define (find-srcdir argv) - (let loop ((argv argv)) - (if (null? argv) - (error "`-s srcdir' not present, can't load cgen")) - (if (string=? "-s" (car argv)) - (begin - (if (null? (cdr argv)) - (error "missing srcdir arg to `-s'")) - (cadr argv)) - (loop (cdr argv)))) -) - ; Main routine, parses options and calls generators. (define (cgen-testsuite argv) (let () - ; Find and set srcdir, then load all Scheme code. - ; Drop the first argument, it is the script name (i.e. argv[0]). - (set! srcdir (find-srcdir (cdr argv))) - (set! %load-path (cons srcdir %load-path)) - (load-files srcdir) - (display-argv argv) (cgen #:argv argv diff --git a/dev-utils.scm b/dev-utils.scm index 89c1ee1..fe7cd7a 100644 --- a/dev-utils.scm +++ b/dev-utils.scm @@ -6,8 +6,8 @@ ;; This file contains a collection of utilities for use when ;; analyzing cpu files from Scheme. -(define srcdir ".") -(set! %load-path (cons srcdir %load-path)) +(define srcdir (dirname (current-filename))) +(add-to-load-path srcdir) (define (load-doc) (load "read") diff --git a/dev.scm b/dev.scm index 2b31688..12be288 100644 --- a/dev.scm +++ b/dev.scm @@ -6,11 +6,11 @@ ; This file is loaded in during an interactive guile session to ; develop and debug CGEN. -; First load guile.scm to coerce guile into something we've been using. -; Guile is always in flux. -(load "guile.scm") - -(load "dev-utils.scm") +(eval-when (expand load eval) + ;; First load guile.scm to coerce guile into something we've been using. + ;; Guile is always in flux. + (load-from-path "guile") + (load-from-path "dev-utils")) ; Also defined in read.scm, but we need it earlier. (define APPLICATION 'UNKNOWN) diff --git a/guile.scm b/guile.scm index 5899f15..274264a 100644 --- a/guile.scm +++ b/guile.scm @@ -6,8 +6,6 @@ (define (eval1 expr) (eval expr (current-module))) -(define load primitive-load-path) - (define %stat stat) (debug-enable 'backtrace) diff --git a/read.scm b/read.scm index e6c2bde..392e7ba 100644 --- a/read.scm +++ b/read.scm @@ -62,41 +62,42 @@ ;; Variables representing misc. global constants. -;; Load the base cgen files. - -(load "pmacros") -(load "cos") -(load "slib/logical") -(load "slib/sort") -;; Used to pretty-print debugging messages. -(load "slib/pp") -;; Used by pretty-print. -(load "slib/random") -(load "slib/genwrite") -(load "utils") -(load "utils-cgen") -(load "attr") -(load "enum") -(load "mach") -(load "model") -(load "types") -(load "mode") -(load "ifield") -(load "iformat") -(load "hardware") -(load "operand") -(load "insn") -(load "minsn") -(load "decode") -(load "rtl") -(load "rtl-traverse") -(load "rtl-xform") -(load "rtx-funcs") -(load "rtl-c") -(load "semantics") -(load "sem-frags") -(load "utils-gen") -(load "pgmr-tools") +(eval-when (expand load eval) + ;; Load the base cgen files. + + (load-from-path "pmacros") + (load-from-path "cos") + (load-from-path "slib/logical") + (load-from-path "slib/sort") + ;; Used to pretty-print debugging messages. + (load-from-path "slib/pp") + ;; Used by pretty-print. + (load-from-path "slib/random") + (load-from-path "slib/genwrite") + (load-from-path "utils") + (load-from-path "utils-cgen") + (load-from-path "attr") + (load-from-path "enum") + (load-from-path "mach") + (load-from-path "model") + (load-from-path "types") + (load-from-path "mode") + (load-from-path "ifield") + (load-from-path "iformat") + (load-from-path "hardware") + (load-from-path "operand") + (load-from-path "insn") + (load-from-path "minsn") + (load-from-path "decode") + (load-from-path "rtl") + (load-from-path "rtl-traverse") + (load-from-path "rtl-xform") + (load-from-path "rtx-funcs") + (load-from-path "rtl-c") + (load-from-path "semantics") + (load-from-path "sem-frags") + (load-from-path "utils-gen") + (load-from-path "pgmr-tools")) ;; A list of three numbers designating the cgen version: major minor fixlevel. ;; The "50" is a generic indicator that we're between 1.1 and 1.2. -- 2.41.0