public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: How to deal with unrecognizable RTL code
@ 2009-06-24 12:42 daniel tian
  2009-06-25 19:18 ` Jeff Law
  0 siblings, 1 reply; 18+ messages in thread
From: daniel tian @ 2009-06-24 12:42 UTC (permalink / raw)
  To: Dave Korn; +Cc: gcc, peng.zheng, thomas.liau

Hi Dove:

> The docs for PROMOTE_MODE suggest using `word_mode'; it may be that on mips,
> Pmode and word_mode are the same, but they aren't on your machine?
Yes.  I think the Pmode and word_mode is the same as MIPS. So I copy
the code in mips.
I just wanna do the operations in WORD mode, and remove the subreg operations.

> Is one of your MD macros not handling the post-reload REG_OK_STRICT macro
> correctly perhaps?
Yes, REG_OK_STRICT  macro is important. I only do it in macro
GO_IF_LEGITIMATE_ADDRESS:
#define GO_IF_LEGITIMATE_ADDRESS(mode,x,label) \
{\
	if (rice_go_if_legitimate_address(mode,x, RICE_REG_STRICT_P))\
		goto label;\
}

and

#ifndef REG_OK_STRICT

#define RICE_REG_STRICT_P 0

#else /* REG_OK_STRICT */

#define RICE_REG_STRICT_P 1

#endif /* REG_OK_STRICT */

I don't know where I should check it again.

BTW:  After tracing the code and comparing with former code I wrote, I
find something some clues. I added a judgement in almost insn patterns
that if the no_new_pseudos is true, if it is, no more force_reg
operations allowed. And another thing is that I add the SUBREG support
in BASEREG, INDEXREG, and any other register predicate functions used
in MD insn pattern. Like following:

/*Here also, strict and non-strict varients are needed.*/
int rice_reg_ok_for_base(rtx x, int bIsStrict)
{
	int regnum;
	if(GET_CODE(x) != REG && GET_CODE(x) != SUBREG)
		return RICE_NO;
	if(GET_CODE(x) == SUBREG)
	{
		regnum = true_regnum (x);		
	}
	else
		regnum = REGNO(x);
	if(is_base_reg_strict(regnum) && bIsStrict)
		return RICE_YES;
	if(non_strict_base_reg(regnum))
		return RICE_YES;
	return RICE_NO;

}

it will be called in GO_IF_LEGITIMATE_ADDRESS, and
LEGITIMIZE_RELOAD_ADDRESS. So like the following unrecognizable RTL
has gone.

> (insn 264 191 193 15 (set (reg:HI 5 R5)
>         (subreg:HI (mem:SI (plus:SI (reg/f:SI 14 R14)
>                     (const_int 12 [0xc])) [0 crc+0 S4 A32]) 0)) -1 (nil)
>     (nil))
>
> (insn 261 197 200 14 (set (reg:HI 5 R5)
>         (subreg:HI (mem:SI (reg/f:SI 14 R14) [7 crc.16+0 S4 A32]) 0))
> -1
> (nil)
>     (nil))

But still some problems puzzled me. Maybe the two errors are coherent.
I mean they may be the same error.  Like the RTL below(including cc1
error notice):

error: insn does not satisfy its constraints:
(insn:HI 20 539 11 0 (set (reg:SI 6 R6 [orig:88 D.1221 ] [88])
        (mem/s:SI (plus:SI (mem/f:SI (plus:SI (reg/f:SI 14 R14)
                        (const_int 172 [0xac])) [35 frame+0 S4 A32])
                (const_int 4 [0x4])) [13 <variable>.mode+0 S4 A32]))
11 {load_si} (insn_list:REG_DEP_TRUE 12 (nil))
    (nil))

Obviously, the RTL is wrong.  And my load and store patterns:

;;store word
(define_insn "store_<mode>"
	[(set (match_operand:GPR 0 "memory_operand" "=m")
	      (match_operand:GPR 1 "rice_gpr_operand" "r"))]
	"TARGET_RICE"
       {
		return rice_output_move (operands, <MODE>mode);
	}
)

;;Load word
(define_insn "load_<mode>"
	[(set (match_operand:GPR 0 "rice_gpr_operand" "=r")
	      (match_operand:GPR 1 "memory_operand" "m"))]
	"TARGET_RICE"
	 {
		return rice_output_move (operands, <MODE>mode);
	}
[(set_attr "type" "load")]
)

