Question about TableGen when adding LLVM Backend.

Hello all,

I have some question about usage of TableGen when adding a new LLVM Backend. There are three place to use TableGen in basic steps of document “Writing an LLVM Compiler
Backend”:

  1. Describe the register set of the target. Use “TableGen” to generate code for register definition, register aliases, and register classes from a target-specific RegisterInfo.td input file.

  2. Describe the instruction set of the target. Use “TableGen” to generate code for target-specific instructions from target-specific versions of TargetInstrFormats.td andTargetInstrInfo.td.

  3. Describe the selection and conversion of the LLVM IR from a Directed Acyclic Graph (DAG) representation of instructions to native target-specific instructions. Use “TableGen” to generate code that matches patterns and selects instructions based on additional information in a target-specific version of TargetInstrInfo.td.

I have already read the document “TableGen Fundamentals” and write correspond .td files in each steps. However I don’t know which TableGen options should I use in 2, 3 or 4 steps as above. Would anyone mind to tell me??

thanks a lot

yi-hong

Look at Makefile.rules in the LLVM top-level directory. There is a bunch of targets executing $(TableGen).

You can also run 'make VERBOSE=1' to see the commands used to build the existing targets.

/jakob

Hello Jakob,

Is this means that TableGen execution is handled in Makefile. Porting programmer doesn’t need to execute TableGen by hand?

thanks

2011/3/10 Jakob Stoklund Olesen <stoklund@2pi.dk>

That's right.

You are going to be editing your .td files a lot, so you want that integrated in the build system.

In practice that'll mean adding the correct directives to CMakeLists.txt, not Makefile, right? That's what the targets I looked at did.
Or is that optional when you just invoke "make"?

Andreas

Hi Andreas,

In practice that'll mean adding the correct directives to
CMakeLists.txt, not Makefile, right? That's what the targets I looked
at did.

LLVM can be built using either CMake or the GNU Autotools. Your backend
ought to provide support for both build systems, so you should create a
CMakeLists.txt as well as a Makefile in your sub-directory.
The Makefile appears to be rather trivial because there's some automagic
going on - nevertheless, you will need one. :slight_smile:

Or is that optional when you just invoke "make"?

In that case you're using the Autotools, so your Makefile is going to be
utilized.

Best regards,
Christoph

Hi Christoph,

In practice that'll mean adding the correct directives to
CMakeLists.txt, not Makefile, right? That's what the targets I looked
at did.

LLVM can be built using either CMake or the GNU Autotools. Your backend
ought to provide support for both build systems, so you should create a
CMakeLists.txt as well as a Makefile in your sub-directory.

The Makefile appears to be rather trivial because there's some automagic
going on - nevertheless, you will need one. :slight_smile:

Now I see: My confusion came from seeing only the customized file names in BUILT_SOURCES. But Makefile.rules:1681 actually processes those files by *Gen*.inc.tmp name patterns.

Thanks for explaining,

Andreas

Those are part of two unrelated build systems - cmake and autoconf.

You need to maintain both for an in-tree target. Otherwise you only need build files for the build system you use.

/jakob