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
7 //===----------------------------------------------------------------------===//
9 /// \file This file implements the more header-heavy bits of the LLT class to
10 /// avoid polluting users' namespaces.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/CodeGen/LowLevelType.h"
15 #include "llvm/Support/raw_ostream.h"
20 bool asVector
= VT
.getVectorMinNumElements() > 1 || VT
.isScalableVector();
21 init(/*IsPointer=*/false, asVector
, /*IsScalar=*/!asVector
,
22 VT
.getVectorElementCount(), VT
.getVectorElementType().getSizeInBits(),
24 } else if (VT
.isValid() && !VT
.isScalableTargetExtVT()) {
25 // Aggregates are no different from real scalars as far as GlobalISel is
27 init(/*IsPointer=*/false, /*IsVector=*/false, /*IsScalar=*/true,
28 ElementCount::getFixed(0), VT
.getSizeInBits(), /*AddressSpace=*/0);
37 void LLT::print(raw_ostream
&OS
) const {
40 OS
<< getElementCount() << " x " << getElementType() << ">";
41 } else if (isPointer())
42 OS
<< "p" << getAddressSpace();
44 assert(isScalar() && "unexpected type");
45 OS
<< "s" << getScalarSizeInBits();
50 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
51 LLVM_DUMP_METHOD
void LLT::dump() const {
57 const constexpr LLT::BitFieldInfo
LLT::ScalarSizeFieldInfo
;
58 const constexpr LLT::BitFieldInfo
LLT::PointerSizeFieldInfo
;
59 const constexpr LLT::BitFieldInfo
LLT::PointerAddressSpaceFieldInfo
;
60 const constexpr LLT::BitFieldInfo
LLT::VectorElementsFieldInfo
;
61 const constexpr LLT::BitFieldInfo
LLT::VectorScalableFieldInfo
;
62 const constexpr LLT::BitFieldInfo
LLT::VectorSizeFieldInfo
;
63 const constexpr LLT::BitFieldInfo
LLT::PointerVectorElementsFieldInfo
;
64 const constexpr LLT::BitFieldInfo
LLT::PointerVectorScalableFieldInfo
;
65 const constexpr LLT::BitFieldInfo
LLT::PointerVectorSizeFieldInfo
;
66 const constexpr LLT::BitFieldInfo
LLT::PointerVectorAddressSpaceFieldInfo
;