reed kotler
2014-Jan-31 23:59 UTC
[LLVMdev] emitting function stub for mips16 floating point patch
I'm rewriting this patch for the stubs to not use outputing of raw text. Generating the instructions is very straightforward and that part is done. I'm translating the actual function now. How do you emit an .ent or .globl from asm printer? .type ? .end ?? .section ??? I'm studying the classes now but it should be simple to do so if you know, you can save me some time because this is another maze of llvm data abstraction. Tia. Reed void MipsAsmPrinter::EmitFPCallStub( const char* Symbol, const Mips16HardFloatInfo::FuncSignature* Signature) { OutStreamer.EmitRawText("\t.globl "+ Twine(Symbol)); ......... OutStreamer.EmitRawText("\t# Stub function to call " + Twine(RetType) + " " + Twine(Symbol) + " (" + Twine(Parms) + ")"); OutStreamer.EmitRawText("\t.section\t.mips16.call.fp"+Twine(Symbol)+",\"ax\", at progbits"); OutStreamer.EmitRawText(".align 2"); OutStreamer.EmitRawText(".nomips16"); OutStreamer.EmitRawText(".nomicromips"); OutStreamer.EmitRawText("\t.ent\t__call_stub_fp_" + Twine(Symbol)); OutStreamer.EmitRawText("\t.type\t__call_stub_fp_" + Twine(Symbol) + ", @function"); OutStreamer.EmitRawText("\t__call_stub_fp_" + Twine(Symbol) + ":"); OutStreamer.EmitRawText("\t.size __call_stub_fp_" + Twine(Symbol) + ", .-__call_stub_fp_" + Twine(Symbol)); OutStreamer.EmitRawText("\t.end __call_stub_fp_" + Twine(Symbol))
reed kotler
2014-Feb-01 00:04 UTC
[LLVMdev] emitting function stub for mips16 floating point patch
On 01/31/2014 03:59 PM, reed kotler wrote:> I'm rewriting this patch for the stubs to not use outputing of raw text. > > Generating the instructions is very straightforward and that part is > done. > > I'm translating the actual function now. > > How do you emit an .ent or .globl from asm printer? > .type ? > .end ?? > .section ??? > > I'm studying the classes now but it should be simple to do so if you > know, you can save me some time > because this is another maze of llvm data abstraction. > > Tia. > > Reed > > >We already have this MIpsTargetStreamer class which seems like a place where this could be added. Given the big storm around any kind of raw text I don't want to add to this if this is already something we are not supposed to be doing.> > > > void MipsAsmPrinter::EmitFPCallStub( > const char* Symbol, const Mips16HardFloatInfo::FuncSignature* > Signature) { > OutStreamer.EmitRawText("\t.globl "+ Twine(Symbol)); > ......... > OutStreamer.EmitRawText("\t# Stub function to call " + Twine(RetType) + > " " + Twine(Symbol) + " (" + Twine(Parms) + > ")"); > OutStreamer.EmitRawText("\t.section\t.mips16.call.fp"+Twine(Symbol)+",\"ax\", at progbits"); > > OutStreamer.EmitRawText(".align 2"); > OutStreamer.EmitRawText(".nomips16"); > OutStreamer.EmitRawText(".nomicromips"); > OutStreamer.EmitRawText("\t.ent\t__call_stub_fp_" + Twine(Symbol)); > OutStreamer.EmitRawText("\t.type\t__call_stub_fp_" + Twine(Symbol) + > ", @function"); > OutStreamer.EmitRawText("\t__call_stub_fp_" + Twine(Symbol) + ":"); > OutStreamer.EmitRawText("\t.size __call_stub_fp_" + Twine(Symbol) + > ", .-__call_stub_fp_" + Twine(Symbol)); > OutStreamer.EmitRawText("\t.end __call_stub_fp_" + Twine(Symbol))
Daniel Sanders
2014-Feb-03 09:59 UTC
[LLVMdev] emitting function stub for mips16 floating point patch
Hi Reed, I think you need to look at: * MCStreamer::SwitchSection() for .section. * MipsTargetStreamer::emitDirectiveEnt() for .ent * MCAsmStreamer::EmitSymbolAttribute() for .globl, and .type I couldn't find a function for .end. I expect it's there but it's difficult to grep for because it clashes with iterators. If there are any directives you need that aren't already supported, you'll need an emitX function for each directive in each of the MIPS target streamers. The one in MipsTargetStreamer should be abstract, the one in MipsAsmTargetStreamer should emit the assembly text, and the one in MipsELFTargetStreamer should do the appropriate thing in the ELF. For your purposes you could leave an llvm_unreachable("Not implemented") in the MipsELFTargetStreamer for now, but it would be great if you could implement that as well since someone will have to do it for the planned assembler anyway. If you do implement MipsELFTargetStreamer::emitX(), you will also need to implement the relevant AsmParser support so that you can test the directive (tests using llc -filetype=obj are not ok). See MipsTargetStreamer::emitDirectiveSetMicroMips() for an example.> -----Original Message----- > From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] > On Behalf Of Reed Kotler > Sent: 01 February 2014 00:04 > To: LLVMdev at cs.uiuc.edu > Subject: Re: [LLVMdev] emitting function stub for mips16 floating point patch > > On 01/31/2014 03:59 PM, reed kotler wrote: > > I'm rewriting this patch for the stubs to not use outputing of raw text. > > > > Generating the instructions is very straightforward and that part is > > done. > > > > I'm translating the actual function now. > > > > How do you emit an .ent or .globl from asm printer? > > .type ? > > .end ?? > > .section ??? > > > > I'm studying the classes now but it should be simple to do so if you > > know, you can save me some time because this is another maze of llvm > > data abstraction. > > > > Tia. > > > > Reed > > > > > > > We already have this MIpsTargetStreamer class which seems like a place > where this could be added. > > Given the big storm around any kind of raw text I don't want to add to this if > this is already something we are not supposed to be doing. > > > > > > > > > void MipsAsmPrinter::EmitFPCallStub( > > const char* Symbol, const Mips16HardFloatInfo::FuncSignature* > > Signature) { > > OutStreamer.EmitRawText("\t.globl "+ Twine(Symbol)); ......... > > OutStreamer.EmitRawText("\t# Stub function to call " + Twine(RetType) + > > " " + Twine(Symbol) + " (" + Twine(Parms) + > > ")"); > > OutStreamer.EmitRawText("\t.section\t.mips16.call.fp"+Twine(Symbol)+", > > \"ax\", at progbits"); > > > > OutStreamer.EmitRawText(".align 2"); > > OutStreamer.EmitRawText(".nomips16"); > > OutStreamer.EmitRawText(".nomicromips"); > > OutStreamer.EmitRawText("\t.ent\t__call_stub_fp_" + Twine(Symbol)); > > OutStreamer.EmitRawText("\t.type\t__call_stub_fp_" + Twine(Symbol) + > > ", @function"); > > OutStreamer.EmitRawText("\t__call_stub_fp_" + Twine(Symbol) + ":"); > > OutStreamer.EmitRawText("\t.size __call_stub_fp_" + Twine(Symbol) + > > ", .-__call_stub_fp_" + Twine(Symbol)); > > OutStreamer.EmitRawText("\t.end __call_stub_fp_" + Twine(Symbol)) > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Rafael Espíndola
2014-Feb-04 16:48 UTC
[LLVMdev] emitting function stub for mips16 floating point patch
On 31 January 2014 18:59, reed kotler <rkotler at mips.com> wrote:> I'm rewriting this patch for the stubs to not use outputing of raw text. > > Generating the instructions is very straightforward and that part is done.awesome!> I'm translating the actual function now. > > How do you emit an .entemitDirectiveEnt in the mips target streamer.> or .globlEmitSymbolAttribute with MCSA_Global> from asm printer? > .type ?EmitSymbolAttribute with MCSA_ELF_Type*> .end ??emitDirectiveEnd on the mips target streamer> .section ???SwitchSection> I'm studying the classes now but it should be simple to do so if you know, > you can save me some time > because this is another maze of llvm data abstraction.The rule of the thumb is that each line in assembly is a method in the streamer or target streamer.> Tia. > > ReedCheers, Rafael
reed kotler
2014-Feb-04 17:05 UTC
[LLVMdev] emitting function stub for mips16 floating point patch
On 02/04/2014 08:48 AM, Rafael Espíndola wrote:> On 31 January 2014 18:59, reed kotler <rkotler at mips.com> wrote: >> I'm rewriting this patch for the stubs to not use outputing of raw text. >> >> Generating the instructions is very straightforward and that part is done. > awesome! > >> I'm translating the actual function now. >> >> How do you emit an .ent > emitDirectiveEnt in the mips target streamer. > >> or .globl > EmitSymbolAttribute with MCSA_Global > >> from asm printer? >> .type ? > EmitSymbolAttribute with MCSA_ELF_Type* > >> .end ?? > emitDirectiveEnd on the mips target streamer > >> .section ??? > SwitchSection > >> I'm studying the classes now but it should be simple to do so if you know, >> you can save me some time >> because this is another maze of llvm data abstraction. > The rule of the thumb is that each line in assembly is a method in the > streamer or target streamer. > >> Tia. >> >> Reed > Cheers, > RafaelTHanks. Your pointers will save some time hunting for the right method. I have 90% of this done already. Now I know where to look for the remaining methods. When I finish this one patch (almost done, which is for a specific bug), I'm planning to start to move all the inline assembly code from pass Mips16HardFloat to this later place in MipsAsmPrinter. Mips16HardFloat pass should shrink to 15% of it's current size. I've already started to move the infrastructure to this place in MipsAsmPrinter. We discussed this a while back and I agreed to eventually do this but it was not clear to me at that time exactly where to move it to and it was much easier for me to do this in the IR pass. Frankly, at that time, I would not have at all thought to move it to AsmPrinter :) . Now I can see where it should go and also understand the gcc mips16 floating point scheme better (undocumented and complicated at the same time) and how it interacts with llvm and such. It makes sense to move it to AsmPrinter because in reality the stubs are just a sophisticated asm directive that must be expanded. There are a few bizarre asm statements that I hardly understand (copied form the gcc mips16 hard float stubs) in some of the yet to be moved stubs. I may need some additional mc methods to handle those. When I get there we can discuss that. This scheme is handshake between gcc, gas and ld (all undocumented of course :))) Reed Reed I'm planning to move most of the inline assembly emission
reed kotler
2014-Feb-04 17:37 UTC
[LLVMdev] emitting function stub for mips16 floating point patch
How is alignment set? On 02/04/2014 08:48 AM, Rafael Espíndola wrote:> On 31 January 2014 18:59, reed kotler <rkotler at mips.com> wrote: >> I'm rewriting this patch for the stubs to not use outputing of raw text. >> >> Generating the instructions is very straightforward and that part is done. > awesome! > >> I'm translating the actual function now. >> >> How do you emit an .ent > emitDirectiveEnt in the mips target streamer. > >> or .globl > EmitSymbolAttribute with MCSA_Global > >> from asm printer? >> .type ? > EmitSymbolAttribute with MCSA_ELF_Type* > >> .end ?? > emitDirectiveEnd on the mips target streamer > >> .section ??? > SwitchSection > >> I'm studying the classes now but it should be simple to do so if you know, >> you can save me some time >> because this is another maze of llvm data abstraction. > The rule of the thumb is that each line in assembly is a method in the > streamer or target streamer. > >> Tia. >> >> Reed > Cheers, > Rafael
Seemingly Similar Threads
- [LLVMdev] emitting function stub for mips16 floating point patch
- [LLVMdev] making emitInlineAsm protected
- [LLVMdev] emitting function stub for mips16 floating point patch
- [LLVMdev] emitting function stub for mips16 floating point patch
- [LLVMdev] emitting function stub for mips16 floating point patch