From alenhar2 at cs.uiuc.edu Mon Feb 7 00:21:50 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Mon, 7 Feb 2005 00:21:50 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp Message-ID: <200502070621.AAA19667@niobe.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.43 -> 1.44 --- Log message: copyfromreg fix --- Diffs of the changes: (+6 -3) AlphaISelPattern.cpp | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.43 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.44 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.43 Sun Feb 6 23:55:55 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Mon Feb 7 00:21:37 2005 @@ -589,8 +589,11 @@ } if (DestType == MVT::f64 || DestType == MVT::f32 || - (opcode == ISD::LOAD && - (N.getValue(0).getValueType() == MVT::f32 || N.getValue(0).getValueType() == MVT::f64))) + ( + (opcode == ISD::LOAD || opcode == ISD::CopyFromReg || opcode == ISD::EXTLOAD) && + (N.getValue(0).getValueType() == MVT::f32 || N.getValue(0).getValueType() == MVT::f64) + ) + ) return SelectExprFP(N, Result); switch (opcode) { @@ -747,7 +750,7 @@ { //no need to restore GP as we are doing an indirect call Tmp1 = SelectExpr(N.getOperand(1)); - BuildMI(BB, Alpha::BIS, 2, Alpha::R27).addReg(Tmp1).addReg(Tmp1); + BuildMI(BB, Alpha::BIS, 2, Alpha::R27).addReg(Tmp1).addReg(Tmp1); BuildMI(BB, Alpha::JSR, 2, Alpha::R26).addReg(Alpha::R27).addImm(0); } From alenhar2 at cs.uiuc.edu Mon Feb 7 00:31:56 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Mon, 7 Feb 2005 00:31:56 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp Message-ID: <200502070631.AAA19697@niobe.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.44 -> 1.45 --- Log message: copytoreg fix --- Diffs of the changes: (+6 -6) AlphaISelPattern.cpp | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.44 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.45 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.44 Mon Feb 7 00:21:37 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Mon Feb 7 00:31:44 2005 @@ -424,7 +424,7 @@ else Result = ExprMap[N.getValue(0)] = MakeReg(N.getValue(0).getValueType()); - //DestType = N.getValue(0).getValueType(); + DestType = N.getValue(0).getValueType(); SDOperand Chain = N.getOperand(0); SDOperand Address = N.getOperand(1); @@ -503,27 +503,24 @@ { AlphaLowering.restoreGP(BB); BuildMI(BB, Alpha::LDS_SYM, 1, Tmp1).addGlobalAddress(cast(Address)->getGlobal()); - BuildMI(BB, Alpha::CVTST, 1, Result).addReg(Tmp1); } else if (ConstantPoolSDNode *CP = dyn_cast(N.getOperand(1))) { AlphaLowering.restoreGP(BB); BuildMI(BB, Alpha::LDS_SYM, 1, Tmp1).addConstantPoolIndex(CP->getIndex()); - BuildMI(BB, Alpha::CVTST, 1, Result).addReg(Tmp1); } else if(Address.getOpcode() == ISD::FrameIndex) { Tmp2 = cast(Address)->getIndex(); BuildMI(BB, Alpha::LDS, 2, Tmp1).addFrameIndex(Tmp2).addReg(Alpha::F31); - BuildMI(BB, Alpha::CVTST, 1, Result).addReg(Tmp1); } else { long offset; SelectAddr(Address, Tmp2, offset); BuildMI(BB, Alpha::LDS, 1, Tmp1).addImm(offset).addReg(Tmp2); - BuildMI(BB, Alpha::CVTST, 1, Result).addReg(Tmp1); } + BuildMI(BB, Alpha::CVTST, 1, Result).addReg(Tmp1); return Result; } @@ -1222,7 +1219,10 @@ Tmp2 = cast(N)->getReg(); if (Tmp1 != Tmp2) { - BuildMI(BB, Alpha::BIS, 2, Tmp2).addReg(Tmp1).addReg(Tmp1); + if (N.getOperand(1).getValueType() == MVT::f64 || N.getOperand(1).getValueType() == MVT::f32) + BuildMI(BB, Alpha::CPYS, 2, Tmp2).addReg(Tmp1).addReg(Tmp1); + else + BuildMI(BB, Alpha::BIS, 2, Tmp2).addReg(Tmp1).addReg(Tmp1); } return; From lattner at cs.uiuc.edu Mon Feb 7 10:09:17 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 7 Feb 2005 10:09:17 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/DataStructure/DataStructure.h Message-ID: <200502071609.j17G9HDP010956@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis/DataStructure: DataStructure.h updated: 1.84 -> 1.85 --- Log message: Hopefully fix the build on Darwin with GCC 3.3 --- Diffs of the changes: (+1 -1) DataStructure.h | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/include/llvm/Analysis/DataStructure/DataStructure.h diff -u llvm/include/llvm/Analysis/DataStructure/DataStructure.h:1.84 llvm/include/llvm/Analysis/DataStructure/DataStructure.h:1.85 --- llvm/include/llvm/Analysis/DataStructure/DataStructure.h:1.84 Fri Feb 4 13:57:57 2005 +++ llvm/include/llvm/Analysis/DataStructure/DataStructure.h Mon Feb 7 10:09:01 2005 @@ -97,7 +97,7 @@ // This map is only maintained during construction of BU Graphs std::map, - std::pair > > IndCallGraphMap; + std::pair > > *IndCallGraphMap; public: ~BUDataStructures() { releaseMemory(); } From lattner at cs.uiuc.edu Mon Feb 7 10:09:28 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 7 Feb 2005 10:09:28 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp Message-ID: <200502071609.j17G9STH010965@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: BottomUpClosure.cpp updated: 1.92 -> 1.93 --- Log message: IndCallGraphMap is now a pointer to a new'd map. --- Diffs of the changes: (+6 -3) BottomUpClosure.cpp | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) Index: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp diff -u llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.92 llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.93 --- llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.92 Fri Feb 4 13:59:49 2005 +++ llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp Mon Feb 7 10:09:15 2005 @@ -40,6 +40,9 @@ GlobalsGraph = new DSGraph(LocalDSA.getGlobalsGraph()); GlobalsGraph->setPrintAuxCalls(); + IndCallGraphMap = new std::map, + std::pair > >(); + std::vector Stack; hash_map ValMap; unsigned NextID = 1; @@ -64,11 +67,11 @@ // If we computed any temporary indcallgraphs, free them now. for (std::map, std::pair > >::iterator I = - IndCallGraphMap.begin(), E = IndCallGraphMap.end(); I != E; ++I) { + IndCallGraphMap->begin(), E = IndCallGraphMap->end(); I != E; ++I) { I->second.second.clear(); // Drop arg refs into the graph. delete I->second.first; } - IndCallGraphMap.clear(); + delete IndCallGraphMap; // At the end of the bottom-up pass, the globals graph becomes complete. // FIXME: This is not the right way to do this, but it is sorta better than @@ -340,7 +343,7 @@ // See if we already computed a graph for this set of callees. std::sort(CalledFuncs.begin(), CalledFuncs.end()); std::pair > &IndCallGraph = - IndCallGraphMap[CalledFuncs]; + (*IndCallGraphMap)[CalledFuncs]; if (IndCallGraph.first == 0) { std::vector::iterator I = CalledFuncs.begin(), From alenhar2 at cs.uiuc.edu Mon Feb 7 17:02:38 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Mon, 7 Feb 2005 17:02:38 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp AlphaInstrInfo.td Message-ID: <200502072302.RAA12160@niobe.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.45 -> 1.46 AlphaInstrInfo.td updated: 1.21 -> 1.22 --- Log message: fix store issue and an FP conversion (segfault) issue --- Diffs of the changes: (+21 -11) AlphaISelPattern.cpp | 30 ++++++++++++++++++++---------- AlphaInstrInfo.td | 2 +- 2 files changed, 21 insertions(+), 11 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.45 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.46 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.45 Mon Feb 7 00:31:44 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Mon Feb 7 17:02:23 2005 @@ -1164,14 +1164,16 @@ void ISel::Select(SDOperand N) { unsigned Tmp1, Tmp2, Opc; + unsigned opcode = N.getOpcode(); // FIXME: Disable for our current expansion model! if (/*!N->hasOneUse() &&*/ !ExprMap.insert(std::make_pair(N, notIn)).second) return; // Already selected. SDNode *Node = N.Val; + - switch (N.getOpcode()) { + switch (opcode) { default: Node->dump(); std::cerr << "\n"; @@ -1267,16 +1269,24 @@ Select(Chain); Tmp1 = SelectExpr(Value); //value - switch(Value.getValueType()) { - default: assert(0 && "unknown Type in store"); - case MVT::i64: Opc = Alpha::STQ; break; - case MVT::f64: Opc = Alpha::STT; break; - case MVT::f32: Opc = Alpha::STS; break; - case MVT::i1: //FIXME: DAG does not promote this load - case MVT::i8: Opc = Alpha::STB; break; - case MVT::i16: Opc = Alpha::STW; break; - case MVT::i32: Opc = Alpha::STL; break; + + if (opcode == ISD::STORE) { + switch(Value.getValueType()) { + default: assert(0 && "unknown Type in store"); + case MVT::i64: Opc = Alpha::STQ; break; + case MVT::f64: Opc = Alpha::STT; break; + case MVT::f32: Opc = Alpha::STS; break; + } + } else { //ISD::TRUNCSTORE + switch(cast(Node)->getExtraValueType()) { + default: assert(0 && "unknown Type in store"); + case MVT::i1: //FIXME: DAG does not promote this load + case MVT::i8: Opc = Alpha::STB; break; + case MVT::i16: Opc = Alpha::STW; break; + case MVT::i32: Opc = Alpha::STL; break; + } } + if (Address.getOpcode() == ISD::GlobalAddress) { AlphaLowering.restoreGP(BB); Index: llvm/lib/Target/Alpha/AlphaInstrInfo.td diff -u llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.21 llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.22 --- llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.21 Sun Feb 6 10:22:15 2005 +++ llvm/lib/Target/Alpha/AlphaInstrInfo.td Mon Feb 7 17:02:23 2005 @@ -358,7 +358,7 @@ //CVTQL F-P 17.030 Convert quadword to longword def CVTQS : FPForm<0x16, 0x0BC, (ops FPRC:$RC, FPRC:$RA), "cvtqs $RA,$RC">; //Convert quadword to S_floating def CVTQT : FPForm<0x16, 0x0BE, (ops FPRC:$RC, FPRC:$RA), "cvtqt $RA,$RC">; //Convert quadword to T_floating -def CVTST : FPForm<0x16, 0x2AC, (ops FPRC:$RC, FPRC:$RA), "cvtst $RA,$RC">; //Convert S_floating to T_floating +def CVTST : FPForm<0x16, 0x2AC, (ops FPRC:$RC, FPRC:$RA), "cvtsts $RA,$RC">; //Convert S_floating to T_floating (use completion, may not have function code for that set right) def CVTTQ : FPForm<0x16, 0x0AF, (ops FPRC:$RC, FPRC:$RA), "cvttq $RA,$RC">; //Convert T_floating to quadword def CVTTS : FPForm<0x16, 0x2AC, (ops FPRC:$RC, FPRC:$RA), "cvtts $RA,$RC">; //Convert T_floating to S_floating From alenhar2 at cs.uiuc.edu Mon Feb 7 18:40:18 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Mon, 7 Feb 2005 18:40:18 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp Message-ID: <200502080040.SAA16221@niobe.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.46 -> 1.47 --- Log message: BranchCC, nifty --- Diffs of the changes: (+117 -7) AlphaISelPattern.cpp | 124 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 117 insertions(+), 7 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.46 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.47 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.46 Mon Feb 7 17:02:23 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Mon Feb 7 18:40:03 2005 @@ -288,6 +288,9 @@ static const unsigned notIn = (unsigned)(-1); std::map ExprMap; + //CCInvMap sometimes (SetNE) we have the inverse CC code for free + std::map CCInvMap; + public: ISel(TargetMachine &TM) : SelectionDAGISel(AlphaLowering), AlphaLowering(TM) { } @@ -300,6 +303,7 @@ // Clear state used for selection. ExprMap.clear(); + CCInvMap.clear(); } unsigned SelectExpr(SDOperand N); @@ -307,6 +311,7 @@ void Select(SDOperand N); void SelectAddr(SDOperand N, unsigned& Reg, long& offset); + void SelectBranchCC(SDOperand N); }; } @@ -354,6 +359,115 @@ return; } +void ISel::SelectBranchCC(SDOperand N) +{ + assert(N.getOpcode() == ISD::BRCOND && "Not a BranchCC???"); + MachineBasicBlock *Dest = cast(N.getOperand(2))->getBasicBlock(); + unsigned Opc; + + Select(N.getOperand(0)); //chain + SDOperand CC = N.getOperand(1); + + if (CC.getOpcode() == ISD::SETCC) + { + SetCCSDNode* SetCC = dyn_cast(CC.Val); + if (MVT::isInteger(SetCC->getOperand(0).getValueType())) { + //Dropping the CC is only useful if we are comparing to 0 + bool isZero0 = false; + bool isZero1 = false; + bool isNE = false; + + if(SetCC->getOperand(0).getOpcode() == ISD::Constant && + cast(SetCC->getOperand(0))->getValue() == 0) + isZero0 = true; + if(SetCC->getOperand(1).getOpcode() == ISD::Constant && + cast(SetCC->getOperand(1))->getValue() == 0) + isZero1 = true; + if(SetCC->getCondition() == ISD::SETNE) + isNE = true; + + if (isZero0) + { + switch (SetCC->getCondition()) { + default: CC.Val->dump(); assert(0 && "Unknown integer comparison!"); + case ISD::SETEQ: Opc = Alpha::BEQ; break; + case ISD::SETLT: Opc = Alpha::BGT; break; + case ISD::SETLE: Opc = Alpha::BGE; break; + case ISD::SETGT: Opc = Alpha::BLT; break; + case ISD::SETGE: Opc = Alpha::BLE; break; + case ISD::SETULT: Opc = Alpha::BNE; break; + case ISD::SETUGT: assert(0 && "0 > (unsigned) x is never true"); break; + case ISD::SETULE: assert(0 && "0 <= (unsigned) x is always true"); break; + case ISD::SETUGE: Opc = Alpha::BEQ; break; //Technically you could have this CC + case ISD::SETNE: Opc = Alpha::BNE; break; + } + unsigned Tmp1 = SelectExpr(SetCC->getOperand(1)); + BuildMI(BB, Opc, 2).addReg(Tmp1).addMBB(Dest); + return; + } + else if (isZero1) + { + switch (SetCC->getCondition()) { + default: CC.Val->dump(); assert(0 && "Unknown integer comparison!"); + case ISD::SETEQ: Opc = Alpha::BEQ; break; + case ISD::SETLT: Opc = Alpha::BLT; break; + case ISD::SETLE: Opc = Alpha::BLE; break; + case ISD::SETGT: Opc = Alpha::BGT; break; + case ISD::SETGE: Opc = Alpha::BGE; break; + case ISD::SETULT: assert(0 && "x (unsigned) < 0 is never true"); break; + case ISD::SETUGT: Opc = Alpha::BNE; break; + case ISD::SETULE: Opc = Alpha::BEQ; break; //Technically you could have this CC + case ISD::SETUGE: assert(0 && "x (unsgined >= 0 is always true"); break; + case ISD::SETNE: Opc = Alpha::BNE; break; + } + unsigned Tmp1 = SelectExpr(SetCC->getOperand(0)); + BuildMI(BB, Opc, 2).addReg(Tmp1).addMBB(Dest); + return; + } + else + { + unsigned Tmp1 = SelectExpr(CC); + if (isNE) + BuildMI(BB, Alpha::BEQ, 2).addReg(CCInvMap[CC]).addMBB(Dest); + else + BuildMI(BB, Alpha::BNE, 2).addReg(Tmp1).addMBB(Dest); + return; + } + } else { //FP + //Any comparison between 2 values should be codegened as an folded branch, as moving + //CC to the integer register is very expensive + //for a cmp b: c = a - b; + //a = b: c = 0 + //a < b: c < 0 + //a > b: c > 0 + unsigned Tmp1 = SelectExpr(SetCC->getOperand(0)); + unsigned Tmp2 = SelectExpr(SetCC->getOperand(1)); + unsigned Tmp3 = MakeReg(MVT::f64); + BuildMI(BB, Alpha::SUBT, 2, Tmp3).addReg(Tmp1).addReg(Tmp2); + + switch (SetCC->getCondition()) { + default: CC.Val->dump(); assert(0 && "Unknown FP comparison!"); + case ISD::SETEQ: Opc = Alpha::FBEQ; break; + case ISD::SETLT: Opc = Alpha::FBLT; break; + case ISD::SETLE: Opc = Alpha::FBLE; break; + case ISD::SETGT: Opc = Alpha::FBGT; break; + case ISD::SETGE: Opc = Alpha::FBGE; break; + case ISD::SETNE: Opc = Alpha::FBNE; break; + } + BuildMI(BB, Opc, 2).addReg(Tmp3).addMBB(Dest); + return; + } + abort(); //Should never be reached + } + else + { //Giveup and do the stupid thing + unsigned Tmp1 = SelectExpr(CC); + BuildMI(BB, Alpha::BNE, 2).addReg(Tmp1).addMBB(Dest); + return; + } + abort(); //Should never be reached +} + unsigned ISel::SelectExprFP(SDOperand N, unsigned Result) { unsigned Tmp1, Tmp2, Tmp3; @@ -886,6 +1000,8 @@ Tmp2 = SelectExpr(N.getOperand(1)); Tmp3 = MakeReg(MVT::i64); BuildMI(BB, Alpha::CMPEQ, 2, Tmp3).addReg(Tmp1).addReg(Tmp2); + //Remeber we have the Inv for this CC + CCInvMap[N] = Tmp3; //and invert BuildMI(BB, Alpha::CMPEQ, 2, Result).addReg(Alpha::R31).addReg(Tmp3); return Result; @@ -1180,13 +1296,7 @@ assert(0 && "Node not handled yet!"); case ISD::BRCOND: { - MachineBasicBlock *Dest = - cast(N.getOperand(2))->getBasicBlock(); - - Select(N.getOperand(0)); //chain - - Tmp1 = SelectExpr(N.getOperand(1)); - BuildMI(BB, Alpha::BNE, 2).addReg(Tmp1).addMBB(Dest); + SelectBranchCC(N); return; } From alkis at cs.uiuc.edu Mon Feb 7 19:38:01 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon, 7 Feb 2005 19:38:01 -0600 Subject: [llvm-commits] CVS: llvm-java/test/Programs/SingleSource/UnitTests/Lists1.java Message-ID: <200502080138.TAA30752@zion.cs.uiuc.edu> Changes in directory llvm-java/test/Programs/SingleSource/UnitTests: Lists1.java updated: 1.1 -> 1.2 --- Log message: Make this test fail. --- Diffs of the changes: (+1 -1) Lists1.java | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm-java/test/Programs/SingleSource/UnitTests/Lists1.java diff -u llvm-java/test/Programs/SingleSource/UnitTests/Lists1.java:1.1 llvm-java/test/Programs/SingleSource/UnitTests/Lists1.java:1.2 --- llvm-java/test/Programs/SingleSource/UnitTests/Lists1.java:1.1 Sat Dec 11 20:48:43 2004 +++ llvm-java/test/Programs/SingleSource/UnitTests/Lists1.java Mon Feb 7 19:37:50 2005 @@ -4,7 +4,7 @@ { public static void main(String[] args) { List list = new LinkedList(); - for (int i = 0; i < 10; ++i) { + for (int i = 0; i < 17; ++i) { list.add(new Integer(i)); } From alkis at cs.uiuc.edu Mon Feb 7 19:38:13 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon, 7 Feb 2005 19:38:13 -0600 Subject: [llvm-commits] CVS: llvm-java/test/Programs/SingleSource/UnitTests/Test.java Message-ID: <200502080138.TAA30770@zion.cs.uiuc.edu> Changes in directory llvm-java/test/Programs/SingleSource/UnitTests: Test.java updated: 1.6 -> 1.7 --- Log message: Add new method. --- Diffs of the changes: (+3 -0) Test.java | 3 +++ 1 files changed, 3 insertions(+) Index: llvm-java/test/Programs/SingleSource/UnitTests/Test.java diff -u llvm-java/test/Programs/SingleSource/UnitTests/Test.java:1.6 llvm-java/test/Programs/SingleSource/UnitTests/Test.java:1.7 --- llvm-java/test/Programs/SingleSource/UnitTests/Test.java:1.6 Thu Dec 16 16:45:55 2004 +++ llvm-java/test/Programs/SingleSource/UnitTests/Test.java Mon Feb 7 19:38:02 2005 @@ -9,6 +9,9 @@ public static native void println(long l); public static native void println(float f); public static native void println(double d); + public static void println(Object o) { + println(o.toString()); + } public static void println(String s) { byte[] bytes = new byte[s.length()]; s.getBytes(0, s.length(), bytes, 0); From alkis at cs.uiuc.edu Mon Feb 7 20:21:34 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon, 7 Feb 2005 20:21:34 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Transforms/ Message-ID: <200502080221.UAA31351@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Transforms: --- Log message: Directory /home/vadve/shared/PublicCVS/llvm-java/lib/Transforms added to the repository --- Diffs of the changes: (+0 -0) 0 files changed From alkis at cs.uiuc.edu Mon Feb 7 20:26:44 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon, 7 Feb 2005 20:26:44 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Makefile Message-ID: <200502080226.UAA31477@zion.cs.uiuc.edu> Changes in directory llvm-java/lib: Makefile updated: 1.3 -> 1.4 --- Log message: Remove the hack from compiler that adds stub returns to undefined functions. Use a pass instead to add stubs after we link a module with the runtime. --- Diffs of the changes: (+1 -1) Makefile | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm-java/lib/Makefile diff -u llvm-java/lib/Makefile:1.3 llvm-java/lib/Makefile:1.4 --- llvm-java/lib/Makefile:1.3 Sat May 22 01:09:42 2004 +++ llvm-java/lib/Makefile Mon Feb 7 20:26:32 2005 @@ -8,6 +8,6 @@ ##===----------------------------------------------------------------------===## LEVEL := .. -PARALLEL_DIRS := ClassFile Compiler +PARALLEL_DIRS := ClassFile Compiler Transforms include $(LEVEL)/Makefile.common From alkis at cs.uiuc.edu Mon Feb 7 20:26:44 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon, 7 Feb 2005 20:26:44 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Transforms/StubAdder.cpp Makefile Message-ID: <200502080226.UAA31487@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Transforms: StubAdder.cpp added (r1.1) Makefile added (r1.1) --- Log message: Remove the hack from compiler that adds stub returns to undefined functions. Use a pass instead to add stubs after we link a module with the runtime. --- Diffs of the changes: (+54 -0) Makefile | 14 ++++++++++++++ StubAdder.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) Index: llvm-java/lib/Transforms/StubAdder.cpp diff -c /dev/null llvm-java/lib/Transforms/StubAdder.cpp:1.1 *** /dev/null Mon Feb 7 20:26:42 2005 --- llvm-java/lib/Transforms/StubAdder.cpp Mon Feb 7 20:26:32 2005 *************** *** 0 **** --- 1,40 ---- + //===- Hello.cpp - Example code from "Writing an LLVM Pass" ---------------===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file implements two versions of the LLVM "Hello World" pass described + // in docs/WritingAnLLVMPass.html + // + //===----------------------------------------------------------------------===// + + #include "llvm/Pass.h" + #include "llvm/Function.h" + #include "llvm/Module.h" + #include "llvm/Type.h" + #include "llvm/Instructions.h" + #include "llvm/Constants.h" + + using namespace llvm; + + namespace { + // Hello - The first implementation, without getAnalysisUsage. + struct StubAdder : public ModulePass { + virtual bool runOnModule(Module &M) { + for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) + if (F->empty() && F->getName().find("java") != std::string::npos) { + BasicBlock* entry = new BasicBlock("entry", F); + if (F->getReturnType() == Type::VoidTy) + new ReturnInst(NULL, entry); + else + new ReturnInst(UndefValue::get(F->getReturnType()), entry); + } + return true; + } + }; + RegisterOpt X("stubadder", "Stub Adder Pass"); + } Index: llvm-java/lib/Transforms/Makefile diff -c /dev/null llvm-java/lib/Transforms/Makefile:1.1 *** /dev/null Mon Feb 7 20:26:44 2005 --- llvm-java/lib/Transforms/Makefile Mon Feb 7 20:26:32 2005 *************** *** 0 **** --- 1,14 ---- + ##===- lib/Transforms/Makefile -----------------------------*- Makefile -*-===## + # + # The LLVM Compiler Infrastructure + # + # This file was developed by the LLVM research group and is distributed under + # the University of Illinois Open Source License. See LICENSE.TXT for details. + # + ##===----------------------------------------------------------------------===## + LEVEL = ../.. + LIBRARYNAME = LLVMJavaTransforms + SHARED_LIBRARY = 1 + LOADABLE_MODULE = 1 + + include $(LEVEL)/Makefile.common From alkis at cs.uiuc.edu Mon Feb 7 20:26:44 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon, 7 Feb 2005 20:26:44 -0600 Subject: [llvm-commits] CVS: llvm-java/test/Makefile.test Message-ID: <200502080226.UAA31495@zion.cs.uiuc.edu> Changes in directory llvm-java/test: Makefile.test updated: 1.37 -> 1.38 --- Log message: Remove the hack from compiler that adds stub returns to undefined functions. Use a pass instead to add stubs after we link a module with the runtime. --- Diffs of the changes: (+2 -0) Makefile.test | 2 ++ 1 files changed, 2 insertions(+) Index: llvm-java/test/Makefile.test diff -u llvm-java/test/Makefile.test:1.37 llvm-java/test/Makefile.test:1.38 --- llvm-java/test/Makefile.test:1.37 Fri Feb 4 10:14:54 2005 +++ llvm-java/test/Makefile.test Mon Feb 7 20:26:32 2005 @@ -21,6 +21,8 @@ %.llvm %.llvm.bc: %.linked.bc $(LibDir)/libjrt.bca $(EXTRA_OBJS) $(LOPT) $(Echo) Linking $< with the Java runtime -$(Verb)$(GCCLD) -o=$*.llvm $< -L $(CFERuntimeLibDir) -L $(LibDir) $(EXTRA_OBJS) + -$(Verb)$(LOPT) -load $(LibDir)/LLVMJavaTransforms -stubadder -f -o=$*.stubbed.llvm.bc $*.llvm.bc + -$(Verb)$(MV) -f $*.stubbed.llvm.bc $*.llvm.bc # rule to link raw bytecode with runtime %.raw.llvm %.raw.llvm.bc: %.raw.bc $(LibDir)/libjrt.bca $(EXTRA_OBJS) $(LOPT) From alkis at cs.uiuc.edu Mon Feb 7 20:26:44 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon, 7 Feb 2005 20:26:44 -0600 Subject: [llvm-commits] CVS: llvm-java/test/Programs/SingleSource/Makefile.singlesrc Message-ID: <200502080226.UAA31481@zion.cs.uiuc.edu> Changes in directory llvm-java/test/Programs/SingleSource: Makefile.singlesrc updated: 1.18 -> 1.19 --- Log message: Remove the hack from compiler that adds stub returns to undefined functions. Use a pass instead to add stubs after we link a module with the runtime. --- Diffs of the changes: (+1 -14) Makefile.singlesrc | 15 +-------------- 1 files changed, 1 insertion(+), 14 deletions(-) Index: llvm-java/test/Programs/SingleSource/Makefile.singlesrc diff -u llvm-java/test/Programs/SingleSource/Makefile.singlesrc:1.18 llvm-java/test/Programs/SingleSource/Makefile.singlesrc:1.19 --- llvm-java/test/Programs/SingleSource/Makefile.singlesrc:1.18 Fri Feb 4 10:14:54 2005 +++ llvm-java/test/Programs/SingleSource/Makefile.singlesrc Mon Feb 7 20:26:32 2005 @@ -8,21 +8,8 @@ ##===----------------------------------------------------------------------===## # rule to build raw bytecode from a classfile -%.raw.bc: %.class $(CLASS2LLVM) +%.linked.bc: %.class $(CLASS2LLVM) $(Echo) Compiling $< to bytecode -$(Verb)$(CLASS2LLVM) -cp $(CLASSPATH):Output $(subst /,.,$(*F)) -o=$@ -OPT_PASSES := -simplifycfg -mem2reg -globalopt -globaldce \ - -ipsccp -simplifycfg -deadargelim -instcombine -simplifycfg \ - -inline -argpromotion -raise -tailduplicate -simplifycfg \ - -scalarrepl -instcombine -tailcallelim -simplifycfg \ - -licm -instcombine -indvars -loop-unroll -instcombine \ - -load-vn -gcse -sccp -instcombine -dse -adce -simplifycfg \ - -deadtypeelim -constmerge - -# optimize raw bytecode -%.linked.bc: %.raw.bc $(LOPT) - $(Echo) Optimizing $< - -$(Verb)$(LOPT) $(OPT_PASSES) -f -o=$@ $< - include $(LEVEL)/test/Makefile.test From alkis at cs.uiuc.edu Mon Feb 7 20:26:44 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon, 7 Feb 2005 20:26:44 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200502080226.UAA31491@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.217 -> 1.218 --- Log message: Remove the hack from compiler that adds stub returns to undefined functions. Use a pass instead to add stubs after we link a module with the runtime. --- Diffs of the changes: (+0 -12) Compiler.cpp | 12 ------------ 1 files changed, 12 deletions(-) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.217 llvm-java/lib/Compiler/Compiler.cpp:1.218 --- llvm-java/lib/Compiler/Compiler.cpp:1.217 Fri Feb 4 14:56:51 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Mon Feb 7 20:26:32 2005 @@ -2400,17 +2400,5 @@ bb); new ReturnInst(NULL, bb); - // HACK: add dummy returns to functions so that the jit can run the - // generated bytecode - for (Module::iterator F = m->begin(), E = m->end(); F != E; ++F) - if (F->getName().find("") != std::string::npos || - F->getName().find("java/lang/VMClassLoader") != std::string::npos) { - BasicBlock* entry = new BasicBlock("entry", F); - if (F->getReturnType() == Type::VoidTy) - new ReturnInst(NULL, entry); - else - new ReturnInst(UndefValue::get(F->getReturnType()), entry); - } - return m; } From alkis at cs.uiuc.edu Mon Feb 7 20:32:23 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon, 7 Feb 2005 20:32:23 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Transforms/StubAdder.cpp Message-ID: <200502080232.UAA31603@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Transforms: StubAdder.cpp updated: 1.1 -> 1.2 --- Log message: Fix comments. --- Diffs of the changes: (+4 -3) StubAdder.cpp | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) Index: llvm-java/lib/Transforms/StubAdder.cpp diff -u llvm-java/lib/Transforms/StubAdder.cpp:1.1 llvm-java/lib/Transforms/StubAdder.cpp:1.2 --- llvm-java/lib/Transforms/StubAdder.cpp:1.1 Mon Feb 7 20:26:32 2005 +++ llvm-java/lib/Transforms/StubAdder.cpp Mon Feb 7 20:32:12 2005 @@ -1,4 +1,4 @@ -//===- Hello.cpp - Example code from "Writing an LLVM Pass" ---------------===// +//===- StubAdder.cpp - Stub Adder Pass ------------------------------------===// // // The LLVM Compiler Infrastructure // @@ -7,8 +7,9 @@ // //===----------------------------------------------------------------------===// // -// This file implements two versions of the LLVM "Hello World" pass described -// in docs/WritingAnLLVMPass.html +// This file implements a stub adder pass. Because class2llvm is not able to +// compile all of java at the moment, this pass is used to add dummy returns +// to those functions. // //===----------------------------------------------------------------------===// From alkis at cs.uiuc.edu Mon Feb 7 20:49:14 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon, 7 Feb 2005 20:49:14 -0600 Subject: [llvm-commits] CVS: llvm-java/test/Programs/SingleSource/UnitTests/Collections5.java Message-ID: <200502080249.UAA31882@zion.cs.uiuc.edu> Changes in directory llvm-java/test/Programs/SingleSource/UnitTests: Collections5.java updated: 1.1 -> 1.2 --- Log message: Make test case fail. --- Diffs of the changes: (+13 -9) Collections5.java | 22 +++++++++++++--------- 1 files changed, 13 insertions(+), 9 deletions(-) Index: llvm-java/test/Programs/SingleSource/UnitTests/Collections5.java diff -u llvm-java/test/Programs/SingleSource/UnitTests/Collections5.java:1.1 llvm-java/test/Programs/SingleSource/UnitTests/Collections5.java:1.2 --- llvm-java/test/Programs/SingleSource/UnitTests/Collections5.java:1.1 Fri Feb 4 15:22:01 2005 +++ llvm-java/test/Programs/SingleSource/UnitTests/Collections5.java Mon Feb 7 20:49:03 2005 @@ -2,15 +2,19 @@ public class Collections5 { + public static void testList(List l) { + Collections.addRandomIntsToCollection(l); + Collections.printIntCollection(l); + java.util.Collections.rotate(l, Collections.rand.nextInt(50000)); + Collections.printIntCollection(l); + java.util.Collections.shuffle(l, Collections.rand); + Collections.printIntCollection(l); + java.util.Collections.sort(l); + Collections.printIntCollection(l); + } + public static void main(String[] args) { - List l1 = new ArrayList(); - Collections.addRandomIntsToCollection(l1); - Collections.printIntCollection(l1); - java.util.Collections.rotate(l1, Collections.rand.nextInt(50000)); - Collections.printIntCollection(l1); - java.util.Collections.shuffle(l1, Collections.rand); - Collections.printIntCollection(l1); - java.util.Collections.sort(l1); - Collections.printIntCollection(l1); + testList(new LinkedList()); + testList(new ArrayList()); } } From alkis at cs.uiuc.edu Tue Feb 8 01:43:34 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue, 8 Feb 2005 01:43:34 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Transforms/AddStubs.cpp Message-ID: <200502080743.BAA05045@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Transforms: AddStubs.cpp updated: 1.2 -> 1.3 --- Log message: Fix comments and rename class. --- Diffs of the changes: (+3 -4) AddStubs.cpp | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) Index: llvm-java/lib/Transforms/AddStubs.cpp diff -u llvm-java/lib/Transforms/AddStubs.cpp:1.2 llvm-java/lib/Transforms/AddStubs.cpp:1.3 --- llvm-java/lib/Transforms/AddStubs.cpp:1.2 Mon Feb 7 20:32:12 2005 +++ llvm-java/lib/Transforms/AddStubs.cpp Tue Feb 8 01:43:23 2005 @@ -1,4 +1,4 @@ -//===- StubAdder.cpp - Stub Adder Pass ------------------------------------===// +//===- AddStubs.cpp - Add Stubs Pass --------------------------------------===// // // The LLVM Compiler Infrastructure // @@ -23,8 +23,7 @@ using namespace llvm; namespace { - // Hello - The first implementation, without getAnalysisUsage. - struct StubAdder : public ModulePass { + struct AddStubs : public ModulePass { virtual bool runOnModule(Module &M) { for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) if (F->empty() && F->getName().find("java") != std::string::npos) { @@ -37,5 +36,5 @@ return true; } }; - RegisterOpt X("stubadder", "Stub Adder Pass"); + RegisterOpt X("addstubs", "Add Stubs pass"); } From tbrethou at cs.uiuc.edu Tue Feb 8 12:39:10 2005 From: tbrethou at cs.uiuc.edu (Tanya Brethour) Date: Tue, 8 Feb 2005 12:39:10 -0600 Subject: [llvm-commits] CVS: llvm-test/TEST.nightly.Makefile Message-ID: <200502081839.MAA02613@niobe.cs.uiuc.edu> Changes in directory llvm-test: TEST.nightly.Makefile updated: 1.39 -> 1.40 --- Log message: When timing llc-beta, actually pass in the beta options. --- Diffs of the changes: (+2 -2) TEST.nightly.Makefile | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm-test/TEST.nightly.Makefile diff -u llvm-test/TEST.nightly.Makefile:1.39 llvm-test/TEST.nightly.Makefile:1.40 --- llvm-test/TEST.nightly.Makefile:1.39 Sat Jan 15 21:16:09 2005 +++ llvm-test/TEST.nightly.Makefile Tue Feb 8 12:38:55 2005 @@ -10,7 +10,7 @@ RELDIR := $(subst $(PROGDIR),,$(CURDIR)) CFLAGS := -O3 -REPORTS_TO_GEN := compile nat +REPORTS_TO_GEN := compile nat llc-beta ifndef DISABLE_LLC REPORTS_TO_GEN += llc endif @@ -78,7 +78,7 @@ -head -n 100 Output/$*.exe-llc-beta >> $@ @-if test -f Output/$*.exe-llc-beta; then \ echo "TEST-PASS: llc-beta $(RELDIR)/$*" >> $@;\ - $(LLC) $< -o /dev/null -f $(TIMEOPT) >> $@ 2>&1; \ + $(LLC) $< $(LLCBETAOPTION) -o /dev/null -f $(TIMEOPT) >> $@ 2>&1; \ printf "TEST-RESULT-llc-beta: " >> $@;\ grep "Total Execution Time" $@.info >> $@;\ printf "TEST-RESULT-llc-beta-time: " >> $@;\ From tbrethou at cs.uiuc.edu Tue Feb 8 13:35:37 2005 From: tbrethou at cs.uiuc.edu (Tanya Brethour) Date: Tue, 8 Feb 2005 13:35:37 -0600 Subject: [llvm-commits] CVS: llvm-test/TEST.nightly.Makefile Message-ID: <200502081935.j18JZb5v017951@apoc.cs.uiuc.edu> Changes in directory llvm-test: TEST.nightly.Makefile updated: 1.40 -> 1.41 --- Log message: Revert part of checkin. --- Diffs of the changes: (+1 -1) TEST.nightly.Makefile | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm-test/TEST.nightly.Makefile diff -u llvm-test/TEST.nightly.Makefile:1.40 llvm-test/TEST.nightly.Makefile:1.41 --- llvm-test/TEST.nightly.Makefile:1.40 Tue Feb 8 12:38:55 2005 +++ llvm-test/TEST.nightly.Makefile Tue Feb 8 13:35:21 2005 @@ -10,7 +10,7 @@ RELDIR := $(subst $(PROGDIR),,$(CURDIR)) CFLAGS := -O3 -REPORTS_TO_GEN := compile nat llc-beta +REPORTS_TO_GEN := compile nat ifndef DISABLE_LLC REPORTS_TO_GEN += llc endif From alkis at cs.uiuc.edu Tue Feb 8 13:56:53 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue, 8 Feb 2005 13:56:53 -0600 Subject: [llvm-commits] CVS: llvm-java/test/Makefile.test Message-ID: <200502081956.NAA10656@zion.cs.uiuc.edu> Changes in directory llvm-java/test: Makefile.test updated: 1.38 -> 1.39 --- Log message: Update after pass name change. --- Diffs of the changes: (+1 -1) Makefile.test | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm-java/test/Makefile.test diff -u llvm-java/test/Makefile.test:1.38 llvm-java/test/Makefile.test:1.39 --- llvm-java/test/Makefile.test:1.38 Mon Feb 7 20:26:32 2005 +++ llvm-java/test/Makefile.test Tue Feb 8 13:56:15 2005 @@ -21,7 +21,7 @@ %.llvm %.llvm.bc: %.linked.bc $(LibDir)/libjrt.bca $(EXTRA_OBJS) $(LOPT) $(Echo) Linking $< with the Java runtime -$(Verb)$(GCCLD) -o=$*.llvm $< -L $(CFERuntimeLibDir) -L $(LibDir) $(EXTRA_OBJS) - -$(Verb)$(LOPT) -load $(LibDir)/LLVMJavaTransforms -stubadder -f -o=$*.stubbed.llvm.bc $*.llvm.bc + -$(Verb)$(LOPT) -load $(LibDir)/LLVMJavaTransforms -addstubs -f -o=$*.stubbed.llvm.bc $*.llvm.bc -$(Verb)$(MV) -f $*.stubbed.llvm.bc $*.llvm.bc # rule to link raw bytecode with runtime From lattner at cs.uiuc.edu Tue Feb 8 14:24:46 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 8 Feb 2005 14:24:46 -0600 Subject: [llvm-commits] CVS: poolalloc/test/TEST.poolalloc.Makefile Message-ID: <200502082024.j18KOkF8018672@apoc.cs.uiuc.edu> Changes in directory poolalloc/test: TEST.poolalloc.Makefile updated: 1.36 -> 1.37 --- Log message: Switch from simple ipcp to ipsccp --- Diffs of the changes: (+1 -1) Index: poolalloc/test/TEST.poolalloc.Makefile diff -u poolalloc/test/TEST.poolalloc.Makefile:1.36 poolalloc/test/TEST.poolalloc.Makefile:1.37 --- poolalloc/test/TEST.poolalloc.Makefile:1.36 Fri Feb 4 14:21:27 2005 +++ poolalloc/test/TEST.poolalloc.Makefile Tue Feb 8 14:24:35 2005 @@ -36,7 +36,7 @@ # output to a file. OPT_PA_STATS = $(OPT_PA) -info-output-file=$(CURDIR)/$@.info -stats -time-passes -OPTZN_PASSES := -globaldce -ipconstprop -deadargelim -adce -instcombine -simplifycfg +OPTZN_PASSES := -globaldce -ipsccp -deadargelim -adce -instcombine -simplifycfg # This rule runs the pool allocator on the .llvm.bc file to produce a new .bc From lattner at cs.uiuc.edu Tue Feb 8 15:47:00 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 8 Feb 2005 15:47:00 -0600 Subject: [llvm-commits] CVS: poolalloc/lib/PoolAllocate/PoolAllocate.cpp Message-ID: <200502082147.j18Ll0WB021266@apoc.cs.uiuc.edu> Changes in directory poolalloc/lib/PoolAllocate: PoolAllocate.cpp updated: 1.98 -> 1.99 --- Log message: Preserve this for later passes to use --- Diffs of the changes: (+1 -0) Index: poolalloc/lib/PoolAllocate/PoolAllocate.cpp diff -u poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.98 poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.99 --- poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.98 Sun Jan 30 17:51:25 2005 +++ poolalloc/lib/PoolAllocate/PoolAllocate.cpp Tue Feb 8 15:46:49 2005 @@ -72,6 +72,7 @@ void PoolAllocate::getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired(); + AU.addPreserved(); AU.addRequired(); } From lattner at cs.uiuc.edu Tue Feb 8 16:11:55 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 8 Feb 2005 16:11:55 -0600 Subject: [llvm-commits] CVS: poolalloc/lib/PoolAllocate/PoolAllocate.h Message-ID: <200502082211.j18MBtlg023507@apoc.cs.uiuc.edu> Changes in directory poolalloc/lib/PoolAllocate: PoolAllocate.h updated: 1.34 -> 1.35 --- Log message: Rename getFunctionInfo -> getFuncInfoOrClone. Implement a releaseMemory method like a proper pass. --- Diffs of the changes: (+25 -16) Index: poolalloc/lib/PoolAllocate/PoolAllocate.h diff -u poolalloc/lib/PoolAllocate/PoolAllocate.h:1.34 poolalloc/lib/PoolAllocate/PoolAllocate.h:1.35 --- poolalloc/lib/PoolAllocate/PoolAllocate.h:1.34 Sun Jan 30 17:51:25 2005 +++ poolalloc/lib/PoolAllocate/PoolAllocate.h Tue Feb 8 16:11:45 2005 @@ -113,27 +113,36 @@ PA::EquivClassGraphs &getECGraphs() const { return *ECGraphs; } - //Dinakar to get function info for all (cloned functions) - PA::FuncInfo *getFunctionInfo(Function *F) { - //If it is cloned or not check it out - if (FunctionInfo.count(F)) - return &FunctionInfo[F]; - else { - //Probably cloned - std::map::iterator fI = FunctionInfo.begin(), - fE = FunctionInfo.end(); - for (; fI != fE; ++fI) - if (fI->second.Clone == F) - return &fI->second; - return 0; - } - } - + /// getFuncInfo - Return the FuncInfo object for the specified function. PA::FuncInfo *getFuncInfo(Function &F) { std::map::iterator I = FunctionInfo.find(&F); return I != FunctionInfo.end() ? &I->second : 0; } + /// getFuncInfoOrClone - Return the function info object for for the specified + /// function. If this function is a clone of another function, return the + /// function info object for the original function. + PA::FuncInfo *getFuncInfoOrClone(Function &F) { + // If it is cloned or not check it out. + if (PA::FuncInfo *FI = getFuncInfo(F)) + return FI; + // Maybe this is a function clone? + for (std::map::iterator I = FunctionInfo.begin(), + E = FunctionInfo.end(); I != E; ++I) + if (I->second.Clone == &F) + return &I->second; + return 0; + } + + + /// releaseMemory - When the pool allocator is no longer used, release + /// resources used by it. + virtual void releaseMemory() { + FunctionInfo.clear(); + GlobalNodes.clear(); + } + + Module *getCurModule() { return CurModule; } /// CreateGlobalPool - Create a global pool descriptor, initialize it in main, From lattner at cs.uiuc.edu Tue Feb 8 17:46:44 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 8 Feb 2005 17:46:44 -0600 Subject: [llvm-commits] CVS: poolalloc/lib/PoolAllocate/PoolAllocate.cpp PoolAllocate.h Message-ID: <200502082346.j18Nki4O027737@apoc.cs.uiuc.edu> Changes in directory poolalloc/lib/PoolAllocate: PoolAllocate.cpp updated: 1.99 -> 1.100 PoolAllocate.h updated: 1.35 -> 1.36 --- Log message: Add a pointer to FuncInfo to indicate what function it is for. Add CloneToOrigMap and getOrigFunctionFromClone method. Speed up getFuncInfoOrClone. Add comments. --- Diffs of the changes: (+35 -14) Index: poolalloc/lib/PoolAllocate/PoolAllocate.cpp diff -u poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.99 poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.100 --- poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.99 Tue Feb 8 15:46:49 2005 +++ poolalloc/lib/PoolAllocate/PoolAllocate.cpp Tue Feb 8 17:46:34 2005 @@ -267,10 +267,15 @@ } +/// FindFunctionPoolArgs - In the first pass over the program, we decide which +/// arguments will have to be added for each function, build the FunctionInfo +/// map and recording this info in the ArgNodes set. void PoolAllocate::FindFunctionPoolArgs(Function &F) { DSGraph &G = ECGraphs->getDSGraph(F); - FuncInfo &FI = FunctionInfo[&F]; // Create a new entry for F + // Create a new entry for F. + FuncInfo &FI = + FunctionInfo.insert(std::make_pair(&F, FuncInfo(F))).first->second; hash_set &MarkedNodes = FI.MarkedNodes; if (G.node_begin() == G.node_end()) @@ -292,7 +297,7 @@ DSGraph &G = ECGraphs->getDSGraph(F); if (G.node_begin() == G.node_end()) return 0; - FuncInfo &FI = FunctionInfo[&F]; + FuncInfo &FI = *getFuncInfo(F); if (FI.ArgNodes.empty()) return 0; // No need to clone if no pools need to be passed in! @@ -314,6 +319,7 @@ // Create the new function... Function *New = new Function(FuncTy, Function::InternalLinkage, F.getName()); F.getParent()->getFunctionList().insert(&F, New); + CloneToOrigMap[New] = &F; // Remember original function. // Set the rest of the new arguments names to be PDa and add entries to the // pool descriptors map @@ -515,7 +521,7 @@ if (G.node_begin() == G.node_end()) return; // Quick exit if nothing to do. - FuncInfo &FI = FunctionInfo[&F]; // Get FuncInfo for F + FuncInfo &FI = *getFuncInfo(F); hash_set &MarkedNodes = FI.MarkedNodes; // Calculate which DSNodes are reachable from globals. If a node is reachable Index: poolalloc/lib/PoolAllocate/PoolAllocate.h diff -u poolalloc/lib/PoolAllocate/PoolAllocate.h:1.35 poolalloc/lib/PoolAllocate/PoolAllocate.h:1.36 --- poolalloc/lib/PoolAllocate/PoolAllocate.h:1.35 Tue Feb 8 16:11:45 2005 +++ poolalloc/lib/PoolAllocate/PoolAllocate.h Tue Feb 8 17:46:34 2005 @@ -44,14 +44,18 @@ /// maps to the original function... /// struct FuncInfo { - FuncInfo() : Clone(0) {} + FuncInfo(Function &f) : F(f), Clone(0) {} /// MarkedNodes - The set of nodes which are not locally pool allocatable in /// the current function. /// hash_set MarkedNodes; + /// F - The function this FuncInfo corresponds to. + Function &F; + /// Clone - The cloned version of the function, if applicable. + /// Function *Clone; /// ArgNodes - The list of DSNodes which have pools passed in as arguments. @@ -70,15 +74,15 @@ /// indirect function calls that are not used in the function. std::map PoolDescriptors; - //This is a map from Old to New Value Map reverse of the one above - //Useful in SAFECode for check insertion - std::map ValueMap; - /// NewToOldValueMap - When and if a function needs to be cloned, this map /// contains a mapping from all of the values in the new function back to /// the values they correspond to in the old function. /// std::map NewToOldValueMap; + + /// ValueMap - This is a map from Old to New Value Map reverse of the one + /// above. Useful in SAFECode for check insertion. + std::map ValueMap; }; }; // end PA namespace @@ -92,8 +96,8 @@ PA::EquivClassGraphs *ECGraphs; std::map FunctionInfo; - - public: + std::map CloneToOrigMap; +public: Function *PoolInit, *PoolDestroy, *PoolAlloc, *PoolRealloc, *PoolMemAlign; Function *PoolFree; @@ -113,7 +117,16 @@ PA::EquivClassGraphs &getECGraphs() const { return *ECGraphs; } + /// getOrigFunctionFromClone - Given a pointer to a function that was cloned + /// from another function, return the original function. If the argument + /// function is not a clone, return null. + Function *getOrigFunctionFromClone(Function *F) const { + std::map::const_iterator I = CloneToOrigMap.find(F); + return I != CloneToOrigMap.end() ? I->second : 0; + } + /// getFuncInfo - Return the FuncInfo object for the specified function. + /// PA::FuncInfo *getFuncInfo(Function &F) { std::map::iterator I = FunctionInfo.find(&F); return I != FunctionInfo.end() ? &I->second : 0; @@ -127,10 +140,8 @@ if (PA::FuncInfo *FI = getFuncInfo(F)) return FI; // Maybe this is a function clone? - for (std::map::iterator I = FunctionInfo.begin(), - E = FunctionInfo.end(); I != E; ++I) - if (I->second.Clone == &F) - return &I->second; + if (Function *FC = getOrigFunctionFromClone(&F)) + return getFuncInfo(F); return 0; } @@ -140,6 +151,7 @@ virtual void releaseMemory() { FunctionInfo.clear(); GlobalNodes.clear(); + CloneToOrigMap.clear(); } @@ -175,6 +187,9 @@ /// are global pools. bool SetupGlobalPools(Module &M); + /// FindFunctionPoolArgs - In the first pass over the program, we decide which + /// arguments will have to be added for each function, build the FunctionInfo + /// map and recording this info in the ArgNodes set. void FindFunctionPoolArgs(Function &F); /// MakeFunctionClone - If the specified function needs to be modified for From lattner at cs.uiuc.edu Tue Feb 8 17:48:01 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 8 Feb 2005 17:48:01 -0600 Subject: [llvm-commits] CVS: poolalloc/lib/PoolAllocate/PoolAllocate.h Message-ID: <200502082348.j18Nm18j028475@apoc.cs.uiuc.edu> Changes in directory poolalloc/lib/PoolAllocate: PoolAllocate.h updated: 1.36 -> 1.37 --- Log message: Remove dead map. If SAFEcode needs this, it should keep the inverse locally. --- Diffs of the changes: (+1 -4) Index: poolalloc/lib/PoolAllocate/PoolAllocate.h diff -u poolalloc/lib/PoolAllocate/PoolAllocate.h:1.36 poolalloc/lib/PoolAllocate/PoolAllocate.h:1.37 --- poolalloc/lib/PoolAllocate/PoolAllocate.h:1.36 Tue Feb 8 17:46:34 2005 +++ poolalloc/lib/PoolAllocate/PoolAllocate.h Tue Feb 8 17:47:51 2005 @@ -52,6 +52,7 @@ hash_set MarkedNodes; /// F - The function this FuncInfo corresponds to. + /// Function &F; /// Clone - The cloned version of the function, if applicable. @@ -79,10 +80,6 @@ /// the values they correspond to in the old function. /// std::map NewToOldValueMap; - - /// ValueMap - This is a map from Old to New Value Map reverse of the one - /// above. Useful in SAFECode for check insertion. - std::map ValueMap; }; }; // end PA namespace From lattner at cs.uiuc.edu Tue Feb 8 18:10:06 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 8 Feb 2005 18:10:06 -0600 Subject: [llvm-commits] CVS: poolalloc/lib/PoolAllocate/PoolAllocate.cpp PoolAllocate.h Message-ID: <200502090010.j190A6FY032539@apoc.cs.uiuc.edu> Changes in directory poolalloc/lib/PoolAllocate: PoolAllocate.cpp updated: 1.100 -> 1.101 PoolAllocate.h updated: 1.37 -> 1.38 --- Log message: Keep track of the nodes that are locally pool allocated into a function. Fix bug in getFuncInfoOrClone. --- Diffs of the changes: (+11 -8) Index: poolalloc/lib/PoolAllocate/PoolAllocate.cpp diff -u poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.100 poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.101 --- poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.100 Tue Feb 8 17:46:34 2005 +++ poolalloc/lib/PoolAllocate/PoolAllocate.cpp Tue Feb 8 18:09:56 2005 @@ -540,7 +540,6 @@ // Loop over all of the nodes which are non-escaping, adding pool-allocatable // ones to the NodesToPA vector. - std::vector NodesToPA; for (DSGraph::node_iterator I = G.node_begin(), E = G.node_end(); I != E;++I){ // We only need to make a pool if there is a heap object in it... DSNode *N = *I; @@ -554,14 +553,14 @@ // Otherwise, if it was not passed in from outside the function, it must // be a local pool! assert(!N->isGlobalNode() && "Should be in global mapping!"); - NodesToPA.push_back(N); + FI.NodesToPA.push_back(N); } } - if (!NodesToPA.empty()) { - std::cerr << "[" << F.getName() << "] " << NodesToPA.size() + if (!FI.NodesToPA.empty()) { + std::cerr << "[" << F.getName() << "] " << FI.NodesToPA.size() << " nodes pool allocatable\n"; - CreatePools(NewF, NodesToPA, FI.PoolDescriptors); + CreatePools(NewF, FI.NodesToPA, FI.PoolDescriptors); } else { DEBUG(std::cerr << "[" << F.getName() << "] transforming body.\n"); } @@ -573,8 +572,8 @@ TransformBody(G, FI, PoolUses, PoolFrees, NewF); // Create pool construction/destruction code - if (!NodesToPA.empty()) - InitializeAndDestroyPools(NewF, NodesToPA, FI.PoolDescriptors, + if (!FI.NodesToPA.empty()) + InitializeAndDestroyPools(NewF, FI.NodesToPA, FI.PoolDescriptors, PoolUses, PoolFrees); CurHeuristic->HackFunctionBody(NewF, FI.PoolDescriptors); } Index: poolalloc/lib/PoolAllocate/PoolAllocate.h diff -u poolalloc/lib/PoolAllocate/PoolAllocate.h:1.37 poolalloc/lib/PoolAllocate/PoolAllocate.h:1.38 --- poolalloc/lib/PoolAllocate/PoolAllocate.h:1.37 Tue Feb 8 17:47:51 2005 +++ poolalloc/lib/PoolAllocate/PoolAllocate.h Tue Feb 8 18:09:56 2005 @@ -63,6 +63,10 @@ /// std::vector ArgNodes; + /// NodesToPA - The list of nodes which are to be pool allocated locally in + /// this function. This only includes heap nodes. + std::vector NodesToPA; + /// PoolDescriptors - The Value* (either an argument or an alloca) which /// defines the pool descriptor for this DSNode. Pools are mapped one to /// one with nodes in the DSGraph, so this contains a pointer to the node it @@ -138,7 +142,7 @@ return FI; // Maybe this is a function clone? if (Function *FC = getOrigFunctionFromClone(&F)) - return getFuncInfo(F); + return getFuncInfo(*FC); return 0; } From alkis at cs.uiuc.edu Tue Feb 8 19:29:08 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue, 8 Feb 2005 19:29:08 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Transforms/AddStubs.cpp Message-ID: <200502090129.TAA22498@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Transforms: AddStubs.cpp updated: 1.3 -> 1.4 --- Log message: Add debugging info. --- Diffs of the changes: (+12 -8) AddStubs.cpp | 20 ++++++++++++-------- 1 files changed, 12 insertions(+), 8 deletions(-) Index: llvm-java/lib/Transforms/AddStubs.cpp diff -u llvm-java/lib/Transforms/AddStubs.cpp:1.3 llvm-java/lib/Transforms/AddStubs.cpp:1.4 --- llvm-java/lib/Transforms/AddStubs.cpp:1.3 Tue Feb 8 01:43:23 2005 +++ llvm-java/lib/Transforms/AddStubs.cpp Tue Feb 8 19:28:30 2005 @@ -1,10 +1,10 @@ //===- AddStubs.cpp - Add Stubs Pass --------------------------------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file implements a stub adder pass. Because class2llvm is not able to @@ -13,12 +13,15 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Pass.h" -#include "llvm/Function.h" -#include "llvm/Module.h" -#include "llvm/Type.h" -#include "llvm/Instructions.h" -#include "llvm/Constants.h" +#define DEBUG_TYPE "addstubs" + +#include +#include +#include +#include +#include +#include +#include using namespace llvm; @@ -27,6 +30,7 @@ virtual bool runOnModule(Module &M) { for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) if (F->empty() && F->getName().find("java") != std::string::npos) { + DEBUG(std::cerr << "Stubbing out: " << F->getName() << '\n'); BasicBlock* entry = new BasicBlock("entry", F); if (F->getReturnType() == Type::VoidTy) new ReturnInst(NULL, entry); From lattner at cs.uiuc.edu Tue Feb 8 20:24:16 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 8 Feb 2005 20:24:16 -0600 Subject: [llvm-commits] CVS: llvm/Makefile.rules Message-ID: <200502090224.j192OGhO000477@apoc.cs.uiuc.edu> Changes in directory llvm: Makefile.rules updated: 1.294 -> 1.295 --- Log message: Fix installation of configured headers when objdir != srcdir. Patch contributed by Vladimir Merzliakov! --- Diffs of the changes: (+11 -3) Makefile.rules | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-) Index: llvm/Makefile.rules diff -u llvm/Makefile.rules:1.294 llvm/Makefile.rules:1.295 --- llvm/Makefile.rules:1.294 Fri Feb 4 15:28:50 2005 +++ llvm/Makefile.rules Tue Feb 8 20:24:00 2005 @@ -1450,18 +1450,26 @@ $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \ cd $(PROJ_SRC_ROOT)/include && \ find . -path '*/Internal' -prune -o '(' -type f \ - '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \ + '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' -o -name '*.in' ')' \ -print ')' | grep -v CVS | pax -rwdvpe $(PROJ_includedir) ; \ fi + $(Verb) if [ -d "$(PROJ_OBJ_ROOT)/include" ] ; then \ + cd $(PROJ_OBJ_ROOT)/include && ( cd $(PROJ_SRC_ROOT)/include && \ + find . -path '*/Internal' -prune -o '(' -type f -name '*.in' -print ')' ) \ + | sed 's#.in$$##' | pax -rwdvpe $(PROJ_includedir) ; \ + fi uninstall-local:: $(Echo) Uninstalling include files $(Verb) if [ -d "$(PROJ_SRC_ROOT)/include" ] ; then \ cd $(PROJ_SRC_ROOT)/include && \ $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \ - '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \ + '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' -o -name '*.in' ')' \ -print ')' | grep -v CVS | sed 's#^#$(PROJ_includedir)/#'` ; \ - fi + cd $(PROJ_SRC_ROOT)/include && \ + $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f -name '*.in' -print ')' \ + | sed 's#\.in$$##;s#^#$(PROJ_includedir)/#'` ; \ + fi endif From lattner at cs.uiuc.edu Tue Feb 8 21:14:44 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 8 Feb 2005 21:14:44 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/DataStructure/DSNode.h Message-ID: <200502090314.j193Ei78002065@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis/DataStructure: DSNode.h updated: 1.49 -> 1.50 --- Log message: Add some iterators that should have come in long ago --- Diffs of the changes: (+10 -0) DSNode.h | 10 ++++++++++ 1 files changed, 10 insertions(+) Index: llvm/include/llvm/Analysis/DataStructure/DSNode.h diff -u llvm/include/llvm/Analysis/DataStructure/DSNode.h:1.49 llvm/include/llvm/Analysis/DataStructure/DSNode.h:1.50 --- llvm/include/llvm/Analysis/DataStructure/DSNode.h:1.49 Sun Jan 30 17:50:48 2005 +++ llvm/include/llvm/Analysis/DataStructure/DSNode.h Tue Feb 8 21:14:29 2005 @@ -213,6 +213,16 @@ /// unsigned getNumLinks() const { return Links.size(); } + /// edge_* - Provide iterators for accessing outgoing edges. Some outgoing + /// edges may be null. + typedef std::vector::iterator edge_iterator; + typedef std::vector::const_iterator const_edge_iterator; + edge_iterator edge_begin() { return Links.begin(); } + edge_iterator edge_end() { return Links.end(); } + const_edge_iterator edge_begin() const { return Links.begin(); } + const_edge_iterator edge_end() const { return Links.end(); } + + /// mergeTypeInfo - This method merges the specified type into the current /// node at the specified offset. This may update the current node's type /// record if this gives more information to the node, it may do nothing to From lattner at cs.uiuc.edu Tue Feb 8 21:20:58 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 8 Feb 2005 21:20:58 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/DataStructure.cpp Message-ID: <200502090320.j193KwGr002264@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: DataStructure.cpp updated: 1.190 -> 1.191 --- Log message: Use new edge iterators to simplify some code. --- Diffs of the changes: (+7 -7) DataStructure.cpp | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) Index: llvm/lib/Analysis/DataStructure/DataStructure.cpp diff -u llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.190 llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.191 --- llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.190 Fri Feb 4 13:58:28 2005 +++ llvm/lib/Analysis/DataStructure/DataStructure.cpp Tue Feb 8 21:20:43 2005 @@ -1432,8 +1432,8 @@ N->setIncompleteMarker(); // Recursively process children... - for (unsigned i = 0, e = N->getSize(); i < e; i += DS::PointerSize) - if (DSNode *DSN = N->getLink(i).getNode()) + for (DSNode::edge_iterator I = N->edge_begin(),E = N->edge_end(); I != E; ++I) + if (DSNode *DSN = I->getNode()) markIncompleteNode(DSN); } @@ -1729,8 +1729,9 @@ if (this == 0) return; assert(getForwardNode() == 0 && "Cannot mark a forwarded node!"); if (ReachableNodes.insert(this).second) // Is newly reachable? - for (unsigned i = 0, e = getSize(); i < e; i += DS::PointerSize) - getLink(i).getNode()->markReachableNodes(ReachableNodes); + for (DSNode::const_edge_iterator I = edge_begin(), E = edge_end(); + I != E; ++I) + I->getNode()->markReachableNodes(ReachableNodes); } void DSCallSite::markReachableNodes(hash_set &Nodes) const { @@ -1764,9 +1765,8 @@ if (Visited.count(N)) return false; // Found a cycle Visited.insert(N); // No recursion, insert into Visited... - for (unsigned i = 0, e = N->getSize(); i < e; i += DS::PointerSize) - if (CanReachAliveNodes(N->getLink(i).getNode(), Alive, Visited, - IgnoreGlobals)) { + for (DSNode::edge_iterator I = N->edge_begin(),E = N->edge_end(); I != E; ++I) + if (CanReachAliveNodes(I->getNode(), Alive, Visited, IgnoreGlobals)) { N->markReachableNodes(Alive); return true; } From lattner at cs.uiuc.edu Tue Feb 8 21:46:33 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 8 Feb 2005 21:46:33 -0600 Subject: [llvm-commits] CVS: poolalloc/lib/PoolAllocate/PointerCompress.cpp Message-ID: <200502090346.j193kXli005141@apoc.cs.uiuc.edu> Changes in directory poolalloc/lib/PoolAllocate: PointerCompress.cpp added (r1.1) --- Log message: Initial draft of the pointer compression pass. This doesn't actually DO anything, but it does print nice messages about what the first draft will and will not be able to compress (which isn't much). :) --- Diffs of the changes: (+172 -0) Index: poolalloc/lib/PoolAllocate/PointerCompress.cpp diff -c /dev/null poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.1 *** /dev/null Tue Feb 8 21:46:32 2005 --- poolalloc/lib/PoolAllocate/PointerCompress.cpp Tue Feb 8 21:46:22 2005 *************** *** 0 **** --- 1,172 ---- + //===-- PointerCompress.cpp - Pointer Compression Pass --------------------===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file implements the -pointercompress pass. + // + //===----------------------------------------------------------------------===// + + #define DEBUG_TYPE "pointercompress" + #include "EquivClassGraphs.h" + #include "PoolAllocate.h" + #include "llvm/Module.h" + #include "llvm/ADT/Statistic.h" + #include "llvm/Support/Debug.h" + using namespace llvm; + + namespace { + Statistic<> NumCompressed("pointercompress", + "Number of pools pointer compressed"); + Statistic<> NumNotCompressed("pointercompress", + "Number of pools not compressible"); + + + /// PointerCompress - This transformation hacks on type-safe pool allocated + /// data structures to reduce the size of pointers in the program. + class PointerCompress : public ModulePass { + PoolAllocate *PoolAlloc; + PA::EquivClassGraphs *ECG; + public: + bool runOnModule(Module &M); + void getAnalysisUsage(AnalysisUsage &AU) const; + + private: + bool CompressPoolsInFunction(Function &F); + void FindPoolsToCompress(std::vector &Pools, Function &F, + DSGraph &DSG, PA::FuncInfo *FI); + }; + + RegisterOpt + X("pointercompress", "Compress type-safe data structures"); + } + + void PointerCompress::getAnalysisUsage(AnalysisUsage &AU) const { + // Need information about how pool allocation happened. + AU.addRequired(); + + // Need information from DSA. + AU.addRequired(); + } + + /// PoolIsCompressible - Return true if we can pointer compress this node. + /// If not, we should DEBUG print out why. + static bool PoolIsCompressible(const DSNode *N, Function &F) { + assert(!N->isForwarding() && "Should not be dealing with merged nodes!"); + if (N->isNodeCompletelyFolded()) { + DEBUG(std::cerr << "Node is not type-safe:\n"); + return false; + } + + // If this has no pointer fields, don't compress. + bool HasFields = false; + for (DSNode::const_edge_iterator I = N->edge_begin(), E = N->edge_end(); + I != E; ++I) + if (!I->isNull()) { + HasFields = true; + if (I->getNode() != N) { + // We currently only handle trivially self cyclic DS's right now. + DEBUG(std::cerr << "Node points to nodes other than itself:\n"); + return false; + } + } + + if (!HasFields) { + DEBUG(std::cerr << "Node does not contain any pointers to compress:\n"); + return false; + } + + if (N->isArray()) { + DEBUG(std::cerr << "Node is an array (not yet handled!):\n"); + return false; + } + + return true; + } + + /// FindPoolsToCompress - Inspect the specified function and find pools that are + /// compressible that are homed in that function. Return those pools in the + /// Pools vector. + void PointerCompress::FindPoolsToCompress(std::vector &Pools, + Function &F, DSGraph &DSG, + PA::FuncInfo *FI) { + hash_set ReachableFromCalls; + + // If a data structure is passed into a call, we currently cannot handle it! + for (DSGraph::fc_iterator I = DSG.fc_begin(), E = DSG.fc_end(); I != E; ++I) { + //DEBUG(std::cerr << " CALLS: " << I->getCalleeFunc()->getName() << "\n"); + I->markReachableNodes(ReachableFromCalls); + } + + DEBUG(std::cerr << "In function '" << F.getName() << "':\n"); + for (unsigned i = 0, e = FI->NodesToPA.size(); i != e; ++i) { + const DSNode *N = FI->NodesToPA[i]; + if (ReachableFromCalls.count(N)) { + DEBUG(std::cerr << "Passed into call:\nPCF: "; N->dump()); + ++NumNotCompressed; + } else if (PoolIsCompressible(N, F)) { + Pools.push_back(N); + ++NumCompressed; + } else { + DEBUG(std::cerr << "PCF: "; N->dump()); + ++NumNotCompressed; + } + } + } + + + /// CompressPoolsInFunction - Find all pools that are compressible in this + /// function and compress them. + bool PointerCompress::CompressPoolsInFunction(Function &F) { + if (F.isExternal()) return false; + + PA::FuncInfo *FI = PoolAlloc->getFuncInfoOrClone(F); + if (FI == 0) { + std::cerr << "DIDN'T FIND POOL INFO FOR: " + << *F.getType() << F.getName() << "!\n"; + return false; + } + + // If this function was cloned, and this is the original function, ignore it + // (it's dead). We'll deal with the cloned version later when we run into it + // again. + if (FI->Clone && &FI->F == &F) + return false; + + // There are no pools in this function. + if (FI->NodesToPA.empty()) + return false; + + // Get the DSGraph for this function. + DSGraph &DSG = ECG->getDSGraph(FI->F); + + // Compute the set of compressible pools in this function. + std::vector PoolsToCompress; + FindPoolsToCompress(PoolsToCompress, F, DSG, FI); + + if (PoolsToCompress.empty()) return false; + + std::cerr << "In function '" << F.getName() << "':\n"; + for (unsigned i = 0, e = PoolsToCompress.size(); i != e; ++i) { + std::cerr << " COMPRESSING POOL:\nPCS:"; + PoolsToCompress[i]->dump(); + } + return false; + } + + bool PointerCompress::runOnModule(Module &M) { + PoolAlloc = &getAnalysis(); + ECG = &getAnalysis(); + + // Iterate over all functions in the module, looking for compressible data + // structures. + bool Changed = false; + for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) + Changed |= CompressPoolsInFunction(*I); + + return Changed; + } From lattner at cs.uiuc.edu Wed Feb 9 11:42:39 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 9 Feb 2005 11:42:39 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Assembler/2005-02-09-AsmWriterStoreBug.ll Message-ID: <200502091742.j19HgdNa007476@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Assembler: 2005-02-09-AsmWriterStoreBug.ll added (r1.1) --- Log message: New testcase that the asmwriter botches. --- Diffs of the changes: (+14 -0) 2005-02-09-AsmWriterStoreBug.ll | 14 ++++++++++++++ 1 files changed, 14 insertions(+) Index: llvm/test/Regression/Assembler/2005-02-09-AsmWriterStoreBug.ll diff -c /dev/null llvm/test/Regression/Assembler/2005-02-09-AsmWriterStoreBug.ll:1.1 *** /dev/null Wed Feb 9 11:42:34 2005 --- llvm/test/Regression/Assembler/2005-02-09-AsmWriterStoreBug.ll Wed Feb 9 11:42:24 2005 *************** *** 0 **** --- 1,14 ---- + ; RUN: llvm-as < %s | llvm-dis | llvm-as + + ; Ensure that the asm writer emits types before both operands of the + ; store, even though they can be the same. + + %RecTy = type %RecTy* + implementation + + void %foo() { + %A = malloc %RecTy + %B = malloc %RecTy + store %RecTy %B, %RecTy %A ;; Both ops are the same + ret void + } From lattner at cs.uiuc.edu Wed Feb 9 11:45:16 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 9 Feb 2005 11:45:16 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp Message-ID: <200502091745.j19HjG6C007819@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: AsmWriter.cpp updated: 1.169 -> 1.170 --- Log message: Fix test/Regression/Assembler/2005-02-09-AsmWriterStoreBug.ll --- Diffs of the changes: (+1 -1) AsmWriter.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/VMCore/AsmWriter.cpp diff -u llvm/lib/VMCore/AsmWriter.cpp:1.169 llvm/lib/VMCore/AsmWriter.cpp:1.170 --- llvm/lib/VMCore/AsmWriter.cpp:1.169 Mon Jan 31 19:24:01 2005 +++ llvm/lib/VMCore/AsmWriter.cpp Wed Feb 9 11:45:03 2005 @@ -1161,7 +1161,7 @@ // Shift Left & Right print both types even for Ubyte LHS, and select prints // types even if all operands are bools. - if (isa(I) || isa(I)) { + if (isa(I) || isa(I) || isa(I)) { PrintAllTypes = true; } else { for (unsigned i = 1, E = I.getNumOperands(); i != E; ++i) { From lattner at cs.uiuc.edu Wed Feb 9 12:41:48 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 9 Feb 2005 12:41:48 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/Timer.cpp Message-ID: <200502091841.j19Ifmhl009312@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Support: Timer.cpp updated: 1.42 -> 1.43 --- Log message: Don't print a 'Total Execution Time' line for the 'Miscellaneous Ungrouped Timers' section. Since these are random timers in the program it doesn't make sense to sum them up. --- Diffs of the changes: (+13 -5) Timer.cpp | 18 +++++++++++++----- 1 files changed, 13 insertions(+), 5 deletions(-) Index: llvm/lib/Support/Timer.cpp diff -u llvm/lib/Support/Timer.cpp:1.42 llvm/lib/Support/Timer.cpp:1.43 --- llvm/lib/Support/Timer.cpp:1.42 Fri Jan 28 23:21:16 2005 +++ llvm/lib/Support/Timer.cpp Wed Feb 9 12:41:32 2005 @@ -302,12 +302,20 @@ *OutStream << "===" << std::string(73, '-') << "===\n" << std::string(Padding, ' ') << Name << "\n" << "===" << std::string(73, '-') - << "===\n Total Execution Time: "; + << "===\n"; - printAlignedFP(Total.getProcessTime(), 4, 5, *OutStream); - *OutStream << " seconds ("; - printAlignedFP(Total.getWallTime(), 4, 5, *OutStream); - *OutStream << " wall clock)\n\n"; + // If this is not an collection of ungrouped times, print the total time. + // Ungrouped timers don't really make sense to add up. We still print the + // TOTAL line to make the percentages make sense. + if (this != DefaultTimerGroup) { + *OutStream << " Total Execution Time: "; + + printAlignedFP(Total.getProcessTime(), 4, 5, *OutStream); + *OutStream << " seconds ("; + printAlignedFP(Total.getWallTime(), 4, 5, *OutStream); + *OutStream << " wall clock)\n"; + } + *OutStream << "\n"; if (Total.UserTime) *OutStream << " ---User Time---"; From lattner at cs.uiuc.edu Wed Feb 9 13:04:58 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 9 Feb 2005 13:04:58 -0600 Subject: [llvm-commits] CVS: poolalloc/lib/PoolAllocate/PoolAllocate.h PoolAllocate.cpp Message-ID: <200502091904.j19J4wSh011279@apoc.cs.uiuc.edu> Changes in directory poolalloc/lib/PoolAllocate: PoolAllocate.h updated: 1.38 -> 1.39 PoolAllocate.cpp updated: 1.101 -> 1.102 --- Log message: When pool allocating, make sure the DSGraph's are kept up-to-date to reflect new pool descriptors added to the program. --- Diffs of the changes: (+12 -5) Index: poolalloc/lib/PoolAllocate/PoolAllocate.h diff -u poolalloc/lib/PoolAllocate/PoolAllocate.h:1.38 poolalloc/lib/PoolAllocate/PoolAllocate.h:1.39 --- poolalloc/lib/PoolAllocate/PoolAllocate.h:1.38 Tue Feb 8 18:09:56 2005 +++ poolalloc/lib/PoolAllocate/PoolAllocate.h Wed Feb 9 13:04:47 2005 @@ -208,7 +208,8 @@ /// pools specified in the NodesToPA list. This adds an entry to the /// PoolDescriptors map for each DSNode. /// - void CreatePools(Function &F, const std::vector &NodesToPA, + void CreatePools(Function &F, DSGraph &G, + const std::vector &NodesToPA, std::map &PoolDescriptors); void TransformBody(DSGraph &g, PA::FuncInfo &fi, Index: poolalloc/lib/PoolAllocate/PoolAllocate.cpp diff -u poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.101 poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.102 --- poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.101 Tue Feb 8 18:09:56 2005 +++ poolalloc/lib/PoolAllocate/PoolAllocate.cpp Wed Feb 9 13:04:48 2005 @@ -463,7 +463,7 @@ // the DSNodes specified by the NodesToPA list. This adds an entry to the // PoolDescriptors map for each DSNode. // -void PoolAllocate::CreatePools(Function &F, +void PoolAllocate::CreatePools(Function &F, DSGraph &DSG, const std::vector &NodesToPA, std::map &PoolDescriptors) { @@ -489,9 +489,15 @@ if (PoolDesc == 0) { // Create a pool descriptor for the pool. The poolinit will be inserted // later. - if (!IsMain) + if (!IsMain) { PoolDesc = new AllocaInst(PoolDescType, 0, "PD", InsertPoint); - else { + + // Create a node in DSG to represent the new alloca. + DSNode *NewNode = new DSNode(PoolDescType, &DSG); + NewNode->setAllocaNodeMarker(); // This is a stack object. + NewNode->setModifiedMarker()->setReadMarker(); // This is M/R + DSG.getNodeForValue(PoolDesc) = NewNode; + } else { PoolDesc = CreateGlobalPool(Pool.PoolSize, Pool.PoolAlignment, InsertPoint); if (Pool.NodesInPool.size() == 1 && @@ -560,7 +566,7 @@ if (!FI.NodesToPA.empty()) { std::cerr << "[" << F.getName() << "] " << FI.NodesToPA.size() << " nodes pool allocatable\n"; - CreatePools(NewF, FI.NodesToPA, FI.PoolDescriptors); + CreatePools(NewF, G, FI.NodesToPA, FI.PoolDescriptors); } else { DEBUG(std::cerr << "[" << F.getName() << "] transforming body.\n"); } From lattner at cs.uiuc.edu Wed Feb 9 14:44:03 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 9 Feb 2005 14:44:03 -0600 Subject: [llvm-commits] CVS: llvm/docs/GettingStarted.html Message-ID: <200502092044.j19Ki3dQ011900@apoc.cs.uiuc.edu> Changes in directory llvm/docs: GettingStarted.html updated: 1.104 -> 1.105 --- Log message: Add instructions for MINGW, contributed by Henrik Bach --- Diffs of the changes: (+18 -2) GettingStarted.html | 20 ++++++++++++++++++-- 1 files changed, 18 insertions(+), 2 deletions(-) Index: llvm/docs/GettingStarted.html diff -u llvm/docs/GettingStarted.html:1.104 llvm/docs/GettingStarted.html:1.105 --- llvm/docs/GettingStarted.html:1.104 Thu Feb 3 16:25:23 2005 +++ llvm/docs/GettingStarted.html Wed Feb 9 14:43:48 2005 @@ -237,6 +237,11 @@ GCC 3.4.X, binutils 2.15 + MinGW/Win32 + x8616 + GCC 3.4.X, binutils 2.15 + + Linux amd643 GCC @@ -254,7 +259,7 @@ Windows x861 - Visual Studio .NET4,5, MinGW + Visual Studio .NET4,5 AIX3,4 PowerPC @@ -274,6 +279,17 @@ 3 No native code generation
4 Build is not complete: one or more tools don't link
5 The GCC-based C/C++ frontend does not build
+6 The port is done using the MSYS shell. +Download (from http://www.mingw.org/MinGWiki/) and install +bison (excl. M4.exe) and flex in that order. +Build binutils 2.15 from source if necessary. +If you want to compile the Cfrontend then upgrade to texinfo 4.5+ from source. +If you need to create a library for an MS dll do these three steps: +1) pexports /C/WINNT/SYSTEM32/file.dll | sed "s/^_//" > /C/MinGW/lib/file.def +2) Edit file and append @<ordinal> to the missing function name +3) dlltool.exe -k -d /C/MinGW/lib/file.def -l /C/MinGW/lib/libfile.a. +Add in .profile: export CPPFLAGS="-D__MINGW -DLLVM_ON_WIN32=1" +

Note that you will need about 1-3 GB of space for a full LLVM build in Debug @@ -1481,7 +1497,7 @@ Chris Lattner
Reid Spencer
The LLVM Compiler Infrastructure
- Last modified: $Date: 2005/02/03 22:25:23 $ + Last modified: $Date: 2005/02/09 20:43:48 $ From brukman at cs.uiuc.edu Wed Feb 9 15:01:37 2005 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Wed, 9 Feb 2005 15:01:37 -0600 Subject: [llvm-commits] CVS: llvm/docs/GettingStarted.html Message-ID: <200502092101.PAA10385@zion.cs.uiuc.edu> Changes in directory llvm/docs: GettingStarted.html updated: 1.105 -> 1.106 --- Log message: * Separate superscript footnotes with a comma, otherwise it's a 2-digit number * Make a URL into an HTML link using anchor tag * Put code in fixed-width font * Since the MinGW footnote is significantly more than the rest of the footnotes combined, it needs to have a border and background color to separate it from the regular flow of text for readability purposes. --- Diffs of the changes: (+19 -15) GettingStarted.html | 34 +++++++++++++++++++--------------- 1 files changed, 19 insertions(+), 15 deletions(-) Index: llvm/docs/GettingStarted.html diff -u llvm/docs/GettingStarted.html:1.105 llvm/docs/GettingStarted.html:1.106 --- llvm/docs/GettingStarted.html:1.105 Wed Feb 9 14:43:48 2005 +++ llvm/docs/GettingStarted.html Wed Feb 9 15:01:26 2005 @@ -238,7 +238,7 @@ MinGW/Win32 - x8616 + x861,6 GCC 3.4.X, binutils 2.15 @@ -272,25 +272,29 @@ -

-Notes:
+

Notes:

+ +
1 Code generation supported for Pentium processors and up
2 Code generation supported for 32-bit ABI only
3 No native code generation
4 Build is not complete: one or more tools don't link
5 The GCC-based C/C++ frontend does not build
6 The port is done using the MSYS shell. -Download (from http://www.mingw.org/MinGWiki/) and install -bison (excl. M4.exe) and flex in that order. -Build binutils 2.15 from source if necessary. -If you want to compile the Cfrontend then upgrade to texinfo 4.5+ from source. -If you need to create a library for an MS dll do these three steps: -1) pexports /C/WINNT/SYSTEM32/file.dll | sed "s/^_//" > /C/MinGW/lib/file.def -2) Edit file and append @<ordinal> to the missing function name -3) dlltool.exe -k -d /C/MinGW/lib/file.def -l /C/MinGW/lib/libfile.a. -Add in .profile: export CPPFLAGS="-D__MINGW -DLLVM_ON_WIN32=1" -
-

+Download and install +bison (excl. M4.exe) and flex in that order. Build binutils-2.15 from source, +if necessary. If you want to compile the C/C++ frontend, then upgrade to +texinfo-4.5+ from source. +If you need to create a library for an MS DLL, do the following: +
    +
  1. pexports /C/WINNT/SYSTEM32/file.dll | sed "s/^_//" > +/C/MinGW/lib/file.def
  2. +
  3. Edit file and append @<ordinal> to the missing function name
  4. +
  5. dlltool.exe -k -d /C/MinGW/lib/file.def -l +/C/MinGW/lib/libfile.a.
  6. +
+Add in .profile: export CPPFLAGS="-D__MINGW -DLLVM_ON_WIN32=1" +

Note that you will need about 1-3 GB of space for a full LLVM build in Debug mode, depending on the system (because of all the debug info), and the libraries @@ -1497,7 +1501,7 @@ Chris Lattner
Reid Spencer
The LLVM Compiler Infrastructure
- Last modified: $Date: 2005/02/09 20:43:48 $ + Last modified: $Date: 2005/02/09 21:01:26 $ From lattner at cs.uiuc.edu Wed Feb 9 15:05:16 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 9 Feb 2005 15:05:16 -0600 Subject: [llvm-commits] CVS: llvm/docs/GettingStarted.html Message-ID: <200502092105.j19L5GxH012000@apoc.cs.uiuc.edu> Changes in directory llvm/docs: GettingStarted.html updated: 1.106 -> 1.107 --- Log message: this should be incorporated into the build --- Diffs of the changes: (+1 -2) GettingStarted.html | 3 +-- 1 files changed, 1 insertion(+), 2 deletions(-) Index: llvm/docs/GettingStarted.html diff -u llvm/docs/GettingStarted.html:1.106 llvm/docs/GettingStarted.html:1.107 --- llvm/docs/GettingStarted.html:1.106 Wed Feb 9 15:01:26 2005 +++ llvm/docs/GettingStarted.html Wed Feb 9 15:05:01 2005 @@ -293,7 +293,6 @@

  • dlltool.exe -k -d /C/MinGW/lib/file.def -l /C/MinGW/lib/libfile.a.
  • -Add in .profile: export CPPFLAGS="-D__MINGW -DLLVM_ON_WIN32=1"

    Note that you will need about 1-3 GB of space for a full LLVM build in Debug @@ -1501,7 +1500,7 @@ Chris Lattner
    Reid Spencer
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2005/02/09 21:01:26 $ + Last modified: $Date: 2005/02/09 21:05:01 $ From lattner at cs.uiuc.edu Wed Feb 9 15:07:36 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 9 Feb 2005 15:07:36 -0600 Subject: [llvm-commits] CVS: llvm/docs/GettingStarted.html Message-ID: <200502092107.j19L7ato012034@apoc.cs.uiuc.edu> Changes in directory llvm/docs: GettingStarted.html updated: 1.107 -> 1.108 --- Log message: If needed, this should be in the 'how to compile the cfe' doc. --- Diffs of the changes: (+2 -4) GettingStarted.html | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-) Index: llvm/docs/GettingStarted.html diff -u llvm/docs/GettingStarted.html:1.107 llvm/docs/GettingStarted.html:1.108 --- llvm/docs/GettingStarted.html:1.107 Wed Feb 9 15:05:01 2005 +++ llvm/docs/GettingStarted.html Wed Feb 9 15:07:21 2005 @@ -283,9 +283,7 @@ 6 The port is done using the MSYS shell. Download and install bison (excl. M4.exe) and flex in that order. Build binutils-2.15 from source, -if necessary. If you want to compile the C/C++ frontend, then upgrade to -texinfo-4.5+ from source. -If you need to create a library for an MS DLL, do the following: +if necessary. If you need to create a library for an MS DLL, do the following:

    1. pexports /C/WINNT/SYSTEM32/file.dll | sed "s/^_//" > /C/MinGW/lib/file.def
    2. @@ -1500,7 +1498,7 @@ Chris Lattner
      Reid Spencer
      The LLVM Compiler Infrastructure
      - Last modified: $Date: 2005/02/09 21:05:01 $ + Last modified: $Date: 2005/02/09 21:07:21 $ From lattner at cs.uiuc.edu Wed Feb 9 15:16:06 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 9 Feb 2005 15:16:06 -0600 Subject: [llvm-commits] CVS: llvm/docs/GettingStarted.html Message-ID: <200502092116.j19LG6qY012077@apoc.cs.uiuc.edu> Changes in directory llvm/docs: GettingStarted.html updated: 1.108 -> 1.109 --- Log message: Turn footnotes into links, make the page validate. --- Diffs of the changes: (+24 -19) GettingStarted.html | 43 ++++++++++++++++++++++++------------------- 1 files changed, 24 insertions(+), 19 deletions(-) Index: llvm/docs/GettingStarted.html diff -u llvm/docs/GettingStarted.html:1.108 llvm/docs/GettingStarted.html:1.109 --- llvm/docs/GettingStarted.html:1.108 Wed Feb 9 15:07:21 2005 +++ llvm/docs/GettingStarted.html Wed Feb 9 15:15:51 2005 @@ -213,7 +213,7 @@ Linux - x861 + x861 GCC @@ -223,27 +223,27 @@ FreeBSD - x861 + x861 GCC - MacOS X2 + MacOS X2 PowerPC GCC Cygwin/Win32 - x861 + x861 GCC 3.4.X, binutils 2.15 MinGW/Win32 - x861,6 + x861,6 GCC 3.4.X, binutils 2.15 Linux - amd643 + amd643 GCC @@ -258,15 +258,15 @@ Windows - x861 - Visual Studio .NET4,5 + x861 + Visual Studio .NET4,5 - AIX3,4 + AIX3,4 PowerPC GCC - Linux3,5 + Linux3,5 PowerPC GCC @@ -275,12 +275,18 @@

      Notes:

      -1 Code generation supported for Pentium processors and up
      -2 Code generation supported for 32-bit ABI only
      -3 No native code generation
      -4 Build is not complete: one or more tools don't link
      -5 The GCC-based C/C++ frontend does not build
      -6 The port is done using the MSYS shell. +1 + Code generation supported for Pentium processors and up
      +2 + Code generation supported for 32-bit ABI only
      +3 + No native code generation
      +4 + Build is not complete: one or more tools don't link
      +5 + The GCC-based C/C++ frontend does not build
      +6 + The port is done using the MSYS shell. Download and install bison (excl. M4.exe) and flex in that order. Build binutils-2.15 from source, if necessary. If you need to create a library for an MS DLL, do the following: @@ -411,7 +417,6 @@ from that package.
    3. Only needed if you want to run the automated test suite in the test directory.
    4. -
    5. Only the C and C++ languages are needed so there's no need to build the other languages for LLVM's purposes. See below for specific version info. @@ -580,7 +585,7 @@
      Source release for the LLVM libraries and tools.
      llvm-test-x.y.tar.gz
      -
      Source release for the LLVM test suite.
      +
      Source release for the LLVM test suite.
      cfrontend-x.y.source.tar.gz
      Source release of the GCC front end.
      @@ -1498,7 +1503,7 @@ Chris Lattner
      Reid Spencer
      The LLVM Compiler Infrastructure
      - Last modified: $Date: 2005/02/09 21:07:21 $ + Last modified: $Date: 2005/02/09 21:15:51 $ From brukman at cs.uiuc.edu Wed Feb 9 16:36:55 2005 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Wed, 9 Feb 2005 16:36:55 -0600 Subject: [llvm-commits] CVS: llvm/docs/llvm.css Message-ID: <200502092236.QAA12810@zion.cs.uiuc.edu> Changes in directory llvm/docs: llvm.css updated: 1.25 -> 1.26 --- Log message: Add style to display notes on a different background than the main text --- Diffs of the changes: (+1 -0) llvm.css | 1 + 1 files changed, 1 insertion(+) Index: llvm/docs/llvm.css diff -u llvm/docs/llvm.css:1.25 llvm/docs/llvm.css:1.26 --- llvm/docs/llvm.css:1.25 Mon Nov 1 03:26:57 2004 +++ llvm/docs/llvm.css Wed Feb 9 16:36:44 2005 @@ -66,6 +66,7 @@ padding: 0 1em 0 1em; display:table; } +.doc_notes { background: #fafafa; border: 1px solid #cecece; padding: 1em } TABLE.layout { text-align: left; border: none; border-collapse: collapse; padding: 4px 4px 4px 4px; } From brukman at cs.uiuc.edu Wed Feb 9 16:38:58 2005 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Wed, 9 Feb 2005 16:38:58 -0600 Subject: [llvm-commits] CVS: llvm/docs/GettingStarted.html Message-ID: <200502092238.QAA12996@zion.cs.uiuc.edu> Changes in directory llvm/docs: GettingStarted.html updated: 1.109 -> 1.110 --- Log message: * Use an HTML list
        instead of custom superscripts in the platform notes * Reorder software requirements list to show relative importance * Use superscripts for footnotes in software list rather than "Note 1" * Use new doc_notes class to separate footnotes from main doc text --- Diffs of the changes: (+45 -46) GettingStarted.html | 91 +++++++++++++++++++++++++--------------------------- 1 files changed, 45 insertions(+), 46 deletions(-) Index: llvm/docs/GettingStarted.html diff -u llvm/docs/GettingStarted.html:1.109 llvm/docs/GettingStarted.html:1.110 --- llvm/docs/GettingStarted.html:1.109 Wed Feb 9 15:15:51 2005 +++ llvm/docs/GettingStarted.html Wed Feb 9 16:38:47 2005 @@ -274,28 +274,25 @@

        Notes:

        -
        -1 - Code generation supported for Pentium processors and up
        -2 - Code generation supported for 32-bit ABI only
        -3 - No native code generation
        -4 - Build is not complete: one or more tools don't link
        -5 - The GCC-based C/C++ frontend does not build
        -6 - The port is done using the MSYS shell. +
        +
          +
        1. Code generation supported for Pentium processors and +up
        2. +
        3. Code generation supported for 32-bit ABI only
        4. +
        5. No native code generation
        6. +
        7. Build is not complete: one or more tools don't link
        8. +
        9. The GCC-based C/C++ frontend does not build
        10. +
        11. The port is done using the MSYS shell. Download and install bison (excl. M4.exe) and flex in that order. Build binutils-2.15 from source, if necessary. If you need to create a library for an MS DLL, do the following: -
            +
            • pexports /C/WINNT/SYSTEM32/file.dll | sed "s/^_//" > /C/MinGW/lib/file.def
            • Edit file and append @<ordinal> to the missing function name
            • dlltool.exe -k -d /C/MinGW/lib/file.def -l /C/MinGW/lib/libfile.a.
            • +
        @@ -338,7 +335,7 @@ GCC 3.4.2 - C/C++ compiler (Note 3) + C/C++ compiler1 @@ -354,77 +351,79 @@ + CVS + ≥1.11 + CVS access to LLVM2 + + + DejaGnu 1.4.2 - Automated test suite (Note 2) + Automated test suite3 tcl 8.3, 8.4 - Automated test suite (Note 2) + Automated test suite3 expect 5.38.0 - Automated test suite (Note 2) + Automated test suite3 + + + + perl + ≥5.6.0 + Nightly tester, utilities GNU M4 1.4 - Macro processor for configuration (Note 1) + Macro processor for configuration4 GNU Autoconf 2.59 - Configuration script builder (Note 1) + Configuration script builder4 GNU Automake 1.9.2 - aclocal macro generator (Note 1) - - - - perl - ≥5.6.0 - Nightly tester, utilities + aclocal macro generator4 libtool 1.5.10 - Shared library manager (Note 1) - - - - CVS - ≥1.11 - CVS access to LLVM (Note 4) + Shared library manager4 -

        Notes:

        +

        Notes:

        + +

        Additionally, your compilation host is expected to have the usual plethora of Unix utilities. Specifically:

          @@ -1503,7 +1502,7 @@ Chris Lattner
          Reid Spencer
          The LLVM Compiler Infrastructure
          - Last modified: $Date: 2005/02/09 21:15:51 $ + Last modified: $Date: 2005/02/09 22:38:47 $ From brukman at cs.uiuc.edu Wed Feb 9 16:47:57 2005 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Wed, 9 Feb 2005 16:47:57 -0600 Subject: [llvm-commits] CVS: llvm/docs/llvm.css Message-ID: <200502092247.QAA13383@zion.cs.uiuc.edu> Changes in directory llvm/docs: llvm.css updated: 1.26 -> 1.27 --- Log message: Do not mention colors in style names, we might want to change styles themselves --- Diffs of the changes: (+1 -1) llvm.css | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/docs/llvm.css diff -u llvm/docs/llvm.css:1.26 llvm/docs/llvm.css:1.27 --- llvm/docs/llvm.css:1.26 Wed Feb 9 16:36:44 2005 +++ llvm/docs/llvm.css Wed Feb 9 16:47:47 2005 @@ -51,7 +51,7 @@ .doc_footer { text-align: left; padding: 0 0 0 0 } -.doc_red { color: red } +.doc_hilite { color: blue; font-weight: bold; } .doc_table { text-align: center; width: 90%; padding: 1px 1px 1px 1px; border: 1px; } From brukman at cs.uiuc.edu Wed Feb 9 16:49:15 2005 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Wed, 9 Feb 2005 16:49:15 -0600 Subject: [llvm-commits] CVS: llvm/docs/CommandLine.html Message-ID: <200502092249.QAA13551@zion.cs.uiuc.edu> Changes in directory llvm/docs: CommandLine.html updated: 1.30 -> 1.31 --- Log message: * Use doc_code style for blocks of code * Convert < to < in
           block
          * Use doc_hilite instead of doc_red style
          * Put some classes and options in  blocks
          
          
          ---
          Diffs of the changes:  (+17 -15)
          
           CommandLine.html |   32 +++++++++++++++++---------------
           1 files changed, 17 insertions(+), 15 deletions(-)
          
          
          Index: llvm/docs/CommandLine.html
          diff -u llvm/docs/CommandLine.html:1.30 llvm/docs/CommandLine.html:1.31
          --- llvm/docs/CommandLine.html:1.30	Wed Nov 24 00:13:42 2004
          +++ llvm/docs/CommandLine.html	Wed Feb  9 16:49:05 2005
          @@ -961,6 +961,7 @@
           
           

          To do this, set up your .h file with your option, like this for example:

          +
           // DebugFlag.h - Get access to the '-debug' command line option
           //
          @@ -976,15 +977,15 @@
           // debug build, then the code specified as the option to the macro will be
           // executed.  Otherwise it will not be.  Example:
           //
          -// DEBUG(cerr << "Bitset contains: " << Bitset << "\n");
          +// DEBUG(std::cerr << "Bitset contains: " << Bitset << "\n");
           //
          -#ifdef NDEBUG
          +#ifdef NDEBUG
           #define DEBUG(X)
           #else
          -#define DEBUG(X) \
          -  do { if (DebugFlag) { X; } } while (0)
          -#endif
          +#define DEBUG(X) do { if (DebugFlag) { X; } } while (0)
          +#endif
           
          +

          This allows clients to blissfully use the DEBUG() macro, or the DebugFlag explicitly if they want to. Now we just need to be able to @@ -993,18 +994,19 @@ where to fill in with the cl::location attribute:

          +
          -bool DebugFlag;      // the actual value
          +bool DebugFlag;                  // the actual value
           static cl::opt<bool, true>       // The parser
          -Debug("debug", cl::desc("Enable debug output"), cl::Hidden,
          -      cl::location(DebugFlag));
          +Debug("debug", cl::desc("Enable debug output"), cl::Hidden, cl::location(DebugFlag));
           
          +

          In the above example, we specify "true" as the second argument to -the cl::opt template, indicating that the template should -not maintain a copy of the value itself. In addition to this, we specify the cl::location attribute, so that DebugFlag is -automatically set.

          +the cl::opt template, indicating that the +template should not maintain a copy of the value itself. In addition to this, +we specify the cl::location attribute, so +that DebugFlag is automatically set.

        @@ -1055,8 +1057,8 @@ information.
      1. The cl::aliasopt attribute -specifies which option a cl::alias option is an alias -for.
      2. +specifies which option a cl::alias option is +an alias for.
      3. The cl::values attribute specifies the string-to-value mapping to be used by the generic parser. It takes a @@ -1808,7 +1810,7 @@ Chris Lattner
        LLVM Compiler Infrastructure
        - Last modified: $Date: 2004/11/24 06:13:42 $ + Last modified: $Date: 2005/02/09 22:49:05 $ From lattner at cs.uiuc.edu Wed Feb 9 16:53:01 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 9 Feb 2005 16:53:01 -0600 Subject: [llvm-commits] CVS: llvm/docs/GettingStarted.html Message-ID: <200502092253.j19Mr1R4024094@apoc.cs.uiuc.edu> Changes in directory llvm/docs: GettingStarted.html updated: 1.110 -> 1.111 --- Log message: This will be moved elsewhere. --- Diffs of the changes: (+2 -9) GettingStarted.html | 11 ++--------- 1 files changed, 2 insertions(+), 9 deletions(-) Index: llvm/docs/GettingStarted.html diff -u llvm/docs/GettingStarted.html:1.110 llvm/docs/GettingStarted.html:1.111 --- llvm/docs/GettingStarted.html:1.110 Wed Feb 9 16:38:47 2005 +++ llvm/docs/GettingStarted.html Wed Feb 9 16:52:46 2005 @@ -285,14 +285,7 @@
      4. The port is done using the MSYS shell. Download and install bison (excl. M4.exe) and flex in that order. Build binutils-2.15 from source, -if necessary. If you need to create a library for an MS DLL, do the following: -
          -
        • pexports /C/WINNT/SYSTEM32/file.dll | sed "s/^_//" > -/C/MinGW/lib/file.def
        • -
        • Edit file and append @<ordinal> to the missing function name
        • -
        • dlltool.exe -k -d /C/MinGW/lib/file.def -l -/C/MinGW/lib/libfile.a.
        • -
      5. +if necessary.
    6. @@ -1502,7 +1495,7 @@ Chris Lattner
      Reid Spencer
      The LLVM Compiler Infrastructure
      - Last modified: $Date: 2005/02/09 22:38:47 $ + Last modified: $Date: 2005/02/09 22:52:46 $ From lattner at cs.uiuc.edu Wed Feb 9 16:56:03 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 9 Feb 2005 16:56:03 -0600 Subject: [llvm-commits] CVS: poolalloc/lib/PoolAllocate/PointerCompress.cpp Message-ID: <200502092256.j19Mu3Nr026016@apoc.cs.uiuc.edu> Changes in directory poolalloc/lib/PoolAllocate: PointerCompress.cpp updated: 1.1 -> 1.2 --- Log message: Continue implementation of ptrcompression xform. Now we successfully compute the "to be compressed to" type (in trivial cases), and we have more of the framework for rewriting the instructions in place. --- Diffs of the changes: (+132 -6) Index: poolalloc/lib/PoolAllocate/PointerCompress.cpp diff -u poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.1 poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.2 --- poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.1 Tue Feb 8 21:46:22 2005 +++ poolalloc/lib/PoolAllocate/PointerCompress.cpp Wed Feb 9 16:55:53 2005 @@ -17,6 +17,7 @@ #include "llvm/Module.h" #include "llvm/ADT/Statistic.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/InstVisitor.h" using namespace llvm; namespace { @@ -25,6 +26,7 @@ Statistic<> NumNotCompressed("pointercompress", "Number of pools not compressible"); + class CompressedPoolInfo; /// PointerCompress - This transformation hacks on type-safe pool allocated /// data structures to reduce the size of pointers in the program. @@ -32,6 +34,8 @@ PoolAllocate *PoolAlloc; PA::EquivClassGraphs *ECG; public: + typedef std::map PoolInfoMap; + bool runOnModule(Module &M); void getAnalysisUsage(AnalysisUsage &AU) const; @@ -45,6 +49,74 @@ X("pointercompress", "Compress type-safe data structures"); } +//===----------------------------------------------------------------------===// +// CompressedPoolInfo Class and Implementation +//===----------------------------------------------------------------------===// + +namespace { + /// CompressedPoolInfo - An instance of this structure is created for each + /// pool that is compressed. + class CompressedPoolInfo { + const DSNode *Pool; + const Type *NewTy; + public: + CompressedPoolInfo(const DSNode *N) : Pool(N), NewTy(0) {} + + /// Initialize - When we know all of the pools in a function that are going + /// to be compressed, initialize our state based on that data. + void Initialize(std::map &Nodes); + + const DSNode *getNode() const { return Pool; } + const Type *getNewType() const { return NewTy; } + + // dump - Emit a debugging dump of this pool info. + void dump() const; + + private: + const Type *ComputeCompressedType(const Type *OrigTy, unsigned NodeOffset, + std::map &Nodes); + }; +} + +/// Initialize - When we know all of the pools in a function that are going +/// to be compressed, initialize our state based on that data. +void CompressedPoolInfo::Initialize(std::map &Nodes) { + // First step, compute the type of the compressed node. This basically + // replaces all pointers to compressed pools with uints. + NewTy = ComputeCompressedType(Pool->getType(), 0, Nodes); + +} + + +/// ComputeCompressedType - Recursively compute the new type for this node after +/// pointer compression. This involves compressing any pointers that point into +/// compressed pools. +const Type *CompressedPoolInfo:: +ComputeCompressedType(const Type *OrigTy, unsigned NodeOffset, + std::map &Nodes) { + if (const PointerType *PTY = dyn_cast(OrigTy)) { + // FIXME: check to see if this pointer is actually compressed! + return Type::UIntTy; + } else if (OrigTy->isFirstClassType()) + return OrigTy; + + // Okay, we have an aggregate type. + assert(0 && "FIXME: Unhandled aggregate type!"); +} + +/// dump - Emit a debugging dump for this pool info. +/// +void CompressedPoolInfo::dump() const { + std::cerr << "Node: "; getNode()->dump(); + std::cerr << "New Type: " << *NewTy << "\n"; +} + + +//===----------------------------------------------------------------------===// +// PointerCompress Implementation +//===----------------------------------------------------------------------===// + void PointerCompress::getAnalysisUsage(AnalysisUsage &AU) const { // Need information about how pool allocation happened. AU.addRequired(); @@ -85,6 +157,11 @@ return false; } + if ((N->getNodeFlags() & DSNode::Composition) != DSNode::HeapNode) { + DEBUG(std::cerr << "Node contains non-heap values:\n"); + return false; + } + return true; } @@ -119,6 +196,41 @@ } +namespace { + class InstructionRewriter : public llvm::InstVisitor { + /// OldToNewValueMap - This keeps track of what new instructions we create + /// for instructions that used to produce pointers into our pool. + std::map OldToNewValueMap; + + /// ForwardRefs - If a value is refered to before it is defined, create a + /// temporary Argument node as a placeholder. When the value is really + /// defined, call replaceAllUsesWith on argument and remove it from this + /// map. + std::map ForwardRefs; + + const PointerCompress::PoolInfoMap &PoolInfo; + + const DSGraph &DSG; + public: + InstructionRewriter(const PointerCompress::PoolInfoMap &poolInfo, + const DSGraph &dsg) + : PoolInfo(poolInfo), DSG(dsg) { + } + ~InstructionRewriter() { + assert(ForwardRefs.empty() && "Unresolved forward refs exist!"); + } + + void visitInstruction(Instruction &I) { + std::cerr << "ERROR: UNHANDLED INSTRUCTION: " << I; + //assert(0); + //abort(); + } + }; +} // end anonymous namespace. + + + + /// CompressPoolsInFunction - Find all pools that are compressible in this /// function and compress them. bool PointerCompress::CompressPoolsInFunction(Function &F) { @@ -145,17 +257,31 @@ DSGraph &DSG = ECG->getDSGraph(FI->F); // Compute the set of compressible pools in this function. - std::vector PoolsToCompress; - FindPoolsToCompress(PoolsToCompress, F, DSG, FI); + std::vector PoolsToCompressList; + FindPoolsToCompress(PoolsToCompressList, F, DSG, FI); - if (PoolsToCompress.empty()) return false; + if (PoolsToCompressList.empty()) return false; + // Compute the initial collection of compressed pointer infos. + std::map PoolsToCompress; + for (unsigned i = 0, e = PoolsToCompressList.size(); i != e; ++i) + PoolsToCompress.insert(std::make_pair(PoolsToCompressList[i], + PoolsToCompressList[i])); + + // Use these to compute the closure of compression information. In + // particular, if one pool points to another, we need to know if the outgoing + // pointer is compressed. std::cerr << "In function '" << F.getName() << "':\n"; - for (unsigned i = 0, e = PoolsToCompress.size(); i != e; ++i) { + for (std::map::iterator + I = PoolsToCompress.begin(), E = PoolsToCompress.end(); I != E; ++I) { + I->second.Initialize(PoolsToCompress); std::cerr << " COMPRESSING POOL:\nPCS:"; - PoolsToCompress[i]->dump(); + I->second.dump(); } - return false; + + // Finally, rewrite the function body to use compressed pointers! + InstructionRewriter(PoolsToCompress, DSG).visit(F); + return true; } bool PointerCompress::runOnModule(Module &M) { From brukman at cs.uiuc.edu Wed Feb 9 19:52:33 2005 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Wed, 9 Feb 2005 19:52:33 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaRegisterInfo.td Message-ID: <200502100152.TAA26839@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaRegisterInfo.td updated: 1.7 -> 1.8 --- Log message: * Fix spelling of `volatile' * Align comments with tablegen elements --- Diffs of the changes: (+9 -9) AlphaRegisterInfo.td | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-) Index: llvm/lib/Target/Alpha/AlphaRegisterInfo.td diff -u llvm/lib/Target/Alpha/AlphaRegisterInfo.td:1.7 llvm/lib/Target/Alpha/AlphaRegisterInfo.td:1.8 --- llvm/lib/Target/Alpha/AlphaRegisterInfo.td:1.7 Sun Feb 6 15:07:31 2005 +++ llvm/lib/Target/Alpha/AlphaRegisterInfo.td Wed Feb 9 19:52:22 2005 @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// // +// This file describes the Alpha register set. // //===----------------------------------------------------------------------===// @@ -78,19 +79,18 @@ /// Register classes def GPRC : RegisterClass; -//R28 is reserved for the assembler + // Note: R28 is reserved for the assembler -//Don't allocate 15, 29, 30, 31 -//Allocation volatiles only for now +// Don't allocate 15, 29, 30, 31 +// Allocation volatiles only for now def FPRC : RegisterClass; - - From brukman at cs.uiuc.edu Wed Feb 9 20:08:07 2005 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Wed, 9 Feb 2005 20:08:07 -0600 Subject: [llvm-commits] CVS: llvm/CREDITS.TXT Message-ID: <200502100208.UAA30924@zion.cs.uiuc.edu> Changes in directory llvm: CREDITS.TXT updated: 1.34 -> 1.35 --- Log message: Give props to Brian for V8 backend --- Diffs of the changes: (+1 -0) CREDITS.TXT | 1 + 1 files changed, 1 insertion(+) Index: llvm/CREDITS.TXT diff -u llvm/CREDITS.TXT:1.34 llvm/CREDITS.TXT:1.35 --- llvm/CREDITS.TXT:1.34 Thu Nov 18 15:04:21 2004 +++ llvm/CREDITS.TXT Wed Feb 9 20:07:57 2005 @@ -55,6 +55,7 @@ D: Portions of X86 static and JIT compilers. D: Dynamic trace optimizer D: FreeBSD/X86 compatibility fixes, the llvm-nm tool +D: SparcV8 backend N: Louis Gerbarg D: Portions of the PowerPC backend From alenhar2 at cs.uiuc.edu Wed Feb 9 23:18:16 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Wed, 9 Feb 2005 23:18:16 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaInstrInfo.td Message-ID: <200502100518.XAA12097@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaInstrInfo.td updated: 1.22 -> 1.23 --- Log message: fix fp branch --- Diffs of the changes: (+6 -6) AlphaInstrInfo.td | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) Index: llvm/lib/Target/Alpha/AlphaInstrInfo.td diff -u llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.22 llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.23 --- llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.22 Mon Feb 7 17:02:23 2005 +++ llvm/lib/Target/Alpha/AlphaInstrInfo.td Wed Feb 9 23:17:38 2005 @@ -324,12 +324,12 @@ def BNE : BForm<0x3D, (ops GPRC:$RA, s21imm:$DISP), "bne $RA,$DISP">; //Branch if != zero //Branches, float -def FBEQ : BForm<0x31, (ops FPRC:$RA, s21imm:$DISP), "beq $RA,$DISP">; //Floating branch if = zero -def FBGE : BForm<0x36, (ops FPRC:$RA, s21imm:$DISP), "beq $RA,$DISP">; //Floating branch if >= zero -def FBGT : BForm<0x37, (ops FPRC:$RA, s21imm:$DISP), "beq $RA,$DISP">; //Floating branch if > zero -def FBLE : BForm<0x33, (ops FPRC:$RA, s21imm:$DISP), "beq $RA,$DISP">; //Floating branch if <= zero -def FBLT : BForm<0x32, (ops FPRC:$RA, s21imm:$DISP), "beq $RA,$DISP">; //Floating branch if < zero -def FBNE : BForm<0x35, (ops FPRC:$RA, s21imm:$DISP), "beq $RA,$DISP">; //Floating branch if != zero +def FBEQ : BForm<0x31, (ops FPRC:$RA, s21imm:$DISP), "fbeq $RA,$DISP">; //Floating branch if = zero +def FBGE : BForm<0x36, (ops FPRC:$RA, s21imm:$DISP), "fbge $RA,$DISP">; //Floating branch if >= zero +def FBGT : BForm<0x37, (ops FPRC:$RA, s21imm:$DISP), "fbgt $RA,$DISP">; //Floating branch if > zero +def FBLE : BForm<0x33, (ops FPRC:$RA, s21imm:$DISP), "fble $RA,$DISP">; //Floating branch if <= zero +def FBLT : BForm<0x32, (ops FPRC:$RA, s21imm:$DISP), "fblt $RA,$DISP">; //Floating branch if < zero +def FBNE : BForm<0x35, (ops FPRC:$RA, s21imm:$DISP), "fbne $RA,$DISP">; //Floating branch if != zero //Funky Floating point ops def CPYS : FPForm<0x17, 0x020, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "cpys $RA,$RB,$RC">; //Copy sign From alenhar2 at cs.uiuc.edu Thu Feb 10 00:25:51 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Thu, 10 Feb 2005 00:25:51 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp AlphaInstrInfo.td AlphaRegisterInfo.td Message-ID: <200502100625.AAA14476@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.47 -> 1.48 AlphaInstrInfo.td updated: 1.23 -> 1.24 AlphaRegisterInfo.td updated: 1.8 -> 1.9 --- Log message: so, if you beat on it, you too can talk emacs into having a sane indenting policy... Also, optimize many function calls with pc-relative calls (partial prologue skipping for that case coming soon), try to fix the random jumps to strange places problem by pesimizing div et. al. register usage and fixing up GP before using, some calling convention tweaks, and make frame pointer unallocatable (not strickly necessary, but let's go for correctness first) --- Diffs of the changes: (+574 -548) AlphaISelPattern.cpp | 1107 ++++++++++++++++++++++++++------------------------- AlphaInstrInfo.td | 12 AlphaRegisterInfo.td | 3 3 files changed, 574 insertions(+), 548 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.47 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.48 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.47 Mon Feb 7 18:40:03 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Thu Feb 10 00:25:13 2005 @@ -46,7 +46,7 @@ addRegisterClass(MVT::i64, Alpha::GPRCRegisterClass); addRegisterClass(MVT::f64, Alpha::FPRCRegisterClass); addRegisterClass(MVT::f32, Alpha::FPRCRegisterClass); - + setOperationAction(ISD::EXTLOAD , MVT::i1 , Promote); setOperationAction(ISD::ZEXTLOAD , MVT::i1 , Expand); @@ -56,7 +56,8 @@ setOperationAction(ISD::SEXTLOAD , MVT::i8 , Expand); setOperationAction(ISD::SEXTLOAD , MVT::i16 , Expand); - setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i1, Expand); //what is the sign expansion of 1? 1 or -1? + //what is the sign expansion of 1? 1 or -1? + setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i1, Expand); setOperationAction(ISD::SREM , MVT::f32 , Expand); setOperationAction(ISD::SREM , MVT::f64 , Expand); @@ -65,26 +66,26 @@ setOperationAction(ISD::MEMSET , MVT::Other, Expand); setOperationAction(ISD::MEMCPY , MVT::Other, Expand); - computeRegisterProperties(); + computeRegisterProperties(); - addLegalFPImmediate(+0.0); //F31 - addLegalFPImmediate(-0.0); //-F31 + addLegalFPImmediate(+0.0); //F31 + addLegalFPImmediate(-0.0); //-F31 } /// LowerArguments - This hook must be implemented to indicate how we should /// lower the arguments for the specified function, into the specified DAG. virtual std::vector LowerArguments(Function &F, SelectionDAG &DAG); - + /// LowerCallTo - This hook lowers an abstract call to a function into an /// actual call. virtual std::pair LowerCallTo(SDOperand Chain, const Type *RetTy, SDOperand Callee, ArgListTy &Args, SelectionDAG &DAG); - + virtual std::pair LowerVAStart(SDOperand Chain, SelectionDAG &DAG); - + virtual std::pair LowerVAArgNext(bool isVANext, SDOperand Chain, SDOperand VAList, const Type *ArgTy, SelectionDAG &DAG); @@ -144,57 +145,69 @@ int count = 0; for (Function::aiterator I = F.abegin(), E = F.aend(); I != E; ++I) - { - SDOperand newroot, argt; - if (count < 6) { - switch (getValueType(I->getType())) { - default: std::cerr << "Unknown Type " << getValueType(I->getType()) << "\n"; abort(); - case MVT::f64: - case MVT::f32: - BuildMI(&BB, Alpha::IDEF, 0, args_float[count]); - argVreg[count] = MF.getSSARegMap()->createVirtualRegister(getRegClassFor(getValueType(I->getType()))); - argPreg[count] = args_float[count]; - argOpc[count] = Alpha::CPYS; - argt = newroot = DAG.getCopyFromReg(argVreg[count], getValueType(I->getType()), DAG.getRoot()); - break; - case MVT::i1: - case MVT::i8: - case MVT::i16: - case MVT::i32: - case MVT::i64: - BuildMI(&BB, Alpha::IDEF, 0, args_int[count]); - argVreg[count] =MF.getSSARegMap()->createVirtualRegister(getRegClassFor(MVT::i64)); - argPreg[count] = args_int[count]; - argOpc[count] = Alpha::BIS; - argt = newroot = DAG.getCopyFromReg(argVreg[count], MVT::i64, DAG.getRoot()); - if (getValueType(I->getType()) != MVT::i64) - argt = DAG.getNode(ISD::TRUNCATE, getValueType(I->getType()), newroot); - break; - } - ++count; - } else { //more args - // Create the frame index object for this incoming parameter... - int FI = MFI->CreateFixedObject(8, 8 * (count - 6)); - - // Create the SelectionDAG nodes corresponding to a load from this parameter - SDOperand FIN = DAG.getFrameIndex(FI, MVT::i64); - argt = newroot = DAG.getLoad(getValueType(I->getType()), DAG.getEntryNode(), FIN); + { + SDOperand newroot, argt; + if (count < 6) { + switch (getValueType(I->getType())) { + default: + std::cerr << "Unknown Type " << getValueType(I->getType()) << "\n"; + abort(); + case MVT::f64: + case MVT::f32: + BuildMI(&BB, Alpha::IDEF, 0, args_float[count]); + argVreg[count] = + MF.getSSARegMap()->createVirtualRegister( + getRegClassFor(getValueType(I->getType()))); + argPreg[count] = args_float[count]; + argOpc[count] = Alpha::CPYS; + argt = newroot = DAG.getCopyFromReg(argVreg[count], + getValueType(I->getType()), + DAG.getRoot()); + break; + case MVT::i1: + case MVT::i8: + case MVT::i16: + case MVT::i32: + case MVT::i64: + BuildMI(&BB, Alpha::IDEF, 0, args_int[count]); + argVreg[count] = + MF.getSSARegMap()->createVirtualRegister(getRegClassFor(MVT::i64)); + argPreg[count] = args_int[count]; + argOpc[count] = Alpha::BIS; + argt = newroot = + DAG.getCopyFromReg(argVreg[count], MVT::i64, DAG.getRoot()); + if (getValueType(I->getType()) != MVT::i64) + argt = + DAG.getNode(ISD::TRUNCATE, getValueType(I->getType()), newroot); + break; } - DAG.setRoot(newroot.getValue(1)); - ArgValues.push_back(argt); + ++count; + } else { //more args + // Create the frame index object for this incoming parameter... + int FI = MFI->CreateFixedObject(8, 8 * (count - 6)); + + // Create the SelectionDAG nodes corresponding to a load + //from this parameter + SDOperand FIN = DAG.getFrameIndex(FI, MVT::i64); + argt = newroot = DAG.getLoad(getValueType(I->getType()), + DAG.getEntryNode(), FIN); } + DAG.setRoot(newroot.getValue(1)); + ArgValues.push_back(argt); + } BuildMI(&BB, Alpha::IDEF, 0, Alpha::R29); BuildMI(&BB, Alpha::BIS, 2, GP).addReg(Alpha::R29).addReg(Alpha::R29); - for (int i = 0; i < count; ++i) + for (int i = 0; i < count; ++i) { + if (argPreg[i] == Alpha::F16 || argPreg[i] == Alpha::F17 || + argPreg[i] == Alpha::F18 || argPreg[i] == Alpha::F19 || + argPreg[i] == Alpha::F20 || argPreg[i] == Alpha::F21) { - if (argPreg[i] == Alpha::F16 || argPreg[i] == Alpha::F17 || argPreg[i] == Alpha::F18 || - argPreg[i] == Alpha::F19 || argPreg[i] == Alpha::F20 || argPreg[i] == Alpha::F21) - { - assert(argOpc[i] == Alpha::CPYS && "Using BIS for a float??"); - } - BuildMI(&BB, argOpc[i], 2, argVreg[i]).addReg(argPreg[i]).addReg(argPreg[i]); + assert(argOpc[i] == Alpha::CPYS && "Using BIS for a float??"); } + BuildMI(&BB, argOpc[i], 2, + argVreg[i]).addReg(argPreg[i]).addReg(argPreg[i]); + } return ArgValues; } @@ -211,27 +224,27 @@ DAG.getConstant(NumBytes, getPointerTy())); std::vector args_to_use; for (unsigned i = 0, e = Args.size(); i != e; ++i) - { - switch (getValueType(Args[i].second)) { - default: assert(0 && "Unexpected ValueType for argument!"); - case MVT::i1: - case MVT::i8: - case MVT::i16: - case MVT::i32: - // Promote the integer to 64 bits. If the input type is signed use a - // sign extend, otherwise use a zero extend. - if (Args[i].second->isSigned()) - Args[i].first = DAG.getNode(ISD::SIGN_EXTEND, MVT::i64, Args[i].first); - else - Args[i].first = DAG.getNode(ISD::ZERO_EXTEND, MVT::i64, Args[i].first); - break; - case MVT::i64: - case MVT::f64: - case MVT::f32: - break; - } - args_to_use.push_back(Args[i].first); + { + switch (getValueType(Args[i].second)) { + default: assert(0 && "Unexpected ValueType for argument!"); + case MVT::i1: + case MVT::i8: + case MVT::i16: + case MVT::i32: + // Promote the integer to 64 bits. If the input type is signed use a + // sign extend, otherwise use a zero extend. + if (Args[i].second->isSigned()) + Args[i].first = DAG.getNode(ISD::SIGN_EXTEND, MVT::i64, Args[i].first); + else + Args[i].first = DAG.getNode(ISD::ZERO_EXTEND, MVT::i64, Args[i].first); + break; + case MVT::i64: + case MVT::f64: + case MVT::f32: + break; } + args_to_use.push_back(Args[i].first); + } std::vector RetVals; MVT::ValueType RetTyVT = getValueType(RetTy); @@ -239,11 +252,12 @@ RetVals.push_back(RetTyVT); RetVals.push_back(MVT::Other); - SDOperand TheCall = SDOperand(DAG.getCall(RetVals, Chain, Callee, args_to_use), 0); + SDOperand TheCall = SDOperand(DAG.getCall(RetVals, + Chain, Callee, args_to_use), 0); Chain = TheCall.getValue(RetTyVT != MVT::isVoid); Chain = DAG.getNode(ISD::ADJCALLSTACKUP, MVT::Other, Chain, DAG.getConstant(NumBytes, getPointerTy())); - return std::make_pair(TheCall, Chain); + return std::make_pair(TheCall, Chain); } std::pair @@ -254,7 +268,7 @@ std::pair AlphaTargetLowering:: LowerVAArgNext(bool isVANext, SDOperand Chain, SDOperand VAList, - const Type *ArgTy, SelectionDAG &DAG) { + const Type *ArgTy, SelectionDAG &DAG) { abort(); } @@ -271,48 +285,48 @@ namespace { - //===--------------------------------------------------------------------===// - /// ISel - Alpha specific code to select Alpha machine instructions for - /// SelectionDAG operations. - /// - class ISel : public SelectionDAGISel { - - /// AlphaLowering - This object fully describes how to lower LLVM code to an - /// Alpha-specific SelectionDAG. - AlphaTargetLowering AlphaLowering; - - - /// ExprMap - As shared expressions are codegen'd, we keep track of which - /// vreg the value is produced in, so we only emit one copy of each compiled - /// tree. - static const unsigned notIn = (unsigned)(-1); - std::map ExprMap; - - //CCInvMap sometimes (SetNE) we have the inverse CC code for free - std::map CCInvMap; - - public: - ISel(TargetMachine &TM) : SelectionDAGISel(AlphaLowering), AlphaLowering(TM) { - } - - /// InstructionSelectBasicBlock - This callback is invoked by - /// SelectionDAGISel when it has created a SelectionDAG for us to codegen. - virtual void InstructionSelectBasicBlock(SelectionDAG &DAG) { - // Codegen the basic block. - Select(DAG.getRoot()); - - // Clear state used for selection. - ExprMap.clear(); - CCInvMap.clear(); - } - - unsigned SelectExpr(SDOperand N); - unsigned SelectExprFP(SDOperand N, unsigned Result); - void Select(SDOperand N); - - void SelectAddr(SDOperand N, unsigned& Reg, long& offset); - void SelectBranchCC(SDOperand N); - }; +//===--------------------------------------------------------------------===// +/// ISel - Alpha specific code to select Alpha machine instructions for +/// SelectionDAG operations. +//===--------------------------------------------------------------------===// +class ISel : public SelectionDAGISel { + + /// AlphaLowering - This object fully describes how to lower LLVM code to an + /// Alpha-specific SelectionDAG. + AlphaTargetLowering AlphaLowering; + + + /// ExprMap - As shared expressions are codegen'd, we keep track of which + /// vreg the value is produced in, so we only emit one copy of each compiled + /// tree. + static const unsigned notIn = (unsigned)(-1); + std::map ExprMap; + + //CCInvMap sometimes (SetNE) we have the inverse CC code for free + std::map CCInvMap; + +public: + ISel(TargetMachine &TM) : SelectionDAGISel(AlphaLowering), AlphaLowering(TM) + {} + + /// InstructionSelectBasicBlock - This callback is invoked by + /// SelectionDAGISel when it has created a SelectionDAG for us to codegen. + virtual void InstructionSelectBasicBlock(SelectionDAG &DAG) { + // Codegen the basic block. + Select(DAG.getRoot()); + + // Clear state used for selection. + ExprMap.clear(); + CCInvMap.clear(); + } + + unsigned SelectExpr(SDOperand N); + unsigned SelectExprFP(SDOperand N, unsigned Result); + void Select(SDOperand N); + + void SelectAddr(SDOperand N, unsigned& Reg, long& offset); + void SelectBranchCC(SDOperand N); +}; } static unsigned GetSymVersion(unsigned opcode) @@ -341,18 +355,20 @@ { unsigned opcode = N.getOpcode(); if (opcode == ISD::ADD) { - if(N.getOperand(1).getOpcode() == ISD::Constant && cast(N.getOperand(1))->getValue() <= 32767) - { //Normal imm add - Reg = SelectExpr(N.getOperand(0)); - offset = cast(N.getOperand(1))->getValue(); - return; - } - else if(N.getOperand(0).getOpcode() == ISD::Constant && cast(N.getOperand(0))->getValue() <= 32767) - { - Reg = SelectExpr(N.getOperand(1)); - offset = cast(N.getOperand(0))->getValue(); - return; - } + if(N.getOperand(1).getOpcode() == ISD::Constant && + cast(N.getOperand(1))->getValue() <= 32767) + { //Normal imm add + Reg = SelectExpr(N.getOperand(0)); + offset = cast(N.getOperand(1))->getValue(); + return; + } + else if(N.getOperand(0).getOpcode() == ISD::Constant && + cast(N.getOperand(0))->getValue() <= 32767) + { + Reg = SelectExpr(N.getOperand(1)); + offset = cast(N.getOperand(0))->getValue(); + return; + } } Reg = SelectExpr(N); offset = 0; @@ -362,109 +378,104 @@ void ISel::SelectBranchCC(SDOperand N) { assert(N.getOpcode() == ISD::BRCOND && "Not a BranchCC???"); - MachineBasicBlock *Dest = cast(N.getOperand(2))->getBasicBlock(); - unsigned Opc; - + MachineBasicBlock *Dest = + cast(N.getOperand(2))->getBasicBlock(); + unsigned Opc = Alpha::WTF; + Select(N.getOperand(0)); //chain SDOperand CC = N.getOperand(1); - + if (CC.getOpcode() == ISD::SETCC) - { - SetCCSDNode* SetCC = dyn_cast(CC.Val); - if (MVT::isInteger(SetCC->getOperand(0).getValueType())) { - //Dropping the CC is only useful if we are comparing to 0 - bool isZero0 = false; - bool isZero1 = false; - bool isNE = false; - - if(SetCC->getOperand(0).getOpcode() == ISD::Constant && - cast(SetCC->getOperand(0))->getValue() == 0) - isZero0 = true; - if(SetCC->getOperand(1).getOpcode() == ISD::Constant && - cast(SetCC->getOperand(1))->getValue() == 0) - isZero1 = true; - if(SetCC->getCondition() == ISD::SETNE) - isNE = true; - - if (isZero0) - { - switch (SetCC->getCondition()) { - default: CC.Val->dump(); assert(0 && "Unknown integer comparison!"); - case ISD::SETEQ: Opc = Alpha::BEQ; break; - case ISD::SETLT: Opc = Alpha::BGT; break; - case ISD::SETLE: Opc = Alpha::BGE; break; - case ISD::SETGT: Opc = Alpha::BLT; break; - case ISD::SETGE: Opc = Alpha::BLE; break; - case ISD::SETULT: Opc = Alpha::BNE; break; - case ISD::SETUGT: assert(0 && "0 > (unsigned) x is never true"); break; - case ISD::SETULE: assert(0 && "0 <= (unsigned) x is always true"); break; - case ISD::SETUGE: Opc = Alpha::BEQ; break; //Technically you could have this CC - case ISD::SETNE: Opc = Alpha::BNE; break; - } - unsigned Tmp1 = SelectExpr(SetCC->getOperand(1)); - BuildMI(BB, Opc, 2).addReg(Tmp1).addMBB(Dest); - return; - } - else if (isZero1) - { - switch (SetCC->getCondition()) { - default: CC.Val->dump(); assert(0 && "Unknown integer comparison!"); - case ISD::SETEQ: Opc = Alpha::BEQ; break; - case ISD::SETLT: Opc = Alpha::BLT; break; - case ISD::SETLE: Opc = Alpha::BLE; break; - case ISD::SETGT: Opc = Alpha::BGT; break; - case ISD::SETGE: Opc = Alpha::BGE; break; - case ISD::SETULT: assert(0 && "x (unsigned) < 0 is never true"); break; - case ISD::SETUGT: Opc = Alpha::BNE; break; - case ISD::SETULE: Opc = Alpha::BEQ; break; //Technically you could have this CC - case ISD::SETUGE: assert(0 && "x (unsgined >= 0 is always true"); break; - case ISD::SETNE: Opc = Alpha::BNE; break; - } - unsigned Tmp1 = SelectExpr(SetCC->getOperand(0)); - BuildMI(BB, Opc, 2).addReg(Tmp1).addMBB(Dest); - return; - } - else - { - unsigned Tmp1 = SelectExpr(CC); - if (isNE) - BuildMI(BB, Alpha::BEQ, 2).addReg(CCInvMap[CC]).addMBB(Dest); - else - BuildMI(BB, Alpha::BNE, 2).addReg(Tmp1).addMBB(Dest); - return; - } - } else { //FP - //Any comparison between 2 values should be codegened as an folded branch, as moving - //CC to the integer register is very expensive - //for a cmp b: c = a - b; - //a = b: c = 0 - //a < b: c < 0 - //a > b: c > 0 - unsigned Tmp1 = SelectExpr(SetCC->getOperand(0)); - unsigned Tmp2 = SelectExpr(SetCC->getOperand(1)); - unsigned Tmp3 = MakeReg(MVT::f64); - BuildMI(BB, Alpha::SUBT, 2, Tmp3).addReg(Tmp1).addReg(Tmp2); + { + SetCCSDNode* SetCC = dyn_cast(CC.Val); + if (MVT::isInteger(SetCC->getOperand(0).getValueType())) { + //Dropping the CC is only useful if we are comparing to 0 + bool isZero0 = false; + bool isZero1 = false; + bool isNE = false; + + if(SetCC->getOperand(0).getOpcode() == ISD::Constant && + cast(SetCC->getOperand(0))->getValue() == 0) + isZero0 = true; + if(SetCC->getOperand(1).getOpcode() == ISD::Constant && + cast(SetCC->getOperand(1))->getValue() == 0) + isZero1 = true; + if(SetCC->getCondition() == ISD::SETNE) + isNE = true; + if (isZero0) { + switch (SetCC->getCondition()) { + default: CC.Val->dump(); assert(0 && "Unknown integer comparison!"); + case ISD::SETEQ: Opc = Alpha::BEQ; break; + case ISD::SETLT: Opc = Alpha::BGT; break; + case ISD::SETLE: Opc = Alpha::BGE; break; + case ISD::SETGT: Opc = Alpha::BLT; break; + case ISD::SETGE: Opc = Alpha::BLE; break; + case ISD::SETULT: Opc = Alpha::BNE; break; + case ISD::SETUGT: assert(0 && "0 > (unsigned) x is never true"); break; + case ISD::SETULE: assert(0 && "0 <= (unsigned) x is always true"); break; + case ISD::SETUGE: Opc = Alpha::BEQ; break; //Technically you could have this CC + case ISD::SETNE: Opc = Alpha::BNE; break; + } + unsigned Tmp1 = SelectExpr(SetCC->getOperand(1)); + BuildMI(BB, Opc, 2).addReg(Tmp1).addMBB(Dest); + return; + } else if (isZero1) { switch (SetCC->getCondition()) { - default: CC.Val->dump(); assert(0 && "Unknown FP comparison!"); - case ISD::SETEQ: Opc = Alpha::FBEQ; break; - case ISD::SETLT: Opc = Alpha::FBLT; break; - case ISD::SETLE: Opc = Alpha::FBLE; break; - case ISD::SETGT: Opc = Alpha::FBGT; break; - case ISD::SETGE: Opc = Alpha::FBGE; break; - case ISD::SETNE: Opc = Alpha::FBNE; break; + default: CC.Val->dump(); assert(0 && "Unknown integer comparison!"); + case ISD::SETEQ: Opc = Alpha::BEQ; break; + case ISD::SETLT: Opc = Alpha::BLT; break; + case ISD::SETLE: Opc = Alpha::BLE; break; + case ISD::SETGT: Opc = Alpha::BGT; break; + case ISD::SETGE: Opc = Alpha::BGE; break; + case ISD::SETULT: assert(0 && "x (unsigned) < 0 is never true"); break; + case ISD::SETUGT: Opc = Alpha::BNE; break; + case ISD::SETULE: Opc = Alpha::BEQ; break; //Technically you could have this CC + case ISD::SETUGE: assert(0 && "x (unsgined >= 0 is always true"); break; + case ISD::SETNE: Opc = Alpha::BNE; break; } - BuildMI(BB, Opc, 2).addReg(Tmp3).addMBB(Dest); + unsigned Tmp1 = SelectExpr(SetCC->getOperand(0)); + BuildMI(BB, Opc, 2).addReg(Tmp1).addMBB(Dest); + return; + } else { + unsigned Tmp1 = SelectExpr(CC); + if (isNE) + BuildMI(BB, Alpha::BEQ, 2).addReg(CCInvMap[CC]).addMBB(Dest); + else + BuildMI(BB, Alpha::BNE, 2).addReg(Tmp1).addMBB(Dest); return; } - abort(); //Should never be reached - } - else - { //Giveup and do the stupid thing - unsigned Tmp1 = SelectExpr(CC); - BuildMI(BB, Alpha::BNE, 2).addReg(Tmp1).addMBB(Dest); + } else { //FP + //Any comparison between 2 values should be codegened as an folded branch, as moving + //CC to the integer register is very expensive + //for a cmp b: c = a - b; + //a = b: c = 0 + //a < b: c < 0 + //a > b: c > 0 + unsigned Tmp1 = SelectExpr(SetCC->getOperand(0)); + unsigned Tmp2 = SelectExpr(SetCC->getOperand(1)); + unsigned Tmp3 = MakeReg(MVT::f64); + BuildMI(BB, Alpha::SUBT, 2, Tmp3).addReg(Tmp1).addReg(Tmp2); + + switch (SetCC->getCondition()) { + default: CC.Val->dump(); assert(0 && "Unknown FP comparison!"); + case ISD::SETEQ: Opc = Alpha::FBEQ; break; + case ISD::SETLT: Opc = Alpha::FBLT; break; + case ISD::SETLE: Opc = Alpha::FBLE; break; + case ISD::SETGT: Opc = Alpha::FBGT; break; + case ISD::SETGE: Opc = Alpha::FBGE; break; + case ISD::SETNE: Opc = Alpha::FBNE; break; + } + BuildMI(BB, Opc, 2).addReg(Tmp3).addMBB(Dest); return; } + abort(); //Should never be reached + } else { + //Giveup and do the stupid thing + unsigned Tmp1 = SelectExpr(CC); + BuildMI(BB, Alpha::BNE, 2).addReg(Tmp1).addMBB(Dest); + return; + } abort(); //Should never be reached } @@ -502,13 +513,17 @@ } case ISD::FP_ROUND: - assert (DestType == MVT::f32 && N.getOperand(0).getValueType() == MVT::f64 && "only f64 to f32 conversion supported here"); + assert (DestType == MVT::f32 && + N.getOperand(0).getValueType() == MVT::f64 && + "only f64 to f32 conversion supported here"); Tmp1 = SelectExpr(N.getOperand(0)); BuildMI(BB, Alpha::CVTTS, 1, Result).addReg(Tmp1); return Result; case ISD::FP_EXTEND: - assert (DestType == MVT::f64 && N.getOperand(0).getValueType() == MVT::f32 && "only f32 to f64 conversion supported here"); + assert (DestType == MVT::f64 && + N.getOperand(0).getValueType() == MVT::f32 && + "only f32 to f64 conversion supported here"); Tmp1 = SelectExpr(N.getOperand(0)); BuildMI(BB, Alpha::CVTST, 1, Result).addReg(Tmp1); return Result; @@ -545,28 +560,24 @@ Select(Chain); Opc = DestType == MVT::f64 ? Alpha::LDT : Alpha::LDS; - if (Address.getOpcode() == ISD::GlobalAddress) - { - AlphaLowering.restoreGP(BB); - Opc = GetSymVersion(Opc); - BuildMI(BB, Opc, 1, Result).addGlobalAddress(cast(Address)->getGlobal()); - } + if (Address.getOpcode() == ISD::GlobalAddress) { + AlphaLowering.restoreGP(BB); + Opc = GetSymVersion(Opc); + BuildMI(BB, Opc, 1, Result).addGlobalAddress(cast(Address)->getGlobal()); + } else if (ConstantPoolSDNode *CP = dyn_cast(Address)) { AlphaLowering.restoreGP(BB); Opc = GetSymVersion(Opc); BuildMI(BB, Opc, 1, Result).addConstantPoolIndex(CP->getIndex()); } - else if(Address.getOpcode() == ISD::FrameIndex) - { - Tmp1 = cast(Address)->getIndex(); - BuildMI(BB, Opc, 2, Result).addFrameIndex(Tmp1).addReg(Alpha::F31); - } - else - { - long offset; - SelectAddr(Address, Tmp1, offset); - BuildMI(BB, Opc, 2, Result).addImm(offset).addReg(Tmp1); - } + else if(Address.getOpcode() == ISD::FrameIndex) { + Tmp1 = cast(Address)->getIndex(); + BuildMI(BB, Opc, 2, Result).addFrameIndex(Tmp1).addReg(Alpha::F31); + } else { + long offset; + SelectAddr(Address, Tmp1, offset); + BuildMI(BB, Opc, 2, Result).addImm(offset).addReg(Tmp1); + } return Result; } case ISD::ConstantFP: @@ -606,34 +617,32 @@ Tmp1 = MakeReg(MVT::f32); - assert(cast(Node)->getExtraValueType() == MVT::f32 && "EXTLOAD not from f32"); + assert(cast(Node)->getExtraValueType() == MVT::f32 && + "EXTLOAD not from f32"); assert(Node->getValueType(0) == MVT::f64 && "EXTLOAD not to f64"); SDOperand Chain = N.getOperand(0); SDOperand Address = N.getOperand(1); Select(Chain); - if (Address.getOpcode() == ISD::GlobalAddress) - { - AlphaLowering.restoreGP(BB); - BuildMI(BB, Alpha::LDS_SYM, 1, Tmp1).addGlobalAddress(cast(Address)->getGlobal()); - } - else if (ConstantPoolSDNode *CP = dyn_cast(N.getOperand(1))) - { - AlphaLowering.restoreGP(BB); - BuildMI(BB, Alpha::LDS_SYM, 1, Tmp1).addConstantPoolIndex(CP->getIndex()); - } - else if(Address.getOpcode() == ISD::FrameIndex) - { - Tmp2 = cast(Address)->getIndex(); - BuildMI(BB, Alpha::LDS, 2, Tmp1).addFrameIndex(Tmp2).addReg(Alpha::F31); - } - else - { - long offset; - SelectAddr(Address, Tmp2, offset); - BuildMI(BB, Alpha::LDS, 1, Tmp1).addImm(offset).addReg(Tmp2); - } + if (Address.getOpcode() == ISD::GlobalAddress) { + AlphaLowering.restoreGP(BB); + BuildMI(BB, Alpha::LDS_SYM, 1, Tmp1).addGlobalAddress(cast(Address)->getGlobal()); + } + else if (ConstantPoolSDNode *CP = + dyn_cast(N.getOperand(1))) + { + AlphaLowering.restoreGP(BB); + BuildMI(BB, Alpha::LDS_SYM, 1, Tmp1).addConstantPoolIndex(CP->getIndex()); + } + else if(Address.getOpcode() == ISD::FrameIndex) { + Tmp2 = cast(Address)->getIndex(); + BuildMI(BB, Alpha::LDS, 2, Tmp1).addFrameIndex(Tmp2).addReg(Alpha::F31); + } else { + long offset; + SelectAddr(Address, Tmp2, offset); + BuildMI(BB, Alpha::LDS, 1, Tmp1).addImm(offset).addReg(Tmp2); + } BuildMI(BB, Alpha::CVTST, 1, Result).addReg(Tmp1); return Result; } @@ -641,7 +650,8 @@ case ISD::UINT_TO_FP: case ISD::SINT_TO_FP: { - assert (N.getOperand(0).getValueType() == MVT::i64 && "only quads can be loaded from"); + assert (N.getOperand(0).getValueType() == MVT::i64 + && "only quads can be loaded from"); Tmp1 = SelectExpr(N.getOperand(0)); // Get the operand register Tmp2 = MakeReg(MVT::f64); @@ -657,11 +667,11 @@ BuildMI(BB, Opc, 1, Result).addReg(Tmp2); //The easy way: doesn't work -// //so these instructions are not supported on ev56 -// Opc = DestType == MVT::f64 ? Alpha::ITOFT : Alpha::ITOFS; -// BuildMI(BB, Opc, 1, Tmp2).addReg(Tmp1); -// Opc = DestType == MVT::f64 ? Alpha::CVTQT : Alpha::CVTQS; -// BuildMI(BB, Opc, 1, Result).addReg(Tmp1); + // //so these instructions are not supported on ev56 + // Opc = DestType == MVT::f64 ? Alpha::ITOFT : Alpha::ITOFS; + // BuildMI(BB, Opc, 1, Tmp2).addReg(Tmp1); + // Opc = DestType == MVT::f64 ? Alpha::CVTQT : Alpha::CVTQS; + // BuildMI(BB, Opc, 1, Result).addReg(Tmp1); return Result; } @@ -701,8 +711,10 @@ if (DestType == MVT::f64 || DestType == MVT::f32 || ( - (opcode == ISD::LOAD || opcode == ISD::CopyFromReg || opcode == ISD::EXTLOAD) && - (N.getValue(0).getValueType() == MVT::f32 || N.getValue(0).getValueType() == MVT::f64) + (opcode == ISD::LOAD || opcode == ISD::CopyFromReg || + opcode == ISD::EXTLOAD) && + (N.getValue(0).getValueType() == MVT::f32 || + N.getValue(0).getValueType() == MVT::f64) ) ) return SelectExprFP(N, Result); @@ -738,40 +750,40 @@ SDOperand Address = N.getOperand(1); Select(Chain); - assert(Node->getValueType(0) == MVT::i64 && "Unknown type to sign extend to."); + assert(Node->getValueType(0) == MVT::i64 && + "Unknown type to sign extend to."); if (opcode == ISD::LOAD) Opc = Alpha::LDQ; else switch (cast(Node)->getExtraValueType()) { default: Node->dump(); assert(0 && "Bad sign extend!"); - case MVT::i32: Opc = Alpha::LDL; assert(opcode != ISD::ZEXTLOAD && "Not sext"); break; - case MVT::i16: Opc = Alpha::LDWU; assert(opcode != ISD::SEXTLOAD && "Not zext"); break; + case MVT::i32: Opc = Alpha::LDL; + assert(opcode != ISD::ZEXTLOAD && "Not sext"); break; + case MVT::i16: Opc = Alpha::LDWU; + assert(opcode != ISD::SEXTLOAD && "Not zext"); break; case MVT::i1: //FIXME: Treat i1 as i8 since there are problems otherwise - case MVT::i8: Opc = Alpha::LDBU; assert(opcode != ISD::SEXTLOAD && "Not zext"); break; + case MVT::i8: Opc = Alpha::LDBU; + assert(opcode != ISD::SEXTLOAD && "Not zext"); break; } - if (Address.getOpcode() == ISD::GlobalAddress) - { - AlphaLowering.restoreGP(BB); - Opc = GetSymVersion(Opc); - BuildMI(BB, Opc, 1, Result).addGlobalAddress(cast(Address)->getGlobal()); - } + if (Address.getOpcode() == ISD::GlobalAddress) { + AlphaLowering.restoreGP(BB); + Opc = GetSymVersion(Opc); + BuildMI(BB, Opc, 1, Result).addGlobalAddress(cast(Address)->getGlobal()); + } else if (ConstantPoolSDNode *CP = dyn_cast(Address)) { AlphaLowering.restoreGP(BB); Opc = GetSymVersion(Opc); - BuildMI(BB, Opc, 1, Result).addConstantPoolIndex(CP->getIndex()); + BuildMI(BB, Opc, 1, Result).addConstantPoolIndex(CP->getIndex()); + } + else if(Address.getOpcode() == ISD::FrameIndex) { + Tmp1 = cast(Address)->getIndex(); + BuildMI(BB, Opc, 2, Result).addFrameIndex(Tmp1).addReg(Alpha::F31); + } else { + long offset; + SelectAddr(Address, Tmp1, offset); + BuildMI(BB, Opc, 2, Result).addImm(offset).addReg(Tmp1); } - else if(Address.getOpcode() == ISD::FrameIndex) - { - Tmp1 = cast(Address)->getIndex(); - BuildMI(BB, Opc, 2, Result).addFrameIndex(Tmp1).addReg(Alpha::F31); - } - else - { - long offset; - SelectAddr(Address, Tmp1, offset); - BuildMI(BB, Opc, 2, Result).addImm(offset).addReg(Tmp1); - } return Result; } @@ -792,78 +804,84 @@ std::vector argvregs; //assert(Node->getNumOperands() < 8 && "Only 6 args supported"); for(int i = 2, e = Node->getNumOperands(); i < e; ++i) - argvregs.push_back(SelectExpr(N.getOperand(i))); + argvregs.push_back(SelectExpr(N.getOperand(i))); //in reg args for(int i = 0, e = std::min(6, (int)argvregs.size()); i < e; ++i) - { - unsigned args_int[] = {Alpha::R16, Alpha::R17, Alpha::R18, - Alpha::R19, Alpha::R20, Alpha::R21}; - unsigned args_float[] = {Alpha::F16, Alpha::F17, Alpha::F18, - Alpha::F19, Alpha::F20, Alpha::F21}; - switch(N.getOperand(i+2).getValueType()) { - default: - Node->dump(); - N.getOperand(i).Val->dump(); - std::cerr << "Type for " << i << " is: " << N.getOperand(i+2).getValueType() << "\n"; - assert(0 && "Unknown value type for call"); - case MVT::i1: - case MVT::i8: - case MVT::i16: - case MVT::i32: - case MVT::i64: - BuildMI(BB, Alpha::BIS, 2, args_int[i]).addReg(argvregs[i]).addReg(argvregs[i]); - break; - case MVT::f32: - case MVT::f64: - BuildMI(BB, Alpha::CPYS, 2, args_float[i]).addReg(argvregs[i]).addReg(argvregs[i]); - break; - } + { + unsigned args_int[] = {Alpha::R16, Alpha::R17, Alpha::R18, + Alpha::R19, Alpha::R20, Alpha::R21}; + unsigned args_float[] = {Alpha::F16, Alpha::F17, Alpha::F18, + Alpha::F19, Alpha::F20, Alpha::F21}; + switch(N.getOperand(i+2).getValueType()) { + default: + Node->dump(); + N.getOperand(i).Val->dump(); + std::cerr << "Type for " << i << " is: " << + N.getOperand(i+2).getValueType() << "\n"; + assert(0 && "Unknown value type for call"); + case MVT::i1: + case MVT::i8: + case MVT::i16: + case MVT::i32: + case MVT::i64: + BuildMI(BB, Alpha::BIS, 2, args_int[i]).addReg(argvregs[i]).addReg(argvregs[i]); + break; + case MVT::f32: + case MVT::f64: + BuildMI(BB, Alpha::CPYS, 2, args_float[i]).addReg(argvregs[i]).addReg(argvregs[i]); + break; } + } //in mem args for (int i = 6, e = argvregs.size(); i < e; ++i) - { - switch(N.getOperand(i+2).getValueType()) { - default: - Node->dump(); - N.getOperand(i).Val->dump(); - std::cerr << "Type for " << i << " is: " << N.getOperand(i+2).getValueType() << "\n"; - assert(0 && "Unknown value type for call"); - case MVT::i1: - case MVT::i8: - case MVT::i16: - case MVT::i32: - case MVT::i64: - BuildMI(BB, Alpha::STQ, 3).addReg(argvregs[i]).addImm((i - 6) * 8).addReg(Alpha::R30); - break; - case MVT::f32: - BuildMI(BB, Alpha::STS, 3).addReg(argvregs[i]).addImm((i - 6) * 8).addReg(Alpha::R30); - break; - case MVT::f64: - BuildMI(BB, Alpha::STT, 3).addReg(argvregs[i]).addImm((i - 6) * 8).addReg(Alpha::R30); - break; - } + { + switch(N.getOperand(i+2).getValueType()) { + default: + Node->dump(); + N.getOperand(i).Val->dump(); + std::cerr << "Type for " << i << " is: " << + N.getOperand(i+2).getValueType() << "\n"; + assert(0 && "Unknown value type for call"); + case MVT::i1: + case MVT::i8: + case MVT::i16: + case MVT::i32: + case MVT::i64: + BuildMI(BB, Alpha::STQ, 3).addReg(argvregs[i]).addImm((i - 6) * 8).addReg(Alpha::R30); + break; + case MVT::f32: + BuildMI(BB, Alpha::STS, 3).addReg(argvregs[i]).addImm((i - 6) * 8).addReg(Alpha::R30); + break; + case MVT::f64: + BuildMI(BB, Alpha::STT, 3).addReg(argvregs[i]).addImm((i - 6) * 8).addReg(Alpha::R30); + break; } + } //build the right kind of call if (GlobalAddressSDNode *GASD = dyn_cast(N.getOperand(1))) - { + { + if (GASD->getGlobal()->isExternal()) { + //use safe calling convention AlphaLowering.restoreGP(BB); BuildMI(BB, Alpha::CALL, 1).addGlobalAddress(GASD->getGlobal(),true); - } + } else { + //use PC relative branch call + BuildMI(BB, Alpha::BSR, 1, Alpha::R26).addGlobalAddress(GASD->getGlobal(),true); + } + } else if (ExternalSymbolSDNode *ESSDN = dyn_cast(N.getOperand(1))) - { - AlphaLowering.restoreGP(BB); - BuildMI(BB, Alpha::CALL, 0).addExternalSymbol(ESSDN->getSymbol(), true); - } - else - { - //no need to restore GP as we are doing an indirect call - Tmp1 = SelectExpr(N.getOperand(1)); - BuildMI(BB, Alpha::BIS, 2, Alpha::R27).addReg(Tmp1).addReg(Tmp1); - BuildMI(BB, Alpha::JSR, 2, Alpha::R26).addReg(Alpha::R27).addImm(0); - } + { + AlphaLowering.restoreGP(BB); + BuildMI(BB, Alpha::CALL, 0).addExternalSymbol(ESSDN->getSymbol(), true); + } else { + //no need to restore GP as we are doing an indirect call + Tmp1 = SelectExpr(N.getOperand(1)); + BuildMI(BB, Alpha::BIS, 2, Alpha::R27).addReg(Tmp1).addReg(Tmp1); + BuildMI(BB, Alpha::JSR, 2, Alpha::R26).addReg(Alpha::R27).addImm(0); + } //push the result into a virtual register @@ -892,56 +910,56 @@ { //Alpha has instructions for a bunch of signed 32 bit stuff if( dyn_cast(Node)->getExtraValueType() == MVT::i32) - { - switch (N.getOperand(0).getOpcode()) { - case ISD::ADD: - case ISD::SUB: - case ISD::MUL: - { - bool isAdd = N.getOperand(0).getOpcode() == ISD::ADD; - bool isMul = N.getOperand(0).getOpcode() == ISD::MUL; - //FIXME: first check for Scaled Adds and Subs! - if(N.getOperand(0).getOperand(1).getOpcode() == ISD::Constant && - cast(N.getOperand(0).getOperand(1))->getValue() <= 255) - { //Normal imm add/sub - Opc = isAdd ? Alpha::ADDLi : (isMul ? Alpha::MULLi : Alpha::SUBLi); - Tmp1 = SelectExpr(N.getOperand(0).getOperand(0)); - Tmp2 = cast(N.getOperand(0).getOperand(1))->getValue(); - BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addImm(Tmp2); - } - else - { //Normal add/sub - Opc = isAdd ? Alpha::ADDL : (isMul ? Alpha::MULLi : Alpha::SUBL); - Tmp1 = SelectExpr(N.getOperand(0).getOperand(0)); - Tmp2 = SelectExpr(N.getOperand(0).getOperand(1)); - BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); - } - return Result; + { + switch (N.getOperand(0).getOpcode()) { + case ISD::ADD: + case ISD::SUB: + case ISD::MUL: + { + bool isAdd = N.getOperand(0).getOpcode() == ISD::ADD; + bool isMul = N.getOperand(0).getOpcode() == ISD::MUL; + //FIXME: first check for Scaled Adds and Subs! + if(N.getOperand(0).getOperand(1).getOpcode() == ISD::Constant && + cast(N.getOperand(0).getOperand(1))->getValue() <= 255) + { //Normal imm add/sub + Opc = isAdd ? Alpha::ADDLi : (isMul ? Alpha::MULLi : Alpha::SUBLi); + Tmp1 = SelectExpr(N.getOperand(0).getOperand(0)); + Tmp2 = cast(N.getOperand(0).getOperand(1))->getValue(); + BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addImm(Tmp2); } - default: break; //Fall Though; + else + { //Normal add/sub + Opc = isAdd ? Alpha::ADDL : (isMul ? Alpha::MULLi : Alpha::SUBL); + Tmp1 = SelectExpr(N.getOperand(0).getOperand(0)); + Tmp2 = SelectExpr(N.getOperand(0).getOperand(1)); + BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); + } + return Result; } - } //Every thing else fall though too, including unhandled opcodes above + default: break; //Fall Though; + } + } //Every thing else fall though too, including unhandled opcodes above Tmp1 = SelectExpr(N.getOperand(0)); MVTSDNode* MVN = dyn_cast(Node); //std::cerr << "SrcT: " << MVN->getExtraValueType() << "\n"; switch(MVN->getExtraValueType()) + { + default: + Node->dump(); + assert(0 && "Sign Extend InReg not there yet"); + break; + case MVT::i32: { - default: - Node->dump(); - assert(0 && "Sign Extend InReg not there yet"); - break; - case MVT::i32: - { - BuildMI(BB, Alpha::ADDLi, 2, Result).addReg(Tmp1).addImm(0); - break; - } - case MVT::i16: - BuildMI(BB, Alpha::SEXTW, 1, Result).addReg(Tmp1); - break; - case MVT::i8: - BuildMI(BB, Alpha::SEXTB, 1, Result).addReg(Tmp1); + BuildMI(BB, Alpha::ADDLi, 2, Result).addReg(Tmp1).addImm(0); break; } + case MVT::i16: + BuildMI(BB, Alpha::SEXTW, 1, Result).addReg(Tmp1); + break; + case MVT::i8: + BuildMI(BB, Alpha::SEXTB, 1, Result).addReg(Tmp1); + break; + } return Result; } case ISD::ZERO_EXTEND_INREG: @@ -950,18 +968,18 @@ MVTSDNode* MVN = dyn_cast(Node); //std::cerr << "SrcT: " << MVN->getExtraValueType() << "\n"; switch(MVN->getExtraValueType()) - { - default: - Node->dump(); - assert(0 && "Zero Extend InReg not there yet"); - break; - case MVT::i32: Tmp2 = 0xf0; break; - case MVT::i16: Tmp2 = 0xfc; break; - case MVT::i8: Tmp2 = 0xfe; break; - case MVT::i1: //handle this one special - BuildMI(BB, Alpha::ANDi, 2, Result).addReg(Tmp1).addImm(1); - return Result; - } + { + default: + Node->dump(); + assert(0 && "Zero Extend InReg not there yet"); + break; + case MVT::i32: Tmp2 = 0xf0; break; + case MVT::i16: Tmp2 = 0xfc; break; + case MVT::i8: Tmp2 = 0xfe; break; + case MVT::i1: //handle this one special + BuildMI(BB, Alpha::ANDi, 2, Result).addReg(Tmp1).addImm(1); + return Result; + } BuildMI(BB, Alpha::ZAPi, 2, Result).addReg(Tmp1).addImm(Tmp2); return Result; } @@ -985,14 +1003,22 @@ switch (SetCC->getCondition()) { default: Node->dump(); assert(0 && "Unknown integer comparison!"); case ISD::SETEQ: Opc = Alpha::CMPEQ; dir=0; break; - case ISD::SETLT: Opc = isConst2 ? Alpha::CMPLTi : Alpha::CMPLT; dir = 1; break; - case ISD::SETLE: Opc = isConst2 ? Alpha::CMPLEi : Alpha::CMPLE; dir = 1; break; - case ISD::SETGT: Opc = isConst1 ? Alpha::CMPLTi : Alpha::CMPLT; dir = 2; break; - case ISD::SETGE: Opc = isConst1 ? Alpha::CMPLEi : Alpha::CMPLE; dir = 2; break; - case ISD::SETULT: Opc = isConst2 ? Alpha::CMPULTi : Alpha::CMPULT; dir = 1; break; - case ISD::SETUGT: Opc = isConst1 ? Alpha::CMPULTi : Alpha::CMPULT; dir = 2; break; - case ISD::SETULE: Opc = isConst2 ? Alpha::CMPULEi : Alpha::CMPULE; dir = 1; break; - case ISD::SETUGE: Opc = isConst1 ? Alpha::CMPULEi : Alpha::CMPULE; dir = 2; break; + case ISD::SETLT: + Opc = isConst2 ? Alpha::CMPLTi : Alpha::CMPLT; dir = 1; break; + case ISD::SETLE: + Opc = isConst2 ? Alpha::CMPLEi : Alpha::CMPLE; dir = 1; break; + case ISD::SETGT: + Opc = isConst1 ? Alpha::CMPLTi : Alpha::CMPLT; dir = 2; break; + case ISD::SETGE: + Opc = isConst1 ? Alpha::CMPLEi : Alpha::CMPLE; dir = 2; break; + case ISD::SETULT: + Opc = isConst2 ? Alpha::CMPULTi : Alpha::CMPULT; dir = 1; break; + case ISD::SETUGT: + Opc = isConst1 ? Alpha::CMPULTi : Alpha::CMPULT; dir = 2; break; + case ISD::SETULE: + Opc = isConst2 ? Alpha::CMPULEi : Alpha::CMPULE; dir = 1; break; + case ISD::SETUGE: + Opc = isConst1 ? Alpha::CMPULEi : Alpha::CMPULE; dir = 2; break; case ISD::SETNE: {//Handle this one special //std::cerr << "Alpha does not have a setne.\n"; //abort(); @@ -1059,17 +1085,17 @@ Tmp2 = SelectExpr(N.getOperand(1)); //Can only compare doubles, and dag won't promote for me if (SetCC->getOperand(0).getValueType() == MVT::f32) - { - Tmp3 = MakeReg(MVT::f64); - BuildMI(BB, Alpha::CVTST, 1, Tmp3).addReg(Tmp1); - Tmp1 = Tmp3; - } + { + Tmp3 = MakeReg(MVT::f64); + BuildMI(BB, Alpha::CVTST, 1, Tmp3).addReg(Tmp1); + Tmp1 = Tmp3; + } if (SetCC->getOperand(1).getValueType() == MVT::f32) - { - Tmp3 = MakeReg(MVT::f64); - BuildMI(BB, Alpha::CVTST, 1, Tmp3).addReg(Tmp2); - Tmp1 = Tmp2; - } + { + Tmp3 = MakeReg(MVT::f64); + BuildMI(BB, Alpha::CVTST, 1, Tmp3).addReg(Tmp2); + Tmp1 = Tmp2; + } if (rev) std::swap(Tmp1, Tmp2); Tmp3 = MakeReg(MVT::f64); @@ -1134,35 +1160,33 @@ assert (DestType == MVT::i64 && "Only do arithmetic on i64s!"); if(N.getOperand(1).getOpcode() == ISD::Constant && cast(N.getOperand(1))->getValue() <= 255) - { - switch(opcode) { - case ISD::AND: Opc = Alpha::ANDi; break; - case ISD::OR: Opc = Alpha::BISi; break; - case ISD::XOR: Opc = Alpha::XORi; break; - case ISD::SHL: Opc = Alpha::SLi; break; - case ISD::SRL: Opc = Alpha::SRLi; break; - case ISD::SRA: Opc = Alpha::SRAi; break; - case ISD::MUL: Opc = Alpha::MULQi; break; - }; - Tmp1 = SelectExpr(N.getOperand(0)); - Tmp2 = cast(N.getOperand(1))->getValue(); - BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addImm(Tmp2); - } - else - { - switch(opcode) { - case ISD::AND: Opc = Alpha::AND; break; - case ISD::OR: Opc = Alpha::BIS; break; - case ISD::XOR: Opc = Alpha::XOR; break; - case ISD::SHL: Opc = Alpha::SL; break; - case ISD::SRL: Opc = Alpha::SRL; break; - case ISD::SRA: Opc = Alpha::SRA; break; - case ISD::MUL: Opc = Alpha::MULQ; break; - }; - Tmp1 = SelectExpr(N.getOperand(0)); - Tmp2 = SelectExpr(N.getOperand(1)); - BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); - } + { + switch(opcode) { + case ISD::AND: Opc = Alpha::ANDi; break; + case ISD::OR: Opc = Alpha::BISi; break; + case ISD::XOR: Opc = Alpha::XORi; break; + case ISD::SHL: Opc = Alpha::SLi; break; + case ISD::SRL: Opc = Alpha::SRLi; break; + case ISD::SRA: Opc = Alpha::SRAi; break; + case ISD::MUL: Opc = Alpha::MULQi; break; + }; + Tmp1 = SelectExpr(N.getOperand(0)); + Tmp2 = cast(N.getOperand(1))->getValue(); + BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addImm(Tmp2); + } else { + switch(opcode) { + case ISD::AND: Opc = Alpha::AND; break; + case ISD::OR: Opc = Alpha::BIS; break; + case ISD::XOR: Opc = Alpha::XOR; break; + case ISD::SHL: Opc = Alpha::SL; break; + case ISD::SRL: Opc = Alpha::SRL; break; + case ISD::SRA: Opc = Alpha::SRA; break; + case ISD::MUL: Opc = Alpha::MULQ; break; + }; + Tmp1 = SelectExpr(N.getOperand(0)); + Tmp2 = SelectExpr(N.getOperand(1)); + BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); + } return Result; case ISD::ADD: @@ -1173,28 +1197,27 @@ //FIXME: first check for Scaled Adds and Subs! if(N.getOperand(1).getOpcode() == ISD::Constant && cast(N.getOperand(1))->getValue() <= 255) - { //Normal imm add/sub - Opc = isAdd ? Alpha::ADDQi : Alpha::SUBQi; - Tmp1 = SelectExpr(N.getOperand(0)); - Tmp2 = cast(N.getOperand(1))->getValue(); - BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addImm(Tmp2); - } + { //Normal imm add/sub + Opc = isAdd ? Alpha::ADDQi : Alpha::SUBQi; + Tmp1 = SelectExpr(N.getOperand(0)); + Tmp2 = cast(N.getOperand(1))->getValue(); + BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addImm(Tmp2); + } else if(N.getOperand(1).getOpcode() == ISD::Constant && cast(N.getOperand(1))->getValue() <= 32767) - { //LDA //FIXME: expand the above condition a bit - Tmp1 = SelectExpr(N.getOperand(0)); - Tmp2 = cast(N.getOperand(1))->getValue(); - if (!isAdd) - Tmp2 = -Tmp2; - BuildMI(BB, Alpha::LDA, 2, Result).addImm(Tmp2).addReg(Tmp1); - } - else - { //Normal add/sub - Opc = isAdd ? Alpha::ADDQ : Alpha::SUBQ; - Tmp1 = SelectExpr(N.getOperand(0)); - Tmp2 = SelectExpr(N.getOperand(1)); - BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); - } + { //LDA //FIXME: expand the above condition a bit + Tmp1 = SelectExpr(N.getOperand(0)); + Tmp2 = cast(N.getOperand(1))->getValue(); + if (!isAdd) + Tmp2 = -Tmp2; + BuildMI(BB, Alpha::LDA, 2, Result).addImm(Tmp2).addReg(Tmp1); + } else { + //Normal add/sub + Opc = isAdd ? Alpha::ADDQ : Alpha::SUBQ; + Tmp1 = SelectExpr(N.getOperand(0)); + Tmp2 = SelectExpr(N.getOperand(1)); + BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); + } return Result; } @@ -1205,11 +1228,12 @@ //FIXME: alpha really doesn't support any of these operations, // the ops are expanded into special library calls with // special calling conventions + //Restore GP because it is a call after all... switch(opcode) { - case ISD::UREM: Opc = Alpha::REMQU; break; - case ISD::SREM: Opc = Alpha::REMQ; break; - case ISD::UDIV: Opc = Alpha::DIVQU; break; - case ISD::SDIV: Opc = Alpha::DIVQ; break; + case ISD::UREM: AlphaLowering.restoreGP(BB); Opc = Alpha::REMQU; break; + case ISD::SREM: AlphaLowering.restoreGP(BB); Opc = Alpha::REMQ; break; + case ISD::UDIV: AlphaLowering.restoreGP(BB); Opc = Alpha::DIVQU; break; + case ISD::SDIV: AlphaLowering.restoreGP(BB); Opc = Alpha::DIVQ; break; } Tmp1 = SelectExpr(N.getOperand(0)); Tmp2 = SelectExpr(N.getOperand(1)); @@ -1218,7 +1242,7 @@ case ISD::FP_TO_UINT: case ISD::FP_TO_SINT: - { + { assert (DestType == MVT::i64 && "only quads can be loaded to"); MVT::ValueType SrcType = N.getOperand(0).getValueType(); assert (SrcType == MVT::f32 || SrcType == MVT::f64); @@ -1233,20 +1257,20 @@ //CVTTQ STT LDQ //CVTST CVTTQ STT LDQ if (SrcType == MVT::f32) - { - Tmp2 = MakeReg(MVT::f64); - BuildMI(BB, Alpha::CVTST, 1, Tmp2).addReg(Tmp1); - Tmp1 = Tmp2; - } + { + Tmp2 = MakeReg(MVT::f64); + BuildMI(BB, Alpha::CVTST, 1, Tmp2).addReg(Tmp1); + Tmp1 = Tmp2; + } Tmp2 = MakeReg(MVT::f64); BuildMI(BB, Alpha::CVTTQ, 1, Tmp2).addReg(Tmp1); BuildMI(BB, Alpha::STT, 3).addReg(Tmp2).addFrameIndex(FrameIdx).addReg(Alpha::F31); BuildMI(BB, Alpha::LDQ, 2, Result).addFrameIndex(FrameIdx).addReg(Alpha::F31); return Result; - } + } -// // case ISD::FP_TO_UINT: + // // case ISD::FP_TO_UINT: case ISD::SELECT: { @@ -1261,17 +1285,16 @@ case ISD::Constant: { unsigned long val = cast(N)->getValue(); - if (val < 32000 && (long)val > -32000) - BuildMI(BB, Alpha::LOAD_IMM, 1, Result).addImm(val); - else - { - MachineConstantPool *CP = BB->getParent()->getConstantPool(); - ConstantUInt *C = ConstantUInt::get(Type::getPrimitiveType(Type::ULongTyID) , val); - unsigned CPI = CP->getConstantPoolIndex(C); - AlphaLowering.restoreGP(BB); - BuildMI(BB, Alpha::LDQ_SYM, 1, Result).addConstantPoolIndex(CPI); - } - return Result; + if (val < 32000 && (long)val > -32000) + BuildMI(BB, Alpha::LOAD_IMM, 1, Result).addImm(val); + else { + MachineConstantPool *CP = BB->getParent()->getConstantPool(); + ConstantUInt *C = ConstantUInt::get(Type::getPrimitiveType(Type::ULongTyID) , val); + unsigned CPI = CP->getConstantPoolIndex(C); + AlphaLowering.restoreGP(BB); + BuildMI(BB, Alpha::LDQ_SYM, 1, Result).addConstantPoolIndex(CPI); + } + return Result; } } @@ -1331,44 +1354,46 @@ Tmp2 = cast(N)->getReg(); if (Tmp1 != Tmp2) { - if (N.getOperand(1).getValueType() == MVT::f64 || N.getOperand(1).getValueType() == MVT::f32) + if (N.getOperand(1).getValueType() == MVT::f64 || + N.getOperand(1).getValueType() == MVT::f32) BuildMI(BB, Alpha::CPYS, 2, Tmp2).addReg(Tmp1).addReg(Tmp1); else BuildMI(BB, Alpha::BIS, 2, Tmp2).addReg(Tmp1).addReg(Tmp1); } return; - case ISD::RET: - switch (N.getNumOperands()) { - default: - std::cerr << N.getNumOperands() << "\n"; - for (unsigned i = 0; i < N.getNumOperands(); ++i) - std::cerr << N.getOperand(i).getValueType() << "\n"; - Node->dump(); - assert(0 && "Unknown return instruction!"); - case 2: - Select(N.getOperand(0)); - Tmp1 = SelectExpr(N.getOperand(1)); - switch (N.getOperand(1).getValueType()) { - default: Node->dump(); assert(0 && "All other types should have been promoted!!"); - case MVT::f64: - case MVT::f32: - BuildMI(BB, Alpha::CPYS, 2, Alpha::F0).addReg(Tmp1).addReg(Tmp1); - break; - case MVT::i32: - case MVT::i64: - BuildMI(BB, Alpha::BIS, 2, Alpha::R0).addReg(Tmp1).addReg(Tmp1); - break; - } - break; - case 1: - Select(N.getOperand(0)); - break; - } - //Tmp2 = AlphaLowering.getRetAddr(); - //BuildMI(BB, Alpha::BIS, 2, Alpha::R26).addReg(Tmp2).addReg(Tmp2); - BuildMI(BB, Alpha::RETURN, 0); // Just emit a 'ret' instruction - return; + case ISD::RET: + switch (N.getNumOperands()) { + default: + std::cerr << N.getNumOperands() << "\n"; + for (unsigned i = 0; i < N.getNumOperands(); ++i) + std::cerr << N.getOperand(i).getValueType() << "\n"; + Node->dump(); + assert(0 && "Unknown return instruction!"); + case 2: + Select(N.getOperand(0)); + Tmp1 = SelectExpr(N.getOperand(1)); + switch (N.getOperand(1).getValueType()) { + default: Node->dump(); + assert(0 && "All other types should have been promoted!!"); + case MVT::f64: + case MVT::f32: + BuildMI(BB, Alpha::CPYS, 2, Alpha::F0).addReg(Tmp1).addReg(Tmp1); + break; + case MVT::i32: + case MVT::i64: + BuildMI(BB, Alpha::BIS, 2, Alpha::R0).addReg(Tmp1).addReg(Tmp1); + break; + } + break; + case 1: + Select(N.getOperand(0)); + break; + } + //Tmp2 = AlphaLowering.getRetAddr(); + //BuildMI(BB, Alpha::BIS, 2, Alpha::R26).addReg(Tmp2).addReg(Tmp2); + BuildMI(BB, Alpha::RETURN, 0); // Just emit a 'ret' instruction + return; case ISD::TRUNCSTORE: case ISD::STORE: @@ -1398,22 +1423,22 @@ } if (Address.getOpcode() == ISD::GlobalAddress) - { - AlphaLowering.restoreGP(BB); - Opc = GetSymVersion(Opc); - BuildMI(BB, Opc, 2).addReg(Tmp1).addGlobalAddress(cast(Address)->getGlobal()); - } + { + AlphaLowering.restoreGP(BB); + Opc = GetSymVersion(Opc); + BuildMI(BB, Opc, 2).addReg(Tmp1).addGlobalAddress(cast(Address)->getGlobal()); + } else if(Address.getOpcode() == ISD::FrameIndex) - { - Tmp2 = cast(Address)->getIndex(); - BuildMI(BB, Opc, 3).addReg(Tmp1).addFrameIndex(Tmp2).addReg(Alpha::F31); - } + { + Tmp2 = cast(Address)->getIndex(); + BuildMI(BB, Opc, 3).addReg(Tmp1).addFrameIndex(Tmp2).addReg(Alpha::F31); + } else - { - long offset; - SelectAddr(Address, Tmp2, offset); - BuildMI(BB, Opc, 3).addReg(Tmp1).addImm(offset).addReg(Tmp2); - } + { + long offset; + SelectAddr(Address, Tmp2, offset); + BuildMI(BB, Opc, 3).addReg(Tmp1).addImm(offset).addReg(Tmp2); + } return; } @@ -1423,7 +1448,7 @@ case ISD::LOAD: case ISD::CopyFromReg: case ISD::CALL: -// case ISD::DYNAMIC_STACKALLOC: + // case ISD::DYNAMIC_STACKALLOC: ExprMap.erase(N); SelectExpr(N); return; Index: llvm/lib/Target/Alpha/AlphaInstrInfo.td diff -u llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.23 llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.24 --- llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.23 Wed Feb 9 23:17:38 2005 +++ llvm/lib/Target/Alpha/AlphaInstrInfo.td Thu Feb 10 00:25:22 2005 @@ -53,7 +53,7 @@ let isReturn = 1, isTerminator = 1 in def RETURN : PseudoInstAlpha<(ops ), "ret $$31,($$26),1">; //Return from subroutine -let Uses = [R28] in +let Uses = [R28, R29] in def LOAD_IMM : PseudoInstAlpha<(ops GPRC:$RC, s64imm:$IMM), "ldiq $RC,$IMM">; //Load Immediate Quadword let Uses = [R29, R28] in { @@ -79,7 +79,8 @@ def STT_SYM : PseudoInstAlpha<(ops GPRC:$RA, s64imm:$DISP), "stt $RA,$DISP">; //store double } -let Uses = [R28, R23, R24, R25, R26] in +let Uses = [R28, R23, R24, R25, R26, R29], + Defs = [R29] in { def REMQU : PseudoInstAlpha<(ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "remqu $RA,$RB,$RC">; //unsigned remander def REMQ : PseudoInstAlpha<(ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "remq $RA,$RB,$RC">; //unsigned remander @@ -274,11 +275,10 @@ def JMP : MForm< 0x1A, (ops GPRC:$RD, GPRC:$RS), "jmp $RD,($RS),0">; //Jump let isCall = 1, Defs = [R0, R1, R2, R3, R4, R5, R6, R7, R8, R16, R17, R18, R19, - R20, R21, R22, R23, R24, R25, R27, R29, + R20, R21, R22, R23, R24, R25, R27, R28, R29, F0, F1, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, - F20, F21, F22, F23, F24, F25, F26, F27, F28, F29, F30], - Uses = [R29] in { + F20, F21, F22, F23, F24, F25, F26, F27, F28, F29, F30] in { def JSR : MForm< 0x1A, (ops GPRC:$RD, GPRC:$RS, s14imm:$DISP), "jsr $RD,($RS),$DISP">; //Jump to subroutine def BSR : BForm<0x34, (ops GPRC:$RD, s21imm:$DISP), "bsr $RD,$DISP">; //Branch to subroutine } @@ -286,7 +286,7 @@ def JSR_COROUTINE : MForm< 0x1A, (ops GPRC:$RD, GPRC:$RS), "jsr_coroutine $RD,($RS),1">; //Jump to subroutine return def BR : BForm<0x30, (ops GPRC:$RD, s21imm:$DISP), "br $RD,$DISP">; //Branch -let Uses = [R29, R28] in { +let Uses = [R28] in { //Stores, int def STB : MForm<0x0E, (ops GPRC:$RA, s16imm:$DISP, GPRC:$RB), "stb $RA,$DISP($RB)">; // Store byte def STW : MForm<0x0D, (ops GPRC:$RA, s16imm:$DISP, GPRC:$RB), "stw $RA,$DISP($RB)">; // Store word Index: llvm/lib/Target/Alpha/AlphaRegisterInfo.td diff -u llvm/lib/Target/Alpha/AlphaRegisterInfo.td:1.8 llvm/lib/Target/Alpha/AlphaRegisterInfo.td:1.9 --- llvm/lib/Target/Alpha/AlphaRegisterInfo.td:1.8 Wed Feb 9 19:52:22 2005 +++ llvm/lib/Target/Alpha/AlphaRegisterInfo.td Thu Feb 10 00:25:22 2005 @@ -83,8 +83,9 @@ [R0, R1, R2, R3, R4, R5, R6, R7, R8, R16, R17, R18, R19, R20, R21, R22, R23, R24, R25, R27, // Non-volatile - R9, R10, R11, R12, R13, R14, R15, R26, /* R28, */ R29 /* R30, R31*/ ]>; + R9, R10, R11, R12, R13, R14, /*R15,*/ R26, /* R28, */ R29 /* R30, R31*/ ]>; // Note: R28 is reserved for the assembler + //leave FP alone // Don't allocate 15, 29, 30, 31 // Allocation volatiles only for now From tbrethou at cs.uiuc.edu Thu Feb 10 11:02:23 2005 From: tbrethou at cs.uiuc.edu (Tanya Brethour) Date: Thu, 10 Feb 2005 11:02:23 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/SparcV9TargetMachine.cpp Message-ID: <200502101702.j1AH2NEY030486@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9: SparcV9TargetMachine.cpp updated: 1.132 -> 1.133 --- Log message: Allow modsched and local scheduling to both be run. --- Diffs of the changes: (+3 -4) SparcV9TargetMachine.cpp | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) Index: llvm/lib/Target/SparcV9/SparcV9TargetMachine.cpp diff -u llvm/lib/Target/SparcV9/SparcV9TargetMachine.cpp:1.132 llvm/lib/Target/SparcV9/SparcV9TargetMachine.cpp:1.133 --- llvm/lib/Target/SparcV9/SparcV9TargetMachine.cpp:1.132 Thu Dec 16 17:16:16 2004 +++ llvm/lib/Target/SparcV9/SparcV9TargetMachine.cpp Thu Feb 10 11:02:06 2005 @@ -192,16 +192,15 @@ PM.add(createSparcV9BurgInstSelector(*this)); + if (!DisableSched) + PM.add(createInstructionSchedulingWithSSAPass(*this)); + if(PrintMachineCode) PM.add(createMachineFunctionPrinterPass(&std::cerr, "Before modulo scheduling:\n")); //Use ModuloScheduling if enabled, otherwise use local scheduling if not disabled. if(EnableModSched) PM.add(createModuloSchedulingPass(*this)); - else { - if (!DisableSched) - PM.add(createInstructionSchedulingWithSSAPass(*this)); - } if (PrintMachineCode) PM.add(createMachineFunctionPrinterPass(&std::cerr, "Before reg alloc:\n")); From tbrethou at cs.uiuc.edu Thu Feb 10 11:03:10 2005 From: tbrethou at cs.uiuc.edu (Tanya Brethour) Date: Thu, 10 Feb 2005 11:03:10 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/ModuloScheduling/MSchedGraph.cpp MSchedGraph.h ModuloScheduling.cpp ModuloScheduling.h Message-ID: <200502101703.j1AH3AoS030556@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9/ModuloScheduling: MSchedGraph.cpp updated: 1.11 -> 1.12 MSchedGraph.h updated: 1.6 -> 1.7 ModuloScheduling.cpp updated: 1.40 -> 1.41 ModuloScheduling.h updated: 1.22 -> 1.23 --- Log message: Added new circuit finding alogrithm. Fixed bug in graph so that phi ite diff edges are added. --- Diffs of the changes: (+487 -51) MSchedGraph.cpp | 118 ++++++++++++++++- MSchedGraph.h | 65 ++++++++- ModuloScheduling.cpp | 343 ++++++++++++++++++++++++++++++++++++++++++++++----- ModuloScheduling.h | 12 + 4 files changed, 487 insertions(+), 51 deletions(-) Index: llvm/lib/Target/SparcV9/ModuloScheduling/MSchedGraph.cpp diff -u llvm/lib/Target/SparcV9/ModuloScheduling/MSchedGraph.cpp:1.11 llvm/lib/Target/SparcV9/ModuloScheduling/MSchedGraph.cpp:1.12 --- llvm/lib/Target/SparcV9/ModuloScheduling/MSchedGraph.cpp:1.11 Sun Nov 28 17:36:15 2004 +++ llvm/lib/Target/SparcV9/ModuloScheduling/MSchedGraph.cpp Thu Feb 10 11:02:58 2005 @@ -14,6 +14,9 @@ #include "MSchedGraph.h" #include "../SparcV9RegisterInfo.h" +#include "../MachineCodeForInstruction.h" +#include "llvm/BasicBlock.h" +#include "llvm/Instructions.h" #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Support/Debug.h" @@ -30,6 +33,17 @@ graph->addNode(inst, this); } +MSchedGraphNode::MSchedGraphNode(const MSchedGraphNode &N) + : Predecessors(N.Predecessors), Successors(N.Successors) { + + Inst = N.Inst; + Parent = N.Parent; + index = N.index; + latency = N.latency; + isBranchInstr = N.isBranchInstr; + +} + void MSchedGraphNode::print(std::ostream &os) const { os << "MSchedGraphNode: Inst=" << *Inst << ", latency= " << latency << "\n"; } @@ -46,6 +60,16 @@ abort(); } +unsigned MSchedGraphNode::getIteDiff(MSchedGraphNode *succ) { + for(std::vector::iterator I = Successors.begin(), E = Successors.end(); + I != E; ++I) { + if(I->getDest() == succ) + return I->getIteDiff(); + } + return 0; +} + + unsigned MSchedGraphNode::getInEdgeNum(MSchedGraphNode *pred) { //Loop over all the successors of our predecessor //return the edge the corresponds to this in edge @@ -85,6 +109,19 @@ GraphMap[MI] = node; } +void MSchedGraph::deleteNode(MSchedGraphNode *node) { + + //Delete the edge to this node from all predecessors + for(MSchedGraphNode::pred_iterator P = node->pred_begin(), PE = node->pred_end(); + P != PE; ++P) { + (*P)->deleteSuccessor(node); + } + + //Remove this node from the graph + GraphMap.erase(node->getInst()); + +} + MSchedGraph::MSchedGraph(const MachineBasicBlock *bb, const TargetMachine &targ) : BB(bb), Target(targ) { @@ -97,6 +134,41 @@ buildNodesAndEdges(); } +MSchedGraph::MSchedGraph(const MSchedGraph &G, std::map &newNodes) + : BB(G.BB), Target(G.Target) { + + std::map oldToNew; + //Copy all nodes + for(MSchedGraph::const_iterator N = G.GraphMap.begin(), NE = G.GraphMap.end(); + N != NE; ++N) { + MSchedGraphNode *newNode = new MSchedGraphNode(*(N->second)); + oldToNew[&*(N->second)] = newNode; + newNodes[newNode] = &*(N->second); + GraphMap[&*(N->first)] = newNode; + } + + //Loop over nodes and update edges to point to new nodes + for(MSchedGraph::iterator N = GraphMap.begin(), NE = GraphMap.end(); N != NE; ++N) { + + //Get the node we are dealing with + MSchedGraphNode *node = &*(N->second); + + node->setParent(this); + + //Loop over nodes successors and predecessors and update to the new nodes + for(unsigned i = 0; i < node->pred_size(); ++i) { + node->setPredecessor(i, oldToNew[node->getPredecessor(i)]); + } + + for(unsigned i = 0; i < node->succ_size(); ++i) { + MSchedGraphEdge *edge = node->getSuccessor(i); + MSchedGraphNode *oldDest = edge->getDest(); + edge->setDest(oldToNew[oldDest]); + } + } +} + + MSchedGraph::~MSchedGraph () { for(MSchedGraph::iterator I = GraphMap.begin(), E = GraphMap.end(); I != E; ++I) delete I->second; @@ -114,12 +186,13 @@ //Save PHI instructions to deal with later std::vector phiInstrs; unsigned index = 0; + //Loop over instructions in MBB and add nodes and edges for (MachineBasicBlock::const_iterator MI = BB->begin(), e = BB->end(); MI != e; ++MI) { //Get each instruction of machine basic block, get the delay //using the op code, create a new node for it, and add to the //graph. - + MachineOpCode opCode = MI->getOpcode(); int delay; @@ -138,9 +211,8 @@ if(MTI->isNop(opCode)) continue; - //Add PHI to phi instruction list to be processed later - if (opCode == TargetInstrInfo::PHI) - phiInstrs.push_back(MI); + //Sparc BE does not use PHI opcode, so assert on this case + assert(opCode != TargetInstrInfo::PHI && "Did not expect PHI opcode"); bool isBranch = false; @@ -185,8 +257,10 @@ assert((mOp.getVRegValue() != NULL) && "Null value is defined"); //Check if this is a read operation in a phi node, if so DO NOT PROCESS - if(mOp.isUse() && (opCode == TargetInstrInfo::PHI)) + if(mOp.isUse() && (opCode == TargetInstrInfo::PHI)) { + DEBUG(std::cerr << "Read Operation in a PHI node\n"); continue; + } if (const Value* srcI = mOp.getVRegValue()) { @@ -213,14 +287,37 @@ } ++index; } + + //Loop over LLVM BB, examine phi instructions, and add them to our phiInstr list to process + const BasicBlock *llvm_bb = BB->getBasicBlock(); + for(BasicBlock::const_iterator I = llvm_bb->begin(), E = llvm_bb->end(); I != E; ++I) { + if(const PHINode *PN = dyn_cast(I)) { + MachineCodeForInstruction & tempMvec = MachineCodeForInstruction::get(PN); + for (unsigned j = 0; j < tempMvec.size(); j++) { + DEBUG(std::cerr << "Inserting phi instr into map: " << *tempMvec[j] << "\n"); + phiInstrs.push_back((MachineInstr*) tempMvec[j]); + } + } + + } + addMemEdges(memInstructions); addMachRegEdges(regNumtoNodeMap); //Finally deal with PHI Nodes and Value* for(std::vector::iterator I = phiInstrs.begin(), E = phiInstrs.end(); I != E; ++I) { + //Get Node for this instruction - MSchedGraphNode *node = find(*I)->second; - + std::map::iterator X; + X = find(*I); + + if(X == GraphMap.end()) + continue; + + MSchedGraphNode *node = X->second; + + DEBUG(std::cerr << "Adding ite diff edges for node: " << *node << "\n"); + //Loop over operands for this instruction and add value edges for(unsigned i=0; i < (*I)->getNumOperands(); ++i) { //Get Operand @@ -258,13 +355,14 @@ //Node is a Def, so add output dep. if(nodeIsDef) { - if(mOp.isUse()) + if(mOp.isUse()) { srcNode->addOutEdge(destNode, MSchedGraphEdge::ValueDep, MSchedGraphEdge::AntiDep, diff); - if(mOp.isDef()) + } + if(mOp.isDef()) { srcNode->addOutEdge(destNode, MSchedGraphEdge::ValueDep, MSchedGraphEdge::OutputDep, diff); - + } } if(nodeIsUse) { if(mOp.isDef()) Index: llvm/lib/Target/SparcV9/ModuloScheduling/MSchedGraph.h diff -u llvm/lib/Target/SparcV9/ModuloScheduling/MSchedGraph.h:1.6 llvm/lib/Target/SparcV9/ModuloScheduling/MSchedGraph.h:1.7 --- llvm/lib/Target/SparcV9/ModuloScheduling/MSchedGraph.h:1.6 Sun Nov 28 17:36:15 2004 +++ llvm/lib/Target/SparcV9/ModuloScheduling/MSchedGraph.h Thu Feb 10 11:02:58 2005 @@ -41,6 +41,7 @@ MSchedGraphNode *getDest() const { return dest; } unsigned getIteDiff() { return iteDiff; } unsigned getDepOrderType() { return depOrderType; } + void setDest(MSchedGraphNode *newDest) { dest = newDest; } private: friend class MSchedGraphNode; @@ -70,15 +71,18 @@ MSchedGraphNode(const MachineInstr *inst, MSchedGraph *graph, unsigned index, unsigned late=0, bool isBranch=false); + MSchedGraphNode(const MSchedGraphNode &N); + //Iterators typedef std::vector::iterator pred_iterator; pred_iterator pred_begin() { return Predecessors.begin(); } pred_iterator pred_end() { return Predecessors.end(); } - + unsigned pred_size() { return Predecessors.size(); } + typedef std::vector::const_iterator pred_const_iterator; pred_const_iterator pred_begin() const { return Predecessors.begin(); } pred_const_iterator pred_end() const { return Predecessors.end(); } - + // Successor iterators. typedef MSchedGraphNodeIterator::const_iterator, const MSchedGraphNode> succ_const_iterator; @@ -89,8 +93,32 @@ MSchedGraphNode> succ_iterator; succ_iterator succ_begin(); succ_iterator succ_end(); + + unsigned succ_size() { return Successors.size(); } + + void setPredecessor(unsigned index, MSchedGraphNode *dest) { + Predecessors[index] = dest; + } + + MSchedGraphNode* getPredecessor(unsigned index) { + return Predecessors[index]; + } + + MSchedGraphEdge* getSuccessor(unsigned index) { + return &Successors[index]; + } + + void deleteSuccessor(MSchedGraphNode *node) { + for (unsigned i = 0; i != Successors.size(); ++i) + if (Successors[i].getDest() == node) { + Successors.erase(Successors.begin()+i); + node->Predecessors.erase(std::find(node->Predecessors.begin(), + node->Predecessors.end(), this)); + --i; + } + } + - void addOutEdge(MSchedGraphNode *destination, MSchedGraphEdge::MSchedGraphEdgeType type, @@ -105,15 +133,15 @@ unsigned getLatency() { return latency; } unsigned getLatency() const { return latency; } unsigned getIndex() { return index; } + unsigned getIteDiff(MSchedGraphNode *succ); MSchedGraphEdge getInEdge(MSchedGraphNode *pred); unsigned getInEdgeNum(MSchedGraphNode *pred); - bool isSuccessor(MSchedGraphNode *); bool isPredecessor(MSchedGraphNode *); bool isBranch() { return isBranchInstr; } //Debug support void print(std::ostream &os) const; - + void setParent(MSchedGraph *p) { Parent = p; } }; template @@ -172,6 +200,24 @@ } + // Provide specializations of GraphTraits to be able to use graph + // iterators on the scheduling graph! + // + template <> struct GraphTraits { + typedef MSchedGraphNode NodeType; + typedef MSchedGraphNode::succ_iterator ChildIteratorType; + + static inline ChildIteratorType child_begin(NodeType *N) { + return N->succ_begin(); + } + static inline ChildIteratorType child_end(NodeType *N) { + return N->succ_end(); + } + + static NodeType *getEntryNode(NodeType* N) { return N; } + }; + + class MSchedGraph { @@ -193,11 +239,13 @@ public: MSchedGraph(const MachineBasicBlock *bb, const TargetMachine &targ); + MSchedGraph(const MSchedGraph &G, std::map &newNodes); ~MSchedGraph(); //Add Nodes to the Graph void addNode(const MachineInstr* MI, MSchedGraphNode *node); - + void deleteNode(MSchedGraphNode *node); + //iterators typedef std::map::iterator iterator; typedef std::map::const_iterator const_iterator; @@ -205,9 +253,11 @@ iterator find(const MachineInstr* I) { return GraphMap.find(I); } iterator end() { return GraphMap.end(); } iterator begin() { return GraphMap.begin(); } + unsigned size() { return GraphMap.size(); } reverse_iterator rbegin() { return GraphMap.rbegin(); } reverse_iterator rend() { return GraphMap.rend(); } const TargetMachine* getTarget() { return &Target; } + const MachineBasicBlock* getBB() { return BB; } }; @@ -242,14 +292,13 @@ static nodes_iterator nodes_end(MSchedGraph *G) { return map_iterator(((MSchedGraph*)G)->end(), DerefFun(getSecond)); } - }; template <> struct GraphTraits { typedef const MSchedGraphNode NodeType; typedef MSchedGraphNode::succ_const_iterator ChildIteratorType; - + static inline ChildIteratorType child_begin(NodeType *N) { return N->succ_begin(); } Index: llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp diff -u llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp:1.40 llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp:1.41 --- llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp:1.40 Mon Jan 17 22:15:41 2005 +++ llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp Thu Feb 10 11:02:58 2005 @@ -23,8 +23,10 @@ #include "llvm/Target/TargetSchedInfo.h" #include "llvm/Support/Debug.h" #include "llvm/Support/GraphWriter.h" +#include "llvm/ADT/SCCIterator.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/Statistic.h" +#include "llvm/Support/Timer.h" #include #include #include @@ -60,11 +62,21 @@ O << "\n"; }; + +#if 1 +#define TIME_REGION(VARNAME, DESC) \ + NamedRegionTimer VARNAME(DESC) +#else +#define TIME_REGION(VARNAME, DESC) +#endif + + //Graph Traits for printing out the dependence graph namespace llvm { Statistic<> ValidLoops("modulosched-validLoops", "Number of candidate loops modulo-scheduled"); Statistic<> MSLoops("modulosched-schedLoops", "Number of loops successfully modulo-scheduled"); Statistic<> IncreasedII("modulosched-increasedII", "Number of times we had to increase II"); + Statistic<> SingleBBLoops("modulosched-singeBBLoops", "Number of single basic block loops"); template<> struct DOTGraphTraits : public DefaultDOTGraphTraits { @@ -151,25 +163,40 @@ //Iterate over the worklist and perform scheduling for(std::vector::iterator BI = Worklist.begin(), BE = Worklist.end(); BI != BE; ++BI) { - - CreateDefMap(*BI); + + //Print out BB for debugging + DEBUG(std::cerr << "ModuloScheduling BB: \n"; (*BI)->print(std::cerr)); + + //Catch the odd case where we only have TmpInstructions and no real Value*s + if(!CreateDefMap(*BI)) { + //Clear out our maps for the next basic block that is processed + nodeToAttributesMap.clear(); + partialOrder.clear(); + recurrenceList.clear(); + FinalNodeOrder.clear(); + schedule.clear(); + defMap.clear(); + continue; + } MSchedGraph *MSG = new MSchedGraph(*BI, target); //Write Graph out to file DEBUG(WriteGraphToFile(std::cerr, F.getName(), MSG)); - //Print out BB for debugging - DEBUG(std::cerr << "ModuloScheduling BB: \n"; (*BI)->print(std::cerr)); - //Calculate Resource II int ResMII = calculateResMII(*BI); //Calculate Recurrence II int RecMII = calculateRecMII(MSG, ResMII); + + DEBUG(std::cerr << "Number of reccurrences found: " << recurrenceList.size() << "\n"); + + + //Our starting initiation interval is the maximum of RecMII and ResMII - /*II = std::max(RecMII, ResMII); + II = std::max(RecMII, ResMII); //Print out II, RecMII, and ResMII DEBUG(std::cerr << "II starts out as " << II << " ( RecMII=" << RecMII << " and ResMII=" << ResMII << ")\n"); @@ -177,10 +204,10 @@ //Dump node properties if in debug mode DEBUG(for(std::map::iterator I = nodeToAttributesMap.begin(), E = nodeToAttributesMap.end(); I !=E; ++I) { - std::cerr << "Node: " << *(I->first) << " ASAP: " << I->second.ASAP << " ALAP: " - << I->second.ALAP << " MOB: " << I->second.MOB << " Depth: " << I->second.depth - << " Height: " << I->second.height << "\n"; - }); + std::cerr << "Node: " << *(I->first) << " ASAP: " << I->second.ASAP << " ALAP: " + << I->second.ALAP << " MOB: " << I->second.MOB << " Depth: " << I->second.depth + << " Height: " << I->second.height << "\n"; + }); //Calculate Node Properties calculateNodeAttributes(MSG, ResMII); @@ -188,10 +215,10 @@ //Dump node properties if in debug mode DEBUG(for(std::map::iterator I = nodeToAttributesMap.begin(), E = nodeToAttributesMap.end(); I !=E; ++I) { - std::cerr << "Node: " << *(I->first) << " ASAP: " << I->second.ASAP << " ALAP: " - << I->second.ALAP << " MOB: " << I->second.MOB << " Depth: " << I->second.depth - << " Height: " << I->second.height << "\n"; - }); + std::cerr << "Node: " << *(I->first) << " ASAP: " << I->second.ASAP << " ALAP: " + << I->second.ALAP << " MOB: " << I->second.MOB << " Depth: " << I->second.depth + << " Height: " << I->second.height << "\n"; + }); //Put nodes in order to schedule them computePartialOrder(); @@ -199,18 +226,18 @@ //Dump out partial order DEBUG(for(std::vector >::iterator I = partialOrder.begin(), E = partialOrder.end(); I !=E; ++I) { - std::cerr << "Start set in PO\n"; - for(std::set::iterator J = I->begin(), JE = I->end(); J != JE; ++J) - std::cerr << "PO:" << **J << "\n"; - }); + std::cerr << "Start set in PO\n"; + for(std::set::iterator J = I->begin(), JE = I->end(); J != JE; ++J) + std::cerr << "PO:" << **J << "\n"; + }); //Place nodes in final order orderNodes(); //Dump out order of nodes DEBUG(for(std::vector::iterator I = FinalNodeOrder.begin(), E = FinalNodeOrder.end(); I != E; ++I) { - std::cerr << "FO:" << **I << "\n"; - }); + std::cerr << "FO:" << **I << "\n"; + }); //Finally schedule nodes bool haveSched = computeSchedule(); @@ -227,7 +254,7 @@ } else DEBUG(std::cerr << "Max stage is 0, so no change in loop or reached cap\n"); - */ + //Clear out our maps for the next basic block that is processed nodeToAttributesMap.clear(); partialOrder.clear(); @@ -249,7 +276,7 @@ return Changed; } -void ModuloSchedulingPass::CreateDefMap(MachineBasicBlock *BI) { +bool ModuloSchedulingPass::CreateDefMap(MachineBasicBlock *BI) { defaultInst = 0; for(MachineBasicBlock::iterator I = BI->begin(), E = BI->end(); I != E; ++I) { @@ -257,7 +284,7 @@ const MachineOperand &mOp = I->getOperand(opNum); if(mOp.getType() == MachineOperand::MO_VirtualRegister && mOp.isDef()) { //assert if this is the second def we have seen - DEBUG(std::cerr << "Putting " << *(mOp.getVRegValue()) << " into map\n"); + //DEBUG(std::cerr << "Putting " << *(mOp.getVRegValue()) << " into map\n"); assert(!defMap.count(mOp.getVRegValue()) && "Def already in the map"); defMap[mOp.getVRegValue()] = &*I; @@ -272,7 +299,10 @@ } } - assert(defaultInst && "We must have a default instruction to use as our main point to add to machine code for instruction\n"); + if(!defaultInst) + return false; + + return true; } /// This function checks if a Machine Basic Block is valid for modulo @@ -302,6 +332,10 @@ if(BI->getBasicBlock()->size() == 1) return false; + + //Increase number of single basic block loops for stats + ++SingleBBLoops; + //Get Target machine instruction info const TargetInstrInfo *TMI = target.getInstrInfo(); @@ -311,6 +345,15 @@ MachineOpCode OC = I->getOpcode(); if(TMI->isCall(OC)) return false; + //Look for conditional move + if(OC == V9::MOVRZr || OC == V9::MOVRZi || OC == V9::MOVRLEZr || OC == V9::MOVRLEZi + || OC == V9::MOVRLZr || OC == V9::MOVRLZi || OC == V9::MOVRNZr || OC == V9::MOVRNZi + || OC == V9::MOVRGZr || OC == V9::MOVRGZi || OC == V9::MOVRGEZr + || OC == V9::MOVRGEZi || OC == V9::MOVLEr || OC == V9::MOVLEi || OC == V9::MOVLEUr + || OC == V9::MOVLEUi || OC == V9::MOVFLEr || OC == V9::MOVFLEi + || OC == V9::MOVNEr || OC == V9::MOVNEi || OC == V9::MOVNEGr || OC == V9::MOVNEGi + || OC == V9::MOVFNEr || OC == V9::MOVFNEi) + return false; } return true; } @@ -321,6 +364,8 @@ //for each instruction int ModuloSchedulingPass::calculateResMII(const MachineBasicBlock *BI) { + TIME_REGION(X, "calculateResMII"); + const TargetInstrInfo *mii = target.getInstrInfo(); const TargetSchedInfo *msi = target.getSchedInfo(); @@ -381,22 +426,22 @@ /// calculateRecMII - Calculates the value of the highest recurrence /// By value we mean the total latency int ModuloSchedulingPass::calculateRecMII(MSchedGraph *graph, int MII) { - std::vector vNodes; + /*std::vector vNodes; //Loop over all nodes in the graph for(MSchedGraph::iterator I = graph->begin(), E = graph->end(); I != E; ++I) { findAllReccurrences(I->second, vNodes, MII); vNodes.clear(); - } + }*/ + + TIME_REGION(X, "calculateRecMII"); + findAllCircuits(graph, MII); int RecMII = 0; for(std::set > >::iterator I = recurrenceList.begin(), E=recurrenceList.end(); I !=E; ++I) { - DEBUG(for(std::vector::const_iterator N = I->second.begin(), NE = I->second.end(); N != NE; ++N) { - std::cerr << **N << "\n"; - }); RecMII = std::max(RecMII, I->first); } - + return MII; } @@ -405,6 +450,8 @@ /// MOB. void ModuloSchedulingPass::calculateNodeAttributes(MSchedGraph *graph, int MII) { + TIME_REGION(X, "calculateNodeAttributes"); + assert(nodeToAttributesMap.empty() && "Node attribute map was not cleared"); //Loop over the nodes and add them to the map @@ -678,11 +725,234 @@ } +int CircCount; + +void ModuloSchedulingPass::unblock(MSchedGraphNode *u, std::set &blocked, + std::map > &B) { + + //Unblock u + DEBUG(std::cerr << "Unblocking: " << *u << "\n"); + blocked.erase(u); + + //std::set toErase; + while (!B[u].empty()) { + MSchedGraphNode *W = *B[u].begin(); + B[u].erase(W); + //toErase.insert(*W); + DEBUG(std::cerr << "Removed: " << *W << "from B-List\n"); + if(blocked.count(W)) + unblock(W, blocked, B); + } + +} + +bool ModuloSchedulingPass::circuit(MSchedGraphNode *v, std::vector &stack, + std::set &blocked, std::vector &SCC, + MSchedGraphNode *s, std::map > &B, + int II, std::map &newNodes) { + bool f = false; + + DEBUG(std::cerr << "Finding Circuits Starting with: ( " << v << ")"<< *v << "\n"); + + //Push node onto the stack + stack.push_back(v); + + //block this node + blocked.insert(v); + + //Loop over all successors of node v that are in the scc, create Adjaceny list + std::set AkV; + for(MSchedGraphNode::succ_iterator I = v->succ_begin(), E = v->succ_end(); I != E; ++I) { + if((std::find(SCC.begin(), SCC.end(), *I) != SCC.end())) { + AkV.insert(*I); + } + } + + for(std::set::iterator I = AkV.begin(), E = AkV.end(); I != E; ++I) { + if(*I == s) { + //We have a circuit, so add it to our list + + std::vector recc; + //Dump recurrence for now + DEBUG(std::cerr << "Starting Recc\n"); + + int totalDelay = 0; + int totalDistance = 0; + MSchedGraphNode *lastN = 0; + + //Loop over recurrence, get delay and distance + for(std::vector::iterator N = stack.begin(), NE = stack.end(); N != NE; ++N) { + totalDelay += (*N)->getLatency(); + if(lastN) { + totalDistance += (*N)->getInEdge(lastN).getIteDiff(); + } + + //Get the original node + lastN = *N; + recc.push_back(newNodes[*N]); + + DEBUG(std::cerr << *lastN << "\n"); + } + + //Get the loop edge + totalDistance += lastN->getIteDiff(*stack.begin()); + + DEBUG(std::cerr << "End Recc\n"); + f = true; + CircCount++; + + //Insert reccurrence into the list + DEBUG(std::cerr << "Ignore Edge from: " << *lastN << " to " << **stack.begin() << "\n"); + edgesToIgnore.insert(std::make_pair(newNodes[lastN], newNodes[(*stack.begin())]->getInEdgeNum(newNodes[lastN]))); + + //Adjust II until we get close to the inequality delay - II*distance <= 0 + int RecMII = II; //Starting value + int value = totalDelay-(RecMII * totalDistance); + int lastII = II; + while(value <= 0) { + + lastII = RecMII; + RecMII--; + value = totalDelay-(RecMII * totalDistance); + } + + recurrenceList.insert(std::make_pair(lastII, recc)); + + } + else if(!blocked.count(*I)) { + if(circuit(*I, stack, blocked, SCC, s, B, II, newNodes)) + f = true; + } + else + DEBUG(std::cerr << "Blocked: " << **I << "\n"); + } + + + if(f) { + unblock(v, blocked, B); + } + else { + for(std::set::iterator I = AkV.begin(), E = AkV.end(); I != E; ++I) + B[*I].insert(v); + + } + + //Pop v + stack.pop_back(); + + return f; + +} + +void ModuloSchedulingPass::findAllCircuits(MSchedGraph *g, int II) { + + CircCount = 0; + + //Keep old to new node mapping information + std::map newNodes; + + //copy the graph + MSchedGraph *MSG = new MSchedGraph(*g, newNodes); + + DEBUG(std::cerr << "Finding All Circuits\n"); + + //Set of blocked nodes + std::set blocked; + + //Stack holding current circuit + std::vector stack; + + //Map for B Lists + std::map > B; + + //current node + MSchedGraphNode *s; + + + //Iterate over the graph until its down to one node or empty + while(MSG->size() > 1) { + + //Write Graph out to file + //WriteGraphToFile(std::cerr, "Graph" + utostr(MSG->size()), MSG); + + DEBUG(std::cerr << "Graph Size: " << MSG->size() << "\n"); + DEBUG(std::cerr << "Finding strong component Vk with least vertex\n"); + + //Iterate over all the SCCs in the graph + std::set Visited; + std::vector Vk; + MSchedGraphNode* s = 0; + + //Find scc with the least vertex + for (MSchedGraph::iterator GI = MSG->begin(), E = MSG->end(); GI != E; ++GI) + if (Visited.insert(GI->second).second) { + for (scc_iterator SCCI = scc_begin(GI->second), + E = scc_end(GI->second); SCCI != E; ++SCCI) { + std::vector &nextSCC = *SCCI; + + if (Visited.insert(nextSCC[0]).second) { + Visited.insert(nextSCC.begin()+1, nextSCC.end()); + + DEBUG(std::cerr << "SCC size: " << nextSCC.size() << "\n"); + + //Ignore self loops + if(nextSCC.size() > 1) { + + //Get least vertex in Vk + if(!s) { + s = nextSCC[0]; + Vk = nextSCC; + } + + for(unsigned i = 0; i < nextSCC.size(); ++i) { + if(nextSCC[i] < s) { + s = nextSCC[i]; + Vk = nextSCC; + } + } + } + } + } + } + + + + //Process SCC + DEBUG(for(std::vector::iterator N = Vk.begin(), NE = Vk.end(); + N != NE; ++N) { std::cerr << *((*N)->getInst()); }); + + //Iterate over all nodes in this scc + for(std::vector::iterator N = Vk.begin(), NE = Vk.end(); + N != NE; ++N) { + blocked.erase(*N); + B[*N].clear(); + } + if(Vk.size() > 1) { + circuit(s, stack, blocked, Vk, s, B, II, newNodes); + + //Find all nodes up to s and delete them + std::vector nodesToRemove; + nodesToRemove.push_back(s); + for(MSchedGraph::iterator N = MSG->begin(), NE = MSG->end(); N != NE; ++N) { + if(N->second < s ) + nodesToRemove.push_back(N->second); + } + for(std::vector::iterator N = nodesToRemove.begin(), NE = nodesToRemove.end(); N != NE; ++N) { + DEBUG(std::cerr << "Deleting Node: " << **N << "\n"); + MSG->deleteNode(*N); + } + } + else + break; + } + DEBUG(std::cerr << "Num Circuits found: " << CircCount << "\n"); +} + + void ModuloSchedulingPass::findAllReccurrences(MSchedGraphNode *node, std::vector &visitedNodes, int II) { - if(node) - DEBUG(std::cerr << *(node->getInst()) << "\n"); + if(std::find(visitedNodes.begin(), visitedNodes.end(), node) != visitedNodes.end()) { std::vector recurrence; @@ -759,6 +1029,8 @@ void ModuloSchedulingPass::computePartialOrder() { + TIME_REGION(X, "calculatePartialOrder"); + //Only push BA branches onto the final node order, we put other branches after it //FIXME: Should we really be pushing branches on it a specific order instead of relying //on BA being there? @@ -936,6 +1208,8 @@ void ModuloSchedulingPass::orderNodes() { + TIME_REGION(X, "orderNodes"); + int BOTTOM_UP = 0; int TOP_DOWN = 1; @@ -1151,6 +1425,8 @@ bool ModuloSchedulingPass::computeSchedule() { + TIME_REGION(X, "computeSchedule"); + bool success = false; //FIXME: Should be set to max II of the original loop @@ -1879,6 +2155,9 @@ void ModuloSchedulingPass::reconstructLoop(MachineBasicBlock *BB) { + TIME_REGION(X, "reconstructLoop"); + + DEBUG(std::cerr << "Reconstructing Loop\n"); //First find the value *'s that we need to "save" Index: llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.h diff -u llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.h:1.22 llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.h:1.23 --- llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.h:1.22 Thu Dec 2 01:22:15 2004 +++ llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.h Thu Feb 10 11:02:58 2005 @@ -67,7 +67,7 @@ int II; //Internal functions - void CreateDefMap(MachineBasicBlock *BI); + bool CreateDefMap(MachineBasicBlock *BI); bool MachineBBisValid(const MachineBasicBlock *BI); int calculateResMII(const MachineBasicBlock *BI); int calculateRecMII(MSchedGraph *graph, int MII); @@ -87,6 +87,16 @@ std::vector &visitedNodes, int II); void addReccurrence(std::vector &recurrence, int II, MSchedGraphNode*, MSchedGraphNode*); + void findAllCircuits(MSchedGraph *MSG, int II); + bool circuit(MSchedGraphNode *v, std::vector &stack, + std::set &blocked, + std::vector &SCC, MSchedGraphNode *s, + std::map > &B, int II, + std::map &newNodes); + + void unblock(MSchedGraphNode *u, std::set &blocked, + std::map > &B); + void computePartialOrder(); bool computeSchedule(); bool scheduleNode(MSchedGraphNode *node, From alkis at cs.uiuc.edu Thu Feb 10 12:36:41 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu, 10 Feb 2005 12:36:41 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/GlobalOpt.cpp Message-ID: <200502101836.MAA09026@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: GlobalOpt.cpp updated: 1.34 -> 1.35 --- Log message: Localize globals if they are only used in main(). This replaces the global with an alloca, which eventually gets promoted into a register. This enables a lot of other optimizations later on. --- Diffs of the changes: (+40 -0) GlobalOpt.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 40 insertions(+) Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.34 llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.35 --- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.34 Mon Jan 31 19:23:31 2005 +++ llvm/lib/Transforms/IPO/GlobalOpt.cpp Thu Feb 10 12:36:30 2005 @@ -38,6 +38,7 @@ Statistic<> NumDeleted ("globalopt", "Number of globals deleted"); Statistic<> NumFnDeleted("globalopt", "Number of functions deleted"); Statistic<> NumGlobUses ("globalopt", "Number of global uses devirtualized"); + Statistic<> NumLocalized("globalopt", "Number of globals localized"); Statistic<> NumShrunkToBool("globalopt", "Number of global vars shrunk to booleans"); @@ -92,12 +93,20 @@ /// ever stored to this global, keep track of what value it is. Value *StoredOnceValue; + // AccessingFunction/HasMultipleAccessingFunctions - These start out + // null/false. When the first accessing function is noticed, it is recorded. + // When a second different accessing function is noticed, + // HasMultipleAccessingFunctions is set to true. + Function *AccessingFunction; + bool HasMultipleAccessingFunctions; + /// isNotSuitableForSRA - Keep track of whether any SRA preventing users of /// the global exist. Such users include GEP instruction with variable /// indexes, and non-gep/load/store users like constant expr casts. bool isNotSuitableForSRA; GlobalStatus() : isLoaded(false), StoredType(NotStored), StoredOnceValue(0), + AccessingFunction(0), HasMultipleAccessingFunctions(false), isNotSuitableForSRA(false) {} }; @@ -146,6 +155,13 @@ } } else if (Instruction *I = dyn_cast(*UI)) { + if (!GS.HasMultipleAccessingFunctions) { + Function *F = I->getParent()->getParent(); + if (GS.AccessingFunction == 0) + GS.AccessingFunction = F; + else if (GS.AccessingFunction != F) + GS.HasMultipleAccessingFunctions = true; + } if (isa(I)) { GS.isLoaded = true; } else if (StoreInst *SI = dyn_cast(I)) { @@ -898,6 +914,30 @@ } if (!AnalyzeGlobal(GV, GS, PHIUsers)) { + // If this is a first class global and has only one accessing function + // and this function is main (which we know is not recursive we can make + // this global a local variable) we replace the global with a local alloca + // in this function. + // + // NOTE: It doesn't make sense to promote non first class types since we + // are just replacing static memory to stack memory. + if (!GS.HasMultipleAccessingFunctions && + GS.AccessingFunction && + GV->getType()->getElementType()->isFirstClassType() && + GS.AccessingFunction->getName() == "main" && + GS.AccessingFunction->hasExternalLinkage()) { + DEBUG(std::cerr << "LOCALIZING GLOBAL: " << *GV); + Instruction* FirstI = GS.AccessingFunction->getEntryBlock().begin(); + const Type* ElemTy = GV->getType()->getElementType(); + AllocaInst* Alloca = new AllocaInst(ElemTy, NULL, GV->getName(), FirstI); + if (!isa(GV->getInitializer())) + new StoreInst(GV->getInitializer(), Alloca, FirstI); + + GV->replaceAllUsesWith(Alloca); + GV->eraseFromParent(); + ++NumLocalized; + return true; + } // If the global is never loaded (but may be stored to), it is dead. // Delete it now. if (!GS.isLoaded) { From reid at x10sys.com Thu Feb 10 13:23:49 2005 From: reid at x10sys.com (Reid Spencer) Date: Thu, 10 Feb 2005 11:23:49 -0800 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/GlobalOpt.cpp In-Reply-To: <200502101836.MAA09026@zion.cs.uiuc.edu> References: <200502101836.MAA09026@zion.cs.uiuc.edu> Message-ID: <420BB4C5.4030008@x10sys.com> Is this a good idea? What if you have a large global variable, say an array about 32MB in size. Moving it to the stack will blow the (typically 8MB) stack away and cause the program to fail. While its probably a good optimization for small things, we ought to set some kind of threshold and not perform this optimization if the global variable is very large. Reid. Alkis Evlogimenos wrote: > Changes in directory llvm/lib/Transforms/IPO: > > GlobalOpt.cpp updated: 1.34 -> 1.35 > --- > Log message: > > Localize globals if they are only used in main(). This replaces the > global with an alloca, which eventually gets promoted into a > register. This enables a lot of other optimizations later on. > > > --- > Diffs of the changes: (+40 -0) > > GlobalOpt.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ > 1 files changed, 40 insertions(+) > > > Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp > diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.34 llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.35 > --- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.34 Mon Jan 31 19:23:31 2005 > +++ llvm/lib/Transforms/IPO/GlobalOpt.cpp Thu Feb 10 12:36:30 2005 > @@ -38,6 +38,7 @@ > Statistic<> NumDeleted ("globalopt", "Number of globals deleted"); > Statistic<> NumFnDeleted("globalopt", "Number of functions deleted"); > Statistic<> NumGlobUses ("globalopt", "Number of global uses devirtualized"); > + Statistic<> NumLocalized("globalopt", "Number of globals localized"); > Statistic<> NumShrunkToBool("globalopt", > "Number of global vars shrunk to booleans"); > > @@ -92,12 +93,20 @@ > /// ever stored to this global, keep track of what value it is. > Value *StoredOnceValue; > > + // AccessingFunction/HasMultipleAccessingFunctions - These start out > + // null/false. When the first accessing function is noticed, it is recorded. > + // When a second different accessing function is noticed, > + // HasMultipleAccessingFunctions is set to true. > + Function *AccessingFunction; > + bool HasMultipleAccessingFunctions; > + > /// isNotSuitableForSRA - Keep track of whether any SRA preventing users of > /// the global exist. Such users include GEP instruction with variable > /// indexes, and non-gep/load/store users like constant expr casts. > bool isNotSuitableForSRA; > > GlobalStatus() : isLoaded(false), StoredType(NotStored), StoredOnceValue(0), > + AccessingFunction(0), HasMultipleAccessingFunctions(false), > isNotSuitableForSRA(false) {} > }; > > @@ -146,6 +155,13 @@ > } > > } else if (Instruction *I = dyn_cast(*UI)) { > + if (!GS.HasMultipleAccessingFunctions) { > + Function *F = I->getParent()->getParent(); > + if (GS.AccessingFunction == 0) > + GS.AccessingFunction = F; > + else if (GS.AccessingFunction != F) > + GS.HasMultipleAccessingFunctions = true; > + } > if (isa(I)) { > GS.isLoaded = true; > } else if (StoreInst *SI = dyn_cast(I)) { > @@ -898,6 +914,30 @@ > } > > if (!AnalyzeGlobal(GV, GS, PHIUsers)) { > + // If this is a first class global and has only one accessing function > + // and this function is main (which we know is not recursive we can make > + // this global a local variable) we replace the global with a local alloca > + // in this function. > + // > + // NOTE: It doesn't make sense to promote non first class types since we > + // are just replacing static memory to stack memory. > + if (!GS.HasMultipleAccessingFunctions && > + GS.AccessingFunction && > + GV->getType()->getElementType()->isFirstClassType() && > + GS.AccessingFunction->getName() == "main" && > + GS.AccessingFunction->hasExternalLinkage()) { > + DEBUG(std::cerr << "LOCALIZING GLOBAL: " << *GV); > + Instruction* FirstI = GS.AccessingFunction->getEntryBlock().begin(); > + const Type* ElemTy = GV->getType()->getElementType(); > + AllocaInst* Alloca = new AllocaInst(ElemTy, NULL, GV->getName(), FirstI); > + if (!isa(GV->getInitializer())) > + new StoreInst(GV->getInitializer(), Alloca, FirstI); > + > + GV->replaceAllUsesWith(Alloca); > + GV->eraseFromParent(); > + ++NumLocalized; > + return true; > + } > // If the global is never loaded (but may be stored to), it is dead. > // Delete it now. > if (!GS.isLoaded) { > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://mail.cs.uiuc.edu/mailman/listinfo/llvm-commits > From sabre at nondot.org Thu Feb 10 13:32:54 2005 From: sabre at nondot.org (Chris Lattner) Date: Thu, 10 Feb 2005 13:32:54 -0600 (CST) Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/GlobalOpt.cpp In-Reply-To: <420BB4C5.4030008@x10sys.com> References: <200502101836.MAA09026@zion.cs.uiuc.edu> <420BB4C5.4030008@x10sys.com> Message-ID: On Thu, 10 Feb 2005, Reid Spencer wrote: > Is this a good idea? What if you have a large global variable, say an array > about 32MB in size. Moving it to the stack will blow the (typically 8MB) > stack away and cause the program to fail. While its probably a good > optimization for small things, we ought to set some kind of threshold and not > perform this optimization if the global variable is very large. This only applies to scalars. -Chris > Alkis Evlogimenos wrote: >> Changes in directory llvm/lib/Transforms/IPO: >> >> GlobalOpt.cpp updated: 1.34 -> 1.35 >> --- >> Log message: >> >> Localize globals if they are only used in main(). This replaces the >> global with an alloca, which eventually gets promoted into a >> register. This enables a lot of other optimizations later on. >> >> >> --- >> Diffs of the changes: (+40 -0) >> >> GlobalOpt.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ >> 1 files changed, 40 insertions(+) >> >> >> Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp >> diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.34 >> llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.35 >> --- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.34 Mon Jan 31 19:23:31 >> 2005 >> +++ llvm/lib/Transforms/IPO/GlobalOpt.cpp Thu Feb 10 12:36:30 2005 >> @@ -38,6 +38,7 @@ >> Statistic<> NumDeleted ("globalopt", "Number of globals deleted"); >> Statistic<> NumFnDeleted("globalopt", "Number of functions deleted"); >> Statistic<> NumGlobUses ("globalopt", "Number of global uses >> devirtualized"); >> + Statistic<> NumLocalized("globalopt", "Number of globals localized"); >> Statistic<> NumShrunkToBool("globalopt", >> "Number of global vars shrunk to booleans"); >> @@ -92,12 +93,20 @@ >> /// ever stored to this global, keep track of what value it is. >> Value *StoredOnceValue; >> + // AccessingFunction/HasMultipleAccessingFunctions - These start out >> + // null/false. When the first accessing function is noticed, it is >> recorded. >> + // When a second different accessing function is noticed, >> + // HasMultipleAccessingFunctions is set to true. >> + Function *AccessingFunction; >> + bool HasMultipleAccessingFunctions; >> + >> /// isNotSuitableForSRA - Keep track of whether any SRA preventing users >> of >> /// the global exist. Such users include GEP instruction with variable >> /// indexes, and non-gep/load/store users like constant expr casts. >> bool isNotSuitableForSRA; >> GlobalStatus() : isLoaded(false), StoredType(NotStored), >> StoredOnceValue(0), >> + AccessingFunction(0), >> HasMultipleAccessingFunctions(false), >> isNotSuitableForSRA(false) {} >> }; >> @@ -146,6 +155,13 @@ >> } >> } else if (Instruction *I = dyn_cast(*UI)) { >> + if (!GS.HasMultipleAccessingFunctions) { >> + Function *F = I->getParent()->getParent(); >> + if (GS.AccessingFunction == 0) >> + GS.AccessingFunction = F; >> + else if (GS.AccessingFunction != F) >> + GS.HasMultipleAccessingFunctions = true; >> + } >> if (isa(I)) { >> GS.isLoaded = true; >> } else if (StoreInst *SI = dyn_cast(I)) { >> @@ -898,6 +914,30 @@ >> } >> if (!AnalyzeGlobal(GV, GS, PHIUsers)) { >> + // If this is a first class global and has only one accessing function >> + // and this function is main (which we know is not recursive we can >> make >> + // this global a local variable) we replace the global with a local >> alloca >> + // in this function. >> + // >> + // NOTE: It doesn't make sense to promote non first class types since >> we >> + // are just replacing static memory to stack memory. >> + if (!GS.HasMultipleAccessingFunctions && >> + GS.AccessingFunction && >> + GV->getType()->getElementType()->isFirstClassType() && >> + GS.AccessingFunction->getName() == "main" && >> + GS.AccessingFunction->hasExternalLinkage()) { >> + DEBUG(std::cerr << "LOCALIZING GLOBAL: " << *GV); >> + Instruction* FirstI = GS.AccessingFunction->getEntryBlock().begin(); >> + const Type* ElemTy = GV->getType()->getElementType(); >> + AllocaInst* Alloca = new AllocaInst(ElemTy, NULL, GV->getName(), >> FirstI); >> + if (!isa(GV->getInitializer())) >> + new StoreInst(GV->getInitializer(), Alloca, FirstI); >> + + GV->replaceAllUsesWith(Alloca); >> + GV->eraseFromParent(); >> + ++NumLocalized; >> + return true; >> + } >> // If the global is never loaded (but may be stored to), it is dead. >> // Delete it now. >> if (!GS.isLoaded) { >> >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://mail.cs.uiuc.edu/mailman/listinfo/llvm-commits >> > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://mail.cs.uiuc.edu/mailman/listinfo/llvm-commits > -Chris -- http://nondot.org/sabre/ http://llvm.cs.uiuc.edu/ From alenhar2 at cs.uiuc.edu Thu Feb 10 14:13:56 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Thu, 10 Feb 2005 14:13:56 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp Message-ID: <200502102013.OAA24358@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.48 -> 1.49 --- Log message: fix a bunch of regressions due to call behavior --- Diffs of the changes: (+4 -4) AlphaISelPattern.cpp | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.48 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.49 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.48 Thu Feb 10 00:25:13 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Thu Feb 10 14:10:38 2005 @@ -862,14 +862,14 @@ if (GlobalAddressSDNode *GASD = dyn_cast(N.getOperand(1))) { - if (GASD->getGlobal()->isExternal()) { + //if (GASD->getGlobal()->isExternal()) { //use safe calling convention AlphaLowering.restoreGP(BB); BuildMI(BB, Alpha::CALL, 1).addGlobalAddress(GASD->getGlobal(),true); - } else { + //} else { //use PC relative branch call - BuildMI(BB, Alpha::BSR, 1, Alpha::R26).addGlobalAddress(GASD->getGlobal(),true); - } + //BuildMI(BB, Alpha::BSR, 1, Alpha::R26).addGlobalAddress(GASD->getGlobal(),true); + //} } else if (ExternalSymbolSDNode *ESSDN = dyn_cast(N.getOperand(1))) From lattner at cs.uiuc.edu Thu Feb 10 14:39:22 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 10 Feb 2005 14:39:22 -0600 Subject: [llvm-commits] CVS: poolalloc/lib/PoolAllocate/PointerCompress.cpp Message-ID: <200502102039.j1AKdMWA006569@apoc.cs.uiuc.edu> Changes in directory poolalloc/lib/PoolAllocate: PointerCompress.cpp updated: 1.2 -> 1.3 --- Log message: Implement pointer compression for some instructions. This can successfully compress data structures that are only involved with the null pointer, store, cast, and malloc instructions. No frees, loads, etc allowed! :-) --- Diffs of the changes: (+253 -21) Index: poolalloc/lib/PoolAllocate/PointerCompress.cpp diff -u poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.2 poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.3 --- poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.2 Wed Feb 9 16:55:53 2005 +++ poolalloc/lib/PoolAllocate/PointerCompress.cpp Thu Feb 10 14:39:11 2005 @@ -14,6 +14,8 @@ #define DEBUG_TYPE "pointercompress" #include "EquivClassGraphs.h" #include "PoolAllocate.h" +#include "llvm/Constants.h" +#include "llvm/Instructions.h" #include "llvm/Module.h" #include "llvm/ADT/Statistic.h" #include "llvm/Support/Debug.h" @@ -34,12 +36,14 @@ PoolAllocate *PoolAlloc; PA::EquivClassGraphs *ECG; public: + Function *PoolInitPC, *PoolDestroyPC, *PoolAllocPC, *PoolFreePC; typedef std::map PoolInfoMap; bool runOnModule(Module &M); void getAnalysisUsage(AnalysisUsage &AU) const; private: + void InitializePoolLibraryFunctions(Module &M); bool CompressPoolsInFunction(Function &F); void FindPoolsToCompress(std::vector &Pools, Function &F, DSGraph &DSG, PA::FuncInfo *FI); @@ -58,17 +62,29 @@ /// pool that is compressed. class CompressedPoolInfo { const DSNode *Pool; + Value *PoolDesc; const Type *NewTy; + unsigned NewSize; public: - CompressedPoolInfo(const DSNode *N) : Pool(N), NewTy(0) {} + CompressedPoolInfo(const DSNode *N, Value *PD) + : Pool(N), PoolDesc(PD), NewTy(0) {} /// Initialize - When we know all of the pools in a function that are going /// to be compressed, initialize our state based on that data. - void Initialize(std::map &Nodes); + void Initialize(std::map &Nodes, + const TargetData &TD); const DSNode *getNode() const { return Pool; } const Type *getNewType() const { return NewTy; } + /// getNewSize - Return the size of each node after compression. + /// + unsigned getNewSize() const { return NewSize; } + + /// getPoolDesc - Return the Value* for the pool descriptor for this pool. + /// + Value *getPoolDesc() const { return PoolDesc; } + // dump - Emit a debugging dump of this pool info. void dump() const; @@ -81,11 +97,14 @@ /// Initialize - When we know all of the pools in a function that are going /// to be compressed, initialize our state based on that data. void CompressedPoolInfo::Initialize(std::map &Nodes) { + CompressedPoolInfo> &Nodes, + const TargetData &TD) { // First step, compute the type of the compressed node. This basically // replaces all pointers to compressed pools with uints. NewTy = ComputeCompressedType(Pool->getType(), 0, Nodes); + // Get the compressed type size. + NewSize = TD.getTypeSize(NewTy); } @@ -197,38 +216,224 @@ namespace { + /// InstructionRewriter - This class implements the rewriting neccesary to + /// transform a function body from normal pool allocation to pointer + /// compression. It is constructed, then the 'visit' method is called on a + /// function. If is responsible for rewriting all instructions that refer to + /// pointers into compressed pools. class InstructionRewriter : public llvm::InstVisitor { /// OldToNewValueMap - This keeps track of what new instructions we create /// for instructions that used to produce pointers into our pool. std::map OldToNewValueMap; - /// ForwardRefs - If a value is refered to before it is defined, create a - /// temporary Argument node as a placeholder. When the value is really - /// defined, call replaceAllUsesWith on argument and remove it from this - /// map. - std::map ForwardRefs; - const PointerCompress::PoolInfoMap &PoolInfo; const DSGraph &DSG; + + PointerCompress &PtrComp; public: InstructionRewriter(const PointerCompress::PoolInfoMap &poolInfo, - const DSGraph &dsg) - : PoolInfo(poolInfo), DSG(dsg) { + const DSGraph &dsg, PointerCompress &ptrcomp) + : PoolInfo(poolInfo), DSG(dsg), PtrComp(ptrcomp) { + } + + ~InstructionRewriter(); + + /// getTransformedValue - Return the transformed version of the specified + /// value, creating a new forward ref value as needed. + Value *getTransformedValue(Value *V) { + if (isa(V)) // null -> uint 0 + return Constant::getNullValue(Type::UIntTy); + + assert(getNodeIfCompressed(V) && "Value is not compressed!"); + Value *&RV = OldToNewValueMap[V]; + if (RV) return RV; + + RV = new Argument(Type::UIntTy); + return RV; + } + + /// setTransformedValue - When we create a new value, this method sets it as + /// the current value. + void setTransformedValue(Instruction &Old, Value *New) { + Value *&EV = OldToNewValueMap[&Old]; + if (EV) { + assert(isa(EV) && "Not a forward reference!"); + EV->replaceAllUsesWith(New); + delete EV; + } + EV = New; } - ~InstructionRewriter() { - assert(ForwardRefs.empty() && "Unresolved forward refs exist!"); + + /// getNodeIfCompressed - If the specified value is a pointer that will be + /// compressed, return the DSNode corresponding to the pool it belongs to. + const DSNode *getNodeIfCompressed(Value *V) { + if (!isa(V->getType())) return false; + DSNode *N = DSG.getNodeForValue(V).getNode(); + return PoolInfo.count(N) ? N : 0; } + /// getPoolInfo - Return the pool info for the specified compressed pool. + /// + const CompressedPoolInfo &getPoolInfo(const DSNode *N) { + assert(N && "Pool not compressed!"); + PointerCompress::PoolInfoMap::const_iterator I = PoolInfo.find(N); + assert(I != PoolInfo.end() && "Pool is not compressed!"); + return I->second; + } + + /// getPoolInfo - Return the pool info object for the specified value if the + /// pointer points into a compressed pool, otherwise return null. + const CompressedPoolInfo *getPoolInfo(Value *V) { + if (const DSNode *N = getNodeIfCompressed(V)) + return &getPoolInfo(N); + return 0; + } + + //===------------------------------------------------------------------===// + // Visitation methods. These do all of the heavy lifting for the various + // cases we have to handle. + + void visitCastInst(CastInst &CI); + void visitStoreInst(StoreInst &SI); + + void visitCallInst(CallInst &CI); + void visitPoolInit(CallInst &CI); + void visitPoolDestroy(CallInst &CI); + void visitPoolAlloc(CallInst &CI); + void visitPoolFree(CallInst &CI); + void visitInstruction(Instruction &I) { - std::cerr << "ERROR: UNHANDLED INSTRUCTION: " << I; - //assert(0); - //abort(); +#ifndef NDEBUG + bool Unhandled = !!getNodeIfCompressed(&I); + for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i) + Unhandled |= !!getNodeIfCompressed(I.getOperand(i)); + + if (Unhandled) { + std::cerr << "ERROR: UNHANDLED INSTRUCTION: " << I; + //assert(0); + //abort(); + } +#endif } }; } // end anonymous namespace. +InstructionRewriter::~InstructionRewriter() { + // Nuke all of the old values from the program. + for (std::map::iterator I = OldToNewValueMap.begin(), + E = OldToNewValueMap.end(); I != E; ++I) { + assert((!isa(I->second) || cast(I->second)->getParent()) + && "ERROR: Unresolved value still left in the program!"); + // If there is anything still using this, provide a temporary value. + if (!I->first->use_empty()) + I->first->replaceAllUsesWith(UndefValue::get(I->first->getType())); + + // Finally, remove it from the program. + cast(I->first)->eraseFromParent(); + } +} + + +void InstructionRewriter::visitCastInst(CastInst &CI) { + if (!isa(CI.getType())) return; + + const CompressedPoolInfo *PI = getPoolInfo(&CI); + if (!PI) return; + assert(getPoolInfo(CI.getOperand(0)) == PI && "Not cast from ptr -> ptr?"); + + // A cast from one pointer to another turns into a cast from uint -> uint, + // which is a noop. + setTransformedValue(CI, getTransformedValue(CI.getOperand(0))); +} + +void InstructionRewriter::visitStoreInst(StoreInst &SI) { + const CompressedPoolInfo *DestPI = getPoolInfo(SI.getOperand(1)); + if (DestPI == 0) { + assert(getPoolInfo(SI.getOperand(0)) == 0 && + "Cannot store a compressed pointer into non-compressed memory!"); + return; + } + + // We care about two cases, here: + // 1. Storing a normal value into a ptr compressed data structure. + // 2. Storing a compressed ptr into a ptr compressed data structure. Note + // that we cannot use the src value to decide if this is a compressed + // pointer if it's a null pointer. We have to try harder. + // + Value *SrcVal = SI.getOperand(0); + if (!isa(SrcVal)) { + const CompressedPoolInfo *SrcPI = getPoolInfo(SrcVal); + if (SrcPI) // If the stored value is compressed, get the xformed version + SrcVal = getTransformedValue(SrcVal); + } else { + // FIXME: This assumes that all pointers are compressed! + SrcVal = getTransformedValue(SrcVal); + } + + // Get the pool base pointer. + Constant *Zero = Constant::getNullValue(Type::UIntTy); + Value *BasePtrPtr = new GetElementPtrInst(DestPI->getPoolDesc(), Zero, Zero, + "poolbaseptrptr", &SI); + Value *BasePtr = new LoadInst(BasePtrPtr, "poolbaseptr", &SI); + std::vector Ops; + Ops.push_back(getTransformedValue(SI.getOperand(1))); + Value *DestPtr = new GetElementPtrInst(BasePtr, Ops, + SI.getOperand(1)->getName()+".pp", + &SI); + DestPtr = new CastInst(DestPtr, PointerType::get(SrcVal->getType()), + DestPtr->getName(), &SI); + new StoreInst(SrcVal, DestPtr, &SI); + + // Finally, explicitly remove the store from the program, as it does not + // produce a pointer result. + SI.eraseFromParent(); +} + + +void InstructionRewriter::visitPoolInit(CallInst &CI) { + // Transform to poolinit_pc if necessary. +} + +void InstructionRewriter::visitPoolDestroy(CallInst &CI) { + // Transform to pooldestroy_pc if necessary. + /* TODO */ +} +void InstructionRewriter::visitPoolAlloc(CallInst &CI) { + // Transform to poolalloc_pc if necessary. + const CompressedPoolInfo *PI = getPoolInfo(&CI); + if (PI == 0) return; // Not a compressed pool! + + std::vector Ops; + Ops.push_back(CI.getOperand(1)); + Ops.push_back(ConstantUInt::get(Type::UIntTy, PI->getNewSize())); + Value *New = new CallInst(PtrComp.PoolAllocPC, Ops, CI.getName(), &CI); + setTransformedValue(CI, New); +} + +void InstructionRewriter::visitPoolFree(CallInst &CI) { + // Transform to poolfree_pc if necessary. +} + +void InstructionRewriter::visitCallInst(CallInst &CI) { + if (Function *F = CI.getCalledFunction()) + if (F->getName() == "poolinit") { + visitPoolInit(CI); + return; + } else if (F->getName() == "pooldestroy") { + visitPoolDestroy(CI); + return; + } else if (F->getName() == "poolalloc") { + visitPoolAlloc(CI); + return; + } else if (F->getName() == "poolfree") { + visitPoolFree(CI); + return; + } + + visitInstruction(CI); +} /// CompressPoolsInFunction - Find all pools that are compressible in this @@ -264,30 +469,57 @@ // Compute the initial collection of compressed pointer infos. std::map PoolsToCompress; - for (unsigned i = 0, e = PoolsToCompressList.size(); i != e; ++i) - PoolsToCompress.insert(std::make_pair(PoolsToCompressList[i], - PoolsToCompressList[i])); + for (unsigned i = 0, e = PoolsToCompressList.size(); i != e; ++i) { + const DSNode *N = PoolsToCompressList[i]; + Value *PD = FI->PoolDescriptors[N]; + assert(PD && "No pool descriptor available for this pool???"); + PoolsToCompress.insert(std::make_pair(N, CompressedPoolInfo(N, PD))); + } // Use these to compute the closure of compression information. In // particular, if one pool points to another, we need to know if the outgoing // pointer is compressed. + const TargetData &TD = DSG.getTargetData(); std::cerr << "In function '" << F.getName() << "':\n"; for (std::map::iterator I = PoolsToCompress.begin(), E = PoolsToCompress.end(); I != E; ++I) { - I->second.Initialize(PoolsToCompress); + I->second.Initialize(PoolsToCompress, TD); std::cerr << " COMPRESSING POOL:\nPCS:"; I->second.dump(); } // Finally, rewrite the function body to use compressed pointers! - InstructionRewriter(PoolsToCompress, DSG).visit(F); + InstructionRewriter(PoolsToCompress, DSG, *this).visit(F); return true; } + +/// InitializePoolLibraryFunctions - Create the function prototypes for pointer +/// compress runtime library functions. +void PointerCompress::InitializePoolLibraryFunctions(Module &M) { + const Type *VoidPtrTy = PointerType::get(Type::SByteTy); + const Type *PoolDescPtrTy = PointerType::get(ArrayType::get(VoidPtrTy, 16)); + + PoolInitPC = M.getOrInsertFunction("poolinit_pc", Type::VoidTy, + PoolDescPtrTy, Type::UIntTy, + Type::UIntTy, 0); + PoolDestroyPC = M.getOrInsertFunction("pooldestroy_pc", Type::VoidTy, + PoolDescPtrTy, 0); + PoolAllocPC = M.getOrInsertFunction("poolalloc_pc", Type::UIntTy, + PoolDescPtrTy, Type::UIntTy, 0); + PoolFreePC = M.getOrInsertFunction("poolfree_pc", Type::VoidTy, + PoolDescPtrTy, Type::UIntTy, 0); + // FIXME: Need bumppointer versions as well as realloc??/memalign?? +} + bool PointerCompress::runOnModule(Module &M) { PoolAlloc = &getAnalysis(); ECG = &getAnalysis(); + // Create the function prototypes for pointer compress runtime library + // functions. + InitializePoolLibraryFunctions(M); + // Iterate over all functions in the module, looking for compressible data // structures. bool Changed = false; From lattner at cs.uiuc.edu Thu Feb 10 14:47:37 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 10 Feb 2005 14:47:37 -0600 Subject: [llvm-commits] CVS: poolalloc/lib/PoolAllocate/PointerCompress.cpp Message-ID: <200502102047.j1AKlbEM007228@apoc.cs.uiuc.edu> Changes in directory poolalloc/lib/PoolAllocate: PointerCompress.cpp updated: 1.3 -> 1.4 --- Log message: Add support for PHI nodes, we can now build RECURSIVE data structures with LOOPS *gasp* :) --- Diffs of the changes: (+14 -0) Index: poolalloc/lib/PoolAllocate/PointerCompress.cpp diff -u poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.3 poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.4 --- poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.3 Thu Feb 10 14:39:11 2005 +++ poolalloc/lib/PoolAllocate/PointerCompress.cpp Thu Feb 10 14:47:27 2005 @@ -295,6 +295,7 @@ // cases we have to handle. void visitCastInst(CastInst &CI); + void visitPHINode(PHINode &PN); void visitStoreInst(StoreInst &SI); void visitCallInst(CallInst &CI); @@ -348,6 +349,19 @@ setTransformedValue(CI, getTransformedValue(CI.getOperand(0))); } +void InstructionRewriter::visitPHINode(PHINode &PN) { + const CompressedPoolInfo *DestPI = getPoolInfo(&PN); + if (DestPI == 0) return; + + PHINode *New = new PHINode(Type::UIntTy, PN.getName(), &PN); + New->reserveOperandSpace(PN.getNumIncomingValues()); + + for (unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i) + New->addIncoming(getTransformedValue(PN.getIncomingValue(i)), + PN.getIncomingBlock(i)); + setTransformedValue(PN, New); +} + void InstructionRewriter::visitStoreInst(StoreInst &SI) { const CompressedPoolInfo *DestPI = getPoolInfo(SI.getOperand(1)); if (DestPI == 0) { From lattner at cs.uiuc.edu Thu Feb 10 15:26:33 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 10 Feb 2005 15:26:33 -0600 Subject: [llvm-commits] CVS: poolalloc/lib/PoolAllocate/PointerCompress.cpp Message-ID: <200502102126.j1ALQXb9008869@apoc.cs.uiuc.edu> Changes in directory poolalloc/lib/PoolAllocate: PointerCompress.cpp updated: 1.4 -> 1.5 --- Log message: Add support for LOADING VALUES from a compressed data structure. Now we can build AND read from our data structures. :) --- Diffs of the changes: (+47 -1) Index: poolalloc/lib/PoolAllocate/PointerCompress.cpp diff -u poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.4 poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.5 --- poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.4 Thu Feb 10 14:47:27 2005 +++ poolalloc/lib/PoolAllocate/PointerCompress.cpp Thu Feb 10 15:26:23 2005 @@ -268,7 +268,8 @@ /// getNodeIfCompressed - If the specified value is a pointer that will be /// compressed, return the DSNode corresponding to the pool it belongs to. const DSNode *getNodeIfCompressed(Value *V) { - if (!isa(V->getType())) return false; + if (!isa(V->getType()) || isa(V)) + return false; DSNode *N = DSG.getNodeForValue(V).getNode(); return PoolInfo.count(N) ? N : 0; } @@ -296,6 +297,7 @@ void visitCastInst(CastInst &CI); void visitPHINode(PHINode &PN); + void visitLoadInst(LoadInst &LI); void visitStoreInst(StoreInst &SI); void visitCallInst(CallInst &CI); @@ -362,6 +364,48 @@ setTransformedValue(PN, New); } +void InstructionRewriter::visitLoadInst(LoadInst &LI) { + if (isa(LI.getOperand(0))) return; // load null ?? + + const CompressedPoolInfo *SrcPI = getPoolInfo(LI.getOperand(0)); + if (SrcPI == 0) { + assert(getPoolInfo(&LI) == 0 && + "Cannot load a compressed pointer from non-compressed memory!"); + return; + } + + // We care about two cases, here: + // 1. Loading a normal value from a ptr compressed data structure. + // 2. Loading a compressed ptr from a ptr compressed data structure. + bool LoadingCompressedPtr = getNodeIfCompressed(&LI) != 0; + + // Get the pool base pointer. + Constant *Zero = Constant::getNullValue(Type::UIntTy); + Value *BasePtrPtr = new GetElementPtrInst(SrcPI->getPoolDesc(), Zero, Zero, + "poolbaseptrptr", &LI); + Value *BasePtr = new LoadInst(BasePtrPtr, "poolbaseptr", &LI); + + // Get the pointer to load from. + std::vector Ops; + Ops.push_back(getTransformedValue(LI.getOperand(0))); + Value *SrcPtr = new GetElementPtrInst(BasePtr, Ops, + LI.getOperand(0)->getName()+".pp", &LI); + const Type *DestTy = LoadingCompressedPtr ? Type::UIntTy : LI.getType(); + SrcPtr = new CastInst(SrcPtr, PointerType::get(DestTy), + SrcPtr->getName(), &LI); + std::string OldName = LI.getName(); LI.setName(""); + Value *NewLoad = new LoadInst(SrcPtr, OldName, &LI); + + if (LoadingCompressedPtr) { + setTransformedValue(LI, NewLoad); + } else { + LI.replaceAllUsesWith(NewLoad); + LI.eraseFromParent(); + } +} + + + void InstructionRewriter::visitStoreInst(StoreInst &SI) { const CompressedPoolInfo *DestPI = getPoolInfo(SI.getOperand(1)); if (DestPI == 0) { @@ -391,6 +435,8 @@ Value *BasePtrPtr = new GetElementPtrInst(DestPI->getPoolDesc(), Zero, Zero, "poolbaseptrptr", &SI); Value *BasePtr = new LoadInst(BasePtrPtr, "poolbaseptr", &SI); + + // Get the pointer to store to. std::vector Ops; Ops.push_back(getTransformedValue(SI.getOperand(1))); Value *DestPtr = new GetElementPtrInst(BasePtr, Ops, From lattner at cs.uiuc.edu Thu Feb 10 15:54:00 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 10 Feb 2005 15:54:00 -0600 Subject: [llvm-commits] CVS: poolalloc/lib/PoolAllocate/PointerCompress.cpp Message-ID: <200502102154.j1ALs0uS010164@apoc.cs.uiuc.edu> Changes in directory poolalloc/lib/PoolAllocate: PointerCompress.cpp updated: 1.5 -> 1.6 --- Log message: Implement comparison of compressed pointers. --- Diffs of the changes: (+22 -0) Index: poolalloc/lib/PoolAllocate/PointerCompress.cpp diff -u poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.5 poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.6 --- poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.5 Thu Feb 10 15:26:23 2005 +++ poolalloc/lib/PoolAllocate/PointerCompress.cpp Thu Feb 10 15:53:50 2005 @@ -297,6 +297,7 @@ void visitCastInst(CastInst &CI); void visitPHINode(PHINode &PN); + void visitSetCondInst(SetCondInst &SCI); void visitLoadInst(LoadInst &LI); void visitStoreInst(StoreInst &SI); @@ -364,6 +365,27 @@ setTransformedValue(PN, New); } +void InstructionRewriter::visitSetCondInst(SetCondInst &SCI) { + if (!isa(SCI.getOperand(0)->getType())) return; + Value *NonNullPtr = SCI.getOperand(0); + if (isa(NonNullPtr)) { + NonNullPtr = SCI.getOperand(1); + if (isa(NonNullPtr)) + return; // setcc null, null + } + + const CompressedPoolInfo *SrcPI = getPoolInfo(NonNullPtr); + if (SrcPI == 0) return; // comparing non-compressed pointers. + + std::string Name = SCI.getName(); SCI.setName(""); + Value *New = new SetCondInst(SCI.getOpcode(), + getTransformedValue(SCI.getOperand(0)), + getTransformedValue(SCI.getOperand(1)), + Name, &SCI); + SCI.replaceAllUsesWith(New); + SCI.eraseFromParent(); +} + void InstructionRewriter::visitLoadInst(LoadInst &LI) { if (isa(LI.getOperand(0))) return; // load null ?? From lattner at cs.uiuc.edu Thu Feb 10 17:32:59 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 10 Feb 2005 17:32:59 -0600 Subject: [llvm-commits] CVS: poolalloc/lib/PoolAllocate/PointerCompress.cpp Message-ID: <200502102332.j1ANWxj9011985@apoc.cs.uiuc.edu> Changes in directory poolalloc/lib/PoolAllocate: PointerCompress.cpp updated: 1.6 -> 1.7 --- Log message: add ability to compress to 16-bit pointers instead of just 32-bit pointers. --- Diffs of the changes: (+28 -7) Index: poolalloc/lib/PoolAllocate/PointerCompress.cpp diff -u poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.6 poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.7 --- poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.6 Thu Feb 10 15:53:50 2005 +++ poolalloc/lib/PoolAllocate/PointerCompress.cpp Thu Feb 10 17:32:49 2005 @@ -18,11 +18,22 @@ #include "llvm/Instructions.h" #include "llvm/Module.h" #include "llvm/ADT/Statistic.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/InstVisitor.h" using namespace llvm; +/// UINTTYPE - This is the actual type we are compressing to. This is really +/// only capable of being UIntTy, except when we are doing tests for 16-bit +/// integers, when it's UShortTy. +static const Type *UINTTYPE; + namespace { + cl::opt + SmallIntCompress("compress-to-16-bits", + cl::desc("Pointer compress data structures to 16 bit " + "integers instead of 32-bit integers")); + Statistic<> NumCompressed("pointercompress", "Number of pools pointer compressed"); Statistic<> NumNotCompressed("pointercompress", @@ -116,7 +127,7 @@ std::map &Nodes) { if (const PointerType *PTY = dyn_cast(OrigTy)) { // FIXME: check to see if this pointer is actually compressed! - return Type::UIntTy; + return UINTTYPE; } else if (OrigTy->isFirstClassType()) return OrigTy; @@ -243,13 +254,13 @@ /// value, creating a new forward ref value as needed. Value *getTransformedValue(Value *V) { if (isa(V)) // null -> uint 0 - return Constant::getNullValue(Type::UIntTy); + return Constant::getNullValue(UINTTYPE); assert(getNodeIfCompressed(V) && "Value is not compressed!"); Value *&RV = OldToNewValueMap[V]; if (RV) return RV; - RV = new Argument(Type::UIntTy); + RV = new Argument(UINTTYPE); return RV; } @@ -356,7 +367,7 @@ const CompressedPoolInfo *DestPI = getPoolInfo(&PN); if (DestPI == 0) return; - PHINode *New = new PHINode(Type::UIntTy, PN.getName(), &PN); + PHINode *New = new PHINode(UINTTYPE, PN.getName(), &PN); New->reserveOperandSpace(PN.getNumIncomingValues()); for (unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i) @@ -410,9 +421,11 @@ // Get the pointer to load from. std::vector Ops; Ops.push_back(getTransformedValue(LI.getOperand(0))); + if (Ops[0]->getType() == Type::UShortTy) + Ops[0] = new CastInst(Ops[0], Type::UIntTy, "extend_idx", &LI); Value *SrcPtr = new GetElementPtrInst(BasePtr, Ops, LI.getOperand(0)->getName()+".pp", &LI); - const Type *DestTy = LoadingCompressedPtr ? Type::UIntTy : LI.getType(); + const Type *DestTy = LoadingCompressedPtr ? UINTTYPE : LI.getType(); SrcPtr = new CastInst(SrcPtr, PointerType::get(DestTy), SrcPtr->getName(), &LI); std::string OldName = LI.getName(); LI.setName(""); @@ -461,6 +474,9 @@ // Get the pointer to store to. std::vector Ops; Ops.push_back(getTransformedValue(SI.getOperand(1))); + if (Ops[0]->getType() == Type::UShortTy) + Ops[0] = new CastInst(Ops[0], Type::UIntTy, "extend_idx", &SI); + Value *DestPtr = new GetElementPtrInst(BasePtr, Ops, SI.getOperand(1)->getName()+".pp", &SI); @@ -587,16 +603,21 @@ Type::UIntTy, 0); PoolDestroyPC = M.getOrInsertFunction("pooldestroy_pc", Type::VoidTy, PoolDescPtrTy, 0); - PoolAllocPC = M.getOrInsertFunction("poolalloc_pc", Type::UIntTy, + PoolAllocPC = M.getOrInsertFunction("poolalloc_pc", UINTTYPE, PoolDescPtrTy, Type::UIntTy, 0); PoolFreePC = M.getOrInsertFunction("poolfree_pc", Type::VoidTy, - PoolDescPtrTy, Type::UIntTy, 0); + PoolDescPtrTy, UINTTYPE, 0); // FIXME: Need bumppointer versions as well as realloc??/memalign?? } bool PointerCompress::runOnModule(Module &M) { PoolAlloc = &getAnalysis(); ECG = &getAnalysis(); + + if (SmallIntCompress) + UINTTYPE = Type::UShortTy; + else + UINTTYPE = Type::UIntTy; // Create the function prototypes for pointer compress runtime library // functions. From lattner at cs.uiuc.edu Thu Feb 10 22:47:12 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 10 Feb 2005 22:47:12 -0600 Subject: [llvm-commits] CVS: llvm/autoconf/configure.ac Message-ID: <200502110447.j1B4lC7H015662@apoc.cs.uiuc.edu> Changes in directory llvm/autoconf: configure.ac updated: 1.167 -> 1.168 --- Log message: The pool allocator is now the llvm-poolalloc module in public CVS --- Diffs of the changes: (+1 -1) configure.ac | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/autoconf/configure.ac diff -u llvm/autoconf/configure.ac:1.167 llvm/autoconf/configure.ac:1.168 --- llvm/autoconf/configure.ac:1.167 Mon Jan 24 11:33:52 2005 +++ llvm/autoconf/configure.ac Thu Feb 10 22:46:58 2005 @@ -75,7 +75,7 @@ "llvm-java") AC_CONFIG_SUBDIRS([projects/llvm-java]) ;; "llvm-tv") AC_CONFIG_SUBDIRS([projects/llvm-tv]) ;; "llvm-fefw") AC_CONFIG_SUBDIRS([projects/llvm-fefw]) ;; - "poolalloc") AC_CONFIG_SUBDIRS([projects/poolalloc]) ;; + "llvm-poolalloc") AC_CONFIG_SUBDIRS([projects/llvm-poolalloc]) ;; *) AC_MSG_WARN([Unknown project (${i}) won't be configured automatically]) ;; From lattner at cs.uiuc.edu Thu Feb 10 22:47:12 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 10 Feb 2005 22:47:12 -0600 Subject: [llvm-commits] CVS: llvm/configure Message-ID: <200502110447.j1B4lCwd015659@apoc.cs.uiuc.edu> Changes in directory llvm: configure updated: 1.173 -> 1.174 --- Log message: The pool allocator is now the llvm-poolalloc module in public CVS --- Diffs of the changes: (+3 -3) configure | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Index: llvm/configure diff -u llvm/configure:1.173 llvm/configure:1.174 --- llvm/configure:1.173 Mon Jan 24 11:25:41 2005 +++ llvm/configure Thu Feb 10 22:46:55 2005 @@ -438,7 +438,7 @@ ac_subdirs_all="$ac_subdirs_all projects/llvm-java" ac_subdirs_all="$ac_subdirs_all projects/llvm-tv" ac_subdirs_all="$ac_subdirs_all projects/llvm-fefw" -ac_subdirs_all="$ac_subdirs_all projects/poolalloc" +ac_subdirs_all="$ac_subdirs_all projects/llvm-poolalloc" # Factoring default headers for most tests. ac_includes_default="\ #include @@ -1603,9 +1603,9 @@ subdirs="$subdirs projects/llvm-fefw" ;; - "poolalloc") + "llvm-poolalloc") -subdirs="$subdirs projects/poolalloc" +subdirs="$subdirs projects/llvm-poolalloc" ;; *) { echo "$as_me:$LINENO: WARNING: Unknown project (${i}) won't be configured automatically" >&5 From lattner at cs.uiuc.edu Fri Feb 11 13:26:23 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 11 Feb 2005 13:26:23 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/C++Frontend/2005-02-11-AnonymousUnion.cpp Message-ID: <200502111926.j1BJQNCN019279@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/C++Frontend: 2005-02-11-AnonymousUnion.cpp added (r1.1) --- Log message: New testcase for PR501: http://llvm.cs.uiuc.edu/PR501 --- Diffs of the changes: (+32 -0) 2005-02-11-AnonymousUnion.cpp | 32 ++++++++++++++++++++++++++++++++ 1 files changed, 32 insertions(+) Index: llvm/test/Regression/C++Frontend/2005-02-11-AnonymousUnion.cpp diff -c /dev/null llvm/test/Regression/C++Frontend/2005-02-11-AnonymousUnion.cpp:1.1 *** /dev/null Fri Feb 11 13:26:17 2005 --- llvm/test/Regression/C++Frontend/2005-02-11-AnonymousUnion.cpp Fri Feb 11 13:26:06 2005 *************** *** 0 **** --- 1,32 ---- + // RUN: %llvmgxx %s -S -o - + + // Test anonymous union with members of the same size. + int test1(float F) { + union { + float G; + int i; + }; + G = F; + return i; + } + + // test anonymous union with members of differing size. + int test2(short F) { + volatile union { + short G; + int i; + }; + G = F; + return i; + } + + // Make sure that normal unions work. duh :) + volatile union { + short S; + int i; + } U; + + int test3(short s) { + U.S = s; + return U.i; + } From lattner at cs.uiuc.edu Fri Feb 11 13:26:58 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 11 Feb 2005 13:26:58 -0600 Subject: [llvm-commits] CVS: llvm-gcc/gcc/llvm-expand.c Message-ID: <200502111926.j1BJQw63019292@apoc.cs.uiuc.edu> Changes in directory llvm-gcc/gcc: llvm-expand.c updated: 1.77 -> 1.78 --- Log message: Implement support for anonymous automatic unions, fixing PR501: http://llvm.cs.uiuc.edu/PR501 and test/Regression/C++Frontend/2005-02-11-AnonymousUnion.cpp --- Diffs of the changes: (+50 -4) llvm-expand.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 50 insertions(+), 4 deletions(-) Index: llvm-gcc/gcc/llvm-expand.c diff -u llvm-gcc/gcc/llvm-expand.c:1.77 llvm-gcc/gcc/llvm-expand.c:1.78 --- llvm-gcc/gcc/llvm-expand.c:1.77 Thu Jan 13 11:16:36 2005 +++ llvm-gcc/gcc/llvm-expand.c Fri Feb 11 13:26:43 2005 @@ -2616,6 +2616,52 @@ } } +/* llvm_expand_anon_union_decl - This function, which corresponds to + * expand_anon_union_decl, expands an anonymous union. An anonymous union is + * where the user can refer to the elements as if they were defined in the same + * scope as the union itself. These appear to always be automatic variables. + */ +static void llvm_expand_anon_union_decl(llvm_function *Fn, tree decl, + tree decl_elts) { + llvm_nesting *InnermostCleanupScope = Fn->ExpandInfo->InnermostBlockScope; + llvm_value *x; + tree t; + + /* If any of the elements are addressable, so is the entire union. */ + for (t = decl_elts; t; t = TREE_CHAIN (t)) + if (TREE_ADDRESSABLE (TREE_VALUE (t))) + { + TREE_ADDRESSABLE (decl) = 1; + break; + } + + llvm_expand_decl(Fn, decl); + x = DECL_LLVM(decl); + + /* Go through the elements, assigning the LLVM location to each. */ + for (t = decl_elts; t; t = TREE_CHAIN (t)) + { + tree decl_elt = TREE_VALUE (t); + enum machine_mode mode = TYPE_MODE (TREE_TYPE (decl_elt)); + + /* If any of the elements are used, so is the entire union. */ + if (TREE_USED (decl_elt)) + TREE_USED (decl) = 1; + + /* Propagate the union's alignment to the elements. */ + DECL_ALIGN (decl_elt) = DECL_ALIGN (decl); + DECL_USER_ALIGN (decl_elt) = DECL_USER_ALIGN (decl); + + /* If the element has BLKmode and the union doesn't, the union is + aligned such that the element doesn't need to have BLKmode, so + change the element's mode to the appropriate one for its size. */ + if (mode == BLKmode && DECL_MODE (decl) != BLKmode) + DECL_MODE (decl_elt) = mode + = mode_for_size_tree (DECL_SIZE (decl_elt), MODE_INT, 1); + SET_DECL_LLVM(decl_elt, x); + } +} + /* Generate LLVM code for T, which is a DECL_STMT. */ static void genllvm_decl_stmt(llvm_function *F, tree t) { @@ -2633,10 +2679,10 @@ if (!anon_aggr_type_p (TREE_TYPE (decl))) { llvm_emit_local_var (F, decl); } else { - /* LLVM: See info about lhd_tree_inlining_anon_aggr_type_p */ - LLVM_TODO_TREE(t); - expand_anon_union_decl (decl, NULL_TREE, - DECL_ANON_UNION_ELEMS (decl)); + /* This is an anonymous aggregate object on the stack: the elements of + * this declaration are actually automatic objects themselves. + */ + llvm_expand_anon_union_decl(F, decl, DECL_ANON_UNION_ELEMS(decl)); } } else if (TREE_STATIC (decl)) { make_llvm_for_local_static(decl); From lattner at cs.uiuc.edu Fri Feb 11 13:30:08 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 11 Feb 2005 13:30:08 -0600 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200502111930.j1BJU8mA019328@apoc.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.292 -> 1.293 --- Log message: Bug fixed --- Diffs of the changes: (+3 -1) ReleaseNotes.html | 4 +++- 1 files changed, 3 insertions(+), 1 deletion(-) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.292 llvm/docs/ReleaseNotes.html:1.293 --- llvm/docs/ReleaseNotes.html:1.292 Mon Jan 31 19:33:52 2005 +++ llvm/docs/ReleaseNotes.html Fri Feb 11 13:29:52 2005 @@ -147,6 +147,8 @@
    7. [llvmgcc] llvm-gcc incorrectly rejects some constant initializers involving the addresses of array elements
    8. +
    9. [llvm-g++] Crash compiling + anonymous union
    @@ -567,7 +569,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2005/02/01 01:33:52 $ + Last modified: $Date: 2005/02/11 19:29:52 $ From lattner at cs.uiuc.edu Fri Feb 11 13:30:43 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 11 Feb 2005 13:30:43 -0600 Subject: [llvm-commits] CVS: llvm-www/releases/1.4/docs/ReleaseNotes.html Message-ID: <200502111930.j1BJUhdp019355@apoc.cs.uiuc.edu> Changes in directory llvm-www/releases/1.4/docs: ReleaseNotes.html updated: 1.9 -> 1.10 --- Log message: Bug fixed --- Diffs of the changes: (+3 -1) ReleaseNotes.html | 4 +++- 1 files changed, 3 insertions(+), 1 deletion(-) Index: llvm-www/releases/1.4/docs/ReleaseNotes.html diff -u llvm-www/releases/1.4/docs/ReleaseNotes.html:1.9 llvm-www/releases/1.4/docs/ReleaseNotes.html:1.10 --- llvm-www/releases/1.4/docs/ReleaseNotes.html:1.9 Sun Jan 2 22:21:38 2005 +++ llvm-www/releases/1.4/docs/ReleaseNotes.html Fri Feb 11 13:30:30 2005 @@ -601,6 +601,8 @@
  • [llvmgcc] llvm-gcc incorrectly rejects some constant initializers involving the addresses of array elements
  • +
  • [llvm-g++] Crash compiling + anonymous union
  • @@ -739,7 +741,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2005/01/03 04:21:38 $ + Last modified: $Date: 2005/02/11 19:30:30 $ From lattner at cs.uiuc.edu Fri Feb 11 14:09:21 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 11 Feb 2005 14:09:21 -0600 Subject: [llvm-commits] CVS: llvm-gcc/gcc/cp/typeck.c Message-ID: <200502112009.j1BK9LDF020098@apoc.cs.uiuc.edu> Changes in directory llvm-gcc/gcc/cp: typeck.c updated: 1.4 -> 1.5 --- Log message: Merge in the patch for this bugfix: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12924 --- Diffs of the changes: (+5 -0) typeck.c | 5 +++++ 1 files changed, 5 insertions(+) Index: llvm-gcc/gcc/cp/typeck.c diff -u llvm-gcc/gcc/cp/typeck.c:1.4 llvm-gcc/gcc/cp/typeck.c:1.5 --- llvm-gcc/gcc/cp/typeck.c:1.4 Mon Jan 3 16:29:15 2005 +++ llvm-gcc/gcc/cp/typeck.c Fri Feb 11 14:09:06 2005 @@ -1863,6 +1863,11 @@ is_template_id = true; template_args = TREE_OPERAND (name, 1); name = TREE_OPERAND (name, 0); + + if (TREE_CODE (name) == OVERLOAD) + name = DECL_NAME (get_first_fn (name)); + else if (DECL_P (name)) + name = DECL_NAME (name); } if (TREE_CODE (name) == SCOPE_REF) From alkis at cs.uiuc.edu Fri Feb 11 14:20:11 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 11 Feb 2005 14:20:11 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/ClassFile/ClassFile.cpp Message-ID: <200502112020.OAA17018@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/ClassFile: ClassFile.cpp updated: 1.35 -> 1.36 --- Log message: Add getConstantMemberRef method. --- Diffs of the changes: (+7 -0) ClassFile.cpp | 7 +++++++ 1 files changed, 7 insertions(+) Index: llvm-java/lib/ClassFile/ClassFile.cpp diff -u llvm-java/lib/ClassFile/ClassFile.cpp:1.35 llvm-java/lib/ClassFile/ClassFile.cpp:1.36 --- llvm-java/lib/ClassFile/ClassFile.cpp:1.35 Wed Feb 2 10:26:54 2005 +++ llvm-java/lib/ClassFile/ClassFile.cpp Fri Feb 11 14:19:16 2005 @@ -265,6 +265,13 @@ return static_cast(getConstant(index)); } +ConstantMemberRef* ClassFile::getConstantMemberRef(unsigned index) const +{ + assert(dynamic_cast(getConstant(index)) && + "Constant is not a ConstantMemberRef!"); + return static_cast(getConstant(index)); +} + ConstantFieldRef* ClassFile::getConstantFieldRef(unsigned index) const { assert(dynamic_cast(getConstant(index)) && From alkis at cs.uiuc.edu Fri Feb 11 14:20:19 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 11 Feb 2005 14:20:19 -0600 Subject: [llvm-commits] CVS: llvm-java/include/llvm/Java/ClassFile.h Message-ID: <200502112020.OAA17024@zion.cs.uiuc.edu> Changes in directory llvm-java/include/llvm/Java: ClassFile.h updated: 1.28 -> 1.29 --- Log message: Add getConstantMemberRef method. --- Diffs of the changes: (+2 -0) ClassFile.h | 2 ++ 1 files changed, 2 insertions(+) Index: llvm-java/include/llvm/Java/ClassFile.h diff -u llvm-java/include/llvm/Java/ClassFile.h:1.28 llvm-java/include/llvm/Java/ClassFile.h:1.29 --- llvm-java/include/llvm/Java/ClassFile.h:1.28 Wed Feb 2 10:26:54 2005 +++ llvm-java/include/llvm/Java/ClassFile.h Fri Feb 11 14:19:33 2005 @@ -35,6 +35,7 @@ class ConstantClass; class ConstantFieldRef; class ConstantInterfaceMethodRef; + class ConstantMemberRef; class ConstantMethodRef; class ConstantNameAndType; class ConstantUtf8; @@ -84,6 +85,7 @@ Constant* getConstant(unsigned index) const { return cPool_[index]; } ConstantClass* getConstantClass(unsigned index) const; + ConstantMemberRef* getConstantMemberRef(unsigned index) const; ConstantFieldRef* getConstantFieldRef(unsigned index) const; ConstantMethodRef* getConstantMethodRef(unsigned index) const; ConstantInterfaceMethodRef* From alkis at cs.uiuc.edu Fri Feb 11 14:25:06 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 11 Feb 2005 14:25:06 -0600 Subject: [llvm-commits] CVS: llvm-java/tools/classdump/classdump.cpp Message-ID: <200502112025.OAA17195@zion.cs.uiuc.edu> Changes in directory llvm-java/tools/classdump: classdump.cpp updated: 1.15 -> 1.16 --- Log message: Make classdump output be similar to javap -c (for debugging the bytecode parser). There are a couple of bytecodes that don't work yet, but the majority is there and a lot of classes in java/lang and java/util are already parsed completely (and correctly!). --- Diffs of the changes: (+567 -1) classdump.cpp | 568 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 567 insertions(+), 1 deletion(-) Index: llvm-java/tools/classdump/classdump.cpp diff -u llvm-java/tools/classdump/classdump.cpp:1.15 llvm-java/tools/classdump/classdump.cpp:1.16 --- llvm-java/tools/classdump/classdump.cpp:1.15 Mon Sep 13 20:04:42 2004 +++ llvm-java/tools/classdump/classdump.cpp Fri Feb 11 14:24:29 2005 @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #include +#include #include #include @@ -24,6 +25,571 @@ static cl::opt InputClass(cl::Positional, cl::desc("")); +namespace { + + using namespace llvm::Java; + + class ClassDump : public BytecodeParser { + const ClassFile* CF; + std::ostream& Out; + + public: + ClassDump(const ClassFile* cf, std::ostream& out) + : CF(cf), Out(out) { + + if (CF->isPublic()) + Out << "public "; + if (CF->isFinal()) + Out << "final "; + + Out << "class " << CF->getThisClass()->getName()->str() << ' '; + + if (ConstantClass* super = CF->getSuperClass()) + Out << "extends " << super->getName()->str() << ' '; + + if (!CF->getInterfaces().empty()) { + const Classes& interfaces = CF->getInterfaces(); + Out << "implements " << interfaces[0]->getName()->str(); + for (unsigned i = 1, e = interfaces.size(); i != e; ++i) + Out << ", " << interfaces[i]->getName()->str(); + Out << ' '; + } + Out << "{\n"; + + const Fields& fields = CF->getFields(); + // Dump static fields. + for (unsigned i = 0, e = fields.size(); i != e; ++i) + if (fields[i]->isStatic()) + dumpField(fields[i]); + // Dump instance fields. + for (unsigned i = 0, e = fields.size(); i != e; ++i) + if (!fields[i]->isStatic()) + dumpField(fields[i]); + + const Methods& methods = CF->getMethods(); + for (unsigned i = 0, e = methods.size(); i != e; ++i) + dumpMethod(methods[i]); + + Out << "\n}\n"; + } + + void dumpField(const Field* F) { + Out << '\n'; + if (F->isPublic()) + Out << "public "; + else if (F->isProtected()) + Out << "protected "; + else if (F->isPrivate()) + Out << "private "; + + if (F->isStatic()) + Out << "static "; + + if (F->isFinal()) + Out << "final "; + + Out << getPrettyString(F->getDescriptor()->str()) << ' ' + << F->getName()->str() << ";\n"; + } + + void dumpMethod(const Method* M) { + Out << '\n'; + if (M->isPublic()) + Out << "public "; + else if (M->isProtected()) + Out << "protected "; + else if (M->isPrivate()) + Out << "private "; + + if (M->isSynchronized()) + Out << "synchronized "; + + if (M->isStatic()) + Out << "static "; + + if (M->isFinal()) + Out << "final "; + + std::string Signature = getPrettyString(M->getDescriptor()->str()); + Signature.insert(Signature.find('('), M->getName()->str()); + + Out << Signature << ";\n"; + if (CodeAttribute* CodeAttr = M->getCodeAttribute()) { + Out << "\tCode:"; + parse(CodeAttr->getCode(), 0, CodeAttr->getCodeSize()); + Out << '\n'; + } + } + + std::string getPrettyString(const std::string& Desc) { + unsigned I = 0; + return getPrettyStringHelper(Desc, I); + } + + std::string getPrettyStringHelper(const std::string& Desc, unsigned& I) { + if (Desc.size() == I) + return ""; + + switch (Desc[I++]) { + case 'B': return "byte"; + case 'C': return "char"; + case 'D': return "double"; + case 'F': return "float"; + case 'I': return "int"; + case 'J': return "long"; + case 'S': return "short"; + case 'Z': return "boolean"; + case 'V': return "void"; + case 'L': { + unsigned E = Desc.find(';', I); + std::string ClassName = Desc.substr(I, E - I); + I = E + 1; + return ClassName; + } + case '[': { + std::string ArrayPart; + ArrayPart += "[]"; + while (Desc[I] == '[') { + ArrayPart += "[]"; + ++I; + } + + return getPrettyStringHelper(Desc, I) + ArrayPart; + } + case '(': { + std::string Params; + while (Desc[I] != ')') { + if (Desc[I-1] != '(') + Params += ", "; + Params += getPrettyStringHelper(Desc, I); + } + return getPrettyStringHelper(Desc, ++I) + " (" + Params + ')'; + } + } + + return ""; + } + + /// @brief called before every bytecode + void pre_inst(unsigned bcI) { Out << "\n\t " << bcI << ":\t"; } + /// @brief called on ACONST_NULL + void do_aconst_null() { Out << "aconst_null"; } + /// @brief called on ICONST_, SIPUSH and BIPUSH + void do_iconst(int value) { + if (value == -1) + Out << "iconst_m1"; + else if (value >=0 && value <= 5) + Out << "iconst_" << value; + else if (value <= 255) + Out << "bipush " << value; + else + Out << "sipush " << value; + } + /// @brief called on LCONST_ + void do_lconst(long long value) { + if (value == 0 || value == 1) + Out << "lconst_" << value; + else + Out << "lconst " << value; + } + /// @brief called on FCONST_ + void do_fconst(float value) { + if (value >= 0 && value <= 2) + Out << "fconst_" << value; + else + Out << "fconst " << value; + } + /// @brief called on DCONST_ + void do_dconst(double value) { + if (value == 0 || value == 1) + Out << "dconst_" << value; + else + Out << "dconst " << value; + } + /// @brief called on LDC and LDC_W + void do_ldc(unsigned index) { Out << "ldc \t#" << index; } + /// @brief called on LDC2_W + void do_ldc2(unsigned index) { Out << "ldc2 \t#" << index; } + /// @brief called on ILOAD and ILOAD_ + void do_iload(unsigned index) { + if (index <= 3) + Out << "iload_" << index; + else + Out << "iload " << index; + } + /// @brief called on LLOAD and LLOAD_ + void do_lload(unsigned index) { + if (index <= 3) + Out << "lload_" << index; + else + Out << "lload " << index; + } + /// @brief called on FLOAD and FLOAD_ + void do_fload(unsigned index) { + if (index <= 3) + Out << "fload_" << index; + else + Out << "fload " << index; + } + /// @brief called on DLOAD and DLOAD_ + void do_dload(unsigned index) { + if (index <= 3) + Out << "dload_" << index; + else + Out << "dload " << index; + } + /// @brief called on ALOAD and ALOAD_ + void do_aload(unsigned index) { + if (index <= 3) + Out << "aload_" << index; + else + Out << "aload " << index; + } + /// @brief called on IALOAD + void do_iaload() { Out << "iaload"; } + /// @brief called on LALOAD + void do_laload() { Out << "laload"; } + /// @brief called on FALOAD + void do_faload() { Out << "faload"; } + /// @brief called on DALOAD + void do_daload() { Out << "daload"; } + /// @brief called on AALOAD + void do_aaload() { Out << "aaload"; } + /// @brief called on BALOAD + void do_baload() { Out << "baload"; } + /// @brief called on CALOAD + void do_caload() { Out << "caload"; } + /// @brief called on SALOAD + void do_saload() { Out << "saload"; } + /// @brief called on ISTORE and ISTORE_ + void do_istore(unsigned index) { + if (index <= 3) + Out << "istore_" << index; + else + Out << "istore " << index; + } + /// @brief called on LSTORE and LSTORE_ + void do_lstore(unsigned index) { + if (index <= 3) + Out << "lstore_" << index; + else + Out << "lstore " << index; + } + /// @brief called on FSTORE and FSTORE_ + void do_fstore(unsigned index) { + if (index <= 3) + Out << "fstore_" << index; + else + Out << "fstore " << index; + } + /// @brief called on DSTORE and DSTORE_ + void do_dstore(unsigned index) { + if (index <= 3) + Out << "dstore_" << index; + else + Out << "dstore " << index; + } + /// @brief called on ASTORE and ASTORE_ + void do_astore(unsigned index) { + if (index <= 3) + Out << "astore_" << index; + else + Out << "astore " << index; + } + /// @brief called on IASTORE + void do_iastore() { Out << "iastore"; } + /// @brief called on LASTORE + void do_lastore() { Out << "lastore"; } + /// @brief called on FASTORE + void do_fastore() { Out << "fastore"; } + /// @brief called on DASTORE + void do_dastore() { Out << "dastore"; } + /// @brief called on AASTORE + void do_aastore() { Out << "aastore"; } + /// @brief called on BASTORE + void do_bastore() { Out << "bastore"; } + /// @brief called on CASTORE + void do_castore() { Out << "castore"; } + /// @brief called on SASTORE + void do_sastore() { Out << "sastore"; } + /// @brief called on POP + void do_pop() { Out << "pop"; } + /// @brief called on POP2 + void do_pop2() { Out << "pop2"; } + /// @brief called on DUP + void do_dup() { Out << "dup"; } + /// @brief called on DUP_X1 + void do_dup_x1() { Out << "dup_x1"; } + /// @brief called on DUP_X2 + void do_dup_x2() { Out << "dup_x2"; } + /// @brief called on DUP2 + void do_dup2() { Out << "dup2"; } + /// @brief called on DUP2_X1 + void do_dup2_x1() { Out << "dup2_x1"; } + /// @brief called on DUP2_X2 + void do_dup2_x2() { Out << "dup2_x2"; } + /// @brief called on SWAP + void do_swap() { Out << "swap"; } + /// @brief called on IADD + void do_iadd() { Out << "iadd"; } + /// @brief called on LADD + void do_ladd() { Out << "ladd"; } + /// @brief called on FADD + void do_fadd() { Out << "fadd"; } + /// @brief called on DADD + void do_dadd() { Out << "dadd"; } + /// @brief called on ISUB + void do_isub() { Out << "isub"; } + /// @brief called on LSUB + void do_lsub() { Out << "lsub"; } + /// @brief called on FSUB + void do_fsub() { Out << "fsub"; } + /// @brief called on DSUB + void do_dsub() { Out << "dsub"; } + /// @brief called on IMUL + void do_imul() { Out << "imul"; } + /// @brief called on LMUL + void do_lmul() { Out << "lmul"; } + /// @brief called on FMUL + void do_fmul() { Out << "fmul"; } + /// @brief called on DMUL + void do_dmul() { Out << "dmul"; } + /// @brief called on IDIV + void do_idiv() { Out << "idiv"; } + /// @brief called on LDIV + void do_ldiv() { Out << "ldiv"; } + /// @brief called on FDIV + void do_fdiv() { Out << "fdiv"; } + /// @brief called on DDIV + void do_ddiv() { Out << "ddiv"; } + /// @brief called on IREM + void do_irem() { Out << "irem"; } + /// @brief called on LREM + void do_lrem() { Out << "lrem"; } + /// @brief called on FREM + void do_frem() { Out << "frem"; } + /// @brief called on DREM + void do_drem() { Out << "drem"; } + /// @brief called on INEG + void do_ineg() { Out << "ineg"; } + /// @brief called on LNEG + void do_lneg() { Out << "lneg"; } + /// @brief called on FNEG + void do_fneg() { Out << "fneg"; } + /// @brief called on DNEG + void do_dneg() { Out << "dneg"; } + /// @brief called on ISHL + void do_ishl() { Out << "ishl"; } + /// @brief called on LSHL + void do_lshl() { Out << "lshl"; } + /// @brief called on ISHR + void do_ishr() { Out << "ishr"; } + /// @brief called on LSHR + void do_lshr() { Out << "lshr"; } + /// @brief called on IUSHR + void do_iushr() { Out << "iushr"; } + /// @brief called on LUSHR + void do_lushr() { Out << "lushr"; } + /// @brief called on IAND + void do_iand() { Out << "iand"; } + /// @brief called on LAND + void do_land() { Out << "land"; } + /// @brief called on IOR + void do_ior() { Out << "ior"; } + /// @brief called on LOR + void do_lor() { Out << "lor"; } + /// @brief called on IXOR + void do_ixor() { Out << "ixor"; } + /// @brief called on LXOR + void do_lxor() { Out << "lxor"; } + /// @brief called on IINC + void do_iinc(unsigned index, int amount) { + Out << "iinc " << index << ", " << amount; + } + /// @brief called on I2L + void do_i2l() { Out << "i2l"; } + /// @brief called on I2F + void do_i2f() { Out << "i2f"; } + /// @brief called on I2D + void do_i2d() { Out << "i2d"; } + /// @brief called on L2I + void do_l2i() { Out << "l2i"; } + /// @brief called on L2F + void do_l2f() { Out << "l2f"; } + /// @brief called on L2D + void do_l2d() { Out << "l2d"; } + /// @brief called on F2I + void do_f2i() { Out << "f2i"; } + /// @brief called on F2L + void do_f2l() { Out << "f2l"; } + /// @brief called on F2D + void do_f2d() { Out << "f2d"; } + /// @brief called on D2I + void do_d2i() { Out << "d2i"; } + /// @brief called on D2L + void do_d2l() { Out << "d2l"; } + /// @brief called on D2F + void do_d2f() { Out << "d2f"; } + /// @brief called on I2B + void do_i2b() { Out << "i2b"; } + /// @brief called on I2C + void do_i2c() { Out << "i2c"; } + /// @brief called on I2S + void do_i2s() { Out << "i2s"; } + /// @brief called on LCMP + void do_lcmp() { Out << "lcmp"; } + /// @brief called on FCMPL + void do_fcmpl() { Out << "fcmpl"; } + /// @brief called on DCMPL + void do_dcmpl() { Out << "dcmpl"; } + /// @brief called on FCMPG + void do_fcmpg() { Out << "fcmpg"; } + /// @brief called on DCMPG + void do_dcmpg() { Out << "dcmpg"; } + /// @brief called on IFEQ + void do_ifeq(unsigned t, unsigned f) { Out << "ifeq " << t; } + /// @brief called on IFNE + void do_ifne(unsigned t, unsigned f) { Out << "ifne " << t; } + /// @brief called on IFLT + void do_iflt(unsigned t, unsigned f) { Out << "iflt " << t; } + /// @brief called on IFGE + void do_ifge(unsigned t, unsigned f) { Out << "ifge " << t; } + /// @brief called on IFGT + void do_ifgt(unsigned t, unsigned f) { Out << "ifgt " << t; } + /// @brief called on IFLE + void do_ifle(unsigned t, unsigned f) { Out << "ifle " << t; } + /// @brief called on IF_ICMPEQ + void do_if_icmpeq(unsigned t, unsigned f) { Out << "if_icmpeq " << t; } + /// @brief called on IF_ICMPNE + void do_if_icmpne(unsigned t, unsigned f) { Out << "if_icmpne " << t; } + /// @brief called on IF_ICMPLT + void do_if_icmplt(unsigned t, unsigned f) { Out << "if_icmplt " << t; } + /// @brief called on IF_ICMPGE + void do_if_icmpge(unsigned t, unsigned f) { Out << "if_icmpge " << t; } + /// @brief called on IF_ICMPGT + void do_if_icmpgt(unsigned t, unsigned f) { Out << "if_icmpgt " << t; } + /// @brief called on IF_ICMPLE + void do_if_icmple(unsigned t, unsigned f) { Out << "if_icmple " << t; } + /// @brief called on IF_ACMPEQ + void do_if_acmpeq(unsigned t, unsigned f) { Out << "if_acmpeq " << t; } + /// @brief called on IF_ACMPNE + void do_if_acmpne(unsigned t, unsigned f) { Out << "if_acmpne " << t; } + /// @brief called on GOTO and GOTO_W + void do_goto(unsigned target) { Out << "goto " << target; } + /// @brief called on JSR and JSR_W + void do_jsr(unsigned target, unsigned retAddress) { abort(); } + /// @brief called on RET + void do_ret(unsigned index) { abort(); } + /// @brief called on TABLESWITCH and LOOKUPSWITCH + void do_switch(unsigned defTarget, const SwitchCases& sw) { abort(); } + /// @brief called on IRETURN + void do_ireturn() { Out << "ireturn"; } + /// @brief called on LRETURN + void do_lreturn() { Out << "lreturn"; } + /// @brief called on FRETURN + void do_freturn() { Out << "freturn"; } + /// @brief called on DRETURN + void do_dreturn() { Out << "dreturn"; } + /// @brief called on ARETURN + void do_areturn() { Out << "areturn"; } + /// @brief called on RETURN + void do_return() { Out << "return"; } + /// @brief called on GETSTATIC + void do_getstatic(unsigned index) { + Out << "getstatic #" << index << "; //Field "; + printMemberRef(index); + } + /// @brief called on PUTSTATIC + void do_putstatic(unsigned index) { + Out << "putstatic #" << index << "; //Field "; + printMemberRef(index); + } + /// @brief called on GETFIELD + void do_getfield(unsigned index) { + Out << "getfield #" << index << "; //Field "; + printMemberRef(index); + } + /// @brief called on PUTFIELD + void do_putfield(unsigned index) { + Out << "putfield #" << index << "; //Field "; + printMemberRef(index); + } + /// @brief called on INVOKEVIRTUAL + void do_invokevirtual(unsigned index) { + Out << "invokevirtual #" << index << "; //Method "; + printMemberRef(index); + } + /// @brief called on INVOKESPECIAL + void do_invokespecial(unsigned index) { + Out << "invokespecial #" << index << "; //Method "; + printMemberRef(index); + } + /// @brief called on INVOKESTATIC + void do_invokestatic(unsigned index) { + Out << "invokestatic #" << index << "; //Method "; + printMemberRef(index); + } + /// @brief called on INVOKEINTERFACE + void do_invokeinterface(unsigned index) { + Out << "invokeinterface #" << index << "; //InterfaceMethod "; + printMemberRef(index); + } + /// @brief called on NEW + void do_new(unsigned index) { + Out << "new #" << index << "; //class "; + printClassRef(index); + } + /// @brief called on NEWARRAY + void do_newarray(JType type) { Out << "newarray #" << type; abort(); } + /// @brief called on ANEWARRAY + void do_anewarray(unsigned index) { + Out << "anewarray #" << index << "; //class "; + printClassRef(index); + } + /// @brief called on ARRAYLENGTH + void do_arraylength() { Out << "arraylength"; } + /// @brief called on ATHROW + void do_athrow() { Out << "athrow"; } + /// @brief called on CHECKCAST + void do_checkcast(unsigned index) { + Out << "checkcast #" << index + << "; //class "; + printClassRef(index); + } + /// @brief called on INSTANCEOF + void do_instanceof(unsigned index) { + Out << "instanceof #" << index + << "; //class "; + printClassRef(index); + } + /// @brief called on MONITORENTER + void do_monitorenter() { Out << "monitorenter"; } + /// @brief called on MONITOREXIT + void do_monitorexit() { Out << "monitorexit"; } + /// @brief called on MULTIANEWARRAY + void do_multianewarray(unsigned index, unsigned dims) { } + /// @brief called on IFNULL + void do_ifnull(unsigned t, unsigned f) { Out << "ifnull " << t; } + /// @brief called on IFNONNULL + void do_ifnonnull(unsigned t, unsigned f) { Out << "ifnonnull " << t; } + + void printMemberRef(unsigned index) { + ConstantMemberRef* Ref = CF->getConstantMemberRef(index); + ConstantClass* Class = Ref->getClass(); + if (Class != CF->getThisClass()) + Out << Class->getName()->str() << '.'; + Out << Ref->getNameAndType()->getName()->str() + << ':' + << Ref->getNameAndType()->getDescriptor()->str(); + } + + void printClassRef(unsigned index) { + const std::string& FQCN = CF->getConstantClass(index)->getName()->str(); + Out << FQCN.substr(FQCN.rfind('/')+1); + } + }; +} + int main(int argc, char* argv[]) { sys::PrintStackTraceOnErrorSignal(); @@ -33,7 +599,7 @@ try { const Java::ClassFile* cf(Java::ClassFile::get(InputClass)); - cf->dump(std::cout); + ClassDump(cf, std::cout); } catch (std::exception& e) { std::cerr << e.what() << '\n'; From lattner at cs.uiuc.edu Fri Feb 11 15:17:42 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 11 Feb 2005 15:17:42 -0600 Subject: [llvm-commits] CVS: llvm/docs/CFEBuildInstrs.html Message-ID: <200502112117.j1BLHgMN003564@apoc.cs.uiuc.edu> Changes in directory llvm/docs: CFEBuildInstrs.html updated: 1.43 -> 1.44 --- Log message: Slightly expand on the instructions. --- Diffs of the changes: (+4 -2) CFEBuildInstrs.html | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) Index: llvm/docs/CFEBuildInstrs.html diff -u llvm/docs/CFEBuildInstrs.html:1.43 llvm/docs/CFEBuildInstrs.html:1.44 --- llvm/docs/CFEBuildInstrs.html:1.43 Fri Dec 31 13:48:59 2004 +++ llvm/docs/CFEBuildInstrs.html Fri Feb 11 15:17:26 2005 @@ -126,7 +126,9 @@ % set path = ( `cd llvm/Debug/bin && pwd` $path ) -
  • Unpack the C/C++ front-end source into cfrontend/src.

  • +
  • Unpack the C/C++ front-end source into cfrontend/src, either by + untar'ing an llvm-gcc.tar.gz file or checking out CVS into this + directory.

  • Make "build" and "install" directories as siblings of the "src" tree.

    @@ -343,7 +345,7 @@
     
       Brian Gaeke
    LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/12/31 19:48:59 $ + Last modified: $Date: 2005/02/11 21:17:26 $ From lattner at cs.uiuc.edu Fri Feb 11 17:08:50 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 11 Feb 2005 17:08:50 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Linker/2005-02-11-ConstantGlobals.ll Message-ID: <200502112308.j1BN8oH6004665@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Linker: 2005-02-11-ConstantGlobals.ll added (r1.1) --- Log message: New testcase that manyoso found compiling QT 4.0. --- Diffs of the changes: (+8 -0) 2005-02-11-ConstantGlobals.ll | 8 ++++++++ 1 files changed, 8 insertions(+) Index: llvm/test/Regression/Linker/2005-02-11-ConstantGlobals.ll diff -c /dev/null llvm/test/Regression/Linker/2005-02-11-ConstantGlobals.ll:1.1 *** /dev/null Fri Feb 11 17:08:44 2005 --- llvm/test/Regression/Linker/2005-02-11-ConstantGlobals.ll Fri Feb 11 17:08:34 2005 *************** *** 0 **** --- 1,8 ---- + ; Test that a prototype can be marked const, and the definition is allowed + ; to be nonconst. + + ; RUN: echo "%X = global int 7" | llvm-as > %t.2.bc + ; RUN: llvm-as < %s > %t.1.bc + ; RUN: llvm-link %t.[12].bc | llvm-dis | grep constant + + %X = external constant int From alkis at cs.uiuc.edu Fri Feb 11 17:18:54 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 11 Feb 2005 17:18:54 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/ClassFile/ClassFile.cpp Message-ID: <200502112318.RAA20320@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/ClassFile: ClassFile.cpp updated: 1.36 -> 1.37 --- Log message: Better support for new classdump. --- Diffs of the changes: (+5 -5) ClassFile.cpp | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) Index: llvm-java/lib/ClassFile/ClassFile.cpp diff -u llvm-java/lib/ClassFile/ClassFile.cpp:1.36 llvm-java/lib/ClassFile/ClassFile.cpp:1.37 --- llvm-java/lib/ClassFile/ClassFile.cpp:1.36 Fri Feb 11 14:19:16 2005 +++ llvm-java/lib/ClassFile/ClassFile.cpp Fri Feb 11 17:18:43 2005 @@ -457,7 +457,7 @@ std::ostream& ConstantString::dump(std::ostream& os) const { - return os << "string " << *getValue(); + return os << "String " << *getValue(); } ConstantInteger::ConstantInteger(const ConstantPool& cp, std::istream& is) @@ -469,7 +469,7 @@ std::ostream& ConstantInteger::dump(std::ostream& os) const { - return os << value_; + return os << "int " << value_; } ConstantFloat::ConstantFloat(const ConstantPool& cp, std::istream& is) @@ -481,7 +481,7 @@ std::ostream& ConstantFloat::dump(std::ostream& os) const { - return os << value_; + return os << "float " << value_; } ConstantLong::ConstantLong(const ConstantPool& cp, std::istream& is) @@ -493,7 +493,7 @@ std::ostream& ConstantLong::dump(std::ostream& os) const { - return os << value_; + return os << "long " << value_; } ConstantDouble::ConstantDouble(const ConstantPool& cp, std::istream& is) @@ -505,7 +505,7 @@ std::ostream& ConstantDouble::dump(std::ostream& os) const { - return os << value_; + return os << "double " << value_; } ConstantNameAndType::ConstantNameAndType(const ConstantPool& cp, From lattner at cs.uiuc.edu Fri Feb 11 17:18:56 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 11 Feb 2005 17:18:56 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Linker/2005-02-11-ConstantGlobals.ll Message-ID: <200502112318.j1BNIuC2004692@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Linker: 2005-02-11-ConstantGlobals.ll (r1.1) removed --- Log message: Actually, this testcase is invalid, the bug is in the C++ FE. --- Diffs of the changes: (+0 -0) 0 files changed From alkis at cs.uiuc.edu Fri Feb 11 17:19:32 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 11 Feb 2005 17:19:32 -0600 Subject: [llvm-commits] CVS: llvm-java/test/Makefile.test Message-ID: <200502112319.RAA20346@zion.cs.uiuc.edu> Changes in directory llvm-java/test: Makefile.test updated: 1.39 -> 1.40 --- Log message: Add stubs to raw llvm.bc files as well. --- Diffs of the changes: (+4 -2) Makefile.test | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) Index: llvm-java/test/Makefile.test diff -u llvm-java/test/Makefile.test:1.39 llvm-java/test/Makefile.test:1.40 --- llvm-java/test/Makefile.test:1.39 Tue Feb 8 13:56:15 2005 +++ llvm-java/test/Makefile.test Fri Feb 11 17:19:21 2005 @@ -25,9 +25,11 @@ -$(Verb)$(MV) -f $*.stubbed.llvm.bc $*.llvm.bc # rule to link raw bytecode with runtime -%.raw.llvm %.raw.llvm.bc: %.raw.bc $(LibDir)/libjrt.bca $(EXTRA_OBJS) $(LOPT) - $(Echo) Linking $< with the Java runtime +%.raw.llvm %.raw.llvm.bc: %.linked.bc $(LibDir)/libjrt.bca $(EXTRA_OBJS) $(LOPT) + $(Echo) Linking $< with the Java runtime \(no optimizations\) -$(Verb)$(GCCLD) -disable-opt -o=$*.raw.llvm $< -L $(CFERuntimeLibDir) -L $(LibDir) $(EXTRA_OBJS) + -$(Verb)$(LOPT) -load $(LibDir)/LLVMJavaTransforms -addstubs -f -o=$*.stubbed.raw.llvm.bc $*.raw.llvm.bc + -$(Verb)$(MV) -f $*.stubbed.raw.llvm.bc $*.raw.llvm.bc # add function trace code %.tracef.llvm %.tracef.llvm.bc: %.llvm %.llvm.bc $(LOPT) From alkis at cs.uiuc.edu Fri Feb 11 17:20:42 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 11 Feb 2005 17:20:42 -0600 Subject: [llvm-commits] CVS: llvm-java/tools/classdump/classdump.cpp Message-ID: <200502112320.RAA20392@zion.cs.uiuc.edu> Changes in directory llvm-java/tools/classdump: classdump.cpp updated: 1.16 -> 1.17 --- Log message: Small fixes. --- Diffs of the changes: (+40 -9) classdump.cpp | 49 ++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 40 insertions(+), 9 deletions(-) Index: llvm-java/tools/classdump/classdump.cpp diff -u llvm-java/tools/classdump/classdump.cpp:1.16 llvm-java/tools/classdump/classdump.cpp:1.17 --- llvm-java/tools/classdump/classdump.cpp:1.16 Fri Feb 11 14:24:29 2005 +++ llvm-java/tools/classdump/classdump.cpp Fri Feb 11 17:20:31 2005 @@ -88,6 +88,9 @@ if (F->isFinal()) Out << "final "; + if (F->isTransient()) + Out << "transient "; + Out << getPrettyString(F->getDescriptor()->str()) << ' ' << F->getName()->str() << ";\n"; } @@ -101,15 +104,18 @@ else if (M->isPrivate()) Out << "private "; - if (M->isSynchronized()) - Out << "synchronized "; - if (M->isStatic()) Out << "static "; + if (M->isAbstract()) + Out << "abstract "; + if (M->isFinal()) Out << "final "; + if (M->isSynchronized()) + Out << "synchronized "; + std::string Signature = getPrettyString(M->getDescriptor()->str()); Signature.insert(Signature.find('('), M->getName()->str()); @@ -123,7 +129,11 @@ std::string getPrettyString(const std::string& Desc) { unsigned I = 0; - return getPrettyStringHelper(Desc, I); + std::string prettyString = getPrettyStringHelper(Desc, I); + for (unsigned i = 0, e = prettyString.size(); i != e; ++i) + if (prettyString[i] == '/') + prettyString[i] = '.'; + return prettyString; } std::string getPrettyStringHelper(const std::string& Desc, unsigned& I) { @@ -160,7 +170,7 @@ std::string Params; while (Desc[I] != ')') { if (Desc[I-1] != '(') - Params += ", "; + Params += ','; Params += getPrettyStringHelper(Desc, I); } return getPrettyStringHelper(Desc, ++I) + " (" + Params + ')'; @@ -180,7 +190,7 @@ Out << "iconst_m1"; else if (value >=0 && value <= 5) Out << "iconst_" << value; - else if (value <= 255) + else if (value >= -128 && value <= 127) Out << "bipush " << value; else Out << "sipush " << value; @@ -207,9 +217,17 @@ Out << "dconst " << value; } /// @brief called on LDC and LDC_W - void do_ldc(unsigned index) { Out << "ldc \t#" << index; } + void do_ldc(unsigned index) { + if (index <= 255) + Out << "ldc"; + else + Out << "ldc_w"; + Out << "\t#" << index << "; //" << *CF->getConstant(index); + } /// @brief called on LDC2_W - void do_ldc2(unsigned index) { Out << "ldc2 \t#" << index; } + void do_ldc2(unsigned index) { + Out << "ldc2_w \t#" << index << "; //" << *CF->getConstant(index); + } /// @brief called on ILOAD and ILOAD_ void do_iload(unsigned index) { if (index <= 3) @@ -540,7 +558,20 @@ printClassRef(index); } /// @brief called on NEWARRAY - void do_newarray(JType type) { Out << "newarray #" << type; abort(); } + void do_newarray(JType type) { + Out << "newarray "; + switch (type) { + case BOOLEAN: Out << "boolean"; break; + case CHAR: Out << "char"; break; + case FLOAT: Out << "float"; break; + case DOUBLE: Out << "byte"; break; + case SHORT: Out << "short"; break; + case INT: Out << "int"; break; + case LONG: Out << "long"; break; + default: assert(0 && "Unknown type for newarray!"); + } + } + /// @brief called on ANEWARRAY void do_anewarray(unsigned index) { Out << "anewarray #" << index << "; //class "; From alkis at cs.uiuc.edu Fri Feb 11 20:59:12 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 11 Feb 2005 20:59:12 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp BasicBlockBuilder.h Message-ID: <200502120259.UAA24622@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.218 -> 1.219 BasicBlockBuilder.h updated: 1.6 -> 1.7 --- Log message: Separate tableswitch from lookupswitch bytecodes. --- Diffs of the changes: (+18 -2) BasicBlockBuilder.h | 10 +++++++++- Compiler.cpp | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.218 llvm-java/lib/Compiler/Compiler.cpp:1.219 --- llvm-java/lib/Compiler/Compiler.cpp:1.218 Mon Feb 7 20:26:32 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Fri Feb 11 20:59:01 2005 @@ -1948,7 +1948,15 @@ // FIXME: this is currently a noop. } - void do_switch(unsigned defTarget, const SwitchCases& sw) { + void do_tableswitch(unsigned defTarget, const SwitchCases& sw) { + do_switch_common(defTarget, sw); + } + + void do_lookupswitch(unsigned defTarget, const SwitchCases& sw) { + do_switch_common(defTarget, sw); + } + + void do_switch_common(unsigned defTarget, const SwitchCases& sw) { Value* v = pop(Type::IntTy); SwitchInst* in = new SwitchInst(v, bbBuilder_->getBasicBlock(defTarget), sw.size(), Index: llvm-java/lib/Compiler/BasicBlockBuilder.h diff -u llvm-java/lib/Compiler/BasicBlockBuilder.h:1.6 llvm-java/lib/Compiler/BasicBlockBuilder.h:1.7 --- llvm-java/lib/Compiler/BasicBlockBuilder.h:1.6 Sat Feb 5 15:10:57 2005 +++ llvm-java/lib/Compiler/BasicBlockBuilder.h Fri Feb 11 20:59:01 2005 @@ -161,7 +161,7 @@ getOrCreateBasicBlockAt(t); } - void do_switch(unsigned defTarget, const SwitchCases& sw) { + void do_switch_common(unsigned defTarget, const SwitchCases& sw) { for (unsigned i = 0, e = sw.size(); i != e; ++i) { unsigned target = sw[i].second; getOrCreateBasicBlockAt(target); @@ -169,6 +169,14 @@ getOrCreateBasicBlockAt(defTarget); } + void do_tableswitch(unsigned defTarget, const SwitchCases& sw) { + do_switch_common(defTarget, sw); + } + + void do_lookupswitch(unsigned defTarget, const SwitchCases& sw) { + do_switch_common(defTarget, sw); + } + void do_goto(unsigned target) { getOrCreateBasicBlockAt(target); } From alkis at cs.uiuc.edu Fri Feb 11 20:59:12 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 11 Feb 2005 20:59:12 -0600 Subject: [llvm-commits] CVS: llvm-java/include/llvm/Java/BytecodeParser.h Message-ID: <200502120259.UAA24626@zion.cs.uiuc.edu> Changes in directory llvm-java/include/llvm/Java: BytecodeParser.h updated: 1.15 -> 1.16 --- Log message: Separate tableswitch from lookupswitch bytecodes. --- Diffs of the changes: (+6 -4) BytecodeParser.h | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) Index: llvm-java/include/llvm/Java/BytecodeParser.h diff -u llvm-java/include/llvm/Java/BytecodeParser.h:1.15 llvm-java/include/llvm/Java/BytecodeParser.h:1.16 --- llvm-java/include/llvm/Java/BytecodeParser.h:1.15 Fri Feb 4 13:52:50 2005 +++ llvm-java/include/llvm/Java/BytecodeParser.h Fri Feb 11 20:59:01 2005 @@ -518,7 +518,7 @@ while (low <= high) switchCases_.push_back( std::make_pair(low++, curBC + readSInt(code, i))); - THIS->do_switch(curBC + def, switchCases_); + THIS->do_tableswitch(curBC + def, switchCases_); break; } case LOOKUPSWITCH: { @@ -532,7 +532,7 @@ switchCases_.push_back( std::make_pair(value, curBC + readSInt(code, i))); } - THIS->do_switch(curBC + def, switchCases_); + THIS->do_lookupswitch(curBC + def, switchCases_); break; } case IRETURN: @@ -885,8 +885,10 @@ void do_jsr(unsigned target, unsigned retAddress) { } /// @brief called on RET void do_ret(unsigned index) { } - /// @brief called on TABLESWITCH and LOOKUPSWITCH - void do_switch(unsigned defTarget, const SwitchCases& sw) { } + /// @brief called on TABLESWITCH + void do_tableswitch(unsigned defTarget, const SwitchCases& sw) { } + /// @brief called on LOOKUPSWITCH + void do_lookupswitch(unsigned defTarget, const SwitchCases& sw) { } /// @brief called on IRETURN void do_ireturn() { } /// @brief called on LRETURN From alkis at cs.uiuc.edu Fri Feb 11 21:01:48 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 11 Feb 2005 21:01:48 -0600 Subject: [llvm-commits] CVS: llvm-java/tools/classdump/classdump.cpp Message-ID: <200502120301.VAA24744@zion.cs.uiuc.edu> Changes in directory llvm-java/tools/classdump: classdump.cpp updated: 1.17 -> 1.18 --- Log message: Separate tableswitch from lookupswitch bytecodes. --- Diffs of the changes: (+4 -2) classdump.cpp | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) Index: llvm-java/tools/classdump/classdump.cpp diff -u llvm-java/tools/classdump/classdump.cpp:1.17 llvm-java/tools/classdump/classdump.cpp:1.18 --- llvm-java/tools/classdump/classdump.cpp:1.17 Fri Feb 11 17:20:31 2005 +++ llvm-java/tools/classdump/classdump.cpp Fri Feb 11 21:01:37 2005 @@ -498,8 +498,10 @@ void do_jsr(unsigned target, unsigned retAddress) { abort(); } /// @brief called on RET void do_ret(unsigned index) { abort(); } - /// @brief called on TABLESWITCH and LOOKUPSWITCH - void do_switch(unsigned defTarget, const SwitchCases& sw) { abort(); } + /// @brief called on TABLESWITCH + void do_tableswitch(unsigned defTarget, const SwitchCases& sw) { abort(); } + /// @brief called on LOOKUPSWITCH + void do_lookupswitch(unsigned defTarget, const SwitchCases& sw) { abort(); } /// @brief called on IRETURN void do_ireturn() { Out << "ireturn"; } /// @brief called on LRETURN From lattner at cs.uiuc.edu Fri Feb 11 21:26:45 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 11 Feb 2005 21:26:45 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/IndVarsSimplify/2005-02-11-InvokeCrash.ll Message-ID: <200502120326.j1C3QjGA005855@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/IndVarsSimplify: 2005-02-11-InvokeCrash.ll added (r1.1) --- Log message: new testcase for PR504: http://llvm.cs.uiuc.edu/PR504 --- Diffs of the changes: (+22 -0) 2005-02-11-InvokeCrash.ll | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+) Index: llvm/test/Regression/Transforms/IndVarsSimplify/2005-02-11-InvokeCrash.ll diff -c /dev/null llvm/test/Regression/Transforms/IndVarsSimplify/2005-02-11-InvokeCrash.ll:1.1 *** /dev/null Fri Feb 11 21:26:40 2005 --- llvm/test/Regression/Transforms/IndVarsSimplify/2005-02-11-InvokeCrash.ll Fri Feb 11 21:26:30 2005 *************** *** 0 **** --- 1,22 ---- + ; RUN: llvm-as < %s | opt -indvars -disable-output + + void %_ZN5ArrayISt7complexIdEEC2ERK10dim_vector() { + entry: + %tmp.7 = invoke int %_ZN5ArrayISt7complexIdEE8get_sizeERK10dim_vector( ) + to label %invoke_cont.0 unwind label %cond_true.1 ; [#uses=2] + + cond_true.1: ; preds = %entry + unwind + + invoke_cont.0: ; preds = %entry + %tmp.4.i = cast int %tmp.7 to uint ; [#uses=0] + %tmp.14.0.i5 = add int %tmp.7, -1 ; [#uses=1] + br label %no_exit.i + + no_exit.i: ; preds = %no_exit.i, %invoke_cont.0 + %tmp.14.0.i.0 = phi int [ %tmp.14.0.i, %no_exit.i ], [ %tmp.14.0.i5, %invoke_cont.0 ] ; [#uses=1] + %tmp.14.0.i = add int %tmp.14.0.i.0, -1 ; [#uses=1] + br label %no_exit.i + } + + declare int %_ZN5ArrayISt7complexIdEE8get_sizeERK10dim_vector() From lattner at cs.uiuc.edu Fri Feb 11 21:27:01 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 11 Feb 2005 21:27:01 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp Message-ID: <200502120327.j1C3R1C1005866@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: IndVarSimplify.cpp updated: 1.74 -> 1.75 --- Log message: Fix for testcase Transforms/IndVarsSimplify/2005-02-11-InvokeCrash.ll and PR504: http://llvm.cs.uiuc.edu/PR504 . --- Diffs of the changes: (+2 -0) IndVarSimplify.cpp | 2 ++ 1 files changed, 2 insertions(+) Index: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp diff -u llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.74 llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.75 --- llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.74 Wed Oct 27 11:12:28 2004 +++ llvm/lib/Transforms/Scalar/IndVarSimplify.cpp Fri Feb 11 21:26:49 2005 @@ -133,6 +133,8 @@ if ((*UI)->getType() == Ty) if (CastInst *CI = dyn_cast(cast(*UI))) { BasicBlock::iterator It = I; ++It; + if (isa(I)) + It = cast(I)->getNormalDest()->begin(); while (isa(It)) ++It; if (It != BasicBlock::iterator(CI)) { // Splice the cast immediately after the operand in question. From lattner at cs.uiuc.edu Sat Feb 12 00:43:01 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 12 Feb 2005 00:43:01 -0600 Subject: [llvm-commits] CVS: llvm-gcc/gcc/cp/init.c Message-ID: <200502120643.j1C6h1Dg007956@apoc.cs.uiuc.edu> Changes in directory llvm-gcc/gcc/cp: init.c updated: 1.1.1.2 -> 1.2 --- Log message: Don't ICE when handling "extern Java" classes. --- Diffs of the changes: (+4 -1) init.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletion(-) Index: llvm-gcc/gcc/cp/init.c diff -u llvm-gcc/gcc/cp/init.c:1.1.1.2 llvm-gcc/gcc/cp/init.c:1.2 --- llvm-gcc/gcc/cp/init.c:1.1.1.2 Tue Jan 13 10:49:37 2004 +++ llvm-gcc/gcc/cp/init.c Sat Feb 12 00:42:46 2005 @@ -1866,7 +1866,10 @@ DECL_ARTIFICIAL (class_decl) = 1; DECL_IGNORED_P (class_decl) = 1; pushdecl_top_level (class_decl); - make_decl_rtl (class_decl, NULL); + if (EMIT_LLVM) + llvm_make_decl_llvm(class_decl, NULL); + else + make_decl_rtl (class_decl, NULL); } return class_decl; } From alkis at cs.uiuc.edu Sat Feb 12 12:44:33 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 12 Feb 2005 12:44:33 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/ClassFile/ClassFile.cpp Message-ID: <200502121844.MAA24559@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/ClassFile: ClassFile.cpp updated: 1.37 -> 1.38 --- Log message: Match javap output. --- Diffs of the changes: (+1 -1) ClassFile.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm-java/lib/ClassFile/ClassFile.cpp diff -u llvm-java/lib/ClassFile/ClassFile.cpp:1.37 llvm-java/lib/ClassFile/ClassFile.cpp:1.38 --- llvm-java/lib/ClassFile/ClassFile.cpp:1.37 Fri Feb 11 17:18:43 2005 +++ llvm-java/lib/ClassFile/ClassFile.cpp Sat Feb 12 12:43:54 2005 @@ -493,7 +493,7 @@ std::ostream& ConstantLong::dump(std::ostream& os) const { - return os << "long " << value_; + return os << "long " << value_ << 'l'; } ConstantDouble::ConstantDouble(const ConstantPool& cp, std::istream& is) From lattner at cs.uiuc.edu Sat Feb 12 13:02:45 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 12 Feb 2005 13:02:45 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/C++Frontend/2004-10-04-ExternalGlobalConstant.cpp.tr Message-ID: <200502121902.j1CJ2jHA009502@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/C++Frontend: 2004-10-04-ExternalGlobalConstant.cpp.tr (r1.1) removed --- Log message: This test is invalid --- Diffs of the changes: (+0 -0) 0 files changed From alkis at cs.uiuc.edu Sat Feb 12 13:06:02 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 12 Feb 2005 13:06:02 -0600 Subject: [llvm-commits] CVS: llvm-java/tools/classdump/classdump.cpp Message-ID: <200502121906.NAA27041@zion.cs.uiuc.edu> Changes in directory llvm-java/tools/classdump: classdump.cpp updated: 1.18 -> 1.19 --- Log message: Implement tableswitch. Fix a bug in newarray. --- Diffs of the changes: (+8 -2) classdump.cpp | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) Index: llvm-java/tools/classdump/classdump.cpp diff -u llvm-java/tools/classdump/classdump.cpp:1.18 llvm-java/tools/classdump/classdump.cpp:1.19 --- llvm-java/tools/classdump/classdump.cpp:1.18 Fri Feb 11 21:01:37 2005 +++ llvm-java/tools/classdump/classdump.cpp Sat Feb 12 13:05:16 2005 @@ -499,7 +499,12 @@ /// @brief called on RET void do_ret(unsigned index) { abort(); } /// @brief called on TABLESWITCH - void do_tableswitch(unsigned defTarget, const SwitchCases& sw) { abort(); } + void do_tableswitch(unsigned defTarget, const SwitchCases& sw) { + Out << "tableswitch{ //" << sw.front().first << " to " << sw.back().first; + for (unsigned i = 0, e = sw.size(); i != e; ++i) + Out << "\n\t\t\t" << sw[i].first << ": " << sw[i].second << ';'; + Out << ";\n\t\t\tdefault: " << defTarget << " }"; + } /// @brief called on LOOKUPSWITCH void do_lookupswitch(unsigned defTarget, const SwitchCases& sw) { abort(); } /// @brief called on IRETURN @@ -566,7 +571,8 @@ case BOOLEAN: Out << "boolean"; break; case CHAR: Out << "char"; break; case FLOAT: Out << "float"; break; - case DOUBLE: Out << "byte"; break; + case DOUBLE: Out << "double"; break; + case BYTE: Out << "byte"; break; case SHORT: Out << "short"; break; case INT: Out << "int"; break; case LONG: Out << "long"; break; From lattner at cs.uiuc.edu Sat Feb 12 13:08:42 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 12 Feb 2005 13:08:42 -0600 Subject: [llvm-commits] CVS: llvm-gcc/gcc/llvm-expand.c Message-ID: <200502121908.j1CJ8g6H010198@apoc.cs.uiuc.edu> Changes in directory llvm-gcc/gcc: llvm-expand.c updated: 1.78 -> 1.79 --- Log message: Deal with PR450: http://llvm.cs.uiuc.edu/PR450 and 502. There is still an llvm linker patch required to make this work though. This will also give us better optimization capabilities for C++ programs in some cases. --- Diffs of the changes: (+8 -3) llvm-expand.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) Index: llvm-gcc/gcc/llvm-expand.c diff -u llvm-gcc/gcc/llvm-expand.c:1.78 llvm-gcc/gcc/llvm-expand.c:1.79 --- llvm-gcc/gcc/llvm-expand.c:1.78 Fri Feb 11 13:26:43 2005 +++ llvm-gcc/gcc/llvm-expand.c Sat Feb 12 13:08:27 2005 @@ -7274,10 +7274,15 @@ if (TREE_READONLY(decl) && !TREE_SIDE_EFFECTS(decl)) { if (DECL_EXTERNAL(decl)) { - /* Mark external globals constant only if they are lacking ctors/dtors. + /* Mark external globals constant even though they could be marked + * non-constant in the defining translation unit. The definition of the + * global determines whether the global is ultimately constant or not, + * marking this constant will allow us to do some extra (legal) + * optimizations that we would otherwise not be able to do. (In C++, + * any global that is 'C++ const' may not be readonly: it could have a + * dynamic initializer. */ - if (!TYPE_NEEDS_CONSTRUCTING(TREE_TYPE(decl))) - G->isConstant = 1; + G->isConstant = 1; } else { /* Mark readonly globals with constant initializes constant. */ if (DECL_INITIAL(decl) != error_mark_node && /* uninitialized? */ From lattner at cs.uiuc.edu Sat Feb 12 13:14:26 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 12 Feb 2005 13:14:26 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Linker/2005-02-12-ConstantGlobals.ll Message-ID: <200502121914.j1CJEQxa010239@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Linker: 2005-02-12-ConstantGlobals.ll added (r1.1) --- Log message: Reinstate this test, it is correct after all. --- Diffs of the changes: (+8 -0) 2005-02-12-ConstantGlobals.ll | 8 ++++++++ 1 files changed, 8 insertions(+) Index: llvm/test/Regression/Linker/2005-02-12-ConstantGlobals.ll diff -c /dev/null llvm/test/Regression/Linker/2005-02-12-ConstantGlobals.ll:1.1 *** /dev/null Sat Feb 12 13:14:21 2005 --- llvm/test/Regression/Linker/2005-02-12-ConstantGlobals.ll Sat Feb 12 13:14:11 2005 *************** *** 0 **** --- 1,8 ---- + ; Test that a prototype can be marked const, and the definition is allowed + ; to be nonconst. + + ; RUN: echo "%X = global int 7" | llvm-as > %t.2.bc + ; RUN: llvm-as < %s > %t.1.bc + ; RUN: llvm-link %t.[12].bc | llvm-dis | grep constant + + %X = external constant int From lattner at cs.uiuc.edu Sat Feb 12 13:19:51 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 12 Feb 2005 13:19:51 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Linker/2005-02-12-ConstantGlobals-2.ll 2005-02-12-ConstantGlobals.ll Message-ID: <200502121919.j1CJJp9f010516@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Linker: 2005-02-12-ConstantGlobals-2.ll added (r1.1) 2005-02-12-ConstantGlobals.ll updated: 1.1 -> 1.2 --- Log message: New test, adjust other test. --- Diffs of the changes: (+9 -1) 2005-02-12-ConstantGlobals-2.ll | 8 ++++++++ 2005-02-12-ConstantGlobals.ll | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) Index: llvm/test/Regression/Linker/2005-02-12-ConstantGlobals-2.ll diff -c /dev/null llvm/test/Regression/Linker/2005-02-12-ConstantGlobals-2.ll:1.1 *** /dev/null Sat Feb 12 13:19:46 2005 --- llvm/test/Regression/Linker/2005-02-12-ConstantGlobals-2.ll Sat Feb 12 13:19:36 2005 *************** *** 0 **** --- 1,8 ---- + ; Test that a prototype can be marked const, and the definition is allowed + ; to be nonconst. + + ; RUN: echo "%X = external constant int" | llvm-as > %t.2.bc + ; RUN: llvm-as < %s > %t.1.bc + ; RUN: llvm-link %t.[12].bc | llvm-dis | grep 'global int 7' + + %X = global int 7 Index: llvm/test/Regression/Linker/2005-02-12-ConstantGlobals.ll diff -u llvm/test/Regression/Linker/2005-02-12-ConstantGlobals.ll:1.1 llvm/test/Regression/Linker/2005-02-12-ConstantGlobals.ll:1.2 --- llvm/test/Regression/Linker/2005-02-12-ConstantGlobals.ll:1.1 Sat Feb 12 13:14:11 2005 +++ llvm/test/Regression/Linker/2005-02-12-ConstantGlobals.ll Sat Feb 12 13:19:36 2005 @@ -3,6 +3,6 @@ ; RUN: echo "%X = global int 7" | llvm-as > %t.2.bc ; RUN: llvm-as < %s > %t.1.bc -; RUN: llvm-link %t.[12].bc | llvm-dis | grep constant +; RUN: llvm-link %t.[12].bc | llvm-dis | grep 'global int 7' %X = external constant int From lattner at cs.uiuc.edu Sat Feb 12 13:20:41 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 12 Feb 2005 13:20:41 -0600 Subject: [llvm-commits] CVS: llvm/lib/Linker/LinkModules.cpp Message-ID: <200502121920.j1CJKf1Y010530@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Linker: LinkModules.cpp updated: 1.101 -> 1.102 --- Log message: Allow globals to be of different const'nesses when we link. This finally resolves PR502: http://llvm.cs.uiuc.edu/PR502 , PR450: http://llvm.cs.uiuc.edu/PR450 , and test/Regression/Linker/2005-02-12-ConstantGlobals{,-2}.ll correctly --- Diffs of the changes: (+2 -8) LinkModules.cpp | 10 ++-------- 1 files changed, 2 insertions(+), 8 deletions(-) Index: llvm/lib/Linker/LinkModules.cpp diff -u llvm/lib/Linker/LinkModules.cpp:1.101 llvm/lib/Linker/LinkModules.cpp:1.102 --- llvm/lib/Linker/LinkModules.cpp:1.101 Sun Dec 12 21:00:16 2004 +++ llvm/lib/Linker/LinkModules.cpp Sat Feb 12 13:20:28 2005 @@ -517,18 +517,12 @@ DGV->setLinkage(NewLinkage); if (LinkFromSrc) { - if (DGV->isConstant() && !SGV->isConstant()) - return Error(Err, "Global Variable Collision on global '" + - SGV->getName() + "': variables differ in const'ness"); // Inherit const as appropriate - if (SGV->isConstant()) DGV->setConstant(true); + DGV->setConstant(SGV->isConstant()); DGV->setInitializer(0); } else { if (SGV->isConstant() && !DGV->isConstant()) { - if (!DGV->isExternal()) - return Error(Err, "Global Variable Collision on global '" + - SGV->getName() + "': variables differ in const'ness"); - else + if (DGV->isExternal()) DGV->setConstant(true); } SGV->setLinkage(GlobalValue::ExternalLinkage); From lattner at cs.uiuc.edu Sat Feb 12 13:30:37 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 12 Feb 2005 13:30:37 -0600 Subject: [llvm-commits] CVS: llvm/docs/LangRef.html Message-ID: <200502121930.j1CJUbYv010566@apoc.cs.uiuc.edu> Changes in directory llvm/docs: LangRef.html updated: 1.83 -> 1.84 --- Log message: Document the newly generalized model for constant globals. --- Diffs of the changes: (+17 -7) LangRef.html | 24 +++++++++++++++++------- 1 files changed, 17 insertions(+), 7 deletions(-) Index: llvm/docs/LangRef.html diff -u llvm/docs/LangRef.html:1.83 llvm/docs/LangRef.html:1.84 --- llvm/docs/LangRef.html:1.83 Fri Dec 10 09:51:16 2004 +++ llvm/docs/LangRef.html Sat Feb 12 13:30:21 2005 @@ -423,12 +423,22 @@
    -

    Global variables define regions of memory allocated at compilation -time instead of run-time. Global variables may optionally be -initialized. A variable may be defined as a global "constant", which -indicates that the contents of the variable will never be modified -(enabling better optimization, allowing the global data to be placed in the -read-only section of an executable, etc).

    +

    Global variables define regions of memory allocated at compilation time +instead of run-time. Global variables may optionally be initialized. A +variable may be defined as a global "constant", which indicates that the +contents of the variable will never be modified (enabling better +optimization, allowing the global data to be placed in the read-only section of +an executable, etc). Note that variables that need runtime initialization +cannot be marked "constant", as there is a store to the variable.

    + +

    +LLVM explicitly allows declarations of global variables to be marked +constant, even if the final definition of the global is not. This capability +can be used to enable slightly better optimization of the program, but requires +the language definition to guarantee that optimizations based on the +'constantness' are valid for the translation units that do not include the +definition. +

    As SSA values, global variables define pointer values that are in scope (i.e. they dominate) all basic blocks in the program. Global @@ -2914,7 +2924,7 @@ Chris Lattner
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/12/10 15:51:16 $ + Last modified: $Date: 2005/02/12 19:30:21 $ From alenhar2 at cs.uiuc.edu Sat Feb 12 13:35:27 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Sat, 12 Feb 2005 13:35:27 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp Message-ID: <200502121935.j1CJZRid010608@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.49 -> 1.50 --- Log message: added sign extend for boolean --- Diffs of the changes: (+5 -3) AlphaISelPattern.cpp | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.49 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.50 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.49 Thu Feb 10 14:10:38 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Sat Feb 12 13:35:12 2005 @@ -56,9 +56,6 @@ setOperationAction(ISD::SEXTLOAD , MVT::i8 , Expand); setOperationAction(ISD::SEXTLOAD , MVT::i16 , Expand); - //what is the sign expansion of 1? 1 or -1? - setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i1, Expand); - setOperationAction(ISD::SREM , MVT::f32 , Expand); setOperationAction(ISD::SREM , MVT::f64 , Expand); @@ -959,6 +956,11 @@ case MVT::i8: BuildMI(BB, Alpha::SEXTB, 1, Result).addReg(Tmp1); break; + case MVT::i1: + Tmp2 = MakeReg(MVT::i64); + BuildMI(BB, Alpha::ANDi, 2, Tmp2).addReg(Tmp1).addImm(1); + BuildMI(BB, Alpha::SUB, 2, Result).addReg(Alpha::F31).addReg(Tmp2); + break; } return Result; } From lattner at cs.uiuc.edu Sat Feb 12 14:11:28 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 12 Feb 2005 14:11:28 -0600 Subject: [llvm-commits] CVS: llvm/docs/GettingStarted.html Message-ID: <200502122011.j1CKBSsX016207@apoc.cs.uiuc.edu> Changes in directory llvm/docs: GettingStarted.html updated: 1.111 -> 1.112 --- Log message: Add note about broken GCC --- Diffs of the changes: (+7 -2) GettingStarted.html | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) Index: llvm/docs/GettingStarted.html diff -u llvm/docs/GettingStarted.html:1.111 llvm/docs/GettingStarted.html:1.112 --- llvm/docs/GettingStarted.html:1.111 Wed Feb 9 16:52:46 2005 +++ llvm/docs/GettingStarted.html Sat Feb 12 14:11:13 2005 @@ -458,7 +458,8 @@

    LLVM is very demanding of the host C++ compiler, and as such tends to expose bugs in the compiler. In particular, several versions of GCC crash when trying to compile LLVM. We routinely use GCC 3.3.3 and GCC 3.4.0 and have had success -with them. Other versions of GCC will probably work as well. GCC versions listed +with them (except on Cygwin, see below). Other versions of GCC will probably +work as well. GCC versions listed here are known to not work. If you are using one of these versions, please try to upgrade your GCC to something more recent. If you run into a problem with a version of GCC not listed here, please let @@ -475,6 +476,10 @@

    GCC 3.3.2: This version of GCC suffered from a serious bug which causes it to crash in the "convert_from_eh_region_ranges_1" GCC function.

    + +

    GCC 3.3.3: The version of GCC 3.3.3 commonly shipped with Cygwin does + not work. Please upgrade to a newer + version if possible. Note that this apparently only affects Cygwin.

    @@ -1495,7 +1500,7 @@ Chris Lattner
    Reid Spencer
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2005/02/09 22:52:46 $ + Last modified: $Date: 2005/02/12 20:11:13 $ From alkis at cs.uiuc.edu Sat Feb 12 14:18:35 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 12 Feb 2005 14:18:35 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200502122018.OAA06574@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.219 -> 1.220 --- Log message: Pass the parent classfile around when creating children objects in the classfile structures. Constify the classes a bit more and update users. --- Diffs of the changes: (+63 -55) Compiler.cpp | 118 +++++++++++++++++++++++++++++++---------------------------- 1 files changed, 63 insertions(+), 55 deletions(-) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.219 llvm-java/lib/Compiler/Compiler.cpp:1.220 --- llvm-java/lib/Compiler/Compiler.cpp:1.219 Fri Feb 11 20:59:01 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Sat Feb 12 14:17:48 2005 @@ -63,7 +63,7 @@ class Compiler : public BytecodeParser { Module& module_; GlobalVariable* JNIEnvPtr_; - ClassFile* cf_; + const ClassFile* cf_; std::auto_ptr bbBuilder_; std::list bbWorkList_; typedef std::map OpStackDepthMap; @@ -114,7 +114,7 @@ unsigned getInterfaceIndex() const { return interfaceIdx_; } void setNextInterfaceIndex() { interfaceIdx_ = InterfaceCount++; } }; - typedef std::map Class2ClassInfoMap; + typedef std::map Class2ClassInfoMap; Class2ClassInfoMap c2ciMap_; /// This class contains the vtable of a class, a vector with the @@ -133,7 +133,7 @@ static StructType* VTableTy; static StructType* TypeInfoTy; }; - typedef std::map Class2VTableInfoMap; + typedef std::map Class2VTableInfoMap; Class2VTableInfoMap c2viMap_; Class2VTableInfoMap ac2viMap_; @@ -321,7 +321,7 @@ /// class info of java.lang.Object. bool initializeClassInfoMap() { DEBUG(std::cerr << "Building ClassInfo for: java/lang/Object\n"); - ClassFile* cf = ClassFile::get("java/lang/Object"); + const ClassFile* cf = ClassFile::get("java/lang/Object"); ClassInfo& ci = c2ciMap_[cf]; module_.addTypeName(LLVM_JAVA_OBJECT_BASE, ObjectBaseTy); @@ -357,7 +357,7 @@ /// VTableInfo for java.lang.Object. bool initializeVTableInfoMap() { DEBUG(std::cerr << "Building VTableInfo for: java/lang/Object\n"); - ClassFile* cf = ClassFile::get("java/lang/Object"); + const ClassFile* cf = ClassFile::get("java/lang/Object"); VTableInfo& vi = c2viMap_[cf]; assert(!vi.vtable && vi.m2iMap.empty() && @@ -452,7 +452,7 @@ } /// Returns the ClassInfo object associated with this classfile. - const ClassInfo& getClassInfo(ClassFile* cf) { + const ClassInfo& getClassInfo(const ClassFile* cf) { static bool initialized = initializeClassInfoMap(); Class2ClassInfoMap::iterator it = c2ciMap_.lower_bound(cf); @@ -577,36 +577,37 @@ /// its corresponding VTable. The most generic class goes first in /// the array. std::pair - buildSuperClassesVTables(ClassFile* cf, const VTableInfo& vi) const { - std::vector superVtables(vi.superVtables.size()); - for (unsigned i = 0, e = vi.superVtables.size(); i != e; ++i) - superVtables[i] = ConstantExpr::getCast( - vi.superVtables[i], - PointerType::get(VTableInfo::VTableTy)); - - llvm::Constant* init = ConstantArray::get( - ArrayType::get(PointerType::get(VTableInfo::VTableTy), - superVtables.size()), - superVtables); - - GlobalVariable* vtablesArray = new GlobalVariable( - init->getType(), - true, - GlobalVariable::ExternalLinkage, - init, - cf->getThisClass()->getName()->str() + "", - &module_); - - return std::make_pair( - vi.superVtables.size(), - ConstantExpr::getGetElementPtr( - vtablesArray, - std::vector(2, ConstantUInt::get(Type::UIntTy, 0)))); - } - - /// Builds an interface VTable for the specified - /// pair. - llvm::Constant* buildInterfaceVTable(ClassFile* cf, ClassFile* interface) { + buildSuperClassesVTables(const ClassFile* cf, const VTableInfo& vi) const { + std::vector superVtables(vi.superVtables.size()); + for (unsigned i = 0, e = vi.superVtables.size(); i != e; ++i) + superVtables[i] = ConstantExpr::getCast( + vi.superVtables[i], + PointerType::get(VTableInfo::VTableTy)); + + llvm::Constant* init = ConstantArray::get( + ArrayType::get(PointerType::get(VTableInfo::VTableTy), + superVtables.size()), + superVtables); + + GlobalVariable* vtablesArray = new GlobalVariable( + init->getType(), + true, + GlobalVariable::ExternalLinkage, + init, + cf->getThisClass()->getName()->str() + "", + &module_); + + return std::make_pair( + vi.superVtables.size(), + ConstantExpr::getGetElementPtr( + vtablesArray, + std::vector(2, ConstantUInt::get(Type::UIntTy, 0)))); + } + + /// Builds an interface VTable for the specified + /// pair. + llvm::Constant* buildInterfaceVTable(const ClassFile* cf, + const ClassFile* interface) { DEBUG(std::cerr << "Building interface vtable: " << interface->getThisClass()->getName()->str() << " for: " << cf->getThisClass()->getName()->str() << '\n'); @@ -652,8 +653,8 @@ } void insertVtablesForInterface(std::vector& vtables, - ClassFile* cf, - ClassFile* ifaceCf) { + const ClassFile* cf, + const ClassFile* ifaceCf) { static llvm::Constant* nullVTable = llvm::Constant::getNullValue(PointerType::get(VTableInfo::VTableTy)); @@ -666,7 +667,8 @@ vtables[ifaceCi.getInterfaceIndex()] = buildInterfaceVTable(cf, ifaceCf); const Classes& interfaces = ifaceCf->getInterfaces(); for (unsigned i = 0, e = interfaces.size(); i != e; ++i) { - ClassFile* otherCf = ClassFile::get(interfaces[i]->getName()->str()); + const ClassFile* otherCf = + ClassFile::get(interfaces[i]->getName()->str()); insertVtablesForInterface(vtables, cf, otherCf); } } @@ -676,7 +678,7 @@ /// corresponding VTableInfo. If this classfile is an interface we /// return a pointer to 0xFFFFFFFF. std::pair - buildInterfacesVTables(ClassFile* cf, const VTableInfo& vi) { + buildInterfacesVTables(const ClassFile* cf, const VTableInfo& vi) { // If this is an interface then we are not implementing any // interfaces so the lastInterface field is our index and the // pointer to the array of interface vtables is an all-ones @@ -697,11 +699,12 @@ llvm::Constant* nullVTable = llvm::Constant::getNullValue(PointerType::get(VTableInfo::VTableTy)); - ClassFile* curCf = cf; + const ClassFile* curCf = cf; while (true) { const Classes& interfaces = curCf->getInterfaces(); for (unsigned i = 0, e = interfaces.size(); i != e; ++i) { - ClassFile* ifaceCf = ClassFile::get(interfaces[i]->getName()->str()); + const ClassFile* ifaceCf = + ClassFile::get(interfaces[i]->getName()->str()); insertVtablesForInterface(vtables, cf, ifaceCf); } if (!curCf->getSuperClass()) @@ -734,7 +737,8 @@ /// Given the classfile and its corresponding VTableInfo, /// construct the typeinfo constant for it. - llvm::Constant* buildClassTypeInfo(ClassFile* cf, const VTableInfo& vi) { + llvm::Constant* buildClassTypeInfo(const ClassFile* cf, + const VTableInfo& vi) { std::vector typeInfoInit; unsigned depth; @@ -762,7 +766,7 @@ } /// Returns the VTableInfo associated with this classfile. - const VTableInfo& getVTableInfo(ClassFile* cf) { + const VTableInfo& getVTableInfo(const ClassFile* cf) { static bool initialized = initializeVTableInfoMap(); Class2VTableInfoMap::iterator it = c2viMap_.lower_bound(cf); @@ -796,7 +800,8 @@ if (cf->isInterface()) { const Classes& ifaces = cf->getInterfaces(); for (unsigned i = 0, e = ifaces.size(); i != e; ++i) { - ClassFile* ifaceCF = ClassFile::get(ifaces[i]->getName()->str()); + const ClassFile* ifaceCF = + ClassFile::get(ifaces[i]->getName()->str()); const VTableInfo& ifaceVI = getVTableInfo(ifaceCF); ConstantStruct* ifaceInit = cast(ifaceVI.vtable->getInitializer()); @@ -1022,7 +1027,7 @@ /// words it adds the VTableInfo for java.lang.Object[]. bool initializeObjectArrayVTableInfoMap() { DEBUG(std::cerr << "Building VTableInfo for: java/lang/Object[]\n"); - ClassFile* cf = ClassFile::get("java/lang/Object"); + const ClassFile* cf = ClassFile::get("java/lang/Object"); VTableInfo& vi = ac2viMap_[cf]; assert(!vi.vtable && vi.m2iMap.empty() && "java/lang/Object[] VTableInfo should not be initialized!"); @@ -1096,7 +1101,7 @@ return true; } - const VTableInfo& getObjectArrayVTableInfo(ClassFile* cf) { + const VTableInfo& getObjectArrayVTableInfo(const ClassFile* cf) { static bool initialized = initializeObjectArrayVTableInfoMap(); Class2VTableInfoMap::iterator it = ac2viMap_.lower_bound(cf); @@ -1204,7 +1209,7 @@ while (true) { // Get ClassInfo for class owning the field - this will force // the globals to be initialized. - ClassFile* cf = ClassFile::get(className); + const ClassFile* cf = ClassFile::get(className); getClassInfo(cf); std::string globalName = @@ -1228,13 +1233,16 @@ Value* getField(unsigned index, Value* ptr) { ConstantFieldRef* fieldRef = cf_->getConstantFieldRef(index); ConstantNameAndType* nameAndType = fieldRef->getNameAndType(); - ClassFile* cf = ClassFile::get(fieldRef->getClass()->getName()->str()); + const ClassFile* cf = + ClassFile::get(fieldRef->getClass()->getName()->str()); return getField(cf, nameAndType->getName()->str(), ptr); } /// Emits the necessary code to get a field from the passed /// pointer to an object. - Value* getField(ClassFile* cf, const std::string& fieldName, Value* ptr) { + Value* getField(const ClassFile* cf, + const std::string& fieldName, + Value* ptr) { // Cast ptr to correct type. ptr = new CastInst(ptr, PointerType::get(getClassInfo(cf).getType()), TMP, currentBB_); @@ -1502,7 +1510,7 @@ /// Returns the llvm::Function corresponding to the specified /// llvm::Java::Method. Function* getFunction(Method* method) { - ClassFile* clazz = method->getParent(); + const ClassFile* clazz = method->getParent(); FunctionType* funcTy = cast( getType(method->getDescriptor(), @@ -1532,7 +1540,7 @@ std::string methodNameAndDescr = classMethodDesc.substr(slash+1); while (true) { - ClassFile* classfile = ClassFile::get(className); + const ClassFile* classfile = ClassFile::get(className); emitStaticInitializers(classfile); Method* method = classfile->getMethod(methodNameAndDescr); @@ -2065,7 +2073,7 @@ } } else { - ClassFile* cf = ClassFile::get(className); + const ClassFile* cf = ClassFile::get(className); vi = &getVTableInfo(cf); ci = &getClassInfo(cf); } @@ -2213,7 +2221,7 @@ void do_new(unsigned index) { ConstantClass* classRef = cf_->getConstantClass(index); - ClassFile* cf = ClassFile::get(classRef->getName()->str()); + const ClassFile* cf = ClassFile::get(classRef->getName()->str()); const ClassInfo& ci = getClassInfo(cf); const VTableInfo& vi = getVTableInfo(cf); @@ -2266,7 +2274,7 @@ Value* count = pop(Type::UIntTy); ConstantClass* classRef = cf_->getConstantClass(index); - ClassFile* cf = ClassFile::get(classRef->getName()->str()); + const ClassFile* cf = ClassFile::get(classRef->getName()->str()); const ClassInfo& ci = getObjectArrayInfo(); const ClassInfo& ei = getClassInfo(cf); const VTableInfo& vi = getObjectArrayVTableInfo(cf); From alkis at cs.uiuc.edu Sat Feb 12 14:18:44 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 12 Feb 2005 14:18:44 -0600 Subject: [llvm-commits] CVS: llvm-java/include/llvm/Java/ClassFile.h Message-ID: <200502122018.OAA06586@zion.cs.uiuc.edu> Changes in directory llvm-java/include/llvm/Java: ClassFile.h updated: 1.29 -> 1.30 --- Log message: Pass the parent classfile around when creating children objects in the classfile structures. Constify the classes a bit more and update users. --- Diffs of the changes: (+47 -51) ClassFile.h | 98 ++++++++++++++++++++++++++++-------------------------------- 1 files changed, 47 insertions(+), 51 deletions(-) Index: llvm-java/include/llvm/Java/ClassFile.h diff -u llvm-java/include/llvm/Java/ClassFile.h:1.29 llvm-java/include/llvm/Java/ClassFile.h:1.30 --- llvm-java/include/llvm/Java/ClassFile.h:1.29 Fri Feb 11 14:19:33 2005 +++ llvm-java/include/llvm/Java/ClassFile.h Sat Feb 12 14:17:57 2005 @@ -69,14 +69,14 @@ const std::string& name); class ClassFile { - static ClassFile* readClassFile(std::istream& is); + static const ClassFile* readClassFile(std::istream& is); static std::vector getClassPath(); static sys::Path getFileForClass(const std::string& classname); typedef std::map Name2MethodMap; public: - static ClassFile* get(const std::string& classname); + static const ClassFile* get(const std::string& classname); ~ClassFile(); @@ -90,6 +90,8 @@ ConstantMethodRef* getConstantMethodRef(unsigned index) const; ConstantInterfaceMethodRef* getConstantInterfaceMethodRef(unsigned index) const; + ConstantNameAndType* getConstantNameAndType(unsigned index) const; + ConstantUtf8* getConstantUtf8(unsigned index) const; bool isPublic() const { return accessFlags_ & ACC_PUBLIC; } bool isFinal() const { return accessFlags_ & ACC_FINAL; } @@ -135,10 +137,10 @@ class Constant { protected: - const ConstantPool& cPool_; + const ClassFile* parent_; - Constant(const ConstantPool& cp) - : cPool_(cp) { } + Constant(const ClassFile* cf) + : parent_(cf) { } public: enum Tag { @@ -155,11 +157,12 @@ UTF8 = 1 }; - static Constant* readConstant(const ConstantPool& cp, - std::istream& is); + static Constant* readConstant(const ClassFile* cf, std::istream& is); virtual bool isSingleSlot() { return true; } bool isDoubleSlot() { return !isSingleSlot(); } + const ClassFile* getParent() { return parent_; } + virtual ~Constant(); virtual std::ostream& dump(std::ostream& os) const = 0; @@ -172,9 +175,9 @@ class ConstantClass : public Constant { uint16_t nameIdx_; public: - ConstantClass(const ConstantPool& cp, std::istream& is); + ConstantClass(const ClassFile* cf, std::istream& is); ConstantUtf8* getName() const { - return (ConstantUtf8*) cPool_[nameIdx_]; + return parent_->getConstantUtf8(nameIdx_); } std::ostream& dump(std::ostream& os) const; }; @@ -183,42 +186,42 @@ uint16_t classIdx_; uint16_t nameAndTypeIdx_; protected: - ConstantMemberRef(const ConstantPool& cp, std::istream& is); + ConstantMemberRef(const ClassFile* cf, std::istream& is); public: ConstantClass* getClass() const { - return (ConstantClass*) cPool_[classIdx_]; + return parent_->getConstantClass(classIdx_); } ConstantNameAndType* getNameAndType() const { - return (ConstantNameAndType*) cPool_[nameAndTypeIdx_]; + return parent_->getConstantNameAndType(nameAndTypeIdx_); } std::ostream& dump(std::ostream& os) const; }; class ConstantFieldRef : public ConstantMemberRef { public: - ConstantFieldRef(const ConstantPool& cp, std::istream& is) - : ConstantMemberRef(cp, is) { } + ConstantFieldRef(const ClassFile* cf, std::istream& is) + : ConstantMemberRef(cf, is) { } }; class ConstantMethodRef : public ConstantMemberRef { public: - ConstantMethodRef(const ConstantPool& cp, std::istream& is) - : ConstantMemberRef(cp, is) { } + ConstantMethodRef(const ClassFile* cf, std::istream& is) + : ConstantMemberRef(cf, is) { } }; class ConstantInterfaceMethodRef : public ConstantMemberRef { public: - ConstantInterfaceMethodRef(const ConstantPool& cp, std::istream& is) - : ConstantMemberRef(cp, is) { } + ConstantInterfaceMethodRef(const ClassFile* cf, std::istream& is) + : ConstantMemberRef(cf, is) { } }; class ConstantString : public Constant { uint16_t stringIdx_; public: - ConstantString(const ConstantPool& cp, std::istream& is); + ConstantString(const ClassFile* cf, std::istream& is); ConstantUtf8* getValue() const { - return (ConstantUtf8*) cPool_[stringIdx_]; + return parent_->getConstantUtf8(stringIdx_); } std::ostream& dump(std::ostream& os) const; }; @@ -226,7 +229,7 @@ class ConstantInteger : public Constant { int32_t value_; public: - ConstantInteger(const ConstantPool& cp, std::istream& is); + ConstantInteger(const ClassFile* cf, std::istream& is); int32_t getValue() const { return value_; } std::ostream& dump(std::ostream& os) const; }; @@ -234,7 +237,7 @@ class ConstantFloat : public Constant { float value_; public: - ConstantFloat(const ConstantPool& cp, std::istream& is); + ConstantFloat(const ClassFile* cf, std::istream& is); float getValue() const { return value_; } std::ostream& dump(std::ostream& os) const; }; @@ -242,7 +245,7 @@ class ConstantLong : public Constant { int64_t value_; public: - ConstantLong(const ConstantPool& cp, std::istream& is); + ConstantLong(const ClassFile* cf, std::istream& is); virtual bool isSingleSlot() { return false; } int64_t getValue() const { return value_; } std::ostream& dump(std::ostream& os) const; @@ -251,7 +254,7 @@ class ConstantDouble : public Constant { double value_; public: - ConstantDouble(const ConstantPool& cp, std::istream& is); + ConstantDouble(const ClassFile* cf, std::istream& is); virtual bool isSingleSlot() { return false; } double getValue() const { return value_; } std::ostream& dump(std::ostream& os) const; @@ -261,12 +264,12 @@ uint16_t nameIdx_; uint16_t descriptorIdx_; public: - ConstantNameAndType(const ConstantPool& cp, std::istream& is); + ConstantNameAndType(const ClassFile* cf, std::istream& is); ConstantUtf8* getName() const { - return (ConstantUtf8*) cPool_[nameIdx_]; + return parent_->getConstantUtf8(nameIdx_); } ConstantUtf8* getDescriptor() const { - return (ConstantUtf8*) cPool_[descriptorIdx_]; + return parent_->getConstantUtf8(descriptorIdx_); } std::ostream& dump(std::ostream& os) const; }; @@ -274,7 +277,7 @@ class ConstantUtf8 : public Constant { std::string utf8_; public: - ConstantUtf8(const ConstantPool& cp, std::istream& is); + ConstantUtf8(const ClassFile* cf, std::istream& is); const std::string& str() const { return utf8_; } std::ostream& dump(std::ostream& os) const; @@ -282,19 +285,17 @@ class Field { private: - ClassFile* parent_; + const ClassFile* parent_; uint16_t accessFlags_; ConstantUtf8* name_; ConstantUtf8* descriptor_; Attributes attributes_; - Field(ClassFile* parent, const ConstantPool& cp, std::istream& is); + Field(const ClassFile* parent, std::istream& is); public: - static Field* readField(ClassFile* parent, - const ConstantPool& cp, - std::istream& is) { - return new Field(parent, cp, is); + static Field* readField(const ClassFile* parent, std::istream& is) { + return new Field(parent, is); } ~Field(); @@ -307,7 +308,7 @@ bool isVolatile() const { return accessFlags_ & ACC_VOLATILE; } bool isTransient() const { return accessFlags_ & ACC_TRANSIENT; } - ClassFile* getParent() const { return parent_; } + const ClassFile* getParent() const { return parent_; } ConstantUtf8* getName() const { return name_; } ConstantUtf8* getDescriptor() const { return descriptor_; } const Attributes& getAttributes() const { return attributes_; } @@ -321,19 +322,17 @@ } class Method { - ClassFile* parent_; + const ClassFile* parent_; uint16_t accessFlags_; ConstantUtf8* name_; ConstantUtf8* descriptor_; Attributes attributes_; - Method(ClassFile* parent, const ConstantPool& cp, std::istream& is); + Method(const ClassFile* parent, std::istream& is); public: - static Method* readMethod(ClassFile* parent, - const ConstantPool& cp, - std::istream& is) { - return new Method(parent, cp, is); + static Method* readMethod(const ClassFile* parent, std::istream& is) { + return new Method(parent, is); } ~Method(); @@ -348,7 +347,7 @@ bool isAbstract() const { return accessFlags_ & ACC_ABSTRACT; } bool isStrict() const { return accessFlags_ & ACC_STRICT; } - ClassFile* getParent() const { return parent_; } + const ClassFile* getParent() const { return parent_; } ConstantUtf8* getName() const { return name_; } ConstantUtf8* getDescriptor() const { return descriptor_; } const Attributes& getAttributes() const { return attributes_; } @@ -366,13 +365,10 @@ ConstantUtf8* name_; protected: - Attribute(ConstantUtf8* name, - const ConstantPool& cp, - std::istream& is); + Attribute(ConstantUtf8* name, const ClassFile* cf, std::istream& is); public: - static Attribute* readAttribute(const ConstantPool& cp, - std::istream& is); + static Attribute* readAttribute(const ClassFile* cf, std::istream& is); virtual ~Attribute(); @@ -399,7 +395,7 @@ Constant* value_; public: ConstantValueAttribute(ConstantUtf8* name, - const ConstantPool& cp, + const ClassFile* cf, std::istream& is); Constant* getValue() const { return value_; } @@ -416,7 +412,7 @@ ConstantClass* catchType_; public: - Exception(const ConstantPool& cp, std::istream& is); + Exception(const ClassFile* cf, std::istream& is); uint16_t getStartPc() const { return startPc_; } uint16_t getEndPc() const { return endPc_; } @@ -438,7 +434,7 @@ public: CodeAttribute(ConstantUtf8* name, - const ConstantPool& cp, + const ClassFile* cf, std::istream& is); ~CodeAttribute(); uint16_t getMaxStack() const { return maxStack_; } @@ -463,7 +459,7 @@ public: ExceptionsAttribute(ConstantUtf8* name, - const ConstantPool& cp, + const ClassFile* cf, std::istream& is); const Classes& getExceptions() const { return exceptions_; } From alkis at cs.uiuc.edu Sat Feb 12 14:18:44 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 12 Feb 2005 14:18:44 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/ClassFile/ClassFile.cpp Message-ID: <200502122018.OAA06590@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/ClassFile: ClassFile.cpp updated: 1.38 -> 1.39 --- Log message: Pass the parent classfile around when creating children objects in the classfile structures. Constify the classes a bit more and update users. --- Diffs of the changes: (+109 -108) ClassFile.cpp | 217 +++++++++++++++++++++++++++++----------------------------- 1 files changed, 109 insertions(+), 108 deletions(-) Index: llvm-java/lib/ClassFile/ClassFile.cpp diff -u llvm-java/lib/ClassFile/ClassFile.cpp:1.38 llvm-java/lib/ClassFile/ClassFile.cpp:1.39 --- llvm-java/lib/ClassFile/ClassFile.cpp:1.38 Sat Feb 12 12:43:54 2005 +++ llvm-java/lib/ClassFile/ClassFile.cpp Sat Feb 12 14:17:57 2005 @@ -84,67 +84,46 @@ return tmp.out; } - void readConstantPool(ConstantPool& cp, std::istream& is) - { - assert(cp.empty() && "Should not call with a non-empty constant pool"); - uint16_t count = readU2(is); - cp.reserve(count); - cp.push_back(NULL); - while (cp.size() < count) { - cp.push_back(Constant::readConstant(cp, is)); - if (cp.back()->isDoubleSlot()) - cp.push_back(NULL); - } - } - - void readClasses(Classes& i, const ConstantPool& cp, std::istream& is) + void readClasses(Classes& i, const ClassFile* cf, std::istream& is) { assert(i.empty() && "Should not call with a non-empty classes vector"); uint16_t count = readU2(is); i.reserve(count); while (count--) { - ConstantClass* c = dynamic_cast(cp[readU2(is)]); + ConstantClass* c = cf->getConstantClass(readU2(is)); if (!c) throw ClassFileSemanticError("ConstantClass expected"); i.push_back(c); } } - void readFields(Fields& f, - ClassFile* parent, - const ConstantPool& cp, - std::istream& is) + void readFields(Fields& f, const ClassFile* parent, std::istream& is) { assert(f.empty() && "Should not call with a non-empty fields vector"); uint16_t count = readU2(is); f.reserve(count); while(count--) - f.push_back(Field::readField(parent, cp, is)); + f.push_back(Field::readField(parent, is)); } - void readMethods(Methods& m, - ClassFile* parent, - const ConstantPool& cp, - std::istream& is) + void readMethods(Methods& m, const ClassFile* parent, std::istream& is) { assert(m.empty() && "Should not call with a non-empty methods vector"); uint16_t count = readU2(is); m.reserve(count); while(count--) - m.push_back(Method::readMethod(parent, cp, is)); + m.push_back(Method::readMethod(parent, is)); } - void readAttributes(Attributes& a, - const ConstantPool& cp, - std::istream& is) + void readAttributes(Attributes& a, const ClassFile* cf, std::istream& is) { assert(a.empty() && "Should not call with a non-empty attributes vector"); uint16_t count = readU2(is); a.reserve(count); while(count--) - a.push_back(Attribute::readAttribute(cp, is)); + a.push_back(Attribute::readAttribute(cf, is)); } template @@ -165,7 +144,7 @@ //===----------------------------------------------------------------------===// // ClassFile implementation -ClassFile* ClassFile::readClassFile(std::istream& is) +const ClassFile* ClassFile::readClassFile(std::istream& is) { if (readU1(is) != 0xCA) throw ClassFileParseError("bad magic"); if (readU1(is) != 0xFE) throw ClassFileParseError("bad magic"); @@ -218,9 +197,9 @@ throw ClassNotFoundException("Class " + classname + " not found"); } -ClassFile* ClassFile::get(const std::string& classname) +const ClassFile* ClassFile::get(const std::string& classname) { - typedef std::map Name2ClassMap; + typedef std::map Name2ClassMap; static Name2ClassMap n2cMap_; Name2ClassMap::iterator it = n2cMap_.lower_bound(classname); @@ -237,20 +216,28 @@ { minorV_ = readU2(is); majorV_ = readU2(is); - readConstantPool(cPool_, is); + // Read constant pool. + uint16_t count = readU2(is); + cPool_.reserve(count); + cPool_.push_back(NULL); + while (cPool_.size() < count) { + cPool_.push_back(Constant::readConstant(this, is)); + if (cPool_.back()->isDoubleSlot()) + cPool_.push_back(NULL); + } accessFlags_ = readU2(is); - thisClass_ = dynamic_cast(cPool_[readU2(is)]); + thisClass_ = getConstantClass(readU2(is)); if (!thisClass_) throw ClassFileSemanticError( "Representation of this class is not of type ConstantClass"); - superClass_ = dynamic_cast(cPool_[readU2(is)]); + superClass_ = getConstantClass(readU2(is)); if (!superClass_ && thisClass_->getName()->str() != "java/lang/Object") throw ClassFileSemanticError( "Representation of super class is not of type ConstantClass"); - readClasses(interfaces_, cPool_, is); - readFields(fields_, this, cPool_, is); - readMethods(methods_, this, cPool_, is); - readAttributes(attributes_, cPool_, is); + readClasses(interfaces_, this, is); + readFields(fields_, this, is); + readMethods(methods_, this, is); + readAttributes(attributes_, this, is); for (Methods::const_iterator i = methods_.begin(), e = methods_.end(); i != e; ++i) n2mMap_.insert( @@ -294,6 +281,20 @@ return static_cast(getConstant(index)); } +ConstantNameAndType* ClassFile::getConstantNameAndType(unsigned index) const +{ + assert(dynamic_cast(getConstant(index)) && + "Constant is not a ConstantNameAndType!"); + return static_cast(getConstant(index)); +} + +ConstantUtf8* ClassFile::getConstantUtf8(unsigned index) const +{ + assert(dynamic_cast(getConstant(index)) && + "Constant is not a ConstantUtf8!"); + return static_cast(getConstant(index)); +} + Method* ClassFile::getMethod(const std::string& nameAndDescr) const { Name2MethodMap::const_iterator it = n2mMap_.find(nameAndDescr); @@ -384,33 +385,32 @@ //===----------------------------------------------------------------------===// // Constant implementation -Constant* Constant::readConstant(const ConstantPool& cp, - std::istream& is) +Constant* Constant::readConstant(const ClassFile* cf, std::istream& is) { Constant::Tag tag = static_cast(readU1(is)); switch (tag) { case Constant::CLASS: - return new ConstantClass(cp, is); + return new ConstantClass(cf, is); case Constant::FIELD_REF: - return new ConstantFieldRef(cp, is); + return new ConstantFieldRef(cf, is); case Constant::METHOD_REF: - return new ConstantMethodRef(cp, is); + return new ConstantMethodRef(cf, is); case Constant::INTERFACE_METHOD_REF: - return new ConstantInterfaceMethodRef(cp, is); + return new ConstantInterfaceMethodRef(cf, is); case Constant::STRING: - return new ConstantString(cp, is); + return new ConstantString(cf, is); case Constant::INTEGER: - return new ConstantInteger(cp, is); + return new ConstantInteger(cf, is); case Constant::FLOAT: - return new ConstantFloat(cp, is); + return new ConstantFloat(cf, is); case Constant::LONG: - return new ConstantLong(cp, is); + return new ConstantLong(cf, is); case Constant::DOUBLE: - return new ConstantDouble(cp, is); + return new ConstantDouble(cf, is); case Constant::NAME_AND_TYPE: - return new ConstantNameAndType(cp, is); + return new ConstantNameAndType(cf, is); case Constant::UTF8: - return new ConstantUtf8(cp, is); + return new ConstantUtf8(cf, is); default: assert(0 && "Unknown constant tag"); } @@ -423,33 +423,33 @@ } -ConstantMemberRef::ConstantMemberRef(const ConstantPool&cp, std::istream& is) - : Constant(cp), - classIdx_(readU2(is)), - nameAndTypeIdx_(readU2(is)) +ConstantClass::ConstantClass(const ClassFile* cf, std::istream& is) + : Constant(cf), + nameIdx_(readU2(is)) { } -std::ostream& ConstantMemberRef::dump(std::ostream& os) const +std::ostream& ConstantClass::dump(std::ostream& os) const { - return os << *getNameAndType() << '(' << *getClass() << ')'; + return os << *getName(); } -ConstantClass::ConstantClass(const ConstantPool& cp, std::istream& is) - : Constant(cp), - nameIdx_(readU2(is)) +ConstantMemberRef::ConstantMemberRef(const ClassFile* cf, std::istream& is) + : Constant(cf), + classIdx_(readU2(is)), + nameAndTypeIdx_(readU2(is)) { } -std::ostream& ConstantClass::dump(std::ostream& os) const +std::ostream& ConstantMemberRef::dump(std::ostream& os) const { - return os << *getName(); + return os << *getNameAndType() << '(' << *getClass() << ')'; } -ConstantString::ConstantString(const ConstantPool& cp, std::istream& is) - : Constant(cp), +ConstantString::ConstantString(const ClassFile* cf, std::istream& is) + : Constant(cf), stringIdx_(readU2(is)) { @@ -460,8 +460,8 @@ return os << "String " << *getValue(); } -ConstantInteger::ConstantInteger(const ConstantPool& cp, std::istream& is) - : Constant(cp), +ConstantInteger::ConstantInteger(const ClassFile* cf, std::istream& is) + : Constant(cf), value_(static_cast(readU4(is))) { @@ -472,8 +472,8 @@ return os << "int " << value_; } -ConstantFloat::ConstantFloat(const ConstantPool& cp, std::istream& is) - : Constant(cp), +ConstantFloat::ConstantFloat(const ClassFile* cf, std::istream& is) + : Constant(cf), value_(int2float(readU4(is))) { @@ -484,8 +484,8 @@ return os << "float " << value_; } -ConstantLong::ConstantLong(const ConstantPool& cp, std::istream& is) - : Constant(cp), +ConstantLong::ConstantLong(const ClassFile* cf, std::istream& is) + : Constant(cf), value_(static_cast(readU8(is))) { @@ -496,8 +496,8 @@ return os << "long " << value_ << 'l'; } -ConstantDouble::ConstantDouble(const ConstantPool& cp, std::istream& is) - : Constant(cp), +ConstantDouble::ConstantDouble(const ClassFile* cf, std::istream& is) + : Constant(cf), value_(long2double(readU8(is))) { @@ -508,9 +508,8 @@ return os << "double " << value_; } -ConstantNameAndType::ConstantNameAndType(const ConstantPool& cp, - std::istream& is) - : Constant(cp), +ConstantNameAndType::ConstantNameAndType(const ClassFile* cf, std::istream& is) + : Constant(cf), nameIdx_(readU2(is)), descriptorIdx_(readU2(is)) { @@ -519,11 +518,16 @@ std::ostream& ConstantNameAndType::dump(std::ostream& os) const { - return os << *getDescriptor() << ' ' << *getName(); + if (getName()->str() == "") + os << "\"\""; + else + os << *getName(); + + return os << ':' << *getDescriptor(); } -ConstantUtf8::ConstantUtf8(const ConstantPool& cp, std::istream& is) - : Constant(cp) +ConstantUtf8::ConstantUtf8(const ClassFile* cf, std::istream& is) + : Constant(cf) { uint16_t length = readU2(is); char *buf = (char *)alloca(length); @@ -541,19 +545,19 @@ //===----------------------------------------------------------------------===// // Field implementation -Field::Field(ClassFile* parent, const ConstantPool& cp, std::istream& is) +Field::Field(const ClassFile* parent, std::istream& is) : parent_(parent) { accessFlags_ = readU2(is); - name_ = dynamic_cast(cp[readU2(is)]); + name_ = parent_->getConstantUtf8(readU2(is)); if (!name_) throw ClassFileSemanticError( "Representation of field name is not of type ConstantUtf8"); - descriptor_ = dynamic_cast(cp[readU2(is)]); + descriptor_ = parent_->getConstantUtf8(readU2(is)); if (!descriptor_) throw ClassFileSemanticError( "Representation of field descriptor is not of type ConstantUtf8"); - readAttributes(attributes_, cp, is); + readAttributes(attributes_, parent_, is); } Field::~Field() @@ -589,19 +593,19 @@ //===----------------------------------------------------------------------===// // Method implementation -Method::Method(ClassFile* parent, const ConstantPool& cp, std::istream& is) +Method::Method(const ClassFile* parent, std::istream& is) : parent_(parent) { accessFlags_ = readU2(is); - name_ = dynamic_cast(cp[readU2(is)]); + name_ = parent_->getConstantUtf8(readU2(is)); if (!name_) throw ClassFileSemanticError( "Representation of method name is not of type ConstantUtf8"); - descriptor_ = dynamic_cast(cp[readU2(is)]); + descriptor_ = parent_->getConstantUtf8(readU2(is)); if (!descriptor_) throw ClassFileSemanticError( "Representation of method descriptor is not of type ConstantUtf8"); - readAttributes(attributes_, cp, is); + readAttributes(attributes_, parent_, is); } Method::~Method() @@ -650,27 +654,25 @@ const std::string Attribute::LOCAL_VARIABLE_TABLE = "LocalVariableTable"; const std::string Attribute::DEPRECATED = "Deprecated"; -Attribute* Attribute::readAttribute(const ConstantPool& cp, std::istream& is) +Attribute* Attribute::readAttribute(const ClassFile* cf, std::istream& is) { - ConstantUtf8* name = dynamic_cast(cp[readU2(is)]); + ConstantUtf8* name = cf->getConstantUtf8(readU2(is)); if (!name) throw ClassFileSemanticError( "Representation of attribute name is not of type ConstantUtf8"); if (CONSTANT_VALUE == name->str()) - return new ConstantValueAttribute(name, cp, is); + return new ConstantValueAttribute(name, cf, is); else if (CODE == name->str()) - return new CodeAttribute(name, cp, is); + return new CodeAttribute(name, cf, is); else { uint32_t length = readU4(is); is.ignore(length); - return new Attribute(name, cp, is); + return new Attribute(name, cf, is); } } -Attribute::Attribute(ConstantUtf8* name, - const ConstantPool& cp, - std::istream& is) +Attribute::Attribute(ConstantUtf8* name, const ClassFile* cf, std::istream& is) : name_(name) { @@ -689,15 +691,15 @@ //===----------------------------------------------------------------------===// // AttributeConstantValue implementation ConstantValueAttribute::ConstantValueAttribute(ConstantUtf8* name, - const ConstantPool& cp, + const ClassFile* cf, std::istream& is) - : Attribute(name, cp, is) + : Attribute(name, cf, is) { uint32_t length = readU4(is); if (length != 2) throw ClassFileSemanticError( "Length of ConstantValueAttribute is not 2"); - value_ = cp[readU2(is)]; + value_ = cf->getConstant(readU2(is)); } std::ostream& ConstantValueAttribute::dump(std::ostream& os) const @@ -708,9 +710,9 @@ //===----------------------------------------------------------------------===// // AttributeCode implementation CodeAttribute::CodeAttribute(ConstantUtf8* name, - const ConstantPool& cp, + const ClassFile* cf, std::istream& is) - : Attribute(name, cp, is) + : Attribute(name, cf, is) { uint32_t length = readU4(is); maxStack_ = readU2(is); @@ -724,8 +726,8 @@ uint16_t exceptCount = readU2(is); exceptions_.reserve(exceptCount); while (exceptCount--) - exceptions_.push_back(new Exception(cp, is)); - readAttributes(attributes_, cp, is); + exceptions_.push_back(new Exception(cf, is)); + readAttributes(attributes_, cf, is); } CodeAttribute::~CodeAttribute() @@ -748,8 +750,7 @@ return os; } -CodeAttribute::Exception::Exception(const ConstantPool& cp, - std::istream& is) +CodeAttribute::Exception::Exception(const ClassFile* cf, std::istream& is) : catchType_(NULL) { startPc_ = readU2(is); @@ -757,7 +758,7 @@ handlerPc_ = readU2(is); uint16_t idx = readU2(is); if (idx) { - catchType_ = dynamic_cast(cp[idx]); + catchType_ = cf->getConstantClass(idx); if (!catchType_) throw ClassFileSemanticError ("Representation of catch type is not of type ConstantClass"); @@ -778,12 +779,12 @@ //===----------------------------------------------------------------------===// // AttributeExceptions implementation ExceptionsAttribute::ExceptionsAttribute(ConstantUtf8* name, - const ConstantPool& cp, + const ClassFile* cf, std::istream& is) - : Attribute(name, cp, is) + : Attribute(name, cf, is) { uint32_t length = readU4(is); - readClasses(exceptions_, cp, is); + readClasses(exceptions_, cf, is); } std::ostream& ExceptionsAttribute::dump(std::ostream& os) const From alkis at cs.uiuc.edu Sat Feb 12 14:39:33 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 12 Feb 2005 14:39:33 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/ClassFile/ClassFile.cpp Message-ID: <200502122039.OAA07850@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/ClassFile: ClassFile.cpp updated: 1.39 -> 1.40 --- Log message: Now that we have parent pointers, shrink the Field and Method classes a bit by storing indices to the constant pool instead of pointers to the constants themselves. While we are at it introduce a non-instanciable class Member that both Field and Method inherit from. --- Diffs of the changes: (+22 -24) ClassFile.cpp | 46 ++++++++++++++++++++++------------------------ 1 files changed, 22 insertions(+), 24 deletions(-) Index: llvm-java/lib/ClassFile/ClassFile.cpp diff -u llvm-java/lib/ClassFile/ClassFile.cpp:1.39 llvm-java/lib/ClassFile/ClassFile.cpp:1.40 --- llvm-java/lib/ClassFile/ClassFile.cpp:1.39 Sat Feb 12 14:17:57 2005 +++ llvm-java/lib/ClassFile/ClassFile.cpp Sat Feb 12 14:38:41 2005 @@ -544,25 +544,32 @@ } //===----------------------------------------------------------------------===// +// Member implementation +Member::Member(const ClassFile* parent, std::istream& is) + : parent_(parent), + accessFlags_(readU2(is)), + nameIdx_(readU2(is)), + descriptorIdx_(readU2(is)) +{ + readAttributes(attributes_, parent_, is); +} + +Member::~Member() +{ + for_each(attributes_.begin(), attributes_.end(), deleter); +} + +//===----------------------------------------------------------------------===// // Field implementation Field::Field(const ClassFile* parent, std::istream& is) - : parent_(parent) + : Member(parent, is) { - accessFlags_ = readU2(is); - name_ = parent_->getConstantUtf8(readU2(is)); - if (!name_) - throw ClassFileSemanticError( - "Representation of field name is not of type ConstantUtf8"); - descriptor_ = parent_->getConstantUtf8(readU2(is)); - if (!descriptor_) - throw ClassFileSemanticError( - "Representation of field descriptor is not of type ConstantUtf8"); - readAttributes(attributes_, parent_, is); + } Field::~Field() { - for_each(attributes_.begin(), attributes_.end(), deleter); + } std::ostream& Field::dump(std::ostream& os) const @@ -594,23 +601,14 @@ //===----------------------------------------------------------------------===// // Method implementation Method::Method(const ClassFile* parent, std::istream& is) - : parent_(parent) + : Member(parent, is) { - accessFlags_ = readU2(is); - name_ = parent_->getConstantUtf8(readU2(is)); - if (!name_) - throw ClassFileSemanticError( - "Representation of method name is not of type ConstantUtf8"); - descriptor_ = parent_->getConstantUtf8(readU2(is)); - if (!descriptor_) - throw ClassFileSemanticError( - "Representation of method descriptor is not of type ConstantUtf8"); - readAttributes(attributes_, parent_, is); + } Method::~Method() { - for_each(attributes_.begin(), attributes_.end(), deleter); + } std::ostream& Method::dump(std::ostream& os) const From alkis at cs.uiuc.edu Sat Feb 12 14:39:42 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 12 Feb 2005 14:39:42 -0600 Subject: [llvm-commits] CVS: llvm-java/include/llvm/Java/ClassFile.h Message-ID: <200502122039.OAA07861@zion.cs.uiuc.edu> Changes in directory llvm-java/include/llvm/Java: ClassFile.h updated: 1.30 -> 1.31 --- Log message: Now that we have parent pointers, shrink the Field and Method classes a bit by storing indices to the constant pool instead of pointers to the constants themselves. While we are at it introduce a non-instanciable class Member that both Field and Method inherit from. --- Diffs of the changes: (+26 -32) ClassFile.h | 58 ++++++++++++++++++++++++++-------------------------------- 1 files changed, 26 insertions(+), 32 deletions(-) Index: llvm-java/include/llvm/Java/ClassFile.h diff -u llvm-java/include/llvm/Java/ClassFile.h:1.30 llvm-java/include/llvm/Java/ClassFile.h:1.31 --- llvm-java/include/llvm/Java/ClassFile.h:1.30 Sat Feb 12 14:17:57 2005 +++ llvm-java/include/llvm/Java/ClassFile.h Sat Feb 12 14:38:50 2005 @@ -283,14 +283,34 @@ std::ostream& dump(std::ostream& os) const; }; - class Field { - private: + class Member { + protected: const ClassFile* parent_; uint16_t accessFlags_; - ConstantUtf8* name_; - ConstantUtf8* descriptor_; + uint16_t nameIdx_; + uint16_t descriptorIdx_; Attributes attributes_; + Member(const ClassFile* parent, std::istream& is); + ~Member(); + +public: + bool isPublic() const { return accessFlags_ & ACC_PUBLIC; } + bool isPrivate() const { return accessFlags_ & ACC_PRIVATE; } + bool isProtected() const { return accessFlags_ & ACC_PROTECTED; } + bool isStatic() const { return accessFlags_ & ACC_STATIC; } + bool isFinal() const { return accessFlags_ & ACC_FINAL; } + + const ClassFile* getParent() const { return parent_; } + ConstantUtf8* getName() const { return parent_->getConstantUtf8(nameIdx_); } + ConstantUtf8* getDescriptor() const { + return parent_->getConstantUtf8(descriptorIdx_); + } + const Attributes& getAttributes() const { return attributes_; } + }; + + class Field : public Member { + private: Field(const ClassFile* parent, std::istream& is); public: @@ -300,18 +320,9 @@ ~Field(); - bool isPublic() const { return accessFlags_ & ACC_PUBLIC; } - bool isPrivate() const { return accessFlags_ & ACC_PRIVATE; } - bool isProtected() const { return accessFlags_ & ACC_PROTECTED; } - bool isStatic() const { return accessFlags_ & ACC_STATIC; } - bool isFinal() const { return accessFlags_ & ACC_FINAL; } bool isVolatile() const { return accessFlags_ & ACC_VOLATILE; } bool isTransient() const { return accessFlags_ & ACC_TRANSIENT; } - const ClassFile* getParent() const { return parent_; } - ConstantUtf8* getName() const { return name_; } - ConstantUtf8* getDescriptor() const { return descriptor_; } - const Attributes& getAttributes() const { return attributes_; } ConstantValueAttribute* getConstantValueAttribute() const; std::ostream& dump(std::ostream& os) const; @@ -321,13 +332,7 @@ return f.dump(os); } - class Method { - const ClassFile* parent_; - uint16_t accessFlags_; - ConstantUtf8* name_; - ConstantUtf8* descriptor_; - Attributes attributes_; - + class Method : public Member { Method(const ClassFile* parent, std::istream& is); public: @@ -337,20 +342,11 @@ ~Method(); - bool isPublic() const { return accessFlags_ & ACC_PUBLIC; } - bool isPrivate() const { return accessFlags_ & ACC_PRIVATE; } - bool isProtected() const { return accessFlags_ & ACC_PROTECTED; } - bool isStatic() const { return accessFlags_ & ACC_STATIC; } - bool isFinal() const { return accessFlags_ & ACC_FINAL; } bool isSynchronized() const { return accessFlags_ & ACC_SYNCHRONIZED; } bool isNative() const { return accessFlags_ & ACC_NATIVE; } bool isAbstract() const { return accessFlags_ & ACC_ABSTRACT; } bool isStrict() const { return accessFlags_ & ACC_STRICT; } - const ClassFile* getParent() const { return parent_; } - ConstantUtf8* getName() const { return name_; } - ConstantUtf8* getDescriptor() const { return descriptor_; } - const Attributes& getAttributes() const { return attributes_; } CodeAttribute* getCodeAttribute() const; ExceptionsAttribute* getExceptionsAttribute() const; @@ -433,9 +429,7 @@ Attributes attributes_; public: - CodeAttribute(ConstantUtf8* name, - const ClassFile* cf, - std::istream& is); + CodeAttribute(ConstantUtf8* name, const ClassFile* cf, std::istream& is); ~CodeAttribute(); uint16_t getMaxStack() const { return maxStack_; } uint16_t getMaxLocals() const { return maxLocals_; } From alenhar2 at cs.uiuc.edu Sat Feb 12 14:42:24 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Sat, 12 Feb 2005 14:42:24 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp Message-ID: <200502122042.j1CKgOie016297@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.50 -> 1.51 --- Log message: oops, I was sure this had already gond though the nightly tester --- Diffs of the changes: (+1 -1) AlphaISelPattern.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.50 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.51 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.50 Sat Feb 12 13:35:12 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Sat Feb 12 14:42:09 2005 @@ -959,7 +959,7 @@ case MVT::i1: Tmp2 = MakeReg(MVT::i64); BuildMI(BB, Alpha::ANDi, 2, Tmp2).addReg(Tmp1).addImm(1); - BuildMI(BB, Alpha::SUB, 2, Result).addReg(Alpha::F31).addReg(Tmp2); + BuildMI(BB, Alpha::SUBQ, 2, Result).addReg(Alpha::F31).addReg(Tmp2); break; } return Result; From alenhar2 at cs.uiuc.edu Sat Feb 12 15:11:13 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Sat, 12 Feb 2005 15:11:13 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaInstrInfo.td Message-ID: <200502122111.j1CLBDrQ016358@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaInstrInfo.td updated: 1.24 -> 1.25 --- Log message: make FP conversion more conservative (matches gcc) --- Diffs of the changes: (+4 -3) AlphaInstrInfo.td | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) Index: llvm/lib/Target/Alpha/AlphaInstrInfo.td diff -u llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.24 llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.25 --- llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.24 Thu Feb 10 00:25:22 2005 +++ llvm/lib/Target/Alpha/AlphaInstrInfo.td Sat Feb 12 15:10:58 2005 @@ -356,11 +356,12 @@ //CVTLQ F-P 17.010 Convert longword to quadword //CVTQL F-P 17.030 Convert quadword to longword +//These use SW completion, may not have function code for that set right (matters for JIT) def CVTQS : FPForm<0x16, 0x0BC, (ops FPRC:$RC, FPRC:$RA), "cvtqs $RA,$RC">; //Convert quadword to S_floating def CVTQT : FPForm<0x16, 0x0BE, (ops FPRC:$RC, FPRC:$RA), "cvtqt $RA,$RC">; //Convert quadword to T_floating -def CVTST : FPForm<0x16, 0x2AC, (ops FPRC:$RC, FPRC:$RA), "cvtsts $RA,$RC">; //Convert S_floating to T_floating (use completion, may not have function code for that set right) -def CVTTQ : FPForm<0x16, 0x0AF, (ops FPRC:$RC, FPRC:$RA), "cvttq $RA,$RC">; //Convert T_floating to quadword -def CVTTS : FPForm<0x16, 0x2AC, (ops FPRC:$RC, FPRC:$RA), "cvtts $RA,$RC">; //Convert T_floating to S_floating +def CVTST : FPForm<0x16, 0x2AC, (ops FPRC:$RC, FPRC:$RA), "cvtsts $RA,$RC">; //Convert S_floating to T_floating +def CVTTQ : FPForm<0x16, 0x0AF, (ops FPRC:$RC, FPRC:$RA), "cvttq/svc $RA,$RC">; //Convert T_floating to quadword +def CVTTS : FPForm<0x16, 0x2AC, (ops FPRC:$RC, FPRC:$RA), "cvtts/su $RA,$RC">; //Convert T_floating to S_floating //S_floating : IEEE Single //T_floating : IEEE Double From alenhar2 at cs.uiuc.edu Sat Feb 12 15:11:30 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Sat, 12 Feb 2005 15:11:30 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp Message-ID: <200502122111.j1CLBUCL016375@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.51 -> 1.52 --- Log message: try to do better match for i32 adds --- Diffs of the changes: (+22 -1) AlphaISelPattern.cpp | 23 ++++++++++++++++++++++- 1 files changed, 22 insertions(+), 1 deletion(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.51 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.52 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.51 Sat Feb 12 14:42:09 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Sat Feb 12 15:11:17 2005 @@ -920,13 +920,34 @@ cast(N.getOperand(0).getOperand(1))->getValue() <= 255) { //Normal imm add/sub Opc = isAdd ? Alpha::ADDLi : (isMul ? Alpha::MULLi : Alpha::SUBLi); - Tmp1 = SelectExpr(N.getOperand(0).getOperand(0)); + //if the value was really originally a i32, skip the up conversion + if (N.getOperand(0).getOperand(0).getOpcode() == ISD::SIGN_EXTEND_INREG && + dyn_cast(N.getOperand(0).getOperand(0).Val) + ->getExtraValueType() == MVT::i32) + Tmp1 = SelectExpr(N.getOperand(0).getOperand(0).getOperand(0)); + else + Tmp1 = SelectExpr(N.getOperand(0).getOperand(0)); Tmp2 = cast(N.getOperand(0).getOperand(1))->getValue(); BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addImm(Tmp2); } else { //Normal add/sub Opc = isAdd ? Alpha::ADDL : (isMul ? Alpha::MULLi : Alpha::SUBL); + //if the value was really originally a i32, skip the up conversion + if (N.getOperand(0).getOperand(0).getOpcode() == ISD::SIGN_EXTEND_INREG && + dyn_cast(N.getOperand(0).getOperand(0).Val) + ->getExtraValueType() == MVT::i32) + Tmp1 = SelectExpr(N.getOperand(0).getOperand(0).getOperand(0)); + else + Tmp1 = SelectExpr(N.getOperand(0).getOperand(0)); + //if the value was really originally a i32, skip the up conversion + if (N.getOperand(0).getOperand(1).getOpcode() == ISD::SIGN_EXTEND_INREG && + dyn_cast(N.getOperand(0).getOperand(1).Val) + ->getExtraValueType() == MVT::i32) + Tmp2 = SelectExpr(N.getOperand(0).getOperand(1).getOperand(0)); + else + Tmp2 = SelectExpr(N.getOperand(0).getOperand(1)); + Tmp1 = SelectExpr(N.getOperand(0).getOperand(0)); Tmp2 = SelectExpr(N.getOperand(0).getOperand(1)); BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); From lattner at cs.uiuc.edu Sat Feb 12 19:41:29 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 12 Feb 2005 19:41:29 -0600 Subject: [llvm-commits] CVS: llvm-www/robots.txt Message-ID: <200502130141.j1D1fT3O019240@apoc.cs.uiuc.edu> Changes in directory llvm-www: robots.txt added (r1.1) --- Log message: Stop crawlers from hitting the bug database hopefully. --- Diffs of the changes: (+3 -0) robots.txt | 3 +++ 1 files changed, 3 insertions(+) Index: llvm-www/robots.txt diff -c /dev/null llvm-www/robots.txt:1.1 *** /dev/null Sat Feb 12 19:41:24 2005 --- llvm-www/robots.txt Sat Feb 12 19:41:14 2005 *************** *** 0 **** --- 1,3 ---- + User-agent: * + Disallow: /bugs + Disallow: /stats From alenhar2 at cs.uiuc.edu Sat Feb 12 21:41:26 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Sat, 12 Feb 2005 21:41:26 -0600 Subject: [llvm-commits] CVS: llvm/Makefile.rules Message-ID: <200502130341.j1D3fQQU022653@apoc.cs.uiuc.edu> Changes in directory llvm: Makefile.rules updated: 1.295 -> 1.296 --- Log message: non-ieee arith crashes passes on alpha --- Diffs of the changes: (+6 -0) Makefile.rules | 6 ++++++ 1 files changed, 6 insertions(+) Index: llvm/Makefile.rules diff -u llvm/Makefile.rules:1.295 llvm/Makefile.rules:1.296 --- llvm/Makefile.rules:1.295 Tue Feb 8 20:24:00 2005 +++ llvm/Makefile.rules Sat Feb 12 21:41:10 2005 @@ -228,6 +228,12 @@ AR.Flags := cru LibTool.Flags := --tag=CXX +#Make Floating point ieee complient on alpha +ifeq ($(ARCH),Alpha) + CXX.Flags += -mieee + CPP.Flags += -mieee +endif + #-------------------------------------------------------------------- # Directory locations #-------------------------------------------------------------------- From lattner at cs.uiuc.edu Sat Feb 12 22:35:07 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 12 Feb 2005 22:35:07 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/ScalarEvolution.h ScalarEvolutionExpressions.h Message-ID: <200502130435.j1D4Z7Zg025696@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: ScalarEvolution.h updated: 1.7 -> 1.8 ScalarEvolutionExpressions.h updated: 1.3 -> 1.4 --- Log message: Add a new replaceSymbolicValuesWithConcrete method to the SCEV class, adjust const'ness a bit to be more correct. --- Diffs of the changes: (+59 -5) ScalarEvolution.h | 21 ++++++++++++++++----- ScalarEvolutionExpressions.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 5 deletions(-) Index: llvm/include/llvm/Analysis/ScalarEvolution.h diff -u llvm/include/llvm/Analysis/ScalarEvolution.h:1.7 llvm/include/llvm/Analysis/ScalarEvolution.h:1.8 --- llvm/include/llvm/Analysis/ScalarEvolution.h:1.7 Mon Dec 6 22:03:45 2004 +++ llvm/include/llvm/Analysis/ScalarEvolution.h Sat Feb 12 22:34:51 2005 @@ -38,11 +38,11 @@ /// class SCEV { const unsigned SCEVType; // The SCEV baseclass this node corresponds to - unsigned RefCount; + mutable unsigned RefCount; friend class SCEVHandle; - void addRef() { ++RefCount; } - void dropRef() { + void addRef() const { ++RefCount; } + void dropRef() const { if (--RefCount == 0) delete this; } @@ -74,6 +74,15 @@ /// virtual const Type *getType() const = 0; + /// replaceSymbolicValuesWithConcrete - If this SCEV internally references + /// the symbolic value "Sym", construct and return a new SCEV that produces + /// the same value, but which uses the concrete value Conc instead of the + /// symbolic value. If this SCEV does not use the symbolic value, it + /// returns itself. + virtual SCEVHandle + replaceSymbolicValuesWithConcrete(const SCEVHandle &Sym, + const SCEVHandle &Conc) const = 0; + /// print - Print out the internal representation of this scalar to the /// specified stream. This should really only be used for debugging /// purposes. @@ -102,7 +111,9 @@ virtual const Type *getType() const; virtual bool hasComputableLoopEvolution(const Loop *L) const; virtual void print(std::ostream &OS) const; - + virtual SCEVHandle + replaceSymbolicValuesWithConcrete(const SCEVHandle &Sym, + const SCEVHandle &Conc) const; /// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const SCEVCouldNotCompute *S) { return true; } @@ -115,7 +126,7 @@ SCEV *S; SCEVHandle(); // DO NOT IMPLEMENT public: - SCEVHandle(SCEV *s) : S(s) { + SCEVHandle(const SCEV *s) : S(const_cast(s)) { assert(S && "Cannot create a handle to a null SCEV!"); S->addRef(); } Index: llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h diff -u llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h:1.3 llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h:1.4 --- llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h:1.3 Tue Apr 27 13:21:56 2004 +++ llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h Sat Feb 12 22:34:51 2005 @@ -56,6 +56,11 @@ virtual const Type *getType() const; + SCEVHandle replaceSymbolicValuesWithConcrete(const SCEVHandle &Sym, + const SCEVHandle &Conc) const { + return this; + } + virtual void print(std::ostream &OS) const; /// Methods for support type inquiry through isa, cast, and dyn_cast: @@ -90,6 +95,14 @@ return Op->hasComputableLoopEvolution(L); } + SCEVHandle replaceSymbolicValuesWithConcrete(const SCEVHandle &Sym, + const SCEVHandle &Conc) const { + SCEVHandle H = Op->replaceSymbolicValuesWithConcrete(Sym, Conc); + if (H == Op) + return this; + return get(H, Ty); + } + /// getValueRange - Return the tightest constant bounds that this value is /// known to have. This method is only valid on integer SCEV objects. virtual ConstantRange getValueRange() const; @@ -132,6 +145,14 @@ /// known to have. This method is only valid on integer SCEV objects. virtual ConstantRange getValueRange() const; + SCEVHandle replaceSymbolicValuesWithConcrete(const SCEVHandle &Sym, + const SCEVHandle &Conc) const { + SCEVHandle H = Op->replaceSymbolicValuesWithConcrete(Sym, Conc); + if (H == Op) + return this; + return get(H, Ty); + } + virtual void print(std::ostream &OS) const; /// Methods for support type inquiry through isa, cast, and dyn_cast: @@ -182,6 +203,9 @@ return false; } + SCEVHandle replaceSymbolicValuesWithConcrete(const SCEVHandle &Sym, + const SCEVHandle &Conc) const; + virtual const char *getOperationStr() const = 0; virtual const Type *getType() const { return getOperand(0)->getType(); } @@ -286,6 +310,17 @@ RHS->hasComputableLoopEvolution(L); } + SCEVHandle replaceSymbolicValuesWithConcrete(const SCEVHandle &Sym, + const SCEVHandle &Conc) const { + SCEVHandle L = LHS->replaceSymbolicValuesWithConcrete(Sym, Conc); + SCEVHandle R = RHS->replaceSymbolicValuesWithConcrete(Sym, Conc); + if (L == LHS && R == RHS) + return this; + else + return get(L, R); + } + + virtual const Type *getType() const; void print(std::ostream &OS) const; @@ -383,6 +418,8 @@ /// returned. SCEVHandle getNumIterationsInRange(ConstantRange Range) const; + SCEVHandle replaceSymbolicValuesWithConcrete(const SCEVHandle &Sym, + const SCEVHandle &Conc) const; virtual void print(std::ostream &OS) const; @@ -420,6 +457,12 @@ return false; // not computable } + SCEVHandle replaceSymbolicValuesWithConcrete(const SCEVHandle &Sym, + const SCEVHandle &Conc) const { + if (&*Sym == this) return Conc; + return this; + } + virtual const Type *getType() const; virtual void print(std::ostream &OS) const; From lattner at cs.uiuc.edu Sat Feb 12 22:37:33 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 12 Feb 2005 22:37:33 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/ScalarEvolution.cpp Message-ID: <200502130437.j1D4bXCE025795@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: ScalarEvolution.cpp updated: 1.31 -> 1.32 --- Log message: Correct the recursive PHI node handling routines in a way that CANNOT induce infinite loops (using the new replaceSymbolicValuesWithConcrete method). This patch reverts this patch: http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20050131/023830.html ... which was an attempted fix for this problem. Unfortunately, that patch caused test/Regression/Transforms/IndVarsSimplify/exit_value_tests.llx to fail and slightly castrated the entire analysis. This patch fixes it right. This patch is dedicated to jeffc, for making me deal with this. :) --- Diffs of the changes: (+83 -27) ScalarEvolution.cpp | 110 +++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 83 insertions(+), 27 deletions(-) Index: llvm/lib/Analysis/ScalarEvolution.cpp diff -u llvm/lib/Analysis/ScalarEvolution.cpp:1.31 llvm/lib/Analysis/ScalarEvolution.cpp:1.32 --- llvm/lib/Analysis/ScalarEvolution.cpp:1.31 Mon Jan 31 18:18:30 2005 +++ llvm/lib/Analysis/ScalarEvolution.cpp Sat Feb 12 22:37:18 2005 @@ -144,6 +144,12 @@ return false; } +SCEVHandle SCEVCouldNotCompute:: +replaceSymbolicValuesWithConcrete(const SCEVHandle &Sym, + const SCEVHandle &Conc) const { + return this; +} + void SCEVCouldNotCompute::print(std::ostream &OS) const { OS << "***COULDNOTCOMPUTE***"; } @@ -259,6 +265,33 @@ OS << ")"; } +SCEVHandle SCEVCommutativeExpr:: +replaceSymbolicValuesWithConcrete(const SCEVHandle &Sym, + const SCEVHandle &Conc) const { + for (unsigned i = 0, e = getNumOperands(); i != e; ++i) { + SCEVHandle H = getOperand(i)->replaceSymbolicValuesWithConcrete(Sym, Conc); + if (H != getOperand(i)) { + std::vector NewOps; + NewOps.reserve(getNumOperands()); + for (unsigned j = 0; j != i; ++j) + NewOps.push_back(getOperand(j)); + NewOps.push_back(H); + for (++i; i != e; ++i) + NewOps.push_back(getOperand(i)-> + replaceSymbolicValuesWithConcrete(Sym, Conc)); + + if (isa(this)) + return SCEVAddExpr::get(NewOps); + else if (isa(this)) + return SCEVMulExpr::get(NewOps); + else + assert(0 && "Unknown commutative expr!"); + } + } + return this; +} + + // SCEVUDivs - Only allow the creation of one SCEVUDivExpr for any particular // input. Don't use a SCEVHandle here, or else the object will never be // deleted! @@ -290,6 +323,28 @@ Operands.end()))); } +SCEVHandle SCEVAddRecExpr:: +replaceSymbolicValuesWithConcrete(const SCEVHandle &Sym, + const SCEVHandle &Conc) const { + for (unsigned i = 0, e = getNumOperands(); i != e; ++i) { + SCEVHandle H = getOperand(i)->replaceSymbolicValuesWithConcrete(Sym, Conc); + if (H != getOperand(i)) { + std::vector NewOps; + NewOps.reserve(getNumOperands()); + for (unsigned j = 0; j != i; ++j) + NewOps.push_back(getOperand(j)); + NewOps.push_back(H); + for (++i; i != e; ++i) + NewOps.push_back(getOperand(i)-> + replaceSymbolicValuesWithConcrete(Sym, Conc)); + + return get(NewOps, L); + } + } + return this; +} + + bool SCEVAddRecExpr::isLoopInvariant(const Loop *QueryLoop) const { // This recurrence is invariant w.r.t to QueryLoop iff QueryLoop doesn't // contain L. @@ -1086,8 +1141,14 @@ /// createNodeForPHI - Provide the special handling we need to analyze PHI /// SCEVs. SCEVHandle createNodeForPHI(PHINode *PN); - void UpdatePHIUserScalarEntries(Instruction *I, PHINode *PN, - std::set &UpdatedInsts); + + /// ReplaceSymbolicValueWithConcrete - This looks up the computed SCEV value + /// for the specified instruction and replaces any references to the + /// symbolic value SymName with the specified value. This is used during + /// PHI resolution. + void ReplaceSymbolicValueWithConcrete(Instruction *I, + const SCEVHandle &SymName, + const SCEVHandle &NewVal); /// ComputeIterationCount - Compute the number of times the specified loop /// will iterate. @@ -1153,26 +1214,27 @@ return S; } - -/// UpdatePHIUserScalarEntries - After PHI node analysis, we have a bunch of -/// entries in the scalar map that refer to the "symbolic" PHI value instead of -/// the recurrence value. After we resolve the PHI we must loop over all of the -/// using instructions that have scalar map entries and update them. -void ScalarEvolutionsImpl::UpdatePHIUserScalarEntries(Instruction *I, - PHINode *PN, - std::set &UpdatedInsts) { +/// ReplaceSymbolicValueWithConcrete - This looks up the computed SCEV value for +/// the specified instruction and replaces any references to the symbolic value +/// SymName with the specified value. This is used during PHI resolution. +void ScalarEvolutionsImpl:: +ReplaceSymbolicValueWithConcrete(Instruction *I, const SCEVHandle &SymName, + const SCEVHandle &NewVal) { std::map::iterator SI = Scalars.find(I); - if (SI == Scalars.end()) return; // This scalar wasn't previous processed. - if (UpdatedInsts.insert(I).second && !isa(PN)) { - Scalars.erase(SI); // Remove the old entry - getSCEV(I); // Calculate the new entry - - for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); - UI != E; ++UI) - UpdatePHIUserScalarEntries(cast(*UI), PN, UpdatedInsts); - } -} + if (SI == Scalars.end()) return; + SCEVHandle NV = + SI->second->replaceSymbolicValuesWithConcrete(SymName, NewVal); + if (NV == SI->second) return; // No change. + + SI->second = NV; // Update the scalars map! + + // Any instruction values that use this instruction might also need to be + // updated! + for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); + UI != E; ++UI) + ReplaceSymbolicValueWithConcrete(cast(*UI), SymName, NewVal); +} /// createNodeForPHI - PHI nodes have two cases. Either the PHI node exists in /// a loop header, making it a potential recurrence, or it doesn't. @@ -1233,13 +1295,7 @@ // entries for the scalars that use the PHI (except for the PHI // itself) to use the new analyzed value instead of the "symbolic" // value. - Scalars.find(PN)->second = PHISCEV; // Update the PHI value - std::set UpdatedInsts; - UpdatedInsts.insert(PN); - for (Value::use_iterator UI = PN->use_begin(), E = PN->use_end(); - UI != E; ++UI) - UpdatePHIUserScalarEntries(cast(*UI), PN, - UpdatedInsts); + ReplaceSymbolicValueWithConcrete(PN, SymbolicName, PHISCEV); return PHISCEV; } } From reid at x10sys.com Sun Feb 13 01:34:28 2005 From: reid at x10sys.com (Reid Spencer) Date: Sun, 13 Feb 2005 01:34:28 -0600 Subject: [llvm-commits] CVS: llvm/tools/llvm-ranlib/llvm-ranlib.cpp Message-ID: <200502130734.BAA19509@zion.cs.uiuc.edu> Changes in directory llvm/tools/llvm-ranlib: llvm-ranlib.cpp updated: 1.4 -> 1.5 --- Log message: Fix PR506: http://llvm.cs.uiuc.edu/PR506 : * Use error returned from Archive::OpenAndLoad * Make sure only std::string is thrown so it gets caught and printed. --- Diffs of the changes: (+6 -4) llvm-ranlib.cpp | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) Index: llvm/tools/llvm-ranlib/llvm-ranlib.cpp diff -u llvm/tools/llvm-ranlib/llvm-ranlib.cpp:1.4 llvm/tools/llvm-ranlib/llvm-ranlib.cpp:1.5 --- llvm/tools/llvm-ranlib/llvm-ranlib.cpp:1.4 Thu Dec 30 11:51:57 2004 +++ llvm/tools/llvm-ranlib/llvm-ranlib.cpp Sun Feb 13 01:34:17 2005 @@ -64,12 +64,14 @@ // Make sure it exists, we don't create empty archives if (!ArchivePath.exists()) - throw "Archive file does not exist"; + throw std::string("Archive file does not exist"); - std::auto_ptr AutoArchive(Archive::OpenAndLoad(ArchivePath)); + std::string err_msg; + std::auto_ptr + AutoArchive(Archive::OpenAndLoad(ArchivePath,&err_msg)); Archive* TheArchive = AutoArchive.get(); - - assert(TheArchive && "Unable to instantiate the archive"); + if (!TheArchive) + throw err_msg; TheArchive->writeToDisk(true, false, false ); From lattner at cs.uiuc.edu Sun Feb 13 09:26:30 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 13 Feb 2005 09:26:30 -0600 Subject: [llvm-commits] CVS: llvm/lib/Linker/LinkArchives.cpp Message-ID: <200502131526.j1DFQUIW000718@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Linker: LinkArchives.cpp updated: 1.44 -> 1.45 --- Log message: Print something useful for gccld -v with an archive. --- Diffs of the changes: (+2 -0) LinkArchives.cpp | 2 ++ 1 files changed, 2 insertions(+) Index: llvm/lib/Linker/LinkArchives.cpp diff -u llvm/lib/Linker/LinkArchives.cpp:1.44 llvm/lib/Linker/LinkArchives.cpp:1.45 --- llvm/lib/Linker/LinkArchives.cpp:1.44 Sun Dec 19 22:15:44 2004 +++ llvm/lib/Linker/LinkArchives.cpp Sun Feb 13 09:26:14 2005 @@ -151,6 +151,8 @@ std::auto_ptr AutoModule( (*I)->releaseModule() ); Module* aModule = AutoModule.get(); + verbose(" Linking in module: " + aModule->getModuleIdentifier()); + // Link it in if (this->LinkInModule(aModule)) return error("Cannot link in module '" + From lattner at cs.uiuc.edu Sun Feb 13 09:44:29 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 13 Feb 2005 09:44:29 -0600 Subject: [llvm-commits] CVS: llvm-www/robots.txt Message-ID: <200502131544.j1DFiT02000817@apoc.cs.uiuc.edu> Changes in directory llvm-www: robots.txt updated: 1.1 -> 1.2 --- Log message: Shut off more spiders --- Diffs of the changes: (+1 -0) robots.txt | 1 + 1 files changed, 1 insertion(+) Index: llvm-www/robots.txt diff -u llvm-www/robots.txt:1.1 llvm-www/robots.txt:1.2 --- llvm-www/robots.txt:1.1 Sat Feb 12 19:41:14 2005 +++ llvm-www/robots.txt Sun Feb 13 09:44:16 2005 @@ -1,3 +1,4 @@ User-agent: * Disallow: /bugs Disallow: /stats +Disallow: /testresults/X86 From lattner at cs.uiuc.edu Sun Feb 13 09:57:36 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 13 Feb 2005 09:57:36 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Message-ID: <200502131557.j1DFvaiK001384@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/lib/PoolAllocate: PointerCompress.cpp updated: 1.7 -> 1.8 --- Log message: Add initial support for rewriting structure types. --- Diffs of the changes: (+10 -1) PointerCompress.cpp | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletion(-) Index: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp diff -u llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.7 llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.8 --- llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.7 Thu Feb 10 17:32:49 2005 +++ llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Sun Feb 13 09:57:23 2005 @@ -132,7 +132,16 @@ return OrigTy; // Okay, we have an aggregate type. - assert(0 && "FIXME: Unhandled aggregate type!"); + if (const StructType *STy = dyn_cast(OrigTy)) { + std::vector Elements; + Elements.reserve(STy->getNumElements()); + for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) + Elements.push_back(ComputeCompressedType(STy->getElementType(i), + NodeOffset, Nodes)); + return StructType::get(Elements); + } else { + assert(0 && "FIXME: Unhandled aggregate type!"); + } } /// dump - Emit a debugging dump for this pool info. From lattner at cs.uiuc.edu Sun Feb 13 10:08:43 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 13 Feb 2005 10:08:43 -0600 Subject: [llvm-commits] CVS: llvm/utils/NightlyTest.pl NightlyTestTemplate.html Message-ID: <200502131608.j1DG8hec001440@apoc.cs.uiuc.edu> Changes in directory llvm/utils: NightlyTest.pl updated: 1.89 -> 1.90 NightlyTestTemplate.html updated: 1.40 -> 1.41 --- Log message: Include local time on the web page for start/end times. --- Diffs of the changes: (+5 -4) NightlyTest.pl | 5 +++-- NightlyTestTemplate.html | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) Index: llvm/utils/NightlyTest.pl diff -u llvm/utils/NightlyTest.pl:1.89 llvm/utils/NightlyTest.pl:1.90 --- llvm/utils/NightlyTest.pl:1.89 Thu Jan 13 12:02:40 2005 +++ llvm/utils/NightlyTest.pl Sun Feb 13 10:08:30 2005 @@ -66,7 +66,7 @@ @TIME = localtime; my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3]; my $DateString = strftime "%B %d, %Y", localtime; -my $TestStartTime = gmtime; +my $TestStartTime = gmtime() . "GMT
    " . localtime() . " (local)"; # Command line argument settings... my $NOCHECKOUT = 0; @@ -798,7 +798,8 @@ } # Main HTML file... my $Output; -my $TestFinishTime = gmtime; +my $TestFinishTime = gmtime() . " GMT
    " . localtime() . " (local)"; + my $TestPlatform = `uname -a`; eval "\$Output = <Nightly Test Overview:
      -
    • Start: $TestStartTime GMT
    • -
    • Finish: $TestFinishTime GMT
    • +
    • Start: $TestStartTime
    • +
    • Finish: $TestFinishTime
    • Platform: $TestPlatform

    CVS Tree Overview:

    From lattner at cs.uiuc.edu Sun Feb 13 11:42:26 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 13 Feb 2005 11:42:26 -0600 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/ReaderWrappers.cpp Message-ID: <200502131742.j1DHgQIb005530@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: ReaderWrappers.cpp updated: 1.41 -> 1.42 --- Log message: Do not put internal symbols into the symbol table. This shrinks the symbol table for archives in common cases, and prevents trying to resolve a external reference with an internal reference. This shrinks the libpython.a symbol table from 126302 to 19770 bytes. --- Diffs of the changes: (+11 -21) ReaderWrappers.cpp | 32 +++++++++++--------------------- 1 files changed, 11 insertions(+), 21 deletions(-) Index: llvm/lib/Bytecode/Reader/ReaderWrappers.cpp diff -u llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.41 llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.42 --- llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.41 Tue Dec 21 01:51:33 2004 +++ llvm/lib/Bytecode/Reader/ReaderWrappers.cpp Sun Feb 13 11:42:11 2005 @@ -328,28 +328,18 @@ } } -namespace { -void getSymbols(Module*M, std::vector& symbols) { +static void getSymbols(Module*M, std::vector& symbols) { // Loop over global variables - for (Module::giterator GI = M->gbegin(), GE=M->gend(); GI != GE; ++GI) { - if (GI->hasInitializer()) { - std::string name ( GI->getName() ); - if (!name.empty()) { - symbols.push_back(name); - } - } - } - - //Loop over functions - for (Module::iterator FI = M->begin(), FE=M->end(); FI != FE; ++FI) { - if (!FI->isExternal()) { - std::string name ( FI->getName() ); - if (!name.empty()) { - symbols.push_back(name); - } - } - } -} + for (Module::giterator GI = M->gbegin(), GE=M->gend(); GI != GE; ++GI) + if (GI->hasInitializer() && !GI->hasInternalLinkage()) + if (!GI->getName().empty()) + symbols.push_back(GI->getName()); + + // Loop over functions. + for (Module::iterator FI = M->begin(), FE = M->end(); FI != FE; ++FI) + if (!FI->isExternal() && !FI->hasInternalLinkage()) + if (!FI->getName().empty()) + symbols.push_back(FI->getName()); } // Get just the externally visible defined symbols from the bytecode From lattner at cs.uiuc.edu Sun Feb 13 11:48:31 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 13 Feb 2005 11:48:31 -0600 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.cpp Message-ID: <200502131748.j1DHmVlW005876@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: Reader.cpp updated: 1.152 -> 1.153 --- Log message: Make sure to clear the LazyFunctionLoadMap after we ParseAllFunctionBodies. Otherwise, clients who call ParseAllFunctionBodies will attempt to parse the function bodies twice, which is (uh) very very bad (tm). This fixes gccld on python. --- Diffs of the changes: (+2 -1) Reader.cpp | 3 ++- 1 files changed, 2 insertions(+), 1 deletion(-) Index: llvm/lib/Bytecode/Reader/Reader.cpp diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.152 llvm/lib/Bytecode/Reader/Reader.cpp:1.153 --- llvm/lib/Bytecode/Reader/Reader.cpp:1.152 Sun Jan 30 19:11:13 2005 +++ llvm/lib/Bytecode/Reader/Reader.cpp Sun Feb 13 11:48:18 2005 @@ -1769,9 +1769,10 @@ Function* Func = Fi->first; BlockStart = At = Fi->second.Buf; BlockEnd = Fi->second.EndBuf; - this->ParseFunctionBody(Func); + ParseFunctionBody(Func); ++Fi; } + LazyFunctionLoadMap.clear(); } /// Parse the global type list From lattner at cs.uiuc.edu Sun Feb 13 11:50:29 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 13 Feb 2005 11:50:29 -0600 Subject: [llvm-commits] CVS: llvm/lib/Linker/LinkArchives.cpp Message-ID: <200502131750.j1DHoTqs006129@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Linker: LinkArchives.cpp updated: 1.45 -> 1.46 --- Log message: Minor cleanup. No need to explicitly tell the compiler the template arguments. --- Diffs of the changes: (+2 -3) LinkArchives.cpp | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) Index: llvm/lib/Linker/LinkArchives.cpp diff -u llvm/lib/Linker/LinkArchives.cpp:1.45 llvm/lib/Linker/LinkArchives.cpp:1.46 --- llvm/lib/Linker/LinkArchives.cpp:1.45 Sun Feb 13 09:26:14 2005 +++ llvm/lib/Linker/LinkArchives.cpp Sun Feb 13 11:50:16 2005 @@ -154,7 +154,7 @@ verbose(" Linking in module: " + aModule->getModuleIdentifier()); // Link it in - if (this->LinkInModule(aModule)) + if (LinkInModule(aModule)) return error("Cannot link in module '" + aModule->getModuleIdentifier() + "': " + Error); } @@ -168,8 +168,7 @@ // NotDefinedByArchive which holds symbols we know the archive doesn't // define. There's no point searching for symbols that we won't find in the // archive so we subtract these sets. - set_subtract,std::set >( - UndefinedSymbols,NotDefinedByArchive); + set_subtract(UndefinedSymbols, NotDefinedByArchive); // If there's no symbols left, no point in continuing to search the // archive. From lattner at cs.uiuc.edu Sun Feb 13 11:54:33 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 13 Feb 2005 11:54:33 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/SymbolTable.cpp Message-ID: <200502131754.j1DHsX3V006161@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: SymbolTable.cpp updated: 1.49 -> 1.50 --- Log message: Nuke blank line. --- Diffs of the changes: (+0 -1) SymbolTable.cpp | 1 - 1 files changed, 1 deletion(-) Index: llvm/lib/VMCore/SymbolTable.cpp diff -u llvm/lib/VMCore/SymbolTable.cpp:1.49 llvm/lib/VMCore/SymbolTable.cpp:1.50 --- llvm/lib/VMCore/SymbolTable.cpp:1.49 Wed Sep 1 17:55:37 2004 +++ llvm/lib/VMCore/SymbolTable.cpp Sun Feb 13 11:54:21 2005 @@ -414,7 +414,6 @@ } } else { insertEntry(V.first, NewType, V.second); - } // Remove the item from the old type plane OldPlane.erase(OldPlane.begin()); From reid at x10sys.com Sun Feb 13 12:12:31 2005 From: reid at x10sys.com (Reid Spencer) Date: Sun, 13 Feb 2005 12:12:31 -0600 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/ReaderWrappers.cpp Message-ID: <200502131812.MAA09842@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: ReaderWrappers.cpp updated: 1.42 -> 1.43 --- Log message: Make the check for global variables the same as the one for functions. In both cases they are looking for non-external variables/functions that do not have internal linkage. Using "!isExternal()" is a little more understandable than "hasInitializer()" --- Diffs of the changes: (+1 -1) ReaderWrappers.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/Bytecode/Reader/ReaderWrappers.cpp diff -u llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.42 llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.43 --- llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.42 Sun Feb 13 11:42:11 2005 +++ llvm/lib/Bytecode/Reader/ReaderWrappers.cpp Sun Feb 13 12:12:20 2005 @@ -331,7 +331,7 @@ static void getSymbols(Module*M, std::vector& symbols) { // Loop over global variables for (Module::giterator GI = M->gbegin(), GE=M->gend(); GI != GE; ++GI) - if (GI->hasInitializer() && !GI->hasInternalLinkage()) + if (!GI->isExternal() && !GI->hasInternalLinkage()) if (!GI->getName().empty()) symbols.push_back(GI->getName()); From lattner at cs.uiuc.edu Sun Feb 13 13:12:09 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 13 Feb 2005 13:12:09 -0600 Subject: [llvm-commits] CVS: llvm/tools/llvm-as/llvm-as.cpp Message-ID: <200502131912.j1DJC94S018029@apoc.cs.uiuc.edu> Changes in directory llvm/tools/llvm-as: llvm-as.cpp updated: 1.42 -> 1.43 --- Log message: Print the module, not the pointer. --- Diffs of the changes: (+1 -1) llvm-as.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/tools/llvm-as/llvm-as.cpp diff -u llvm/tools/llvm-as/llvm-as.cpp:1.42 llvm/tools/llvm-as/llvm-as.cpp:1.43 --- llvm/tools/llvm-as/llvm-as.cpp:1.42 Sat Jan 22 11:36:17 2005 +++ llvm/tools/llvm-as/llvm-as.cpp Sun Feb 13 13:11:48 2005 @@ -73,7 +73,7 @@ return 1; } - if (DumpAsm) std::cerr << "Here's the assembly:\n" << M.get(); + if (DumpAsm) std::cerr << "Here's the assembly:\n" << *M.get(); if (OutputFilename != "") { // Specified an output filename? if (OutputFilename != "-") { // Not stdout? From lattner at cs.uiuc.edu Sun Feb 13 13:12:51 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 13 Feb 2005 13:12:51 -0600 Subject: [llvm-commits] CVS: llvm/tools/llvm-link/llvm-link.cpp Message-ID: <200502131912.j1DJCpoS019261@apoc.cs.uiuc.edu> Changes in directory llvm/tools/llvm-link: llvm-link.cpp updated: 1.55 -> 1.56 --- Log message: Print the module, not the pointer. --- Diffs of the changes: (+1 -1) llvm-link.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/tools/llvm-link/llvm-link.cpp diff -u llvm/tools/llvm-link/llvm-link.cpp:1.55 llvm/tools/llvm-link/llvm-link.cpp:1.56 --- llvm/tools/llvm-link/llvm-link.cpp:1.55 Sat Jan 22 11:36:17 2005 +++ llvm/tools/llvm-link/llvm-link.cpp Sun Feb 13 13:12:31 2005 @@ -110,7 +110,7 @@ // TODO: Iterate over the -l list and link in any modules containing // global symbols that have not been resolved so far. - if (DumpAsm) std::cerr << "Here's the assembly:\n" << Composite.get(); + if (DumpAsm) std::cerr << "Here's the assembly:\n" << *Composite.get(); // FIXME: cout is not binary! std::ostream *Out = &std::cout; // Default to printing to stdout... From lattner at cs.uiuc.edu Sun Feb 13 13:15:17 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 13 Feb 2005 13:15:17 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Module.h Message-ID: <200502131915.j1DJFHvA022581@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: Module.h updated: 1.57 -> 1.58 --- Log message: Do not replace ostream << Module*, only ostream << Module&. --- Diffs of the changes: (+0 -5) Module.h | 5 ----- 1 files changed, 5 deletions(-) Index: llvm/include/llvm/Module.h diff -u llvm/include/llvm/Module.h:1.57 llvm/include/llvm/Module.h:1.58 --- llvm/include/llvm/Module.h:1.57 Sat Jan 29 18:08:26 2005 +++ llvm/include/llvm/Module.h Sun Feb 13 13:15:01 2005 @@ -263,11 +263,6 @@ void dropAllReferences(); }; -inline std::ostream &operator<<(std::ostream &O, const Module *M) { - M->print(O); - return O; -} - inline std::ostream &operator<<(std::ostream &O, const Module &M) { M.print(O); return O; From lattner at cs.uiuc.edu Sun Feb 13 14:36:25 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 13 Feb 2005 14:36:25 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Message-ID: <200502132036.j1DKaPk9024272@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/lib/PoolAllocate: PointerCompress.cpp updated: 1.8 -> 1.9 --- Log message: Implement the simple and common 3-operand form of getelementptr: gep P, 0, uint --- Diffs of the changes: (+28 -1) PointerCompress.cpp | 29 ++++++++++++++++++++++++++++- 1 files changed, 28 insertions(+), 1 deletion(-) Index: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp diff -u llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.8 llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.9 --- llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.8 Sun Feb 13 09:57:23 2005 +++ llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Sun Feb 13 14:36:10 2005 @@ -248,13 +248,14 @@ const PointerCompress::PoolInfoMap &PoolInfo; + const TargetData &TD; const DSGraph &DSG; PointerCompress &PtrComp; public: InstructionRewriter(const PointerCompress::PoolInfoMap &poolInfo, const DSGraph &dsg, PointerCompress &ptrcomp) - : PoolInfo(poolInfo), DSG(dsg), PtrComp(ptrcomp) { + : PoolInfo(poolInfo), TD(dsg.getTargetData()), DSG(dsg), PtrComp(ptrcomp){ } ~InstructionRewriter(); @@ -318,6 +319,7 @@ void visitCastInst(CastInst &CI); void visitPHINode(PHINode &PN); void visitSetCondInst(SetCondInst &SCI); + void visitGetElementPtrInst(GetElementPtrInst &GEPI); void visitLoadInst(LoadInst &LI); void visitStoreInst(StoreInst &SI); @@ -406,6 +408,31 @@ SCI.eraseFromParent(); } +void InstructionRewriter::visitGetElementPtrInst(GetElementPtrInst &GEPI) { + const CompressedPoolInfo *PI = getPoolInfo(&GEPI); + if (PI == 0) return; + + // For now, we only support very very simple getelementptr instructions, with + // two indices, where the first is zero. + assert(GEPI.getNumOperands() == 3 && isa(GEPI.getOperand(1)) && + cast(GEPI.getOperand(1))->isNullValue()); + const Type *IdxTy = + cast(GEPI.getOperand(0)->getType())->getElementType(); + assert(isa(IdxTy) && "Can only handle structs right now!"); + + Value *Val = getTransformedValue(GEPI.getOperand(0)); + + unsigned Field = (unsigned)cast(GEPI.getOperand(2))->getValue(); + if (Field) { + const StructType *NTy = cast(PI->getNewType()); + uint64_t FieldOffs = TD.getStructLayout(NTy)->MemberOffsets[Field]; + Constant *FieldOffsCst = ConstantUInt::get(UINTTYPE, FieldOffs); + Val = BinaryOperator::createAdd(Val, FieldOffsCst, GEPI.getName(), &GEPI); + } + + setTransformedValue(GEPI, Val); +} + void InstructionRewriter::visitLoadInst(LoadInst &LI) { if (isa(LI.getOperand(0))) return; // load null ?? From lattner at cs.uiuc.edu Sun Feb 13 15:11:47 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 13 Feb 2005 15:11:47 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Message-ID: <200502132111.j1DLBlNO025777@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/lib/PoolAllocate: PointerCompress.cpp updated: 1.9 -> 1.10 --- Log message: Implement transformation of poolinit/pooldestroy --- Diffs of the changes: (+31 -3) PointerCompress.cpp | 34 +++++++++++++++++++++++++++++++--- 1 files changed, 31 insertions(+), 3 deletions(-) Index: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp diff -u llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.9 llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.10 --- llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.9 Sun Feb 13 14:36:10 2005 +++ llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Sun Feb 13 15:11:35 2005 @@ -312,6 +312,16 @@ return 0; } + /// getPoolInfoForPoolDesc - Given a pool descriptor as a Value*, return the + /// pool info for the pool if it is compressed. + const CompressedPoolInfo *getPoolInfoForPoolDesc(Value *PD) const { + for (PointerCompress::PoolInfoMap::const_iterator I = PoolInfo.begin(), + E = PoolInfo.end(); I != E; ++I) + if (I->second.getPoolDesc() == PD) + return &I->second; + return 0; + } + //===------------------------------------------------------------------===// // Visitation methods. These do all of the heavy lifting for the various // cases we have to handle. @@ -527,12 +537,30 @@ void InstructionRewriter::visitPoolInit(CallInst &CI) { - // Transform to poolinit_pc if necessary. + // Transform to poolinit_pc if this is initializing a pool that we are + // compressing. + const CompressedPoolInfo *PI = getPoolInfoForPoolDesc(CI.getOperand(1)); + if (PI == 0) return; // Pool isn't compressed. + + std::vector Ops; + Ops.push_back(CI.getOperand(1)); + Ops.push_back(ConstantUInt::get(Type::UIntTy, PI->getNewSize())); + Ops.push_back(CI.getOperand(3)); + // TODO: Compression could reduce the alignment restriction for the pool! + new CallInst(PtrComp.PoolInitPC, Ops, "", &CI); + CI.eraseFromParent(); } void InstructionRewriter::visitPoolDestroy(CallInst &CI) { - // Transform to pooldestroy_pc if necessary. - /* TODO */ + // Transform to pooldestroy_pc if this is destroying a pool that we are + // compressing. + const CompressedPoolInfo *PI = getPoolInfoForPoolDesc(CI.getOperand(1)); + if (PI == 0) return; // Pool isn't compressed. + + std::vector Ops; + Ops.push_back(CI.getOperand(1)); + new CallInst(PtrComp.PoolDestroyPC, Ops, "", &CI); + CI.eraseFromParent(); } void InstructionRewriter::visitPoolAlloc(CallInst &CI) { // Transform to poolalloc_pc if necessary. From lattner at cs.uiuc.edu Sun Feb 13 15:24:58 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 13 Feb 2005 15:24:58 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp Message-ID: <200502132124.j1DLOwmi026588@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/lib/PoolAllocate: TransformFunctionBody.cpp updated: 1.35 -> 1.36 --- Log message: Make sure to update the DSGraph for the transformed function to include the cast inserted for pool frees. --- Diffs of the changes: (+3 -1) TransformFunctionBody.cpp | 4 +++- 1 files changed, 3 insertions(+), 1 deletion(-) Index: llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp diff -u llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.35 llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.36 --- llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.35 Sun Jan 30 17:51:25 2005 +++ llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp Sun Feb 13 15:24:43 2005 @@ -202,9 +202,11 @@ // Insert a cast and a call to poolfree... Value *Casted = Arg; - if (Arg->getType() != PointerType::get(Type::SByteTy)) + if (Arg->getType() != PointerType::get(Type::SByteTy)) { Casted = new CastInst(Arg, PointerType::get(Type::SByteTy), Arg->getName()+".casted", Where); + G.getScalarMap()[Casted] = G.getScalarMap()[Arg]; + } CallInst *FreeI = new CallInst(PAInfo.PoolFree, make_vector(PH, Casted, 0), "", Where); From lattner at cs.uiuc.edu Sun Feb 13 15:25:06 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 13 Feb 2005 15:25:06 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Message-ID: <200502132125.j1DLP6D2026597@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/lib/PoolAllocate: PointerCompress.cpp updated: 1.10 -> 1.11 --- Log message: Implement transformation of pool frees. --- Diffs of the changes: (+10 -1) PointerCompress.cpp | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletion(-) Index: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp diff -u llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.10 llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.11 --- llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.10 Sun Feb 13 15:11:35 2005 +++ llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Sun Feb 13 15:24:53 2005 @@ -562,6 +562,7 @@ new CallInst(PtrComp.PoolDestroyPC, Ops, "", &CI); CI.eraseFromParent(); } + void InstructionRewriter::visitPoolAlloc(CallInst &CI) { // Transform to poolalloc_pc if necessary. const CompressedPoolInfo *PI = getPoolInfo(&CI); @@ -575,7 +576,15 @@ } void InstructionRewriter::visitPoolFree(CallInst &CI) { - // Transform to poolfree_pc if necessary. + // Transform to poolfree_pc if the pool is compressed. + const CompressedPoolInfo *PI = getPoolInfo(CI.getOperand(2)); + if (PI == 0) return; // Not a free to a compressed pool. + + std::vector Ops; + Ops.push_back(CI.getOperand(1)); + Ops.push_back(getTransformedValue(CI.getOperand(2))); + new CallInst(PtrComp.PoolFreePC, Ops, "", &CI); + CI.eraseFromParent(); } void InstructionRewriter::visitCallInst(CallInst &CI) { From alkis at cs.uiuc.edu Sun Feb 13 16:16:18 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sun, 13 Feb 2005 16:16:18 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/ClassFile/ClassFile.cpp Message-ID: <200502132216.QAA29301@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/ClassFile: ClassFile.cpp updated: 1.40 -> 1.41 --- Log message: Shrink ClassFile by one word. --- Diffs of the changes: (+2 -8) ClassFile.cpp | 10 ++-------- 1 files changed, 2 insertions(+), 8 deletions(-) Index: llvm-java/lib/ClassFile/ClassFile.cpp diff -u llvm-java/lib/ClassFile/ClassFile.cpp:1.40 llvm-java/lib/ClassFile/ClassFile.cpp:1.41 --- llvm-java/lib/ClassFile/ClassFile.cpp:1.40 Sat Feb 12 14:38:41 2005 +++ llvm-java/lib/ClassFile/ClassFile.cpp Sun Feb 13 16:15:31 2005 @@ -226,14 +226,8 @@ cPool_.push_back(NULL); } accessFlags_ = readU2(is); - thisClass_ = getConstantClass(readU2(is)); - if (!thisClass_) - throw ClassFileSemanticError( - "Representation of this class is not of type ConstantClass"); - superClass_ = getConstantClass(readU2(is)); - if (!superClass_ && thisClass_->getName()->str() != "java/lang/Object") - throw ClassFileSemanticError( - "Representation of super class is not of type ConstantClass"); + thisClassIdx_ = readU2(is); + superClassIdx_ = readU2(is); readClasses(interfaces_, this, is); readFields(fields_, this, is); readMethods(methods_, this, is); From alkis at cs.uiuc.edu Sun Feb 13 16:16:27 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sun, 13 Feb 2005 16:16:27 -0600 Subject: [llvm-commits] CVS: llvm-java/include/llvm/Java/ClassFile.h Message-ID: <200502132216.QAA29306@zion.cs.uiuc.edu> Changes in directory llvm-java/include/llvm/Java: ClassFile.h updated: 1.31 -> 1.32 --- Log message: Shrink ClassFile by one word. --- Diffs of the changes: (+8 -4) ClassFile.h | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) Index: llvm-java/include/llvm/Java/ClassFile.h diff -u llvm-java/include/llvm/Java/ClassFile.h:1.31 llvm-java/include/llvm/Java/ClassFile.h:1.32 --- llvm-java/include/llvm/Java/ClassFile.h:1.31 Sat Feb 12 14:38:50 2005 +++ llvm-java/include/llvm/Java/ClassFile.h Sun Feb 13 16:15:41 2005 @@ -99,8 +99,12 @@ bool isInterface() const { return accessFlags_ & ACC_INTERFACE; } bool isAbstract() const { return accessFlags_ & ACC_ABSTRACT; } - ConstantClass* getThisClass() const { return thisClass_; } - ConstantClass* getSuperClass() const { return superClass_; } + ConstantClass* getThisClass() const { + return getConstantClass(thisClassIdx_); + } + ConstantClass* getSuperClass() const { + return superClassIdx_ ? getConstantClass(superClassIdx_) : NULL; + } const Classes& getInterfaces() const { return interfaces_; } @@ -120,8 +124,8 @@ uint16_t minorV_; ConstantPool cPool_; uint16_t accessFlags_; - ConstantClass* thisClass_; - ConstantClass* superClass_; + uint16_t thisClassIdx_; + uint16_t superClassIdx_; Classes interfaces_; Fields fields_; Methods methods_; From lattner at cs.uiuc.edu Sun Feb 13 16:21:04 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 13 Feb 2005 16:21:04 -0600 Subject: [llvm-commits] CVS: llvm/docs/GettingStarted.html Message-ID: <200502132221.j1DML4xp030034@apoc.cs.uiuc.edu> Changes in directory llvm/docs: GettingStarted.html updated: 1.112 -> 1.113 --- Log message: SuSE 3.3.3 is also borken. --- Diffs of the changes: (+9 -5) GettingStarted.html | 14 +++++++++----- 1 files changed, 9 insertions(+), 5 deletions(-) Index: llvm/docs/GettingStarted.html diff -u llvm/docs/GettingStarted.html:1.112 llvm/docs/GettingStarted.html:1.113 --- llvm/docs/GettingStarted.html:1.112 Sat Feb 12 14:11:13 2005 +++ llvm/docs/GettingStarted.html Sun Feb 13 16:20:49 2005 @@ -458,7 +458,7 @@

    LLVM is very demanding of the host C++ compiler, and as such tends to expose bugs in the compiler. In particular, several versions of GCC crash when trying to compile LLVM. We routinely use GCC 3.3.3 and GCC 3.4.0 and have had success -with them (except on Cygwin, see below). Other versions of GCC will probably +with them (however, see below). Other versions of GCC will probably work as well. GCC versions listed here are known to not work. If you are using one of these versions, please try to upgrade your GCC to something more recent. If you run into a problem with a @@ -477,9 +477,13 @@ href="http://gcc.gnu.org/PR13392">serious bug which causes it to crash in the "convert_from_eh_region_ranges_1" GCC function.

    -

    GCC 3.3.3: The version of GCC 3.3.3 commonly shipped with Cygwin does - not work. Please upgrade to a newer - version if possible. Note that this apparently only affects Cygwin.

    +

    Cygwin GCC 3.3.3: The version of GCC 3.3.3 commonly shipped with + Cygwin does not work. Please upgrade + to a newer version if possible.

    +

    SuSE GCC 3.3.3: The version of GCC 3.3.3 shipped with SuSE 9.1 (and + possibly others) does not compile LLVM correctly (it appears that exception + handling is broken in some cases). Please download the FSF 3.3.3 or upgrade + to a newer version of GCC.

    @@ -1500,7 +1504,7 @@ Chris Lattner
    Reid Spencer
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2005/02/12 20:11:13 $ + Last modified: $Date: 2005/02/13 22:20:49 $ From lattner at cs.uiuc.edu Sun Feb 13 16:27:39 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 13 Feb 2005 16:27:39 -0600 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200502132227.j1DMRdaW031249@apoc.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.293 -> 1.294 --- Log message: Add some updates --- Diffs of the changes: (+7 -2) ReleaseNotes.html | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.293 llvm/docs/ReleaseNotes.html:1.294 --- llvm/docs/ReleaseNotes.html:1.293 Fri Feb 11 13:29:52 2005 +++ llvm/docs/ReleaseNotes.html Sun Feb 13 16:27:24 2005 @@ -79,7 +79,11 @@ Interprocedural Sparse Conditional Constant Propagation pass, named -ipsccp, which is run by default at link-time.
  • LLVM 1.5 is now about 15% faster than LLVM 1.4 and its core data structures - use about 20% less memory.
  • + use about 30% less memory. +
  • LLVM includes new experimental native code generators for SparcV8 and + Alpha.
  • +
  • Support for Microsoft Visual Studio is improved, and not documented.
  • @@ -216,6 +220,7 @@ be used to step through programs and inspect the stack.
  • The "iterative scan" register allocator (enabled with -regalloc=iterativescan) is not stable.
  • +
  • The SparcV8 and Alpha ports are experimental.
  • @@ -569,7 +574,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2005/02/11 19:29:52 $ + Last modified: $Date: 2005/02/13 22:27:24 $ From lattner at cs.uiuc.edu Sun Feb 13 16:46:52 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 13 Feb 2005 16:46:52 -0600 Subject: [llvm-commits] CVS: llvm/lib/System/Unix/MappedFile.inc Unix.h Message-ID: <200502132246.j1DMkq5w001446@apoc.cs.uiuc.edu> Changes in directory llvm/lib/System/Unix: MappedFile.inc updated: 1.9 -> 1.10 Unix.h updated: 1.10 -> 1.11 --- Log message: If errno is zero strerror_r does not modify the buffer, leaving it unterminated. This causes garbage to be printed out after error messages. --- Diffs of the changes: (+6 -2) MappedFile.inc | 1 + Unix.h | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) Index: llvm/lib/System/Unix/MappedFile.inc diff -u llvm/lib/System/Unix/MappedFile.inc:1.9 llvm/lib/System/Unix/MappedFile.inc:1.10 --- llvm/lib/System/Unix/MappedFile.inc:1.9 Mon Dec 27 00:16:52 2004 +++ llvm/lib/System/Unix/MappedFile.inc Sun Feb 13 16:46:37 2005 @@ -51,6 +51,7 @@ else if (options_&WRITE_ACCESS) mode = O_WRONLY; info_->fd_ = ::open(path_.c_str(),mode); + if (info_->fd_ < 0) { delete info_; info_ = 0; Index: llvm/lib/System/Unix/Unix.h diff -u llvm/lib/System/Unix/Unix.h:1.10 llvm/lib/System/Unix/Unix.h:1.11 --- llvm/lib/System/Unix/Unix.h:1.10 Mon Dec 27 00:17:50 2004 +++ llvm/lib/System/Unix/Unix.h Sun Feb 13 16:46:37 2005 @@ -68,14 +68,17 @@ inline void ThrowErrno(const std::string& prefix) { char buffer[MAXPATHLEN]; + buffer[0] = 0; #ifdef HAVE_STRERROR_R // strerror_r is thread-safe. - strerror_r(errno,buffer,MAXPATHLEN-1); + if (errno) + strerror_r(errno,buffer,MAXPATHLEN-1); #elif HAVE_STRERROR // Copy the thread un-safe result of strerror into // the buffer as fast as possible to minimize impact // of collision of strerror in multiple threads. - strncpy(buffer,strerror(errno),MAXPATHLEN-1); + if (Errno) + strncpy(buffer,strerror(errno),MAXPATHLEN-1); buffer[MAXPATHLEN-1] = 0; #else // Strange that this system doesn't even have strerror From lattner at cs.uiuc.edu Sun Feb 13 17:02:49 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 13 Feb 2005 17:02:49 -0600 Subject: [llvm-commits] CVS: llvm/tools/gccld/GenerateCode.cpp gccld.cpp Message-ID: <200502132302.j1DN2nFv004252@apoc.cs.uiuc.edu> Changes in directory llvm/tools/gccld: GenerateCode.cpp updated: 1.42 -> 1.43 gccld.cpp updated: 1.95 -> 1.96 --- Log message: Make sure to null terminate argument lists! --- Diffs of the changes: (+4 -1) GenerateCode.cpp | 3 +++ gccld.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) Index: llvm/tools/gccld/GenerateCode.cpp diff -u llvm/tools/gccld/GenerateCode.cpp:1.42 llvm/tools/gccld/GenerateCode.cpp:1.43 --- llvm/tools/gccld/GenerateCode.cpp:1.42 Sun Dec 19 12:00:56 2004 +++ llvm/tools/gccld/GenerateCode.cpp Sun Feb 13 17:02:34 2005 @@ -247,6 +247,7 @@ args.push_back("-o"); args.push_back(OutputFilename.c_str()); args.push_back(InputFilename.c_str()); + args.push_back(0); return sys::Program::ExecuteAndWait(llc, &args[0]); } @@ -263,6 +264,7 @@ args.push_back("-o"); args.push_back(OutputFile.c_str()); args.push_back(InputFile.c_str()); + args.push_back(0); return sys::Program::ExecuteAndWait(llc, &args[0]); } @@ -322,6 +324,7 @@ args.push_back(Libraries[index].c_str()); } } + args.push_back(0); // Run the compiler to assembly and link together the program. return sys::Program::ExecuteAndWait(gcc, &args[0], (const char**)clean_env); Index: llvm/tools/gccld/gccld.cpp diff -u llvm/tools/gccld/gccld.cpp:1.95 llvm/tools/gccld/gccld.cpp:1.96 --- llvm/tools/gccld/gccld.cpp:1.95 Sat Jan 22 11:36:16 2005 +++ llvm/tools/gccld/gccld.cpp Sun Feb 13 17:02:34 2005 @@ -299,7 +299,7 @@ Libraries, gcc, envp ); // Remove the assembly language file. - AssemblyFile.destroyFile();; + AssemblyFile.destroyFile(); } else if (NativeCBE) { sys::Path CFile (OutputFilename); CFile.appendSuffix("cbe.c"); From lattner at cs.uiuc.edu Sun Feb 13 17:10:49 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 13 Feb 2005 17:10:49 -0600 Subject: [llvm-commits] CVS: llvm/tools/llvmc/CompilerDriver.cpp Message-ID: <200502132310.j1DNAnjw014752@apoc.cs.uiuc.edu> Changes in directory llvm/tools/llvmc: CompilerDriver.cpp updated: 1.25 -> 1.26 --- Log message: Conform to the documented interface by null terminating argument lists! --- Diffs of the changes: (+5 -7) CompilerDriver.cpp | 12 +++++------- 1 files changed, 5 insertions(+), 7 deletions(-) Index: llvm/tools/llvmc/CompilerDriver.cpp diff -u llvm/tools/llvmc/CompilerDriver.cpp:1.25 llvm/tools/llvmc/CompilerDriver.cpp:1.26 --- llvm/tools/llvmc/CompilerDriver.cpp:1.25 Sun Dec 19 22:02:01 2004 +++ llvm/tools/llvmc/CompilerDriver.cpp Sun Feb 13 17:10:34 2005 @@ -394,22 +394,20 @@ // Invoke the program const char** Args = (const char**) - alloca(sizeof(const char*)*action->args.size()); - for (unsigned i = 0; i != action->args.size(); ++i) { + alloca(sizeof(const char*)*(action->args.size()+1)); + for (unsigned i = 0; i != action->args.size(); ++i) Args[i] = action->args[i].c_str(); - } + Args[action->args.size()] = 0; // null terminate list. if (isSet(TIME_ACTIONS_FLAG)) { Timer timer(action->program.toString()); timer.startTimer(); - int resultCode = - sys::Program::ExecuteAndWait(action->program,Args); + int resultCode = sys::Program::ExecuteAndWait(action->program, Args); timer.stopTimer(); timer.print(timer,std::cerr); return resultCode == 0; } else - return 0 == - sys::Program::ExecuteAndWait(action->program, Args); + return 0 == sys::Program::ExecuteAndWait(action->program, Args); } return true; } From lattner at cs.uiuc.edu Sun Feb 13 17:10:59 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 13 Feb 2005 17:10:59 -0600 Subject: [llvm-commits] CVS: llvm/tools/llvm-ld/llvm-ld.cpp Message-ID: <200502132310.j1DNAxgY014786@apoc.cs.uiuc.edu> Changes in directory llvm/tools/llvm-ld: llvm-ld.cpp updated: 1.21 -> 1.22 --- Log message: Conform to the documented interface by null terminating argument lists! --- Diffs of the changes: (+3 -0) llvm-ld.cpp | 3 +++ 1 files changed, 3 insertions(+) Index: llvm/tools/llvm-ld/llvm-ld.cpp diff -u llvm/tools/llvm-ld/llvm-ld.cpp:1.21 llvm/tools/llvm-ld/llvm-ld.cpp:1.22 --- llvm/tools/llvm-ld/llvm-ld.cpp:1.21 Sat Jan 22 11:36:17 2005 +++ llvm/tools/llvm-ld/llvm-ld.cpp Sun Feb 13 17:10:45 2005 @@ -225,6 +225,7 @@ args.push_back( "-o"); args.push_back( OutputFilename.c_str() ); args.push_back( InputFilename.c_str() ); + args.push_back(0); return sys::Program::ExecuteAndWait(llc,&args[0]); } @@ -241,6 +242,7 @@ args.push_back( "-o"); args.push_back( OutputFile.c_str() ); args.push_back( InputFile.c_str() ); + args.push_back(0); return sys::Program::ExecuteAndWait(llc, &args[0]); } @@ -300,6 +302,7 @@ args.push_back("-l"); args.push_back(Libraries[index].c_str()); } + args.push_back(0); // Run the compiler to assembly and link together the program. return sys::Program::ExecuteAndWait(gcc, &args[0], (const char**)clean_env); From lattner at cs.uiuc.edu Sun Feb 13 17:14:01 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 13 Feb 2005 17:14:01 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/ToolRunner.cpp Message-ID: <200502132314.j1DNE1NO021458@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Support: ToolRunner.cpp updated: 1.37 -> 1.38 --- Log message: Move helper function here. --- Diffs of the changes: (+28 -0) ToolRunner.cpp | 28 ++++++++++++++++++++++++++++ 1 files changed, 28 insertions(+) Index: llvm/lib/Support/ToolRunner.cpp diff -u llvm/lib/Support/ToolRunner.cpp:1.37 llvm/lib/Support/ToolRunner.cpp:1.38 --- llvm/lib/Support/ToolRunner.cpp:1.37 Sun Dec 19 12:00:21 2004 +++ llvm/lib/Support/ToolRunner.cpp Sun Feb 13 17:13:47 2005 @@ -14,6 +14,7 @@ #define DEBUG_TYPE "toolrunner" #include "llvm/Support/ToolRunner.h" #include "llvm/Config/config.h" // for HAVE_LINK_R +#include "llvm/System/Program.h" #include "llvm/Support/Debug.h" #include "llvm/Support/FileUtilities.h" #include @@ -22,6 +23,26 @@ ToolExecutionError::~ToolExecutionError() throw() { } +/// RunProgramWithTimeout - This function provides an alternate interface to the +/// sys::Program::ExecuteAndWait interface. +/// @see sys:Program::ExecuteAndWait +static int RunProgramWithTimeout(const sys::Path &ProgramPath, + const char **Args, + const sys::Path &StdInFile, + const sys::Path &StdOutFile, + const sys::Path &StdErrFile, + unsigned NumSeconds = 0) { + const sys::Path* redirects[3]; + redirects[0] = &StdInFile; + redirects[1] = &StdOutFile; + redirects[2] = &StdErrFile; + + return + sys::Program::ExecuteAndWait(ProgramPath, Args, 0, redirects, NumSeconds); +} + + + static void ProcessFailure(sys::Path ProgPath, const char** Args) { std::ostringstream OS; OS << "\nError running tool:\n "; @@ -370,6 +391,10 @@ sys::Path OutputBinary (ProgramFile+".gcc.exe"); OutputBinary.makeUnique(); GCCArgs.push_back(OutputBinary.c_str()); // Output to the right file... + GCCArgs.push_back("-L/home/vadve/shared/localtools/x86/lib"); + GCCArgs.push_back("-lf2c"); // Hard-code the math library... + GCCArgs.push_back("-lpng"); // Hard-code the math library... + GCCArgs.push_back("-lz"); // Hard-code the math library... GCCArgs.push_back("-lm"); // Hard-code the math library... GCCArgs.push_back("-O2"); // Optimize the program a bit... #if defined (HAVE_LINK_R) @@ -385,6 +410,9 @@ } std::vector ProgramArgs; + //ProgramArgs.push_back("valgrind"); + //ProgramArgs.push_back("--tool=memcheck"); + ProgramArgs.push_back(OutputBinary.c_str()); // Add optional parameters to the running program from Argv for (unsigned i=0, e = Args.size(); i != e; ++i) From lattner at cs.uiuc.edu Sun Feb 13 17:14:20 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 13 Feb 2005 17:14:20 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Support/SystemUtils.h Message-ID: <200502132314.j1DNEKFZ021522@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Support: SystemUtils.h updated: 1.19 -> 1.20 --- Log message: Move private helper function into the only .cpp file that uses it. --- Diffs of the changes: (+0 -18) SystemUtils.h | 18 ------------------ 1 files changed, 18 deletions(-) Index: llvm/include/llvm/Support/SystemUtils.h diff -u llvm/include/llvm/Support/SystemUtils.h:1.19 llvm/include/llvm/Support/SystemUtils.h:1.20 --- llvm/include/llvm/Support/SystemUtils.h:1.19 Sat Jan 1 18:10:03 2005 +++ llvm/include/llvm/Support/SystemUtils.h Sun Feb 13 17:14:06 2005 @@ -37,24 +37,6 @@ sys::Path FindExecutable(const std::string &ExeName, const std::string &ProgramPath); -/// RunProgramWithTimeout - This function provides an alternate interface to the -/// sys::Program::ExecuteAndWait interface. -/// @see sys:Program::ExecuteAndWait -inline int RunProgramWithTimeout(const sys::Path &ProgramPath, - const char **Args, - const sys::Path &StdInFile, - const sys::Path &StdOutFile, - const sys::Path &StdErrFile, - unsigned NumSeconds = 0) { - const sys::Path* redirects[3]; - redirects[0] = &StdInFile; - redirects[1] = &StdOutFile; - redirects[2] = &StdErrFile; - - return - sys::Program::ExecuteAndWait(ProgramPath, Args, 0, redirects, NumSeconds); -} - } // End llvm namespace #endif From lattner at cs.uiuc.edu Sun Feb 13 17:37:24 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 13 Feb 2005 17:37:24 -0600 Subject: [llvm-commits] CVS: llvm/lib/System/ltdl.c Message-ID: <200502132337.j1DNbOSN003198@apoc.cs.uiuc.edu> Changes in directory llvm/lib/System: ltdl.c updated: 1.2 -> 1.3 --- Log message: Fix the llvm bootstrap --- Diffs of the changes: (+2 -2) ltdl.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/lib/System/ltdl.c diff -u llvm/lib/System/ltdl.c:1.2 llvm/lib/System/ltdl.c:1.3 --- llvm/lib/System/ltdl.c:1.2 Mon Nov 29 06:04:27 2004 +++ llvm/lib/System/ltdl.c Sun Feb 13 17:37:09 2005 @@ -1165,7 +1165,7 @@ /* --- SHL_LOAD() INTERFACE LOADER --- */ -#if HAVE_SHL_LOAD +#if HAVE_SHL_LOAD && !defined(__llvm__) /* dynamic linking with shl_load (HP-UX) (comments from gmodule) */ @@ -2214,7 +2214,7 @@ #if HAVE_LIBDL errors += lt_dlloader_add (lt_dlloader_next (0), &sys_dl, "dlopen"); #endif -#if HAVE_SHL_LOAD +#if HAVE_SHL_LOAD && !defined(__llvm__) errors += lt_dlloader_add (lt_dlloader_next (0), &sys_shl, "dlopen"); #endif #ifdef __WINDOWS__ From lattner at cs.uiuc.edu Sun Feb 13 20:54:12 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 13 Feb 2005 20:54:12 -0600 Subject: [llvm-commits] CVS: llvm-gcc/gcc/llvm-expand.c Message-ID: <200502140254.j1E2sC4f010550@apoc.cs.uiuc.edu> Changes in directory llvm-gcc/gcc: llvm-expand.c updated: 1.79 -> 1.80 --- Log message: Fix a warning, remove unnecessary restriction. --- Diffs of the changes: (+1 -2) llvm-expand.c | 3 +-- 1 files changed, 1 insertion(+), 2 deletions(-) Index: llvm-gcc/gcc/llvm-expand.c diff -u llvm-gcc/gcc/llvm-expand.c:1.79 llvm-gcc/gcc/llvm-expand.c:1.80 --- llvm-gcc/gcc/llvm-expand.c:1.79 Sat Feb 12 13:08:27 2005 +++ llvm-gcc/gcc/llvm-expand.c Sun Feb 13 20:53:56 2005 @@ -89,7 +89,7 @@ */ static llvm_value *append_inst(llvm_function *Fn, llvm_instruction *I) { llvm_basicblock *BB; - int i; + unsigned i; for (i = 0; i != I->NumOperands; ++i) if (I->Operands[i] && llvm_value_is_global(I->Operands[i])) @@ -5372,7 +5372,6 @@ break; case INDIRECT_REF: - assert(Fn && "Cannot use INDIRECT_REFS to initialize constants!"); Result = llvm_expand_expr(Fn, TREE_OPERAND(exp, 0), 0); break; From lattner at cs.uiuc.edu Sun Feb 13 20:54:53 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 13 Feb 2005 20:54:53 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/C++Frontend/2005-02-13-BadDynamicInit.cpp Message-ID: <200502140254.j1E2srbD011220@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/C++Frontend: 2005-02-13-BadDynamicInit.cpp added (r1.1) --- Log message: new testcase for PR509: http://llvm.cs.uiuc.edu/PR509 --- Diffs of the changes: (+9 -0) 2005-02-13-BadDynamicInit.cpp | 9 +++++++++ 1 files changed, 9 insertions(+) Index: llvm/test/Regression/C++Frontend/2005-02-13-BadDynamicInit.cpp diff -c /dev/null llvm/test/Regression/C++Frontend/2005-02-13-BadDynamicInit.cpp:1.1 *** /dev/null Sun Feb 13 20:54:51 2005 --- llvm/test/Regression/C++Frontend/2005-02-13-BadDynamicInit.cpp Sun Feb 13 20:54:41 2005 *************** *** 0 **** --- 1,9 ---- + // RUN: %llvmgxx %s -S -o - | not grep llvm.global_ctors + // This testcase corresponds to PR509 + struct Data { + unsigned *data; + unsigned array[1]; + }; + + Data shared_null = { shared_null.array }; + From lattner at cs.uiuc.edu Sun Feb 13 21:20:48 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 13 Feb 2005 21:20:48 -0600 Subject: [llvm-commits] CVS: llvm-gcc/gcc/tree.c Message-ID: <200502140320.j1E3Kmaa018882@apoc.cs.uiuc.edu> Changes in directory llvm-gcc/gcc: tree.c updated: 1.4 -> 1.5 --- Log message: Teach GCC that the address of a global is a constant! This is the correct solution to much hackery I have had to endure in the past. --- Diffs of the changes: (+9 -0) tree.c | 9 +++++++++ 1 files changed, 9 insertions(+) Index: llvm-gcc/gcc/tree.c diff -u llvm-gcc/gcc/tree.c:1.4 llvm-gcc/gcc/tree.c:1.5 --- llvm-gcc/gcc/tree.c:1.4 Mon Sep 27 21:30:02 2004 +++ llvm-gcc/gcc/tree.c Sun Feb 13 21:20:33 2005 @@ -1305,6 +1305,10 @@ case BIT_FIELD_REF: return 0; + + case INDIRECT_REF: + return TREE_CONSTANT (TREE_OPERAND (arg, 0)); + #if 0 /* This case is technically correct, but results in setting TREE_CONSTANT on ADDR_EXPRs that cannot be evaluated at @@ -2481,6 +2485,11 @@ TREE_READONLY (t) = 0; break; + case ADDR_EXPR: + if (node && staticp (node)) + TREE_CONSTANT (t) = 1; + break; + default: if (TREE_CODE_CLASS (code) == '1' && node && TREE_CONSTANT (node)) TREE_CONSTANT (t) = 1; From lattner at cs.uiuc.edu Sun Feb 13 21:21:57 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 13 Feb 2005 21:21:57 -0600 Subject: [llvm-commits] CVS: llvm-gcc/gcc/cp/parser.c typeck.c Message-ID: <200502140321.j1E3Lv8w019046@apoc.cs.uiuc.edu> Changes in directory llvm-gcc/gcc/cp: parser.c updated: 1.3 -> 1.4 typeck.c updated: 1.5 -> 1.6 --- Log message: Now that GCC can properly realize new things are constants (e.g. &Global[10]), we can get rid of the gross hackery we have added in the past to handle global initializers. --- Diffs of the changes: (+4 -12) parser.c | 4 ---- typeck.c | 12 ++++-------- 2 files changed, 4 insertions(+), 12 deletions(-) Index: llvm-gcc/gcc/cp/parser.c diff -u llvm-gcc/gcc/cp/parser.c:1.3 llvm-gcc/gcc/cp/parser.c:1.4 --- llvm-gcc/gcc/cp/parser.c:1.3 Mon Jan 3 16:29:14 2005 +++ llvm-gcc/gcc/cp/parser.c Sun Feb 13 21:21:43 2005 @@ -10878,7 +10878,6 @@ set to FALSE if there is no initializer present. If there is an initializer, and it is not a constant-expression, *NON_CONSTANT_P is set to true; otherwise it is set to false. */ -extern int parsing_initializer; static tree cp_parser_initializer (cp_parser* parser, bool* is_parenthesized_init, bool* non_constant_p) @@ -10895,8 +10894,6 @@ /* Assume that the initializer is constant. */ *non_constant_p = false; - ++parsing_initializer; - if (token->type == CPP_EQ) { /* Consume the `='. */ @@ -10914,7 +10911,6 @@ init = error_mark_node; } - --parsing_initializer; return init; } Index: llvm-gcc/gcc/cp/typeck.c diff -u llvm-gcc/gcc/cp/typeck.c:1.5 llvm-gcc/gcc/cp/typeck.c:1.6 --- llvm-gcc/gcc/cp/typeck.c:1.5 Fri Feb 11 14:09:06 2005 +++ llvm-gcc/gcc/cp/typeck.c Sun Feb 13 21:21:43 2005 @@ -20,8 +20,6 @@ the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -extern int parsing_initializer; - /* This file is part of the C++ front end. It contains routines to build C++ expressions given their operands, including computing the types of the result, C and C++ specific error @@ -2229,7 +2227,7 @@ * instead, generate an array ref, even though the first argument is a * pointer, not an array! */ - if (EMIT_LLVM && !parsing_initializer) + if (EMIT_LLVM) return build (ARRAY_REF, TREE_TYPE(TREE_TYPE(ar)), ar, ind); return build_indirect_ref (cp_build_binary_op (PLUS_EXPR, ar, ind), @@ -3913,7 +3911,7 @@ } /* For &x[y], return x+y */ - if (TREE_CODE (arg) == ARRAY_REF && (!EMIT_LLVM || parsing_initializer)) + if (TREE_CODE (arg) == ARRAY_REF && !EMIT_LLVM) { if (!cxx_mark_addressable (TREE_OPERAND (arg, 0))) return error_mark_node; @@ -4054,13 +4052,11 @@ rval = build_base_path (PLUS_EXPR, rval, binfo, 1); rval = build_nop (argtype, rval); - if (!EMIT_LLVM || parsing_initializer) + if (!EMIT_LLVM) addr = fold (build (PLUS_EXPR, argtype, rval, cp_convert (argtype, byte_position (field)))); else - /* For LLVM, don't fold pointer arithmetic unless parsing a - * static initializer. - */ + /* For LLVM, don't fold pointer arithmetic! */ addr = fold(build1(ADDR_EXPR, argtype, arg)); } From lattner at cs.uiuc.edu Sun Feb 13 21:22:09 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 13 Feb 2005 21:22:09 -0600 Subject: [llvm-commits] CVS: llvm-gcc/gcc/c-typeck.c Message-ID: <200502140322.j1E3M95P019097@apoc.cs.uiuc.edu> Changes in directory llvm-gcc/gcc: c-typeck.c updated: 1.5 -> 1.6 --- Log message: Now that GCC can properly realize new things are constants (e.g. &Global[10]), we can get rid of the gross hackery we have added in the past to handle global initializers. --- Diffs of the changes: (+3 -10) c-typeck.c | 13 +++---------- 1 files changed, 3 insertions(+), 10 deletions(-) Index: llvm-gcc/gcc/c-typeck.c diff -u llvm-gcc/gcc/c-typeck.c:1.5 llvm-gcc/gcc/c-typeck.c:1.6 --- llvm-gcc/gcc/c-typeck.c:1.5 Mon Jan 3 16:13:16 2005 +++ llvm-gcc/gcc/c-typeck.c Sun Feb 13 21:21:56 2005 @@ -46,8 +46,6 @@ #include "target.h" #include "llvm-out.h" -extern int parsing_initializer; - /* Nonzero if we've already printed a "missing braces around initializer" message within this initializer. */ static int missing_braces_mentioned; @@ -2417,7 +2415,7 @@ /* DON'T fold this, unless its a constant expression which might * initialize a global. */ - if (!EMIT_LLVM || parsing_initializer) + if (!EMIT_LLVM) return build_binary_op (PLUS_EXPR, TREE_OPERAND (arg, 0), TREE_OPERAND (arg, 1), 1); } @@ -2468,10 +2466,8 @@ return error_mark_node; } - if (EMIT_LLVM && !parsing_initializer) { - /* For LLVM, don't fold pointer arithmetic unless doing so - * produces a constant! - */ + if (EMIT_LLVM) { + /* For LLVM, don't fold pointer arithmetic! */ addr = build1 (code, argtype, arg); } else @@ -4347,8 +4343,6 @@ if (asmspec_tree) asmspec = TREE_STRING_POINTER (asmspec_tree); - ++parsing_initializer; - p->decl = constructor_decl; p->asmspec = constructor_asmspec; p->require_constant_value = require_constant_value; @@ -4431,7 +4425,6 @@ constructor_top_level = p->top_level; initializer_stack = p->next; free (p); - --parsing_initializer; } /* Call here when we see the initializer is surrounded by braces. From lattner at cs.uiuc.edu Sun Feb 13 21:22:17 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 13 Feb 2005 21:22:17 -0600 Subject: [llvm-commits] CVS: llvm-gcc/gcc/c-common.c Message-ID: <200502140322.j1E3MHTH019116@apoc.cs.uiuc.edu> Changes in directory llvm-gcc/gcc: c-common.c updated: 1.6 -> 1.7 --- Log message: Now that GCC can properly realize new things are constants (e.g. &Global[10]), we can get rid of the gross hackery we have added in the past to handle global initializers. --- Diffs of the changes: (+1 -4) c-common.c | 5 +---- 1 files changed, 1 insertion(+), 4 deletions(-) Index: llvm-gcc/gcc/c-common.c diff -u llvm-gcc/gcc/c-common.c:1.6 llvm-gcc/gcc/c-common.c:1.7 --- llvm-gcc/gcc/c-common.c:1.6 Mon Jan 3 16:13:16 2005 +++ llvm-gcc/gcc/c-common.c Sun Feb 13 21:22:04 2005 @@ -44,8 +44,6 @@ #include "toplev.h" #include "llvm-out.h" -int parsing_initializer = 0; - cpp_reader *parse_in; /* Declared in c-pragma.h. */ /* We let tm.h override the types used here, to handle trivial differences @@ -2563,8 +2561,7 @@ intop = convert (c_common_type_for_size (TYPE_PRECISION (sizetype), TREE_UNSIGNED (sizetype)), intop); - /* Don't create an ARRAY_REF if this is a potentially a static initializer. */ - if (EMIT_LLVM && !parsing_initializer) { + if (EMIT_LLVM) { /* In LLVM we really want to represent this as &P[i], not as P+i*sizeof(*P) */ tree arrayref; From alenhar2 at cs.uiuc.edu Sun Feb 13 23:41:59 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Sun, 13 Feb 2005 23:41:59 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp Message-ID: <200502140541.j1E5fxO2023854@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.52 -> 1.53 --- Log message: fix setcc on floats, fixes singlesource:pi, perhaps others --- Diffs of the changes: (+5 -1) AlphaISelPattern.cpp | 6 +++++- 1 files changed, 5 insertions(+), 1 deletion(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.52 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.53 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.52 Sat Feb 12 15:11:17 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Sun Feb 13 23:41:43 2005 @@ -63,6 +63,8 @@ setOperationAction(ISD::MEMSET , MVT::Other, Expand); setOperationAction(ISD::MEMCPY , MVT::Other, Expand); + setOperationAction(ISD::SETCC , MVT::f32, Promote); + computeRegisterProperties(); addLegalFPImmediate(+0.0); //F31 @@ -1109,15 +1111,17 @@ //Can only compare doubles, and dag won't promote for me if (SetCC->getOperand(0).getValueType() == MVT::f32) { + std::cerr << "Setcc On float?\n"; Tmp3 = MakeReg(MVT::f64); BuildMI(BB, Alpha::CVTST, 1, Tmp3).addReg(Tmp1); Tmp1 = Tmp3; } if (SetCC->getOperand(1).getValueType() == MVT::f32) { + std::cerr << "Setcc On float?\n"; Tmp3 = MakeReg(MVT::f64); BuildMI(BB, Alpha::CVTST, 1, Tmp3).addReg(Tmp2); - Tmp1 = Tmp2; + Tmp2 = Tmp3; } if (rev) std::swap(Tmp1, Tmp2);