llvm.org GIT mirror llvm / 60d8139
fix a fixme by improving const correctness. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45633 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 11 years ago
3 changed file(s) with 26 addition(s) and 26 deletion(s). Raw diff Collapse all Expand all
506506 pf_iterator pf_end() const { return PatternFragments.end(); }
507507
508508 // Patterns to match information.
509 // FIXME: make a const_iterator.
510 typedef std::vector::iterator ptm_iterator;
511 ptm_iterator ptm_begin() { return PatternsToMatch.begin(); }
512 ptm_iterator ptm_end() { return PatternsToMatch.end(); }
509 typedef std::vector::const_iterator ptm_iterator;
510 ptm_iterator ptm_begin() const { return PatternsToMatch.begin(); }
511 ptm_iterator ptm_end() const { return PatternsToMatch.end(); }
513512
514513
515514
138138 PatternSortingPredicate(CodegenDAGPatterns &cgp) : CGP(cgp) {}
139139 CodegenDAGPatterns &CGP;
140140
141 bool operator()(PatternToMatch *LHS,
142 PatternToMatch *RHS) {
141 bool operator()(const PatternToMatch *LHS,
142 const PatternToMatch *RHS) {
143143 unsigned LHSSize = getPatternSize(LHS->getSrcPattern(), CGP);
144144 unsigned RHSSize = getPatternSize(RHS->getSrcPattern(), CGP);
145145 LHSSize += LHS->getAddedComplexity();
11931193 /// EmitCodeForPattern - Given a pattern to match, emit code to the specified
11941194 /// stream to match the pattern, and generate the code for the match if it
11951195 /// succeeds. Returns true if the pattern is not guaranteed to match.
1196 void DAGISelEmitter::GenerateCodeForPattern(PatternToMatch &Pattern,
1196 void DAGISelEmitter::GenerateCodeForPattern(const PatternToMatch &Pattern,
11971197 std::vector > &GeneratedCode,
11981198 std::set &GeneratedDecl,
11991199 std::vector &TargetOpcodes,
12511251 /// EraseCodeLine - Erase one code line from all of the patterns. If removing
12521252 /// a line causes any of them to be empty, remove them and return true when
12531253 /// done.
1254 static bool EraseCodeLine(std::vectorPatternToMatch*,
1254 static bool EraseCodeLine(std::vectorconst PatternToMatch*,
12551255 std::vector > > >
12561256 &Patterns) {
12571257 bool ErasedPatterns = false;
12681268
12691269 /// EmitPatterns - Emit code for at least one pattern, but try to group common
12701270 /// code together between the patterns.
1271 void DAGISelEmitter::EmitPatterns(std::vectorPatternToMatch*,
1271 void DAGISelEmitter::EmitPatterns(std::vectorconst PatternToMatch*,
12721272 std::vector > > >
12731273 &Patterns, unsigned Indent,
12741274 std::ostream &OS) {
12751275 typedef std::pair CodeLine;
12761276 typedef std::vector CodeList;
1277 typedef std::vectorPatternToMatch*, CodeList> > PatternList;
1277 typedef std::vectorconst PatternToMatch*, CodeList> > PatternList;
12781278
12791279 if (Patterns.empty()) return;
12801280
12941294
12951295 // FIXME: Emit braces?
12961296 if (Shared.size() == 1) {
1297 PatternToMatch &Pattern = *Shared.back().first;
1297 const PatternToMatch &Pattern = *Shared.back().first;
12981298 OS << "\n" << std::string(Indent, ' ') << "// Pattern: ";
12991299 Pattern.getSrcPattern()->print(OS);
13001300 OS << "\n" << std::string(Indent, ' ') << "// Emits: ";
13191319 }
13201320
13211321 if (Other.size() == 1) {
1322 PatternToMatch &Pattern = *Other.back().first;
1322 const PatternToMatch &Pattern = *Other.back().first;
13231323 OS << "\n" << std::string(Indent, ' ') << "// Pattern: ";
13241324 Pattern.getSrcPattern()->print(OS);
13251325 OS << "\n" << std::string(Indent, ' ') << "// Emits: ";
14071407 if (!InstNS.empty()) InstNS += "::";
14081408
14091409 // Group the patterns by their top-level opcodes.
1410 std::mapPatternToMatch*> > PatternsByOpcode;
1410 std::mapconst PatternToMatch*> > PatternsByOpcode;
14111411 // All unique target node emission functions.
14121412 std::map EmitFunctions;
14131413 for (CodegenDAGPatterns::ptm_iterator I = CGP->ptm_begin(),
14141414 E = CGP->ptm_end(); I != E; ++I) {
1415 PatternToMatch &Pattern = *I;
1415 const PatternToMatch &Pattern = *I;
14161416
14171417 TreePatternNode *Node = Pattern.getSrcPattern();
14181418 if (!Node->isLeaf()) {
14481448 // Emit one Select_* method for each top-level opcode. We do this instead of
14491449 // emitting one giant switch statement to support compilers where this will
14501450 // result in the recursive functions taking less stack space.
1451 for (std::mapPatternToMatch*> >::iterator
1451 for (std::mapconst PatternToMatch*> >::iterator
14521452 PBOI = PatternsByOpcode.begin(), E = PatternsByOpcode.end();
14531453 PBOI != E; ++PBOI) {
14541454 const std::string &OpName = PBOI->first;
1455 std::vector<PatternToMatch*> &PatternsOfOp = PBOI->second;
1455 std::vector<const PatternToMatch*> &PatternsOfOp = PBOI->second;
14561456 assert(!PatternsOfOp.empty() && "No patterns but map has entry?");
14571457
14581458 // We want to emit all of the matching code now. However, we want to emit
14621462 PatternSortingPredicate(*CGP));
14631463
14641464 // Split them into groups by type.
1465 std::mapPatternToMatch*> > PatternsByType;
1465 std::mapconst PatternToMatch*> >PatternsByType;
14661466 for (unsigned i = 0, e = PatternsOfOp.size(); i != e; ++i) {
1467 PatternToMatch *Pat = PatternsOfOp[i];
1467 const PatternToMatch *Pat = PatternsOfOp[i];
14681468 TreePatternNode *SrcPat = Pat->getSrcPattern();
14691469 MVT::ValueType VT = SrcPat->getTypeNum(0);
1470 std::mapstd::vector >::iterator TI =
1470 std::map
1471 std::vector >::iterator TI =
14711472 PatternsByType.find(VT);
14721473 if (TI != PatternsByType.end())
14731474 TI->second.push_back(Pat);
14741475 else {
1475 std::vector<PatternToMatch*> PVec;
1476 std::vector<const PatternToMatch*> PVec;
14761477 PVec.push_back(Pat);
14771478 PatternsByType.insert(std::make_pair(VT, PVec));
14781479 }
14791480 }
14801481
1481 for (std::mapPatternToMatch*> >::iterator
1482 for (std::mapconst PatternToMatch*> >::iterator
14821483 II = PatternsByType.begin(), EE = PatternsByType.end(); II != EE;
14831484 ++II) {
14841485 MVT::ValueType OpVT = II->first;
1485 std::vector<PatternToMatch*> &Patterns = II->second;
1486 std::vector<const PatternToMatch*> &Patterns = II->second;
14861487 typedef std::vector > CodeList;
14871488 typedef std::vector >::iterator CodeListI;
14881489
1489 std::vectorPatternToMatch*, CodeList> > CodeForPatterns;
1490 std::vectorconst PatternToMatch*, CodeList> > CodeForPatterns;
14901491 std::vector > PatternOpcodes;
14911492 std::vector > PatternVTs;
14921493 std::vector > PatternDecls;
17561757
17571758 // Loop over all of the case statements, emiting a call to each method we
17581759 // emitted above.
1759 for (std::mapPatternToMatch*> >::iterator
1760 for (std::mapconst PatternToMatch*> >::iterator
17601761 PBOI = PatternsByOpcode.begin(), E = PatternsByOpcode.end();
17611762 PBOI != E; ++PBOI) {
17621763 const std::string &OpName = PBOI->first;
3232
3333
3434 private:
35 void GenerateCodeForPattern(PatternToMatch &Pattern,
35 void GenerateCodeForPattern(const PatternToMatch &Pattern,
3636 std::vector > &GeneratedCode,
3737 std::set &GeneratedDecl,
3838 std::vector &TargetOpcodes,
3939 std::vector &TargetVTs);
40 void EmitPatterns(std::vectorPatternToMatch*,
40 void EmitPatterns(std::vectorconst PatternToMatch*,
4141 std::vector > > > &Patterns,
4242 unsigned Indent, std::ostream &OS);
4343 void EmitInstructionSelector(std::ostream &OS);