Skip to content

Commit 177d282

Browse files
committed
[MVT][TableGen] Extend Machine Value Type to uint16_t
Currently 208 out of 256 MVTs are used, it will be run out soon, so ultimately we need to extend the original `MVT::SimpleValueType` from `uint8_t` to `uint16_t` to accomodate more types. The `MatcherTable` uses `unsigned char` for encoding the matcher code, so the extended MVTs are no longer fit into the table, thus we need to use VBR to encode them as we do on others that are wider than 8 bits. The statistics below shows the difference of "Total Array size" of the matcher table that appears in every files: Table Before After Change(%) WebAssemblyGenDAGISel.inc 23576 23775 0.844 NVPTXGenDAGISel.inc 173498 173498 0 RISCVGenDAGISel.inc 2179121 2369929 8.756 AVRGenDAGISel.inc 2754 2754 0 PPCGenDAGISel.inc 163315 163617 0.185 MipsGenDAGISel.inc 47280 47447 0.353 SystemZGenDAGISel.inc 56243 56461 0.388 AArch64GenDAGISel.inc 467893 487830 4.261 MSP430GenDAGISel.inc 8069 8069 0 LoongArchGenDAGISel.inc 78928 79131 0.257 XCoreGenDAGISel.inc 3432 3432 0 BPFGenDAGISel.inc 3733 3733 0 VEGenDAGISel.inc 65174 66456 1.967 LanaiGenDAGISel.inc 2067 2067 0 X86GenDAGISel.inc 628787 636987 1.304 ARMGenDAGISel.inc 170968 171036 0.040 HexagonGenDAGISel.inc 155764 155764 0 SparcGenDAGISel.inc 5762 5798 0.625 AMDGPUGenDAGISel.inc 504356 504463 0.021 R600GenDAGISel.inc 29785 29785 0 The statistics below shows the runtime peak memory usage by compiling a simple C program: `/bin/time -v clang -target $TARGET -O3 -c test.c` ``` int test(int a) { return a * 3; } ``` Target Before(kbytes) After(kbytes) Change(%) wasm64 110172 110088 -0.076 nvptx64 109784 109980 0.179 riscv64 114020 113656 -0.319 avr 110352 110068 -0.257 ppc64 112612 112476 -0.120 mips64 113588 113668 0.070 systemz 110860 110760 -0.090 aarch64 113704 113432 -0.239 msp430 110284 110200 -0.076 loongarch64 111052 110756 -0.267 xcore 108340 108020 -0.295 bpf 110620 110708 0.080 ve 110960 110920 -0.036 lanai 110180 109960 -0.200 x86_64 113640 113304 -0.296 arm64 113540 113172 -0.324 hexagon 114620 114684 0.056 sparc 110412 110136 -0.250 amdgcn 118164 117144 -0.863 r600 111200 110508 -0.622
1 parent 4b9fab5 commit 177d282

File tree

6 files changed

+100
-57
lines changed

6 files changed

+100
-57
lines changed

