This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: Implement more MIPS QI andHI atomic memory operations.


David Daney <ddaney@avtrex.com> writes:
> Q1: Is is ok to pass a union of function pointers to the expander?

Should be.  I'm not sure it adds all that much type safety over
and above a simple "rtx (*fn) ()" though.  (That's what we use
for optabs.)

> Q2:  Should all the atomic insns be put in a seperate sync.md as they
> are for several other targets (sparc, i386...)?

I'm fine with that.  FWIW, I was thinking of splitting mips.md up
at some point, once I've got more important things out of the way.
It might be good to put constants into their own file, iterators
into their own file, and so on.

So, feel free to do this now if you want, but I'll get to it
eventually if not.

> Q3: What is the namespace of the unspec_volatile numbers?  Or: when and
> why do I have to define new numbers?

You only really need a new number if the patterns would otherwise
conflict, but for clarity, I think the UNSPEC_FOO/UNSPEC_FOO_12
split you did for compare-and-swap is the right way to go.

> Q4: Is there a better way to accomplish this?

The patch looks good to me.  I'm just a bit worried about the
proliferation of asm templates in mips.h.

I suppose we could at least avoid duplicating code for FOO_12 and
FOO_12_0.  E.g.:

#define MIPS_COMPARE_AND_SWAP_12(NONZERO_OPS)	\
  "%(%<%[%|sync\n"				\
  "1:\tll\t%0,%1\n"				\
  "\tand\t%@,%0,%2\n"				\
  "\tbne\t%@,%z4,2f\n"				\
  "\tand\t%@,%0,%3\n"				\
  NONZERO_OPS					\
  "\tsc\t%@,%1\n"				\
  "\tbeq\t%@,%.,1b\n"				\
  "\tnop\n"					\
  "\tsync%-%]%>%)\n"				\
  "2:\n"

#define MIPS_SYNC_EXCHANGE_12(NONZERO_OPS)	\
  "%(%<%[%|sync\n"				\
  "1:\tll\t%0,%1\n"				\
  "\tand\t%@,%0,%2\n"				\
  NONZERO_OPS					\
  "\tsc\t%@,%1\n"				\
  "\tbeq\t%@,%.,1b\n"				\
  "\tnop\n"					\
  "\tsync%-%]%>%)"
...
  if (operands[5] == const0_rtx)
    return MIPS_COMPARE_AND_SWAP_12 ("");
  else
    return MIPS_COMPARE_AND_SWAP_12 ("\tor\t%@,%@,%5\n");
...
  if (operands[3] == const0_rtx)
    return MIPS_SYNC_EXCHANGE_12 ("")
  else
    return MIPS_SYNC_EXCHANGE_12 ("\tor\t%@,%@,%3\n")

Perhaps we could go one step further and have a common macro
that is used as a convenience macro for all three specific macros
(native width, FOO_12 and FOO_12_0).

There again, I suppose many of the other ops won't have a FOO_12_0 form.

Richard


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]