This is the mail archive of the gcc@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]

Unable to match instruction pattern


I'm porting gcc to a 16 bit processor. Occasionally compiling source such as

short v1;
long global;

....

global = (long)v1;

results in ...

(insn 11 10 12 2 (set (subreg:HI (mem/c:SI (symbol_ref:HI ("global") <var_decl 0xb7076000 global>) [2 global+0 S4 A16]) 2)
        (const_int 0 [0])) t.c:15 -1
     (nil))
(insn 12 11 13 2 (set (subreg:HI (mem/c:SI (symbol_ref:HI ("global") <var_decl 0xb7076000 global>) [2 global+0 S4 A16]) 0)
        (reg:HI 24 [ D.1348 ])) t.c:15 -1
     (nil))

The second of these instructions successfully matches a movhi pattern which is found via the define_expand below

;the INTEGER iterator includes [QI HI SI]
(define_expand "mov<mode>"
  [(set (match_operand:INTEGER 0 "nonimmediate_operand" "")
    (match_operand:INTEGER 1 "general_operand" ""))]
  ""
  {
    if( can_create_pseudo_p() )
    {
            if( !register_operand( operands[0], <MODE>mode )
                && !register_operand( operands[1], <MODE>mode ))
            {
              /* one of the operands must be in a register.  */
operands[1] = copy_to_mode_reg (<MODE>mode, operands[1]);
            }
     }


However the first instruction fails to match and be expanded so that the const_int is forced into a register. I defined an instruction which is an exact match

(define_insn "*storesic"
  [
(set (subreg:HI (mem:SI (match_operand:HI 0 "symbol_ref_operand" "")) 2)
                    (match_operand:HI 1 "const_int_operand"))
  ]

This matches, however I need a scratch register (R? below) to transform this into

        load    R?, const_int_operand
        store R?, address

and as soon as I add the match_scratch

    (clobber(match_scratch:HI 2 "=r"))


the pattern no longer matches because expand calls recog() with pnum_clobbers = 0 (NULL)

I a similar vein to the way CC setting instructions are handled I tried defining a second instruction containing the required match_scratch prior to the define_insn "*storesic" (see above) in the hope that it may match subsequent to the expand pass, however it is never seen.

Can anyone offer any insight to what I'm doing wrong and how I might proceed ?

Thanks, Paul.













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