1 //===-- LoongArchTargetTransformInfo.cpp - LoongArch specific TTI ---------===// 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 implements a TargetTransformInfo analysis pass specific to the 10 /// LoongArch 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 #include "LoongArchTargetTransformInfo.h" 17 18 using namespace llvm; 19 20 #define DEBUG_TYPE "loongarchtti" 21 22 TypeSize LoongArchTTIImpl::getRegisterBitWidth( 23 TargetTransformInfo::RegisterKind K) const { 24 TypeSize DefSize = TargetTransformInfoImplBase::getRegisterBitWidth(K); 25 switch (K) { 26 case TargetTransformInfo::RGK_Scalar: 27 return TypeSize::getFixed(ST->is64Bit() ? 64 : 32); 28 case TargetTransformInfo::RGK_FixedWidthVector: 29 if (!ST->hasExpAutoVec()) 30 return DefSize; 31 if (ST->hasExtLASX()) 32 return TypeSize::getFixed(256); 33 if (ST->hasExtLSX()) 34 return TypeSize::getFixed(128); 35 [[fallthrough]]; 36 case TargetTransformInfo::RGK_ScalableVector: 37 return DefSize; 38 } 39 40 llvm_unreachable("Unsupported register kind"); 41 } 42 43 // TODO: Implement more hooks to provide TTI machinery for LoongArch. 44