diff --git a/clang/lib/CodeGen/CMakeLists.txt b/clang/lib/CodeGen/CMakeLists.txt --- a/clang/lib/CodeGen/CMakeLists.txt +++ b/clang/lib/CodeGen/CMakeLists.txt @@ -3,6 +3,7 @@ Analysis BitReader BitWriter + CodeGen Core Coroutines Coverage diff --git a/llvm/include/llvm/CodeGen/LowLevelType.h b/llvm/include/llvm/CodeGen/LowLevelType.h --- a/llvm/include/llvm/CodeGen/LowLevelType.h +++ b/llvm/include/llvm/CodeGen/LowLevelType.h @@ -9,21 +9,425 @@ /// Implement a low-level type suitable for MachineInstr level instruction /// selection. /// -/// This provides the CodeGen aspects of LowLevelType, such as Type conversion. +/// For a type attached to a MachineInstr, we only care about 2 details: total +/// size and the number of vector lanes (if any). Accordingly, there are 4 +/// possible valid type-kinds: +/// +/// * `sN` for scalars and aggregates +/// * `` for vectors, which must have at least 2 elements. +/// * `pN` for pointers +/// +/// Other information required for correct selection is expected to be carried +/// by the opcode, or non-type flags. For example the distinction between G_ADD +/// and G_FADD for int/float or fast-math flags. /// //===----------------------------------------------------------------------===// #ifndef LLVM_CODEGEN_LOWLEVELTYPE_H #define LLVM_CODEGEN_LOWLEVELTYPE_H +#include "llvm/ADT/DenseMapInfo.h" +#include "llvm/CodeGen/MachineValueType.h" #include "llvm/CodeGen/ValueTypes.h" -#include "llvm/Support/LowLevelTypeImpl.h" +#include "llvm/Support/Debug.h" +#include namespace llvm { class DataLayout; class Type; struct fltSemantics; +class raw_ostream; + +class LLT { +public: + /// Get a low-level scalar or aggregate "bag of bits". + static constexpr LLT scalar(unsigned SizeInBits) { + return LLT{/*isPointer=*/false, /*isVector=*/false, /*isScalar=*/true, + ElementCount::getFixed(0), SizeInBits, + /*AddressSpace=*/0}; + } + + /// Get a low-level pointer in the given address space. + static constexpr LLT pointer(unsigned AddressSpace, unsigned SizeInBits) { + assert(SizeInBits > 0 && "invalid pointer size"); + return LLT{/*isPointer=*/true, /*isVector=*/false, /*isScalar=*/false, + ElementCount::getFixed(0), SizeInBits, AddressSpace}; + } + + /// Get a low-level vector of some number of elements and element width. + static constexpr LLT vector(ElementCount EC, unsigned ScalarSizeInBits) { + assert(!EC.isScalar() && "invalid number of vector elements"); + return LLT{/*isPointer=*/false, /*isVector=*/true, /*isScalar=*/false, + EC, ScalarSizeInBits, /*AddressSpace=*/0}; + } + + /// Get a low-level vector of some number of elements and element type. + static constexpr LLT vector(ElementCount EC, LLT ScalarTy) { + assert(!EC.isScalar() && "invalid number of vector elements"); + assert(!ScalarTy.isVector() && "invalid vector element type"); + return LLT{ScalarTy.isPointer(), + /*isVector=*/true, + /*isScalar=*/false, + EC, + ScalarTy.getSizeInBits().getFixedValue(), + ScalarTy.isPointer() ? ScalarTy.getAddressSpace() : 0}; + } + + /// Get a low-level fixed-width vector of some number of elements and element + /// width. + static constexpr LLT fixed_vector(unsigned NumElements, + unsigned ScalarSizeInBits) { + return vector(ElementCount::getFixed(NumElements), ScalarSizeInBits); + } + + /// Get a low-level fixed-width vector of some number of elements and element + /// type. + static constexpr LLT fixed_vector(unsigned NumElements, LLT ScalarTy) { + return vector(ElementCount::getFixed(NumElements), ScalarTy); + } + + /// Get a low-level scalable vector of some number of elements and element + /// width. + static constexpr LLT scalable_vector(unsigned MinNumElements, + unsigned ScalarSizeInBits) { + return vector(ElementCount::getScalable(MinNumElements), ScalarSizeInBits); + } + + /// Get a low-level scalable vector of some number of elements and element + /// type. + static constexpr LLT scalable_vector(unsigned MinNumElements, LLT ScalarTy) { + return vector(ElementCount::getScalable(MinNumElements), ScalarTy); + } + + static constexpr LLT scalarOrVector(ElementCount EC, LLT ScalarTy) { + return EC.isScalar() ? ScalarTy : LLT::vector(EC, ScalarTy); + } + + static constexpr LLT scalarOrVector(ElementCount EC, uint64_t ScalarSize) { + assert(ScalarSize <= std::numeric_limits::max() && + "Not enough bits in LLT to represent size"); + return scalarOrVector(EC, LLT::scalar(static_cast(ScalarSize))); + } + + explicit constexpr LLT(bool isPointer, bool isVector, bool isScalar, + ElementCount EC, uint64_t SizeInBits, + unsigned AddressSpace) + : LLT() { + init(isPointer, isVector, isScalar, EC, SizeInBits, AddressSpace); + } + explicit constexpr LLT() + : IsScalar(false), IsPointer(false), IsVector(false), RawData(0) {} + + explicit LLT(MVT VT); + + constexpr bool isValid() const { return IsScalar || RawData != 0; } + + constexpr bool isScalar() const { return IsScalar; } + + constexpr bool isPointer() const { + return isValid() && IsPointer && !IsVector; + } + + constexpr bool isVector() const { return isValid() && IsVector; } + + /// Returns the number of elements in a vector LLT. Must only be called on + /// vector types. + constexpr uint16_t getNumElements() const { + if (isScalable()) + llvm::reportInvalidSizeRequest( + "Possible incorrect use of LLT::getNumElements() for " + "scalable vector. Scalable flag may be dropped, use " + "LLT::getElementCount() instead"); + return getElementCount().getKnownMinValue(); + } + + /// Returns true if the LLT is a scalable vector. Must only be called on + /// vector types. + constexpr bool isScalable() const { + assert(isVector() && "Expected a vector type"); + return IsPointer ? getFieldValue(PointerVectorScalableFieldInfo) + : getFieldValue(VectorScalableFieldInfo); + } + + constexpr ElementCount getElementCount() const { + assert(IsVector && "cannot get number of elements on scalar/aggregate"); + return ElementCount::get(IsPointer + ? getFieldValue(PointerVectorElementsFieldInfo) + : getFieldValue(VectorElementsFieldInfo), + isScalable()); + } + + /// Returns the total size of the type. Must only be called on sized types. + constexpr TypeSize getSizeInBits() const { + if (isPointer() || isScalar()) + return TypeSize::Fixed(getScalarSizeInBits()); + auto EC = getElementCount(); + return TypeSize(getScalarSizeInBits() * EC.getKnownMinValue(), + EC.isScalable()); + } + + /// Returns the total size of the type in bytes, i.e. number of whole bytes + /// needed to represent the size in bits. Must only be called on sized types. + constexpr TypeSize getSizeInBytes() const { + TypeSize BaseSize = getSizeInBits(); + return {(BaseSize.getKnownMinValue() + 7) / 8, BaseSize.isScalable()}; + } + + constexpr LLT getScalarType() const { + return isVector() ? getElementType() : *this; + } + + /// If this type is a vector, return a vector with the same number of elements + /// but the new element type. Otherwise, return the new element type. + constexpr LLT changeElementType(LLT NewEltTy) const { + return isVector() ? LLT::vector(getElementCount(), NewEltTy) : NewEltTy; + } + + /// If this type is a vector, return a vector with the same number of elements + /// but the new element size. Otherwise, return the new element type. Invalid + /// for pointer types. For pointer types, use changeElementType. + constexpr LLT changeElementSize(unsigned NewEltSize) const { + assert(!getScalarType().isPointer() && + "invalid to directly change element size for pointers"); + return isVector() ? LLT::vector(getElementCount(), NewEltSize) + : LLT::scalar(NewEltSize); + } + + /// Return a vector or scalar with the same element type and the new element + /// count. + constexpr LLT changeElementCount(ElementCount EC) const { + return LLT::scalarOrVector(EC, getScalarType()); + } + + /// Return a type that is \p Factor times smaller. Reduces the number of + /// elements if this is a vector, or the bitwidth for scalar/pointers. Does + /// not attempt to handle cases that aren't evenly divisible. + constexpr LLT divide(int Factor) const { + assert(Factor != 1); + assert((!isScalar() || getScalarSizeInBits() != 0) && + "cannot divide scalar of size zero"); + if (isVector()) { + assert(getElementCount().isKnownMultipleOf(Factor)); + return scalarOrVector(getElementCount().divideCoefficientBy(Factor), + getElementType()); + } + + assert(getScalarSizeInBits() % Factor == 0); + return scalar(getScalarSizeInBits() / Factor); + } + + /// Produce a vector type that is \p Factor times bigger, preserving the + /// element type. For a scalar or pointer, this will produce a new vector with + /// \p Factor elements. + constexpr LLT multiplyElements(int Factor) const { + if (isVector()) { + return scalarOrVector(getElementCount().multiplyCoefficientBy(Factor), + getElementType()); + } + + return fixed_vector(Factor, *this); + } + + constexpr bool isByteSized() const { + return getSizeInBits().isKnownMultipleOf(8); + } + + constexpr unsigned getScalarSizeInBits() const { + if (IsScalar) + return getFieldValue(ScalarSizeFieldInfo); + if (IsVector) { + if (!IsPointer) + return getFieldValue(VectorSizeFieldInfo); + else + return getFieldValue(PointerVectorSizeFieldInfo); + } else if (IsPointer) + return getFieldValue(PointerSizeFieldInfo); + else + llvm_unreachable("unexpected LLT"); + } + + constexpr unsigned getAddressSpace() const { + assert(RawData != 0 && "Invalid Type"); + assert(IsPointer && "cannot get address space of non-pointer type"); + if (!IsVector) + return getFieldValue(PointerAddressSpaceFieldInfo); + else + return getFieldValue(PointerVectorAddressSpaceFieldInfo); + } + + /// Returns the vector's element type. Only valid for vector types. + constexpr LLT getElementType() const { + assert(isVector() && "cannot get element type of scalar/aggregate"); + if (IsPointer) + return pointer(getAddressSpace(), getScalarSizeInBits()); + else + return scalar(getScalarSizeInBits()); + } + + void print(raw_ostream &OS) const; + +#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) + LLVM_DUMP_METHOD void dump() const { + print(dbgs()); + dbgs() << '\n'; + } +#endif + + constexpr bool operator==(const LLT &RHS) const { + return IsPointer == RHS.IsPointer && IsVector == RHS.IsVector && + IsScalar == RHS.IsScalar && RHS.RawData == RawData; + } + + constexpr bool operator!=(const LLT &RHS) const { return !(*this == RHS); } + + friend struct DenseMapInfo; + friend class GISelInstProfileBuilder; + +private: + /// LLT is packed into 64 bits as follows: + /// isScalar : 1 + /// isPointer : 1 + /// isVector : 1 + /// with 61 bits remaining for Kind-specific data, packed in bitfields + /// as described below. As there isn't a simple portable way to pack bits + /// into bitfields, here the different fields in the packed structure is + /// described in static const *Field variables. Each of these variables + /// is a 2-element array, with the first element describing the bitfield size + /// and the second element describing the bitfield offset. + typedef int BitFieldInfo[2]; + /// + /// This is how the bitfields are packed per Kind: + /// * Invalid: + /// gets encoded as RawData == 0, as that is an invalid encoding, since for + /// valid encodings, SizeInBits/SizeOfElement must be larger than 0. + /// * Non-pointer scalar (isPointer == 0 && isVector == 0): + /// SizeInBits: 32; + static const constexpr BitFieldInfo ScalarSizeFieldInfo{32, 0}; + /// * Pointer (isPointer == 1 && isVector == 0): + /// SizeInBits: 16; + /// AddressSpace: 24; + static const constexpr BitFieldInfo PointerSizeFieldInfo{16, 0}; + static const constexpr BitFieldInfo PointerAddressSpaceFieldInfo{ + 24, PointerSizeFieldInfo[0] + PointerSizeFieldInfo[1]}; + static_assert((PointerAddressSpaceFieldInfo[0] + + PointerAddressSpaceFieldInfo[1]) <= 61, + "Insufficient bits to encode all data"); + /// * Vector-of-non-pointer (isPointer == 0 && isVector == 1): + /// NumElements: 16; + /// SizeOfElement: 32; + /// Scalable: 1; + static const constexpr BitFieldInfo VectorElementsFieldInfo{16, 0}; + static const constexpr BitFieldInfo VectorSizeFieldInfo{ + 32, VectorElementsFieldInfo[0] + VectorElementsFieldInfo[1]}; + static const constexpr BitFieldInfo VectorScalableFieldInfo{ + 1, VectorSizeFieldInfo[0] + VectorSizeFieldInfo[1]}; + static_assert((VectorSizeFieldInfo[0] + VectorSizeFieldInfo[1]) <= 61, + "Insufficient bits to encode all data"); + /// * Vector-of-pointer (isPointer == 1 && isVector == 1): + /// NumElements: 16; + /// SizeOfElement: 16; + /// AddressSpace: 24; + /// Scalable: 1; + static const constexpr BitFieldInfo PointerVectorElementsFieldInfo{16, 0}; + static const constexpr BitFieldInfo PointerVectorSizeFieldInfo{ + 16, + PointerVectorElementsFieldInfo[1] + PointerVectorElementsFieldInfo[0]}; + static const constexpr BitFieldInfo PointerVectorAddressSpaceFieldInfo{ + 24, PointerVectorSizeFieldInfo[1] + PointerVectorSizeFieldInfo[0]}; + static const constexpr BitFieldInfo PointerVectorScalableFieldInfo{ + 1, PointerVectorAddressSpaceFieldInfo[0] + + PointerVectorAddressSpaceFieldInfo[1]}; + static_assert((PointerVectorAddressSpaceFieldInfo[0] + + PointerVectorAddressSpaceFieldInfo[1]) <= 61, + "Insufficient bits to encode all data"); + + uint64_t IsScalar : 1; + uint64_t IsPointer : 1; + uint64_t IsVector : 1; + uint64_t RawData : 61; + + static constexpr uint64_t getMask(const BitFieldInfo FieldInfo) { + const int FieldSizeInBits = FieldInfo[0]; + return (((uint64_t)1) << FieldSizeInBits) - 1; + } + static constexpr uint64_t maskAndShift(uint64_t Val, uint64_t Mask, + uint8_t Shift) { + assert(Val <= Mask && "Value too large for field"); + return (Val & Mask) << Shift; + } + static constexpr uint64_t maskAndShift(uint64_t Val, + const BitFieldInfo FieldInfo) { + return maskAndShift(Val, getMask(FieldInfo), FieldInfo[1]); + } + + constexpr uint64_t getFieldValue(const BitFieldInfo FieldInfo) const { + return getMask(FieldInfo) & (RawData >> FieldInfo[1]); + } + + constexpr void init(bool IsPointer, bool IsVector, bool IsScalar, + ElementCount EC, uint64_t SizeInBits, + unsigned AddressSpace) { + assert(SizeInBits <= std::numeric_limits::max() && + "Not enough bits in LLT to represent size"); + this->IsPointer = IsPointer; + this->IsVector = IsVector; + this->IsScalar = IsScalar; + if (IsScalar) + RawData = maskAndShift(SizeInBits, ScalarSizeFieldInfo); + else if (IsVector) { + assert(EC.isVector() && "invalid number of vector elements"); + if (!IsPointer) + RawData = + maskAndShift(EC.getKnownMinValue(), VectorElementsFieldInfo) | + maskAndShift(SizeInBits, VectorSizeFieldInfo) | + maskAndShift(EC.isScalable() ? 1 : 0, VectorScalableFieldInfo); + else + RawData = + maskAndShift(EC.getKnownMinValue(), + PointerVectorElementsFieldInfo) | + maskAndShift(SizeInBits, PointerVectorSizeFieldInfo) | + maskAndShift(AddressSpace, PointerVectorAddressSpaceFieldInfo) | + maskAndShift(EC.isScalable() ? 1 : 0, + PointerVectorScalableFieldInfo); + } else if (IsPointer) + RawData = maskAndShift(SizeInBits, PointerSizeFieldInfo) | + maskAndShift(AddressSpace, PointerAddressSpaceFieldInfo); + else + llvm_unreachable("unexpected LLT configuration"); + } + +public: + constexpr uint64_t getUniqueRAWLLTData() const { + return ((uint64_t)RawData) << 3 | ((uint64_t)IsScalar) << 2 | + ((uint64_t)IsPointer) << 1 | ((uint64_t)IsVector); + } +}; + +inline raw_ostream& operator<<(raw_ostream &OS, const LLT &Ty) { + Ty.print(OS); + return OS; +} + +template<> struct DenseMapInfo { + static inline LLT getEmptyKey() { + LLT Invalid; + Invalid.IsPointer = true; + return Invalid; + } + static inline LLT getTombstoneKey() { + LLT Invalid; + Invalid.IsVector = true; + return Invalid; + } + static inline unsigned getHashValue(const LLT &Ty) { + uint64_t Val = Ty.getUniqueRAWLLTData(); + return DenseMapInfo::getHashValue(Val); + } + static bool isEqual(const LLT &LHS, const LLT &RHS) { + return LHS == RHS; + } +}; /// Construct a low-level type based on an LLVM type. LLT getLLTForType(Type &Ty, const DataLayout &DL); diff --git a/llvm/include/llvm/Support/MachineValueType.h b/llvm/include/llvm/CodeGen/MachineValueType.h rename from llvm/include/llvm/Support/MachineValueType.h rename to llvm/include/llvm/CodeGen/MachineValueType.h --- a/llvm/include/llvm/Support/MachineValueType.h +++ b/llvm/include/llvm/CodeGen/MachineValueType.h @@ -1,4 +1,4 @@ -//===- Support/MachineValueType.h - Machine-Level types ---------*- C++ -*-===// +//===- CodeGen/MachineValueType.h - Machine-Level types ---------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -11,8 +11,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_SUPPORT_MACHINEVALUETYPE_H -#define LLVM_SUPPORT_MACHINEVALUETYPE_H +#ifndef LLVM_CODEGEN_MACHINEVALUETYPE_H +#define LLVM_CODEGEN_MACHINEVALUETYPE_H #include "llvm/ADT/Sequence.h" #include "llvm/ADT/iterator_range.h" diff --git a/llvm/include/llvm/Support/LowLevelTypeImpl.h b/llvm/include/llvm/Support/LowLevelTypeImpl.h deleted file mode 100644 --- a/llvm/include/llvm/Support/LowLevelTypeImpl.h +++ /dev/null @@ -1,431 +0,0 @@ -//== llvm/Support/LowLevelTypeImpl.h --------------------------- -*- C++ -*-==// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -/// \file -/// Implement a low-level type suitable for MachineInstr level instruction -/// selection. -/// -/// For a type attached to a MachineInstr, we only care about 2 details: total -/// size and the number of vector lanes (if any). Accordingly, there are 4 -/// possible valid type-kinds: -/// -/// * `sN` for scalars and aggregates -/// * `` for vectors, which must have at least 2 elements. -/// * `pN` for pointers -/// -/// Other information required for correct selection is expected to be carried -/// by the opcode, or non-type flags. For example the distinction between G_ADD -/// and G_FADD for int/float or fast-math flags. -/// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_SUPPORT_LOWLEVELTYPEIMPL_H -#define LLVM_SUPPORT_LOWLEVELTYPEIMPL_H - -#include "llvm/ADT/DenseMapInfo.h" -#include "llvm/Support/Debug.h" -#include "llvm/Support/MachineValueType.h" -#include - -namespace llvm { - -class Type; -class raw_ostream; - -class LLT { -public: - /// Get a low-level scalar or aggregate "bag of bits". - static constexpr LLT scalar(unsigned SizeInBits) { - return LLT{/*isPointer=*/false, /*isVector=*/false, /*isScalar=*/true, - ElementCount::getFixed(0), SizeInBits, - /*AddressSpace=*/0}; - } - - /// Get a low-level pointer in the given address space. - static constexpr LLT pointer(unsigned AddressSpace, unsigned SizeInBits) { - assert(SizeInBits > 0 && "invalid pointer size"); - return LLT{/*isPointer=*/true, /*isVector=*/false, /*isScalar=*/false, - ElementCount::getFixed(0), SizeInBits, AddressSpace}; - } - - /// Get a low-level vector of some number of elements and element width. - static constexpr LLT vector(ElementCount EC, unsigned ScalarSizeInBits) { - assert(!EC.isScalar() && "invalid number of vector elements"); - return LLT{/*isPointer=*/false, /*isVector=*/true, /*isScalar=*/false, - EC, ScalarSizeInBits, /*AddressSpace=*/0}; - } - - /// Get a low-level vector of some number of elements and element type. - static constexpr LLT vector(ElementCount EC, LLT ScalarTy) { - assert(!EC.isScalar() && "invalid number of vector elements"); - assert(!ScalarTy.isVector() && "invalid vector element type"); - return LLT{ScalarTy.isPointer(), - /*isVector=*/true, - /*isScalar=*/false, - EC, - ScalarTy.getSizeInBits().getFixedValue(), - ScalarTy.isPointer() ? ScalarTy.getAddressSpace() : 0}; - } - - /// Get a low-level fixed-width vector of some number of elements and element - /// width. - static constexpr LLT fixed_vector(unsigned NumElements, - unsigned ScalarSizeInBits) { - return vector(ElementCount::getFixed(NumElements), ScalarSizeInBits); - } - - /// Get a low-level fixed-width vector of some number of elements and element - /// type. - static constexpr LLT fixed_vector(unsigned NumElements, LLT ScalarTy) { - return vector(ElementCount::getFixed(NumElements), ScalarTy); - } - - /// Get a low-level scalable vector of some number of elements and element - /// width. - static constexpr LLT scalable_vector(unsigned MinNumElements, - unsigned ScalarSizeInBits) { - return vector(ElementCount::getScalable(MinNumElements), ScalarSizeInBits); - } - - /// Get a low-level scalable vector of some number of elements and element - /// type. - static constexpr LLT scalable_vector(unsigned MinNumElements, LLT ScalarTy) { - return vector(ElementCount::getScalable(MinNumElements), ScalarTy); - } - - static constexpr LLT scalarOrVector(ElementCount EC, LLT ScalarTy) { - return EC.isScalar() ? ScalarTy : LLT::vector(EC, ScalarTy); - } - - static constexpr LLT scalarOrVector(ElementCount EC, uint64_t ScalarSize) { - assert(ScalarSize <= std::numeric_limits::max() && - "Not enough bits in LLT to represent size"); - return scalarOrVector(EC, LLT::scalar(static_cast(ScalarSize))); - } - - explicit constexpr LLT(bool isPointer, bool isVector, bool isScalar, - ElementCount EC, uint64_t SizeInBits, - unsigned AddressSpace) - : LLT() { - init(isPointer, isVector, isScalar, EC, SizeInBits, AddressSpace); - } - explicit constexpr LLT() - : IsScalar(false), IsPointer(false), IsVector(false), RawData(0) {} - - explicit LLT(MVT VT); - - constexpr bool isValid() const { return IsScalar || RawData != 0; } - - constexpr bool isScalar() const { return IsScalar; } - - constexpr bool isPointer() const { - return isValid() && IsPointer && !IsVector; - } - - constexpr bool isVector() const { return isValid() && IsVector; } - - /// Returns the number of elements in a vector LLT. Must only be called on - /// vector types. - constexpr uint16_t getNumElements() const { - if (isScalable()) - llvm::reportInvalidSizeRequest( - "Possible incorrect use of LLT::getNumElements() for " - "scalable vector. Scalable flag may be dropped, use " - "LLT::getElementCount() instead"); - return getElementCount().getKnownMinValue(); - } - - /// Returns true if the LLT is a scalable vector. Must only be called on - /// vector types. - constexpr bool isScalable() const { - assert(isVector() && "Expected a vector type"); - return IsPointer ? getFieldValue(PointerVectorScalableFieldInfo) - : getFieldValue(VectorScalableFieldInfo); - } - - constexpr ElementCount getElementCount() const { - assert(IsVector && "cannot get number of elements on scalar/aggregate"); - return ElementCount::get(IsPointer - ? getFieldValue(PointerVectorElementsFieldInfo) - : getFieldValue(VectorElementsFieldInfo), - isScalable()); - } - - /// Returns the total size of the type. Must only be called on sized types. - constexpr TypeSize getSizeInBits() const { - if (isPointer() || isScalar()) - return TypeSize::Fixed(getScalarSizeInBits()); - auto EC = getElementCount(); - return TypeSize(getScalarSizeInBits() * EC.getKnownMinValue(), - EC.isScalable()); - } - - /// Returns the total size of the type in bytes, i.e. number of whole bytes - /// needed to represent the size in bits. Must only be called on sized types. - constexpr TypeSize getSizeInBytes() const { - TypeSize BaseSize = getSizeInBits(); - return {(BaseSize.getKnownMinValue() + 7) / 8, BaseSize.isScalable()}; - } - - constexpr LLT getScalarType() const { - return isVector() ? getElementType() : *this; - } - - /// If this type is a vector, return a vector with the same number of elements - /// but the new element type. Otherwise, return the new element type. - constexpr LLT changeElementType(LLT NewEltTy) const { - return isVector() ? LLT::vector(getElementCount(), NewEltTy) : NewEltTy; - } - - /// If this type is a vector, return a vector with the same number of elements - /// but the new element size. Otherwise, return the new element type. Invalid - /// for pointer types. For pointer types, use changeElementType. - constexpr LLT changeElementSize(unsigned NewEltSize) const { - assert(!getScalarType().isPointer() && - "invalid to directly change element size for pointers"); - return isVector() ? LLT::vector(getElementCount(), NewEltSize) - : LLT::scalar(NewEltSize); - } - - /// Return a vector or scalar with the same element type and the new element - /// count. - constexpr LLT changeElementCount(ElementCount EC) const { - return LLT::scalarOrVector(EC, getScalarType()); - } - - /// Return a type that is \p Factor times smaller. Reduces the number of - /// elements if this is a vector, or the bitwidth for scalar/pointers. Does - /// not attempt to handle cases that aren't evenly divisible. - constexpr LLT divide(int Factor) const { - assert(Factor != 1); - assert((!isScalar() || getScalarSizeInBits() != 0) && - "cannot divide scalar of size zero"); - if (isVector()) { - assert(getElementCount().isKnownMultipleOf(Factor)); - return scalarOrVector(getElementCount().divideCoefficientBy(Factor), - getElementType()); - } - - assert(getScalarSizeInBits() % Factor == 0); - return scalar(getScalarSizeInBits() / Factor); - } - - /// Produce a vector type that is \p Factor times bigger, preserving the - /// element type. For a scalar or pointer, this will produce a new vector with - /// \p Factor elements. - constexpr LLT multiplyElements(int Factor) const { - if (isVector()) { - return scalarOrVector(getElementCount().multiplyCoefficientBy(Factor), - getElementType()); - } - - return fixed_vector(Factor, *this); - } - - constexpr bool isByteSized() const { - return getSizeInBits().isKnownMultipleOf(8); - } - - constexpr unsigned getScalarSizeInBits() const { - if (IsScalar) - return getFieldValue(ScalarSizeFieldInfo); - if (IsVector) { - if (!IsPointer) - return getFieldValue(VectorSizeFieldInfo); - else - return getFieldValue(PointerVectorSizeFieldInfo); - } else if (IsPointer) - return getFieldValue(PointerSizeFieldInfo); - else - llvm_unreachable("unexpected LLT"); - } - - constexpr unsigned getAddressSpace() const { - assert(RawData != 0 && "Invalid Type"); - assert(IsPointer && "cannot get address space of non-pointer type"); - if (!IsVector) - return getFieldValue(PointerAddressSpaceFieldInfo); - else - return getFieldValue(PointerVectorAddressSpaceFieldInfo); - } - - /// Returns the vector's element type. Only valid for vector types. - constexpr LLT getElementType() const { - assert(isVector() && "cannot get element type of scalar/aggregate"); - if (IsPointer) - return pointer(getAddressSpace(), getScalarSizeInBits()); - else - return scalar(getScalarSizeInBits()); - } - - void print(raw_ostream &OS) const; - -#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) - LLVM_DUMP_METHOD void dump() const { - print(dbgs()); - dbgs() << '\n'; - } -#endif - - constexpr bool operator==(const LLT &RHS) const { - return IsPointer == RHS.IsPointer && IsVector == RHS.IsVector && - IsScalar == RHS.IsScalar && RHS.RawData == RawData; - } - - constexpr bool operator!=(const LLT &RHS) const { return !(*this == RHS); } - - friend struct DenseMapInfo; - friend class GISelInstProfileBuilder; - -private: - /// LLT is packed into 64 bits as follows: - /// isScalar : 1 - /// isPointer : 1 - /// isVector : 1 - /// with 61 bits remaining for Kind-specific data, packed in bitfields - /// as described below. As there isn't a simple portable way to pack bits - /// into bitfields, here the different fields in the packed structure is - /// described in static const *Field variables. Each of these variables - /// is a 2-element array, with the first element describing the bitfield size - /// and the second element describing the bitfield offset. - typedef int BitFieldInfo[2]; - /// - /// This is how the bitfields are packed per Kind: - /// * Invalid: - /// gets encoded as RawData == 0, as that is an invalid encoding, since for - /// valid encodings, SizeInBits/SizeOfElement must be larger than 0. - /// * Non-pointer scalar (isPointer == 0 && isVector == 0): - /// SizeInBits: 32; - static const constexpr BitFieldInfo ScalarSizeFieldInfo{32, 0}; - /// * Pointer (isPointer == 1 && isVector == 0): - /// SizeInBits: 16; - /// AddressSpace: 24; - static const constexpr BitFieldInfo PointerSizeFieldInfo{16, 0}; - static const constexpr BitFieldInfo PointerAddressSpaceFieldInfo{ - 24, PointerSizeFieldInfo[0] + PointerSizeFieldInfo[1]}; - static_assert((PointerAddressSpaceFieldInfo[0] + - PointerAddressSpaceFieldInfo[1]) <= 61, - "Insufficient bits to encode all data"); - /// * Vector-of-non-pointer (isPointer == 0 && isVector == 1): - /// NumElements: 16; - /// SizeOfElement: 32; - /// Scalable: 1; - static const constexpr BitFieldInfo VectorElementsFieldInfo{16, 0}; - static const constexpr BitFieldInfo VectorSizeFieldInfo{ - 32, VectorElementsFieldInfo[0] + VectorElementsFieldInfo[1]}; - static const constexpr BitFieldInfo VectorScalableFieldInfo{ - 1, VectorSizeFieldInfo[0] + VectorSizeFieldInfo[1]}; - static_assert((VectorSizeFieldInfo[0] + VectorSizeFieldInfo[1]) <= 61, - "Insufficient bits to encode all data"); - /// * Vector-of-pointer (isPointer == 1 && isVector == 1): - /// NumElements: 16; - /// SizeOfElement: 16; - /// AddressSpace: 24; - /// Scalable: 1; - static const constexpr BitFieldInfo PointerVectorElementsFieldInfo{16, 0}; - static const constexpr BitFieldInfo PointerVectorSizeFieldInfo{ - 16, - PointerVectorElementsFieldInfo[1] + PointerVectorElementsFieldInfo[0]}; - static const constexpr BitFieldInfo PointerVectorAddressSpaceFieldInfo{ - 24, PointerVectorSizeFieldInfo[1] + PointerVectorSizeFieldInfo[0]}; - static const constexpr BitFieldInfo PointerVectorScalableFieldInfo{ - 1, PointerVectorAddressSpaceFieldInfo[0] + - PointerVectorAddressSpaceFieldInfo[1]}; - static_assert((PointerVectorAddressSpaceFieldInfo[0] + - PointerVectorAddressSpaceFieldInfo[1]) <= 61, - "Insufficient bits to encode all data"); - - uint64_t IsScalar : 1; - uint64_t IsPointer : 1; - uint64_t IsVector : 1; - uint64_t RawData : 61; - - static constexpr uint64_t getMask(const BitFieldInfo FieldInfo) { - const int FieldSizeInBits = FieldInfo[0]; - return (((uint64_t)1) << FieldSizeInBits) - 1; - } - static constexpr uint64_t maskAndShift(uint64_t Val, uint64_t Mask, - uint8_t Shift) { - assert(Val <= Mask && "Value too large for field"); - return (Val & Mask) << Shift; - } - static constexpr uint64_t maskAndShift(uint64_t Val, - const BitFieldInfo FieldInfo) { - return maskAndShift(Val, getMask(FieldInfo), FieldInfo[1]); - } - - constexpr uint64_t getFieldValue(const BitFieldInfo FieldInfo) const { - return getMask(FieldInfo) & (RawData >> FieldInfo[1]); - } - - constexpr void init(bool IsPointer, bool IsVector, bool IsScalar, - ElementCount EC, uint64_t SizeInBits, - unsigned AddressSpace) { - assert(SizeInBits <= std::numeric_limits::max() && - "Not enough bits in LLT to represent size"); - this->IsPointer = IsPointer; - this->IsVector = IsVector; - this->IsScalar = IsScalar; - if (IsScalar) - RawData = maskAndShift(SizeInBits, ScalarSizeFieldInfo); - else if (IsVector) { - assert(EC.isVector() && "invalid number of vector elements"); - if (!IsPointer) - RawData = - maskAndShift(EC.getKnownMinValue(), VectorElementsFieldInfo) | - maskAndShift(SizeInBits, VectorSizeFieldInfo) | - maskAndShift(EC.isScalable() ? 1 : 0, VectorScalableFieldInfo); - else - RawData = - maskAndShift(EC.getKnownMinValue(), - PointerVectorElementsFieldInfo) | - maskAndShift(SizeInBits, PointerVectorSizeFieldInfo) | - maskAndShift(AddressSpace, PointerVectorAddressSpaceFieldInfo) | - maskAndShift(EC.isScalable() ? 1 : 0, - PointerVectorScalableFieldInfo); - } else if (IsPointer) - RawData = maskAndShift(SizeInBits, PointerSizeFieldInfo) | - maskAndShift(AddressSpace, PointerAddressSpaceFieldInfo); - else - llvm_unreachable("unexpected LLT configuration"); - } - -public: - constexpr uint64_t getUniqueRAWLLTData() const { - return ((uint64_t)RawData) << 3 | ((uint64_t)IsScalar) << 2 | - ((uint64_t)IsPointer) << 1 | ((uint64_t)IsVector); - } -}; - -inline raw_ostream& operator<<(raw_ostream &OS, const LLT &Ty) { - Ty.print(OS); - return OS; -} - -template<> struct DenseMapInfo { - static inline LLT getEmptyKey() { - LLT Invalid; - Invalid.IsPointer = true; - return Invalid; - } - static inline LLT getTombstoneKey() { - LLT Invalid; - Invalid.IsVector = true; - return Invalid; - } - static inline unsigned getHashValue(const LLT &Ty) { - uint64_t Val = Ty.getUniqueRAWLLTData(); - return DenseMapInfo::getHashValue(Val); - } - static bool isEqual(const LLT &LHS, const LLT &RHS) { - return LHS == RHS; - } -}; - -} - -#endif // LLVM_SUPPORT_LOWLEVELTYPEIMPL_H diff --git a/llvm/include/llvm/module.modulemap b/llvm/include/llvm/module.modulemap --- a/llvm/include/llvm/module.modulemap +++ b/llvm/include/llvm/module.modulemap @@ -15,6 +15,20 @@ module * { export * } } +module LLVM_CodeGenTypes { + requires cplusplus + + module LLT { + header "CodeGen/LowLevelType.h" export * + } + module MVT { + header "CodeGen/MachineValueType.h" export * + } + module VT { + header "CodeGen/ValueTypes.h" export * + } +} + // A module covering CodeGen/ and Target/. These are intertwined // and codependent, and thus notionally form a single module. module LLVM_Backend { @@ -336,15 +350,6 @@ module * { export * } } -// Used by llvm-tblgen -module LLVM_MC_TableGen { - requires cplusplus - module MC_LaneBitmask { header "MC/LaneBitmask.h" export * } - module MC_InstrItineraries { header "MC/MCInstrItineraries.h" export * } - module MC_Schedule { header "MC/MCSchedule.h" export * } - module MC_SubtargetFeature { header "MC/SubtargetFeature.h" export * } -} - module LLVM_Object { requires cplusplus umbrella "Object" diff --git a/llvm/lib/CodeGen/LowLevelType.cpp b/llvm/lib/CodeGen/LowLevelType.cpp --- a/llvm/lib/CodeGen/LowLevelType.cpp +++ b/llvm/lib/CodeGen/LowLevelType.cpp @@ -83,3 +83,46 @@ } llvm_unreachable("Invalid FP type size."); } + +LLT::LLT(MVT VT) { + if (VT.isVector()) { + bool asVector = VT.getVectorMinNumElements() > 1; + init(/*IsPointer=*/false, asVector, /*IsScalar=*/!asVector, + VT.getVectorElementCount(), VT.getVectorElementType().getSizeInBits(), + /*AddressSpace=*/0); + } else if (VT.isValid() && !VT.isScalableTargetExtVT()) { + // Aggregates are no different from real scalars as far as GlobalISel is + // concerned. + init(/*IsPointer=*/false, /*IsVector=*/false, /*IsScalar=*/true, + ElementCount::getFixed(0), VT.getSizeInBits(), /*AddressSpace=*/0); + } else { + IsScalar = false; + IsPointer = false; + IsVector = false; + RawData = 0; + } +} + +void LLT::print(raw_ostream &OS) const { + if (isVector()) { + OS << "<"; + OS << getElementCount() << " x " << getElementType() << ">"; + } else if (isPointer()) + OS << "p" << getAddressSpace(); + else if (isValid()) { + assert(isScalar() && "unexpected type"); + OS << "s" << getScalarSizeInBits(); + } else + OS << "LLT_invalid"; +} + +const constexpr LLT::BitFieldInfo LLT::ScalarSizeFieldInfo; +const constexpr LLT::BitFieldInfo LLT::PointerSizeFieldInfo; +const constexpr LLT::BitFieldInfo LLT::PointerAddressSpaceFieldInfo; +const constexpr LLT::BitFieldInfo LLT::VectorElementsFieldInfo; +const constexpr LLT::BitFieldInfo LLT::VectorScalableFieldInfo; +const constexpr LLT::BitFieldInfo LLT::VectorSizeFieldInfo; +const constexpr LLT::BitFieldInfo LLT::PointerVectorElementsFieldInfo; +const constexpr LLT::BitFieldInfo LLT::PointerVectorScalableFieldInfo; +const constexpr LLT::BitFieldInfo LLT::PointerVectorSizeFieldInfo; +const constexpr LLT::BitFieldInfo LLT::PointerVectorAddressSpaceFieldInfo; diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt --- a/llvm/lib/Support/CMakeLists.txt +++ b/llvm/lib/Support/CMakeLists.txt @@ -182,7 +182,6 @@ LineIterator.cpp Locale.cpp LockFileManager.cpp - LowLevelType.cpp ManagedStatic.cpp MathExtras.cpp MemAlloc.cpp diff --git a/llvm/lib/Support/LowLevelType.cpp b/llvm/lib/Support/LowLevelType.cpp deleted file mode 100644 --- a/llvm/lib/Support/LowLevelType.cpp +++ /dev/null @@ -1,59 +0,0 @@ -//===-- llvm/Support/LowLevelType.cpp -------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -/// \file This file implements the more header-heavy bits of the LLT class to -/// avoid polluting users' namespaces. -// -//===----------------------------------------------------------------------===// - -#include "llvm/Support/LowLevelTypeImpl.h" -#include "llvm/Support/raw_ostream.h" -using namespace llvm; - -LLT::LLT(MVT VT) { - if (VT.isVector()) { - bool asVector = VT.getVectorMinNumElements() > 1; - init(/*IsPointer=*/false, asVector, /*IsScalar=*/!asVector, - VT.getVectorElementCount(), VT.getVectorElementType().getSizeInBits(), - /*AddressSpace=*/0); - } else if (VT.isValid() && !VT.isScalableTargetExtVT()) { - // Aggregates are no different from real scalars as far as GlobalISel is - // concerned. - init(/*IsPointer=*/false, /*IsVector=*/false, /*IsScalar=*/true, - ElementCount::getFixed(0), VT.getSizeInBits(), /*AddressSpace=*/0); - } else { - IsScalar = false; - IsPointer = false; - IsVector = false; - RawData = 0; - } -} - -void LLT::print(raw_ostream &OS) const { - if (isVector()) { - OS << "<"; - OS << getElementCount() << " x " << getElementType() << ">"; - } else if (isPointer()) - OS << "p" << getAddressSpace(); - else if (isValid()) { - assert(isScalar() && "unexpected type"); - OS << "s" << getScalarSizeInBits(); - } else - OS << "LLT_invalid"; -} - -const constexpr LLT::BitFieldInfo LLT::ScalarSizeFieldInfo; -const constexpr LLT::BitFieldInfo LLT::PointerSizeFieldInfo; -const constexpr LLT::BitFieldInfo LLT::PointerAddressSpaceFieldInfo; -const constexpr LLT::BitFieldInfo LLT::VectorElementsFieldInfo; -const constexpr LLT::BitFieldInfo LLT::VectorScalableFieldInfo; -const constexpr LLT::BitFieldInfo LLT::VectorSizeFieldInfo; -const constexpr LLT::BitFieldInfo LLT::PointerVectorElementsFieldInfo; -const constexpr LLT::BitFieldInfo LLT::PointerVectorScalableFieldInfo; -const constexpr LLT::BitFieldInfo LLT::PointerVectorSizeFieldInfo; -const constexpr LLT::BitFieldInfo LLT::PointerVectorAddressSpaceFieldInfo; diff --git a/llvm/lib/Target/AArch64/AsmParser/CMakeLists.txt b/llvm/lib/Target/AArch64/AsmParser/CMakeLists.txt --- a/llvm/lib/Target/AArch64/AsmParser/CMakeLists.txt +++ b/llvm/lib/Target/AArch64/AsmParser/CMakeLists.txt @@ -7,6 +7,7 @@ AArch64Desc AArch64Info AArch64Utils + CodeGen MC MCParser Support diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/CMakeLists.txt b/llvm/lib/Target/AArch64/MCTargetDesc/CMakeLists.txt --- a/llvm/lib/Target/AArch64/MCTargetDesc/CMakeLists.txt +++ b/llvm/lib/Target/AArch64/MCTargetDesc/CMakeLists.txt @@ -16,6 +16,7 @@ AArch64Info AArch64Utils BinaryFormat + CodeGen MC Support TargetParser diff --git a/llvm/lib/Target/AMDGPU/AsmParser/CMakeLists.txt b/llvm/lib/Target/AMDGPU/AsmParser/CMakeLists.txt --- a/llvm/lib/Target/AMDGPU/AsmParser/CMakeLists.txt +++ b/llvm/lib/Target/AMDGPU/AsmParser/CMakeLists.txt @@ -5,6 +5,7 @@ AMDGPUDesc AMDGPUInfo AMDGPUUtils + CodeGen MC MCParser Support diff --git a/llvm/lib/Target/AMDGPU/Disassembler/CMakeLists.txt b/llvm/lib/Target/AMDGPU/Disassembler/CMakeLists.txt --- a/llvm/lib/Target/AMDGPU/Disassembler/CMakeLists.txt +++ b/llvm/lib/Target/AMDGPU/Disassembler/CMakeLists.txt @@ -7,6 +7,7 @@ AMDGPUDesc AMDGPUInfo AMDGPUUtils + CodeGen MC MCDisassembler Support diff --git a/llvm/lib/Target/AMDGPU/MCA/CMakeLists.txt b/llvm/lib/Target/AMDGPU/MCA/CMakeLists.txt --- a/llvm/lib/Target/AMDGPU/MCA/CMakeLists.txt +++ b/llvm/lib/Target/AMDGPU/MCA/CMakeLists.txt @@ -5,6 +5,7 @@ AMDGPUDesc AMDGPUInfo AMDGPUUtils + CodeGen MC MCA MCParser diff --git a/llvm/lib/Target/AMDGPU/MCTargetDesc/CMakeLists.txt b/llvm/lib/Target/AMDGPU/MCTargetDesc/CMakeLists.txt --- a/llvm/lib/Target/AMDGPU/MCTargetDesc/CMakeLists.txt +++ b/llvm/lib/Target/AMDGPU/MCTargetDesc/CMakeLists.txt @@ -16,6 +16,7 @@ AMDGPUInfo AMDGPUUtils BinaryFormat + CodeGen Core MC Support diff --git a/llvm/lib/Target/AMDGPU/Utils/CMakeLists.txt b/llvm/lib/Target/AMDGPU/Utils/CMakeLists.txt --- a/llvm/lib/Target/AMDGPU/Utils/CMakeLists.txt +++ b/llvm/lib/Target/AMDGPU/Utils/CMakeLists.txt @@ -8,6 +8,7 @@ LINK_COMPONENTS Analysis BinaryFormat + CodeGen Core MC Support diff --git a/llvm/lib/Target/ARM/AsmParser/CMakeLists.txt b/llvm/lib/Target/ARM/AsmParser/CMakeLists.txt --- a/llvm/lib/Target/ARM/AsmParser/CMakeLists.txt +++ b/llvm/lib/Target/ARM/AsmParser/CMakeLists.txt @@ -5,6 +5,7 @@ ARMDesc ARMInfo ARMUtils + CodeGen MC MCParser Support diff --git a/llvm/lib/Target/ARM/Disassembler/CMakeLists.txt b/llvm/lib/Target/ARM/Disassembler/CMakeLists.txt --- a/llvm/lib/Target/ARM/Disassembler/CMakeLists.txt +++ b/llvm/lib/Target/ARM/Disassembler/CMakeLists.txt @@ -5,6 +5,7 @@ ARMDesc ARMInfo ARMUtils + CodeGen MC MCDisassembler Support diff --git a/llvm/lib/Target/ARM/MCTargetDesc/CMakeLists.txt b/llvm/lib/Target/ARM/MCTargetDesc/CMakeLists.txt --- a/llvm/lib/Target/ARM/MCTargetDesc/CMakeLists.txt +++ b/llvm/lib/Target/ARM/MCTargetDesc/CMakeLists.txt @@ -18,6 +18,7 @@ ARMInfo ARMUtils BinaryFormat + CodeGen MC MCDisassembler Support diff --git a/llvm/lib/Target/AVR/AsmParser/CMakeLists.txt b/llvm/lib/Target/AVR/AsmParser/CMakeLists.txt --- a/llvm/lib/Target/AVR/AsmParser/CMakeLists.txt +++ b/llvm/lib/Target/AVR/AsmParser/CMakeLists.txt @@ -4,6 +4,7 @@ LINK_COMPONENTS AVRDesc AVRInfo + CodeGen MC MCParser Support diff --git a/llvm/lib/Target/AVR/Disassembler/CMakeLists.txt b/llvm/lib/Target/AVR/Disassembler/CMakeLists.txt --- a/llvm/lib/Target/AVR/Disassembler/CMakeLists.txt +++ b/llvm/lib/Target/AVR/Disassembler/CMakeLists.txt @@ -3,6 +3,7 @@ LINK_COMPONENTS AVRInfo + CodeGen MC MCDisassembler Support diff --git a/llvm/lib/Target/Lanai/AsmParser/CMakeLists.txt b/llvm/lib/Target/Lanai/AsmParser/CMakeLists.txt --- a/llvm/lib/Target/Lanai/AsmParser/CMakeLists.txt +++ b/llvm/lib/Target/Lanai/AsmParser/CMakeLists.txt @@ -4,6 +4,7 @@ LanaiAsmParser.cpp LINK_COMPONENTS + CodeGen LanaiDesc LanaiInfo MC diff --git a/llvm/lib/Target/Lanai/Disassembler/CMakeLists.txt b/llvm/lib/Target/Lanai/Disassembler/CMakeLists.txt --- a/llvm/lib/Target/Lanai/Disassembler/CMakeLists.txt +++ b/llvm/lib/Target/Lanai/Disassembler/CMakeLists.txt @@ -2,6 +2,7 @@ LanaiDisassembler.cpp LINK_COMPONENTS + CodeGen LanaiDesc LanaiInfo MC diff --git a/llvm/lib/Target/MSP430/AsmParser/CMakeLists.txt b/llvm/lib/Target/MSP430/AsmParser/CMakeLists.txt --- a/llvm/lib/Target/MSP430/AsmParser/CMakeLists.txt +++ b/llvm/lib/Target/MSP430/AsmParser/CMakeLists.txt @@ -2,6 +2,7 @@ MSP430AsmParser.cpp LINK_COMPONENTS + CodeGen MC MCParser MSP430Desc diff --git a/llvm/lib/Target/Mips/MCTargetDesc/CMakeLists.txt b/llvm/lib/Target/Mips/MCTargetDesc/CMakeLists.txt --- a/llvm/lib/Target/Mips/MCTargetDesc/CMakeLists.txt +++ b/llvm/lib/Target/Mips/MCTargetDesc/CMakeLists.txt @@ -14,6 +14,7 @@ MipsTargetStreamer.cpp LINK_COMPONENTS + CodeGen MC MipsInfo Support diff --git a/llvm/lib/Target/PowerPC/MCTargetDesc/CMakeLists.txt b/llvm/lib/Target/PowerPC/MCTargetDesc/CMakeLists.txt --- a/llvm/lib/Target/PowerPC/MCTargetDesc/CMakeLists.txt +++ b/llvm/lib/Target/PowerPC/MCTargetDesc/CMakeLists.txt @@ -13,6 +13,7 @@ LINK_COMPONENTS BinaryFormat + CodeGen MC PowerPCInfo Support diff --git a/llvm/lib/Target/RISCV/MCA/CMakeLists.txt b/llvm/lib/Target/RISCV/MCA/CMakeLists.txt --- a/llvm/lib/Target/RISCV/MCA/CMakeLists.txt +++ b/llvm/lib/Target/RISCV/MCA/CMakeLists.txt @@ -2,6 +2,7 @@ RISCVCustomBehaviour.cpp LINK_COMPONENTS + CodeGen MC MCA MCParser diff --git a/llvm/lib/Target/SystemZ/MCTargetDesc/CMakeLists.txt b/llvm/lib/Target/SystemZ/MCTargetDesc/CMakeLists.txt --- a/llvm/lib/Target/SystemZ/MCTargetDesc/CMakeLists.txt +++ b/llvm/lib/Target/SystemZ/MCTargetDesc/CMakeLists.txt @@ -7,6 +7,7 @@ SystemZMCTargetDesc.cpp LINK_COMPONENTS + CodeGen MC Support SystemZInfo diff --git a/llvm/lib/Target/VE/AsmParser/CMakeLists.txt b/llvm/lib/Target/VE/AsmParser/CMakeLists.txt --- a/llvm/lib/Target/VE/AsmParser/CMakeLists.txt +++ b/llvm/lib/Target/VE/AsmParser/CMakeLists.txt @@ -2,6 +2,7 @@ VEAsmParser.cpp LINK_COMPONENTS + CodeGen MC MCParser Support diff --git a/llvm/lib/Target/VE/Disassembler/CMakeLists.txt b/llvm/lib/Target/VE/Disassembler/CMakeLists.txt --- a/llvm/lib/Target/VE/Disassembler/CMakeLists.txt +++ b/llvm/lib/Target/VE/Disassembler/CMakeLists.txt @@ -2,6 +2,7 @@ VEDisassembler.cpp LINK_COMPONENTS + CodeGen MC MCDisassembler Support diff --git a/llvm/lib/Target/VE/MCTargetDesc/CMakeLists.txt b/llvm/lib/Target/VE/MCTargetDesc/CMakeLists.txt --- a/llvm/lib/Target/VE/MCTargetDesc/CMakeLists.txt +++ b/llvm/lib/Target/VE/MCTargetDesc/CMakeLists.txt @@ -9,6 +9,7 @@ VETargetStreamer.cpp LINK_COMPONENTS + CodeGen MC Support TargetParser diff --git a/llvm/lib/Target/WebAssembly/AsmParser/CMakeLists.txt b/llvm/lib/Target/WebAssembly/AsmParser/CMakeLists.txt --- a/llvm/lib/Target/WebAssembly/AsmParser/CMakeLists.txt +++ b/llvm/lib/Target/WebAssembly/AsmParser/CMakeLists.txt @@ -3,6 +3,7 @@ WebAssemblyAsmTypeCheck.cpp LINK_COMPONENTS + CodeGen MC MCParser Support diff --git a/llvm/lib/Target/WebAssembly/Disassembler/CMakeLists.txt b/llvm/lib/Target/WebAssembly/Disassembler/CMakeLists.txt --- a/llvm/lib/Target/WebAssembly/Disassembler/CMakeLists.txt +++ b/llvm/lib/Target/WebAssembly/Disassembler/CMakeLists.txt @@ -2,6 +2,7 @@ WebAssemblyDisassembler.cpp LINK_COMPONENTS + CodeGen MC MCDisassembler Support diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/CMakeLists.txt b/llvm/lib/Target/WebAssembly/MCTargetDesc/CMakeLists.txt --- a/llvm/lib/Target/WebAssembly/MCTargetDesc/CMakeLists.txt +++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/CMakeLists.txt @@ -9,6 +9,7 @@ WebAssemblyWasmObjectWriter.cpp LINK_COMPONENTS + CodeGen MC Support TargetParser diff --git a/llvm/lib/Target/X86/MCA/CMakeLists.txt b/llvm/lib/Target/X86/MCA/CMakeLists.txt --- a/llvm/lib/Target/X86/MCA/CMakeLists.txt +++ b/llvm/lib/Target/X86/MCA/CMakeLists.txt @@ -2,6 +2,7 @@ X86CustomBehaviour.cpp LINK_COMPONENTS + CodeGen MC MCA MCParser diff --git a/llvm/lib/Target/X86/MCTargetDesc/CMakeLists.txt b/llvm/lib/Target/X86/MCTargetDesc/CMakeLists.txt --- a/llvm/lib/Target/X86/MCTargetDesc/CMakeLists.txt +++ b/llvm/lib/Target/X86/MCTargetDesc/CMakeLists.txt @@ -18,6 +18,7 @@ LINK_COMPONENTS BinaryFormat + CodeGen MC MCDisassembler Support diff --git a/llvm/lib/Target/XCore/Disassembler/CMakeLists.txt b/llvm/lib/Target/XCore/Disassembler/CMakeLists.txt --- a/llvm/lib/Target/XCore/Disassembler/CMakeLists.txt +++ b/llvm/lib/Target/XCore/Disassembler/CMakeLists.txt @@ -2,6 +2,7 @@ XCoreDisassembler.cpp LINK_COMPONENTS + CodeGen MC MCDisassembler Support diff --git a/llvm/tools/llvm-dwarfutil/CMakeLists.txt b/llvm/tools/llvm-dwarfutil/CMakeLists.txt --- a/llvm/tools/llvm-dwarfutil/CMakeLists.txt +++ b/llvm/tools/llvm-dwarfutil/CMakeLists.txt @@ -6,6 +6,7 @@ AllTargetsCodeGens AllTargetsDescs AllTargetsInfos + CodeGen DWARFLinker DebugInfoDWARF MC diff --git a/llvm/tools/llvm-exegesis/CMakeLists.txt b/llvm/tools/llvm-exegesis/CMakeLists.txt --- a/llvm/tools/llvm-exegesis/CMakeLists.txt +++ b/llvm/tools/llvm-exegesis/CMakeLists.txt @@ -4,6 +4,7 @@ AllTargetsDescs AllTargetsDisassemblers AllTargetsInfos + CodeGen MC MCParser Support diff --git a/llvm/tools/llvm-exegesis/lib/AArch64/CMakeLists.txt b/llvm/tools/llvm-exegesis/lib/AArch64/CMakeLists.txt --- a/llvm/tools/llvm-exegesis/lib/AArch64/CMakeLists.txt +++ b/llvm/tools/llvm-exegesis/lib/AArch64/CMakeLists.txt @@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS AArch64 + CodeGen Core Exegesis MC diff --git a/llvm/tools/llvm-exegesis/lib/Mips/CMakeLists.txt b/llvm/tools/llvm-exegesis/lib/Mips/CMakeLists.txt --- a/llvm/tools/llvm-exegesis/lib/Mips/CMakeLists.txt +++ b/llvm/tools/llvm-exegesis/lib/Mips/CMakeLists.txt @@ -4,6 +4,7 @@ ) set(LLVM_LINK_COMPONENTS + CodeGen Core Exegesis MC diff --git a/llvm/tools/llvm-exegesis/lib/PowerPC/CMakeLists.txt b/llvm/tools/llvm-exegesis/lib/PowerPC/CMakeLists.txt --- a/llvm/tools/llvm-exegesis/lib/PowerPC/CMakeLists.txt +++ b/llvm/tools/llvm-exegesis/lib/PowerPC/CMakeLists.txt @@ -4,6 +4,7 @@ ) set(LLVM_LINK_COMPONENTS + CodeGen Core Exegesis MC diff --git a/llvm/unittests/DebugInfo/DWARF/CMakeLists.txt b/llvm/unittests/DebugInfo/DWARF/CMakeLists.txt --- a/llvm/unittests/DebugInfo/DWARF/CMakeLists.txt +++ b/llvm/unittests/DebugInfo/DWARF/CMakeLists.txt @@ -2,6 +2,7 @@ ${LLVM_TARGETS_TO_BUILD} AsmPrinter BinaryFormat + CodeGen DebugInfoDWARF MC Object diff --git a/llvm/unittests/Support/MVTTest.cpp b/llvm/unittests/Support/MVTTest.cpp --- a/llvm/unittests/Support/MVTTest.cpp +++ b/llvm/unittests/Support/MVTTest.cpp @@ -7,12 +7,12 @@ //===----------------------------------------------------------------------===// // // Make sure the generated version of MachineValueType.h to be equivalent to -// the constant version of llvm/Support/MachineValueType.h. +// the constant version of llvm/CodeGen/MachineValueType.h. // //===----------------------------------------------------------------------===// #include "MachineValueType.h" -#include "llvm/Support/MachineValueType.h" +#include "llvm/CodeGen/MachineValueType.h" #include "gtest/gtest.h" #include #include diff --git a/llvm/utils/TableGen/CMakeLists.txt b/llvm/utils/TableGen/CMakeLists.txt --- a/llvm/utils/TableGen/CMakeLists.txt +++ b/llvm/utils/TableGen/CMakeLists.txt @@ -15,6 +15,11 @@ ) set_target_properties(llvm-min-tblgen PROPERTIES FOLDER "Tablegenning") +set(LLVM_LINK_COMPONENTS + CodeGen + Support + ) + add_tablegen(llvm-tblgen LLVM DESTINATION "${LLVM_TOOLS_INSTALL_DIR}" EXPORT LLVM diff --git a/llvm/utils/TableGen/GlobalISel/CMakeLists.txt b/llvm/utils/TableGen/GlobalISel/CMakeLists.txt --- a/llvm/utils/TableGen/GlobalISel/CMakeLists.txt +++ b/llvm/utils/TableGen/GlobalISel/CMakeLists.txt @@ -1,4 +1,5 @@ set(LLVM_LINK_COMPONENTS + CodeGen Support TableGen ) diff --git a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel @@ -616,6 +616,7 @@ features = ["-header_modules"], strip_include_prefix = "utils/TableGen", deps = [ + ":CodeGen", ":Support", ":TableGen", ":config", @@ -642,6 +643,7 @@ copts = llvm_copts, stamp = 0, deps = [ + ":CodeGen", ":Support", ":TableGen", ":TableGenGlobalISel", @@ -2335,6 +2337,7 @@ copts = llvm_copts, features = ["-layering_check"], deps = [ + ":CodeGen", ":MC", ":MCA", ":MCParser", @@ -3403,6 +3406,7 @@ deps = [ ":AllTargetsAsmParsers", ":AllTargetsCodeGens", + ":CodeGen", ":DWARFLinker", ":DebugInfoDWARF", ":DwarfutilOptionsTableGen", @@ -3443,6 +3447,7 @@ ":AllTargetsAsmParsers", ":AllTargetsCodeGens", ":AllTargetsDisassemblers", + ":CodeGen", ":Exegesis", ":MC", ":MCParser",