From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26788 invoked by alias); 14 Jan 2003 06:09:22 -0000 Mailing-List: contact cgen-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cgen-owner@sources.redhat.com Received: (qmail 26772 invoked from network); 14 Jan 2003 06:09:19 -0000 Received: from unknown (HELO neon-gw.transmeta.com) (63.209.4.196) by 209.249.29.67 with SMTP; 14 Jan 2003 06:09:19 -0000 Received: (from root@localhost) by neon-gw.transmeta.com (8.9.3/8.9.3) id WAA29181; Mon, 13 Jan 2003 22:09:01 -0800 Received: from mailhost.transmeta.com(10.1.1.15) by neon-gw.transmeta.com via smap (V2.1) id xma029179; Mon, 13 Jan 03 22:08:44 -0800 Received: from xris-athlon.transmeta.com (xris-athlon.transmeta.com [10.10.25.96]) by deepthought.transmeta.com (8.11.6/8.11.6) with ESMTP id h0E68p302202; Mon, 13 Jan 2003 22:08:51 -0800 (PST) Received: (from dje@localhost) by xris-athlon.transmeta.com (8.9.3/8.7.3) id WAA13862; Mon, 13 Jan 2003 22:08:51 -0800 Date: Tue, 14 Jan 2003 06:09:00 -0000 Message-Id: <200301140608.WAA13862@xris-athlon.transmeta.com> From: Doug Evans To: Hans-Peter Nilsson cc: cgen@sources.redhat.com Subject: Re: [RFA:] In -build-operand!, -build-reg-operand, collect the natural mode, not the used mode, In-Reply-To: <200212140138.gBE1c6HA026946@ignucius.axis.se> References: <15866.32849.125398.731160@casey.transmeta.com> <200212140138.gBE1c6HA026946@ignucius.axis.se> X-SW-Source: 2003-q1/txt/msg00021.txt.bz2 When we last left our story, I had proposed this patch and then pointed out that it didn't handle floating point or sets. I'm not sure how to handle floating point other than to defer a decision on how to handle it and flag an error if the size changes for now. So that's what this patch does now. w.r.t. sets: there's various solutions but I think this patch can still go in. I propose checking this in. 2003-01-13 Doug Evans * semantics.scm (-build-operand!): Record operand in its natural mode. (-build-reg-operand!): Ditto. Index: semantics.scm =================================================================== RCS file: /cvs/src/src/cgen/semantics.scm,v retrieving revision 1.2 diff -u -p -r1.2 semantics.scm --- semantics.scm 20 Dec 2002 06:39:04 -0000 1.2 +++ semantics.scm 14 Jan 2003 06:03:55 -0000 @@ -407,8 +407,14 @@ (let* ((mode (mode-real-name (if (eq? mode 'DFLT) (op:mode op) mode))) + ; NUB-MODE is the mode to use to uniquify all the operands. + ; For registers it is the natural mode of the register. + ; For memory it is the mode of the use/set. + (nub-mode (if (register? (op:type op)) + (op:mode op) + mode)) ; The first #f is a placeholder for the object. - (try (list '-op- #f mode op-name #f)) + (try (list '-op- #f nub-mode op-name #f)) (existing-op (-rtx-find-op try op-list))) (if (and (pc? op) @@ -416,23 +422,37 @@ (append! sem-attrs (list (if (tstate-cond? tstate) 'COND-CTI 'UNCOND-CTI)))) - ; If already present, return the object, otherwise add it. - (if existing-op - - (cadr existing-op) - - ; We can't set the operand number yet 'cus we don't know it. - ; However, when it's computed we'll need to set all associated - ; operands. This is done by creating shared rtx (a la gcc) - the - ; operand number then need only be updated in one place. - - (let ((xop (op:new-mode op mode))) - (op:set-cond?! xop (tstate-cond? tstate)) - ; Set the object rtx in `try', now that we have it. - (set-car! (cdr try) (rtx-make 'xop xop)) - ; Add the operand to in/out-ops. - (append! op-list (list try)) - (cadr try)))) + (let ((result-op + ; If already recorded, use it, otherwise add it. + (if existing-op + + (cadr existing-op) + + ; We can't set the operand number yet 'cus we don't know it. + ; However, when it's computed we'll need to set all associated + ; operands. This is done by creating shared rtx (a la gcc) - + ; the operand number then need only be updated in one place. + + (let ((xop (op:new-mode op nub-mode))) + (op:set-cond?! xop (tstate-cond? tstate)) + ; Set the object rtx in `try', now that we have it. + (set-car! (cdr try) (rtx-make 'xop xop)) + ; Add the operand to in/out-ops. + (append! op-list (list try)) + (cadr try))))) + + ; We can't return a mode different than requested. Mixing + ; modes in things like and,add,etc. is illegal. + ; If MODE isn't the nub mode, wrap the operand in a mode change. + ; Not sure how to handle floats so just punt for now and flag an + ; error if the size changes. + (if (mode-compatible? 'samesize mode nub-mode) + result-op + (if (mode-float? (mode:lookup mode)) + (error "floating point operand implicitly referenced in different mode") + (if (mode-bigger? nub-mode mode) + (rtx-make 'trunc mode result-op) + (error "implicit reference of operand in bigger mode")))))) ) ; Subroutine of semantic-compile:process-expr!, to simplify it. @@ -443,28 +463,45 @@ (if hw ; If the mode is DFLT, use the object's natural mode. - (let* ((mode (mode-real-name (if (eq? (rtx-mode expr) 'DFLT) - (obj:name (hw-mode hw)) + (let* (; Always record the register in the operand table using its + ; natural mode. + (nub-mode (obj:name (hw-mode hw))) + (mode (mode-real-name (if (eq? (rtx-mode expr) 'DFLT) + nub-mode (rtx-mode expr)))) (indx-sel (rtx-reg-index-sel expr)) ; #f is a place-holder for the object (filled in later) - (try (list 'reg #f mode hw-name indx-sel)) + (try (list 'reg #f nub-mode hw-name indx-sel)) (existing-op (-rtx-find-op try op-list))) - ; If already present, return the object, otherwise add it. - (if existing-op - - (cadr existing-op) - - (let ((xop (apply reg (cons (tstate->estate tstate) - (cons mode - (cons hw-name indx-sel)))))) - (op:set-cond?! xop (tstate-cond? tstate)) - ; Set the object rtx in `try', now that we have it. - (set-car! (cdr try) (rtx-make 'xop xop)) - ; Add the operand to in/out-ops. - (append! op-list (list try)) - (cadr try)))) + (let ((result-op + ; If already recorded, use it, otherwise add it. + (if existing-op + + (cadr existing-op) + + (let ((xop (apply reg (cons (tstate->estate tstate) + (cons nub-mode + (cons hw-name indx-sel)))))) + (op:set-cond?! xop (tstate-cond? tstate)) + ; Set the object rtx in `try', now that we have it. + (set-car! (cdr try) (rtx-make 'xop xop)) + ; Add the operand to in/out-ops. + (append! op-list (list try)) + (cadr try))))) + + ; We can't return a mode different than requested. Mixing + ; modes in things like and,add,etc. is illegal. + ; If MODE isn't the nub mode, wrap the operand in a mode change. + ; Not sure how to handle floats so just punt for now and flag an + ; error if the size changes. + (if (mode-compatible? 'samesize mode nub-mode) + result-op + (if (mode-float? (mode:lookup mode)) + (error "floating point operand implicitly referenced in different mode") + (if (mode-bigger? nub-mode mode) + (rtx-make 'trunc mode result-op) + (error "implicit reference of operand in bigger mode")))))) (parse-error "FIXME" "unknown reg" expr))) )