Now fix errors in NDEBUG build.

Hope this won't break any hardware next.

llvm-svn: 253799
This commit is contained in:
Krzysztof Parzyszek 2015-11-21 22:46:52 +00:00
parent 8dd552db29
commit dd1352499c
1 changed files with 49 additions and 33 deletions

View File

@ -31,6 +31,7 @@
#include <queue> #include <queue>
using namespace llvm; using namespace llvm;
#ifndef NDEBUG
// To enable debugging, run llvm-tblgen with: "-debug-only dfa-emitter". // To enable debugging, run llvm-tblgen with: "-debug-only dfa-emitter".
// //
// dbgsInsnClass - When debugging, print instruction class stages. // dbgsInsnClass - When debugging, print instruction class stages.
@ -44,6 +45,7 @@ void dbgsStateInfo(const std::set<unsigned> &stateInfo);
// dbgsIndent - When debugging, indent by the specified amount. // dbgsIndent - When debugging, indent by the specified amount.
// //
void dbgsIndent(unsigned indent); void dbgsIndent(unsigned indent);
#endif
// //
// class DFAPacketizerEmitter: class that generates and prints out the DFA // class DFAPacketizerEmitter: class that generates and prints out the DFA
@ -326,11 +328,13 @@ void State::AddInsnClassStages(std::vector<unsigned> &InsnClass,
assert((chkstage < numstages) && "AddInsnClassStages: stage out of range"); assert((chkstage < numstages) && "AddInsnClassStages: stage out of range");
unsigned thisStage = InsnClass[chkstage]; unsigned thisStage = InsnClass[chkstage];
dbgsIndent((1 + numstages - chkstage) << 1); DEBUG({
DEBUG(dbgs() << "AddInsnClassStages " << chkstage dbgsIndent((1 + numstages - chkstage) << 1);
<< " (0x" << utohexstr(thisStage) << ") from "); dbgs() << "AddInsnClassStages " << chkstage << " (0x"
dbgsInsnClass(InsnClass); << utohexstr(thisStage) << ") from ";
DEBUG(dbgs() << "\n"); dbgsInsnClass(InsnClass);
dbgs() << "\n";
});
// //
// Iterate over all possible resources used in thisStage. // Iterate over all possible resources used in thisStage.
@ -351,13 +355,14 @@ void State::AddInsnClassStages(std::vector<unsigned> &InsnClass,
// resource state if that resource was used. // resource state if that resource was used.
// //
unsigned ResultingResourceState = prevState | resourceMask | combo; unsigned ResultingResourceState = prevState | resourceMask | combo;
dbgsIndent((2 + numstages - chkstage) << 1); DEBUG({
DEBUG(dbgs() << "0x" << utohexstr(prevState) dbgsIndent((2 + numstages - chkstage) << 1);
<< " | 0x" << utohexstr(resourceMask)); dbgs() << "0x" << utohexstr(prevState)
if (combo) { << " | 0x" << utohexstr(resourceMask);
DEBUG(dbgs() << " | 0x" << utohexstr(combo)); if (combo)
} dbgs() << " | 0x" << utohexstr(combo);
DEBUG(dbgs() << " = 0x" << utohexstr(ResultingResourceState) << " "); dbgs() << " = 0x" << utohexstr(ResultingResourceState) << " ";
});
// //
// If this is the final stage for this class // If this is the final stage for this class
@ -741,9 +746,11 @@ int DFAPacketizerEmitter::collectOneInsnClass(const std::string &ProcName,
if (UnitBits.size() > 0) if (UnitBits.size() > 0)
allInsnClasses.push_back(UnitBits); allInsnClasses.push_back(UnitBits);
DEBUG(dbgs() << " "); DEBUG({
dbgsInsnClass(UnitBits); dbgs() << " ";
DEBUG(dbgs() << "\n"); dbgsInsnClass(UnitBits);
dbgs() << "\n";
});
return NStages; return NStages;
} }
@ -867,15 +874,19 @@ void DFAPacketizerEmitter::run(raw_ostream &OS) {
// //
while (!WorkList.empty()) { while (!WorkList.empty()) {
const State *current = WorkList.pop_back_val(); const State *current = WorkList.pop_back_val();
DEBUG(dbgs() << "---------------------\n"); DEBUG({
DEBUG(dbgs() << "Processing state: " << current->stateNum << " - "); dbgs() << "---------------------\n";
dbgsStateInfo(current->stateInfo); dbgs() << "Processing state: " << current->stateNum << " - ";
DEBUG(dbgs() << "\n"); dbgsStateInfo(current->stateInfo);
dbgs() << "\n";
});
for (unsigned i = 0; i < allInsnClasses.size(); i++) { for (unsigned i = 0; i < allInsnClasses.size(); i++) {
std::vector<unsigned> InsnClass = allInsnClasses[i]; std::vector<unsigned> InsnClass = allInsnClasses[i];
DEBUG(dbgs() << i << " "); DEBUG({
dbgsInsnClass(InsnClass); dbgs() << i << " ";
DEBUG(dbgs() << "\n"); dbgsInsnClass(InsnClass);
dbgs() << "\n";
});
std::set<unsigned> NewStateResources; std::set<unsigned> NewStateResources;
// //
@ -891,9 +902,11 @@ void DFAPacketizerEmitter::run(raw_ostream &OS) {
continue; continue;
} }
DEBUG(dbgs() << "\t"); DEBUG({
dbgsStateInfo(NewStateResources); dbgs() << "\t";
DEBUG(dbgs() << "\n"); dbgsStateInfo(NewStateResources);
dbgs() << "\n";
});
// //
// If we have seen this state before, then do not create a new state. // If we have seen this state before, then do not create a new state.
@ -901,19 +914,22 @@ void DFAPacketizerEmitter::run(raw_ostream &OS) {
auto VI = Visited.find(NewStateResources); auto VI = Visited.find(NewStateResources);
if (VI != Visited.end()) { if (VI != Visited.end()) {
NewState = VI->second; NewState = VI->second;
DEBUG(dbgs() << "\tFound existing state: " DEBUG({
<< NewState->stateNum << " - "); dbgs() << "\tFound existing state: " << NewState->stateNum
dbgsStateInfo(NewState->stateInfo); << " - ";
DEBUG(dbgs() << "\n"); dbgsStateInfo(NewState->stateInfo);
dbgs() << "\n";
});
} else { } else {
NewState = &D.newState(); NewState = &D.newState();
NewState->stateInfo = NewStateResources; NewState->stateInfo = NewStateResources;
Visited[NewStateResources] = NewState; Visited[NewStateResources] = NewState;
WorkList.push_back(NewState); WorkList.push_back(NewState);
DEBUG(dbgs() << "\tAccepted new state: " DEBUG({
<< NewState->stateNum << " - "); dbgs() << "\tAccepted new state: " << NewState->stateNum << " - ";
dbgsStateInfo(NewState->stateInfo); dbgsStateInfo(NewState->stateInfo);
DEBUG(dbgs() << "\n"); dbgs() << "\n";
});
} }
current->addTransition(InsnClass, NewState); current->addTransition(InsnClass, NewState);