public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Help required for c to VCG GDL flow chart
@ 2006-07-07 13:54 Sharad Pratap
  2006-07-07 14:24 ` adding movz to machine description Petar Bajic
  0 siblings, 1 reply; 8+ messages in thread
From: Sharad Pratap @ 2006-07-07 13:54 UTC (permalink / raw)
  To: gcc-help

 I am developing a c2vcg program which takes C Program text

  and produces GDL of flow chart usable for VCG (Visual

  Compiler Graphics,) This program can now work for normal

  ANSI C some time fails on some special. In this I simply written

  a Bison Grammer file generating GDL according to Sources.

  I want for my program to  work  for  GNU C, But I am not getting

  any starting point here. I didn't understand whether GEM could help

  for this.

  Please tell whether it is possible to integrate this program/module

  in GCC or it should be totally seperate from it. work as independent

  program. If it is good to integrate in GCC so please tell how should

  I start it in GCC me a starting point.

  This is my gram.y view for one construct.

 iteration_statement:
  FOR '(' ';' ';' ')' statement
         {
         crtnode (++node, strdup ("for (;;)"), "rhomb", NULL);
         crtedge (EDGE, node, $6->flows->entry, NULL, NULL);
         crtoutsedge (BENTNEAR/*EDGE*/, &($6->flows->outs), node, FORWARD);
         crtoutsedge (BACK, &($6->flows->cnt), node, FORWARD);

         $$ = $6;
         $$->flows->entry = node;
         $$->flows->sttyp = LOOP;
         push_link (&($$->flows->outs), crtnodtyp (node, LOOP));
         push_list (&($$->flows->outs), $6->flows->brk);
         $$->flows->brk = NULL;
         }

  Regard
       Sharad

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

* adding movz to machine description
  2006-07-07 13:54 Help required for c to VCG GDL flow chart Sharad Pratap
@ 2006-07-07 14:24 ` Petar Bajic
  2006-07-07 17:39   ` Ian Lance Taylor
  2006-07-25 18:25   ` Rask Ingemann Lambertsen
  0 siblings, 2 replies; 8+ messages in thread
From: Petar Bajic @ 2006-07-07 14:24 UTC (permalink / raw)
  To: gcc-help

I need to add conditional move instructions to gcc dlx port.
I found implemented pattern 'movmodecc' for conditional move instruction 
that look like this:
if (condition)
    a = b;
else
   a = c;

but my "movz" look like this

if (c == 0)
    a = b;

or asm: movz r1, r2, r3  ;; ((if r3 == 0, move r2 to r1))

there is no 'else'  branch.

In md file it's easy to describe first case:

