LLVM 20.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
20 if (VT.isVector()) {
21 bool asVector = VT.getVectorMinNumElements() > 1 || VT.isScalableVector();
22 init(/*IsPointer=*/false, asVector, /*IsScalar=*/!asVector,
24 /*AddressSpace=*/0);
25 } else if (VT.isValid() && !VT.isScalableTargetExtVT()) {
26 // Aggregates are no different from real scalars as far as GlobalISel is
27 // concerned.
28 init(/*IsPointer=*/false, /*IsVector=*/false, /*IsScalar=*/true,
29 ElementCount::getFixed(0), VT.getSizeInBits(), /*AddressSpace=*/0);
30 } else {
31 IsScalar = false;
32 IsPointer = false;
33 IsVector = false;
34 RawData = 0;
35 }
36}
37
39 if (isVector()) {
40 OS << "<";
41 OS << getElementCount() << " x " << getElementType() << ">";
42 } else if (isPointer())
43 OS << "p" << getAddressSpace();
44 else if (isValid()) {
45 assert(isScalar() && "unexpected type");
46 OS << "s" << getScalarSizeInBits();
47 } else
48 OS << "LLT_invalid";
49}
50
51#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
53 print(dbgs());
54 dbgs() << '\n';
55}
56#endif
57
58const constexpr LLT::BitFieldInfo LLT::ScalarSizeFieldInfo;
59const constexpr LLT::BitFieldInfo LLT::PointerSizeFieldInfo;
60const constexpr LLT::BitFieldInfo LLT::PointerAddressSpaceFieldInfo;
61const constexpr LLT::BitFieldInfo LLT::VectorElementsFieldInfo;
62const constexpr LLT::BitFieldInfo LLT::VectorScalableFieldInfo;
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Definition: Compiler.h:622
Implement a low-level type suitable for MachineInstr level instruction selection.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
raw_pwrite_stream & OS
static constexpr ElementCount getFixed(ScalarTy MinVal)
Definition: TypeSize.h:311
void print(raw_ostream &OS) const
constexpr unsigned getScalarSizeInBits() const
Definition: LowLevelType.h:264
constexpr bool isScalar() const
Definition: LowLevelType.h:146
constexpr bool isValid() const
Definition: LowLevelType.h:145
constexpr bool isVector() const
Definition: LowLevelType.h:148
constexpr bool isPointer() const
Definition: LowLevelType.h:149
constexpr LLT()
Definition: LowLevelType.h:140
constexpr LLT getElementType() const
Returns the vector's element type. Only valid for vector types.
Definition: LowLevelType.h:277
constexpr ElementCount getElementCount() const
Definition: LowLevelType.h:183
constexpr unsigned getAddressSpace() const
Definition: LowLevelType.h:270
LLVM_DUMP_METHOD void dump() const
Machine Value Type.
unsigned getVectorMinNumElements() const
Given a vector type, return the minimum number of elements it contains.
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 isValid() const
Return true if this is a valid simple valuetype.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163