Adding a target-specific TargetTransformInfo implementation
If you remember what you read in Chapter 4, you will know that the TargetTransformInfo
class, from the Analysis
library, is used to get some information about the cost of lowering LLVM IR constructs.
In this section, you will learn how to create your own TargetTransformInfo
implementation to match what your target supports.
Establishing a connection to your target-specific information
The targeting of TargetTransformInfo
goes through a helper class, BasicTTIImplBase
, from the CodeGen
library, which uses the curiously recurring template pattern (CRTP).
Concretely, you must retarget this helper class and then register it with TargetTransformInfo
through your TargetMachine
.
Let’s start with the retargeting of BasicTTIImplBase
.
The following snippet does exactly this:
class H2BLBTTIImpl : public BasicTTIImplBase<H2BLBTTIImpl> {
using BaseT = BasicTTIImplBase<H2BLBTTIImpl>;
using...