llvm/include/llvm/CodeGenTypes/MachineValueType.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace llvm {
3333
/// type can be represented by an MVT.
3434
class MVT {
3535
public:
36-
enum SimpleValueType : uint8_t {
36+
enum SimpleValueType : uint16_t {
3737
// Simple value types that aren't explicitly part of this enumeration
3838
// are considered extended value types.
3939
INVALID_SIMPLE_VALUE_TYPE = 0,

llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2617,6 +2617,17 @@ GetVBR(uint64_t Val, const unsigned char *MatcherTable, unsigned &Idx) {
26172617
return Val;
26182618
}
26192619

2620+
/// getSimpleVT - Decode a value in MatcherTable, if it's a VBR encoded value,
2621+
/// use GetVBR to decode it.
2622+
LLVM_ATTRIBUTE_ALWAYS_INLINE static MVT::SimpleValueType
2623+
getSimpleVT(const unsigned char *MatcherTable, unsigned &MatcherIndex) {
2624+
unsigned SimpleVT = MatcherTable[MatcherIndex++];
2625+
if (SimpleVT & 128)
2626+
SimpleVT = GetVBR(SimpleVT, MatcherTable, MatcherIndex);
2627+
2628+
return static_cast<MVT::SimpleValueType>(SimpleVT);
2629+
}
2630+
26202631
void SelectionDAGISel::Select_JUMP_TABLE_DEBUG_INFO(SDNode *N) {
26212632
SDLoc dl(N);
26222633
CurDAG->SelectNodeTo(N, TargetOpcode::JUMP_TABLE_DEBUG_INFO, MVT::Glue,
@@ -2896,8 +2907,7 @@ CheckChild2CondCode(const unsigned char *MatcherTable, unsigned &MatcherIndex,
28962907
LLVM_ATTRIBUTE_ALWAYS_INLINE static bool
28972908
CheckValueType(const unsigned char *MatcherTable, unsigned &MatcherIndex,
28982909
SDValue N, const TargetLowering *TLI, const DataLayout &DL) {
2899-
MVT::SimpleValueType VT =
2900-
static_cast<MVT::SimpleValueType>(MatcherTable[MatcherIndex++]);
2910+
MVT::SimpleValueType VT = getSimpleVT(MatcherTable, MatcherIndex);
29012911
if (cast<VTSDNode>(N)->getVT() == VT)
29022912
return true;
29032913

@@ -3027,17 +3037,16 @@ static unsigned IsPredicateKnownToFail(const unsigned char *Table,
30273037
VT = MVT::i64;
30283038
break;
30293039
default:
3030-
VT = static_cast<MVT::SimpleValueType>(Table[Index++]);
3040+
VT = getSimpleVT(Table, Index);
30313041
break;
30323042
}
30333043
Result = !::CheckType(VT, N, SDISel.TLI, SDISel.CurDAG->getDataLayout());
30343044
return Index;
30353045
}
30363046
case SelectionDAGISel::OPC_CheckTypeRes: {
30373047
unsigned Res = Table[Index++];
3038-
Result = !::CheckType(static_cast<MVT::SimpleValueType>(Table[Index++]),
3039-
N.getValue(Res), SDISel.TLI,
3040-
SDISel.CurDAG->getDataLayout());
3048+
Result = !::CheckType(getSimpleVT(Table, Index), N.getValue(Res),
3049+
SDISel.TLI, SDISel.CurDAG->getDataLayout());
30413050
return Index;
30423051
}
30433052
case SelectionDAGISel::OPC_CheckChild0Type:
@@ -3075,7 +3084,7 @@ static unsigned IsPredicateKnownToFail(const unsigned char *Table,
30753084
VT = MVT::i64;
30763085
ChildNo = Opcode - SelectionDAGISel::OPC_CheckChild0TypeI64;
30773086
} else {
3078-
VT = static_cast<MVT::SimpleValueType>(Table[Index++]);
3087+
VT = getSimpleVT(Table, Index);
30793088
ChildNo = Opcode - SelectionDAGISel::OPC_CheckChild0Type;
30803089
}
30813090
Result = !::CheckChildType(VT, N, SDISel.TLI,
@@ -3579,7 +3588,7 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch,
35793588
VT = MVT::i64;
35803589
break;
35813590
default:
3582-
VT = static_cast<MVT::SimpleValueType>(MatcherTable[MatcherIndex++]);
3591+
VT = getSimpleVT(MatcherTable, MatcherIndex);
35833592
break;
35843593
}
35853594
if (!::CheckType(VT, N, TLI, CurDAG->getDataLayout()))
@@ -3588,9 +3597,8 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch,
35883597

35893598
case OPC_CheckTypeRes: {
35903599
unsigned Res = MatcherTable[MatcherIndex++];
3591-
if (!::CheckType(
3592-
static_cast<MVT::SimpleValueType>(MatcherTable[MatcherIndex++]),
3593-
N.getValue(Res), TLI, CurDAG->getDataLayout()))
3600+
if (!::CheckType(getSimpleVT(MatcherTable, MatcherIndex), N.getValue(Res),
3601+
TLI, CurDAG->getDataLayout()))
35943602
break;
35953603
continue;
35963604
}
@@ -3637,8 +3645,7 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch,
36373645
CaseSize = GetVBR(CaseSize, MatcherTable, MatcherIndex);
36383646
if (CaseSize == 0) break;
36393647

3640-
MVT CaseVT =
3641-
static_cast<MVT::SimpleValueType>(MatcherTable[MatcherIndex++]);
3648+
MVT CaseVT = getSimpleVT(MatcherTable, MatcherIndex);
36423649
if (CaseVT == MVT::iPTR)
36433650
CaseVT = TLI->getPointerTy(CurDAG->getDataLayout());
36443651

@@ -3694,7 +3701,7 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch,
36943701
VT = MVT::i64;
36953702
ChildNo = Opcode - SelectionDAGISel::OPC_CheckChild0TypeI64;
36963703
} else {
3697-
VT = static_cast<MVT::SimpleValueType>(MatcherTable[MatcherIndex++]);
3704+
VT = getSimpleVT(MatcherTable, MatcherIndex);
36983705
ChildNo = Opcode - SelectionDAGISel::OPC_CheckChild0Type;
36993706
}
37003707
if (!::CheckChildType(VT, N, TLI, CurDAG->getDataLayout(), ChildNo))
@@ -3788,7 +3795,7 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch,
37883795
VT = MVT::i64;
37893796
break;
37903797
default:
3791-
VT = static_cast<MVT::SimpleValueType>(MatcherTable[MatcherIndex++]);
3798+
VT = getSimpleVT(MatcherTable, MatcherIndex);
37923799
break;
37933800
}
37943801
int64_t Val = MatcherTable[MatcherIndex++];
@@ -3812,7 +3819,7 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch,
38123819
VT = MVT::i64;
38133820
break;
38143821
default:
3815-
VT = static_cast<MVT::SimpleValueType>(MatcherTable[MatcherIndex++]);
3822+
VT = getSimpleVT(MatcherTable, MatcherIndex);
38163823
break;
38173824
}
38183825
unsigned RegNo = MatcherTable[MatcherIndex++];
@@ -3824,8 +3831,7 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch,
38243831
// For targets w/ more than 256 register names, the register enum
38253832
// values are stored in two bytes in the matcher table (just like
38263833
// opcodes).
3827-
MVT::SimpleValueType VT =
3828-
static_cast<MVT::SimpleValueType>(MatcherTable[MatcherIndex++]);
3834+
MVT::SimpleValueType VT = getSimpleVT(MatcherTable, MatcherIndex);
38293835
unsigned RegNo = MatcherTable[MatcherIndex++];
38303836
RegNo |= MatcherTable[MatcherIndex++] << 8;
38313837
RecordedNodes.push_back(std::pair<SDValue, SDNode*>(
@@ -4063,8 +4069,7 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch,
40634069
NumVTs = MatcherTable[MatcherIndex++];
40644070
SmallVector<EVT, 4> VTs;
40654071
for (unsigned i = 0; i != NumVTs; ++i) {
4066-
MVT::SimpleValueType VT =
4067-
static_cast<MVT::SimpleValueType>(MatcherTable[MatcherIndex++]);
4072+
MVT::SimpleValueType VT = getSimpleVT(MatcherTable, MatcherIndex);
40684073
if (VT == MVT::iPTR)
40694074
VT = TLI->getPointerTy(CurDAG->getDataLayout()).SimpleTy;
40704075
VTs.push_back(VT);

llvm/test/TableGen/dag-isel-regclass-emit-enum.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ def GPRAbove127 : RegisterClass<"TestTarget", [i32], 32,
2727
// CHECK-NEXT: OPC_CheckChild1Integer, 0,
2828
// CHECK-NEXT: OPC_EmitInteger32, 0|128,2/*256*/,
2929
// CHECK-NEXT: OPC_MorphNodeTo1None, TARGET_VAL(TargetOpcode::COPY_TO_REGCLASS),
30-
// CHECK-NEXT: MVT::i32, 2/*#Ops*/, 1, 0,
30+
// CHECK-NEXT: /*MVT::i32*/7, 2/*#Ops*/, 1, 0,
3131
def : Pat<(i32 (add i32:$src, (i32 0))),
3232
(COPY_TO_REGCLASS GPRAbove127, GPR0:$src)>;
3333

3434
// CHECK: OPC_CheckChild1Integer, 2,
3535
// CHECK-NEXT: OPC_EmitStringInteger32, TestNamespace::GPR127RegClassID,
3636
// CHECK-NEXT: OPC_MorphNodeTo1None, TARGET_VAL(TargetOpcode::COPY_TO_REGCLASS),
37-
// CHECK-NEXT: MVT::i32, 2/*#Ops*/, 1, 0,
37+
// CHECK-NEXT: /*MVT::i32*/7, 2/*#Ops*/, 1, 0,
3838
def : Pat<(i32 (add i32:$src, (i32 1))),
3939
(COPY_TO_REGCLASS GPR127, GPR0:$src)>;

llvm/utils/TableGen/Common/CodeGenDAGPatterns.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ class CodeGenDAGPatterns;
4848
using TreePatternNodePtr = IntrusiveRefCntPtr<TreePatternNode>;
4949

5050
/// This represents a set of MVTs. Since the underlying type for the MVT
51-
/// is uint8_t, there are at most 256 values. To reduce the number of memory
51+
/// is uint16_t, there are at most 65536 values. To reduce the number of memory
5252
/// allocations and deallocations, represent the set as a sequence of bits.
5353
/// To reduce the allocations even further, make MachineValueTypeSet own
5454
/// the storage and use std::array as the bit container.
5555
struct MachineValueTypeSet {
5656
static_assert(std::is_same<std::underlying_type_t<MVT::SimpleValueType>,
57-
uint8_t>::value,
58-
"Change uint8_t here to the SimpleValueType's type");
59-
static unsigned constexpr Capacity = std::numeric_limits<uint8_t>::max() + 1;
57+
uint16_t>::value,
58+
"Change uint16_t here to the SimpleValueType's type");
59+
static unsigned constexpr Capacity = std::numeric_limits<uint16_t>::max() + 1;
6060
using WordType = uint64_t;
6161
static unsigned constexpr WordWidth = CHAR_BIT * sizeof(WordType);
6262
static unsigned constexpr NumWords = Capacity / WordWidth;

llvm/utils/TableGen/DAGISelMatcherEmitter.cpp

Lines changed: 66 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,8 @@ unsigned MatcherTableEmitter::SizeMatcher(Matcher *N, raw_ostream &OS) {
339339
Size += 2; // Count the child's opcode.
340340
} else {
341341
Child = cast<SwitchTypeMatcher>(N)->getCaseMatcher(i);
342-
++Size; // Count the child's type.
342+
Size += GetVBRSize(cast<SwitchTypeMatcher>(N)->getCaseType(
343+
i)); // Count the child's type.
343344
}
344345
const unsigned ChildSize = SizeMatcherList(Child, OS);
345346
assert(ChildSize != 0 && "Matcher cannot have child of size 0");
@@ -599,7 +600,8 @@ unsigned MatcherTableEmitter::EmitMatcher(const Matcher *N,
599600
IdxSize = 2; // size of opcode in table is 2 bytes.
600601
} else {
601602
Child = cast<SwitchTypeMatcher>(N)->getCaseMatcher(i);
602-
IdxSize = 1; // size of type in table is 1 byte.
603+
IdxSize = GetVBRSize(cast<SwitchTypeMatcher>(N)->getCaseType(
604+
i)); // size of type in table is sizeof(MVT) byte.
603605
}
604606

605607
if (i != 0) {
@@ -615,8 +617,13 @@ unsigned MatcherTableEmitter::EmitMatcher(const Matcher *N,
615617
CurrentIdx += EmitVBRValue(ChildSize, OS) + IdxSize;
616618
if (const SwitchOpcodeMatcher *SOM = dyn_cast<SwitchOpcodeMatcher>(N))
617619
OS << "TARGET_VAL(" << SOM->getCaseOpcode(i).getEnumName() << "),";
618-
else
619-
OS << getEnumName(cast<SwitchTypeMatcher>(N)->getCaseType(i)) << ',';
620+
else {
621+
if (!OmitComments)
622+
OS << "/*" << getEnumName(cast<SwitchTypeMatcher>(N)->getCaseType(i))
623+
<< "*/";
624+
EmitVBRValue(cast<SwitchTypeMatcher>(N)->getCaseType(i),
625+
OS); // size of type in table is sizeof(MVT) byte.
626+
}
620627
if (!OmitComments)
621628
OS << "// ->" << CurrentIdx + ChildSize;
622629
OS << '\n';
@@ -639,7 +646,7 @@ unsigned MatcherTableEmitter::EmitMatcher(const Matcher *N,
639646
return CurrentIdx - StartIdx + 1;
640647
}
641648

642-
case Matcher::CheckType:
649+
case Matcher::CheckType: {
643650
if (cast<CheckTypeMatcher>(N)->getResNo() == 0) {
644651
MVT::SimpleValueType VT = cast<CheckTypeMatcher>(N)->getType();
645652
switch (VT) {
@@ -648,13 +655,21 @@ unsigned MatcherTableEmitter::EmitMatcher(const Matcher *N,
648655
OS << "OPC_CheckTypeI" << MVT(VT).getSizeInBits() << ",\n";
649656
return 1;
650657
default:
651-
OS << "OPC_CheckType, " << getEnumName(VT) << ",\n";
652-
return 2;
658+
OS << "OPC_CheckType, ";
659+
if (!OmitComments)
660+
OS << "/*" << getEnumName(VT) << "*/";
661+
unsigned NumBytes = EmitVBRValue(VT, OS);
662+
OS << "\n";
663+
return NumBytes + 1;
653664
}
654665
}
655-
OS << "OPC_CheckTypeRes, " << cast<CheckTypeMatcher>(N)->getResNo() << ", "
656-
<< getEnumName(cast<CheckTypeMatcher>(N)->getType()) << ",\n";
657-
return 3;
666+
OS << "OPC_CheckTypeRes, " << cast<CheckTypeMatcher>(N)->getResNo() << ", ";
667+
if (!OmitComments)
668+
OS << "/*" << getEnumName(cast<CheckTypeMatcher>(N)->getType()) << "*/";
669+
unsigned NumBytes = EmitVBRValue(cast<CheckTypeMatcher>(N)->getType(), OS);
670+
OS << "\n";
671+
return NumBytes + 2;
672+
}
658673

659674
case Matcher::CheckChildType: {
660675
MVT::SimpleValueType VT = cast<CheckChildTypeMatcher>(N)->getType();
@@ -666,8 +681,12 @@ unsigned MatcherTableEmitter::EmitMatcher(const Matcher *N,
666681
return 1;
667682
default:
668683
OS << "OPC_CheckChild" << cast<CheckChildTypeMatcher>(N)->getChildNo()
669-
<< "Type, " << getEnumName(VT) << ",\n";
670-
return 2;
684+
<< "Type, ";
685+
if (!OmitComments)
686+
OS << "/*" << getEnumName(VT) << "*/";
687+
unsigned NumBytes = EmitVBRValue(VT, OS);
688+
OS << "\n";
689+
return NumBytes + 1;
671690
}
672691
}
673692

@@ -696,10 +715,16 @@ unsigned MatcherTableEmitter::EmitMatcher(const Matcher *N,
696715
<< cast<CheckChild2CondCodeMatcher>(N)->getCondCodeName() << ",\n";
697716
return 2;
698717

699-
case Matcher::CheckValueType:
700-
OS << "OPC_CheckValueType, "
701-
<< getEnumName(cast<CheckValueTypeMatcher>(N)->getVT()) << ",\n";
702-
return 2;
718+
case Matcher::CheckValueType: {
719+
OS << "OPC_CheckValueType, ";
720+
if (!OmitComments)
721+
OS << "/*" << getEnumName(cast<CheckValueTypeMatcher>(N)->getVT())
722+
<< "*/";
723+
unsigned NumBytes =
724+
EmitVBRValue(cast<CheckValueTypeMatcher>(N)->getVT(), OS);
725+
OS << "\n";
726+
return NumBytes + 1;
727+
}
703728

704729
case Matcher::CheckComplexPat: {
705730
const CheckComplexPatMatcher *CCPM = cast<CheckComplexPatMatcher>(N);
@@ -766,8 +791,10 @@ unsigned MatcherTableEmitter::EmitMatcher(const Matcher *N,
766791
OS << "OPC_EmitInteger" << MVT(VT).getSizeInBits() << ", ";
767792
break;
768793
default:
769-
OpBytes = 2;
770-
OS << "OPC_EmitInteger, " << getEnumName(VT) << ", ";
794+
OS << "OPC_EmitInteger, ";
795+
if (!OmitComments)
796+
OS << "/*" << getEnumName(VT) << "*/";
797+
OpBytes = EmitVBRValue(VT, OS) + 1;
771798
break;
772799
}
773800
unsigned Bytes = OpBytes + EmitSignedVBRValue(Val, OS);
@@ -785,8 +812,10 @@ unsigned MatcherTableEmitter::EmitMatcher(const Matcher *N,
785812
OS << "OPC_EmitStringInteger" << MVT(VT).getSizeInBits() << ", ";
786813
break;
787814
default:
788-
OpBytes = 2;
789-
OS << "OPC_EmitStringInteger, " << getEnumName(VT) << ", ";
815+
OS << "OPC_EmitStringInteger, ";
816+
if (!OmitComments)
817+
OS << "/*" << getEnumName(VT) << "*/";
818+
OpBytes = EmitVBRValue(VT, OS) + 1;
790819
break;
791820
}
792821
OS << Val << ",\n";
@@ -797,23 +826,28 @@ unsigned MatcherTableEmitter::EmitMatcher(const Matcher *N,
797826
const EmitRegisterMatcher *Matcher = cast<EmitRegisterMatcher>(N);
798827
const CodeGenRegister *Reg = Matcher->getReg();
799828
MVT::SimpleValueType VT = Matcher->getVT();
829+
unsigned OpBytes;
800830
// If the enum value of the register is larger than one byte can handle,
801831
// use EmitRegister2.
802832
if (Reg && Reg->EnumValue > 255) {
803-
OS << "OPC_EmitRegister2, " << getEnumName(VT) << ", ";
833+
OS << "OPC_EmitRegister2, ";
834+
if (!OmitComments)
835+
OS << "/*" << getEnumName(VT) << "*/";
836+
OpBytes = EmitVBRValue(VT, OS);
804837
OS << "TARGET_VAL(" << getQualifiedName(Reg->TheDef) << "),\n";
805-
return 4;
838+
return OpBytes + 3;
806839
}
807-
unsigned OpBytes;
808840
switch (VT) {
809841
case MVT::i32:
810842
case MVT::i64:
811843
OpBytes = 1;
812844
OS << "OPC_EmitRegisterI" << MVT(VT).getSizeInBits() << ", ";
813845
break;
814846
default:
815-
OpBytes = 2;
816-
OS << "OPC_EmitRegister, " << getEnumName(VT) << ", ";
847+
OS << "OPC_EmitRegister, ";
848+
if (!OmitComments)
849+
OS << "/*" << getEnumName(VT) << "*/";
850+
OpBytes = EmitVBRValue(VT, OS) + 1;
817851
break;
818852
}
819853
if (Reg) {
@@ -958,8 +992,12 @@ unsigned MatcherTableEmitter::EmitMatcher(const Matcher *N,
958992
OS << "/*#VTs*/";
959993
OS << ", ";
960994
}
961-
for (unsigned i = 0, e = EN->getNumVTs(); i != e; ++i)
962-
OS << getEnumName(EN->getVT(i)) << ", ";
995+
unsigned NumTypeBytes = 0;
996+
for (unsigned i = 0, e = EN->getNumVTs(); i != e; ++i) {
997+
if (!OmitComments)
998+
OS << "/*" << getEnumName(EN->getVT(i)) << "*/";
999+
NumTypeBytes += EmitVBRValue(EN->getVT(i), OS);
1000+
}
9631001

9641002
OS << EN->getNumOperands();
9651003
if (!OmitComments)
@@ -992,7 +1030,7 @@ unsigned MatcherTableEmitter::EmitMatcher(const Matcher *N,
9921030
} else
9931031
OS << '\n';
9941032

995-
return 4 + !CompressVTs + !CompressNodeInfo + EN->getNumVTs() +
1033+
return 4 + !CompressVTs + !CompressNodeInfo + NumTypeBytes +
9961034
NumOperandBytes + NumCoveredBytes;
9971035
}
9981036
case Matcher::CompleteMatch: {

llvm/utils/TableGen/VTEmitter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ static void VTtoGetLLVMTyString(raw_ostream &OS, const Record *VT) {
7979
void VTEmitter::run(raw_ostream &OS) {
8080
emitSourceFileHeader("ValueTypes Source Fragment", OS, Records);
8181

82-
std::array<const Record *, 256> VTsByNumber = {};
82+
std::array<const Record *, 65536> VTsByNumber = {};
8383
auto ValueTypes = Records.getAllDerivedDefinitions("ValueType");
8484
for (auto *VT : ValueTypes) {
8585
auto Number = VT->getValueAsInt("Value");
8686
assert(0 <= Number && Number < (int)VTsByNumber.size() &&
87-
"ValueType should be uint8_t");
87+
"ValueType should be uint16_t");
8888
assert(!VTsByNumber[Number] && "Duplicate ValueType");
8989
VTsByNumber[Number] = VT;
9090
}

0 commit comments

Comments
 (0)