mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-18 12:27:55 +00:00
- Eliminate the last traces of the 'analysis' namespace
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3550 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -15,8 +15,6 @@ class Type;
|
|||||||
class Value;
|
class Value;
|
||||||
class ConstantInt;
|
class ConstantInt;
|
||||||
|
|
||||||
namespace analysis {
|
|
||||||
|
|
||||||
struct ExprType;
|
struct ExprType;
|
||||||
|
|
||||||
// ClassifyExpression: Analyze an expression to determine the complexity of the
|
// ClassifyExpression: Analyze an expression to determine the complexity of the
|
||||||
@@ -52,6 +50,4 @@ struct ExprType {
|
|||||||
const Type *getExprType(const Type *Default) const;
|
const Type *getExprType(const Type *Default) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End namespace analysis
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -10,11 +10,6 @@
|
|||||||
#include "llvm/Analysis/Expressions.h"
|
#include "llvm/Analysis/Expressions.h"
|
||||||
#include "llvm/ConstantHandling.h"
|
#include "llvm/ConstantHandling.h"
|
||||||
#include "llvm/Function.h"
|
#include "llvm/Function.h"
|
||||||
#include "llvm/BasicBlock.h"
|
|
||||||
#include "llvm/Instruction.h"
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
using namespace analysis;
|
|
||||||
|
|
||||||
ExprType::ExprType(Value *Val) {
|
ExprType::ExprType(Value *Val) {
|
||||||
if (Val)
|
if (Val)
|
||||||
@@ -233,7 +228,7 @@ static inline ExprType negate(const ExprType &E, Value *V) {
|
|||||||
// Note that this analysis cannot get into infinite loops because it treats PHI
|
// Note that this analysis cannot get into infinite loops because it treats PHI
|
||||||
// nodes as being an unknown linear expression.
|
// nodes as being an unknown linear expression.
|
||||||
//
|
//
|
||||||
ExprType analysis::ClassifyExpression(Value *Expr) {
|
ExprType ClassifyExpression(Value *Expr) {
|
||||||
assert(Expr != 0 && "Can't classify a null expression!");
|
assert(Expr != 0 && "Can't classify a null expression!");
|
||||||
if (Expr->getType() == Type::FloatTy || Expr->getType() == Type::DoubleTy)
|
if (Expr->getType() == Type::FloatTy || Expr->getType() == Type::DoubleTy)
|
||||||
return Expr; // FIXME: Can't handle FP expressions
|
return Expr; // FIXME: Can't handle FP expressions
|
||||||
|
@@ -25,9 +25,6 @@
|
|||||||
#include "llvm/Constants.h"
|
#include "llvm/Constants.h"
|
||||||
#include "llvm/Assembly/Writer.h"
|
#include "llvm/Assembly/Writer.h"
|
||||||
|
|
||||||
using analysis::ExprType;
|
|
||||||
|
|
||||||
|
|
||||||
static bool isLoopInvariant(const Value *V, const Loop *L) {
|
static bool isLoopInvariant(const Value *V, const Loop *L) {
|
||||||
if (isa<Constant>(V) || isa<Argument>(V) || isa<GlobalValue>(V))
|
if (isa<Constant>(V) || isa<Argument>(V) || isa<GlobalValue>(V))
|
||||||
return true;
|
return true;
|
||||||
@@ -85,8 +82,8 @@ InductionVariable::InductionVariable(PHINode *P, LoopInfo *LoopInfo) {
|
|||||||
Value *V2 = Phi->getIncomingValue(1);
|
Value *V2 = Phi->getIncomingValue(1);
|
||||||
|
|
||||||
if (L == 0) { // No loop information? Base everything on expression analysis
|
if (L == 0) { // No loop information? Base everything on expression analysis
|
||||||
ExprType E1 = analysis::ClassifyExpression(V1);
|
ExprType E1 = ClassifyExpression(V1);
|
||||||
ExprType E2 = analysis::ClassifyExpression(V2);
|
ExprType E2 = ClassifyExpression(V2);
|
||||||
|
|
||||||
if (E1.ExprTy > E2.ExprTy) // Make E1 be the simpler expression
|
if (E1.ExprTy > E2.ExprTy) // Make E1 be the simpler expression
|
||||||
std::swap(E1, E2);
|
std::swap(E1, E2);
|
||||||
@@ -128,7 +125,7 @@ InductionVariable::InductionVariable(PHINode *P, LoopInfo *LoopInfo) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Step == 0) { // Unrecognized step value...
|
if (Step == 0) { // Unrecognized step value...
|
||||||
ExprType StepE = analysis::ClassifyExpression(V2);
|
ExprType StepE = ClassifyExpression(V2);
|
||||||
if (StepE.ExprTy != ExprType::Linear ||
|
if (StepE.ExprTy != ExprType::Linear ||
|
||||||
StepE.Var != Phi) return;
|
StepE.Var != Phi) return;
|
||||||
|
|
||||||
@@ -136,7 +133,7 @@ InductionVariable::InductionVariable(PHINode *P, LoopInfo *LoopInfo) {
|
|||||||
if (isa<PointerType>(ETy)) ETy = Type::ULongTy;
|
if (isa<PointerType>(ETy)) ETy = Type::ULongTy;
|
||||||
Step = (Value*)(StepE.Offset ? StepE.Offset : ConstantInt::get(ETy, 0));
|
Step = (Value*)(StepE.Offset ? StepE.Offset : ConstantInt::get(ETy, 0));
|
||||||
} else { // We were able to get a step value, simplify with expr analysis
|
} else { // We were able to get a step value, simplify with expr analysis
|
||||||
ExprType StepE = analysis::ClassifyExpression(Step);
|
ExprType StepE = ClassifyExpression(Step);
|
||||||
if (StepE.ExprTy == ExprType::Linear && StepE.Offset == 0) {
|
if (StepE.ExprTy == ExprType::Linear && StepE.Offset == 0) {
|
||||||
// No offset from variable? Grab the variable
|
// No offset from variable? Grab the variable
|
||||||
Step = StepE.Var;
|
Step = StepE.Var;
|
||||||
|
@@ -15,7 +15,6 @@
|
|||||||
#include "Support/STLExtras.h"
|
#include "Support/STLExtras.h"
|
||||||
#include "Support/StatisticReporter.h"
|
#include "Support/StatisticReporter.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
|
||||||
using std::cerr;
|
using std::cerr;
|
||||||
|
|
||||||
static bool OperandConvertableToType(User *U, Value *V, const Type *Ty,
|
static bool OperandConvertableToType(User *U, Value *V, const Type *Ty,
|
||||||
@@ -44,7 +43,7 @@ static bool MallocConvertableToType(MallocInst *MI, const Type *Ty,
|
|||||||
if (!Ty->isSized()) return false; // Can only alloc something with a size
|
if (!Ty->isSized()) return false; // Can only alloc something with a size
|
||||||
|
|
||||||
// Analyze the number of bytes allocated...
|
// Analyze the number of bytes allocated...
|
||||||
analysis::ExprType Expr = analysis::ClassifyExpression(MI->getArraySize());
|
ExprType Expr = ClassifyExpression(MI->getArraySize());
|
||||||
|
|
||||||
// Get information about the base datatype being allocated, before & after
|
// Get information about the base datatype being allocated, before & after
|
||||||
int ReqTypeSize = TD.getTypeSize(Ty);
|
int ReqTypeSize = TD.getTypeSize(Ty);
|
||||||
@@ -79,7 +78,7 @@ static Instruction *ConvertMallocToType(MallocInst *MI, const Type *Ty,
|
|||||||
BasicBlock::iterator It = BB->end();
|
BasicBlock::iterator It = BB->end();
|
||||||
|
|
||||||
// Analyze the number of bytes allocated...
|
// Analyze the number of bytes allocated...
|
||||||
analysis::ExprType Expr = analysis::ClassifyExpression(MI->getArraySize());
|
ExprType Expr = ClassifyExpression(MI->getArraySize());
|
||||||
|
|
||||||
const PointerType *AllocTy = cast<PointerType>(Ty);
|
const PointerType *AllocTy = cast<PointerType>(Ty);
|
||||||
const Type *ElType = AllocTy->getElementType();
|
const Type *ElType = AllocTy->getElementType();
|
||||||
|
@@ -94,7 +94,7 @@ const Type *ConvertableToGEP(const Type *Ty, Value *OffsetVal,
|
|||||||
// See if the cast is of an integer expression that is either a constant,
|
// See if the cast is of an integer expression that is either a constant,
|
||||||
// or a value scaled by some amount with a possible offset.
|
// or a value scaled by some amount with a possible offset.
|
||||||
//
|
//
|
||||||
analysis::ExprType Expr = analysis::ClassifyExpression(OffsetVal);
|
ExprType Expr = ClassifyExpression(OffsetVal);
|
||||||
|
|
||||||
// Get the offset and scale values if they exists...
|
// Get the offset and scale values if they exists...
|
||||||
// A scale of zero with Expr.Var != 0 means a scale of 1.
|
// A scale of zero with Expr.Var != 0 means a scale of 1.
|
||||||
|
@@ -71,20 +71,20 @@ namespace {
|
|||||||
OS << *I;
|
OS << *I;
|
||||||
|
|
||||||
if ((*I)->getType() == Type::VoidTy) continue;
|
if ((*I)->getType() == Type::VoidTy) continue;
|
||||||
analysis::ExprType R = analysis::ClassifyExpression(*I);
|
ExprType R = ClassifyExpression(*I);
|
||||||
if (R.Var == *I) continue; // Doesn't tell us anything
|
if (R.Var == *I) continue; // Doesn't tell us anything
|
||||||
|
|
||||||
OS << "\t\tExpr =";
|
OS << "\t\tExpr =";
|
||||||
switch (R.ExprTy) {
|
switch (R.ExprTy) {
|
||||||
case analysis::ExprType::ScaledLinear:
|
case ExprType::ScaledLinear:
|
||||||
WriteAsOperand(OS << "(", (Value*)R.Scale) << " ) *";
|
WriteAsOperand(OS << "(", (Value*)R.Scale) << " ) *";
|
||||||
// fall through
|
// fall through
|
||||||
case analysis::ExprType::Linear:
|
case ExprType::Linear:
|
||||||
WriteAsOperand(OS << "(", R.Var) << " )";
|
WriteAsOperand(OS << "(", R.Var) << " )";
|
||||||
if (R.Offset == 0) break;
|
if (R.Offset == 0) break;
|
||||||
else OS << " +";
|
else OS << " +";
|
||||||
// fall through
|
// fall through
|
||||||
case analysis::ExprType::Constant:
|
case ExprType::Constant:
|
||||||
if (R.Offset) WriteAsOperand(OS, (Value*)R.Offset);
|
if (R.Offset) WriteAsOperand(OS, (Value*)R.Offset);
|
||||||
else OS << " 0";
|
else OS << " 0";
|
||||||
break;
|
break;
|
||||||
|
@@ -71,20 +71,20 @@ namespace {
|
|||||||
OS << *I;
|
OS << *I;
|
||||||
|
|
||||||
if ((*I)->getType() == Type::VoidTy) continue;
|
if ((*I)->getType() == Type::VoidTy) continue;
|
||||||
analysis::ExprType R = analysis::ClassifyExpression(*I);
|
ExprType R = ClassifyExpression(*I);
|
||||||
if (R.Var == *I) continue; // Doesn't tell us anything
|
if (R.Var == *I) continue; // Doesn't tell us anything
|
||||||
|
|
||||||
OS << "\t\tExpr =";
|
OS << "\t\tExpr =";
|
||||||
switch (R.ExprTy) {
|
switch (R.ExprTy) {
|
||||||
case analysis::ExprType::ScaledLinear:
|
case ExprType::ScaledLinear:
|
||||||
WriteAsOperand(OS << "(", (Value*)R.Scale) << " ) *";
|
WriteAsOperand(OS << "(", (Value*)R.Scale) << " ) *";
|
||||||
// fall through
|
// fall through
|
||||||
case analysis::ExprType::Linear:
|
case ExprType::Linear:
|
||||||
WriteAsOperand(OS << "(", R.Var) << " )";
|
WriteAsOperand(OS << "(", R.Var) << " )";
|
||||||
if (R.Offset == 0) break;
|
if (R.Offset == 0) break;
|
||||||
else OS << " +";
|
else OS << " +";
|
||||||
// fall through
|
// fall through
|
||||||
case analysis::ExprType::Constant:
|
case ExprType::Constant:
|
||||||
if (R.Offset) WriteAsOperand(OS, (Value*)R.Offset);
|
if (R.Offset) WriteAsOperand(OS, (Value*)R.Offset);
|
||||||
else OS << " 0";
|
else OS << " 0";
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user