1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

Tablegen fixes for new syntax when initializing bits from variables.

Followup to r215086.

llvm-svn: 216757
This commit is contained in:
Jean-Luc Duprat 2014-08-29 19:41:04 +00:00
parent 69d86a518a
commit 9d6a52ea2b
2 changed files with 12 additions and 1 deletions

View File

@ -1321,6 +1321,15 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType,
NewBits.push_back(BI->getBit((e - i) - 1));
continue;
}
// bits<n> can also come from variable initializers.
if (VarInit *VI = dyn_cast<VarInit>(Vals[i])) {
if (BitsRecTy *BitsRec = dyn_cast<BitsRecTy>(VI->getType())) {
for (unsigned i = 0, e = BitsRec->getNumBits(); i != e; ++i)
NewBits.push_back(VI->getBit((e - i) - 1));
continue;
}
// Fallthrough to try convert this to a bit.
}
// All other values must be convertible to just a single bit.
Init *Bit = Vals[i]->convertInitializerTo(BitRecTy::get());
if (!Bit) {

View File

@ -16,7 +16,7 @@ def a {
// CHECK: bits<2> opc = { 0, 1 };
// CHECK: bits<2> opc2 = { 1, 0 };
// CHECK: bits<1> opc3 = { 1 };
// CHECK: bits<2> a = { ?, ? };
// CHECK: bits<2> a;
// CHECK: bits<2> b = { 1, 0 };
// CHECK: bits<2> c = { 1, 1 };
// CHECK: }
@ -51,6 +51,7 @@ def {
bits<16> H;
let H{15-0} = { { 0b11001100 }, 0b00110011 };
bits<16> I = { G1, G2 };
// Make sure we can initialise ints with bits<> values.
int J = H;
@ -78,6 +79,7 @@ def {
// CHECK: bits<8> G2 = { 0, 1, 1, 0, 0, 1, 0, 0 };
// CHECK: bits<8> G3 = { 0, 1, 1, 0, 0, 1, 0, 0 };
// CHECK: bits<16> H = { 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1 };
// CHECK: bits<16> I = { 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0 };
// CHECK: int J = 52275;
// CHECK: int K = 1;
// CHECK: }