This is the mail archive of the gcc-help@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: shifting among patterns


Rajiv KI <rajivkumarsingla@gmx.com> writes:

> (define_insn_and_split "*movdi"
>   [(set(match_operand: DI 0  "nonimmediate_operand" "=r,r,r,m")
>
>         (match_operand:  DI  1   "general_operand"        "r,Di,m,r"))]
>         ""
> 	"*
> 	 switch (which_alternative)
> 	 {
> 	 case 0:  return \"#\";
> 	 case 1:  
> 	 case 2:  return divert_to_si(operands);
> 	 case 3:  return output_move_double (operands);	 
> 	 }"
> 	"reload_completed"
>       [(set (match_dup 0)(match_dup 1))
> 	 (set (match_dup 2)(match_dup 3))]
>         "{
> 	    operands[2] = gen_highpart (SImode, operands[0]);
> 	    operands[0] = gen_lowpart (SImode, operands[0]);
>  	    operands[3] = gen_highpart (SImode, operands[1]);
> 	    operands[1] = gen_lowpart (SImode, operands[1]);
> 	}"
> )
>
> Here 'Di' is constraint for double integer range.
>
> And 'divert_to_si' is function i have written in '.c' file:
>
> void divert_to_si(rtx *operands)
> {
> 	printf("inside divert_to_si fxn\n");
> 	emit_insn(gen_movsi(operands[0],operands[1]));
> }
>
> My doubts are:
>
> 1.Can we do this type of diversion?
> 2.To me its giving 'segmentation fault' for simple 64bit assignment.

The general idea should work.  However, you appear to be returning a
void value from your define_insn_and_split.  That won't work.  The
define_insn_and_split needs to return a char*.  Make sure that
functions like divert_to_si are declared in your CPU-protos.h file.
Make sure your code compiles without warnings.

Ian


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