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

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

 



Ian, thanks for replying.
I am performing this task in the prologue in the section where the
hard frame pointer is pushed on the stack.
After that section comes the code:

  allocate = frame.to_allocate;

  if (!frame.save_regs_using_mov)
    ix86_emit_save_regs ();
  else
    allocate += frame.nregs * UNITS_PER_WORD;

here the space for the registers are allocated on the stack and I have
written my code before this one but I haven't allocated a register
specially for this task. So does this count?
If not, please tell me how and where can I allocate the register and
then use my code accordingly.
And by the way, the program is currently showing a segmentation fault
error which I am not able to solve.
I thought that there is some flaws in the code. If so please help me out.
Thank You


On Wed, Apr 14, 2010 at 5:50 AM, Ian Lance Taylor <iant@xxxxxxxxxx> wrote:
> 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
>



-- 
Vaibhav Shrimali
BTech(ICT), DA-IICT
Gandhinagar


[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