LLVM 23.0.0git
SparcTargetTransformInfo.cpp
Go to the documentation of this file.
1//===-- SparcTargetTransformInfo.cpp - SPARC 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
11
12using namespace llvm;
13
14#define DEBUG_TYPE "sparctti"
15
17SparcTTIImpl::getPopcntSupport(unsigned TyWidth) const {
18 assert(isPowerOf2_32(TyWidth) && "Type width must be power of 2");
19 if (ST->usePopc())
21 return TTI::PSK_Software;
22}
23
25 if (Vector)
26 return VRRC;
27 if (Ty &&
28 (Ty->getScalarType()->isFloatTy() || Ty->getScalarType()->isDoubleTy()))
29 return FPRRC;
30 if (Ty && (Ty->getScalarType()->isFP128Ty()))
31 return FP128RRC;
32 return GPRRC;
33}
34
35unsigned SparcTTIImpl::getNumberOfRegisters(unsigned ClassID) const {
36 switch (ClassID) {
37 case GPRRC:
38 // %g0, %g6, %g7, %o6, %i6, and %i7 are used for special purposes so we
39 // discount them here.
40 return 26;
41 case FPRRC:
42 return 32;
43 case FP128RRC:
44 return 16;
45 case VRRC:
46 // TODO We have vector capabilities as part of the VIS extensions, but the
47 // codegen doesn't currently use it. Revisit this when vector codegen is
48 // ready.
49 return 0;
50 }
51
52 llvm_unreachable("Unsupported register class");
53}
54
57 switch (K) {
59 // TODO When targeting V8+ ABI, G and O registers are 64-bit.
60 return TypeSize::getFixed(ST->is64Bit() ? 64 : 32);
62 // TODO We have vector capabilities as part of the VIS extensions, but the
63 // codegen doesn't currently use it. Revisit this when vector codegen is
64 // ready.
65 return TypeSize::getFixed(0);
67 return TypeSize::getScalable(0);
68 }
69
70 llvm_unreachable("Unsupported register kind");
71}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file a TargetTransformInfoImplBase conforming object specific to the SPARC target machine.
unsigned getNumberOfRegisters(unsigned ClassID) const override
TypeSize getRegisterBitWidth(TargetTransformInfo::RegisterKind K) const override
unsigned getRegisterClassForType(bool Vector, Type *Ty=nullptr) const override
TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth) const override
PopcntSupportKind
Flags indicating the kind of support for population count.
static constexpr TypeSize getFixed(ScalarTy ExactSize)
Definition TypeSize.h:343
static constexpr TypeSize getScalable(ScalarTy MinimumSize)
Definition TypeSize.h:346
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
Definition MathExtras.h:279