Regenerate.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32848 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Reid Spencer
2007-01-03 23:45:42 +00:00
parent 7596fd0774
commit eff838e18c
6 changed files with 608 additions and 500 deletions

View File

@ -1196,7 +1196,7 @@ yy_match:
yy_find_action: yy_find_action:
yy_current_state = *--yy_state_ptr; yy_current_state = *--yy_state_ptr;
yy_lp = yy_accept[yy_current_state]; yy_lp = yy_accept[yy_current_state];
find_rule: /* we branch to this label when backing up */
for ( ; ; ) /* until we find what rule we matched */ for ( ; ; ) /* until we find what rule we matched */
{ {
if ( yy_lp && yy_lp < yy_accept[yy_current_state + 1] ) if ( yy_lp && yy_lp < yy_accept[yy_current_state + 1] )

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -333,7 +333,7 @@
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
#line 357 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" #line 400 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
typedef union YYSTYPE { typedef union YYSTYPE {
std::string* String; std::string* String;
TypeInfo* Type; TypeInfo* Type;

View File

@ -333,7 +333,7 @@
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
#line 357 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" #line 400 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
typedef union YYSTYPE { typedef union YYSTYPE {
std::string* String; std::string* String;
TypeInfo* Type; TypeInfo* Type;

View File

@ -78,24 +78,26 @@ void UpgradeAssembly(const std::string &infile, std::istream& in,
TypeInfo* ResolveType(TypeInfo*& Ty) { TypeInfo* ResolveType(TypeInfo*& Ty) {
if (Ty->isUnresolved()) { if (Ty->isUnresolved()) {
if (Ty->getNewTy()[0] == '%' && isdigit(Ty->getNewTy()[1])) {
unsigned ref = atoi(&((Ty->getNewTy().c_str())[1])); // skip the %
if (ref < EnumeratedTypes.size()) {
Ty = &EnumeratedTypes[ref];
return Ty;
} else {
std::string msg("Can't resolve numbered type: ");
msg += Ty->getNewTy();
yyerror(msg.c_str());
}
} else {
TypeMap::iterator I = NamedTypes.find(Ty->getNewTy()); TypeMap::iterator I = NamedTypes.find(Ty->getNewTy());
if (I != NamedTypes.end()) { if (I != NamedTypes.end()) {
Ty = I->second.clone(); Ty = &I->second;
return Ty; return Ty;
} else { } else {
std::string msg("Cannot resolve type: "); std::string msg("Cannot resolve type: ");
msg += Ty->getNewTy(); msg += Ty->getNewTy();
yyerror(msg.c_str()); yyerror(msg.c_str());
} }
} else if (Ty->isNumeric()) {
unsigned ref = atoi(&((Ty->getNewTy().c_str())[1])); // Skip the '\\'
if (ref < EnumeratedTypes.size()) {
Ty = EnumeratedTypes[ref].clone();
return Ty;
} else {
std::string msg("Can't resolve type: ");
msg += Ty->getNewTy();
yyerror(msg.c_str());
} }
} }
// otherwise its already resolved. // otherwise its already resolved.
@ -293,18 +295,35 @@ static TypeInfo* getFunctionReturnType(TypeInfo* PFTy) {
return PFTy->clone(); return PFTy->clone();
} }
typedef std::vector<TypeInfo*> UpRefStack;
static TypeInfo* ResolveUpReference(TypeInfo* Ty, UpRefStack* stack) {
assert(Ty->isUpReference() && "Can't resolve a non-upreference");
unsigned upref = atoi(&((Ty->getNewTy().c_str())[1])); // skip the slash
assert(upref < stack->size() && "Invalid up reference");
return (*stack)[upref - stack->size() - 1];
}
static TypeInfo* getGEPIndexedType(TypeInfo* PTy, ValueList* idxs) { static TypeInfo* getGEPIndexedType(TypeInfo* PTy, ValueList* idxs) {
ResolveType(PTy); TypeInfo* Result = ResolveType(PTy);
assert(PTy->isPointer() && "GEP Operand is not a pointer?"); assert(PTy->isPointer() && "GEP Operand is not a pointer?");
TypeInfo* Result = PTy->getElementType(); // just skip first index UpRefStack stack;
ResolveType(Result); for (unsigned i = 0; i < idxs->size(); ++i) {
for (unsigned i = 1; i < idxs->size(); ++i) {
if (Result->isComposite()) { if (Result->isComposite()) {
Result = Result->getIndexedType((*idxs)[i]); Result = Result->getIndexedType((*idxs)[i]);
ResolveType(Result); ResolveType(Result);
stack.push_back(Result);
} else } else
yyerror("Invalid type for index"); yyerror("Invalid type for index");
} }
// Resolve upreferences so we can return a more natural type
if (Result->isPointer()) {
if (Result->getElementType()->isUpReference()) {
stack.push_back(Result);
Result = ResolveUpReference(Result->getElementType(), &stack);
}
} else if (Result->isUpReference()) {
Result = ResolveUpReference(Result->getElementType(), &stack);
}
return Result->getPointerType(); return Result->getPointerType();
} }
@ -335,17 +354,41 @@ static std::string getUniqueName(const std::string *Name, TypeInfo* Ty) {
// Resolve the type // Resolve the type
ResolveType(Ty); ResolveType(Ty);
// Remove as many levels of pointer nesting that we have.
if (Ty->isPointer()) {
// Avoid infinite loops in recursive types
TypeInfo* Last = 0;
while (Ty->isPointer() && Last != Ty) {
Last = Ty;
Ty = Ty->getElementType();
ResolveType(Ty);
}
}
// Default the result to the current name // Default the result to the current name
std::string Result = *Name; std::string Result = *Name;
// Now deal with the underlying type
if (Ty->isInteger()) { if (Ty->isInteger()) {
// If its an integer type, make the name unique // If its an integer type, make the name unique
Result = makeUniqueName(Name, Ty->isSigned()); Result = makeUniqueName(Name, Ty->isSigned());
} else if (Ty->isPointer()) { } else if (Ty->isArray() || Ty->isPacked()) {
while (Ty->isPointer())
Ty = Ty->getElementType(); Ty = Ty->getElementType();
if (Ty->isInteger()) if (Ty->isInteger())
Result = makeUniqueName(Name, Ty->isSigned()); Result = makeUniqueName(Name, Ty->isSigned());
} else if (Ty->isStruct()) {
// Scan the fields and count the signed and unsigned fields
int isSigned = 0;
for (unsigned i = 0; i < Ty->getNumStructElements(); ++i) {
TypeInfo* Tmp = Ty->getElement(i);
if (Tmp->isInteger())
if (Tmp->isSigned())
isSigned++;
else
isSigned--;
}
if (isSigned != 0)
Result = makeUniqueName(Name, isSigned > 0);
} }
return Result; return Result;
} }
@ -536,7 +579,7 @@ UpRTypes
} }
| '\\' EUINT64VAL { // Type UpReference | '\\' EUINT64VAL { // Type UpReference
$2->insert(0, "\\"); $2->insert(0, "\\");
$$ = new TypeInfo($2, NumericTy); $$ = new TypeInfo($2, UpRefTy);
} }
| UpRTypesV '(' ArgTypeListI ')' { // Function derived type? | UpRTypesV '(' ArgTypeListI ')' { // Function derived type?
std::string newTy( $1->getNewTy() + "("); std::string newTy( $1->getNewTy() + "(");
@ -550,21 +593,18 @@ UpRTypes
} }
newTy += ")"; newTy += ")";
$$ = new TypeInfo(new std::string(newTy), $1, $3); $$ = new TypeInfo(new std::string(newTy), $1, $3);
EnumeratedTypes.push_back(*$$);
} }
| '[' EUINT64VAL 'x' UpRTypes ']' { // Sized array type? | '[' EUINT64VAL 'x' UpRTypes ']' { // Sized array type?
$2->insert(0,"[ "); $2->insert(0,"[ ");
*$2 += " x " + $4->getNewTy() + " ]"; *$2 += " x " + $4->getNewTy() + " ]";
uint64_t elems = atoi($2->c_str()); uint64_t elems = atoi($2->c_str());
$$ = new TypeInfo($2, ArrayTy, $4, elems); $$ = new TypeInfo($2, ArrayTy, $4, elems);
EnumeratedTypes.push_back(*$$);
} }
| '<' EUINT64VAL 'x' UpRTypes '>' { // Packed array type? | '<' EUINT64VAL 'x' UpRTypes '>' { // Packed array type?
$2->insert(0,"< "); $2->insert(0,"< ");
*$2 += " x " + $4->getNewTy() + " >"; *$2 += " x " + $4->getNewTy() + " >";
uint64_t elems = atoi($2->c_str()); uint64_t elems = atoi($2->c_str());
$$ = new TypeInfo($2, PackedTy, $4, elems); $$ = new TypeInfo($2, PackedTy, $4, elems);
EnumeratedTypes.push_back(*$$);
} }
| '{' TypeListI '}' { // Structure type? | '{' TypeListI '}' { // Structure type?
std::string newTy("{"); std::string newTy("{");
@ -575,11 +615,9 @@ UpRTypes
} }
newTy += "}"; newTy += "}";
$$ = new TypeInfo(new std::string(newTy), StructTy, $2); $$ = new TypeInfo(new std::string(newTy), StructTy, $2);
EnumeratedTypes.push_back(*$$);
} }
| '{' '}' { // Empty structure type? | '{' '}' { // Empty structure type?
$$ = new TypeInfo(new std::string("{}"), StructTy, new TypeList()); $$ = new TypeInfo(new std::string("{}"), StructTy, new TypeList());
EnumeratedTypes.push_back(*$$);
} }
| '<' '{' TypeListI '}' '>' { // Packed Structure type? | '<' '{' TypeListI '}' '>' { // Packed Structure type?
std::string newTy("<{"); std::string newTy("<{");
@ -590,15 +628,12 @@ UpRTypes
} }
newTy += "}>"; newTy += "}>";
$$ = new TypeInfo(new std::string(newTy), PackedStructTy, $3); $$ = new TypeInfo(new std::string(newTy), PackedStructTy, $3);
EnumeratedTypes.push_back(*$$);
} }
| '<' '{' '}' '>' { // Empty packed structure type? | '<' '{' '}' '>' { // Empty packed structure type?
$$ = new TypeInfo(new std::string("<{}>"), PackedStructTy, new TypeList()); $$ = new TypeInfo(new std::string("<{}>"), PackedStructTy, new TypeList());
EnumeratedTypes.push_back(*$$);
} }
| UpRTypes '*' { // Pointer type? | UpRTypes '*' { // Pointer type?
$$ = $1->getPointerType(); $$ = $1->getPointerType();
EnumeratedTypes.push_back(*$$);
}; };
// TypeList - Used for struct declarations and as a basis for function type // TypeList - Used for struct declarations and as a basis for function type
@ -745,7 +780,7 @@ ConstExpr: CastOps '(' ConstVal TO Types ')' {
$$ = new std::string(*$1); $$ = new std::string(*$1);
*$$ += "( " + source + " to " + $5->getNewTy() + ")"; *$$ += "( " + source + " to " + $5->getNewTy() + ")";
} }
delete $1; $3.destroy(); delete $4; delete $5; delete $1; $3.destroy(); delete $4;
} }
| GETELEMENTPTR '(' ConstVal IndexList ')' { | GETELEMENTPTR '(' ConstVal IndexList ')' {
*$1 += "(" + *$3.cnst; *$1 += "(" + *$3.cnst;
@ -1129,6 +1164,7 @@ ValueRef
// type immediately preceeds the value reference, and allows complex constant // type immediately preceeds the value reference, and allows complex constant
// pool references (for things like: 'ret [2 x int] [ int 12, int 42]') // pool references (for things like: 'ret [2 x int] [ int 12, int 42]')
ResolvedVal : Types ValueRef { ResolvedVal : Types ValueRef {
ResolveType($1);
std::string Name = getUniqueName($2.val, $1); std::string Name = getUniqueName($2.val, $1);
$$ = $2; $$ = $2;
delete $$.val; delete $$.val;
@ -1414,7 +1450,7 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
*$1 += " " + *$2.val + ", " + *$4.val; *$1 += " " + *$2.val + ", " + *$4.val;
$$.val = $1; $$.val = $1;
ResolveType($2.type); ResolveType($2.type);
$$.type = $2.type->getElementType()->clone(); $$.type = $2.type->getElementType();
delete $2.val; $4.destroy(); delete $2.val; $4.destroy();
} }
| INSERTELEMENT ResolvedVal ',' ResolvedVal ',' ResolvedVal { | INSERTELEMENT ResolvedVal ',' ResolvedVal ',' ResolvedVal {