summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/TargetTransformImpl.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Switch TargetTransformInfo from an immutable analysis pass that requiresChandler Carruth2013-01-071-388/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | a TargetMachine to construct (and thus isn't always available), to an analysis group that supports layered implementations much like AliasAnalysis does. This is a pretty massive change, with a few parts that I was unable to easily separate (sorry), so I'll walk through it. The first step of this conversion was to make TargetTransformInfo an analysis group, and to sink the nonce implementations in ScalarTargetTransformInfo and VectorTargetTranformInfo into a NoTargetTransformInfo pass. This allows other passes to add a hard requirement on TTI, and assume they will always get at least on implementation. The TargetTransformInfo analysis group leverages the delegation chaining trick that AliasAnalysis uses, where the base class for the analysis group delegates to the previous analysis *pass*, allowing all but tho NoFoo analysis passes to only implement the parts of the interfaces they support. It also introduces a new trick where each pass in the group retains a pointer to the top-most pass that has been initialized. This allows passes to implement one API in terms of another API and benefit when some other pass above them in the stack has more precise results for the second API. The second step of this conversion is to create a pass that implements the TargetTransformInfo analysis using the target-independent abstractions in the code generator. This replaces the ScalarTargetTransformImpl and VectorTargetTransformImpl classes in lib/Target with a single pass in lib/CodeGen called BasicTargetTransformInfo. This class actually provides most of the TTI functionality, basing it upon the TargetLowering abstraction and other information in the target independent code generator. The third step of the conversion adds support to all TargetMachines to register custom analysis passes. This allows building those passes with access to TargetLowering or other target-specific classes, and it also allows each target to customize the set of analysis passes desired in the pass manager. The baseline LLVMTargetMachine implements this interface to add the BasicTTI pass to the pass manager, and all of the tools that want to support target-aware TTI passes call this routine on whatever target machine they end up with to add the appropriate passes. The fourth step of the conversion created target-specific TTI analysis passes for the X86 and ARM backends. These passes contain the custom logic that was previously in their extensions of the ScalarTargetTransformInfo and VectorTargetTransformInfo interfaces. I separated them into their own file, as now all of the interface bits are private and they just expose a function to create the pass itself. Then I extended these target machines to set up a custom set of analysis passes, first adding BasicTTI as a fallback, and then adding their customized TTI implementations. The fourth step required logic that was shared between the target independent layer and the specific targets to move to a different interface, as they no longer derive from each other. As a consequence, a helper functions were added to TargetLowering representing the common logic needed both in the target implementation and the codegen implementation of the TTI pass. While technically this is the only change that could have been committed separately, it would have been a nightmare to extract. The final step of the conversion was just to delete all the old boilerplate. This got rid of the ScalarTargetTransformInfo and VectorTargetTransformInfo classes, all of the support in all of the targets for producing instances of them, and all of the support in the tools for manually constructing a pass based around them. Now that TTI is a relatively normal analysis group, two things become straightforward. First, we can sink it into lib/Analysis which is a more natural layer for it to live. Second, clients of this interface can depend on it *always* being available which will simplify their code and behavior. These (and other) simplifications will follow in subsequent commits, this one is clearly big enough. Finally, I'm very aware that much of the comments and documentation needs to be updated. As soon as I had this working, and plausibly well commented, I wanted to get it committed and in front of the build bots. I'll be doing a few passes over documentation later if it sticks. Commits to update DragonEgg and Clang will be made presently. llvm-svn: 171681
* Refactor the ScalarTargetTransformInfo API for querying about theChandler Carruth2013-01-051-2/+8
| | | | | | | | | | | | legality of an address mode to not use a struct of four values and instead to accept them as parameters. I'd love to have named parameters here as most callers only care about one or two of these, but the defaults aren't terribly scary to write out. That said, there is no real impact of this as the passes aren't yet using STTI for this and are still relying upon TargetLowering. llvm-svn: 171595
* Change the default number of registers to prevent unrolling on targets that ↵Nadav Rotem2013-01-041-1/+1
| | | | | | dont have this hook. llvm-svn: 171489
* LoopVectorizer:Nadav Rotem2013-01-041-0/+4
| | | | | | | | 1. Add code to estimate register pressure. 2. Add code to select the unroll factor based on register pressure. 3. Add bits to TargetTransformInfo to provide the number of registers. llvm-svn: 171469
* Add a subtype parameter to VTTI::getShuffleCostHal Finkel2013-01-031-2/+1
| | | | | | | | | In order to cost subvector insertion and extraction, we need to know the type of the subvector being extracted. No functionality change. llvm-svn: 171453
* Move all of the header files which are involved in modelling the LLVM IRChandler Carruth2013-01-021-1/+1
| | | | | | | | | | | | | | | | | | | | | into their new header subdirectory: include/llvm/IR. This matches the directory structure of lib, and begins to correct a long standing point of file layout clutter in LLVM. There are still more header files to move here, but I wanted to handle them in separate commits to make tracking what files make sense at each layer easier. The only really questionable files here are the target intrinsic tablegen files. But that's a battle I'd rather not fight today. I've updated both CMake and Makefile build systems (I think, and my tests think, but I may have missed something). I've also re-sorted the includes throughout the project. I'll be committing updates to Clang, DragonEgg, and Polly momentarily. llvm-svn: 171366
* CostModel: We have API for checking the costs of known shuffles. This patch addsNadav Rotem2012-12-241-1/+2
| | | | | | support for the insert-subvector and extract-subvector kinds. llvm-svn: 171027
* Change the codegen Cost Model API for shuffeles. This patch removes the API ↵Nadav Rotem2012-12-241-1/+2
| | | | | | for broadcast and adds a more general API that accepts an enum of known shuffles. llvm-svn: 171022
* CostModel: Change the default target-independent implementation for findingNadav Rotem2012-12-231-3/+13
| | | | | | | | the cost of arithmetic functions. We now assume that the cost of arithmetic operations that are marked as Legal or Promote is low, but ops that are marked as custom are higher. llvm-svn: 171002
* Loop Vectorizer: Update the cost model of scatter/gather operations and makeNadav Rotem2012-12-231-8/+2
| | | | | | them more expensive. llvm-svn: 170995
* BB-Vectorizer: Check the cost of the store pointer typeNadav Rotem2012-12-211-0/+1
| | | | | | | and not the return type, which is void. A number of test cases fail after adding the assertion in TTImpl. llvm-svn: 170828
* LoopVectorize: support vectorizing intrinsic callsPaul Redmond2012-12-091-0/+19
| | | | | | | | | - added function to VectorTargetTransformInfo to query cost of intrinsics - vectorize trivially vectorizable intrinsic calls such as sin, cos, log, etc. Reviewed by: Nadav llvm-svn: 169711
* Cost Model: change the default cost of control flow instructions (br / ret / ↵Nadav Rotem2012-12-051-1/+1
| | | | | | ...) to zero. llvm-svn: 169423
* Use the isTruncFree and isZExtFree API to figure out of these operations are ↵Nadav Rotem2012-11-111-2/+10
| | | | | | free. Thanks Andy! llvm-svn: 167685
* Refactor the getTypeLegalizationCost interface. No functionality change.Nadav Rotem2012-11-051-18/+14
| | | | llvm-svn: 167422
* Code Model: Improve the accuracy of the zext/sext/trunc vector cost estimation.Nadav Rotem2012-11-051-3/+10
| | | | llvm-svn: 167412
* Cost Model: teach the cost model about expanding integers.Nadav Rotem2012-11-051-2/+3
| | | | llvm-svn: 167401
* Implement the cost of abnormal x86 instruction lowering as a table.Nadav Rotem2012-11-051-9/+9
| | | | llvm-svn: 167395
* Scalar Bitcasts and Truncs are usually freeNadav Rotem2012-11-021-0/+5
| | | | llvm-svn: 167323
* Fix a bug in the cost calculation of vector casts. Detect situations where ↵Nadav Rotem2012-10-311-26/+41
| | | | | | bitcasts cost zero. llvm-svn: 167170
* Use TargetTransformInfo to control switch-to-lookup table transformationHans Wennborg2012-10-301-1/+6
| | | | | | | | | | | | | | When the switch-to-lookup tables transform landed in SimplifyCFG, it was pointed out that this could be inappropriate for some targets. Since there was no way at the time for the pass to know anything about the target, an awkward reverse-transform was added in CodeGenPrepare that turned lookup tables back into switches for some targets. This patch uses the new TargetTransformInfo to determine if a switch should be transformed, and removes CodeGenPrepare::ConvertLoadToSwitch. llvm-svn: 167011
* Remove an invalid assert in TargetTransformImplHal Finkel2012-10-301-4/+13
| | | | | | | getCastInstrCost had an assert prohibiting scalar to vector casts. Such casts, however, are allowed. This should make the vectorizer buildbot happier. llvm-svn: 166998
* Minor style fixes for TargetTransformationInfo and TargetTransformImplHans Wennborg2012-10-291-3/+3
| | | | llvm-svn: 166936
* Calling TLI->getNumRegisters creates a circular dependency when building ↵Nadav Rotem2012-10-291-2/+4
| | | | | | | | | | LLVM using cmake. Get the number of registers by calling getTypeLegalizationCost. PR14199. llvm-svn: 166911
* Refactor the VectorTargetTransformInfo interface.Nadav Rotem2012-10-261-27/+125
| | | | | | | | | | Add getCostXXX calls for different families of opcodes, such as casts, arithmetic, cmp, etc. Port the LoopVectorizer to the new API. The LoopVectorizer now finds instructions which will remain uniform after vectorization. It uses this information when calculating the cost of these instructions. llvm-svn: 166836
* Better handling of OpcodeToISD using enum/switch.Renato Golin2012-10-261-67/+68
| | | | | | Patch by Pasi Parviainen <pasi.parviainen@iki.fi> llvm-svn: 166773
* Add VectorTargetTransform::getNumberOfParts.Hal Finkel2012-10-261-0/+8
| | | | | | | As discussed on IRC, add VectorTargetTransform::getNumberOfParts to provide a stable interface to the vector legalization splitting factor. llvm-svn: 166751
* Minor cleanups.Nadav Rotem2012-10-251-7/+7
| | | | llvm-svn: 166706
* Implement a basic cost model for vector and scalar instructions. Nadav Rotem2012-10-241-2/+127
| | | | llvm-svn: 166642
* Implement a basic VectorTargetTransformInfo interface to be used by the loop ↵Nadav Rotem2012-10-241-0/+30
| | | | | | and bb vectorizers for modeling the cost of instructions. llvm-svn: 166593
* Reapply the TargerTransformInfo changes, minus the changes to LSR and ↵Nadav Rotem2012-10-181-0/+43
| | | | | | Lowerinvoke. llvm-svn: 166248
* Temporarily revert the TargetTransform changes.Bob Wilson2012-10-181-43/+0
| | | | | | | | | | | The TargetTransform changes are breaking LTO bootstraps of clang. I am working with Nadav to figure out the problem, but I am reverting it for now to get our buildbots working. This reverts svn commits: 165665 165669 165670 165786 165787 165997 and I have also reverted clang svn 165741 llvm-svn: 166168
* Add a new interface to allow IR-level passes to access codegen-specific ↵Nadav Rotem2012-10-101-0/+43
information. llvm-svn: 165665
OpenPOWER on IntegriCloud