[LLVMdev] getInstructionName() in XXXGenAsmWriter.cpp

Benjamin Kramer benny.kra at googlemail.com
Fri Mar 30 16:19:07 PDT 2012


On 31.03.2012, at 00:33, Jakob Stoklund Olesen wrote:

> 
> On Mar 30, 2012, at 3:12 PM, Benjamin Kramer <benny.kra at googlemail.com> wrote:
> 
>> 
>> On 30.03.2012, at 23:30, Jakob Stoklund Olesen wrote:
>> 
>>> Is this function required?
>>> 
>>> MCInstrInfo::getName(OpCode) returns the same string, and we have two copies of the string table now.
>>> 
>>> Can MCInstrPrinter refer to MCInstrInfo, and why not?
>> 
>> I looked into this at some point and if my memory serves me correctly using MCInstrInfo in the printer would create a cyclic dependency between the libXXXAsmPrinter and libXXXDesc for the target. I guess libXXXDesc could be refactored not to depend on libXXXAsmPrinter but I haven't checked what exactly uses it.
> 
> I thought it was something like that.
> 
> The AsmPrinter wouldn't need to depend on the XXXMCTargetDesc library, though. It just needs an MCInstrInfo pointer. It already has an MCRegisterInfo pointer.

I see. Adding a MCInstrInfo pointer to MCInstPrinter and using it to get the instruction name should be possible then. It's another object just for debug output but still a lot cheaper than having copies of the huge tables for the names.

> The regIsInRegisterClass() function also looks like it is identical to MCRegisterClass::contains(). It it even used anywhere?

It seems to be used by the asm printers for x86, I replaced the few users with MCRegisterClass::contains and removed the obsolete function in r153782.

- Ben

> 
> /jakob
> 





More information about the llvm-dev mailing list