Jason Kim
2010-Oct-21 00:12 UTC
[LLVMdev] Fwd: [llvm-commits] Proof of concept patch for unifying the .s/ELF emission of .ARM.attributes
On Wed, Oct 20, 2010 at 2:56 PM, Rafael Espíndola <rafael.espindola at gmail.com> wrote:>> Gosh, this is taking a while :-) >> Is there anything else I missed? > > Another one I noticed. Instead of > > SmallString<32> *FC = &currFileFragment.getContents(); > (*FC) += static_cast<char>(attr); > (*FC) += static_cast<char>(0xFF & v); > > You can do > > OutStreamer.EmitIntValue(static_cast<char>(attr), 1); > OutStreamer.EmitIntValue(0xFF & v, 1); > > No? Using the streamer interface looks a lot more in line with what > the rest of the code does.Hmm, I wish we had this discussion way earlier.. How would I emit things in different subsections? I can do a high level switch to .ARM.attributes, and if I were emitting one blob from begin to end, using the higher level interface would be preferable, but it contains additional subsections - which are naturally represented by MCDataFragments - Is there an MC equivalent of a SubSection (which is-a Section so I can switch back and forth?) Currently we only have stuff that go into the File subsection only, but.. for futureproofing? I pretty much duplicated style from MCELFObjectWriter.cpp, which does muck with MCDataFragments - (in function WriteRelocation() around line 910 of MCELFObjectWriter.cpp ) I could not find an easier solution. The code currently closely tracks the layout required in the section, and its very simple, which itself was a win. -jason> >> Thanks! >> >> -jason >> > > Cheers, > Rafael >
Rafael Espíndola
2010-Oct-21 14:50 UTC
[LLVMdev] [llvm-commits] Fwd: Proof of concept patch for unifying the .s/ELF emission of .ARM.attributes
> Hmm, I wish we had this discussion way earlier.. > > How would I emit things in different subsections? I can do a high > level switch to .ARM.attributes, and if I were emitting one blob from > begin to end, using the higher level interface would be preferable, > but it contains additional subsections - which are naturally > represented by MCDataFragments - Is there an MC equivalent of a > SubSection (which is-a Section so I can switch back and forth?) > Currently we only have stuff that go into the File subsection only, > but.. for futureproofing?We cross that bridge when we get there. It might be that the best thing to do is organize the code so that we output the subsections in order. It might be to add some missing feature. For now using the regular streamer API will make this code a lot easier to read.> > -jasonCheers, Rafael
Jason Kim
2010-Oct-21 18:07 UTC
[LLVMdev] [llvm-commits] Fwd: Proof of concept patch for unifying the .s/ELF emission of .ARM.attributes
On Thu, Oct 21, 2010 at 7:50 AM, Rafael Espíndola <rafael.espindola at gmail.com> wrote:>> Hmm, I wish we had this discussion way earlier.. >> >> How would I emit things in different subsections? I can do a high >> level switch to .ARM.attributes, and if I were emitting one blob from >> begin to end, using the higher level interface would be preferable, >> but it contains additional subsections - which are naturally >> represented by MCDataFragments - Is there an MC equivalent of a >> SubSection (which is-a Section so I can switch back and forth?) >> Currently we only have stuff that go into the File subsection only, >> but.. for futureproofing? > > We cross that bridge when we get there. It might be that the best > thing to do is organize the code so that we output the subsections in > order. It might be to add some missing feature. For now using the > regular streamer API will make this code a lot easier to read.Of the roughly 111 or so calls to EmitIntValue(), rouighly half are in the Dwarf code, which is cross-architecture. (And they have their own MCSection types to deal with back and forth type issues) Of the 45 remaining, there are 4 interesting uses in MCAsmStreamer.cpp - (I suppose for emitting data constants in a cross platform manner) The other remaining uses are in AsmPrinter, again to do cross platform things. It seems a bit strange to use a high level hammer to do ballpeen work..... But when in Rome.... :-) Also what is the preferred method for MC way of setting out subsection sizes after the fact? I am guessing I need to use an MCFixup? How do I get an MCExpr to evaluate a method for the subsection size? Is there an equivalent use in the places using MCFixup? Do I need to add a new subclass to MCExpr for doing this? JimG, can you please comment on the MachO specific parts in the ARMAsmPrinter.cpp? Is there an example of a "subsection size" that is "Fixed up" after all the blobs that go into that subsection are emitted? The closest examples I could find weren't that close :-( (Matter of fact, for ELF, it looks like the section sizes are actually calculated after everything has been processed by MCAssembler, and the headers sizes are not "fixed up" but completely rewritten from the beginning) Thanks! -jason> >> >> -jason > > Cheers, > Rafael >
Seemingly Similar Threads
- [LLVMdev] [llvm-commits] Fwd: Proof of concept patch for unifying the .s/ELF emission of .ARM.attributes
- [LLVMdev] Fwd: [llvm-commits] Proof of concept patch for unifying the .s/ELF emission of .ARM.attributes
- [LLVMdev] [llvm-commits] Fwd: Proof of concept patch for unifying the .s/ELF emission of .ARM.attributes
- [LLVMdev] [llvm-commits] Fwd: Proof of concept patch for unifying the .s/ELF emission of .ARM.attributes
- [LLVMdev] Fwd: [llvm-commits] Fwd: Proof of concept patch for unifying the .s/ELF emission of .ARM.attributes