LLVM  13.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  init(/*IsPointer=*/false, VT.getVectorNumElements() > 1,
22  /*AddressSpace=*/0);
23  } else if (VT.isValid()) {
24  // Aggregates are no different from real scalars as far as GlobalISel is
25  // concerned.
26  assert(VT.getSizeInBits().isNonZero() && "invalid zero-sized type");
27  init(/*IsPointer=*/false, /*IsVector=*/false, /*NumElements=*/0,
28  VT.getSizeInBits(), /*AddressSpace=*/0);
29  } else {
30  IsPointer = false;
31  IsVector = false;
32  RawData = 0;
33  }
34 }
35 
36 void LLT::print(raw_ostream &OS) const {
37  if (isVector())
38  OS << "<" << getNumElements() << " x " << getElementType() << ">";
39  else if (isPointer())
40  OS << "p" << getAddressSpace();
41  else if (isValid()) {
42  assert(isScalar() && "unexpected type");
43  OS << "s" << getScalarSizeInBits();
44  } else
45  OS << "LLT_invalid";
46 }
47 
48 const constexpr LLT::BitFieldInfo LLT::ScalarSizeFieldInfo;
49 const constexpr LLT::BitFieldInfo LLT::PointerSizeFieldInfo;
50 const constexpr LLT::BitFieldInfo LLT::PointerAddressSpaceFieldInfo;
51 const constexpr LLT::BitFieldInfo LLT::VectorElementsFieldInfo;
52 const constexpr LLT::BitFieldInfo LLT::VectorSizeFieldInfo;
53 const constexpr LLT::BitFieldInfo LLT::PointerVectorElementsFieldInfo;
54 const constexpr LLT::BitFieldInfo LLT::PointerVectorSizeFieldInfo;
55 const constexpr LLT::BitFieldInfo LLT::PointerVectorAddressSpaceFieldInfo;
llvm::MVT::getVectorElementType
MVT getVectorElementType() const
Definition: MachineValueType.h:502
llvm
Definition: AllocatorList.h:23
llvm::LLT::getScalarSizeInBits
unsigned getScalarSizeInBits() const
Definition: LowLevelTypeImpl.h:163
llvm::MVT::isVector
bool isVector() const
Return true if this is a vector value type.
Definition: MachineValueType.h:349
llvm::LLT::isValid
bool isValid() const
Definition: LowLevelTypeImpl.h:90
llvm::LLT::print
void print(raw_ostream &OS) const
Definition: LowLevelType.cpp:36
llvm::MVT::isValid
bool isValid() const
Return true if this is a valid simple valuetype.
Definition: MachineValueType.h:317
llvm::LLT::LLT
LLT()
Definition: LowLevelTypeImpl.h:86
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:50
LowLevelTypeImpl.h
llvm::LLT::getAddressSpace
unsigned getAddressSpace() const
Definition: LowLevelTypeImpl.h:178
llvm::LLT::isVector
bool isVector() const
Definition: LowLevelTypeImpl.h:96
llvm::LLT::getNumElements
uint16_t getNumElements() const
Returns the number of elements in a vector LLT.
Definition: LowLevelTypeImpl.h:100
llvm::MVT::getVectorNumElements
unsigned getVectorNumElements() const
Definition: MachineValueType.h:813
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::LLT::isPointer
bool isPointer() const
Definition: LowLevelTypeImpl.h:94
llvm::MVT::getSizeInBits
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
Definition: MachineValueType.h:823
llvm::MVT
Machine Value Type.
Definition: MachineValueType.h:30
llvm::LLT::isScalar
bool isScalar() const
Definition: LowLevelTypeImpl.h:92
llvm::UnivariateLinearPolyBase::isNonZero
bool isNonZero() const
Definition: TypeSize.h:230
llvm::LLT::getElementType
LLT getElementType() const
Returns the vector's element type. Only valid for vector types.
Definition: LowLevelTypeImpl.h:188
raw_ostream.h