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: symbol_ref constants


--- Nathan Sidwell <nathan@codesourcery.com> wrote:
> Sanjiv Kumar Gupta wrote:
> 
> > 
> > Thanks for a prompt reply, Nathan.
> > The add insn can take a symbol_ref, which is
> converted
> > to const_int during relocation. But I don't want
> to
> > allow expressions like (const:SI (plus:SI
> > symbol_ref:SI) (const_int)) in the insn.
> > How should I do that, do I need to implement
> > LEGITIMATE_CONST_P () accordingly?
> 
> you could do that, but I don't understand why
> symref+const
> is not allowed. After all, you could have a
> different plain symref whose
> value was the original symbol+const.
> 
> I.e. why is
> 	add r1,foo+10
> not allowed, but
> 	add r1,baz
> allowed. When linking baz could be defined as
> 'foo+10'.  so what's going
> on?
> 
> nathan
consider the second operand as an 8-bit offset
calculated by linker. 
Now
  add r1, foo
  add r1, 10
  add r1, -10
are okay but 
  add r1, foo + 10
  add r1, -10 
are not, since (foo + 10)  may  overflow during
relocation, so the value (foo + 10) && 0xff inserted
by linker is not correct.

Let me know if I am still not able to explain it.

Regards
--Sanjiv.



		
__________________________________ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/ 


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