I'm implementing a port of LLVM for PowerPC VLE. It's a compressed
instruction set similar to mips16 and ARM Thumb. Instruction
encoding (VLE/non-vle) is selected for a given memory region by an
attribute in a memory area descriptor. Targets supporting this that
I know of are all bare-metal (so powerpc-none-elf).
I'm trying to implement ELF support right now. VLE ELF files should
have a section header flag set (SHF_PPC_VLE = 0x10000000). I have
added a subtarget feature "vle", similar to Altivec, SPE, VSX etc
and I'm enabling this feature for appropriate CPUs.
Now, functions that are compiled with "vle" feature should go into
a different text section (text_vle). I can see that TargetMachine
has a method getSubtargetImpl which can be overridden for the
implementation and it can return different subtargets for different
function attributes. What I'm struggling with is connecting it
to section selection; in MCObjectFileInfo::initELFMCObjectFileInfo
a default text section is created but since here section should
be selected based on function, I'm not sure where object file
writer implementation should be "connected" to the subtarget info.
What would be the appropriate place for this kind of logic?