Hi - sorry to intrude, but can somebody point me to a suitable mailing list where a tyro can get some advice on modifying an existing llvm llvm assembler ... rather lightly? I want to add an extra instruction to the assembler/machine code supported by the OR1K llvm port. Well, there are a few more things I need to do, but that will be good enough to start with! I was able to what I wanted easily enough for gas, but I don't really see where to start with llvm. The files that do the business seem to be those with ".td" suffixes (which look like they're written in a kind of ML, which is OK with me!). Is that right? I've tried making my additions in lib/Target/OR1K/OR1KInstrFormats.td lib/Target/OR1K/OR1KInstrInfo.td in the llvm (port) source. Surely there must be somewhere where my attempts at additions should be referenced, from, however! Where is that? Regards, and hoping to get a pointer to where I should be posting! PTB
Hi Peter, While I’m not familiar with the OR1K port specifics, since it’s an out of tree port, you’re in the general right place for LLVM related questions, including about the assembler infrastructure. You are correct that the .td files contain most of the information for instructions. All of it for simple instructions, really. Those files are used to create .inc files for asm matchers (it’s a bunch of data tables, and a few helper functions) via the tblgen utility. The main assembler functionality is in the lib/MC library of llvm, with target specific bits in lib/Target/<targetname>/AsmParser. You can start by perusing that code a bit and stepping through the instruction matching. The llvm-mc utility is handy for this, as it’s a developer tool that provides a no-frills front end to the assembler and disassembler engines. -Jim> On Apr 27, 2015, at 1:49 PM, Peter T. Breuer <ptb at inv.it.uc3m.es> wrote: > > Hi - sorry to intrude, but can somebody point me to a suitable mailing > list where a tyro can get some advice on modifying an existing llvm > llvm assembler ... rather lightly? > > I want to add an extra instruction to the assembler/machine code > supported by the OR1K llvm port. > > Well, there are a few more things I need to do, but that will be > good enough to start with! > > I was able to what I wanted easily enough for gas, but I don't really > see where to start with llvm. The files that do the business seem to be > those with ".td" suffixes (which look like they're written in a kind of > ML, which is OK with me!). Is that right? I've tried making my > additions in > > lib/Target/OR1K/OR1KInstrFormats.td > lib/Target/OR1K/OR1KInstrInfo.td > > in the llvm (port) source. Surely there must be somewhere where my > attempts at additions should be referenced, from, however! Where is > that? > > Regards, and hoping to get a pointer to where I should be posting! > > PTB > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
"Also sprach Jim Grosbach:"> out of tree port, youâre in the general right place for LLVM related > questions, including about the assembler infrastructure.Great!> You are correct that the .td files contain most of the information for > instructions. All of it for simple instructions, really. Those files > are used to create .inc files for asm matchers (itâs a bunch of data > tables, and a few helper functions) via the tblgen utility.Aaaaaah. OK. So the .td files are scanned by a woojah and produce .inc files, which get incorporated in other things (parsers, printers, ...). Yes, I can see references to the extra instruction I tried defining coming through in the build dir in the lib/Target/OR1K/OR1KGenAsmMatcher.inc file. That's the only place I can see a reference, however. Is that going to be it?> The main assembler functionality is in the lib/MC library of llvm, > with target specific bits in lib/Target/<targetname>/AsmParser. You can > start by perusing that code a bit and stepping through the instruction > matching. The llvm-mc utility is handy for this, as itâs a developer > tool that provides a no-frills front end to the assembler and > disassembler engines.At the moment that leaves me a bit cold, as I don't know what llvm-mc is for, hence what I might use it for. The "m" in "mc" sounds like "meta", so I guess it's a generic engine of some kind. What kind of input file I might run it on is a mystery to me at the moment, but I see it has some likely looking options -as-lex so I guess it can run over an assembler file. OK, I'll try that. Oooh .. yes, it does do lexing. I see. I suppose it does more things too, per option. I'll check to see if I have done enough to get my extra instruction io Yes, the lexer is happy. I'll see what else ... After adding that one more instruction, which is a "prefix" instruction that allows immediate data for a prefixed instruction to be extended beyond 16 bits, I would like to change the backend so that 1) it recognizes an extra pseudo assembler instruction that puts it in a special mode, and another that gets it out of it again 2) in the special mode, when it sees an assembler instruction with immediate data in, it should emit the machine code for an extra prefix instruction before it. Where would I head over to for those increments? Regards PTB