mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-29 06:30:39 +00:00
Use Doxygen-style comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50833 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1fd2e6d84e
commit
4561ab5d81
@ -21,8 +21,11 @@ namespace llvmc {
|
||||
|
||||
typedef std::vector<std::string> StringVector;
|
||||
|
||||
/// Action - A class that encapsulates a single shell command.
|
||||
class Action {
|
||||
/// Command_ - The actual command (for example, 'ls').
|
||||
std::string Command_;
|
||||
/// Args_ - Command arguments. Stdout redirection is allowed.
|
||||
std::vector<std::string> Args_;
|
||||
public:
|
||||
Action (const std::string& C,
|
||||
@ -30,6 +33,7 @@ namespace llvmc {
|
||||
: Command_(C), Args_(A)
|
||||
{}
|
||||
|
||||
/// Execute - Executes the represented action.
|
||||
int Execute() const;
|
||||
};
|
||||
|
||||
|
@ -23,7 +23,11 @@ namespace llvmc {
|
||||
typedef llvm::StringMap<std::string> LanguageMap;
|
||||
class CompilationGraph;
|
||||
|
||||
/// PopulateLanguageMap - The auto-generated function that fills in
|
||||
/// the language map (map from file extensions to language names).
|
||||
void PopulateLanguageMap(LanguageMap& language_map);
|
||||
/// PopulateCompilationGraph - The auto-generated function that
|
||||
/// populates the compilation graph with nodes and edges.
|
||||
void PopulateCompilationGraph(CompilationGraph& tools);
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ extern cl::list<std::string> Languages;
|
||||
|
||||
namespace {
|
||||
|
||||
// Return the edge with the maximum weight.
|
||||
/// ChooseEdge - Return the edge with the maximum weight.
|
||||
template <class C>
|
||||
const Edge* ChooseEdge(const C& EdgesContainer,
|
||||
const InputLanguagesSet& InLangs,
|
||||
@ -304,8 +304,6 @@ TopologicalSortFilterJoinNodes(std::vector<const Node*>& Out) {
|
||||
std::back_inserter(Out), NotJoinNode);
|
||||
}
|
||||
|
||||
// Build the targets. Command-line options are accessed through global
|
||||
// variables.
|
||||
int CompilationGraph::Build (const sys::Path& TempDir) {
|
||||
|
||||
InputLanguagesSet InLangs;
|
||||
|
@ -29,8 +29,9 @@
|
||||
|
||||
namespace llvmc {
|
||||
|
||||
// A wrapper for StringMap that provides set-like functionality.
|
||||
// Only insert() and count() methods are used by my code.
|
||||
/// StringSet - A wrapper for StringMap that provides set-like
|
||||
/// functionality. Only insert() and count() methods are used by my
|
||||
/// code.
|
||||
template <class AllocatorTy = llvm::MallocAllocator>
|
||||
class StringSet : public llvm::StringMap<char, AllocatorTy> {
|
||||
typedef llvm::StringMap<char, AllocatorTy> base;
|
||||
@ -45,7 +46,7 @@ namespace llvmc {
|
||||
};
|
||||
typedef StringSet<> InputLanguagesSet;
|
||||
|
||||
// An edge of the compilation graph.
|
||||
/// Edge - Represents an edge of the compilation graph.
|
||||
class Edge : public llvm::RefCountedBaseVPTR<Edge> {
|
||||
public:
|
||||
Edge(const std::string& T) : ToolName_(T) {}
|
||||
@ -57,14 +58,14 @@ namespace llvmc {
|
||||
std::string ToolName_;
|
||||
};
|
||||
|
||||
// Edges that have no properties are instances of this class.
|
||||
/// SimpleEdge - An edge that has no properties.
|
||||
class SimpleEdge : public Edge {
|
||||
public:
|
||||
SimpleEdge(const std::string& T) : Edge(T) {}
|
||||
unsigned Weight(const InputLanguagesSet&) const { return 1; }
|
||||
};
|
||||
|
||||
// A node of the compilation graph.
|
||||
/// Node - A node (vertex) of the compilation graph.
|
||||
struct Node {
|
||||
// A Node holds a list of the outward edges.
|
||||
typedef llvm::SmallVector<llvm::IntrusiveRefCntPtr<Edge>, 3> container_type;
|
||||
@ -86,7 +87,8 @@ namespace llvmc {
|
||||
iterator EdgesEnd() { return OutEdges.end(); }
|
||||
const_iterator EdgesEnd() const { return OutEdges.end(); }
|
||||
|
||||
// Add an outward edge. Takes ownership of the Edge object.
|
||||
/// AddEdge - Add an outward edge. Takes ownership of the provided
|
||||
/// Edge object.
|
||||
void AddEdge(Edge* E)
|
||||
{ OutEdges.push_back(llvm::IntrusiveRefCntPtr<Edge>(E)); }
|
||||
|
||||
@ -111,56 +113,57 @@ namespace llvmc {
|
||||
|
||||
class NodesIterator;
|
||||
|
||||
// The compilation graph itself.
|
||||
/// CompilationGraph - The compilation graph itself.
|
||||
class CompilationGraph {
|
||||
// Main data structure.
|
||||
/// nodes_map_type - The main data structure.
|
||||
typedef llvm::StringMap<Node> nodes_map_type;
|
||||
// These are used to map from language names to tools. (We can
|
||||
// have several tools associated with each language name, hence
|
||||
// the need for a vector of Edges.)
|
||||
/// tools_vector_type, tools_map_type - Data structures used to
|
||||
/// map from language names to tools. (We can have several tools
|
||||
/// associated with each language name, hence the need for a
|
||||
/// vector.)
|
||||
typedef
|
||||
llvm::SmallVector<llvm::IntrusiveRefCntPtr<Edge>, 3> tools_vector_type;
|
||||
typedef llvm::StringMap<tools_vector_type> tools_map_type;
|
||||
|
||||
// Map from file extensions to language names.
|
||||
/// ExtsToLangs - Map from file extensions to language names.
|
||||
LanguageMap ExtsToLangs;
|
||||
// Map from language names to lists of tool names.
|
||||
/// ToolsMap - Map from language names to lists of tool names.
|
||||
tools_map_type ToolsMap;
|
||||
// Map from tool names to Tool objects.
|
||||
/// NodesMap - Map from tool names to Tool objects.
|
||||
nodes_map_type NodesMap;
|
||||
|
||||
public:
|
||||
|
||||
CompilationGraph();
|
||||
|
||||
// insertVertex - insert a new node into the graph. Takes
|
||||
// ownership of the object.
|
||||
/// insertNode - Insert a new node into the graph. Takes
|
||||
/// ownership of the object.
|
||||
void insertNode(Tool* T);
|
||||
|
||||
// insertEdge - Insert a new edge into the graph. Takes ownership
|
||||
// of the Edge object.
|
||||
/// insertEdge - Insert a new edge into the graph. Takes ownership
|
||||
/// of the Edge object.
|
||||
void insertEdge(const std::string& A, Edge* E);
|
||||
|
||||
// Build - Build target(s) from the input file set. Command-line
|
||||
// options are passed implicitly as global variables.
|
||||
/// Build - Build target(s) from the input file set. Command-line
|
||||
/// options are passed implicitly as global variables.
|
||||
int Build(llvm::sys::Path const& tempDir);
|
||||
|
||||
// Return a reference to the node correponding to the given tool
|
||||
// name. Throws std::runtime_error.
|
||||
/// getNode -Return a reference to the node correponding to the
|
||||
/// given tool name. Throws std::runtime_error.
|
||||
Node& getNode(const std::string& ToolName);
|
||||
const Node& getNode(const std::string& ToolName) const;
|
||||
|
||||
// viewGraph - This function is meant for use from the debugger.
|
||||
// You can just say 'call G->viewGraph()' and a ghostview window
|
||||
// should pop up from the program, displaying the compilation
|
||||
// graph. This depends on there being a 'dot' and 'gv' program
|
||||
// in your path.
|
||||
/// viewGraph - This function is meant for use from the debugger.
|
||||
/// You can just say 'call G->viewGraph()' and a ghostview window
|
||||
/// should pop up from the program, displaying the compilation
|
||||
/// graph. This depends on there being a 'dot' and 'gv' program
|
||||
/// in your path.
|
||||
void viewGraph();
|
||||
|
||||
// Write a CompilationGraph.dot file.
|
||||
/// writeGraph - Write a compilation-graph.dot file.
|
||||
void writeGraph();
|
||||
|
||||
// GraphTraits support
|
||||
// GraphTraits support.
|
||||
friend NodesIterator GraphBegin(CompilationGraph*);
|
||||
friend NodesIterator GraphEnd(CompilationGraph*);
|
||||
friend void PopulateCompilationGraph(CompilationGraph&);
|
||||
@ -168,39 +171,42 @@ namespace llvmc {
|
||||
private:
|
||||
// Helper functions.
|
||||
|
||||
// Find out which language corresponds to the suffix of this file.
|
||||
/// getLanguage - Find out which language corresponds to the
|
||||
/// suffix of this file.
|
||||
const std::string& getLanguage(const llvm::sys::Path& File) const;
|
||||
|
||||
// Return a reference to the list of tool names corresponding to
|
||||
// the given language name. Throws std::runtime_error.
|
||||
/// getToolsVector - Return a reference to the list of tool names
|
||||
/// corresponding to the given language name. Throws
|
||||
/// std::runtime_error.
|
||||
const tools_vector_type& getToolsVector(const std::string& LangName) const;
|
||||
|
||||
// Pass the input file through the toolchain starting at StartNode.
|
||||
/// PassThroughGraph - Pass the input file through the toolchain
|
||||
/// starting at StartNode.
|
||||
void PassThroughGraph (const llvm::sys::Path& In, const Node* StartNode,
|
||||
const InputLanguagesSet& InLangs,
|
||||
const llvm::sys::Path& TempDir) const;
|
||||
|
||||
// Find head of the toolchain corresponding to the given file.
|
||||
/// FindToolChain - Find head of the toolchain corresponding to the given file.
|
||||
const Node* FindToolChain(const llvm::sys::Path& In,
|
||||
const std::string* forceLanguage,
|
||||
InputLanguagesSet& InLangs) const;
|
||||
|
||||
// Traverse the initial parts of the toolchains.
|
||||
/// BuildInitial - Traverse the initial parts of the toolchains.
|
||||
void BuildInitial(InputLanguagesSet& InLangs,
|
||||
const llvm::sys::Path& TempDir);
|
||||
|
||||
// Sort the nodes in topological order.
|
||||
/// TopologicalSort - Sort the nodes in topological order.
|
||||
void TopologicalSort(std::vector<const Node*>& Out);
|
||||
// Call TopologicalSort and filter the resulting list to include
|
||||
// only Join nodes.
|
||||
/// TopologicalSortFilterJoinNodes - Call TopologicalSort and
|
||||
/// filter the resulting list to include only Join nodes.
|
||||
void TopologicalSortFilterJoinNodes(std::vector<const Node*>& Out);
|
||||
};
|
||||
|
||||
/// GraphTraits support code.
|
||||
// GraphTraits support code.
|
||||
|
||||
// Auxiliary class needed to implement GraphTraits support. Can be
|
||||
// generalised to something like value_iterator for map-like
|
||||
// containers.
|
||||
/// NodesIterator - Auxiliary class needed to implement GraphTraits
|
||||
/// support. Can be generalised to something like value_iterator
|
||||
/// for map-like containers.
|
||||
class NodesIterator : public llvm::StringMap<Node>::iterator {
|
||||
typedef llvm::StringMap<Node>::iterator super;
|
||||
typedef NodesIterator ThisType;
|
||||
@ -227,7 +233,7 @@ namespace llvmc {
|
||||
}
|
||||
|
||||
|
||||
// Another auxiliary class needed by GraphTraits.
|
||||
/// NodeChildIterator - Another auxiliary class needed by GraphTraits.
|
||||
class NodeChildIterator : public bidirectional_iterator<Node, ptrdiff_t> {
|
||||
typedef NodeChildIterator ThisType;
|
||||
typedef Node::container_type::iterator iterator;
|
||||
|
@ -26,6 +26,7 @@ namespace llvmc {
|
||||
|
||||
typedef std::vector<llvm::sys::Path> PathVector;
|
||||
|
||||
/// Tool - A class
|
||||
class Tool : public llvm::RefCountedBaseVPTR<Tool> {
|
||||
public:
|
||||
|
||||
@ -46,7 +47,7 @@ namespace llvmc {
|
||||
virtual bool IsJoin() const = 0;
|
||||
};
|
||||
|
||||
// Join tools have an input file list associated with them.
|
||||
/// JoinTool - A Tool that has an associated input file list.
|
||||
class JoinTool : public Tool {
|
||||
public:
|
||||
void AddToJoinList(const llvm::sys::Path& P) { JoinList_.push_back(P); }
|
||||
|
@ -48,6 +48,7 @@ cl::opt<bool> ViewGraph("view-graph",
|
||||
cl::Hidden);
|
||||
|
||||
namespace {
|
||||
/// BuildTargets - A small wrapper for CompilationGraph::Build.
|
||||
int BuildTargets(CompilationGraph& graph) {
|
||||
int ret;
|
||||
sys::Path tempDir(sys::Path::GetTemporaryDirectory());
|
||||
|
@ -38,16 +38,16 @@ typedef std::vector<std::string> StrVector;
|
||||
//===----------------------------------------------------------------------===//
|
||||
/// Constants
|
||||
|
||||
// Indentation strings
|
||||
// Indentation strings.
|
||||
const char * Indent1 = " ";
|
||||
const char * Indent2 = " ";
|
||||
const char * Indent3 = " ";
|
||||
const char * Indent4 = " ";
|
||||
|
||||
// Default help string
|
||||
// Default help string.
|
||||
const char * DefaultHelpString = "NO HELP MESSAGE PROVIDED";
|
||||
|
||||
// Name for the "sink" option
|
||||
// Name for the "sink" option.
|
||||
const char * SinkOptionName = "AutoGeneratedSinkOption";
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
@ -69,8 +69,8 @@ const DagInit& InitPtrToDagInitRef(Init* ptr) {
|
||||
}
|
||||
|
||||
|
||||
// Ensure that the number of args in d is <= min_arguments,
|
||||
// throw exception otherwise
|
||||
// checkNumberOfArguments - Ensure that the number of args in d is
|
||||
// less than or equal to min_arguments, otherwise throw an exception .
|
||||
void checkNumberOfArguments (const DagInit* d, unsigned min_arguments) {
|
||||
if (d->getNumArgs() < min_arguments)
|
||||
throw "Property " + d->getOperator()->getAsString()
|
||||
@ -111,8 +111,7 @@ bool IsListOptionType (OptionType::OptionType t) {
|
||||
// the option registration code, while ToolOptionDescriptions are used
|
||||
// to generate tool-specific code.
|
||||
|
||||
// Base class for option descriptions
|
||||
|
||||
/// OptionDescription - Base class for option descriptions.
|
||||
struct OptionDescription {
|
||||
OptionType::OptionType Type;
|
||||
std::string Name;
|
||||
@ -154,7 +153,7 @@ struct OptionDescription {
|
||||
|
||||
};
|
||||
|
||||
// Global option description
|
||||
// Global option description.
|
||||
|
||||
namespace GlobalOptionDescriptionFlags {
|
||||
enum GlobalOptionDescriptionFlags { Required = 0x1 };
|
||||
@ -180,7 +179,7 @@ struct GlobalOptionDescription : public OptionDescription {
|
||||
Flags |= GlobalOptionDescriptionFlags::Required;
|
||||
}
|
||||
|
||||
// Merge two option descriptions
|
||||
/// Merge - Merge two option descriptions.
|
||||
void Merge (const GlobalOptionDescription& other)
|
||||
{
|
||||
if (other.Type != Type)
|
||||
@ -197,15 +196,16 @@ struct GlobalOptionDescription : public OptionDescription {
|
||||
}
|
||||
};
|
||||
|
||||
// A GlobalOptionDescription array
|
||||
// + some flags affecting generation of option declarations
|
||||
/// GlobalOptionDescriptions - A GlobalOptionDescription array
|
||||
/// together with some flags affecting generation of option
|
||||
/// declarations.
|
||||
struct GlobalOptionDescriptions {
|
||||
typedef StringMap<GlobalOptionDescription> container_type;
|
||||
typedef container_type::const_iterator const_iterator;
|
||||
|
||||
// A list of GlobalOptionDescriptions
|
||||
/// Descriptions - A list of GlobalOptionDescriptions.
|
||||
container_type Descriptions;
|
||||
// Should the emitter generate a "cl::sink" option?
|
||||
/// HasSink - Should the emitter generate a "cl::sink" option?
|
||||
bool HasSink;
|
||||
|
||||
const GlobalOptionDescription& FindOption(const std::string& OptName) const {
|
||||
@ -307,31 +307,34 @@ struct ToolProperties : public RefCountedBase<ToolProperties> {
|
||||
};
|
||||
|
||||
|
||||
// A list of Tool information records
|
||||
// IntrusiveRefCntPtrs are used because StringMap has no copy constructor
|
||||
// (and we want to avoid copying ToolProperties anyway)
|
||||
/// ToolPropertiesList - A list of Tool information records
|
||||
/// IntrusiveRefCntPtrs are used here because StringMap has no copy
|
||||
/// constructor (and we want to avoid copying ToolProperties anyway).
|
||||
typedef std::vector<IntrusiveRefCntPtr<ToolProperties> > ToolPropertiesList;
|
||||
|
||||
|
||||
// Function object for iterating over a list of tool property records
|
||||
/// CollectProperties - Function object for iterating over a list of
|
||||
/// tool property records
|
||||
class CollectProperties {
|
||||
private:
|
||||
|
||||
/// Implementation details
|
||||
|
||||
// "Property handler" - a function that extracts information
|
||||
// about a given tool property from its DAG representation
|
||||
/// PropertyHandler - a function that extracts information
|
||||
/// about a given tool property from its DAG representation
|
||||
typedef void (CollectProperties::*PropertyHandler)(const DagInit*);
|
||||
|
||||
// Map from property names -> property handlers
|
||||
/// PropertyHandlerMap - A map from property names to property
|
||||
/// handlers.
|
||||
typedef StringMap<PropertyHandler> PropertyHandlerMap;
|
||||
|
||||
// "Option property handler" - a function that extracts information
|
||||
// about a given option property from its DAG representation
|
||||
/// OptionPropertyHandler - a function that extracts information
|
||||
/// about a given option property from its DAG representation.
|
||||
typedef void (CollectProperties::* OptionPropertyHandler)
|
||||
(const DagInit*, GlobalOptionDescription &);
|
||||
|
||||
// Map from option property names -> option property handlers
|
||||
/// OptionPropertyHandlerMap - A map from option property names to
|
||||
/// option property handlers
|
||||
typedef StringMap<OptionPropertyHandler> OptionPropertyHandlerMap;
|
||||
|
||||
// Static maps from strings to CollectProperties methods("handlers")
|
||||
@ -342,9 +345,10 @@ private:
|
||||
|
||||
/// This is where the information is stored
|
||||
|
||||
// Current Tool properties
|
||||
/// toolProps_ - Properties of the current Tool.
|
||||
ToolProperties& toolProps_;
|
||||
// OptionDescriptions table(used to register options globally)
|
||||
/// optDescs_ - OptionDescriptions table (used to register options
|
||||
/// globally).
|
||||
GlobalOptionDescriptions& optDescs_;
|
||||
|
||||
public:
|
||||
@ -383,8 +387,8 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
// Gets called for every tool property;
|
||||
// Just forwards to the corresponding property handler.
|
||||
/// operator() - Gets called for every tool property; Just forwards
|
||||
/// to the corresponding property handler.
|
||||
void operator() (Init* i) {
|
||||
const DagInit& d = InitPtrToDagInitRef(i);
|
||||
const std::string& property_name = d.getOperator()->getAsString();
|
||||
@ -525,12 +529,12 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
// Go through the list of option properties and call a corresponding
|
||||
// handler for each.
|
||||
//
|
||||
// Parameters:
|
||||
// name - option name
|
||||
// d - option property list
|
||||
/// processOptionProperties - Go through the list of option
|
||||
/// properties and call a corresponding handler for each.
|
||||
///
|
||||
/// Parameters:
|
||||
/// name - option name
|
||||
/// d - option property list
|
||||
void processOptionProperties (const DagInit* d, GlobalOptionDescription& o) {
|
||||
// First argument is option name
|
||||
checkNumberOfArguments(d, 2);
|
||||
@ -564,8 +568,8 @@ CollectProperties::optionPropertyHandlers_;
|
||||
bool CollectProperties::staticMembersInitialized_ = false;
|
||||
|
||||
|
||||
// Gather information from the parsed TableGen data
|
||||
// (Basically a wrapper for CollectProperties)
|
||||
/// CollectToolProperties - Gather information from the parsed
|
||||
/// TableGen data (basically a wrapper for CollectProperties).
|
||||
void CollectToolProperties (RecordVector::const_iterator B,
|
||||
RecordVector::const_iterator E,
|
||||
ToolPropertiesList& TPList,
|
||||
@ -585,7 +589,7 @@ void CollectToolProperties (RecordVector::const_iterator B,
|
||||
}
|
||||
}
|
||||
|
||||
// Used by EmitGenerateActionMethod
|
||||
/// EmitOptionPropertyHandlingCode - Used by EmitGenerateActionMethod.
|
||||
void EmitOptionPropertyHandlingCode (const ToolProperties& P,
|
||||
const ToolOptionDescription& D,
|
||||
std::ostream& O)
|
||||
@ -673,7 +677,8 @@ void EmitOptionPropertyHandlingCode (const ToolProperties& P,
|
||||
O << Indent2 << "}\n";
|
||||
}
|
||||
|
||||
// Emite one of two versions of GenerateAction method
|
||||
// EmitGenerateActionMethod - Emit one of two versions of
|
||||
// GenerateAction method.
|
||||
void EmitGenerateActionMethod (const ToolProperties& P, int V, std::ostream& O)
|
||||
{
|
||||
assert(V==1 || V==2);
|
||||
@ -731,7 +736,8 @@ void EmitGenerateActionMethod (const ToolProperties& P, int V, std::ostream& O)
|
||||
<< Indent1 << "}\n\n";
|
||||
}
|
||||
|
||||
// Emit GenerateAction methods for Tool classes
|
||||
/// EmitGenerateActionMethods - Emit two GenerateAction methods for a given
|
||||
/// Tool class.
|
||||
void EmitGenerateActionMethods (const ToolProperties& P, std::ostream& O) {
|
||||
|
||||
if (!P.isJoin())
|
||||
@ -747,7 +753,7 @@ void EmitGenerateActionMethods (const ToolProperties& P, std::ostream& O) {
|
||||
EmitGenerateActionMethod(P, 2, O);
|
||||
}
|
||||
|
||||
// Emit IsLast() method for Tool classes
|
||||
/// EmitIsLastMethod - Emit IsLast() method for a given Tool class
|
||||
void EmitIsLastMethod (const ToolProperties& P, std::ostream& O) {
|
||||
O << Indent1 << "bool IsLast() const {\n"
|
||||
<< Indent2 << "bool last = false;\n";
|
||||
@ -766,7 +772,8 @@ void EmitIsLastMethod (const ToolProperties& P, std::ostream& O) {
|
||||
<< Indent1 << "}\n\n";
|
||||
}
|
||||
|
||||
// Emit static [Input,Output]Language() methods for Tool classes
|
||||
/// EmitInOutLanguageMethods - Emit the [Input,Output]Language()
|
||||
/// methods for a given Tool class.
|
||||
void EmitInOutLanguageMethods (const ToolProperties& P, std::ostream& O) {
|
||||
O << Indent1 << "const char* InputLanguage() const {\n"
|
||||
<< Indent2 << "return \"" << P.InLanguage << "\";\n"
|
||||
@ -777,21 +784,23 @@ void EmitInOutLanguageMethods (const ToolProperties& P, std::ostream& O) {
|
||||
<< Indent1 << "}\n\n";
|
||||
}
|
||||
|
||||
// Emit static [Input,Output]Language() methods for Tool classes
|
||||
/// EmitOutputSuffixMethod - Emit the OutputSuffix() method for a
|
||||
/// given Tool class.
|
||||
void EmitOutputSuffixMethod (const ToolProperties& P, std::ostream& O) {
|
||||
O << Indent1 << "const char* OutputSuffix() const {\n"
|
||||
<< Indent2 << "return \"" << P.OutputSuffix << "\";\n"
|
||||
<< Indent1 << "}\n\n";
|
||||
}
|
||||
|
||||
// Emit static Name() method for Tool classes
|
||||
/// EmitNameMethod - Emit the Name() method for a given Tool class.
|
||||
void EmitNameMethod (const ToolProperties& P, std::ostream& O) {
|
||||
O << Indent1 << "const char* Name() const {\n"
|
||||
<< Indent2 << "return \"" << P.Name << "\";\n"
|
||||
<< Indent1 << "}\n\n";
|
||||
}
|
||||
|
||||
// Emit static Name() method for Tool classes
|
||||
/// EmitIsJoinMethod - Emit the IsJoin() method for a given Tool
|
||||
/// class.
|
||||
void EmitIsJoinMethod (const ToolProperties& P, std::ostream& O) {
|
||||
O << Indent1 << "bool IsJoin() const {\n";
|
||||
if (P.isJoin())
|
||||
@ -801,7 +810,7 @@ void EmitIsJoinMethod (const ToolProperties& P, std::ostream& O) {
|
||||
O << Indent1 << "}\n\n";
|
||||
}
|
||||
|
||||
// Emit a Tool class definition
|
||||
/// EmitToolClassDefinition - Emit a Tool class definition.
|
||||
void EmitToolClassDefinition (const ToolProperties& P, std::ostream& O) {
|
||||
|
||||
if(P.Name == "root")
|
||||
@ -826,7 +835,8 @@ void EmitToolClassDefinition (const ToolProperties& P, std::ostream& O) {
|
||||
O << "};\n\n";
|
||||
}
|
||||
|
||||
// Iterate over a list of option descriptions and emit registration code
|
||||
/// EmitOptionDescriptions - Iterate over a list of option
|
||||
/// descriptions and emit registration code.
|
||||
void EmitOptionDescriptions (const GlobalOptionDescriptions& descs,
|
||||
std::ostream& O)
|
||||
{
|
||||
@ -862,6 +872,7 @@ void EmitOptionDescriptions (const GlobalOptionDescriptions& descs,
|
||||
O << '\n';
|
||||
}
|
||||
|
||||
/// EmitPopulateLanguageMap - Emit the PopulateLanguageMap() function.
|
||||
void EmitPopulateLanguageMap (const RecordKeeper& Records, std::ostream& O)
|
||||
{
|
||||
// Get the relevant field out of RecordKeeper
|
||||
@ -891,8 +902,8 @@ void EmitPopulateLanguageMap (const RecordKeeper& Records, std::ostream& O)
|
||||
O << "}\n\n";
|
||||
}
|
||||
|
||||
// Fills in two tables that map tool names to (input, output) languages.
|
||||
// Used by the typechecker.
|
||||
/// FillInToolToLang - Fills in two tables that map tool names to
|
||||
/// (input, output) languages. Used by the typechecker.
|
||||
void FillInToolToLang (const ToolPropertiesList& TPList,
|
||||
StringMap<std::string>& ToolToInLang,
|
||||
StringMap<std::string>& ToolToOutLang) {
|
||||
@ -904,7 +915,8 @@ void FillInToolToLang (const ToolPropertiesList& TPList,
|
||||
}
|
||||
}
|
||||
|
||||
// Check that all output and input language names match.
|
||||
/// TypecheckGraph - Check that names for output and input languages
|
||||
/// on all edges do match.
|
||||
// TOFIX: check for cycles.
|
||||
// TOFIX: check for multiple default edges.
|
||||
void TypecheckGraph (Record* CompilationGraph,
|
||||
@ -935,7 +947,8 @@ void TypecheckGraph (Record* CompilationGraph,
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function used by EmitEdgePropertyTest.
|
||||
/// EmitEdgePropertyTest1Arg - Helper function used by
|
||||
/// EmitEdgePropertyTest.
|
||||
bool EmitEdgePropertyTest1Arg(const std::string& PropName,
|
||||
const DagInit& Prop,
|
||||
const GlobalOptionDescriptions& OptDescs,
|
||||
@ -956,7 +969,8 @@ bool EmitEdgePropertyTest1Arg(const std::string& PropName,
|
||||
return false;
|
||||
}
|
||||
|
||||
// Helper function used by EmitEdgePropertyTest.
|
||||
/// EmitEdgePropertyTest2Args - Helper function used by
|
||||
/// EmitEdgePropertyTest.
|
||||
bool EmitEdgePropertyTest2Args(const std::string& PropName,
|
||||
const DagInit& Prop,
|
||||
const GlobalOptionDescriptions& OptDescs,
|
||||
@ -992,7 +1006,8 @@ void EmitEdgePropertyTest(const DagInit& Prop,
|
||||
const GlobalOptionDescriptions& OptDescs,
|
||||
std::ostream& O);
|
||||
|
||||
// Helper function used by EmitEdgeClass.
|
||||
/// EmitLogicalOperationTest - Helper function used by
|
||||
/// EmitEdgePropertyTest.
|
||||
void EmitLogicalOperationTest(const DagInit& Prop, const char* LogicOp,
|
||||
const GlobalOptionDescriptions& OptDescs,
|
||||
std::ostream& O) {
|
||||
@ -1007,7 +1022,7 @@ void EmitLogicalOperationTest(const DagInit& Prop, const char* LogicOp,
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function used by EmitEdgeClass.
|
||||
/// EmitEdgePropertyTest - Helper function used by EmitEdgeClass.
|
||||
void EmitEdgePropertyTest(const DagInit& Prop,
|
||||
const GlobalOptionDescriptions& OptDescs,
|
||||
std::ostream& O) {
|
||||
@ -1025,7 +1040,7 @@ void EmitEdgePropertyTest(const DagInit& Prop,
|
||||
throw PropName + ": unknown edge property!";
|
||||
}
|
||||
|
||||
// Emit a single Edge* class.
|
||||
/// EmitEdgeClass - Emit a single Edge# class.
|
||||
void EmitEdgeClass(unsigned N, const std::string& Target,
|
||||
ListInit* Props, const GlobalOptionDescriptions& OptDescs,
|
||||
std::ostream& O) {
|
||||
@ -1083,6 +1098,8 @@ void EmitEdgeClasses (Record* CompilationGraph,
|
||||
}
|
||||
}
|
||||
|
||||
/// EmitPopulateCompilationGraph - Emit the PopulateCompilationGraph()
|
||||
/// function.
|
||||
void EmitPopulateCompilationGraph (Record* CompilationGraph,
|
||||
std::ostream& O)
|
||||
{
|
||||
@ -1131,29 +1148,30 @@ void EmitPopulateCompilationGraph (Record* CompilationGraph,
|
||||
// End of anonymous namespace
|
||||
}
|
||||
|
||||
// Back-end entry point
|
||||
/// run - The back-end entry point.
|
||||
void LLVMCConfigurationEmitter::run (std::ostream &O) {
|
||||
// Emit file header
|
||||
|
||||
// Emit file header.
|
||||
EmitSourceFileHeader("LLVMC Configuration Library", O);
|
||||
|
||||
// Get a list of all defined Tools
|
||||
// Get a list of all defined Tools.
|
||||
RecordVector Tools = Records.getAllDerivedDefinitions("Tool");
|
||||
if (Tools.empty())
|
||||
throw std::string("No tool definitions found!");
|
||||
|
||||
// Gather information from the Tool descriptions
|
||||
// Gather information from the Tool description dags.
|
||||
ToolPropertiesList tool_props;
|
||||
GlobalOptionDescriptions opt_descs;
|
||||
CollectToolProperties(Tools.begin(), Tools.end(), tool_props, opt_descs);
|
||||
|
||||
// Emit global option registration code
|
||||
// Emit global option registration code.
|
||||
EmitOptionDescriptions(opt_descs, O);
|
||||
|
||||
// Emit PopulateLanguageMap function
|
||||
// (a language map maps from file extensions to language names)
|
||||
// Emit PopulateLanguageMap() function
|
||||
// (a language map maps from file extensions to language names).
|
||||
EmitPopulateLanguageMap(Records, O);
|
||||
|
||||
// Emit Tool classes
|
||||
// Emit Tool classes.
|
||||
for (ToolPropertiesList::const_iterator B = tool_props.begin(),
|
||||
E = tool_props.end(); B!=E; ++B)
|
||||
EmitToolClassDefinition(*(*B), O);
|
||||
@ -1165,10 +1183,10 @@ void LLVMCConfigurationEmitter::run (std::ostream &O) {
|
||||
// Typecheck the compilation graph.
|
||||
TypecheckGraph(CompilationGraphRecord, tool_props);
|
||||
|
||||
// Emit Edge* classes.
|
||||
// Emit Edge# classes.
|
||||
EmitEdgeClasses(CompilationGraphRecord, opt_descs, O);
|
||||
|
||||
// Emit PopulateCompilationGraph function
|
||||
// Emit PopulateCompilationGraph() function.
|
||||
EmitPopulateCompilationGraph(CompilationGraphRecord, O);
|
||||
|
||||
// EOF
|
||||
|
@ -17,6 +17,9 @@
|
||||
#include "TableGenBackend.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
/// LLVMCConfigurationEmitter - TableGen backend that generates
|
||||
/// configuration code for LLVMC.
|
||||
class LLVMCConfigurationEmitter : public TableGenBackend {
|
||||
RecordKeeper &Records;
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user