mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-22 13:29:44 +00:00
Remove the SignedType class and other dead code. Improve comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33538 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1ee2925742
commit
9373d272b2
@ -38,30 +38,6 @@ Module* UpgradeAssembly(const std::string &infile, std::istream& in,
|
|||||||
bool debug, bool addAttrs);
|
bool debug, bool addAttrs);
|
||||||
|
|
||||||
|
|
||||||
class SignedType : public IntegerType {
|
|
||||||
const IntegerType *base_type;
|
|
||||||
static SignedType *SByteTy;
|
|
||||||
static SignedType *SShortTy;
|
|
||||||
static SignedType *SIntTy;
|
|
||||||
static SignedType *SLongTy;
|
|
||||||
SignedType(const IntegerType* ITy);
|
|
||||||
public:
|
|
||||||
static const SignedType *get(const IntegerType* ITy);
|
|
||||||
|
|
||||||
bool isSigned() const { return true; }
|
|
||||||
const IntegerType* getBaseType() const {
|
|
||||||
return base_type;
|
|
||||||
}
|
|
||||||
const IntegerType* resolve() const {
|
|
||||||
ForwardType = base_type;
|
|
||||||
return base_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
|
||||||
static inline bool classof(const SignedType *T) { return true; }
|
|
||||||
static inline bool classof(const Type *T);
|
|
||||||
};
|
|
||||||
|
|
||||||
extern std::istream* LexInput;
|
extern std::istream* LexInput;
|
||||||
|
|
||||||
// UnEscapeLexed - Run through the specified buffer and change \xx codes to the
|
// UnEscapeLexed - Run through the specified buffer and change \xx codes to the
|
||||||
@ -206,14 +182,9 @@ struct ValID {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// The following enums are used to keep track of prior opcodes. The lexer will
|
||||||
// This structure is used to keep track of obsolete opcodes. The lexer will
|
/// retain the ability to parse obsolete opcode mnemonics and generates semantic
|
||||||
// retain the ability to parse obsolete opcode mnemonics. In this case it will
|
/// values containing one of these enumerators.
|
||||||
// set "obsolete" to true and the opcode will be the replacement opcode. For
|
|
||||||
// example if "rem" is encountered then opcode will be set to "urem" and the
|
|
||||||
// "obsolete" flag will be true. If the opcode is not obsolete then "obsolete"
|
|
||||||
// will be false.
|
|
||||||
|
|
||||||
enum TermOps {
|
enum TermOps {
|
||||||
RetOp, BrOp, SwitchOp, InvokeOp, UnwindOp, UnreachableOp
|
RetOp, BrOp, SwitchOp, InvokeOp, UnwindOp, UnreachableOp
|
||||||
};
|
};
|
||||||
@ -242,8 +213,14 @@ enum CastOps {
|
|||||||
UIToFPOp, SIToFPOp, PtrToIntOp, IntToPtrOp, BitCastOp
|
UIToFPOp, SIToFPOp, PtrToIntOp, IntToPtrOp, BitCastOp
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// 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 };
|
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
|
||||||
|
/// productions.
|
||||||
struct TypeInfo {
|
struct TypeInfo {
|
||||||
const llvm::Type *T;
|
const llvm::Type *T;
|
||||||
Signedness S;
|
Signedness S;
|
||||||
|
@ -48,132 +48,6 @@ static void warning(const std::string& WarningMsg);
|
|||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
|
|
||||||
SignedType *SignedType::SByteTy = 0;
|
|
||||||
SignedType *SignedType::SShortTy = 0;
|
|
||||||
SignedType *SignedType::SIntTy = 0;
|
|
||||||
SignedType *SignedType::SLongTy = 0;
|
|
||||||
|
|
||||||
inline bool SignedType::classof(const Type *T) {
|
|
||||||
if (T->getTypeID() != IntegerTyID)
|
|
||||||
return false;
|
|
||||||
return (T == SByteTy || T == SShortTy || T == SIntTy || T == SLongTy );
|
|
||||||
}
|
|
||||||
|
|
||||||
SignedType::SignedType(const IntegerType* ITy)
|
|
||||||
: IntegerType(ITy->getBitWidth()), base_type(ITy)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
const SignedType *SignedType::get(const IntegerType* ITy) {
|
|
||||||
if (ITy == Type::Int8Ty) {
|
|
||||||
if (!SByteTy)
|
|
||||||
SByteTy = new SignedType(IntegerType::get(8));
|
|
||||||
return SByteTy;
|
|
||||||
} else if (ITy == Type::Int16Ty) {
|
|
||||||
if (!SShortTy)
|
|
||||||
SShortTy = new SignedType(IntegerType::get(16));
|
|
||||||
return SShortTy;
|
|
||||||
} else if (ITy == Type::Int32Ty) {
|
|
||||||
if (!SIntTy)
|
|
||||||
SIntTy = new SignedType(IntegerType::get(32));
|
|
||||||
return SIntTy;
|
|
||||||
} else if (ITy == Type::Int64Ty) {
|
|
||||||
if (!SLongTy)
|
|
||||||
SLongTy = new SignedType(IntegerType::get(64));
|
|
||||||
return SLongTy;
|
|
||||||
} else
|
|
||||||
assert(0 && "Invalid integer type for SignedType::get");
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline Signedness getSign(const Type *&Ty) {
|
|
||||||
if (const SignedType *STy = dyn_cast<SignedType>(Ty)) {
|
|
||||||
Ty = STy->getBaseType();
|
|
||||||
return Signed;
|
|
||||||
} else if (isa<IntegerType>(Ty))
|
|
||||||
return Unsigned;
|
|
||||||
return Signless;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const Type*
|
|
||||||
resolveTypeImpl(const Type* Ty, std::vector<const Type*>& TyStack)
|
|
||||||
{
|
|
||||||
// Nothing to resolve if it isn't a derived type
|
|
||||||
if (!Ty->isDerivedType())
|
|
||||||
return Ty;
|
|
||||||
|
|
||||||
// Prevent infinite recursion for recursive types
|
|
||||||
for (std::vector<const Type*>::const_iterator I = TyStack.begin(),
|
|
||||||
E = TyStack.end(); I != E; ++I)
|
|
||||||
if (Ty == *I)
|
|
||||||
return Ty;
|
|
||||||
|
|
||||||
// Okay, haven't seen this derived type yet, push it on the stack.
|
|
||||||
const Type* Result = Ty;
|
|
||||||
TyStack.push_back(Ty);
|
|
||||||
|
|
||||||
// Process the type
|
|
||||||
switch (Ty->getTypeID()) {
|
|
||||||
default: assert(0 && "Invalid derived type");
|
|
||||||
case Type::IntegerTyID:
|
|
||||||
break;
|
|
||||||
case Type::FunctionTyID: {
|
|
||||||
const FunctionType* FTy = cast<FunctionType>(Ty);
|
|
||||||
const Type* RetTy = resolveTypeImpl(FTy->getReturnType(), TyStack);
|
|
||||||
std::vector<const Type*> Types;
|
|
||||||
FunctionType::ParamAttrsList Attrs;
|
|
||||||
Attrs.push_back(FTy->getParamAttrs(0));
|
|
||||||
for (unsigned i = 0; i < FTy->getNumParams(); ++i) {
|
|
||||||
Types.push_back(resolveTypeImpl(FTy->getParamType(i), TyStack));
|
|
||||||
Attrs.push_back(FTy->getParamAttrs(i+1));
|
|
||||||
}
|
|
||||||
Result = FunctionType::get(RetTy, Types, FTy->isVarArg(), Attrs);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Type::StructTyID:
|
|
||||||
case Type::PackedStructTyID: {
|
|
||||||
const StructType *STy = cast<StructType>(Ty);
|
|
||||||
std::vector<const Type*> FieldTypes;
|
|
||||||
for (unsigned i = 0; i < STy->getNumElements(); ++i)
|
|
||||||
FieldTypes.push_back(resolveTypeImpl(STy->getElementType(i), TyStack));
|
|
||||||
Result = StructType::get(FieldTypes, STy->isPacked());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Type::ArrayTyID: {
|
|
||||||
const ArrayType *ATy = cast<ArrayType>(Ty);
|
|
||||||
uint64_t NElems = ATy->getNumElements();
|
|
||||||
const Type *ElemTy = resolveTypeImpl(ATy->getElementType(), TyStack);
|
|
||||||
Result = ArrayType::get(ElemTy, NElems);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Type::PointerTyID: {
|
|
||||||
const PointerType *PTy = cast<PointerType>(Ty);
|
|
||||||
const Type *ElemTy = resolveTypeImpl(PTy->getElementType(), TyStack);
|
|
||||||
Result = PointerType::get(ElemTy);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Type::PackedTyID: {
|
|
||||||
const PackedType *PTy = cast<PackedType>(Ty);
|
|
||||||
unsigned NElems = PTy->getNumElements();
|
|
||||||
const Type *ElemTy = resolveTypeImpl(PTy->getElementType(), TyStack);
|
|
||||||
Result = PackedType::get(ElemTy, NElems);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Done with it, pop it off.
|
|
||||||
TyStack.pop_back();
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline const Type* resolveType(const Type* Ty) {
|
|
||||||
if (!Ty)
|
|
||||||
return 0;
|
|
||||||
if (const SignedType* STy = dyn_cast<SignedType>(Ty))
|
|
||||||
return STy->getBaseType();
|
|
||||||
std::vector<const Type*> TyStack;
|
|
||||||
return resolveTypeImpl(Ty, TyStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::istream* LexInput;
|
std::istream* LexInput;
|
||||||
static std::string CurFilename;
|
static std::string CurFilename;
|
||||||
|
|
||||||
@ -187,8 +61,6 @@ static bool NewVarArgs;
|
|||||||
static BasicBlock *CurBB;
|
static BasicBlock *CurBB;
|
||||||
static GlobalVariable *CurGV;
|
static GlobalVariable *CurGV;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// This contains info used when building the body of a function. It is
|
// This contains info used when building the body of a function. It is
|
||||||
// destroyed when the function is completed.
|
// destroyed when the function is completed.
|
||||||
//
|
//
|
||||||
@ -299,7 +171,6 @@ static struct PerFunctionInfo {
|
|||||||
std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
|
std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
|
||||||
std::vector<BasicBlock*> NumberedBlocks;
|
std::vector<BasicBlock*> NumberedBlocks;
|
||||||
RenameMapType RenameMap;
|
RenameMapType RenameMap;
|
||||||
std::set<Value*> SignedValues;
|
|
||||||
unsigned NextBBNum;
|
unsigned NextBBNum;
|
||||||
|
|
||||||
inline PerFunctionInfo() {
|
inline PerFunctionInfo() {
|
||||||
@ -328,7 +199,6 @@ static struct PerFunctionInfo {
|
|||||||
|
|
||||||
Values.clear(); // Clear out function local definitions
|
Values.clear(); // Clear out function local definitions
|
||||||
RenameMap.clear();
|
RenameMap.clear();
|
||||||
SignedValues.clear();
|
|
||||||
CurrentFunction = 0;
|
CurrentFunction = 0;
|
||||||
isDeclare = false;
|
isDeclare = false;
|
||||||
Linkage = GlobalValue::ExternalLinkage;
|
Linkage = GlobalValue::ExternalLinkage;
|
||||||
@ -352,7 +222,7 @@ static int InsertValue(Value *V,
|
|||||||
return List.size()-1;
|
return List.size()-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
|
static const Type *getType(const ValID &D, bool DoNotImprovise = false) {
|
||||||
switch (D.Type) {
|
switch (D.Type) {
|
||||||
case ValID::NumberVal: // Is it a numbered definition?
|
case ValID::NumberVal: // Is it a numbered definition?
|
||||||
// Module constants occupy the lowest numbered slots...
|
// Module constants occupy the lowest numbered slots...
|
||||||
@ -540,7 +410,6 @@ static Value *getVal(const Type *Ty, const ValID &ID) {
|
|||||||
// If we reached here, we referenced either a symbol that we don't know about
|
// If we reached here, we referenced either a symbol that we don't know about
|
||||||
// or an id number that hasn't been read yet. We may be referencing something
|
// or an id number that hasn't been read yet. We may be referencing something
|
||||||
// forward, so just create an entry to be resolved later and get to it...
|
// forward, so just create an entry to be resolved later and get to it...
|
||||||
assert(!isa<SignedType>(Ty) && "Can't create value with SignedType");
|
|
||||||
V = new Argument(Ty);
|
V = new Argument(Ty);
|
||||||
|
|
||||||
// Remember where this forward reference came from. FIXME, shouldn't we try
|
// Remember where this forward reference came from. FIXME, shouldn't we try
|
||||||
@ -722,7 +591,6 @@ static void setValueName(Value *V, char *NameStr) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(!isa<SignedType>(V->getType()) && "Shouldn't have SignedType Value");
|
|
||||||
assert(inFunctionScope() && "Must be in function scope");
|
assert(inFunctionScope() && "Must be in function scope");
|
||||||
|
|
||||||
// Search the function's symbol table for an existing value of this name
|
// Search the function's symbol table for an existing value of this name
|
||||||
@ -1532,6 +1400,7 @@ using namespace llvm;
|
|||||||
// ValueRef - Unresolved reference to a definition or BB
|
// ValueRef - Unresolved reference to a definition or BB
|
||||||
%type <ValIDVal> ValueRef ConstValueRef SymbolicValueRef
|
%type <ValIDVal> ValueRef ConstValueRef SymbolicValueRef
|
||||||
%type <ValueVal> ResolvedVal // <type> <valref> pair
|
%type <ValueVal> ResolvedVal // <type> <valref> pair
|
||||||
|
|
||||||
// Tokens and types for handling constant integer values
|
// Tokens and types for handling constant integer values
|
||||||
//
|
//
|
||||||
// ESINT64VAL - A negative number within long long range
|
// ESINT64VAL - A negative number within long long range
|
||||||
@ -1588,6 +1457,7 @@ using namespace llvm;
|
|||||||
%token <OtherOpVal> EXTRACTELEMENT INSERTELEMENT SHUFFLEVECTOR
|
%token <OtherOpVal> EXTRACTELEMENT INSERTELEMENT SHUFFLEVECTOR
|
||||||
%token VAARG_old VANEXT_old //OBSOLETE
|
%token VAARG_old VANEXT_old //OBSOLETE
|
||||||
|
|
||||||
|
// Support for ICmp/FCmp Predicates, which is 1.9++ but not 2.0
|
||||||
%type <IPred> IPredicates
|
%type <IPred> IPredicates
|
||||||
%type <FPred> FPredicates
|
%type <FPred> FPredicates
|
||||||
%token EQ NE SLT SGT SLE SGE ULT UGT ULE UGE
|
%token EQ NE SLT SGT SLE SGE ULT UGT ULE UGE
|
||||||
@ -1818,7 +1688,7 @@ UpRTypes
|
|||||||
$$.S = Signless;
|
$$.S = Signless;
|
||||||
}
|
}
|
||||||
| SymbolicValueRef { // Named types are also simple types...
|
| SymbolicValueRef { // Named types are also simple types...
|
||||||
const Type* tmp = getTypeVal($1);
|
const Type* tmp = getType($1);
|
||||||
$$.T = new PATypeHolder(tmp);
|
$$.T = new PATypeHolder(tmp);
|
||||||
$$.S = Signless; // FIXME: what if its signed?
|
$$.S = Signless; // FIXME: what if its signed?
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user