Skip to content

Commit f944eef

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 f944eef

File tree

6 files changed

+99
-54
lines changed

6 files changed

+99
-54
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: 50 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2896,8 +2896,10 @@ CheckChild2CondCode(const unsigned char *MatcherTable, unsigned &MatcherIndex,
28962896
LLVM_ATTRIBUTE_ALWAYS_INLINE static bool
28972897
CheckValueType(const unsigned char *MatcherTable, unsigned &MatcherIndex,
28982898
SDValue N, const TargetLowering *TLI, const DataLayout &DL) {
2899-
MVT::SimpleValueType VT =
2900-
static_cast<MVT::SimpleValueType>(MatcherTable[MatcherIndex++]);
2899+
unsigned SimpleVT = MatcherTable[MatcherIndex++];
2900+
if (SimpleVT & 128)
2901+
SimpleVT = GetVBR(SimpleVT, MatcherTable, MatcherIndex);
2902+
MVT::SimpleValueType VT = static_cast<MVT::SimpleValueType>(SimpleVT);
29012903
if (cast<VTSDNode>(N)->getVT() == VT)
29022904
return true;
29032905

@@ -3027,15 +3029,21 @@ static unsigned IsPredicateKnownToFail(const unsigned char *Table,
30273029
VT = MVT::i64;
30283030
break;
30293031
default:
3030-
VT = static_cast<MVT::SimpleValueType>(Table[Index++]);
3032+
unsigned SimpleVT = Table[Index++];
3033+
if (SimpleVT & 128)
3034+
SimpleVT = GetVBR(SimpleVT, Table, Index);
3035+
VT = static_cast<MVT::SimpleValueType>(SimpleVT);
30313036
break;
30323037
}
30333038
Result = !::CheckType(VT, N, SDISel.TLI, SDISel.CurDAG->getDataLayout());
30343039
return Index;
30353040
}
30363041
case SelectionDAGISel::OPC_CheckTypeRes: {
30373042
unsigned Res = Table[Index++];
3038-
Result = !::CheckType(static_cast<MVT::SimpleValueType>(Table[Index++]),
3043+
unsigned SimpleVT = Table[Index++];
3044+
if (SimpleVT & 128)
3045+
SimpleVT = GetVBR(SimpleVT, Table, Index);
3046+
Result = !::CheckType(static_cast<MVT::SimpleValueType>(SimpleVT),
30393047
N.getValue(Res), SDISel.TLI,
30403048
SDISel.CurDAG->getDataLayout());
30413049
return Index;
@@ -3075,7 +3083,10 @@ static unsigned IsPredicateKnownToFail(const unsigned char *Table,
30753083
VT = MVT::i64;
30763084
ChildNo = Opcode - SelectionDAGISel::OPC_CheckChild0TypeI64;
30773085
} else {
3078-
VT = static_cast<MVT::SimpleValueType>(Table[Index++]);
3086+
unsigned SimpleVT = Table[Index++];
3087+
if (SimpleVT & 128)
3088+
SimpleVT = GetVBR(SimpleVT, Table, Index);
3089+
VT = static_cast<MVT::SimpleValueType>(SimpleVT);
30793090
ChildNo = Opcode - SelectionDAGISel::OPC_CheckChild0Type;
30803091
}
30813092
Result = !::CheckChildType(VT, N, SDISel.TLI,
@@ -3579,7 +3590,10 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch,
35793590
VT = MVT::i64;
35803591
break;
35813592
default:
3582-
VT = static_cast<MVT::SimpleValueType>(MatcherTable[MatcherIndex++]);
3593+
unsigned SimpleVT = MatcherTable[MatcherIndex++];
3594+
if (SimpleVT & 128)
3595+
SimpleVT = GetVBR(SimpleVT, MatcherTable, MatcherIndex);
3596+
VT = static_cast<MVT::SimpleValueType>(SimpleVT);
35833597
break;
35843598
}
35853599
if (!::CheckType(VT, N, TLI, CurDAG->getDataLayout()))
@@ -3588,9 +3602,11 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch,
35883602

35893603
case OPC_CheckTypeRes: {
35903604
unsigned Res = MatcherTable[MatcherIndex++];
3591-
if (!::CheckType(
3592-
static_cast<MVT::SimpleValueType>(MatcherTable[MatcherIndex++]),
3593-
N.getValue(Res), TLI, CurDAG->getDataLayout()))
3605+
unsigned SimpleVT = MatcherTable[MatcherIndex++];
3606+
if (SimpleVT & 128)
3607+
SimpleVT = GetVBR(SimpleVT, MatcherTable, MatcherIndex);
3608+
if (!::CheckType(static_cast<MVT::SimpleValueType>(SimpleVT),
3609+
N.getValue(Res), TLI, CurDAG->getDataLayout()))
35943610
break;
35953611
continue;
35963612
}
@@ -3629,16 +3645,18 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch,
36293645
case OPC_SwitchType: {
36303646
MVT CurNodeVT = N.getSimpleValueType();
36313647
unsigned SwitchStart = MatcherIndex-1; (void)SwitchStart;
3632-
unsigned CaseSize;
3648+
unsigned CaseSize, CaseSimpleVT;
36333649
while (true) {
36343650
// Get the size of this case.
36353651
CaseSize = MatcherTable[MatcherIndex++];
36363652
if (CaseSize & 128)
36373653
CaseSize = GetVBR(CaseSize, MatcherTable, MatcherIndex);
36383654
if (CaseSize == 0) break;
36393655

3640-
MVT CaseVT =
3641-
static_cast<MVT::SimpleValueType>(MatcherTable[MatcherIndex++]);
3656+
CaseSimpleVT = MatcherTable[MatcherIndex++];
3657+
if (CaseSimpleVT & 128)
3658+
CaseSimpleVT = GetVBR(CaseSimpleVT, MatcherTable, MatcherIndex);
3659+
MVT CaseVT = static_cast<MVT::SimpleValueType>(CaseSimpleVT);
36423660
if (CaseVT == MVT::iPTR)
36433661
CaseVT = TLI->getPointerTy(CurDAG->getDataLayout());
36443662

@@ -3694,7 +3712,10 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch,
36943712
VT = MVT::i64;
36953713
ChildNo = Opcode - SelectionDAGISel::OPC_CheckChild0TypeI64;
36963714
} else {
3697-
VT = static_cast<MVT::SimpleValueType>(MatcherTable[MatcherIndex++]);
3715+
unsigned SimpleVT = MatcherTable[MatcherIndex++];
3716+
if (SimpleVT & 128)
3717+
SimpleVT = GetVBR(SimpleVT, MatcherTable, MatcherIndex);
3718+
VT = static_cast<MVT::SimpleValueType>(SimpleVT);
36983719
ChildNo = Opcode - SelectionDAGISel::OPC_CheckChild0Type;
36993720
}
37003721
if (!::CheckChildType(VT, N, TLI, CurDAG->getDataLayout(), ChildNo))
@@ -3788,7 +3809,10 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch,
37883809
VT = MVT::i64;
37893810
break;
37903811
default:
3791-
VT = static_cast<MVT::SimpleValueType>(MatcherTable[MatcherIndex++]);
3812+
unsigned SimpleVT = MatcherTable[MatcherIndex++];
3813+
if (SimpleVT & 128)
3814+
SimpleVT = GetVBR(SimpleVT, MatcherTable, MatcherIndex);
3815+
VT = static_cast<MVT::SimpleValueType>(SimpleVT);
37923816
break;
37933817
}
37943818
int64_t Val = MatcherTable[MatcherIndex++];
@@ -3812,7 +3836,10 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch,
38123836
VT = MVT::i64;
38133837
break;
38143838
default:
3815-
VT = static_cast<MVT::SimpleValueType>(MatcherTable[MatcherIndex++]);
3839+
unsigned SimpleVT = MatcherTable[MatcherIndex++];
3840+
if (SimpleVT & 128)
3841+
SimpleVT = GetVBR(SimpleVT, MatcherTable, MatcherIndex);
3842+
VT = static_cast<MVT::SimpleValueType>(SimpleVT);
38163843
break;
38173844
}
38183845
unsigned RegNo = MatcherTable[MatcherIndex++];
@@ -3824,8 +3851,10 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch,
38243851
// For targets w/ more than 256 register names, the register enum
38253852
// values are stored in two bytes in the matcher table (just like
38263853
// opcodes).
3827-
MVT::SimpleValueType VT =
3828-
static_cast<MVT::SimpleValueType>(MatcherTable[MatcherIndex++]);
3854+
unsigned SimpleVT = MatcherTable[MatcherIndex++];
3855+
if (SimpleVT & 128)
3856+
SimpleVT = GetVBR(SimpleVT, MatcherTable, MatcherIndex);
3857+
MVT::SimpleValueType VT = static_cast<MVT::SimpleValueType>(SimpleVT);
38293858
unsigned RegNo = MatcherTable[MatcherIndex++];
38303859
RegNo |= MatcherTable[MatcherIndex++] << 8;
38313860
RecordedNodes.push_back(std::pair<SDValue, SDNode*>(
@@ -4063,8 +4092,10 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch,
40634092
NumVTs = MatcherTable[MatcherIndex++];
40644093
SmallVector<EVT, 4> VTs;
40654094
for (unsigned i = 0; i != NumVTs; ++i) {
4066-
MVT::SimpleValueType VT =
4067-
static_cast<MVT::SimpleValueType>(MatcherTable[MatcherIndex++]);
4095+
unsigned SimpleVT = MatcherTable[MatcherIndex++];
4096+
if (SimpleVT & 128)
4097+
SimpleVT = GetVBR(SimpleVT, MatcherTable, MatcherIndex);
4098+
MVT::SimpleValueType VT = static_cast<MVT::SimpleValueType>(SimpleVT);
40684099
if (VT == MVT::iPTR)
40694100
VT = TLI->getPointerTy(CurDAG->getDataLayout()).SimpleTy;
40704101
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: 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: 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: 40 additions & 26 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) {
@@ -616,7 +618,8 @@ unsigned MatcherTableEmitter::EmitMatcher(const Matcher *N,
616618
if (const SwitchOpcodeMatcher *SOM = dyn_cast<SwitchOpcodeMatcher>(N))
617619
OS << "TARGET_VAL(" << SOM->getCaseOpcode(i).getEnumName() << "),";
618620
else
619-
OS << getEnumName(cast<SwitchTypeMatcher>(N)->getCaseType(i)) << ',';
621+
EmitVBRValue(cast<SwitchTypeMatcher>(N)->getCaseType(i),
622+
OS); // size of type in table is sizeof(MVT) byte.
620623
if (!OmitComments)
621624
OS << "// ->" << CurrentIdx + ChildSize;
622625
OS << '\n';
@@ -639,7 +642,7 @@ unsigned MatcherTableEmitter::EmitMatcher(const Matcher *N,
639642
return CurrentIdx - StartIdx + 1;
640643
}
641644

642-
case Matcher::CheckType:
645+
case Matcher::CheckType: {
643646
if (cast<CheckTypeMatcher>(N)->getResNo() == 0) {
644647
MVT::SimpleValueType VT = cast<CheckTypeMatcher>(N)->getType();
645648
switch (VT) {
@@ -648,13 +651,17 @@ unsigned MatcherTableEmitter::EmitMatcher(const Matcher *N,
648651
OS << "OPC_CheckTypeI" << MVT(VT).getSizeInBits() << ",\n";
649652
return 1;
650653
default:
651-
OS << "OPC_CheckType, " << getEnumName(VT) << ",\n";
652-
return 2;
654+
OS << "OPC_CheckType, ";
655+
unsigned NumBytes = EmitVBRValue(VT, OS);
656+
OS << "\n";
657+
return NumBytes + 1;
653658
}
654659
}
655-
OS << "OPC_CheckTypeRes, " << cast<CheckTypeMatcher>(N)->getResNo() << ", "
656-
<< getEnumName(cast<CheckTypeMatcher>(N)->getType()) << ",\n";
657-
return 3;
660+
OS << "OPC_CheckTypeRes, " << cast<CheckTypeMatcher>(N)->getResNo() << ", ";
661+
unsigned NumBytes = EmitVBRValue(cast<CheckTypeMatcher>(N)->getType(), OS);
662+
OS << "\n";
663+
return NumBytes + 2;
664+
}
658665

659666
case Matcher::CheckChildType: {
660667
MVT::SimpleValueType VT = cast<CheckChildTypeMatcher>(N)->getType();
@@ -666,8 +673,10 @@ unsigned MatcherTableEmitter::EmitMatcher(const Matcher *N,
666673
return 1;
667674
default:
668675
OS << "OPC_CheckChild" << cast<CheckChildTypeMatcher>(N)->getChildNo()
669-
<< "Type, " << getEnumName(VT) << ",\n";
670-
return 2;
676+
<< "Type, ";
677+
unsigned NumBytes = EmitVBRValue(VT, OS);
678+
OS << "\n";
679+
return NumBytes + 1;
671680
}
672681
}
673682

@@ -696,10 +705,13 @@ unsigned MatcherTableEmitter::EmitMatcher(const Matcher *N,
696705
<< cast<CheckChild2CondCodeMatcher>(N)->getCondCodeName() << ",\n";
697706
return 2;
698707

699-
case Matcher::CheckValueType:
700-
OS << "OPC_CheckValueType, "
701-
<< getEnumName(cast<CheckValueTypeMatcher>(N)->getVT()) << ",\n";
702-
return 2;
708+
case Matcher::CheckValueType: {
709+
OS << "OPC_CheckValueType, ";
710+
unsigned NumBytes =
711+
EmitVBRValue(cast<CheckValueTypeMatcher>(N)->getVT(), OS);
712+
OS << "\n";
713+
return NumBytes + 1;
714+
}
703715

704716
case Matcher::CheckComplexPat: {
705717
const CheckComplexPatMatcher *CCPM = cast<CheckComplexPatMatcher>(N);
@@ -766,8 +778,8 @@ unsigned MatcherTableEmitter::EmitMatcher(const Matcher *N,
766778
OS << "OPC_EmitInteger" << MVT(VT).getSizeInBits() << ", ";
767779
break;
768780
default:
769-
OpBytes = 2;
770-
OS << "OPC_EmitInteger, " << getEnumName(VT) << ", ";
781+
OS << "OPC_EmitInteger, ";
782+
OpBytes = EmitVBRValue(VT, OS) + 1;
771783
break;
772784
}
773785
unsigned Bytes = OpBytes + EmitSignedVBRValue(Val, OS);
@@ -785,8 +797,8 @@ unsigned MatcherTableEmitter::EmitMatcher(const Matcher *N,
785797
OS << "OPC_EmitStringInteger" << MVT(VT).getSizeInBits() << ", ";
786798
break;
787799
default:
788-
OpBytes = 2;
789-
OS << "OPC_EmitStringInteger, " << getEnumName(VT) << ", ";
800+
OS << "OPC_EmitStringInteger, ";
801+
OpBytes = EmitVBRValue(VT, OS) + 1;
790802
break;
791803
}
792804
OS << Val << ",\n";
@@ -797,23 +809,24 @@ unsigned MatcherTableEmitter::EmitMatcher(const Matcher *N,
797809
const EmitRegisterMatcher *Matcher = cast<EmitRegisterMatcher>(N);
798810
const CodeGenRegister *Reg = Matcher->getReg();
799811
MVT::SimpleValueType VT = Matcher->getVT();
812+
unsigned OpBytes;
800813
// If the enum value of the register is larger than one byte can handle,
801814
// use EmitRegister2.
802815
if (Reg && Reg->EnumValue > 255) {
803-
OS << "OPC_EmitRegister2, " << getEnumName(VT) << ", ";
816+
OS << "OPC_EmitRegister2, ";
817+
OpBytes = EmitVBRValue(VT, OS);
804818
OS << "TARGET_VAL(" << getQualifiedName(Reg->TheDef) << "),\n";
805-
return 4;
819+
return OpBytes + 3;
806820
}
807-
unsigned OpBytes;
808821
switch (VT) {
809822
case MVT::i32:
810823
case MVT::i64:
811824
OpBytes = 1;
812825
OS << "OPC_EmitRegisterI" << MVT(VT).getSizeInBits() << ", ";
813826
break;
814827
default:
815-
OpBytes = 2;
816-
OS << "OPC_EmitRegister, " << getEnumName(VT) << ", ";
828+
OS << "OPC_EmitRegister, ";
829+
OpBytes = EmitVBRValue(VT, OS) + 1;
817830
break;
818831
}
819832
if (Reg) {
@@ -958,8 +971,9 @@ unsigned MatcherTableEmitter::EmitMatcher(const Matcher *N,
958971
OS << "/*#VTs*/";
959972
OS << ", ";
960973
}
974+
unsigned NumTypeBytes = 0;
961975
for (unsigned i = 0, e = EN->getNumVTs(); i != e; ++i)
962-
OS << getEnumName(EN->getVT(i)) << ", ";
976+
NumTypeBytes += EmitVBRValue(EN->getVT(i), OS);
963977

964978
OS << EN->getNumOperands();
965979
if (!OmitComments)
@@ -992,7 +1006,7 @@ unsigned MatcherTableEmitter::EmitMatcher(const Matcher *N,
9921006
} else
9931007
OS << '\n';
9941008

995-
return 4 + !CompressVTs + !CompressNodeInfo + EN->getNumVTs() +
1009+
return 4 + !CompressVTs + !CompressNodeInfo + NumTypeBytes +
9961010
NumOperandBytes + NumCoveredBytes;
9971011
}
9981012
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)