mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-19 03:24:09 +00:00
Get rid of using decls, finegrainify namespacification
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10137 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -19,11 +19,7 @@
|
|||||||
#include "llvm/Target/TargetData.h"
|
#include "llvm/Target/TargetData.h"
|
||||||
#include "llvm/DerivedTypes.h"
|
#include "llvm/DerivedTypes.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
using std::vector;
|
using namespace llvm;
|
||||||
using std::set;
|
|
||||||
using std::pair;
|
|
||||||
|
|
||||||
namespace llvm {
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct SimpleStructMutation : public MutateStructTypes {
|
struct SimpleStructMutation : public MutateStructTypes {
|
||||||
@ -76,8 +72,9 @@ Pass *createSortElementsPass() { return new SortStructElements(); }
|
|||||||
// PruneTypes - Given a type Ty, make sure that neither it, or one of its
|
// PruneTypes - Given a type Ty, make sure that neither it, or one of its
|
||||||
// subtypes, occur in TypesToModify.
|
// subtypes, occur in TypesToModify.
|
||||||
//
|
//
|
||||||
static void PruneTypes(const Type *Ty, set<const StructType*> &TypesToModify,
|
static void PruneTypes(const Type *Ty,
|
||||||
set<const Type*> &ProcessedTypes) {
|
std::set<const StructType*> &TypesToModify,
|
||||||
|
std::set<const Type*> &ProcessedTypes) {
|
||||||
if (ProcessedTypes.count(Ty)) return; // Already been checked
|
if (ProcessedTypes.count(Ty)) return; // Already been checked
|
||||||
ProcessedTypes.insert(Ty);
|
ProcessedTypes.insert(Ty);
|
||||||
|
|
||||||
@ -98,19 +95,19 @@ static void PruneTypes(const Type *Ty, set<const StructType*> &TypesToModify,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool FirstLess(const pair<unsigned, unsigned> &LHS,
|
static bool FirstLess(const std::pair<unsigned, unsigned> &LHS,
|
||||||
const pair<unsigned, unsigned> &RHS) {
|
const std::pair<unsigned, unsigned> &RHS) {
|
||||||
return LHS.second < RHS.second;
|
return LHS.second < RHS.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned getIndex(const vector<pair<unsigned, unsigned> > &Vec,
|
static unsigned getIndex(const std::vector<std::pair<unsigned, unsigned> > &Vec,
|
||||||
unsigned Field) {
|
unsigned Field) {
|
||||||
for (unsigned i = 0; ; ++i)
|
for (unsigned i = 0; ; ++i)
|
||||||
if (Vec[i].first == Field) return i;
|
if (Vec[i].first == Field) return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void GetTransformation(const TargetData &TD, const StructType *ST,
|
static inline void GetTransformation(const TargetData &TD, const StructType *ST,
|
||||||
vector<int> &Transform,
|
std::vector<int> &Transform,
|
||||||
enum SimpleStructMutation::Transform XForm) {
|
enum SimpleStructMutation::Transform XForm) {
|
||||||
unsigned NumElements = ST->getElementTypes().size();
|
unsigned NumElements = ST->getElementTypes().size();
|
||||||
Transform.reserve(NumElements);
|
Transform.reserve(NumElements);
|
||||||
@ -123,7 +120,7 @@ static inline void GetTransformation(const TargetData &TD, const StructType *ST,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SimpleStructMutation::SortElements: {
|
case SimpleStructMutation::SortElements: {
|
||||||
vector<pair<unsigned, unsigned> > ElList;
|
std::vector<std::pair<unsigned, unsigned> > ElList;
|
||||||
|
|
||||||
// Build mapping from index to size
|
// Build mapping from index to size
|
||||||
for (unsigned i = 0; i < NumElements; ++i)
|
for (unsigned i = 0; i < NumElements; ++i)
|
||||||
@ -148,17 +145,16 @@ SimpleStructMutation::TransformsType
|
|||||||
|
|
||||||
// Get the results out of the analyzers...
|
// Get the results out of the analyzers...
|
||||||
FindUsedTypes &FUT = getAnalysis<FindUsedTypes>();
|
FindUsedTypes &FUT = getAnalysis<FindUsedTypes>();
|
||||||
const set<const Type *> &UsedTypes = FUT.getTypes();
|
const std::set<const Type *> &UsedTypes = FUT.getTypes();
|
||||||
|
|
||||||
FindUnsafePointerTypes &FUPT = getAnalysis<FindUnsafePointerTypes>();
|
FindUnsafePointerTypes &FUPT = getAnalysis<FindUnsafePointerTypes>();
|
||||||
const set<PointerType*> &UnsafePTys = FUPT.getUnsafeTypes();
|
const std::set<PointerType*> &UnsafePTys = FUPT.getUnsafeTypes();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Combine the two sets, weeding out non structure types. Closures in C++
|
// Combine the two sets, weeding out non structure types. Closures in C++
|
||||||
// sure would be nice.
|
// sure would be nice.
|
||||||
set<const StructType*> TypesToModify;
|
std::set<const StructType*> TypesToModify;
|
||||||
for (set<const Type *>::const_iterator I = UsedTypes.begin(),
|
for (std::set<const Type *>::const_iterator I = UsedTypes.begin(),
|
||||||
E = UsedTypes.end(); I != E; ++I)
|
E = UsedTypes.end(); I != E; ++I)
|
||||||
if (const StructType *ST = dyn_cast<StructType>(*I))
|
if (const StructType *ST = dyn_cast<StructType>(*I))
|
||||||
TypesToModify.insert(ST);
|
TypesToModify.insert(ST);
|
||||||
@ -167,8 +163,8 @@ SimpleStructMutation::TransformsType
|
|||||||
// Go through the Unsafe types and remove all types from TypesToModify that we
|
// Go through the Unsafe types and remove all types from TypesToModify that we
|
||||||
// are not allowed to modify, because that would be unsafe.
|
// are not allowed to modify, because that would be unsafe.
|
||||||
//
|
//
|
||||||
set<const Type*> ProcessedTypes;
|
std::set<const Type*> ProcessedTypes;
|
||||||
for (set<PointerType*>::const_iterator I = UnsafePTys.begin(),
|
for (std::set<PointerType*>::const_iterator I = UnsafePTys.begin(),
|
||||||
E = UnsafePTys.end(); I != E; ++I) {
|
E = UnsafePTys.end(); I != E; ++I) {
|
||||||
//cerr << "Pruning type: " << *I << "\n";
|
//cerr << "Pruning type: " << *I << "\n";
|
||||||
PruneTypes(*I, TypesToModify, ProcessedTypes);
|
PruneTypes(*I, TypesToModify, ProcessedTypes);
|
||||||
@ -177,18 +173,17 @@ SimpleStructMutation::TransformsType
|
|||||||
|
|
||||||
// Build up a set of structure types that we are going to modify, and
|
// Build up a set of structure types that we are going to modify, and
|
||||||
// information describing how to modify them.
|
// information describing how to modify them.
|
||||||
std::map<const StructType*, vector<int> > Transforms;
|
std::map<const StructType*, std::vector<int> > Transforms;
|
||||||
TargetData &TD = getAnalysis<TargetData>();
|
TargetData &TD = getAnalysis<TargetData>();
|
||||||
|
|
||||||
for (set<const StructType*>::iterator I = TypesToModify.begin(),
|
for (std::set<const StructType*>::iterator I = TypesToModify.begin(),
|
||||||
E = TypesToModify.end(); I != E; ++I) {
|
E = TypesToModify.end(); I != E; ++I) {
|
||||||
const StructType *ST = *I;
|
const StructType *ST = *I;
|
||||||
|
|
||||||
vector<int> &Transform = Transforms[ST]; // Fill in the map directly
|
std::vector<int> &Transform = Transforms[ST]; // Fill in the map directly
|
||||||
GetTransformation(TD, ST, Transform, XForm);
|
GetTransformation(TD, ST, Transform, XForm);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Transforms;
|
return Transforms;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // End llvm namespace
|
|
||||||
|
Reference in New Issue
Block a user