xref: /freebsd-src/contrib/llvm-project/llvm/lib/Target/LoongArch/LoongArchTargetTransformInfo.h (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
106c3fb27SDimitry Andric //===- LoongArchTargetTransformInfo.h - LoongArch specific TTI --*- C++ -*-===//
206c3fb27SDimitry Andric //
306c3fb27SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
406c3fb27SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
506c3fb27SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
606c3fb27SDimitry Andric //
706c3fb27SDimitry Andric //===----------------------------------------------------------------------===//
806c3fb27SDimitry Andric /// \file
906c3fb27SDimitry Andric /// This file a TargetTransformInfo::Concept conforming object specific to the
1006c3fb27SDimitry Andric /// LoongArch target machine. It uses the target's detailed information to
1106c3fb27SDimitry Andric /// provide more precise answers to certain TTI queries, while letting the
1206c3fb27SDimitry Andric /// target independent and default TTI implementations handle the rest.
1306c3fb27SDimitry Andric ///
1406c3fb27SDimitry Andric //===----------------------------------------------------------------------===//
1506c3fb27SDimitry Andric 
1606c3fb27SDimitry Andric #ifndef LLVM_LIB_TARGET_LOONGARCH_LOONGARCHTARGETTRANSFORMINFO_H
1706c3fb27SDimitry Andric #define LLVM_LIB_TARGET_LOONGARCH_LOONGARCHTARGETTRANSFORMINFO_H
1806c3fb27SDimitry Andric 
1906c3fb27SDimitry Andric #include "LoongArchSubtarget.h"
2006c3fb27SDimitry Andric #include "LoongArchTargetMachine.h"
2106c3fb27SDimitry Andric #include "llvm/Analysis/TargetTransformInfo.h"
2206c3fb27SDimitry Andric #include "llvm/CodeGen/BasicTTIImpl.h"
2306c3fb27SDimitry Andric 
2406c3fb27SDimitry Andric namespace llvm {
2506c3fb27SDimitry Andric 
2606c3fb27SDimitry Andric class LoongArchTTIImpl : public BasicTTIImplBase<LoongArchTTIImpl> {
2706c3fb27SDimitry Andric   typedef BasicTTIImplBase<LoongArchTTIImpl> BaseT;
2806c3fb27SDimitry Andric   typedef TargetTransformInfo TTI;
2906c3fb27SDimitry Andric   friend BaseT;
3006c3fb27SDimitry Andric 
31*0fca6ea1SDimitry Andric   enum LoongArchRegisterClass { GPRRC, FPRRC, VRRC };
3206c3fb27SDimitry Andric   const LoongArchSubtarget *ST;
3306c3fb27SDimitry Andric   const LoongArchTargetLowering *TLI;
3406c3fb27SDimitry Andric 
3506c3fb27SDimitry Andric   const LoongArchSubtarget *getST() const { return ST; }
3606c3fb27SDimitry Andric   const LoongArchTargetLowering *getTLI() const { return TLI; }
3706c3fb27SDimitry Andric 
3806c3fb27SDimitry Andric public:
3906c3fb27SDimitry Andric   explicit LoongArchTTIImpl(const LoongArchTargetMachine *TM, const Function &F)
40*0fca6ea1SDimitry Andric       : BaseT(TM, F.getDataLayout()), ST(TM->getSubtargetImpl(F)),
4106c3fb27SDimitry Andric         TLI(ST->getTargetLowering()) {}
4206c3fb27SDimitry Andric 
437a6dacacSDimitry Andric   TypeSize getRegisterBitWidth(TargetTransformInfo::RegisterKind K) const;
44*0fca6ea1SDimitry Andric   unsigned getNumberOfRegisters(unsigned ClassID) const;
45*0fca6ea1SDimitry Andric   unsigned getRegisterClassForType(bool Vector, Type *Ty = nullptr) const;
46*0fca6ea1SDimitry Andric   unsigned getMaxInterleaveFactor(ElementCount VF);
47*0fca6ea1SDimitry Andric   const char *getRegisterClassName(unsigned ClassID) const;
487a6dacacSDimitry Andric 
4906c3fb27SDimitry Andric   // TODO: Implement more hooks to provide TTI machinery for LoongArch.
5006c3fb27SDimitry Andric };
5106c3fb27SDimitry Andric 
5206c3fb27SDimitry Andric } // end namespace llvm
5306c3fb27SDimitry Andric 
5406c3fb27SDimitry Andric #endif // LLVM_LIB_TARGET_LOONGARCH_LOONGARCHTARGETTRANSFORMINFO_H
55