First Last Prev Next    No search results available
Details
: Need support for position independent code & relocations
Bug#: 283
: libraries
: Common Code Generator Code
Status: RESOLVED
Resolution: FIXED
: All
: All
: 1.0
: P2
: enhancement
: 1.4

:
: new-feature
:
:
  Show dependency tree - Show dependency graph
People
Reporter: Chris Lattner <sabre@nondot.org>
Assigned To: Chris Lattner <sabre@nondot.org>
:

Attachments


Note

You need to log in before you can comment on or make changes to this bug.

Related actions


Description:   Opened: 2004-03-10 13:20
Our current mechanism for outputing machine code is basically the bare minimum
required to get the JIT working.  Long term, we want to be able to write the
code generated by the JIT out and read it back in as well.  To do this, we will
need to generate relocatable machine code along with a list of relocations.

Currently the code emission process looks something like this:
X86CodeGen: emit an instruction 'mov EAX, [global]'
X86CodeGen: "hey jit, what's the address of global"
JIT       : Hey code generator, it's at 0x12345678
X86CodeGen: Ok, emit 0xAB 0xCD 0x12345678

So currently the code generators produce a stream of binary machine code, but
has to call into the JIT to get the addresses of various globals, constant pool
entries, etc.  Instead the code generator should be independent of the JIT and
produce both machine code and *relocations*, so that it does not need to call
into the JIT at all.

Consumers of this information could choose to write out a native ELF .o file, or
could choose to splat it to memory and then execute it (like the JIT).  Once the
LLVM code generators can write out PIC code, making the JIT cache translations
would be really quite easy :)

-Chris
------- Comment #1 From Chris Lattner 2004-11-22 16:07:11 -------
This is now fixed.  The target code emitters now produce a block of machine code
and a bunch of MachineRelocation objects.  The JIT now uses these to relocate
the machine code to where ever the code ends up.  Both the X86 and V9 JITs have
been updated to use the new interfaces, and I sped up the V9 JIT and fixed bugs
in it in the process (Olden works with the V9 JIT again now, woo!).

This makes the code much cleaner, gets a bunch of JIT-specific cruft out of the
MachineCodeEmitter class, and factors common code out of targets into the JIT. 
For all of these reasons and more it also makes the PPC JIT easier to do.

-Chris

First Last Prev Next    No search results available