Re: how to set some value at a memory location in stack

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Vaibhav Shrimali <vaibhav.shrimali@xxxxxxxxx> writes:

> I wanted to know : how to set some value at a particular memory
> location on the stack.
> Suppose I want to set a value stored in a rtx type variable to a
> memory location.
> Is the following code correct?
> I need to read a particular memory location, then XOR it with the hard
> frame pointer and then store it back in its place.
> will this code work?
> Note: Here at (argument pointer - 8) location, I am pushing a copy of
> return address earlier and after that the hard_frame_pointer is
> pushed.
> Now, I want to XOR the duplicate return address with the new
> hard_frame_pointer_rtx generated after pushing the frame pointer on
> the stack.
> I wanted to know that will this code work to do the task?
>
>       arg_ptr = cfun->machine->force_align_arg_pointer;
>       r = gen_rtx_PLUS (Pmode, arg_ptr, -8);
>       r = gen_rtx_MEM (Pmode, r);
>       m = force_reg(Pmode,r);     // OR : m = copy_to_mode_reg(Pmode, r);
>       m1 = simplify_binary_operation(XOR, Pmode, m, hard_frame_pointer_rtx);
>
>       set1 = emit_insn(gen_rtx_SET (Pmode,r, m1));
>       RTX_FRAME_RELATED_P (set1) = 1;
>
>
> If not, please guide me with some solution that would allow me to
> write a rtx variable value to a particular memory location.

I'm guessing that you are doing this after register allocation.  At
that point in the compilation you can no longer call force_reg, as
force_reg will try to create a new pseudo-register which will never
get allocated.  You have to pick a register to use instead.

If you are doing this before register allocation then it looks more or
less OK.  Does it work?

Ian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux