mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
Revert last changes as they introduced other problems.
llvm-svn: 35115
This commit is contained in:
parent
1464c63d5d
commit
fa12fdc543
@ -59,10 +59,6 @@ struct InlineAsmDescriptor {
|
||||
: 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
|
||||
// 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.
|
||||
InlineAsmDescriptor *IAD;
|
||||
};
|
||||
Signedness S;
|
||||
|
||||
static ValID create(int Num, Signedness Sign) {
|
||||
ValID D; D.Type = NumberVal; D.Num = Num; D.S = Sign;
|
||||
return D;
|
||||
static ValID create(int Num) {
|
||||
ValID D; D.Type = NumberVal; D.Num = Num; return D;
|
||||
}
|
||||
|
||||
static ValID create(char *Name, Signedness Sign) {
|
||||
ValID D; D.Type = NameVal; D.Name = Name; D.S = Sign;
|
||||
return D;
|
||||
static ValID create(char *Name) {
|
||||
ValID D; D.Type = NameVal; D.Name = Name; return D;
|
||||
}
|
||||
|
||||
static ValID create(int64_t Val) {
|
||||
ValID D; D.Type = ConstSIntVal; D.ConstPool64 = Val; D.S = Signed;
|
||||
return D;
|
||||
ValID D; D.Type = ConstSIntVal; D.ConstPool64 = Val; return D;
|
||||
}
|
||||
|
||||
static ValID create(uint64_t Val) {
|
||||
ValID D; D.Type = ConstUIntVal; D.UConstPool64 = Val; D.S = Unsigned;
|
||||
return D;
|
||||
ValID D; D.Type = ConstUIntVal; D.UConstPool64 = Val; return D;
|
||||
}
|
||||
|
||||
static ValID create(double Val) {
|
||||
ValID D; D.Type = ConstFPVal; D.ConstPoolFP = Val; D.S = Signless;
|
||||
return D;
|
||||
ValID D; D.Type = ConstFPVal; D.ConstPoolFP = Val; return D;
|
||||
}
|
||||
|
||||
static ValID createNull() {
|
||||
ValID D; D.Type = ConstNullVal; D.S = Signless;
|
||||
return D;
|
||||
ValID D; D.Type = ConstNullVal; return D;
|
||||
}
|
||||
|
||||
static ValID createUndef() {
|
||||
ValID D; D.Type = ConstUndefVal; D.S = Signless;
|
||||
return D;
|
||||
ValID D; D.Type = ConstUndefVal; return D;
|
||||
}
|
||||
|
||||
static ValID createZeroInit() {
|
||||
ValID D; D.Type = ConstZeroVal; D.S = Signless;
|
||||
return D;
|
||||
ValID D; D.Type = ConstZeroVal; return D;
|
||||
}
|
||||
|
||||
static ValID create(Constant *Val, Signedness Sign) {
|
||||
ValID D; D.Type = ConstantVal; D.ConstantValue = Val; D.S = Sign;
|
||||
return D;
|
||||
static ValID create(Constant *Val) {
|
||||
ValID D; D.Type = ConstantVal; D.ConstantValue = Val; return D;
|
||||
}
|
||||
|
||||
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
|
||||
/// productions in the grammar. They simply bundle an LLVM IR object with
|
||||
/// its Signedness value. These help track signedness through the various
|
||||
@ -242,16 +232,6 @@ namespace OldCallingConv {
|
||||
struct TypeInfo {
|
||||
const llvm::Type *T;
|
||||
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 {
|
||||
|
@ -67,7 +67,7 @@ static GlobalVariable *CurGV;
|
||||
//
|
||||
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;
|
||||
|
||||
static void
|
||||
@ -286,24 +286,11 @@ bool FuncTysDifferOnlyBySRet(const FunctionType *F1,
|
||||
}
|
||||
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
|
||||
// to not be found because the param attribute changed the type of the called
|
||||
// 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) {
|
||||
// Handle degenerate cases
|
||||
if (!V)
|
||||
@ -315,8 +302,10 @@ static Value* handleSRetFuncTypeMerge(Value *V, const Type* Ty) {
|
||||
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());
|
||||
const FunctionType *FT1 =
|
||||
dyn_cast<FunctionType>(PF1->getElementType());
|
||||
const FunctionType *FT2 =
|
||||
dyn_cast<FunctionType>(PF2->getElementType());
|
||||
if (FT1 && FT2 && FuncTysDifferOnlyBySRet(FT1, FT2))
|
||||
if (FT2->paramHasAttr(1, FunctionType::StructRetAttribute))
|
||||
Result = V;
|
||||
@ -363,8 +352,7 @@ static Value *getExistingValue(const Type *Ty, const ValID &D) {
|
||||
// Get the name out of the ID
|
||||
std::string Name(D.Name);
|
||||
Value* V = 0;
|
||||
TypeInfo TI; TI.T = Ty; TI.S = D.S;
|
||||
RenameMapKey Key = std::make_pair(Name, TI);
|
||||
RenameMapKey Key = std::make_pair(Name, Ty);
|
||||
if (inFunctionScope()) {
|
||||
// See if the name was renamed
|
||||
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();
|
||||
V = SymTab.lookup(LookupName);
|
||||
V = handleSRetFuncTypeMerge(V, Ty);
|
||||
assert((!V || TypesDifferOnlyBySRet(V, Ty)) && "Found wrong type!");
|
||||
}
|
||||
if (!V) {
|
||||
RenameMapType::const_iterator I = CurModule.RenameMap.find(Key);
|
||||
@ -387,7 +374,6 @@ static Value *getExistingValue(const Type *Ty, const ValID &D) {
|
||||
LookupName = Name;
|
||||
V = CurModule.CurrentModule->getValueSymbolTable().lookup(LookupName);
|
||||
V = handleSRetFuncTypeMerge(V, Ty);
|
||||
assert((!V || TypesDifferOnlyBySRet(V, Ty)) && "Found wrong type!");
|
||||
}
|
||||
if (!V)
|
||||
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
|
||||
// rename the register and treat this name as if no basic block
|
||||
// had been found.
|
||||
TypeInfo TI; TI.T = N->getType(); TI.S = ID.S;
|
||||
RenameMapKey Key = std::make_pair(N->getName(),TI);
|
||||
RenameMapKey Key = std::make_pair(N->getName(),N->getType());
|
||||
N->setName(makeNameUnique(N->getName()));
|
||||
CurModule.RenameMap[Key] = N->getName();
|
||||
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
|
||||
// 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;
|
||||
if (Name)
|
||||
D = ValID::create(Name, Sign);
|
||||
else
|
||||
D = ValID::create((int)CurModule.Types.size(), Sign);
|
||||
if (Name) D = ValID::create(Name);
|
||||
else D = ValID::create((int)CurModule.Types.size());
|
||||
|
||||
std::map<ValID, PATypeHolder>::iterator I =
|
||||
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
|
||||
// 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) {
|
||||
std::string Name(NameStr); // Copy 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");
|
||||
return;
|
||||
}
|
||||
@ -731,13 +714,13 @@ static void setValueName(const ValueInfo &V, char *NameStr) {
|
||||
if (Existing) {
|
||||
// An existing value of the same name was found. This might have happened
|
||||
// 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())) {
|
||||
// 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
|
||||
// should error out as the assembly is invalid.
|
||||
error("Redefinition of value named '" + Name + "' of type '" +
|
||||
V.V->getType()->getDescription() + "'");
|
||||
V->getType()->getDescription() + "'");
|
||||
return;
|
||||
}
|
||||
// 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
|
||||
// instructions as operands later on. Consequently we have to retain
|
||||
// a mapping of the renaming that we're doing.
|
||||
TypeInfo TI;
|
||||
TI.T = V.V->getType();
|
||||
TI.S = V.S;
|
||||
RenameMapKey Key = std::make_pair(Name,TI);
|
||||
RenameMapKey Key = std::make_pair(Name,V->getType());
|
||||
CurFun.RenameMap[Key] = NewName;
|
||||
Name = NewName;
|
||||
}
|
||||
|
||||
// Set the name.
|
||||
V.V->setName(Name);
|
||||
V->setName(Name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -769,8 +749,7 @@ static void setValueName(const ValueInfo &V, char *NameStr) {
|
||||
static GlobalVariable *
|
||||
ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
|
||||
bool isConstantGlobal, const Type *Ty,
|
||||
Constant *Initializer,
|
||||
Signedness Sign) {
|
||||
Constant *Initializer) {
|
||||
if (isa<FunctionType>(Ty))
|
||||
error("Cannot declare global vars of function type");
|
||||
|
||||
@ -786,9 +765,9 @@ ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
|
||||
// object.
|
||||
ValID ID;
|
||||
if (!Name.empty()) {
|
||||
ID = ValID::create((char*)Name.c_str(), Sign);
|
||||
ID = ValID::create((char*)Name.c_str());
|
||||
} 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)) {
|
||||
@ -832,8 +811,7 @@ ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
|
||||
}
|
||||
|
||||
// Put the renaming in the global rename map
|
||||
TypeInfo TI; TI.T = PointerType::get(Ty); TI.S = Signless;
|
||||
RenameMapKey Key = std::make_pair(Name,TI);
|
||||
RenameMapKey Key = std::make_pair(Name,PointerType::get(Ty));
|
||||
CurModule.RenameMap[Key] = NewName;
|
||||
|
||||
// Rename it
|
||||
@ -1829,7 +1807,7 @@ UpRTypes
|
||||
| SymbolicValueRef { // Named types are also simple types...
|
||||
const Type* tmp = getType($1);
|
||||
$$.PAT = new PATypeHolder(tmp);
|
||||
$$.S = $1.S; // FIXME: what if its signed?
|
||||
$$.S = Signless; // FIXME: what if its signed?
|
||||
}
|
||||
| '\\' EUINT64VAL { // Type UpReference
|
||||
if ($2 > (uint64_t)~0U)
|
||||
@ -2428,7 +2406,7 @@ ConstPool
|
||||
// determined to be the same type!
|
||||
//
|
||||
const Type* Ty = $4.PAT->get();
|
||||
ResolveTypeTo($2, Ty, $4.S);
|
||||
ResolveTypeTo($2, Ty);
|
||||
|
||||
if (!setTypeName(Ty, $2) && !$2) {
|
||||
// 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 {
|
||||
if ($5.C == 0)
|
||||
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 {
|
||||
CurGV = 0;
|
||||
}
|
||||
| ConstPool OptAssign EXTERNAL GlobalType Types {
|
||||
const Type *Ty = $5.PAT->get();
|
||||
CurGV = ParseGlobalVariable($2, GlobalValue::ExternalLinkage, $4, Ty, 0,
|
||||
$5.S);
|
||||
CurGV = ParseGlobalVariable($2, GlobalValue::ExternalLinkage, $4, Ty, 0);
|
||||
delete $5.PAT;
|
||||
} GlobalVarAttributes {
|
||||
CurGV = 0;
|
||||
}
|
||||
| ConstPool OptAssign DLLIMPORT GlobalType Types {
|
||||
const Type *Ty = $5.PAT->get();
|
||||
CurGV = ParseGlobalVariable($2, GlobalValue::DLLImportLinkage, $4, Ty, 0,
|
||||
$5.S);
|
||||
CurGV = ParseGlobalVariable($2, GlobalValue::DLLImportLinkage, $4, Ty, 0);
|
||||
delete $5.PAT;
|
||||
} GlobalVarAttributes {
|
||||
CurGV = 0;
|
||||
@ -2467,8 +2443,7 @@ ConstPool
|
||||
| ConstPool OptAssign EXTERN_WEAK GlobalType Types {
|
||||
const Type *Ty = $5.PAT->get();
|
||||
CurGV =
|
||||
ParseGlobalVariable($2, GlobalValue::ExternalWeakLinkage, $4, Ty, 0,
|
||||
$5.S);
|
||||
ParseGlobalVariable($2, GlobalValue::ExternalWeakLinkage, $4, Ty, 0);
|
||||
delete $5.PAT;
|
||||
} GlobalVarAttributes {
|
||||
CurGV = 0;
|
||||
@ -2639,9 +2614,9 @@ FunctionHeaderH
|
||||
|
||||
ValID ID;
|
||||
if (!FunctionName.empty()) {
|
||||
ID = ValID::create((char*)FunctionName.c_str(), $2.S);
|
||||
ID = ValID::create((char*)FunctionName.c_str());
|
||||
} else {
|
||||
ID = ValID::create((int)CurModule.Values[PFT].size(), $2.S);
|
||||
ID = ValID::create((int)CurModule.Values[PFT].size());
|
||||
}
|
||||
|
||||
Function *Fn = 0;
|
||||
@ -2669,16 +2644,14 @@ FunctionHeaderH
|
||||
std::string NewName(makeNameUnique(FunctionName));
|
||||
if (Conflict->hasInternalLinkage()) {
|
||||
Conflict->setName(NewName);
|
||||
TypeInfo TI; TI.T = Conflict->getType(); TI.S = ID.S;
|
||||
RenameMapKey Key = std::make_pair(FunctionName,TI);
|
||||
RenameMapKey Key = std::make_pair(FunctionName,Conflict->getType());
|
||||
CurModule.RenameMap[Key] = NewName;
|
||||
Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
|
||||
InsertValue(Fn, CurModule.Values);
|
||||
} else {
|
||||
Fn = new Function(FT, CurFun.Linkage, NewName, M);
|
||||
InsertValue(Fn, CurModule.Values);
|
||||
TypeInfo TI; TI.T = PFT; TI.S = ID.S;
|
||||
RenameMapKey Key = std::make_pair(FunctionName,TI);
|
||||
RenameMapKey Key = std::make_pair(FunctionName,PFT);
|
||||
CurModule.RenameMap[Key] = NewName;
|
||||
}
|
||||
} else {
|
||||
@ -2702,8 +2675,7 @@ FunctionHeaderH
|
||||
if (Conflict->hasInternalLinkage()) {
|
||||
// We can safely renamed the Conflict.
|
||||
Conflict->setName(makeNameUnique(Conflict->getName()));
|
||||
TypeInfo TI; TI.T = Conflict->getType(); TI.S = ID.S;
|
||||
RenameMapKey Key = std::make_pair(FunctionName,TI);
|
||||
RenameMapKey Key = std::make_pair(FunctionName,Conflict->getType());
|
||||
CurModule.RenameMap[Key] = Conflict->getName();
|
||||
Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
|
||||
InsertValue(Fn, CurModule.Values);
|
||||
@ -2712,8 +2684,7 @@ FunctionHeaderH
|
||||
std::string NewName = makeNameUnique(FunctionName);
|
||||
Fn = new Function(FT, CurFun.Linkage, NewName, M);
|
||||
InsertValue(Fn, CurModule.Values);
|
||||
TypeInfo TI; TI.T = PFT; TI.S = ID.S;
|
||||
RenameMapKey Key = std::make_pair(FunctionName,TI);
|
||||
RenameMapKey Key = std::make_pair(FunctionName,PFT);
|
||||
CurModule.RenameMap[Key] = NewName;
|
||||
} else {
|
||||
// We can't quietly rename either of these things, but we must
|
||||
@ -2724,8 +2695,7 @@ FunctionHeaderH
|
||||
"' may cause linkage errors");
|
||||
Fn = new Function(FT, CurFun.Linkage, NewName, M);
|
||||
InsertValue(Fn, CurModule.Values);
|
||||
TypeInfo TI; TI.T = PFT; TI.S = ID.S;
|
||||
RenameMapKey Key = std::make_pair(FunctionName,TI);
|
||||
RenameMapKey Key = std::make_pair(FunctionName,PFT);
|
||||
CurModule.RenameMap[Key] = NewName;
|
||||
}
|
||||
} else {
|
||||
@ -2764,8 +2734,7 @@ FunctionHeaderH
|
||||
std::vector<std::pair<PATypeInfo,char*> >::iterator E = $5->end();
|
||||
for ( ; I != E && ArgIt != ArgEnd; ++I, ++ArgIt) {
|
||||
delete I->first.PAT; // Delete the typeholder...
|
||||
ValueInfo VI; VI.V = ArgIt; VI.S = Signless; // FIXME: Sign
|
||||
setValueName(VI, I->second); // Insert arg into symtab...
|
||||
setValueName(ArgIt, I->second); // Insert arg into symtab...
|
||||
InsertValue(ArgIt);
|
||||
}
|
||||
delete $5; // We're now done with the argument list
|
||||
@ -2825,12 +2794,8 @@ ConstValueRef
|
||||
: ESINT64VAL { $$ = ValID::create($1); }
|
||||
| EUINT64VAL { $$ = ValID::create($1); }
|
||||
| FPVAL { $$ = ValID::create($1); }
|
||||
| TRUETOK {
|
||||
$$ = ValID::create(ConstantInt::get(Type::Int1Ty, true), Signed);
|
||||
}
|
||||
| FALSETOK {
|
||||
$$ = ValID::create(ConstantInt::get(Type::Int1Ty, false), Unsigned);
|
||||
}
|
||||
| TRUETOK { $$ = ValID::create(ConstantInt::get(Type::Int1Ty, true)); }
|
||||
| FALSETOK { $$ = ValID::create(ConstantInt::get(Type::Int1Ty, false)); }
|
||||
| NULL_TOK { $$ = ValID::createNull(); }
|
||||
| UNDEF { $$ = ValID::createUndef(); }
|
||||
| ZEROINITIALIZER { $$ = ValID::createZeroInit(); }
|
||||
@ -2852,11 +2817,11 @@ ConstValueRef
|
||||
CTy->getDescription() + "'");
|
||||
Elems.push_back(C);
|
||||
}
|
||||
$$ = ValID::create(ConstantVector::get(pt, Elems), Signless);
|
||||
$$ = ValID::create(ConstantVector::get(pt, Elems));
|
||||
delete PTy; delete $2;
|
||||
}
|
||||
| ConstExpr {
|
||||
$$ = ValID::create($1.C, $1.S);
|
||||
$$ = ValID::create($1.C);
|
||||
}
|
||||
| ASM_TOK OptSideEffect STRINGCONSTANT ',' STRINGCONSTANT {
|
||||
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
|
||||
: INTVAL { $$ = ValID::create($1,Signless); }
|
||||
| Name { $$ = ValID::create($1,Signless); }
|
||||
: INTVAL { $$ = ValID::create($1); }
|
||||
| Name { $$ = ValID::create($1); }
|
||||
;
|
||||
|
||||
// ValueRef - A reference to a definition... either constant or symbolic
|
||||
@ -2888,9 +2854,8 @@ ValueRef
|
||||
ResolvedVal
|
||||
: Types ValueRef {
|
||||
const Type *Ty = $1.PAT->get();
|
||||
$2.S = $1.S;
|
||||
$$.V = getVal(Ty, $2);
|
||||
$$.S = $1.S;
|
||||
$$.V = getVal(Ty, $2);
|
||||
delete $1.PAT;
|
||||
}
|
||||
;
|
||||
@ -2909,8 +2874,7 @@ BasicBlockList
|
||||
//
|
||||
BasicBlock
|
||||
: InstructionList OptAssign BBTerminatorInst {
|
||||
ValueInfo VI; VI.V = $3; VI.S = Signless;
|
||||
setValueName(VI, $2);
|
||||
setValueName($3, $2);
|
||||
InsertValue($3);
|
||||
$1->getInstList().push_back($3);
|
||||
InsertValue($1);
|
||||
@ -2925,7 +2889,7 @@ InstructionList
|
||||
$$ = $1;
|
||||
}
|
||||
| /* 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
|
||||
// function, instead of leaving it inserted wherever it was first
|
||||
// referenced.
|
||||
@ -2934,7 +2898,7 @@ InstructionList
|
||||
BBL.splice(BBL.end(), BBL, $$);
|
||||
}
|
||||
| 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
|
||||
// function, instead of leaving it inserted wherever it was first
|
||||
// referenced.
|
||||
@ -2964,7 +2928,6 @@ BBTerminatorInst
|
||||
$$ = new BranchInst(tmpBBA, tmpBBB, tmpVal);
|
||||
}
|
||||
| SWITCH IntType ValueRef ',' LABEL ValueRef '[' JumpTable ']' {
|
||||
$3.S = $2.S;
|
||||
Value* tmpVal = getVal($2.T, $3);
|
||||
BasicBlock* tmpBB = getBBVal($6);
|
||||
SwitchInst *S = new SwitchInst(tmpVal, tmpBB, $8->size());
|
||||
@ -2980,7 +2943,6 @@ BBTerminatorInst
|
||||
delete $8;
|
||||
}
|
||||
| SWITCH IntType ValueRef ',' LABEL ValueRef '[' ']' {
|
||||
$3.S = $2.S;
|
||||
Value* tmpVal = getVal($2.T, $3);
|
||||
BasicBlock* tmpBB = getBBVal($6);
|
||||
SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
|
||||
@ -3053,7 +3015,6 @@ BBTerminatorInst
|
||||
JumpTable
|
||||
: JumpTable IntType ConstValueRef ',' LABEL ValueRef {
|
||||
$$ = $1;
|
||||
$3.S = $2.S;
|
||||
Constant *V = cast<Constant>(getExistingValue($2.T, $3));
|
||||
|
||||
if (V == 0)
|
||||
@ -3064,7 +3025,6 @@ JumpTable
|
||||
}
|
||||
| IntType ConstValueRef ',' LABEL ValueRef {
|
||||
$$ = new std::vector<std::pair<Constant*, BasicBlock*> >();
|
||||
$2.S = $1.S;
|
||||
Constant *V = cast<Constant>(getExistingValue($1.T, $2));
|
||||
|
||||
if (V == 0)
|
||||
@ -3099,8 +3059,7 @@ Inst
|
||||
$$.I = 0;
|
||||
$$.S = Signless;
|
||||
} else {
|
||||
ValueInfo VI; VI.V = $2.I; VI.S = $2.S;
|
||||
setValueName(VI, $1);
|
||||
setValueName($2.I, $1);
|
||||
InsertValue($2.I);
|
||||
$$ = $2;
|
||||
}
|
||||
@ -3109,7 +3068,6 @@ Inst
|
||||
PHIList : Types '[' ValueRef ',' ValueRef ']' { // Used for PHI nodes
|
||||
$$.P = new std::list<std::pair<Value*, BasicBlock*> >();
|
||||
$$.S = $1.S;
|
||||
$3.S = $1.S;
|
||||
Value* tmpVal = getVal($1.PAT->get(), $3);
|
||||
BasicBlock* tmpBB = getBBVal($5);
|
||||
$$.P->push_back(std::make_pair(tmpVal, tmpBB));
|
||||
@ -3117,7 +3075,6 @@ PHIList : Types '[' ValueRef ',' ValueRef ']' { // Used for PHI nodes
|
||||
}
|
||||
| PHIList ',' '[' ValueRef ',' ValueRef ']' {
|
||||
$$ = $1;
|
||||
$4.S = $1.S;
|
||||
Value* tmpVal = getVal($1.P->front().first->getType(), $4);
|
||||
BasicBlock* tmpBB = getBBVal($6);
|
||||
$1.P->push_back(std::make_pair(tmpVal, tmpBB));
|
||||
@ -3150,7 +3107,6 @@ OptTailCall
|
||||
|
||||
InstVal
|
||||
: ArithmeticOps Types ValueRef ',' ValueRef {
|
||||
$3.S = $5.S = $2.S;
|
||||
const Type* Ty = $2.PAT->get();
|
||||
if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<VectorType>(Ty))
|
||||
error("Arithmetic operator requires integer, FP, or packed operands");
|
||||
@ -3168,7 +3124,6 @@ InstVal
|
||||
delete $2.PAT;
|
||||
}
|
||||
| LogicalOps Types ValueRef ',' ValueRef {
|
||||
$3.S = $5.S = $2.S;
|
||||
const Type *Ty = $2.PAT->get();
|
||||
if (!Ty->isInteger()) {
|
||||
if (!isa<VectorType>(Ty) ||
|
||||
@ -3185,7 +3140,6 @@ InstVal
|
||||
delete $2.PAT;
|
||||
}
|
||||
| SetCondOps Types ValueRef ',' ValueRef {
|
||||
$3.S = $5.S = $2.S;
|
||||
const Type* Ty = $2.PAT->get();
|
||||
if(isa<VectorType>(Ty))
|
||||
error("VectorTypes currently not supported in setcc instructions");
|
||||
@ -3200,7 +3154,6 @@ InstVal
|
||||
delete $2.PAT;
|
||||
}
|
||||
| ICMP IPredicates Types ValueRef ',' ValueRef {
|
||||
$4.S = $6.S = $3.S;
|
||||
const Type *Ty = $3.PAT->get();
|
||||
if (isa<VectorType>(Ty))
|
||||
error("VectorTypes currently not supported in icmp instructions");
|
||||
@ -3213,7 +3166,6 @@ InstVal
|
||||
delete $3.PAT;
|
||||
}
|
||||
| FCMP FPredicates Types ValueRef ',' ValueRef {
|
||||
$4.S = $6.S = $3.S;
|
||||
const Type *Ty = $3.PAT->get();
|
||||
if (isa<VectorType>(Ty))
|
||||
error("VectorTypes currently not supported in fcmp instructions");
|
||||
@ -3359,6 +3311,7 @@ InstVal
|
||||
delete $2.P; // Free the list...
|
||||
}
|
||||
| OptTailCall OptCallingConv TypesV ValueRef '(' ValueRefListE ')' {
|
||||
|
||||
// Handle the short call syntax
|
||||
const PointerType *PFTy;
|
||||
const FunctionType *FTy;
|
||||
@ -3462,7 +3415,6 @@ MemoryInst
|
||||
| MALLOC Types ',' UINT ValueRef OptCAlign {
|
||||
const Type *Ty = $2.PAT->get();
|
||||
$$.S = $2.S;
|
||||
$5.S = Unsigned;
|
||||
$$.I = new MallocInst(Ty, getVal($4.T, $5), $6);
|
||||
delete $2.PAT;
|
||||
}
|
||||
@ -3475,7 +3427,6 @@ MemoryInst
|
||||
| ALLOCA Types ',' UINT ValueRef OptCAlign {
|
||||
const Type *Ty = $2.PAT->get();
|
||||
$$.S = $2.S;
|
||||
$5.S = Unsigned;
|
||||
$$.I = new AllocaInst(Ty, getVal($4.T, $5), $6);
|
||||
delete $2.PAT;
|
||||
}
|
||||
@ -3489,7 +3440,6 @@ MemoryInst
|
||||
| OptVolatile LOAD Types ValueRef {
|
||||
const Type* Ty = $3.PAT->get();
|
||||
$$.S = $3.S;
|
||||
$4.S = $3.S;
|
||||
if (!isa<PointerType>(Ty))
|
||||
error("Can't load from nonpointer type: " + Ty->getDescription());
|
||||
if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType())
|
||||
@ -3500,7 +3450,6 @@ MemoryInst
|
||||
delete $3.PAT;
|
||||
}
|
||||
| OptVolatile STORE ResolvedVal ',' Types ValueRef {
|
||||
$6.S = $5.S;
|
||||
const PointerType *PTy = dyn_cast<PointerType>($5.PAT->get());
|
||||
if (!PTy)
|
||||
error("Can't store to a nonpointer type: " +
|
||||
@ -3526,7 +3475,6 @@ MemoryInst
|
||||
delete $5.PAT;
|
||||
}
|
||||
| GETELEMENTPTR Types ValueRef IndexList {
|
||||
$3.S = $2.S;
|
||||
const Type* Ty = $2.PAT->get();
|
||||
if (!isa<PointerType>(Ty))
|
||||
error("getelementptr insn requires pointer operand");
|
||||
|
Loading…
Reference in New Issue
Block a user