[prev in list] [next in list] [prev in thread] [next in thread]
List: sbcl-commits
Subject: Re: [Sbcl-commits] master: Allow composing instruction emitters
From: Charles Zhang via Sbcl-commits <sbcl-commits () lists ! sourceforge ! net>
Date: 2021-01-31 7:32:22
Message-ID: 593886829.719993.1612078342586 () mail ! yahoo ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
So the way I achieved the same thing in the riscv backend (using other instructions \
in instruction emitters without duplicating the definition) is just by using the \
ASSEMBLE macro. This seems a little cleaner in my opinion since just plain INST can \
be used, the segment doesn't need to be spelled out more than once, and doesn't \
require extending the INST* macro to work "context-sensitively". See the definition \
of JAL in the riscv backend for instance.
On Saturday, January 30, 2021, 9:30:17 AM PST, Douglas Katzman via Sbcl-commits \
<sbcl-commits@lists.sourceforge.net> wrote:
The branch "master" has been updated in SBCL:
via 95c03039806c959b83be156a8e753639a1b68e8f (commit)
from c642a0bcc700688718b05ca8377b10afac519af5 (commit)
- Log -----------------------------------------------------------------
commit 95c03039806c959b83be156a8e753639a1b68e8f
Author: Douglas Katzman <dougk@google.com>
Date: Sat Jan 30 12:28:50 2021 -0500
Allow composing instruction emitters
(not used yet, but will be)
---
src/compiler/assem.lisp | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/compiler/assem.lisp b/src/compiler/assem.lisp
index 4a27c66a3..d4fb5ba6d 100644
--- a/src/compiler/assem.lisp
+++ b/src/compiler/assem.lisp
@@ -1600,9 +1600,20 @@
;;; As such, we must detect that we are emitting directly to machine code.
;;;
(defun inst* (mnemonic &rest operands)
- (declare (symbol mnemonic))
- (let ((action (gethash mnemonic *inst-encoder*))
- (dest *current-destination*))
+ (let ((dest
+ (etypecase mnemonic
+ (symbol
+ ;; If called by a vop, the first argument is a mnemonic.
+ *current-destination*)
+ (segment
+ ;; If called by an instruction encoder to encode other \
instructions, + ;; the first argument is a SEGMENT. This facilitates \
a different kind of + ;; macro-instruction, one which decides only \
at encoding time what other + ;; instructions to emit. Similar \
results could be achievedy by factoring + ;; out other emitters into \
callable functions, though the INST macro + ;; tends to be a more \
convenient interface. + (prog1 mnemonic (setq mnemonic (the symbol \
(pop operands))))))) + (action (gethash mnemonic *inst-encoder*)))
(unless action ; try canonicalizing again
(setq mnemonic (find-symbol (string mnemonic)
*backend-instruction-set-package*)
-----------------------------------------------------------------------
hooks/post-receive
--
SBCL
_______________________________________________
Sbcl-commits mailing list
Sbcl-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sbcl-commits
[Attachment #5 (text/html)]
<html><head></head><body><div class="ydpe66d9702yahoo-style-wrap" \
style="font-family:Helvetica Neue, Helvetica, Arial, \
sans-serif;font-size:16px;"><div><div dir="ltr" data-setdir="false">So the way I \
achieved the same thing in the riscv backend (using other instructions in instruction \
emitters without duplicating the definition) is just by using the ASSEMBLE macro. \
This seems a little cleaner in my opinion since just plain INST can be used, the \
segment doesn't need to be spelled out more than once, and doesn't require extending \
the INST* macro to work "context-sensitively". See the definition of JAL in the riscv \
backend for instance.<br></div><div class="ydpe66d9702signature"><div><span \
style="font-size:16px;"><span style="color: rgb(0, 191, 191); \
--darkreader-inline-color:#abf9de;" data-darkreader-inline-color=""><span \
style="font-family:arial, helvetica, sans-serif;"><span id="ydpe66d9702result_box" \
class="ydpe66d9702short_text" lang="la"><span></span></span></span><span \
style="font-size:16px;"><span style="color: rgb(0, 191, 191); \
--darkreader-inline-color:#abf9de;" data-darkreader-inline-color=""><span \
id="ydpe66d9702result_box" class="ydpe66d9702short_text" lang="el"><span \
class="ydpe66d9702hps"></span><span \
class="ydpe66d9702hps"></span></span></span></span></span></span><span style="color: \
rgb(0, 191, 191); --darkreader-inline-color:#abf9de;" \
data-darkreader-inline-color=""><br></span><span style="font-size:16px;"><span \
style="color: rgb(0, 191, 191); --darkreader-inline-color:#abf9de;" \
data-darkreader-inline-color=""><span id="ydpe66d9702result_box" \
class="ydpe66d9702short_text" lang="el"></span></span><br></span></div></div></div> \
<div><br></div><div><br></div>
</div><div id="ydp36eb2f23yahoo_quoted_2357730116" \
class="ydp36eb2f23yahoo_quoted"> <div style="font-family: Helvetica Neue, Helvetica, \
Arial, sans-serif; font-size: 13px; color: rgb(38, 40, 42); \
--darkreader-inline-color:#f1e0c1;" data-darkreader-inline-color="">
<div>
On Saturday, January 30, 2021, 9:30:17 AM PST, Douglas Katzman \
via Sbcl-commits <sbcl-commits@lists.sourceforge.net> wrote: </div>
<div><br></div>
<div><br></div>
<div><div dir="ltr">The branch "master" has been updated in \
SBCL:<br></div><div dir="ltr"> via \
95c03039806c959b83be156a8e753639a1b68e8f (commit)<br></div><div dir="ltr"> \
from c642a0bcc700688718b05ca8377b10afac519af5 \
(commit)<br></div><div dir="ltr"><br></div><div dir="ltr">- Log \
-----------------------------------------------------------------<br></div><div \
dir="ltr">commit 95c03039806c959b83be156a8e753639a1b68e8f<br></div><div \
dir="ltr">Author: Douglas Katzman <<a href="mailto:dougk@google.com" \
rel="nofollow" target="_blank">dougk@google.com</a>><br></div><div \
dir="ltr">Date: Sat Jan 30 12:28:50 2021 -0500<br></div><div \
dir="ltr"><br></div><div dir="ltr"> Allow composing instruction \
emitters<br></div><div dir="ltr"> <br></div><div dir="ltr"> \
(not used yet, but will be)<br></div><div dir="ltr">---<br></div><div dir="ltr"> \
src/compiler/assem.lisp | 17 ++++++++++++++---<br></div><div dir="ltr"> 1 file \
changed, 14 insertions(+), 3 deletions(-)<br></div><div dir="ltr"><br></div><div \
dir="ltr">diff --git a/src/compiler/assem.lisp \
b/src/compiler/assem.lisp<br></div><div dir="ltr">index 4a27c66a3..d4fb5ba6d \
100644<br></div><div dir="ltr">--- a/src/compiler/assem.lisp<br></div><div \
dir="ltr">+++ b/src/compiler/assem.lisp<br></div><div dir="ltr">@@ -1600,9 +1600,20 \
@@<br></div><div dir="ltr"> ;;; As such, we must detect that we are emitting directly \
to machine code.<br></div><div dir="ltr"> ;;;<br></div><div dir="ltr"> (defun inst* \
(mnemonic &rest operands)<br></div><div dir="ltr">- (declare (symbol \
mnemonic))<br></div><div dir="ltr">- (let ((action (gethash mnemonic \
*inst-encoder*))<br></div><div dir="ltr">- (dest \
*current-destination*))<br></div><div dir="ltr">+ (let ((dest<br></div><div \
dir="ltr">+ (etypecase mnemonic<br></div><div \
dir="ltr">+ (symbol<br></div><div \
dir="ltr">+ ;; If called by a vop, the first \
argument is a mnemonic.<br></div><div dir="ltr">+ \
*current-destination*)<br></div><div dir="ltr">+ \
(segment<br></div><div dir="ltr">+ \
;; If called by an instruction encoder to encode other instructions,<br></div><div \
dir="ltr">+ ;; the first argument is a \
SEGMENT. This facilitates a different kind of<br></div><div dir="ltr">+ \
;; macro-instruction, one which decides only at encoding \
time what other<br></div><div dir="ltr">+ ;; \
instructions to emit. Similar results could be achievedy by factoring<br></div><div \
dir="ltr">+ ;; out other emitters into \
callable functions, though the INST macro<br></div><div dir="ltr">+ \
;; tends to be a more convenient interface.<br></div><div \
dir="ltr">+ (prog1 mnemonic (setq mnemonic \
(the symbol (pop operands)))))))<br></div><div dir="ltr">+ \
(action (gethash mnemonic *inst-encoder*)))<br></div><div dir="ltr"> \
(unless action ; try canonicalizing again<br></div><div dir="ltr"> \
(setq mnemonic (find-symbol (string mnemonic)<br></div><div dir="ltr"> \
\
*backend-instruction-set-package*)<br></div><div \
dir="ltr"><br></div><div \
dir="ltr">-----------------------------------------------------------------------<br></div><div \
dir="ltr"><br></div><div dir="ltr"><br></div><div \
dir="ltr">hooks/post-receive<br></div><div dir="ltr">-- <br></div><div \
dir="ltr">SBCL<br></div><div dir="ltr"><br></div><div dir="ltr"><br></div><div \
dir="ltr">_______________________________________________<br></div><div \
dir="ltr">Sbcl-commits mailing list<br></div><div dir="ltr"><a \
href="mailto:Sbcl-commits@lists.sourceforge.net" rel="nofollow" \
target="_blank">Sbcl-commits@lists.sourceforge.net</a><br></div><div dir="ltr"><a \
href="https://lists.sourceforge.net/lists/listinfo/sbcl-commits" rel="nofollow" \
target="_blank">https://lists.sourceforge.net/lists/listinfo/sbcl-commits</a><br></div></div>
</div>
</div></body></html>
_______________________________________________
Sbcl-commits mailing list
Sbcl-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sbcl-commits
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic