//===- LLVMCConfigurationEmitter.cpp - Generate LLVMC config --------------===////// The LLVM Compiler Infrastructure//// This file is distributed under the University of Illinois Open// Source License. See LICENSE.TXT for details.////===----------------------------------------------------------------------===////// This tablegen backend is responsible for emitting LLVMC configuration code.////===----------------------------------------------------------------------===//#include"LLVMCConfigurationEmitter.h"#include"Record.h"#include"llvm/ADT/IntrusiveRefCntPtr.h"#include"llvm/ADT/SmallVector.h"#include"llvm/ADT/StringExtras.h"#include"llvm/ADT/StringMap.h"#include"llvm/Support/Streams.h"#include<algorithm>#include<cassert>#include<functional>#include<string>usingnamespacellvm;namespace{//===----------------------------------------------------------------------===///// Typedefstypedefstd::vector<Record*>RecordVector;typedefstd::vector<std::string>StrVector;//===----------------------------------------------------------------------===///// Constants// Indentation strings.constchar*Indent1=" ";constchar*Indent2=" ";constchar*Indent3=" ";constchar*Indent4=" ";// Default help string.constchar*DefaultHelpString="NO HELP MESSAGE PROVIDED";// Name for the "sink" option.constchar*SinkOptionName="AutoGeneratedSinkOption";//===----------------------------------------------------------------------===///// Helper functionsconststd::string&InitPtrToString(constInit*ptr){constStringInit&val=dynamic_cast<constStringInit&>(*ptr);returnval.getValue();}intInitPtrToInt(constInit*ptr){constIntInit&val=dynamic_cast<constIntInit&>(*ptr);returnval.getValue();}constDagInit&InitPtrToDagInitRef(constInit*ptr){constDagInit&val=dynamic_cast<constDagInit&>(*ptr);returnval;}// checkNumberOfArguments - Ensure that the number of args in d is// less than or equal to min_arguments, otherwise throw an exception.voidcheckNumberOfArguments(constDagInit*d,unsignedmin_arguments){if(d->getNumArgs()<min_arguments)throw"Property "+d->getOperator()->getAsString()+" has too few arguments!";}// isDagEmpty - is this DAG marked with an empty marker?boolisDagEmpty