public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: An x86 patch for egcs
       [not found] ` <smtp.earthlink.net>
@ 1998-03-13 18:47 Mark Mitchell
       [not found] ` <smtp.earthlink.net>
  4 siblings, 1 reply; 10+ messages in thread
From: Mark Mitchell @ 1998-03-13 18:47 UTC (permalink / raw)
  To: hjl; +Cc: egcs

    Hi,

    This is a partial patch for the PPro bug I reported. It fixed
    loading standard x87 constants in conditional move. But it still
    leaves an undefined label in one of my test cases. My other test
    case still doesn't compile.

    Thanks.


This is not a commentary on the contents of this patch, merely its
form.  I object strongly to the kind of code-duplication in your
patch.  It appears to me that you replaced each of several similar
pieces of code with some large block of code which is also similar.  I
hope that you did this only because you weren't quite finished with
the patch, and wanted someone to help resolve the remaining problems.

This kind of code duplication is a pet peeve of mine; it makes it much
harder to maintain software, especially software as complex as gcc.
In general, if you had to change something in several places, then
there should have been some kind of abstraction (e.g. a macro or a
function) that would have allowed you to change something in only one
place.  That might be the fault of the previous author, but it's up to
us, the current authors, to correct these defects.

I hereby encourage the maintainers to reject patches that contain
unnecessary duplication, including mine.

    -- 
    H.J. Lu (hjl@gnu.org)
    --
    Thu Mar 12 08:25:19 1998  H.J. Lu  (hjl@gnu.org)

	    * config/i386/i386.md (movsfcc_1, movdfcc_1, movxfcc_1): Handle
	    loading standard x87 constants.

    Index: config/i386/i386.md
    ===================================================================
    RCS file: /home/work/cvs/gnu/egcs/gcc/config/i386/i386.md,v
    retrieving revision 1.1.1.8
    diff -u -r1.1.1.8 i386.md
    --- i386.md	1998/03/12 17:19:11	1.1.1.8
    +++ i386.md	1998/03/13 00:12:40
    @@ -7528,8 +7529,21 @@
	    output_asm_insn (AS1 (fld%z2,%y2), operands);
	   else
	     {
    -	  operands[2] = XEXP (operands[2], 0);
    -	  output_asm_insn (AS1 (fld%z2,%y2), operands);
    +	  int conval = standard_80387_constant_p (operands[2]);
    +
    +	  switch (conval)
    +	    {
    +	    case 1:
    +	      fprintf (asm_out_file, \"\\tfldz\\n\");
    +	      break;
    +	    case 2:
    +	      fprintf (asm_out_file, \"\\tfld1\\n\");
    +	      break;
    +	    default:
    +	      operands[2] = XEXP (operands[2], 0);
    +	      output_asm_insn (AS1 (fld%z2,%y2), operands);
    +	      break;
    +	    }
	     }
	   output_asm_insn (\"jmp %l1\", xops);
	   ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\", CODE_LABEL_NUMBER (xops[0]));
    @@ -7537,8 +7551,21 @@
	      output_asm_insn (AS1 (fld%z3,%y3), operands);
	   else
	    {
    -	  operands[3] = XEXP (operands[3], 0);
    -	  output_asm_insn (AS1 (fld%z3,%y3), operands);
    +	  int conval = standard_80387_constant_p (operands[3]);
    +
    +	  switch (conval)
    +	    {
    +	    case 1:
    +	      fprintf (asm_out_file, \"\\tfldz\\n\");
    +	      break;
    +	    case 2:
    +	      fprintf (asm_out_file, \"\\tfld1\\n\");
    +	      break;
    +	    default:
    +	      operands[3] = XEXP (operands[3], 0);
    +	      output_asm_insn (AS1 (fld%z3,%y3), operands);
    +	      break;
    +	   }

<more deleted>

-- 
Mark Mitchell <mmitchell@usa.net>
http://home.earthlink.net/~mbmitchell
Consulting Services Available

^ permalink raw reply	[flat|nested] 10+ messages in thread
* cp/semantics.c is broken.
@ 1998-03-19 12:55 H.J. Lu
  0 siblings, 0 replies; 10+ messages in thread
From: H.J. Lu @ 1998-03-19 12:55 UTC (permalink / raw)
  To: mmitchell; +Cc: egcs

Hi,

On x86,

# g++ -O2 -B/home/work/gnu/bin/egcs/gcc/    -c cw.cc -o cw.o
cw.cc: In function `double floor(double)':
cw.cc:9: warning: volatile qualifier ignored on asm
cw.cc:11: warning: volatile qualifier ignored on asm
cw.cc: In function `double ceil(double)':
cw.cc:21: warning: volatile qualifier ignored on asm
cw.cc:23: warning: volatile qualifier ignored on asm
/tmp/cca30122.s: Assembler messages:
/tmp/cca30122.s:31: Error: bad register name ('%0')
/tmp/cca30122.s:33: Error: bad register name ('%0')

It is from cp/semantics.c.

Thanks.


-- 
H.J. Lu (hjl@gnu.org)
---cw.cc--
extern "C" { 
__inline  double
floor (double __x)
{
  register double __value;
  __volatile unsigned short int __cw, __cwtmp;
  __asm __volatile ("fnstcw %0" : "=m" (__cw));
  __cwtmp = (__cw & 0xf3ff) | 0x0400;  
  __asm __volatile ("fldcw %0" : : "m" (__cwtmp));
  __asm __volatile ("frndint" : "=t" (__value) : "0" (__x));
  __asm __volatile ("fldcw %0" : : "m" (__cw));
  return __value;
}
__inline  double
ceil (double __x)
{
  register double __value;
  __volatile unsigned short int __cw, __cwtmp;
  __asm __volatile ("fnstcw %0" : "=m" (__cw));
  __cwtmp = (__cw & 0xf3ff) | 0x0800;  
  __asm __volatile ("fldcw %0" : : "m" (__cwtmp));
  __asm __volatile ("frndint" : "=t" (__value) : "0" (__x));
  __asm __volatile ("fldcw %0" : : "m" (__cw));
  return __value;
}
} 
class DiscreteUniform {
    long pLow;
    double delta;
public:
    virtual double operator()();
};
double DiscreteUniform::operator()()
{
    long tmp = long(floor(delta * 2.5));
    return( double(pLow + tmp) );
}

^ permalink raw reply	[flat|nested] 10+ messages in thread
* egcs-1.0.2, egcs-980315 and templates
@ 1998-03-19 12:55 Andrew Pollard
  0 siblings, 0 replies; 10+ messages in thread
From: Andrew Pollard @ 1998-03-19 12:55 UTC (permalink / raw)
  To: egcs

Hi,

 I'm not sure if this is an egcs specific thing or just my
misunderstanding of the latest C++ spec, but the following code
snippet (which was created from a much larger bit of our source code)
has problems with egcs-980315..

-------------------------------------------------------------------------------
template<class K>
struct A {
	int foo(const K&);
	int bar(const K&);
};

template<class K>
int
A<K>::bar(const K& k)
{
#if PROBLEM
	return(foo(k));
#else
	return(0);
#endif
}

#if (__GNUC__ == 2) && (__GNUC_MINOR__ >= 90)
template<>
#endif
int
A<const char*>::foo(const char*const& k)
{
        return((int)k);
}
-------------------------------------------------------------------------------

It compiles fine with egcs-1.0.2 and gcc-2.7.2.2, but with

% gcc -v
Reading specs from /usr/egcs/usr/lib/gcc-lib/i586-pc-linux-gnulibc1/egcs-2.91.14/specs
gcc version egcs-2.91.14 980315 (gcc-2.8.0 release)
% g++ -DPROBLEM -c f.cc
f.cc:23: specialization of A<const char *>::foo<const char *>(const char *const &) after instantiation
f.cc:23: explicit specialization of A<const char *>::foo<const char *>(const char *const &) after first use

but without the -DPROBLEM it compiles

(It compiles with both in egcs-1.0.2 and gcc-2.7.2.2 as well).

From what I could understand from the draft C++ spec, I can't see why
the call to foo(k) in A::bar should instantiate the template and hence
make the specialization invalid.

Can someone tell me what I am missing here?

Cheers,
 Andrew.
--
   Andrew Pollard, Auto Simulations Ltd. UK.    | home: andrew@odie.demon.co.uk
   2 Milbanke Court, Milbanke Way, Bracknell    | work: andrewp@autosim.com
Tel:+44(0)1344 426486x103 Fax:+44(0)1344 426615 | http://www.odie.demon.co.uk



^ permalink raw reply	[flat|nested] 10+ messages in thread
* An x86 patch for egcs
@ 1998-03-12 17:24 H.J. Lu
  1998-03-16 19:46 ` Jim Wilson
  0 siblings, 1 reply; 10+ messages in thread
From: H.J. Lu @ 1998-03-12 17:24 UTC (permalink / raw)
  To: egcs

Hi,

This is a partial patch for the PPro bug I reported. It fixed
loading standard x87 constants in conditional move. But it still
leaves an undefined label in one of my test cases. My other test
case still doesn't compile.

Thanks.


-- 
H.J. Lu (hjl@gnu.org)
--
Thu Mar 12 08:25:19 1998  H.J. Lu  (hjl@gnu.org)

	* config/i386/i386.md (movsfcc_1, movdfcc_1, movxfcc_1): Handle
	loading standard x87 constants.

Index: config/i386/i386.md
===================================================================
RCS file: /home/work/cvs/gnu/egcs/gcc/config/i386/i386.md,v
retrieving revision 1.1.1.8
diff -u -r1.1.1.8 i386.md
--- i386.md	1998/03/12 17:19:11	1.1.1.8
+++ i386.md	1998/03/13 00:12:40
@@ -7528,8 +7529,21 @@
 	output_asm_insn (AS1 (fld%z2,%y2), operands);
       else
         {
-	  operands[2] = XEXP (operands[2], 0);
-	  output_asm_insn (AS1 (fld%z2,%y2), operands);
+	  int conval = standard_80387_constant_p (operands[2]);
+
+	  switch (conval)
+	    {
+	    case 1:
+	      fprintf (asm_out_file, \"\\tfldz\\n\");
+	      break;
+	    case 2:
+	      fprintf (asm_out_file, \"\\tfld1\\n\");
+	      break;
+	    default:
+	      operands[2] = XEXP (operands[2], 0);
+	      output_asm_insn (AS1 (fld%z2,%y2), operands);
+	      break;
+	    }
         }
       output_asm_insn (\"jmp %l1\", xops);
       ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\", CODE_LABEL_NUMBER (xops[0]));
@@ -7537,8 +7551,21 @@
 	  output_asm_insn (AS1 (fld%z3,%y3), operands);
       else
 	{
-	  operands[3] = XEXP (operands[3], 0);
-	  output_asm_insn (AS1 (fld%z3,%y3), operands);
+	  int conval = standard_80387_constant_p (operands[3]);
+
+	  switch (conval)
+	    {
+	    case 1:
+	      fprintf (asm_out_file, \"\\tfldz\\n\");
+	      break;
+	    case 2:
+	      fprintf (asm_out_file, \"\\tfld1\\n\");
+	      break;
+	    default:
+	      operands[3] = XEXP (operands[3], 0);
+	      output_asm_insn (AS1 (fld%z3,%y3), operands);
+	      break;
+	   }
 	}
       ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\", CODE_LABEL_NUMBER (xops[1]));
 }
@@ -7584,8 +7611,21 @@
 	output_asm_insn (AS1 (fld%z2,%y2), operands);
       else
         {
-	  operands[2] = XEXP (operands[2], 0);
-	  output_asm_insn (AS1 (fld%z2,%y2), operands);
+	  int conval = standard_80387_constant_p (operands[2]);
+
+	  switch (conval)
+	    {
+	    case 1:
+	      fprintf (asm_out_file, \"\\tfldz\\n\");
+	      break;
+	    case 2:
+	      fprintf (asm_out_file, \"\\tfld1\\n\");
+	      break;
+	    default:
+	      operands[2] = XEXP (operands[2], 0);
+	      output_asm_insn (AS1 (fld%z2,%y2), operands);
+	      break;
+	    }
         }
       output_asm_insn (\"jmp %l1\", xops);
       ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\", CODE_LABEL_NUMBER (xops[0]));
@@ -7593,8 +7633,21 @@
 	  output_asm_insn (AS1 (fld%z3,%y3), operands);
       else
 	{
-	  operands[3] = XEXP (operands[3], 0);
-	  output_asm_insn (AS1 (fld%z3,%y3), operands);
+	  int conval = standard_80387_constant_p (operands[3]);
+
+	  switch (conval)
+	    {
+	    case 1:
+	      fprintf (asm_out_file, \"\\tfldz\\n\");
+	      break;
+	    case 2:
+	      fprintf (asm_out_file, \"\\tfld1\\n\");
+	      break;
+	    default:
+	      operands[3] = XEXP (operands[3], 0);
+	      output_asm_insn (AS1 (fld%z3,%y3), operands);
+	      break;
+	   }
 	}
       ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\", CODE_LABEL_NUMBER (xops[1]));
 }
@@ -7640,8 +7693,21 @@
 	output_asm_insn (AS1 (fld%z2,%y2), operands);
       else
         {
-	  operands[2] = XEXP (operands[2], 0);
-	  output_asm_insn (AS1 (fld%z2,%y2), operands);
+	  int conval = standard_80387_constant_p (operands[2]);
+
+	  switch (conval)
+	    {
+	    case 1:
+	      fprintf (asm_out_file, \"\\tfldz\\n\");
+	      break;
+	    case 2:
+	      fprintf (asm_out_file, \"\\tfld1\\n\");
+	      break;
+	    default:
+	      operands[2] = XEXP (operands[2], 0);
+	      output_asm_insn (AS1 (fld%z2,%y2), operands);
+	      break;
+	    }
         }
       output_asm_insn (\"jmp %l1\", xops);
       ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\", CODE_LABEL_NUMBER (xops[0]));
@@ -7649,8 +7715,21 @@
 	  output_asm_insn (AS1 (fld%z3,%y3), operands);
       else
 	{
-	  operands[3] = XEXP (operands[3], 0);
-	  output_asm_insn (AS1 (fld%z3,%y3), operands);
+	  int conval = standard_80387_constant_p (operands[3]);
+
+	  switch (conval)
+	    {
+	    case 1:
+	      fprintf (asm_out_file, \"\\tfldz\\n\");
+	      break;
+	    case 2:
+	      fprintf (asm_out_file, \"\\tfld1\\n\");
+	      break;
+	    default:
+	      operands[3] = XEXP (operands[3], 0);
+	      output_asm_insn (AS1 (fld%z3,%y3), operands);
+	      break;
+	   }
 	}
       ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\", CODE_LABEL_NUMBER (xops[1]));
 }

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~1998-03-23 19:24 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-03-13 18:47 An x86 patch for egcs Mark Mitchell
     [not found] ` <smtp.earthlink.net>
1998-03-13 18:29   ` H.J. Lu
1998-03-18 16:14   ` PATCH: add semantics.c Mark Mitchell
1998-03-19 21:47   ` PATCH for Re: cp/semantics.c is broken Mark Mitchell
1998-03-23 15:35   ` PATCH for Re: egcs-1.0.2, egcs-980315 and templates Andrew Pollard
1998-03-23 19:24   ` Mark Mitchell
  -- strict thread matches above, loose matches on Subject: below --
1998-03-19 12:55 cp/semantics.c is broken H.J. Lu
1998-03-19 12:55 egcs-1.0.2, egcs-980315 and templates Andrew Pollard
1998-03-12 17:24 An x86 patch for egcs H.J. Lu
1998-03-16 19:46 ` Jim Wilson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).