(define_insn "movsicc_internal"
  [(set (match_operand:SI 0 "register_operand" "=d,d")
  (if_then_else:SI
  (match_operator 1 "comparison_operator" [(match_operand:SI 4 
"register_operand" "=d,d") (const_int 0)])
  (match_operand:SI 2 "register_operand" "=d,d")
  (match_operand:SI 3 "register_operand" "=d,d")))]

"movc\\t%0, %2, %3, %1" ;;theoretic conditional move with else branch
[(set_attr "mode" "SI")]

But I can't seem to describe what I need: conditional move without else 
branch.
Any help is appreciated. Im new here.

Petar 

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

* Re: adding movz to machine description
  2006-07-07 14:24 ` adding movz to machine description Petar Bajic
@ 2006-07-07 17:39   ` Ian Lance Taylor
  2006-07-12 11:10     ` Petar Bajic
  2006-07-25 18:25   ` Rask Ingemann Lambertsen
  1 sibling, 1 reply; 8+ messages in thread
From: Ian Lance Taylor @ 2006-07-07 17:39 UTC (permalink / raw)
  To: Petar Bajic; +Cc: gcc-help

"Petar Bajic" <petar.bajic@micronasnit.com> writes:

> I need to add conditional move instructions to gcc dlx port.
> I found implemented pattern 'movmodecc' for conditional move
> instruction that look like this:
> if (condition)
>     a = b;
> else
>    a = c;
> 
> but my "movz" look like this
> 
> if (c == 0)
>     a = b;
> 
> or asm: movz r1, r2, r3  ;; ((if r3 == 0, move r2 to r1))
> 
> there is no 'else'  branch.
> 
> In md file it's easy to describe first case:
> 
> (define_insn "movsicc_internal"
>   [(set (match_operand:SI 0 "register_operand" "=d,d")
>   (if_then_else:SI
>   (match_operator 1 "comparison_operator" [(match_operand:SI 4
> "register_operand" "=d,d") (const_int 0)])
>   (match_operand:SI 2 "register_operand" "=d,d")
>   (match_operand:SI 3 "register_operand" "=d,d")))]
> 
> "movc\\t%0, %2, %3, %1" ;;theoretic conditional move with else branch
> [(set_attr "mode" "SI")]
> 
> But I can't seem to describe what I need: conditional move without
> else branch.
> Any help is appreciated. Im new here.

Write it as a define_expand which generates, more or less,
    (set a c)
    (set a (if_then_else (eq b 0) d (match_dup a)))

Ian

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

* Re: adding movz to machine description
  2006-07-07 17:39   ` Ian Lance Taylor
@ 2006-07-12 11:10     ` Petar Bajic
  2006-07-13  7:52       ` Ian Lance Taylor
  0 siblings, 1 reply; 8+ messages in thread
From: Petar Bajic @ 2006-07-12 11:10 UTC (permalink / raw)
  To: gcc-help


----- Original Message ----- 
From: "Ian Lance Taylor" <iant@google.com>
To: "Petar Bajic" <petar.bajic@micronasnit.com>
Cc: <gcc-help@gcc.gnu.org>
Sent: Friday, July 07, 2006 7:39 PM
Subject: Re: adding movz to machine description


> "Petar Bajic" <petar.bajic@micronasnit.com> writes:
>
>> I need to add conditional move instructions without else branch to gcc 
>> dlx port.
>> Any help is appreciated. Im new here.
>
>
> Write it as a define_expand which generates, more or less,
>    (set a c)
>    (set a (if_then_else (eq b 0) d (match_dup a)))
>
> Ian
>


If I write define_expand like this :

(define_expand "movsicc_movz"
  [(set (match_operand:SI 0 "register_operand" "=d,d")
  (if_then_else (eq (match_operand:SI 2 "register_operand" "=d,d") 
(const_int 0))
     (match_operand:SI 1 "register_operand" "=d,d") (match_dup 0)))]
  ""
  "{dlx_emit_cond_move(operands[0], operands[1], operands[2]); DONE;}" )


it never gets used/generated 

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

* Re: adding movz to machine description
  2006-07-12 11:10     ` Petar Bajic
@ 2006-07-13  7:52       ` Ian Lance Taylor
  2006-07-18 12:06         ` Petar Bajic
  0 siblings, 1 reply; 8+ messages in thread
From: Ian Lance Taylor @ 2006-07-13  7:52 UTC (permalink / raw)
  To: Petar Bajic; +Cc: gcc-help

"Petar Bajic" <petar.bajic@micronasnit.com> writes:

> If I write define_expand like this :
> 
> (define_expand "movsicc_movz"
>   [(set (match_operand:SI 0 "register_operand" "=d,d")
>   (if_then_else (eq (match_operand:SI 2 "register_operand" "=d,d")
> (const_int 0))
>      (match_operand:SI 1 "register_operand" "=d,d") (match_dup 0)))]
>   ""
>   "{dlx_emit_cond_move(operands[0], operands[1], operands[2]); DONE;}" )
> 
> 
> it never gets used/generated

In order for a define_expand to be used by the machine independent
code, it must have a standard name, as listed here:
    http://gcc.gnu.org/onlinedocs/gccint/Standard-Names.html

In this case you should call it simply "movsicc", not "movsicc_movz".

Ian

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

* Re: adding movz to machine description
  2006-07-13  7:52       ` Ian Lance Taylor
@ 2006-07-18 12:06         ` Petar Bajic
  2006-07-18 14:35           ` Ian Lance Taylor
  0 siblings, 1 reply; 8+ messages in thread
From: Petar Bajic @ 2006-07-18 12:06 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-help


----- Original Message ----- 
From: "Ian Lance Taylor" <iant@google.com>
To: "Petar Bajic" <petar.bajic@micronasnit.com>
Cc: <gcc-help@gcc.gnu.org>
Sent: Thursday, July 13, 2006 9:51 AM
Subject: Re: adding movz to machine description


> "Petar Bajic" <petar.bajic@micronasnit.com> writes:
>
>> If I write define_expand like this :
>>
>> (define_expand "movsicc_movz"
>>   [(set (match_operand:SI 0 "register_operand" "=d,d")
>>   (if_then_else (eq (match_operand:SI 2 "register_operand" "=d,d")
>> (const_int 0))
>>      (match_operand:SI 1 "register_operand" "=d,d") (match_dup 0)))]
>>   ""
>>   "{dlx_emit_cond_move(operands[0], operands[1], operands[2]); DONE;}" )
>>
>>
>> it never gets used/generated
>
> In order for a define_expand to be used by the machine independent
> code, it must have a standard name, as listed here:
>    http://gcc.gnu.org/onlinedocs/gccint/Standard-Names.html
>
> In this case you should call it simply "movsicc", not "movsicc_movz".
>
> Ian
>

define_expand is used but instruction is not generated

(define_expand "movsicc"
    [(set (match_operand:SI 0 "register_operand" "=d,d")
     (if_then_else:SI (eq:SI (match_operand:SI 2 "register_operand" "=d,d") 
(const_int 0))
        (match_operand:SI 1 "register_operand" "=d,d")
 (match_dup 0)))]
  ""
  "
{
  dlx_emit_cond_move(operands[0], operands[1], operands[2]);
  DONE;
}")

In function dlx_emitcond_move I try to emit my instruction "movsicc_movz".
Comment is printed out, but instruction is not generated.
dlx_emit_cond_move (rtx dest, rtx src1, rtx test_rtx)

{

printf("dlx_emit_cond_move called");



emit_insn(gen_movsicc_movz(dest, src1, test_rtx));

return TRUE;

}

and finally instruction is defined like this:

(define_insn "movsicc_movz"
  [(set (match_operand:SI 0 "register_operand" "=d,d")
   (if_then_else:SI (match_operand:SI 1 "comparison_operator" "")
    (match_operand:SI 2 "register_operand" "=d,d")
    (match_dup 0)))]
  ""
  "movz\\t%0,%2,%1"
  [(set_attr "type" "condmove")
   (set_attr "mode" "SI")])

I also have regular patern movsicc_insn wich is always used, and if I skip 
it's definition, I can't build compiler (errpor "gen_movsicc_move not 
defined")

(define_insn "movsicc_internal"
  [(set (match_operand:SI 0 "register_operand" "=j,j")
  (if_then_else:SI
  (match_operator 1 "comparison_operator" [(match_operand:SI 4 
"register_operand" "=k,k") (const_int 0)])
  (match_operand:SI 2 "register_operand" "=d,d")
  (match_operand:SI 3 "register_operand" "=d,d")))]
  ""
  "movz\\t%0,%2,%4\\n\\tmovn\\t%0,%3,%4"
  [(set_attr "type" "condmove")
   (set_attr "mode" "SI")])

What do I have to do to make compiler use movsicc_movz when appropriate?



Petar

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

* Re: adding movz to machine description
  2006-07-18 12:06         ` Petar Bajic
@ 2006-07-18 14:35           ` Ian Lance Taylor
  0 siblings, 0 replies; 8+ messages in thread
From: Ian Lance Taylor @ 2006-07-18 14:35 UTC (permalink / raw)
  To: Petar Bajic; +Cc: gcc-help

"Petar Bajic" <petar.bajic@micronasnit.com> writes:

> define_expand is used but instruction is not generated

...

> What do I have to do to make compiler use movsicc_movz when appropriate?

What do you mean when you say that the instruction is not generated?
Your code looks OK.  Look at the .expand debugging dump (use -da to
generate all the RTL debugging dump files); do you see the instruction
there?  If so, trace it forward to see what happens to it.

Ian

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

* Re: adding movz to machine description
  2006-07-07 14:24 ` adding movz to machine description Petar Bajic
  2006-07-07 17:39   ` Ian Lance Taylor
@ 2006-07-25 18:25   ` Rask Ingemann Lambertsen
  1 sibling, 0 replies; 8+ messages in thread
From: Rask Ingemann Lambertsen @ 2006-07-25 18:25 UTC (permalink / raw)
  To: Petar Bajic; +Cc: gcc-help

On Fri, Jul 07, 2006 at 04:25:08PM +0200, Petar Bajic wrote:
> but my "movz" look like this
> 
> if (c == 0)
>    a = b;
> 
> or asm: movz r1, r2, r3  ;; ((if r3 == 0, move r2 to r1))
> 
> there is no 'else'  branch.

There _is_ an 'else' branch:

if (r3 == 0)
  r1 = r2;
else
  r1 = r1;

With that, the insn definition is easy enough:

(define_insn "*movz"
	[(set (match_operand:SI 0 "register_operand" "=d")
	      (if_then_else (eq (match_operand:SI 1 "register_operand" "d")
				(const_int 0))
			    (match_operand:SI 2 "register_operand" "d")
			    (match_operand:SI 3 "register_operand" "0")))]
	""
	"movz\t%0, %2, %1"
)

This is not all that different from the "*movsicc_noc" pattern in i386.md.
You may want to add a reverse conditional pattern too, i.e. with (ne ...)
instead of (eq ...) and operands 2 and 3 swapped.

As for the expander, I don't know enough of our target machine to write one,
and I'm not sure you need one. Passes such as combine, ce1, ce2 and ce3 may
create "*movz".

Having read the rest of the thread, I suggest you reread the documentation
about define_expand, in particular the description of the DONE and FAIL
macros for the preparation statements and how they affect the generation of
the RTL template.

-- 
Rask Ingemann Lambertsen

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

end of thread, other threads:[~2006-07-25 18:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-07 13:54 Help required for c to VCG GDL flow chart Sharad Pratap
2006-07-07 14:24 ` adding movz to machine description Petar Bajic
2006-07-07 17:39   ` Ian Lance Taylor
2006-07-12 11:10     ` Petar Bajic
2006-07-13  7:52       ` Ian Lance Taylor
2006-07-18 12:06         ` Petar Bajic
2006-07-18 14:35           ` Ian Lance Taylor
2006-07-25 18:25   ` Rask Ingemann Lambertsen

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).