* subreg vs register_operand
@ 2002-09-12 1:09 Pierre Mallard
2002-09-12 14:09 ` Richard Henderson
0 siblings, 1 reply; 3+ messages in thread
From: Pierre Mallard @ 2002-09-12 1:09 UTC (permalink / raw)
To: gcc
Hi ,
I've got a simple set of define_insn to match move
instruction :
(define_insn "movqi"
[(set (match_operand:QI 0 "nonimmediate_operand"
"=r,m,r,r")
(match_operand:QI 1 "general_operand"
"r,r,m,i"))]
"(register_operand (operands[0],QImode)
|| register_operand (operands[1], QImode))"
"* return output_movqi (insn, operands, NULL);"
[(set_attr "length" "1,5,5,1")
(set_attr "cc" "none,none,none,none")
(set_attr "type" "none,load,none,none")])
(define_insn "movhi"
[(set (match_operand:HI 0 "nonimmediate_operand"
"=r,r,m,r,r")
(match_operand:HI 1 "general_operand"
"r,m,r,I,i"))]
"(register_operand (operands[0],HImode)
|| register_operand (operands[1],HImode))"
"* return output_movhi (insn, operands, NULL);"
[(set_attr "length" "1,6,6,1,2")
(set_attr "cc" "none,none,none,none,none")
(set_attr "type" "none,load,none,none,none")])
(define_insn "movsi"
[(set (match_operand:SI 0 "nonimmediate_operand"
"=r,r,m,r,r")
(match_operand:SI 1 "general_operand"
"r,m,r,I,i"))]
"(register_operand (operands[0],SImode)
|| register_operand (operands[1],SImode))"
"* return output_movsisf (insn, operands, NULL);"
[(set_attr "length" "2,8,8,2,4")
(set_attr "cc" "none,none,none,none,none")
(set_attr "type" "none,load,none,none,none")])
In order to optimize the jump delay slot I make some
define_split to reduce SI and HI move :
(define_split
[(set (match_operand:HI 0 "register_operand" "=r")
(match_operand:HI 1 "general_operand" "i"))]
""
[(set (subreg:QI (match_dup 0) 0) (match_operand:QI
2 "general_operand" "i"))
(set (subreg:QI (match_dup 0) 1) (match_operand:QI
3 "general_operand" "i"))]
"{
HOST_WIDE_INT low = INTVAL(operands[1])&0xfff;
HOST_WIDE_INT high = (INTVAL(operands[1])&0xfff000)
>> 12;
operands[2] = GEN_INT(low);
operands[3] = GEN_INT(high);
}")
(define_split
[(set (match_operand:SI 0 "register_operand" "")
(match_operand:SI 1 "register_operand" ""))]
""
[(set (subreg:HI (match_dup 0) 0)
(subreg:HI(match_dup 1) 0))
(set (subreg:HI (match_dup 0) 2) (subreg:HI
(match_dup 1) 2))]
"")
(define_split
[(set (match_operand:SI 0 "register_operand" "=r")
(match_operand:SI 1 "general_operand" "i"))]
""
[(set (subreg:HI (match_dup 0) 0) (match_operand:HI
2 "general_operand" "i"))
(set (subreg:HI (match_dup 0) 2) (match_operand:HI
3 "general_operand" "i"))]
"{
HOST_WIDE_INT low =
CONST_DOUBLE_LOW(operands[1])&0xffffff;
HOST_WIDE_INT high =
((CONST_DOUBLE_LOW(operands[1])&0xff000000) >>
24)|((CONST_DOUBLE_HIGH(operands[1])&0xffff) << 8);
operands[2] = GEN_INT(low);
operands[3] = GEN_INT(high);
}")
When the compiler split a MOVSI(reg,immediate), into
an HI and then into a QI it just throw an error :
Unrecognizable insn:
(insn 357 190 358 (set (subreg:QI (subreg:HI (reg:SI
16 r16) 0) 0)
(const_int 0 [0x0])) -1 (nil)
(nil))
I'm wondering why this insn is not catch by
define_insn "movqi" as a simple (set (reg:QI would do?
Someone can help me?
Thanks, regards
Pierre
___________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: subreg vs register_operand
2002-09-12 1:09 subreg vs register_operand Pierre Mallard
@ 2002-09-12 14:09 ` Richard Henderson
2002-09-13 2:48 ` Pierre Mallard
0 siblings, 1 reply; 3+ messages in thread
From: Richard Henderson @ 2002-09-12 14:09 UTC (permalink / raw)
To: Pierre Mallard; +Cc: gcc
On Thu, Sep 12, 2002 at 10:09:56AM +0200, Pierre Mallard wrote:
> Unrecognizable insn:
> (insn 357 190 358 (set (subreg:QI (subreg:HI (reg:SI 16 r16) 0) 0)
Nested subregs are illegal.
This happened because you did this:
> [(set (subreg:HI (match_dup 0) 0) ...
You should be using gen_lowpart instead of creating
subregs by yourself.
r~
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: subreg vs register_operand
2002-09-12 14:09 ` Richard Henderson
@ 2002-09-13 2:48 ` Pierre Mallard
0 siblings, 0 replies; 3+ messages in thread
From: Pierre Mallard @ 2002-09-13 2:48 UTC (permalink / raw)
To: Richard Henderson; +Cc: gcc
Thanks for your answer.
This works well for the low_part of the reg but the
high_part seems to be working only when I split a HI
reg into 2 QI reg (wich has the size of
UNIT_PER_WORD).
But when I'm trying to split an SI reg into 2 HI regs,
gen_high_part generate an internal compiler error, due
to the test :
if (GET_MODE_SIZE (mode) > UNITS_PER_WORD
&& GET_MODE_SIZE (mode) != GET_MODE_UNIT_SIZE
(GET_MODE (x)))
abort ();
Is gen_high_part the right expression to generate an
HI register, highpart of an SI register, when the
WORD_SIZE is set on QI?
Pierre
ps : when u have in the assembler mnemonics to
different kind of register size (QI and HI) is it
better to define word as having the size of HI?
--- Richard Henderson <rth@redhat.com> a écrit : > On
Thu, Sep 12, 2002 at 10:09:56AM +0200, Pierre
> Mallard wrote:
> > Unrecognizable insn:
> > (insn 357 190 358 (set (subreg:QI (subreg:HI
> (reg:SI 16 r16) 0) 0)
>
> Nested subregs are illegal.
>
> This happened because you did this:
>
> > [(set (subreg:HI (match_dup 0) 0) ...
>
> You should be using gen_lowpart instead of creating
> subregs by yourself.
>
>
> r~
___________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-09-13 9:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-12 1:09 subreg vs register_operand Pierre Mallard
2002-09-12 14:09 ` Richard Henderson
2002-09-13 2:48 ` Pierre Mallard
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).