diff options
| author | Chris Lattner <sabre@nondot.org> | 2003-08-06 06:16:35 +0000 | 
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2003-08-06 06:16:35 +0000 | 
| commit | f0f55a9b28170a05c8e8368441885092542db41f (patch) | |
| tree | c913d58f717d3e150d4748a59e5e2a795b1fc840 /llvm/support/tools/TableGen/InstrSelectorEmitter.cpp | |
| parent | b5035a4ec9b517400d613a263a671c2ee9fe0356 (diff) | |
| download | bcm5719-llvm-f0f55a9b28170a05c8e8368441885092542db41f.tar.gz bcm5719-llvm-f0f55a9b28170a05c8e8368441885092542db41f.zip | |
Add error checking code to the node type parser.  Start the instruction pattern
reader
llvm-svn: 7632
Diffstat (limited to 'llvm/support/tools/TableGen/InstrSelectorEmitter.cpp')
| -rw-r--r-- | llvm/support/tools/TableGen/InstrSelectorEmitter.cpp | 32 | 
1 files changed, 29 insertions, 3 deletions
| diff --git a/llvm/support/tools/TableGen/InstrSelectorEmitter.cpp b/llvm/support/tools/TableGen/InstrSelectorEmitter.cpp index 98bd9943074..522cd11aaff 100644 --- a/llvm/support/tools/TableGen/InstrSelectorEmitter.cpp +++ b/llvm/support/tools/TableGen/InstrSelectorEmitter.cpp @@ -24,7 +24,6 @@ NodeType::ArgResultTypes NodeType::Translate(Record *R) {  ///  void InstrSelectorEmitter::ProcessNodeTypes() {    std::vector<Record*> Nodes = Records.getAllDerivedDefinitions("DagNode"); -    for (unsigned i = 0, e = Nodes.size(); i != e; ++i) {      Record *Node = Nodes[i]; @@ -36,21 +35,48 @@ void InstrSelectorEmitter::ProcessNodeTypes() {      ListInit *Args = Node->getValueAsListInit("ArgTypes");      std::vector<NodeType::ArgResultTypes> ArgTypes; -    for (unsigned a = 0, e = Args->getSize(); a != e; ++a) +    for (unsigned a = 0, e = Args->getSize(); a != e; ++a) {        if (DefInit *DI = dynamic_cast<DefInit*>(Args->getElement(a)))          ArgTypes.push_back(NodeType::Translate(DI->getDef()));        else          throw "In node " + Node->getName() + ", argument is not a Def!"; +      if (a == 0 && ArgTypes.back() == NodeType::Arg0) +        throw "In node " + Node->getName() + ", arg 0 cannot have type 'arg0'!"; +      if (ArgTypes.back() == NodeType::Void) +        throw "In node " + Node->getName() + ", args cannot be void type!"; +    } +    if (RetTy == NodeType::Arg0 && Args->getSize() == 0) +      throw "In node " + Node->getName() + +            ", invalid return type for nullary node!"; +      // Add the node type mapping now...      NodeTypes[Node] = NodeType(RetTy, ArgTypes);    }    } +/// ProcessInstructionPatterns - Read in all subclasses of Instruction, and +/// process those with a useful Pattern field. +/// +void InstrSelectorEmitter::ProcessInstructionPatterns() { +  std::vector<Record*> Insts = Records.getAllDerivedDefinitions("Instruction"); +  for (unsigned i = 0, e = Insts.size(); i != e; ++i) { +    Record *Inst = Insts[i]; +    if (DagInit *PatternInit = +          dynamic_cast<DagInit*>(Inst->getValueInit("Pattern"))) { + +    } +  } +} + +  void InstrSelectorEmitter::run(std::ostream &OS) {    // Type-check all of the node types to ensure we "understand" them.    ProcessNodeTypes(); -   +  // Read all of the instruction patterns in... +  ProcessInstructionPatterns(); + +  // Read all of the Expander patterns in...  } | 

