ryan baird
2012-Sep-08 15:07 UTC
[LLVMdev] Create target with alternate syntax for globals?
I'm working on building a target for llvm that's the intermediate language of another compiler, so that the other compiler can benifit from llvm's optimization passes. I essentially made a copy of the mips backend, and then started changing the output to match the intermediate language of the compiler. Most of the output can be overriden, but I haven't figured out how to change the way globals are emitted. The AsmPrinter::EmitGlobalVariable function in the llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp file is not virtual; if I try to override it, I get a "multiple definitions" error. To emit the global, it just calls the OutputStreamer.EmitCommonSymbol method. Again, this has become a problem because I don't want the default output for global symbols. If I can't override this method, how can I change the way that my target outputs globals variables? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120908/bbbd2613/attachment.html>
ryan baird
2012-Sep-08 15:58 UTC
[LLVMdev] Create target with alternate syntax for globals?
Update for anyone else that comes across this: You have to register an ASM streamer, and overide the EditCommonSymbol method. On Sat, Sep 8, 2012 at 9:07 AM, ryan baird <ryanrbaird at gmail.com> wrote:> I'm working on building a target for llvm that's the intermediate language > of another compiler, so that the other compiler can benifit from llvm's > optimization passes. > > I essentially made a copy of the mips backend, and then started changing > the output to match the intermediate language of the compiler. Most of the > output can be overriden, but I haven't figured out how to change the way > globals are emitted. > > The AsmPrinter::EmitGlobalVariable function in the > llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp file is not virtual; if I try to > override it, I get a "multiple definitions" error. To emit the global, it > just calls the OutputStreamer.EmitCommonSymbol method. Again, this has > become a problem because I don't want the default output for global > symbols. If I can't override this method, how can I change the way that my > target outputs globals variables? >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120908/36935579/attachment.html>
NAKAMURA Takumi
2012-Sep-09 00:50 UTC
[LLVMdev] Create target with alternate syntax for globals?
2012/9/9 ryan baird <ryanrbaird at gmail.com>:> I'm working on building a target for llvm that's the intermediate language > of another compiler, so that the other compiler can benifit from llvm's > optimization passes. > > I essentially made a copy of the mips backend, and then started changing the > output to match the intermediate language of the compiler. Most of the > output can be overriden, but I haven't figured out how to change the way > globals are emitted. > > The AsmPrinter::EmitGlobalVariable function in the > llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp file is not virtual; if I try to > override it, I get a "multiple definitions" error. To emit the global, it > just calls the OutputStreamer.EmitCommonSymbol method. Again, this has > become a problem because I don't want the default output for global symbols. > If I can't override this method, how can I change the way that my target > outputs globals variables?Ryan, On which version are you working? I can see, since r93858; Author: Chris Lattner <sabre at nondot.org> Date: Tue Jan 19 14:38:33 2010 + virtual void EmitGlobalVariable(const GlobalVariable *GV); It seems XCoreAsmPrinter overrides some methods. ...Takumi
ryan baird
2012-Sep-09 14:20 UTC
[LLVMdev] Create target with alternate syntax for globals?
I'm working on 3.1. For now I added a custom AsmStreamer, but it's nice to know that this will be fixed in 3.2. On Sat, Sep 8, 2012 at 6:50 PM, NAKAMURA Takumi <geek4civic at gmail.com>wrote:> 2012/9/9 ryan baird <ryanrbaird at gmail.com>: > > I'm working on building a target for llvm that's the intermediate > language > > of another compiler, so that the other compiler can benifit from llvm's > > optimization passes. > > > > I essentially made a copy of the mips backend, and then started changing > the > > output to match the intermediate language of the compiler. Most of the > > output can be overriden, but I haven't figured out how to change the way > > globals are emitted. > > > > The AsmPrinter::EmitGlobalVariable function in the > > llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp file is not virtual; if I try > to > > override it, I get a "multiple definitions" error. To emit the global, > it > > just calls the OutputStreamer.EmitCommonSymbol method. Again, this has > > become a problem because I don't want the default output for global > symbols. > > If I can't override this method, how can I change the way that my target > > outputs globals variables? > > Ryan, > > On which version are you working? I can see, since r93858; > > Author: Chris Lattner <sabre at nondot.org> > Date: Tue Jan 19 14:38:33 2010 > > + virtual void EmitGlobalVariable(const GlobalVariable *GV); > > It seems XCoreAsmPrinter overrides some methods. > > ...Takumi >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120909/70bcb55f/attachment.html>