last entry stored in the map could be retrieved for a given integer type.
Propagating the sign information required an invasive change to ensure that
all ValueRef (ValID) instances get the right sign information as well. Also,
put in some assertions to ensure the RenameMap always gives us out the type
that is expected.
This fixes PR1256 and
test/Assembler/2007-03-14-UgpradeLocalSignless.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35112
91177308-0d34-0410-b5e6-
96231b3b80d8
//
typedef std::vector<Value *> ValueList; // Numbered defs
//
typedef std::vector<Value *> ValueList; // Numbered defs
-typedef std::pair<std::string,const Type*> RenameMapKey;
+typedef std::pair<std::string,TypeInfo> RenameMapKey;
typedef std::map<RenameMapKey,std::string> RenameMapType;
static void
typedef std::map<RenameMapKey,std::string> RenameMapType;
static void
+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
// 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 returns V if it occurs and 0 otherwise.
+// situation and bitcasts the function to the correct type.
static Value* handleSRetFuncTypeMerge(Value *V, const Type* Ty) {
// Handle degenerate cases
if (!V)
static Value* handleSRetFuncTypeMerge(Value *V, const Type* Ty) {
// Handle degenerate cases
if (!V)
const PointerType *PF1 = dyn_cast<PointerType>(Ty);
const PointerType *PF2 = dyn_cast<PointerType>(V->getType());
if (PF1 && PF2) {
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;
if (FT1 && FT2 && FuncTysDifferOnlyBySRet(FT1, FT2))
if (FT2->paramHasAttr(1, FunctionType::StructRetAttribute))
Result = V;
// Get the name out of the ID
std::string Name(D.Name);
Value* V = 0;
// Get the name out of the ID
std::string Name(D.Name);
Value* V = 0;
- RenameMapKey Key = std::make_pair(Name, Ty);
+ TypeInfo TI; TI.T = Ty; TI.S = D.S;
+ RenameMapKey Key = std::make_pair(Name, TI);
if (inFunctionScope()) {
// See if the name was renamed
RenameMapType::const_iterator I = CurFun.RenameMap.find(Key);
if (inFunctionScope()) {
// See if the name was renamed
RenameMapType::const_iterator I = CurFun.RenameMap.find(Key);
ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
V = SymTab.lookup(LookupName);
V = handleSRetFuncTypeMerge(V, Ty);
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);
}
if (!V) {
RenameMapType::const_iterator I = CurModule.RenameMap.find(Key);
LookupName = Name;
V = CurModule.CurrentModule->getValueSymbolTable().lookup(LookupName);
V = handleSRetFuncTypeMerge(V, Ty);
LookupName = Name;
V = CurModule.CurrentModule->getValueSymbolTable().lookup(LookupName);
V = handleSRetFuncTypeMerge(V, Ty);
+ assert((!V || TypesDifferOnlyBySRet(V, Ty)) && "Found wrong type!");
// 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.
// 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.
- RenameMapKey Key = std::make_pair(N->getName(),N->getType());
+ TypeInfo TI; TI.T = N->getType(); TI.S = ID.S;
+ RenameMapKey Key = std::make_pair(N->getName(),TI);
N->setName(makeNameUnique(N->getName()));
CurModule.RenameMap[Key] = N->getName();
BB = 0;
N->setName(makeNameUnique(N->getName()));
CurModule.RenameMap[Key] = N->getName();
BB = 0;
// name is not null) things referencing Name can be resolved. Otherwise, things
// refering to the number can be resolved. Do this now.
//
// 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) {
+static void ResolveTypeTo(char *Name, const Type *ToTy, Signedness Sign) {
- if (Name) D = ValID::create(Name);
- else D = ValID::create((int)CurModule.Types.size());
+ if (Name)
+ D = ValID::create(Name, Sign);
+ else
+ D = ValID::create((int)CurModule.Types.size(), Sign);
std::map<ValID, PATypeHolder>::iterator I =
CurModule.LateResolveTypes.find(D);
std::map<ValID, PATypeHolder>::iterator I =
CurModule.LateResolveTypes.find(D);
// 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.
//
// 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(Value *V, char *NameStr) {
+static void setValueName(const ValueInfo &V, char *NameStr) {
if (NameStr) {
std::string Name(NameStr); // Copy string
free(NameStr); // Free old string
if (NameStr) {
std::string Name(NameStr); // Copy string
free(NameStr); // Free old string
- if (V->getType() == Type::VoidTy) {
+ if (V.V->getType() == Type::VoidTy) {
error("Can't assign name '" + Name + "' to value with void type");
return;
}
error("Can't assign name '" + Name + "' to value with void type");
return;
}
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) {
// 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->getType() &&
+ if (Existing->getType() == V.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 '" +
!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->getType()->getDescription() + "'");
+ V.V->getType()->getDescription() + "'");
return;
}
// In LLVM 2.0 we don't allow names to be re-used for any values in a
return;
}
// In LLVM 2.0 we don't allow names to be re-used for any values in a
// 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.
// 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.
- RenameMapKey Key = std::make_pair(Name,V->getType());
+ TypeInfo TI;
+ TI.T = V.V->getType();
+ TI.S = V.S;
+ RenameMapKey Key = std::make_pair(Name,TI);
CurFun.RenameMap[Key] = NewName;
Name = NewName;
}
// Set the name.
CurFun.RenameMap[Key] = NewName;
Name = NewName;
}
// Set the name.
static GlobalVariable *
ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
bool isConstantGlobal, const Type *Ty,
static GlobalVariable *
ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
bool isConstantGlobal, const Type *Ty,
- Constant *Initializer) {
+ Constant *Initializer,
+ Signedness Sign) {
if (isa<FunctionType>(Ty))
error("Cannot declare global vars of function type");
if (isa<FunctionType>(Ty))
error("Cannot declare global vars of function type");
// object.
ValID ID;
if (!Name.empty()) {
// object.
ValID ID;
if (!Name.empty()) {
- ID = ValID::create((char*)Name.c_str());
+ ID = ValID::create((char*)Name.c_str(), Sign);
- ID = ValID::create((int)CurModule.Values[PTy].size());
+ ID = ValID::create((int)CurModule.Values[PTy].size(), Sign);
}
if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
}
if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
}
// Put the renaming in the global rename map
}
// Put the renaming in the global rename map
- RenameMapKey Key = std::make_pair(Name,PointerType::get(Ty));
+ TypeInfo TI; TI.T = PointerType::get(Ty); TI.S = Signless;
+ RenameMapKey Key = std::make_pair(Name,TI);
CurModule.RenameMap[Key] = NewName;
// Rename it
CurModule.RenameMap[Key] = NewName;
// Rename it
| SymbolicValueRef { // Named types are also simple types...
const Type* tmp = getType($1);
$$.PAT = new PATypeHolder(tmp);
| SymbolicValueRef { // Named types are also simple types...
const Type* tmp = getType($1);
$$.PAT = new PATypeHolder(tmp);
- $$.S = Signless; // FIXME: what if its signed?
+ $$.S = $1.S; // FIXME: what if its signed?
}
| '\\' EUINT64VAL { // Type UpReference
if ($2 > (uint64_t)~0U)
}
| '\\' EUINT64VAL { // Type UpReference
if ($2 > (uint64_t)~0U)
// determined to be the same type!
//
const Type* Ty = $4.PAT->get();
// determined to be the same type!
//
const Type* Ty = $4.PAT->get();
+ ResolveTypeTo($2, Ty, $4.S);
if (!setTypeName(Ty, $2) && !$2) {
// If this is a named type that is not a redefinition, add it to the slot
if (!setTypeName(Ty, $2) && !$2) {
// If this is a named type that is not a redefinition, add it to the slot
| ConstPool OptAssign OptLinkage GlobalType ConstVal {
if ($5.C == 0)
error("Global value initializer is not a constant");
| 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);
+ CurGV = ParseGlobalVariable($2, $3, $4, $5.C->getType(), $5.C, $5.S);
} GlobalVarAttributes {
CurGV = 0;
}
| ConstPool OptAssign EXTERNAL GlobalType Types {
const Type *Ty = $5.PAT->get();
} GlobalVarAttributes {
CurGV = 0;
}
| ConstPool OptAssign EXTERNAL GlobalType Types {
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;
} GlobalVarAttributes {
CurGV = 0;
}
| ConstPool OptAssign DLLIMPORT GlobalType Types {
const Type *Ty = $5.PAT->get();
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);
+ CurGV = ParseGlobalVariable($2, GlobalValue::DLLImportLinkage, $4, Ty, 0,
+ $5.S);
delete $5.PAT;
} GlobalVarAttributes {
CurGV = 0;
delete $5.PAT;
} GlobalVarAttributes {
CurGV = 0;
| ConstPool OptAssign EXTERN_WEAK GlobalType Types {
const Type *Ty = $5.PAT->get();
CurGV =
| ConstPool OptAssign EXTERN_WEAK GlobalType Types {
const Type *Ty = $5.PAT->get();
CurGV =
- ParseGlobalVariable($2, GlobalValue::ExternalWeakLinkage, $4, Ty, 0);
+ ParseGlobalVariable($2, GlobalValue::ExternalWeakLinkage, $4, Ty, 0,
+ $5.S);
delete $5.PAT;
} GlobalVarAttributes {
CurGV = 0;
delete $5.PAT;
} GlobalVarAttributes {
CurGV = 0;
ValID ID;
if (!FunctionName.empty()) {
ValID ID;
if (!FunctionName.empty()) {
- ID = ValID::create((char*)FunctionName.c_str());
+ ID = ValID::create((char*)FunctionName.c_str(), $2.S);
- ID = ValID::create((int)CurModule.Values[PFT].size());
+ ID = ValID::create((int)CurModule.Values[PFT].size(), $2.S);
std::string NewName(makeNameUnique(FunctionName));
if (Conflict->hasInternalLinkage()) {
Conflict->setName(NewName);
std::string NewName(makeNameUnique(FunctionName));
if (Conflict->hasInternalLinkage()) {
Conflict->setName(NewName);
- RenameMapKey Key = std::make_pair(FunctionName,Conflict->getType());
+ TypeInfo TI; TI.T = Conflict->getType(); TI.S = ID.S;
+ RenameMapKey Key = std::make_pair(FunctionName,TI);
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);
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);
- RenameMapKey Key = std::make_pair(FunctionName,PFT);
+ TypeInfo TI; TI.T = PFT; TI.S = ID.S;
+ RenameMapKey Key = std::make_pair(FunctionName,TI);
CurModule.RenameMap[Key] = NewName;
}
} else {
CurModule.RenameMap[Key] = NewName;
}
} else {
if (Conflict->hasInternalLinkage()) {
// We can safely renamed the Conflict.
Conflict->setName(makeNameUnique(Conflict->getName()));
if (Conflict->hasInternalLinkage()) {
// We can safely renamed the Conflict.
Conflict->setName(makeNameUnique(Conflict->getName()));
- RenameMapKey Key = std::make_pair(FunctionName,Conflict->getType());
+ TypeInfo TI; TI.T = Conflict->getType(); TI.S = ID.S;
+ RenameMapKey Key = std::make_pair(FunctionName,TI);
CurModule.RenameMap[Key] = Conflict->getName();
Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
InsertValue(Fn, CurModule.Values);
CurModule.RenameMap[Key] = Conflict->getName();
Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
InsertValue(Fn, CurModule.Values);
std::string NewName = makeNameUnique(FunctionName);
Fn = new Function(FT, CurFun.Linkage, NewName, M);
InsertValue(Fn, CurModule.Values);
std::string NewName = makeNameUnique(FunctionName);
Fn = new Function(FT, CurFun.Linkage, NewName, M);
InsertValue(Fn, CurModule.Values);
- RenameMapKey Key = std::make_pair(FunctionName,PFT);
+ TypeInfo TI; TI.T = PFT; TI.S = ID.S;
+ RenameMapKey Key = std::make_pair(FunctionName,TI);
CurModule.RenameMap[Key] = NewName;
} else {
// We can't quietly rename either of these things, but we must
CurModule.RenameMap[Key] = NewName;
} else {
// We can't quietly rename either of these things, but we must
"' may cause linkage errors");
Fn = new Function(FT, CurFun.Linkage, NewName, M);
InsertValue(Fn, CurModule.Values);
"' may cause linkage errors");
Fn = new Function(FT, CurFun.Linkage, NewName, M);
InsertValue(Fn, CurModule.Values);
- RenameMapKey Key = std::make_pair(FunctionName,PFT);
+ TypeInfo TI; TI.T = PFT; TI.S = ID.S;
+ RenameMapKey Key = std::make_pair(FunctionName,TI);
CurModule.RenameMap[Key] = NewName;
}
} else {
CurModule.RenameMap[Key] = NewName;
}
} else {
std::vector<std::pair<PATypeInfo,char*> >::iterator E = $5->end();
for ( ; I != E && ArgIt != ArgEnd; ++I, ++ArgIt) {
delete I->first.PAT; // Delete the typeholder...
std::vector<std::pair<PATypeInfo,char*> >::iterator E = $5->end();
for ( ; I != E && ArgIt != ArgEnd; ++I, ++ArgIt) {
delete I->first.PAT; // Delete the typeholder...
- setValueName(ArgIt, I->second); // Insert arg into symtab...
+ ValueInfo VI; VI.V = ArgIt; VI.S = Signless; // FIXME: Sign
+ setValueName(VI, I->second); // Insert arg into symtab...
InsertValue(ArgIt);
}
delete $5; // We're now done with the argument list
InsertValue(ArgIt);
}
delete $5; // We're now done with the argument list
: ESINT64VAL { $$ = ValID::create($1); }
| EUINT64VAL { $$ = ValID::create($1); }
| FPVAL { $$ = ValID::create($1); }
: ESINT64VAL { $$ = ValID::create($1); }
| EUINT64VAL { $$ = ValID::create($1); }
| FPVAL { $$ = ValID::create($1); }
- | TRUETOK { $$ = ValID::create(ConstantInt::get(Type::Int1Ty, true)); }
- | FALSETOK { $$ = ValID::create(ConstantInt::get(Type::Int1Ty, false)); }
+ | TRUETOK {
+ $$ = ValID::create(ConstantInt::get(Type::Int1Ty, true), Signed);
+ }
+ | FALSETOK {
+ $$ = ValID::create(ConstantInt::get(Type::Int1Ty, false), Unsigned);
+ }
| NULL_TOK { $$ = ValID::createNull(); }
| UNDEF { $$ = ValID::createUndef(); }
| ZEROINITIALIZER { $$ = ValID::createZeroInit(); }
| NULL_TOK { $$ = ValID::createNull(); }
| UNDEF { $$ = ValID::createUndef(); }
| ZEROINITIALIZER { $$ = ValID::createZeroInit(); }
CTy->getDescription() + "'");
Elems.push_back(C);
}
CTy->getDescription() + "'");
Elems.push_back(C);
}
- $$ = ValID::create(ConstantVector::get(pt, Elems));
+ $$ = ValID::create(ConstantVector::get(pt, Elems), Signless);
delete PTy; delete $2;
}
| ConstExpr {
delete PTy; delete $2;
}
| ConstExpr {
- $$ = ValID::create($1.C);
+ $$ = ValID::create($1.C, $1.S);
}
| ASM_TOK OptSideEffect STRINGCONSTANT ',' STRINGCONSTANT {
char *End = UnEscapeLexed($3, true);
}
| ASM_TOK OptSideEffect STRINGCONSTANT ',' STRINGCONSTANT {
char *End = UnEscapeLexed($3, true);
-// 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.
- : INTVAL { $$ = ValID::create($1); }
- | Name { $$ = ValID::create($1); }
+ : INTVAL { $$ = ValID::create($1,Signless); }
+ | Name { $$ = ValID::create($1,Signless); }
;
// ValueRef - A reference to a definition... either constant or symbolic
;
// ValueRef - A reference to a definition... either constant or symbolic
ResolvedVal
: Types ValueRef {
const Type *Ty = $1.PAT->get();
ResolvedVal
: Types ValueRef {
const Type *Ty = $1.PAT->get();
//
BasicBlock
: InstructionList OptAssign BBTerminatorInst {
//
BasicBlock
: InstructionList OptAssign BBTerminatorInst {
+ ValueInfo VI; VI.V = $3; VI.S = Signless;
+ setValueName(VI, $2);
InsertValue($3);
$1->getInstList().push_back($3);
InsertValue($1);
InsertValue($3);
$1->getInstList().push_back($3);
InsertValue($1);
$$ = $1;
}
| /* empty */ {
$$ = $1;
}
| /* empty */ {
- $$ = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
+ $$ = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++,Signless),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.
// Make sure to move the basic block to the correct location in the
// function, instead of leaving it inserted wherever it was first
// referenced.
BBL.splice(BBL.end(), BBL, $$);
}
| LABELSTR {
BBL.splice(BBL.end(), BBL, $$);
}
| LABELSTR {
- $$ = CurBB = getBBVal(ValID::create($1), true);
+ $$ = CurBB = getBBVal(ValID::create($1,Signless), 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.
// Make sure to move the basic block to the correct location in the
// function, instead of leaving it inserted wherever it was first
// referenced.
$$ = new BranchInst(tmpBBA, tmpBBB, tmpVal);
}
| SWITCH IntType ValueRef ',' LABEL ValueRef '[' JumpTable ']' {
$$ = new BranchInst(tmpBBA, tmpBBB, tmpVal);
}
| SWITCH IntType ValueRef ',' LABEL ValueRef '[' JumpTable ']' {
Value* tmpVal = getVal($2.T, $3);
BasicBlock* tmpBB = getBBVal($6);
SwitchInst *S = new SwitchInst(tmpVal, tmpBB, $8->size());
Value* tmpVal = getVal($2.T, $3);
BasicBlock* tmpBB = getBBVal($6);
SwitchInst *S = new SwitchInst(tmpVal, tmpBB, $8->size());
delete $8;
}
| SWITCH IntType ValueRef ',' LABEL ValueRef '[' ']' {
delete $8;
}
| SWITCH IntType ValueRef ',' LABEL ValueRef '[' ']' {
Value* tmpVal = getVal($2.T, $3);
BasicBlock* tmpBB = getBBVal($6);
SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Value* tmpVal = getVal($2.T, $3);
BasicBlock* tmpBB = getBBVal($6);
SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
JumpTable
: JumpTable IntType ConstValueRef ',' LABEL ValueRef {
$$ = $1;
JumpTable
: JumpTable IntType ConstValueRef ',' LABEL ValueRef {
$$ = $1;
Constant *V = cast<Constant>(getExistingValue($2.T, $3));
if (V == 0)
Constant *V = cast<Constant>(getExistingValue($2.T, $3));
if (V == 0)
}
| IntType ConstValueRef ',' LABEL ValueRef {
$$ = new std::vector<std::pair<Constant*, BasicBlock*> >();
}
| IntType ConstValueRef ',' LABEL ValueRef {
$$ = new std::vector<std::pair<Constant*, BasicBlock*> >();
Constant *V = cast<Constant>(getExistingValue($1.T, $2));
if (V == 0)
Constant *V = cast<Constant>(getExistingValue($1.T, $2));
if (V == 0)
$$.I = 0;
$$.S = Signless;
} else {
$$.I = 0;
$$.S = Signless;
} else {
- setValueName($2.I, $1);
+ ValueInfo VI; VI.V = $2.I; VI.S = $2.S;
+ setValueName(VI, $1);
InsertValue($2.I);
$$ = $2;
}
InsertValue($2.I);
$$ = $2;
}
PHIList : Types '[' ValueRef ',' ValueRef ']' { // Used for PHI nodes
$$.P = new std::list<std::pair<Value*, BasicBlock*> >();
$$.S = $1.S;
PHIList : Types '[' ValueRef ',' ValueRef ']' { // Used for PHI nodes
$$.P = new std::list<std::pair<Value*, BasicBlock*> >();
$$.S = $1.S;
Value* tmpVal = getVal($1.PAT->get(), $3);
BasicBlock* tmpBB = getBBVal($5);
$$.P->push_back(std::make_pair(tmpVal, tmpBB));
Value* tmpVal = getVal($1.PAT->get(), $3);
BasicBlock* tmpBB = getBBVal($5);
$$.P->push_back(std::make_pair(tmpVal, tmpBB));
}
| PHIList ',' '[' ValueRef ',' ValueRef ']' {
$$ = $1;
}
| PHIList ',' '[' ValueRef ',' ValueRef ']' {
$$ = $1;
Value* tmpVal = getVal($1.P->front().first->getType(), $4);
BasicBlock* tmpBB = getBBVal($6);
$1.P->push_back(std::make_pair(tmpVal, tmpBB));
Value* tmpVal = getVal($1.P->front().first->getType(), $4);
BasicBlock* tmpBB = getBBVal($6);
$1.P->push_back(std::make_pair(tmpVal, tmpBB));
InstVal
: ArithmeticOps Types ValueRef ',' ValueRef {
InstVal
: ArithmeticOps Types ValueRef ',' ValueRef {
const Type* Ty = $2.PAT->get();
if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<VectorType>(Ty))
error("Arithmetic operator requires integer, FP, or packed operands");
const Type* Ty = $2.PAT->get();
if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<VectorType>(Ty))
error("Arithmetic operator requires integer, FP, or packed operands");
delete $2.PAT;
}
| LogicalOps Types ValueRef ',' ValueRef {
delete $2.PAT;
}
| LogicalOps Types ValueRef ',' ValueRef {
const Type *Ty = $2.PAT->get();
if (!Ty->isInteger()) {
if (!isa<VectorType>(Ty) ||
const Type *Ty = $2.PAT->get();
if (!Ty->isInteger()) {
if (!isa<VectorType>(Ty) ||
delete $2.PAT;
}
| SetCondOps Types ValueRef ',' ValueRef {
delete $2.PAT;
}
| SetCondOps Types ValueRef ',' ValueRef {
const Type* Ty = $2.PAT->get();
if(isa<VectorType>(Ty))
error("VectorTypes currently not supported in setcc instructions");
const Type* Ty = $2.PAT->get();
if(isa<VectorType>(Ty))
error("VectorTypes currently not supported in setcc instructions");
delete $2.PAT;
}
| ICMP IPredicates Types ValueRef ',' ValueRef {
delete $2.PAT;
}
| ICMP IPredicates Types ValueRef ',' ValueRef {
const Type *Ty = $3.PAT->get();
if (isa<VectorType>(Ty))
error("VectorTypes currently not supported in icmp instructions");
const Type *Ty = $3.PAT->get();
if (isa<VectorType>(Ty))
error("VectorTypes currently not supported in icmp instructions");
delete $3.PAT;
}
| FCMP FPredicates Types ValueRef ',' ValueRef {
delete $3.PAT;
}
| FCMP FPredicates Types ValueRef ',' ValueRef {
const Type *Ty = $3.PAT->get();
if (isa<VectorType>(Ty))
error("VectorTypes currently not supported in fcmp instructions");
const Type *Ty = $3.PAT->get();
if (isa<VectorType>(Ty))
error("VectorTypes currently not supported in fcmp instructions");
delete $2.P; // Free the list...
}
| OptTailCall OptCallingConv TypesV ValueRef '(' ValueRefListE ')' {
delete $2.P; // Free the list...
}
| OptTailCall OptCallingConv TypesV ValueRef '(' ValueRefListE ')' {
// Handle the short call syntax
const PointerType *PFTy;
const FunctionType *FTy;
// Handle the short call syntax
const PointerType *PFTy;
const FunctionType *FTy;
| MALLOC Types ',' UINT ValueRef OptCAlign {
const Type *Ty = $2.PAT->get();
$$.S = $2.S;
| MALLOC Types ',' UINT ValueRef OptCAlign {
const Type *Ty = $2.PAT->get();
$$.S = $2.S;
$$.I = new MallocInst(Ty, getVal($4.T, $5), $6);
delete $2.PAT;
}
$$.I = new MallocInst(Ty, getVal($4.T, $5), $6);
delete $2.PAT;
}
| ALLOCA Types ',' UINT ValueRef OptCAlign {
const Type *Ty = $2.PAT->get();
$$.S = $2.S;
| ALLOCA Types ',' UINT ValueRef OptCAlign {
const Type *Ty = $2.PAT->get();
$$.S = $2.S;
$$.I = new AllocaInst(Ty, getVal($4.T, $5), $6);
delete $2.PAT;
}
$$.I = new AllocaInst(Ty, getVal($4.T, $5), $6);
delete $2.PAT;
}
| OptVolatile LOAD Types ValueRef {
const Type* Ty = $3.PAT->get();
$$.S = $3.S;
| OptVolatile LOAD Types ValueRef {
const Type* Ty = $3.PAT->get();
$$.S = $3.S;
if (!isa<PointerType>(Ty))
error("Can't load from nonpointer type: " + Ty->getDescription());
if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType())
if (!isa<PointerType>(Ty))
error("Can't load from nonpointer type: " + Ty->getDescription());
if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType())
delete $3.PAT;
}
| OptVolatile STORE ResolvedVal ',' Types ValueRef {
delete $3.PAT;
}
| OptVolatile STORE ResolvedVal ',' Types ValueRef {
const PointerType *PTy = dyn_cast<PointerType>($5.PAT->get());
if (!PTy)
error("Can't store to a nonpointer type: " +
const PointerType *PTy = dyn_cast<PointerType>($5.PAT->get());
if (!PTy)
error("Can't store to a nonpointer type: " +
delete $5.PAT;
}
| GETELEMENTPTR Types ValueRef IndexList {
delete $5.PAT;
}
| GETELEMENTPTR Types ValueRef IndexList {
const Type* Ty = $2.PAT->get();
if (!isa<PointerType>(Ty))
error("getelementptr insn requires pointer operand");
const Type* Ty = $2.PAT->get();
if (!isa<PointerType>(Ty))
error("getelementptr insn requires pointer operand");