Skip to content

Commit 7db6e8c

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 the generated matcher table file in terms of "number of characters": Table Before After Change(%) WebAssemblyGenDAGISel.inc 393561 379244 -3.64 NVPTXGenDAGISel.inc 2559591 2430267 -5.05 RISCVGenDAGISel.inc 34077228 33338013 -2.17 AVRGenDAGISel.inc 50151 47965 -4.36 PPCGenDAGISel.inc 2504435 2392041 -4.49 MipsGenDAGISel.inc 778353 751718 -3.42 SystemZGenDAGISel.inc 896893 863890 -3.68 AArch64GenDAGISel.inc 8107608 7841939 -3.28 MSP430GenDAGISel.inc 135129 130357 -3.53 LoongArchGenDAGISel.inc 1270101 1220317 -3.92 XCoreGenDAGISel.inc 61883 60740 -1.85 BPFGenDAGISel.inc 70406 69036 -1.95 VEGenDAGISel.inc 939901 909025 -3.29 LanaiGenDAGISel.inc 39537 38571 -2.44 X86GenDAGISel.inc 10144147 9789910 -3.49 ARMGenDAGISel.inc 2538230 2431278 -4.21 HexagonGenDAGISel.inc 2553975 2470275 -3.28 SparcGenDAGISel.inc 96671 93963 -2.80 AMDGPUGenDAGISel.inc 8546226 8391452 -1.81 R600GenDAGISel.inc 397075 390725 -1.60 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 109708 108748 -0.88 nvptx64 109892 108616 -1.16 riscv64 113492 112624 -0.76 avr 110440 109080 -1.23 ppc64 112384 111676 -0.63 mips64 113524 112568 -0.84 systemz 110864 109964 -0.81 aarch64 113736 112484 -1.10 msp430 110136 108956 -1.07 loongarch64 110784 109784 -0.90 xcore 108004 106776 -1.14 bpf 110612 109520 -0.99 ve 110976 109756 -1.10 lanai 109880 108620 -1.15 x86_64 113652 112540 -0.98 arm64 113576 112588 -0.87 hexagon 115264 113556 -1.48 sparc 110336 108792 -1.40 amdgcn 117248 116088 -0.99 r600 111060 109788 -1.15
1 parent 4b9fab5 commit 7db6e8c

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)