New Configure Option for LLVM Builds

For the PTX back-end, I would like to introduce a configure-time option to determine the number of architectural registers available to LLVM register allocation during code generation. The motivation for this is PTX is a virtual instruction set and the number of registers is configurable in the output file. Thus, the number of registers specified via tablegen is arbitrary. For different use-cases, it may be desirable to change this number.

That said, my question is in regards to how best to implement this considering that the PTX back-end is a part of upstream LLVM and the new option will be committed to LLVM trunk. Creating a new option seems trivial for the CMake build scripts; just add a special target to automatically generate parts of the PTXRegisterInfo.td file. The Autotools build scripts seem to complicate matters, however. The makefiles for the different back-ends appear to be regular makefiles that are not processed by automake, making it difficult to introduce configure-time variables.

  1. Is the introduction of a configure-time variable in the CMake build scripts an acceptable addition in LLVM trunk?
  2. Is there any precedent for backend-specific configure options? Would the autotools-based build system need to be modified to get something like this to work?

Thanks,

Justin Holewinski

Is it possible to make this option a command-line option to llc instead of a configure-time option?

In my experience, it’s better to make these options command-line options to tools when possible; that way, when someone wants to experiment with changing the parameter, they do not need to recompile.

– John T.

For the PTX back-end, I would like to introduce a configure-time option to determine the number of architectural registers available to LLVM register allocation during code generation. The motivation for this is PTX is a virtual instruction set and the number of registers is configurable in the output file. Thus, the number of registers specified via tablegen is arbitrary. For different use-cases, it may be desirable to change this number.

Is it possible to make this option a command-line option to llc instead of a configure-time option?

Ideally, that would be the way to go. However, as far as I know, LLVM requires static register data that is generated from tablegen files. The only way I can think of changing this data is by automatically generating the tablegen files at configure time.

In my experience, it’s better to make these options command-line options to tools when possible; that way, when someone wants to experiment with changing the parameter, they do not need to recompile.

I completely agree. Unfortunately, I do not believe that is possible in this case (without major LLVM back-end changes).

– John T.

Thanks,

Justin Holewinski

This should be a run-time option.

You should be able to define 'enough' registers in your RegisterInfo.td file, and then simply reserve the registers you don't want.

/jakob

TableGen is not required, you can provide your own TargetRegisterInfo sub-class. That's a lot of work, though, and I wouldn't recommend it.

/jakob

However, as far as I know, LLVM requires static register data that is generated from tablegen files.

TableGen is not required, you can provide your own TargetRegisterInfo sub-class. That’s a lot of work, though, and I wouldn’t recommend it.

That’s an interesting idea. Since the PTX register file is fairly simple (no overlapping, etc.), the generated register info does not seem too complicated.

My main concern would be if the register description structures change, which would require manual changes to the PTX back-end instead of just relying on TableGen being updated to use the new format.

/jakob

Thanks,

Justin Holewinski

Justin Holewinski <justin.holewinski@gmail.com> writes:

[snip]

Is the introduction of a configure-time variable in the CMake build
scripts an acceptable addition in LLVM trunk?

Yes, but I'm just speaking just as the "official" maintainer of the
CMake build so I'm not saying that it is the best solution for your
problem.

If you end adding the configure option, please put it in the PTX target
CMakelists.txt file. Extra bonus if you document it on doc/CMake.html
(you may create a new section "Target-specific options.")

Instead of configuring a header file, try passing the option as a
`define' (add_definitions -DPTX_FOO=BAR)

Is there any precedent for backend-specific configure options?

No, AFAIR, but I don't think it matters if it turns to be the Right
Thing for solving your problem.

Would the autotools-based build system need to be modified to get
something like this to work?

Sure, you need to add the option to the scripts, just like CMake, but
don't know the details. I'll look at the svn log for
autoconf/configure.ac and see what modifications required a similar
change. Then submit a patch for review. Once approved, you need to
regenerate the scripts before committing.

HTH