[PATCH] MIPS: Fix __sync_nand for changed semantics.

Richard Sandiford rdsandiford@googlemail.com
Sat Dec 6 17:14:00 GMT 2008


David Daney <ddaney@caviumnetworks.com> writes:
> Index: config/mips/mips.h
> ===================================================================
> --- config/mips/mips.h	(revision 142423)
> +++ config/mips/mips.h	(working copy)
> @@ -3183,24 +3183,23 @@ while (0)
>  
>       - Uses scratch register %4.
>  
> -    NOT_OP are the optional instructions to do a bit-wise not
> -    operation in conjunction with an AND INSN to generate a sync_nand
> -    operation.  */
> -#define MIPS_SYNC_OP_12(INSN, NOT_OP)		\
> +    AND_OP are the instructions done after the INSN to mask the INSN's
> +    result with the mask.  In the case of the sync_nand operation, it
> +    also does the bit-wise not that is required after the AND INSN.  */
> +#define MIPS_SYNC_OP_12(INSN, AND_OP)		\
>    "%(%<%[%|sync\n"				\
>    "1:\tll\t%4,%0\n"				\
>    "\tand\t%@,%4,%2\n"				\
> -  NOT_OP					\
>    "\t" INSN "\t%4,%4,%z3\n"			\
> -  "\tand\t%4,%4,%1\n"				\
> +  AND_OP					\
>    "\tor\t%@,%@,%4\n"				\
>    "\tsc\t%@,%0\n"				\
>    "\tbeq%?\t%@,%.,1b\n"				\
>    "\tnop\n"					\
>    "\tsync%-%]%>%)"
>  
> -#define MIPS_SYNC_OP_12_NOT_NOP ""
> -#define MIPS_SYNC_OP_12_NOT_NOT "\tnor\t%4,%4,%.\n"
> +#define MIPS_SYNC_OP_12_NOT_NOP "\tand\t%4,%4,%1\n"
> +#define MIPS_SYNC_OP_12_NOT_NOT "\txor\t%4,%4,%1\n"

These names seem a bit confusing in the new context.  *_NOT_* made
sense when we were passing to a NOP_OP parameter, but now we're
passing to an AND_OP parameter.  Maybe:

  s/NOT_NOP/AND/
  s/NOT_NOT/XOR/

would be better.

> @@ -3347,11 +3339,12 @@ while (0)
>  #define MIPS_SYNC_NEW_NAND(SUFFIX, INSN)	\
>    "%(%<%[%|sync\n"				\
>    "1:\tll" SUFFIX "\t%0,%1\n"			\
> -  "\tnor\t%0,%0,%.\n"				\
>    "\t" INSN "\t%@,%0,%2\n"			\
> +  "\tnor\t%@,%@,%.\n"				\
> +  "\tmove\t%0,%@\n"				\
>    "\tsc" SUFFIX "\t%@,%1\n"			\
>    "\tbeq%?\t%@,%.,1b%~\n"			\
> -  "\t" INSN "\t%0,%0,%2\n"			\
> +  "\tnop\n"					\
>    "\tsync%-%]%>%)"
>  
>  /* Return an asm string that atomically:

Couldn't this be:

   "%(%<%[%|sync\n"				\
   "1:\tll" SUFFIX "\t%0,%1\n"			\
-  "\tnor\t%0,%0,%.\n"				\
-  "\t" INSN "\t%@,%0,%2\n"			\
+  "\t" INSN "\t%0,%0,%2\n"			\
+  "\tnor\t%@,%0,%.\n"				\
   "\tsc" SUFFIX "\t%@,%1\n"			\
   "\tbeq%?\t%@,%.,1b%~\n"			\
-  "\t" INSN "\t%0,%0,%2\n"			\
+  "\tnor\t%0,%0,%.\n"				\
   "\tsync%-%]%>%)"

?

Richard



More information about the Gcc-patches mailing list