Skip to content

[TableGen][MVT] Lower the maximum 16-bit MVT from 16384 to 511. #101401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions llvm/include/llvm/CodeGen/ValueTypes.td
Original file line number Diff line number Diff line change
Expand Up @@ -289,34 +289,34 @@ def aarch64svcount
def spirvbuiltin : ValueType<0, 200>; // SPIR-V's builtin type

let isNormalValueType = false in {
def token : ValueType<0, 16376>; // TokenTy
def MetadataVT : ValueType<0, 16377> { // Metadata
def token : ValueType<0, 504>; // TokenTy
def MetadataVT : ValueType<0, 505> { // Metadata
let LLVMName = "Metadata";
}

// Pseudo valuetype mapped to the current pointer size to any address space.
// Should only be used in TableGen.
def iPTRAny : VTAny<16378>;
def iPTRAny : VTAny<506>;

// Pseudo valuetype to represent "vector of any size"
// Should only be used in TableGen.
def vAny : VTAny<16379>;
def vAny : VTAny<507>;

// Pseudo valuetype to represent "float of any format"
// Should only be used in TableGen.
def fAny : VTAny<16380>;
def fAny : VTAny<508>;

// Pseudo valuetype to represent "integer of any bit width"
// Should only be used in TableGen.
def iAny : VTAny<16381>;
def iAny : VTAny<509>;

// Pseudo valuetype mapped to the current pointer size.
// Should only be used in TableGen.
def iPTR : ValueType<0, 16382>;
def iPTR : ValueType<0, 510>;

// Pseudo valuetype to represent "any type of any size".
// Should only be used in TableGen.
def Any : VTAny<16383>;
def Any : VTAny<511>;

} // isNormalValueType = false

Expand Down
8 changes: 4 additions & 4 deletions llvm/utils/TableGen/Common/CodeGenDAGPatterns.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ using TreePatternNodePtr = IntrusiveRefCntPtr<TreePatternNode>;
/// To reduce the allocations even further, make MachineValueTypeSet own
/// the storage and use std::array as the bit container.
struct MachineValueTypeSet {
static_assert(std::is_same<std::underlying_type_t<MVT::SimpleValueType>,
uint16_t>::value,
"Change uint16_t here to the SimpleValueType's type");
static unsigned constexpr Capacity = std::numeric_limits<uint16_t>::max() + 1;
static unsigned constexpr Capacity = 512;
using WordType = uint64_t;
static unsigned constexpr WordWidth = CHAR_BIT * sizeof(WordType);
static unsigned constexpr NumWords = Capacity / WordWidth;
Expand Down Expand Up @@ -84,9 +81,11 @@ struct MachineValueTypeSet {
}
LLVM_ATTRIBUTE_ALWAYS_INLINE
unsigned count(MVT T) const {
assert(T.SimpleTy < Capacity && "Capacity needs to be enlarged");
return (Words[T.SimpleTy / WordWidth] >> (T.SimpleTy % WordWidth)) & 1;
}
std::pair<MachineValueTypeSet &, bool> insert(MVT T) {
assert(T.SimpleTy < Capacity && "Capacity needs to be enlarged");
bool V = count(T.SimpleTy);
Words[T.SimpleTy / WordWidth] |= WordType(1) << (T.SimpleTy % WordWidth);
return {*this, V};
Expand All @@ -98,6 +97,7 @@ struct MachineValueTypeSet {
}
LLVM_ATTRIBUTE_ALWAYS_INLINE
void erase(MVT T) {
assert(T.SimpleTy < Capacity && "Capacity needs to be enlarged");
Words[T.SimpleTy / WordWidth] &= ~(WordType(1) << (T.SimpleTy % WordWidth));
}

Expand Down
2 changes: 1 addition & 1 deletion llvm/utils/TableGen/VTEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ static void VTtoGetLLVMTyString(raw_ostream &OS, const Record *VT) {
void VTEmitter::run(raw_ostream &OS) {
emitSourceFileHeader("ValueTypes Source Fragment", OS, Records);

std::vector<const Record *> VTsByNumber{16384};
std::vector<const Record *> VTsByNumber{512};
auto ValueTypes = Records.getAllDerivedDefinitions("ValueType");
for (auto *VT : ValueTypes) {
auto Number = VT->getValueAsInt("Value");
Expand Down
Loading