From 898efb338a4572a163adc626c28a5be5c20592dd Mon Sep 17 00:00:00 2001 From: Andrew Lenharth Date: Wed, 29 Jun 2005 18:54:02 +0000 Subject: [PATCH] restore old srcValueNode behavior and try to to work around it llvm-svn: 22315 --- lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 2 + lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 4 +- lib/Target/Alpha/AlphaISelPattern.cpp | 122 ++++++++++-------- lib/Target/Alpha/AlphaInstrInfo.td | 3 +- 4 files changed, 76 insertions(+), 55 deletions(-) diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 8614e3ec4b6..8a34a59a15e 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -1394,6 +1394,8 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT, } SDOperand SelectionDAG::getSrcValue(const Value *V, int Offset) { + assert((!V || isa(V->getType())) && + "SrcValue is not a pointer?"); SDNode *&N = ValueNodes[std::make_pair(V, Offset)]; if (N) return SDOperand(N, 0); diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 68150545150..fa6d6d4d14c 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -644,7 +644,7 @@ void SelectionDAGLowering::visitLoad(LoadInst &I) { } SDOperand L = DAG.getLoad(TLI.getValueType(I.getType()), Root, Ptr, - DAG.getSrcValue(&I)); + DAG.getSrcValue(I.getOperand(0))); setValue(&I, L); if (I.isVolatile()) @@ -659,7 +659,7 @@ void SelectionDAGLowering::visitStore(StoreInst &I) { SDOperand Src = getValue(SrcV); SDOperand Ptr = getValue(I.getOperand(1)); DAG.setRoot(DAG.getNode(ISD::STORE, MVT::Other, getRoot(), Src, Ptr, - DAG.getSrcValue(&I))); + DAG.getSrcValue(I.getOperand(1)))); } void SelectionDAGLowering::visitCall(CallInst &I) { diff --git a/lib/Target/Alpha/AlphaISelPattern.cpp b/lib/Target/Alpha/AlphaISelPattern.cpp index bab3c6eed91..5229743b109 100644 --- a/lib/Target/Alpha/AlphaISelPattern.cpp +++ b/lib/Target/Alpha/AlphaISelPattern.cpp @@ -604,37 +604,48 @@ void AlphaISel::EmitFunctionEntryCode(Function &Fn, MachineFunction &MF) { } } -//Find the offset of the arg in it's parent's function -static int getValueOffset(const Value* v) +static void getValueInfo(const Value* v, int& type, int& fun, int& offset) { - if (v == NULL) - return 0; - - const Instruction* itarget = dyn_cast(v); - const BasicBlock* btarget = itarget->getParent(); - const Function* ftarget = btarget->getParent(); - - //offset due to earlier BBs - int i = 1; - for(Function::const_iterator ii = ftarget->begin(); &*ii != btarget; ++ii) - i += ii->size(); - - for(BasicBlock::const_iterator ii = btarget->begin(); &*ii != itarget; ++ii) - ++i; - - return i; -} -//Find the offset of the function in it's module -static int getFunctionOffset(const Function* fun) -{ - const Module* M = fun->getParent(); - - //offset due to earlier BBs - int i = 0; - for(Module::const_iterator ii = M->begin(); &*ii != fun; ++ii) - ++i; - - return i; + if (v == NULL) { + type = 0; + fun = 0; + offset = 0; + } else if (const GlobalValue* GV = dyn_cast(v)) { + type = 1; + fun = 1; + const Module* M = GV->getParent(); + int i = 0; + for(Module::const_global_iterator ii = M->global_begin(); &*ii != GV; ++ii) + ++i; + offset = i; + } else if (const Argument* Arg = dyn_cast(v)) { + type = 2; + const Function* F = Arg->getParent(); + const Module* M = F->getParent(); + int i = 0; + for(Module::const_iterator ii = M->begin(); &*ii != F; ++ii) + ++i; + fun = i; + i = 0; + for(Function::const_arg_iterator ii = F->arg_begin(); &*ii != Arg; ++ii) + ++i; + offset = i; + } else if (const Instruction* I = dyn_cast(v)) { + type = 3; + const BasicBlock* bb = I->getParent(); + const Function* F = bb->getParent(); + const Module* M = F->getParent(); + int i = 0; + for(Module::const_iterator ii = M->begin(); &*ii != F; ++ii) + ++i; + fun = i; + i = 0; + for(Function::const_iterator ii = F->begin(); &*ii != bb; ++ii) + i += ii->size(); + for(BasicBlock::const_iterator ii = bb->begin(); &*ii != I; ++ii) + ++i; + offset = i; + } } static int getUID() @@ -1244,18 +1255,18 @@ unsigned AlphaISel::SelectExpr(SDOperand N) { assert(opcode != ISD::SEXTLOAD && "Not zext"); break; } - int i = 0, j = 0; - if (EnableAlphaLSMark) { - i = getValueOffset(dyn_cast(N.getOperand(2)) - ->getValue()); - j = getFunctionOffset(BB->getParent()->getFunction()); - } + int i, j, k; + if (EnableAlphaLSMark) + getValueInfo(dyn_cast(N.getOperand(2))->getValue(), + i, j, k); + if (GlobalAddressSDNode *GASD = dyn_cast(Address)) { if (GASD->getGlobal()->isExternal()) { Tmp1 = SelectExpr(Address); if (EnableAlphaLSMark) - BuildMI(BB, Alpha::MEMLABEL, 3).addImm(j).addImm(i).addImm(getUID()); + BuildMI(BB, Alpha::MEMLABEL, 4).addImm(i).addImm(j).addImm(k) + .addImm(getUID()); BuildMI(BB, Opc, 2, Result).addImm(0).addReg(Tmp1); } else { Tmp1 = MakeReg(MVT::i64); @@ -1263,7 +1274,8 @@ unsigned AlphaISel::SelectExpr(SDOperand N) { BuildMI(BB, Alpha::LDAHr, 2, Tmp1) .addGlobalAddress(GASD->getGlobal()).addReg(Alpha::R29); if (EnableAlphaLSMark) - BuildMI(BB, Alpha::MEMLABEL, 3).addImm(j).addImm(i).addImm(getUID()); + BuildMI(BB, Alpha::MEMLABEL, 4).addImm(i).addImm(j).addImm(k) + .addImm(getUID()); BuildMI(BB, GetRelVersion(Opc), 2, Result) .addGlobalAddress(GASD->getGlobal()).addReg(Tmp1); } @@ -1274,12 +1286,14 @@ unsigned AlphaISel::SelectExpr(SDOperand N) { BuildMI(BB, Alpha::LDAHr, 2, Tmp1).addConstantPoolIndex(CP->getIndex()) .addReg(Alpha::R29); if (EnableAlphaLSMark) - BuildMI(BB, Alpha::MEMLABEL, 3).addImm(j).addImm(i).addImm(getUID()); + BuildMI(BB, Alpha::MEMLABEL, 4).addImm(i).addImm(j).addImm(k) + .addImm(getUID()); BuildMI(BB, GetRelVersion(Opc), 2, Result) .addConstantPoolIndex(CP->getIndex()).addReg(Tmp1); } else if(Address.getOpcode() == ISD::FrameIndex) { if (EnableAlphaLSMark) - BuildMI(BB, Alpha::MEMLABEL, 3).addImm(j).addImm(i).addImm(getUID()); + BuildMI(BB, Alpha::MEMLABEL, 4).addImm(i).addImm(j).addImm(k) + .addImm(getUID()); BuildMI(BB, Opc, 2, Result) .addFrameIndex(cast(Address)->getIndex()) .addReg(Alpha::F31); @@ -1287,7 +1301,8 @@ unsigned AlphaISel::SelectExpr(SDOperand N) { long offset; SelectAddr(Address, Tmp1, offset); if (EnableAlphaLSMark) - BuildMI(BB, Alpha::MEMLABEL, 3).addImm(j).addImm(i).addImm(getUID()); + BuildMI(BB, Alpha::MEMLABEL, 4).addImm(i).addImm(j).addImm(k) + .addImm(getUID()); BuildMI(BB, Opc, 2, Result).addImm(offset).addReg(Tmp1); } return Result; @@ -1298,7 +1313,8 @@ unsigned AlphaISel::SelectExpr(SDOperand N) { has_sym = true; if (EnableAlphaLSMark) - BuildMI(BB, Alpha::MEMLABEL, 3).addImm(0).addImm(1).addImm(getUID()); + BuildMI(BB, Alpha::MEMLABEL, 4).addImm(0).addImm(0).addImm(0) + .addImm(getUID()); BuildMI(BB, Alpha::LDQl, 2, Result) .addGlobalAddress(cast(N)->getGlobal()) @@ -2268,19 +2284,18 @@ void AlphaISel::Select(SDOperand N) { } } - int i = 0, j = 0; - if (EnableAlphaLSMark) { - i = - getValueOffset(dyn_cast(N.getOperand(3))->getValue()); - j = getFunctionOffset(BB->getParent()->getFunction()); - } + int i, j, k; + if (EnableAlphaLSMark) + getValueInfo(dyn_cast(N.getOperand(3))->getValue(), + i, j, k); if (GlobalAddressSDNode *GASD = dyn_cast(Address)) { if (GASD->getGlobal()->isExternal()) { Tmp2 = SelectExpr(Address); if (EnableAlphaLSMark) - BuildMI(BB, Alpha::MEMLABEL, 3).addImm(j).addImm(i).addImm(getUID()); + BuildMI(BB, Alpha::MEMLABEL, 4).addImm(i).addImm(j).addImm(k) + .addImm(getUID()); BuildMI(BB, Opc, 3).addReg(Tmp1).addImm(0).addReg(Tmp2); } else { Tmp2 = MakeReg(MVT::i64); @@ -2288,13 +2303,15 @@ void AlphaISel::Select(SDOperand N) { BuildMI(BB, Alpha::LDAHr, 2, Tmp2) .addGlobalAddress(GASD->getGlobal()).addReg(Alpha::R29); if (EnableAlphaLSMark) - BuildMI(BB, Alpha::MEMLABEL, 3).addImm(j).addImm(i).addImm(getUID()); + BuildMI(BB, Alpha::MEMLABEL, 4).addImm(i).addImm(j).addImm(k) + .addImm(getUID()); BuildMI(BB, GetRelVersion(Opc), 3).addReg(Tmp1) .addGlobalAddress(GASD->getGlobal()).addReg(Tmp2); } } else if(Address.getOpcode() == ISD::FrameIndex) { if (EnableAlphaLSMark) - BuildMI(BB, Alpha::MEMLABEL, 3).addImm(j).addImm(i).addImm(getUID()); + BuildMI(BB, Alpha::MEMLABEL, 4).addImm(i).addImm(j).addImm(k) + .addImm(getUID()); BuildMI(BB, Opc, 3).addReg(Tmp1) .addFrameIndex(cast(Address)->getIndex()) .addReg(Alpha::F31); @@ -2302,7 +2319,8 @@ void AlphaISel::Select(SDOperand N) { long offset; SelectAddr(Address, Tmp2, offset); if (EnableAlphaLSMark) - BuildMI(BB, Alpha::MEMLABEL, 3).addImm(j).addImm(i).addImm(getUID()); + BuildMI(BB, Alpha::MEMLABEL, 4).addImm(i).addImm(j).addImm(k) + .addImm(getUID()); BuildMI(BB, Opc, 3).addReg(Tmp1).addImm(offset).addReg(Tmp2); } return; diff --git a/lib/Target/Alpha/AlphaInstrInfo.td b/lib/Target/Alpha/AlphaInstrInfo.td index b7489fbcdd5..9f63ecadf56 100644 --- a/lib/Target/Alpha/AlphaInstrInfo.td +++ b/lib/Target/Alpha/AlphaInstrInfo.td @@ -31,7 +31,8 @@ def ADJUSTSTACKUP : PseudoInstAlpha<(ops ), "ADJUP">; def ADJUSTSTACKDOWN : PseudoInstAlpha<(ops ), "ADJDOWN">; def ALTENT : PseudoInstAlpha<(ops s64imm:$TARGET), "$TARGET:\n">; def PCLABEL : PseudoInstAlpha<(ops s64imm:$num), "PCMARKER_$num:\n">; -def MEMLABEL : PseudoInstAlpha<(ops s64imm:$i, s64imm:$j, s64imm:$k), "LSMARKER$$$i$$$j$$$k:\n">; +def MEMLABEL : PseudoInstAlpha<(ops s64imm:$i, s64imm:$j, s64imm:$k, s64imm:$m), + "LSMARKER$$$i$$$j$$$k$$$m:\n">; //***************** //These are shortcuts, the assembler expands them