From 13745262a8db98d6c4513ff9934db4be75a8b26c Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Wed, 3 Oct 2012 23:06:32 +0000 Subject: Added instregex support to TableGen subtarget emitter. This allows the processor-specific machine model to override selected base opcodes without any fanciness. e.g. InstRW<[CoreXWriteVANDP], (instregex "VANDP")>. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165180 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/SetTheory.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'utils/TableGen/SetTheory.cpp') diff --git a/utils/TableGen/SetTheory.cpp b/utils/TableGen/SetTheory.cpp index 46e6db1..bdca9a6 100644 --- a/utils/TableGen/SetTheory.cpp +++ b/utils/TableGen/SetTheory.cpp @@ -294,7 +294,10 @@ const RecVec *SetTheory::expand(Record *Set) { // This is the first time we see Set. Find a suitable expander. try { const std::vector &SC = Set->getSuperClasses(); - for (unsigned i = 0, e = SC.size(); i != e; ++i) + for (unsigned i = 0, e = SC.size(); i != e; ++i) { + // Skip unnamed superclasses. + if (!dynamic_cast(SC[i]->getNameInit())) + continue; if (Expander *Exp = Expanders.lookup(SC[i]->getName())) { // This breaks recursive definitions. RecVec &EltVec = Expansions[Set]; @@ -303,6 +306,7 @@ const RecVec *SetTheory::expand(Record *Set) { EltVec.assign(Elts.begin(), Elts.end()); return &EltVec; } + } } catch (const std::string &Error) { throw TGError(Set->getLoc(), Error); } -- 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 --- utils/TableGen/SetTheory.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'utils/TableGen/SetTheory.cpp') diff --git a/utils/TableGen/SetTheory.cpp b/utils/TableGen/SetTheory.cpp index bdca9a6..dcc8871 100644 --- a/utils/TableGen/SetTheory.cpp +++ b/utils/TableGen/SetTheory.cpp @@ -72,7 +72,7 @@ struct SetIntBinOp : public SetTheory::Operator { throw "Operator requires (Op Set, Int) arguments: " + Expr->getAsString(); RecSet Set; ST.evaluate(Expr->arg_begin()[0], Set); - IntInit *II = dynamic_cast(Expr->arg_begin()[1]); + IntInit *II = dyn_cast(Expr->arg_begin()[1]); if (!II) throw "Second argument must be an integer: " + Expr->getAsString(); apply2(ST, Expr, Set, II->getValue(), Elts); @@ -165,27 +165,27 @@ struct SequenceOp : public SetTheory::Operator { throw "Bad args to (sequence \"Format\", From, To): " + Expr->getAsString(); else if (Expr->arg_size() == 4) { - if (IntInit *II = dynamic_cast(Expr->arg_begin()[3])) { + if (IntInit *II = dyn_cast(Expr->arg_begin()[3])) { Step = II->getValue(); } else throw "Stride must be an integer: " + Expr->getAsString(); } std::string Format; - if (StringInit *SI = dynamic_cast(Expr->arg_begin()[0])) + if (StringInit *SI = dyn_cast(Expr->arg_begin()[0])) Format = SI->getValue(); else throw "Format must be a string: " + Expr->getAsString(); int64_t From, To; - if (IntInit *II = dynamic_cast(Expr->arg_begin()[1])) + if (IntInit *II = dyn_cast(Expr->arg_begin()[1])) From = II->getValue(); else throw "From must be an integer: " + Expr->getAsString(); if (From < 0 || From >= (1 << 30)) throw "From out of range"; - if (IntInit *II = dynamic_cast(Expr->arg_begin()[2])) + if (IntInit *II = dyn_cast(Expr->arg_begin()[2])) To = II->getValue(); else throw "From must be an integer: " + Expr->getAsString(); @@ -193,7 +193,7 @@ struct SequenceOp : public SetTheory::Operator { throw "To out of range"; RecordKeeper &Records = - dynamic_cast(*Expr->getOperator()).getDef()->getRecords(); + dyn_cast(Expr->getOperator())->getDef()->getRecords(); Step *= From <= To ? 1 : -1; while (true) { @@ -261,7 +261,7 @@ void SetTheory::addFieldExpander(StringRef ClassName, StringRef FieldName) { void SetTheory::evaluate(Init *Expr, RecSet &Elts) { // A def in a list can be a just an element, or it may expand. - if (DefInit *Def = dynamic_cast(Expr)) { + if (DefInit *Def = dyn_cast(Expr)) { if (const RecVec *Result = expand(Def->getDef())) return Elts.insert(Result->begin(), Result->end()); Elts.insert(Def->getDef()); @@ -269,14 +269,14 @@ void SetTheory::evaluate(Init *Expr, RecSet &Elts) { } // Lists simply expand. - if (ListInit *LI = dynamic_cast(Expr)) + if (ListInit *LI = dyn_cast(Expr)) return evaluate(LI->begin(), LI->end(), Elts); // Anything else must be a DAG. - DagInit *DagExpr = dynamic_cast(Expr); + DagInit *DagExpr = dyn_cast(Expr); if (!DagExpr) throw "Invalid set element: " + Expr->getAsString(); - DefInit *OpInit = dynamic_cast(DagExpr->getOperator()); + DefInit *OpInit = dyn_cast(DagExpr->getOperator()); if (!OpInit) throw "Bad set expression: " + Expr->getAsString(); Operator *Op = Operators.lookup(OpInit->getDef()->getName()); @@ -296,7 +296,7 @@ const RecVec *SetTheory::expand(Record *Set) { const std::vector &SC = Set->getSuperClasses(); for (unsigned i = 0, e = SC.size(); i != e; ++i) { // Skip unnamed superclasses. - if (!dynamic_cast(SC[i]->getNameInit())) + if (!dyn_cast(SC[i]->getNameInit())) continue; if (Expander *Exp = Expanders.lookup(SC[i]->getName())) { // This breaks recursive definitions. -- 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 --- utils/TableGen/SetTheory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils/TableGen/SetTheory.cpp') diff --git a/utils/TableGen/SetTheory.cpp b/utils/TableGen/SetTheory.cpp index dcc8871..5b760e7 100644 --- a/utils/TableGen/SetTheory.cpp +++ b/utils/TableGen/SetTheory.cpp @@ -193,7 +193,7 @@ struct SequenceOp : public SetTheory::Operator { throw "To out of range"; RecordKeeper &Records = - dyn_cast(Expr->getOperator())->getDef()->getRecords(); + cast(Expr->getOperator())->getDef()->getRecords(); Step *= From <= To ? 1 : -1; while (true) { -- cgit v1.1 From 2c6d71388fb1b68ce6fdbb88642a95a24b27b2a7 Mon Sep 17 00:00:00 2001 From: Joerg Sonnenberger Date: Wed, 24 Oct 2012 22:03:59 +0000 Subject: Don't use stack unwinding to provide the location information for SetTheory, but pass down the location explicitly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166629 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/SetTheory.cpp | 121 ++++++++++++++++++++++--------------------- 1 file changed, 62 insertions(+), 59 deletions(-) (limited to 'utils/TableGen/SetTheory.cpp') diff --git a/utils/TableGen/SetTheory.cpp b/utils/TableGen/SetTheory.cpp index 5b760e7..33a8f0e 100644 --- a/utils/TableGen/SetTheory.cpp +++ b/utils/TableGen/SetTheory.cpp @@ -27,20 +27,20 @@ typedef SetTheory::RecVec RecVec; // (add a, b, ...) Evaluate and union all arguments. struct AddOp : public SetTheory::Operator { - void apply(SetTheory &ST, DagInit *Expr, RecSet &Elts) { - ST.evaluate(Expr->arg_begin(), Expr->arg_end(), Elts); + void apply(SetTheory &ST, DagInit *Expr, RecSet &Elts, ArrayRef Loc) { + ST.evaluate(Expr->arg_begin(), Expr->arg_end(), Elts, Loc); } }; // (sub Add, Sub, ...) Set difference. struct SubOp : public SetTheory::Operator { - void apply(SetTheory &ST, DagInit *Expr, RecSet &Elts) { + void apply(SetTheory &ST, DagInit *Expr, RecSet &Elts, ArrayRef Loc) { if (Expr->arg_size() < 2) - throw "Set difference needs at least two arguments: " + - Expr->getAsString(); + throw TGError(Loc, "Set difference needs at least two arguments: " + + Expr->getAsString()); RecSet Add, Sub; - ST.evaluate(*Expr->arg_begin(), Add); - ST.evaluate(Expr->arg_begin() + 1, Expr->arg_end(), Sub); + ST.evaluate(*Expr->arg_begin(), Add, Loc); + ST.evaluate(Expr->arg_begin() + 1, Expr->arg_end(), Sub, Loc); for (RecSet::iterator I = Add.begin(), E = Add.end(); I != E; ++I) if (!Sub.count(*I)) Elts.insert(*I); @@ -49,12 +49,13 @@ struct SubOp : public SetTheory::Operator { // (and S1, S2) Set intersection. struct AndOp : public SetTheory::Operator { - void apply(SetTheory &ST, DagInit *Expr, RecSet &Elts) { + void apply(SetTheory &ST, DagInit *Expr, RecSet &Elts, ArrayRef Loc) { if (Expr->arg_size() != 2) - throw "Set intersection requires two arguments: " + Expr->getAsString(); + throw TGError(Loc, "Set intersection requires two arguments: " + + Expr->getAsString()); RecSet S1, S2; - ST.evaluate(Expr->arg_begin()[0], S1); - ST.evaluate(Expr->arg_begin()[1], S2); + ST.evaluate(Expr->arg_begin()[0], S1, Loc); + ST.evaluate(Expr->arg_begin()[1], S2, Loc); for (RecSet::iterator I = S1.begin(), E = S1.end(); I != E; ++I) if (S2.count(*I)) Elts.insert(*I); @@ -65,17 +66,19 @@ struct AndOp : public SetTheory::Operator { struct SetIntBinOp : public SetTheory::Operator { virtual void apply2(SetTheory &ST, DagInit *Expr, RecSet &Set, int64_t N, - RecSet &Elts) =0; + RecSet &Elts, ArrayRef Loc) =0; - void apply(SetTheory &ST, DagInit *Expr, RecSet &Elts) { + void apply(SetTheory &ST, DagInit *Expr, RecSet &Elts, ArrayRef Loc) { if (Expr->arg_size() != 2) - throw "Operator requires (Op Set, Int) arguments: " + Expr->getAsString(); + throw TGError(Loc, "Operator requires (Op Set, Int) arguments: " + + Expr->getAsString()); RecSet Set; - ST.evaluate(Expr->arg_begin()[0], Set); + ST.evaluate(Expr->arg_begin()[0], Set, Loc); IntInit *II = dyn_cast(Expr->arg_begin()[1]); if (!II) - throw "Second argument must be an integer: " + Expr->getAsString(); - apply2(ST, Expr, Set, II->getValue(), Elts); + throw TGError(Loc, "Second argument must be an integer: " + + Expr->getAsString()); + apply2(ST, Expr, Set, II->getValue(), Elts, Loc); } }; @@ -83,9 +86,10 @@ struct SetIntBinOp : public SetTheory::Operator { struct ShlOp : public SetIntBinOp { void apply2(SetTheory &ST, DagInit *Expr, RecSet &Set, int64_t N, - RecSet &Elts) { + RecSet &Elts, ArrayRef Loc) { if (N < 0) - throw "Positive shift required: " + Expr->getAsString(); + throw TGError(Loc, "Positive shift required: " + + Expr->getAsString()); if (unsigned(N) < Set.size()) Elts.insert(Set.begin() + N, Set.end()); } @@ -95,9 +99,10 @@ struct ShlOp : public SetIntBinOp { struct TruncOp : public SetIntBinOp { void apply2(SetTheory &ST, DagInit *Expr, RecSet &Set, int64_t N, - RecSet &Elts) { + RecSet &Elts, ArrayRef Loc) { if (N < 0) - throw "Positive length required: " + Expr->getAsString(); + throw TGError(Loc, "Positive length required: " + + Expr->getAsString()); if (unsigned(N) > Set.size()) N = Set.size(); Elts.insert(Set.begin(), Set.begin() + N); @@ -112,7 +117,7 @@ struct RotOp : public SetIntBinOp { void apply2(SetTheory &ST, DagInit *Expr, RecSet &Set, int64_t N, - RecSet &Elts) { + RecSet &Elts, ArrayRef Loc) { if (Reverse) N = -N; // N > 0 -> rotate left, N < 0 -> rotate right. @@ -131,9 +136,10 @@ struct RotOp : public SetIntBinOp { struct DecimateOp : public SetIntBinOp { void apply2(SetTheory &ST, DagInit *Expr, RecSet &Set, int64_t N, - RecSet &Elts) { + RecSet &Elts, ArrayRef Loc) { if (N <= 0) - throw "Positive stride required: " + Expr->getAsString(); + throw TGError(Loc, "Positive stride required: " + + Expr->getAsString()); for (unsigned I = 0; I < Set.size(); I += N) Elts.insert(Set[I]); } @@ -141,12 +147,12 @@ struct DecimateOp : public SetIntBinOp { // (interleave S1, S2, ...) Interleave elements of the arguments. struct InterleaveOp : public SetTheory::Operator { - void apply(SetTheory &ST, DagInit *Expr, RecSet &Elts) { + void apply(SetTheory &ST, DagInit *Expr, RecSet &Elts, ArrayRef Loc) { // Evaluate the arguments individually. SmallVector Args(Expr->getNumArgs()); unsigned MaxSize = 0; for (unsigned i = 0, e = Expr->getNumArgs(); i != e; ++i) { - ST.evaluate(Expr->getArg(i), Args[i]); + ST.evaluate(Expr->getArg(i), Args[i], Loc); MaxSize = std::max(MaxSize, unsigned(Args[i].size())); } // Interleave arguments into Elts. @@ -159,38 +165,38 @@ struct InterleaveOp : public SetTheory::Operator { // (sequence "Format", From, To) Generate a sequence of records by name. struct SequenceOp : public SetTheory::Operator { - void apply(SetTheory &ST, DagInit *Expr, RecSet &Elts) { + void apply(SetTheory &ST, DagInit *Expr, RecSet &Elts, ArrayRef Loc) { int Step = 1; if (Expr->arg_size() > 4) - throw "Bad args to (sequence \"Format\", From, To): " + - Expr->getAsString(); + throw TGError(Loc, "Bad args to (sequence \"Format\", From, To): " + + Expr->getAsString()); else if (Expr->arg_size() == 4) { if (IntInit *II = dyn_cast(Expr->arg_begin()[3])) { Step = II->getValue(); } else - throw "Stride must be an integer: " + Expr->getAsString(); + throw TGError(Loc, "Stride must be an integer: " + Expr->getAsString()); } std::string Format; if (StringInit *SI = dyn_cast(Expr->arg_begin()[0])) Format = SI->getValue(); else - throw "Format must be a string: " + Expr->getAsString(); + throw TGError(Loc, "Format must be a string: " + Expr->getAsString()); int64_t From, To; if (IntInit *II = dyn_cast(Expr->arg_begin()[1])) From = II->getValue(); else - throw "From must be an integer: " + Expr->getAsString(); + throw TGError(Loc, "From must be an integer: " + Expr->getAsString()); if (From < 0 || From >= (1 << 30)) - throw "From out of range"; + throw TGError(Loc, "From out of range"); if (IntInit *II = dyn_cast(Expr->arg_begin()[2])) To = II->getValue(); else - throw "From must be an integer: " + Expr->getAsString(); + throw TGError(Loc, "From must be an integer: " + Expr->getAsString()); if (To < 0 || To >= (1 << 30)) - throw "To out of range"; + throw TGError(Loc, "To out of range"); RecordKeeper &Records = cast(Expr->getOperator())->getDef()->getRecords(); @@ -206,7 +212,8 @@ struct SequenceOp : public SetTheory::Operator { OS << format(Format.c_str(), unsigned(From)); Record *Rec = Records.getDef(OS.str()); if (!Rec) - throw "No def named '" + Name + "': " + Expr->getAsString(); + throw TGError(Loc, "No def named '" + Name + "': " + + Expr->getAsString()); // Try to reevaluate Rec in case it is a set. if (const RecVec *Result = ST.expand(Rec)) Elts.insert(Result->begin(), Result->end()); @@ -225,7 +232,7 @@ struct FieldExpander : public SetTheory::Expander { FieldExpander(StringRef fn) : FieldName(fn) {} void expand(SetTheory &ST, Record *Def, RecSet &Elts) { - ST.evaluate(Def->getValueInit(FieldName), Elts); + ST.evaluate(Def->getValueInit(FieldName), Elts, Def->getLoc()); } }; } // end anonymous namespace @@ -259,7 +266,7 @@ void SetTheory::addFieldExpander(StringRef ClassName, StringRef FieldName) { addExpander(ClassName, new FieldExpander(FieldName)); } -void SetTheory::evaluate(Init *Expr, RecSet &Elts) { +void SetTheory::evaluate(Init *Expr, RecSet &Elts, ArrayRef Loc) { // A def in a list can be a just an element, or it may expand. if (DefInit *Def = dyn_cast(Expr)) { if (const RecVec *Result = expand(Def->getDef())) @@ -270,19 +277,19 @@ void SetTheory::evaluate(Init *Expr, RecSet &Elts) { // Lists simply expand. if (ListInit *LI = dyn_cast(Expr)) - return evaluate(LI->begin(), LI->end(), Elts); + return evaluate(LI->begin(), LI->end(), Elts, Loc); // Anything else must be a DAG. DagInit *DagExpr = dyn_cast(Expr); if (!DagExpr) - throw "Invalid set element: " + Expr->getAsString(); + throw TGError(Loc, "Invalid set element: " + Expr->getAsString()); DefInit *OpInit = dyn_cast(DagExpr->getOperator()); if (!OpInit) - throw "Bad set expression: " + Expr->getAsString(); + throw TGError(Loc, "Bad set expression: " + Expr->getAsString()); Operator *Op = Operators.lookup(OpInit->getDef()->getName()); if (!Op) - throw "Unknown set operator: " + Expr->getAsString(); - Op->apply(*this, DagExpr, Elts); + throw TGError(Loc, "Unknown set operator: " + Expr->getAsString()); + Op->apply(*this, DagExpr, Elts, Loc); } const RecVec *SetTheory::expand(Record *Set) { @@ -292,23 +299,19 @@ const RecVec *SetTheory::expand(Record *Set) { return &I->second; // This is the first time we see Set. Find a suitable expander. - try { - const std::vector &SC = Set->getSuperClasses(); - for (unsigned i = 0, e = SC.size(); i != e; ++i) { - // Skip unnamed superclasses. - if (!dyn_cast(SC[i]->getNameInit())) - continue; - if (Expander *Exp = Expanders.lookup(SC[i]->getName())) { - // This breaks recursive definitions. - RecVec &EltVec = Expansions[Set]; - RecSet Elts; - Exp->expand(*this, Set, Elts); - EltVec.assign(Elts.begin(), Elts.end()); - return &EltVec; - } + const std::vector &SC = Set->getSuperClasses(); + for (unsigned i = 0, e = SC.size(); i != e; ++i) { + // Skip unnamed superclasses. + if (!dyn_cast(SC[i]->getNameInit())) + continue; + if (Expander *Exp = Expanders.lookup(SC[i]->getName())) { + // This breaks recursive definitions. + RecVec &EltVec = Expansions[Set]; + RecSet Elts; + Exp->expand(*this, Set, Elts); + EltVec.assign(Elts.begin(), Elts.end()); + return &EltVec; } - } catch (const std::string &Error) { - throw TGError(Set->getLoc(), Error); } // Set is not expandable. -- cgit v1.1 From 61131ab15fd593a2e295d79fe2714e7bc21f2ec8 Mon Sep 17 00:00:00 2001 From: Joerg Sonnenberger Date: Thu, 25 Oct 2012 20:33:17 +0000 Subject: Remove exception handling usage from tblgen. Most places can use PrintFatalError as the unwinding mechanism was not used for anything other than printing the error. The single exception was CodeGenDAGPatterns.cpp, where intermediate errors during type resolution were ignored to simplify incremental platform development. This use is replaced by an error flag in TreePattern and bailout earlier in various places if it is set. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166712 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/SetTheory.cpp | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'utils/TableGen/SetTheory.cpp') diff --git a/utils/TableGen/SetTheory.cpp b/utils/TableGen/SetTheory.cpp index 33a8f0e..0dd9853 100644 --- a/utils/TableGen/SetTheory.cpp +++ b/utils/TableGen/SetTheory.cpp @@ -36,7 +36,7 @@ struct AddOp : public SetTheory::Operator { struct SubOp : public SetTheory::Operator { void apply(SetTheory &ST, DagInit *Expr, RecSet &Elts, ArrayRef Loc) { if (Expr->arg_size() < 2) - throw TGError(Loc, "Set difference needs at least two arguments: " + + PrintFatalError(Loc, "Set difference needs at least two arguments: " + Expr->getAsString()); RecSet Add, Sub; ST.evaluate(*Expr->arg_begin(), Add, Loc); @@ -51,7 +51,7 @@ struct SubOp : public SetTheory::Operator { struct AndOp : public SetTheory::Operator { void apply(SetTheory &ST, DagInit *Expr, RecSet &Elts, ArrayRef Loc) { if (Expr->arg_size() != 2) - throw TGError(Loc, "Set intersection requires two arguments: " + + PrintFatalError(Loc, "Set intersection requires two arguments: " + Expr->getAsString()); RecSet S1, S2; ST.evaluate(Expr->arg_begin()[0], S1, Loc); @@ -70,13 +70,13 @@ struct SetIntBinOp : public SetTheory::Operator { void apply(SetTheory &ST, DagInit *Expr, RecSet &Elts, ArrayRef Loc) { if (Expr->arg_size() != 2) - throw TGError(Loc, "Operator requires (Op Set, Int) arguments: " + + PrintFatalError(Loc, "Operator requires (Op Set, Int) arguments: " + Expr->getAsString()); RecSet Set; ST.evaluate(Expr->arg_begin()[0], Set, Loc); IntInit *II = dyn_cast(Expr->arg_begin()[1]); if (!II) - throw TGError(Loc, "Second argument must be an integer: " + + PrintFatalError(Loc, "Second argument must be an integer: " + Expr->getAsString()); apply2(ST, Expr, Set, II->getValue(), Elts, Loc); } @@ -88,7 +88,7 @@ struct ShlOp : public SetIntBinOp { RecSet &Set, int64_t N, RecSet &Elts, ArrayRef Loc) { if (N < 0) - throw TGError(Loc, "Positive shift required: " + + PrintFatalError(Loc, "Positive shift required: " + Expr->getAsString()); if (unsigned(N) < Set.size()) Elts.insert(Set.begin() + N, Set.end()); @@ -101,7 +101,7 @@ struct TruncOp : public SetIntBinOp { RecSet &Set, int64_t N, RecSet &Elts, ArrayRef Loc) { if (N < 0) - throw TGError(Loc, "Positive length required: " + + PrintFatalError(Loc, "Positive length required: " + Expr->getAsString()); if (unsigned(N) > Set.size()) N = Set.size(); @@ -138,7 +138,7 @@ struct DecimateOp : public SetIntBinOp { RecSet &Set, int64_t N, RecSet &Elts, ArrayRef Loc) { if (N <= 0) - throw TGError(Loc, "Positive stride required: " + + PrintFatalError(Loc, "Positive stride required: " + Expr->getAsString()); for (unsigned I = 0; I < Set.size(); I += N) Elts.insert(Set[I]); @@ -168,35 +168,36 @@ struct SequenceOp : public SetTheory::Operator { void apply(SetTheory &ST, DagInit *Expr, RecSet &Elts, ArrayRef Loc) { int Step = 1; if (Expr->arg_size() > 4) - throw TGError(Loc, "Bad args to (sequence \"Format\", From, To): " + + PrintFatalError(Loc, "Bad args to (sequence \"Format\", From, To): " + Expr->getAsString()); else if (Expr->arg_size() == 4) { if (IntInit *II = dyn_cast(Expr->arg_begin()[3])) { Step = II->getValue(); } else - throw TGError(Loc, "Stride must be an integer: " + Expr->getAsString()); + PrintFatalError(Loc, "Stride must be an integer: " + + Expr->getAsString()); } std::string Format; if (StringInit *SI = dyn_cast(Expr->arg_begin()[0])) Format = SI->getValue(); else - throw TGError(Loc, "Format must be a string: " + Expr->getAsString()); + PrintFatalError(Loc, "Format must be a string: " + Expr->getAsString()); int64_t From, To; if (IntInit *II = dyn_cast(Expr->arg_begin()[1])) From = II->getValue(); else - throw TGError(Loc, "From must be an integer: " + Expr->getAsString()); + PrintFatalError(Loc, "From must be an integer: " + Expr->getAsString()); if (From < 0 || From >= (1 << 30)) - throw TGError(Loc, "From out of range"); + PrintFatalError(Loc, "From out of range"); if (IntInit *II = dyn_cast(Expr->arg_begin()[2])) To = II->getValue(); else - throw TGError(Loc, "From must be an integer: " + Expr->getAsString()); + PrintFatalError(Loc, "From must be an integer: " + Expr->getAsString()); if (To < 0 || To >= (1 << 30)) - throw TGError(Loc, "To out of range"); + PrintFatalError(Loc, "To out of range"); RecordKeeper &Records = cast(Expr->getOperator())->getDef()->getRecords(); @@ -212,7 +213,7 @@ struct SequenceOp : public SetTheory::Operator { OS << format(Format.c_str(), unsigned(From)); Record *Rec = Records.getDef(OS.str()); if (!Rec) - throw TGError(Loc, "No def named '" + Name + "': " + + PrintFatalError(Loc, "No def named '" + Name + "': " + Expr->getAsString()); // Try to reevaluate Rec in case it is a set. if (const RecVec *Result = ST.expand(Rec)) @@ -282,13 +283,13 @@ void SetTheory::evaluate(Init *Expr, RecSet &Elts, ArrayRef Loc) { // Anything else must be a DAG. DagInit *DagExpr = dyn_cast(Expr); if (!DagExpr) - throw TGError(Loc, "Invalid set element: " + Expr->getAsString()); + PrintFatalError(Loc, "Invalid set element: " + Expr->getAsString()); DefInit *OpInit = dyn_cast(DagExpr->getOperator()); if (!OpInit) - throw TGError(Loc, "Bad set expression: " + Expr->getAsString()); + PrintFatalError(Loc, "Bad set expression: " + Expr->getAsString()); Operator *Op = Operators.lookup(OpInit->getDef()->getName()); if (!Op) - throw TGError(Loc, "Unknown set operator: " + Expr->getAsString()); + PrintFatalError(Loc, "Unknown set operator: " + Expr->getAsString()); Op->apply(*this, DagExpr, Elts, Loc); } -- cgit v1.1 From 4ffd89fa4d2788611187d1a534d2ed46adf1702c Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Tue, 4 Dec 2012 10:37:14 +0000 Subject: Sort the #include lines for utils/... I've tried to find main moudle headers where possible, but the TableGen stuff may warrant someone else looking at it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169251 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/SetTheory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils/TableGen/SetTheory.cpp') diff --git a/utils/TableGen/SetTheory.cpp b/utils/TableGen/SetTheory.cpp index 0dd9853..3e5c38c 100644 --- a/utils/TableGen/SetTheory.cpp +++ b/utils/TableGen/SetTheory.cpp @@ -13,9 +13,9 @@ //===----------------------------------------------------------------------===// #include "SetTheory.h" +#include "llvm/Support/Format.h" #include "llvm/TableGen/Error.h" #include "llvm/TableGen/Record.h" -#include "llvm/Support/Format.h" using namespace llvm; -- cgit v1.1