//===- TGParser.cpp - Parser for TableGen Files ---------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Implement the Parser for TableGen.
//
//===----------------------------------------------------------------------===//
#include <algorithm>
#include "TGParser.h"
#include "Record.h"
#include "llvm/ADT/StringExtras.h"
using namespace llvm;
//===----------------------------------------------------------------------===//
// Support Code for the Semantic Actions.
//===----------------------------------------------------------------------===//
namespace llvm {
struct MultiClass {
Record Rec; // Placeholder for template args and Name.
std::vector<Record*> DefPrototypes;
MultiClass(const std::string &Name) : Rec(Name) {}
};
struct SubClassReference {
TGParser::LocTy RefLoc;
Record *Rec;
std::vector<Init*> TemplateArgs;
SubClassReference() : RefLoc(0), Rec(0) {}
bool isInvalid() const { return Rec == 0; }
};
} // end namespace llvm
bool TGParser::AddValue(Record *CurRec, LocTy Loc, const RecordVal &RV) {
if (CurRec == 0)
CurRec = &CurMultiClass->Rec;
if (RecordVal *ERV = CurRec->getValue(RV.getName())) {
// The value already exists in the class, treat this as a set.
if (ERV->setValue(RV.getValue()))
return Error(Loc, "New definition of '" + RV.getName() + "' of type '" +
RV