1 //===-- llvm/CodeGenTypes/LowLevelType.cpp
2 //---------------------------------===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 /// \file This file implements the more header-heavy bits of the LLT class to
11 /// avoid polluting users' namespaces.
13 //===----------------------------------------------------------------------===//
15 #include "llvm/CodeGenTypes/LowLevelType.h"
16 #include "llvm/Support/raw_ostream.h"
21 bool asVector
= VT
.getVectorMinNumElements() > 1 || VT
.isScalableVector();
22 init(/*IsPointer=*/false, asVector
, /*IsScalar=*/!asVector
,
23 VT
.getVectorElementCount(), VT
.getVectorElementType().getSizeInBits(),
25 } else if (VT
.isValid() && !VT
.isScalableTargetExtVT()) {
26 // Aggregates are no different from real scalars as far as GlobalISel is
28 init(/*IsPointer=*/false, /*IsVector=*/false, /*IsScalar=*/true,
29 ElementCount::getFixed(0), VT
.getSizeInBits(), /*AddressSpace=*/0);
38 void LLT::print(raw_ostream
&OS
) const {
41 OS
<< getElementCount() << " x " << getElementType() << ">";
42 } else if (isPointer())
43 OS
<< "p" << getAddressSpace();
45 assert(isScalar() && "unexpected type");
46 OS
<< "s" << getScalarSizeInBits();
51 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
52 LLVM_DUMP_METHOD
void LLT::dump() const {
58 const constexpr LLT::BitFieldInfo
LLT::ScalarSizeFieldInfo
;
59 const constexpr LLT::BitFieldInfo
LLT::PointerSizeFieldInfo
;
60 const constexpr LLT::BitFieldInfo
LLT::PointerAddressSpaceFieldInfo
;
61 const constexpr LLT::BitFieldInfo
LLT::VectorElementsFieldInfo
;
62 const constexpr LLT::BitFieldInfo
LLT::VectorScalableFieldInfo
;