//===- InstrInfoEmitter.cpp - Generate a Instruction Set Desc. ------------===////// The LLVM Compiler Infrastructure//// This file was developed by the LLVM research group and is distributed under// the University of Illinois Open Source License. See LICENSE.TXT for details.////===----------------------------------------------------------------------===////// This tablegen backend is responsible for emitting a description of the target// instruction set for the code generator.////===----------------------------------------------------------------------===//#include"InstrSelectorEmitter.h"#include"Record.h"#include"llvm/Support/Debug.h"#include"llvm/ADT/StringExtras.h"#include<set>usingnamespacellvm;NodeType::ArgResultTypesNodeType::Translate(Record*R){conststd::string&Name=R->getName();if(Name=="DNVT_any")returnAny;if(Name=="DNVT_void")returnVoid;if(Name=="DNVT_val")returnVal;if(Name=="DNVT_arg0")returnArg0;if(Name=="DNVT_arg1")returnArg1;if(Name=="DNVT_ptr")returnPtr;if(Name=="DNVT_i8")returnI8;throw"Unknown DagNodeValType '"+Name+"'!";}//===----------------------------------------------------------------------===//// TreePatternNode implementation///// getValueRecord - Returns the value of this tree node as a record. For now/// we only allow DefInit's as our leaf values, so this is used.Record*TreePatternNode::getValueRecord()const{DefInit*DI=dynamic_cast<DefInit*>(getValue());assert(DI&&"Instruction Selector does not yet support non-def leaves!");returnDI->getDef();}// updateNodeType - Set the node type of N to VT if VT contains information. If// N already contains a conflicting type, then throw an exception//boolTreePatternNode::updateNodeType(MVT::ValueTypeVT,conststd::string&RecName){if(VT==MVT::Other||getType()==VT)returnfalse;if(getType()==MVT::Other){setType(VT);returntrue;}throw"Type inference contradiction found for pattern "+RecName;}/// InstantiateNonterminals - If this pattern refers to any nonterminals which/// are not themselves completely resolved, clone the nonterminal and resolve it/// with the using context we provide.///voidTreePatternNode::InstantiateNonterminals(InstrSelectorEmitter&ISE){if(!isLeaf()){for(unsigned