1 //=- llvm/Target/TargetTransformImpl.h - Target Loop Trans Info----*- C++ -*-=//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains the target-specific implementations of the
11 // TargetTransform interfaces.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_TARGET_TARGET_TRANSFORMATION_IMPL_H
16 #define LLVM_TARGET_TARGET_TRANSFORMATION_IMPL_H
18 #include "llvm/CodeGen/ValueTypes.h"
19 #include "llvm/TargetTransformInfo.h"
25 /// ScalarTargetTransformInfo - This is a default implementation for the
26 /// ScalarTargetTransformInfo interface. Different targets can implement
27 /// this interface differently.
28 class ScalarTargetTransformImpl : public ScalarTargetTransformInfo {
30 const TargetLowering *TLI;
34 explicit ScalarTargetTransformImpl(const TargetLowering *TL) : TLI(TL) {}
36 virtual bool isLegalAddImmediate(int64_t imm) const;
38 virtual bool isLegalICmpImmediate(int64_t imm) const;
40 virtual bool isLegalAddressingMode(const AddrMode &AM, Type *Ty) const;
42 virtual bool isTruncateFree(Type *Ty1, Type *Ty2) const;
44 virtual bool isTypeLegal(Type *Ty) const;
46 virtual unsigned getJumpBufAlignment() const;
48 virtual unsigned getJumpBufSize() const;
50 virtual bool shouldBuildLookupTables() const;
53 class VectorTargetTransformImpl : public VectorTargetTransformInfo {
55 const TargetLowering *TLI;
57 /// Estimate the cost of type-legalization and the legalized type.
58 std::pair<unsigned, MVT> getTypeLegalizationCost(Type *Ty) const;
60 /// Estimate the overhead of scalarizing an instruction. Insert and Extract
61 /// are set if the result needs to be inserted and/or extracted from vectors.
62 unsigned getScalarizationOverhead(Type *Ty, bool Insert, bool Extract) const;
64 // Get the ISD node that corresponds to the Instruction class opcode.
65 int InstructionOpcodeToISD(unsigned Opcode) const;
68 explicit VectorTargetTransformImpl(const TargetLowering *TL) : TLI(TL) {}
70 virtual ~VectorTargetTransformImpl() {}
72 virtual unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty) const;
74 virtual unsigned getShuffleCost(ShuffleKind Kind, Type *Tp) const;
76 virtual unsigned getCastInstrCost(unsigned Opcode, Type *Dst,
79 virtual unsigned getCFInstrCost(unsigned Opcode) const;
81 virtual unsigned getCmpSelInstrCost(unsigned Opcode, Type *ValTy,
84 virtual unsigned getVectorInstrCost(unsigned Opcode, Type *Val,
85 unsigned Index) const;
87 virtual unsigned getMemoryOpCost(unsigned Opcode, Type *Src,
89 unsigned AddressSpace) const;
91 virtual unsigned getIntrinsicInstrCost(Intrinsic::ID, Type *RetTy,
92 ArrayRef<Type*> Tys) const;
94 virtual unsigned getNumberOfParts(Type *Tp) const;
97 } // end llvm namespace