[llvm-commits] [patch] "TargetTransform" as an API between codegen and IR-level passes

Nadav Rotem nrotem at apple.com
Tue Oct 9 16:37:00 PDT 2012


Hi, 

Following the discussion that we had on the mailing list and on IRC I implemented an abstraction layer to separate IR-level passes from the codegen. Passes such as Loop-Strength-Reduce rely on the CodeGen for querying target-specific information (such as the legality of types).  In the future we plan to add new passes (vectorizer!!) which will rely heavily on target-specific information.  So, before things get out of hand, we agreed that we need to define an interface. The idea is that IR-level transformations that live in /Transforms/ must not include files from /Target. We also don't want to create one mega analysis that will expose everything in the codegen.  Following Evan's suggestion, I created a number of classes that can provide different codegen specific information. Every class provides information for a different set of optimizations. Currently only one interface is implemented and I ported LSR and LowerInvoke to use it. 

Here's the general design.  We have a new Analysis pass called "TargetTransformInfo". Much like DataLayout (until recentlyTargetData), it exists in the pass manager and can be obtained using getAnalysisIfAvailable call.  This analysis can provide a number of classes. Currently there are two interfaces: ScalarTransformInfo, which is used by scalar transformation such as LSR and LowerInvoke,  and VectorTransformInfo, which is currently empty, and will be used by the vectorizers. The XXXTransformInfo classes are abstract classes which are implemented by concrete codegen classes. When the TargetMachine is initialized it creates the concrete XXXTargetTransformImpl classes and add creates the TargetTransformInfo analysis pass. Notice that the interface that the XXXinfo classes exposes is IR-level interface. 

This patch includes the following changes, broken into three patches. :

1. The new TargetTransform classes (TargetTransform_Infra.diff)
2. Changes to LSR and LowerInvoke to use this new infrastructure and break the dependency on TLI (TargetTransform_Passes.diff).
3. Changes to the command line tools OPT and LLC.  Opt now links with the codegen (TargetTransform_tools.diff).

-------------- next part --------------
A non-text attachment was scrubbed...
Name: TargetTransform_everything.diff
Type: application/octet-stream
Size: 62512 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121009/fea3f9e0/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TargetTransform_Infra.diff
Type: application/octet-stream
Size: 11063 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121009/fea3f9e0/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TargetTransform_tools.diff
Type: application/octet-stream
Size: 22122 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121009/fea3f9e0/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TargetTransform_Passes.diff
Type: application/octet-stream
Size: 32397 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121009/fea3f9e0/attachment-0003.obj>
-------------- next part --------------


Thanks,
Nadav

Here is a small diagram of the different components:

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Chart.001.jpeg
Type: image/jpg
Size: 26676 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121009/fea3f9e0/attachment.jpg>


More information about the llvm-commits mailing list