|
| 1 | +//===- AVRTargetTransformInfo.h - AVR specific TTI ---------*- C++ -*-===// |
| 2 | +// |
| 3 | +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | +// See https://llvm.org/LICENSE.txt for license information. |
| 5 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | +// |
| 7 | +//===----------------------------------------------------------------------===// |
| 8 | +/// \file |
| 9 | +/// This file defines a TargetTransformInfoImplBase conforming object specific |
| 10 | +/// to the AVR target machine. It uses the target's detailed information to |
| 11 | +/// provide more precise answers to certain TTI queries, while letting the |
| 12 | +/// target independent and default TTI implementations handle the rest. |
| 13 | +/// |
| 14 | +//===----------------------------------------------------------------------===// |
| 15 | + |
| 16 | +#ifndef LLVM_LIB_TARGET_AVR_AVRTARGETTRANSFORMINFO_H |
| 17 | +#define LLVM_LIB_TARGET_AVR_AVRTARGETTRANSFORMINFO_H |
| 18 | + |
| 19 | +#include "AVRSubtarget.h" |
| 20 | +#include "AVRTargetMachine.h" |
| 21 | +#include "llvm/Analysis/TargetTransformInfo.h" |
| 22 | +#include "llvm/CodeGen/BasicTTIImpl.h" |
| 23 | +#include "llvm/IR/Function.h" |
| 24 | +#include <optional> |
| 25 | + |
| 26 | +namespace llvm { |
| 27 | + |
| 28 | +class AVRTTIImpl final : public BasicTTIImplBase<AVRTTIImpl> { |
| 29 | + using BaseT = BasicTTIImplBase<AVRTTIImpl>; |
| 30 | + using TTI = TargetTransformInfo; |
| 31 | + |
| 32 | + friend BaseT; |
| 33 | + |
| 34 | + const AVRSubtarget *ST; |
| 35 | + const AVRTargetLowering *TLI; |
| 36 | + |
| 37 | + const AVRSubtarget *getST() const { return ST; } |
| 38 | + const AVRTargetLowering *getTLI() const { return TLI; } |
| 39 | + |
| 40 | +public: |
| 41 | + explicit AVRTTIImpl(const AVRTargetMachine *TM, const Function &F) |
| 42 | + : BaseT(TM, F.getDataLayout()), ST(TM->getSubtargetImpl(F)), |
| 43 | + TLI(ST->getTargetLowering()) {} |
| 44 | + |
| 45 | +#if 0 // TODO Examine if these options result in better code generation |
| 46 | + /// Return the cost of materializing an immediate for a value operand of |
| 47 | + /// a store instruction. |
| 48 | + InstructionCost getStoreImmCost(Type *VecTy, TTI::OperandValueInfo OpInfo, |
| 49 | + TTI::TargetCostKind CostKind) const; |
| 50 | + |
| 51 | + InstructionCost getIntImmCost(const APInt &Imm, Type *Ty, |
| 52 | + TTI::TargetCostKind CostKind) const override; |
| 53 | + InstructionCost getIntImmCostInst(unsigned Opcode, unsigned Idx, |
| 54 | + const APInt &Imm, Type *Ty, |
| 55 | + TTI::TargetCostKind CostKind, |
| 56 | + Instruction *Inst = nullptr) const override; |
| 57 | + InstructionCost |
| 58 | + getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, const APInt &Imm, |
| 59 | + Type *Ty, TTI::TargetCostKind CostKind) const override; |
| 60 | + |
| 61 | + InstructionCost |
| 62 | + getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, |
| 63 | + TTI::TargetCostKind CostKind) const override; |
| 64 | + |
| 65 | + InstructionCost getCmpSelInstrCost( |
| 66 | + unsigned Opcode, Type *ValTy, Type *CondTy, CmpInst::Predicate VecPred, |
| 67 | + TTI::TargetCostKind CostKind, |
| 68 | + TTI::OperandValueInfo Op1Info = {TTI::OK_AnyValue, TTI::OP_None}, |
| 69 | + TTI::OperandValueInfo Op2Info = {TTI::OK_AnyValue, TTI::OP_None}, |
| 70 | + const Instruction *I = nullptr) const override; |
| 71 | +#endif |
| 72 | + |
| 73 | + bool isLSRCostLess(const TargetTransformInfo::LSRCost &C1, |
| 74 | + const TargetTransformInfo::LSRCost &C2) const override {return C1.Insns < C2.Insns;} |
| 75 | +}; |
| 76 | + |
| 77 | +} // end namespace llvm |
| 78 | + |
| 79 | +#endif // LLVM_LIB_TARGET_AVR_AVRTARGETTRANSFORMINFO_H |
0 commit comments