[PATCH] Addition to TableGen for dumping intrinsics as XML

The LLVM libraries provide the llvm::Intrinsic::getDeclaration() function, which can provide a standard external declaration for any of the (currently) 762 defined LLVM intrinsics, both for ordinary intrinsics and for overrideable intrinsics with supplied parameter types. Clients that do not link with the LLVM libraries (such as the Open Dylan compiler, which has its own IR and its own bitcode output) do not have access to this facility, however.

In order to make intrinsics information available, the enclosed patch adds a command-line flag which causes TableGen to dump all of the information obtained from parsing Intrinsics.td into an XML output file. This output can then be read by clients or transformed into code or tables using (say) an XSLT script.

The current output of the tool is also enclosed as a sample.


xmlintrinsic.diff (9.66 KB)

Intrinsics.xml (320 KB)


On IRC Dan Gohman expressed some reservations about doing this, given
the incremental burden of yet another emitter backend (this would be
number 28) in TableGen, making it that much harder to refactor and
maintain. I'm not particularly worried about this, given that
XMLIntrinsicEmitter uses the same interface to the rest of TableGen as
the existing IntrinsicEmitter (namely the LoadIntrinsics function and
the CodeGenIntrinsic class).

An alternative, which would permit anyone to generate any information
they need from TableGen would be to embed a Python interpreter,
allowing users to execute arbitrary scripts. These scripts could
traverse the TableGen data model and generate appropriate output;
eventually all of the emitters could be ripped out and replaced with
(likely more concise) scripts. I have seen this approach used to good
effect in the omniORB IDL compiler. It would be a fair amount of work
to implement, however, so I don't want to pursue this approach without
consensus that it would be a good idea. (It would also have to be done
carefully to avoid making the build dependencies for LLVM more

Whatever approach is taken, I (and other people) do need some way of
automatically generating intrinsics information for languages other
than C++ and C, and I'd rather not have to implement my own TableGen


The enclosed patch adds a FileCheck test for the feature.


tg.diff (12.1 KB)

FWIW, I did end up implementing my own (subset of) TableGen in
Dylan. The curious can see it at