[llvm-commits] [patch] Minor X86CodeEmitter Memory Foot Reduction

Aaron Gray aaronngray.lists at googlemail.com
Mon Jul 6 13:13:34 PDT 2009


> Sorry, I am missing some context. Why is each of the emitter a  separate 
> template instantiation in the first place? Why can't the code  in 
> X86CodeEmitter.cpp be shared across all 3?

If you rememer we generically parameterized X86CodeEmitter, 
ARMBaseCodeEmitter, AlphaCodeEmitter, and the PowerPCCodeEmitter to take 
different machineCodeEmitters, one for JIT, JITCodeEmitter, and one for 
ObjectCodeEmission. Both JITCodeEmitter and ObjectCodeEmitter inherit from 
MachineCodeEmitter, but JITCodeEmitter writes to a buffer where as 
MachineCodeEmitter writes to a vector<byte>.

Basically this patch is a cleanup patch that reduces the need to linkin the 
JITCodeEmitter version of the actual code Emitter if you are only producing 
Object Modules, or coversly the Emitter<ObjectCodeEmitter> if you are doing 
JIT, which is where you may want a small footprint on some embedded device.

Having templates and templated methods into headers is quite common stuff in 
projects which use alot of templating.

Basically everything is transparent and this allow other CodeEmitters to be 
created and added easily. Reid Kleckner may well want to inherit from the 
current JITCodeEmitter and add extra functionality for his unladden swallow 
Python/LLVM project. And having separate .cpp objects means we don't link in 
his code and he only links in what code he needs.

Hope this explains things,

Aaron

> Evan
> On Jul 6, 2009, at 10:57 AM, Aaron Gray wrote:
>
>> This patch separates the template instatiations for the 
>> createX86*CodeEmitterPass of [X86]Emiiter<codeEmitter> into  separate 
>> .cpp file and thus different object modules in the library.  This will 
>> result in a slightly smaller footprint for programs just  using one of 
>> the MachineCodeEmitter, ObjectCodeEmitter, or  JITCodeEmitter classes.
>>
>> This should save 2 * 47K each for llc, lli, and LTOCodeGenerator.
>>
>> Although the MachineCodeEmitter version is not being use anymore at 
>> present I have left it in for now.
>>
>> It also opens the door for altername MachineCodeEmitters for 
>> experimental or other purposes such as unladen Swallow.
>>
>> I will be submitting simular patches for Alpha, ARM, and PowerPC if  this 
>> one gets accepted.
>>
>> I have made CMake the necessary CMake changes too in the patch.
>>
>> This patch needs to be applied relatively quickly as it moves 
>> X86CodeEmitter.cpp code to X86CodeEmitter.h and any chages in SVN 
>> inbetween would be lost.
>>
>> Aaron
>>
>> <x86-Memory-Opt.patch>
> 




More information about the llvm-commits mailing list