Try again to revert the bad patch. The tree was reverted for some unknown reason
[oota-llvm.git] / lib / TableGen / TGParser.cpp
index 1b1c18b589ac9b00663b38db6e238a9acb2e42c6..e5875ad7957ed8ec15a76bd341a2d3c5c8bc31b5 100644 (file)
 //===----------------------------------------------------------------------===//
 
 #include "TGParser.h"
-#include "llvm/TableGen/Record.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/TableGen/Record.h"
 #include <algorithm>
 #include <sstream>
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/Support/CommandLine.h"
 using namespace llvm;
 
 //===----------------------------------------------------------------------===//
@@ -406,8 +406,7 @@ Init *TGParser::ParseObjectName(MultiClass *CurMultiClass) {
 
   RecTy *Type = 0;
   if (CurRec) {
-    const TypedInit *CurRecName =
-      dyn_cast<TypedInit>(CurRec->getNameInit());
+    const TypedInit *CurRecName = dyn_cast<TypedInit>(CurRec->getNameInit());
     if (!CurRecName) {
       TokError("Record name is not typed!");
       return 0;
@@ -1050,20 +1049,20 @@ Init *TGParser::ParseOperation(Record *CurRec) {
         MHSTy = MHSt->getType();
       if (BitsInit *MHSbits = dyn_cast<BitsInit>(MHS))
         MHSTy = BitsRecTy::get(MHSbits->getNumBits());
-      if (dyn_cast<BitInit>(MHS))
+      if (isa<BitInit>(MHS))
         MHSTy = BitRecTy::get();
 
       if (TypedInit *RHSt = dyn_cast<TypedInit>(RHS))
         RHSTy = RHSt->getType();
       if (BitsInit *RHSbits = dyn_cast<BitsInit>(RHS))
         RHSTy = BitsRecTy::get(RHSbits->getNumBits());
-      if (dyn_cast<BitInit>(RHS))
+      if (isa<BitInit>(RHS))
         RHSTy = BitRecTy::get();
 
       // For UnsetInit, it's typed from the other hand.
-      if (dyn_cast<UnsetInit>(MHS))
+      if (isa<UnsetInit>(MHS))
         MHSTy = RHSTy;
-      if (dyn_cast<UnsetInit>(RHS))
+      if (isa<UnsetInit>(RHS))
         RHSTy = MHSTy;
 
       if (!MHSTy || !RHSTy) {
@@ -2407,7 +2406,11 @@ bool TGParser::ParseDefm(MultiClass *CurMultiClass) {
 
   Init *DefmPrefix = 0;
 
-  if (Lex.Lex() == tgtok::Id) {  // eat the defm.
+  Lex.Lex(); // eat the defm.
+
+  // Note that tgtok::paste is here to allow starting with #NAME.
+  if (Lex.getCode() == tgtok::Id ||
+      Lex.getCode() == tgtok::paste) {
     DefmPrefix = ParseObjectName(CurMultiClass);
   }