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: Help restricting args of an intrinsic function



On Jan 30, 2004, at 4:53 PM, Ian Lance Taylor wrote:


Syd Polk <spolk@apple.com> writes:

The problem is this:

   const int shift = 3;
   r2 = __rlwimi (r, arg, shift, 5, 8);

When I get the tree for the third arg, it is of type NOP_EXPR. I tried
just calling default_conversion() from c-typeck.c as an experiment,
knowing that it is C-specific. However, it still came out a NOP_EXPR.

Why must you check this at the tree level? Presumably you will eventually generate some insn. The insn is presumably going to require a const int, since that is what the instruction requires. Can you just have the insn verify that the values are in range, and give an error if not?


I have a constraint function that tries to do this:


/* Return 1 if C is a constant than can be encoded as a shift operator
  in a rlwimi or rlwinm instruction. */

int
shift_operand (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
{
  HOST_WIDE_INT c;

  if (GET_CODE (op) != CONST_INT)
    return 0;

  c = INTVAL (op);
  return ((c >= 0) && (c < 32));
}

gdb shows me that the op has the following rtl for a constant int:

(gdb) p op
$1 = 0x40f0f33c
(gdb) pr
(const_int 5 [0x5])
(gdb)

which is great.

However, for my problem-child argument, it has the following rtl:

(gdb) p op
$2 = 0x77ed2c
(gdb) pr
(mem/u/f:SI (plus:SI (reg/f:SI 114 virtual-stack-vars)
        (const_int 24 [0x18])) [0 shift+0 S4 A32])
(gdb)

How do I collapse it down to a const_int?

I mean, sure, it would be better to handle it at the tree
level--you'll probably give a better error message.  But you can pass
some of the job onto the final pass, can't you?


I would love to be able to do this.



Syd Polk Apple Computer Technology EPM, Mac OS X Development Tools +1 408 974-0577


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