LLVM  14.0.0git
LowLevelType.cpp
Go to the documentation of this file.
1 //===-- llvm/Support/LowLevelType.cpp -------------------------------------===//
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 //
9 /// \file This file implements the more header-heavy bits of the LLT class to
10 /// avoid polluting users' namespaces.
11 //
12 //===----------------------------------------------------------------------===//
13 
16 using namespace llvm;
17 
19  if (VT.isVector()) {
20  bool asVector = VT.getVectorNumElements() > 1;
21  init(/*IsPointer=*/false, asVector, /*IsScalar=*/!asVector,
23  /*AddressSpace=*/0);
24  } else if (VT.isValid()) {
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  }
35 }
36 
37 void LLT::print(raw_ostream &OS) const {
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";
48 }
49 
50 const constexpr LLT::BitFieldInfo LLT::ScalarSizeFieldInfo;
51 const constexpr LLT::BitFieldInfo LLT::PointerSizeFieldInfo;
52 const constexpr LLT::BitFieldInfo LLT::PointerAddressSpaceFieldInfo;
53 const constexpr LLT::BitFieldInfo LLT::VectorElementsFieldInfo;
54 const constexpr LLT::BitFieldInfo LLT::VectorScalableFieldInfo;
55 const constexpr LLT::BitFieldInfo LLT::VectorSizeFieldInfo;
56 const constexpr LLT::BitFieldInfo LLT::PointerVectorElementsFieldInfo;
57 const constexpr LLT::BitFieldInfo LLT::PointerVectorScalableFieldInfo;
58 const constexpr LLT::BitFieldInfo LLT::PointerVectorSizeFieldInfo;
59 const constexpr LLT::BitFieldInfo LLT::PointerVectorAddressSpaceFieldInfo;
llvm::MVT::getVectorElementType
MVT getVectorElementType() const
Definition: MachineValueType.h:519
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
llvm::LLT::getScalarSizeInBits
unsigned getScalarSizeInBits() const
Definition: LowLevelTypeImpl.h:213
llvm::MVT::isVector
bool isVector() const
Return true if this is a vector value type.
Definition: MachineValueType.h:366
llvm::LLT::isValid
bool isValid() const
Definition: LowLevelTypeImpl.h:117
llvm::LLT::print
void print(raw_ostream &OS) const
Definition: LowLevelType.cpp:37
llvm::MVT::isValid
bool isValid() const
Return true if this is a valid simple valuetype.
Definition: MachineValueType.h:334
llvm::LLT::LLT
LLT()
Definition: LowLevelTypeImpl.h:112
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
llvm::LinearPolySize< ElementCount >::getFixed
static ElementCount getFixed(ScalarTy MinVal)
Definition: TypeSize.h:284
LowLevelTypeImpl.h
llvm::LLT::getAddressSpace
unsigned getAddressSpace() const
Definition: LowLevelTypeImpl.h:227
llvm::LLT::isVector
bool isVector() const
Definition: LowLevelTypeImpl.h:123
llvm::MVT::getVectorNumElements
unsigned getVectorNumElements() const
Definition: MachineValueType.h:850
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::LLT::isPointer
bool isPointer() const
Definition: LowLevelTypeImpl.h:121
llvm::MVT::getSizeInBits
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
Definition: MachineValueType.h:860
llvm::MVT
Machine Value Type.
Definition: MachineValueType.h:31
llvm::LLT::isScalar
bool isScalar() const
Definition: LowLevelTypeImpl.h:119
llvm::MVT::getVectorElementCount
ElementCount getVectorElementCount() const
Definition: MachineValueType.h:846
llvm::LLT::getElementCount
ElementCount getElementCount() const
Definition: LowLevelTypeImpl.h:144
llvm::LLT::getElementType
LLT getElementType() const
Returns the vector's element type. Only valid for vector types.
Definition: LowLevelTypeImpl.h:237
raw_ostream.h