I386.md: *_mixed and *_sse

2008-04-22 Thread Ye, Joey
Hi,

From i386.md, alternative 1 of *fop_sf_comm_mixed is duplicated with
*fop_sf_comm_sse. Why do we define a _mixed pattern here?

(define_insn "*fop_sf_comm_mixed"
  [(set (match_operand:SF 0 "register_operand" "=f,x")
(match_operator:SF 3 "binary_fp_operator"
[(match_operand:SF 1 "nonimmediate_operand"
"%0,0")
 (match_operand:SF 2 "nonimmediate_operand"
"fm,xm")]))]
  "TARGET_MIX_SSE_I387
   && COMMUTATIVE_ARITH_P (operands[3])
   && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
  "* return output_387_binary_op (insn, operands);"
  [(set (attr "type")
(if_then_else (eq_attr "alternative" "1")
   (if_then_else (match_operand:SF 3 "mult_operator" "")
  (const_string "ssemul")
  (const_string "sseadd"))
   (if_then_else (match_operand:SF 3 "mult_operator" "")
  (const_string "fmul")
  (const_string "fop"
   (set_attr "mode" "SF")])

(define_insn "*fop_sf_comm_sse"
  [(set (match_operand:SF 0 "register_operand" "=x")
(match_operator:SF 3 "binary_fp_operator"
[(match_operand:SF 1 "nonimmediate_operand"
"%0")
 (match_operand:SF 2 "nonimmediate_operand"
"xm")]))]
  "TARGET_SSE_MATH
   && COMMUTATIVE_ARITH_P (operands[3])
   && !(MEM_P (operands[1]) && MEM_P (operands[2]))"
  "* return output_387_binary_op (insn, operands);"
  [(set (attr "type")
(if_then_else (match_operand:SF 3 "mult_operator" "")
   (const_string "ssemul")
   (const_string "sseadd")))
   (set_attr "mode" "SF")])

Thanks - Joey


Re: How to teach gcc, that registers are clobbered by api calls?

2008-04-22 Thread Ross Ridge
Kai Tietz writes:
>I read that too, but how can I teach gcc to do this that registers are
>callee-saved? I tried it by use of call_used part in regclass.c, but
>this didn't worked as expected.

I think you need to modify CALL_USED_REGISTERS and/or
CONDITIONAL_REGISTER_USAGE in i386.h.  Making any changes to regclass.c
is probably not the right thing to do.

Ross Ridge



Re: no mul/div instruction

2008-04-22 Thread Kunal Parmar
Hi,

I wanted support for software floating point on the architecture. I am
using fp-bit.c & dp-bit.c and have defined FLOAT_TYPE_SIZE as 32 and
DOUBLE_TYPE_SIZE as 64. dp-bit.c requires __muldi3. How do I enable
emulation of 64 bit multiply in libgcc2.a ?

Thanks in advance,
Kunal Parmar


Re: no mul/div instruction

2008-04-22 Thread Kunal Parmar
Hi Ian,

On Tue, Apr 22, 2008 at 7:12 PM, Ian Lance Taylor <[EMAIL PROTECTED]> wrote:
>  Looking at libgcc2.h, it seems like you might need to define
>  LIBGCC2_UNITS_PER_WORD in your tm.h file.

That solved my problem. Thanks a ton !

Kunal


Re: no mul/div instruction

2008-04-22 Thread Ian Lance Taylor
"Kunal Parmar" <[EMAIL PROTECTED]> writes:

>>  Yes, I think __mulsi3 will be built for you automatically.
>
> I gave a definition of __mulhi3 for my architecture. But I don't get
> __mulsi3 in libgcc.a. Do I have to enable some options for this ?

Looking at libgcc2.h, it seems like you might need to define
LIBGCC2_UNITS_PER_WORD in your tm.h file.

Ian


Re: US-CERT Vulnerability Note VU#162289

2008-04-22 Thread Brad Roberts
On Tue, 22 Apr 2008, Mark Mitchell wrote:

> Chad Dougherty wrote:
> 
> > The vulnerability note has been significantly reworked to focus on the issue
> > of undefined behavior handling in the compiler and the fact that conforming
> > implementations are not required to warn of this condition. I've tried to
> > incorporate many of the valid concerns that were raise on this list in
> > response to the original vulnerability note.
> 
> Thank you for making the update; this is a big improvement.
> 
> However, I'm surprised that only GCC is listed as "vulnerable" at the bottom
> of the page.  We've provided information about a lot of other compilers that
> do the same optimization.  Why is the status for compilers from Microsoft,
> Intel, IBM, etc. listed as "Unknown" instead of "Vulnerable"?
> 
> -- 
> Mark Mitchell
> CodeSourcery
> [EMAIL PROTECTED]
> (650) 331-3385 x713

Additionally, the linked to notes for GCC are reflective of the original 
innaccuracies: 

http://www.kb.cert.org/vuls/id/CRDY-7DWKWM

Vendor Statement
No statement is currently available from the vendor regarding this 
vulnerability.

US-CERT Addendum
Vendors and developers using the GNU C compiler should consider 
downgrading their version of gcc or sticking with versions of the gcc 
compiler (before version 4.1) that do not perform the offending 
optimization. In the case of gcc, it should be emphasized that this is a 
change of behavior in the later versions of the compiler.

Later,
Brad


Re: no mul/div instruction

2008-04-22 Thread Kunal Parmar
Hi Ian,

>  Yes, I think __mulsi3 will be built for you automatically.

I gave a definition of __mulhi3 for my architecture. But I don't get
__mulsi3 in libgcc.a. Do I have to enable some options for this ?

Thanks in advance,
Kunal Parmar


Re: no mul/div instruction

2008-04-22 Thread Ian Lance Taylor
"Kunal Parmar" <[EMAIL PROTECTED]> writes:

> On Tue, Apr 22, 2008 at 1:24 PM, Ian Lance Taylor <[EMAIL PROTECTED]> wrote:
>>  It depends on UNITS_PER_WORD.  If UNITS_PER_WORD is 4, you need
>>  __mulsi3.  If UNITS_PER_WORD is 2, you need __mulhi3, and, if you have
>>  32-bit integer types, you will also need __mulsi3.  In the latter case
>>  you can, if you like, get code for __mulsi3 from longlong.h--see the
>>  comments at the top of the file.
>
> UNITS_PER_WORD is 2 and INT_TYPE_SIZE is 16. This means I need to
> provide __mulhi3. Does this mean that libgcc will provide the definition of
> __mulsi3 ?

Yes, I think __mulsi3 will be built for you automatically.

Ian


Re: no mul/div instruction

2008-04-22 Thread Kunal Parmar
Hi Ian,

On Tue, Apr 22, 2008 at 1:24 PM, Ian Lance Taylor <[EMAIL PROTECTED]> wrote:
>  It depends on UNITS_PER_WORD.  If UNITS_PER_WORD is 4, you need
>  __mulsi3.  If UNITS_PER_WORD is 2, you need __mulhi3, and, if you have
>  32-bit integer types, you will also need __mulsi3.  In the latter case
>  you can, if you like, get code for __mulsi3 from longlong.h--see the
>  comments at the top of the file.

UNITS_PER_WORD is 2 and INT_TYPE_SIZE is 16. This means I need to
provide __mulhi3. Does this mean that libgcc will provide the definition of
__mulsi3 ?

Thanks,
Kunal


Re: US-CERT Vulnerability Note VU#162289

2008-04-22 Thread Mark Mitchell

Chad Dougherty wrote:

The vulnerability note has been significantly reworked to focus on the 
issue of undefined behavior handling in the compiler and the fact that 
conforming implementations are not required to warn of this condition. 
I've tried to incorporate many of the valid concerns that were raise on 
this list in response to the original vulnerability note.


Thank you for making the update; this is a big improvement.

However, I'm surprised that only GCC is listed as "vulnerable" at the 
bottom of the page.  We've provided information about a lot of other 
compilers that do the same optimization.  Why is the status for 
compilers from Microsoft, Intel, IBM, etc. listed as "Unknown" instead 
of "Vulnerable"?


--
Mark Mitchell
CodeSourcery
[EMAIL PROTECTED]
(650) 331-3385 x713


Re: US-CERT Vulnerability Note VU#162289

2008-04-22 Thread Chad Dougherty

Joe Buck wrote:

Thanks.  I hope that you will correct the advisory promptly to avoid any
implication that one should switch from GCC to a different compiler based
on this issue, since we've already established that most of GCC's
competitors perform similar optimizations under some cicumstances (even if
the particular example that appears in the CERT report is not affected,
other, similar examples will be, particularly if they appear in a loop).

Both CERT and GCC have their reputations to consider here, and I think
that this advisory has damaged the reputations of *both*.



The vulnerability note has been significantly reworked to focus on the 
issue of undefined behavior handling in the compiler and the fact that 
conforming implementations are not required to warn of this condition. 
I've tried to incorporate many of the valid concerns that were raise on 
this list in response to the original vulnerability note.



The advisory should emphasize the solution of auditing buffer overflow
checks to make sure that they are correct C, and should help people
write such checks correctly.


The vulnerability note itself essentially punts this issue to the 
corresponding documents in our Secure Coding standard.


-Chad


Re: namelookup bug in gcc?

2008-04-22 Thread Joe Buck
On Tue, Apr 22, 2008 at 02:28:15PM +0200, Balazs Dezso wrote:
> I have tested the following code on  g++ 4.3, 4.2, 4.1 and 3.4.

Looks like a bug.  Please file a bug report at http://gcc.gnu.org/bugzilla

> #include 
> 
> struct B {
>   static const int x = 1;
> };
> 
> struct A {
>   static const int x = 0;
>   template 
>   static void f() {
> std::cerr << A::x << std::endl;
>   }
> };
> 
> int main() {
>   A::f();
>   return 0;
> }
> 
> The gcc result:
> 0
> While icc, msvc result:
> 1


Re: no mul/div instruction

2008-04-22 Thread Ian Lance Taylor
Kunal Parmar <[EMAIL PROTECTED]> writes:

> I am porting GCC to a new 16 bit RISC architecture which does not have
> multiplication and division instructions. I figured that I have to provide
> emulation routines for the multiplication and division which will be
> inserted into libgcc2.a. But I am confused about which versions of these
> routines to provide i.e. do I provide __mulsi3 or __mulhi3 or both.

It depends on UNITS_PER_WORD.  If UNITS_PER_WORD is 4, you need
__mulsi3.  If UNITS_PER_WORD is 2, you need __mulhi3, and, if you have
32-bit integer types, you will also need __mulsi3.  In the latter case
you can, if you like, get code for __mulsi3 from longlong.h--see the
comments at the top of the file.

Ian


no mul/div instruction

2008-04-22 Thread Kunal Parmar

Hi all,

I am porting GCC to a new 16 bit RISC architecture which does not have
multiplication and division instructions. I figured that I have to provide
emulation routines for the multiplication and division which will be
inserted into libgcc2.a. But I am confused about which versions of these
routines to provide i.e. do I provide __mulsi3 or __mulhi3 or both.

Thanks in advance,
Kunal


Re: Google Summer of Code 2008: seven approved applications for gcc

2008-04-22 Thread Manuel López-Ibáñez
And in our wiki:

http://gcc.gnu.org/wiki/SummerOfCode

which our new developers are welcome to use to document their progress.

Cheers,

Manuel.


On 22/04/2008, Ian Lance Taylor <[EMAIL PROTECTED]> wrote:
> I'm happy to report that Google approved seven applications for Summer
>  of Code for the gcc project.  The approved applications can be found
>  here: http://code.google.com/soc/2008/gcc/about.html .
>
>
>  Ian
>


Google Summer of Code 2008: seven approved applications for gcc

2008-04-22 Thread Ian Lance Taylor
I'm happy to report that Google approved seven applications for Summer
of Code for the gcc project.  The approved applications can be found
here: http://code.google.com/soc/2008/gcc/about.html .

Ian


namelookup bug in gcc?

2008-04-22 Thread Balazs Dezso
Hello all,

I have tested the following code on  g++ 4.3, 4.2, 4.1 and 3.4.

#include 

struct B {
  static const int x = 1;
};

struct A {
  static const int x = 0;
  template 
  static void f() {
std::cerr << A::x << std::endl;
  }
};

int main() {
  A::f();
  return 0;
}

The gcc result:
0
While icc, msvc result:
1

Best, Balazs

---


Re: How to insert functions?

2008-04-22 Thread Hugh Leather


Hi Andrew,

Yes, I did a bit.  it segfaults at
cgraphunit.c:cgraph_expand_all_functions:1323
node->lowered = DECL_STRUCT_FUNCTION (node->decl)->cfg != NULL;
It seems that the node->decl has been nulled by the time it gets 
here.  It definitely isn't NULL after leaving my code. 
Can you think of anything that might do that?  I figured I must be 
doing something pretty wrong and that there must be tons of examples 
for this kind of thing but I haven't been able to find one.
   


Cheers for the help,

Hugh.

Andrew Haley wrote:

Hugh Leather wrote:
  

Hi,

  I am trying to add a new destructor function to object files I
compile.  I'm doing this to instrument programs and then, once the
program has finished I want to print out the statistics I've gathered.
  So, just before pass 'remove_useless_stmts' is called on each function
I try to create a static destructor which will print stats for the
current function (and obviously, I don't do it on the functions just
created).

  Below I've put a simpler form, which should work for a one function
program.  Calling createFnDecl() creates a new function called
__my_new_function.  It should print "It worked!" when the program exits.
  Now, with compiler flag -O0, this works just fine, but with -O1 or
above it seg faults the compiler.

  Can anyone tell me what I'm doing wrong?



Nothing obvious to me.  Did you debug the point at which the
segfault happened?

Andrew.


  




Re: How to insert functions?

2008-04-22 Thread Andrew Haley
Hugh Leather wrote:
> Hi,
> 
>   I am trying to add a new destructor function to object files I
> compile.  I'm doing this to instrument programs and then, once the
> program has finished I want to print out the statistics I've gathered.
>   So, just before pass 'remove_useless_stmts' is called on each function
> I try to create a static destructor which will print stats for the
> current function (and obviously, I don't do it on the functions just
> created).
> 
>   Below I've put a simpler form, which should work for a one function
> program.  Calling createFnDecl() creates a new function called
> __my_new_function.  It should print "It worked!" when the program exits.
>   Now, with compiler flag -O0, this works just fine, but with -O1 or
> above it seg faults the compiler.
> 
>   Can anyone tell me what I'm doing wrong?

Nothing obvious to me.  Did you debug the point at which the
segfault happened?

Andrew.


How to insert functions?

2008-04-22 Thread Hugh Leather

Hi,

  I am trying to add a new destructor function to object files I 
compile.  I'm doing this to instrument programs and then, once the 
program has finished I want to print out the statistics I've gathered.
  So, just before pass 'remove_useless_stmts' is called on each 
function I try to create a static destructor which will print stats for 
the current function (and obviously, I don't do it on the functions just 
created).


  Below I've put a simpler form, which should work for a one function 
program.  Calling createFnDecl() creates a new function called 
__my_new_function.  It should print "It worked!" when the program exits.
  Now, with compiler flag -O0, this works just fine, but with -O1 or 
above it seg faults the compiler.


  Can anyone tell me what I'm doing wrong?

  Cheers,

  Hugh.

static tree createFnBody() {
  tree arg;
  tree argList;
  tree putsFn;
  tree call;
  tree bind;
  char msg[] = "It worked!";

  bind = build3( BIND_EXPR, void_type_node, NULL_TREE, NULL_TREE, 
NULL_TREE );

  TREE_SIDE_EFFECTS( bind ) = 1;

  putsFn = implicit_built_in_decls[ BUILT_IN_PUTS ];
  arg = build_string_literal( sizeof( msg ) + 1, msg );
  argList = tree_cons( NULL_TREE, arg, NULL_TREE );
  call = build_function_call_expr( putsFn, argList );
  append_to_statement_list( call, &BIND_EXPR_BODY( bind ));
  return bind;
}

static tree createFnDecl() {
  tree callTypes;
  tree fnName;
  tree fnDecl;
  tree t;
  struct function* oldCfun = cfun;
 fnName = get_identifier( "__my_new_function" );
  callTypes = build_function_type_list( void_type_node, NULL_TREE );
  fnDecl = build_decl( FUNCTION_DECL, fnName, callTypes );
  fnDecl = lang_hooks.decls.pushdecl( fnDecl );

  TREE_STATIC( fnDecl ) = 1;
  TREE_USED( fnDecl ) = 1;
  DECL_ARTIFICIAL( fnDecl ) = 1;
  DECL_IGNORED_P( fnDecl ) = 0;
  TREE_PUBLIC( fnDecl ) = 0;
  DECL_UNINLINABLE( fnDecl ) = 1;
  DECL_EXTERNAL( fnDecl ) = 0;
  DECL_CONTEXT( fnDecl ) = NULL_TREE;
  DECL_INITIAL( fnDecl ) = make_node ( BLOCK );
  DECL_STATIC_DESTRUCTOR( fnDecl ) = 1;
  DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT( fnDecl ) = 1;
 
  t = build_decl( RESULT_DECL, NULL_TREE, void_type_node );

  DECL_ARTIFICIAL( t ) = 1;
  DECL_IGNORED_P( t ) = 1;
  DECL_RESULT( fnDecl ) = t;

  DECL_SAVED_TREE( fnDecl ) = createFnBody();

  allocate_struct_function( fnDecl );
  cgraph_add_new_function( fnDecl );  
  cfun = oldCfun;

  return fnDecl;
}




Re: ada: What is libgnalasup?

2008-04-22 Thread Samuel Tardieu
> "Arnaud" == Arnaud Charlet <[EMAIL PROTECTED]> writes:

Arnaud> Yes, libgnalasup is a bundled version of lapack/blas
Arnaud> libraries.

Thanks. I've submitted a patch to make lapack/blas the default
version.

  Sam
-- 
Samuel Tardieu -- [EMAIL PROTECTED] -- http://www.rfc1149.net/