llvm.org GIT mirror llvm / 0561f78
Revertin 50867 since it was breaking the build. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50871 91177308-0d34-0410-b5e6-96231b3b80d8 Tanya Lattner 11 years ago
2 changed file(s) with 54 addition(s) and 65 deletion(s). Raw diff Collapse all Expand all
1414 list properties = l;
1515 }
1616
17 // Special Tool instance - the root node of the compilation graph.
17 // Special Tool instance - graph root.
1818
1919 def root : Tool<[]>;
2020
4646
4747 // Possible edge properties
4848
49 // 'Atomic' properties.
5049 def switch_on;
5150 def parameter_equals;
5251 def element_in_list;
162162 std::string Help;
163163 unsigned Flags;
164164
165 // We need to provide a default constructor because
166 // StringMap can only store DefaultConstructible objects.
165 // We need t provide a default constructor since
166 // StringMap can only store DefaultConstructible objects
167167 GlobalOptionDescription() : OptionDescription(), Flags(0)
168168 {}
169169
221221 };
222222
223223
224 // Tool-local option description.
225
226 // Properties without arguments are implemented as flags.
224 // Tool-local option description
225
226 // Properties without arguments are implemented as flags
227227 namespace ToolOptionDescriptionFlags {
228228 enum ToolOptionDescriptionFlags { StopCompilation = 0x1,
229229 Forward = 0x2, UnpackValues = 0x4};
313313
314314
315315 /// CollectProperties - Function object for iterating over a list of
316 /// tool property records.
316 /// tool property records
317317 class CollectProperties {
318318 private:
319319
568568
569569
570570 /// CollectToolProperties - Gather information from the parsed
571 /// TableGen data (basically a wrapper for the CollectProperties
572 /// function object).
571 /// TableGen data (basically a wrapper for CollectProperties).
573572 void CollectToolProperties (RecordVector::const_iterator B,
574573 RecordVector::const_iterator E,
575574 ToolPropertiesList& TPList,
589588 }
590589 }
591590
592 /// EmitForwardOptionPropertyHandlingCode - Helper function used to
593 /// implement EmitOptionPropertyHandlingCode(). Emits code for
594 /// handling the (forward) option property.
595 void EmitForwardOptionPropertyHandlingCode (const ToolOptionDescription& D,
596 std::ostream& O) {
597 switch (D.Type) {
598 case OptionType::Switch:
599 O << Indent3 << "vec.push_back(\"-" << D.Name << "\");\n";
600 break;
601 case OptionType::Parameter:
602 O << Indent3 << "vec.push_back(\"-" << D.Name << "\");\n";
603 O << Indent3 << "vec.push_back(" << D.GenVariableName() << ");\n";
604 break;
605 case OptionType::Prefix:
606 O << Indent3 << "vec.push_back(\"-" << D.Name << "\" + "
607 << D.GenVariableName() << ");\n";
608 break;
609 case OptionType::PrefixList:
610 O << Indent3 << "for (" << D.GenTypeDeclaration()
611 << "::iterator B = " << D.GenVariableName() << ".begin(),\n"
612 << Indent3 << "E = " << D.GenVariableName() << ".end(); B != E; ++B)\n"
613 << Indent4 << "vec.push_back(\"-" << D.Name << "\" + "
614 << "*B);\n";
615 break;
616 case OptionType::ParameterList:
617 O << Indent3 << "for (" << D.GenTypeDeclaration()
618 << "::iterator B = " << D.GenVariableName() << ".begin(),\n"
619 << Indent3 << "E = " << D.GenVariableName()
620 << ".end() ; B != E; ++B) {\n"
621 << Indent4 << "vec.push_back(\"-" << D.Name << "\");\n"
622 << Indent4 << "vec.push_back(*B);\n"
623 << Indent3 << "}\n";
624 break;
625 }
626 }
627
628 /// EmitOptionPropertyHandlingCode - Helper function used by
629 /// EmitGenerateActionMethod(). Emits code that handles option
630 /// properties.
591 /// EmitOptionPropertyHandlingCode - Used by EmitGenerateActionMethod.
631592 void EmitOptionPropertyHandlingCode (const ToolProperties& P,
632593 const ToolOptionDescription& D,
633594 std::ostream& O)
634595 {
635 // Start of the if-clause.
596 // if clause
636597 O << Indent2 << "if (";
637598 if (D.Type == OptionType::Switch)
638599 O << D.GenVariableName();
641602
642603 O <<") {\n";
643604
644 // Handle option properties that take an argument.
605 // Handle option properties that take an argument
645606 for (OptionPropertyList::const_iterator B = D.Props.begin(),
646607 E = D.Props.end(); B!=E; ++B) {
647608 const OptionProperty& val = *B;
660621 // Handle flags
661622
662623 // (forward) property
663 if (D.isForward())
664 HandleForwardPropertyy(O);
624 if (D.isForward()) {
625 switch (D.Type) {
626 case OptionType::Switch:
627 O << Indent3 << "vec.push_back(\"-" << D.Name << "\");\n";
628 break;
629 case OptionType::Parameter:
630 O << Indent3 << "vec.push_back(\"-" << D.Name << "\");\n";
631 O << Indent3 << "vec.push_back(" << D.GenVariableName() << ");\n";
632 break;
633 case OptionType::Prefix:
634 O << Indent3 << "vec.push_back(\"-" << D.Name << "\" + "
635 << D.GenVariableName() << ");\n";
636 break;
637 case OptionType::PrefixList:
638 O << Indent3 << "for (" << D.GenTypeDeclaration()
639 << "::iterator B = " << D.GenVariableName() << ".begin(),\n"
640 << Indent3 << "E = " << D.GenVariableName() << ".end(); B != E; ++B)\n"
641 << Indent4 << "vec.push_back(\"-" << D.Name << "\" + "
642 << "*B);\n";
643 break;
644 case OptionType::ParameterList:
645 O << Indent3 << "for (" << D.GenTypeDeclaration()
646 << "::iterator B = " << D.GenVariableName() << ".begin(),\n"
647 << Indent3 << "E = " << D.GenVariableName()
648 << ".end() ; B != E; ++B) {\n"
649 << Indent4 << "vec.push_back(\"-" << D.Name << "\");\n"
650 << Indent4 << "vec.push_back(*B);\n"
651 << Indent3 << "}\n";
652 break;
653 }
654 }
665655
666656 // (unpack_values) property
667657 if (D.isUnpackValues()) {
682672 }
683673 }
684674
685 // End of the if-clause.
675 // close if clause
686676 O << Indent2 << "}\n";
687677 }
688678
689 // EmitGenerateActionMethod - Emit one of two versions of the
690 // Tool::GenerateAction() method.
691 void EmitGenerateActionMethod (const ToolProperties& P, bool V, std::ostream& O)
679 // EmitGenerateActionMethod - Emit one of two versions of
680 // GenerateAction method.
681 void EmitGenerateActionMethod (const ToolProperties& P, int V, std::ostream& O)
692682 {
693 if (V)
683 assert(V==1 || V==2);
684 if (V==1)
694685 O << Indent1 << "Action GenerateAction(const PathVector& inFiles,\n";
695686 else
696687 O << Indent1 << "Action GenerateAction(const sys::Path& inFile,\n";
709700 const std::string& cmd = *I;
710701 O << Indent2;
711702 if (cmd == "$INFILE") {
712 if (V)
703 if (V==1)
713704 O << "for (PathVector::const_iterator B = inFiles.begin()"
714705 << ", E = inFiles.end();\n"
715706 << Indent2 << "B != E; ++B)\n"
725716 }
726717 }
727718
728 // For every understood option, emit handling code.
719 // For every understood option, emit handling code
729720 for (ToolOptionDescriptions::const_iterator B = P.OptDescs.begin(),
730721 E = P.OptDescs.end(); B != E; ++B) {
731722 const ToolOptionDescription& val = B->second;
732723 EmitOptionPropertyHandlingCode(P, val, O);
733724 }
734725
735 // Handle the Sink property.
726 // Handle Sink property
736727 if (P.isSink()) {
737728 O << Indent2 << "if (!" << SinkOptionName << ".empty()) {\n"
738729 << Indent3 << "vec.insert(vec.end(), "
744735 << Indent1 << "}\n\n";
745736 }
746737
747 /// EmitGenerateActionMethods - Emit two GenerateAction() methods for
748 /// a given Tool class.
738 /// EmitGenerateActionMethods - Emit two GenerateAction methods for a given
739 /// Tool class.
749740 void EmitGenerateActionMethods (const ToolProperties& P, std::ostream& O) {
750741
751742 if (!P.isJoin())
761752 EmitGenerateActionMethod(P, 2, O);
762753 }
763754
764 /// EmitIsLastMethod - Emit the IsLast() method for a given Tool
765 /// class.
755 /// EmitIsLastMethod - Emit IsLast() method for a given Tool class
766756 void EmitIsLastMethod (const ToolProperties& P, std::ostream& O) {
767757 O << Indent1 << "bool IsLast() const {\n"
768758 << Indent2 << "bool last = false;\n";