compiler-errorscompiler-constructionllvmcustom-backendllvm-3.0

What command line exactly should one use to produce all the records from a <Target>RegisterInfo.td file?


Background things: Thus far I have read from the llvm tutorials, including: The Table Gen Command Guide

Table Gen's General Documentation, especially the Running TableGen section

I am currently writing code for a new target for llvm, which I am not allowed to post here. I'm using the X86 Target for the context of my question because it's still applicable to that target.

What I am trying to do: I am trying to use tablegen to generate the records from X86RegisterInfo.td The command line I am using is this:

llvm-tblgen X86RegisterInfo.td -class=Register -I/home/des_fw/fler_llvm/llvm/include

which returns this error

X86RegisterInfo.td:16:43: error: Couldn't find class 'Register'
class X86Reg<string n, bits<16> Enc, list<Register> subregs = []> : Register<n> {
                                      ^

I was able to run the sample command for X86.td given in the Running TableGen reference above, so I am pretty confident that the include path -I/.../... is correct because without it written in this way, the command doesn't run. I am also running my command in the same directory, the ../Target/X86, as the sample command that works.

What is the correct command to use so that the TableGen tool will produce the records for the X86RegisterInfo.td file (or in general for XXXRegisterInfo.td where XXX is the target name)?

I am very new to LLVM and customizing or writing compilers in general, so I'm praying it's just me not understanding how to use the command line, but if it could be an entirely different issue as well, any tips to point me in the right direction are all extremely appreciated.

Thank you very much!


Solution

  • I believe I have found the answer to my own question. The command line should be

    llvm-tblgen X86.td -gen-register-info -I/home/des_fw/fler_llvm/llvm/include
    

    because

    "On all LLVM back-ends, the llvm-tblgen binary will be executed on the root TableGen file .td, which should include all others. This guarantees that all information needed is accessible, and that no duplication is needed in the TbleGen files." (http://llvm.org/docs/TableGen/BackEnds.html#llvm-backends)

    and I used the

    -gen-register-info
    

    option found at the site I mentioned in my question: http://llvm.org/docs/CommandGuide/tblgen.html

    So the whole command line in general is

    llvm-tblgen TargetNameHere.td -back-end-opt-for-specific-record-set -I/path/to/file/include/