From 749a1a4c3c6c1b69a9cf39f821e6121df9dbf432 Mon Sep 17 00:00:00 2001 From: devans Date: Wed, 6 Jan 2010 14:05:13 +0000 Subject: [PATCH] * 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. --- cgen/ChangeLog | 8 ++++++ cgen/mode.scm | 77 +++++++++++++++++++++++++--------------------------------- cgen/rtl-c.scm | 27 +++++++++++--------- 3 files changed, 57 insertions(+), 55 deletions(-) diff --git a/cgen/ChangeLog b/cgen/ChangeLog index b0f6480f5e..0f38dc9267 100644 --- a/cgen/ChangeLog +++ b/cgen/ChangeLog @@ -1,3 +1,11 @@ +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. + 2010-01-04 Doug Evans * gen-all (all_cgen_cpus): Add sh. diff --git a/cgen/mode.scm b/cgen/mode.scm index a0e8a9702e..2a18af86e9 100644 --- a/cgen/mode.scm +++ b/cgen/mode.scm @@ -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) ) diff --git a/cgen/rtl-c.scm b/cgen/rtl-c.scm index 96d3c70af2..44db175a99 100644 --- a/cgen/rtl-c.scm +++ b/cgen/rtl-c.scm @@ -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 -- 2.11.0