* shifting among patterns
@ 2010-03-15 8:42 Rajiv KI
2010-03-16 15:20 ` Ian Lance Taylor
0 siblings, 1 reply; 3+ messages in thread
From: Rajiv KI @ 2010-03-15 8:42 UTC (permalink / raw)
To: gcc-help
Hi all,
I am new to this porting gcc architecture field. I have a doubt.
What i was trying is, In "movdi" pattern for some pairs of constraints like
(r,r) or (m,r) i was letting movdi pattern to handle this while working over
64bit data. But for other constraints pair like (r,i) or (r,m) i was trying
to make movsi handle this pair of constraints by diverting from movdi to
movsi. I did it in this way:
(define_expand "movdi"
[(set (match_operand:DI 0 "general_operand" "")
(match_operand:DI 1 "general_operand" ""))]
""
"
if(GET_CODE(operands[0])==MEM && GET_CODE(operands[1])!=REG)
{
if(can_create_pseudo_p())
{
operands[1]=force_reg(DImode,operands[1]);
}
}
"
)
(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.
I am new, learning while practising. Please help me in this.
Rajiv.
--
View this message in context: http://old.nabble.com/shifting-among-patterns-tp27901006p27901006.html
Sent from the gcc - Help mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: shifting among patterns
2010-03-15 8:42 shifting among patterns Rajiv KI
@ 2010-03-16 15:20 ` Ian Lance Taylor
0 siblings, 0 replies; 3+ messages in thread
From: Ian Lance Taylor @ 2010-03-16 15:20 UTC (permalink / raw)
To: Rajiv KI; +Cc: gcc-help
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: shifting among patterns
@ 2010-03-15 10:29 Bill McEnaney
0 siblings, 0 replies; 3+ messages in thread
From: Bill McEnaney @ 2010-03-15 10:29 UTC (permalink / raw)
To: Rajiv KI, gcc-help
Rajiv,
I'm sorry I don't know the answer to your question. But thank you for
writing such readable code.
Cheers,
Bill
>
> Hi all,
>
> I am new to this porting gcc architecture field. I have a doubt.
>
> What i was trying is, In "movdi" pattern for some pairs of constraints
like
> (r,r) or (m,r) i was letting movdi pattern to handle this while
working over
> 64bit data. But for other constraints pair like (r,i) or (r,m) i was
trying
> to make movsi handle this pair of constraints by diverting from movdi to
> movsi. I did it in this way:
>
> (define_expand "movdi"
> [(set (match_operand:DI 0 "general_operand" "")
> (match_operand:DI 1 "general_operand" ""))]
> ""
> "
> if(GET_CODE(operands[0])==MEM && GET_CODE(operands[1])!=REG)
>
> {
>
> if(can_create_pseudo_p())
>
> {
>
> operands[1]=force_reg(DImode,operands[1]);
>
> }
>
> }
> "
> )
> (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.
>
> I am new, learning while practising. Please help me in this.
>
> Rajiv.
>
>
>
>
>
>
>
>
> --
> View this message in context:
http://old.nabble.com/shifting-among-patterns-tp27901006p27901006.html
> Sent from the gcc - Help mailing list archive at Nabble.com.
>
>
________________________________________________________________
Please visit a saintly hero:
http://www.jakemoore.org
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-03-16 15:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-15 8:42 shifting among patterns Rajiv KI
2010-03-16 15:20 ` Ian Lance Taylor
2010-03-15 10:29 Bill McEnaney
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).