Revert last changes as they introduced other problems.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35115 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Reid Spencer 2007-03-15 03:25:34 +00:00
parent 8f7d26bce7
commit 44f87ee746
2 changed files with 65 additions and 137 deletions

View File

@ -59,10 +59,6 @@ struct InlineAsmDescriptor {
: AsmString(as), Constraints(c), HasSideEffects(HSE) {} : AsmString(as), Constraints(c), HasSideEffects(HSE) {}
}; };
/// An enumeration for defining the Signedness of a type or value. Signless
/// means the signedness is not relevant to the type or value.
enum Signedness { Signless, Unsigned, Signed };
// ValID - Represents a reference of a definition of some sort. This may either // ValID - Represents a reference of a definition of some sort. This may either
// be a numeric reference or a symbolic (%var) reference. This is just a // be a numeric reference or a symbolic (%var) reference. This is just a
@ -86,51 +82,41 @@ struct ValID {
Constant *ConstantValue; // Fully resolved constant for ConstantVal case. Constant *ConstantValue; // Fully resolved constant for ConstantVal case.
InlineAsmDescriptor *IAD; InlineAsmDescriptor *IAD;
}; };
Signedness S;
static ValID create(int Num, Signedness Sign) { static ValID create(int Num) {
ValID D; D.Type = NumberVal; D.Num = Num; D.S = Sign; ValID D; D.Type = NumberVal; D.Num = Num; return D;
return D;
} }
static ValID create(char *Name, Signedness Sign) { static ValID create(char *Name) {
ValID D; D.Type = NameVal; D.Name = Name; D.S = Sign; ValID D; D.Type = NameVal; D.Name = Name; return D;
return D;
} }
static ValID create(int64_t Val) { static ValID create(int64_t Val) {
ValID D; D.Type = ConstSIntVal; D.ConstPool64 = Val; D.S = Signed; ValID D; D.Type = ConstSIntVal; D.ConstPool64 = Val; return D;
return D;
} }
static ValID create(uint64_t Val) { static ValID create(uint64_t Val) {
ValID D; D.Type = ConstUIntVal; D.UConstPool64 = Val; D.S = Unsigned; ValID D; D.Type = ConstUIntVal; D.UConstPool64 = Val; return D;
return D;
} }
static ValID create(double Val) { static ValID create(double Val) {
ValID D; D.Type = ConstFPVal; D.ConstPoolFP = Val; D.S = Signless; ValID D; D.Type = ConstFPVal; D.ConstPoolFP = Val; return D;
return D;
} }
static ValID createNull() { static ValID createNull() {
ValID D; D.Type = ConstNullVal; D.S = Signless; ValID D; D.Type = ConstNullVal; return D;
return D;
} }
static ValID createUndef() { static ValID createUndef() {
ValID D; D.Type = ConstUndefVal; D.S = Signless; ValID D; D.Type = ConstUndefVal; return D;
return D;
} }
static ValID createZeroInit() { static ValID createZeroInit() {
ValID D; D.Type = ConstZeroVal; D.S = Signless; ValID D; D.Type = ConstZeroVal; return D;
return D;
} }
static ValID create(Constant *Val, Signedness Sign) { static ValID create(Constant *Val) {
ValID D; D.Type = ConstantVal; D.ConstantValue = Val; D.S = Sign; ValID D; D.Type = ConstantVal; D.ConstantValue = Val; return D;
return D;
} }
static ValID createInlineAsm(const std::string &AsmString, static ValID createInlineAsm(const std::string &AsmString,
@ -235,6 +221,10 @@ namespace OldCallingConv {
}; };
} }
/// An enumeration for defining the Signedness of a type or value. Signless
/// means the signedness is not relevant to the type or value.
enum Signedness { Signless, Unsigned, Signed };
/// These structures are used as the semantic values returned from various /// These structures are used as the semantic values returned from various
/// productions in the grammar. They simply bundle an LLVM IR object with /// productions in the grammar. They simply bundle an LLVM IR object with
/// its Signedness value. These help track signedness through the various /// its Signedness value. These help track signedness through the various
@ -242,16 +232,6 @@ namespace OldCallingConv {
struct TypeInfo { struct TypeInfo {
const llvm::Type *T; const llvm::Type *T;
Signedness S; Signedness S;
bool operator<(const TypeInfo& that) const {
if (this == &that)
return false;
return (T < that.T) || (T == that.T && S < that.S);
}
bool operator==(const TypeInfo& that) const {
if (this == &that)
return true;
return T == that.T && S == that.S;
}
}; };
struct PATypeInfo { struct PATypeInfo {

View File

@ -67,7 +67,7 @@ static GlobalVariable *CurGV;
// //
typedef std::vector<Value *> ValueList; // Numbered defs typedef std::vector<Value *> ValueList; // Numbered defs
typedef std::pair<std::string,TypeInfo> RenameMapKey; typedef std::pair<std::string,const Type*> RenameMapKey;
typedef std::map<RenameMapKey,std::string> RenameMapType; typedef std::map<RenameMapKey,std::string> RenameMapType;
static void static void
@ -286,24 +286,11 @@ bool FuncTysDifferOnlyBySRet(const FunctionType *F1,
} }
return true; return true;
} }
bool TypesDifferOnlyBySRet(Value *V, const Type* Ty) {
if (V->getType() == Ty)
return true;
const PointerType *PF1 = dyn_cast<PointerType>(Ty);
const PointerType *PF2 = dyn_cast<PointerType>(V->getType());
if (PF1 && PF2) {
const FunctionType* FT1 = dyn_cast<FunctionType>(PF1->getElementType());
const FunctionType* FT2 = dyn_cast<FunctionType>(PF2->getElementType());
if (FT1 && FT2)
return FuncTysDifferOnlyBySRet(FT1, FT2);
}
return false;
}
// The upgrade of csretcc to sret param attribute may have caused a function // The upgrade of csretcc to sret param attribute may have caused a function
// to not be found because the param attribute changed the type of the called // to not be found because the param attribute changed the type of the called
// function. This helper function, used in getExistingValue, detects that // function. This helper function, used in getExistingValue, detects that
// situation and bitcasts the function to the correct type. // situation and returns V if it occurs and 0 otherwise.
static Value* handleSRetFuncTypeMerge(Value *V, const Type* Ty) { static Value* handleSRetFuncTypeMerge(Value *V, const Type* Ty) {
// Handle degenerate cases // Handle degenerate cases
if (!V) if (!V)
@ -315,8 +302,10 @@ static Value* handleSRetFuncTypeMerge(Value *V, const Type* Ty) {
const PointerType *PF1 = dyn_cast<PointerType>(Ty); const PointerType *PF1 = dyn_cast<PointerType>(Ty);
const PointerType *PF2 = dyn_cast<PointerType>(V->getType()); const PointerType *PF2 = dyn_cast<PointerType>(V->getType());
if (PF1 && PF2) { if (PF1 && PF2) {
const FunctionType *FT1 = dyn_cast<FunctionType>(PF1->getElementType()); const FunctionType *FT1 =
const FunctionType *FT2 = dyn_cast<FunctionType>(PF2->getElementType()); dyn_cast<FunctionType>(PF1->getElementType());
const FunctionType *FT2 =
dyn_cast<FunctionType>(PF2->getElementType());
if (FT1 && FT2 && FuncTysDifferOnlyBySRet(FT1, FT2)) if (FT1 && FT2 && FuncTysDifferOnlyBySRet(FT1, FT2))
if (FT2->paramHasAttr(1, FunctionType::StructRetAttribute)) if (FT2->paramHasAttr(1, FunctionType::StructRetAttribute))
Result = V; Result = V;
@ -363,8 +352,7 @@ static Value *getExistingValue(const Type *Ty, const ValID &D) {
// Get the name out of the ID // Get the name out of the ID
std::string Name(D.Name); std::string Name(D.Name);
Value* V = 0; Value* V = 0;
TypeInfo TI; TI.T = Ty; TI.S = D.S; RenameMapKey Key = std::make_pair(Name, Ty);
RenameMapKey Key = std::make_pair(Name, TI);
if (inFunctionScope()) { if (inFunctionScope()) {
// See if the name was renamed // See if the name was renamed
RenameMapType::const_iterator I = CurFun.RenameMap.find(Key); RenameMapType::const_iterator I = CurFun.RenameMap.find(Key);
@ -376,7 +364,6 @@ static Value *getExistingValue(const Type *Ty, const ValID &D) {
ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable(); ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
V = SymTab.lookup(LookupName); V = SymTab.lookup(LookupName);
V = handleSRetFuncTypeMerge(V, Ty); V = handleSRetFuncTypeMerge(V, Ty);
assert((!V || TypesDifferOnlyBySRet(V, Ty)) && "Found wrong type!");
} }
if (!V) { if (!V) {
RenameMapType::const_iterator I = CurModule.RenameMap.find(Key); RenameMapType::const_iterator I = CurModule.RenameMap.find(Key);
@ -387,7 +374,6 @@ static Value *getExistingValue(const Type *Ty, const ValID &D) {
LookupName = Name; LookupName = Name;
V = CurModule.CurrentModule->getValueSymbolTable().lookup(LookupName); V = CurModule.CurrentModule->getValueSymbolTable().lookup(LookupName);
V = handleSRetFuncTypeMerge(V, Ty); V = handleSRetFuncTypeMerge(V, Ty);
assert((!V || TypesDifferOnlyBySRet(V, Ty)) && "Found wrong type!");
} }
if (!V) if (!V)
return 0; return 0;
@ -527,8 +513,7 @@ static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
// because of type planes. Now they all have to be unique. So, we just // because of type planes. Now they all have to be unique. So, we just
// rename the register and treat this name as if no basic block // rename the register and treat this name as if no basic block
// had been found. // had been found.
TypeInfo TI; TI.T = N->getType(); TI.S = ID.S; RenameMapKey Key = std::make_pair(N->getName(),N->getType());
RenameMapKey Key = std::make_pair(N->getName(),TI);
N->setName(makeNameUnique(N->getName())); N->setName(makeNameUnique(N->getName()));
CurModule.RenameMap[Key] = N->getName(); CurModule.RenameMap[Key] = N->getName();
BB = 0; BB = 0;
@ -643,12 +628,10 @@ ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
// name is not null) things referencing Name can be resolved. Otherwise, things // name is not null) things referencing Name can be resolved. Otherwise, things
// refering to the number can be resolved. Do this now. // refering to the number can be resolved. Do this now.
// //
static void ResolveTypeTo(char *Name, const Type *ToTy, Signedness Sign) { static void ResolveTypeTo(char *Name, const Type *ToTy) {
ValID D; ValID D;
if (Name) if (Name) D = ValID::create(Name);
D = ValID::create(Name, Sign); else D = ValID::create((int)CurModule.Types.size());
else
D = ValID::create((int)CurModule.Types.size(), Sign);
std::map<ValID, PATypeHolder>::iterator I = std::map<ValID, PATypeHolder>::iterator I =
CurModule.LateResolveTypes.find(D); CurModule.LateResolveTypes.find(D);
@ -713,12 +696,12 @@ static inline bool TypeHasInteger(const Type *Ty) {
// null potentially, in which case this is a noop. The string passed in is // null potentially, in which case this is a noop. The string passed in is
// assumed to be a malloc'd string buffer, and is free'd by this function. // assumed to be a malloc'd string buffer, and is free'd by this function.
// //
static void setValueName(const ValueInfo &V, char *NameStr) { static void setValueName(Value *V, char *NameStr) {
if (NameStr) { if (NameStr) {
std::string Name(NameStr); // Copy string std::string Name(NameStr); // Copy string
free(NameStr); // Free old string free(NameStr); // Free old string
if (V.V->getType() == Type::VoidTy) { if (V->getType() == Type::VoidTy) {
error("Can't assign name '" + Name + "' to value with void type"); error("Can't assign name '" + Name + "' to value with void type");
return; return;
} }
@ -731,13 +714,13 @@ static void setValueName(const ValueInfo &V, char *NameStr) {
if (Existing) { if (Existing) {
// An existing value of the same name was found. This might have happened // An existing value of the same name was found. This might have happened
// because of the integer type planes collapsing in LLVM 2.0. // because of the integer type planes collapsing in LLVM 2.0.
if (Existing->getType() == V.V->getType() && if (Existing->getType() == V->getType() &&
!TypeHasInteger(Existing->getType())) { !TypeHasInteger(Existing->getType())) {
// If the type does not contain any integers in them then this can't be // If the type does not contain any integers in them then this can't be
// a type plane collapsing issue. It truly is a redefinition and we // a type plane collapsing issue. It truly is a redefinition and we
// should error out as the assembly is invalid. // should error out as the assembly is invalid.
error("Redefinition of value named '" + Name + "' of type '" + error("Redefinition of value named '" + Name + "' of type '" +
V.V->getType()->getDescription() + "'"); V->getType()->getDescription() + "'");
return; return;
} }
// In LLVM 2.0 we don't allow names to be re-used for any values in a // In LLVM 2.0 we don't allow names to be re-used for any values in a
@ -751,16 +734,13 @@ static void setValueName(const ValueInfo &V, char *NameStr) {
// We're changing the name but it will probably be used by other // We're changing the name but it will probably be used by other
// instructions as operands later on. Consequently we have to retain // instructions as operands later on. Consequently we have to retain
// a mapping of the renaming that we're doing. // a mapping of the renaming that we're doing.
TypeInfo TI; RenameMapKey Key = std::make_pair(Name,V->getType());
TI.T = V.V->getType();
TI.S = V.S;
RenameMapKey Key = std::make_pair(Name,TI);
CurFun.RenameMap[Key] = NewName; CurFun.RenameMap[Key] = NewName;
Name = NewName; Name = NewName;
} }
// Set the name. // Set the name.
V.V->setName(Name); V->setName(Name);
} }
} }
@ -769,8 +749,7 @@ static void setValueName(const ValueInfo &V, char *NameStr) {
static GlobalVariable * static GlobalVariable *
ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage, ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
bool isConstantGlobal, const Type *Ty, bool isConstantGlobal, const Type *Ty,
Constant *Initializer, Constant *Initializer) {
Signedness Sign) {
if (isa<FunctionType>(Ty)) if (isa<FunctionType>(Ty))
error("Cannot declare global vars of function type"); error("Cannot declare global vars of function type");
@ -786,9 +765,9 @@ ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
// object. // object.
ValID ID; ValID ID;
if (!Name.empty()) { if (!Name.empty()) {
ID = ValID::create((char*)Name.c_str(), Sign); ID = ValID::create((char*)Name.c_str());
} else { } else {
ID = ValID::create((int)CurModule.Values[PTy].size(), Sign); ID = ValID::create((int)CurModule.Values[PTy].size());
} }
if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) { if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
@ -832,8 +811,7 @@ ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
} }
// Put the renaming in the global rename map // Put the renaming in the global rename map
TypeInfo TI; TI.T = PointerType::get(Ty); TI.S = Signless; RenameMapKey Key = std::make_pair(Name,PointerType::get(Ty));
RenameMapKey Key = std::make_pair(Name,TI);
CurModule.RenameMap[Key] = NewName; CurModule.RenameMap[Key] = NewName;
// Rename it // Rename it
@ -1829,7 +1807,7 @@ UpRTypes
| SymbolicValueRef { // Named types are also simple types... | SymbolicValueRef { // Named types are also simple types...
const Type* tmp = getType($1); const Type* tmp = getType($1);
$$.PAT = new PATypeHolder(tmp); $$.PAT = new PATypeHolder(tmp);
$$.S = $1.S; // FIXME: what if its signed? $$.S = Signless; // FIXME: what if its signed?
} }
| '\\' EUINT64VAL { // Type UpReference | '\\' EUINT64VAL { // Type UpReference
if ($2 > (uint64_t)~0U) if ($2 > (uint64_t)~0U)
@ -2428,7 +2406,7 @@ ConstPool
// determined to be the same type! // determined to be the same type!
// //
const Type* Ty = $4.PAT->get(); const Type* Ty = $4.PAT->get();
ResolveTypeTo($2, Ty, $4.S); ResolveTypeTo($2, Ty);
if (!setTypeName(Ty, $2) && !$2) { if (!setTypeName(Ty, $2) && !$2) {
// If this is a named type that is not a redefinition, add it to the slot // If this is a named type that is not a redefinition, add it to the slot
@ -2444,22 +2422,20 @@ ConstPool
| ConstPool OptAssign OptLinkage GlobalType ConstVal { | ConstPool OptAssign OptLinkage GlobalType ConstVal {
if ($5.C == 0) if ($5.C == 0)
error("Global value initializer is not a constant"); error("Global value initializer is not a constant");
CurGV = ParseGlobalVariable($2, $3, $4, $5.C->getType(), $5.C, $5.S); CurGV = ParseGlobalVariable($2, $3, $4, $5.C->getType(), $5.C);
} GlobalVarAttributes { } GlobalVarAttributes {
CurGV = 0; CurGV = 0;
} }
| ConstPool OptAssign EXTERNAL GlobalType Types { | ConstPool OptAssign EXTERNAL GlobalType Types {
const Type *Ty = $5.PAT->get(); const Type *Ty = $5.PAT->get();
CurGV = ParseGlobalVariable($2, GlobalValue::ExternalLinkage, $4, Ty, 0, CurGV = ParseGlobalVariable($2, GlobalValue::ExternalLinkage, $4, Ty, 0);
$5.S);
delete $5.PAT; delete $5.PAT;
} GlobalVarAttributes { } GlobalVarAttributes {
CurGV = 0; CurGV = 0;
} }
| ConstPool OptAssign DLLIMPORT GlobalType Types { | ConstPool OptAssign DLLIMPORT GlobalType Types {
const Type *Ty = $5.PAT->get(); const Type *Ty = $5.PAT->get();
CurGV = ParseGlobalVariable($2, GlobalValue::DLLImportLinkage, $4, Ty, 0, CurGV = ParseGlobalVariable($2, GlobalValue::DLLImportLinkage, $4, Ty, 0);
$5.S);
delete $5.PAT; delete $5.PAT;
} GlobalVarAttributes { } GlobalVarAttributes {
CurGV = 0; CurGV = 0;
@ -2467,8 +2443,7 @@ ConstPool
| ConstPool OptAssign EXTERN_WEAK GlobalType Types { | ConstPool OptAssign EXTERN_WEAK GlobalType Types {
const Type *Ty = $5.PAT->get(); const Type *Ty = $5.PAT->get();
CurGV = CurGV =
ParseGlobalVariable($2, GlobalValue::ExternalWeakLinkage, $4, Ty, 0, ParseGlobalVariable($2, GlobalValue::ExternalWeakLinkage, $4, Ty, 0);
$5.S);
delete $5.PAT; delete $5.PAT;
} GlobalVarAttributes { } GlobalVarAttributes {
CurGV = 0; CurGV = 0;
@ -2639,9 +2614,9 @@ FunctionHeaderH
ValID ID; ValID ID;
if (!FunctionName.empty()) { if (!FunctionName.empty()) {
ID = ValID::create((char*)FunctionName.c_str(), $2.S); ID = ValID::create((char*)FunctionName.c_str());
} else { } else {
ID = ValID::create((int)CurModule.Values[PFT].size(), $2.S); ID = ValID::create((int)CurModule.Values[PFT].size());
} }
Function *Fn = 0; Function *Fn = 0;
@ -2669,16 +2644,14 @@ FunctionHeaderH
std::string NewName(makeNameUnique(FunctionName)); std::string NewName(makeNameUnique(FunctionName));
if (Conflict->hasInternalLinkage()) { if (Conflict->hasInternalLinkage()) {
Conflict->setName(NewName); Conflict->setName(NewName);
TypeInfo TI; TI.T = Conflict->getType(); TI.S = ID.S; RenameMapKey Key = std::make_pair(FunctionName,Conflict->getType());
RenameMapKey Key = std::make_pair(FunctionName,TI);
CurModule.RenameMap[Key] = NewName; CurModule.RenameMap[Key] = NewName;
Fn = new Function(FT, CurFun.Linkage, FunctionName, M); Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
InsertValue(Fn, CurModule.Values); InsertValue(Fn, CurModule.Values);
} else { } else {
Fn = new Function(FT, CurFun.Linkage, NewName, M); Fn = new Function(FT, CurFun.Linkage, NewName, M);
InsertValue(Fn, CurModule.Values); InsertValue(Fn, CurModule.Values);
TypeInfo TI; TI.T = PFT; TI.S = ID.S; RenameMapKey Key = std::make_pair(FunctionName,PFT);
RenameMapKey Key = std::make_pair(FunctionName,TI);
CurModule.RenameMap[Key] = NewName; CurModule.RenameMap[Key] = NewName;
} }
} else { } else {
@ -2702,8 +2675,7 @@ FunctionHeaderH
if (Conflict->hasInternalLinkage()) { if (Conflict->hasInternalLinkage()) {
// We can safely renamed the Conflict. // We can safely renamed the Conflict.
Conflict->setName(makeNameUnique(Conflict->getName())); Conflict->setName(makeNameUnique(Conflict->getName()));
TypeInfo TI; TI.T = Conflict->getType(); TI.S = ID.S; RenameMapKey Key = std::make_pair(FunctionName,Conflict->getType());
RenameMapKey Key = std::make_pair(FunctionName,TI);
CurModule.RenameMap[Key] = Conflict->getName(); CurModule.RenameMap[Key] = Conflict->getName();
Fn = new Function(FT, CurFun.Linkage, FunctionName, M); Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
InsertValue(Fn, CurModule.Values); InsertValue(Fn, CurModule.Values);
@ -2712,8 +2684,7 @@ FunctionHeaderH
std::string NewName = makeNameUnique(FunctionName); std::string NewName = makeNameUnique(FunctionName);
Fn = new Function(FT, CurFun.Linkage, NewName, M); Fn = new Function(FT, CurFun.Linkage, NewName, M);
InsertValue(Fn, CurModule.Values); InsertValue(Fn, CurModule.Values);
TypeInfo TI; TI.T = PFT; TI.S = ID.S; RenameMapKey Key = std::make_pair(FunctionName,PFT);
RenameMapKey Key = std::make_pair(FunctionName,TI);
CurModule.RenameMap[Key] = NewName; CurModule.RenameMap[Key] = NewName;
} else { } else {
// We can't quietly rename either of these things, but we must // We can't quietly rename either of these things, but we must
@ -2724,8 +2695,7 @@ FunctionHeaderH
"' may cause linkage errors"); "' may cause linkage errors");
Fn = new Function(FT, CurFun.Linkage, NewName, M); Fn = new Function(FT, CurFun.Linkage, NewName, M);
InsertValue(Fn, CurModule.Values); InsertValue(Fn, CurModule.Values);
TypeInfo TI; TI.T = PFT; TI.S = ID.S; RenameMapKey Key = std::make_pair(FunctionName,PFT);
RenameMapKey Key = std::make_pair(FunctionName,TI);
CurModule.RenameMap[Key] = NewName; CurModule.RenameMap[Key] = NewName;
} }
} else { } else {
@ -2764,8 +2734,7 @@ FunctionHeaderH
std::vector<std::pair<PATypeInfo,char*> >::iterator E = $5->end(); std::vector<std::pair<PATypeInfo,char*> >::iterator E = $5->end();
for ( ; I != E && ArgIt != ArgEnd; ++I, ++ArgIt) { for ( ; I != E && ArgIt != ArgEnd; ++I, ++ArgIt) {
delete I->first.PAT; // Delete the typeholder... delete I->first.PAT; // Delete the typeholder...
ValueInfo VI; VI.V = ArgIt; VI.S = Signless; // FIXME: Sign setValueName(ArgIt, I->second); // Insert arg into symtab...
setValueName(VI, I->second); // Insert arg into symtab...
InsertValue(ArgIt); InsertValue(ArgIt);
} }
delete $5; // We're now done with the argument list delete $5; // We're now done with the argument list
@ -2825,12 +2794,8 @@ ConstValueRef
: ESINT64VAL { $$ = ValID::create($1); } : ESINT64VAL { $$ = ValID::create($1); }
| EUINT64VAL { $$ = ValID::create($1); } | EUINT64VAL { $$ = ValID::create($1); }
| FPVAL { $$ = ValID::create($1); } | FPVAL { $$ = ValID::create($1); }
| TRUETOK { | TRUETOK { $$ = ValID::create(ConstantInt::get(Type::Int1Ty, true)); }
$$ = ValID::create(ConstantInt::get(Type::Int1Ty, true), Signed); | FALSETOK { $$ = ValID::create(ConstantInt::get(Type::Int1Ty, false)); }
}
| FALSETOK {
$$ = ValID::create(ConstantInt::get(Type::Int1Ty, false), Unsigned);
}
| NULL_TOK { $$ = ValID::createNull(); } | NULL_TOK { $$ = ValID::createNull(); }
| UNDEF { $$ = ValID::createUndef(); } | UNDEF { $$ = ValID::createUndef(); }
| ZEROINITIALIZER { $$ = ValID::createZeroInit(); } | ZEROINITIALIZER { $$ = ValID::createZeroInit(); }
@ -2852,11 +2817,11 @@ ConstValueRef
CTy->getDescription() + "'"); CTy->getDescription() + "'");
Elems.push_back(C); Elems.push_back(C);
} }
$$ = ValID::create(ConstantVector::get(pt, Elems), Signless); $$ = ValID::create(ConstantVector::get(pt, Elems));
delete PTy; delete $2; delete PTy; delete $2;
} }
| ConstExpr { | ConstExpr {
$$ = ValID::create($1.C, $1.S); $$ = ValID::create($1.C);
} }
| ASM_TOK OptSideEffect STRINGCONSTANT ',' STRINGCONSTANT { | ASM_TOK OptSideEffect STRINGCONSTANT ',' STRINGCONSTANT {
char *End = UnEscapeLexed($3, true); char *End = UnEscapeLexed($3, true);
@ -2869,11 +2834,12 @@ ConstValueRef
} }
; ;
// SymbolicValueRef - Reference to one of two ways of symbolically refering to // another value. // SymbolicValueRef - Reference to one of two ways of symbolically refering to
// another value.
// //
SymbolicValueRef SymbolicValueRef
: INTVAL { $$ = ValID::create($1,Signless); } : INTVAL { $$ = ValID::create($1); }
| Name { $$ = ValID::create($1,Signless); } | Name { $$ = ValID::create($1); }
; ;
// ValueRef - A reference to a definition... either constant or symbolic // ValueRef - A reference to a definition... either constant or symbolic
@ -2888,9 +2854,8 @@ ValueRef
ResolvedVal ResolvedVal
: Types ValueRef { : Types ValueRef {
const Type *Ty = $1.PAT->get(); const Type *Ty = $1.PAT->get();
$2.S = $1.S;
$$.V = getVal(Ty, $2);
$$.S = $1.S; $$.S = $1.S;
$$.V = getVal(Ty, $2);
delete $1.PAT; delete $1.PAT;
} }
; ;
@ -2909,8 +2874,7 @@ BasicBlockList
// //
BasicBlock BasicBlock
: InstructionList OptAssign BBTerminatorInst { : InstructionList OptAssign BBTerminatorInst {
ValueInfo VI; VI.V = $3; VI.S = Signless; setValueName($3, $2);
setValueName(VI, $2);
InsertValue($3); InsertValue($3);
$1->getInstList().push_back($3); $1->getInstList().push_back($3);
InsertValue($1); InsertValue($1);
@ -2925,7 +2889,7 @@ InstructionList
$$ = $1; $$ = $1;
} }
| /* empty */ { | /* empty */ {
$$ = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++,Signless),true); $$ = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
// Make sure to move the basic block to the correct location in the // Make sure to move the basic block to the correct location in the
// function, instead of leaving it inserted wherever it was first // function, instead of leaving it inserted wherever it was first
// referenced. // referenced.
@ -2934,7 +2898,7 @@ InstructionList
BBL.splice(BBL.end(), BBL, $$); BBL.splice(BBL.end(), BBL, $$);
} }
| LABELSTR { | LABELSTR {
$$ = CurBB = getBBVal(ValID::create($1,Signless), true); $$ = CurBB = getBBVal(ValID::create($1), true);
// Make sure to move the basic block to the correct location in the // Make sure to move the basic block to the correct location in the
// function, instead of leaving it inserted wherever it was first // function, instead of leaving it inserted wherever it was first
// referenced. // referenced.
@ -2964,7 +2928,6 @@ BBTerminatorInst
$$ = new BranchInst(tmpBBA, tmpBBB, tmpVal); $$ = new BranchInst(tmpBBA, tmpBBB, tmpVal);
} }
| SWITCH IntType ValueRef ',' LABEL ValueRef '[' JumpTable ']' { | SWITCH IntType ValueRef ',' LABEL ValueRef '[' JumpTable ']' {
$3.S = $2.S;
Value* tmpVal = getVal($2.T, $3); Value* tmpVal = getVal($2.T, $3);
BasicBlock* tmpBB = getBBVal($6); BasicBlock* tmpBB = getBBVal($6);
SwitchInst *S = new SwitchInst(tmpVal, tmpBB, $8->size()); SwitchInst *S = new SwitchInst(tmpVal, tmpBB, $8->size());
@ -2980,7 +2943,6 @@ BBTerminatorInst
delete $8; delete $8;
} }
| SWITCH IntType ValueRef ',' LABEL ValueRef '[' ']' { | SWITCH IntType ValueRef ',' LABEL ValueRef '[' ']' {
$3.S = $2.S;
Value* tmpVal = getVal($2.T, $3); Value* tmpVal = getVal($2.T, $3);
BasicBlock* tmpBB = getBBVal($6); BasicBlock* tmpBB = getBBVal($6);
SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0); SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
@ -3053,7 +3015,6 @@ BBTerminatorInst
JumpTable JumpTable
: JumpTable IntType ConstValueRef ',' LABEL ValueRef { : JumpTable IntType ConstValueRef ',' LABEL ValueRef {
$$ = $1; $$ = $1;
$3.S = $2.S;
Constant *V = cast<Constant>(getExistingValue($2.T, $3)); Constant *V = cast<Constant>(getExistingValue($2.T, $3));
if (V == 0) if (V == 0)
@ -3064,7 +3025,6 @@ JumpTable
} }
| IntType ConstValueRef ',' LABEL ValueRef { | IntType ConstValueRef ',' LABEL ValueRef {
$$ = new std::vector<std::pair<Constant*, BasicBlock*> >(); $$ = new std::vector<std::pair<Constant*, BasicBlock*> >();
$2.S = $1.S;
Constant *V = cast<Constant>(getExistingValue($1.T, $2)); Constant *V = cast<Constant>(getExistingValue($1.T, $2));
if (V == 0) if (V == 0)
@ -3099,8 +3059,7 @@ Inst
$$.I = 0; $$.I = 0;
$$.S = Signless; $$.S = Signless;
} else { } else {
ValueInfo VI; VI.V = $2.I; VI.S = $2.S; setValueName($2.I, $1);
setValueName(VI, $1);
InsertValue($2.I); InsertValue($2.I);
$$ = $2; $$ = $2;
} }
@ -3109,7 +3068,6 @@ Inst
PHIList : Types '[' ValueRef ',' ValueRef ']' { // Used for PHI nodes PHIList : Types '[' ValueRef ',' ValueRef ']' { // Used for PHI nodes
$$.P = new std::list<std::pair<Value*, BasicBlock*> >(); $$.P = new std::list<std::pair<Value*, BasicBlock*> >();
$$.S = $1.S; $$.S = $1.S;
$3.S = $1.S;
Value* tmpVal = getVal($1.PAT->get(), $3); Value* tmpVal = getVal($1.PAT->get(), $3);
BasicBlock* tmpBB = getBBVal($5); BasicBlock* tmpBB = getBBVal($5);
$$.P->push_back(std::make_pair(tmpVal, tmpBB)); $$.P->push_back(std::make_pair(tmpVal, tmpBB));
@ -3117,7 +3075,6 @@ PHIList : Types '[' ValueRef ',' ValueRef ']' { // Used for PHI nodes
} }
| PHIList ',' '[' ValueRef ',' ValueRef ']' { | PHIList ',' '[' ValueRef ',' ValueRef ']' {
$$ = $1; $$ = $1;
$4.S = $1.S;
Value* tmpVal = getVal($1.P->front().first->getType(), $4); Value* tmpVal = getVal($1.P->front().first->getType(), $4);
BasicBlock* tmpBB = getBBVal($6); BasicBlock* tmpBB = getBBVal($6);
$1.P->push_back(std::make_pair(tmpVal, tmpBB)); $1.P->push_back(std::make_pair(tmpVal, tmpBB));
@ -3150,7 +3107,6 @@ OptTailCall
InstVal InstVal
: ArithmeticOps Types ValueRef ',' ValueRef { : ArithmeticOps Types ValueRef ',' ValueRef {
$3.S = $5.S = $2.S;
const Type* Ty = $2.PAT->get(); const Type* Ty = $2.PAT->get();
if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<VectorType>(Ty)) if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<VectorType>(Ty))
error("Arithmetic operator requires integer, FP, or packed operands"); error("Arithmetic operator requires integer, FP, or packed operands");
@ -3168,7 +3124,6 @@ InstVal
delete $2.PAT; delete $2.PAT;
} }
| LogicalOps Types ValueRef ',' ValueRef { | LogicalOps Types ValueRef ',' ValueRef {
$3.S = $5.S = $2.S;
const Type *Ty = $2.PAT->get(); const Type *Ty = $2.PAT->get();
if (!Ty->isInteger()) { if (!Ty->isInteger()) {
if (!isa<VectorType>(Ty) || if (!isa<VectorType>(Ty) ||
@ -3185,7 +3140,6 @@ InstVal
delete $2.PAT; delete $2.PAT;
} }
| SetCondOps Types ValueRef ',' ValueRef { | SetCondOps Types ValueRef ',' ValueRef {
$3.S = $5.S = $2.S;
const Type* Ty = $2.PAT->get(); const Type* Ty = $2.PAT->get();
if(isa<VectorType>(Ty)) if(isa<VectorType>(Ty))
error("VectorTypes currently not supported in setcc instructions"); error("VectorTypes currently not supported in setcc instructions");
@ -3200,7 +3154,6 @@ InstVal
delete $2.PAT; delete $2.PAT;
} }
| ICMP IPredicates Types ValueRef ',' ValueRef { | ICMP IPredicates Types ValueRef ',' ValueRef {
$4.S = $6.S = $3.S;
const Type *Ty = $3.PAT->get(); const Type *Ty = $3.PAT->get();
if (isa<VectorType>(Ty)) if (isa<VectorType>(Ty))
error("VectorTypes currently not supported in icmp instructions"); error("VectorTypes currently not supported in icmp instructions");
@ -3213,7 +3166,6 @@ InstVal
delete $3.PAT; delete $3.PAT;
} }
| FCMP FPredicates Types ValueRef ',' ValueRef { | FCMP FPredicates Types ValueRef ',' ValueRef {
$4.S = $6.S = $3.S;
const Type *Ty = $3.PAT->get(); const Type *Ty = $3.PAT->get();
if (isa<VectorType>(Ty)) if (isa<VectorType>(Ty))
error("VectorTypes currently not supported in fcmp instructions"); error("VectorTypes currently not supported in fcmp instructions");
@ -3359,6 +3311,7 @@ InstVal
delete $2.P; // Free the list... delete $2.P; // Free the list...
} }
| OptTailCall OptCallingConv TypesV ValueRef '(' ValueRefListE ')' { | OptTailCall OptCallingConv TypesV ValueRef '(' ValueRefListE ')' {
// Handle the short call syntax // Handle the short call syntax
const PointerType *PFTy; const PointerType *PFTy;
const FunctionType *FTy; const FunctionType *FTy;
@ -3462,7 +3415,6 @@ MemoryInst
| MALLOC Types ',' UINT ValueRef OptCAlign { | MALLOC Types ',' UINT ValueRef OptCAlign {
const Type *Ty = $2.PAT->get(); const Type *Ty = $2.PAT->get();
$$.S = $2.S; $$.S = $2.S;
$5.S = Unsigned;
$$.I = new MallocInst(Ty, getVal($4.T, $5), $6); $$.I = new MallocInst(Ty, getVal($4.T, $5), $6);
delete $2.PAT; delete $2.PAT;
} }
@ -3475,7 +3427,6 @@ MemoryInst
| ALLOCA Types ',' UINT ValueRef OptCAlign { | ALLOCA Types ',' UINT ValueRef OptCAlign {
const Type *Ty = $2.PAT->get(); const Type *Ty = $2.PAT->get();
$$.S = $2.S; $$.S = $2.S;
$5.S = Unsigned;
$$.I = new AllocaInst(Ty, getVal($4.T, $5), $6); $$.I = new AllocaInst(Ty, getVal($4.T, $5), $6);
delete $2.PAT; delete $2.PAT;
} }
@ -3489,7 +3440,6 @@ MemoryInst
| OptVolatile LOAD Types ValueRef { | OptVolatile LOAD Types ValueRef {
const Type* Ty = $3.PAT->get(); const Type* Ty = $3.PAT->get();
$$.S = $3.S; $$.S = $3.S;
$4.S = $3.S;
if (!isa<PointerType>(Ty)) if (!isa<PointerType>(Ty))
error("Can't load from nonpointer type: " + Ty->getDescription()); error("Can't load from nonpointer type: " + Ty->getDescription());
if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType()) if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType())
@ -3500,7 +3450,6 @@ MemoryInst
delete $3.PAT; delete $3.PAT;
} }
| OptVolatile STORE ResolvedVal ',' Types ValueRef { | OptVolatile STORE ResolvedVal ',' Types ValueRef {
$6.S = $5.S;
const PointerType *PTy = dyn_cast<PointerType>($5.PAT->get()); const PointerType *PTy = dyn_cast<PointerType>($5.PAT->get());
if (!PTy) if (!PTy)
error("Can't store to a nonpointer type: " + error("Can't store to a nonpointer type: " +
@ -3526,7 +3475,6 @@ MemoryInst
delete $5.PAT; delete $5.PAT;
} }
| GETELEMENTPTR Types ValueRef IndexList { | GETELEMENTPTR Types ValueRef IndexList {
$3.S = $2.S;
const Type* Ty = $2.PAT->get(); const Type* Ty = $2.PAT->get();
if (!isa<PointerType>(Ty)) if (!isa<PointerType>(Ty))
error("getelementptr insn requires pointer operand"); error("getelementptr insn requires pointer operand");