From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.devel Subject: [PATCH 4/9] RTL language Date: Thu, 29 Aug 2013 09:49:34 +0200 Message-ID: <1377762579-9738-5-git-send-email-wingo@pobox.com> References: <1377762579-9738-1-git-send-email-wingo@pobox.com> NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1377762643 22174 80.91.229.3 (29 Aug 2013 07:50:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 29 Aug 2013 07:50:43 +0000 (UTC) Cc: Andy Wingo To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu Aug 29 09:50:46 2013 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VEx09-0005Yo-KM for guile-devel@m.gmane.org; Thu, 29 Aug 2013 09:50:45 +0200 Original-Received: from localhost ([::1]:41062 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VEx09-00023e-9v for guile-devel@m.gmane.org; Thu, 29 Aug 2013 03:50:45 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54561) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VEwzu-0001yA-SQ for guile-devel@gnu.org; Thu, 29 Aug 2013 03:50:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VEwzn-0002cx-1m for guile-devel@gnu.org; Thu, 29 Aug 2013 03:50:30 -0400 Original-Received: from a-pb-sasl-quonix.pobox.com ([208.72.237.25]:42055 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VEwzm-0002ct-To for guile-devel@gnu.org; Thu, 29 Aug 2013 03:50:22 -0400 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id A386DE855; Thu, 29 Aug 2013 03:50:22 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:date:message-id:in-reply-to:references; s=sasl; bh=f334 Vw9UrKTRQQ7niTCc3GlQ4IU=; b=UEA/pYBMcZVT1A2KZHcaqpqT4D92HzdwVeQ8 RdfgLQ7byx8j0AomXgtAVycG5FTdLWuVxv/x8a3c6kH/QszC8qSuJZqj97DMulhx AFdsu4XGsrcvjBzwyh3QUv5zHynH5ePPT6iUoi2/DTtabaY4EnoIhoPRim4iI/l5 1PDsZa0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:date:message-id:in-reply-to:references; q=dns; s=sasl; b= F58soXsRAy/xcCzTyJ1AQcOrVFILCA9Yri9KakiB3hogj9SYtI0GXj7f9rI1Owo5 zuLPcx7naTNesewB9CgW09H3IjHe729JpkNRKONoUI+UzXg/t0SpH+rrHJlhuFhA k6f7iVNwePgKQP9SvT42qxdNMHE2Lla0vfpN1tBr/UI= Original-Received: from a-pb-sasl-quonix.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 9AAC3E854; Thu, 29 Aug 2013 03:50:22 -0400 (EDT) Original-Received: from localhost.localdomain (unknown [88.160.190.192]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTPSA id C1D83E853; Thu, 29 Aug 2013 03:50:20 -0400 (EDT) X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1377762579-9738-1-git-send-email-wingo@pobox.com> X-Pobox-Relay-ID: A8358B7C-107F-11E3-AB10-CE710E5B5709-02397024!a-pb-sasl-quonix.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 208.72.237.25 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:16583 Archived-At: * module/Makefile.am * module/language/rtl.scm: * module/language/rtl/spec.scm: Add a stub RTL language. --- module/Makefile.am | 5 +++ module/language/rtl.scm | 92 ++++++++++++++++++++++++++++++++++++++++++++ module/language/rtl/spec.scm | 31 +++++++++++++++ 3 files changed, 128 insertions(+) create mode 100644 module/language/rtl.scm create mode 100644 module/language/rtl/spec.scm diff --git a/module/Makefile.am b/module/Makefile.am index 6fd88e6..e2268a8 100644 --- a/module/Makefile.am +++ b/module/Makefile.am @@ -54,6 +54,7 @@ SOURCES = \ language/assembly.scm \ $(TREE_IL_LANG_SOURCES) \ $(CPS_LANG_SOURCES) \ + $(RTL_LANG_SOURCES) \ $(GLIL_LANG_SOURCES) \ $(ASSEMBLY_LANG_SOURCES) \ $(BYTECODE_LANG_SOURCES) \ @@ -123,6 +124,10 @@ CPS_LANG_SOURCES = \ language/cps/spec.scm \ language/cps/verify.scm +RTL_LANG_SOURCES = \ + language/rtl.scm \ + language/rtl/spec.scm + GLIL_LANG_SOURCES = \ language/glil/spec.scm language/glil/compile-assembly.scm diff --git a/module/language/rtl.scm b/module/language/rtl.scm new file mode 100644 index 0000000..d217517 --- /dev/null +++ b/module/language/rtl.scm @@ -0,0 +1,92 @@ +;;; Register Transfer Language (RTL) + +;; Copyright (C) 2013 Free Software Foundation, Inc. + +;;;; This library is free software; you can redistribute it and/or +;;;; modify it under the terms of the GNU Lesser General Public +;;;; License as published by the Free Software Foundation; either +;;;; version 3 of the License, or (at your option) any later version. +;;;; +;;;; This library is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;;; Lesser General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU Lesser General Public +;;;; License along with this library; if not, write to the Free Software +;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +;;; Code: + +(define-module (language rtl) + #:use-module (ice-9 match) + #:use-module ((srfi srfi-1) #:select (fold)) + #:use-module (system vm instruction) + #:re-export (rtl-instruction-list) + #:export (rtl-instruction-arity)) + +(define (compute-rtl-instruction-arity name args) + (define (first-word-arity word) + (case word + ((U8_X24) 0) + ((U8_U24) 1) + ((U8_L24) 1) + ((U8_U8_I16) 2) + ((U8_U12_U12) 2) + ((U8_U8_U8_U8) 3))) + (define (tail-word-arity word) + (case word + ((U8_U24) 2) + ((U8_L24) 2) + ((U8_U8_I16) 3) + ((U8_U12_U12) 3) + ((U8_U8_U8_U8) 4) + ((U32) 1) + ((I32) 1) + ((A32) 1) + ((B32) 0) + ((N32) 1) + ((S32) 1) + ((L32) 1) + ((LO32) 1) + ((X8_U24) 1) + ((X8_U12_U12) 2) + ((X8_L24) 1) + ((B1_X7_L24) 2) + ((B1_U7_L24) 3) + ((B1_X31) 1) + ((B1_X7_U24) 2))) + (match args + ((arg0 . args) + (fold (lambda (arg arity) + (+ (tail-word-arity arg) arity)) + (first-word-arity arg0) + args)))) + +(define *macro-instruction-arities* + '((cache-current-module! . (0 . 2)) + (cached-toplevel-box . (1 . 3)) + (cached-module-box . (1 . 4)))) + +(define (compute-rtl-instruction-arities) + (let ((table (make-hash-table))) + (for-each + (match-lambda + ;; Put special cases here. + ((name op '! . args) + (hashq-set! table name + (cons 0 (compute-rtl-instruction-arity name args)))) + ((name op '<- . args) + (hashq-set! table name + (cons 1 (1- (compute-rtl-instruction-arity name args)))))) + (rtl-instruction-list)) + (for-each (match-lambda + ((name . arity) + (hashq-set! table name arity))) + *macro-instruction-arities*) + table)) + +(define *rtl-instruction-arities* (delay (compute-rtl-instruction-arities))) + +(define (rtl-instruction-arity name) + (hashq-ref (force *rtl-instruction-arities*) name)) diff --git a/module/language/rtl/spec.scm b/module/language/rtl/spec.scm new file mode 100644 index 0000000..0a8c4ee --- /dev/null +++ b/module/language/rtl/spec.scm @@ -0,0 +1,31 @@ +;;; Register Transfer Language (RTL) + +;; Copyright (C) 2013 Free Software Foundation, Inc. + +;;;; This library is free software; you can redistribute it and/or +;;;; modify it under the terms of the GNU Lesser General Public +;;;; License as published by the Free Software Foundation; either +;;;; version 3 of the License, or (at your option) any later version. +;;;; +;;;; This library is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;;; Lesser General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU Lesser General Public +;;;; License along with this library; if not, write to the Free Software +;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +;;; Code: + +(define-module (language rtl spec) + #:use-module (system base language) + #:use-module (ice-9 binary-ports) + #:export (rtl)) + +(define-language rtl + #:title "Register Transfer Language" + #:compilers '() + #:printer (lambda (rtl port) (put-bytevector port rtl)) + #:reader get-bytevector-all + #:for-humans? #f) -- 1.8.3.2