This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [tree-ssa] PATCH to gimplification of ASM_EXPR
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 06 Jun 2003 13:01:45 -0400
- Subject: Re: [tree-ssa] PATCH to gimplification of ASM_EXPR
- References: <wvl65njmc6d.fsf@prospero.boston.redhat.com>
I'm also applying this subset of the patch to the trunk. Tested
x86_64-pc-linux-gnu.
2003-06-06 Jason Merrill <jason@redhat.com>
* stmt.c (resolve_asm_operand_names): Rename from
resolve_operand_names. No longer static. Avoid needless copying.
Don't build array of constraints.
(expand_asm_operands): Build it here.
* tree.h: Declare resolve_asm_operand_names.
* stmt.c (expand_decl): Put artificial vars into registers even
when not optimizing, and don't mark the regs as user vars.
Index: stmt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/stmt.c,v
retrieving revision 1.302
diff -c -p -r1.302 stmt.c
*** stmt.c 8 May 2003 17:09:09 -0000 1.302
--- stmt.c 6 Jun 2003 17:01:25 -0000
*************** static void fixup_gotos PARAMS ((struc
*** 404,411 ****
rtx, int));
static bool check_operand_nalternatives PARAMS ((tree, tree));
static bool check_unique_operand_names PARAMS ((tree, tree));
- static tree resolve_operand_names PARAMS ((tree, tree, tree,
- const char **));
static char *resolve_operand_name_1 PARAMS ((char *, tree, tree));
static void expand_null_return_1 PARAMS ((rtx));
static enum br_predictor return_prediction PARAMS ((rtx));
--- 404,409 ----
*************** expand_asm_operands (string, outputs, in
*** 1517,1522 ****
--- 1515,1521 ----
HARD_REG_SET clobbered_regs;
int clobber_conflict_found = 0;
tree tail;
+ tree t;
int i;
/* Vector of RTX's of evaluated output operands. */
rtx *output_rtx = (rtx *) alloca (noutputs * sizeof (rtx));
*************** expand_asm_operands (string, outputs, in
*** 1538,1544 ****
if (! check_unique_operand_names (outputs, inputs))
return;
! string = resolve_operand_names (string, outputs, inputs, constraints);
#ifdef MD_ASM_CLOBBERS
/* Sometimes we wish to automatically clobber registers across an asm.
--- 1537,1550 ----
if (! check_unique_operand_names (outputs, inputs))
return;
! string = resolve_asm_operand_names (string, outputs, inputs);
!
! /* Collect constraints. */
! i = 0;
! for (t = outputs; t ; t = TREE_CHAIN (t), i++)
! constraints[i] = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (t)));
! for (t = inputs; t ; t = TREE_CHAIN (t), i++)
! constraints[i] = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (t)));
#ifdef MD_ASM_CLOBBERS
/* Sometimes we wish to automatically clobber registers across an asm.
*************** check_unique_operand_names (outputs, inp
*** 2032,2052 ****
in *POUTPUTS and *PINPUTS to numbers, and replace the name expansions in
STRING and in the constraints to those numbers. */
! static tree
! resolve_operand_names (string, outputs, inputs, pconstraints)
! tree string;
! tree outputs, inputs;
! const char **pconstraints;
{
! char *buffer = xstrdup (TREE_STRING_POINTER (string));
char *p;
tree t;
/* Assume that we will not need extra space to perform the substitution.
This because we get to remove '[' and ']', which means we cannot have
a problem until we have more than 999 operands. */
! p = buffer;
while ((p = strchr (p, '%')) != NULL)
{
if (p[1] == '[')
--- 2038,2074 ----
in *POUTPUTS and *PINPUTS to numbers, and replace the name expansions in
STRING and in the constraints to those numbers. */
! tree
! resolve_asm_operand_names (tree string, tree outputs, tree inputs)
{
! char *buffer;
char *p;
tree t;
+ /* Substitute [<name>] in input constraint strings. There should be no
+ named operands in output constraints. */
+ for (t = inputs; t ; t = TREE_CHAIN (t))
+ {
+ const char *c = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (t)));
+ if (strchr (c, '[') != NULL)
+ {
+ p = buffer = xstrdup (c);
+ while ((p = strchr (p, '[')) != NULL)
+ p = resolve_operand_name_1 (p, outputs, inputs);
+ TREE_VALUE (TREE_PURPOSE (t))
+ = build_string (strlen (buffer), buffer);
+ free (buffer);
+ }
+ }
+
+ if (strchr (TREE_STRING_POINTER (string), '[') == NULL)
+ return string;
+
/* Assume that we will not need extra space to perform the substitution.
This because we get to remove '[' and ']', which means we cannot have
a problem until we have more than 999 operands. */
! p = buffer = xstrdup (TREE_STRING_POINTER (string));
while ((p = strchr (p, '%')) != NULL)
{
if (p[1] == '[')
*************** resolve_operand_names (string, outputs,
*** 2065,2093 ****
string = build_string (strlen (buffer), buffer);
free (buffer);
- /* Collect output constraints here because it's convenient.
- There should be no named operands here; this is verified
- in expand_asm_operand. */
- for (t = outputs; t ; t = TREE_CHAIN (t), pconstraints++)
- *pconstraints = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (t)));
-
- /* Substitute [<name>] in input constraint strings. */
- for (t = inputs; t ; t = TREE_CHAIN (t), pconstraints++)
- {
- const char *c = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (t)));
- if (strchr (c, '[') == NULL)
- *pconstraints = c;
- else
- {
- p = buffer = xstrdup (c);
- while ((p = strchr (p, '[')) != NULL)
- p = resolve_operand_name_1 (p, outputs, inputs);
-
- *pconstraints = ggc_alloc_string (buffer, -1);
- free (buffer);
- }
- }
-
return string;
}
--- 2087,2092 ----
*************** expand_decl (decl)
*** 3940,3946 ****
&& TREE_CODE (type) == REAL_TYPE)
&& ! TREE_THIS_VOLATILE (decl)
&& ! DECL_NONLOCAL (decl)
! && (DECL_REGISTER (decl) || optimize))
{
/* Automatic variable that can go in a register. */
int unsignedp = TREE_UNSIGNED (type);
--- 3939,3945 ----
&& TREE_CODE (type) == REAL_TYPE)
&& ! TREE_THIS_VOLATILE (decl)
&& ! DECL_NONLOCAL (decl)
! && (DECL_REGISTER (decl) || DECL_ARTIFICIAL (decl) || optimize))
{
/* Automatic variable that can go in a register. */
int unsignedp = TREE_UNSIGNED (type);
*************** expand_decl (decl)
*** 3949,3955 ****
SET_DECL_RTL (decl, gen_reg_rtx (reg_mode));
! mark_user_reg (DECL_RTL (decl));
if (POINTER_TYPE_P (type))
mark_reg_pointer (DECL_RTL (decl),
--- 3948,3955 ----
SET_DECL_RTL (decl, gen_reg_rtx (reg_mode));
! if (!DECL_ARTIFICIAL (decl))
! mark_user_reg (DECL_RTL (decl));
if (POINTER_TYPE_P (type))
mark_reg_pointer (DECL_RTL (decl),
Index: tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.406
diff -c -p -r1.406 tree.h
*** tree.h 27 May 2003 22:53:01 -0000 1.406
--- tree.h 6 Jun 2003 17:01:26 -0000
*************** extern bool parse_output_constraint
*** 2920,2925 ****
--- 2920,2926 ----
bool *, bool *, bool *));
extern void expand_asm_operands PARAMS ((tree, tree, tree, tree, int,
const char *, int));
+ extern tree resolve_asm_operand_names (tree, tree, tree);
extern int any_pending_cleanups PARAMS ((int));
extern void init_stmt_for_function PARAMS ((void));
extern void expand_start_target_temps PARAMS ((void));