From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4451 invoked by alias); 6 Jan 2010 05:06:13 -0000 Received: (qmail 4264 invoked by uid 22791); 6 Jan 2010 05:06:10 -0000 X-SWARE-Spam-Status: No, hits=-0.5 required=5.0 tests=AWL,BAYES_00,DNS_FROM_RFC_BOGUSMX X-Spam-Check-By: sourceware.org Received: from sebabeach.org (HELO sebabeach.org) (64.165.110.50) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 06 Jan 2010 05:06:05 +0000 Received: by sebabeach.org (Postfix, from userid 500) id 505466E3D9; Tue, 5 Jan 2010 21:06:03 -0800 (PST) From: Doug Evans To: cgen@sourceware.org Subject: [commit] fix DI mode shifts in opcodes Message-Id: <20100106050603.505466E3D9@sebabeach.org> Date: Wed, 06 Jan 2010 05:06:00 -0000 X-IsSubscribed: yes Mailing-List: contact cgen-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cgen-owner@sourceware.org X-SW-Source: 2010-q1/txt/msg00002.txt.bz2 Hi. fyi, I checked this in. 2010-01-05 Doug Evans * mode.scm () Rename member non-mode-c-type to c-type. All uses updated. (mode:non-mode-c-type): Delete. (mode:c-type): Update. * rtl-c.scm (s-shop): Fix casting of DI mode values. Index: mode.scm =================================================================== RCS file: /cvs/src/src/cgen/mode.scm,v retrieving revision 1.11 diff -u -p -r1.11 mode.scm --- mode.scm 28 Oct 2009 16:37:33 -0000 1.11 +++ mode.scm 6 Jan 2010 05:04:10 -0000 @@ -1,5 +1,5 @@ ; Mode objects. -; Copyright (C) 2000, 2009 Red Hat, Inc. +; Copyright (C) 2000, 2009, 2010 Red Hat, Inc. ; This file is part of CGEN. ; See file COPYING.CGEN for details. @@ -18,13 +18,9 @@ ; size in bytes bytes - ; NON-MODE-C-TYPE is the C type to use in situations where - ; modes aren't available. A somewhat dubious feature, but at - ; the moment the opcodes tables use it. It is either the C - ; type as a string (e.g. "int") or #f for non-portable modes - ; (??? could use other typedefs for #f, e.g. int64 for DI). - ; Use of GCC can't be assumed though. - non-mode-c-type + ; The C type to use or #f if there is no such C type. + ; This is generally the name of the mode. + c-type ; PRINTF-TYPE is the % arg to printf-like functions, ; however we define our own extensions for non-portable modes. @@ -72,7 +68,7 @@ (define mode:class (elm-make-getter 'class)) (define mode:bits (elm-make-getter 'bits)) (define mode:bytes (elm-make-getter 'bytes)) -(define mode:non-mode-c-type (elm-make-getter 'non-mode-c-type)) +(define mode:c-type (elm-make-getter 'c-type)) (define mode:printf-type (elm-make-getter 'printf-type)) (define mode:sem-mode (elm-make-getter 'sem-mode)) ; ptr-to is currently private so there is no accessor. @@ -87,15 +83,6 @@ *UNSPECIFIED* ) -; Return string C type to use for values of mode M. - -(define (mode:c-type m) - (let ((ptr-to (elm-xget m 'ptr-to))) - (if ptr-to - (string-append (mode:c-type ptr-to) " *") - (obj:str-name m))) -) - ; CM is short for "concat mode". It is a list of modes of the elements ; of a `concat'. ; ??? Experiment. Not currently used. @@ -250,7 +237,7 @@ ; All arguments are in raw (non-evaluated) form. (define (/mode-parse context name comment attrs class bits bytes - non-mode-c-type printf-type sem-mode ptr-to host?) + c-type printf-type sem-mode ptr-to host?) (logit 2 "Processing mode " name " ...\n") ;; Pick out name first to augment the error context. @@ -261,7 +248,7 @@ name (parse-comment context comment) (atlist-parse context attrs "mode") - class bits bytes non-mode-c-type printf-type + class bits bytes c-type printf-type sem-mode ptr-to host?)) ) @@ -271,11 +258,11 @@ ; Define a mode object, all arguments specified. (define (define-full-mode name comment attrs class bits bytes - non-mode-c-type printf-type sem-mode ptr-to host?) + c-type printf-type sem-mode ptr-to host?) (let ((m (/mode-parse (make-current-context "define-full-mode") name comment attrs class bits bytes - non-mode-c-type printf-type sem-mode ptr-to host?))) + c-type printf-type sem-mode ptr-to host?))) ; Add it to the list of insn modes. (mode:add! name m) m) @@ -559,47 +546,47 @@ Define a mode, all arguments specified. (dfm 'VOID "void" '() 'RANDOM 0 0 "void" "" #f #f #f) ; VOIDmode ; Special marker to indicate "use the default mode". - (dfm 'DFLT "default mode" '() 'RANDOM 0 0 "" "" #f #f #f) + (dfm 'DFLT "default mode" '() 'RANDOM 0 0 #f "" #f #f #f) ; Mode used in `symbol' rtxs. - (dfm 'SYM "symbol" '() 'RANDOM 0 0 "" "" #f #f #f) + (dfm 'SYM "symbol" '() 'RANDOM 0 0 #f "" #f #f #f) ; Mode used in `current-insn' rtxs. - (dfm 'INSN "insn" '() 'RANDOM 0 0 "" "" #f #f #f) + (dfm 'INSN "insn" '() 'RANDOM 0 0 #f "" #f #f #f) ; Mode used in `current-mach' rtxs. - (dfm 'MACH "mach" '() 'RANDOM 0 0 "" "" #f #f #f) + (dfm 'MACH "mach" '() 'RANDOM 0 0 #f "" #f #f #f) ; Not UINT on purpose. - (dfm 'BI "one bit (0,1 not 0,-1)" '() 'INT 1 1 "int" "'x'" #f #f #f) + (dfm 'BI "one bit (0,1 not 0,-1)" '() 'INT 1 1 "BI" "'x'" #f #f #f) - (dfm 'QI "8 bit byte" '() 'INT 8 1 "int" "'x'" #f #f #f) - (dfm 'HI "16 bit int" '() 'INT 16 2 "int" "'x'" #f #f #f) - (dfm 'SI "32 bit int" '() 'INT 32 4 "int" "'x'" #f #f #f) - (dfm 'DI "64 bit int" '(FN-SUPPORT) 'INT 64 8 "" "'D'" #f #f #f) + (dfm 'QI "8 bit byte" '() 'INT 8 1 "QI" "'x'" #f #f #f) + (dfm 'HI "16 bit int" '() 'INT 16 2 "HI" "'x'" #f #f #f) + (dfm 'SI "32 bit int" '() 'INT 32 4 "SI" "'x'" #f #f #f) + (dfm 'DI "64 bit int" '(FN-SUPPORT) 'INT 64 8 "DI" "'D'" #f #f #f) ; No unsigned versions on purpose for now. - (dfm 'TI "128 bit int" '(FN-SUPPORT) 'INT 128 16 "" "'T'" #f #f #f) - (dfm 'OI "256 bit int" '(FN-SUPPORT) 'INT 256 32 "" "'O'" #f #f #f) + (dfm 'TI "128 bit int" '(FN-SUPPORT) 'INT 128 16 "TI" "'T'" #f #f #f) + (dfm 'OI "256 bit int" '(FN-SUPPORT) 'INT 256 32 "OI" "'O'" #f #f #f) (dfm 'UQI "8 bit unsigned byte" '() 'UINT - 8 1 "unsigned int" "'x'" (mode:lookup 'QI) #f #f) + 8 1 "UQI" "'x'" (mode:lookup 'QI) #f #f) (dfm 'UHI "16 bit unsigned int" '() 'UINT - 16 2 "unsigned int" "'x'" (mode:lookup 'HI) #f #f) + 16 2 "UHI" "'x'" (mode:lookup 'HI) #f #f) (dfm 'USI "32 bit unsigned int" '() 'UINT - 32 4 "unsigned int" "'x'" (mode:lookup 'SI) #f #f) + 32 4 "USI" "'x'" (mode:lookup 'SI) #f #f) (dfm 'UDI "64 bit unsigned int" '(FN-SUPPORT) 'UINT - 64 8 "" "'D'" (mode:lookup 'DI) #f #f) + 64 8 "UDI" "'D'" (mode:lookup 'DI) #f #f) ; Floating point values. (dfm 'SF "32 bit float" '(FN-SUPPORT) 'FLOAT - 32 4 "" "'f'" #f #f #f) + 32 4 "SF" "'f'" #f #f #f) (dfm 'DF "64 bit float" '(FN-SUPPORT) 'FLOAT - 64 8 "" "'f'" #f #f #f) + 64 8 "DF" "'f'" #f #f #f) (dfm 'XF "80/96 bit float" '(FN-SUPPORT) 'FLOAT - 96 12 "" "'F'" #f #f #f) + 96 12 "XF" "'F'" #f #f #f) (dfm 'TF "128 bit float" '(FN-SUPPORT) 'FLOAT - 128 16 "" "'F'" #f #f #f) + 128 16 "TF" "'F'" #f #f #f) ; These are useful modes that represent host values. ; For INT/UINT the sizes indicate maximum portable values. @@ -607,13 +594,15 @@ Define a mode, all arguments specified. ; and registers). ; FIXME: Can't be used to represent both host and target values. ; Either remove the distinction or add new modes with the distinction. - (dfm 'INT "portable int" '() 'INT 32 4 "int" "'x'" + ; FIXME: IWBN to specify #f for sem-mode, but that means we'd need + ; TRUNCINTQI,etc. + (dfm 'INT "portable int" '() 'INT 32 4 "INT" "'x'" (mode:lookup 'SI) #f #t) - (dfm 'UINT "portable unsigned int" '() 'UINT 32 4 "unsigned int" "'x'" + (dfm 'UINT "portable unsigned int" '() 'UINT 32 4 "UINT" "'x'" (mode:lookup 'SI) #f #t) ; ??? Experimental. - (dfm 'PTR "host pointer" '() 'RANDOM 0 0 "PTR" "'x'" + (dfm 'PTR "host pointer" '() 'RANDOM 0 0 "void*" "'x'" #f (mode:lookup 'VOID) #t) ) Index: rtl-c.scm =================================================================== RCS file: /cvs/src/src/cgen/rtl-c.scm,v retrieving revision 1.28 diff -u -p -r1.28 rtl-c.scm --- rtl-c.scm 23 Nov 2009 00:44:48 -0000 1.28 +++ rtl-c.scm 6 Jan 2010 05:04:11 -0000 @@ -1,5 +1,5 @@ ; RTL->C translation support. -; Copyright (C) 2000, 2005, 2009 Red Hat, Inc. +; Copyright (C) 2000, 2005, 2009, 2010 Red Hat, Inc. ; This file is part of CGEN. ; See file COPYING.CGEN for details. @@ -778,18 +778,23 @@ (cx:c val2) ")")) (cx:make mode ; not sem-mode on purpose (string-append "(" - ; Ensure correct sign of shift. + ;; Ensure correct sign of shift. (cond ((equal? name "SRL") - (string-append "(" - (if (eq? (mode:class mode) 'UINT) - "" - "unsigned ") - (mode:non-mode-c-type mode) - ") ")) + (string-append + "(" + (cond ((mode-unsigned? mode) (mode:c-type mode)) + ((mode:eq? mode 'INT) (mode:c-type UINT)) + (else (mode:c-type (mode-find (mode:bits mode) 'UINT)))) + ") ")) ((equal? name "SRA") - (string-append "(" - (mode:non-mode-c-type mode) - ") ")) + (string-append + "(" + (cond ((mode-signed? mode) (mode:c-type mode)) + ((mode:eq? mode 'UINT) (mode:c-type INT)) + (else (mode:c-type (mode-find (mode:bits mode) 'INT)))) + ") ")) + ;; May wish to make this unsigned if not + ;; already. Later. (else "")) "(" (cx:c val1) ") " c-op