Thanks to visit codestin.com
Credit goes to llvm.org

LLVM 22.0.0git
BPFTargetTransformInfo.h
Go to the documentation of this file.
1//===------ BPFTargetTransformInfo.h - BPF 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//
9// This file uses the target's specific information to
10// provide more precise answers to certain TTI queries, while letting the
11// target independent and default TTI implementations handle the rest.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_LIB_TARGET_BPF_BPFTARGETTRANSFORMINFO_H
16#define LLVM_LIB_TARGET_BPF_BPFTARGETTRANSFORMINFO_H
17
18#include "BPFTargetMachine.h"
22
23namespace llvm {
24class BPFTTIImpl final : public BasicTTIImplBase<BPFTTIImpl> {
25 typedef BasicTTIImplBase<BPFTTIImpl> BaseT;
26 typedef TargetTransformInfo TTI;
27 friend BaseT;
28
29 const BPFSubtarget *ST;
30 const BPFTargetLowering *TLI;
31
32 const BPFSubtarget *getST() const { return ST; }
33 const BPFTargetLowering *getTLI() const { return TLI; }
34
35public:
36 explicit BPFTTIImpl(const BPFTargetMachine *TM, const Function &F)
37 : BaseT(TM, F.getDataLayout()), ST(TM->getSubtargetImpl(F)),
38 TLI(ST->getTargetLowering()) {}
39
41 TTI::TargetCostKind CostKind) const override {
42 if (Imm.getBitWidth() <= 64 && isInt<32>(Imm.getSExtValue()))
43 return TTI::TCC_Free;
44
45 return TTI::TCC_Basic;
46 }
47
49 unsigned Opcode, Type *ValTy, Type *CondTy, CmpInst::Predicate VecPred,
53 const llvm::Instruction *I = nullptr) const override {
54 if (Opcode == Instruction::Select)
55 return SCEVCheapExpansionBudget.getValue();
56
57 return BaseT::getCmpSelInstrCost(Opcode, ValTy, CondTy, VecPred, CostKind,
58 Op1Info, Op2Info, I);
59 }
60
62 unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
66 const Instruction *CxtI = nullptr) const override {
67 int ISD = TLI->InstructionOpcodeToISD(Opcode);
69 return SCEVCheapExpansionBudget.getValue() + 1;
70
71 return BaseT::getArithmeticInstrCost(Opcode, Ty, CostKind, Op1Info,
72 Op2Info);
73 }
74
76 enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const override {
78 Options.LoadSizes = {8, 4, 2, 1};
79 Options.MaxNumLoads = TLI->getMaxExpandSizeMemcmp(OptSize);
80 return Options;
81 }
82
83 unsigned getMaxNumArgs() const override { return 5; }
84};
85
86} // end namespace llvm
87
88#endif // LLVM_LIB_TARGET_BPF_BPFTARGETTRANSFORMINFO_H
This file provides a helper that implements much of the TTI interface in terms of the target-independ...
static cl::opt< OutputCostKind > CostKind("cost-kind", cl::desc("Target cost kind"), cl::init(OutputCostKind::RecipThroughput), cl::values(clEnumValN(OutputCostKind::RecipThroughput, "throughput", "Reciprocal throughput"), clEnumValN(OutputCostKind::Latency, "latency", "Instruction latency"), clEnumValN(OutputCostKind::CodeSize, "code-size", "Code size"), clEnumValN(OutputCostKind::SizeAndLatency, "size-latency", "Code size and latency"), clEnumValN(OutputCostKind::All, "all", "Print all cost kinds")))
static LVOptions Options
Definition LVOptions.cpp:25
#define F(x, y, z)
Definition MD5.cpp:55
#define I(x, y, z)
Definition MD5.cpp:58
This pass exposes codegen information to IR-level passes.
Class for arbitrary precision integers.
Definition APInt.h:78
InstructionCost getIntImmCost(const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind) const override
InstructionCost getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy, CmpInst::Predicate VecPred, TTI::TargetCostKind CostKind, TTI::OperandValueInfo Op1Info={TTI::OK_AnyValue, TTI::OP_None}, TTI::OperandValueInfo Op2Info={TTI::OK_AnyValue, TTI::OP_None}, const llvm::Instruction *I=nullptr) const override
TTI::MemCmpExpansionOptions enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const override
InstructionCost getArithmeticInstrCost(unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind, TTI::OperandValueInfo Op1Info={TTI::OK_AnyValue, TTI::OP_None}, TTI::OperandValueInfo Op2Info={TTI::OK_AnyValue, TTI::OP_None}, ArrayRef< const Value * > Args={}, const Instruction *CxtI=nullptr) const override
BPFTTIImpl(const BPFTargetMachine *TM, const Function &F)
unsigned getMaxNumArgs() const override
InstructionCost getArithmeticInstrCost(unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind, TTI::OperandValueInfo Opd1Info={TTI::OK_AnyValue, TTI::OP_None}, TTI::OperandValueInfo Opd2Info={TTI::OK_AnyValue, TTI::OP_None}, ArrayRef< const Value * > Args={}, const Instruction *CxtI=nullptr) const override
InstructionCost getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy, CmpInst::Predicate VecPred, TTI::TargetCostKind CostKind, TTI::OperandValueInfo Op1Info={TTI::OK_AnyValue, TTI::OP_None}, TTI::OperandValueInfo Op2Info={TTI::OK_AnyValue, TTI::OP_None}, const Instruction *I=nullptr) const override
BasicTTIImplBase(const TargetMachine *TM, const DataLayout &DL)
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition InstrTypes.h:678
virtual const DataLayout & getDataLayout() const
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
TargetCostKind
The kind of cost model.
@ TCK_RecipThroughput
Reciprocal throughput.
@ TCC_Free
Expected to fold away in lowering.
@ TCC_Basic
The cost of a typical 'add' instruction.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:45
@ ADD
Simple integer binary arithmetic operators.
Definition ISDOpcodes.h:259
friend class Instruction
Iterator for Instructions in a `BasicBlock.
Definition BasicBlock.h:73
This is an optimization pass for GlobalISel generic memory operations.
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
Definition MathExtras.h:174
LLVM_ABI cl::opt< unsigned > SCEVCheapExpansionBudget
ArrayRef(const T &OneElt) -> ArrayRef< T >
Returns options for expansion of memcmp. IsZeroCmp is.