mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-01 00:33:09 +00:00
rename ClassifyExpression -> ClassifyExpr
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10592 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4e4bbc792c
commit
9a0a41f224
@ -233,13 +233,13 @@ static inline ExprType negate(const ExprType &E, Value *V) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ClassifyExpression: Analyze an expression to determine the complexity of the
|
// ClassifyExpr: Analyze an expression to determine the complexity of the
|
||||||
// expression, and which other values it depends on.
|
// expression, and which other values it depends on.
|
||||||
//
|
//
|
||||||
// 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 llvm::ClassifyExpression(Value *Expr) {
|
ExprType llvm::ClassifyExpr(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
|
||||||
@ -266,14 +266,14 @@ ExprType llvm::ClassifyExpression(Value *Expr) {
|
|||||||
|
|
||||||
switch (I->getOpcode()) { // Handle each instruction type separately
|
switch (I->getOpcode()) { // Handle each instruction type separately
|
||||||
case Instruction::Add: {
|
case Instruction::Add: {
|
||||||
ExprType Left (ClassifyExpression(I->getOperand(0)));
|
ExprType Left (ClassifyExpr(I->getOperand(0)));
|
||||||
ExprType Right(ClassifyExpression(I->getOperand(1)));
|
ExprType Right(ClassifyExpr(I->getOperand(1)));
|
||||||
return handleAddition(Left, Right, I);
|
return handleAddition(Left, Right, I);
|
||||||
} // end case Instruction::Add
|
} // end case Instruction::Add
|
||||||
|
|
||||||
case Instruction::Sub: {
|
case Instruction::Sub: {
|
||||||
ExprType Left (ClassifyExpression(I->getOperand(0)));
|
ExprType Left (ClassifyExpr(I->getOperand(0)));
|
||||||
ExprType Right(ClassifyExpression(I->getOperand(1)));
|
ExprType Right(ClassifyExpr(I->getOperand(1)));
|
||||||
ExprType RightNeg = negate(Right, I);
|
ExprType RightNeg = negate(Right, I);
|
||||||
if (RightNeg.Var == I && !RightNeg.Offset && !RightNeg.Scale)
|
if (RightNeg.Var == I && !RightNeg.Offset && !RightNeg.Scale)
|
||||||
return I; // Could not negate value...
|
return I; // Could not negate value...
|
||||||
@ -281,9 +281,9 @@ ExprType llvm::ClassifyExpression(Value *Expr) {
|
|||||||
} // end case Instruction::Sub
|
} // end case Instruction::Sub
|
||||||
|
|
||||||
case Instruction::Shl: {
|
case Instruction::Shl: {
|
||||||
ExprType Right(ClassifyExpression(I->getOperand(1)));
|
ExprType Right(ClassifyExpr(I->getOperand(1)));
|
||||||
if (Right.ExprTy != ExprType::Constant) break;
|
if (Right.ExprTy != ExprType::Constant) break;
|
||||||
ExprType Left(ClassifyExpression(I->getOperand(0)));
|
ExprType Left(ClassifyExpr(I->getOperand(0)));
|
||||||
if (Right.Offset == 0) return Left; // shl x, 0 = x
|
if (Right.Offset == 0) return Left; // shl x, 0 = x
|
||||||
assert(Right.Offset->getType() == Type::UByteTy &&
|
assert(Right.Offset->getType() == Type::UByteTy &&
|
||||||
"Shift amount must always be a unsigned byte!");
|
"Shift amount must always be a unsigned byte!");
|
||||||
@ -308,8 +308,8 @@ ExprType llvm::ClassifyExpression(Value *Expr) {
|
|||||||
} // end case Instruction::Shl
|
} // end case Instruction::Shl
|
||||||
|
|
||||||
case Instruction::Mul: {
|
case Instruction::Mul: {
|
||||||
ExprType Left (ClassifyExpression(I->getOperand(0)));
|
ExprType Left (ClassifyExpr(I->getOperand(0)));
|
||||||
ExprType Right(ClassifyExpression(I->getOperand(1)));
|
ExprType Right(ClassifyExpr(I->getOperand(1)));
|
||||||
if (Left.ExprTy > Right.ExprTy)
|
if (Left.ExprTy > Right.ExprTy)
|
||||||
std::swap(Left, Right); // Make left be simpler than right
|
std::swap(Left, Right); // Make left be simpler than right
|
||||||
|
|
||||||
@ -323,7 +323,7 @@ ExprType llvm::ClassifyExpression(Value *Expr) {
|
|||||||
} // end case Instruction::Mul
|
} // end case Instruction::Mul
|
||||||
|
|
||||||
case Instruction::Cast: {
|
case Instruction::Cast: {
|
||||||
ExprType Src(ClassifyExpression(I->getOperand(0)));
|
ExprType Src(ClassifyExpr(I->getOperand(0)));
|
||||||
const Type *DestTy = I->getType();
|
const Type *DestTy = I->getType();
|
||||||
if (isa<PointerType>(DestTy))
|
if (isa<PointerType>(DestTy))
|
||||||
DestTy = Type::ULongTy; // Pointer types are represented as ulong
|
DestTy = Type::ULongTy; // Pointer types are represented as ulong
|
||||||
|
@ -89,8 +89,8 @@ InductionVariable::InductionVariable(PHINode *P, LoopInfo *LoopInfo): End(0) {
|
|||||||
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 = ClassifyExpression(V1);
|
ExprType E1 = ClassifyExpr(V1);
|
||||||
ExprType E2 = ClassifyExpression(V2);
|
ExprType E2 = ClassifyExpr(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);
|
||||||
@ -152,7 +152,7 @@ InductionVariable::InductionVariable(PHINode *P, LoopInfo *LoopInfo): End(0) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Step == 0) { // Unrecognized step value...
|
if (Step == 0) { // Unrecognized step value...
|
||||||
ExprType StepE = ClassifyExpression(V2);
|
ExprType StepE = ClassifyExpr(V2);
|
||||||
if (StepE.ExprTy != ExprType::Linear ||
|
if (StepE.ExprTy != ExprType::Linear ||
|
||||||
StepE.Var != Phi) return;
|
StepE.Var != Phi) return;
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ InductionVariable::InductionVariable(PHINode *P, LoopInfo *LoopInfo): End(0) {
|
|||||||
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 = ClassifyExpression(Step);
|
ExprType StepE = ClassifyExpr(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;
|
||||||
|
@ -52,7 +52,7 @@ static bool MallocConvertibleToType(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...
|
||||||
ExprType Expr = ClassifyExpression(MI->getArraySize());
|
ExprType Expr = ClassifyExpr(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);
|
||||||
@ -89,7 +89,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...
|
||||||
ExprType Expr = ClassifyExpression(MI->getArraySize());
|
ExprType Expr = ClassifyExpr(MI->getArraySize());
|
||||||
|
|
||||||
const PointerType *AllocTy = cast<PointerType>(Ty);
|
const PointerType *AllocTy = cast<PointerType>(Ty);
|
||||||
const Type *ElType = AllocTy->getElementType();
|
const Type *ElType = AllocTy->getElementType();
|
||||||
|
@ -104,7 +104,7 @@ const Type *ConvertibleToGEP(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.
|
||||||
//
|
//
|
||||||
ExprType Expr = ClassifyExpression(OffsetVal);
|
ExprType Expr = ClassifyExpr(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.
|
||||||
|
Loading…
Reference in New Issue
Block a user