I checked *.22.lreg, the RTL is fine:

(insn:HI 12 13 20 0 (set (reg/v/f:SI 91 [ frame ])
        (reg:SI 5 R5 [ frame ])) 14 {move_regs_si} (nil)
    (expr_list:REG_DEAD (reg:SI 5 R5 [ frame ])
        (nil)))

(insn:HI 20 12 11 0 (set (reg:SI 88 [ D.1221 ])
        (mem/s:SI (plus:SI (reg/v/f:SI 91 [ frame ])
                (const_int 4 [0x4])) [13 <variable>.mode+0 S4 A32]))
11 {load_si} (insn_list:REG_DEP_TRUE 12 (nil))
    (nil))

but in *.23.greg, error occurred:
(insn:HI 20 539 11 0 (set (reg:SI 6 R6 [orig:88 D.1221 ] [88])
        (mem/s:SI (plus:SI (mem/f:SI (plus:SI (reg/f:SI 14 R14)
                        (const_int 172 [0xac])) [35 frame+0 S4 A32])
                (const_int 4 [0x4])) [13 <variable>.mode+0 S4 A32]))
11 {load_si} (insn_list:REG_DEP_TRUE 12 (nil))
    (nil))

The RTL is at the beginning of the function, and R5 is used to pass
parameter. So I think maybe should also trace the parameter passing
function.
Maybe you guys can give me some advices.

Thank you.

-- 
Best Regards
daniel tian
Mavrix Technology, Inc.
Address:200 Zhangheng Road, #3501, Building 3, Zhangjiang Hi-tech
Park, Shanghai, P.R.China (201204)
Tel:86(21)51095958 - 8125
Fax:86(21)50277658
Email:daniel.tian@mavrixtech.com.cn
www.mavrixtech.com

