LLVM 18.0.0git
Go to the documentation of this file.
1//===-- llvm/CodeGen/LowLevelType.cpp -------------------------------------===//
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
9/// \file This file implements the more header-heavy bits of the LLT class to
10/// avoid polluting users' namespaces.
16using namespace llvm;
19 if (VT.isVector()) {
20 bool asVector = VT.getVectorMinNumElements() > 1 || VT.isScalableVector();
21 init(/*IsPointer=*/false, asVector, /*IsScalar=*/!asVector,
23 /*AddressSpace=*/0);
24 } else if (VT.isValid() && !VT.isScalableTargetExtVT()) {
25 // Aggregates are no different from real scalars as far as GlobalISel is
26 // concerned.
27 init(/*IsPointer=*/false, /*IsVector=*/false, /*IsScalar=*/true,
28 ElementCount::getFixed(0), VT.getSizeInBits(), /*AddressSpace=*/0);
29 } else {
30 IsScalar = false;
31 IsPointer = false;
32 IsVector = false;
33 RawData = 0;
34 }
38 if (isVector()) {
39 OS << "<";
40 OS << getElementCount() << " x " << getElementType() << ">";
41 } else if (isPointer())
42 OS << "p" << getAddressSpace();
43 else if (isValid()) {
44 assert(isScalar() && "unexpected type");
45 OS << "s" << getScalarSizeInBits();
46 } else
47 OS << "LLT_invalid";
50#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
52 print(dbgs());
53 dbgs() << '\n';
57const constexpr LLT::BitFieldInfo LLT::ScalarSizeFieldInfo;
58const constexpr LLT::BitFieldInfo LLT::PointerSizeFieldInfo;
59const constexpr LLT::BitFieldInfo LLT::PointerAddressSpaceFieldInfo;
60const constexpr LLT::BitFieldInfo LLT::VectorElementsFieldInfo;
61const constexpr LLT::BitFieldInfo LLT::VectorScalableFieldInfo;
62const constexpr LLT::BitFieldInfo LLT::VectorSizeFieldInfo;
63const constexpr LLT::BitFieldInfo LLT::PointerVectorElementsFieldInfo;
64const constexpr LLT::BitFieldInfo LLT::PointerVectorScalableFieldInfo;
65const constexpr LLT::BitFieldInfo LLT::PointerVectorSizeFieldInfo;
66const constexpr LLT::BitFieldInfo LLT::PointerVectorAddressSpaceFieldInfo;
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Definition: Compiler.h:510
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:298
void print(raw_ostream &OS) const
constexpr unsigned getScalarSizeInBits() const
Definition: LowLevelType.h:257
constexpr bool isScalar() const
Definition: LowLevelType.h:139
constexpr bool isValid() const
Definition: LowLevelType.h:137
constexpr bool isVector() const
Definition: LowLevelType.h:145
constexpr bool isPointer() const
Definition: LowLevelType.h:141
constexpr LLT()
Definition: LowLevelType.h:132
constexpr LLT getElementType() const
Returns the vector's element type. Only valid for vector types.
Definition: LowLevelType.h:280
constexpr ElementCount getElementCount() const
Definition: LowLevelType.h:174
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