LLVM  8.0.1
LowLevelType.cpp
Go to the documentation of this file.
1 //===-- llvm/Support/LowLevelType.cpp -------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
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 
17 using namespace llvm;
18 
20  if (VT.isVector()) {
21  init(/*isPointer=*/false, VT.getVectorNumElements() > 1,
23  /*AddressSpace=*/0);
24  } else if (VT.isValid()) {
25  // Aggregates are no different from real scalars as far as GlobalISel is
26  // concerned.
27  assert(VT.getSizeInBits() != 0 && "invalid zero-sized type");
28  init(/*isPointer=*/false, /*isVector=*/false, /*NumElements=*/0,
29  VT.getSizeInBits(), /*AddressSpace=*/0);
30  } else {
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 << "<" << getNumElements() << " x " << getElementType() << ">";
40  else if (isPointer())
41  OS << "p" << getAddressSpace();
42  else if (isValid()) {
43  assert(isScalar() && "unexpected type");
44  OS << "s" << getScalarSizeInBits();
45  } else
46  OS << "LLT_invalid";
47 }
48 
49 const constexpr LLT::BitFieldInfo LLT::ScalarSizeFieldInfo;
50 const constexpr LLT::BitFieldInfo LLT::PointerSizeFieldInfo;
51 const constexpr LLT::BitFieldInfo LLT::PointerAddressSpaceFieldInfo;
52 const constexpr LLT::BitFieldInfo LLT::VectorElementsFieldInfo;
53 const constexpr LLT::BitFieldInfo LLT::VectorSizeFieldInfo;
54 const constexpr LLT::BitFieldInfo LLT::PointerVectorElementsFieldInfo;
55 const constexpr LLT::BitFieldInfo LLT::PointerVectorSizeFieldInfo;
56 const constexpr LLT::BitFieldInfo LLT::PointerVectorAddressSpaceFieldInfo;
This class represents lattice values for constants.
Definition: AllocatorList.h:24
unsigned getScalarSizeInBits() const
bool isVector() const
Return true if this is a vector value type.
bool isScalar() const
unsigned getVectorNumElements() const
bool isValid() const
Return true if this is a valid simple valuetype.
bool isVector() const
LLT getElementType() const
Returns the vector&#39;s element type. Only valid for vector types.
unsigned getSizeInBits() const
MVT getVectorElementType() const
Machine Value Type.
bool isValid() const
unsigned getAddressSpace() const
void print(raw_ostream &OS) const
bool isPointer() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
uint16_t getNumElements() const
Returns the number of elements in a vector LLT.
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:46