^ permalink raw reply	[flat|nested] 18+ messages in thread
* RE: How to deal with unrecognizable RTL code
@ 2009-07-01  3:02 daniel.tian
  2009-07-01  6:14 ` Jeff Law
  0 siblings, 1 reply; 18+ messages in thread
From: daniel.tian @ 2009-07-01  3:02 UTC (permalink / raw)
  To: 'Jeff Law'; +Cc: gcc

> Which means that reg 91 was spilled (ie, it did not get a hard register
> assigned). You can verify this by looking at reg_equiv_mem[91] just
> before this loop in reload1.c:
> 
> /* This loop scans the entire function each go-round
> and repeats until one repetition spills no additional hard regs. */
> for (;;)
> 
> Presumably reload then replaced reg91 with its equivalent memory
> location in insn 20, thus giving you the somewhat strange looking (mem
> (plus (mem (...)). This is normal behaviour so far. Presumably your port
> rejects (plus (mem (...)) in GO_IF_LEGITIMATE_ADDRESS?
> 
> 
> You'll probably want to put a breakpoint at this point in reload1.c:
> /* Now eliminate all pseudo regs by modifying them into
> their equivalent memory references.
> The REG-rtx's for the pseudos are modified in place,
> so all insns that used to refer to them now refer to memory.
> 
> For a reg that has a reg_equiv_address, all those insns
> were changed by reloading so that no insns refer to it any longer;
> but the DECL_RTL of a variable decl may refer to it,
> and if so this causes the debugging info to mention the variable. */
> 
> When you hit that breakpoint look at insn 20. If it still references
> reg91, then reload thinks that (plus (mem (...))) is a valid address,
> most likely due to a botched GO_IF_LEGITIMATE_ADDRESS macro.
> 
> Jeff
>
Actually, you are right. I have traced the GO_IF_LEGITIMATE_ADDRESS. I do
reject the memory form like (plus (mem (...))). And my Risc do not support
the memory reference like this. You mean I should accept the form in
GO_IF_LEGITIMATE_ADDRESS macro?

Thanks.
	
Daniel.
_______________________________________________

Best Regards

Daniel Tian

Mavrix Technology, Inc.
Address:200 Zhangheng Road, #3501, Building 3, Zhangjiang Hi-tech Park,
Shanghai, P.R.China (201204) 

Tel:86(21)51095958 - 8125

Fax:86(21)50277658

Email:daniel.tian@mavrixtech.com.cn

www.mavrixtech.com



^ permalink raw reply	[flat|nested] 18+ messages in thread
[parent not found: <5885251a0906190727p301b9122k7dcd235dcdd082a4@mail.gmail.com>]
* How to deal with unrecognizable RTL code
@ 2009-06-19  8:08 田晓南
  2009-06-19 11:56 ` Paolo Bonzini
  2009-06-25 18:43 ` Jeff Law
  0 siblings, 2 replies; 18+ messages in thread
From: 田晓南 @ 2009-06-19  8:08 UTC (permalink / raw)
  To: gcc
  Cc: 'Peng Zheng', thomas.liau, 'Ian Lance Taylor',
	'Jeff Law', 'Michael Hope',
	'Joern Rennecke'

Hello, guys:
	The porting is really a difficult and huge job. So many things I
don't know or miss result in countless bugs. 
	I'd like to thank you for your guys in maillist helping so much,
especially, Ian Lance Taylor.
	
     Here I encounter some unrecognizable RTL (R0 to R15 are registers. I
hate the unrecognizable RTL insns always coming about, and I wanna end it.):
(insn 264 191 193 15 (set (reg:HI 5 R5)
        (subreg:HI (mem:SI (plus:SI (reg/f:SI 14 R14)
                    (const_int 12 [0xc])) [0 crc+0 S4 A32]) 0)) -1 (nil)
    (nil))

(insn 261 197 200 14 (set (reg:HI 5 R5)
        (subreg:HI (mem:SI (reg/f:SI 14 R14) [7 crc.16+0 S4 A32]) 0)) -1
(nil)
    (nil))
PROMOTE_MODE, stolen from mips, is defined in my port:
#define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE)	\
  if (GET_MODE_CLASS (MODE) == MODE_INT		\
      && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \
    {                                           \      
      (MODE) = Pmode;                           \
    }
I don't know whether those RTL related with this macro. Yeah, there is a
solution to fix them -- updated the LOAD/STORE constraint. But I don't think
it's a good point.
My RISC chip only accepts the specified RTL which I have already defined
them with insn and expand patterns. So I think there must be a way which
legitimizes RTL code.
 
(insn:HI 17 13 14 0 (set (mem/s:SI (plus:SI (mem/f:SI (reg/f:SI 14 R14) [15
header+0 S4 A32])

                (const_int 32 [0x20])) [10 <variable>.private_bits+0 S4
A32])

        (reg:SI 4 R4 [56])) 8 {store_si} (insn_list:REG_DEP_TRUE 13
(insn_list:REG_DEP_TRUE 6 (nil)))

    (expr_list:REG_EQUAL (const_int 0 [0x0])

        (nil)))

If I have to fix those RTL one by one, that would be so tough! So did there
are some macros or TARGET HOOKs, which retrieve those unknown RTL, then, I
can write code there to force them into specified way.

Any suggestion is appreciated!
Thank you very much!
	
Daniel.Tian
_______________________________________________
Best Regards
Daniel Tian
Tel:86(21)51095958 - 8125
Fax:86(21)50277658
Email:daniel.tian@mavrixtech.com.cn
www.mavrixtech.com



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

end of thread, other threads:[~2009-07-02  3:06 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-24 12:42 How to deal with unrecognizable RTL code daniel tian
2009-06-25 19:18 ` Jeff Law
  -- strict thread matches above, loose matches on Subject: below --
2009-07-01  3:02 daniel.tian
2009-07-01  6:14 ` Jeff Law
2009-07-02  3:06   ` daniel.tian
     [not found] <5885251a0906190727p301b9122k7dcd235dcdd082a4@mail.gmail.com>
2009-06-22  1:56 ` daniel.tian
2009-06-22 11:21   ` Dave Korn
2009-06-19  8:08 田晓南
2009-06-19 11:56 ` Paolo Bonzini
2009-06-24  9:35   ` daniel.tian
2009-06-24  9:36     ` Dave Korn
2009-06-24  9:37       ` Paolo Bonzini
2009-06-24 10:16         ` Dave Korn
2009-06-25 18:43 ` Jeff Law
2009-06-29 10:52   ` daniel.tian
2009-06-29 21:11     ` How " Ian Lance Taylor
2009-06-30  6:20     ` Jim Wilson
2009-06-30 14:22   ` daniel.tian
2009-07-01  2:05     ` Jeff Law

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