diff options
| author | Misha Brukman <brukman+llvm@gmail.com> | 2005-05-10 22:02:28 +0000 | 
|---|---|---|
| committer | Misha Brukman <brukman+llvm@gmail.com> | 2005-05-10 22:02:28 +0000 | 
| commit | 8b47707b5c8e6714be41cd745dfc1f6edbb433e6 (patch) | |
| tree | 10e420410f07cc9eb431c4b64673c36a49470683 | |
| parent | 332b16aaeb2771970339fd2a5282d23982c57034 (diff) | |
| download | bcm5719-llvm-8b47707b5c8e6714be41cd745dfc1f6edbb433e6.tar.gz bcm5719-llvm-8b47707b5c8e6714be41cd745dfc1f6edbb433e6.zip  | |
* Convert tabs to spaces, fix code alignment
* Remove trailing whitespace
* Wrap long lines
llvm-svn: 21844
| -rw-r--r-- | llvm/lib/AsmParser/Lexer.l | 50 | ||||
| -rw-r--r-- | llvm/lib/AsmParser/llvmAsmParser.y | 102 | 
2 files changed, 75 insertions, 77 deletions
diff --git a/llvm/lib/AsmParser/Lexer.l b/llvm/lib/AsmParser/Lexer.l index ab04bc83f24..12a430af36b 100644 --- a/llvm/lib/AsmParser/Lexer.l +++ b/llvm/lib/AsmParser/Lexer.l @@ -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 @@ char *UnEscapeLexed(char *Buffer, bool AllowNull) {        *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 @@ getelementptr   { RET_TOK(MemOpVal, GetElementPtr, GETELEMENTPTR); }  {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 @@ getelementptr   { RET_TOK(MemOpVal, GetElementPtr, GETELEMENTPTR); }                  }  {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; } diff --git a/llvm/lib/AsmParser/llvmAsmParser.y b/llvm/lib/AsmParser/llvmAsmParser.y index 6f40ca6ac2d..c459a0eec0e 100644 --- a/llvm/lib/AsmParser/llvmAsmParser.y +++ b/llvm/lib/AsmParser/llvmAsmParser.y @@ -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 @@ static Module *ParserResult;  // 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 @@ static struct PerModuleInfo {      //      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 @@ static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {    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 const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {   }  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 @@ static Value *getValNonImprovising(const Type *Ty, const ValID &D) {      // 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 @@ static Value *getValNonImprovising(const Type *Ty, const ValID &D) {      // Check that the number is within bounds...      if (VI->second.size() <= Num) return 0; -   +      return VI->second[Num];    } @@ -261,12 +262,12 @@ static Value *getValNonImprovising(const Type *Ty, const ValID &D) {      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 @@ static Value *getValNonImprovising(const Type *Ty, const ValID &D) {      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 @@ static Value *getVal(const Type *Ty, const ValID &ID) {    if (inFunctionScope())      InsertValue(V, CurFun.LateResolveValues); -  else  +  else      InsertValue(V, CurModule.LateResolveValues);    return V;  } @@ -419,12 +420,13 @@ static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {  // 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 @@ static void ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,                           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 @@ static void setValueName(Value *V, char *NameStr) {      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 @@ static void ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,    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 @@ static void ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,    // 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 @@ static void ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,    }    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 @@ static void ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,    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 @@ static void ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,          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 void ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,  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 @@ static bool setTypeName(const Type *T, char *NameStr) {  // 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 @@ namespace {      // 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 std::vector<UpRefRecord> UpRefs;  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 @@ static PATypeHolder HandleUpRefs(const Type *ty) {    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 @@ Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {    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 @@ Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {  %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 @@ EINT64VAL : EUINT64VAL {    $$ = (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 @@ SetCondOps   : SETLE | SETGE | SETLT | SETGT | SETEQ | SETNE;  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 @@ FPType   : FLOAT | DOUBLE;  OptAssign : Name '=' {      $$ = $1;    } -  | /*empty*/ {  -    $$ = 0;  +  | /*empty*/ { +    $$ = 0;    };  OptLinkage : INTERNAL  { $$ = GlobalValue::InternalLinkage; } | @@ -986,7 +986,7 @@ UpRTypes : '\\' EUINT64VAL {                   // Type UpReference      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 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {          !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!");  | 

