[LLVMdev] MachO and ELFWriters/MachineCodeEmittersarehard-codedinto LLVMTargetMachine

Aaron Gray aaronngray.lists at googlemail.com
Mon Mar 16 10:56:26 PDT 2009


> Aaron, I mailed in the same mail twice (by mistake), you answered both
> copies. Differently!
>
> In any case, I've re-read what exists. I'm dumping what I understand
> here, so that we can discuss in detail. I'm using MachO as the example
> object format, as the ELF code is totally broken and outdated. Lets
> use the following as the basis for our discussion?

I've never looked at the MachO code as I do not have such a platform nor do 
I know the file format.

Could we concentrate on the ELF backend, please.


> 3. X86CodeEmitter
>   - a MachineFunctionPass, NOT a MachineCodeEmitter (Could the naming
> change perhaps?)

Yes, it uses a MachineCodeEmitter in its internals (MCE) and as a 
constructor argument.

> This class receives (during construction) a reference to a
> MachineCodeEmitter (e.g. MachOCodeEmitter, which in turn stores a
> reference to a MachOWritter).
>
> The runOnMachineFunction for the X86CodeEmitter does:
> - call MachOCodeEmitter::startFunction
> - for each basicblock in function:
>   - call MachOCodeEmitter::StartMachineBasicBlock
>   - for each instruction in basicblock:
>       - emit instruction, using MachineCodeEmitter::emit* functions
> - call MachOCodeEmitter::finishFunction
>
> [This runOnMachineFunction could definitely be generalized, i.e.
> implemented in a base class ('EmitterMachineFunctionPass' or a better
> name). This base class would then have (abstract) emitInstruction,
> emitOperand, etc... methods. It should also integrate with the
> *GenCodeEmitter emitted by tblgen so that you get automatic code
> emission. When implementing a new target, one would simply need to
> inherit the baseclass, and override the functions necessary to tweak
> output.]

runOnMachineFunction is a standard LLVM message we cannot play around with 
it.

Please read LLVM code more and get a general overview of the standard 
interfaces.

Aaron


> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev 




More information about the llvm-dev mailing list