LLVM 23.0.0git
LowLevelType.cpp
Go to the documentation of this file.
1//===-- llvm/CodeGenTypes/LowLevelType.cpp
2//---------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9//
10/// \file This file implements the more header-heavy bits of the LLT class to
11/// avoid polluting users' namespaces.
12//
13//===----------------------------------------------------------------------===//
14
17using namespace llvm;
18
19bool LLT::ExtendedLLT = false;
20
22 switch (VT.getScalarType().SimpleTy) {
23 default:
24 llvm_unreachable("Unknown FP format");
25 case MVT::f16:
26 return LLT::FpSemantics::S_IEEEhalf;
27 case MVT::bf16:
28 return LLT::FpSemantics::S_BFloat;
29 case MVT::f32:
30 return LLT::FpSemantics::S_IEEEsingle;
31 case MVT::f64:
32 return LLT::FpSemantics::S_IEEEdouble;
33 case MVT::f80:
34 return LLT::FpSemantics::S_x87DoubleExtended;
35 case MVT::f128:
36 return LLT::FpSemantics::S_IEEEquad;
37 case MVT::ppcf128:
38 return LLT::FpSemantics::S_PPCDoubleDouble;
39 }
40}
41
43 if (!ExtendedLLT) {
44 if (VT.isVector()) {
45 bool AsVector = VT.getVectorMinNumElements() > 1 || VT.isScalableVector();
46 Kind Info = AsVector ? Kind::VECTOR_ANY : Kind::ANY_SCALAR;
47 init(Info, VT.getVectorElementCount(),
49 } else if (VT.isValid() && !VT.isScalableTargetExtVT()) {
51 } else {
52 this->Info = Kind::INVALID;
53 this->RawData = 0;
54 }
55 return;
56 }
57
58 bool IsFloatingPoint = VT.isFloatingPoint();
59 bool AsVector = VT.isVector() &&
61
62 if (AsVector) {
63 if (IsFloatingPoint)
66 else
69 } else if (VT.isValid() && !VT.isScalableTargetExtVT()) {
70 // Aggregates are no different from real scalars as far as GlobalISel is
71 // concerned.
72 if (IsFloatingPoint)
75 else
77 } else {
78 this->Info = Kind::INVALID;
79 this->RawData = 0;
80 }
81 return;
82}
83
84void LLT::print(raw_ostream &OS) const {
85 if (isVector()) {
86 OS << "<";
87 OS << getElementCount() << " x " << getElementType() << ">";
88 } else if (isPointer()) {
89 OS << "p" << getAddressSpace();
90 } else if (isBFloat16()) {
91 OS << "bf16";
92 } else if (isPPCF128()) {
93 OS << "ppcf128";
94 } else if (isFloatIEEE()) {
95 OS << "f" << getScalarSizeInBits();
96 } else if (isInteger()) {
97 OS << "i" << getScalarSizeInBits();
98 } else if (isValid()) {
99 assert(isScalar() && "unexpected type");
100 OS << "s" << getScalarSizeInBits();
101 } else {
102 OS << "LLT_invalid";
103 }
104}
105
106#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
108 print(dbgs());
109 dbgs() << '\n';
110}
111#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Definition Compiler.h:661
static LLT::FpSemantics getFpSemanticsForMVT(MVT VT)
Implement a low-level type suitable for MachineInstr level instruction selection.
static constexpr ElementCount getFixed(ScalarTy MinVal)
Definition TypeSize.h:309
LLVM_ABI void print(raw_ostream &OS) const
constexpr bool isBFloat16() const
constexpr unsigned getScalarSizeInBits() const
constexpr bool isScalar() const
APFloat::Semantics FpSemantics
constexpr bool isInteger() const
constexpr bool isValid() const
constexpr bool isVector() const
constexpr bool isPointer() const
constexpr LLT()
constexpr ElementCount getElementCount() const
constexpr unsigned getAddressSpace() const
LLVM_DUMP_METHOD void dump() const
constexpr bool isFloatIEEE() const
LLT getElementType() const
Returns the vector's element type. Only valid for vector types.
constexpr bool isPPCF128() const
Machine Value Type.
unsigned getVectorMinNumElements() const
Given a vector type, return the minimum number of elements it contains.
SimpleValueType SimpleTy
bool isScalableTargetExtVT() const
Return true if this is a custom target type that has a scalable size.
bool isVector() const
Return true if this is a vector value type.
bool isScalableVector() const
Return true if this is a vector value type where the runtime length is machine dependent.
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
ElementCount getVectorElementCount() const
MVT getVectorElementType() const
bool isFloatingPoint() const
Return true if this is a FP or a vector FP type.
bool isValid() const
Return true if this is a valid simple valuetype.
MVT getScalarType() const
If this is a vector, return the element type, otherwise return this.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
#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.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:207