Skip to content

Commit 3c37ad6

Browse files
committed
Resolve conflicts
1 parent 979a836 commit 3c37ad6

File tree

2 files changed

+44
-28
lines changed

2 files changed

+44
-28
lines changed

llvm/test/TableGen/FixedLenDecoderEmitter/InvalidEncoding.td

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
// RUN: not llvm-tblgen -gen-disassembler -I %p/../../../include %s -DTEST1 2>&1 | FileCheck %s -DFILE=%s --check-prefix=CHECK-TEST1
2-
// RUN: not llvm-tblgen -gen-disassembler -I %p/../../../include %s -DTEST2 2>&1 | FileCheck %s -DFILE=%s --check-prefix=CHECK-TEST2
1+
// RUN: not llvm-tblgen -gen-disassembler -I %p/../../../include %s -DTEST1 2>&1 | FileCheck %s --check-prefix=CHECK-TEST1
2+
// RUN: not llvm-tblgen -gen-disassembler -I %p/../../../include %s -DTEST2 2>&1 | FileCheck %s --check-prefix=CHECK-TEST2
3+
// RUN: not llvm-tblgen -gen-disassembler -I %p/../../../include %s -DTEST3 2>&1 | FileCheck %s --check-prefix=CHECK-TEST3
34

45
include "llvm/Target/Target.td"
56

@@ -10,10 +11,10 @@ def arch : Target {
1011
}
1112

