[llvm-commits] CVS: llvm/lib/AsmParser/Lexer.l llvmAsmParser.y

Misha Brukman brukman at cs.uiuc.edu
Tue May 10 15:02:39 PDT 2005



Changes in directory llvm/lib/AsmParser:

Lexer.l updated: 1.61 -> 1.62
llvmAsmParser.y updated: 1.223 -> 1.224
---
Log message:

* Convert tabs to spaces, fix code alignment
* Remove trailing whitespace
* Wrap long lines


---
Diffs of the changes:  (+75 -77)

 Lexer.l         |   50 +++++++++++++--------------
 llvmAsmParser.y |  102 +++++++++++++++++++++++++++-----------------------------
 2 files changed, 75 insertions(+), 77 deletions(-)


Index: llvm/lib/AsmParser/Lexer.l
diff -u llvm/lib/AsmParser/Lexer.l:1.61 llvm/lib/AsmParser/Lexer.l:1.62
--- llvm/lib/AsmParser/Lexer.l:1.61	Fri May  6 15:27:19 2005
+++ llvm/lib/AsmParser/Lexer.l	Tue May 10 17:02:28 2005
@@ -1,10 +1,10 @@
 /*===-- Lexer.l - Scanner for llvm assembly files --------------*- C++ -*--===//
-// 
+//
 //                     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 file implements the flex scanner for LLVM assembly languages files.
@@ -37,12 +37,12 @@
 
 namespace llvm {
 
-// TODO: All of the static identifiers are figured out by the lexer, 
+// TODO: All of the static identifiers are figured out by the lexer,
 // these should be hashed to reduce the lexer size
 
 
 // atoull - Convert an ascii string of decimal digits into the unsigned long
-// long representation... this does not have to do input error checking, 
+// long representation... this does not have to do input error checking,
 // because we know that the input will be matched by a suitable regex...
 //
 static uint64_t atoull(const char *Buffer) {
@@ -110,7 +110,7 @@
       *BOut = (char)strtol(BIn+1, 0, 16);  // Convert to number
       if (!AllowNull && !*BOut)
         ThrowException("String literal cannot accept \\00 escape!");
-      
+
       BIn[3] = Tmp;                  // Restore character
       BIn += 3;                      // Skip over handled chars
       ++BOut;
@@ -267,43 +267,43 @@
 {VarID}         {
                   UnEscapeLexed(yytext+1);
                   llvmAsmlval.StrVal = strdup(yytext+1);             // Skip %
-                  return VAR_ID; 
+                  return VAR_ID;
                 }
 {Label}         {
                   yytext[strlen(yytext)-1] = 0;  // nuke colon
                   UnEscapeLexed(yytext);
-		  llvmAsmlval.StrVal = strdup(yytext);
-		  return LABELSTR; 
+                  llvmAsmlval.StrVal = strdup(yytext);
+                  return LABELSTR;
                 }
 {QuoteLabel}    {
                   yytext[strlen(yytext)-2] = 0;  // nuke colon, end quote
                   UnEscapeLexed(yytext+1);
-		  llvmAsmlval.StrVal = strdup(yytext+1);
-		  return LABELSTR; 
+                  llvmAsmlval.StrVal = strdup(yytext+1);
+                  return LABELSTR;
                 }
 
 {StringConstant} { // Note that we cannot unescape a string constant here!  The
-                   // string constant might contain a \00 which would not be 
+                   // string constant might contain a \00 which would not be
                    // understood by the string stuff.  It is valid to make a
                    // [sbyte] c"Hello World\00" constant, for example.
                    //
-                  yytext[strlen(yytext)-1] = 0;           // nuke end quote
-		  llvmAsmlval.StrVal = strdup(yytext+1);  // Nuke start quote
-		  return STRINGCONSTANT;
+                   yytext[strlen(yytext)-1] = 0;           // nuke end quote
+                   llvmAsmlval.StrVal = strdup(yytext+1);  // Nuke start quote
+                   return STRINGCONSTANT;
                  }
 
 
 {PInteger}      { llvmAsmlval.UInt64Val = atoull(yytext); return EUINT64VAL; }
-{NInteger}      { 
+{NInteger}      {
                   uint64_t Val = atoull(yytext+1);
-		  // +1:  we have bigger negative range
-		  if (Val > (uint64_t)INT64_MAX+1)
-		    ThrowException("Constant too large for signed 64 bits!");
-                  llvmAsmlval.SInt64Val = -Val; 
-		  return ESINT64VAL; 
+                  // +1:  we have bigger negative range
+                  if (Val > (uint64_t)INT64_MAX+1)
+                    ThrowException("Constant too large for signed 64 bits!");
+                  llvmAsmlval.SInt64Val = -Val;
+                  return ESINT64VAL;
                 }
 {HexIntConstant} {
-                   llvmAsmlval.UInt64Val = HexIntToVal(yytext+3); 
+                   llvmAsmlval.UInt64Val = HexIntToVal(yytext+3);
                    return yytext[0] == 's' ? ESINT64VAL : EUINT64VAL;
                  }
 
@@ -316,11 +316,11 @@
                 }
 {ENInteger}     {
                   uint64_t Val = atoull(yytext+2);
-		  // +1:  we have bigger negative range
-		  if (Val > (uint64_t)INT32_MAX+1)
-		    ThrowException("Constant too large for signed 32 bits!");
+                  // +1:  we have bigger negative range
+                  if (Val > (uint64_t)INT32_MAX+1)
+                    ThrowException("Constant too large for signed 32 bits!");
                   llvmAsmlval.SIntVal = (int)-Val;
-		  return SINTVAL;
+                  return SINTVAL;
                 }
 
 {FPConstant}    { llvmAsmlval.FPVal = atof(yytext); return FPVAL; }


Index: llvm/lib/AsmParser/llvmAsmParser.y
diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.223 llvm/lib/AsmParser/llvmAsmParser.y:1.224
--- llvm/lib/AsmParser/llvmAsmParser.y:1.223	Fri May  6 15:27:19 2005
+++ llvm/lib/AsmParser/llvmAsmParser.y	Tue May 10 17:02:28 2005
@@ -1,10 +1,10 @@
 //===-- llvmAsmParser.y - Parser for llvm assembly files --------*- C++ -*-===//
-// 
+//
 //                     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 file implements the bison parser for LLVM assembly languages files.
@@ -51,8 +51,9 @@
 // destroyed when the function is completed.
 //
 typedef std::vector<Value *> ValueList;           // Numbered defs
-static void ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
-                               std::map<const Type *,ValueList> *FutureLateResolvers = 0);
+static void 
+ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
+                   std::map<const Type *,ValueList> *FutureLateResolvers = 0);
 
 static struct PerModuleInfo {
   Module *CurrentModule;
@@ -87,7 +88,7 @@
     //
     if (!GlobalRefs.empty()) {
       std::string UndefinedReferences = "Unresolved global references exist:\n";
-      
+
       for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
            I != E; ++I) {
         UndefinedReferences += "  " + I->first.first->getDescription() + " " +
@@ -179,7 +180,7 @@
   switch (D.Type) {
   case ValID::NumberVal:               // Is it a numbered definition?
     // Module constants occupy the lowest numbered slots...
-    if ((unsigned)D.Num < CurModule.Types.size()) 
+    if ((unsigned)D.Num < CurModule.Types.size())
       return CurModule.Types[(unsigned)D.Num];
     break;
   case ValID::NameVal:                 // Is it a named definition?
@@ -216,7 +217,7 @@
  }
 
 static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
-  SymbolTable &SymTab = 
+  SymbolTable &SymTab =
     inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
                         CurModule.CurrentModule->getSymbolTable();
   return SymTab.lookup(Ty, Name);
@@ -238,7 +239,7 @@
     // Module constants occupy the lowest numbered slots...
     std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
     if (VI != CurModule.Values.end()) {
-      if (Num < VI->second.size()) 
+      if (Num < VI->second.size())
         return VI->second[Num];
       Num -= VI->second.size();
     }
@@ -249,7 +250,7 @@
 
     // Check that the number is within bounds...
     if (VI->second.size() <= Num) return 0;
-  
+
     return VI->second[Num];
   }
 
@@ -261,12 +262,12 @@
     return N;
   }
 
-  // Check to make sure that "Ty" is an integral type, and that our 
+  // Check to make sure that "Ty" is an integral type, and that our
   // value will fit into the specified type...
   case ValID::ConstSIntVal:    // Is it a constant pool reference??
     if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64))
       ThrowException("Signed integral constant '" +
-                     itostr(D.ConstPool64) + "' is invalid for type '" + 
+                     itostr(D.ConstPool64) + "' is invalid for type '" +
                      Ty->getDescription() + "'!");
     return ConstantSInt::get(Ty, D.ConstPool64);
 
@@ -286,15 +287,15 @@
     if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
       ThrowException("FP constant invalid for type!!");
     return ConstantFP::get(Ty, D.ConstPoolFP);
-    
+
   case ValID::ConstNullVal:      // Is it a null value?
     if (!isa<PointerType>(Ty))
       ThrowException("Cannot create a a non pointer null!");
     return ConstantPointerNull::get(cast<PointerType>(Ty));
-    
+
   case ValID::ConstUndefVal:      // Is it an undef value?
     return UndefValue::get(Ty);
-    
+
   case ValID::ConstantVal:       // Fully resolved constant?
     if (D.ConstantValue->getType() != Ty)
       ThrowException("Constant expression type different from required type!");
@@ -339,7 +340,7 @@
 
   if (inFunctionScope())
     InsertValue(V, CurFun.LateResolveValues);
-  else 
+  else
     InsertValue(V, CurModule.LateResolveValues);
   return V;
 }
@@ -419,12 +420,13 @@
 // and back patchs after we are done.
 //
 
-// ResolveDefinitions - If we could not resolve some defs at parsing 
-// time (forward branches, phi functions for loops, etc...) resolve the 
+// ResolveDefinitions - If we could not resolve some defs at parsing
+// time (forward branches, phi functions for loops, etc...) resolve the
 // defs now...
 //
-static void ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
-                               std::map<const Type*,ValueList> *FutureLateResolvers) {
+static void 
+ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
+                   std::map<const Type*,ValueList> *FutureLateResolvers) {
   // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
   for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
          E = LateResolvers.end(); LRI != E; ++LRI) {
@@ -455,7 +457,7 @@
                          PHI->second.second);
         else
           ThrowException("Reference to an invalid definition: #" +
-                         itostr(DID.Num) + " of type '" + 
+                         itostr(DID.Num) + " of type '" +
                          V->getType()->getDescription() + "'",
                          PHI->second.second);
       }
@@ -491,15 +493,15 @@
     std::string Name(NameStr);      // Copy string
     free(NameStr);                  // Free old string
 
-    if (V->getType() == Type::VoidTy) 
+    if (V->getType() == Type::VoidTy)
       ThrowException("Can't assign name '" + Name+"' to value with void type!");
-    
+
     assert(inFunctionScope() && "Must be in function scope!");
     SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
     if (ST.lookup(V->getType(), Name))
       ThrowException("Redefinition of value named '" + Name + "' in the '" +
                      V->getType()->getDescription() + "' type plane!");
-    
+
     // Set the name.
     V->setName(Name);
   }
@@ -513,7 +515,7 @@
   if (isa<FunctionType>(Ty))
     ThrowException("Cannot declare global vars of function type!");
 
-  const PointerType *PTy = PointerType::get(Ty); 
+  const PointerType *PTy = PointerType::get(Ty);
 
   std::string Name;
   if (NameStr) {
@@ -523,7 +525,7 @@
 
   // See if this global value was forward referenced.  If so, recycle the
   // object.
-  ValID ID; 
+  ValID ID;
   if (!Name.empty()) {
     ID = ValID::create((char*)Name.c_str());
   } else {
@@ -531,7 +533,7 @@
   }
 
   if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
-    // Move the global to the end of the list, from whereever it was 
+    // Move the global to the end of the list, from whereever it was
     // previously inserted.
     GlobalVariable *GV = cast<GlobalVariable>(FWGV);
     CurModule.CurrentModule->getGlobalList().remove(GV);
@@ -549,10 +551,10 @@
   if (!Name.empty()) {
     // We are a simple redefinition of a value, check to see if it is defined
     // the same as the old one.
-    if (GlobalVariable *EGV = 
+    if (GlobalVariable *EGV =
                 CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
       // We are allowed to redefine a global variable in two circumstances:
-      // 1. If at least one of the globals is uninitialized or 
+      // 1. If at least one of the globals is uninitialized or
       // 2. If both initializers have the same value.
       //
       if (!EGV->hasInitializer() || !Initializer ||
@@ -568,14 +570,14 @@
         return;
       }
 
-      ThrowException("Redefinition of global variable named '" + Name + 
+      ThrowException("Redefinition of global variable named '" + Name +
                      "' in the '" + Ty->getDescription() + "' type plane!");
     }
   }
 
   // Otherwise there is no existing GV to use, create one now.
   GlobalVariable *GV =
-    new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name, 
+    new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
                        CurModule.CurrentModule);
   InsertValue(GV, CurModule.Values);
 }
@@ -590,12 +592,12 @@
 static bool setTypeName(const Type *T, char *NameStr) {
   assert(!inFunctionScope() && "Can't give types function-local names!");
   if (NameStr == 0) return false;
-  
+ 
   std::string Name(NameStr);      // Copy string
   free(NameStr);                  // Free old string
 
   // We don't allow assigning names to void type
-  if (T == Type::VoidTy) 
+  if (T == Type::VoidTy)
     ThrowException("Can't assign name '" + Name + "' to the void type!");
 
   // Set the type name, checking for conflicts as we do so.
@@ -634,7 +636,7 @@
 // TypeContains - Returns true if Ty directly contains E in it.
 //
 static bool TypeContains(const Type *Ty, const Type *E) {
-  return std::find(Ty->subtype_begin(), Ty->subtype_end(), 
+  return std::find(Ty->subtype_begin(), Ty->subtype_end(),
                    E) != Ty->subtype_end();
 }
 
@@ -643,7 +645,7 @@
     // NestingLevel - The number of nesting levels that need to be popped before
     // this type is resolved.
     unsigned NestingLevel;
-    
+
     // LastContainedTy - This is the type at the current binding level for the
     // type.  Every time we reduce the nesting level, this gets updated.
     const Type *LastContainedTy;
@@ -670,7 +672,7 @@
 static PATypeHolder HandleUpRefs(const Type *ty) {
   if (!ty->isAbstract()) return ty;
   PATypeHolder Ty(ty);
-  UR_OUT("Type '" << Ty->getDescription() << 
+  UR_OUT("Type '" << Ty->getDescription() <<
          "' newly formed.  Resolving upreferences.\n" <<
          UpRefs.size() << " upreferences active!\n");
 
@@ -681,15 +683,15 @@
   OpaqueType *TypeToResolve = 0;
 
   for (unsigned i = 0; i != UpRefs.size(); ++i) {
-    UR_OUT("  UR#" << i << " - TypeContains(" << Ty->getDescription() << ", " 
-           << UpRefs[i].second->getDescription() << ") = " 
+    UR_OUT("  UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
+           << UpRefs[i].second->getDescription() << ") = "
            << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
     if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
       // Decrement level of upreference
       unsigned Level = --UpRefs[i].NestingLevel;
       UpRefs[i].LastContainedTy = Ty;
       UR_OUT("  Uplevel Ref Level = " << Level << "\n");
-      if (Level == 0) {                     // Upreference should be resolved! 
+      if (Level == 0) {                     // Upreference should be resolved!
         if (!TypeToResolve) {
           TypeToResolve = UpRefs[i].UpRefTy;
         } else {
@@ -757,8 +759,9 @@
   std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList;
   std::vector<llvm::Value*>              *ValueList;
   std::list<llvm::PATypeHolder>          *TypeList;
+  // Represent the RHS of PHI node
   std::list<std::pair<llvm::Value*,
-                      llvm::BasicBlock*> > *PHIList; // Represent the RHS of PHI node
+                      llvm::BasicBlock*> > *PHIList;
   std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
   std::vector<llvm::Constant*>           *ConstVector;
 
@@ -835,10 +838,10 @@
 %token CC_TOK CCC_TOK FASTCC_TOK COLDCC_TOK
 %type <UIntVal> OptCallingConv
 
-// Basic Block Terminating Operators 
+// Basic Block Terminating Operators
 %token <TermOpVal> RET BR SWITCH INVOKE UNWIND UNREACHABLE
 
-// Binary Operators 
+// Binary Operators
 %type  <BinaryOpVal> ArithmeticOps LogicalOps SetCondOps // Binops Subcatagories
 %token <BinaryOpVal> ADD SUB MUL DIV REM AND OR XOR
 %token <BinaryOpVal> SETLE SETGE SETLT SETGT SETEQ SETNE  // Binary Comarators
@@ -871,7 +874,7 @@
   $$ = (int64_t)$1;
 };
 
-// Operations that are notably excluded from this list include: 
+// Operations that are notably excluded from this list include:
 // RET, BR, & SWITCH because they end basic blocks and are treated specially.
 //
 ArithmeticOps: ADD | SUB | MUL | DIV | REM;
@@ -880,9 +883,6 @@
 
 ShiftOps  : SHL | SHR;
 
-
-
-
 // These are some types that allow classification if we only want a particular 
 // thing... for example, only a signed, unsigned, or integral type.
 SIntType :  LONG |  INT |  SHORT | SBYTE;
@@ -894,8 +894,8 @@
 OptAssign : Name '=' {
     $$ = $1;
   }
-  | /*empty*/ { 
-    $$ = 0; 
+  | /*empty*/ {
+    $$ = 0;
   };
 
 OptLinkage : INTERNAL  { $$ = GlobalValue::InternalLinkage; } |
@@ -986,7 +986,7 @@
     for (std::list<llvm::PATypeHolder>::iterator I = $2->begin(),
            E = $2->end(); I != E; ++I)
       Elements.push_back(*I);
-    
+
     $$ = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
     delete $2;
   }
@@ -1887,10 +1887,8 @@
         !isa<PackedType>((*$2).get()))
       ThrowException(
         "Arithmetic operator requires integer, FP, or packed operands!");
-    if(isa<PackedType>((*$2).get()) && $1 == Instruction::Rem) {
-      ThrowException(
-        "Rem not supported on packed types!");
-    }
+    if (isa<PackedType>((*$2).get()) && $1 == Instruction::Rem)
+      ThrowException("Rem not supported on packed types!");
     $$ = BinaryOperator::create($1, getVal(*$2, $3), getVal(*$2, $5));
     if ($$ == 0)
       ThrowException("binary operator returned null!");






More information about the llvm-commits mailing list