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]

Re: Implementing a restrictive addressing mode for a gcc port


On Tue, Apr 1, 2008 at 2:10 AM, Jim Wilson <wilson@tuliptree.org> wrote:
> Mohamed Shafi wrote:
>>
>> For the source or the destination register Rd/Ra, the restriction is
>> that it should be one more than the base register . So the following
>> instructions are valid:
>
> GCC doesn't provide any easy way for the source address to depend on the
> destination address, or vice versa.
>
> One thing you could try is generating a double-word pseudo-reg at RTL expand
> time, and then using subreg 0 for the source and subreg 1 for the dest (or
> vice versa depending on endianness/word order).  This will get you a
> register pair you can use from the register allocator.  This doesn't help at
> reload time though.

Ok, whatever i tried to do didn't work properly. So i am trying to
implement the way you have suggested.
In define_expand for movhi i have the following code to generate
double word pseudo-reg.

.....
    rtx dword,base,reg;
    HOST_WIDE_INT offset;

    offset = INTVAL(XEXP(XEXP(mem_op, 0), 1));
    siwrd = gen_reg_rtx (SImode);
    base = simplify_gen_subreg (HImode, dword, SImode, 0);
    reg = simplify_gen_subreg (HImode, dword, SImode, 2);

    if (GET_CODE (operands[0]) == MEM)
      {
        operands[0] = gen_rtx_MEM (Pmode, plus_constant (base, offset));
        operands[1] = reg;
      }
    else if (GET_CODE (operands[1]) == MEM)
      {
        operands[1] = gen_rtx_MEM (Pmode, plus_constant (base, offset));
        operands[0] = reg;
      }

I hope i am doing correctly.


>
> You probably have to define a constraint for every register, and then write
> an alternative for every register pair matching the correct even register
> with the correct odd register.  That gets you past reload.
>

I have defined a constraint for all the registers. But i am not sure
as how to use them
in the pattern.

  [(set (match_operand:HI 0 "register_operand" "=r")
      	(match_operand:HI 1 "memory_operand" "m"))]

I have to add the constraints along with 'm' and 'r'. But the new
constraints are suppose to
indicate the register that has to be used. So i have defined
REG_CLASS_FROM_CONSTRAINT
macro to return the reg class of a particular constraint. But i am not
sure how this can be used
with a memory operand.  Should i be defining EXTRA_MEMORY_CONSTRAINT?
Can i directly use the register constraints for a memory operand?

Thanks for your time.

Regards,
Shafi


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