mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-06 05:33:28 +00:00
Fix bug with
%list = type {%list *} %list = type {%list *} not being accepted (broken testmisc.ll) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@935 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9245fc75a4
commit
4a42e909cd
@ -57,7 +57,8 @@ static struct PerModuleInfo {
|
|||||||
Module *CurrentModule;
|
Module *CurrentModule;
|
||||||
vector<ValueList> Values; // Module level numbered definitions
|
vector<ValueList> Values; // Module level numbered definitions
|
||||||
vector<ValueList> LateResolveValues;
|
vector<ValueList> LateResolveValues;
|
||||||
vector<PATypeHolder<Type> > Types, LateResolveTypes;
|
vector<PATypeHolder<Type> > Types;
|
||||||
|
map<ValID, PATypeHolder<Type> > LateResolveTypes;
|
||||||
|
|
||||||
// GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
|
// GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
|
||||||
// references to global values. Global values may be referenced before they
|
// references to global values. Global values may be referenced before they
|
||||||
@ -80,7 +81,8 @@ static struct PerModuleInfo {
|
|||||||
if (!GlobalRefs.empty()) {
|
if (!GlobalRefs.empty()) {
|
||||||
// TODO: Make this more detailed! Loop over each undef value and print
|
// TODO: Make this more detailed! Loop over each undef value and print
|
||||||
// info
|
// info
|
||||||
ThrowException("TODO: Make better error - Unresolved forward constant references exist!");
|
ThrowException("TODO: Make better error - Unresolved forward constant "
|
||||||
|
"references exist!");
|
||||||
}
|
}
|
||||||
|
|
||||||
Values.clear(); // Clear out method local definitions
|
Values.clear(); // Clear out method local definitions
|
||||||
@ -131,7 +133,8 @@ static struct PerMethodInfo {
|
|||||||
|
|
||||||
vector<ValueList> Values; // Keep track of numbered definitions
|
vector<ValueList> Values; // Keep track of numbered definitions
|
||||||
vector<ValueList> LateResolveValues;
|
vector<ValueList> LateResolveValues;
|
||||||
vector<PATypeHolder<Type> > Types, LateResolveTypes;
|
vector<PATypeHolder<Type> > Types;
|
||||||
|
map<ValID, PATypeHolder<Type> > LateResolveTypes;
|
||||||
bool isDeclare; // Is this method a forward declararation?
|
bool isDeclare; // Is this method a forward declararation?
|
||||||
|
|
||||||
inline PerMethodInfo() {
|
inline PerMethodInfo() {
|
||||||
@ -226,11 +229,16 @@ static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
|
|||||||
//
|
//
|
||||||
if (DoNotImprovise) return 0; // Do we just want a null to be returned?
|
if (DoNotImprovise) return 0; // Do we just want a null to be returned?
|
||||||
|
|
||||||
vector<PATypeHolder<Type> > *LateResolver = inMethodScope() ?
|
map<ValID, PATypeHolder<Type> > &LateResolver = inMethodScope() ?
|
||||||
&CurMeth.LateResolveTypes : &CurModule.LateResolveTypes;
|
CurMeth.LateResolveTypes : CurModule.LateResolveTypes;
|
||||||
|
|
||||||
|
map<ValID, PATypeHolder<Type> >::iterator I = LateResolver.find(D);
|
||||||
|
if (I != LateResolver.end()) {
|
||||||
|
return I->second;
|
||||||
|
}
|
||||||
|
|
||||||
Type *Typ = new TypePlaceHolder(Type::TypeTy, D);
|
Type *Typ = new TypePlaceHolder(Type::TypeTy, D);
|
||||||
InsertType(Typ, *LateResolver);
|
LateResolver.insert(make_pair(D, Typ));
|
||||||
return Typ;
|
return Typ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -438,27 +446,41 @@ static bool ResolveType(PATypeHolder<Type> &T) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ResolveTypeTo - A brand new type was just declared. This means that (if
|
||||||
// ResolveTypes - This goes through the forward referenced type table and makes
|
// name is not null) things referencing Name can be resolved. Otherwise, things
|
||||||
// sure that all type references are complete. This code is executed after the
|
// refering to the number can be resolved. Do this now.
|
||||||
// constant pool of a method or module is completely parsed.
|
|
||||||
//
|
//
|
||||||
static void ResolveTypes(vector<PATypeHolder<Type> > &LateResolveTypes) {
|
static void ResolveTypeTo(char *Name, const Type *ToTy) {
|
||||||
while (!LateResolveTypes.empty()) {
|
vector<PATypeHolder<Type> > &Types = inMethodScope ?
|
||||||
if (ResolveType(LateResolveTypes.back())) {
|
CurMeth.Types : CurModule.Types;
|
||||||
const Type *Ty = LateResolveTypes.back();
|
|
||||||
ValID &DID = getValIDFromPlaceHolder(Ty);
|
|
||||||
|
|
||||||
if (DID.Type == ValID::NameVal)
|
ValID D;
|
||||||
ThrowException("Reference to an invalid type: '" +DID.getName() + "'",
|
if (Name) D = ValID::create(Name);
|
||||||
getLineNumFromPlaceHolder(Ty));
|
else D = ValID::create((int)Types.size());
|
||||||
else
|
|
||||||
ThrowException("Reference to an invalid type: #" + itostr(DID.Num),
|
|
||||||
getLineNumFromPlaceHolder(Ty));
|
|
||||||
}
|
|
||||||
|
|
||||||
// No need to delete type, refine does that for us.
|
map<ValID, PATypeHolder<Type> > &LateResolver = inMethodScope() ?
|
||||||
LateResolveTypes.pop_back();
|
CurMeth.LateResolveTypes : CurModule.LateResolveTypes;
|
||||||
|
|
||||||
|
map<ValID, PATypeHolder<Type> >::iterator I = LateResolver.find(D);
|
||||||
|
if (I != LateResolver.end()) {
|
||||||
|
cast<DerivedType>(I->second.get())->refineAbstractTypeTo(ToTy);
|
||||||
|
LateResolver.erase(I);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResolveTypes - At this point, all types should be resolved. Any that aren't
|
||||||
|
// are errors.
|
||||||
|
//
|
||||||
|
static void ResolveTypes(map<ValID, PATypeHolder<Type> > &LateResolveTypes) {
|
||||||
|
if (!LateResolveTypes.empty()) {
|
||||||
|
ValID &DID = LateResolveTypes.begin()->first;
|
||||||
|
|
||||||
|
if (DID.Type == ValID::NameVal)
|
||||||
|
ThrowException("Reference to an invalid type: '" +DID.getName() + "'",
|
||||||
|
getLineNumFromPlaceHolder(Ty));
|
||||||
|
else
|
||||||
|
ThrowException("Reference to an invalid type: #" + itostr(DID.Num),
|
||||||
|
getLineNumFromPlaceHolder(Ty));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1019,6 +1041,17 @@ ConstPool : ConstPool OptAssign CONST ConstVal {
|
|||||||
InsertValue($4);
|
InsertValue($4);
|
||||||
}
|
}
|
||||||
| ConstPool OptAssign TYPE TypesV { // Types can be defined in the const pool
|
| ConstPool OptAssign TYPE TypesV { // Types can be defined in the const pool
|
||||||
|
// Eagerly resolve types. This is not an optimization, this is a
|
||||||
|
// requirement that is due to the fact that we could have this:
|
||||||
|
//
|
||||||
|
// %list = type { %list * }
|
||||||
|
// %list = type { %list * } ; repeated type decl
|
||||||
|
//
|
||||||
|
// If types are not resolved eagerly, then the two types will not be
|
||||||
|
// determined to be the same type!
|
||||||
|
//
|
||||||
|
ResolveTypeTo($2, $4->get());
|
||||||
|
|
||||||
// TODO: FIXME when Type are not const
|
// TODO: FIXME when Type are not const
|
||||||
if (!setValueName(const_cast<Type*>($4->get()), $2)) {
|
if (!setValueName(const_cast<Type*>($4->get()), $2)) {
|
||||||
// If this is not a redefinition of a type...
|
// If this is not a redefinition of a type...
|
||||||
|
Loading…
x
Reference in New Issue
Block a user