From 736ceace11249da645ec4ed91b8714832193ead4 Mon Sep 17 00:00:00 2001 From: Sean Silva Date: Fri, 5 Oct 2012 03:31:58 +0000 Subject: tblgen: Replace uses of dynamic_cast with dyn_cast<>. This is a mechanical change of dynamic_cast<> to dyn_cast<>. A number of these uses are actually more like isa<> or cast<>, and will be changed to the semanticaly appropriate one in a future patch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165291 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/TableGen/TGParser.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/TableGen/TGParser.cpp') diff --git a/lib/TableGen/TGParser.cpp b/lib/TableGen/TGParser.cpp index aee93e7..82d1957 100644 --- a/lib/TableGen/TGParser.cpp +++ b/lib/TableGen/TGParser.cpp @@ -864,8 +864,8 @@ Init *TGParser::ParseOperation(Record *CurRec) { return 0; } if (LHSt) { - ListRecTy *LType = dynamic_cast(LHSt->getType()); - StringRecTy *SType = dynamic_cast(LHSt->getType()); + ListRecTy *LType = dyn_cast(LHSt->getType()); + StringRecTy *SType = dyn_cast(LHSt->getType()); if (LType == 0 && SType == 0) { TokError("expected list or string type argumnet in unary operator"); return 0; @@ -897,7 +897,7 @@ Init *TGParser::ParseOperation(Record *CurRec) { } } else { assert(LHSt && "expected list type argument in unary operator"); - ListRecTy *LType = dynamic_cast(LHSt->getType()); + ListRecTy *LType = dyn_cast(LHSt->getType()); if (LType == 0) { TokError("expected list type argumnet in unary operator"); return 0; @@ -1271,7 +1271,7 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType, ListRecTy *GivenListTy = 0; if (ItemType != 0) { - ListRecTy *ListType = dynamic_cast(ItemType); + ListRecTy *ListType = dyn_cast(ItemType); if (ListType == 0) { std::stringstream s; s << "Type mismatch for list, expected list type, got " @@ -1723,7 +1723,7 @@ VarInit *TGParser::ParseForeachDeclaration(ListInit *&ForeachListValue) { return 0; } RecTy *ValueType = ForeachListValue->getType(); - ListRecTy *ListType = dynamic_cast(ValueType); + ListRecTy *ListType = dyn_cast(ValueType); if (ListType == 0) { TokError("Value list is not of list type"); return 0; -- cgit v1.1 From 80d94e053a384f83075b55c3f62ccc91caf93d18 Mon Sep 17 00:00:00 2001 From: Sean Silva Date: Tue, 9 Oct 2012 17:03:11 +0000 Subject: tblgen: Remove pointless method call. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165511 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/TableGen/TGParser.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/TableGen/TGParser.cpp') diff --git a/lib/TableGen/TGParser.cpp b/lib/TableGen/TGParser.cpp index 82d1957..0ed75f0 100644 --- a/lib/TableGen/TGParser.cpp +++ b/lib/TableGen/TGParser.cpp @@ -110,7 +110,6 @@ bool TGParser::SetValue(Record *CurRec, SMLoc Loc, Init *ValName, // Convert the incoming value to a bits type of the appropriate size... Init *BI = V->convertInitializerTo(BitsRecTy::get(BitList.size())); if (BI == 0) { - V->convertInitializerTo(BitsRecTy::get(BitList.size())); return Error(Loc, "Initializer is not compatible with bit range"); } -- cgit v1.1 From 6cfc806a6b82b60a3e923b6b89f2b4da62cdb50b Mon Sep 17 00:00:00 2001 From: Sean Silva Date: Wed, 10 Oct 2012 20:24:43 +0000 Subject: tblgen: Mechanically move dynamic_cast<> to dyn_cast<>. Some of these dyn_cast<>'s would be better phrased as isa<> or cast<>. That will happen in a future patch. There are also two dyn_cast_or_null<>'s slipped in instead of dyn_cast<>'s, since they were causing crashes with just dyn_cast<>. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165646 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/TableGen/TGParser.cpp | 52 +++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'lib/TableGen/TGParser.cpp') diff --git a/lib/TableGen/TGParser.cpp b/lib/TableGen/TGParser.cpp index 0ed75f0..1b1c18b 100644 --- a/lib/TableGen/TGParser.cpp +++ b/lib/TableGen/TGParser.cpp @@ -93,7 +93,7 @@ bool TGParser::SetValue(Record *CurRec, SMLoc Loc, Init *ValName, // Do not allow assignments like 'X = X'. This will just cause infinite loops // in the resolution machinery. if (BitList.empty()) - if (VarInit *VI = dynamic_cast(V)) + if (VarInit *VI = dyn_cast(V)) if (VI->getNameInit() == ValName) return false; @@ -102,7 +102,7 @@ bool TGParser::SetValue(Record *CurRec, SMLoc Loc, Init *ValName, // initializer. // if (!BitList.empty()) { - BitsInit *CurVal = dynamic_cast(RV->getValue()); + BitsInit *CurVal = dyn_cast(RV->getValue()); if (CurVal == 0) return Error(Loc, "Value '" + ValName->getAsUnquotedString() + "' is not a bits type"); @@ -114,7 +114,7 @@ bool TGParser::SetValue(Record *CurRec, SMLoc Loc, Init *ValName, } // We should have a BitsInit type now. - BitsInit *BInit = dynamic_cast(BI); + BitsInit *BInit = dyn_cast(BI); assert(BInit != 0); SmallVector NewBits(CurVal->getNumBits()); @@ -310,7 +310,7 @@ bool TGParser::ProcessForeachDefs(Record *CurRec, SMLoc Loc, IterSet &IterVals){ if (IterVals.size() != Loops.size()) { assert(IterVals.size() < Loops.size()); ForeachLoop &CurLoop = Loops[IterVals.size()]; - ListInit *List = dynamic_cast(CurLoop.ListValue); + ListInit *List = dyn_cast(CurLoop.ListValue); if (List == 0) { Error(Loc, "Loop list is not a list"); return true; @@ -335,7 +335,7 @@ bool TGParser::ProcessForeachDefs(Record *CurRec, SMLoc Loc, IterSet &IterVals){ // Set the iterator values now. for (unsigned i = 0, e = IterVals.size(); i != e; ++i) { VarInit *IterVar = IterVals[i].IterVar; - TypedInit *IVal = dynamic_cast(IterVals[i].IterValue); + TypedInit *IVal = dyn_cast(IterVals[i].IterValue); if (IVal == 0) { Error(Loc, "foreach iterator value is untyped"); return true; @@ -407,7 +407,7 @@ Init *TGParser::ParseObjectName(MultiClass *CurMultiClass) { RecTy *Type = 0; if (CurRec) { const TypedInit *CurRecName = - dynamic_cast(CurRec->getNameInit()); + dyn_cast(CurRec->getNameInit()); if (!CurRecName) { TokError("Record name is not typed!"); return 0; @@ -780,7 +780,7 @@ Init *TGParser::ParseIDValue(Record *CurRec, for (LoopVector::iterator i = Loops.begin(), iend = Loops.end(); i != iend; ++i) { - VarInit *IterVar = dynamic_cast(i->IterVar); + VarInit *IterVar = dyn_cast(i->IterVar); if (IterVar && IterVar->getName() == Name) return IterVar; } @@ -855,9 +855,9 @@ Init *TGParser::ParseOperation(Record *CurRec) { if (Code == UnOpInit::HEAD || Code == UnOpInit::TAIL || Code == UnOpInit::EMPTY) { - ListInit *LHSl = dynamic_cast(LHS); - StringInit *LHSs = dynamic_cast(LHS); - TypedInit *LHSt = dynamic_cast(LHS); + ListInit *LHSl = dyn_cast(LHS); + StringInit *LHSs = dyn_cast(LHS); + TypedInit *LHSt = dyn_cast(LHS); if (LHSl == 0 && LHSs == 0 && LHSt == 0) { TokError("expected list or string type argument in unary operator"); return 0; @@ -884,7 +884,7 @@ Init *TGParser::ParseOperation(Record *CurRec) { } if (LHSl) { Init *Item = LHSl->getElement(0); - TypedInit *Itemt = dynamic_cast(Item); + TypedInit *Itemt = dyn_cast(Item); if (Itemt == 0) { TokError("untyped list element in unary operator"); return 0; @@ -1046,24 +1046,24 @@ Init *TGParser::ParseOperation(Record *CurRec) { RecTy *MHSTy = 0; RecTy *RHSTy = 0; - if (TypedInit *MHSt = dynamic_cast(MHS)) + if (TypedInit *MHSt = dyn_cast(MHS)) MHSTy = MHSt->getType(); - if (BitsInit *MHSbits = dynamic_cast(MHS)) + if (BitsInit *MHSbits = dyn_cast(MHS)) MHSTy = BitsRecTy::get(MHSbits->getNumBits()); - if (dynamic_cast(MHS)) + if (dyn_cast(MHS)) MHSTy = BitRecTy::get(); - if (TypedInit *RHSt = dynamic_cast(RHS)) + if (TypedInit *RHSt = dyn_cast(RHS)) RHSTy = RHSt->getType(); - if (BitsInit *RHSbits = dynamic_cast(RHS)) + if (BitsInit *RHSbits = dyn_cast(RHS)) RHSTy = BitsRecTy::get(RHSbits->getNumBits()); - if (dynamic_cast(RHS)) + if (dyn_cast(RHS)) RHSTy = BitRecTy::get(); // For UnsetInit, it's typed from the other hand. - if (dynamic_cast(MHS)) + if (dyn_cast(MHS)) MHSTy = RHSTy; - if (dynamic_cast(RHS)) + if (dyn_cast(RHS)) RHSTy = MHSTy; if (!MHSTy || !RHSTy) { @@ -1082,7 +1082,7 @@ Init *TGParser::ParseOperation(Record *CurRec) { break; } case tgtok::XForEach: { - TypedInit *MHSt = dynamic_cast(MHS); + TypedInit *MHSt = dyn_cast(MHS); if (MHSt == 0) { TokError("could not get type for !foreach"); return 0; @@ -1091,7 +1091,7 @@ Init *TGParser::ParseOperation(Record *CurRec) { break; } case tgtok::XSubst: { - TypedInit *RHSt = dynamic_cast(RHS); + TypedInit *RHSt = dyn_cast(RHS); if (RHSt == 0) { TokError("could not get type for !subst"); return 0; @@ -1315,7 +1315,7 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType, for (std::vector::iterator i = Vals.begin(), ie = Vals.end(); i != ie; ++i) { - TypedInit *TArg = dynamic_cast(*i); + TypedInit *TArg = dyn_cast(*i); if (TArg == 0) { TokError("Untyped list element"); return 0; @@ -1498,7 +1498,7 @@ Init *TGParser::ParseValue(Record *CurRec, RecTy *ItemType, IDParseMode Mode) { // Create a !strconcat() operation, first casting each operand to // a string if necessary. - TypedInit *LHS = dynamic_cast(Result); + TypedInit *LHS = dyn_cast(Result); if (!LHS) { Error(PasteLoc, "LHS of paste is not typed!"); return 0; @@ -1525,7 +1525,7 @@ Init *TGParser::ParseValue(Record *CurRec, RecTy *ItemType, IDParseMode Mode) { default: Init *RHSResult = ParseValue(CurRec, ItemType, ParseNameMode); - RHS = dynamic_cast(RHSResult); + RHS = dyn_cast(RHSResult); if (!RHS) { Error(PasteLoc, "RHS of paste is not typed!"); return 0; @@ -1716,7 +1716,7 @@ VarInit *TGParser::ParseForeachDeclaration(ListInit *&ForeachListValue) { default: TokError("Unknown token when expecting a range list"); return 0; case tgtok::l_square: { // '[' ValueList ']' Init *List = ParseSimpleValue(0, 0, ParseForeachMode); - ForeachListValue = dynamic_cast(List); + ForeachListValue = dyn_cast(List); if (ForeachListValue == 0) { TokError("Expected a Value list"); return 0; @@ -2257,7 +2257,7 @@ InstantiateMulticlassDef(MultiClass &MC, Init *DefName = DefProto->getNameInit(); - StringInit *DefNameString = dynamic_cast(DefName); + StringInit *DefNameString = dyn_cast(DefName); if (DefNameString != 0) { // We have a fully expanded string so there are no operators to -- cgit v1.1 From 3f7b7f8ce0b050fc6a0100839d9c5a84198b2aed Mon Sep 17 00:00:00 2001 From: Sean Silva Date: Wed, 10 Oct 2012 20:24:47 +0000 Subject: tblgen: Use semantically correct RTTI functions. Also, some minor cleanup. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165647 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/TableGen/TGParser.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'lib/TableGen/TGParser.cpp') diff --git a/lib/TableGen/TGParser.cpp b/lib/TableGen/TGParser.cpp index 1b1c18b..b1f9f72 100644 --- a/lib/TableGen/TGParser.cpp +++ b/lib/TableGen/TGParser.cpp @@ -406,8 +406,7 @@ Init *TGParser::ParseObjectName(MultiClass *CurMultiClass) { RecTy *Type = 0; if (CurRec) { - const TypedInit *CurRecName = - dyn_cast(CurRec->getNameInit()); + const TypedInit *CurRecName = dyn_cast(CurRec->getNameInit()); if (!CurRecName) { TokError("Record name is not typed!"); return 0; @@ -1050,20 +1049,20 @@ Init *TGParser::ParseOperation(Record *CurRec) { MHSTy = MHSt->getType(); if (BitsInit *MHSbits = dyn_cast(MHS)) MHSTy = BitsRecTy::get(MHSbits->getNumBits()); - if (dyn_cast(MHS)) + if (isa(MHS)) MHSTy = BitRecTy::get(); if (TypedInit *RHSt = dyn_cast(RHS)) RHSTy = RHSt->getType(); if (BitsInit *RHSbits = dyn_cast(RHS)) RHSTy = BitsRecTy::get(RHSbits->getNumBits()); - if (dyn_cast(RHS)) + if (isa(RHS)) RHSTy = BitRecTy::get(); // For UnsetInit, it's typed from the other hand. - if (dyn_cast(MHS)) + if (isa(MHS)) MHSTy = RHSTy; - if (dyn_cast(RHS)) + if (isa(RHS)) RHSTy = MHSTy; if (!MHSTy || !RHSTy) { -- cgit v1.1 From d04a8d4b33ff316ca4cf961e06c9e312eff8e64f Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Mon, 3 Dec 2012 16:50:05 +0000 Subject: Use the new script to sort the includes of every file under lib. Sooooo many of these had incorrect or strange main module includes. I have manually inspected all of these, and fixed the main module include to be the nearest plausible thing I could find. If you own or care about any of these source files, I encourage you to take some time and check that these edits were sensible. I can't have broken anything (I strictly added headers, and reordered them, never removed), but they may not be the headers you'd really like to identify as containing the API being implemented. Many forward declarations and missing includes were added to a header files to allow them to parse cleanly when included first. The main module rule does in fact have its merits. =] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169131 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/TableGen/TGParser.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/TableGen/TGParser.cpp') diff --git a/lib/TableGen/TGParser.cpp b/lib/TableGen/TGParser.cpp index b1f9f72..17f0abc 100644 --- a/lib/TableGen/TGParser.cpp +++ b/lib/TableGen/TGParser.cpp @@ -12,12 +12,12 @@ //===----------------------------------------------------------------------===// #include "TGParser.h" -#include "llvm/TableGen/Record.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/TableGen/Record.h" #include #include -#include "llvm/ADT/SmallVector.h" -#include "llvm/Support/CommandLine.h" using namespace llvm; //===----------------------------------------------------------------------===// -- cgit v1.1 From 025c5de9bac36e98340944e29fa316e53002e354 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Thu, 27 Dec 2012 06:32:52 +0000 Subject: Update tablegen parser to allow defm names to start with #NAME. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171140 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/TableGen/TGParser.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/TableGen/TGParser.cpp') diff --git a/lib/TableGen/TGParser.cpp b/lib/TableGen/TGParser.cpp index 17f0abc..e5875ad 100644 --- a/lib/TableGen/TGParser.cpp +++ b/lib/TableGen/TGParser.cpp @@ -2406,7 +2406,11 @@ bool TGParser::ParseDefm(MultiClass *CurMultiClass) { Init *DefmPrefix = 0; - if (Lex.Lex() == tgtok::Id) { // eat the defm. + Lex.Lex(); // eat the defm. + + // Note that tgtok::paste is here to allow starting with #NAME. + if (Lex.getCode() == tgtok::Id || + Lex.getCode() == tgtok::paste) { DefmPrefix = ParseObjectName(CurMultiClass); } -- cgit v1.1 From 6a59f5ade8e13e323affe09d5a22df7d146ae259 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Mon, 7 Jan 2013 05:09:33 +0000 Subject: Revert r171140. We don't actually need to support #NAME. Because NAME by itself is interpreted just fine. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171695 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/TableGen/TGParser.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'lib/TableGen/TGParser.cpp') diff --git a/lib/TableGen/TGParser.cpp b/lib/TableGen/TGParser.cpp index e5875ad..17f0abc 100644 --- a/lib/TableGen/TGParser.cpp +++ b/lib/TableGen/TGParser.cpp @@ -2406,11 +2406,7 @@ bool TGParser::ParseDefm(MultiClass *CurMultiClass) { Init *DefmPrefix = 0; - Lex.Lex(); // eat the defm. - - // Note that tgtok::paste is here to allow starting with #NAME. - if (Lex.getCode() == tgtok::Id || - Lex.getCode() == tgtok::paste) { + if (Lex.Lex() == tgtok::Id) { // eat the defm. DefmPrefix = ParseObjectName(CurMultiClass); } -- cgit v1.1