Commit 9a5834ae by Zack Weinberg Committed by Zack Weinberg

gensupport.c (n_comma_elts): Moved here from genattrtab.c.

	* gensupport.c (n_comma_elts): Moved here from genattrtab.c.
	(scan_comma_elt): New function.  Accepts whitespace in comma lists.
	* gensupport.h: Prototype new routines.
	* genattr.c (gen_attr): Use scan_comma_elt.  Avoid unnecessary
	use of printf.
	* genattrtab.c (n_comma_elts): Moved to gensupport.c.
	(next_comma_elt): Use scan_comma_elt.

	* config/i386/i386.md: Use new attribute notation to break up
	long lines in define_attr forms.

From-SVN: r53403
parent 0d08ea48
2002-05-12 Zack Weinberg <zack@codesourcery.com>
* gensupport.c (n_comma_elts): Moved here from genattrtab.c.
(scan_comma_elt): New function. Accepts whitespace in comma lists.
* gensupport.h: Prototype new routines.
* genattr.c (gen_attr): Use scan_comma_elt. Avoid unnecessary
use of printf.
* genattrtab.c (n_comma_elts): Moved to gensupport.c.
(next_comma_elt): Use scan_comma_elt.
* config/i386/i386.md: Use new attribute notation to break up
long lines in define_attr forms.
2002-05-12 Richard Henderson <rth@redhat.com> 2002-05-12 Richard Henderson <rth@redhat.com>
* expr.c (compress_float_constant): New. * expr.c (compress_float_constant): New.
......
...@@ -123,20 +123,31 @@ ...@@ -123,20 +123,31 @@
;; A basic instruction type. Refinements due to arguments to be ;; A basic instruction type. Refinements due to arguments to be
;; provided in other attributes. ;; provided in other attributes.
(define_attr "type" (define_attr "type"
"other,multi,alu1,negnot,alu,icmp,test,imov,imovx,lea,incdec,ishift,rotate,imul,idiv,ibr,setcc,push,pop,call,callv,icmov,fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,str,cld,sse,sseadd,ssemul,ssediv,ssemov,ssecmp,ssecvt,sselog,sseiadd,sseishft,sseimul,mmx,mmxmov,mmxadd,mmxshft,mmxcmp,mmxcvt,mmxmul,fistp" "other,multi,
alu,alu1,negnot,imov,imovx,lea,
incdec,ishift,rotate,imul,idiv,
icmp,test,ibr,setcc,icmov,
push,pop,call,callv,
str,cld,
fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,
sselog,sseiadd,sseishft,sseimul,
sse,ssemov,sseadd,ssemul,ssecmp,ssecvt,ssediv,
mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft"
(const_string "other")) (const_string "other"))
;; Main data type used by the insn ;; Main data type used by the insn
(define_attr "mode" "unknown,none,QI,HI,SI,DI,unknownfp,SF,DF,XF,TI,V4SF,V2DF,V2SF" (define_attr "mode"
"unknown,none,QI,HI,SI,DI,unknownfp,SF,DF,XF,TI,V4SF,V2DF,V2SF"
(const_string "unknown")) (const_string "unknown"))
;; The CPU unit operations uses. ;; The CPU unit operations uses.
(define_attr "unit" "integer,i387,sse,mmx,unknown" (define_attr "unit" "integer,i387,sse,mmx,unknown"
(cond [(eq_attr "type" "fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp") (cond [(eq_attr "type" "fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp")
(const_string "i387") (const_string "i387")
(eq_attr "type" "sse,sseadd,ssemul,ssediv,ssemov,ssecmp,ssecvt,sselog,sseiadd,sseishft,sseimul") (eq_attr "type" "sselog,sseiadd,sseishft,sseimul,
sse,ssemov,sseadd,ssemul,ssecmp,ssecvt,ssediv")
(const_string "sse") (const_string "sse")
(eq_attr "type" "mmx,mmxmov,mmxadd,mmxshft,mmxcmp,mmxcvt,mmxmul") (eq_attr "type" "mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft")
(const_string "mmx")] (const_string "mmx")]
(const_string "integer"))) (const_string "integer")))
...@@ -146,7 +157,8 @@ ...@@ -146,7 +157,8 @@
(const_int 0) (const_int 0)
(eq_attr "unit" "i387,sse,mmx") (eq_attr "unit" "i387,sse,mmx")
(const_int 0) (const_int 0)
(eq_attr "type" "alu1,negnot,alu,icmp,imovx,ishift,rotate,imul,push,pop") (eq_attr "type" "alu,alu1,negnot,imovx,ishift,rotate,imul,
icmp,push,pop")
(symbol_ref "ix86_attr_length_immediate_default(insn,1)") (symbol_ref "ix86_attr_length_immediate_default(insn,1)")
(eq_attr "type" "imov,test") (eq_attr "type" "imov,test")
(symbol_ref "ix86_attr_length_immediate_default(insn,0)") (symbol_ref "ix86_attr_length_immediate_default(insn,0)")
...@@ -166,7 +178,8 @@ ...@@ -166,7 +178,8 @@
(const_int 1) (const_int 1)
(const_int 4)) (const_int 4))
] ]
(symbol_ref "/* Update immediate_length and other attributes! */ abort(),1"))) (symbol_ref "/* Update immediate_length and other attributes! */
abort(),1")))
;; The (bounding maximum) length of an instruction address. ;; The (bounding maximum) length of an instruction address.
(define_attr "length_address" "" (define_attr "length_address" ""
...@@ -196,7 +209,12 @@ ...@@ -196,7 +209,12 @@
;; Set when 0f opcode prefix is used. ;; Set when 0f opcode prefix is used.
(define_attr "prefix_0f" "" (define_attr "prefix_0f" ""
(if_then_else (eq_attr "type" "imovx,setcc,icmov,sse,sseadd,ssemul,ssediv,ssemov,ssecmp,ssecvt,sselog,sseiadd,sseishft,sseimul,mmx,mmxmov,mmxadd,mmxshft,mmxcmp,mmxcvt,mmxmul") (if_then_else
(eq_attr "type"
"imovx,setcc,icmov,
sselog,sseiadd,sseishft,sseimul,
sse,ssemov,sseadd,ssemul,ssecmp,ssecvt,ssediv,
mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft")
(const_int 1) (const_int 1)
(const_int 0))) (const_int 0)))
...@@ -287,7 +305,12 @@ ...@@ -287,7 +305,12 @@
(const_string "store") (const_string "store")
(match_operand 1 "memory_operand" "") (match_operand 1 "memory_operand" "")
(const_string "load") (const_string "load")
(and (eq_attr "type" "!icmp,test,alu1,negnot,fsgn,imov,imovx,fmov,fcmp,sse,ssecmp,mmx,ssemov,mmxmov,ssecvt,mmxcvt,mmxcmp") (and (eq_attr "type"
"!alu1,negnot,
imov,imovx,icmp,test,
fmov,fcmp,fsgn,
sse,ssemov,ssecmp,ssecvt,
mmx,mmxmov,mmxcmp,mmxcvt")
(match_operand 2 "memory_operand" "")) (match_operand 2 "memory_operand" ""))
(const_string "load") (const_string "load")
(and (eq_attr "type" "icmov") (and (eq_attr "type" "icmov")
......
...@@ -86,34 +86,30 @@ static void ...@@ -86,34 +86,30 @@ static void
gen_attr (attr) gen_attr (attr)
rtx attr; rtx attr;
{ {
const char *p; const char *p, *tag;
int is_const = GET_CODE (XEXP (attr, 2)) == CONST; int is_const = GET_CODE (XEXP (attr, 2)) == CONST;
printf ("#define HAVE_ATTR_%s\n", XSTR (attr, 0)); printf ("#define HAVE_ATTR_%s\n", XSTR (attr, 0));
/* If numeric attribute, don't need to write an enum. */ /* If numeric attribute, don't need to write an enum. */
if (*XSTR (attr, 1) == '\0') p = XSTR (attr, 1);
if (*p == '\0')
printf ("extern int get_attr_%s PARAMS ((%s));\n", XSTR (attr, 0), printf ("extern int get_attr_%s PARAMS ((%s));\n", XSTR (attr, 0),
(is_const ? "void" : "rtx")); (is_const ? "void" : "rtx"));
else else
{ {
printf ("enum attr_%s {", XSTR (attr, 0)); printf ("enum attr_%s {", XSTR (attr, 0));
write_upcase (XSTR (attr, 0));
printf ("_");
for (p = XSTR (attr, 1); *p != '\0'; p++) while ((tag = scan_comma_elt (&p)) != 0)
{ {
if (*p == ',') write_upcase (XSTR (attr, 0));
{ putchar ('_');
printf (", "); while (tag != p)
write_upcase (XSTR (attr, 0)); putchar (TOUPPER (*tag++));
printf ("_"); fputs (", ", stdout);
}
else
putchar (TOUPPER(*p));
} }
printf ("};\n"); fputs ("};\n", stdout);
printf ("extern enum attr_%s get_attr_%s PARAMS ((%s));\n\n", printf ("extern enum attr_%s get_attr_%s PARAMS ((%s));\n\n",
XSTR (attr, 0), XSTR (attr, 0), (is_const ? "void" : "rtx")); XSTR (attr, 0), XSTR (attr, 0), (is_const ? "void" : "rtx"));
} }
...@@ -122,11 +118,12 @@ gen_attr (attr) ...@@ -122,11 +118,12 @@ gen_attr (attr)
variables used by `insn_current_length'. */ variables used by `insn_current_length'. */
if (! strcmp (XSTR (attr, 0), "length")) if (! strcmp (XSTR (attr, 0), "length"))
{ {
printf ("extern void shorten_branches PARAMS ((rtx));\n"); puts ("\
printf ("extern int insn_default_length PARAMS ((rtx));\n"); extern void shorten_branches PARAMS ((rtx));\n\
printf ("extern int insn_variable_length_p PARAMS ((rtx));\n"); extern int insn_default_length PARAMS ((rtx));\n\
printf ("extern int insn_current_length PARAMS ((rtx));\n\n"); extern int insn_variable_length_p PARAMS ((rtx));\n\
printf ("#include \"insn-addr.h\"\n\n"); extern int insn_current_length PARAMS ((rtx));\n\n\
#include \"insn-addr.h\"\n");
} }
} }
......
...@@ -456,7 +456,6 @@ static void write_complex_function PARAMS ((struct function_unit *, const char * ...@@ -456,7 +456,6 @@ static void write_complex_function PARAMS ((struct function_unit *, const char *
static int write_expr_attr_cache PARAMS ((rtx, struct attr_desc *)); static int write_expr_attr_cache PARAMS ((rtx, struct attr_desc *));
static void write_toplevel_expr PARAMS ((rtx)); static void write_toplevel_expr PARAMS ((rtx));
static void write_const_num_delay_slots PARAMS ((void)); static void write_const_num_delay_slots PARAMS ((void));
static int n_comma_elts PARAMS ((const char *));
static char *next_comma_elt PARAMS ((const char **)); static char *next_comma_elt PARAMS ((const char **));
static struct attr_desc *find_attr PARAMS ((const char *, int)); static struct attr_desc *find_attr PARAMS ((const char *, int));
static struct attr_value *find_most_used PARAMS ((struct attr_desc *)); static struct attr_value *find_most_used PARAMS ((struct attr_desc *));
...@@ -5793,25 +5792,6 @@ write_complex_function (unit, name, connection) ...@@ -5793,25 +5792,6 @@ write_complex_function (unit, name, connection)
/* This page contains miscellaneous utility routines. */ /* This page contains miscellaneous utility routines. */
/* Given a string, return the number of comma-separated elements in it.
Return 0 for the null string. */
static int
n_comma_elts (s)
const char *s;
{
int n;
if (*s == '\0')
return 0;
for (n = 1; *s; s++)
if (*s == ',')
n++;
return n;
}
/* Given a pointer to a (char *), return a malloc'ed string containing the /* Given a pointer to a (char *), return a malloc'ed string containing the
next comma-separated element. Advance the pointer to after the string next comma-separated element. Advance the pointer to after the string
scanned, or the end-of-string. Return NULL if at end of string. */ scanned, or the end-of-string. Return NULL if at end of string. */
...@@ -5820,23 +5800,14 @@ static char * ...@@ -5820,23 +5800,14 @@ static char *
next_comma_elt (pstr) next_comma_elt (pstr)
const char **pstr; const char **pstr;
{ {
char *out_str; const char *start;
const char *p;
if (**pstr == '\0')
return NULL;
/* Find end of string to compute length. */
for (p = *pstr; *p != ',' && *p != '\0'; p++)
;
out_str = attr_string (*pstr, p - *pstr); start = scan_comma_elt (pstr);
*pstr = p;
if (**pstr == ',') if (start == NULL)
(*pstr)++; return NULL;
return out_str; return attr_string (start, *pstr - start);
} }
/* Return a `struct attr_desc' pointer for a given named attribute. If CREATE /* Return a `struct attr_desc' pointer for a given named attribute. If CREATE
......
/* Support routines for the various generation passes. /* Support routines for the various generation passes.
Copyright (C) 2000, 2001 Free Software Foundation, Inc. Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of GCC. This file is part of GCC.
...@@ -1099,3 +1099,51 @@ read_md_rtx (lineno, seqnr) ...@@ -1099,3 +1099,51 @@ read_md_rtx (lineno, seqnr)
return desc; return desc;
} }
/* Given a string, return the number of comma-separated elements in it.
Return 0 for the null string. */
int
n_comma_elts (s)
const char *s;
{
int n;
if (*s == '\0')
return 0;
for (n = 1; *s; s++)
if (*s == ',')
n++;
return n;
}
/* Given a pointer to a (char *), return a pointer to the beginning of the
next comma-separated element in the string. Advance the pointer given
to the end of that element. Return NULL if at end of string. Caller
is responsible for copying the string if necessary. White space between
a comma and an element is ignored. */
const char *
scan_comma_elt (pstr)
const char **pstr;
{
const char *start;
const char *p = *pstr;
if (*p == ',')
p++;
while (ISSPACE(*p))
p++;
if (*p == '\0')
return NULL;
start = p;
while (*p != ',' && *p != '\0')
p++;
*pstr = p;
return start;
}
/* Declarations for rtx-reader support for gen* routines. /* Declarations for rtx-reader support for gen* routines.
Copyright (C) 2000 Free Software Foundation, Inc. Copyright (C) 2000, 2002 Free Software Foundation, Inc.
This file is part of GCC. This file is part of GCC.
...@@ -27,3 +27,7 @@ extern rtx read_md_rtx PARAMS ((int *, int *)); ...@@ -27,3 +27,7 @@ extern rtx read_md_rtx PARAMS ((int *, int *));
extern void message_with_line PARAMS ((int, const char *, ...)) extern void message_with_line PARAMS ((int, const char *, ...))
ATTRIBUTE_PRINTF_2; ATTRIBUTE_PRINTF_2;
extern int n_comma_elts PARAMS ((const char *));
extern const char *scan_comma_elt PARAMS ((const char **));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment