Keep tabs and trailing spaces out.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22565 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jeff Cohen 2005-07-30 18:33:25 +00:00
parent cfb1d4235f
commit d29b6aa608
8 changed files with 62 additions and 61 deletions

View File

@ -42,10 +42,10 @@ namespace llvm {
SCEVExpander(ScalarEvolution &se, LoopInfo &li) : SE(se), LI(li) {} SCEVExpander(ScalarEvolution &se, LoopInfo &li) : SE(se), LI(li) {}
/// clear - Erase the contents of the InsertedExpressions map so that users /// clear - Erase the contents of the InsertedExpressions map so that users
/// trying to expand the same expression into multiple BasicBlocks or /// trying to expand the same expression into multiple BasicBlocks or
/// different places within the same BasicBlock can do so. /// different places within the same BasicBlock can do so.
void clear() { InsertedExpressions.clear(); } void clear() { InsertedExpressions.clear(); }
/// isInsertedInstruction - Return true if the specified instruction was /// isInsertedInstruction - Return true if the specified instruction was
/// inserted by the code rewriter. If so, the client should not modify the /// inserted by the code rewriter. If so, the client should not modify the
/// instruction. /// instruction.

View File

@ -271,14 +271,14 @@ SDOperand SelectionDAGLegalize::PromoteLegalFP_TO_INT(SDOperand LegalOp,
bool isSigned) { bool isSigned) {
// First step, figure out the appropriate FP_TO*INT operation to use. // First step, figure out the appropriate FP_TO*INT operation to use.
MVT::ValueType NewOutTy = DestVT; MVT::ValueType NewOutTy = DestVT;
unsigned OpToUse = 0; unsigned OpToUse = 0;
// Scan for the appropriate larger type to use. // Scan for the appropriate larger type to use.
while (1) { while (1) {
NewOutTy = (MVT::ValueType)(NewOutTy+1); NewOutTy = (MVT::ValueType)(NewOutTy+1);
assert(MVT::isInteger(NewOutTy) && "Ran out of possibilities!"); assert(MVT::isInteger(NewOutTy) && "Ran out of possibilities!");
// If the target supports FP_TO_SINT returning this type, use it. // If the target supports FP_TO_SINT returning this type, use it.
switch (TLI.getOperationAction(ISD::FP_TO_SINT, NewOutTy)) { switch (TLI.getOperationAction(ISD::FP_TO_SINT, NewOutTy)) {
default: break; default: break;
@ -291,7 +291,7 @@ SDOperand SelectionDAGLegalize::PromoteLegalFP_TO_INT(SDOperand LegalOp,
break; break;
} }
if (OpToUse) break; if (OpToUse) break;
// If the target supports FP_TO_UINT of this type, use it. // If the target supports FP_TO_UINT of this type, use it.
switch (TLI.getOperationAction(ISD::FP_TO_UINT, NewOutTy)) { switch (TLI.getOperationAction(ISD::FP_TO_UINT, NewOutTy)) {
default: break; default: break;
@ -304,13 +304,13 @@ SDOperand SelectionDAGLegalize::PromoteLegalFP_TO_INT(SDOperand LegalOp,
break; break;
} }
if (OpToUse) break; if (OpToUse) break;
// Otherwise, try a larger type. // Otherwise, try a larger type.
} }
// Make sure to legalize any nodes we create here in the next pass. // Make sure to legalize any nodes we create here in the next pass.
NeedsAnotherIteration = true; NeedsAnotherIteration = true;
// Okay, we found the operation and type to use. Truncate the result of the // Okay, we found the operation and type to use. Truncate the result of the
// extended FP_TO_*INT operation to the desired size. // extended FP_TO_*INT operation to the desired size.
return DAG.getNode(ISD::TRUNCATE, DestVT, return DAG.getNode(ISD::TRUNCATE, DestVT,
@ -1502,7 +1502,7 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
bool isSigned = Node->getOpcode() == ISD::SINT_TO_FP; bool isSigned = Node->getOpcode() == ISD::SINT_TO_FP;
switch (getTypeAction(Node->getOperand(0).getValueType())) { switch (getTypeAction(Node->getOperand(0).getValueType())) {
case Legal: case Legal:
switch (TLI.getOperationAction(Node->getOpcode(), switch (TLI.getOperationAction(Node->getOpcode(),
Node->getOperand(0).getValueType())) { Node->getOperand(0).getValueType())) {
default: assert(0 && "Unknown operation action!"); default: assert(0 && "Unknown operation action!");
case TargetLowering::Expand: case TargetLowering::Expand:
@ -1565,7 +1565,7 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
break; break;
} }
break; break;
case ISD::FP_TO_SINT: case ISD::FP_TO_SINT:
case ISD::FP_TO_UINT: case ISD::FP_TO_UINT:
switch (getTypeAction(Node->getOperand(0).getValueType())) { switch (getTypeAction(Node->getOperand(0).getValueType())) {
@ -1590,7 +1590,7 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
NeedsAnotherIteration = true; NeedsAnotherIteration = true;
return Result; return Result;
} }
if (Tmp1 != Node->getOperand(0)) if (Tmp1 != Node->getOperand(0))
Result = DAG.getNode(Node->getOpcode(), Node->getValueType(0), Tmp1); Result = DAG.getNode(Node->getOpcode(), Node->getValueType(0), Tmp1);
break; break;
@ -1602,7 +1602,7 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
break; break;
} }
break; break;
case ISD::ZERO_EXTEND: case ISD::ZERO_EXTEND:
case ISD::SIGN_EXTEND: case ISD::SIGN_EXTEND:
case ISD::FP_EXTEND: case ISD::FP_EXTEND:
@ -2785,7 +2785,7 @@ void SelectionDAGLegalize::ExpandOp(SDOperand Op, SDOperand &Lo, SDOperand &Hi){
case Legal: Op = LegalizeOp(Node->getOperand(0)); break; case Legal: Op = LegalizeOp(Node->getOperand(0)); break;
case Promote: Op = PromoteOp(Node->getOperand(0)); break; case Promote: Op = PromoteOp(Node->getOperand(0)); break;
} }
Op = TLI.LowerOperation(DAG.getNode(ISD::FP_TO_SINT, VT, Op), DAG); Op = TLI.LowerOperation(DAG.getNode(ISD::FP_TO_SINT, VT, Op), DAG);
// Now that the custom expander is done, expand the result, which is still // Now that the custom expander is done, expand the result, which is still
@ -2793,12 +2793,13 @@ void SelectionDAGLegalize::ExpandOp(SDOperand Op, SDOperand &Lo, SDOperand &Hi){
ExpandOp(Op, Lo, Hi); ExpandOp(Op, Lo, Hi);
break; break;
} }
if (Node->getOperand(0).getValueType() == MVT::f32) if (Node->getOperand(0).getValueType() == MVT::f32)
Lo = ExpandLibCall("__fixsfdi", Node, Hi); Lo = ExpandLibCall("__fixsfdi", Node, Hi);
else else
Lo = ExpandLibCall("__fixdfdi", Node, Hi); Lo = ExpandLibCall("__fixdfdi", Node, Hi);
break; break;
case ISD::FP_TO_UINT: case ISD::FP_TO_UINT:
if (TLI.getOperationAction(ISD::FP_TO_UINT, VT) == TargetLowering::Custom) { if (TLI.getOperationAction(ISD::FP_TO_UINT, VT) == TargetLowering::Custom) {
SDOperand Op = DAG.getNode(ISD::FP_TO_UINT, VT, SDOperand Op = DAG.getNode(ISD::FP_TO_UINT, VT,
@ -2808,7 +2809,7 @@ void SelectionDAGLegalize::ExpandOp(SDOperand Op, SDOperand &Lo, SDOperand &Hi){
ExpandOp(TLI.LowerOperation(Op, DAG), Lo, Hi); ExpandOp(TLI.LowerOperation(Op, DAG), Lo, Hi);
break; break;
} }
if (Node->getOperand(0).getValueType() == MVT::f32) if (Node->getOperand(0).getValueType() == MVT::f32)
Lo = ExpandLibCall("__fixunssfdi", Node, Hi); Lo = ExpandLibCall("__fixunssfdi", Node, Hi);
else else

View File

@ -65,7 +65,7 @@ namespace {
inline unsigned char *allocateStub(unsigned StubSize); inline unsigned char *allocateStub(unsigned StubSize);
inline unsigned char *allocateConstant(unsigned ConstantSize, inline unsigned char *allocateConstant(unsigned ConstantSize,
unsigned Alignment); unsigned Alignment);
inline unsigned char* allocateGlobal(unsigned Size, inline unsigned char* allocateGlobal(unsigned Size,
unsigned Alignment); unsigned Alignment);
inline unsigned char *startFunctionBody(); inline unsigned char *startFunctionBody();
inline void endFunctionBody(unsigned char *FunctionEnd); inline void endFunctionBody(unsigned char *FunctionEnd);
@ -373,8 +373,8 @@ void *JITResolver::JITCompilerFn(void *Stub) {
// FIXME: We could rewrite all references to this stub if we knew them. // FIXME: We could rewrite all references to this stub if we knew them.
// What we will do is set the compiled function address to map to the // What we will do is set the compiled function address to map to the
// same GOT entry as the stub so that later clients may update the GOT // same GOT entry as the stub so that later clients may update the GOT
// if they see it still using the stub address. // if they see it still using the stub address.
// Note: this is done so the Resolver doesn't have to manage GOT memory // Note: this is done so the Resolver doesn't have to manage GOT memory
// Do this without allocating map space if the target isn't using a GOT // Do this without allocating map space if the target isn't using a GOT
@ -548,7 +548,7 @@ void JITEmitter::finishFunction(MachineFunction &F) {
if(MemMgr.isManagingGOT()) { if(MemMgr.isManagingGOT()) {
unsigned idx = getJITResolver(this).getGOTIndexForAddr((void*)CurBlock); unsigned idx = getJITResolver(this).getGOTIndexForAddr((void*)CurBlock);
if (((void**)MemMgr.getGOTBase())[idx] != (void*)CurBlock) { if (((void**)MemMgr.getGOTBase())[idx] != (void*)CurBlock) {
DEBUG(std::cerr << "GOT was out of date for " << (void*)CurBlock DEBUG(std::cerr << "GOT was out of date for " << (void*)CurBlock
<< " pointing at " << ((void**)MemMgr.getGOTBase())[idx] << "\n"); << " pointing at " << ((void**)MemMgr.getGOTBase())[idx] << "\n");
((void**)MemMgr.getGOTBase())[idx] = (void*)CurBlock; ((void**)MemMgr.getGOTBase())[idx] = (void*)CurBlock;
} }

View File

@ -92,7 +92,7 @@ extern "C" {
EmitBranchToAt(CameFromStub, Target); EmitBranchToAt(CameFromStub, Target);
} else { } else {
DEBUG(std::cerr << "confused, didn't come from stub at " << CameFromStub DEBUG(std::cerr << "confused, didn't come from stub at " << CameFromStub
<< " old jump vector " << oldpv << " old jump vector " << oldpv
<< " new jump vector " << Target << "\n"); << " new jump vector " << Target << "\n");
} }
@ -291,7 +291,7 @@ void AlphaJITInfo::relocate(void *Function, MachineRelocation *MR,
} }
break; break;
case Alpha::reloc_bsr: { case Alpha::reloc_bsr: {
idx = (((unsigned char*)MR->getResultPointer() - idx = (((unsigned char*)MR->getResultPointer() -
(unsigned char*)RelocPos) >> 2) + 1; //skip first 2 inst of fun (unsigned char*)RelocPos) >> 2) + 1; //skip first 2 inst of fun
*RelocPos |= (idx & ((1 << 21)-1)); *RelocPos |= (idx & ((1 << 21)-1));
doCommon = false; doCommon = false;

View File

@ -245,7 +245,7 @@ void PPC32RegisterInfo::emitPrologue(MachineFunction &MF) const {
NumBytes += MFI->getMaxCallFrameSize(); NumBytes += MFI->getMaxCallFrameSize();
} }
// If we are a leaf function, and use up to 224 bytes of stack space, // If we are a leaf function, and use up to 224 bytes of stack space,
// and don't have a frame pointer, then we do not need to adjust the stack // and don't have a frame pointer, then we do not need to adjust the stack
// pointer (we fit in the Red Zone). // pointer (we fit in the Red Zone).
if ((NumBytes == 0) || (NumBytes <= 224 && !hasFP(MF) && !MFI->hasCalls())) { if ((NumBytes == 0) || (NumBytes <= 224 && !hasFP(MF) && !MFI->hasCalls())) {

View File

@ -62,7 +62,7 @@ namespace {
FP_TO_INT16_IN_MEM, FP_TO_INT16_IN_MEM,
FP_TO_INT32_IN_MEM, FP_TO_INT32_IN_MEM,
FP_TO_INT64_IN_MEM, FP_TO_INT64_IN_MEM,
/// CALL/TAILCALL - These operations represent an abstract X86 call /// CALL/TAILCALL - These operations represent an abstract X86 call
/// instruction, which includes a bunch of information. In particular the /// instruction, which includes a bunch of information. In particular the
/// operands of these node are: /// operands of these node are:
@ -135,7 +135,7 @@ namespace {
setOperationAction(ISD::FP_TO_SINT , MVT::i32 , Custom); setOperationAction(ISD::FP_TO_SINT , MVT::i32 , Custom);
setOperationAction(ISD::FP_TO_SINT , MVT::i16 , Custom); setOperationAction(ISD::FP_TO_SINT , MVT::i16 , Custom);
} }
// Handle FP_TO_UINT by promoting the destination to a larger signed // Handle FP_TO_UINT by promoting the destination to a larger signed
// conversion. // conversion.
setOperationAction(ISD::FP_TO_UINT , MVT::i1 , Promote); setOperationAction(ISD::FP_TO_UINT , MVT::i1 , Promote);
@ -147,7 +147,7 @@ namespace {
// this operation. // this operation.
setOperationAction(ISD::FP_TO_SINT , MVT::i1 , Promote); setOperationAction(ISD::FP_TO_SINT , MVT::i1 , Promote);
setOperationAction(ISD::FP_TO_SINT , MVT::i8 , Promote); setOperationAction(ISD::FP_TO_SINT , MVT::i8 , Promote);
setOperationAction(ISD::BRCONDTWOWAY , MVT::Other, Expand); setOperationAction(ISD::BRCONDTWOWAY , MVT::Other, Expand);
setOperationAction(ISD::MEMMOVE , MVT::Other, Expand); setOperationAction(ISD::MEMMOVE , MVT::Other, Expand);
setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i16 , Expand); setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i16 , Expand);
@ -1008,14 +1008,14 @@ SDOperand X86TargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) {
case MVT::i32: Opc = X86ISD::FP_TO_INT32_IN_MEM; break; case MVT::i32: Opc = X86ISD::FP_TO_INT32_IN_MEM; break;
case MVT::i64: Opc = X86ISD::FP_TO_INT64_IN_MEM; break; case MVT::i64: Opc = X86ISD::FP_TO_INT64_IN_MEM; break;
} }
// Build the FP_TO_INT*_IN_MEM // Build the FP_TO_INT*_IN_MEM
std::vector<SDOperand> Ops; std::vector<SDOperand> Ops;
Ops.push_back(DAG.getEntryNode()); Ops.push_back(DAG.getEntryNode());
Ops.push_back(Op.getOperand(0)); Ops.push_back(Op.getOperand(0));
Ops.push_back(StackSlot); Ops.push_back(StackSlot);
SDOperand FIST = DAG.getNode(Opc, MVT::Other, Ops); SDOperand FIST = DAG.getNode(Opc, MVT::Other, Ops);
// Load the result. // Load the result.
return DAG.getLoad(Op.getValueType(), FIST, StackSlot, return DAG.getLoad(Op.getValueType(), FIST, StackSlot,
DAG.getSrcValue(NULL)); DAG.getSrcValue(NULL));
@ -3308,7 +3308,7 @@ unsigned ISel::SelectExpr(SDOperand N) {
addFullAddress(BuildMI(BB, X86::FILD64m, 4, Result), AM); addFullAddress(BuildMI(BB, X86::FILD64m, 4, Result), AM);
} }
return Result; return Result;
case ISD::EXTLOAD: // Arbitrarily codegen extloads as MOVZX* case ISD::EXTLOAD: // Arbitrarily codegen extloads as MOVZX*
case ISD::ZEXTLOAD: { case ISD::ZEXTLOAD: {
// Make sure we generate both values. // Make sure we generate both values.
@ -4307,7 +4307,7 @@ void ISel::Select(SDOperand N) {
ExprMap.erase(N); ExprMap.erase(N);
SelectExpr(N.getValue(0)); SelectExpr(N.getValue(0));
return; return;
case X86ISD::FP_TO_INT16_IN_MEM: case X86ISD::FP_TO_INT16_IN_MEM:
case X86ISD::FP_TO_INT32_IN_MEM: case X86ISD::FP_TO_INT32_IN_MEM:
case X86ISD::FP_TO_INT64_IN_MEM: { case X86ISD::FP_TO_INT64_IN_MEM: {
@ -4323,24 +4323,24 @@ void ISel::Select(SDOperand N) {
SelectAddress(N.getOperand(2), AM); SelectAddress(N.getOperand(2), AM);
ValReg = SelectExpr(N.getOperand(1)); ValReg = SelectExpr(N.getOperand(1));
} }
// Change the floating point control register to use "round towards zero" // Change the floating point control register to use "round towards zero"
// mode when truncating to an integer value. // mode when truncating to an integer value.
// //
MachineFunction *F = BB->getParent(); MachineFunction *F = BB->getParent();
int CWFrameIdx = F->getFrameInfo()->CreateStackObject(2, 2); int CWFrameIdx = F->getFrameInfo()->CreateStackObject(2, 2);
addFrameReference(BuildMI(BB, X86::FNSTCW16m, 4), CWFrameIdx); addFrameReference(BuildMI(BB, X86::FNSTCW16m, 4), CWFrameIdx);
// Load the old value of the high byte of the control word... // Load the old value of the high byte of the control word...
unsigned OldCW = MakeReg(MVT::i16); unsigned OldCW = MakeReg(MVT::i16);
addFrameReference(BuildMI(BB, X86::MOV16rm, 4, OldCW), CWFrameIdx); addFrameReference(BuildMI(BB, X86::MOV16rm, 4, OldCW), CWFrameIdx);
// Set the high part to be round to zero... // Set the high part to be round to zero...
addFrameReference(BuildMI(BB, X86::MOV16mi, 5), CWFrameIdx).addImm(0xC7F); addFrameReference(BuildMI(BB, X86::MOV16mi, 5), CWFrameIdx).addImm(0xC7F);
// Reload the modified control word now... // Reload the modified control word now...
addFrameReference(BuildMI(BB, X86::FLDCW16m, 4), CWFrameIdx); addFrameReference(BuildMI(BB, X86::FLDCW16m, 4), CWFrameIdx);
// Restore the memory image of control word to original value // Restore the memory image of control word to original value
addFrameReference(BuildMI(BB, X86::MOV16mr, 5), CWFrameIdx).addReg(OldCW); addFrameReference(BuildMI(BB, X86::MOV16mr, 5), CWFrameIdx).addReg(OldCW);
@ -4350,9 +4350,9 @@ void ISel::Select(SDOperand N) {
case X86ISD::FP_TO_INT32_IN_MEM: Tmp1 = X86::FIST32m; break; case X86ISD::FP_TO_INT32_IN_MEM: Tmp1 = X86::FIST32m; break;
case X86ISD::FP_TO_INT64_IN_MEM: Tmp1 = X86::FISTP64m; break; case X86ISD::FP_TO_INT64_IN_MEM: Tmp1 = X86::FISTP64m; break;
} }
addFullAddress(BuildMI(BB, Tmp1, 5), AM).addReg(ValReg); addFullAddress(BuildMI(BB, Tmp1, 5), AM).addReg(ValReg);
// Reload the original control word now. // Reload the original control word now.
addFrameReference(BuildMI(BB, X86::FLDCW16m, 4), CWFrameIdx); addFrameReference(BuildMI(BB, X86::FLDCW16m, 4), CWFrameIdx);
return; return;

View File

@ -172,7 +172,7 @@ static bool CanReduceSCEV(const SCEVHandle &SH, Loop *L) {
if (SCEVUnknown *SU = dyn_cast<SCEVUnknown>(AddRec->getOperand(1))) if (SCEVUnknown *SU = dyn_cast<SCEVUnknown>(AddRec->getOperand(1)))
if (SU->getValue()->getType()->isUnsigned()) if (SU->getValue()->getType()->isUnsigned())
return true; return true;
// Otherwise, no, we can't handle it yet. // Otherwise, no, we can't handle it yet.
return false; return false;
} }
@ -192,7 +192,7 @@ static SCEVHandle GetAdjustedIndex(const SCEVHandle &Idx, uint64_t TySize,
// This index is scaled by the type size being indexed. // This index is scaled by the type size being indexed.
if (TySize != 1) if (TySize != 1)
Result = SCEVMulExpr::get(Result, Result = SCEVMulExpr::get(Result,
SCEVConstant::get(ConstantUInt::get(UIntPtrTy, SCEVConstant::get(ConstantUInt::get(UIntPtrTy,
TySize))); TySize)));
return Result; return Result;
@ -216,7 +216,7 @@ void LoopStrengthReduce::AnalyzeGetElementPtrUsers(GetElementPtrInst *GEP,
Value *BasePtr; Value *BasePtr;
if (Constant *CB = dyn_cast<Constant>(GEP->getOperand(0))) if (Constant *CB = dyn_cast<Constant>(GEP->getOperand(0)))
BasePtr = ConstantExpr::getCast(CB, UIntPtrTy); BasePtr = ConstantExpr::getCast(CB, UIntPtrTy);
else { else {
Value *&BP = CastedBasePointers[GEP->getOperand(0)]; Value *&BP = CastedBasePointers[GEP->getOperand(0)];
if (BP == 0) { if (BP == 0) {
BasicBlock::iterator InsertPt; BasicBlock::iterator InsertPt;
@ -321,7 +321,7 @@ void LoopStrengthReduce::AnalyzeGetElementPtrUsers(GetElementPtrInst *GEP,
DEBUG(std::cerr << "FOUND USER: " << *User DEBUG(std::cerr << "FOUND USER: " << *User
<< " OF STRIDE: " << *Step << " BASE = " << *Base << "\n"); << " OF STRIDE: " << *Step << " BASE = " << *Base << "\n");
// Okay, we found a user that we cannot reduce. Analyze the instruction // Okay, we found a user that we cannot reduce. Analyze the instruction
// and decide what to do with it. // and decide what to do with it.
IVUsesByStride[Step].addUser(Base, User, GEP); IVUsesByStride[Step].addUser(Base, User, GEP);
@ -351,7 +351,7 @@ bool LoopStrengthReduce::AddUsersIfInteresting(Instruction *I, Loop *L) {
assert(Step->getType()->isUnsigned() && "Bad step value!"); assert(Step->getType()->isUnsigned() && "Bad step value!");
std::set<GetElementPtrInst*> AnalyzedGEPs; std::set<GetElementPtrInst*> AnalyzedGEPs;
for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); UI != E;++UI){ for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); UI != E;++UI){
Instruction *User = cast<Instruction>(*UI); Instruction *User = cast<Instruction>(*UI);
@ -364,12 +364,12 @@ bool LoopStrengthReduce::AddUsersIfInteresting(Instruction *I, Loop *L) {
if (LI->getLoopFor(User->getParent()) != L) if (LI->getLoopFor(User->getParent()) != L)
continue; continue;
// Next, see if this user is analyzable itself! // Next, see if this user is analyzable itself!
if (!AddUsersIfInteresting(User, L)) { if (!AddUsersIfInteresting(User, L)) {
if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(User)) { if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(User)) {
// If this is a getelementptr instruction, figure out what linear // If this is a getelementptr instruction, figure out what linear
// expression of induction variable is actually being used. // expression of induction variable is actually being used.
// //
if (AnalyzedGEPs.insert(GEP).second) // Not already analyzed? if (AnalyzedGEPs.insert(GEP).second) // Not already analyzed?
AnalyzeGetElementPtrUsers(GEP, I, L); AnalyzeGetElementPtrUsers(GEP, I, L);
} else { } else {
@ -426,12 +426,12 @@ void BasedUser::dump() const {
/// isTargetConstant - Return true if the following can be referenced by the /// isTargetConstant - Return true if the following can be referenced by the
/// immediate field of a target instruction. /// immediate field of a target instruction.
static bool isTargetConstant(const SCEVHandle &V) { static bool isTargetConstant(const SCEVHandle &V) {
// FIXME: Look at the target to decide if &GV is a legal constant immediate. // FIXME: Look at the target to decide if &GV is a legal constant immediate.
if (isa<SCEVConstant>(V)) return true; if (isa<SCEVConstant>(V)) return true;
return false; // ENABLE this for x86 return false; // ENABLE this for x86
if (SCEVUnknown *SU = dyn_cast<SCEVUnknown>(V)) if (SCEVUnknown *SU = dyn_cast<SCEVUnknown>(V))
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(SU->getValue())) if (ConstantExpr *CE = dyn_cast<ConstantExpr>(SU->getValue()))
if (CE->getOpcode() == Instruction::Cast) if (CE->getOpcode() == Instruction::Cast)
@ -455,7 +455,7 @@ static SCEVHandle GetImmediateValues(SCEVHandle Val, bool isAddress) {
for (; i != SAE->getNumOperands(); ++i) for (; i != SAE->getNumOperands(); ++i)
if (isTargetConstant(SAE->getOperand(i))) { if (isTargetConstant(SAE->getOperand(i))) {
SCEVHandle ImmVal = SAE->getOperand(i); SCEVHandle ImmVal = SAE->getOperand(i);
// If there are any other immediates that we can handle here, pull them // If there are any other immediates that we can handle here, pull them
// out too. // out too.
for (++i; i != SAE->getNumOperands(); ++i) for (++i; i != SAE->getNumOperands(); ++i)
@ -481,8 +481,8 @@ void LoopStrengthReduce::StrengthReduceStridedIVUsers(Value *Stride,
// eventually emit the object. // eventually emit the object.
std::vector<std::pair<SCEVHandle, BasedUser> > UsersToProcess; std::vector<std::pair<SCEVHandle, BasedUser> > UsersToProcess;
UsersToProcess.reserve(Uses.Users.size()); UsersToProcess.reserve(Uses.Users.size());
SCEVHandle ZeroBase = SCEVUnknown::getIntegerSCEV(0, SCEVHandle ZeroBase = SCEVUnknown::getIntegerSCEV(0,
Uses.Users[0].first->getType()); Uses.Users[0].first->getType());
for (unsigned i = 0, e = Uses.Users.size(); i != e; ++i) for (unsigned i = 0, e = Uses.Users.size(); i != e; ++i)
@ -497,7 +497,7 @@ void LoopStrengthReduce::StrengthReduceStridedIVUsers(Value *Stride,
for (unsigned i = 0, e = UsersToProcess.size(); i != e; ++i) { for (unsigned i = 0, e = UsersToProcess.size(); i != e; ++i) {
bool isAddress = isa<LoadInst>(UsersToProcess[i].second.Inst) || bool isAddress = isa<LoadInst>(UsersToProcess[i].second.Inst) ||
isa<StoreInst>(UsersToProcess[i].second.Inst); isa<StoreInst>(UsersToProcess[i].second.Inst);
UsersToProcess[i].second.Imm = GetImmediateValues(UsersToProcess[i].first, UsersToProcess[i].second.Imm = GetImmediateValues(UsersToProcess[i].first,
isAddress); isAddress);
UsersToProcess[i].first = SCEV::getMinusSCEV(UsersToProcess[i].first, UsersToProcess[i].first = SCEV::getMinusSCEV(UsersToProcess[i].first,
UsersToProcess[i].second.Imm); UsersToProcess[i].second.Imm);
@ -511,14 +511,14 @@ void LoopStrengthReduce::StrengthReduceStridedIVUsers(Value *Stride,
Instruction *PreInsertPt = Preheader->getTerminator(); Instruction *PreInsertPt = Preheader->getTerminator();
Instruction *PhiInsertBefore = L->getHeader()->begin(); Instruction *PhiInsertBefore = L->getHeader()->begin();
assert(isa<PHINode>(PhiInsertBefore) && assert(isa<PHINode>(PhiInsertBefore) &&
"How could this loop have IV's without any phis?"); "How could this loop have IV's without any phis?");
PHINode *SomeLoopPHI = cast<PHINode>(PhiInsertBefore); PHINode *SomeLoopPHI = cast<PHINode>(PhiInsertBefore);
assert(SomeLoopPHI->getNumIncomingValues() == 2 && assert(SomeLoopPHI->getNumIncomingValues() == 2 &&
"This loop isn't canonicalized right"); "This loop isn't canonicalized right");
BasicBlock *LatchBlock = BasicBlock *LatchBlock =
SomeLoopPHI->getIncomingBlock(SomeLoopPHI->getIncomingBlock(0) == Preheader); SomeLoopPHI->getIncomingBlock(SomeLoopPHI->getIncomingBlock(0) == Preheader);
// FIXME: This loop needs increasing levels of intelligence. // FIXME: This loop needs increasing levels of intelligence.
// STAGE 0: just emit everything as its own base. <-- We are here // STAGE 0: just emit everything as its own base. <-- We are here
// STAGE 1: factor out common vars from bases, and try and push resulting // STAGE 1: factor out common vars from bases, and try and push resulting
@ -534,7 +534,7 @@ void LoopStrengthReduce::StrengthReduceStridedIVUsers(Value *Stride,
PHINode *NewPHI = new PHINode(ReplacedTy, Replaced->getName()+".str", PHINode *NewPHI = new PHINode(ReplacedTy, Replaced->getName()+".str",
PhiInsertBefore); PhiInsertBefore);
// Emit the initial base value into the loop preheader, and add it to the // Emit the initial base value into the loop preheader, and add it to the
// Phi node. // Phi node.
Value *BaseV = Rewriter.expandCodeFor(UsersToProcess.front().first, Value *BaseV = Rewriter.expandCodeFor(UsersToProcess.front().first,
PreInsertPt, ReplacedTy); PreInsertPt, ReplacedTy);
@ -552,7 +552,7 @@ void LoopStrengthReduce::StrengthReduceStridedIVUsers(Value *Stride,
// Emit the code to add the immediate offset to the Phi value, just before // Emit the code to add the immediate offset to the Phi value, just before
// the instruction that we identified as using this stride and base. // the instruction that we identified as using this stride and base.
// First, empty the SCEVExpander's expression map so that we are guaranteed // First, empty the SCEVExpander's expression map so that we are guaranteed
// to have the code emitted where we expect it. // to have the code emitted where we expect it.
Rewriter.clear(); Rewriter.clear();
SCEVHandle NewValSCEV = SCEVAddExpr::get(SCEVUnknown::get(NewPHI), SCEVHandle NewValSCEV = SCEVAddExpr::get(SCEVUnknown::get(NewPHI),
@ -560,16 +560,16 @@ void LoopStrengthReduce::StrengthReduceStridedIVUsers(Value *Stride,
Value *newVal = Rewriter.expandCodeFor(NewValSCEV, Value *newVal = Rewriter.expandCodeFor(NewValSCEV,
UsersToProcess.front().second.Inst, UsersToProcess.front().second.Inst,
ReplacedTy); ReplacedTy);
// Replace the use of the operand Value with the new Phi we just created. // Replace the use of the operand Value with the new Phi we just created.
DEBUG(std::cerr << "REPLACING: " << *Replaced << "IN: " << DEBUG(std::cerr << "REPLACING: " << *Replaced << "IN: " <<
*UsersToProcess.front().second.Inst << "WITH: "<< *newVal << '\n'); *UsersToProcess.front().second.Inst << "WITH: "<< *newVal << '\n');
UsersToProcess.front().second.Inst->replaceUsesOfWith(Replaced, newVal); UsersToProcess.front().second.Inst->replaceUsesOfWith(Replaced, newVal);
// Mark old value we replaced as possibly dead, so that it is elminated // Mark old value we replaced as possibly dead, so that it is elminated
// if we just replaced the last use of that value. // if we just replaced the last use of that value.
DeadInsts.insert(cast<Instruction>(Replaced)); DeadInsts.insert(cast<Instruction>(Replaced));
UsersToProcess.erase(UsersToProcess.begin()); UsersToProcess.erase(UsersToProcess.begin());
++NumReduced; ++NumReduced;
@ -578,7 +578,7 @@ void LoopStrengthReduce::StrengthReduceStridedIVUsers(Value *Stride,
// IMPORTANT TODO: Figure out how to partition the IV's with this stride, but // IMPORTANT TODO: Figure out how to partition the IV's with this stride, but
// different starting values, into different PHIs. // different starting values, into different PHIs.
// BEFORE writing this, it's probably useful to handle GEP's. // BEFORE writing this, it's probably useful to handle GEP's.
// NOTE: pull all constants together, for REG+IMM addressing, include &GV in // NOTE: pull all constants together, for REG+IMM addressing, include &GV in

View File

@ -65,7 +65,7 @@ cl::list<const PassInfo*, bool, FilteredPassNameParser<PassInfo::LLC> >
LLCPassList(cl::desc("Passes Available")); LLCPassList(cl::desc("Passes Available"));
cl::opt<bool> NoVerify("disable-verify", cl::Hidden, cl::opt<bool> NoVerify("disable-verify", cl::Hidden,
cl::desc("Do not verify input module")); cl::desc("Do not verify input module"));
// GetFileNameRoot - Helper function to get the basename of a filename. // GetFileNameRoot - Helper function to get the basename of a filename.