From 2597764ad95e1972d071ca89f0366277bcb56b9a Mon Sep 17 00:00:00 2001 From: Pete Cooper Date: Thu, 7 Aug 2014 05:47:00 +0000 Subject: Change TableGen so that binary literals such as 0b001 are now sized. Instead of these becoming an integer literal internally, they now become bits values. Prior to this change, 0b001 was 1 bit long. This is confusing as clearly the user gave 3 bits. This new type holds both the literal value and the size, and so can ensure sizes match on initializers. For example, this used to be legal bits<1> x = 0b00; but now it must be written as bits<2> x = 0b00; llvm-svn: 215084 --- llvm/lib/TableGen/TGParser.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'llvm/lib/TableGen/TGParser.cpp') diff --git a/llvm/lib/TableGen/TGParser.cpp b/llvm/lib/TableGen/TGParser.cpp index d020a8bdc1a..709c7a52b9f 100644 --- a/llvm/lib/TableGen/TGParser.cpp +++ b/llvm/lib/TableGen/TGParser.cpp @@ -1182,6 +1182,15 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType, Lex.Lex(); // Skip '#'. return ParseSimpleValue(CurRec, ItemType, Mode); case tgtok::IntVal: R = IntInit::get(Lex.getCurIntVal()); Lex.Lex(); break; + case tgtok::BinaryIntVal: { + auto BinaryVal = Lex.getCurBinaryIntVal(); + SmallVector Bits(BinaryVal.second); + for (unsigned i = 0, e = BinaryVal.second; i != e; ++i) + Bits[i] = BitInit::get(BinaryVal.first & (1 << i)); + R = BitsInit::get(Bits); + Lex.Lex(); + break; + } case tgtok::StrVal: { std::string Val = Lex.getCurStrVal(); Lex.Lex(); -- cgit v1.2.3