[LLVMdev] MCStreamer interface

Chris Lattner clattner at apple.com
Wed May 5 11:15:10 PDT 2010


On May 4, 2010, at 11:03 AM, Nathan Jeffords wrote:
> This is a brain-dump of my thoughts on the MCStreamer interface after several
> days of digging around trying to get a COFF writer working.

Great!  Something that is worth pointing out is that the MCStreamer API is intended to directly reflect what is happening in .s files.  We basically want one MCStreamer callback to correspond to one statement in the .s file.  This makes it easier to handle from the compiler standpoint, but is also very important for the llvm-mc assembly parser itself.

> All fragments should be associated with a symbol. For assembler components, a
> unnammed "virtual" symbol can be used when there is no explicit label defined.

What do you mean by fragment?  Can you give me an analogy with what the syntax looks like in a .s file, I'm not sure exactly what you mean here.

> Section assignment should be the responsiblity of the object imlementing the
> MCStreamer interface, with the caller givin the ability to give hints as to
> what section to place the symbol into.

Section assignment really needs to happen at a higher level.  The TargetLoweringObjectFile interfaces are the ones responsible for mapping a global/function -> section.  This interface (not mcstreamer) should handle this.

The important point here is that the COFF MCSection needs to have the right level of semantic information.  In fact, MCSection is the place that I'd start for COFF bringup.

> instead of SwitchSection, there would be BeginSymbol, and SymbolSymbol, it would
> be illegal to call any EmitXXX function outside of these two calls
> 
> BeginSymbol(Symbol, SectionHint)
>   EmitAttribute(...)
>   EmitAttribute(...)
>   ...
> StartFragmentEmission()
>   EmitFragment(...)
>   EmitFragment(...)
>   ...
> EndSymbol()
> 
> Object file writers would typically start recording fragments and attributes for
> a symbol on the BeginSymbol, then at EndSymbol they would evaluate what was
> streamed, and decide what section the symbol should be placed in.

Why do you need this?  This concept doesn't exist in the .s file, so I don't think that MCStreamer is the right level for this.

-Chris





More information about the llvm-dev mailing list