1213
#ifdef TEST1
13-
// CHECK-TEST1: [[FILE]]:[[@LINE+1]]:5: error: foo: Size is 16 bits, but Inst bits beyond that are not zero/unset
14+
// CHECK-TEST1: [[#@LINE+1]]:5: error: foo: Size is 16 bits, but Inst bits beyond that are not zero/unset
1415
def foo : Instruction {
1516
let OutOperandList = (outs);
16-
let InOperandList = (ins i32imm:$factor);
17+
let InOperandList = (ins i32imm:$factor);
1718
let Size = 2;
1819
field bits<24> Inst;
1920
field bits<24> SoftFail = 0;
@@ -24,10 +25,25 @@ def foo : Instruction {
2425
#endif
2526

2627
#ifdef TEST2
27-
// CHECK-TEST2: [[FILE]]:[[@LINE+1]]:5: error: bar: Size is 16 bits, but Inst specifies only 8 bits
28+
// CHECK-TEST2: [[#@LINE+1]]:5: error: foo: Size is 16 bits, but SoftFail bits beyond that are not zero/unset
29+
def foo : Instruction {
30+
let OutOperandList = (outs);
31+
let InOperandList = (ins i32imm:$factor);
32+
let Size = 2;
33+
field bits<24> Inst;
34+
field bits<24> SoftFail = 0;
35+
bits<8> factor;
36+
let Inst{15...8} = factor{7...0};
37+
let Inst{23...16} = 0;
38+
let SoftFail{20} = 1;
39+
}
40+
#endif
41+
42+
#ifdef TEST3
43+
// CHECK-TEST3: [[#@LINE+1]]:5: error: bar: Size is 16 bits, but Inst specifies only 8 bits
2844
def bar : Instruction {
2945
let OutOperandList = (outs);
30-
let InOperandList = (ins i32imm:$factor);
46+
let InOperandList = (ins i32imm:$factor);
3147
let Size = 2;
3248
field bits<8> Inst;
3349
field bits<8> SoftFail = 0;

llvm/utils/TableGen/DecoderEmitter.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ class InstructionEncoding {
212212

213213
private:
214214
void parseVarLenEncoding(const VarLenInst &VLI);
215-
void parseFixedLenEncoding(const BitsInit &Bits);
215+
void parseFixedLenEncoding(const BitsInit &RecordInstBits);
216216

217217
void parseVarLenOperands(const VarLenInst &VLI);
218218
void parseFixedLenOperands(const BitsInit &Bits);
@@ -1787,46 +1787,46 @@ void InstructionEncoding::parseVarLenEncoding(const VarLenInst &VLI) {
17871787
assert(I == VLI.size());
17881788
}
17891789

1790-
void InstructionEncoding::parseFixedLenEncoding(const BitsInit &InstBits) {
1790+
void InstructionEncoding::parseFixedLenEncoding(
1791+
const BitsInit &RecordInstBits) {
17911792
// For fixed length instructions, sometimes the `Inst` field specifies more
17921793
// bits than the actual size of the instruction, which is specified in `Size`.
17931794
// In such cases, we do some basic validation and drop the upper bits.
17941795
unsigned BitWidth = EncodingDef->getValueAsInt("Size") * 8;
1795-
unsigned InstNumBits = InstBits.getNumBits();
1796+
unsigned InstNumBits = RecordInstBits.getNumBits();
17961797

17971798
// Returns true if all bits in `Bits` are zero or unset.
1798-
auto CheckAllZeroOrUnset = [&](ArrayRef<const Init *> Bits, const RecordVal *Field) {
1799+
auto CheckAllZeroOrUnset = [&](ArrayRef<const Init *> Bits,
1800+
const RecordVal *Field) {
17991801
bool AllZeroOrUnset = llvm::all_of(Bits, [](const Init *Bit) {
18001802
if (const auto *BI = dyn_cast<BitInit>(Bit))
18011803
return !BI->getValue();
18021804
return isa<UnsetInit>(Bit);
18031805
});
18041806
if (AllZeroOrUnset)
18051807
return;
1806-
PrintNote([Field](raw_ostream &OS) {
1807-
Field->print(OS);
1808-
});
1809-
PrintFatalError(
1810-
EncodingDef,
1811-
Twine(Name) + ": Size is " + Twine(BitWidth) +
1812-
" bits, but " + Field->getName() + " bits beyond that are not zero/unset");
1808+
PrintNote([Field](raw_ostream &OS) { Field->print(OS); });
1809+
PrintFatalError(EncodingDef, Twine(Name) + ": Size is " + Twine(BitWidth) +
1810+
" bits, but " + Field->getName() +
1811+
" bits beyond that are not zero/unset");
18131812
};
18141813

18151814
if (InstNumBits < BitWidth)
1816-
PrintFatalError(EncodingDef, Twine(Name) + ": Size is " +
1817-
Twine(BitWidth) +
1818-
" bits, but Inst specifies only " +
1819-
Twine(InstNumBits) + " bits");
1815+
PrintFatalError(EncodingDef, Twine(Name) + ": Size is " + Twine(BitWidth) +
1816+
" bits, but Inst specifies only " +
1817+
Twine(InstNumBits) + " bits");
18201818

18211819
if (InstNumBits > BitWidth) {
18221820
// Ensure that all the bits beyond 'Size' are 0 or unset (i.e., carry no
18231821
// actual encoding).
1824-
ArrayRef<const Init *> UpperBits = InstBits.getBits().drop_front(BitWidth);
1822+
ArrayRef<const Init *> UpperBits =
1823+
RecordInstBits.getBits().drop_front(BitWidth);
18251824
const RecordVal *InstField = EncodingDef->getValue("Inst");
18261825
CheckAllZeroOrUnset(UpperBits, InstField);
18271826
}
18281827

1829-
ArrayRef<const Init *> ActiveInstBits = InstBits.getBits().take_front(BitWidth);
1828+
ArrayRef<const Init *> ActiveInstBits =
1829+
RecordInstBits.getBits().take_front(BitWidth);
18301830
InstBits = KnownBits(BitWidth);
18311831
SoftFailBits = APInt(BitWidth, 0);
18321832

@@ -1846,12 +1846,12 @@ void InstructionEncoding::parseFixedLenEncoding(const BitsInit &InstBits) {
18461846
return;
18471847

18481848
const auto *SFBits = dyn_cast<BitsInit>(SoftFailField->getValue());
1849-
if (!SFBits || SFBits->getNumBits() != Bits.getNumBits()) {
1849+
if (!SFBits || SFBits->getNumBits() != InstNumBits) {
18501850
PrintNote(EncodingDef->getLoc(), "in record");
18511851
PrintFatalError(SoftFailField,
18521852
formatv("SoftFail field, if defined, must be "
18531853
"of the same type as Inst, which is bits<{}>",
1854-
Bits.getNumBits()));
1854+
InstNumBits));
18551855
}
18561856

18571857
if (InstNumBits > BitWidth) {
@@ -1866,9 +1866,9 @@ void InstructionEncoding::parseFixedLenEncoding(const BitsInit &InstBits) {
18661866
if (!InstBits.Zero[I] && !InstBits.One[I]) {
18671867
PrintNote(EncodingDef->getLoc(), "in record");
18681868
PrintError(SoftFailField,
1869-
formatv("SoftFail{{{0}} = 1 requires Inst{{{0}} "
1870-
"to be fully defined (0 or 1, not '?')",
1871-
I));
1869+
formatv("SoftFail{{{0}} = 1 requires Inst{{{0}} "
1870+
"to be fully defined (0 or 1, not '?')",
1871+
I));
18721872
}
18731873
SoftFailBits.setBit(I);
18741874
}

0 commit comments

Comments
 (0)