From lattner at cs.uiuc.edu Mon Mar 28 00:21:33 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 28 Mar 2005 00:21:33 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/IPA/Andersens.cpp Message-ID: <200503280621.j2S6LX9i001415@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/IPA: Andersens.cpp updated: 1.15 -> 1.16 --- Log message: Teach andersens that non-escaping memory cannot be mod/ref'd by external fn calls. --- Diffs of the changes: (+40 -2) Andersens.cpp | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 40 insertions(+), 2 deletions(-) Index: llvm/lib/Analysis/IPA/Andersens.cpp diff -u llvm/lib/Analysis/IPA/Andersens.cpp:1.15 llvm/lib/Analysis/IPA/Andersens.cpp:1.16 --- llvm/lib/Analysis/IPA/Andersens.cpp:1.15 Sun Mar 27 22:32:12 2005 +++ llvm/lib/Analysis/IPA/Andersens.cpp Mon Mar 28 00:21:17 2005 @@ -235,6 +235,7 @@ // AliasResult alias(const Value *V1, unsigned V1Size, const Value *V2, unsigned V2Size); + ModRefResult getModRefInfo(CallSite CS, Value *P, unsigned Size); void getMustAliases(Value *P, std::vector &RetVals); bool pointsToConstantMemory(const Value *P); @@ -346,8 +347,8 @@ AliasAnalysis::AliasResult Andersens::alias(const Value *V1, unsigned V1Size, const Value *V2, unsigned V2Size) { - Node *N1 = getNode((Value*)V1); - Node *N2 = getNode((Value*)V2); + Node *N1 = getNode(const_cast(V1)); + Node *N2 = getNode(const_cast(V2)); // Check to see if the two pointers are known to not alias. They don't alias // if their points-to sets do not intersect. @@ -357,6 +358,39 @@ return AliasAnalysis::alias(V1, V1Size, V2, V2Size); } +AliasAnalysis::ModRefResult +Andersens::getModRefInfo(CallSite CS, Value *P, unsigned Size) { + // The only thing useful that we can contribute for mod/ref information is + // when calling external function calls: if we know that memory never escapes + // from the program, it cannot be modified by an external call. + // + // NOTE: This is not really safe, at least not when the entire program is not + // available. The deal is that the external function could call back into the + // program and modify stuff. We ignore this technical niggle for now. This + // is, after all, a "research quality" implementation of Andersen's analysis. + if (Function *F = CS.getCalledFunction()) + if (F->isExternal()) { + Node *N1 = getNode(P); + bool PointsToUniversalSet = false; + + for (Node::iterator NI = N1->begin(), E = N1->end(); NI != E; ++NI) { + Node *PN = *NI; + if (PN->begin() == PN->end()) + continue; // P doesn't point to anything. + // Get the first pointee. + Node *FirstPointee = *PN->begin(); + if (FirstPointee == &GraphNodes[UniversalSet]) { + PointsToUniversalSet = true; + break; + } + } + + if (!PointsToUniversalSet) + return NoModRef; // P doesn't point to the universal set. + } + + return AliasAnalysis::getModRefInfo(CS, P, Size); +} /// getMustAlias - We can provide must alias information if we know that a /// pointer can only point to a specific function or the null pointer. @@ -604,6 +638,10 @@ void Andersens::CollectConstraints(Module &M) { // First, the universal set points to itself. GraphNodes[UniversalSet].addPointerTo(&GraphNodes[UniversalSet]); + Constraints.push_back(Constraint(Constraint::Load, &GraphNodes[UniversalSet], + &GraphNodes[UniversalSet])); + Constraints.push_back(Constraint(Constraint::Store, &GraphNodes[UniversalSet], + &GraphNodes[UniversalSet])); // Next, the null pointer points to the null object. GraphNodes[NullPtr].addPointerTo(&GraphNodes[NullObject]); From alkis at cs.uiuc.edu Mon Mar 28 09:30:09 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon, 28 Mar 2005 09:30:09 -0600 Subject: [llvm-commits] CVS: llvm-java/tools/class2llvm/Makefile Message-ID: <200503281530.JAA32472@zion.cs.uiuc.edu> Changes in directory llvm-java/tools/class2llvm: Makefile updated: 1.7 -> 1.8 --- Log message: Disable llc diffs. --- Diffs of the changes: (+2 -1) Makefile | 3 ++- 1 files changed, 2 insertions(+), 1 deletion(-) Index: llvm-java/tools/class2llvm/Makefile diff -u llvm-java/tools/class2llvm/Makefile:1.7 llvm-java/tools/class2llvm/Makefile:1.8 --- llvm-java/tools/class2llvm/Makefile:1.7 Thu Dec 2 15:51:12 2004 +++ llvm-java/tools/class2llvm/Makefile Mon Mar 28 09:29:55 2005 @@ -11,6 +11,7 @@ TOOLNAME := class2llvm USEDLIBS := LLVMJavaClassfile LLVMJavaCompiler -LLVMLIBS := LLVMBCWriter LLVMCore LLVMSupport.a LLVMbzip2 LLVMSystem.a +LLVMLIBS := LLVMScalarOpts.a LLVMTarget.a LLVMTransformUtils.a LLVMAnalysis.a \ + LLVMBCWriter LLVMCore LLVMSupport.a LLVMbzip2 LLVMSystem.a include $(LEVEL)/Makefile.common From duraid at octopus.com.au Mon Mar 28 09:21:54 2005 From: duraid at octopus.com.au (Duraid Madina) Date: Mon, 28 Mar 2005 09:21:54 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/IA64/IA64AsmPrinter.cpp Message-ID: <200503281521.JAA32388@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/IA64: IA64AsmPrinter.cpp updated: 1.3 -> 1.4 --- Log message: Emit .global @function and .global @object entries so the Intel ias assembler may be used; identify LLVM output as such. --- Diffs of the changes: (+21 -7) IA64AsmPrinter.cpp | 28 +++++++++++++++++++++------- 1 files changed, 21 insertions(+), 7 deletions(-) Index: llvm/lib/Target/IA64/IA64AsmPrinter.cpp diff -u llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.3 llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.4 --- llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.3 Wed Mar 23 23:12:48 2005 +++ llvm/lib/Target/IA64/IA64AsmPrinter.cpp Mon Mar 28 09:21:43 2005 @@ -36,7 +36,7 @@ struct IA64SharedAsmPrinter : public AsmPrinter { - std::set ExternalFunctionNames; + std::set ExternalFunctionNames, ExternalObjectNames; IA64SharedAsmPrinter(std::ostream &O, TargetMachine &TM) : AsmPrinter(O, TM) { } @@ -84,7 +84,8 @@ if (CP.empty()) return; - O << "\n\t.section .data\n"; // would be nice to have this rodata? hmmm + O << "\n\t.section .data, \"aw\", \"progbits\"\n"; + // FIXME: would be nice to have rodata (no 'w') when appropriate? for (unsigned i = 0, e = CP.size(); i != e; ++i) { emitAlignment(TD.getTypeAlignmentShift(CP[i]->getType())); O << ".CPI" << CurrentFnName << "_" << i << ":\t\t\t\t\t" << CommentString @@ -112,7 +113,7 @@ I->hasWeakLinkage() /* FIXME: Verify correct */)) { SwitchSection(O, CurSection, ".data"); if (I->hasInternalLinkage()) - O << "\t.local " << name << "\n"; +// FIXME O << "\t.local " << name << "\n"; O << "\t.common " << name << "," << TD.getTypeSize(C->getType()) << "," << (1 << Align); @@ -169,6 +170,14 @@ } O << "\n\n"; + // we print out ".global X \n .type X, @object" for each external object + O << "\n\n// (external) symbols referenced (and not defined) above: \n"; + for (std::set::iterator i = ExternalObjectNames.begin(), + e = ExternalObjectNames.end(); i!=e; ++i) { + O << "\t.global " << *i << "\n\t.type " << *i << ", @object\n"; + } + O << "\n\n"; + AsmPrinter::doFinalization(M); return false; // success } @@ -265,7 +274,7 @@ // Print out labels for the function. O << "\n\t.section .text, \"ax\", \"progbits\"\n"; // ^^ means "Allocated instruXions in mem, initialized" - emitAlignment(4); + emitAlignment(5); O << "\t.global\t" << CurrentFnName << "\n"; O << "\t.type\t" << CurrentFnName << ", @function\n"; O << CurrentFnName << ":\n"; @@ -343,9 +352,12 @@ // the function somewhere (GNU gas has no problem without this, but // Intel ias rightly complains of an 'undefined symbol') - if(F && isBRCALLinsn && F->isExternal()) + if(F /*&& isBRCALLinsn*/ && F->isExternal()) ExternalFunctionNames.insert(Mang->getValueName(MO.getGlobal())); - + else + if(GV->isExternal()) // e.g. stuff like 'stdin' + ExternalObjectNames.insert(Mang->getValueName(MO.getGlobal())); + if (!isBRCALLinsn) O << "@ltoff("; if (Needfptr) @@ -364,6 +376,7 @@ } case MachineOperand::MO_ExternalSymbol: O << MO.getSymbolName(); + ExternalFunctionNames.insert(MO.getSymbolName()); return; default: O << ""; return; @@ -384,7 +397,8 @@ bool IA64AsmPrinter::doInitialization(Module &M) { AsmPrinter::doInitialization(M); - O << "\t.psr lsb\n" // should be "msb" on HP-UX, for starters + O << "\n.ident \"LLVM-ia64\"\n\n" + << "\t.psr lsb\n" // should be "msb" on HP-UX, for starters << "\t.radix C\n" << "\t.psr abi64\n"; // we only support 64 bits for now return false; From alkis at cs.uiuc.edu Mon Mar 28 09:33:55 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon, 28 Mar 2005 09:33:55 -0600 Subject: [llvm-commits] CVS: llvm-java/test/Makefile.test Message-ID: <200503281533.JAA32505@zion.cs.uiuc.edu> Changes in directory llvm-java/test: Makefile.test updated: 1.45 -> 1.46 --- Log message: Disable llc diffs. --- 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.45 llvm-java/test/Makefile.test:1.46 --- llvm-java/test/Makefile.test:1.45 Sat Mar 12 02:29:57 2005 +++ llvm-java/test/Makefile.test Mon Mar 28 09:33:44 2005 @@ -115,6 +115,6 @@ %.bugpoint.gccld: %.raw.llvm.bc %.out-nat $(LBUGPOINT) $< $(GCCLD_PASS_ARGS) -output=$*.out-nat -all-local:: $(JIT_DIFFS) $(LLC_DIFFS) +all-local:: $(JIT_DIFFS) endif From alkis at cs.uiuc.edu Mon Mar 28 09:36:05 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon, 28 Mar 2005 09:36:05 -0600 Subject: [llvm-commits] CVS: llvm-java/tools/class2llvm/Makefile Message-ID: <200503281536.JAA32529@zion.cs.uiuc.edu> Changes in directory llvm-java/tools/class2llvm: Makefile updated: 1.8 -> 1.9 --- Log message: Revert patch committed by mistake. --- Diffs of the changes: (+1 -2) Makefile | 3 +-- 1 files changed, 1 insertion(+), 2 deletions(-) Index: llvm-java/tools/class2llvm/Makefile diff -u llvm-java/tools/class2llvm/Makefile:1.8 llvm-java/tools/class2llvm/Makefile:1.9 --- llvm-java/tools/class2llvm/Makefile:1.8 Mon Mar 28 09:29:55 2005 +++ llvm-java/tools/class2llvm/Makefile Mon Mar 28 09:35:54 2005 @@ -11,7 +11,6 @@ TOOLNAME := class2llvm USEDLIBS := LLVMJavaClassfile LLVMJavaCompiler -LLVMLIBS := LLVMScalarOpts.a LLVMTarget.a LLVMTransformUtils.a LLVMAnalysis.a \ - LLVMBCWriter LLVMCore LLVMSupport.a LLVMbzip2 LLVMSystem.a +LLVMLIBS := LLVMBCWriter LLVMCore LLVMSupport.a LLVMbzip2 LLVMSystem.a include $(LEVEL)/Makefile.common From lattner at cs.uiuc.edu Mon Mar 28 12:40:37 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 28 Mar 2005 12:40:37 -0600 Subject: [llvm-commits] CVS: llvm-www/testresults/index.html Message-ID: <200503281840.j2SIebLW012383@apoc.cs.uiuc.edu> Changes in directory llvm-www/testresults: index.html updated: 1.33 -> 1.34 --- Log message: Add Al Stone's IA64 tester, sort by architecture --- Diffs of the changes: (+32 -25) index.html | 57 ++++++++++++++++++++++++++++++++------------------------- 1 files changed, 32 insertions(+), 25 deletions(-) Index: llvm-www/testresults/index.html diff -u llvm-www/testresults/index.html:1.33 llvm-www/testresults/index.html:1.34 --- llvm-www/testresults/index.html:1.33 Thu Mar 24 22:52:01 2005 +++ llvm-www/testresults/index.html Mon Mar 28 12:40:20 2005 @@ -18,8 +18,39 @@ mailing list.

-

X86

+

Alpha

+
    + +
  1. Linux (Single 21164 EV56 500 +MHz) -- release build
  2. + +
  3. Linux (Single 21264 EV7 +633 MHz) -- debug build
  4. +
+ +

IA-64

+
    + +
  1. Debian GNU/Linux +unstable, dual Itanium2(tm) 1.5GHz -- debug build
  2. +
+ + +

PowerPC

+
    + +
  1. Mac OS X 10.3 +"Panther" on PowerPC G5 (dual 1.8Ghz CPU) -- debug build
  2. +
+

Sparc V9

+
    + +
  1. SunOS 5.8 on Sun Fire V240 (dual 1Ghz CPU) -- debug +build
  2. +
+ +

X86

  1. Linux (Dual P4 Xeon @ 3.06GHz) -- debug build
  2. @@ -42,30 +73,6 @@
-

PowerPC

-
    - -
  1. Mac OS X 10.3 -"Panther" on PowerPC G5 (dual 1.8Ghz CPU) -- debug build
  2. -
- -

Sparc V9

-
    - -
  1. SunOS 5.8 on Sun Fire V240 (dual 1Ghz CPU) -- debug -build
  2. -
- -

Alpha

-
    - -
  1. Linux (Single 21164 EV56 500 MHz) -- release -build
  2. - -
  3. Linux (Single 21264 EV7 633 MHz) -- debug -build
  4. -
- From alenhar2 at cs.uiuc.edu Mon Mar 28 13:03:45 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Mon, 28 Mar 2005 13:03:45 -0600 Subject: [llvm-commits] CVS: llvm-test/MultiSource/Benchmarks/Olden/voronoi/newvor.c Message-ID: <200503281903.NAA08995@niobe.cs.uiuc.edu> Changes in directory llvm-test/MultiSource/Benchmarks/Olden/voronoi: newvor.c updated: 1.8 -> 1.9 --- Log message: added define for alpha to get correct prototype for memalign --- Diffs of the changes: (+5 -0) newvor.c | 5 +++++ 1 files changed, 5 insertions(+) Index: llvm-test/MultiSource/Benchmarks/Olden/voronoi/newvor.c diff -u llvm-test/MultiSource/Benchmarks/Olden/voronoi/newvor.c:1.8 llvm-test/MultiSource/Benchmarks/Olden/voronoi/newvor.c:1.9 --- llvm-test/MultiSource/Benchmarks/Olden/voronoi/newvor.c:1.8 Mon Mar 7 10:41:13 2005 +++ llvm-test/MultiSource/Benchmarks/Olden/voronoi/newvor.c Mon Mar 28 13:03:28 2005 @@ -4,6 +4,11 @@ #include #include "defines.h" +#if defined(__alpha__) +#include +#endif + + VERTEX_PTR *vp ; struct VERTEX *va ; EDGE_PTR *next ; From alkis at cs.uiuc.edu Mon Mar 28 13:19:38 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon, 28 Mar 2005 13:19:38 -0600 Subject: [llvm-commits] CVS: llvm-java/runtime/runtime.c Message-ID: <200503281919.NAA01335@zion.cs.uiuc.edu> Changes in directory llvm-java/runtime: runtime.c updated: 1.22 -> 1.23 --- Log message: Always use memmove when copying arrays. --- Diffs of the changes: (+1 -6) runtime.c | 7 +------ 1 files changed, 1 insertion(+), 6 deletions(-) Index: llvm-java/runtime/runtime.c diff -u llvm-java/runtime/runtime.c:1.22 llvm-java/runtime/runtime.c:1.23 --- llvm-java/runtime/runtime.c:1.22 Fri Mar 25 20:40:48 2005 +++ llvm-java/runtime/runtime.c Mon Mar 28 13:19:27 2005 @@ -380,12 +380,7 @@ src += srcStart * srcObj->vtable->typeinfo.elementSize; dst += dstStart * dstObj->vtable->typeinfo.elementSize; - // If arrays do not overlap use memcpy. - if ((dst > src ? dst - src : src - dst) > nbytes) - memcpy(dst, src, nbytes); - // If arrays overlap use memmove. - else - memmove(dst, src, nbytes); + memmove(dst, src, nbytes); } void Java_gnu_classpath_VMSystemProperties_preInit(JNIEnv *env, jobject clazz, From natebegeman at mac.com Mon Mar 28 13:36:54 2005 From: natebegeman at mac.com (Nate Begeman) Date: Mon, 28 Mar 2005 13:36:54 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Message-ID: <200503281936.NAA01615@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPC32ISelPattern.cpp updated: 1.9 -> 1.10 --- Log message: Implement proper loads and zero-extends of all types --- Diffs of the changes: (+61 -12) PPC32ISelPattern.cpp | 73 ++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 61 insertions(+), 12 deletions(-) Index: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp diff -u llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.9 llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.10 --- llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.9 Sat Mar 26 02:25:22 2005 +++ llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Mon Mar 28 13:36:43 2005 @@ -559,8 +559,37 @@ return Result; case ISD::LOAD: - case ISD::EXTLOAD: - abort(); + case ISD::EXTLOAD: { + MVT::ValueType TypeBeingLoaded = (ISD::LOAD == opcode) ? + Node->getValueType(0) : cast(Node)->getExtraValueType(); + + // Make sure we generate both values. + if (Result != 1) + ExprMap[N.getValue(1)] = 1; // Generate the token + else + Result = ExprMap[N.getValue(0)] = MakeReg(N.getValue(0).getValueType()); + + SDOperand Chain = N.getOperand(0); + SDOperand Address = N.getOperand(1); + Select(Chain); + + switch (TypeBeingLoaded) { + default: assert(0 && "Cannot fp load this type!"); + case MVT::f32: Opc = PPC::LFS; break; + case MVT::f64: Opc = PPC::LFD; break; + } + + if(Address.getOpcode() == ISD::FrameIndex) { + BuildMI(BB, Opc, 2, Result) + .addFrameIndex(cast(Address)->getIndex()) + .addReg(PPC::R1); + } else { + int offset; + SelectAddr(Address, Tmp1, offset); + BuildMI(BB, Opc, 2, Result).addSImm(offset).addReg(Tmp1); + } + return Result; + } case ISD::ConstantFP: abort(); @@ -681,6 +710,11 @@ case ISD::EXTLOAD: case ISD::ZEXTLOAD: case ISD::SEXTLOAD: { + bool sext = (ISD::SEXTLOAD == opcode); + bool byte = (MVT::i8 == Node->getValueType(0)); + MVT::ValueType TypeBeingLoaded = (ISD::LOAD == opcode) ? + Node->getValueType(0) : cast(Node)->getExtraValueType(); + // Make sure we generate both values. if (Result != 1) ExprMap[N.getValue(1)] = 1; // Generate the token @@ -691,14 +725,20 @@ SDOperand Address = N.getOperand(1); Select(Chain); - switch (Node->getValueType(0)) { + switch (TypeBeingLoaded) { default: assert(0 && "Cannot load this type!"); - case MVT::i1: Opc = PPC::LBZ; Tmp3 = 0; break; - case MVT::i8: Opc = PPC::LBZ; Tmp3 = 1; break; - case MVT::i16: Opc = PPC::LHZ; Tmp3 = 0; break; - case MVT::i32: Opc = PPC::LWZ; Tmp3 = 0; break; + case MVT::i1: Opc = PPC::LBZ; break; + case MVT::i8: Opc = PPC::LBZ; break; + case MVT::i16: Opc = sext ? PPC::LHA : PPC::LHZ; break; + case MVT::i32: Opc = PPC::LWZ; break; } + // Since there's no load byte & sign extend instruction we have to split + // byte SEXTLOADs into lbz + extsb. This requires we make a temp register. + if (sext && byte) { + Tmp3 = Result; + Result = MakeReg(MVT::i32); + } if(Address.getOpcode() == ISD::FrameIndex) { BuildMI(BB, Opc, 2, Result) .addFrameIndex(cast(Address)->getIndex()) @@ -708,6 +748,10 @@ SelectAddr(Address, Tmp1, offset); BuildMI(BB, Opc, 2, Result).addSImm(offset).addReg(Tmp1); } + if (sext && byte) { + BuildMI(BB, PPC::EXTSB, 1, Tmp3).addReg(Result); + Result = Tmp3; + } return Result; } @@ -809,16 +853,21 @@ case ISD::SIGN_EXTEND: case ISD::SIGN_EXTEND_INREG: Tmp1 = SelectExpr(N.getOperand(0)); - BuildMI(BB, PPC::EXTSH, 1, Result).addReg(Tmp1); + switch(cast(Node)->getExtraValueType()) { + default: Node->dump(); assert(0 && "Unhandled SIGN_EXTEND type"); break; + case MVT::i16: + BuildMI(BB, PPC::EXTSH, 1, Result).addReg(Tmp1); + break; + case MVT::i8: + BuildMI(BB, PPC::EXTSB, 1, Result).addReg(Tmp1); + break; + } return Result; case ISD::ZERO_EXTEND_INREG: Tmp1 = SelectExpr(N.getOperand(0)); switch(cast(Node)->getExtraValueType()) { - default: - Node->dump(); - assert(0 && "Zero Extend InReg not there yet"); - break; + default: Node->dump(); assert(0 && "Unhandled ZERO_EXTEND type"); break; case MVT::i16: Tmp2 = 16; break; case MVT::i8: Tmp2 = 24; break; case MVT::i1: Tmp2 = 31; break; From alkis at cs.uiuc.edu Mon Mar 28 13:53:35 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon, 28 Mar 2005 13:53:35 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMClass.h VMClass.cpp Resolver.h Resolver.cpp Compiler.cpp Class.h Class.cpp Message-ID: <200503281953.NAA01931@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMClass.h updated: 1.12 -> 1.13 VMClass.cpp updated: 1.13 -> 1.14 Resolver.h updated: 1.7 -> 1.8 Resolver.cpp updated: 1.5 -> 1.6 Compiler.cpp updated: 1.260 -> 1.261 Class.h (r1.12) removed Class.cpp (r1.13) removed --- Log message: Rename Class to VMClass. --- Diffs of the changes: (+101 -97) Compiler.cpp | 88 ++++++++++++++++++++++++++++++----------------------------- Resolver.cpp | 26 ++++++++--------- Resolver.h | 18 ++++++------ VMClass.cpp | 38 ++++++++++++------------- VMClass.h | 28 +++++++++--------- 5 files changed, 101 insertions(+), 97 deletions(-) Index: llvm-java/lib/Compiler/VMClass.h diff -u llvm-java/lib/Compiler/VMClass.h:1.12 llvm-java/lib/Compiler/VMClass.h:1.13 --- llvm-java/lib/Compiler/VMClass.h:1.12 Sun Mar 27 20:46:19 2005 +++ llvm-java/lib/Compiler/VMClass.h Mon Mar 28 13:53:24 2005 @@ -1,4 +1,4 @@ -//===-- Class.h - Compiler representation of a Java class -------*- C++ -*-===// +//===-- VMClass.h - Compiler representation of a Java class -----*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -27,13 +27,13 @@ class ClassFile; class Resolver; - class Class { + class VMClass { static const unsigned INVALID_INTERFACE_INDEX = 0xFFFFFFFF; const std::string name_; Resolver* resolver_; const ClassFile* classFile_; - const Class* componentClass_; + const VMClass* componentClass_; Type* structType_; const Type* type_; unsigned interfaceIndex_; @@ -42,8 +42,8 @@ typedef std::vector ElementTypes; ElementTypes elementTypes_; mutable std::vector resolvedConstantPool_; - std::vector superClasses_; - std::vector interfaces_; + std::vector superClasses_; + std::vector interfaces_; void addField(const std::string& name, const Type* type); void resolveType(); @@ -53,13 +53,13 @@ // Resolver interface. // Load primitive class for type. - Class(Resolver* resolver, const Type* type); + VMClass(Resolver* resolver, const Type* type); // Load class by name. - Class(Resolver* resolver, const std::string& className); + VMClass(Resolver* resolver, const std::string& className); // Load array class of component the passed class. - Class(Resolver* resolver, const Class* componentClass); + VMClass(Resolver* resolver, const VMClass* componentClass); // Link the class. void link(); @@ -74,13 +74,13 @@ const Type* getType() const { return type_; } const ClassFile* getClassFile() const { return classFile_; } unsigned getNumSuperClasses() const { return superClasses_.size(); } - const Class* getSuperClass(unsigned i) const { return superClasses_[i]; } - const Class* getSuperClass() const { + const VMClass* getSuperClass(unsigned i) const { return superClasses_[i]; } + const VMClass* getSuperClass() const { return getNumSuperClasses() ? getSuperClass(0) : NULL; } unsigned getNumInterfaces() const { return interfaces_.size(); } - const Class* getInterface(unsigned i) const { return interfaces_[i]; } - const Class* getComponentClass() const { return componentClass_; } + const VMClass* getInterface(unsigned i) const { return interfaces_[i]; } + const VMClass* getComponentClass() const { return componentClass_; } bool isArray() const { return componentClass_; } bool isPrimitive() const { return !structType_; } bool isInterface() const { return classFile_ && !getSuperClass(); } @@ -88,8 +88,8 @@ int getFieldIndex(const std::string& name) const; llvm::Constant* getConstant(unsigned index) const; - const Class* getClassForClass(unsigned index) const; - const Class* getClassForDescriptor(unsigned index) const; + const VMClass* getClassForClass(unsigned index) const; + const VMClass* getClassForDescriptor(unsigned index) const; }; } } // namespace llvm::Java Index: llvm-java/lib/Compiler/VMClass.cpp diff -u llvm-java/lib/Compiler/VMClass.cpp:1.13 llvm-java/lib/Compiler/VMClass.cpp:1.14 --- llvm-java/lib/Compiler/VMClass.cpp:1.13 Sun Mar 27 20:48:25 2005 +++ llvm-java/lib/Compiler/VMClass.cpp Mon Mar 28 13:53:24 2005 @@ -1,4 +1,4 @@ -//===-- Class.cpp - Compiler representation of a Java class -----*- C++ -*-===// +//===-- VMClass.cpp - Compiler representation of a Java class ---*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -15,7 +15,7 @@ // //===----------------------------------------------------------------------===// -#include "Class.h" +#include "VMClass.h" #include "Resolver.h" #include #include @@ -26,7 +26,7 @@ using namespace llvm; using namespace llvm::Java; -Class::Class(Resolver* resolver, const std::string& className) +VMClass::VMClass(Resolver* resolver, const std::string& className) : name_(Resolver::canonicalizeClassName(className)), resolver_(resolver), classFile_(ClassFile::get(className)), @@ -39,7 +39,7 @@ } -Class::Class(Resolver* resolver, const Class* componentClass) +VMClass::VMClass(Resolver* resolver, const VMClass* componentClass) : name_('[' + componentClass->getName()), resolver_(resolver), classFile_(NULL), @@ -51,7 +51,7 @@ } -Class::Class(Resolver* resolver, const Type* type) +VMClass::VMClass(Resolver* resolver, const Type* type) : name_(type == Type::SByteTy ? "B" : type == Type::UShortTy ? "C" : type == Type::DoubleTy ? "D" : @@ -70,18 +70,18 @@ } -void Class::addField(const std::string& name, const Type* type) +void VMClass::addField(const std::string& name, const Type* type) { f2iMap_.insert(std::make_pair(name, elementTypes_.size())); elementTypes_.push_back(type); } -int Class::getFieldIndex(const std::string& name) const { +int VMClass::getFieldIndex(const std::string& name) const { Field2IndexMap::const_iterator it = f2iMap_.find(name); return it == f2iMap_.end() ? -1 : it->second; } -void Class::resolveType() { +void VMClass::resolveType() { PATypeHolder holder = structType_; Type* resolvedType = StructType::get(elementTypes_); cast(structType_)->refineAbstractTypeTo(resolvedType); @@ -89,7 +89,7 @@ type_ = PointerType::get(structType_); } -void Class::link() +void VMClass::link() { assert(!isPrimitive() && "Should not link primitive classes!"); @@ -111,7 +111,7 @@ // This is any class but java/lang/Object. else { // Our direct super class. - const Class* superClass = + const VMClass* superClass = resolver_->getClass(classFile_->getSuperClass()->getName()->str()); // Add the interfaces of our direct superclass. @@ -121,7 +121,7 @@ // For each of the interfaces we implement, load it and add that // interface and all the interfaces it inherits from. for (unsigned i = 0, e = classFile_->getNumInterfaces(); i != e; ++i) { - const Class* interface = + const VMClass* interface = getClassForClass(classFile_->getInterfaceIndex(i)); interfaces_.push_back(interface); for (unsigned j = 0, f = interface->getNumInterfaces(); j != f; ++j) @@ -169,7 +169,7 @@ assert(!isa(getStructType()) &&"Class not initialized properly!"); } -llvm::Constant* Class::getConstant(unsigned index) const +llvm::Constant* VMClass::getConstant(unsigned index) const { assert(classFile_ && "No constant pool!"); assert((dynamic_cast(classFile_->getConstant(index)) || @@ -183,7 +183,7 @@ if (!resolvedConstantPool_[index]) { Constant* jc = classFile_->getConstant(index); if (ConstantString* s = dynamic_cast(jc)) { - const Class* stringClass = resolver_->getClass("java/lang/String"); + const VMClass* stringClass = resolver_->getClass("java/lang/String"); const Type* stringType = stringClass->getStructType(); resolvedConstantPool_[index] = new GlobalVariable(stringType, @@ -212,7 +212,7 @@ return static_cast(resolvedConstantPool_[index]); } -const Class* Class::getClassForClass(unsigned index) const +const VMClass* VMClass::getClassForClass(unsigned index) const { assert(classFile_ && "No constant pool!"); assert(dynamic_cast(classFile_->getConstant(index)) && @@ -222,13 +222,13 @@ if (!resolvedConstantPool_[index]) { ConstantClass* jc = classFile_->getConstantClass(index); resolvedConstantPool_[index] = - const_cast(resolver_->getClass(jc->getName()->str())); + const_cast(resolver_->getClass(jc->getName()->str())); } - return static_cast(resolvedConstantPool_[index]); + return static_cast(resolvedConstantPool_[index]); } -const Class* Class::getClassForDescriptor(unsigned index) const +const VMClass* VMClass::getClassForDescriptor(unsigned index) const { assert(classFile_ && "No constant pool!"); assert(dynamic_cast(classFile_->getConstant(index)) && @@ -238,8 +238,8 @@ if (!resolvedConstantPool_[index]) { ConstantUtf8* jc = classFile_->getConstantUtf8(index); resolvedConstantPool_[index] = - const_cast(resolver_->getClassForDesc(jc->str())); + const_cast(resolver_->getClassForDesc(jc->str())); } - return static_cast(resolvedConstantPool_[index]); + return static_cast(resolvedConstantPool_[index]); } Index: llvm-java/lib/Compiler/Resolver.h diff -u llvm-java/lib/Compiler/Resolver.h:1.7 llvm-java/lib/Compiler/Resolver.h:1.8 --- llvm-java/lib/Compiler/Resolver.h:1.7 Sun Mar 27 20:48:25 2005 +++ llvm-java/lib/Compiler/Resolver.h Mon Mar 28 13:53:24 2005 @@ -15,7 +15,7 @@ #ifndef LLVM_JAVA_RESOLVER_H #define LLVM_JAVA_RESOLVER_H -#include "Class.h" +#include "VMClass.h" #include #include #include @@ -27,26 +27,26 @@ class Resolver { Module* module_; - typedef std::map ClassMap; + typedef std::map ClassMap; ClassMap classMap_; unsigned nextInterfaceIndex_; const Type* objectBaseType_; const Type* objectBaseRefType_; - const Class* getClassForDesc(const std::string& descriptor); + const VMClass* getClassForDesc(const std::string& descriptor); const Type* getTypeHelper(const std::string&, unsigned& i, bool memberMethod = false) const; - std::pair insertClass(const Class& clazz) { + std::pair insertClass(const VMClass& clazz) { return classMap_.insert(std::make_pair(clazz.getName(), clazz)); } - ClassMap::iterator insertClass(ClassMap::iterator i, const Class& clazz) { + ClassMap::iterator insertClass(ClassMap::iterator i, const VMClass& clazz) { return classMap_.insert(i, std::make_pair(clazz.getName(), clazz)); } - friend class Class; + friend class VMClass; public: static std::string canonicalizeClassName(const std::string& className) { @@ -73,13 +73,13 @@ return !isTwoSlotType(type); } - const Class* getClass(const std::string& className) { + const VMClass* getClass(const std::string& className) { return getClassForDesc(canonicalizeClassName(className)); } - const Class* getClass(JType type); + const VMClass* getClass(JType type); - const Class* getArrayClass(const Class* clazz) { + const VMClass* getArrayClass(const VMClass* clazz) { return getClassForDesc('[' + clazz->getName()); } Index: llvm-java/lib/Compiler/Resolver.cpp diff -u llvm-java/lib/Compiler/Resolver.cpp:1.5 llvm-java/lib/Compiler/Resolver.cpp:1.6 --- llvm-java/lib/Compiler/Resolver.cpp:1.5 Sat Mar 26 18:04:10 2005 +++ llvm-java/lib/Compiler/Resolver.cpp Mon Mar 28 13:53:24 2005 @@ -27,15 +27,15 @@ objectBaseType_(OpaqueType::get()), objectBaseRefType_(PointerType::get(objectBaseType_)) { - insertClass(Class(this, Type::SByteTy)); - insertClass(Class(this, Type::UShortTy)); - insertClass(Class(this, Type::DoubleTy)); - insertClass(Class(this, Type::FloatTy)); - insertClass(Class(this, Type::IntTy)); - insertClass(Class(this, Type::LongTy)); - insertClass(Class(this, Type::ShortTy)); - insertClass(Class(this, Type::BoolTy)); - insertClass(Class(this, Type::VoidTy)); + insertClass(VMClass(this, Type::SByteTy)); + insertClass(VMClass(this, Type::UShortTy)); + insertClass(VMClass(this, Type::DoubleTy)); + insertClass(VMClass(this, Type::FloatTy)); + insertClass(VMClass(this, Type::IntTy)); + insertClass(VMClass(this, Type::LongTy)); + insertClass(VMClass(this, Type::ShortTy)); + insertClass(VMClass(this, Type::BoolTy)); + insertClass(VMClass(this, Type::VoidTy)); module_->addTypeName("struct.llvm_java_object_base", objectBaseType_); } @@ -88,7 +88,7 @@ return 0; // not reached } -const Class* Resolver::getClassForDesc(const std::string& descriptor) +const VMClass* Resolver::getClassForDesc(const std::string& descriptor) { ClassMap::iterator it = classMap_.lower_bound(descriptor); if (it == classMap_.end() || it->first != descriptor) { @@ -108,12 +108,12 @@ case 'L': { unsigned pos = descriptor.find(';', 1); const std::string& className = descriptor.substr(1, pos - 1); - it = insertClass(it, Class(this, className)); + it = insertClass(it, VMClass(this, className)); break; } case '[': { const std::string& componentDescriptor = descriptor.substr(1); - it = insertClass(it, Class(this, getClassForDesc(componentDescriptor))); + it = insertClass(it, VMClass(this, getClassForDesc(componentDescriptor))); break; } default: @@ -128,7 +128,7 @@ return &it->second; } -const Class* Resolver::getClass(JType type) +const VMClass* Resolver::getClass(JType type) { switch (type) { case BOOLEAN: return getClassForDesc("Z"); Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.260 llvm-java/lib/Compiler/Compiler.cpp:1.261 --- llvm-java/lib/Compiler/Compiler.cpp:1.260 Sun Mar 27 20:46:19 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Mon Mar 28 13:53:24 2005 @@ -61,7 +61,7 @@ Module* module_; std::auto_ptr resolver_; GlobalVariable* JNIEnvPtr_; - const Class* class_; + const VMClass* class_; std::auto_ptr bbBuilder_; std::list bbWorkList_; typedef std::map OpStackDepthMap; @@ -93,7 +93,7 @@ static StructType* VTableTy; static StructType* TypeInfoTy; }; - typedef std::map Class2VTableInfoMap; + typedef std::map Class2VTableInfoMap; Class2VTableInfoMap c2viMap_; public: @@ -191,7 +191,7 @@ new CallInst(memcpy_, params, "", ip); // Get class information for java/lang/String. - const Class* clazz = resolver_->getClass("java/lang/String"); + const VMClass* clazz = resolver_->getClass("java/lang/String"); const VTableInfo* vi = getVTableInfoGeneric(clazz); // Install the vtable pointer. @@ -263,7 +263,7 @@ /// VTableInfo for java.lang.Object. bool initializeVTableInfoMap() { DEBUG(std::cerr << "Building VTableInfo for: java/lang/Object\n"); - const Class* clazz = resolver_->getClass("java/lang/Object"); + const VMClass* clazz = resolver_->getClass("java/lang/Object"); VTableInfo& vi = c2viMap_[clazz]; assert(!vi.vtable && vi.m2iMap.empty() && @@ -361,7 +361,7 @@ /// its corresponding VTable. The direct superclass goes first in /// the array. llvm::Constant* - buildSuperClassesVTables(const Class* clazz, const VTableInfo& vi) const { + buildSuperClassesVTables(const VMClass* clazz, 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( @@ -387,8 +387,8 @@ /// Builds an interface VTable for the specified /// pair. - llvm::Constant* buildInterfaceVTable(const Class* clazz, - const Class* interface) { + llvm::Constant* buildInterfaceVTable(const VMClass* clazz, + const VMClass* interface) { DEBUG(std::cerr << "Building interface vtable: " << interface->getName() << " for: " << clazz->getName() << '\n'); @@ -438,8 +438,8 @@ } void insertVtablesForInterface(std::vector& vtables, - const Class* clazz, - const Class* interface) { + const VMClass* clazz, + const VMClass* interface) { static llvm::Constant* nullVTable = llvm::Constant::getNullValue(PointerType::get(VTableInfo::VTableTy)); @@ -455,7 +455,7 @@ /// corresponding VTableInfo. If this classfile is an interface we /// return a pointer to 0xFFFFFFFF. std::pair - buildInterfacesVTables(const Class* clazz, const VTableInfo& vi) { + buildInterfacesVTables(const VMClass* clazz, 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 @@ -501,7 +501,7 @@ /// Given the classfile and its corresponding VTableInfo, /// construct the typeinfo constant for it. - llvm::Constant* buildClassTypeInfo(const Class* clazz, + llvm::Constant* buildClassTypeInfo(const VMClass* clazz, const VTableInfo& vi) { std::vector typeInfoInit; @@ -529,7 +529,7 @@ } /// Returns the VTableInfo associated with this classfile. - const VTableInfo& getVTableInfo(const Class* clazz) { + const VTableInfo& getVTableInfo(const VMClass* clazz) { static bool initialized = initializeVTableInfoMap(); Class2VTableInfoMap::iterator it = c2viMap_.lower_bound(clazz); @@ -552,7 +552,7 @@ // this inherits from. if (clazz->isInterface()) { for (unsigned i = 0, e = clazz->getNumInterfaces(); i != e; ++i) { - const Class* interface = clazz->getInterface(i); + const VMClass* interface = clazz->getInterface(i); const VTableInfo& ifaceVI = getVTableInfo(interface); const ClassFile* ifaceCF = interface->getClassFile(); ConstantStruct* ifaceInit = @@ -574,7 +574,7 @@ // Otherwise this is a class, so add all methods from its super // class. else { - const Class* superClass = clazz->getSuperClass(); + const VMClass* superClass = clazz->getSuperClass(); assert(superClass && "Class does not have superclass!"); const VTableInfo& superVI = getVTableInfo(superClass); @@ -808,9 +808,9 @@ /// Finds a static field in the specified class, any of its /// super clases, or any of the interfaces it implements. - GlobalVariable* getStaticField(const Class* clazz, + GlobalVariable* getStaticField(const VMClass* clazz, const std::string& name, - const Class* fieldClass) { + const VMClass* fieldClass) { emitStaticInitializers(clazz->getClassFile()); std::string globalName = @@ -821,7 +821,7 @@ return g; for (unsigned i = 0, e = clazz->getNumInterfaces(); i != e; ++i) { - const Class* interface = clazz->getInterface(i); + const VMClass* interface = clazz->getInterface(i); emitStaticInitializers(interface->getClassFile()); globalName = interface->getClassFile()->getThisClass()->getName()->str() + @@ -832,7 +832,7 @@ } for (unsigned i = 0, e = clazz->getNumSuperClasses(); i != e; ++i) { - const Class* superClass = clazz->getSuperClass(i); + const VMClass* superClass = clazz->getSuperClass(i); emitStaticInitializers(superClass->getClassFile()); globalName = superClass->getClassFile()->getThisClass()->getName()->str() + @@ -859,7 +859,7 @@ /// Emits the necessary code to get a field from the passed /// pointer to an object. - Value* getField(const Class* clazz, + Value* getField(const VMClass* clazz, const std::string& fieldName, Value* ptr) { // Cast ptr to correct type. @@ -1094,14 +1094,14 @@ const std::string& className = classfile->getThisClass()->getName()->str(); - const Class* clazz = resolver_->getClass(className); + const VMClass* clazz = resolver_->getClass(className); // Create the global variables of this class. const Fields& fields = classfile->getFields(); for (unsigned i = 0, e = fields.size(); i != e; ++i) { Field* field = fields[i]; if (field->isStatic()) { - const Class* fieldClass = + const VMClass* fieldClass = clazz->getClassForDescriptor(field->getDescriptorIndex()); const Type* globalTy = fieldClass->getType(); // A java field can be final/constant even if it has a @@ -1281,7 +1281,7 @@ void do_saload() { do_aload_common("[S"); } void do_aload_common(const std::string& className) { - const Class* arrayClass = resolver_->getClass(className); + const VMClass* arrayClass = resolver_->getClass(className); assert(arrayClass->isArray() && "Not an array class!"); Value* index = pop(Type::IntTy); Value* arrayRef = pop(arrayClass->getType()); @@ -1318,9 +1318,9 @@ void do_sastore() { do_astore_common("[S"); } void do_astore_common(const std::string& className) { - const Class* arrayClass = resolver_->getClass(className); + const VMClass* arrayClass = resolver_->getClass(className); assert(arrayClass->isArray() && "Not an array class!"); - const Class* componentClass = arrayClass->getComponentClass(); + const VMClass* componentClass = arrayClass->getComponentClass(); Value* value = pop(componentClass->getType()); Value* index = pop(Type::IntTy); Value* arrayRef = pop(arrayClass->getType()); @@ -1636,7 +1636,7 @@ void do_putfield(unsigned index) { ConstantFieldRef* fieldRef = class_->getClassFile()->getConstantFieldRef(index); - const Class* fieldClass = class_->getClassForDescriptor( + const VMClass* fieldClass = class_->getClassForDescriptor( fieldRef->getNameAndType()->getDescriptorIndex()); const Type* type = fieldClass->getType(); Value* v = pop(type); @@ -1669,11 +1669,11 @@ return params; } - const VTableInfo* getVTableInfoGeneric(const Class* clazz) { + const VTableInfo* getVTableInfoGeneric(const VMClass* clazz) { assert(!clazz->isPrimitive() && "Cannot get VTableInfo for primitive class!"); if (clazz->isArray()) { - const Class* componentClass = clazz->getComponentClass(); + const VMClass* componentClass = clazz->getComponentClass(); if (componentClass->isPrimitive()) return &getPrimitiveArrayVTableInfo(componentClass->getType()); else @@ -1690,7 +1690,8 @@ const std::string& className = methodRef->getClass()->getName()->str(); - const Class* clazz = class_->getClassForClass(methodRef->getClassIndex()); + const VMClass* clazz = + class_->getClassForClass(methodRef->getClassIndex()); const VTableInfo* vi = getVTableInfoGeneric(clazz); const std::string& methodDescr = @@ -1732,7 +1733,8 @@ const std::string& methodDescr = methodName + nameAndType->getDescriptor()->str(); std::string funcName = className + '/' + methodDescr; - const Class* clazz = class_->getClassForClass(methodRef->getClassIndex()); + const VMClass* clazz = + class_->getClassForClass(methodRef->getClassIndex()); const FunctionType* funcTy = cast( resolver_->getType(nameAndType->getDescriptor()->str(), true)); @@ -1744,7 +1746,8 @@ void do_invokestatic(unsigned index) { ConstantMethodRef* methodRef = class_->getClassFile()->getConstantMethodRef(index); - const Class* clazz = class_->getClassForClass(methodRef->getClassIndex()); + const VMClass* clazz = + class_->getClassForClass(methodRef->getClassIndex()); emitStaticInitializers(clazz->getClassFile()); Method* method = getMethod(methodRef); Function* function = getFunction(method); @@ -1771,7 +1774,8 @@ const std::string& className = methodRef->getClass()->getName()->str(); - const Class* clazz = class_->getClassForClass(methodRef->getClassIndex()); + const VMClass* clazz = + class_->getClassForClass(methodRef->getClassIndex()); const VTableInfo* vi = getVTableInfoGeneric(clazz); const std::string& methodDescr = @@ -1822,7 +1826,7 @@ } template - Value* allocateObject(const Class& clazz, + Value* allocateObject(const VMClass& clazz, const VTableInfo& vi, InsertionPointTy* ip) { static std::vector params(4); @@ -1844,7 +1848,7 @@ } void do_new(unsigned index) { - const Class* clazz = class_->getClassForClass(index); + const VMClass* clazz = class_->getClassForClass(index); emitStaticInitializers(clazz->getClassFile()); const VTableInfo& vi = getVTableInfo(clazz); @@ -1872,14 +1876,14 @@ } template - Value* allocateArray(const Class* clazz, + Value* allocateArray(const VMClass* clazz, const VTableInfo* vi, Value* count, InsertionPointTy* ip) { static std::vector params(4); assert(clazz->isArray() && "Not an array class!"); - const Class* componentClass = clazz->getComponentClass(); + const VMClass* componentClass = clazz->getComponentClass(); const Type* elementTy = componentClass->getType(); // The size of the element. @@ -1923,8 +1927,8 @@ void do_newarray(JType type) { Value* count = pop(Type::UIntTy); - const Class* clazz = resolver_->getClass(type); - const Class* arrayClass = resolver_->getArrayClass(clazz); + const VMClass* clazz = resolver_->getClass(type); + const VMClass* arrayClass = resolver_->getArrayClass(clazz); const VTableInfo* vi = getVTableInfoGeneric(arrayClass); push(allocateArray(arrayClass, vi, count, currentBB_)); @@ -1933,15 +1937,15 @@ void do_anewarray(unsigned index) { Value* count = pop(Type::UIntTy); - const Class* clazz = class_->getClassForClass(index); - const Class* arrayClass = resolver_->getArrayClass(clazz); + const VMClass* clazz = class_->getClassForClass(index); + const VMClass* arrayClass = resolver_->getArrayClass(clazz); const VTableInfo* vi = getVTableInfoGeneric(arrayClass); push(allocateArray(arrayClass, vi, count, currentBB_)); } void do_arraylength() { - const Class* clazz = resolver_->getClass("[Ljava/lang/Object;"); + const VMClass* clazz = resolver_->getClass("[Ljava/lang/Object;"); Value* arrayRef = pop(clazz->getType()); Value* lengthPtr = getArrayLengthPtr(arrayRef, currentBB_); Value* length = new LoadInst(lengthPtr, TMP, currentBB_); @@ -1955,7 +1959,7 @@ } void do_checkcast(unsigned index) { - const Class* clazz = class_->getClassForClass(index); + const VMClass* clazz = class_->getClassForClass(index); const VTableInfo* vi = getVTableInfoGeneric(clazz); Value* objRef = pop(resolver_->getObjectBaseRefType()); @@ -1972,7 +1976,7 @@ } void do_instanceof(unsigned index) { - const Class* clazz = class_->getClassForClass(index); + const VMClass* clazz = class_->getClassForClass(index); const VTableInfo* vi = getVTableInfoGeneric(clazz); Value* objRef = pop(resolver_->getObjectBaseRefType()); From alkis at cs.uiuc.edu Mon Mar 28 13:55:53 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon, 28 Mar 2005 13:55:53 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMClass.h Message-ID: <200503281955.NAA01964@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMClass.h updated: 1.13 -> 1.14 --- Log message: Some minor changes left behind after the rename. --- Diffs of the changes: (+4 -4) VMClass.h | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) Index: llvm-java/lib/Compiler/VMClass.h diff -u llvm-java/lib/Compiler/VMClass.h:1.13 llvm-java/lib/Compiler/VMClass.h:1.14 --- llvm-java/lib/Compiler/VMClass.h:1.13 Mon Mar 28 13:53:24 2005 +++ llvm-java/lib/Compiler/VMClass.h Mon Mar 28 13:55:42 2005 @@ -7,13 +7,13 @@ // //===----------------------------------------------------------------------===// // -// This file contains the declaration of the Class class that represents a +// This file contains the declaration of the VMClass class that represents a // compile time representation of a Java class (java.lang.Class). // //===----------------------------------------------------------------------===// -#ifndef LLVM_JAVA_CLASS_H -#define LLVM_JAVA_CLASS_H +#ifndef LLVM_JAVA_VMCLASS_H +#define LLVM_JAVA_VMCLASS_H #include #include @@ -94,4 +94,4 @@ } } // namespace llvm::Java -#endif//LLVM_JAVA_CLASS_H +#endif//LLVM_JAVA_VMCLASS_H From alenhar2 at cs.uiuc.edu Mon Mar 28 14:06:05 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Mon, 28 Mar 2005 14:06:05 -0600 Subject: [llvm-commits] CVS: llvm/docs/LangRef.html Message-ID: <200503282006.j2SK6531012790@apoc.cs.uiuc.edu> Changes in directory llvm/docs: LangRef.html updated: 1.90 -> 1.91 --- Log message: First step in adding pcmarker intrinsic. Second step (soon) is adding backend support. --- Diffs of the changes: (+42 -1) LangRef.html | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 42 insertions(+), 1 deletion(-) Index: llvm/docs/LangRef.html diff -u llvm/docs/LangRef.html:1.90 llvm/docs/LangRef.html:1.91 --- llvm/docs/LangRef.html:1.90 Mon Mar 7 16:13:59 2005 +++ llvm/docs/LangRef.html Mon Mar 28 14:05:48 2005 @@ -126,6 +126,7 @@
  • 'llvm.returnaddress' Intrinsic
  • 'llvm.frameaddress' Intrinsic
  • 'llvm.prefetch' Intrinsic
  • +
  • 'llvm.pcmarker' Intrinsic
  • Operating System Intrinsics @@ -2548,6 +2549,46 @@ + + + +
    + +
    Syntax:
    +
    +  call void (uint)* %llvm.pcmarker( uint <id> )
    +
    + +
    Overview:
    + + +

    +The 'llvm.pcmarker' intrinsic is a method to export a PC in a region of +code to simulators and other tools. The method is target specific, but it is +expected that the marker will use exported symbols to transmit the PC of the marker. +The marker makes no guaranties that it will remain with any specific instruction +after optimizations. It is possible that the presense of a marker will inhibit +optimizations. The intended use is to be inserted after optmizations to allow +corrolations of simulation runs. +

    + +
    Arguments:
    + +

    +id is a numerical id identifying the marker. +

    + +
    Semantics:
    + +

    +This intrinsic does not modify the behavior of the program. Backends that do not +support this intrinisic may ignore it. +

    + +
    +
    @@ -2974,7 +3015,7 @@ Chris Lattner
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2005/03/07 22:13:59 $ + Last modified: $Date: 2005/03/28 20:05:48 $ From alenhar2 at cs.uiuc.edu Mon Mar 28 14:06:06 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Mon, 28 Mar 2005 14:06:06 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Intrinsics.h Message-ID: <200503282006.j2SK66eh012796@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: Intrinsics.h updated: 1.28 -> 1.29 --- Log message: First step in adding pcmarker intrinsic. Second step (soon) is adding backend support. --- Diffs of the changes: (+1 -0) Intrinsics.h | 1 + 1 files changed, 1 insertion(+) Index: llvm/include/llvm/Intrinsics.h diff -u llvm/include/llvm/Intrinsics.h:1.28 llvm/include/llvm/Intrinsics.h:1.29 --- llvm/include/llvm/Intrinsics.h:1.28 Mon Feb 28 13:25:57 2005 +++ llvm/include/llvm/Intrinsics.h Mon Mar 28 14:05:49 2005 @@ -35,6 +35,7 @@ returnaddress, // Yields the return address of a dynamic call frame frameaddress, // Yields the frame address of a dynamic call frame prefetch, // Prefetch a value into the cache + pcmarker, // Export a PC from near the marker // setjmp/longjmp intrinsics. setjmp, // Used to represent a setjmp call in C From alenhar2 at cs.uiuc.edu Mon Mar 28 14:06:07 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Mon, 28 Mar 2005 14:06:07 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Verifier.cpp Function.cpp Message-ID: <200503282006.j2SK67dH012808@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Verifier.cpp updated: 1.128 -> 1.129 Function.cpp updated: 1.90 -> 1.91 --- Log message: First step in adding pcmarker intrinsic. Second step (soon) is adding backend support. --- Diffs of the changes: (+6 -0) Function.cpp | 1 + Verifier.cpp | 5 +++++ 2 files changed, 6 insertions(+) Index: llvm/lib/VMCore/Verifier.cpp diff -u llvm/lib/VMCore/Verifier.cpp:1.128 llvm/lib/VMCore/Verifier.cpp:1.129 --- llvm/lib/VMCore/Verifier.cpp:1.128 Mon Mar 14 22:54:21 2005 +++ llvm/lib/VMCore/Verifier.cpp Mon Mar 28 14:05:49 2005 @@ -749,6 +749,11 @@ case Intrinsic::memset: NumArgs = 4; break; case Intrinsic::prefetch: NumArgs = 3; break; + case Intrinsic::pcmarker: + NumArgs = 1; + Assert1(isa(CI.getOperand(1)), + "First argument to llvm.pcmarker must be a constant!", &CI); + break; case Intrinsic::not_intrinsic: assert(0 && "Invalid intrinsic!"); NumArgs = 0; break; Index: llvm/lib/VMCore/Function.cpp diff -u llvm/lib/VMCore/Function.cpp:1.90 llvm/lib/VMCore/Function.cpp:1.91 --- llvm/lib/VMCore/Function.cpp:1.90 Sat Mar 5 13:51:50 2005 +++ llvm/lib/VMCore/Function.cpp Mon Mar 28 14:05:49 2005 @@ -234,6 +234,7 @@ break; case 'p': if (getName() == "llvm.prefetch") return Intrinsic::prefetch; + if (getName() == "llvm.pcmarker") return Intrinsic::pcmarker; break; case 'r': if (getName() == "llvm.returnaddress") return Intrinsic::returnaddress; From alenhar2 at cs.uiuc.edu Mon Mar 28 14:06:07 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Mon, 28 Mar 2005 14:06:07 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/IntrinsicLowering.cpp Message-ID: <200503282006.j2SK67WI012800@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: IntrinsicLowering.cpp updated: 1.24 -> 1.25 --- Log message: First step in adding pcmarker intrinsic. Second step (soon) is adding backend support. --- Diffs of the changes: (+3 -0) IntrinsicLowering.cpp | 3 +++ 1 files changed, 3 insertions(+) Index: llvm/lib/CodeGen/IntrinsicLowering.cpp diff -u llvm/lib/CodeGen/IntrinsicLowering.cpp:1.24 llvm/lib/CodeGen/IntrinsicLowering.cpp:1.25 --- llvm/lib/CodeGen/IntrinsicLowering.cpp:1.24 Mon Mar 14 22:54:19 2005 +++ llvm/lib/CodeGen/IntrinsicLowering.cpp Mon Mar 28 14:05:49 2005 @@ -172,6 +172,9 @@ case Intrinsic::prefetch: break; // Simply strip out prefetches on unsupported architectures + case Intrinsic::pcmarker: + break; // Simply strip out pcmarker on unsupported architectures + case Intrinsic::dbg_stoppoint: case Intrinsic::dbg_region_start: case Intrinsic::dbg_region_end: From lattner at cs.uiuc.edu Mon Mar 28 16:03:29 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 28 Mar 2005 16:03:29 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Message-ID: <200503282203.j2SM3TDA013823@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: LegalizeDAG.cpp updated: 1.62 -> 1.63 --- Log message: implement legalization of build_pair for nate --- Diffs of the changes: (+8 -0) LegalizeDAG.cpp | 8 ++++++++ 1 files changed, 8 insertions(+) Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.62 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.63 --- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.62 Fri Mar 25 19:29:23 2005 +++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Mon Mar 28 16:03:13 2005 @@ -1590,6 +1590,14 @@ break; } + case ISD::BUILD_PAIR: + // Legalize both operands. FIXME: in the future we should handle the case + // where the two elements are not legal. + assert(isTypeLegal(NVT) && "Cannot expand this multiple times yet!"); + Lo = LegalizeOp(Node->getOperand(0)); + Hi = LegalizeOp(Node->getOperand(1)); + break; + case ISD::LOAD: { SDOperand Ch = LegalizeOp(Node->getOperand(0)); // Legalize the chain. SDOperand Ptr = LegalizeOp(Node->getOperand(1)); // Legalize the pointer. From natebegeman at mac.com Mon Mar 28 16:28:48 2005 From: natebegeman at mac.com (Nate Begeman) Date: Mon, 28 Mar 2005 16:28:48 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp PPC32ISelSimple.cpp PowerPCInstrInfo.td Message-ID: <200503282228.QAA05539@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPC32ISelPattern.cpp updated: 1.10 -> 1.11 PPC32ISelSimple.cpp updated: 1.129 -> 1.130 PowerPCInstrInfo.td updated: 1.50 -> 1.51 --- Log message: Remove fake instruction 'subc' (mnemonic for subfc). More pattern isel updates --- Diffs of the changes: (+42 -12) PPC32ISelPattern.cpp | 50 +++++++++++++++++++++++++++++++++++++++++--------- PPC32ISelSimple.cpp | 2 +- PowerPCInstrInfo.td | 2 -- 3 files changed, 42 insertions(+), 12 deletions(-) Index: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp diff -u llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.10 llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.11 --- llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.10 Mon Mar 28 13:36:43 2005 +++ llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Mon Mar 28 16:28:37 2005 @@ -137,13 +137,22 @@ if (GPR_remaining > 1) { BuildMI(&BB, PPC::IMPLICIT_DEF, 0, GPR[GPR_idx]); BuildMI(&BB, PPC::IMPLICIT_DEF, 0, GPR[GPR_idx+1]); + SDOperand root = DAG.getRoot(); + SDOperand Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, MVT::i32, + root, DAG.getConstant(1, MVT::i32)); + SDOperand Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, MVT::i32, + root, DAG.getConstant(0, MVT::i32)); + + // Create the pair of virtual registers MF.getSSARegMap()->createVirtualRegister(getRegClassFor(MVT::i32)); - unsigned virtReg = - MF.getSSARegMap()->createVirtualRegister(getRegClassFor(MVT::i32))-1; - // FIXME: is this correct? - argt = newroot = DAG.getCopyFromReg(virtReg, MVT::i32, DAG.getRoot()); - argt = DAG.getCopyFromReg(virtReg+1, MVT::i32, newroot); - // Push the arguments for emitting into BB later + unsigned virtReg = MF.getSSARegMap()->createVirtualRegister(getRegClassFor(MVT::i32))-1; + + // Copy the extracted halves into the virtual registers + SDOperand argHi = DAG.getCopyFromReg(virtReg, MVT::i32, Hi); + SDOperand argLo = DAG.getCopyFromReg(virtReg+1, MVT::i32, Lo); + + // Build the outgoing arg thingy + argt = newroot = DAG.getNode(ISD::BUILD_PAIR, MVT::i64, argLo, argHi); argVR.push_back(virtReg); argVR.push_back(virtReg+1); argPR.push_back(GPR[GPR_idx]); argPR.push_back(GPR[GPR_idx+1]); argOp.push_back(PPC::OR); argOp.push_back(PPC::OR); @@ -592,6 +601,7 @@ } case ISD::ConstantFP: + assert(0 && "ISD::ConstantFP Unimplemented"); abort(); case ISD::MUL: @@ -688,14 +698,20 @@ return Result; case ISD::ConstantPool: - abort(); + Tmp1 = cast(N)->getIndex(); + Tmp2 = MakeReg(MVT::i32); + BuildMI(BB, PPC::LOADHiAddr, 2, Tmp2).addReg(getGlobalBaseReg()) + .addConstantPoolIndex(Tmp1); + BuildMI(BB, PPC::LA, 2, Result).addReg(Tmp2).addConstantPoolIndex(Tmp1); + return Result; case ISD::FrameIndex: + assert(0 && "ISD::FrameIndex Unimplemented"); abort(); case ISD::GlobalAddress: { GlobalValue *GV = cast(N)->getGlobal(); - unsigned Tmp1 = MakeReg(MVT::i32); + Tmp1 = MakeReg(MVT::i32); BuildMI(BB, PPC::LOADHiAddr, 2, Tmp1).addReg(getGlobalBaseReg()) .addGlobalAddress(GV); if (GV->hasWeakLinkage() || GV->isExternal()) { @@ -990,7 +1006,23 @@ return Result; case ISD::ADD_PARTS: - case ISD::SUB_PARTS: + case ISD::SUB_PARTS: { + assert(N.getNumOperands() == 4 && N.getValueType() == MVT::i32 && + "Not an i64 add/sub!"); + // Emit all of the operands. + std::vector InVals; + for (unsigned i = 0, e = N.getNumOperands(); i != e; ++i) + InVals.push_back(SelectExpr(N.getOperand(i))); + if (N.getOpcode() == ISD::ADD_PARTS) { + BuildMI(BB, PPC::ADDC, 2, Result+1).addReg(InVals[1]).addReg(InVals[3]); + BuildMI(BB, PPC::ADDE, 2, Result).addReg(InVals[0]).addReg(InVals[2]); + } else { + BuildMI(BB, PPC::SUBFC, 2, Result+1).addReg(InVals[1]).addReg(InVals[3]); + BuildMI(BB, PPC::SUBFE, 2, Result).addReg(InVals[0]).addReg(InVals[2]); + } + return Result+N.ResNo; + } + case ISD::UREM: case ISD::SREM: case ISD::SDIV: Index: llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp diff -u llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp:1.129 llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp:1.130 --- llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp:1.129 Fri Mar 25 19:28:05 2005 +++ llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp Mon Mar 28 16:28:37 2005 @@ -2392,7 +2392,7 @@ PPC::ADD, PPC::SUB, PPC::AND, PPC::OR, PPC::XOR }; static const unsigned LongOpTab[2][5] = { - { PPC::ADDC, PPC::SUBC, PPC::AND, PPC::OR, PPC::XOR }, + { PPC::ADDC, PPC::SUBFC, PPC::AND, PPC::OR, PPC::XOR }, { PPC::ADDE, PPC::SUBFE, PPC::AND, PPC::OR, PPC::XOR } }; Index: llvm/lib/Target/PowerPC/PowerPCInstrInfo.td diff -u llvm/lib/Target/PowerPC/PowerPCInstrInfo.td:1.50 llvm/lib/Target/PowerPC/PowerPCInstrInfo.td:1.51 --- llvm/lib/Target/PowerPC/PowerPCInstrInfo.td:1.50 Tue Feb 15 14:26:49 2005 +++ llvm/lib/Target/PowerPC/PowerPCInstrInfo.td Mon Mar 28 16:28:37 2005 @@ -376,8 +376,6 @@ "subfe $rT, $rA, $rB">; def SUB : XOForm_1r<31, 40, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB), "sub $rT, $rA, $rB">; -def SUBC : XOForm_1r<31, 8, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB), - "subc $rT, $rA, $rB">; def ADDME : XOForm_3<31, 234, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA), "addme $rT, $rA">; def ADDZE : XOForm_3<31, 202, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA), From natebegeman at mac.com Mon Mar 28 17:09:05 2005 From: natebegeman at mac.com (Nate Begeman) Date: Mon, 28 Mar 2005 17:09:05 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp PPC32ISelSimple.cpp Message-ID: <200503282309.RAA05980@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPC32ISelPattern.cpp updated: 1.11 -> 1.12 PPC32ISelSimple.cpp updated: 1.130 -> 1.131 --- Log message: Pattern ISel: fix argument loading for i64s (thanks chris) Simple ISel: fix i64 subtract --- Diffs of the changes: (+26 -42) PPC32ISelPattern.cpp | 53 ++++++++++++--------------------------------------- PPC32ISelSimple.cpp | 15 ++++++++++++-- 2 files changed, 26 insertions(+), 42 deletions(-) Index: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp diff -u llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.11 llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.12 --- llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.11 Mon Mar 28 16:28:37 2005 +++ llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Mon Mar 28 17:08:54 2005 @@ -120,14 +120,10 @@ ObjSize = 4; if (GPR_remaining > 0) { BuildMI(&BB, PPC::IMPLICIT_DEF, 0, GPR[GPR_idx]); - unsigned virtReg = - MF.getSSARegMap()->createVirtualRegister(getRegClassFor(MVT::i32)); - argt = newroot = DAG.getCopyFromReg(virtReg, MVT::i32, DAG.getRoot()); + argt = newroot = DAG.getCopyFromReg(GPR[GPR_idx], MVT::i32, + DAG.getRoot()); if (ObjectVT != MVT::i32) argt = DAG.getNode(ISD::TRUNCATE, ObjectVT, newroot); - argVR.push_back(virtReg); - argPR.push_back(GPR[GPR_idx]); - argOp.push_back(PPC::OR); } else { needsLoad = true; } @@ -137,25 +133,13 @@ if (GPR_remaining > 1) { BuildMI(&BB, PPC::IMPLICIT_DEF, 0, GPR[GPR_idx]); BuildMI(&BB, PPC::IMPLICIT_DEF, 0, GPR[GPR_idx+1]); - SDOperand root = DAG.getRoot(); - SDOperand Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, MVT::i32, - root, DAG.getConstant(1, MVT::i32)); - SDOperand Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, MVT::i32, - root, DAG.getConstant(0, MVT::i32)); - - // Create the pair of virtual registers - MF.getSSARegMap()->createVirtualRegister(getRegClassFor(MVT::i32)); - unsigned virtReg = MF.getSSARegMap()->createVirtualRegister(getRegClassFor(MVT::i32))-1; - // Copy the extracted halves into the virtual registers - SDOperand argHi = DAG.getCopyFromReg(virtReg, MVT::i32, Hi); - SDOperand argLo = DAG.getCopyFromReg(virtReg+1, MVT::i32, Lo); - + SDOperand argHi = DAG.getCopyFromReg(GPR[GPR_idx], MVT::i32, + DAG.getRoot()); + SDOperand argLo = DAG.getCopyFromReg(GPR[GPR_idx+1], MVT::i32, argHi); // Build the outgoing arg thingy - argt = newroot = DAG.getNode(ISD::BUILD_PAIR, MVT::i64, argLo, argHi); - argVR.push_back(virtReg); argVR.push_back(virtReg+1); - argPR.push_back(GPR[GPR_idx]); argPR.push_back(GPR[GPR_idx+1]); - argOp.push_back(PPC::OR); argOp.push_back(PPC::OR); + argt = DAG.getNode(ISD::BUILD_PAIR, MVT::i64, argLo, argHi); + newroot = argLo; } else { needsLoad = true; } @@ -164,12 +148,8 @@ case MVT::f64: ObjSize = 8; if (FPR_remaining > 0) { BuildMI(&BB, PPC::IMPLICIT_DEF, 0, FPR[FPR_idx]); - unsigned virtReg = - MF.getSSARegMap()->createVirtualRegister(getRegClassFor(ObjectVT)); - argt = newroot = DAG.getCopyFromReg(virtReg, ObjectVT, DAG.getRoot()); - argVR.push_back(virtReg); - argPR.push_back(FPR[FPR_idx]); - argOp.push_back(PPC::FMR); + argt = newroot = DAG.getCopyFromReg(FPR[FPR_idx], ObjectVT, + DAG.getRoot()); --FPR_remaining; ++FPR_idx; } else { @@ -199,13 +179,6 @@ ArgValues.push_back(argt); } - for (int i = 0, count = argVR.size(); i < count; ++i) { - if (argOp[i] == PPC::FMR) - BuildMI(&BB, argOp[i], 1, argVR[i]).addReg(argPR[i]); - else - BuildMI(&BB, argOp[i], 2, argVR[i]).addReg(argPR[i]).addReg(argPR[i]); - } - // If the function takes variable number of arguments, make a frame index for // the start of the first vararg value... for expansion of llvm.va_start. if (F.isVarArg()) @@ -1014,11 +987,11 @@ for (unsigned i = 0, e = N.getNumOperands(); i != e; ++i) InVals.push_back(SelectExpr(N.getOperand(i))); if (N.getOpcode() == ISD::ADD_PARTS) { - BuildMI(BB, PPC::ADDC, 2, Result+1).addReg(InVals[1]).addReg(InVals[3]); - BuildMI(BB, PPC::ADDE, 2, Result).addReg(InVals[0]).addReg(InVals[2]); + BuildMI(BB, PPC::ADDC, 2, Result+1).addReg(InVals[0]).addReg(InVals[2]); + BuildMI(BB, PPC::ADDE, 2, Result).addReg(InVals[1]).addReg(InVals[3]); } else { - BuildMI(BB, PPC::SUBFC, 2, Result+1).addReg(InVals[1]).addReg(InVals[3]); - BuildMI(BB, PPC::SUBFE, 2, Result).addReg(InVals[0]).addReg(InVals[2]); + BuildMI(BB, PPC::SUBFC, 2, Result+1).addReg(InVals[2]).addReg(InVals[0]); + BuildMI(BB, PPC::SUBFE, 2, Result).addReg(InVals[3]).addReg(InVals[1]); } return Result+N.ResNo; } Index: llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp diff -u llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp:1.130 llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp:1.131 --- llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp:1.130 Mon Mar 28 16:28:37 2005 +++ llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp Mon Mar 28 17:08:54 2005 @@ -2389,7 +2389,7 @@ unsigned DestReg) { // Arithmetic and Bitwise operators static const unsigned OpcodeTab[] = { - PPC::ADD, PPC::SUB, PPC::AND, PPC::OR, PPC::XOR + PPC::ADD, PPC::SUBF, PPC::AND, PPC::OR, PPC::XOR }; static const unsigned LongOpTab[2][5] = { { PPC::ADDC, PPC::SUBFC, PPC::AND, PPC::OR, PPC::XOR }, @@ -2444,6 +2444,17 @@ unsigned Op0r = getReg(Op0, MBB, IP); unsigned Op1r = getReg(Op1, MBB, IP); + // Subtracts have their operands swapped + if (OperatorClass == 1) { + if (Class != cLong) { + BuildMI(*MBB, IP, PPC::SUBF, 2, DestReg).addReg(Op1r).addReg(Op0r); + } else { + BuildMI(*MBB, IP, PPC::SUBFC, 2, DestReg+1).addReg(Op1r+1).addReg(Op0r+1); + BuildMI(*MBB, IP, PPC::SUBFE, 2, DestReg).addReg(Op1r).addReg(Op0r); + } + return; + } + if (Class != cLong) { unsigned Opcode = OpcodeTab[OperatorClass]; BuildMI(*MBB, IP, Opcode, 2, DestReg).addReg(Op0r).addReg(Op1r); @@ -3876,7 +3887,7 @@ .addImm(0).addImm(27); // Subtract size from stack pointer, thereby allocating some space. - BuildMI(BB, PPC::SUB, 2, PPC::R1).addReg(PPC::R1).addReg(AlignedSize); + BuildMI(BB, PPC::SUBF, 2, PPC::R1).addReg(AlignedSize).addReg(PPC::R1); // Put a pointer to the space into the result register, by copying // the stack pointer. From alkis at cs.uiuc.edu Mon Mar 28 17:14:51 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon, 28 Mar 2005 17:14:51 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMClass.cpp Resolver.h Resolver.cpp Message-ID: <200503282314.RAA06038@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMClass.cpp updated: 1.14 -> 1.15 Resolver.h updated: 1.8 -> 1.9 Resolver.cpp updated: 1.6 -> 1.7 --- Log message: Lazily create primitive classes. --- Diffs of the changes: (+23 -17) Resolver.cpp | 33 ++++++++++++++++++++------------- Resolver.h | 3 --- VMClass.cpp | 4 +++- 3 files changed, 23 insertions(+), 17 deletions(-) Index: llvm-java/lib/Compiler/VMClass.cpp diff -u llvm-java/lib/Compiler/VMClass.cpp:1.14 llvm-java/lib/Compiler/VMClass.cpp:1.15 --- llvm-java/lib/Compiler/VMClass.cpp:1.14 Mon Mar 28 13:53:24 2005 +++ llvm-java/lib/Compiler/VMClass.cpp Mon Mar 28 17:14:41 2005 @@ -91,7 +91,9 @@ void VMClass::link() { - assert(!isPrimitive() && "Should not link primitive classes!"); + // Primitive classes require no linking. + if (isPrimitive()) + return; if (isArray()) { superClasses_.reserve(1); Index: llvm-java/lib/Compiler/Resolver.h diff -u llvm-java/lib/Compiler/Resolver.h:1.8 llvm-java/lib/Compiler/Resolver.h:1.9 --- llvm-java/lib/Compiler/Resolver.h:1.8 Mon Mar 28 13:53:24 2005 +++ llvm-java/lib/Compiler/Resolver.h Mon Mar 28 17:14:41 2005 @@ -39,9 +39,6 @@ unsigned& i, bool memberMethod = false) const; - std::pair insertClass(const VMClass& clazz) { - return classMap_.insert(std::make_pair(clazz.getName(), clazz)); - } ClassMap::iterator insertClass(ClassMap::iterator i, const VMClass& clazz) { return classMap_.insert(i, std::make_pair(clazz.getName(), clazz)); } Index: llvm-java/lib/Compiler/Resolver.cpp diff -u llvm-java/lib/Compiler/Resolver.cpp:1.6 llvm-java/lib/Compiler/Resolver.cpp:1.7 --- llvm-java/lib/Compiler/Resolver.cpp:1.6 Mon Mar 28 13:53:24 2005 +++ llvm-java/lib/Compiler/Resolver.cpp Mon Mar 28 17:14:41 2005 @@ -27,16 +27,6 @@ objectBaseType_(OpaqueType::get()), objectBaseRefType_(PointerType::get(objectBaseType_)) { - insertClass(VMClass(this, Type::SByteTy)); - insertClass(VMClass(this, Type::UShortTy)); - insertClass(VMClass(this, Type::DoubleTy)); - insertClass(VMClass(this, Type::FloatTy)); - insertClass(VMClass(this, Type::IntTy)); - insertClass(VMClass(this, Type::LongTy)); - insertClass(VMClass(this, Type::ShortTy)); - insertClass(VMClass(this, Type::BoolTy)); - insertClass(VMClass(this, Type::VoidTy)); - module_->addTypeName("struct.llvm_java_object_base", objectBaseType_); } @@ -95,16 +85,32 @@ DEBUG(std::cerr << "Loading class: " << descriptor << '\n'); switch (descriptor[0]) { case 'B': + it = insertClass(it, VMClass(this, Type::SByteTy)); + break; case 'C': + it = insertClass(it, VMClass(this, Type::UShortTy)); + break; case 'D': + it = insertClass(it, VMClass(this, Type::DoubleTy)); + break; case 'F': + it = insertClass(it, VMClass(this, Type::FloatTy)); + break; case 'I': + it = insertClass(it, VMClass(this, Type::IntTy)); + break; case 'J': + it = insertClass(it, VMClass(this, Type::LongTy)); + break; case 'S': + it = insertClass(it, VMClass(this, Type::ShortTy)); + break; case 'Z': + it = insertClass(it, VMClass(this, Type::BoolTy)); + break; case 'V': - assert(0 && "Primitive classes should already be in the map!"); - abort(); + it = insertClass(it, VMClass(this, Type::VoidTy)); + break; case 'L': { unsigned pos = descriptor.find(';', 1); const std::string& className = descriptor.substr(1, pos - 1); @@ -121,7 +127,8 @@ abort(); } it->second.link(); - module_->addTypeName(descriptor, it->second.getStructType()); + if (!it->second.isPrimitive()) + module_->addTypeName(descriptor, it->second.getStructType()); DEBUG(std::cerr << "Loaded class: " << descriptor << '\n'); } From alkis at cs.uiuc.edu Mon Mar 28 17:40:01 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon, 28 Mar 2005 17:40:01 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMClass.h VMClass.cpp Resolver.cpp Compiler.cpp Message-ID: <200503282340.RAA06285@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMClass.h updated: 1.14 -> 1.15 VMClass.cpp updated: 1.15 -> 1.16 Resolver.cpp updated: 1.7 -> 1.8 Compiler.cpp updated: 1.261 -> 1.262 --- Log message: Rename getStructType() to getLayoutType(). --- Diffs of the changes: (+9 -9) Compiler.cpp | 6 +++--- Resolver.cpp | 2 +- VMClass.cpp | 8 ++++---- VMClass.h | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) Index: llvm-java/lib/Compiler/VMClass.h diff -u llvm-java/lib/Compiler/VMClass.h:1.14 llvm-java/lib/Compiler/VMClass.h:1.15 --- llvm-java/lib/Compiler/VMClass.h:1.14 Mon Mar 28 13:55:42 2005 +++ llvm-java/lib/Compiler/VMClass.h Mon Mar 28 17:39:50 2005 @@ -70,7 +70,7 @@ public: const std::string& getName() const { return name_; } - const Type* getStructType() const { return structType_; } + const Type* getLayoutType() const { return structType_; } const Type* getType() const { return type_; } const ClassFile* getClassFile() const { return classFile_; } unsigned getNumSuperClasses() const { return superClasses_.size(); } Index: llvm-java/lib/Compiler/VMClass.cpp diff -u llvm-java/lib/Compiler/VMClass.cpp:1.15 llvm-java/lib/Compiler/VMClass.cpp:1.16 --- llvm-java/lib/Compiler/VMClass.cpp:1.15 Mon Mar 28 17:14:41 2005 +++ llvm-java/lib/Compiler/VMClass.cpp Mon Mar 28 17:39:50 2005 @@ -98,7 +98,7 @@ if (isArray()) { superClasses_.reserve(1); superClasses_.push_back(resolver_->getClass("java/lang/Object")); - addField("super", superClasses_[0]->getStructType()); + addField("super", superClasses_[0]->getLayoutType()); addField("", Type::UIntTy); addField("", ArrayType::get(componentClass_->getType(), 0)); @@ -136,7 +136,7 @@ interfaces_.end()); // We first add the struct of the super class. - addField("super", superClass->getStructType()); + addField("super", superClass->getLayoutType()); // Although we can safely assume that all interfaces inherit // from java/lang/Object, java/lang/Class.getSuperclass() @@ -168,7 +168,7 @@ resolveType(); - assert(!isa(getStructType()) &&"Class not initialized properly!"); + assert(!isa(getLayoutType()) &&"Class not initialized properly!"); } llvm::Constant* VMClass::getConstant(unsigned index) const @@ -186,7 +186,7 @@ Constant* jc = classFile_->getConstant(index); if (ConstantString* s = dynamic_cast(jc)) { const VMClass* stringClass = resolver_->getClass("java/lang/String"); - const Type* stringType = stringClass->getStructType(); + const Type* stringType = stringClass->getLayoutType(); resolvedConstantPool_[index] = new GlobalVariable(stringType, false, Index: llvm-java/lib/Compiler/Resolver.cpp diff -u llvm-java/lib/Compiler/Resolver.cpp:1.7 llvm-java/lib/Compiler/Resolver.cpp:1.8 --- llvm-java/lib/Compiler/Resolver.cpp:1.7 Mon Mar 28 17:14:41 2005 +++ llvm-java/lib/Compiler/Resolver.cpp Mon Mar 28 17:39:50 2005 @@ -128,7 +128,7 @@ } it->second.link(); if (!it->second.isPrimitive()) - module_->addTypeName(descriptor, it->second.getStructType()); + module_->addTypeName(descriptor, it->second.getLayoutType()); DEBUG(std::cerr << "Loaded class: " << descriptor << '\n'); } Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.261 llvm-java/lib/Compiler/Compiler.cpp:1.262 --- llvm-java/lib/Compiler/Compiler.cpp:1.261 Mon Mar 28 13:53:24 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Mon Mar 28 17:39:50 2005 @@ -1831,11 +1831,11 @@ InsertionPointTy* ip) { static std::vector params(4); - Value* objRef = new MallocInst(clazz.getStructType(), NULL, TMP, ip); + Value* objRef = new MallocInst(clazz.getLayoutType(), NULL, TMP, ip); params[0] = new CastInst(objRef, PointerType::get(Type::SByteTy), TMP, ip); // dest params[1] = ConstantUInt::get(Type::UByteTy, 0); // value - params[2] = ConstantExpr::getSizeOf(clazz.getStructType()); // size + params[2] = ConstantExpr::getSizeOf(clazz.getLayoutType()); // size params[3] = ConstantUInt::get(Type::UIntTy, 0); // alignment new CallInst(memset_, params, "", ip); @@ -1895,7 +1895,7 @@ Instruction::Mul, count, elementSize, TMP, ip); // The size of the rest of the array object. llvm::Constant* arrayObjectSize = - ConstantExpr::getCast(ConstantExpr::getSizeOf(clazz->getStructType()), + ConstantExpr::getCast(ConstantExpr::getSizeOf(clazz->getLayoutType()), Type::UIntTy); // Add the array part plus the object part together. From alkis at cs.uiuc.edu Mon Mar 28 17:56:57 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon, 28 Mar 2005 17:56:57 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMClass.cpp Resolver.h Resolver.cpp Compiler.cpp Message-ID: <200503282356.RAA06385@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMClass.cpp updated: 1.16 -> 1.17 Resolver.h updated: 1.9 -> 1.10 Resolver.cpp updated: 1.8 -> 1.9 Compiler.cpp updated: 1.262 -> 1.263 --- Log message: Rename getObjectBaseType() and getObjectBaseRefType() to getObjectBaseLayoutType() and getObjectBaseType() respectively. --- Diffs of the changes: (+41 -40) Compiler.cpp | 60 +++++++++++++++++++++++++++++------------------------------ Resolver.cpp | 15 +++++++------- Resolver.h | 4 +-- VMClass.cpp | 2 - 4 files changed, 41 insertions(+), 40 deletions(-) Index: llvm-java/lib/Compiler/VMClass.cpp diff -u llvm-java/lib/Compiler/VMClass.cpp:1.16 llvm-java/lib/Compiler/VMClass.cpp:1.17 --- llvm-java/lib/Compiler/VMClass.cpp:1.16 Mon Mar 28 17:39:50 2005 +++ llvm-java/lib/Compiler/VMClass.cpp Mon Mar 28 17:56:46 2005 @@ -109,7 +109,7 @@ else { // This is java/lang/Object. if (!classFile_->getSuperClass()) - addField("base", resolver_->getObjectBaseType()); + addField("base", resolver_->getObjectBaseLayoutType()); // This is any class but java/lang/Object. else { // Our direct super class. Index: llvm-java/lib/Compiler/Resolver.h diff -u llvm-java/lib/Compiler/Resolver.h:1.9 llvm-java/lib/Compiler/Resolver.h:1.10 --- llvm-java/lib/Compiler/Resolver.h:1.9 Mon Mar 28 17:14:41 2005 +++ llvm-java/lib/Compiler/Resolver.h Mon Mar 28 17:56:46 2005 @@ -30,8 +30,8 @@ typedef std::map ClassMap; ClassMap classMap_; unsigned nextInterfaceIndex_; + const Type* objectBaseLayoutType_; const Type* objectBaseType_; - const Type* objectBaseRefType_; const VMClass* getClassForDesc(const std::string& descriptor); @@ -55,8 +55,8 @@ Resolver(Module* module); + const Type* getObjectBaseLayoutType() const {return objectBaseLayoutType_; } const Type* getObjectBaseType() const { return objectBaseType_; } - const Type* getObjectBaseRefType() const { return objectBaseRefType_; } const Type* getType(const std::string& descriptor, bool memberMethod = false) const; Index: llvm-java/lib/Compiler/Resolver.cpp diff -u llvm-java/lib/Compiler/Resolver.cpp:1.8 llvm-java/lib/Compiler/Resolver.cpp:1.9 --- llvm-java/lib/Compiler/Resolver.cpp:1.8 Mon Mar 28 17:39:50 2005 +++ llvm-java/lib/Compiler/Resolver.cpp Mon Mar 28 17:56:46 2005 @@ -24,10 +24,11 @@ Resolver::Resolver(Module* module) : module_(module), nextInterfaceIndex_(0), - objectBaseType_(OpaqueType::get()), - objectBaseRefType_(PointerType::get(objectBaseType_)) + objectBaseLayoutType_(OpaqueType::get()), + objectBaseType_(PointerType::get(objectBaseLayoutType_)) { - module_->addTypeName("struct.llvm_java_object_base", objectBaseType_); + module_->addTypeName("struct.llvm_java_object_base", + getObjectBaseLayoutType()); } const Type* Resolver::getType(const std::string& descriptor, @@ -55,7 +56,7 @@ case 'L': { unsigned e = descr.find(';', i); i = e + 1; - return objectBaseRefType_; + return getObjectBaseType(); } case '[': // Skip '['s. @@ -63,11 +64,11 @@ do { ++i; } while (descr[i] == '['); // Consume the element type getTypeHelper(descr, i); - return objectBaseRefType_; + return getObjectBaseType(); case '(': { std::vector params; if (memberMethod) - params.push_back(objectBaseRefType_); + params.push_back(getObjectBaseType()); while (descr[i] != ')') params.push_back(getTypeHelper(descr, i)); return FunctionType::get(getTypeHelper(descr, ++i), params, false); @@ -153,7 +154,7 @@ const Type* Resolver::getStorageType(const Type* type) const { if (isa(type)) - return objectBaseRefType_; + return getObjectBaseType(); else if (type == Type::BoolTy || type == Type::UByteTy || type == Type::SByteTy || Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.262 llvm-java/lib/Compiler/Compiler.cpp:1.263 --- llvm-java/lib/Compiler/Compiler.cpp:1.262 Mon Mar 28 17:39:50 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Mon Mar 28 17:56:46 2005 @@ -113,16 +113,16 @@ module_->addTypeName("llvm_java_object_vtable", VTableBaseTy); getVtable_ = module_->getOrInsertFunction( "llvm_java_get_vtable", VTableBaseRefTy, - resolver_->getObjectBaseRefType(), NULL); + resolver_->getObjectBaseType(), NULL); setVtable_ = module_->getOrInsertFunction( "llvm_java_set_vtable", Type::VoidTy, - resolver_->getObjectBaseRefType(), VTableBaseRefTy, NULL); + resolver_->getObjectBaseType(), VTableBaseRefTy, NULL); throw_ = module_->getOrInsertFunction( "llvm_java_throw", Type::IntTy, - resolver_->getObjectBaseRefType(), NULL); + resolver_->getObjectBaseType(), NULL); isInstanceOf_ = module_->getOrInsertFunction( "llvm_java_is_instance_of", Type::IntTy, - resolver_->getObjectBaseRefType(), VTableBaseRefTy, NULL); + resolver_->getObjectBaseType(), VTableBaseRefTy, NULL); memcpy_ = module_->getOrInsertFunction( "llvm.memcpy", Type::VoidTy, PointerType::get(Type::SByteTy), @@ -196,7 +196,7 @@ // Install the vtable pointer. Value* objBase = - new CastInst(globalString, resolver_->getObjectBaseRefType(), TMP, ip); + new CastInst(globalString, resolver_->getObjectBaseType(), TMP, ip); Value* vtable = new CastInst(vi->vtable, VTableBaseRefTy, TMP, ip); new CallInst(setVtable_, objBase, vtable, "", ip); @@ -208,7 +208,7 @@ params.reserve(3); params.clear(); params.push_back(objBase); - params.push_back(new CastInst(arrayRef, resolver_->getObjectBaseRefType(), TMP, ip)); + params.push_back(new CastInst(arrayRef, resolver_->getObjectBaseType(), TMP, ip)); params.push_back(ConstantSInt::get(Type::IntTy, 0)); new CallInst(function, params, "", ip); } @@ -235,7 +235,7 @@ case 'L': { unsigned e = descr.find(';', i); i = e + 1; - return resolver_->getObjectBaseRefType(); + return resolver_->getObjectBaseType(); } case '[': // Skip '['s. @@ -243,12 +243,12 @@ do { ++i; } while (descr[i] == '['); // Consume the element type getJNITypeHelper(descr, i); - return resolver_->getObjectBaseRefType(); + return resolver_->getObjectBaseType(); case '(': { std::vector params; // JNIEnv* params.push_back(JNIEnvPtr_->getType()); - params.push_back(resolver_->getObjectBaseRefType()); + params.push_back(resolver_->getObjectBaseType()); while (descr[i] != ')') params.push_back(getJNITypeHelper(descr, i)); return FunctionType::get(getJNITypeHelper(descr, ++i), params, false); @@ -783,7 +783,7 @@ const VTableInfo& getObjectArrayVTableInfo() { static VTableInfo arrayInfo = - buildArrayVTableInfo(resolver_->getObjectBaseRefType()); + buildArrayVTableInfo(resolver_->getObjectBaseType()); return arrayInfo; } @@ -939,7 +939,7 @@ std::vector params; params.push_back(JNIEnvPtr_); if (method->isStatic()) - params.push_back(llvm::Constant::getNullValue(resolver_->getObjectBaseRefType())); + params.push_back(llvm::Constant::getNullValue(resolver_->getObjectBaseType())); for (Function::arg_iterator A = function->arg_begin(), E = function->arg_end(); A != E; ++A) { params.push_back( @@ -1231,7 +1231,7 @@ } void do_aconst_null() { - push(llvm::Constant::getNullValue(resolver_->getObjectBaseRefType())); + push(llvm::Constant::getNullValue(resolver_->getObjectBaseType())); } void do_iconst(int value) { @@ -1264,7 +1264,7 @@ void do_lload(unsigned index) { do_load_common(index, Type::LongTy); } void do_fload(unsigned index) { do_load_common(index, Type::FloatTy); } void do_dload(unsigned index) { do_load_common(index, Type::DoubleTy); } - void do_aload(unsigned index) { do_load_common(index, resolver_->getObjectBaseRefType()); } + void do_aload(unsigned index) { do_load_common(index, resolver_->getObjectBaseType()); } void do_load_common(unsigned index, const Type* type) { Value* val = locals_.load(index, type, currentBB_); @@ -1301,7 +1301,7 @@ void do_lstore(unsigned index) { do_store_common(index, Type::LongTy); } void do_fstore(unsigned index) { do_store_common(index, Type::FloatTy); } void do_dstore(unsigned index) { do_store_common(index, Type::DoubleTy); } - void do_astore(unsigned index) { do_store_common(index, resolver_->getObjectBaseRefType()); } + void do_astore(unsigned index) { do_store_common(index, resolver_->getObjectBaseType()); } void do_store_common(unsigned index, const Type* type) { Value* val = pop(type); @@ -1541,18 +1541,18 @@ do_if_common(Instruction::SetLE, Type::IntTy, t, f); } void do_if_acmpeq(unsigned t, unsigned f) { - do_if_common(Instruction::SetEQ, resolver_->getObjectBaseRefType(), t, f); + do_if_common(Instruction::SetEQ, resolver_->getObjectBaseType(), t, f); } void do_if_acmpne(unsigned t, unsigned f) { - do_if_common(Instruction::SetNE, resolver_->getObjectBaseRefType(), t, f); + do_if_common(Instruction::SetNE, resolver_->getObjectBaseType(), t, f); } void do_ifnull(unsigned t, unsigned f) { do_aconst_null(); - do_if_common(Instruction::SetEQ, resolver_->getObjectBaseRefType(), t, f); + do_if_common(Instruction::SetEQ, resolver_->getObjectBaseType(), t, f); } void do_ifnonnull(unsigned t, unsigned f) { do_aconst_null(); - do_if_common(Instruction::SetNE, resolver_->getObjectBaseRefType(), t, f); + do_if_common(Instruction::SetNE, resolver_->getObjectBaseType(), t, f); } void do_if_common(Instruction::BinaryOps cc, const Type* type, @@ -1573,7 +1573,7 @@ void do_lreturn() { do_return_common(Type::LongTy); } void do_freturn() { do_return_common(Type::FloatTy); } void do_dreturn() { do_return_common(Type::DoubleTy); } - void do_areturn() { do_return_common(resolver_->getObjectBaseRefType()); } + void do_areturn() { do_return_common(resolver_->getObjectBaseType()); } void do_return_common(const Type* type) { Value* r = pop(type); @@ -1628,7 +1628,7 @@ ConstantFieldRef* fieldRef = class_->getClassFile()->getConstantFieldRef(index); const std::string& name = fieldRef->getNameAndType()->getName()->str(); - Value* p = pop(resolver_->getObjectBaseRefType()); + Value* p = pop(resolver_->getObjectBaseType()); Value* v = new LoadInst(getField(index, p), name, currentBB_); push(v); } @@ -1640,7 +1640,7 @@ fieldRef->getNameAndType()->getDescriptorIndex()); const Type* type = fieldClass->getType(); Value* v = pop(type); - Value* p = pop(resolver_->getObjectBaseRefType()); + Value* p = pop(resolver_->getObjectBaseType()); Value* fp = getField(index, p); const Type* ft = cast(fp->getType())->getElementType(); v = new CastInst(v, ft, TMP, currentBB_); @@ -1706,7 +1706,7 @@ Value* objRef = params.front(); objRef = new CastInst(objRef, clazz->getType(), "this", currentBB_); Value* objBase = - new CastInst(objRef, resolver_->getObjectBaseRefType(), TMP, currentBB_); + new CastInst(objRef, resolver_->getObjectBaseType(), TMP, currentBB_); Value* vtable = new CallInst(getVtable_, objBase, TMP, currentBB_); vtable = new CastInst(vtable, vi->vtable->getType(), className + ".vtable", currentBB_); @@ -1790,7 +1790,7 @@ Value* objRef = params.front(); objRef = new CastInst(objRef, clazz->getType(), "this", currentBB_); Value* objBase = - new CastInst(objRef, resolver_->getObjectBaseRefType(), TMP, currentBB_); + new CastInst(objRef, resolver_->getObjectBaseType(), TMP, currentBB_); Value* vtable = new CallInst(getVtable_, objBase, TMP, currentBB_); vtable = new CastInst(vtable, PointerType::get(VTableInfo::VTableTy), TMP, currentBB_); @@ -1840,7 +1840,7 @@ new CallInst(memset_, params, "", ip); // Install the vtable pointer. - Value* objBase = new CastInst(objRef, resolver_->getObjectBaseRefType(), TMP, ip); + Value* objBase = new CastInst(objRef, resolver_->getObjectBaseType(), TMP, ip); Value* vtable = new CastInst(vi.vtable, VTableBaseRefTy, TMP, ip); new CallInst(setVtable_, objBase, vtable, "", ip); @@ -1917,7 +1917,7 @@ new StoreInst(count, lengthPtr, ip); // Install the vtable pointer. - Value* objBase = new CastInst(objRef, resolver_->getObjectBaseRefType(), TMP, ip); + Value* objBase = new CastInst(objRef, resolver_->getObjectBaseType(), TMP, ip); Value* vtable = new CastInst(vi->vtable, VTableBaseRefTy, TMP, ip); new CallInst(setVtable_, objBase, vtable, "", ip); @@ -1953,7 +1953,7 @@ } void do_athrow() { - Value* objRef = pop(resolver_->getObjectBaseRefType()); + Value* objRef = pop(resolver_->getObjectBaseType()); new CallInst(throw_, objRef, "", currentBB_); new UnreachableInst(currentBB_); } @@ -1962,7 +1962,7 @@ const VMClass* clazz = class_->getClassForClass(index); const VTableInfo* vi = getVTableInfoGeneric(clazz); - Value* objRef = pop(resolver_->getObjectBaseRefType()); + Value* objRef = pop(resolver_->getObjectBaseType()); Value* vtable = new CastInst(vi->vtable, VTableBaseRefTy, TMP, currentBB_); @@ -1979,7 +1979,7 @@ const VMClass* clazz = class_->getClassForClass(index); const VTableInfo* vi = getVTableInfoGeneric(clazz); - Value* objRef = pop(resolver_->getObjectBaseRefType()); + Value* objRef = pop(resolver_->getObjectBaseType()); Value* vtable = new CastInst(vi->vtable, VTableBaseRefTy, TMP, currentBB_); Value* r = new CallInst(isInstanceOf_, objRef, vtable, TMP, currentBB_); @@ -1988,12 +1988,12 @@ void do_monitorenter() { // FIXME: This is currently a noop. - pop(resolver_->getObjectBaseRefType()); + pop(resolver_->getObjectBaseType()); } void do_monitorexit() { // FIXME: This is currently a noop. - pop(resolver_->getObjectBaseRefType()); + pop(resolver_->getObjectBaseType()); } void do_multianewarray(unsigned index, unsigned dims) { From natebegeman at mac.com Mon Mar 28 18:03:38 2005 From: natebegeman at mac.com (Nate Begeman) Date: Mon, 28 Mar 2005 18:03:38 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Message-ID: <200503290003.SAA06516@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPC32ISelPattern.cpp updated: 1.12 -> 1.13 --- Log message: Implement div, rem, and frameindex --- Diffs of the changes: (+27 -8) PPC32ISelPattern.cpp | 35 +++++++++++++++++++++++++++-------- 1 files changed, 27 insertions(+), 8 deletions(-) Index: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp diff -u llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.12 llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.13 --- llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.12 Mon Mar 28 17:08:54 2005 +++ llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Mon Mar 28 18:03:27 2005 @@ -595,6 +595,7 @@ case ISD::UINT_TO_FP: case ISD::SINT_TO_FP: + assert(0 && "ISD::U/SINT_TO_FP Unimplemented"); abort(); } assert(0 && "should not get here"); @@ -679,8 +680,9 @@ return Result; case ISD::FrameIndex: - assert(0 && "ISD::FrameIndex Unimplemented"); - abort(); + Tmp1 = cast(N)->getIndex(); + addFrameReference(BuildMI(BB, PPC::ADDI, 2, Result), (int)Tmp1); + return Result; case ISD::GlobalAddress: { GlobalValue *GV = cast(N)->getGlobal(); @@ -978,6 +980,29 @@ } return Result; + case ISD::SDIV: + case ISD::UDIV: + assert (DestType == MVT::i32 && "Only do arithmetic on i32s!"); + Tmp1 = SelectExpr(N.getOperand(0)); + Tmp2 = SelectExpr(N.getOperand(1)); + Opc = (ISD::UDIV == opcode) ? PPC::DIVWU : PPC::DIVW; + BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); + return Result; + + case ISD::UREM: + case ISD::SREM: { + assert (DestType == MVT::i32 && "Only do arithmetic on i32s!"); + Tmp1 = SelectExpr(N.getOperand(0)); + Tmp2 = SelectExpr(N.getOperand(1)); + Tmp3 = MakeReg(MVT::i32); + unsigned Tmp4 = MakeReg(MVT::i32); + Opc = (ISD::UREM == opcode) ? PPC::DIVWU : PPC::DIVW; + BuildMI(BB, Opc, 2, Tmp3).addReg(Tmp1).addReg(Tmp2); + BuildMI(BB, PPC::MULLW, 2, Tmp4).addReg(Tmp3).addReg(Tmp2); + BuildMI(BB, PPC::SUBF, 2, Result).addReg(Tmp4).addReg(Tmp1); + return Result; + } + case ISD::ADD_PARTS: case ISD::SUB_PARTS: { assert(N.getNumOperands() == 4 && N.getValueType() == MVT::i32 && @@ -996,12 +1021,6 @@ return Result+N.ResNo; } - case ISD::UREM: - case ISD::SREM: - case ISD::SDIV: - case ISD::UDIV: - abort(); - case ISD::FP_TO_UINT: case ISD::FP_TO_SINT: abort(); From alkis at cs.uiuc.edu Mon Mar 28 18:41:33 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon, 28 Mar 2005 18:41:33 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMClass.h VMClass.cpp Message-ID: <200503290041.SAA06775@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMClass.h updated: 1.15 -> 1.16 VMClass.cpp updated: 1.17 -> 1.18 --- Log message: Rename member field and cleanup class a bit. --- Diffs of the changes: (+13 -13) VMClass.cpp | 18 +++++++++--------- VMClass.h | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-) Index: llvm-java/lib/Compiler/VMClass.h diff -u llvm-java/lib/Compiler/VMClass.h:1.15 llvm-java/lib/Compiler/VMClass.h:1.16 --- llvm-java/lib/Compiler/VMClass.h:1.15 Mon Mar 28 17:39:50 2005 +++ llvm-java/lib/Compiler/VMClass.h Mon Mar 28 18:41:22 2005 @@ -34,7 +34,7 @@ Resolver* resolver_; const ClassFile* classFile_; const VMClass* componentClass_; - Type* structType_; + Type* layoutType_; const Type* type_; unsigned interfaceIndex_; typedef std::map Field2IndexMap; @@ -70,7 +70,7 @@ public: const std::string& getName() const { return name_; } - const Type* getLayoutType() const { return structType_; } + const Type* getLayoutType() const { return layoutType_; } const Type* getType() const { return type_; } const ClassFile* getClassFile() const { return classFile_; } unsigned getNumSuperClasses() const { return superClasses_.size(); } @@ -81,8 +81,8 @@ unsigned getNumInterfaces() const { return interfaces_.size(); } const VMClass* getInterface(unsigned i) const { return interfaces_[i]; } const VMClass* getComponentClass() const { return componentClass_; } - bool isArray() const { return componentClass_; } - bool isPrimitive() const { return !structType_; } + bool isArray() const { return getComponentClass(); } + bool isPrimitive() const { return getType() == getLayoutType(); } bool isInterface() const { return classFile_ && !getSuperClass(); } unsigned getInterfaceIndex() const { return interfaceIndex_; } int getFieldIndex(const std::string& name) const; Index: llvm-java/lib/Compiler/VMClass.cpp diff -u llvm-java/lib/Compiler/VMClass.cpp:1.17 llvm-java/lib/Compiler/VMClass.cpp:1.18 --- llvm-java/lib/Compiler/VMClass.cpp:1.17 Mon Mar 28 17:56:46 2005 +++ llvm-java/lib/Compiler/VMClass.cpp Mon Mar 28 18:41:22 2005 @@ -31,8 +31,8 @@ resolver_(resolver), classFile_(ClassFile::get(className)), componentClass_(NULL), - structType_(OpaqueType::get()), - type_(PointerType::get(structType_)), + layoutType_(OpaqueType::get()), + type_(PointerType::get(layoutType_)), interfaceIndex_(INVALID_INTERFACE_INDEX), resolvedConstantPool_(classFile_->getNumConstants()) { @@ -44,8 +44,8 @@ resolver_(resolver), classFile_(NULL), componentClass_(componentClass), - structType_(OpaqueType::get()), - type_(PointerType::get(structType_)), + layoutType_(OpaqueType::get()), + type_(PointerType::get(layoutType_)), interfaceIndex_(INVALID_INTERFACE_INDEX) { @@ -63,7 +63,7 @@ resolver_(resolver), classFile_(NULL), componentClass_(NULL), - structType_(NULL), + layoutType_(const_cast(type)), type_(type), interfaceIndex_(INVALID_INTERFACE_INDEX) { @@ -82,11 +82,11 @@ } void VMClass::resolveType() { - PATypeHolder holder = structType_; + PATypeHolder holder = layoutType_; Type* resolvedType = StructType::get(elementTypes_); - cast(structType_)->refineAbstractTypeTo(resolvedType); - structType_ = holder.get(); - type_ = PointerType::get(structType_); + cast(layoutType_)->refineAbstractTypeTo(resolvedType); + layoutType_ = holder.get(); + type_ = PointerType::get(layoutType_); } void VMClass::link() From alkis at cs.uiuc.edu Mon Mar 28 18:47:21 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon, 28 Mar 2005 18:47:21 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMClass.cpp Message-ID: <200503290047.SAA06835@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMClass.cpp updated: 1.18 -> 1.19 --- Log message: Move implemented interface computation to happen for all classes. --- Diffs of the changes: (+16 -16) VMClass.cpp | 32 ++++++++++++++++---------------- 1 files changed, 16 insertions(+), 16 deletions(-) Index: llvm-java/lib/Compiler/VMClass.cpp diff -u llvm-java/lib/Compiler/VMClass.cpp:1.18 llvm-java/lib/Compiler/VMClass.cpp:1.19 --- llvm-java/lib/Compiler/VMClass.cpp:1.18 Mon Mar 28 18:41:22 2005 +++ llvm-java/lib/Compiler/VMClass.cpp Mon Mar 28 18:47:10 2005 @@ -120,21 +120,6 @@ for (unsigned i = 0, e = superClass->getNumInterfaces(); i != e; ++i) interfaces_.push_back(superClass->getInterface(i)); - // For each of the interfaces we implement, load it and add that - // interface and all the interfaces it inherits from. - for (unsigned i = 0, e = classFile_->getNumInterfaces(); i != e; ++i) { - const VMClass* interface = - getClassForClass(classFile_->getInterfaceIndex(i)); - interfaces_.push_back(interface); - for (unsigned j = 0, f = interface->getNumInterfaces(); j != f; ++j) - interfaces_.push_back(interface->getInterface(j)); - } - - // Sort the interfaces array and remove duplicates. - std::sort(interfaces_.begin(), interfaces_.end()); - interfaces_.erase(std::unique(interfaces_.begin(), interfaces_.end()), - interfaces_.end()); - // We first add the struct of the super class. addField("super", superClass->getLayoutType()); @@ -156,7 +141,22 @@ } } - // Then we add the rest of the fields. + // For each of the interfaces we implement, load it and add that + // interface and all the interfaces it inherits from. + for (unsigned i = 0, e = classFile_->getNumInterfaces(); i != e; ++i) { + const VMClass* interface = + getClassForClass(classFile_->getInterfaceIndex(i)); + interfaces_.push_back(interface); + for (unsigned j = 0, f = interface->getNumInterfaces(); j != f; ++j) + interfaces_.push_back(interface->getInterface(j)); + } + + // Sort the interfaces array and remove duplicates. + std::sort(interfaces_.begin(), interfaces_.end()); + interfaces_.erase(std::unique(interfaces_.begin(), interfaces_.end()), + interfaces_.end()); + + // Now add the rest of the fields. const Fields& fields = classFile_->getFields(); for (unsigned i = 0, e = fields.size(); i != e; ++i) { Field* field = fields[i]; From alkis at cs.uiuc.edu Mon Mar 28 19:01:27 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon, 28 Mar 2005 19:01:27 -0600 Subject: [llvm-commits] CVS: llvm-java/include/llvm/Java/ClassFile.h Message-ID: <200503290101.TAA07087@zion.cs.uiuc.edu> Changes in directory llvm-java/include/llvm/Java: ClassFile.h updated: 1.35 -> 1.36 --- Log message: Eliminate class lookup for the superclass. --- 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.35 llvm-java/include/llvm/Java/ClassFile.h:1.36 --- llvm-java/include/llvm/Java/ClassFile.h:1.35 Sat Mar 26 13:14:02 2005 +++ llvm-java/include/llvm/Java/ClassFile.h Mon Mar 28 19:01:16 2005 @@ -99,9 +99,11 @@ bool isInterface() const { return accessFlags_ & ACC_INTERFACE; } bool isAbstract() const { return accessFlags_ & ACC_ABSTRACT; } + unsigned getThisClassIndex() const { return thisClassIdx_; } ConstantClass* getThisClass() const { return getConstantClass(thisClassIdx_); } + unsigned getSuperClassIndex() const { return superClassIdx_; } ConstantClass* getSuperClass() const { return superClassIdx_ ? getConstantClass(superClassIdx_) : NULL; } From alkis at cs.uiuc.edu Mon Mar 28 19:01:27 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon, 28 Mar 2005 19:01:27 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMClass.cpp Message-ID: <200503290101.TAA07083@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMClass.cpp updated: 1.19 -> 1.20 --- Log message: Eliminate class lookup for the superclass. --- Diffs of the changes: (+1 -1) VMClass.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm-java/lib/Compiler/VMClass.cpp diff -u llvm-java/lib/Compiler/VMClass.cpp:1.19 llvm-java/lib/Compiler/VMClass.cpp:1.20 --- llvm-java/lib/Compiler/VMClass.cpp:1.19 Mon Mar 28 18:47:10 2005 +++ llvm-java/lib/Compiler/VMClass.cpp Mon Mar 28 19:01:16 2005 @@ -114,7 +114,7 @@ else { // Our direct super class. const VMClass* superClass = - resolver_->getClass(classFile_->getSuperClass()->getName()->str()); + getClassForClass(classFile_->getSuperClassIndex()); // Add the interfaces of our direct superclass. for (unsigned i = 0, e = superClass->getNumInterfaces(); i != e; ++i) From alkis at cs.uiuc.edu Mon Mar 28 20:47:52 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon, 28 Mar 2005 20:47:52 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMClass.h Resolver.h Message-ID: <200503290247.UAA07832@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMClass.h updated: 1.16 -> 1.17 Resolver.h updated: 1.10 -> 1.11 --- Log message: Fix isInterface() so that it doesn't return true for java/lang/Object. --- Diffs of the changes: (+2 -3) Resolver.h | 1 - VMClass.h | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) Index: llvm-java/lib/Compiler/VMClass.h diff -u llvm-java/lib/Compiler/VMClass.h:1.16 llvm-java/lib/Compiler/VMClass.h:1.17 --- llvm-java/lib/Compiler/VMClass.h:1.16 Mon Mar 28 18:41:22 2005 +++ llvm-java/lib/Compiler/VMClass.h Mon Mar 28 20:47:41 2005 @@ -18,13 +18,13 @@ #include #include #include +#include #include #include #include namespace llvm { namespace Java { - class ClassFile; class Resolver; class VMClass { @@ -83,7 +83,7 @@ const VMClass* getComponentClass() const { return componentClass_; } bool isArray() const { return getComponentClass(); } bool isPrimitive() const { return getType() == getLayoutType(); } - bool isInterface() const { return classFile_ && !getSuperClass(); } + bool isInterface() const { return classFile_ && classFile_->isInterface(); } unsigned getInterfaceIndex() const { return interfaceIndex_; } int getFieldIndex(const std::string& name) const; Index: llvm-java/lib/Compiler/Resolver.h diff -u llvm-java/lib/Compiler/Resolver.h:1.10 llvm-java/lib/Compiler/Resolver.h:1.11 --- llvm-java/lib/Compiler/Resolver.h:1.10 Mon Mar 28 17:56:46 2005 +++ llvm-java/lib/Compiler/Resolver.h Mon Mar 28 20:47:41 2005 @@ -17,7 +17,6 @@ #include "VMClass.h" #include -#include #include #include #include From alkis at cs.uiuc.edu Mon Mar 28 20:49:57 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon, 28 Mar 2005 20:49:57 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMClass.h VMClass.cpp Message-ID: <200503290249.UAA07872@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMClass.h updated: 1.17 -> 1.18 VMClass.cpp updated: 1.20 -> 1.21 --- Log message: Resolve fields when computing the layout type of the object. --- Diffs of the changes: (+37 -32) VMClass.cpp | 62 ++++++++++++++++++++++++++++++++---------------------------- VMClass.h | 7 ++---- 2 files changed, 37 insertions(+), 32 deletions(-) Index: llvm-java/lib/Compiler/VMClass.h diff -u llvm-java/lib/Compiler/VMClass.h:1.17 llvm-java/lib/Compiler/VMClass.h:1.18 --- llvm-java/lib/Compiler/VMClass.h:1.17 Mon Mar 28 20:47:41 2005 +++ llvm-java/lib/Compiler/VMClass.h Mon Mar 28 20:49:46 2005 @@ -15,6 +15,7 @@ #ifndef LLVM_JAVA_VMCLASS_H #define LLVM_JAVA_VMCLASS_H +#include "VMField.h" #include #include #include @@ -39,14 +40,12 @@ unsigned interfaceIndex_; typedef std::map Field2IndexMap; Field2IndexMap f2iMap_; - typedef std::vector ElementTypes; - ElementTypes elementTypes_; mutable std::vector resolvedConstantPool_; std::vector superClasses_; std::vector interfaces_; + std::vector memberFields_; - void addField(const std::string& name, const Type* type); - void resolveType(); + void computeLayout(); friend class Resolver; Index: llvm-java/lib/Compiler/VMClass.cpp diff -u llvm-java/lib/Compiler/VMClass.cpp:1.20 llvm-java/lib/Compiler/VMClass.cpp:1.21 --- llvm-java/lib/Compiler/VMClass.cpp:1.20 Mon Mar 28 19:01:16 2005 +++ llvm-java/lib/Compiler/VMClass.cpp Mon Mar 28 20:49:46 2005 @@ -70,20 +70,44 @@ } -void VMClass::addField(const std::string& name, const Type* type) -{ - f2iMap_.insert(std::make_pair(name, elementTypes_.size())); - elementTypes_.push_back(type); -} - int VMClass::getFieldIndex(const std::string& name) const { Field2IndexMap::const_iterator it = f2iMap_.find(name); return it == f2iMap_.end() ? -1 : it->second; } -void VMClass::resolveType() { +void VMClass::computeLayout() { + std::vector layout; + if (isArray()) { + layout.reserve(3); + layout.push_back(resolver_->getClass("java/lang/Object")->getLayoutType()); + layout.push_back(Type::UIntTy); + layout.push_back(ArrayType::get(componentClass_->getType(), 0)); + } + else if (isInterface()) { + layout.reserve(1); + layout.push_back(resolver_->getClass("java/lang/Object")->getLayoutType()); + } + else { + if (const VMClass* superClass = getSuperClass()) + layout.push_back(superClass->getLayoutType()); + else // This is java/lang/Object + layout.push_back(resolver_->getObjectBaseLayoutType()); + // Now add the fields. + const Fields& fields = classFile_->getFields(); + for (unsigned i = 0, e = fields.size(); i != e; ++i) { + Field* field = fields[i]; + if (!field->isStatic()) { + memberFields_.push_back(NULL); + f2iMap_.insert(std::make_pair(field->getName()->str(), + memberFields_.size())); + layout.push_back( + getClassForDescriptor(field->getDescriptorIndex())->getType()); + } + } + } + PATypeHolder holder = layoutType_; - Type* resolvedType = StructType::get(elementTypes_); + Type* resolvedType = StructType::get(layout); cast(layoutType_)->refineAbstractTypeTo(resolvedType); layoutType_ = holder.get(); type_ = PointerType::get(layoutType_); @@ -98,20 +122,14 @@ if (isArray()) { superClasses_.reserve(1); superClasses_.push_back(resolver_->getClass("java/lang/Object")); - addField("super", superClasses_[0]->getLayoutType()); - addField("", Type::UIntTy); - addField("", ArrayType::get(componentClass_->getType(), 0)); interfaces_.reserve(2); interfaces_.push_back(resolver_->getClass("java/lang/Cloneable")); interfaces_.push_back(resolver_->getClass("java/io/Serializable")); } else { - // This is java/lang/Object. - if (!classFile_->getSuperClass()) - addField("base", resolver_->getObjectBaseLayoutType()); // This is any class but java/lang/Object. - else { + if (classFile_->getSuperClass()) { // Our direct super class. const VMClass* superClass = getClassForClass(classFile_->getSuperClassIndex()); @@ -120,9 +138,6 @@ for (unsigned i = 0, e = superClass->getNumInterfaces(); i != e; ++i) interfaces_.push_back(superClass->getInterface(i)); - // We first add the struct of the super class. - addField("super", superClass->getLayoutType()); - // Although we can safely assume that all interfaces inherit // from java/lang/Object, java/lang/Class.getSuperclass() // returns null on interface types. So we only set the @@ -155,18 +170,9 @@ std::sort(interfaces_.begin(), interfaces_.end()); interfaces_.erase(std::unique(interfaces_.begin(), interfaces_.end()), interfaces_.end()); - - // Now add the rest of the fields. - const Fields& fields = classFile_->getFields(); - for (unsigned i = 0, e = fields.size(); i != e; ++i) { - Field* field = fields[i]; - if (!field->isStatic()) - addField(field->getName()->str(), - getClassForDescriptor(field->getDescriptorIndex())->getType()); - } } - resolveType(); + computeLayout(); assert(!isa(getLayoutType()) &&"Class not initialized properly!"); } From alkis at cs.uiuc.edu Mon Mar 28 21:10:56 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon, 28 Mar 2005 21:10:56 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMField.h VMField.cpp VMClass.h VMClass.cpp Message-ID: <200503290310.VAA08015@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMField.h added (r1.1) VMField.cpp added (r1.1) VMClass.h updated: 1.18 -> 1.19 VMClass.cpp updated: 1.21 -> 1.22 --- Log message: Add VMField class that represents a member or static field in a class. This will allow us to resolve and cache field references. --- Diffs of the changes: (+113 -10) VMClass.cpp | 21 +++++++++++------- VMClass.h | 4 +-- VMField.cpp | 28 ++++++++++++++++++++++++ VMField.h | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 113 insertions(+), 10 deletions(-) Index: llvm-java/lib/Compiler/VMField.h diff -c /dev/null llvm-java/lib/Compiler/VMField.h:1.1 *** /dev/null Mon Mar 28 21:10:56 2005 --- llvm-java/lib/Compiler/VMField.h Mon Mar 28 21:10:46 2005 *************** *** 0 **** --- 1,70 ---- + //===-- VMField.h - Compiler representation of a Java field -----*- C++ -*-===// + // + // 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 contains the declaration of the Field class that represents a + // compile time representation of a Java class field (java.lang.Field). + // + //===----------------------------------------------------------------------===// + + #ifndef LLVM_JAVA_VMFIELD_H + #define LLVM_JAVA_VMFIELD_H + + #include + + namespace llvm { + + class GlobalVariable; + + } + + namespace llvm { namespace Java { + + class VMClass; + + class VMField { + const VMClass* clazz_; + const Field* field_; + union { + int index; + GlobalVariable* global; + } data_; + + friend class VMClass; + // Interface for VMClass. + + // Create static field reference. + VMField(const VMClass* clazz, const Field* field); + + // Create member field reference. + VMField(const VMClass* clazz, const Field* field, int index) + : clazz_(clazz), + field_(field) { + assert(!isStatic() && "This should be a member field!"); + data_.index = index; + } + + + public: + const std::string& getName() const { return field_->getName()->str(); } + bool isStatic() const { return field_->isStatic(); } + + const VMClass* getClass() const { return clazz_; } + int getMemberIndex() const { + assert(!isStatic() && "Field should not be static!"); + return data_.index; + } + GlobalVariable* getGlobal() const { + assert(isStatic() && "Field should be static!"); + return data_.global; + } + }; + + } } // namespace llvm::Java + + #endif//LLVM_JAVA_VMFIELD_H Index: llvm-java/lib/Compiler/VMField.cpp diff -c /dev/null llvm-java/lib/Compiler/VMField.cpp:1.1 *** /dev/null Mon Mar 28 21:10:56 2005 --- llvm-java/lib/Compiler/VMField.cpp Mon Mar 28 21:10:46 2005 *************** *** 0 **** --- 1,28 ---- + //===-- VMField.cpp - Compiler representation of a Java field ---*- C++ -*-===// + // + // 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 contains the implementation of the Field class that represents a + // compile time representation of a Java class field (java.lang.Field). + // + //===----------------------------------------------------------------------===// + + #include "VMField.h" + #include "VMClass.h" + #include + + using namespace llvm; + using namespace llvm::Java; + + VMField::VMField(const VMClass* clazz, const Field* field) + : clazz_(clazz), + field_(field) + { + assert(isStatic() && "This should be a static field!"); + // FIXME: add Global to module. + } Index: llvm-java/lib/Compiler/VMClass.h diff -u llvm-java/lib/Compiler/VMClass.h:1.18 llvm-java/lib/Compiler/VMClass.h:1.19 --- llvm-java/lib/Compiler/VMClass.h:1.18 Mon Mar 28 20:49:46 2005 +++ llvm-java/lib/Compiler/VMClass.h Mon Mar 28 21:10:46 2005 @@ -38,8 +38,8 @@ Type* layoutType_; const Type* type_; unsigned interfaceIndex_; - typedef std::map Field2IndexMap; - Field2IndexMap f2iMap_; + typedef std::map FieldMap; + FieldMap fieldMap_; mutable std::vector resolvedConstantPool_; std::vector superClasses_; std::vector interfaces_; Index: llvm-java/lib/Compiler/VMClass.cpp diff -u llvm-java/lib/Compiler/VMClass.cpp:1.21 llvm-java/lib/Compiler/VMClass.cpp:1.22 --- llvm-java/lib/Compiler/VMClass.cpp:1.21 Mon Mar 28 20:49:46 2005 +++ llvm-java/lib/Compiler/VMClass.cpp Mon Mar 28 21:10:46 2005 @@ -71,8 +71,8 @@ } int VMClass::getFieldIndex(const std::string& name) const { - Field2IndexMap::const_iterator it = f2iMap_.find(name); - return it == f2iMap_.end() ? -1 : it->second; + FieldMap::const_iterator it = fieldMap_.find(name); + return it == fieldMap_.end() ? -1 : it->second.getMemberIndex(); } void VMClass::computeLayout() { @@ -96,12 +96,17 @@ const Fields& fields = classFile_->getFields(); for (unsigned i = 0, e = fields.size(); i != e; ++i) { Field* field = fields[i]; - if (!field->isStatic()) { - memberFields_.push_back(NULL); - f2iMap_.insert(std::make_pair(field->getName()->str(), - memberFields_.size())); - layout.push_back( - getClassForDescriptor(field->getDescriptorIndex())->getType()); + if (field->isStatic()) { + // FIXME: Initialize static VMFields as well. + } + else { + const VMClass* fc = getClassForDescriptor(field->getDescriptorIndex()); + FieldMap::iterator i = + fieldMap_.insert(std::make_pair( + field->getName()->str(), + VMField(fc, field, memberFields_.size()+1))).first; + memberFields_.push_back(&i->second); + layout.push_back(fc->getType()); } } } From lattner at cs.uiuc.edu Tue Mar 29 00:09:23 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 29 Mar 2005 00:09:23 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/IPA/Andersens.cpp Message-ID: <200503290609.j2T69Nmp018525@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/IPA: Andersens.cpp updated: 1.16 -> 1.17 --- Log message: Handle "known" external calls context sensitively, add support for realloc and a couple of other functions that are important. Handle aggregate undef values for gv initializers --- Diffs of the changes: (+29 -17) Andersens.cpp | 46 +++++++++++++++++++++++++++++----------------- 1 files changed, 29 insertions(+), 17 deletions(-) Index: llvm/lib/Analysis/IPA/Andersens.cpp diff -u llvm/lib/Analysis/IPA/Andersens.cpp:1.16 llvm/lib/Analysis/IPA/Andersens.cpp:1.17 --- llvm/lib/Analysis/IPA/Andersens.cpp:1.16 Mon Mar 28 00:21:17 2005 +++ llvm/lib/Analysis/IPA/Andersens.cpp Tue Mar 29 00:09:07 2005 @@ -306,8 +306,8 @@ void AddGlobalInitializerConstraints(Node *N, Constant *C); void AddConstraintsForNonInternalLinkage(Function *F); - bool AddConstraintsForExternalFunction(Function *F); void AddConstraintsForCall(CallSite CS, Function *F); + bool AddConstraintsForExternalCall(CallSite CS, Function *F); void PrintNode(Node *N); @@ -581,7 +581,7 @@ } else if (C->isNullValue()) { N->addPointerTo(&GraphNodes[NullObject]); return; - } else { + } else if (!isa(C)) { // If this is an array or struct, include constraints for each element. assert(isa(C) || isa(C)); for (unsigned i = 0, e = C->getNumOperands(); i != e; ++i) @@ -601,32 +601,41 @@ &GraphNodes[UniversalSet])); } -/// AddConstraintsForExternalFunction - If this is a call to a "known" function, -/// add the constraints and return false. If this is a call to an unknown -/// function, return true. -bool Andersens::AddConstraintsForExternalFunction(Function *F) { +/// AddConstraintsForCall - If this is a call to a "known" function, add the +/// constraints and return true. If this is a call to an unknown function, +/// return false. +bool Andersens::AddConstraintsForExternalCall(CallSite CS, Function *F) { assert(F->isExternal() && "Not an external function!"); // These functions don't induce any points-to constraints. if (F->getName() == "printf" || F->getName() == "fprintf" || + F->getName() == "fgets" || F->getName() == "open" || F->getName() == "fopen" || - F->getName() == "atoi" || + F->getName() == "fclose" || F->getName() == "fflush" || + F->getName() == "atoi" || F->getName() == "sscanf" || F->getName() == "llvm.memset" || F->getName() == "memcmp" || F->getName() == "read" || F->getName() == "write") - return false; + return true; // These functions do induce points-to edges. if (F->getName() == "llvm.memcpy" || F->getName() == "llvm.memmove") { - Function::arg_iterator Dst = F->arg_begin(), Src = Dst; // Note: this is a poor approximation, this says Dest = Src, instead of // *Dest = *Src. - ++Src; - Constraints.push_back(Constraint(Constraint::Copy, getNode(Dst), - getNode(Src))); - return false; + Constraints.push_back(Constraint(Constraint::Copy, + getNode(CS.getArgument(0)), + getNode(CS.getArgument(1)))); + return true; } - return true; + if (F->getName() == "realloc") { + // Result = Arg + Constraints.push_back(Constraint(Constraint::Copy, + getNode(CS.getInstruction()), + getNode(CS.getArgument(0)))); + return true; + } + + return false; } @@ -689,9 +698,7 @@ // allocation in the body of the function and a node to represent all // pointer values defined by instructions and used as operands. visit(F); - } else if (AddConstraintsForExternalFunction(F)) { - // If we don't "know" about this function, assume the worst. - + } else { // External functions that return pointers return the universal set. if (isa(F->getFunctionType()->getReturnType())) Constraints.push_back(Constraint(Constraint::Copy, @@ -836,6 +843,11 @@ /// the function pointer has been casted. If this is the case, do something /// reasonable. void Andersens::AddConstraintsForCall(CallSite CS, Function *F) { + // If this is a call to an external function, handle it directly to get some + // taste of context sensitivity. + if (F->isExternal() && AddConstraintsForExternalCall(CS, F)) + return; + if (isa(CS.getType())) { Node *CSN = getNode(CS.getInstruction()); if (isa(F->getFunctionType()->getReturnType())) { From lattner at cs.uiuc.edu Tue Mar 29 00:25:27 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 29 Mar 2005 00:25:27 -0600 Subject: [llvm-commits] CVS: llvm/tools/gccas/gccas.cpp Message-ID: <200503290625.j2T6PRBn019283@apoc.cs.uiuc.edu> Changes in directory llvm/tools/gccas: gccas.cpp updated: 1.110 -> 1.111 --- Log message: there is no reason to run -instcombine -instcombine! --- Diffs of the changes: (+0 -1) gccas.cpp | 1 - 1 files changed, 1 deletion(-) Index: llvm/tools/gccas/gccas.cpp diff -u llvm/tools/gccas/gccas.cpp:1.110 llvm/tools/gccas/gccas.cpp:1.111 --- llvm/tools/gccas/gccas.cpp:1.110 Sun Mar 27 20:01:12 2005 +++ llvm/tools/gccas/gccas.cpp Tue Mar 29 00:25:11 2005 @@ -103,7 +103,6 @@ addPass(PM, createScalarReplAggregatesPass()); // Break up aggregate allocas addPass(PM, createInstructionCombiningPass()); // Combine silly seq's - addPass(PM, createInstructionCombiningPass()); // Combine silly seq's addPass(PM, createTailCallEliminationPass()); // Eliminate tail calls addPass(PM, createCFGSimplificationPass()); // Merge & remove BBs addPass(PM, createLICMPass()); // Hoist loop invariants From lattner at cs.uiuc.edu Tue Mar 29 00:38:03 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 29 Mar 2005 00:38:03 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200503290638.j2T6c3lh020117@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.316 -> 1.317 --- Log message: disable this transformation in the one obscure case that really pessimizes pointer analysis. --- Diffs of the changes: (+3 -0) InstructionCombining.cpp | 3 +++ 1 files changed, 3 insertions(+) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.316 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.317 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.316 Fri Mar 4 17:21:33 2005 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Tue Mar 29 00:37:47 2005 @@ -4646,6 +4646,9 @@ } if ((SrcPTy->isInteger() || isa(SrcPTy)) && + // Do not allow turning this into a load of an integer, which is then + // casted to a pointer, this pessimizes pointer analysis a lot. + (isa(SrcPTy) == isa(LI.getType())) && IC.getTargetData().getTypeSize(SrcPTy) == IC.getTargetData().getTypeSize(DestPTy)) { From lattner at cs.uiuc.edu Tue Mar 29 00:52:41 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 29 Mar 2005 00:52:41 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/IPA/Andersens.cpp Message-ID: <200503290652.j2T6qfq8027105@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/IPA: Andersens.cpp updated: 1.17 -> 1.18 --- Log message: add some more functions, ignore setcc for constraints! --- Diffs of the changes: (+9 -4) Andersens.cpp | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-) Index: llvm/lib/Analysis/IPA/Andersens.cpp diff -u llvm/lib/Analysis/IPA/Andersens.cpp:1.17 llvm/lib/Analysis/IPA/Andersens.cpp:1.18 --- llvm/lib/Analysis/IPA/Andersens.cpp:1.17 Tue Mar 29 00:09:07 2005 +++ llvm/lib/Analysis/IPA/Andersens.cpp Tue Mar 29 00:52:20 2005 @@ -328,6 +328,7 @@ void visitGetElementPtrInst(GetElementPtrInst &GEP); void visitPHINode(PHINode &PN); void visitCastInst(CastInst &CI); + void visitSetCondInst(SetCondInst &SCI) {} // NOOP! void visitSelectInst(SelectInst &SI); void visitVANext(VANextInst &I); void visitVAArg(VAArgInst &I); @@ -609,16 +610,20 @@ // These functions don't induce any points-to constraints. if (F->getName() == "printf" || F->getName() == "fprintf" || + F->getName() == "sprintf" || F->getName() == "fgets" || F->getName() == "open" || F->getName() == "fopen" || F->getName() == "fclose" || F->getName() == "fflush" || - F->getName() == "atoi" || F->getName() == "sscanf" || + F->getName() == "rewind" || + F->getName() == "atoi" || F->getName() == "unlink" || + F->getName() == "sscanf" || F->getName() == "fscanf" || F->getName() == "llvm.memset" || F->getName() == "memcmp" || F->getName() == "read" || F->getName() == "write") return true; // These functions do induce points-to edges. - if (F->getName() == "llvm.memcpy" || F->getName() == "llvm.memmove") { + if (F->getName() == "llvm.memcpy" || F->getName() == "llvm.memmove" || + F->getName() == "memmove") { // Note: this is a poor approximation, this says Dest = Src, instead of // *Dest = *Src. Constraints.push_back(Constraint(Constraint::Copy, @@ -647,8 +652,8 @@ void Andersens::CollectConstraints(Module &M) { // First, the universal set points to itself. GraphNodes[UniversalSet].addPointerTo(&GraphNodes[UniversalSet]); - Constraints.push_back(Constraint(Constraint::Load, &GraphNodes[UniversalSet], - &GraphNodes[UniversalSet])); + //Constraints.push_back(Constraint(Constraint::Load, &GraphNodes[UniversalSet], + // &GraphNodes[UniversalSet])); Constraints.push_back(Constraint(Constraint::Store, &GraphNodes[UniversalSet], &GraphNodes[UniversalSet])); From alkis at cs.uiuc.edu Tue Mar 29 06:51:08 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue, 29 Mar 2005 06:51:08 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMClass.h VMClass.cpp Compiler.cpp Message-ID: <200503291251.GAA03676@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMClass.h updated: 1.19 -> 1.20 VMClass.cpp updated: 1.22 -> 1.23 Compiler.cpp updated: 1.263 -> 1.264 --- Log message: Merge VMClass::getClassForClass() and VMClass::getClassForDescriptor() into one function VMClass::getClass(). --- Diffs of the changes: (+30 -42) Compiler.cpp | 26 +++++++++++++------------- VMClass.cpp | 43 ++++++++++++++++--------------------------- VMClass.h | 3 +-- 3 files changed, 30 insertions(+), 42 deletions(-) Index: llvm-java/lib/Compiler/VMClass.h diff -u llvm-java/lib/Compiler/VMClass.h:1.19 llvm-java/lib/Compiler/VMClass.h:1.20 --- llvm-java/lib/Compiler/VMClass.h:1.19 Mon Mar 28 21:10:46 2005 +++ llvm-java/lib/Compiler/VMClass.h Tue Mar 29 06:50:57 2005 @@ -87,8 +87,7 @@ int getFieldIndex(const std::string& name) const; llvm::Constant* getConstant(unsigned index) const; - const VMClass* getClassForClass(unsigned index) const; - const VMClass* getClassForDescriptor(unsigned index) const; + const VMClass* getClass(unsigned index) const; }; } } // namespace llvm::Java Index: llvm-java/lib/Compiler/VMClass.cpp diff -u llvm-java/lib/Compiler/VMClass.cpp:1.22 llvm-java/lib/Compiler/VMClass.cpp:1.23 --- llvm-java/lib/Compiler/VMClass.cpp:1.22 Mon Mar 28 21:10:46 2005 +++ llvm-java/lib/Compiler/VMClass.cpp Tue Mar 29 06:50:57 2005 @@ -100,7 +100,7 @@ // FIXME: Initialize static VMFields as well. } else { - const VMClass* fc = getClassForDescriptor(field->getDescriptorIndex()); + const VMClass* fc = getClass(field->getDescriptorIndex()); FieldMap::iterator i = fieldMap_.insert(std::make_pair( field->getName()->str(), @@ -136,8 +136,7 @@ // This is any class but java/lang/Object. if (classFile_->getSuperClass()) { // Our direct super class. - const VMClass* superClass = - getClassForClass(classFile_->getSuperClassIndex()); + const VMClass* superClass = getClass(classFile_->getSuperClassIndex()); // Add the interfaces of our direct superclass. for (unsigned i = 0, e = superClass->getNumInterfaces(); i != e; ++i) @@ -164,8 +163,7 @@ // For each of the interfaces we implement, load it and add that // interface and all the interfaces it inherits from. for (unsigned i = 0, e = classFile_->getNumInterfaces(); i != e; ++i) { - const VMClass* interface = - getClassForClass(classFile_->getInterfaceIndex(i)); + const VMClass* interface = getClass(classFile_->getInterfaceIndex(i)); interfaces_.push_back(interface); for (unsigned j = 0, f = interface->getNumInterfaces(); j != f; ++j) interfaces_.push_back(interface->getInterface(j)); @@ -225,33 +223,24 @@ return static_cast(resolvedConstantPool_[index]); } -const VMClass* VMClass::getClassForClass(unsigned index) const +const VMClass* VMClass::getClass(unsigned index) const { assert(classFile_ && "No constant pool!"); - assert(dynamic_cast(classFile_->getConstant(index)) && - "Not an index to a class reference!"); + assert((dynamic_cast(classFile_->getConstant(index)) || + dynamic_cast(classFile_->getConstant(index))) && + "Not an index to a class or descriptor reference!"); // If we haven't resolved this constant already, do so now. if (!resolvedConstantPool_[index]) { - ConstantClass* jc = classFile_->getConstantClass(index); - resolvedConstantPool_[index] = - const_cast(resolver_->getClass(jc->getName()->str())); - } - - return static_cast(resolvedConstantPool_[index]); -} - -const VMClass* VMClass::getClassForDescriptor(unsigned index) const -{ - assert(classFile_ && "No constant pool!"); - assert(dynamic_cast(classFile_->getConstant(index)) && - "Not an index to a descriptor reference!"); - - // If we haven't resolved this constant already, do so now. - if (!resolvedConstantPool_[index]) { - ConstantUtf8* jc = classFile_->getConstantUtf8(index); - resolvedConstantPool_[index] = - const_cast(resolver_->getClassForDesc(jc->str())); + Constant* jc = classFile_->getConstant(index); + if (ConstantClass* c = dynamic_cast(jc)) + resolvedConstantPool_[index] = + const_cast(resolver_->getClass(c->getName()->str())); + else if (ConstantUtf8* d = dynamic_cast(jc)) + resolvedConstantPool_[index] = + const_cast(resolver_->getClassForDesc(d->str())); + else + assert(0 && "Not a class!"); } return static_cast(resolvedConstantPool_[index]); Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.263 llvm-java/lib/Compiler/Compiler.cpp:1.264 --- llvm-java/lib/Compiler/Compiler.cpp:1.263 Mon Mar 28 17:56:46 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Tue Mar 29 06:50:57 2005 @@ -797,9 +797,9 @@ const std::string& className = fieldRef->getClass()->getName()->str(); GlobalVariable* global = getStaticField( - class_->getClassForClass(fieldRef->getClassIndex()), + class_->getClass(fieldRef->getClassIndex()), nameAndType->getName()->str(), - class_->getClassForDescriptor(nameAndType->getDescriptorIndex())); + class_->getClass(nameAndType->getDescriptorIndex())); assert(global && "Cannot find global for static field!"); @@ -852,7 +852,7 @@ class_->getClassFile()->getConstantFieldRef(index); ConstantNameAndType* nameAndType = fieldRef->getNameAndType(); return getField( - class_->getClassForClass(fieldRef->getClassIndex()), + class_->getClass(fieldRef->getClassIndex()), nameAndType->getName()->str(), ptr); } @@ -1102,7 +1102,7 @@ Field* field = fields[i]; if (field->isStatic()) { const VMClass* fieldClass = - clazz->getClassForDescriptor(field->getDescriptorIndex()); + clazz->getClass(field->getDescriptorIndex()); const Type* globalTy = fieldClass->getType(); // A java field can be final/constant even if it has a // dynamic initializer. Because LLVM does not currently @@ -1636,7 +1636,7 @@ void do_putfield(unsigned index) { ConstantFieldRef* fieldRef = class_->getClassFile()->getConstantFieldRef(index); - const VMClass* fieldClass = class_->getClassForDescriptor( + const VMClass* fieldClass = class_->getClass( fieldRef->getNameAndType()->getDescriptorIndex()); const Type* type = fieldClass->getType(); Value* v = pop(type); @@ -1691,7 +1691,7 @@ const std::string& className = methodRef->getClass()->getName()->str(); const VMClass* clazz = - class_->getClassForClass(methodRef->getClassIndex()); + class_->getClass(methodRef->getClassIndex()); const VTableInfo* vi = getVTableInfoGeneric(clazz); const std::string& methodDescr = @@ -1734,7 +1734,7 @@ methodName + nameAndType->getDescriptor()->str(); std::string funcName = className + '/' + methodDescr; const VMClass* clazz = - class_->getClassForClass(methodRef->getClassIndex()); + class_->getClass(methodRef->getClassIndex()); const FunctionType* funcTy = cast( resolver_->getType(nameAndType->getDescriptor()->str(), true)); @@ -1747,7 +1747,7 @@ ConstantMethodRef* methodRef = class_->getClassFile()->getConstantMethodRef(index); const VMClass* clazz = - class_->getClassForClass(methodRef->getClassIndex()); + class_->getClass(methodRef->getClassIndex()); emitStaticInitializers(clazz->getClassFile()); Method* method = getMethod(methodRef); Function* function = getFunction(method); @@ -1775,7 +1775,7 @@ const std::string& className = methodRef->getClass()->getName()->str(); const VMClass* clazz = - class_->getClassForClass(methodRef->getClassIndex()); + class_->getClass(methodRef->getClassIndex()); const VTableInfo* vi = getVTableInfoGeneric(clazz); const std::string& methodDescr = @@ -1848,7 +1848,7 @@ } void do_new(unsigned index) { - const VMClass* clazz = class_->getClassForClass(index); + const VMClass* clazz = class_->getClass(index); emitStaticInitializers(clazz->getClassFile()); const VTableInfo& vi = getVTableInfo(clazz); @@ -1937,7 +1937,7 @@ void do_anewarray(unsigned index) { Value* count = pop(Type::UIntTy); - const VMClass* clazz = class_->getClassForClass(index); + const VMClass* clazz = class_->getClass(index); const VMClass* arrayClass = resolver_->getArrayClass(clazz); const VTableInfo* vi = getVTableInfoGeneric(arrayClass); @@ -1959,7 +1959,7 @@ } void do_checkcast(unsigned index) { - const VMClass* clazz = class_->getClassForClass(index); + const VMClass* clazz = class_->getClass(index); const VTableInfo* vi = getVTableInfoGeneric(clazz); Value* objRef = pop(resolver_->getObjectBaseType()); @@ -1976,7 +1976,7 @@ } void do_instanceof(unsigned index) { - const VMClass* clazz = class_->getClassForClass(index); + const VMClass* clazz = class_->getClass(index); const VTableInfo* vi = getVTableInfoGeneric(clazz); Value* objRef = pop(resolver_->getObjectBaseType()); From alkis at cs.uiuc.edu Tue Mar 29 07:24:57 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue, 29 Mar 2005 07:24:57 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMField.h VMField.cpp VMClass.h VMClass.cpp Compiler.cpp Message-ID: <200503291324.HAA05813@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMField.h updated: 1.1 -> 1.2 VMField.cpp updated: 1.1 -> 1.2 VMClass.h updated: 1.20 -> 1.21 VMClass.cpp updated: 1.23 -> 1.24 Compiler.cpp updated: 1.264 -> 1.265 --- Log message: Resolve and cache field references in VMClass objects. --- Diffs of the changes: (+75 -54) Compiler.cpp | 64 ++++++++++++++--------------------------------------------- VMClass.cpp | 44 +++++++++++++++++++++++++++++++++++++++- VMClass.h | 2 + VMField.cpp | 7 ++++-- VMField.h | 12 ++++++++--- 5 files changed, 75 insertions(+), 54 deletions(-) Index: llvm-java/lib/Compiler/VMField.h diff -u llvm-java/lib/Compiler/VMField.h:1.1 llvm-java/lib/Compiler/VMField.h:1.2 --- llvm-java/lib/Compiler/VMField.h:1.1 Mon Mar 28 21:10:46 2005 +++ llvm-java/lib/Compiler/VMField.h Tue Mar 29 07:24:46 2005 @@ -28,6 +28,7 @@ class VMClass; class VMField { + const VMClass* parent_; const VMClass* clazz_; const Field* field_; union { @@ -39,11 +40,15 @@ // Interface for VMClass. // Create static field reference. - VMField(const VMClass* clazz, const Field* field); + VMField(const VMClass* parent, const VMClass* clazz, const Field* field); // Create member field reference. - VMField(const VMClass* clazz, const Field* field, int index) - : clazz_(clazz), + VMField(const VMClass* parent, + const VMClass* clazz, + const Field* field, + int index) + : parent_(parent), + clazz_(clazz), field_(field) { assert(!isStatic() && "This should be a member field!"); data_.index = index; @@ -54,6 +59,7 @@ const std::string& getName() const { return field_->getName()->str(); } bool isStatic() const { return field_->isStatic(); } + const VMClass* getParent() const { return parent_; } const VMClass* getClass() const { return clazz_; } int getMemberIndex() const { assert(!isStatic() && "Field should not be static!"); Index: llvm-java/lib/Compiler/VMField.cpp diff -u llvm-java/lib/Compiler/VMField.cpp:1.1 llvm-java/lib/Compiler/VMField.cpp:1.2 --- llvm-java/lib/Compiler/VMField.cpp:1.1 Mon Mar 28 21:10:46 2005 +++ llvm-java/lib/Compiler/VMField.cpp Tue Mar 29 07:24:46 2005 @@ -19,8 +19,11 @@ using namespace llvm; using namespace llvm::Java; -VMField::VMField(const VMClass* clazz, const Field* field) - : clazz_(clazz), +VMField::VMField(const VMClass* parent, + const VMClass* clazz, + const Field* field) + : parent_(parent), + clazz_(clazz), field_(field) { assert(isStatic() && "This should be a static field!"); Index: llvm-java/lib/Compiler/VMClass.h diff -u llvm-java/lib/Compiler/VMClass.h:1.20 llvm-java/lib/Compiler/VMClass.h:1.21 --- llvm-java/lib/Compiler/VMClass.h:1.20 Tue Mar 29 06:50:57 2005 +++ llvm-java/lib/Compiler/VMClass.h Tue Mar 29 07:24:46 2005 @@ -46,6 +46,7 @@ std::vector memberFields_; void computeLayout(); + const VMField* lookupField(const std::string& name) const; friend class Resolver; @@ -88,6 +89,7 @@ llvm::Constant* getConstant(unsigned index) const; const VMClass* getClass(unsigned index) const; + const VMField* getField(unsigned index) const; }; } } // namespace llvm::Java Index: llvm-java/lib/Compiler/VMClass.cpp diff -u llvm-java/lib/Compiler/VMClass.cpp:1.23 llvm-java/lib/Compiler/VMClass.cpp:1.24 --- llvm-java/lib/Compiler/VMClass.cpp:1.23 Tue Mar 29 06:50:57 2005 +++ llvm-java/lib/Compiler/VMClass.cpp Tue Mar 29 07:24:46 2005 @@ -70,6 +70,29 @@ } +const VMField* VMClass::lookupField(const std::string& name) const +{ + FieldMap::const_iterator it = fieldMap_.find(name); + if (it != fieldMap_.end()) + return &it->second; + + for (unsigned i = 0, e = getNumInterfaces(); i != e; ++i) { + const VMClass* interface = getInterface(i); + it = interface->fieldMap_.find(name); + if (it != interface->fieldMap_.end()) + return &it->second; + } + + for (unsigned i = 0, e = getNumSuperClasses(); i != e; ++i) { + const VMClass* superClass = getSuperClass(i); + it = superClass->fieldMap_.find(name); + if (it != superClass->fieldMap_.end()) + return &it->second; + } + + return NULL; +} + int VMClass::getFieldIndex(const std::string& name) const { FieldMap::const_iterator it = fieldMap_.find(name); return it == fieldMap_.end() ? -1 : it->second.getMemberIndex(); @@ -101,10 +124,11 @@ } else { const VMClass* fc = getClass(field->getDescriptorIndex()); + unsigned index = memberFields_.size() + 1; FieldMap::iterator i = fieldMap_.insert(std::make_pair( field->getName()->str(), - VMField(fc, field, memberFields_.size()+1))).first; + VMField(this, fc, field, index))).first; memberFields_.push_back(&i->second); layout.push_back(fc->getType()); } @@ -245,3 +269,21 @@ return static_cast(resolvedConstantPool_[index]); } + +const VMField* VMClass::getField(unsigned index) const +{ + assert(classFile_ && "No constant pool!"); + assert(dynamic_cast(classFile_->getConstant(index)) && + "Not an index to a field reference!"); + + // If we haven't resolved this constant already, do so now. + if (!resolvedConstantPool_[index]) { + ConstantFieldRef* jc = classFile_->getConstantFieldRef(index); + const VMClass* clazz = getClass(jc->getClassIndex()); + const std::string& name = jc->getNameAndType()->getName()->str(); + resolvedConstantPool_[index] = + const_cast(clazz->lookupField(name)); + } + + return static_cast(resolvedConstantPool_[index]); +} Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.264 llvm-java/lib/Compiler/Compiler.cpp:1.265 --- llvm-java/lib/Compiler/Compiler.cpp:1.264 Tue Mar 29 06:50:57 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Tue Mar 29 07:24:46 2005 @@ -847,39 +847,14 @@ /// Emits the necessary code to get a field from the passed /// pointer to an object. - Value* getField(unsigned index, Value* ptr) { - ConstantFieldRef* fieldRef = - class_->getClassFile()->getConstantFieldRef(index); - ConstantNameAndType* nameAndType = fieldRef->getNameAndType(); - return getField( - class_->getClass(fieldRef->getClassIndex()), - nameAndType->getName()->str(), - ptr); - } - - /// Emits the necessary code to get a field from the passed - /// pointer to an object. - Value* getField(const VMClass* clazz, - const std::string& fieldName, - Value* ptr) { - // Cast ptr to correct type. - ptr = new CastInst(ptr, clazz->getType(), TMP, currentBB_); - - // Deref pointer. - std::vector indices(1, ConstantUInt::get(Type::UIntTy, 0)); - while (true) { - int slot = clazz->getFieldIndex(fieldName); - if (slot == -1) { - indices.push_back(ConstantUInt::get(Type::UIntTy, 0)); - clazz = clazz->getSuperClass(); - } - else { - indices.push_back(ConstantUInt::get(Type::UIntTy, slot)); - break; - } - } + Value* getField(const VMField* field, Value* ptr) { + std::vector indices(2, ConstantUInt::get(Type::UIntTy, 0)); + indices[1] = ConstantUInt::get(Type::UIntTy, field->getMemberIndex()); - return new GetElementPtrInst(ptr, indices, fieldName + '*', currentBB_); + return new GetElementPtrInst(ptr, + indices, + field->getName()+'*', + currentBB_); } std::string getMangledString(const std::string& str) { @@ -1625,26 +1600,19 @@ } void do_getfield(unsigned index) { - ConstantFieldRef* fieldRef = - class_->getClassFile()->getConstantFieldRef(index); - const std::string& name = fieldRef->getNameAndType()->getName()->str(); - Value* p = pop(resolver_->getObjectBaseType()); - Value* v = new LoadInst(getField(index, p), name, currentBB_); + const VMField* field = class_->getField(index); + + Value* p = pop(field->getParent()->getType()); + Value* v = new LoadInst(getField(field, p), field->getName(), currentBB_); push(v); } void do_putfield(unsigned index) { - ConstantFieldRef* fieldRef = - class_->getClassFile()->getConstantFieldRef(index); - const VMClass* fieldClass = class_->getClass( - fieldRef->getNameAndType()->getDescriptorIndex()); - const Type* type = fieldClass->getType(); - Value* v = pop(type); - Value* p = pop(resolver_->getObjectBaseType()); - Value* fp = getField(index, p); - const Type* ft = cast(fp->getType())->getElementType(); - v = new CastInst(v, ft, TMP, currentBB_); - new StoreInst(v, getField(index, p), currentBB_); + const VMField* field = class_->getField(index); + + Value* v = pop(field->getClass()->getType()); + Value* p = pop(field->getParent()->getType()); + new StoreInst(v, getField(field, p), currentBB_); } void makeCall(Value* fun, const std::vector params) { From lattner at cs.uiuc.edu Tue Mar 29 09:13:44 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 29 Mar 2005 09:13:44 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Message-ID: <200503291513.j2TFDinS004507@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPC32ISelPattern.cpp updated: 1.13 -> 1.14 --- Log message: fix a warning in the optimized build --- Diffs of the changes: (+2 -0) PPC32ISelPattern.cpp | 2 ++ 1 files changed, 2 insertions(+) Index: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp diff -u llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.13 llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.14 --- llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.13 Mon Mar 28 18:03:27 2005 +++ llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Tue Mar 29 09:13:27 2005 @@ -729,6 +729,8 @@ if (sext && byte) { Tmp3 = Result; Result = MakeReg(MVT::i32); + } else { + Tmp3 = 0; // Silence GCC warning. } if(Address.getOpcode() == ISD::FrameIndex) { BuildMI(BB, Opc, 2, Result) From alkis at cs.uiuc.edu Tue Mar 29 11:11:50 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue, 29 Mar 2005 11:11:50 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMField.h VMField.cpp Message-ID: <200503291711.LAA07058@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMField.h updated: 1.2 -> 1.3 VMField.cpp updated: 1.2 -> 1.3 --- Log message: Rename member field. --- Diffs of the changes: (+4 -4) VMField.cpp | 2 +- VMField.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) Index: llvm-java/lib/Compiler/VMField.h diff -u llvm-java/lib/Compiler/VMField.h:1.2 llvm-java/lib/Compiler/VMField.h:1.3 --- llvm-java/lib/Compiler/VMField.h:1.2 Tue Mar 29 07:24:46 2005 +++ llvm-java/lib/Compiler/VMField.h Tue Mar 29 11:11:39 2005 @@ -29,7 +29,7 @@ class VMField { const VMClass* parent_; - const VMClass* clazz_; + const VMClass* class_; const Field* field_; union { int index; @@ -48,7 +48,7 @@ const Field* field, int index) : parent_(parent), - clazz_(clazz), + class_(clazz), field_(field) { assert(!isStatic() && "This should be a member field!"); data_.index = index; @@ -60,7 +60,7 @@ bool isStatic() const { return field_->isStatic(); } const VMClass* getParent() const { return parent_; } - const VMClass* getClass() const { return clazz_; } + const VMClass* getClass() const { return class_; } int getMemberIndex() const { assert(!isStatic() && "Field should not be static!"); return data_.index; Index: llvm-java/lib/Compiler/VMField.cpp diff -u llvm-java/lib/Compiler/VMField.cpp:1.2 llvm-java/lib/Compiler/VMField.cpp:1.3 --- llvm-java/lib/Compiler/VMField.cpp:1.2 Tue Mar 29 07:24:46 2005 +++ llvm-java/lib/Compiler/VMField.cpp Tue Mar 29 11:11:39 2005 @@ -23,7 +23,7 @@ const VMClass* clazz, const Field* field) : parent_(parent), - clazz_(clazz), + class_(clazz), field_(field) { assert(isStatic() && "This should be a static field!"); From lattner at cs.uiuc.edu Tue Mar 29 11:22:10 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 29 Mar 2005 11:22:10 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/IPA/Andersens.cpp Message-ID: <200503291722.j2THMAHQ007074@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/IPA: Andersens.cpp updated: 1.18 -> 1.19 --- Log message: Fix a major problem with global variable initializers. This could cause us to have stuff pointing to the null pointer, which makes no sense (the null ptr is an ssa value, not the null object) --- Diffs of the changes: (+2 -1) Andersens.cpp | 3 ++- 1 files changed, 2 insertions(+), 1 deletion(-) Index: llvm/lib/Analysis/IPA/Andersens.cpp diff -u llvm/lib/Analysis/IPA/Andersens.cpp:1.18 llvm/lib/Analysis/IPA/Andersens.cpp:1.19 --- llvm/lib/Analysis/IPA/Andersens.cpp:1.18 Tue Mar 29 00:52:20 2005 +++ llvm/lib/Analysis/IPA/Andersens.cpp Tue Mar 29 11:21:53 2005 @@ -578,7 +578,8 @@ void Andersens::AddGlobalInitializerConstraints(Node *N, Constant *C) { if (C->getType()->isFirstClassType()) { if (isa(C->getType())) - N->addPointerTo(getNodeForConstantPointer(C)); + N->copyFrom(getNodeForConstantPointer(C)); + } else if (C->isNullValue()) { N->addPointerTo(&GraphNodes[NullObject]); return; From alkis at cs.uiuc.edu Tue Mar 29 11:30:07 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue, 29 Mar 2005 11:30:07 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200503291730.LAA07294@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.265 -> 1.266 --- Log message: Inline getField() to its two users. --- Diffs of the changes: (+12 -14) Compiler.cpp | 26 ++++++++++++-------------- 1 files changed, 12 insertions(+), 14 deletions(-) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.265 llvm-java/lib/Compiler/Compiler.cpp:1.266 --- llvm-java/lib/Compiler/Compiler.cpp:1.265 Tue Mar 29 07:24:46 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Tue Mar 29 11:29:56 2005 @@ -845,18 +845,6 @@ return NULL; } - /// Emits the necessary code to get a field from the passed - /// pointer to an object. - Value* getField(const VMField* field, Value* ptr) { - std::vector indices(2, ConstantUInt::get(Type::UIntTy, 0)); - indices[1] = ConstantUInt::get(Type::UIntTy, field->getMemberIndex()); - - return new GetElementPtrInst(ptr, - indices, - field->getName()+'*', - currentBB_); - } - std::string getMangledString(const std::string& str) { std::string mangledStr; @@ -1603,7 +1591,12 @@ const VMField* field = class_->getField(index); Value* p = pop(field->getParent()->getType()); - Value* v = new LoadInst(getField(field, p), field->getName(), currentBB_); + std::vector indices(2); + indices[0] = ConstantUInt::get(Type::UIntTy, 0); + indices[1] = ConstantUInt::get(Type::UIntTy, field->getMemberIndex()); + Value* fieldPtr = + new GetElementPtrInst(p, indices, field->getName()+'*', currentBB_); + Value* v = new LoadInst(fieldPtr, field->getName(), currentBB_); push(v); } @@ -1612,7 +1605,12 @@ Value* v = pop(field->getClass()->getType()); Value* p = pop(field->getParent()->getType()); - new StoreInst(v, getField(field, p), currentBB_); + std::vector indices(2); + indices[0] = ConstantUInt::get(Type::UIntTy, 0); + indices[1] = ConstantUInt::get(Type::UIntTy, field->getMemberIndex()); + Value* fieldPtr = + new GetElementPtrInst(p, indices, field->getName()+'*', currentBB_); + new StoreInst(v, fieldPtr, currentBB_); } void makeCall(Value* fun, const std::vector params) { From alkis at cs.uiuc.edu Tue Mar 29 11:37:19 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue, 29 Mar 2005 11:37:19 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMField.cpp VMClass.h VMClass.cpp Compiler.cpp Message-ID: <200503291737.LAA07363@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMField.cpp updated: 1.3 -> 1.4 VMClass.h updated: 1.21 -> 1.22 VMClass.cpp updated: 1.24 -> 1.25 Compiler.cpp updated: 1.266 -> 1.267 --- Log message: Allocate space for static members and initialize the constant static members as part of class linking (as per the JVM specification). Use the VMField abstraction to refer to static members as well. This remove a bunch of code from the Compiler. --- Diffs of the changes: (+33 -99) Compiler.cpp | 102 ++++------------------------------------------------------- VMClass.cpp | 5 +- VMClass.h | 1 VMField.cpp | 24 ++++++++++++- 4 files changed, 33 insertions(+), 99 deletions(-) Index: llvm-java/lib/Compiler/VMField.cpp diff -u llvm-java/lib/Compiler/VMField.cpp:1.3 llvm-java/lib/Compiler/VMField.cpp:1.4 --- llvm-java/lib/Compiler/VMField.cpp:1.3 Tue Mar 29 11:11:39 2005 +++ llvm-java/lib/Compiler/VMField.cpp Tue Mar 29 11:37:08 2005 @@ -13,8 +13,9 @@ //===----------------------------------------------------------------------===// #include "VMField.h" +#include "Resolver.h" #include "VMClass.h" -#include +#include using namespace llvm; using namespace llvm::Java; @@ -27,5 +28,24 @@ field_(field) { assert(isStatic() && "This should be a static field!"); - // FIXME: add Global to module. + + // A java static field is constant if it is marked final and has a + // static initializer. + bool isConstant = field_->isFinal() && field->getConstantValueAttribute(); + + llvm::Constant* init = NULL; + if (ConstantValueAttribute* attr = field_->getConstantValueAttribute()) { + init = parent_->getConstant(attr->getValueIndex()); + if (init->getType() != class_->getType()) + init = ConstantExpr::getCast(init, class_->getType()); + } + else + init = llvm::Constant::getNullValue(class_->getType()); + + data_.global = new GlobalVariable(class_->getType(), + isConstant, + GlobalVariable::ExternalLinkage, + init, + parent_->getName() + '/' + getName(), + parent_->getResolver()->getModule()); } Index: llvm-java/lib/Compiler/VMClass.h diff -u llvm-java/lib/Compiler/VMClass.h:1.21 llvm-java/lib/Compiler/VMClass.h:1.22 --- llvm-java/lib/Compiler/VMClass.h:1.21 Tue Mar 29 07:24:46 2005 +++ llvm-java/lib/Compiler/VMClass.h Tue Mar 29 11:37:08 2005 @@ -70,6 +70,7 @@ public: const std::string& getName() const { return name_; } + Resolver* getResolver() const { return resolver_; } const Type* getLayoutType() const { return layoutType_; } const Type* getType() const { return type_; } const ClassFile* getClassFile() const { return classFile_; } Index: llvm-java/lib/Compiler/VMClass.cpp diff -u llvm-java/lib/Compiler/VMClass.cpp:1.24 llvm-java/lib/Compiler/VMClass.cpp:1.25 --- llvm-java/lib/Compiler/VMClass.cpp:1.24 Tue Mar 29 07:24:46 2005 +++ llvm-java/lib/Compiler/VMClass.cpp Tue Mar 29 11:37:08 2005 @@ -119,11 +119,12 @@ const Fields& fields = classFile_->getFields(); for (unsigned i = 0, e = fields.size(); i != e; ++i) { Field* field = fields[i]; + const VMClass* fc = getClass(field->getDescriptorIndex()); if (field->isStatic()) { - // FIXME: Initialize static VMFields as well. + fieldMap_.insert(std::make_pair(field->getName()->str(), + VMField(this, fc, field))); } else { - const VMClass* fc = getClass(field->getDescriptorIndex()); unsigned index = memberFields_.size() + 1; FieldMap::iterator i = fieldMap_.insert(std::make_pair( Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.266 llvm-java/lib/Compiler/Compiler.cpp:1.267 --- llvm-java/lib/Compiler/Compiler.cpp:1.266 Tue Mar 29 11:29:56 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Tue Mar 29 11:37:08 2005 @@ -788,63 +788,6 @@ return arrayInfo; } - /// Emits the necessary code to get a pointer to a static field of - /// an object. - GlobalVariable* getStaticField(unsigned index) { - ConstantFieldRef* fieldRef = - class_->getClassFile()->getConstantFieldRef(index); - ConstantNameAndType* nameAndType = fieldRef->getNameAndType(); - - const std::string& className = fieldRef->getClass()->getName()->str(); - GlobalVariable* global = getStaticField( - class_->getClass(fieldRef->getClassIndex()), - nameAndType->getName()->str(), - class_->getClass(nameAndType->getDescriptorIndex())); - - assert(global && "Cannot find global for static field!"); - - return global; - } - - /// Finds a static field in the specified class, any of its - /// super clases, or any of the interfaces it implements. - GlobalVariable* getStaticField(const VMClass* clazz, - const std::string& name, - const VMClass* fieldClass) { - emitStaticInitializers(clazz->getClassFile()); - - std::string globalName = - clazz->getClassFile()->getThisClass()->getName()->str() + '/' + name; - DEBUG(std::cerr << "Looking up global: " << globalName << '\n'); - const Type* type = fieldClass->getType(); - if (GlobalVariable* g = module_->getGlobalVariable(globalName, type)) - return g; - - for (unsigned i = 0, e = clazz->getNumInterfaces(); i != e; ++i) { - const VMClass* interface = clazz->getInterface(i); - emitStaticInitializers(interface->getClassFile()); - globalName = - interface->getClassFile()->getThisClass()->getName()->str() + - '/' + name; - DEBUG(std::cerr << "Looking up global: " << globalName << '\n'); - if (GlobalVariable* g = module_->getGlobalVariable(globalName, type)) - return g; - } - - for (unsigned i = 0, e = clazz->getNumSuperClasses(); i != e; ++i) { - const VMClass* superClass = clazz->getSuperClass(i); - emitStaticInitializers(superClass->getClassFile()); - globalName = - superClass->getClassFile()->getThisClass()->getName()->str() + - '/' + name; - DEBUG(std::cerr << "Looking up global: " << globalName << '\n'); - if (GlobalVariable* g = module_->getGlobalVariable(globalName, type)) - return g; - } - - return NULL; - } - std::string getMangledString(const std::string& str) { std::string mangledStr; @@ -1059,39 +1002,6 @@ classfile->getThisClass()->getName()->str(); const VMClass* clazz = resolver_->getClass(className); - // Create the global variables of this class. - const Fields& fields = classfile->getFields(); - for (unsigned i = 0, e = fields.size(); i != e; ++i) { - Field* field = fields[i]; - if (field->isStatic()) { - const VMClass* fieldClass = - clazz->getClass(field->getDescriptorIndex()); - const Type* globalTy = fieldClass->getType(); - // A java field can be final/constant even if it has a - // dynamic initializer. Because LLVM does not currently - // support these semantics, we consider constants only - // final fields with static initializers. - bool isConstant = false; - llvm::Constant* init = llvm::Constant::getNullValue(globalTy); - if (field->getConstantValueAttribute()) { - unsigned i = field->getConstantValueAttribute()->getValueIndex(); - init = ConstantExpr::getCast(clazz->getConstant(i), globalTy); - isConstant = field->isFinal(); - } - - std::string globalName = - classfile->getThisClass()->getName()->str() + '/' + - field->getName()->str(); - DEBUG(std::cerr << "Adding global: " << globalName << '\n'); - new GlobalVariable(globalTy, - isConstant, - GlobalVariable::ExternalLinkage, - init, - globalName, - module_); - } - } - Function* hook = module_->getOrInsertFunction(LLVM_JAVA_STATIC_INIT, Type::VoidTy, 0); Instruction* I = hook->front().getTerminator(); @@ -1576,15 +1486,17 @@ } void do_getstatic(unsigned index) { - Value* v = new LoadInst(getStaticField(index), TMP, currentBB_); + const VMField* field = class_->getField(index); + + Value* v = new LoadInst(field->getGlobal(), TMP, currentBB_); push(v); } void do_putstatic(unsigned index) { - Value* ptr = getStaticField(index); - const Type* fieldTy = cast(ptr->getType())->getElementType(); - Value* v = pop(fieldTy); - new StoreInst(v, ptr, currentBB_); + const VMField* field = class_->getField(index); + + Value* v = pop(field->getClass()->getType()); + new StoreInst(v, field->getGlobal(), currentBB_); } void do_getfield(unsigned index) { From lattner at cs.uiuc.edu Tue Mar 29 11:45:08 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 29 Mar 2005 11:45:08 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/AliasAnalysisEvaluator.cpp Message-ID: <200503291745.j2THj89W009000@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: AliasAnalysisEvaluator.cpp updated: 1.25 -> 1.26 --- Log message: there is no point comparing against null pointer. --- Diffs of the changes: (+3 -2) AliasAnalysisEvaluator.cpp | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) Index: llvm/lib/Analysis/AliasAnalysisEvaluator.cpp diff -u llvm/lib/Analysis/AliasAnalysisEvaluator.cpp:1.25 llvm/lib/Analysis/AliasAnalysisEvaluator.cpp:1.26 --- llvm/lib/Analysis/AliasAnalysisEvaluator.cpp:1.25 Sat Mar 26 17:56:33 2005 +++ llvm/lib/Analysis/AliasAnalysisEvaluator.cpp Tue Mar 29 11:44:52 2005 @@ -17,10 +17,11 @@ // //===----------------------------------------------------------------------===// +#include "llvm/Constants.h" +#include "llvm/DerivedTypes.h" #include "llvm/Function.h" #include "llvm/Instructions.h" #include "llvm/Pass.h" -#include "llvm/DerivedTypes.h" #include "llvm/Analysis/Passes.h" #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Assembly/Writer.h" @@ -115,7 +116,7 @@ isa(Inst.getOperand(0))) ++OI; // Skip actual functions for direct function calls. for (; OI != Inst.op_end(); ++OI) - if (isa((*OI)->getType())) + if (isa((*OI)->getType()) && !isa(*OI)) Pointers.insert(*OI); CallSite CS = CallSite::get(&*I); From lattner at cs.uiuc.edu Tue Mar 29 13:10:12 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 29 Mar 2005 13:10:12 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <200503291910.j2TJACwb012139@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: SelectionDAGISel.cpp updated: 1.34 -> 1.35 --- Log message: Fix a bug that andrew noticed where we do not correctly sign/zero extend returned integer values all of the way to 64-bits (we only did it to 32-bits leaving the top bits undefined). This causes problems for targets like alpha whose ABI's define the top bits too. --- Diffs of the changes: (+13 -4) SelectionDAGISel.cpp | 17 +++++++++++++---- 1 files changed, 13 insertions(+), 4 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.34 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.35 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.34 Fri Mar 25 19:29:23 2005 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Tue Mar 29 13:09:56 2005 @@ -378,22 +378,31 @@ } SDOperand Op1 = getValue(I.getOperand(0)); + MVT::ValueType TmpVT; + switch (Op1.getValueType()) { default: assert(0 && "Unknown value type!"); case MVT::i1: case MVT::i8: case MVT::i16: - // Extend integer types to 32-bits. + case MVT::i32: + // If this is a machine where 32-bits is legal or expanded, promote to + // 32-bits, otherwise, promote to 64-bits. + if (TLI.getTypeAction(MVT::i32) == TargetLowering::Promote) + TmpVT = TLI.getTypeToTransformTo(MVT::i32); + else + TmpVT = MVT::i32; + + // Extend integer types to result type. if (I.getOperand(0)->getType()->isSigned()) - Op1 = DAG.getNode(ISD::SIGN_EXTEND, MVT::i32, Op1); + Op1 = DAG.getNode(ISD::SIGN_EXTEND, TmpVT, Op1); else - Op1 = DAG.getNode(ISD::ZERO_EXTEND, MVT::i32, Op1); + Op1 = DAG.getNode(ISD::ZERO_EXTEND, TmpVT, Op1); break; case MVT::f32: // Extend float to double. Op1 = DAG.getNode(ISD::FP_EXTEND, MVT::f64, Op1); break; - case MVT::i32: case MVT::i64: case MVT::f64: break; // No extension needed! From brukman at cs.uiuc.edu Tue Mar 29 13:11:29 2005 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Tue, 29 Mar 2005 13:11:29 -0600 Subject: [llvm-commits] CVS: llvm-www/RandomBoxes/010-Docs.html Message-ID: <200503291911.NAA08352@zion.cs.uiuc.edu> Changes in directory llvm-www/RandomBoxes: 010-Docs.html updated: 1.3 -> 1.4 --- Log message: Fix some grammar --- Diffs of the changes: (+2 -2) 010-Docs.html | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm-www/RandomBoxes/010-Docs.html diff -u llvm-www/RandomBoxes/010-Docs.html:1.3 llvm-www/RandomBoxes/010-Docs.html:1.4 --- llvm-www/RandomBoxes/010-Docs.html:1.3 Mon Aug 2 16:43:14 2004 +++ llvm-www/RandomBoxes/010-Docs.html Tue Mar 29 13:11:16 2005 @@ -1,6 +1,6 @@ -LLVM has extensive Documentation +LLVM has extensive documentation describing the high-level aspects of the compiler system in good detail. LLVM also includes doxygen and CVSWeb documentation for the low-level aspects and individual API references. -LLVM is one of the best documented compilers available. +LLVM is one of the best-documented compilers available. From lattner at cs.uiuc.edu Tue Mar 29 13:17:15 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 29 Mar 2005 13:17:15 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/DataStructure.cpp Steensgaard.cpp Message-ID: <200503291917.j2TJHF0s013771@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: DataStructure.cpp updated: 1.235 -> 1.236 Steensgaard.cpp updated: 1.58 -> 1.59 --- Log message: Fix a problem where we not marking incoming arguments to functions with external linkage as incomplete. --- Diffs of the changes: (+14 -5) DataStructure.cpp | 3 ++- Steensgaard.cpp | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) Index: llvm/lib/Analysis/DataStructure/DataStructure.cpp diff -u llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.235 llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.236 --- llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.235 Thu Mar 24 18:02:41 2005 +++ llvm/lib/Analysis/DataStructure/DataStructure.cpp Tue Mar 29 13:16:59 2005 @@ -1657,7 +1657,8 @@ for (ReturnNodesTy::iterator FI = ReturnNodes.begin(), E =ReturnNodes.end(); FI != E; ++FI) { Function &F = *FI->first; - for (Function::arg_iterator I = F.arg_begin(), E = F.arg_end(); I != E; ++I) + for (Function::arg_iterator I = F.arg_begin(), E = F.arg_end(); + I != E; ++I) if (isPointerType(I->getType())) markIncompleteNode(getNodeForValue(I).getNode()); markIncompleteNode(FI->second.getNode()); Index: llvm/lib/Analysis/DataStructure/Steensgaard.cpp diff -u llvm/lib/Analysis/DataStructure/Steensgaard.cpp:1.58 llvm/lib/Analysis/DataStructure/Steensgaard.cpp:1.59 --- llvm/lib/Analysis/DataStructure/Steensgaard.cpp:1.58 Sun Mar 27 15:56:55 2005 +++ llvm/lib/Analysis/DataStructure/Steensgaard.cpp Tue Mar 29 13:16:59 2005 @@ -167,14 +167,22 @@ } } - // Remove our knowledge of what the return values of the functions are. - ResultGraph->getReturnNodes().clear(); + // Remove our knowledge of what the return values of the functions are, except + // for functions that are externally visible from this module (e.g. main). We + // keep these functions so that their arguments are marked incomplete. + for (DSGraph::ReturnNodesTy::iterator I = + ResultGraph->getReturnNodes().begin(), + E = ResultGraph->getReturnNodes().end(); I != E; ) + if (I->first->hasInternalLinkage()) + ResultGraph->getReturnNodes().erase(I++); + else + ++I; // Update the "incomplete" markers on the nodes, ignoring unknownness due to // incoming arguments... ResultGraph->maskIncompleteMarkers(); - ResultGraph->markIncompleteNodes(DSGraph::IgnoreFormalArgs | - DSGraph::IgnoreGlobals); + ResultGraph->markIncompleteNodes(DSGraph::IgnoreGlobals | + DSGraph::MarkFormalArgs); // Remove any nodes that are dead after all of the merging we have done... // FIXME: We should be able to disable the globals graph for steens! From alenhar2 at cs.uiuc.edu Tue Mar 29 13:24:20 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Tue, 29 Mar 2005 13:24:20 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp AlphaRegisterInfo.cpp Message-ID: <200503291924.j2TJOKIi014774@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.68 -> 1.69 AlphaRegisterInfo.cpp updated: 1.17 -> 1.18 --- Log message: Fix up some types and constants --- Diffs of the changes: (+5 -7) AlphaISelPattern.cpp | 8 +++----- AlphaRegisterInfo.cpp | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.68 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.69 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.68 Fri Mar 25 19:29:23 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Tue Mar 29 13:24:04 2005 @@ -327,8 +327,8 @@ } //These describe LDAx -static const int64_t IMM_LOW = 0xffffffffffff8000LL; -static const int IMM_HIGH = 0x0000000000007fffLL; +static const int IMM_LOW = -32768; +static const int IMM_HIGH = 32767; static const int IMM_MULT = 65536; static long getUpper16(long l) @@ -1325,8 +1325,6 @@ BuildMI(BB, Alpha::ADDQi, 2, Tmp4).addReg(Alpha::R31).addImm(1); Opc = inv?Alpha::CMOVNEi_FP:Alpha::CMOVEQi_FP; BuildMI(BB, Opc, 3, Result).addReg(Tmp4).addImm(0).addReg(Tmp3); -// Opc = inv?Alpha::CC2INT_INV:Alpha::CC2INT; -// BuildMI(BB, Opc, 1, Result).addReg(Tmp3); // // Spill the FP to memory and reload it from there. // unsigned Size = MVT::getSizeInBits(MVT::f64)/8; @@ -1515,7 +1513,7 @@ case ISD::Constant: { - int64_t val = (long)cast(N)->getValue(); + int64_t val = (int64_t)cast(N)->getValue(); if (val <= IMM_HIGH && val >= IMM_LOW) { BuildMI(BB, Alpha::LDA, 2, Result).addImm(val).addReg(Alpha::R31); } Index: llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp diff -u llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.17 llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.18 --- llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.17 Sat Mar 12 18:43:20 2005 +++ llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp Tue Mar 29 13:24:04 2005 @@ -31,8 +31,8 @@ using namespace llvm; //These describe LDAx -static const int64_t IMM_LOW = 0xffffffffffff8000LL; -static const int IMM_HIGH = 0x0000000000007fffLL; +static const int IMM_LOW = -32768; +static const int IMM_HIGH = 32767; static const int IMM_MULT = 65536; static long getUpper16(long l) From lattner at cs.uiuc.edu Tue Mar 29 14:04:40 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 29 Mar 2005 14:04:40 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/IPA/Andersens.cpp Message-ID: <200503292004.j2TK4etZ017775@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/IPA: Andersens.cpp updated: 1.19 -> 1.20 --- Log message: learn about some more functions. --- Diffs of the changes: (+7 -4) Andersens.cpp | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-) Index: llvm/lib/Analysis/IPA/Andersens.cpp diff -u llvm/lib/Analysis/IPA/Andersens.cpp:1.19 llvm/lib/Analysis/IPA/Andersens.cpp:1.20 --- llvm/lib/Analysis/IPA/Andersens.cpp:1.19 Tue Mar 29 11:21:53 2005 +++ llvm/lib/Analysis/IPA/Andersens.cpp Tue Mar 29 14:04:24 2005 @@ -612,11 +612,12 @@ // These functions don't induce any points-to constraints. if (F->getName() == "printf" || F->getName() == "fprintf" || F->getName() == "sprintf" || - F->getName() == "fgets" || + F->getName() == "fgets" || F->getName() == "__assert_fail" || F->getName() == "open" || F->getName() == "fopen" || F->getName() == "fclose" || F->getName() == "fflush" || F->getName() == "rewind" || - F->getName() == "atoi" || F->getName() == "unlink" || + F->getName() == "atoi" || F->getName() == "atol" || + F->getName() == "unlink" || F->getName() == "sscanf" || F->getName() == "fscanf" || F->getName() == "llvm.memset" || F->getName() == "memcmp" || F->getName() == "read" || F->getName() == "write") @@ -633,8 +634,10 @@ return true; } - if (F->getName() == "realloc") { - // Result = Arg + // Result = Arg0 + if (F->getName() == "realloc" || F->getName() == "strchr" || + F->getName() == "strrchr" || F->getName() == "strstr" || + F->getName() == "strtok") { Constraints.push_back(Constraint(Constraint::Copy, getNode(CS.getInstruction()), getNode(CS.getArgument(0)))); From tbrethou at cs.uiuc.edu Tue Mar 29 14:33:53 2005 From: tbrethou at cs.uiuc.edu (Tanya Brethour) Date: Tue, 29 Mar 2005 14:33:53 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/ModuloScheduling/DependenceAnalyzer.cpp DependenceAnalyzer.h Message-ID: <200503292033.j2TKXrGe020561@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9/ModuloScheduling: DependenceAnalyzer.cpp added (r1.1) DependenceAnalyzer.h added (r1.1) --- Log message: Dependence analyzer that just determines dependences within a loop for loads and stores using alias analysis. --- Diffs of the changes: (+182 -0) DependenceAnalyzer.cpp | 109 +++++++++++++++++++++++++++++++++++++++++++++++++ DependenceAnalyzer.h | 73 ++++++++++++++++++++++++++++++++ 2 files changed, 182 insertions(+) Index: llvm/lib/Target/SparcV9/ModuloScheduling/DependenceAnalyzer.cpp diff -c /dev/null llvm/lib/Target/SparcV9/ModuloScheduling/DependenceAnalyzer.cpp:1.1 *** /dev/null Tue Mar 29 14:33:52 2005 --- llvm/lib/Target/SparcV9/ModuloScheduling/DependenceAnalyzer.cpp Tue Mar 29 14:33:42 2005 *************** *** 0 **** --- 1,109 ---- + //===-- DependenceAnalyzer.cpp - DependenceAnalyzer ----------------*- C++ -*-===// + // + // 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. + // + //===----------------------------------------------------------------------===// + // + // + // + // + //===----------------------------------------------------------------------===// + #define DEBUG_TYPE "ModuloSched" + + #include "DependenceAnalyzer.h" + #include "llvm/Support/Debug.h" + + namespace llvm { + + + /// Create ModuloSchedulingPass + /// + FunctionPass *llvm::createDependenceAnalyzer() { + return new DependenceAnalyzer(); + } + + bool DependenceAnalyzer::runOnFunction(Function &F) { + AA = &getAnalysis(); + TD = &getAnalysis(); + + return false; + } + + static RegisterAnalysisX("depanalyzer", "Dependence Analyzer"); + + DependenceResult DependenceAnalyzer::getDependenceInfo(Instruction *inst1, Instruction *inst2) { + std::vector deps; + + DEBUG(std::cerr << "Inst1: " << *inst1 << "\n"); + DEBUG(std::cerr << "Inst2: " << *inst2 << "\n"); + + + if(LoadInst *ldInst = dyn_cast(inst1)) { + + if(StoreInst *stInst = dyn_cast(inst2)) { + //Get load mem ref + Value *ldOp = ldInst->getOperand(0); + + //Get store mem ref + Value *stOp = stInst->getOperand(1); + + if(AA->alias(ldOp, (unsigned)TD->getTypeSize(ldOp->getType()), + stOp,(unsigned)TD->getTypeSize(stOp->getType())) + != AliasAnalysis::NoAlias) { + + //Anti Dep + deps.push_back(Dependence(0, Dependence::AntiDep)); + } + } + } + + else if(StoreInst *stInst = dyn_cast(inst1)) { + + if(LoadInst *ldInst = dyn_cast(inst2)) { + //Get load mem ref + Value *ldOp = ldInst->getOperand(0); + + //Get store mem ref + Value *stOp = stInst->getOperand(1); + + + if(AA->alias(ldOp, (unsigned)TD->getTypeSize(ldOp->getType()), + stOp,(unsigned)TD->getTypeSize(stOp->getType())) + != AliasAnalysis::NoAlias) { + + //Anti Dep + deps.push_back(Dependence(0, Dependence::TrueDep)); + } + } + else if(StoreInst *stInst2 = dyn_cast(inst2)) { + + //Get load mem ref + Value *stOp1 = stInst->getOperand(1); + + //Get store mem ref + Value *stOp2 = stInst2->getOperand(1); + + + if(AA->alias(stOp1, (unsigned)TD->getTypeSize(stOp1->getType()), + stOp2,(unsigned)TD->getTypeSize(stOp2->getType())) + != AliasAnalysis::NoAlias) { + + //Anti Dep + deps.push_back(Dependence(0, Dependence::OutputDep)); + } + } + + + } + else + assert("Expected a load or a store\n"); + + DependenceResult dr = DependenceResult(deps); + return dr; + } + } + + Index: llvm/lib/Target/SparcV9/ModuloScheduling/DependenceAnalyzer.h diff -c /dev/null llvm/lib/Target/SparcV9/ModuloScheduling/DependenceAnalyzer.h:1.1 *** /dev/null Tue Mar 29 14:33:53 2005 --- llvm/lib/Target/SparcV9/ModuloScheduling/DependenceAnalyzer.h Tue Mar 29 14:33:42 2005 *************** *** 0 **** --- 1,73 ---- + //===-- DependenceAnalyzer.h - Dependence Analyzer--------------*- C++ -*-===// + // + // 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. + // + //===----------------------------------------------------------------------===// + // + // + //===----------------------------------------------------------------------===// + + #ifndef LLVM_DEPENDENCEANALYZER_H + #define LLVM_DEPENDENCEANALYZER_H + + #include "llvm/Instructions.h" + #include "llvm/Function.h" + #include "llvm/Pass.h" + #include "llvm/Analysis/AliasAnalysis.h" + #include "llvm/Target/TargetData.h" + #include + + namespace llvm { + + //class to represent a dependence + struct Dependence { + + enum DataDepType { + TrueDep, AntiDep, OutputDep, NonDateDep, + }; + + Dependence(int diff, DataDepType dep) : iteDiff(diff), depType(dep) {} + unsigned getIteDiff() { return iteDiff; } + unsigned getDepType() { return depType; } + + private: + + unsigned iteDiff; + unsigned depType; + }; + + + struct DependenceResult { + std::vector dependences; + DependenceResult(const std::vector &d) : dependences(d) {} + }; + + + class DependenceAnalyzer : public FunctionPass { + AliasAnalysis *AA; + TargetData *TD; + + public: + DependenceAnalyzer() { AA = 0; TD = 0; } + virtual bool runOnFunction(Function &F); + virtual const char* getPassName() const { return "DependenceAnalyzer"; } + + // getAnalysisUsage + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired(); + AU.addRequired(); + } + + //get dependence info + DependenceResult getDependenceInfo(Instruction *inst1, Instruction *inst2); + + }; + + } + + + + #endif From tbrethou at cs.uiuc.edu Tue Mar 29 14:35:21 2005 From: tbrethou at cs.uiuc.edu (Tanya Brethour) Date: Tue, 29 Mar 2005 14:35:21 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/ModuloScheduling/MSchedGraph.cpp MSchedGraph.h ModuloScheduling.cpp ModuloScheduling.h Message-ID: <200503292035.j2TKZLEI020582@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9/ModuloScheduling: MSchedGraph.cpp updated: 1.15 -> 1.16 MSchedGraph.h updated: 1.8 -> 1.9 ModuloScheduling.cpp updated: 1.44 -> 1.45 ModuloScheduling.h updated: 1.25 -> 1.26 --- Log message: Compare dependence analysis with llvm instructions versus machine instrutions. the problem with using machine instructions and alias analysis is that aa does not handle tmp instructions. --- Diffs of the changes: (+129 -52) MSchedGraph.cpp | 143 ++++++++++++++++++++++++++++++++++++--------------- MSchedGraph.h | 12 ++-- ModuloScheduling.cpp | 20 +++++-- ModuloScheduling.h | 6 +- 4 files changed, 129 insertions(+), 52 deletions(-) Index: llvm/lib/Target/SparcV9/ModuloScheduling/MSchedGraph.cpp diff -u llvm/lib/Target/SparcV9/ModuloScheduling/MSchedGraph.cpp:1.15 llvm/lib/Target/SparcV9/ModuloScheduling/MSchedGraph.cpp:1.16 --- llvm/lib/Target/SparcV9/ModuloScheduling/MSchedGraph.cpp:1.15 Wed Mar 23 23:13:53 2005 +++ llvm/lib/Target/SparcV9/ModuloScheduling/MSchedGraph.cpp Tue Mar 29 14:35:10 2005 @@ -141,7 +141,10 @@ //Create a graph for a machine block. The ignoreInstrs map is so that we ignore instructions //associated to the index variable since this is a special case in Modulo Scheduling. //We only want to deal with the body of the loop. -MSchedGraph::MSchedGraph(const MachineBasicBlock *bb, const TargetMachine &targ, AliasAnalysis &AA, TargetData &TD, std::map &ignoreInstrs) +MSchedGraph::MSchedGraph(const MachineBasicBlock *bb, const TargetMachine &targ, AliasAnalysis &AA, + TargetData &TD, std::map &ignoreInstrs, + DependenceAnalyzer &DA, std::map &machineTollvm + ) : BB(bb), Target(targ) { //Make sure BB is not null, @@ -150,7 +153,7 @@ //DEBUG(std::cerr << "Constructing graph for " << bb << "\n"); //Create nodes and edges for this BB - buildNodesAndEdges(AA, TD, ignoreInstrs); + buildNodesAndEdges(AA, TD, ignoreInstrs, DA, machineTollvm); //Experimental! //addBranchEdges(); @@ -270,7 +273,10 @@ //Add edges between the nodes -void MSchedGraph::buildNodesAndEdges(AliasAnalysis &AA, TargetData &TD, std::map &ignoreInstrs) { +void MSchedGraph::buildNodesAndEdges(AliasAnalysis &AA, TargetData &TD, + std::map &ignoreInstrs, + DependenceAnalyzer &DA, + std::map &machineTollvm) { //Get Machine target information for calculating latency const TargetInstrInfo *MTI = Target.getInstrInfo(); @@ -405,7 +411,7 @@ } - addMemEdges(memInstructions, AA, TD); + addMemEdges(memInstructions, AA, TD, DA, machineTollvm); addMachRegEdges(regNumtoNodeMap); //Finally deal with PHI Nodes and Value* @@ -584,7 +590,9 @@ //Add edges between all loads and stores //Can be less strict with alias analysis and data dependence analysis. -void MSchedGraph::addMemEdges(const std::vector& memInst, AliasAnalysis &AA, TargetData &TD) { +void MSchedGraph::addMemEdges(const std::vector& memInst, AliasAnalysis &AA, + TargetData &TD, DependenceAnalyzer &DA, + std::map &machineTollvm) { //Get Target machine instruction info const TargetInstrInfo *TMI = Target.getInstrInfo(); @@ -598,11 +606,16 @@ //Get the machine opCode to determine type of memory instruction MachineOpCode srcNodeOpCode = srcInst->getOpcode(); - //All instructions after this one in execution order have an iteration delay of 0 for(unsigned destIndex = srcIndex + 1; destIndex < memInst.size(); ++destIndex) { MachineInstr *destInst = (MachineInstr*) memInst[destIndex]->getInst(); + bool malias = false; + + DEBUG(std::cerr << "MInst1: " << *srcInst << "\n"); + DEBUG(std::cerr << "Inst1: " << *machineTollvm[srcInst] << "\n"); + DEBUG(std::cerr << "MInst2: " << *destInst << "\n"); + DEBUG(std::cerr << "Inst2: " << *machineTollvm[destInst] << "\n"); //Add Anti dependencies (store after load) //Source is a Load @@ -613,14 +626,24 @@ //Get the Value* that we are reading from the load, always the first op const MachineOperand &mOp = srcInst->getOperand(0); - assert((mOp.isUse() && (mOp.getType() == MachineOperand::MO_VirtualRegister)) && "Assumed first operand was a use and a value*\n"); - - //Get the value* for the store const MachineOperand &mOp2 = destInst->getOperand(0); - assert(mOp2.getType() == MachineOperand::MO_VirtualRegister && "Assumed first operand was a value*\n"); + + if(mOp.hasAllocatedReg()) + if(mOp.getReg() == SparcV9::g0) + continue; + else + malias = true; + if(mOp2.hasAllocatedReg()) + if(mOp2.getReg() == SparcV9::g0) + continue; + else + malias = true; + //compare to DA + DependenceResult dr = DA.getDependenceInfo(machineTollvm[srcInst], machineTollvm[destInst]); + //Only add the edge if we can't verify that they do not alias - if(AA.alias(mOp2.getVRegValue(), + if(malias || AA.alias(mOp2.getVRegValue(), (unsigned)TD.getTypeSize(mOp2.getVRegValue()->getType()), mOp.getVRegValue(), (unsigned)TD.getTypeSize(mOp.getVRegValue()->getType())) @@ -630,23 +653,38 @@ memInst[srcIndex]->addOutEdge(memInst[destIndex], MSchedGraphEdge::MemoryDep, MSchedGraphEdge::AntiDep); + + assert(dr.dependences.size() == 1 && "Expected at least one dependence\n"); + } + else + assert(dr.dependences.size() == 0 && "Expected no dependence\n"); } } //If source is a store, add output and true dependencies if(TMI->isStore(srcNodeOpCode)) { - - //Get the Value* that we are reading from the store (src), always the first op - const MachineOperand &mOp = srcInst->getOperand(0); - assert(mOp.getType() == MachineOperand::MO_VirtualRegister && "Assumed first operand was a use and a value*\n"); //Get the Value* that we are reading from the load, always the first op - const MachineOperand &mOp2 = srcInst->getOperand(0); - assert((mOp2.isUse() && (mOp2.getType() == MachineOperand::MO_VirtualRegister)) && "Assumed first operand was a use and a value*\n"); + const MachineOperand &mOp = srcInst->getOperand(0); + const MachineOperand &mOp2 = destInst->getOperand(0); + + if(mOp.hasAllocatedReg()) + if(mOp.getReg() == SparcV9::g0) + continue; + else + malias = true; + if(mOp2.hasAllocatedReg()) + if(mOp2.getReg() == SparcV9::g0) + continue; + else + malias = true; + + //compare to DA + DependenceResult dr = DA.getDependenceInfo(machineTollvm[srcInst], machineTollvm[destInst]); //Only add the edge if we can't verify that they do not alias - if(AA.alias(mOp2.getVRegValue(), + if(malias || AA.alias(mOp2.getVRegValue(), (unsigned)TD.getTypeSize(mOp2.getVRegValue()->getType()), mOp.getVRegValue(), (unsigned)TD.getTypeSize(mOp.getVRegValue()->getType())) @@ -660,7 +698,12 @@ memInst[srcIndex]->addOutEdge(memInst[destIndex], MSchedGraphEdge::MemoryDep, MSchedGraphEdge::TrueDep); + assert(dr.dependences.size() == 1 && "Expected at least one dependence\n"); + } + + else + assert(dr.dependences.size() == 0 && "Expected no dependence\n"); } } @@ -668,39 +711,55 @@ for(unsigned destIndex = 0; destIndex < srcIndex; ++destIndex) { MachineInstr *destInst = (MachineInstr*) memInst[destIndex]->getInst(); + bool malias = false; //source is a Load, so add anti-dependencies (store after load) if(TMI->isLoad(srcNodeOpCode)) { - //Get the Value* that we are reading from the load, always the first op - const MachineOperand &mOp = srcInst->getOperand(0); - assert((mOp.isUse() && (mOp.getType() == MachineOperand::MO_VirtualRegister)) && "Assumed first operand was a use and a value*\n"); - - //Get the value* for the store - const MachineOperand &mOp2 = destInst->getOperand(0); - assert(mOp2.getType() == MachineOperand::MO_VirtualRegister && "Assumed first operand was a value*\n"); - //Only add the edge if we can't verify that they do not alias - if(AA.alias(mOp2.getVRegValue(), - (unsigned)TD.getTypeSize(mOp2.getVRegValue()->getType()), - mOp.getVRegValue(), - (unsigned)TD.getTypeSize(mOp.getVRegValue()->getType())) - != AliasAnalysis::NoAlias) { - if(TMI->isStore(memInst[destIndex]->getInst()->getOpcode())) - memInst[srcIndex]->addOutEdge(memInst[destIndex], - MSchedGraphEdge::MemoryDep, - MSchedGraphEdge::AntiDep, 1); - } + //Get the Value* that we are reading from the load, always the first op + const MachineOperand &mOp = srcInst->getOperand(0); + const MachineOperand &mOp2 = destInst->getOperand(0); + + if(mOp.hasAllocatedReg()) + if(mOp.getReg() == SparcV9::g0) + continue; + else + malias = true; + if(mOp2.hasAllocatedReg()) + if(mOp2.getReg() == SparcV9::g0) + continue; + else + malias = true; + + //Only add the edge if we can't verify that they do not alias + if(AA.alias(mOp2.getVRegValue(), + (unsigned)TD.getTypeSize(mOp2.getVRegValue()->getType()), + mOp.getVRegValue(), + (unsigned)TD.getTypeSize(mOp.getVRegValue()->getType())) + != AliasAnalysis::NoAlias) { + if(TMI->isStore(memInst[destIndex]->getInst()->getOpcode())) + memInst[srcIndex]->addOutEdge(memInst[destIndex], + MSchedGraphEdge::MemoryDep, + MSchedGraphEdge::AntiDep, 1); + } } if(TMI->isStore(srcNodeOpCode)) { - //Get the Value* that we are reading from the store (src), always the first op - const MachineOperand &mOp = srcInst->getOperand(0); - assert(mOp.getType() == MachineOperand::MO_VirtualRegister && "Assumed first operand was a use and a value*\n"); - //Get the Value* that we are reading from the load, always the first op - const MachineOperand &mOp2 = srcInst->getOperand(0); - assert((mOp2.isUse() && (mOp2.getType() == MachineOperand::MO_VirtualRegister)) && "Assumed first operand was a use and a value*\n"); + const MachineOperand &mOp = srcInst->getOperand(0); + const MachineOperand &mOp2 = destInst->getOperand(0); + if(mOp.hasAllocatedReg()) + if(mOp.getReg() == SparcV9::g0) + continue; + else + malias = true; + if(mOp2.hasAllocatedReg()) + if(mOp2.getReg() == SparcV9::g0) + continue; + else + malias = true; + //Only add the edge if we can't verify that they do not alias if(AA.alias(mOp2.getVRegValue(), (unsigned)TD.getTypeSize(mOp2.getVRegValue()->getType()), Index: llvm/lib/Target/SparcV9/ModuloScheduling/MSchedGraph.h diff -u llvm/lib/Target/SparcV9/ModuloScheduling/MSchedGraph.h:1.8 llvm/lib/Target/SparcV9/ModuloScheduling/MSchedGraph.h:1.9 --- llvm/lib/Target/SparcV9/ModuloScheduling/MSchedGraph.h:1.8 Tue Mar 22 19:47:20 2005 +++ llvm/lib/Target/SparcV9/ModuloScheduling/MSchedGraph.h Tue Mar 29 14:35:10 2005 @@ -16,7 +16,7 @@ #ifndef LLVM_MSCHEDGRAPH_H #define LLVM_MSCHEDGRAPH_H - +#include "DependenceAnalyzer.h" #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/Target/TargetMachine.h" @@ -241,18 +241,20 @@ //Add Nodes and Edges to this graph for our BB typedef std::pair OpIndexNodePair; - void buildNodesAndEdges(AliasAnalysis &AA, TargetData &TD, std::map &ignoreInstrs); + void buildNodesAndEdges(AliasAnalysis &AA, TargetData &TD, std::map &ignoreInstrs, DependenceAnalyzer &DA, std::map &machineTollvm); void addValueEdges(std::vector &NodesInMap, MSchedGraphNode *node, bool nodeIsUse, bool nodeIsDef, std::vector &phiInstrs, int diff=0); void addMachRegEdges(std::map >& regNumtoNodeMap); - void addMemEdges(const std::vector& memInst, AliasAnalysis &AA, TargetData &TD); + void addMemEdges(const std::vector& memInst, AliasAnalysis &AA, TargetData &TD, + DependenceAnalyzer &DA, std::map &machineTollvm); void addBranchEdges(); public: - MSchedGraph(const MachineBasicBlock *bb, const TargetMachine &targ, AliasAnalysis &AA, TargetData &TD, - std::map &ignoreInstrs); + MSchedGraph(const MachineBasicBlock *bb, const TargetMachine &targ, AliasAnalysis &AA, + TargetData &TD, std::map &ignoreInstrs, + DependenceAnalyzer &DA, std::map &machineTollvm); //Copy constructor with maps to link old nodes to new nodes MSchedGraph(const MSchedGraph &G, std::map &newNodes); Index: llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp diff -u llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp:1.44 llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp:1.45 --- llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp:1.44 Tue Mar 22 19:47:20 2005 +++ llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp Tue Mar 29 14:35:10 2005 @@ -152,6 +152,7 @@ //Get MachineFunction MachineFunction &MF = MachineFunction::get(&F); + DependenceAnalyzer &DA = getAnalysis(); AliasAnalysis &AA = getAnalysis(); TargetData &TD = getAnalysis(); @@ -191,7 +192,7 @@ continue; } - MSchedGraph *MSG = new MSchedGraph(*BI, target, AA, TD, indVarInstrs[*BI]); + MSchedGraph *MSG = new MSchedGraph(*BI, target, AA, TD, indVarInstrs[*BI], DA, machineTollvm[*BI]); //Write Graph out to file DEBUG(WriteGraphToFile(std::cerr, F.getName(), MSG)); @@ -349,7 +350,6 @@ if(BI->getBasicBlock()->size() == 1) return false; - //Increase number of single basic block loops for stats ++SingleBBLoops; @@ -363,8 +363,11 @@ for(MachineBasicBlock::const_iterator I = BI->begin(), E = BI->end(); I != E; ++I) { //Get opcode to check instruction type MachineOpCode OC = I->getOpcode(); + + //Look for calls 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 @@ -422,6 +425,15 @@ std::cerr << **N << "\n"; }); + //Create map of machine instr to llvm instr + std::map mllvm; + for(BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) { + MachineCodeForInstruction & tempMvec = MachineCodeForInstruction::get(I); + for (unsigned j = 0; j < tempMvec.size(); j++) { + mllvm[tempMvec[j]] = I; + } + } + //Convert list of LLVM Instructions to list of Machine instructions std::map mIndVar; for(std::set::iterator N = indVar.begin(), NE = indVar.end(); N != NE; ++N) { @@ -443,7 +455,7 @@ //Put into a map for future access indVarInstrs[BI] = mIndVar; - + machineTollvm[BI] = mllvm; return true; } @@ -1864,7 +1876,7 @@ MSchedGraphNode *branch = 0; MSchedGraphNode *BAbranch = 0; - schedule.print(std::cerr); + DEBUG(schedule.print(std::cerr)); std::vector branches; Index: llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.h diff -u llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.h:1.25 llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.h:1.26 --- llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.h:1.25 Tue Mar 22 19:47:20 2005 +++ llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.h Tue Mar 29 14:35:10 2005 @@ -17,7 +17,7 @@ #include "MSSchedule.h" #include "llvm/Function.h" #include "llvm/Pass.h" -#include "llvm/Analysis/AliasAnalysis.h" +#include "DependenceAnalyzer.h" #include "llvm/Target/TargetData.h" #include @@ -47,6 +47,9 @@ //Map to hold list of instructions associate to the induction var for each BB std::map > indVarInstrs; + //Map to hold machine to llvm instrs for each valid BB + std::map > machineTollvm; + //LLVM Instruction we know we can add TmpInstructions to its MCFI Instruction *defaultInst; @@ -145,6 +148,7 @@ // getAnalysisUsage virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired(); AU.addRequired(); AU.addRequired(); } From lattner at cs.uiuc.edu Tue Mar 29 14:36:18 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 29 Mar 2005 14:36:18 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/IPA/Andersens.cpp Message-ID: <200503292036.j2TKaI6n020611@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/IPA: Andersens.cpp updated: 1.20 -> 1.21 --- Log message: import all of the rest of the stubs that dsa uses for direct comparison --- Diffs of the changes: (+43 -11) Andersens.cpp | 54 +++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 43 insertions(+), 11 deletions(-) Index: llvm/lib/Analysis/IPA/Andersens.cpp diff -u llvm/lib/Analysis/IPA/Andersens.cpp:1.20 llvm/lib/Analysis/IPA/Andersens.cpp:1.21 --- llvm/lib/Analysis/IPA/Andersens.cpp:1.20 Tue Mar 29 14:04:24 2005 +++ llvm/lib/Analysis/IPA/Andersens.cpp Tue Mar 29 14:36:05 2005 @@ -610,19 +610,47 @@ assert(F->isExternal() && "Not an external function!"); // These functions don't induce any points-to constraints. - if (F->getName() == "printf" || F->getName() == "fprintf" || - F->getName() == "sprintf" || - F->getName() == "fgets" || F->getName() == "__assert_fail" || - F->getName() == "open" || F->getName() == "fopen" || - F->getName() == "fclose" || F->getName() == "fflush" || - F->getName() == "rewind" || - F->getName() == "atoi" || F->getName() == "atol" || - F->getName() == "unlink" || - F->getName() == "sscanf" || F->getName() == "fscanf" || - F->getName() == "llvm.memset" || F->getName() == "memcmp" || - F->getName() == "read" || F->getName() == "write") + if (F->getName() == "atoi" || F->getName() == "atof" || + F->getName() == "atol" || F->getName() == "atoll" || + F->getName() == "remove" || F->getName() == "unlink" || + F->getName() == "rename" || F->getName() == "memcmp" || + F->getName() == "llvm.memset" || + F->getName() == "strcmp" || F->getName() == "strncmp" || + F->getName() == "execl" || F->getName() == "execlp" || + F->getName() == "execle" || F->getName() == "execv" || + F->getName() == "execvp" || F->getName() == "chmod" || + F->getName() == "puts" || F->getName() == "write" || + F->getName() == "open" || F->getName() == "create" || + F->getName() == "truncate" || F->getName() == "chdir" || + F->getName() == "mkdir" || F->getName() == "rmdir" || + F->getName() == "read" || F->getName() == "pipe" || + F->getName() == "wait" || F->getName() == "time" || + F->getName() == "stat" || F->getName() == "fstat" || + F->getName() == "lstat" || F->getName() == "strtod" || + F->getName() == "strtof" || F->getName() == "strtold" || + F->getName() == "fopen" || F->getName() == "fdopen" || + F->getName() == "freopen" || + F->getName() == "fflush" || F->getName() == "feof" || + F->getName() == "fileno" || F->getName() == "clearerr" || + F->getName() == "rewind" || F->getName() == "ftell" || + F->getName() == "ferror" || F->getName() == "fgetc" || + F->getName() == "fgetc" || F->getName() == "_IO_getc" || + F->getName() == "fwrite" || F->getName() == "fread" || + F->getName() == "fgets" || F->getName() == "ungetc" || + F->getName() == "fputc" || + F->getName() == "fputs" || F->getName() == "putc" || + F->getName() == "ftell" || F->getName() == "rewind" || + F->getName() == "_IO_putc" || F->getName() == "fseek" || + F->getName() == "fgetpos" || F->getName() == "fsetpos" || + F->getName() == "printf" || F->getName() == "fprintf" || + F->getName() == "sprintf" || F->getName() == "vprintf" || + F->getName() == "vfprintf" || F->getName() == "vsprintf" || + F->getName() == "scanf" || F->getName() == "fscanf" || + F->getName() == "sscanf" || F->getName() == "__assert_fail" || + F->getName() == "modf") return true; + // These functions do induce points-to edges. if (F->getName() == "llvm.memcpy" || F->getName() == "llvm.memmove" || F->getName() == "memmove") { @@ -816,14 +844,18 @@ getNode(CI.getOperand(0)))); } else { // P1 = cast int --> +#if 0 Constraints.push_back(Constraint(Constraint::Copy, getNodeValue(CI), &GraphNodes[UniversalSet])); +#endif } } else if (isa(Op->getType())) { // int = cast P1 --> +#if 0 Constraints.push_back(Constraint(Constraint::Copy, &GraphNodes[UniversalSet], getNode(CI.getOperand(0)))); +#endif } } From natebegeman at mac.com Tue Mar 29 15:54:49 2005 From: natebegeman at mac.com (Nate Begeman) Date: Tue, 29 Mar 2005 15:54:49 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp PowerPCInstrInfo.td Message-ID: <200503292154.PAA12012@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPC32ISelPattern.cpp updated: 1.14 -> 1.15 PowerPCInstrInfo.td updated: 1.51 -> 1.52 --- Log message: Implement SetCC, fix ZERO_EXTEND_INREG --- Diffs of the changes: (+75 -6) PPC32ISelPattern.cpp | 79 +++++++++++++++++++++++++++++++++++++++++++++++---- PowerPCInstrInfo.td | 2 + 2 files changed, 75 insertions(+), 6 deletions(-) Index: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp diff -u llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.14 llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.15 --- llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.14 Tue Mar 29 09:13:27 2005 +++ llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Tue Mar 29 15:54:38 2005 @@ -587,7 +587,6 @@ case ISD::SUB: Opc = DestType == MVT::f64 ? PPC::FSUB : PPC::FSUBS; break; case ISD::SDIV: Opc = DestType == MVT::f64 ? PPC::FDIV : PPC::FDIVS; break; }; - Tmp1 = SelectExpr(N.getOperand(0)); Tmp2 = SelectExpr(N.getOperand(1)); BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); @@ -865,8 +864,8 @@ case MVT::i8: Tmp2 = 24; break; case MVT::i1: Tmp2 = 31; break; } - BuildMI(BB, PPC::RLWINM, 5, Result).addReg(Tmp1).addImm(0).addImm(0) - .addImm(Tmp2).addImm(31); + BuildMI(BB, PPC::RLWINM, 4, Result).addReg(Tmp1).addImm(0).addImm(Tmp2) + .addImm(31); return Result; case ISD::CopyFromReg: @@ -880,7 +879,7 @@ Tmp1 = SelectExpr(N.getOperand(0)); if (ConstantSDNode *CN = dyn_cast(N.getOperand(1))) { Tmp2 = CN->getValue() & 0x1F; - BuildMI(BB, PPC::RLWINM, 5, Result).addReg(Tmp1).addImm(Tmp2).addImm(0) + BuildMI(BB, PPC::RLWINM, 4, Result).addReg(Tmp1).addImm(Tmp2).addImm(0) .addImm(31-Tmp2); } else { Tmp2 = SelectExpr(N.getOperand(1)); @@ -892,7 +891,7 @@ Tmp1 = SelectExpr(N.getOperand(0)); if (ConstantSDNode *CN = dyn_cast(N.getOperand(1))) { Tmp2 = CN->getValue() & 0x1F; - BuildMI(BB, PPC::RLWINM, 5, Result).addReg(Tmp1).addImm(32-Tmp2) + BuildMI(BB, PPC::RLWINM, 4, Result).addReg(Tmp1).addImm(32-Tmp2) .addImm(Tmp2).addImm(31); } else { Tmp2 = SelectExpr(N.getOperand(1)); @@ -1028,7 +1027,75 @@ abort(); case ISD::SETCC: - abort(); + if (SetCCSDNode *SetCC = dyn_cast(Node)) { + bool U = false; + bool IsInteger = MVT::isInteger(SetCC->getOperand(0).getValueType()); + + switch (SetCC->getCondition()) { + default: Node->dump(); assert(0 && "Unknown comparison!"); + case ISD::SETEQ: Opc = PPC::BEQ; break; + case ISD::SETNE: Opc = PPC::BNE; break; + case ISD::SETULT: U = true; + case ISD::SETLT: Opc = PPC::BLT; break; + case ISD::SETULE: U = true; + case ISD::SETLE: Opc = PPC::BLE; break; + case ISD::SETUGT: U = true; + case ISD::SETGT: Opc = PPC::BGT; break; + case ISD::SETUGE: U = true; + case ISD::SETGE: Opc = PPC::BGE; break; + } + + // FIXME: Is there a situation in which we would ever need to emit fcmpo? + static const unsigned CompareOpcodes[] = + { PPC::FCMPU, PPC::FCMPU, PPC::CMPW, PPC::CMPLW }; + unsigned CompareOpc = CompareOpcodes[2 * IsInteger + U]; + + // Create an iterator with which to insert the MBB for copying the false + // value and the MBB to hold the PHI instruction for this SetCC. + MachineBasicBlock *thisMBB = BB; + const BasicBlock *LLVM_BB = BB->getBasicBlock(); + ilist::iterator It = BB; + ++It; + + // thisMBB: + // ... + // cmpTY cr0, r1, r2 + // %TrueValue = li 1 + // bCC sinkMBB + Tmp1 = SelectExpr(N.getOperand(0)); + Tmp2 = SelectExpr(N.getOperand(1)); + BuildMI(BB, CompareOpc, 2, PPC::CR0).addReg(Tmp1).addReg(Tmp2); + unsigned TrueValue = MakeReg(MVT::i32); + BuildMI(BB, PPC::LI, 1, TrueValue).addSImm(1); + MachineBasicBlock *copy0MBB = new MachineBasicBlock(LLVM_BB); + MachineBasicBlock *sinkMBB = new MachineBasicBlock(LLVM_BB); + BuildMI(BB, Opc, 2).addReg(PPC::CR0).addMBB(sinkMBB); + MachineFunction *F = BB->getParent(); + F->getBasicBlockList().insert(It, copy0MBB); + F->getBasicBlockList().insert(It, sinkMBB); + // Update machine-CFG edges + BB->addSuccessor(copy0MBB); + BB->addSuccessor(sinkMBB); + + // copy0MBB: + // %FalseValue = li 0 + // fallthrough + BB = copy0MBB; + unsigned FalseValue = MakeReg(MVT::i32); + BuildMI(BB, PPC::LI, 1, FalseValue).addSImm(0); + // Update machine-CFG edges + BB->addSuccessor(sinkMBB); + + // sinkMBB: + // %Result = phi [ %FalseValue, copy0MBB ], [ %TrueValue, thisMBB ] + // ... + BB = sinkMBB; + BuildMI(BB, PPC::PHI, 4, Result).addReg(FalseValue) + .addMBB(copy0MBB).addReg(TrueValue).addMBB(thisMBB); + return Result; + } + assert(0 && "Is this legal?"); + return 0; case ISD::SELECT: abort(); Index: llvm/lib/Target/PowerPC/PowerPCInstrInfo.td diff -u llvm/lib/Target/PowerPC/PowerPCInstrInfo.td:1.51 llvm/lib/Target/PowerPC/PowerPCInstrInfo.td:1.52 --- llvm/lib/Target/PowerPC/PowerPCInstrInfo.td:1.51 Mon Mar 28 16:28:37 2005 +++ llvm/lib/Target/PowerPC/PowerPCInstrInfo.td Tue Mar 29 15:54:38 2005 @@ -292,6 +292,8 @@ def CMPLD : XForm_16_ext<31, 32, 1, 0, (ops CRRC:$crD, GPRC:$rA, GPRC:$rB), "cmpld $crD, $rA, $rB">; +def FCMPO : XForm_17<63, 32, 0, 0, (ops CRRC:$crD, FPRC:$fA, FPRC:$fB), + "fcmpo $crD, $fA, $fB">; def FCMPU : XForm_17<63, 0, 0, 0, (ops CRRC:$crD, FPRC:$fA, FPRC:$fB), "fcmpu $crD, $fA, $fB">; let isLoad = 1 in { From natebegeman at mac.com Tue Mar 29 16:25:02 2005 From: natebegeman at mac.com (Nate Begeman) Date: Tue, 29 Mar 2005 16:25:02 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Message-ID: <200503292225.QAA12786@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPC32ISelPattern.cpp updated: 1.15 -> 1.16 --- Log message: Implement integer select and i1 sign extend --- Diffs of the changes: (+49 -2) PPC32ISelPattern.cpp | 51 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 49 insertions(+), 2 deletions(-) Index: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp diff -u llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.15 llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.16 --- llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.15 Tue Mar 29 15:54:38 2005 +++ llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Tue Mar 29 16:24:51 2005 @@ -853,6 +853,9 @@ case MVT::i8: BuildMI(BB, PPC::EXTSB, 1, Result).addReg(Tmp1); break; + case MVT::i1: + BuildMI(BB, PPC::SUBFIC, 2, Result).addReg(Tmp1).addSImm(0); + break; } return Result; @@ -1097,8 +1100,52 @@ assert(0 && "Is this legal?"); return 0; - case ISD::SELECT: - abort(); + case ISD::SELECT: { + Tmp1 = SelectExpr(N.getOperand(0)); //Cond + + // Create an iterator with which to insert the MBB for copying the false + // value and the MBB to hold the PHI instruction for this SetCC. + MachineBasicBlock *thisMBB = BB; + const BasicBlock *LLVM_BB = BB->getBasicBlock(); + ilist::iterator It = BB; + ++It; + + // thisMBB: + // ... + // TrueVal = ... + // cmpTY cr0, r1, r2 + // bCC copy1MBB + // fallthrough --> copy0MBB + BuildMI(BB, PPC::CMPLWI, 2, PPC::CR0).addReg(Tmp1).addImm(0); + MachineBasicBlock *copy0MBB = new MachineBasicBlock(LLVM_BB); + MachineBasicBlock *sinkMBB = new MachineBasicBlock(LLVM_BB); + unsigned TrueValue = SelectExpr(N.getOperand(1)); //Use if TRUE + BuildMI(BB, PPC::BNE, 2).addReg(PPC::CR0).addMBB(sinkMBB); + MachineFunction *F = BB->getParent(); + F->getBasicBlockList().insert(It, copy0MBB); + F->getBasicBlockList().insert(It, sinkMBB); + // Update machine-CFG edges + BB->addSuccessor(copy0MBB); + BB->addSuccessor(sinkMBB); + + // copy0MBB: + // %FalseValue = ... + // # fallthrough to sinkMBB + BB = copy0MBB; + unsigned FalseValue = SelectExpr(N.getOperand(2)); //Use if FALSE + // Update machine-CFG edges + BB->addSuccessor(sinkMBB); + + // sinkMBB: + // %Result = phi [ %FalseValue, copy0MBB ], [ %TrueValue, thisMBB ] + // ... + BB = sinkMBB; + BuildMI(BB, PPC::PHI, 4, Result).addReg(FalseValue) + .addMBB(copy0MBB).addReg(TrueValue).addMBB(thisMBB); + + // FIXME: Select i64? + return Result; + } case ISD::Constant: switch (N.getValueType()) { From natebegeman at mac.com Tue Mar 29 16:49:06 2005 From: natebegeman at mac.com (Nate Begeman) Date: Tue, 29 Mar 2005 16:49:06 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Message-ID: <200503292249.QAA12930@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPC32ISelPattern.cpp updated: 1.16 -> 1.17 --- Log message: Fix BranchCC (it's still dumb), and implement FP select (also dumb) --- Diffs of the changes: (+49 -4) PPC32ISelPattern.cpp | 53 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 49 insertions(+), 4 deletions(-) Index: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp diff -u llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.16 llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.17 --- llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.16 Tue Mar 29 16:24:51 2005 +++ llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Tue Mar 29 16:48:55 2005 @@ -495,9 +495,10 @@ Select(N.getOperand(0)); //chain SDOperand CC = N.getOperand(1); - //Giveup and do the stupid thing + //Give up and do the stupid thing unsigned Tmp1 = SelectExpr(CC); - BuildMI(BB, PPC::BNE, 2).addReg(Tmp1).addMBB(Dest); + BuildMI(BB, PPC::CMPLWI, 2, PPC::CR0).addReg(Tmp1).addImm(0); + BuildMI(BB, PPC::BNE, 2).addReg(PPC::CR0).addMBB(Dest); return; } @@ -514,8 +515,52 @@ Node->dump(); assert(0 && "Node not handled!\n"); - case ISD::SELECT: - abort(); + case ISD::SELECT: { + Tmp1 = SelectExpr(N.getOperand(0)); //Cond + + // FIXME: generate FSEL here + + // Create an iterator with which to insert the MBB for copying the false + // value and the MBB to hold the PHI instruction for this SetCC. + MachineBasicBlock *thisMBB = BB; + const BasicBlock *LLVM_BB = BB->getBasicBlock(); + ilist::iterator It = BB; + ++It; + + // thisMBB: + // ... + // TrueVal = ... + // cmpTY cr0, r1, r2 + // bCC copy1MBB + // fallthrough --> copy0MBB + BuildMI(BB, PPC::CMPLWI, 2, PPC::CR0).addReg(Tmp1).addImm(0); + MachineBasicBlock *copy0MBB = new MachineBasicBlock(LLVM_BB); + MachineBasicBlock *sinkMBB = new MachineBasicBlock(LLVM_BB); + unsigned TrueValue = SelectExpr(N.getOperand(1)); //Use if TRUE + BuildMI(BB, PPC::BNE, 2).addReg(PPC::CR0).addMBB(sinkMBB); + MachineFunction *F = BB->getParent(); + F->getBasicBlockList().insert(It, copy0MBB); + F->getBasicBlockList().insert(It, sinkMBB); + // Update machine-CFG edges + BB->addSuccessor(copy0MBB); + BB->addSuccessor(sinkMBB); + + // copy0MBB: + // %FalseValue = ... + // # fallthrough to sinkMBB + BB = copy0MBB; + unsigned FalseValue = SelectExpr(N.getOperand(2)); //Use if FALSE + // Update machine-CFG edges + BB->addSuccessor(sinkMBB); + + // sinkMBB: + // %Result = phi [ %FalseValue, copy0MBB ], [ %TrueValue, thisMBB ] + // ... + BB = sinkMBB; + BuildMI(BB, PPC::PHI, 4, Result).addReg(FalseValue) + .addMBB(copy0MBB).addReg(TrueValue).addMBB(thisMBB); + return Result; + } case ISD::FP_ROUND: assert (DestType == MVT::f32 && From lattner at cs.uiuc.edu Tue Mar 29 19:10:16 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 29 Mar 2005 19:10:16 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ISelPattern.cpp Message-ID: <200503300110.j2U1AGMS010462@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ISelPattern.cpp updated: 1.94 -> 1.95 --- Log message: don't depend on the cfg being set up yet --- Diffs of the changes: (+1 -1) X86ISelPattern.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/Target/X86/X86ISelPattern.cpp diff -u llvm/lib/Target/X86/X86ISelPattern.cpp:1.94 llvm/lib/Target/X86/X86ISelPattern.cpp:1.95 --- llvm/lib/Target/X86/X86ISelPattern.cpp:1.94 Fri Mar 25 19:29:23 2005 +++ llvm/lib/Target/X86/X86ISelPattern.cpp Tue Mar 29 19:10:00 2005 @@ -444,7 +444,7 @@ // basic blocks. This will be a huge win, but we are waiting on the global // allocators before we can do this. // - if (ContainsFPCode && BB->succ_size()) { + if (ContainsFPCode) { BuildMI(*BB, BB->getFirstTerminator(), X86::FP_REG_KILL, 0); ++NumFPKill; } From lattner at cs.uiuc.edu Tue Mar 29 19:11:00 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 29 Mar 2005 19:11:00 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <200503300111.j2U1B0Gh010474@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: SelectionDAGISel.cpp updated: 1.35 -> 1.36 --- Log message: Instead of setting up the CFG edges at selectiondag construction time, set them up after the code has been emitted. This allows targets to select one mbb as multiple mbb's as needed. --- Diffs of the changes: (+15 -7) SelectionDAGISel.cpp | 22 +++++++++++++++------- 1 files changed, 15 insertions(+), 7 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.35 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.36 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.35 Tue Mar 29 13:09:56 2005 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Tue Mar 29 19:10:47 2005 @@ -414,7 +414,6 @@ void SelectionDAGLowering::visitBr(BranchInst &I) { // Update machine-CFG edges. MachineBasicBlock *Succ0MBB = FuncInfo.MBBMap[I.getSuccessor(0)]; - CurMBB->addSuccessor(Succ0MBB); // Figure out which block is immediately after the current one. MachineBasicBlock *NextBlock = 0; @@ -429,7 +428,6 @@ DAG.getBasicBlock(Succ0MBB))); } else { MachineBasicBlock *Succ1MBB = FuncInfo.MBBMap[I.getSuccessor(1)]; - CurMBB->addSuccessor(Succ1MBB); SDOperand Cond = getValue(I.getCondition()); @@ -893,7 +891,8 @@ // anything special. if (OldRoot != SDL.DAG.getRoot()) { unsigned a = 0; - for (Function::arg_iterator AI = F.arg_begin(), E = F.arg_end(); AI != E; ++AI,++a) + for (Function::arg_iterator AI = F.arg_begin(), E = F.arg_end(); + AI != E; ++AI,++a) if (!AI->use_empty()) { SDL.setValue(AI, Args[a]); SDOperand Copy = @@ -904,7 +903,8 @@ // Otherwise, if any argument is only accessed in a single basic block, // emit that argument only to that basic block. unsigned a = 0; - for (Function::arg_iterator AI = F.arg_begin(), E = F.arg_end(); AI != E; ++AI,++a) + for (Function::arg_iterator AI = F.arg_begin(), E = F.arg_end(); + AI != E; ++AI,++a) if (!AI->use_empty()) { if (BasicBlock *BBU = IsOnlyUsedInOneBasicBlock(AI)) { FuncInfo.BlockLocalArguments.insert(std::make_pair(BBU, @@ -1058,8 +1058,8 @@ DEBUG(std::cerr << "Legalized selection DAG:\n"); DEBUG(DAG.dump()); - // Finally, instruction select all of the operations to machine code, adding - // the code to the MachineBasicBlock. + // Third, instruction select all of the operations to machine code, adding the + // code to the MachineBasicBlock. InstructionSelectBasicBlock(DAG); if (ViewDAGs) DAG.viewGraph(); @@ -1067,7 +1067,7 @@ DEBUG(std::cerr << "Selected machine code:\n"); DEBUG(BB->dump()); - // Finally, now that we know what the last MBB the LLVM BB expanded is, update + // Next, now that we know what the last MBB the LLVM BB expanded is, update // PHI nodes in successors. for (unsigned i = 0, e = PHINodesToUpdate.size(); i != e; ++i) { MachineInstr *PHI = PHINodesToUpdate[i].first; @@ -1076,4 +1076,12 @@ PHI->addRegOperand(PHINodesToUpdate[i].second); PHI->addMachineBasicBlockOperand(BB); } + + // Finally, add the CFG edges from the last selected MBB to the successor + // MBBs. + TerminatorInst *TI = LLVMBB->getTerminator(); + for (unsigned i = 0, e = TI->getNumSuccessors(); i != e; ++i) { + MachineBasicBlock *Succ0MBB = FuncInfo.MBBMap[TI->getSuccessor(i)]; + BB->addSuccessor(Succ0MBB); + } } From brukman at cs.uiuc.edu Tue Mar 29 19:14:49 2005 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Tue, 29 Mar 2005 19:14:49 -0600 Subject: [llvm-commits] CVS: llvm/docs/CompilerWriterInfo.html Message-ID: <200503300114.TAA14337@zion.cs.uiuc.edu> Changes in directory llvm/docs: CompilerWriterInfo.html updated: 1.3 -> 1.4 --- Log message: * Add section for Alpha * Remove extraneous subsections --- Diffs of the changes: (+13 -9) CompilerWriterInfo.html | 22 +++++++++++++--------- 1 files changed, 13 insertions(+), 9 deletions(-) Index: llvm/docs/CompilerWriterInfo.html diff -u llvm/docs/CompilerWriterInfo.html:1.3 llvm/docs/CompilerWriterInfo.html:1.4 --- llvm/docs/CompilerWriterInfo.html:1.3 Fri Mar 11 15:18:18 2005 +++ llvm/docs/CompilerWriterInfo.html Tue Mar 29 19:14:38 2005 @@ -19,6 +19,7 @@
    1. Hardware
        +
      1. Alpha
      2. ARM
      3. MIPS
      4. PowerPC
      5. @@ -43,10 +44,18 @@ - + - -
        ARM - Official manuals and docs
        +
        + +
        + + +
          @@ -59,17 +68,12 @@ - -
          MIPS - Official manuals and docs
          - @@ -239,7 +243,7 @@ Misha Brukman
          LLVM Compiler Infrastructure
          - Last modified: $Date: 2005/03/11 21:18:18 $ + Last modified: $Date: 2005/03/30 01:14:38 $ From natebegeman at mac.com Tue Mar 29 19:45:54 2005 From: natebegeman at mac.com (Nate Begeman) Date: Tue, 29 Mar 2005 19:45:54 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp PowerPCAsmPrinter.cpp Message-ID: <200503300145.TAA14580@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPC32ISelPattern.cpp updated: 1.17 -> 1.18 PowerPCAsmPrinter.cpp updated: 1.72 -> 1.73 --- Log message: Fix external symbol printing in the AsmPrinter. Tell the ISel that we don't support things like memcpy directly. This allows a handful of the Shootout programs to work, yay! --- Diffs of the changes: (+13 -1) PPC32ISelPattern.cpp | 6 ++++++ PowerPCAsmPrinter.cpp | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) Index: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp diff -u llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.17 llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.18 --- llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.17 Tue Mar 29 16:48:55 2005 +++ llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Tue Mar 29 19:45:43 2005 @@ -47,6 +47,10 @@ addRegisterClass(MVT::f32, PPC32::FPRCRegisterClass); addRegisterClass(MVT::f64, PPC32::FPRCRegisterClass); + setOperationAction(ISD::MEMMOVE, MVT::Other, Expand); + setOperationAction(ISD::MEMSET, MVT::Other, Expand); + setOperationAction(ISD::MEMCPY, MVT::Other, Expand); + computeRegisterProperties(); } @@ -372,6 +376,7 @@ std::pair PPC32TargetLowering:: LowerFrameReturnAddress(bool isFrameAddress, SDOperand Chain, unsigned Depth, SelectionDAG &DAG) { + assert(0 && "LowerFrameReturnAddress unimplemented"); abort(); } @@ -1072,6 +1077,7 @@ case ISD::FP_TO_UINT: case ISD::FP_TO_SINT: + assert(0 && "FP_TO_S/UINT unimplemented"); abort(); case ISD::SETCC: Index: llvm/lib/Target/PowerPC/PowerPCAsmPrinter.cpp diff -u llvm/lib/Target/PowerPC/PowerPCAsmPrinter.cpp:1.72 llvm/lib/Target/PowerPC/PowerPCAsmPrinter.cpp:1.73 --- llvm/lib/Target/PowerPC/PowerPCAsmPrinter.cpp:1.72 Mon Mar 14 22:54:19 2005 +++ llvm/lib/Target/PowerPC/PowerPCAsmPrinter.cpp Tue Mar 29 19:45:43 2005 @@ -349,7 +349,13 @@ return; case MachineOperand::MO_ExternalSymbol: - O << MO.getSymbolName(); + if (IsCallOp) { + std::string Name(GlobalPrefix); Name += MO.getSymbolName(); + FnStubs.insert(Name); + O << "L" << Name << "$stub"; + return; + } + O << GlobalPrefix << MO.getSymbolName(); return; case MachineOperand::MO_GlobalAddress: { From natebegeman at mac.com Tue Mar 29 20:23:19 2005 From: natebegeman at mac.com (Nate Begeman) Date: Tue, 29 Mar 2005 20:23:19 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Message-ID: <200503300223.UAA14884@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPC32ISelPattern.cpp updated: 1.18 -> 1.19 --- Log message: Fix frame index code to generate legal PowerPC instructions. About half of Shootout now works. --- Diffs of the changes: (+7 -9) PPC32ISelPattern.cpp | 16 +++++++--------- 1 files changed, 7 insertions(+), 9 deletions(-) Index: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp diff -u llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.18 llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.19 --- llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.18 Tue Mar 29 19:45:43 2005 +++ llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Tue Mar 29 20:23:08 2005 @@ -612,9 +612,8 @@ } if(Address.getOpcode() == ISD::FrameIndex) { - BuildMI(BB, Opc, 2, Result) - .addFrameIndex(cast(Address)->getIndex()) - .addReg(PPC::R1); + Tmp1 = cast(Address)->getIndex(); + addFrameReference(BuildMI(BB, Opc, 2, Result), (int)Tmp1); } else { int offset; SelectAddr(Address, Tmp1, offset); @@ -730,7 +729,7 @@ case ISD::FrameIndex: Tmp1 = cast(N)->getIndex(); - addFrameReference(BuildMI(BB, PPC::ADDI, 2, Result), (int)Tmp1); + addFrameReference(BuildMI(BB, PPC::ADDI, 2, Result), (int)Tmp1, 0, false); return Result; case ISD::GlobalAddress: { @@ -782,9 +781,8 @@ Tmp3 = 0; // Silence GCC warning. } if(Address.getOpcode() == ISD::FrameIndex) { - BuildMI(BB, Opc, 2, Result) - .addFrameIndex(cast(Address)->getIndex()) - .addReg(PPC::R1); + Tmp1 = cast(Address)->getIndex(); + addFrameReference(BuildMI(BB, Opc, 2, Result), (int)Tmp1); } else { int offset; SelectAddr(Address, Tmp1, offset); @@ -1343,8 +1341,8 @@ } else if(Address.getOpcode() == ISD::FrameIndex) { - BuildMI(BB, Opc, 2).addReg(Tmp1) - .addFrameIndex(cast(Address)->getIndex()); + Tmp2 = cast(Address)->getIndex(); + addFrameReference(BuildMI(BB, Opc, 3).addReg(Tmp1), (int)Tmp2); } else { From duraid at octopus.com.au Tue Mar 29 23:34:05 2005 From: duraid at octopus.com.au (Duraid Madina) Date: Tue, 29 Mar 2005 23:34:05 -0600 Subject: [llvm-commits] CVS: llvm/docs/CompilerWriterInfo.html Message-ID: <200503300534.XAA16146@zion.cs.uiuc.edu> Changes in directory llvm/docs: CompilerWriterInfo.html updated: 1.4 -> 1.5 --- Log message: Add section for Itanium --- Diffs of the changes: (+13 -1) CompilerWriterInfo.html | 14 +++++++++++++- 1 files changed, 13 insertions(+), 1 deletion(-) Index: llvm/docs/CompilerWriterInfo.html diff -u llvm/docs/CompilerWriterInfo.html:1.4 llvm/docs/CompilerWriterInfo.html:1.5 --- llvm/docs/CompilerWriterInfo.html:1.4 Tue Mar 29 19:14:38 2005 +++ llvm/docs/CompilerWriterInfo.html Tue Mar 29 23:33:54 2005 @@ -21,6 +21,7 @@
          1. Alpha
          2. ARM
          3. +
          4. Itanium
          5. MIPS
          6. PowerPC
          7. SPARC
          8. @@ -66,6 +67,17 @@
        + + + + +
        @@ -243,7 +255,7 @@ Misha Brukman
        LLVM Compiler Infrastructure
        - Last modified: $Date: 2005/03/30 01:14:38 $ + Last modified: $Date: 2005/03/30 05:33:54 $ From alenhar2 at cs.uiuc.edu Wed Mar 30 12:23:14 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Wed, 30 Mar 2005 12:23:14 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp Message-ID: <200503301823.j2UINECO015144@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.69 -> 1.70 --- Log message: yea, fine Duraid --- 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.69 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.70 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.69 Tue Mar 29 13:24:04 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Wed Mar 30 12:22:52 2005 @@ -1017,7 +1017,7 @@ dyn_cast(N.getOperand(1))) { AlphaLowering.restoreGP(BB); - BuildMI(BB, Alpha::CALL, 0).addExternalSymbol(ESSDN->getSymbol(), true); + BuildMI(BB, Alpha::CALL, 1).addExternalSymbol(ESSDN->getSymbol(), true); } else { //no need to restore GP as we are doing an indirect call Tmp1 = SelectExpr(N.getOperand(1)); From brukman at cs.uiuc.edu Wed Mar 30 13:14:35 2005 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Wed, 30 Mar 2005 13:14:35 -0600 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200503301914.NAA16069@zion.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.306 -> 1.307 --- Log message: * Put command-line switches and function names in * Add links to mailing lists and publications --- Diffs of the changes: (+11 -10) ReleaseNotes.html | 21 +++++++++++---------- 1 files changed, 11 insertions(+), 10 deletions(-) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.306 llvm/docs/ReleaseNotes.html:1.307 --- llvm/docs/ReleaseNotes.html:1.306 Thu Mar 17 18:48:56 2005 +++ llvm/docs/ReleaseNotes.html Wed Mar 30 13:14:24 2005 @@ -240,8 +240,8 @@ releases: -cee, -branch-combine, -instloops, -paths, -pre
      6. The llvm-db tool is in a very early stage of development, but can be used to step through programs and inspect the stack.
      7. -
      8. The "iterative scan" register allocator (enabled with -regalloc=iterativescan) - is not stable.
      9. +
      10. The "iterative scan" register allocator (enabled with + -regalloc=iterativescan) is not stable.
      11. The SparcV8, Alpha, and IA64 ports are experimental.
      12. @@ -255,8 +255,8 @@
          -
        • In the JIT, dlsym on a symbol compiled by the JIT will not work. -
        • +
        • In the JIT, dlsym() on a symbol compiled by the JIT will not + work.
        • The JIT does not use mutexes to protect its internal data structures. As such, execution of a threaded program could cause these data structures to be corrupted. @@ -575,11 +575,12 @@

          A wide variety of additional information is available on the LLVM web page, -including mailing lists and publications describing algorithms and components -implemented in LLVM. The web page also contains versions of the API -documentation which is up-to-date with the CVS version of the source code. You -can access versions of these documents specific to this release by going into -the "llvm/doc/" directory in the LLVM tree.

          +including mailing lists and +publications describing algorithms and +components implemented in LLVM. The web page also contains versions of the +API documentation which is up-to-date with the CVS version of the source code. +You can access versions of these documents specific to this release by going +into the "llvm/doc/" directory in the LLVM tree.

          If you have any questions or comments about LLVM, please feel free to contact us via the mailing @@ -597,7 +598,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
          - Last modified: $Date: 2005/03/18 00:48:56 $ + Last modified: $Date: 2005/03/30 19:14:24 $ From natebegeman at mac.com Wed Mar 30 13:38:46 2005 From: natebegeman at mac.com (Nate Begeman) Date: Wed, 30 Mar 2005 13:38:46 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp PPC32ISelSimple.cpp Message-ID: <200503301938.NAA16421@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPC32ISelPattern.cpp updated: 1.19 -> 1.20 PPC32ISelSimple.cpp updated: 1.131 -> 1.132 --- Log message: Fix calls whose arguments fit entirely in registers to not break the Chain. Implement SINT_TO_FP and UINT_TO_FP Remove some dead code from the simple ISel --- Diffs of the changes: (+51 -8) PPC32ISelPattern.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++++++---- PPC32ISelSimple.cpp | 4 --- 2 files changed, 51 insertions(+), 8 deletions(-) Index: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp diff -u llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.19 llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.20 --- llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.19 Tue Mar 29 20:23:08 2005 +++ llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Wed Mar 30 13:38:35 2005 @@ -327,7 +327,8 @@ break; } } - Chain = DAG.getNode(ISD::TokenFactor, MVT::Other, Stores); + if (!Stores.empty()) + Chain = DAG.getNode(ISD::TokenFactor, MVT::Other, Stores); } std::vector RetVals; @@ -642,9 +643,55 @@ return Result; case ISD::UINT_TO_FP: - case ISD::SINT_TO_FP: - assert(0 && "ISD::U/SINT_TO_FP Unimplemented"); - abort(); + case ISD::SINT_TO_FP: { + assert (N.getOperand(0).getValueType() == MVT::i32 + && "int to float must operate on i32"); + bool IsUnsigned = (ISD::UINT_TO_FP == opcode); + Tmp1 = SelectExpr(N.getOperand(0)); // Get the operand register + Tmp2 = MakeReg(MVT::f64); // temp reg to load the integer value into + Tmp3 = MakeReg(MVT::i32); // temp reg to hold the conversion constant + unsigned ConstF = MakeReg(MVT::f64); // temp reg to hold the fp constant + + int FrameIdx = BB->getParent()->getFrameInfo()->CreateStackObject(8, 8); + MachineConstantPool *CP = BB->getParent()->getConstantPool(); + + // FIXME: pull this FP constant generation stuff out into something like + // the simple ISel's getReg. + if (IsUnsigned) { + ConstantFP *CFP = ConstantFP::get(Type::DoubleTy, 0x1.000000p52); + unsigned CPI = CP->getConstantPoolIndex(CFP); + // Load constant fp value + unsigned Tmp4 = MakeReg(MVT::i32); + BuildMI(BB, PPC::LOADHiAddr, 2, Tmp4).addReg(getGlobalBaseReg()) + .addConstantPoolIndex(CPI); + BuildMI(BB, PPC::LFD, 2, ConstF).addConstantPoolIndex(CPI).addReg(Tmp4); + // Store the hi & low halves of the fp value, currently in int regs + BuildMI(BB, PPC::LIS, 1, Tmp3).addSImm(0x4330); + addFrameReference(BuildMI(BB, PPC::STW, 3).addReg(Tmp3), FrameIdx); + addFrameReference(BuildMI(BB, PPC::STW, 3).addReg(Tmp1), FrameIdx, 4); + addFrameReference(BuildMI(BB, PPC::LFD, 2, Tmp2), FrameIdx); + // Generate the return value with a subtract + BuildMI(BB, PPC::FSUB, 2, Result).addReg(Tmp2).addReg(ConstF); + } else { + ConstantFP *CFP = ConstantFP::get(Type::DoubleTy, 0x1.000008p52); + unsigned CPI = CP->getConstantPoolIndex(CFP); + // Load constant fp value + unsigned Tmp4 = MakeReg(MVT::i32); + unsigned TmpL = MakeReg(MVT::i32); + BuildMI(BB, PPC::LOADHiAddr, 2, Tmp4).addReg(getGlobalBaseReg()) + .addConstantPoolIndex(CPI); + BuildMI(BB, PPC::LFD, 2, ConstF).addConstantPoolIndex(CPI).addReg(Tmp4); + // Store the hi & low halves of the fp value, currently in int regs + BuildMI(BB, PPC::LIS, 1, Tmp3).addSImm(0x4330); + addFrameReference(BuildMI(BB, PPC::STW, 3).addReg(Tmp3), FrameIdx); + BuildMI(BB, PPC::XORIS, 2, TmpL).addReg(Tmp1).addImm(0x8000); + addFrameReference(BuildMI(BB, PPC::STW, 3).addReg(TmpL), FrameIdx, 4); + addFrameReference(BuildMI(BB, PPC::LFD, 2, Tmp2), FrameIdx); + // Generate the return value with a subtract + BuildMI(BB, PPC::FSUB, 2, Result).addReg(Tmp2).addReg(ConstF); + } + return Result; + } } assert(0 && "should not get here"); return 0; Index: llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp diff -u llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp:1.131 llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp:1.132 --- llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp:1.131 Mon Mar 28 17:08:54 2005 +++ llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp Wed Mar 30 13:38:35 2005 @@ -683,7 +683,6 @@ assert(Ty == Type::FloatTy || Ty == Type::DoubleTy && "Unknown FP type!"); // Load addr of constant to reg; constant is located at base + distance - unsigned GlobalBase = makeAnotherReg(Type::IntTy); unsigned Reg1 = makeAnotherReg(Type::IntTy); unsigned Opcode = (Ty == Type::FloatTy) ? PPC::LFS : PPC::LFD; // Move value at base + distance into return reg @@ -695,8 +694,6 @@ BuildMI(*MBB, IP, PPC::LI, 1, R).addSImm(0); } else if (GlobalValue *GV = dyn_cast(C)) { // GV is located at base + distance - - unsigned GlobalBase = makeAnotherReg(Type::IntTy); unsigned TmpReg = makeAnotherReg(GV->getType()); // Move value at base + distance into return reg @@ -3337,7 +3334,6 @@ int ValueFrameIdx = F->getFrameInfo()->CreateStackObject(Type::DoubleTy, TM.getTargetData()); - MachineConstantPool *CP = F->getConstantPool(); unsigned constantHi = makeAnotherReg(Type::IntTy); unsigned TempF = makeAnotherReg(Type::DoubleTy); From natebegeman at mac.com Wed Mar 30 18:15:37 2005 From: natebegeman at mac.com (Nate Begeman) Date: Wed, 30 Mar 2005 18:15:37 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Message-ID: <200503310015.SAA20227@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPC32ISelPattern.cpp updated: 1.20 -> 1.21 --- Log message: Rewrite LowerCallTo and Select(ISD::CALL) to properly handle float varargs Tell the SelectionDAG ISel to expand SEXTLOAD of i1 and i8, rather than complicate the code in ISD::SEXTLOAD to do it by hand Combine the FP and Int ISD::LOAD codegen Generate better code for constant pool loads As a result, all of Shootout, and likely many other programs are now working. --- Diffs of the changes: (+82 -135) PPC32ISelPattern.cpp | 217 +++++++++++++++++++-------------------------------- 1 files changed, 82 insertions(+), 135 deletions(-) Index: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp diff -u llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.20 llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.21 --- llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.20 Wed Mar 30 13:38:35 2005 +++ llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Wed Mar 30 18:15:26 2005 @@ -40,17 +40,20 @@ int ReturnAddrIndex; // FrameIndex for return slot. public: PPC32TargetLowering(TargetMachine &TM) : TargetLowering(TM) { - // Set up the TargetLowering object. - // Set up the register classes. addRegisterClass(MVT::i32, PPC32::GPRCRegisterClass); addRegisterClass(MVT::f32, PPC32::FPRCRegisterClass); addRegisterClass(MVT::f64, PPC32::FPRCRegisterClass); + // PowerPC has no intrinsics for these particular operations setOperationAction(ISD::MEMMOVE, MVT::Other, Expand); setOperationAction(ISD::MEMSET, MVT::Other, Expand); setOperationAction(ISD::MEMCPY, MVT::Other, Expand); + // PowerPC has an i16 but no i8 (or i1) SEXTLOAD + setOperationAction(ISD::SEXTLOAD, MVT::i1, Expand); + setOperationAction(ISD::SEXTLOAD, MVT::i8, Expand); + computeRegisterProperties(); } @@ -244,7 +247,17 @@ unsigned ArgOffset = 24; unsigned GPR_remaining = 8; unsigned FPR_remaining = 13; - std::vector Stores; + unsigned GPR_idx = 0, FPR_idx = 0; + static const unsigned GPR[] = { + PPC::R3, PPC::R4, PPC::R5, PPC::R6, + PPC::R7, PPC::R8, PPC::R9, PPC::R10, + }; + static const unsigned FPR[] = { + PPC::F1, PPC::F2, PPC::F3, PPC::F4, PPC::F5, PPC::F6, PPC::F7, + PPC::F8, PPC::F9, PPC::F10, PPC::F11, PPC::F12, PPC::F13 + }; + + std::vector MemOps; for (unsigned i = 0, e = Args.size(); i != e; ++i) { // PtrOff will be used to store the current argument to the stack if a // register cannot be found for it. @@ -266,11 +279,13 @@ // FALL THROUGH case MVT::i32: if (GPR_remaining > 0) { - args_to_use.push_back(Args[i].first); + args_to_use.push_back(DAG.getCopyToReg(Chain, Args[i].first, + GPR[GPR_idx])); --GPR_remaining; + ++GPR_idx; } else { - Stores.push_back(DAG.getNode(ISD::STORE, MVT::Other, Chain, - Args[i].first, PtrOff)); + MemOps.push_back(DAG.getNode(ISD::STORE, MVT::Other, Chain, + Args[i].first, PtrOff)); } ArgOffset += 4; break; @@ -283,20 +298,22 @@ Args[i].first, DAG.getConstant(1, MVT::i32)); SDOperand Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, MVT::i32, Args[i].first, DAG.getConstant(0, MVT::i32)); - args_to_use.push_back(Hi); - if (GPR_remaining > 1) { - args_to_use.push_back(Lo); - GPR_remaining -= 2; + args_to_use.push_back(DAG.getCopyToReg(Chain, Hi, GPR[GPR_idx])); + --GPR_remaining; + ++GPR_idx; + if (GPR_remaining > 0) { + args_to_use.push_back(DAG.getCopyToReg(Chain, Lo, GPR[GPR_idx])); + --GPR_remaining; + ++GPR_idx; } else { SDOperand ConstFour = DAG.getConstant(4, getPointerTy()); PtrOff = DAG.getNode(ISD::ADD, MVT::i32, PtrOff, ConstFour); - Stores.push_back(DAG.getNode(ISD::STORE, MVT::Other, Chain, - Lo, PtrOff)); - --GPR_remaining; + MemOps.push_back(DAG.getNode(ISD::STORE, MVT::Other, Chain, + Lo, PtrOff)); } } else { - Stores.push_back(DAG.getNode(ISD::STORE, MVT::Other, Chain, - Args[i].first, PtrOff)); + MemOps.push_back(DAG.getNode(ISD::STORE, MVT::Other, Chain, + Args[i].first, PtrOff)); } ArgOffset += 8; break; @@ -304,31 +321,49 @@ case MVT::f64: if (FPR_remaining > 0) { if (isVarArg) { - // FIXME: Need FunctionType information so we can conditionally - // store only the non-fixed arguments in a vararg function. - Stores.push_back(DAG.getNode(ISD::STORE, MVT::Other, Chain, - Args[i].first, PtrOff)); - // FIXME: Need a way to communicate to the ISD::CALL select code - // that a particular argument is non-fixed so that we can load them - // into the correct GPR to shadow the FPR + MemOps.push_back(DAG.getNode(ISD::STORE, MVT::Other, Chain, + Args[i].first, PtrOff)); + // Float varargs are always shadowed in available integer registers + if (GPR_remaining > 0) { + SDOperand Load = DAG.getLoad(MVT::i32, Chain, PtrOff); + MemOps.push_back(Load); + args_to_use.push_back(DAG.getCopyToReg(Chain, Load, + GPR[GPR_idx])); + } + if (GPR_remaining > 1 && MVT::f64 == ArgVT) { + SDOperand ConstFour = DAG.getConstant(4, getPointerTy()); + PtrOff = DAG.getNode(ISD::ADD, MVT::i32, PtrOff, ConstFour); + SDOperand Load = DAG.getLoad(MVT::i32, Chain, PtrOff); + MemOps.push_back(Load); + args_to_use.push_back(DAG.getCopyToReg(Chain, Load, + GPR[GPR_idx+1])); + } } - args_to_use.push_back(Args[i].first); + args_to_use.push_back(DAG.getCopyToReg(Chain, Args[i].first, + FPR[FPR_idx])); --FPR_remaining; + ++FPR_idx; // If we have any FPRs remaining, we may also have GPRs remaining. // Args passed in FPRs consume either 1 (f32) or 2 (f64) available // GPRs. - if (GPR_remaining > 0) --GPR_remaining; - if (GPR_remaining > 0 && MVT::f64 == ArgVT) --GPR_remaining; + if (GPR_remaining > 0) { + --GPR_remaining; + ++GPR_idx; + } + if (GPR_remaining > 0 && MVT::f64 == ArgVT) { + --GPR_remaining; + ++GPR_idx; + } } else { - Stores.push_back(DAG.getNode(ISD::STORE, MVT::Other, Chain, - Args[i].first, PtrOff)); + MemOps.push_back(DAG.getNode(ISD::STORE, MVT::Other, Chain, + Args[i].first, PtrOff)); } ArgOffset += (ArgVT == MVT::f32) ? 4 : 8; break; } } - if (!Stores.empty()) - Chain = DAG.getNode(ISD::TokenFactor, MVT::Other, Stores); + if (!MemOps.empty()) + Chain = DAG.getNode(ISD::TokenFactor, MVT::Other, MemOps); } std::vector RetVals; @@ -591,38 +626,6 @@ BuildMI(BB, PPC::FMR, 1, Result).addReg(Tmp1); return Result; - case ISD::LOAD: - case ISD::EXTLOAD: { - MVT::ValueType TypeBeingLoaded = (ISD::LOAD == opcode) ? - Node->getValueType(0) : cast(Node)->getExtraValueType(); - - // Make sure we generate both values. - if (Result != 1) - ExprMap[N.getValue(1)] = 1; // Generate the token - else - Result = ExprMap[N.getValue(0)] = MakeReg(N.getValue(0).getValueType()); - - SDOperand Chain = N.getOperand(0); - SDOperand Address = N.getOperand(1); - Select(Chain); - - switch (TypeBeingLoaded) { - default: assert(0 && "Cannot fp load this type!"); - case MVT::f32: Opc = PPC::LFS; break; - case MVT::f64: Opc = PPC::LFD; break; - } - - if(Address.getOpcode() == ISD::FrameIndex) { - Tmp1 = cast(Address)->getIndex(); - addFrameReference(BuildMI(BB, Opc, 2, Result), (int)Tmp1); - } else { - int offset; - SelectAddr(Address, Tmp1, offset); - BuildMI(BB, Opc, 2, Result).addSImm(offset).addReg(Tmp1); - } - return Result; - } - case ISD::ConstantFP: assert(0 && "ISD::ConstantFP Unimplemented"); abort(); @@ -735,7 +738,8 @@ } if (DestType == MVT::f64 || DestType == MVT::f32) - return SelectExprFP(N, Result); + if (ISD::LOAD != opcode && ISD::EXTLOAD != opcode) + return SelectExprFP(N, Result); switch (opcode) { default: @@ -796,11 +800,11 @@ case ISD::EXTLOAD: case ISD::ZEXTLOAD: case ISD::SEXTLOAD: { - bool sext = (ISD::SEXTLOAD == opcode); - bool byte = (MVT::i8 == Node->getValueType(0)); MVT::ValueType TypeBeingLoaded = (ISD::LOAD == opcode) ? Node->getValueType(0) : cast(Node)->getExtraValueType(); - + bool sext = (ISD::SEXTLOAD == opcode); + bool byte = (MVT::i8 == TypeBeingLoaded); + // Make sure we generate both values. if (Result != 1) ExprMap[N.getValue(1)] = 1; // Generate the token @@ -812,22 +816,23 @@ Select(Chain); switch (TypeBeingLoaded) { - default: assert(0 && "Cannot load this type!"); + default: Node->dump(); assert(0 && "Cannot load this type!"); case MVT::i1: Opc = PPC::LBZ; break; case MVT::i8: Opc = PPC::LBZ; break; case MVT::i16: Opc = sext ? PPC::LHA : PPC::LHZ; break; case MVT::i32: Opc = PPC::LWZ; break; + case MVT::f32: Opc = PPC::LFS; break; + case MVT::f64: Opc = PPC::LFD; break; } - // Since there's no load byte & sign extend instruction we have to split - // byte SEXTLOADs into lbz + extsb. This requires we make a temp register. - if (sext && byte) { - Tmp3 = Result; - Result = MakeReg(MVT::i32); - } else { - Tmp3 = 0; // Silence GCC warning. + if (ConstantPoolSDNode *CP = dyn_cast(Address)) { + Tmp1 = MakeReg(MVT::i32); + int CPI = CP->getIndex(); + BuildMI(BB, PPC::LOADHiAddr, 2, Tmp1).addReg(getGlobalBaseReg()) + .addConstantPoolIndex(CPI); + BuildMI(BB, Opc, 2, Result).addConstantPoolIndex(CPI).addReg(Tmp1); } - if(Address.getOpcode() == ISD::FrameIndex) { + else if(Address.getOpcode() == ISD::FrameIndex) { Tmp1 = cast(Address)->getIndex(); addFrameReference(BuildMI(BB, Opc, 2, Result), (int)Tmp1); } else { @@ -835,10 +840,6 @@ SelectAddr(Address, Tmp1, offset); BuildMI(BB, Opc, 2, Result).addSImm(offset).addReg(Tmp1); } - if (sext && byte) { - BuildMI(BB, PPC::EXTSB, 1, Tmp3).addReg(Result); - Result = Tmp3; - } return Result; } @@ -846,64 +847,10 @@ // Lower the chain for this call. Select(N.getOperand(0)); ExprMap[N.getValue(Node->getNumValues()-1)] = 1; - - // get the virtual reg for each argument - std::vector VRegs; - for(int i = 2, e = Node->getNumOperands(); i < e; ++i) - VRegs.push_back(SelectExpr(N.getOperand(i))); - - // The ABI specifies that the first 32 bytes of args may be passed in GPRs, - // and that 13 FPRs may also be used for passing any floating point args. - int GPR_remaining = 8, FPR_remaining = 13; - unsigned GPR_idx = 0, FPR_idx = 0; - static const unsigned GPR[] = { - PPC::R3, PPC::R4, PPC::R5, PPC::R6, - PPC::R7, PPC::R8, PPC::R9, PPC::R10, - }; - static const unsigned FPR[] = { - PPC::F1, PPC::F2, PPC::F3, PPC::F4, PPC::F5, PPC::F6, - PPC::F7, PPC::F8, PPC::F9, PPC::F10, PPC::F11, PPC::F12, - PPC::F13 - }; - - // move the vregs into the appropriate architected register or stack slot - for(int i = 0, e = VRegs.size(); i < e; ++i) { - unsigned OperandType = N.getOperand(i+2).getValueType(); - switch(OperandType) { - 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: - if (GPR_remaining > 0) - BuildMI(BB, PPC::OR, 2, GPR[GPR_idx]).addReg(VRegs[i]) - .addReg(VRegs[i]); - break; - case MVT::f32: - case MVT::f64: - if (FPR_remaining > 0) { - BuildMI(BB, PPC::FMR, 1, FPR[FPR_idx]).addReg(VRegs[i]); - ++FPR_idx; - --FPR_remaining; - } - break; - } - // All arguments consume GPRs available for argument passing - if (GPR_remaining > 0) { - ++GPR_idx; - --GPR_remaining; - } - if (MVT::f64 == OperandType && GPR_remaining > 0) { - ++GPR_idx; - --GPR_remaining; - } - } + for(int i = 2, e = Node->getNumOperands(); i < e; ++i) + Select(N.getOperand(i)); + // Emit the correct call instruction based on the type of symbol called. if (GlobalAddressSDNode *GASD = dyn_cast(N.getOperand(1))) { From natebegeman at mac.com Wed Mar 30 20:06:03 2005 From: natebegeman at mac.com (Nate Begeman) Date: Wed, 30 Mar 2005 20:06:03 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Message-ID: <200503310206.UAA20718@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPC32ISelPattern.cpp updated: 1.21 -> 1.22 --- Log message: Pass the correct values to the chain argument for node construction during LowerCallTo. Handle ISD::ADD in SelectAddr, allowing us to have nonzero immediates for loads and stores, amazing! --- Diffs of the changes: (+14 -6) PPC32ISelPattern.cpp | 20 ++++++++++++++------ 1 files changed, 14 insertions(+), 6 deletions(-) Index: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp diff -u llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.21 llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.22 --- llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.21 Wed Mar 30 18:15:26 2005 +++ llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Wed Mar 30 20:05:53 2005 @@ -321,21 +321,22 @@ case MVT::f64: if (FPR_remaining > 0) { if (isVarArg) { - MemOps.push_back(DAG.getNode(ISD::STORE, MVT::Other, Chain, - Args[i].first, PtrOff)); + SDOperand Store = DAG.getNode(ISD::STORE, MVT::Other, Chain, + Args[i].first, PtrOff); + MemOps.push_back(Store); // Float varargs are always shadowed in available integer registers if (GPR_remaining > 0) { - SDOperand Load = DAG.getLoad(MVT::i32, Chain, PtrOff); + SDOperand Load = DAG.getLoad(MVT::i32, Store, PtrOff); MemOps.push_back(Load); - args_to_use.push_back(DAG.getCopyToReg(Chain, Load, + args_to_use.push_back(DAG.getCopyToReg(Load, Load, GPR[GPR_idx])); } if (GPR_remaining > 1 && MVT::f64 == ArgVT) { SDOperand ConstFour = DAG.getConstant(4, getPointerTy()); PtrOff = DAG.getNode(ISD::ADD, MVT::i32, PtrOff, ConstFour); - SDOperand Load = DAG.getLoad(MVT::i32, Chain, PtrOff); + SDOperand Load = DAG.getLoad(MVT::i32, Store, PtrOff); MemOps.push_back(Load); - args_to_use.push_back(DAG.getCopyToReg(Chain, Load, + args_to_use.push_back(DAG.getCopyToReg(Load, Load, GPR[GPR_idx+1])); } } @@ -521,6 +522,13 @@ //Check to see if the load is a constant offset from a base register void ISel::SelectAddr(SDOperand N, unsigned& Reg, int& offset) { + unsigned imm = 0, opcode = N.getOpcode(); + if (N.getOpcode() == ISD::ADD) + if (1 == canUseAsImmediateForOpcode(N.getOperand(1), opcode, imm)) { + Reg = SelectExpr(N.getOperand(0)); + offset = imm; + return; + } Reg = SelectExpr(N); offset = 0; return; From alkis at cs.uiuc.edu Wed Mar 30 21:15:19 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed, 30 Mar 2005 21:15:19 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMField.h VMField.cpp VMClass.cpp Message-ID: <200503310315.VAA21160@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMField.h updated: 1.3 -> 1.4 VMField.cpp updated: 1.4 -> 1.5 VMClass.cpp updated: 1.25 -> 1.26 --- Log message: Remove unneeded parameters from VMField constructors. --- Diffs of the changes: (+20 -25) VMClass.cpp | 16 +++++++--------- VMField.cpp | 15 +++++++++++---- VMField.h | 14 ++------------ 3 files changed, 20 insertions(+), 25 deletions(-) Index: llvm-java/lib/Compiler/VMField.h diff -u llvm-java/lib/Compiler/VMField.h:1.3 llvm-java/lib/Compiler/VMField.h:1.4 --- llvm-java/lib/Compiler/VMField.h:1.3 Tue Mar 29 11:11:39 2005 +++ llvm-java/lib/Compiler/VMField.h Wed Mar 30 21:15:08 2005 @@ -40,20 +40,10 @@ // Interface for VMClass. // Create static field reference. - VMField(const VMClass* parent, const VMClass* clazz, const Field* field); + VMField(const VMClass* parent, const Field* field); // Create member field reference. - VMField(const VMClass* parent, - const VMClass* clazz, - const Field* field, - int index) - : parent_(parent), - class_(clazz), - field_(field) { - assert(!isStatic() && "This should be a member field!"); - data_.index = index; - } - + VMField(const VMClass* parent, const Field* field, int index); public: const std::string& getName() const { return field_->getName()->str(); } Index: llvm-java/lib/Compiler/VMField.cpp diff -u llvm-java/lib/Compiler/VMField.cpp:1.4 llvm-java/lib/Compiler/VMField.cpp:1.5 --- llvm-java/lib/Compiler/VMField.cpp:1.4 Tue Mar 29 11:37:08 2005 +++ llvm-java/lib/Compiler/VMField.cpp Wed Mar 30 21:15:08 2005 @@ -20,11 +20,9 @@ using namespace llvm; using namespace llvm::Java; -VMField::VMField(const VMClass* parent, - const VMClass* clazz, - const Field* field) +VMField::VMField(const VMClass* parent, const Field* field) : parent_(parent), - class_(clazz), + class_(parent->getClass(field->getDescriptorIndex())), field_(field) { assert(isStatic() && "This should be a static field!"); @@ -49,3 +47,12 @@ parent_->getName() + '/' + getName(), parent_->getResolver()->getModule()); } + +VMField::VMField(const VMClass* parent, const Field* field, int index) + : parent_(parent), + class_(parent->getClass(field->getDescriptorIndex())), + field_(field) +{ + assert(!isStatic() && "This should be a member field!"); + data_.index = index; +} Index: llvm-java/lib/Compiler/VMClass.cpp diff -u llvm-java/lib/Compiler/VMClass.cpp:1.25 llvm-java/lib/Compiler/VMClass.cpp:1.26 --- llvm-java/lib/Compiler/VMClass.cpp:1.25 Tue Mar 29 11:37:08 2005 +++ llvm-java/lib/Compiler/VMClass.cpp Wed Mar 30 21:15:08 2005 @@ -119,19 +119,17 @@ const Fields& fields = classFile_->getFields(); for (unsigned i = 0, e = fields.size(); i != e; ++i) { Field* field = fields[i]; - const VMClass* fc = getClass(field->getDescriptorIndex()); + const std::string& name = field->getName()->str(); if (field->isStatic()) { - fieldMap_.insert(std::make_pair(field->getName()->str(), - VMField(this, fc, field))); + fieldMap_.insert(std::make_pair(name, VMField(this, field))); } else { unsigned index = memberFields_.size() + 1; - FieldMap::iterator i = - fieldMap_.insert(std::make_pair( - field->getName()->str(), - VMField(this, fc, field, index))).first; - memberFields_.push_back(&i->second); - layout.push_back(fc->getType()); + FieldMap::iterator i = fieldMap_.insert( + std::make_pair(name, VMField(this, field, index))).first; + const VMField* vmf = &i->second; + memberFields_.push_back(vmf); + layout.push_back(vmf->getClass()->getType()); } } } From alkis at cs.uiuc.edu Wed Mar 30 21:19:39 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed, 30 Mar 2005 21:19:39 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMClass.h VMClass.cpp Message-ID: <200503310319.VAA21205@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMClass.h updated: 1.22 -> 1.23 VMClass.cpp updated: 1.26 -> 1.27 --- Log message: Remove dead function. --- Diffs of the changes: (+0 -6) VMClass.cpp | 5 ----- VMClass.h | 1 - 2 files changed, 6 deletions(-) Index: llvm-java/lib/Compiler/VMClass.h diff -u llvm-java/lib/Compiler/VMClass.h:1.22 llvm-java/lib/Compiler/VMClass.h:1.23 --- llvm-java/lib/Compiler/VMClass.h:1.22 Tue Mar 29 11:37:08 2005 +++ llvm-java/lib/Compiler/VMClass.h Wed Mar 30 21:19:27 2005 @@ -86,7 +86,6 @@ bool isPrimitive() const { return getType() == getLayoutType(); } bool isInterface() const { return classFile_ && classFile_->isInterface(); } unsigned getInterfaceIndex() const { return interfaceIndex_; } - int getFieldIndex(const std::string& name) const; llvm::Constant* getConstant(unsigned index) const; const VMClass* getClass(unsigned index) const; Index: llvm-java/lib/Compiler/VMClass.cpp diff -u llvm-java/lib/Compiler/VMClass.cpp:1.26 llvm-java/lib/Compiler/VMClass.cpp:1.27 --- llvm-java/lib/Compiler/VMClass.cpp:1.26 Wed Mar 30 21:15:08 2005 +++ llvm-java/lib/Compiler/VMClass.cpp Wed Mar 30 21:19:27 2005 @@ -93,11 +93,6 @@ return NULL; } -int VMClass::getFieldIndex(const std::string& name) const { - FieldMap::const_iterator it = fieldMap_.find(name); - return it == fieldMap_.end() ? -1 : it->second.getMemberIndex(); -} - void VMClass::computeLayout() { std::vector layout; if (isArray()) { From alkis at cs.uiuc.edu Wed Mar 30 21:23:09 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed, 30 Mar 2005 21:23:09 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMClass.cpp Message-ID: <200503310323.VAA21257@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMClass.cpp updated: 1.27 -> 1.28 --- Log message: Indentation fix. --- Diffs of the changes: (+2 -1) VMClass.cpp | 3 ++- 1 files changed, 2 insertions(+), 1 deletion(-) Index: llvm-java/lib/Compiler/VMClass.cpp diff -u llvm-java/lib/Compiler/VMClass.cpp:1.27 llvm-java/lib/Compiler/VMClass.cpp:1.28 --- llvm-java/lib/Compiler/VMClass.cpp:1.27 Wed Mar 30 21:19:27 2005 +++ llvm-java/lib/Compiler/VMClass.cpp Wed Mar 30 21:22:58 2005 @@ -93,7 +93,8 @@ return NULL; } -void VMClass::computeLayout() { +void VMClass::computeLayout() +{ std::vector layout; if (isArray()) { layout.reserve(3); From alkis at cs.uiuc.edu Wed Mar 30 23:08:58 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed, 30 Mar 2005 23:08:58 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200503310508.XAA22023@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.267 -> 1.268 --- Log message: Fix bug introduced in previous commit. --- Diffs of the changes: (+2 -0) Compiler.cpp | 2 ++ 1 files changed, 2 insertions(+) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.267 llvm-java/lib/Compiler/Compiler.cpp:1.268 --- llvm-java/lib/Compiler/Compiler.cpp:1.267 Tue Mar 29 11:37:08 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Wed Mar 30 23:08:47 2005 @@ -1487,6 +1487,7 @@ void do_getstatic(unsigned index) { const VMField* field = class_->getField(index); + emitStaticInitializers(field->getParent()->getClassFile()); Value* v = new LoadInst(field->getGlobal(), TMP, currentBB_); push(v); @@ -1494,6 +1495,7 @@ void do_putstatic(unsigned index) { const VMField* field = class_->getField(index); + emitStaticInitializers(field->getParent()->getClassFile()); Value* v = pop(field->getClass()->getType()); new StoreInst(v, field->getGlobal(), currentBB_); From alkis at cs.uiuc.edu Wed Mar 30 23:10:40 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed, 30 Mar 2005 23:10:40 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMMethod.h VMMethod.cpp VMClass.h VMClass.cpp Compiler.cpp Message-ID: <200503310510.XAA22063@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMMethod.h added (r1.1) VMMethod.cpp added (r1.1) VMClass.h updated: 1.23 -> 1.24 VMClass.cpp updated: 1.28 -> 1.29 Compiler.cpp updated: 1.268 -> 1.269 --- Log message: Add VMMethod class. This class will behave for methods like VMField does for fields This allows for the complete resolution of the constant pool table and eventually will aid with the removal of the VTableInfo class from Compiler. --- Diffs of the changes: (+184 -67) Compiler.cpp | 87 ++++++++++++++--------------------------------------------- VMClass.cpp | 63 ++++++++++++++++++++++++++++++++++++++++++ VMClass.h | 8 ++++- VMMethod.cpp | 39 ++++++++++++++++++++++++++ VMMethod.h | 54 ++++++++++++++++++++++++++++++++++++ 5 files changed, 184 insertions(+), 67 deletions(-) Index: llvm-java/lib/Compiler/VMMethod.h diff -c /dev/null llvm-java/lib/Compiler/VMMethod.h:1.1 *** /dev/null Wed Mar 30 23:10:39 2005 --- llvm-java/lib/Compiler/VMMethod.h Wed Mar 30 23:10:29 2005 *************** *** 0 **** --- 1,54 ---- + //===-- VMMethod.h - Compiler representation of a Java method ---*- C++ -*-===// + // + // 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 contains the declaration of the Method class that represents a + // compile time representation of a Java class method (java.lang.Method). + // + //===----------------------------------------------------------------------===// + + #ifndef LLVM_JAVA_VMMETHOD_H + #define LLVM_JAVA_VMMETHOD_H + + #include + + namespace llvm { + + class Function; + class FunctionType; + + } + + namespace llvm { namespace Java { + + class VMClass; + + class VMMethod { + const VMClass* parent_; + const Method* method_; + Function* function_; + + friend class VMClass; + // Interface for VMClass. + + // Create statically bound method reference. + VMMethod(const VMClass* parent, const Method* method); + + public: + const VMClass* getParent() const { return parent_; } + Function* getFunction() const { return function_; } + + // FIXME: remove when transition is complete. + std::string getNameAndDescriptor() const { + return method_->getName()->str() + method_->getDescriptor()->str(); + } + }; + + } } // namespace llvm::Java + + #endif//LLVM_JAVA_VMMETHOD_H Index: llvm-java/lib/Compiler/VMMethod.cpp diff -c /dev/null llvm-java/lib/Compiler/VMMethod.cpp:1.1 *** /dev/null Wed Mar 30 23:10:40 2005 --- llvm-java/lib/Compiler/VMMethod.cpp Wed Mar 30 23:10:29 2005 *************** *** 0 **** --- 1,39 ---- + //===-- VMMethod.cpp - Compiler representation of a Java method -*- C++ -*-===// + // + // 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 contains the implementation of the Method class that represents a + // compile time representation of a Java class method (java.lang.Method). + // + //===----------------------------------------------------------------------===// + + #include "VMMethod.h" + #include "Resolver.h" + #include "VMClass.h" + #include + #include + + using namespace llvm; + using namespace llvm::Java; + + VMMethod::VMMethod(const VMClass* parent, const Method* method) + : parent_(parent), + method_(method) + { + const std::string& methodName = method_->getName()->str(); + const std::string& methodDescriptor = method_->getDescriptor()->str(); + Resolver* resolver = parent_->getResolver(); + const FunctionType* functionType = cast( + resolver->getType(methodDescriptor, !method_->isStatic())); + const std::string& className = + parent_->getClassFile()->getThisClass()->getName()->str(); + const std::string& functionName = + className + '/' + methodName + methodDescriptor; + Module* module = resolver->getModule(); + function_ = module->getOrInsertFunction(functionName, functionType); + } Index: llvm-java/lib/Compiler/VMClass.h diff -u llvm-java/lib/Compiler/VMClass.h:1.23 llvm-java/lib/Compiler/VMClass.h:1.24 --- llvm-java/lib/Compiler/VMClass.h:1.23 Wed Mar 30 21:19:27 2005 +++ llvm-java/lib/Compiler/VMClass.h Wed Mar 30 23:10:29 2005 @@ -16,6 +16,7 @@ #define LLVM_JAVA_VMCLASS_H #include "VMField.h" +#include "VMMethod.h" #include #include #include @@ -40,14 +41,18 @@ unsigned interfaceIndex_; typedef std::map FieldMap; FieldMap fieldMap_; + typedef std::map MethodMap; + MethodMap methodMap_; mutable std::vector resolvedConstantPool_; std::vector superClasses_; std::vector interfaces_; std::vector memberFields_; void computeLayout(); + void computeClassRecord(); const VMField* lookupField(const std::string& name) const; - + const VMMethod* lookupMethod(const std::string& name) const; + friend class Resolver; // Resolver interface. @@ -90,6 +95,7 @@ llvm::Constant* getConstant(unsigned index) const; const VMClass* getClass(unsigned index) const; const VMField* getField(unsigned index) const; + const VMMethod* getMethod(unsigned index) const; }; } } // namespace llvm::Java Index: llvm-java/lib/Compiler/VMClass.cpp diff -u llvm-java/lib/Compiler/VMClass.cpp:1.28 llvm-java/lib/Compiler/VMClass.cpp:1.29 --- llvm-java/lib/Compiler/VMClass.cpp:1.28 Wed Mar 30 21:22:58 2005 +++ llvm-java/lib/Compiler/VMClass.cpp Wed Mar 30 23:10:29 2005 @@ -90,7 +90,33 @@ return &it->second; } - return NULL; + assert(0 && "Field not found!"); + abort(); +} + +const VMMethod* VMClass::lookupMethod(const std::string& name) const +{ + MethodMap::const_iterator it = methodMap_.find(name); + if (it != methodMap_.end()) + return &it->second; + + if (isInterface()) + for (unsigned i = 0, e = getNumInterfaces(); i != e; ++i) { + const VMClass* interface = getInterface(i); + it = interface->methodMap_.find(name); + if (it != interface->methodMap_.end()) + return &it->second; + } + else + for (unsigned i = 0, e = getNumSuperClasses(); i != e; ++i) { + const VMClass* superClass = getSuperClass(i); + it = superClass->methodMap_.find(name); + if (it != superClass->methodMap_.end()) + return &it->second; + } + + assert(0 && "Method not found!"); + abort(); } void VMClass::computeLayout() @@ -137,6 +163,19 @@ type_ = PointerType::get(layoutType_); } +void VMClass::computeClassRecord() +{ + if (classFile_) { + const Methods& methods = classFile_->getMethods(); + for (unsigned i = 0, e = methods.size(); i != e; ++i) { + Method* method = methods[i]; + const std::string& name = + method->getName()->str() + method->getDescriptor()->str(); + methodMap_.insert(std::make_pair(name, VMMethod(this, method))); + } + } +} + void VMClass::link() { // Primitive classes require no linking. @@ -195,6 +234,7 @@ } computeLayout(); + computeClassRecord(); assert(!isa(getLayoutType()) &&"Class not initialized properly!"); } @@ -282,3 +322,24 @@ return static_cast(resolvedConstantPool_[index]); } + +const VMMethod* VMClass::getMethod(unsigned index) const +{ + assert(classFile_ && "No constant pool!"); + assert((dynamic_cast(classFile_->getConstant(index)) || + dynamic_cast(classFile_->getConstant(index))) && + "Not an index to a method reference!"); + + // If we haven't resolved this constant already, do so now. + if (!resolvedConstantPool_[index]) { + ConstantMemberRef* jc = classFile_->getConstantMemberRef(index); + const VMClass* clazz = getClass(jc->getClassIndex()); + ConstantNameAndType* ntc = jc->getNameAndType(); + const std::string& name = ntc->getName()->str(); + const std::string& descriptor = ntc->getDescriptor()->str(); + resolvedConstantPool_[index] = + const_cast(clazz->lookupMethod(name + descriptor)); + } + + return static_cast(resolvedConstantPool_[index]); +} Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.268 llvm-java/lib/Compiler/Compiler.cpp:1.269 --- llvm-java/lib/Compiler/Compiler.cpp:1.268 Wed Mar 30 23:08:47 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Wed Mar 30 23:10:29 2005 @@ -1564,24 +1564,12 @@ } void do_invokevirtual(unsigned index) { - ConstantMethodRef* methodRef = - class_->getClassFile()->getConstantMethodRef(index); - ConstantNameAndType* nameAndType = methodRef->getNameAndType(); - - const std::string& className = methodRef->getClass()->getName()->str(); - - const VMClass* clazz = - class_->getClass(methodRef->getClassIndex()); + const VMMethod* method = class_->getMethod(index); + const VMClass* clazz = method->getParent(); const VTableInfo* vi = getVTableInfoGeneric(clazz); - const std::string& methodDescr = - nameAndType->getName()->str() + - nameAndType->getDescriptor()->str(); - - const FunctionType* funTy = cast( - resolver_->getType(nameAndType->getDescriptor()->str(), true)); - - std::vector params(getParams(funTy)); + Function* function = method->getFunction(); + std::vector params(getParams(function->getFunctionType())); Value* objRef = params.front(); objRef = new CastInst(objRef, clazz->getType(), "this", currentBB_); @@ -1589,48 +1577,30 @@ new CastInst(objRef, resolver_->getObjectBaseType(), TMP, currentBB_); Value* vtable = new CallInst(getVtable_, objBase, TMP, currentBB_); vtable = new CastInst(vtable, vi->vtable->getType(), - className + ".vtable", currentBB_); + clazz->getName() + ".vtable", currentBB_); std::vector indices(1, ConstantUInt::get(Type::UIntTy, 0)); - assert(vi->m2iMap.find(methodDescr) != vi->m2iMap.end() && + assert(vi->m2iMap.find(method->getNameAndDescriptor()) != vi->m2iMap.end() && "could not find slot for virtual function!"); - unsigned vSlot = vi->m2iMap.find(methodDescr)->second; + unsigned vSlot = vi->m2iMap.find(method->getNameAndDescriptor())->second; indices.push_back(ConstantUInt::get(Type::UIntTy, vSlot)); Value* vfunPtr = new GetElementPtrInst(vtable, indices, TMP, currentBB_); - Value* vfun = new LoadInst(vfunPtr, className + '/' + methodDescr, - currentBB_); + Value* vfun = new LoadInst(vfunPtr, function->getName(), currentBB_); makeCall(vfun, params); } void do_invokespecial(unsigned index) { - ConstantMethodRef* methodRef = - class_->getClassFile()->getConstantMethodRef(index); - ConstantNameAndType* nameAndType = methodRef->getNameAndType(); - - const std::string& className = methodRef->getClass()->getName()->str(); - const std::string& methodName = nameAndType->getName()->str(); - const std::string& methodDescr = - methodName + nameAndType->getDescriptor()->str(); - std::string funcName = className + '/' + methodDescr; - const VMClass* clazz = - class_->getClass(methodRef->getClassIndex()); - - const FunctionType* funcTy = cast( - resolver_->getType(nameAndType->getDescriptor()->str(), true)); - Function* function = module_->getOrInsertFunction(funcName, funcTy); + const VMMethod* method = class_->getMethod(index); + Function* function = method->getFunction(); scheduleFunction(function); - makeCall(function, getParams(funcTy)); + makeCall(function, getParams(function->getFunctionType())); } void do_invokestatic(unsigned index) { - ConstantMethodRef* methodRef = - class_->getClassFile()->getConstantMethodRef(index); - const VMClass* clazz = - class_->getClass(methodRef->getClassIndex()); - emitStaticInitializers(clazz->getClassFile()); - Method* method = getMethod(methodRef); - Function* function = getFunction(method); + const VMMethod* method = class_->getMethod(index); + emitStaticInitializers(method->getParent()->getClassFile()); + Function* function = method->getFunction(); // Intercept java/lang/System/loadLibrary() calls and add // library deps to the module if (function->getName().find( @@ -1648,24 +1618,12 @@ } void do_invokeinterface(unsigned index) { - ConstantInterfaceMethodRef* methodRef = - class_->getClassFile()->getConstantInterfaceMethodRef(index); - ConstantNameAndType* nameAndType = methodRef->getNameAndType(); - - const std::string& className = methodRef->getClass()->getName()->str(); - - const VMClass* clazz = - class_->getClass(methodRef->getClassIndex()); + const VMMethod* method = class_->getMethod(index); + const VMClass* clazz = method->getParent(); const VTableInfo* vi = getVTableInfoGeneric(clazz); - const std::string& methodDescr = - nameAndType->getName()->str() + - nameAndType->getDescriptor()->str(); - - const FunctionType* funTy = cast( - resolver_->getType(nameAndType->getDescriptor()->str(), true)); - - std::vector params(getParams(funTy)); + Function* function = method->getFunction(); + std::vector params(getParams(function->getFunctionType())); Value* objRef = params.front(); objRef = new CastInst(objRef, clazz->getType(), "this", currentBB_); @@ -1687,20 +1645,19 @@ Value* interfaceVTable = new GetElementPtrInst(interfaceVTables, indices, TMP, currentBB_); interfaceVTable = - new LoadInst(interfaceVTable, className + ".vtable", currentBB_); + new LoadInst(interfaceVTable, clazz->getName() + ".vtable", currentBB_); interfaceVTable = new CastInst(interfaceVTable, vi->vtable->getType(), TMP, currentBB_); // Get the function pointer. - assert(vi->m2iMap.find(methodDescr) != vi->m2iMap.end() && + assert(vi->m2iMap.find(method->getNameAndDescriptor()) != vi->m2iMap.end() && "could not find slot for virtual function!"); - unsigned vSlot = vi->m2iMap.find(methodDescr)->second; + unsigned vSlot = vi->m2iMap.find(method->getNameAndDescriptor())->second; indices.resize(2); indices[0] = ConstantUInt::get(Type::UIntTy, 0); indices[1] = ConstantUInt::get(Type::UIntTy, vSlot); Value* vfunPtr = new GetElementPtrInst(interfaceVTable, indices, TMP, currentBB_); - Value* vfun = new LoadInst(vfunPtr, className + '/' + methodDescr, - currentBB_); + Value* vfun = new LoadInst(vfunPtr, function->getName(), currentBB_); makeCall(vfun, params); } From alkis at cs.uiuc.edu Thu Mar 31 01:17:26 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu, 31 Mar 2005 01:17:26 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMClass.cpp Message-ID: <200503310717.BAA22769@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMClass.cpp updated: 1.29 -> 1.30 --- Log message: This is not needed. It is already set in the initialization list. --- Diffs of the changes: (+0 -1) VMClass.cpp | 1 - 1 files changed, 1 deletion(-) Index: llvm-java/lib/Compiler/VMClass.cpp diff -u llvm-java/lib/Compiler/VMClass.cpp:1.29 llvm-java/lib/Compiler/VMClass.cpp:1.30 --- llvm-java/lib/Compiler/VMClass.cpp:1.29 Wed Mar 30 23:10:29 2005 +++ llvm-java/lib/Compiler/VMClass.cpp Thu Mar 31 01:17:14 2005 @@ -160,7 +160,6 @@ Type* resolvedType = StructType::get(layout); cast(layoutType_)->refineAbstractTypeTo(resolvedType); layoutType_ = holder.get(); - type_ = PointerType::get(layoutType_); } void VMClass::computeClassRecord() From alkis at cs.uiuc.edu Thu Mar 31 01:22:55 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu, 31 Mar 2005 01:22:55 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMClass.cpp Message-ID: <200503310722.BAA22828@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMClass.cpp updated: 1.30 -> 1.31 --- Log message: Revert previous patch. This is really needed. --- Diffs of the changes: (+1 -0) VMClass.cpp | 1 + 1 files changed, 1 insertion(+) Index: llvm-java/lib/Compiler/VMClass.cpp diff -u llvm-java/lib/Compiler/VMClass.cpp:1.30 llvm-java/lib/Compiler/VMClass.cpp:1.31 --- llvm-java/lib/Compiler/VMClass.cpp:1.30 Thu Mar 31 01:17:14 2005 +++ llvm-java/lib/Compiler/VMClass.cpp Thu Mar 31 01:22:43 2005 @@ -160,6 +160,7 @@ Type* resolvedType = StructType::get(layout); cast(layoutType_)->refineAbstractTypeTo(resolvedType); layoutType_ = holder.get(); + type_ = PointerType::get(layoutType_); } void VMClass::computeClassRecord() From duraid at octopus.com.au Thu Mar 31 01:32:43 2005 From: duraid at octopus.com.au (Duraid Madina) Date: Thu, 31 Mar 2005 01:32:43 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/IA64/IA64InstrInfo.td Message-ID: <200503310732.BAA22886@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/IA64: IA64InstrInfo.td updated: 1.1 -> 1.2 --- Log message: add what we need to fudge a 'floating point conditional move', this is used to get FP div-by-zero working properly (shunt the right answer depending on how frcpa sets its predicate output) --- Diffs of the changes: (+8 -0) IA64InstrInfo.td | 8 ++++++++ 1 files changed, 8 insertions(+) Index: llvm/lib/Target/IA64/IA64InstrInfo.td diff -u llvm/lib/Target/IA64/IA64InstrInfo.td:1.1 llvm/lib/Target/IA64/IA64InstrInfo.td:1.2 --- llvm/lib/Target/IA64/IA64InstrInfo.td:1.1 Thu Mar 17 12:17:03 2005 +++ llvm/lib/Target/IA64/IA64InstrInfo.td Thu Mar 31 01:32:32 2005 @@ -59,6 +59,14 @@ "($qp) mov $dst = $src;;">; } +def PFMOV : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src, PR:$qp), + "($qp) mov $dst = $src;;">; + +let isTwoAddress = 1 in { + def CFMOV : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src2, FP:$src, PR:$qp), + "($qp) mov $dst = $src;;">; +} + let isTwoAddress = 1 in { def TCMPNE : AForm<0x03, 0x0b, (ops PR:$dst, PR:$src2, GR:$src3, GR:$src4), From duraid at octopus.com.au Thu Mar 31 01:36:55 2005 From: duraid at octopus.com.au (Duraid Madina) Date: Thu, 31 Mar 2005 01:36:55 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/IA64/IA64RegisterInfo.cpp Message-ID: <200503310736.BAA22902@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/IA64: IA64RegisterInfo.cpp updated: 1.1 -> 1.2 --- Log message: daintyness --- Diffs of the changes: (+2 -2) IA64RegisterInfo.cpp | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/lib/Target/IA64/IA64RegisterInfo.cpp diff -u llvm/lib/Target/IA64/IA64RegisterInfo.cpp:1.1 llvm/lib/Target/IA64/IA64RegisterInfo.cpp:1.2 --- llvm/lib/Target/IA64/IA64RegisterInfo.cpp:1.1 Thu Mar 17 12:17:03 2005 +++ llvm/lib/Target/IA64/IA64RegisterInfo.cpp Thu Mar 31 01:36:43 2005 @@ -134,11 +134,11 @@ MachineInstr *New; if (Old->getOpcode() == IA64::ADJUSTCALLSTACKDOWN) { New=BuildMI(IA64::ADDIMM22, 2, IA64::r12).addReg(IA64::r12) - .addImm(-Amount); + .addSImm(-Amount); } else { assert(Old->getOpcode() == IA64::ADJUSTCALLSTACKUP); New=BuildMI(IA64::ADDIMM22, 2, IA64::r12).addReg(IA64::r12) - .addImm(Amount); + .addSImm(Amount); } // Replace the pseudo instruction with a new instruction... From duraid at octopus.com.au Thu Mar 31 01:40:35 2005 From: duraid at octopus.com.au (Duraid Madina) Date: Thu, 31 Mar 2005 01:40:35 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/IA64/IA64AsmPrinter.cpp Message-ID: <200503310740.BAA22923@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/IA64: IA64AsmPrinter.cpp updated: 1.4 -> 1.5 --- Log message: * declare local common symbols as such (.lcomm, not merely .common) * begin great adventure into correct function descriptor materialization --- Diffs of the changes: (+10 -7) IA64AsmPrinter.cpp | 17 ++++++++++------- 1 files changed, 10 insertions(+), 7 deletions(-) Index: llvm/lib/Target/IA64/IA64AsmPrinter.cpp diff -u llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.4 llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.5 --- llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.4 Mon Mar 28 09:21:43 2005 +++ llvm/lib/Target/IA64/IA64AsmPrinter.cpp Thu Mar 31 01:40:24 2005 @@ -112,12 +112,15 @@ (I->hasLinkOnceLinkage() || I->hasInternalLinkage() || I->hasWeakLinkage() /* FIXME: Verify correct */)) { SwitchSection(O, CurSection, ".data"); - if (I->hasInternalLinkage()) -// FIXME O << "\t.local " << name << "\n"; - - O << "\t.common " << name << "," << TD.getTypeSize(C->getType()) - << "," << (1 << Align); - O << "\t\t// "; + if (I->hasInternalLinkage()) { + O << "\t.lcomm " << name << "," << TD.getTypeSize(C->getType()) + << "," << (1 << Align); + O << "\t\t// "; + } else { + O << "\t.common " << name << "," << TD.getTypeSize(C->getType()) + << "," << (1 << Align); + O << "\t\t// "; + } WriteAsOperand(O, I, true, true, &M); O << "\n"; } else { @@ -345,7 +348,7 @@ bool Needfptr=false; // if we're computing an address @ltoff(X), do // we need to decorate it so it becomes // @ltoff(@fptr(X)) ? - if(F && !isBRCALLinsn && F->isExternal()) + if(F && !isBRCALLinsn /*&& F->isExternal()*/) Needfptr=true; // if this is the target of a call instruction, we should define From alkis at cs.uiuc.edu Thu Mar 31 01:55:53 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu, 31 Mar 2005 01:55:53 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMClass.cpp Message-ID: <200503310755.BAA22981@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMClass.cpp updated: 1.31 -> 1.32 --- Log message: Make the layout of a an interface object (it doesn't exist - this is used only to cast to) the same as java/lang/Object. --- Diffs of the changes: (+12 -10) VMClass.cpp | 22 ++++++++++++---------- 1 files changed, 12 insertions(+), 10 deletions(-) Index: llvm-java/lib/Compiler/VMClass.cpp diff -u llvm-java/lib/Compiler/VMClass.cpp:1.31 llvm-java/lib/Compiler/VMClass.cpp:1.32 --- llvm-java/lib/Compiler/VMClass.cpp:1.31 Thu Mar 31 01:22:43 2005 +++ llvm-java/lib/Compiler/VMClass.cpp Thu Mar 31 01:55:42 2005 @@ -121,6 +121,15 @@ void VMClass::computeLayout() { + // If this is an interface, then its layout and type are the same as + // java/lang/Object. + if (isInterface()) { + const VMClass* object = resolver_->getClass("java/lang/Object"); + layoutType_ = const_cast(object->getLayoutType()); + type_ = object->getType(); + return; + } + std::vector layout; if (isArray()) { layout.reserve(3); @@ -128,10 +137,6 @@ layout.push_back(Type::UIntTy); layout.push_back(ArrayType::get(componentClass_->getType(), 0)); } - else if (isInterface()) { - layout.reserve(1); - layout.push_back(resolver_->getClass("java/lang/Object")->getLayoutType()); - } else { if (const VMClass* superClass = getSuperClass()) layout.push_back(superClass->getLayoutType()); @@ -200,12 +205,9 @@ for (unsigned i = 0, e = superClass->getNumInterfaces(); i != e; ++i) interfaces_.push_back(superClass->getInterface(i)); - // Although we can safely assume that all interfaces inherit - // from java/lang/Object, java/lang/Class.getSuperclass() - // returns null on interface types. So we only set the - // superClass_ field when the class is not an interface type, - // but we model the LLVM type of the interface to be as if it - // inherits java/lang/Object. + // In a classfile an interface is as if it inherits + // java/lang/Object, but java/lang/Class/getSuperClass() should + // return null on any interface class. Thus we do the same here. if (classFile_->isInterface()) interfaceIndex_ = resolver_->getNextInterfaceIndex(); else { From alkis at cs.uiuc.edu Thu Mar 31 01:56:14 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu, 31 Mar 2005 01:56:14 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Resolver.cpp Message-ID: <200503310756.BAA22993@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Resolver.cpp updated: 1.9 -> 1.10 --- Log message: Do not add typenames for interfaces. --- Diffs of the changes: (+1 -1) Resolver.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm-java/lib/Compiler/Resolver.cpp diff -u llvm-java/lib/Compiler/Resolver.cpp:1.9 llvm-java/lib/Compiler/Resolver.cpp:1.10 --- llvm-java/lib/Compiler/Resolver.cpp:1.9 Mon Mar 28 17:56:46 2005 +++ llvm-java/lib/Compiler/Resolver.cpp Thu Mar 31 01:56:03 2005 @@ -128,7 +128,7 @@ abort(); } it->second.link(); - if (!it->second.isPrimitive()) + if (!it->second.isPrimitive() && !it->second.isInterface()) module_->addTypeName(descriptor, it->second.getLayoutType()); DEBUG(std::cerr << "Loaded class: " << descriptor << '\n'); } From alkis at cs.uiuc.edu Thu Mar 31 01:56:40 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu, 31 Mar 2005 01:56:40 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Resolver.h Resolver.cpp Compiler.cpp Message-ID: <200503310756.BAA23028@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Resolver.h updated: 1.11 -> 1.12 Resolver.cpp updated: 1.10 -> 1.11 Compiler.cpp updated: 1.269 -> 1.270 --- Log message: Remove global variables. --- Diffs of the changes: (+97 -71) Compiler.cpp | 120 ++++++++++++++++++++++++----------------------------------- Resolver.cpp | 42 ++++++++++++++++++++ Resolver.h | 6 ++ 3 files changed, 97 insertions(+), 71 deletions(-) Index: llvm-java/lib/Compiler/Resolver.h diff -u llvm-java/lib/Compiler/Resolver.h:1.11 llvm-java/lib/Compiler/Resolver.h:1.12 --- llvm-java/lib/Compiler/Resolver.h:1.11 Mon Mar 28 20:47:41 2005 +++ llvm-java/lib/Compiler/Resolver.h Thu Mar 31 01:56:28 2005 @@ -31,6 +31,9 @@ unsigned nextInterfaceIndex_; const Type* objectBaseLayoutType_; const Type* objectBaseType_; + const Type* typeInfoType_; + const Type* classRecordType_; + const Type* classRecordPtrType_; const VMClass* getClassForDesc(const std::string& descriptor); @@ -56,6 +59,9 @@ const Type* getObjectBaseLayoutType() const {return objectBaseLayoutType_; } const Type* getObjectBaseType() const { return objectBaseType_; } + const Type* getTypeInfoType() const { return typeInfoType_; } + const Type* getClassRecordType() const { return classRecordType_; } + const Type* getClassRecordPtrType() const { return classRecordPtrType_; } const Type* getType(const std::string& descriptor, bool memberMethod = false) const; Index: llvm-java/lib/Compiler/Resolver.cpp diff -u llvm-java/lib/Compiler/Resolver.cpp:1.10 llvm-java/lib/Compiler/Resolver.cpp:1.11 --- llvm-java/lib/Compiler/Resolver.cpp:1.10 Thu Mar 31 01:56:03 2005 +++ llvm-java/lib/Compiler/Resolver.cpp Thu Mar 31 01:56:28 2005 @@ -25,10 +25,50 @@ : module_(module), nextInterfaceIndex_(0), objectBaseLayoutType_(OpaqueType::get()), - objectBaseType_(PointerType::get(objectBaseLayoutType_)) + objectBaseType_(PointerType::get(objectBaseLayoutType_)), + classRecordType_(OpaqueType::get()), + classRecordPtrType_(PointerType::get(classRecordType_)) { module_->addTypeName("struct.llvm_java_object_base", getObjectBaseLayoutType()); + + // Compute the class record type. A class record looks like: + // + // struct class_record { + // struct type_info; + // }; + // + // struct type_info { + // int depth; + // struct class_record** superClasses; + // int interfaceIndex; + // union { + // int interfaceFlag; + // struct class_record** interfaces; + // }; + // int elementSize; + // }; + + // Compute the type_info type. + std::vector elements; + elements.push_back(Type::IntTy); + elements.push_back(PointerType::get(PointerType::get(classRecordType_))); + elements.push_back(Type::IntTy); + elements.push_back(PointerType::get(PointerType::get(classRecordType_))); + elements.push_back(Type::IntTy); + typeInfoType_ = StructType::get(elements); + + module_->addTypeName("struct.llvm_java_object_typeinfo", getTypeInfoType()); + + // Compute the class_record type. + PATypeHolder holder = classRecordType_; + cast(const_cast(classRecordType_))->refineAbstractTypeTo( + StructType::get(std::vector(1, getTypeInfoType()))); + classRecordType_ = holder.get(); + + module_->addTypeName("struct.llvm_java_object_vtable", getClassRecordType()); + + classRecordPtrType_ = PointerType::get(classRecordType_); } const Type* Resolver::getType(const std::string& descriptor, Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.269 llvm-java/lib/Compiler/Compiler.cpp:1.270 --- llvm-java/lib/Compiler/Compiler.cpp:1.269 Wed Mar 30 23:10:29 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Thu Mar 31 01:56:28 2005 @@ -33,19 +33,11 @@ #include #include -#define LLVM_JAVA_OBJECT_BASE "struct.llvm_java_object_base" -#define LLVM_JAVA_OBJECT_HEADER "struct.llvm_java_object_header" -#define LLVM_JAVA_OBJECT_TYPEINFO "struct.llvm_java_object_typeinfo" -#define LLVM_JAVA_OBJECT_VTABLE "struct.llvm_java_object_vtable" - #define LLVM_JAVA_STATIC_INIT "llvm_java_static_init" using namespace llvm; using namespace llvm::Java; -Type* llvm::Java::VTableBaseTy = OpaqueType::get(); -Type* llvm::Java::VTableBaseRefTy = PointerType::get(VTableBaseTy); - namespace llvm { namespace Java { namespace { const std::string TMP("tmp"); @@ -89,9 +81,6 @@ typedef Method2IndexMap::iterator iterator; typedef Method2IndexMap::const_iterator const_iterator; Method2IndexMap m2iMap; - - static StructType* VTableTy; - static StructType* TypeInfoTy; }; typedef std::map Class2VTableInfoMap; Class2VTableInfoMap c2viMap_; @@ -110,19 +99,19 @@ NULL, "llvm_java_JNIEnv", module_); - module_->addTypeName("llvm_java_object_vtable", VTableBaseTy); + const Type* vtablePtrType = resolver_->getClassRecordPtrType(); getVtable_ = module_->getOrInsertFunction( - "llvm_java_get_vtable", VTableBaseRefTy, + "llvm_java_get_vtable", vtablePtrType, resolver_->getObjectBaseType(), NULL); setVtable_ = module_->getOrInsertFunction( "llvm_java_set_vtable", Type::VoidTy, - resolver_->getObjectBaseType(), VTableBaseRefTy, NULL); + resolver_->getObjectBaseType(), vtablePtrType, NULL); throw_ = module_->getOrInsertFunction( "llvm_java_throw", Type::IntTy, resolver_->getObjectBaseType(), NULL); isInstanceOf_ = module_->getOrInsertFunction( "llvm_java_is_instance_of", Type::IntTy, - resolver_->getObjectBaseType(), VTableBaseRefTy, NULL); + resolver_->getObjectBaseType(), vtablePtrType, NULL); memcpy_ = module_->getOrInsertFunction( "llvm.memcpy", Type::VoidTy, PointerType::get(Type::SByteTy), @@ -197,7 +186,8 @@ // Install the vtable pointer. Value* objBase = new CastInst(globalString, resolver_->getObjectBaseType(), TMP, ip); - Value* vtable = new CastInst(vi->vtable, VTableBaseRefTy, TMP, ip); + const Type* vtablePtrType = resolver_->getClassRecordPtrType(); + Value* vtable = new CastInst(vi->vtable, vtablePtrType, TMP, ip); new CallInst(setVtable_, objBase, vtable, "", ip); // Initialize it: call java/lang/String/(byte[],int) @@ -271,38 +261,31 @@ Type* VTtype = OpaqueType::get(); - std::vector elements; std::vector init; - // This is java/lang/Object so we must add a - // llvm_java_object_typeinfo struct first. + // This is java/lang/Object so we must add a typeinfo struct + // first. + const Type* vtablePtrPtrType = + PointerType::get(resolver_->getClassRecordPtrType()); // depth - elements.push_back(Type::IntTy); - init.push_back(llvm::ConstantSInt::get(elements[0], 0)); + init.push_back(llvm::ConstantSInt::get(Type::IntTy, 0)); // superclasses vtable pointers - elements.push_back(PointerType::get(PointerType::get(VTtype))); - init.push_back(llvm::Constant::getNullValue(elements[1])); + init.push_back(llvm::Constant::getNullValue(vtablePtrPtrType)); // last interface index - elements.push_back(Type::IntTy); - init.push_back(llvm::ConstantSInt::get(elements[2], -1)); + init.push_back(llvm::ConstantSInt::get(Type::IntTy, -1)); // interfaces vtable pointers - elements.push_back(PointerType::get(PointerType::get(VTtype))); - init.push_back(llvm::Constant::getNullValue(elements[3])); + init.push_back(llvm::Constant::getNullValue(vtablePtrPtrType)); // the element size (0 for classes) - elements.push_back(Type::IntTy); - init.push_back(llvm::ConstantSInt::get(elements[4], 0)); + init.push_back(llvm::ConstantSInt::get(Type::IntTy, 0)); - // This is a static variable. - VTableInfo::TypeInfoTy = StructType::get(elements); - module_->addTypeName(LLVM_JAVA_OBJECT_TYPEINFO, VTableInfo::TypeInfoTy); - llvm::Constant* typeInfoInit = - ConstantStruct::get(VTableInfo::TypeInfoTy, init); + llvm::Constant* typeInfoInit = ConstantStruct::get(init); + assert(typeInfoInit->getType() == resolver_->getTypeInfoType() && + "TypeInfo types mismatch!"); // Now that we have both the type and initializer for the - // llvm_java_object_typeinfo struct we can start adding the - // function pointers. - elements.clear(); + // typeinfo struct we can start adding the function pointers. + std::vector elements; init.clear(); /// First add the typeinfo struct itself. @@ -345,10 +328,10 @@ PATypeHolder holder = VTtype; cast(VTtype)->refineAbstractTypeTo(StructType::get(elements)); - VTableInfo::VTableTy = cast(holder.get()); - module_->addTypeName("java/lang/Object", VTableInfo::VTableTy); + VTtype = holder.get(); + module_->addTypeName("java/lang/Object", VTtype); - vi.vtable = new GlobalVariable(VTableInfo::VTableTy, + vi.vtable = new GlobalVariable(VTtype, true, GlobalVariable::ExternalLinkage, ConstantStruct::get(init), "java/lang/Object", @@ -365,12 +348,10 @@ 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)); + vi.superVtables[i], resolver_->getClassRecordPtrType()); llvm::Constant* init = ConstantArray::get( - ArrayType::get(PointerType::get(VTableInfo::VTableTy), - superVtables.size()), + ArrayType::get(resolver_->getClassRecordPtrType(), superVtables.size()), superVtables); GlobalVariable* vtablesArray = new GlobalVariable( @@ -400,7 +381,7 @@ // of methods for this interface (the first slot is the typeinfo // struct. std::vector init(interfaceVI.m2iMap.size()+1, NULL); - init[0] = llvm::Constant::getNullValue(VTableInfo::TypeInfoTy); + init[0] = llvm::Constant::getNullValue(resolver_->getTypeInfoType()); // For each method in this interface find the implementing // method in the class' VTable and add it to the appropriate @@ -417,8 +398,7 @@ } else init[i->second] = - llvm::Constant::getNullValue( - PointerType::get(VTableInfo::VTableTy)); + llvm::Constant::getNullValue(resolver_->getClassRecordPtrType()); } llvm::Constant* vtable = ConstantStruct::get(init); @@ -434,14 +414,14 @@ globalName, module_); - return ConstantExpr::getCast(gv, PointerType::get(VTableInfo::VTableTy)); + return ConstantExpr::getCast(gv, resolver_->getClassRecordPtrType()); } void insertVtablesForInterface(std::vector& vtables, const VMClass* clazz, const VMClass* interface) { static llvm::Constant* nullVTable = - llvm::Constant::getNullValue(PointerType::get(VTableInfo::VTableTy)); + llvm::Constant::getNullValue(resolver_->getClassRecordPtrType()); assert(interface->isInterface() && "Classfile must be an interface!"); unsigned index = interface->getInterfaceIndex(); @@ -465,7 +445,7 @@ clazz->getInterfaceIndex(), ConstantExpr::getCast( ConstantIntegral::getAllOnesValue(Type::LongTy), - PointerType::get(PointerType::get(VTableInfo::VTableTy)))); + PointerType::get(resolver_->getClassRecordPtrType()))); // Otherwise we must fill in the interfaces vtables array. For // each implemented interface we insert a pointer to the @@ -474,7 +454,7 @@ // interfaces. std::vector vtables; llvm::Constant* nullVTable = - llvm::Constant::getNullValue(PointerType::get(VTableInfo::VTableTy)); + llvm::Constant::getNullValue(resolver_->getClassRecordPtrType()); for (unsigned i = 0, e = clazz->getNumInterfaces(); i != e; ++i) insertVtablesForInterface(vtables, clazz, clazz->getInterface(i)); @@ -482,7 +462,7 @@ const std::string& globalName = clazz->getName() + ""; llvm::Constant* init = ConstantArray::get( - ArrayType::get(PointerType::get(VTableInfo::VTableTy), vtables.size()), + ArrayType::get(resolver_->getClassRecordPtrType(), vtables.size()), vtables); module_->addTypeName(globalName, init->getType()); @@ -525,7 +505,7 @@ // the element size (0 for classes) typeInfoInit.push_back(llvm::ConstantSInt::get(Type::IntTy, 0)); - return ConstantStruct::get(VTableInfo::TypeInfoTy, typeInfoInit); + return ConstantStruct::get(typeInfoInit); } /// Returns the VTableInfo associated with this classfile. @@ -546,7 +526,7 @@ std::vector init(1); // Use a null typeinfo struct for now. - init[0] = llvm::Constant::getNullValue(VTableInfo::TypeInfoTy); + init[0] = llvm::Constant::getNullValue(resolver_->getTypeInfoType()); // If this is an interface, add all methods from each interface // this inherits from. @@ -662,14 +642,16 @@ // Add java/lang/Object as its superclass. vi.superVtables.reserve(1); - vi.superVtables.push_back(superVI.vtable); + vi.superVtables.push_back( + ConstantExpr::getCast( + superVI.vtable, resolver_->getClassRecordPtrType())); // Copy the constants from java/lang/Object vtable. ConstantStruct* superInit = cast(superVI.vtable->getInitializer()); std::vector init(superInit->getNumOperands()); // Use a null typeinfo struct for now. - init[0] = llvm::Constant::getNullValue(VTableInfo::TypeInfoTy); + init[0] = llvm::Constant::getNullValue(resolver_->getTypeInfoType()); // Fill in the function pointers as they are in // java/lang/Object. There are no overriden methods. @@ -699,7 +681,7 @@ typeInfoInit.push_back(ConstantSInt::get(Type::IntTy, 1)); // Build the super classes' vtable array. ArrayType* vtablesArrayTy = - ArrayType::get(PointerType::get(VTableInfo::VTableTy), + ArrayType::get(resolver_->getClassRecordPtrType(), vi.superVtables.size()); GlobalVariable* vtablesArray = new GlobalVariable( @@ -714,13 +696,13 @@ typeInfoInit.push_back(ConstantSInt::get(Type::IntTy, 0)); typeInfoInit.push_back( llvm::Constant::getNullValue( - PointerType::get(PointerType::get(VTableInfo::VTableTy)))); + PointerType::get(resolver_->getClassRecordPtrType()))); // the element size typeInfoInit.push_back( ConstantExpr::getCast( ConstantExpr::getSizeOf(elementTy), Type::IntTy)); - init[0] = ConstantStruct::get(VTableInfo::TypeInfoTy, typeInfoInit); + init[0] = ConstantStruct::get(typeInfoInit); vi.vtable->setInitializer(ConstantStruct::get(init)); return vi; @@ -1630,7 +1612,7 @@ Value* objBase = new CastInst(objRef, resolver_->getObjectBaseType(), TMP, currentBB_); Value* vtable = new CallInst(getVtable_, objBase, TMP, currentBB_); - vtable = new CastInst(vtable, PointerType::get(VTableInfo::VTableTy), + vtable = new CastInst(vtable, resolver_->getClassRecordPtrType(), TMP, currentBB_); // get the interfaces array of vtables std::vector indices(2, ConstantUInt::get(Type::UIntTy, 0)); @@ -1678,7 +1660,8 @@ // Install the vtable pointer. Value* objBase = new CastInst(objRef, resolver_->getObjectBaseType(), TMP, ip); - Value* vtable = new CastInst(vi.vtable, VTableBaseRefTy, TMP, ip); + const Type* vtablePtrType = resolver_->getClassRecordPtrType(); + Value* vtable = new CastInst(vi.vtable, vtablePtrType, TMP, ip); new CallInst(setVtable_, objBase, vtable, "", ip); return objRef; @@ -1755,7 +1738,8 @@ // Install the vtable pointer. Value* objBase = new CastInst(objRef, resolver_->getObjectBaseType(), TMP, ip); - Value* vtable = new CastInst(vi->vtable, VTableBaseRefTy, TMP, ip); + const Type* vtablePtrType = resolver_->getClassRecordPtrType(); + Value* vtable = new CastInst(vi->vtable, vtablePtrType, TMP, ip); new CallInst(setVtable_, objBase, vtable, "", ip); return objRef; @@ -1800,9 +1784,8 @@ const VTableInfo* vi = getVTableInfoGeneric(clazz); Value* objRef = pop(resolver_->getObjectBaseType()); - Value* vtable = new CastInst(vi->vtable, - VTableBaseRefTy, - TMP, currentBB_); + const Type* vtablePtrType = resolver_->getClassRecordPtrType(); + Value* vtable = new CastInst(vi->vtable, vtablePtrType, TMP, currentBB_); Value* r = new CallInst(isInstanceOf_, objRef, vtable, TMP, currentBB_); Value* b = new SetCondInst(Instruction::SetEQ, @@ -1817,8 +1800,8 @@ const VTableInfo* vi = getVTableInfoGeneric(clazz); Value* objRef = pop(resolver_->getObjectBaseType()); - Value* vtable = new CastInst(vi->vtable, VTableBaseRefTy, - TMP, currentBB_); + const Type* vtablePtrType = resolver_->getClassRecordPtrType(); + Value* vtable = new CastInst(vi->vtable, vtablePtrType, TMP, currentBB_); Value* r = new CallInst(isInstanceOf_, objRef, vtable, TMP, currentBB_); push(r); } @@ -1838,9 +1821,6 @@ } }; - StructType* Compiler::VTableInfo::VTableTy; - StructType* Compiler::VTableInfo::TypeInfoTy; - } } } // namespace llvm::Java:: std::auto_ptr llvm::Java::compile(const std::string& className) From alkis at cs.uiuc.edu Thu Mar 31 01:56:40 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu, 31 Mar 2005 01:56:40 -0600 Subject: [llvm-commits] CVS: llvm-java/include/llvm/Java/Compiler.h Message-ID: <200503310756.BAA23026@zion.cs.uiuc.edu> Changes in directory llvm-java/include/llvm/Java: Compiler.h updated: 1.14 -> 1.15 --- Log message: Remove global variables. --- Diffs of the changes: (+0 -3) Compiler.h | 3 --- 1 files changed, 3 deletions(-) Index: llvm-java/include/llvm/Java/Compiler.h diff -u llvm-java/include/llvm/Java/Compiler.h:1.14 llvm-java/include/llvm/Java/Compiler.h:1.15 --- llvm-java/include/llvm/Java/Compiler.h:1.14 Wed Mar 23 22:47:47 2005 +++ llvm-java/include/llvm/Java/Compiler.h Thu Mar 31 01:56:28 2005 @@ -21,9 +21,6 @@ std::auto_ptr compile(const std::string& className); - extern Type* VTableBaseTy; - extern Type* VTableBaseRefTy; - } } // namespace llvm::Java #endif//LLVM_JAVA_COMPILER_H From duraid at octopus.com.au Thu Mar 31 06:31:22 2005 From: duraid at octopus.com.au (Duraid Madina) Date: Thu, 31 Mar 2005 06:31:22 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/IA64/IA64ISelPattern.cpp README Message-ID: <200503311231.GAA05951@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/IA64: IA64ISelPattern.cpp updated: 1.5 -> 1.6 README updated: 1.2 -> 1.3 --- Log message: Assorted fixes: * Stop being pessimistic about output register allocation * Start to handle function descriptors: compute target GPs and so on when doing indirect calls etc. Not there yet, though. For the moment, we try to use _indirect_ branches wherever possible, to stress test function descriptors. * FP divide-by-zero should work now * add varargs (it doesn't work, though) At this point, all of SingleSource passes (modulo C++ tests that are due to issues with the CFE, see note in the README.) Much of MultiSource also passes although there's still a ton of bugs around. Something for me to work on tomorrow, then. :) --- Diffs of the changes: (+138 -39) IA64ISelPattern.cpp | 173 ++++++++++++++++++++++++++++++++++++++++------------ README | 4 - 2 files changed, 138 insertions(+), 39 deletions(-) Index: llvm/lib/Target/IA64/IA64ISelPattern.cpp diff -u llvm/lib/Target/IA64/IA64ISelPattern.cpp:1.5 llvm/lib/Target/IA64/IA64ISelPattern.cpp:1.6 --- llvm/lib/Target/IA64/IA64ISelPattern.cpp:1.5 Fri Mar 25 19:29:23 2005 +++ llvm/lib/Target/IA64/IA64ISelPattern.cpp Thu Mar 31 06:31:11 2005 @@ -118,6 +118,12 @@ BuildMI(BB, IA64::MOV, 1, IA64::rp).addReg(RP); } + void restoreSP_RP(MachineBasicBlock* BB) + { + BuildMI(BB, IA64::MOV, 1, IA64::r12).addReg(SP); + BuildMI(BB, IA64::MOV, 1, IA64::rp).addReg(RP); + } + void restoreRP(MachineBasicBlock* BB) { BuildMI(BB, IA64::MOV, 1, IA64::rp).addReg(RP); @@ -159,9 +165,11 @@ unsigned argPreg[8]; unsigned argOpc[8]; - unsigned used_FPArgs=0; // how many FP args have been used so far? - + unsigned used_FPArgs = 0; // how many FP args have been used so far? + + unsigned ArgOffset = 0; int count = 0; + for (Function::arg_iterator I = F.arg_begin(), E = F.arg_end(); I != E; ++I) { SDOperand newroot, argt; @@ -206,8 +214,9 @@ } } else { // more than 8 args go into the frame // Create the frame index object for this incoming parameter... - int FI = MFI->CreateFixedObject(8, 16 + 8 * (count - 8)); - + ArgOffset = 16 + 8 * (count - 8); + int FI = MFI->CreateFixedObject(8, ArgOffset); + // Create the SelectionDAG nodes corresponding to a load //from this parameter SDOperand FIN = DAG.getFrameIndex(FI, MVT::i64); @@ -218,9 +227,10 @@ DAG.setRoot(newroot.getValue(1)); ArgValues.push_back(argt); } - -// Create a vreg to hold the output of (what will become) -// the "alloc" instruction + + + // Create a vreg to hold the output of (what will become) + // the "alloc" instruction VirtGPR = MF.getSSARegMap()->createVirtualRegister(getRegClassFor(MVT::i64)); BuildMI(&BB, IA64::PSEUDO_ALLOC, 0, VirtGPR); // we create a PSEUDO_ALLOC (pseudo)instruction for now @@ -239,10 +249,29 @@ BuildMI(&BB, IA64::MOV, 1, RP).addReg(IA64::rp); // ..hmm. + unsigned tempOffset=0; + + // if this is a varargs function, we simply lower llvm.va_start by + // pointing to the first entry + if(F.isVarArg()) { + tempOffset=0; + VarArgsFrameIndex = MFI->CreateFixedObject(8, tempOffset); + } + + // here we actually do the moving of args, and store them to the stack + // too if this is a varargs function: for (int i = 0; i < count && i < 8; ++i) { BuildMI(&BB, argOpc[i], 1, argVreg[i]).addReg(argPreg[i]); + if(F.isVarArg()) { + // if this is a varargs function, we copy the input registers to the stack + int FI = MFI->CreateFixedObject(8, tempOffset); + tempOffset+=8; //XXX: is it safe to use r22 like this? + BuildMI(&BB, IA64::MOV, 1, IA64::r22).addFrameIndex(FI); + // FIXME: we should use st8.spill here, one day + BuildMI(&BB, IA64::ST8, 1, IA64::r22).addReg(argPreg[i]); + } } - + return ArgValues; } @@ -253,19 +282,26 @@ MachineFunction &MF = DAG.getMachineFunction(); -// fow now, we are overly-conservative and pretend that all 8 -// outgoing registers (out0-out7) are always used. FIXME - -// update comment line 137 of MachineFunction.h - MF.getInfo()->outRegsUsed=8; - unsigned NumBytes = 16; - if (Args.size() > 8) + unsigned outRegsUsed = 0; + + if (Args.size() > 8) { NumBytes += (Args.size() - 8) * 8; + outRegsUsed = 8; + } else { + outRegsUsed = Args.size(); + } + + // FIXME? this WILL fail if we ever try to pass around an arg that + // consumes more than a single output slot (a 'real' double, int128 + // some sort of aggregate etc.), as we'll underestimate how many 'outX' + // registers we use. Hopefully, the assembler will notice. + MF.getInfo()->outRegsUsed= + std::max(outRegsUsed, MF.getInfo()->outRegsUsed); Chain = DAG.getNode(ISD::ADJCALLSTACKDOWN, MVT::Other, Chain, DAG.getConstant(NumBytes, getPointerTy())); - + std::vector args_to_use; for (unsigned i = 0, e = Args.size(); i != e; ++i) { @@ -317,11 +353,25 @@ std::pair IA64TargetLowering:: LowerVAArgNext(bool isVANext, SDOperand Chain, SDOperand VAList, const Type *ArgTy, SelectionDAG &DAG) { - - assert(0 && "LowerVAArgNext not done yet!\n"); - abort(); + + MVT::ValueType ArgVT = getValueType(ArgTy); + SDOperand Result; + if (!isVANext) { + Result = DAG.getLoad(ArgVT, DAG.getEntryNode(), VAList); + } else { + unsigned Amt; + if (ArgVT == MVT::i32 || ArgVT == MVT::f32) + Amt = 8; + else { + assert((ArgVT == MVT::i64 || ArgVT == MVT::f64) && + "Other types should have been promoted for varargs!"); + Amt = 8; + } + Result = DAG.getNode(ISD::ADD, VAList.getValueType(), VAList, + DAG.getConstant(Amt, VAList.getValueType())); + } + return std::make_pair(Result, Chain); } - std::pair IA64TargetLowering:: LowerFrameReturnAddress(bool isFrameAddress, SDOperand Chain, unsigned Depth, @@ -469,7 +519,8 @@ << " the stack alignment yet!"; abort(); } - + +/* Select(N.getOperand(0)); if (ConstantSDNode* CN = dyn_cast(N.getOperand(1))) { @@ -487,7 +538,11 @@ // Subtract size from stack pointer, thereby allocating some space. BuildMI(BB, IA64::SUB, 2, IA64::r12).addReg(IA64::r12).addReg(Tmp1); } - +*/ + Select(N.getOperand(0)); + Tmp1 = SelectExpr(N.getOperand(1)); + // Subtract size from stack pointer, thereby allocating some space. + BuildMI(BB, IA64::SUB, 2, IA64::r12).addReg(IA64::r12).addReg(Tmp1); // Put a pointer to the space into the result register, by copying the // stack pointer. BuildMI(BB, IA64::MOV, 1, Result).addReg(IA64::r12); @@ -569,16 +624,17 @@ case ISD::GlobalAddress: { GlobalValue *GV = cast(N)->getGlobal(); unsigned Tmp1 = MakeReg(MVT::i64); + BuildMI(BB, IA64::ADD, 2, Tmp1).addGlobalAddress(GV).addReg(IA64::r1); - //r1==GP BuildMI(BB, IA64::LD8, 1, Result).addReg(Tmp1); + return Result; } case ISD::ExternalSymbol: { const char *Sym = cast(N)->getSymbol(); - assert(0 && "ISD::ExternalSymbol not done yet\n"); - //XXX BuildMI(BB, IA64::MOV, 1, Result).addExternalSymbol(Sym); +// assert(0 && "sorry, but what did you want an ExternalSymbol for again?"); + BuildMI(BB, IA64::MOV, 1, Result).addExternalSymbol(Sym); // XXX return Result; } @@ -944,7 +1000,8 @@ case ISD::UREM: isModulus=true; isSigned=false; break; } - unsigned TmpPR=MakeReg(MVT::i1); // we need a scratch predicate register, + unsigned TmpPR=MakeReg(MVT::i1); // we need two scratch + unsigned TmpPR2=MakeReg(MVT::i1); // predicate registers, unsigned TmpF1=MakeReg(MVT::f64); // and one metric truckload of FP regs. unsigned TmpF2=MakeReg(MVT::f64); // lucky we have IA64? unsigned TmpF3=MakeReg(MVT::f64); // well, the real FIXME is to have @@ -960,7 +1017,7 @@ unsigned TmpF13=MakeReg(MVT::f64); unsigned TmpF14=MakeReg(MVT::f64); unsigned TmpF15=MakeReg(MVT::f64); - + // OK, emit some code: if(!isFP) { @@ -989,6 +1046,14 @@ BuildMI(BB, IA64::FRCPAS1FLOAT, 2, TmpF5).addReg(TmpF3).addReg(TmpF4); BuildMI(BB, IA64::FRCPAS1PREDICATE, 2, TmpPR).addReg(TmpF3).addReg(TmpF4); + if(!isModulus) { // if this is a divide, we worry about div-by-zero + unsigned bogusPR=MakeReg(MVT::i1); // won't appear, due to twoAddress + // TPCMPNE below + BuildMI(BB, IA64::CMPEQ, 2, bogusPR).addReg(IA64::r0).addReg(IA64::r0); + BuildMI(BB, IA64::TPCMPNE, 3, TmpPR2).addReg(bogusPR) + .addReg(IA64::r0).addReg(IA64::r0).addReg(TmpPR); + } + // now we apply newton's method, thrice! (FIXME: this is ~72 bits of // precision, don't need this much for f32/i32) BuildMI(BB, IA64::CFNMAS1, 4, TmpF6) @@ -1023,8 +1088,16 @@ } if(!isModulus) { - if(isFP) - BuildMI(BB, IA64::FMOV, 1, Result).addReg(TmpF15); + if(isFP) { // extra worrying about div-by-zero + unsigned bogoResult=MakeReg(MVT::f64); + + // we do a 'conditional fmov' (of the correct result, depending + // on how the frcpa predicate turned out) + BuildMI(BB, IA64::PFMOV, 2, bogoResult) + .addReg(TmpF12).addReg(TmpPR2); + BuildMI(BB, IA64::CFMOV, 2, Result) + .addReg(bogoResult).addReg(TmpF15).addReg(TmpPR); + } else BuildMI(BB, IA64::GETFSIG, 1, Result).addReg(TmpF15); } else { // this is a modulus @@ -1329,6 +1402,7 @@ case MVT::f64: BuildMI(BB, IA64::FMOV, 1, FPArgs[used_FPArgs++]) .addReg(argvregs[i]); + // FIXME: we don't need to do this _all_ the time: BuildMI(BB, IA64::GETFD, 1, intArgs[i]).addReg(argvregs[i]); break; } @@ -1363,6 +1437,9 @@ break; } } + + /* XXX we want to re-enable direct branches! crippling them now + * to stress-test indirect branches.: //build the right kind of call if (GlobalAddressSDNode *GASD = dyn_cast(N.getOperand(1))) @@ -1370,23 +1447,43 @@ BuildMI(BB, IA64::BRCALL, 1).addGlobalAddress(GASD->getGlobal(),true); IA64Lowering.restoreGP_SP_RP(BB); } - - else if (ExternalSymbolSDNode *ESSDN = + ^^^^^^^^^^^^^ we want this code one day XXX */ + if (ExternalSymbolSDNode *ESSDN = dyn_cast(N.getOperand(1))) - { - BuildMI(BB, IA64::BRCALL, 0) + { // FIXME : currently need this case for correctness, to avoid + // "non-pic code with imm relocation against dynamic symbol" errors + BuildMI(BB, IA64::BRCALL, 1) .addExternalSymbol(ESSDN->getSymbol(), true); IA64Lowering.restoreGP_SP_RP(BB); } else { - // no need to restore GP as we are doing an indirect call Tmp1 = SelectExpr(N.getOperand(1)); - // b6 is a scratch branch register, we load the target: - BuildMI(BB, IA64::MOV, 1, IA64::B6).addReg(Tmp1); + + unsigned targetEntryPoint=MakeReg(MVT::i64); + unsigned targetGPAddr=MakeReg(MVT::i64); + unsigned currentGP=MakeReg(MVT::i64); + + // b6 is a scratch branch register, we load the target entry point + // from the base of the function descriptor + BuildMI(BB, IA64::LD8, 1, targetEntryPoint).addReg(Tmp1); + BuildMI(BB, IA64::MOV, 1, IA64::B6).addReg(targetEntryPoint); + + // save the current GP: + BuildMI(BB, IA64::MOV, 1, currentGP).addReg(IA64::r1); + + /* TODO: we need to make sure doing this never, ever loads a + * bogus value into r1 (GP). */ + // load the target GP (which is at mem[functiondescriptor+8]) + BuildMI(BB, IA64::ADDIMM22, 2, targetGPAddr) + .addReg(Tmp1).addImm(8); // FIXME: addimm22? why not postincrement ld + BuildMI(BB, IA64::LD8, 1, IA64::r1).addReg(targetGPAddr); + // and then jump: (well, call) BuildMI(BB, IA64::BRCALL, 1).addReg(IA64::B6); - IA64Lowering.restoreGP_SP_RP(BB); - } + // and finally restore the old GP + BuildMI(BB, IA64::MOV, 1, IA64::r1).addReg(currentGP); + IA64Lowering.restoreSP_RP(BB); + } switch (Node->getValueType(0)) { default: assert(0 && "Unknown value type for call result!"); Index: llvm/lib/Target/IA64/README diff -u llvm/lib/Target/IA64/README:1.2 llvm/lib/Target/IA64/README:1.3 --- llvm/lib/Target/IA64/README:1.2 Thu Mar 17 14:23:27 2005 +++ llvm/lib/Target/IA64/README Thu Mar 31 06:31:11 2005 @@ -77,7 +77,9 @@ KNOWN DEFECTS AT THE CURRENT TIME: - - no varargs + - C++ vtables contain naked function pointers, not function descriptors, + which is bad. see http://llvm.cs.uiuc.edu/bugs/show_bug.cgi?id=406 + - varargs are broken - alloca doesn't work (indeed, stack frame layout is bogus) - no support for big-endian environments - (not really the backend, but...) the CFE has some issues on IA64. From alkis at cs.uiuc.edu Thu Mar 31 11:42:39 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu, 31 Mar 2005 11:42:39 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200503311742.LAA19183@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.270 -> 1.271 --- Log message: Change emitStaticInitializers to take a VMClass as a parameter. --- Diffs of the changes: (+16 -17) Compiler.cpp | 33 ++++++++++++++++----------------- 1 files changed, 16 insertions(+), 17 deletions(-) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.270 llvm-java/lib/Compiler/Compiler.cpp:1.271 --- llvm-java/lib/Compiler/Compiler.cpp:1.270 Thu Mar 31 01:56:28 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Thu Mar 31 11:42:28 2005 @@ -970,19 +970,17 @@ } /// Emits static initializers for this class if not done already. - void emitStaticInitializers(const ClassFile* classfile) { - typedef SetVector ClassFileSet; - static ClassFileSet toInitClasses; + void emitStaticInitializers(const VMClass* clazz) { + static SetVector toInitClasses; - if (toInitClasses.insert(classfile)) { + const ClassFile* classfile = clazz->getClassFile(); + if (!classfile) + return; + + if (toInitClasses.insert(clazz)) { // If this class has a super class, initialize that first. - if (classfile->getSuperClass()) - emitStaticInitializers( - ClassFile::get(classfile->getSuperClass()->getName()->str())); - - const std::string& className = - classfile->getThisClass()->getName()->str(); - const VMClass* clazz = resolver_->getClass(className); + if (const VMClass* superClass = clazz->getSuperClass()) + emitStaticInitializers(superClass); Function* hook = module_->getOrInsertFunction(LLVM_JAVA_STATIC_INIT, Type::VoidTy, 0); @@ -996,7 +994,8 @@ // Call its class initialization method if it exists. if (const Method* method = classfile->getMethod("()V")) { - const std::string& functionName = className + '/' + + const std::string& functionName = + classfile->getThisClass()->getName()->str() + '/' + method->getName()->str() + method->getDescriptor()->str(); Function* init = module_->getOrInsertFunction(functionName, Type::VoidTy, 0); @@ -1044,7 +1043,7 @@ while (true) { const ClassFile* classfile = ClassFile::get(className); - emitStaticInitializers(classfile); + emitStaticInitializers(resolver_->getClass(className)); Method* method = classfile->getMethod(methodNameAndDescr); if (method) @@ -1469,7 +1468,7 @@ void do_getstatic(unsigned index) { const VMField* field = class_->getField(index); - emitStaticInitializers(field->getParent()->getClassFile()); + emitStaticInitializers(field->getParent()); Value* v = new LoadInst(field->getGlobal(), TMP, currentBB_); push(v); @@ -1477,7 +1476,7 @@ void do_putstatic(unsigned index) { const VMField* field = class_->getField(index); - emitStaticInitializers(field->getParent()->getClassFile()); + emitStaticInitializers(field->getParent()); Value* v = pop(field->getClass()->getType()); new StoreInst(v, field->getGlobal(), currentBB_); @@ -1581,7 +1580,7 @@ void do_invokestatic(unsigned index) { const VMMethod* method = class_->getMethod(index); - emitStaticInitializers(method->getParent()->getClassFile()); + emitStaticInitializers(method->getParent()); Function* function = method->getFunction(); // Intercept java/lang/System/loadLibrary() calls and add // library deps to the module @@ -1669,7 +1668,7 @@ void do_new(unsigned index) { const VMClass* clazz = class_->getClass(index); - emitStaticInitializers(clazz->getClassFile()); + emitStaticInitializers(clazz); const VTableInfo& vi = getVTableInfo(clazz); push(allocateObject(*clazz, vi, currentBB_)); From alkis at cs.uiuc.edu Thu Mar 31 12:12:30 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu, 31 Mar 2005 12:12:30 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMClass.h VMClass.cpp Message-ID: <200503311812.MAA19439@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMClass.h updated: 1.24 -> 1.25 VMClass.cpp updated: 1.32 -> 1.33 --- Log message: Provide methods to get VMFields and VMMethods by name. Simplify implementation of lookupField() and lookupMethod(). --- Diffs of the changes: (+22 -20) VMClass.cpp | 32 +++++++++++++------------------- VMClass.h | 10 +++++++++- 2 files changed, 22 insertions(+), 20 deletions(-) Index: llvm-java/lib/Compiler/VMClass.h diff -u llvm-java/lib/Compiler/VMClass.h:1.24 llvm-java/lib/Compiler/VMClass.h:1.25 --- llvm-java/lib/Compiler/VMClass.h:1.24 Wed Mar 30 23:10:29 2005 +++ llvm-java/lib/Compiler/VMClass.h Thu Mar 31 12:12:19 2005 @@ -51,7 +51,7 @@ void computeLayout(); void computeClassRecord(); const VMField* lookupField(const std::string& name) const; - const VMMethod* lookupMethod(const std::string& name) const; + const VMMethod* lookupMethod(const std::string& nameAndType) const; friend class Resolver; @@ -95,7 +95,15 @@ llvm::Constant* getConstant(unsigned index) const; const VMClass* getClass(unsigned index) const; const VMField* getField(unsigned index) const; + const VMField* getField(const std::string& name) const { + FieldMap::const_iterator it = fieldMap_.find(name); + return it == fieldMap_.end() ? NULL : &it->second; + } const VMMethod* getMethod(unsigned index) const; + const VMMethod* getMethod(const std::string& nameAndType) const { + MethodMap::const_iterator it = methodMap_.find(nameAndType); + return it == methodMap_.end() ? NULL : &it->second; + } }; } } // namespace llvm::Java Index: llvm-java/lib/Compiler/VMClass.cpp diff -u llvm-java/lib/Compiler/VMClass.cpp:1.32 llvm-java/lib/Compiler/VMClass.cpp:1.33 --- llvm-java/lib/Compiler/VMClass.cpp:1.32 Thu Mar 31 01:55:42 2005 +++ llvm-java/lib/Compiler/VMClass.cpp Thu Mar 31 12:12:19 2005 @@ -72,47 +72,41 @@ const VMField* VMClass::lookupField(const std::string& name) const { - FieldMap::const_iterator it = fieldMap_.find(name); - if (it != fieldMap_.end()) - return &it->second; + if (const VMField* field = getField(name)) + return field; for (unsigned i = 0, e = getNumInterfaces(); i != e; ++i) { const VMClass* interface = getInterface(i); - it = interface->fieldMap_.find(name); - if (it != interface->fieldMap_.end()) - return &it->second; + if (const VMField* field = interface->getField(name)) + return field; } for (unsigned i = 0, e = getNumSuperClasses(); i != e; ++i) { const VMClass* superClass = getSuperClass(i); - it = superClass->fieldMap_.find(name); - if (it != superClass->fieldMap_.end()) - return &it->second; + if (const VMField* field = superClass->getField(name)) + return field; } assert(0 && "Field not found!"); abort(); } -const VMMethod* VMClass::lookupMethod(const std::string& name) const +const VMMethod* VMClass::lookupMethod(const std::string& nameAndType) const { - MethodMap::const_iterator it = methodMap_.find(name); - if (it != methodMap_.end()) - return &it->second; + if (const VMMethod* method = getMethod(nameAndType)) + return method; if (isInterface()) for (unsigned i = 0, e = getNumInterfaces(); i != e; ++i) { const VMClass* interface = getInterface(i); - it = interface->methodMap_.find(name); - if (it != interface->methodMap_.end()) - return &it->second; + if (const VMMethod* method = interface->getMethod(nameAndType)) + return method; } else for (unsigned i = 0, e = getNumSuperClasses(); i != e; ++i) { const VMClass* superClass = getSuperClass(i); - it = superClass->methodMap_.find(name); - if (it != superClass->methodMap_.end()) - return &it->second; + if (const VMMethod* method = superClass->getMethod(nameAndType)) + return method; } assert(0 && "Method not found!"); From natebegeman at mac.com Thu Mar 31 13:18:30 2005 From: natebegeman at mac.com (Nate Begeman) Date: Thu, 31 Mar 2005 13:18:30 -0600 Subject: [llvm-commits] CVS: llvm-test/Makefile.programs Message-ID: <200503311918.NAA19976@zion.cs.uiuc.edu> Changes in directory llvm-test: Makefile.programs updated: 1.150 -> 1.151 --- Log message: Change PPC beta option from Loop Strength Reduce to Pattern ISel until Pattern ISel has subsumed the Simple ISel. --- Diffs of the changes: (+1 -1) Makefile.programs | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm-test/Makefile.programs diff -u llvm-test/Makefile.programs:1.150 llvm-test/Makefile.programs:1.151 --- llvm-test/Makefile.programs:1.150 Tue Mar 15 17:12:39 2005 +++ llvm-test/Makefile.programs Thu Mar 31 13:18:19 2005 @@ -187,7 +187,7 @@ endif#DISABLE_DIFFS ifeq ($(ARCH),PowerPC) -LLCBETAOPTION := -enable-lsr-for-ppc +LLCBETAOPTION := -enable-ppc-pattern-isel else ifeq ($(ARCH),Alpha) LLCBETAOPTION := -enable-lsr-for-alpha From alkis at cs.uiuc.edu Thu Mar 31 13:33:48 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu, 31 Mar 2005 13:33:48 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMMethod.h Compiler.cpp Message-ID: <200503311933.NAA20147@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMMethod.h updated: 1.1 -> 1.2 Compiler.cpp updated: 1.271 -> 1.272 --- Log message: Use VMMethod in Compiler and simplify a lot of code in it (eliminate recursive method lookups for example). --- Diffs of the changes: (+111 -165) Compiler.cpp | 265 ++++++++++++++++++++++------------------------------------- VMMethod.h | 11 ++ 2 files changed, 111 insertions(+), 165 deletions(-) Index: llvm-java/lib/Compiler/VMMethod.h diff -u llvm-java/lib/Compiler/VMMethod.h:1.1 llvm-java/lib/Compiler/VMMethod.h:1.2 --- llvm-java/lib/Compiler/VMMethod.h:1.1 Wed Mar 30 23:10:29 2005 +++ llvm-java/lib/Compiler/VMMethod.h Thu Mar 31 13:33:37 2005 @@ -41,12 +41,21 @@ public: const VMClass* getParent() const { return parent_; } + const Method* getMethod() const { return method_; } Function* getFunction() const { return function_; } + bool isAbstract() const { return method_->isAbstract(); } + bool isNative() const { return method_->isNative(); } + bool isStatic() const { return method_->isStatic(); } // FIXME: remove when transition is complete. + const std::string& getName() const { return method_->getName()->str(); } + const std::string& getDescriptor() const { + return method_->getDescriptor()->str(); + } std::string getNameAndDescriptor() const { - return method_->getName()->str() + method_->getDescriptor()->str(); + return getName() + getDescriptor(); } + }; } } // namespace llvm::Java Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.271 llvm-java/lib/Compiler/Compiler.cpp:1.272 --- llvm-java/lib/Compiler/Compiler.cpp:1.271 Thu Mar 31 11:42:28 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Thu Mar 31 13:33:37 2005 @@ -64,10 +64,9 @@ Locals locals_; OperandStack opStack_; Function *getVtable_, *setVtable_, *throw_, *isInstanceOf_, - *memcpy_, *memset_; + *memcpy_, *memset_, *staticInit_; - typedef SetVector FunctionSet; - FunctionSet toCompileFunctions_; + SetVector toCompileMethods_; /// This class contains the vtable of a class, a vector with the /// vtables of its super classes (with the class higher in the @@ -121,6 +120,10 @@ "llvm.memset", Type::VoidTy, PointerType::get(Type::SByteTy), Type::UByteTy, Type::ULongTy, Type::UIntTy, NULL); + staticInit_ = + module_->getOrInsertFunction(LLVM_JAVA_STATIC_INIT, Type::VoidTy, NULL); + BasicBlock* staticInitBB = new BasicBlock("entry", staticInit_); + new ReturnInst(NULL, staticInitBB); } private: @@ -134,10 +137,10 @@ /// Schedule a method for compilation. Returns true if this is the /// first time this function was scheduled. - bool scheduleFunction(Function* function) { - if (toCompileFunctions_.insert(function)) { - DEBUG(std::cerr << "Scheduling function: " << function->getName() - << " for compilation\n"); + bool scheduleMethod(const VMMethod* method) { + if (toCompileMethods_.insert(method)) { + DEBUG(std::cerr << "Scheduling function: " + << method->getFunction()->getName() << " for compilation\n"); return true; } return false; @@ -181,6 +184,8 @@ // Get class information for java/lang/String. const VMClass* clazz = resolver_->getClass("java/lang/String"); + emitStaticInitializers(clazz); + const VTableInfo* vi = getVTableInfoGeneric(clazz); // Install the vtable pointer. @@ -191,22 +196,21 @@ new CallInst(setVtable_, objBase, vtable, "", ip); // Initialize it: call java/lang/String/(byte[],int) - Method* method = getMethod("java/lang/String/([BI)V"); - Function* function = getFunction(method); - scheduleFunction(function); + const VMMethod* method = clazz->getMethod("([BI)V"); + scheduleMethod(method); params.reserve(3); params.clear(); params.push_back(objBase); params.push_back(new CastInst(arrayRef, resolver_->getObjectBaseType(), TMP, ip)); params.push_back(ConstantSInt::get(Type::IntTy, 0)); - new CallInst(function, params, "", ip); + new CallInst(method->getFunction(), params, "", ip); } /// Returns the type of the Java string descriptor for JNI. - const Type* getJNIType(ConstantUtf8* descr) { + const Type* getJNIType(const std::string& descr) { unsigned i = 0; - return getJNITypeHelper(descr->str(), i); + return getJNITypeHelper(descr, i); } const Type* getJNITypeHelper(const std::string& descr, unsigned& i) { @@ -303,16 +307,11 @@ if (!method->isStatic() && !method->isPrivate() && method->getName()->str()[0] != '<') { - std::string methodDescr = - method->getName()->str() + - method->getDescriptor()->str(); - - std::string funcName = "java/lang/Object/" + methodDescr; - const FunctionType* funcTy = cast( - resolver_->getType(method->getDescriptor()->str(), true)); + const std::string& methodDescr = + method->getName()->str() + method->getDescriptor()->str(); - Function* vfun = module_->getOrInsertFunction(funcName, funcTy); - scheduleFunction(vfun); + const VMMethod* method = clazz->getMethod(methodDescr); + scheduleMethod(method); unsigned& index = vi.m2iMap[methodDescr]; if (!index) { @@ -320,8 +319,8 @@ elements.resize(index + 1, NULL); init.resize(index + 1, NULL); } - elements[index] = vfun->getType(); - init[index] = vfun; + elements[index] = method->getFunction()->getType(); + init[index] = method->getFunction(); } } @@ -588,24 +587,19 @@ const std::string& methodDescr = method->getName()->str() + method->getDescriptor()->str(); - std::string funcName = className + '/' + methodDescr; - - const FunctionType* funcTy = cast( - resolver_->getType(method->getDescriptor()->str(), true)); - llvm::Constant* vfun = NULL; + const VMMethod* method = clazz->getMethod(methodDescr); + llvm::Constant* vf = method->getFunction(); if (clazz->isInterface() || method->isAbstract()) - vfun = llvm::Constant::getNullValue(PointerType::get(funcTy)); - else { - vfun = module_->getOrInsertFunction(funcName, funcTy); - scheduleFunction(cast(vfun)); - } + vf = llvm::Constant::getNullValue(method->getFunction()->getType()); + else + scheduleMethod(method); unsigned& index = vi.m2iMap[methodDescr]; if (!index) { index = init.size(); init.resize(index + 1); } - init[index] = vfun; + init[index] = vf; } } @@ -790,38 +784,40 @@ /// Compiles the passed method only (it does not compile any /// callers or methods of objects it creates). - Function* compileMethodOnly(const std::string& classMethodDesc) { - Method* method = getMethod(classMethodDesc); - const std::string& className = - method->getParent()->getThisClass()->getName()->str(); - class_ = resolver_->getClass(className); + void compileMethodOnly(const VMMethod* method) { + class_ = method->getParent(); - Function* function = getFunction(method); + Function* function = method->getFunction(); if (!function->empty()) { - DEBUG(std::cerr << "Function: " << function->getName() << " is already compiled!\n"); - return function; + DEBUG(std::cerr << "Function: " << function->getName() + << " is already compiled!\n"); + return; } + const std::string& className = + class_->getClassFile()->getThisClass()->getName()->str(); + if (method->isNative()) { DEBUG(std::cerr << "Adding stub for natively implemented method: " - << classMethodDesc << '\n'); + << function->getName() << '\n'); const FunctionType* jniFuncTy = cast(getJNIType(method->getDescriptor())); std::string funcName = "Java_" + getMangledString(className) + '_' + - getMangledString(method->getName()->str()); - if (class_->getClassFile()->isNativeMethodOverloaded(*method)) { + getMangledString(method->getName()); + if (class_->getClassFile()->isNativeMethodOverloaded(*method->getMethod())) { // We need to add two underscores and a mangled argument signature funcName += "__"; - const std::string descr = method->getDescriptor()->str(); + const std::string descr = method->getDescriptor(); funcName += getMangledString( std::string(descr.begin() + descr.find('(') + 1, descr.begin() + descr.find(')'))); } - Function* jniFunction = module_->getOrInsertFunction(funcName,jniFuncTy); + Function* jniFunction = + module_->getOrInsertFunction(funcName, jniFuncTy); BasicBlock* bb = new BasicBlock("entry", function); std::vector params; @@ -838,46 +834,47 @@ result = new CastInst(result, function->getReturnType(), TMP,bb); new ReturnInst(result, bb); - return function; + return; } assert (!method->isAbstract() && "Trying to compile an abstract method!"); // HACK: skip most of the class libraries. - if ((classMethodDesc.find("java/") == 0 && - classMethodDesc.find("java/lang/Object") != 0 && - (classMethodDesc.find("java/lang/Throwable") != 0 || - classMethodDesc.find("java/lang/Throwable$StaticData/getName(); + if ((funcName.find("java/") == 0 && + funcName.find("java/lang/Object") != 0 && + (funcName.find("java/lang/Throwable") != 0 || + funcName.find("java/lang/Throwable$StaticData/getCodeAttribute(); + Java::CodeAttribute* codeAttr = method->getMethod()->getCodeAttribute(); opStackDepthMap_.clear(); bbBuilder_.reset(new BasicBlockBuilder(function, codeAttr)); @@ -962,11 +959,8 @@ else ++bb; - DEBUG(std::cerr << "Finished compilation of method: " - << classMethodDesc << '\n'); + DEBUG(std::cerr << "Finished compilation of method: "<< funcName << '\n'); // DEBUG(function->dump()); - - return function; } /// Emits static initializers for this class if not done already. @@ -982,9 +976,7 @@ if (const VMClass* superClass = clazz->getSuperClass()) emitStaticInitializers(superClass); - Function* hook = module_->getOrInsertFunction(LLVM_JAVA_STATIC_INIT, - Type::VoidTy, 0); - Instruction* I = hook->front().getTerminator(); + Instruction* I = staticInit_->front().getTerminator(); assert(I && LLVM_JAVA_STATIC_INIT " should have a terminator!"); // Create constant strings for this class. @@ -993,95 +985,38 @@ initializeString(clazz->getConstant(i), s->getValue()->str(), I); // Call its class initialization method if it exists. - if (const Method* method = classfile->getMethod("()V")) { - const std::string& functionName = - classfile->getThisClass()->getName()->str() + '/' + - method->getName()->str() + method->getDescriptor()->str(); - Function* init = - module_->getOrInsertFunction(functionName, Type::VoidTy, 0); - + if (const VMMethod* method = clazz->getMethod("()V")) { // Insert a call to it right before the terminator of the only // basic block in llvm_java_static_init. - bool inserted = scheduleFunction(init); + bool inserted = scheduleMethod(method); assert(inserted && "Class initialization method already called!"); - new CallInst(init, "", I); + new CallInst(method->getFunction(), "", I); } } } - /// Returns the llvm::Function corresponding to the specified - /// llvm::Java::Method. - Function* getFunction(Method* method) { - const ClassFile* clazz = method->getParent(); - - const FunctionType* funcTy = cast( - resolver_->getType(method->getDescriptor()->str(), - !method->isStatic())); - std::string funcName = - clazz->getThisClass()->getName()->str() + '/' + - method->getName()->str() + method->getDescriptor()->str(); - - Function* function = module_->getOrInsertFunction(funcName, funcTy); - - return function; - } - - /// Returns the llvm::Java::Method given a - /// llvm::Java::ClassMethodRef. - Method* getMethod(ConstantMethodRef* methodRef) { - return getMethod(methodRef->getClass()->getName()->str() + '/' + - methodRef->getNameAndType()->getName()->str() + - methodRef->getNameAndType()->getDescriptor()->str()); - } - - /// Returns the llvm::Java::Method given a - /// descriptor. - Method* getMethod(const std::string& classMethodDesc) { - unsigned slash = classMethodDesc.rfind('/', classMethodDesc.find('(')); - std::string className = classMethodDesc.substr(0, slash); - std::string methodNameAndDescr = classMethodDesc.substr(slash+1); - - while (true) { - const ClassFile* classfile = ClassFile::get(className); - emitStaticInitializers(resolver_->getClass(className)); - - Method* method = classfile->getMethod(methodNameAndDescr); - if (method) - return method; - - if (!classfile->getSuperClass()) - break; - - className = classfile->getSuperClass()->getName()->str(); - } - - throw InvocationTargetException("Method " + methodNameAndDescr + - " not found in class " + className); - } - public: /// Compiles the specified method given a /// descriptor and the transitive closure of all methods /// (possibly) called by it. - Function* compileMethod(const std::string& classMethodDesc) { - // Initialize the static initializer function. - Function* staticInit = - module_->getOrInsertFunction(LLVM_JAVA_STATIC_INIT, Type::VoidTy, 0); - BasicBlock* staticInitBB = new BasicBlock("entry", staticInit); - new ReturnInst(NULL, staticInitBB); + const VMMethod* compileMethod(const std::string& className, + const std::string& methodDesc) { + // Load the class. + const VMClass* clazz = resolver_->getClass(className); + emitStaticInitializers(clazz); - // Create the method requested. - Function* function = getFunction(getMethod(classMethodDesc)); - scheduleFunction(function); + // Find the method. + const VMMethod* method = clazz->getMethod(methodDesc); + scheduleMethod(method); // Compile the transitive closure of methods called by this method. - for (unsigned i = 0; i != toCompileFunctions_.size(); ++i) { - Function* f = toCompileFunctions_[i]; - compileMethodOnly(f->getName()); - DEBUG(std::cerr << i+1 << '/' << toCompileFunctions_.size() + for (unsigned i = 0; i != toCompileMethods_.size(); ++i) { + const VMMethod* m = toCompileMethods_[i]; + compileMethodOnly(m); + DEBUG(std::cerr << i+1 << '/' << toCompileMethods_.size() << " functions compiled\n"); } - return function; + return method; } void do_aconst_null() { @@ -1573,8 +1508,8 @@ void do_invokespecial(unsigned index) { const VMMethod* method = class_->getMethod(index); + scheduleMethod(method); Function* function = method->getFunction(); - scheduleFunction(function); makeCall(function, getParams(function->getFunctionType())); } @@ -1594,7 +1529,7 @@ new ReturnInst(NULL, new BasicBlock("entry", function)); } else - scheduleFunction(function); + scheduleMethod(method); makeCall(function, getParams(function->getFunctionType())); } @@ -1831,14 +1766,16 @@ m->addLibrary("jrt"); Compiler c(m.get()); - Function* main = c.compileMethod(className + "/main([Ljava/lang/String;)V"); + const VMMethod* main = + c.compileMethod(className, "main([Ljava/lang/String;)V"); + Function* javaMain = m->getOrInsertFunction ("llvm_java_main", Type::VoidTy, Type::IntTy, PointerType::get(PointerType::get(Type::SByteTy)), NULL); BasicBlock* bb = new BasicBlock("entry", javaMain); - const FunctionType* mainTy = main->getFunctionType(); - new CallInst(main, + const FunctionType* mainTy = main->getFunction()->getFunctionType(); + new CallInst(main->getFunction(), // FIXME: Forward correct params from llvm_java_main llvm::Constant::getNullValue(mainTy->getParamType(0)), "", From alenhar2 at cs.uiuc.edu Thu Mar 31 15:24:22 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Thu, 31 Mar 2005 15:24:22 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp SelectionDAG.cpp LegalizeDAG.cpp Message-ID: <200503312124.j2VLOMWE030087@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: SelectionDAGISel.cpp updated: 1.36 -> 1.37 SelectionDAG.cpp updated: 1.53 -> 1.54 LegalizeDAG.cpp updated: 1.63 -> 1.64 --- Log message: PCMarker support for DAG and Alpha --- Diffs of the changes: (+11 -0) LegalizeDAG.cpp | 4 ++++ SelectionDAG.cpp | 1 + SelectionDAGISel.cpp | 6 ++++++ 3 files changed, 11 insertions(+) Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.36 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.37 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.36 Tue Mar 29 19:10:47 2005 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Thu Mar 31 15:24:06 2005 @@ -662,6 +662,12 @@ setValue(&I, DAG.getSetCC(ISD::SETUO, MVT::i1, getValue(I.getOperand(1)), getValue(I.getOperand(2)))); return; + case Intrinsic::pcmarker: { + SDOperand Num = getValue(I.getOperand(1)); + DAG.setRoot(DAG.getNode(ISD::PCMARKER, MVT::Other, getRoot(), Num)); + return; + } + } SDOperand Callee; Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.53 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.54 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.53 Thu Mar 10 14:55:51 2005 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Thu Mar 31 15:24:06 2005 @@ -1099,6 +1099,7 @@ const char *SDNode::getOperationName() const { switch (getOpcode()) { default: return "<>"; + case ISD::PCMARKER: return "PCMarker"; case ISD::EntryToken: return "EntryToken"; case ISD::TokenFactor: return "TokenFactor"; case ISD::Constant: return "Constant"; Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.63 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.64 --- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.63 Mon Mar 28 16:03:13 2005 +++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Thu Mar 31 15:24:06 2005 @@ -552,6 +552,10 @@ break; } break; + case ISD::PCMARKER: + Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the chain. + Result = DAG.getNode(ISD::PCMARKER, MVT::Other, Tmp1, Node->getOperand(1)); + break; case ISD::TRUNCSTORE: Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the chain. Tmp3 = LegalizeOp(Node->getOperand(2)); // Legalize the pointer. From alenhar2 at cs.uiuc.edu Thu Mar 31 15:24:23 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Thu, 31 Mar 2005 15:24:23 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/SelectionDAGNodes.h Message-ID: <200503312124.j2VLONuA030096@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: SelectionDAGNodes.h updated: 1.21 -> 1.22 --- Log message: PCMarker support for DAG and Alpha --- Diffs of the changes: (+2 -0) SelectionDAGNodes.h | 2 ++ 1 files changed, 2 insertions(+) Index: llvm/include/llvm/CodeGen/SelectionDAGNodes.h diff -u llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.21 llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.22 --- llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.21 Fri Jan 21 15:39:38 2005 +++ llvm/include/llvm/CodeGen/SelectionDAGNodes.h Thu Mar 31 15:24:06 2005 @@ -225,6 +225,8 @@ ADJCALLSTACKDOWN, // Beginning of a call sequence ADJCALLSTACKUP, // End of a call sequence + // PCMARKER - This corrosponds to the pcmarker intrinsic. + PCMARKER, // BUILTIN_OP_END - This must be the last enum value in this list. BUILTIN_OP_END, From alenhar2 at cs.uiuc.edu Thu Mar 31 15:24:22 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Thu, 31 Mar 2005 15:24:22 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaInstrInfo.td AlphaISelPattern.cpp Message-ID: <200503312124.j2VLOMe2030080@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaInstrInfo.td updated: 1.35 -> 1.36 AlphaISelPattern.cpp updated: 1.70 -> 1.71 --- Log message: PCMarker support for DAG and Alpha --- Diffs of the changes: (+17 -0) AlphaISelPattern.cpp | 15 +++++++++++++++ AlphaInstrInfo.td | 2 ++ 2 files changed, 17 insertions(+) Index: llvm/lib/Target/Alpha/AlphaInstrInfo.td diff -u llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.35 llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.36 --- llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.35 Tue Mar 22 10:42:52 2005 +++ llvm/lib/Target/Alpha/AlphaInstrInfo.td Thu Mar 31 15:24:05 2005 @@ -30,6 +30,8 @@ def ADJUSTSTACKUP : PseudoInstAlpha<(ops ), "ADJUP">; def ADJUSTSTACKDOWN : PseudoInstAlpha<(ops ), "ADJDOWN">; +def PCLABEL : PseudoInstAlpha<(ops s64imm:$num), "PCMARKER_$num:\n">; + //***************** //These are shortcuts, the assembler expands them //***************** Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.70 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.71 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.70 Wed Mar 30 12:22:52 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Thu Mar 31 15:24:05 2005 @@ -27,10 +27,20 @@ #include "llvm/Support/MathExtras.h" #include "llvm/ADT/Statistic.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/CommandLine.h" #include #include using namespace llvm; +namespace llvm { + cl::opt EnableAlphaIDIV("enable-alpha-intfpdiv", + cl::desc("Use the FP div instruction for integer div when possible"), + cl::Hidden); + cl::opt EnableAlpha("enable-alpha-ftoi", + cl::desc("Enablue use of ftoi* and itof* instructions (ev6 and higher)"), + cl::Hidden); +} + //===----------------------------------------------------------------------===// // AlphaTargetLowering - Alpha Implementation of the TargetLowering interface namespace { @@ -1697,6 +1707,11 @@ Alpha::ADJUSTSTACKUP; BuildMI(BB, Opc, 1).addImm(Tmp1); return; + + case ISD::PCMARKER: + Select(N.getOperand(0)); //Chain + BuildMI(BB, Alpha::PCLABEL, 2).addImm( cast(N.getOperand(1))->getValue()); + return; } assert(0 && "Should not be reached!"); } From brukman at cs.uiuc.edu Thu Mar 31 15:30:46 2005 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Thu, 31 Mar 2005 15:30:46 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/SelectionDAGNodes.h Message-ID: <200503312130.PAA21334@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: SelectionDAGNodes.h updated: 1.22 -> 1.23 --- Log message: Fix spelling of `corresponds' --- Diffs of the changes: (+1 -1) SelectionDAGNodes.h | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/include/llvm/CodeGen/SelectionDAGNodes.h diff -u llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.22 llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.23 --- llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.22 Thu Mar 31 15:24:06 2005 +++ llvm/include/llvm/CodeGen/SelectionDAGNodes.h Thu Mar 31 15:30:35 2005 @@ -225,7 +225,7 @@ ADJCALLSTACKDOWN, // Beginning of a call sequence ADJCALLSTACKUP, // End of a call sequence - // PCMARKER - This corrosponds to the pcmarker intrinsic. + // PCMARKER - This corresponds to the pcmarker intrinsic. PCMARKER, // BUILTIN_OP_END - This must be the last enum value in this list. From alenhar2 at cs.uiuc.edu Thu Mar 31 16:02:40 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Thu, 31 Mar 2005 16:02:40 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp Message-ID: <200503312202.j2VM2eeW030316@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.71 -> 1.72 --- Log message: make fp div trick dependend on flag --- Diffs of the changes: (+2 -2) AlphaISelPattern.cpp | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.71 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.72 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.71 Thu Mar 31 15:24:05 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Thu Mar 31 16:02:25 2005 @@ -37,7 +37,7 @@ cl::desc("Use the FP div instruction for integer div when possible"), cl::Hidden); cl::opt EnableAlpha("enable-alpha-ftoi", - cl::desc("Enablue use of ftoi* and itof* instructions (ev6 and higher)"), + cl::desc("Enable use of ftoi* and itof* instructions (ev6 and higher)"), cl::Hidden); } @@ -1061,7 +1061,7 @@ case ISD::SIGN_EXTEND_INREG: { //do SDIV opt for all levels of ints - if (N.getOperand(0).getOpcode() == ISD::SDIV) + if (EnableAlphaIDIV && N.getOperand(0).getOpcode() == ISD::SDIV) { Tmp1 = SelectExpr(N.getOperand(0).getOperand(0)); Tmp2 = SelectExpr(N.getOperand(0).getOperand(1)); From natebegeman at mac.com Thu Mar 31 17:55:51 2005 From: natebegeman at mac.com (Nate Begeman) Date: Thu, 31 Mar 2005 17:55:51 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Message-ID: <200503312355.RAA29000@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPC32ISelPattern.cpp updated: 1.22 -> 1.23 --- Log message: fsel generation for f32 and f64 select generate compare immediate for integer compare with constant fold setcc into branch fold setcc into select Code generation quality for Shootout is now on par with the Simple ISel --- Diffs of the changes: (+181 -35) PPC32ISelPattern.cpp | 216 ++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 181 insertions(+), 35 deletions(-) Index: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp diff -u llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.22 llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.23 --- llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.22 Wed Mar 30 20:05:53 2005 +++ llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Thu Mar 31 17:55:40 2005 @@ -54,6 +54,9 @@ setOperationAction(ISD::SEXTLOAD, MVT::i1, Expand); setOperationAction(ISD::SEXTLOAD, MVT::i8, Expand); + addLegalFPImmediate(+0.0); // Necessary for FSEL + addLegalFPImmediate(-0.0); // + computeRegisterProperties(); } @@ -478,7 +481,7 @@ /// placed in Imm. /// static unsigned canUseAsImmediateForOpcode(SDOperand N, unsigned Opcode, - unsigned& Imm) { + unsigned& Imm, bool U = false) { if (N.getOpcode() != ISD::Constant) return 0; int v = (int)cast(N)->getSignExtended(); @@ -498,9 +501,33 @@ case ISD::MUL: if (v <= 32767 && v >= -32768) { Imm = v & 0xFFFF; return 1; } break; + case ISD::SETCC: + if (U && (v >= 0 && v <= 65535)) { Imm = v & 0xFFFF; return 1; } + if (!U && (v <= 32767 && v >= -32768)) { Imm = v & 0xFFFF; return 1; } + break; } return 0; } + +/// getBCCForSetCC - Returns the PowerPC condition branch mnemonic corresponding +/// to Condition. If the Condition is unordered or unsigned, the bool argument +/// U is set to true, otherwise it is set to false. +static unsigned getBCCForSetCC(unsigned Condition, bool& U) { + U = false; + switch (Condition) { + default: assert(0 && "Unknown condition!"); abort(); + case ISD::SETEQ: return PPC::BEQ; + case ISD::SETNE: return PPC::BNE; + case ISD::SETULT: U = true; + case ISD::SETLT: return PPC::BLT; + case ISD::SETULE: U = true; + case ISD::SETLE: return PPC::BLE; + case ISD::SETUGT: U = true; + case ISD::SETGT: return PPC::BGT; + case ISD::SETUGE: U = true; + case ISD::SETGE: return PPC::BGE; + } +} } /// getGlobalBaseReg - Output the instructions required to put the @@ -539,15 +566,39 @@ assert(N.getOpcode() == ISD::BRCOND && "Not a BranchCC???"); MachineBasicBlock *Dest = cast(N.getOperand(2))->getBasicBlock(); - unsigned Opc; - + + unsigned Opc, Tmp1, Tmp2; Select(N.getOperand(0)); //chain - SDOperand CC = N.getOperand(1); - - //Give up and do the stupid thing - unsigned Tmp1 = SelectExpr(CC); - BuildMI(BB, PPC::CMPLWI, 2, PPC::CR0).addReg(Tmp1).addImm(0); - BuildMI(BB, PPC::BNE, 2).addReg(PPC::CR0).addMBB(Dest); + + // If the first operand to the select is a SETCC node, then we can fold it + // into the branch that selects which value to return. + SetCCSDNode* SetCC = dyn_cast(N.getOperand(1).Val); + if (SetCC && N.getOperand(1).getOpcode() == ISD::SETCC && + MVT::isInteger(SetCC->getOperand(0).getValueType())) { + bool U; + Opc = getBCCForSetCC(SetCC->getCondition(), U); + Tmp1 = SelectExpr(SetCC->getOperand(0)); + + // Pass the optional argument U to canUseAsImmediateForOpcode for SETCC, + // so that it knows whether the SETCC immediate range is signed or not. + if (1 == canUseAsImmediateForOpcode(SetCC->getOperand(1), ISD::SETCC, + Tmp2, U)) { + if (U) + BuildMI(BB, PPC::CMPLWI, 2, PPC::CR0).addReg(Tmp1).addImm(Tmp2); + else + BuildMI(BB, PPC::CMPWI, 2, PPC::CR0).addReg(Tmp1).addSImm(Tmp2); + } else { + Tmp2 = SelectExpr(SetCC->getOperand(1)); + BuildMI(BB, U ? PPC::CMPLW : PPC::CMPW, 2, PPC::CR0).addReg(Tmp1) + .addReg(Tmp2); + } + } else { + Tmp1 = SelectExpr(N.getOperand(1)); + BuildMI(BB, PPC::CMPLWI, 2, PPC::CR0).addReg(Tmp1).addImm(0); + Opc = PPC::BNE; + } + + BuildMI(BB, Opc, 2).addReg(PPC::CR0).addMBB(Dest); return; } @@ -565,10 +616,77 @@ assert(0 && "Node not handled!\n"); case ISD::SELECT: { - Tmp1 = SelectExpr(N.getOperand(0)); //Cond - - // FIXME: generate FSEL here - + // Attempt to generate FSEL. We can do this whenever we have an FP result, + // and an FP comparison in the SetCC node. + SetCCSDNode* SetCC = dyn_cast(N.getOperand(0).Val); + if (SetCC && N.getOperand(0).getOpcode() == ISD::SETCC && + !MVT::isInteger(SetCC->getOperand(0).getValueType()) && + SetCC->getCondition() != ISD::SETEQ && + SetCC->getCondition() != ISD::SETNE) { + MVT::ValueType VT = SetCC->getOperand(0).getValueType(); + Tmp1 = SelectExpr(SetCC->getOperand(0)); // Val to compare against + unsigned TV = SelectExpr(N.getOperand(1)); // Use if TRUE + unsigned FV = SelectExpr(N.getOperand(2)); // Use if FALSE + + ConstantFPSDNode *CN = dyn_cast(SetCC->getOperand(1)); + if (CN && (CN->isExactlyValue(-0.0) || CN->isExactlyValue(0.0))) { + switch(SetCC->getCondition()) { + default: assert(0 && "Invalid FSEL condition"); abort(); + case ISD::SETULT: + case ISD::SETLT: + BuildMI(BB, PPC::FSEL, 3, Result).addReg(Tmp1).addReg(FV).addReg(TV); + return Result; + case ISD::SETUGE: + case ISD::SETGE: + BuildMI(BB, PPC::FSEL, 3, Result).addReg(Tmp1).addReg(TV).addReg(FV); + return Result; + case ISD::SETUGT: + case ISD::SETGT: { + Tmp2 = MakeReg(VT); + BuildMI(BB, PPC::FNEG, 1, Tmp2).addReg(Tmp1); + BuildMI(BB, PPC::FSEL, 3, Result).addReg(Tmp2).addReg(FV).addReg(TV); + return Result; + } + case ISD::SETULE: + case ISD::SETLE: { + Tmp2 = MakeReg(VT); + BuildMI(BB, PPC::FNEG, 1, Tmp2).addReg(Tmp1); + BuildMI(BB, PPC::FSEL, 3, Result).addReg(Tmp2).addReg(TV).addReg(FV); + return Result; + } + } + } else { + Opc = (MVT::f64 == VT) ? PPC::FSUB : PPC::FSUBS; + Tmp2 = SelectExpr(SetCC->getOperand(1)); + Tmp3 = MakeReg(VT); + switch(SetCC->getCondition()) { + default: assert(0 && "Invalid FSEL condition"); abort(); + case ISD::SETULT: + case ISD::SETLT: + BuildMI(BB, Opc, 2, Tmp3).addReg(Tmp1).addReg(Tmp2); + BuildMI(BB, PPC::FSEL, 3, Result).addReg(Tmp3).addReg(FV).addReg(TV); + return Result; + case ISD::SETUGE: + case ISD::SETGE: + BuildMI(BB, Opc, 2, Tmp3).addReg(Tmp1).addReg(Tmp2); + BuildMI(BB, PPC::FSEL, 3, Result).addReg(Tmp3).addReg(TV).addReg(FV); + return Result; + case ISD::SETUGT: + case ISD::SETGT: + BuildMI(BB, Opc, 2, Tmp3).addReg(Tmp2).addReg(Tmp1); + BuildMI(BB, PPC::FSEL, 3, Result).addReg(Tmp3).addReg(FV).addReg(TV); + return Result; + case ISD::SETULE: + case ISD::SETLE: + BuildMI(BB, Opc, 2, Tmp3).addReg(Tmp2).addReg(Tmp1); + BuildMI(BB, PPC::FSEL, 3, Result).addReg(Tmp3).addReg(TV).addReg(FV); + return Result; + } + } + assert(0 && "Should never get here"); + return 0; + } + // Create an iterator with which to insert the MBB for copying the false // value and the MBB to hold the PHI instruction for this SetCC. MachineBasicBlock *thisMBB = BB; @@ -582,6 +700,7 @@ // cmpTY cr0, r1, r2 // bCC copy1MBB // fallthrough --> copy0MBB + Tmp1 = SelectExpr(N.getOperand(0)); //Cond BuildMI(BB, PPC::CMPLWI, 2, PPC::CR0).addReg(Tmp1).addImm(0); MachineBasicBlock *copy0MBB = new MachineBasicBlock(LLVM_BB); MachineBasicBlock *sinkMBB = new MachineBasicBlock(LLVM_BB); @@ -1085,24 +1204,29 @@ bool U = false; bool IsInteger = MVT::isInteger(SetCC->getOperand(0).getValueType()); - switch (SetCC->getCondition()) { - default: Node->dump(); assert(0 && "Unknown comparison!"); - case ISD::SETEQ: Opc = PPC::BEQ; break; - case ISD::SETNE: Opc = PPC::BNE; break; - case ISD::SETULT: U = true; - case ISD::SETLT: Opc = PPC::BLT; break; - case ISD::SETULE: U = true; - case ISD::SETLE: Opc = PPC::BLE; break; - case ISD::SETUGT: U = true; - case ISD::SETGT: Opc = PPC::BGT; break; - case ISD::SETUGE: U = true; - case ISD::SETGE: Opc = PPC::BGE; break; - } - // FIXME: Is there a situation in which we would ever need to emit fcmpo? static const unsigned CompareOpcodes[] = { PPC::FCMPU, PPC::FCMPU, PPC::CMPW, PPC::CMPLW }; - unsigned CompareOpc = CompareOpcodes[2 * IsInteger + U]; + + // Set the branch opcode to use below + Opc = getBCCForSetCC(SetCC->getCondition(), U); + + // Try and use an integer compare with immediate, if applicable. + // Normal setcc uses the sign-extended immediate range, unsigned setcc + // uses the zero extended immediate range. + if (IsInteger && + 1 == canUseAsImmediateForOpcode(N.getOperand(1), opcode, Tmp2, U)) { + Tmp1 = SelectExpr(N.getOperand(0)); + if (U) + BuildMI(BB, PPC::CMPLWI, 2, PPC::CR0).addReg(Tmp1).addImm(Tmp2); + else + BuildMI(BB, PPC::CMPWI, 2, PPC::CR0).addReg(Tmp1).addSImm(Tmp2); + } else { + Tmp1 = SelectExpr(N.getOperand(0)); + Tmp2 = SelectExpr(N.getOperand(1)); + unsigned CompareOpc = CompareOpcodes[2 * IsInteger + U]; + BuildMI(BB, CompareOpc, 2, PPC::CR0).addReg(Tmp1).addReg(Tmp2); + } // Create an iterator with which to insert the MBB for copying the false // value and the MBB to hold the PHI instruction for this SetCC. @@ -1116,9 +1240,6 @@ // cmpTY cr0, r1, r2 // %TrueValue = li 1 // bCC sinkMBB - Tmp1 = SelectExpr(N.getOperand(0)); - Tmp2 = SelectExpr(N.getOperand(1)); - BuildMI(BB, CompareOpc, 2, PPC::CR0).addReg(Tmp1).addReg(Tmp2); unsigned TrueValue = MakeReg(MVT::i32); BuildMI(BB, PPC::LI, 1, TrueValue).addSImm(1); MachineBasicBlock *copy0MBB = new MachineBasicBlock(LLVM_BB); @@ -1152,8 +1273,6 @@ return 0; case ISD::SELECT: { - Tmp1 = SelectExpr(N.getOperand(0)); //Cond - // Create an iterator with which to insert the MBB for copying the false // value and the MBB to hold the PHI instruction for this SetCC. MachineBasicBlock *thisMBB = BB; @@ -1161,17 +1280,44 @@ ilist::iterator It = BB; ++It; + // If the first operand to the select is a SETCC node, then we can fold it + // into the branch that selects which value to return. + SetCCSDNode* SetCC = dyn_cast(N.getOperand(0).Val); + if (SetCC && N.getOperand(0).getOpcode() == ISD::SETCC && + MVT::isInteger(SetCC->getOperand(0).getValueType())) { + bool U; + Opc = getBCCForSetCC(SetCC->getCondition(), U); + Tmp1 = SelectExpr(SetCC->getOperand(0)); + + // Pass the optional argument U to canUseAsImmediateForOpcode for SETCC, + // so that it knows whether the SETCC immediate range is signed or not. + if (1 == canUseAsImmediateForOpcode(SetCC->getOperand(1), ISD::SETCC, + Tmp2, U)) { + if (U) + BuildMI(BB, PPC::CMPLWI, 2, PPC::CR0).addReg(Tmp1).addImm(Tmp2); + else + BuildMI(BB, PPC::CMPWI, 2, PPC::CR0).addReg(Tmp1).addSImm(Tmp2); + } else { + Tmp2 = SelectExpr(SetCC->getOperand(1)); + BuildMI(BB, U ? PPC::CMPLW : PPC::CMPW, 2, PPC::CR0).addReg(Tmp1) + .addReg(Tmp2); + } + } else { + Tmp1 = SelectExpr(N.getOperand(0)); //Cond + BuildMI(BB, PPC::CMPLWI, 2, PPC::CR0).addReg(Tmp1).addImm(0); + Opc = PPC::BNE; + } + // thisMBB: // ... // TrueVal = ... // cmpTY cr0, r1, r2 // bCC copy1MBB // fallthrough --> copy0MBB - BuildMI(BB, PPC::CMPLWI, 2, PPC::CR0).addReg(Tmp1).addImm(0); MachineBasicBlock *copy0MBB = new MachineBasicBlock(LLVM_BB); MachineBasicBlock *sinkMBB = new MachineBasicBlock(LLVM_BB); unsigned TrueValue = SelectExpr(N.getOperand(1)); //Use if TRUE - BuildMI(BB, PPC::BNE, 2).addReg(PPC::CR0).addMBB(sinkMBB); + BuildMI(BB, Opc, 2).addReg(PPC::CR0).addMBB(sinkMBB); MachineFunction *F = BB->getParent(); F->getBasicBlockList().insert(It, copy0MBB); F->getBasicBlockList().insert(It, sinkMBB); From natebegeman at mac.com Thu Mar 31 18:32:45 2005 From: natebegeman at mac.com (Nate Begeman) Date: Thu, 31 Mar 2005 18:32:45 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Message-ID: <200504010032.SAA29179@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPC32ISelPattern.cpp updated: 1.23 -> 1.24 --- Log message: Factor out common code, support FP comparison in folded SetCC --- Diffs of the changes: (+40 -84) PPC32ISelPattern.cpp | 124 ++++++++++++++++----------------------------------- 1 files changed, 40 insertions(+), 84 deletions(-) Index: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp diff -u llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.23 llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.24 --- llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.23 Thu Mar 31 17:55:40 2005 +++ llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Thu Mar 31 18:32:34 2005 @@ -462,7 +462,8 @@ ExprMap.clear(); } - unsigned ISel::getGlobalBaseReg(); + unsigned getGlobalBaseReg(); + unsigned SelectSetCR0(SDOperand CC); unsigned SelectExpr(SDOperand N); unsigned SelectExprFP(SDOperand N, unsigned Result); void Select(SDOperand N); @@ -546,35 +547,15 @@ return GlobalBaseReg; } -//Check to see if the load is a constant offset from a base register -void ISel::SelectAddr(SDOperand N, unsigned& Reg, int& offset) -{ - unsigned imm = 0, opcode = N.getOpcode(); - if (N.getOpcode() == ISD::ADD) - if (1 == canUseAsImmediateForOpcode(N.getOperand(1), opcode, imm)) { - Reg = SelectExpr(N.getOperand(0)); - offset = imm; - return; - } - Reg = SelectExpr(N); - offset = 0; - return; -} - -void ISel::SelectBranchCC(SDOperand N) -{ - assert(N.getOpcode() == ISD::BRCOND && "Not a BranchCC???"); - MachineBasicBlock *Dest = - cast(N.getOperand(2))->getBasicBlock(); - +unsigned ISel::SelectSetCR0(SDOperand CC) { unsigned Opc, Tmp1, Tmp2; - Select(N.getOperand(0)); //chain - + static const unsigned CompareOpcodes[] = + { PPC::FCMPU, PPC::FCMPU, PPC::CMPW, PPC::CMPLW }; + // If the first operand to the select is a SETCC node, then we can fold it // into the branch that selects which value to return. - SetCCSDNode* SetCC = dyn_cast(N.getOperand(1).Val); - if (SetCC && N.getOperand(1).getOpcode() == ISD::SETCC && - MVT::isInteger(SetCC->getOperand(0).getValueType())) { + SetCCSDNode* SetCC = dyn_cast(CC.Val); + if (SetCC && CC.getOpcode() == ISD::SETCC) { bool U; Opc = getBCCForSetCC(SetCC->getCondition(), U); Tmp1 = SelectExpr(SetCC->getOperand(0)); @@ -588,16 +569,42 @@ else BuildMI(BB, PPC::CMPWI, 2, PPC::CR0).addReg(Tmp1).addSImm(Tmp2); } else { + bool IsInteger = MVT::isInteger(SetCC->getOperand(0).getValueType()); + unsigned CompareOpc = CompareOpcodes[2 * IsInteger + U]; Tmp2 = SelectExpr(SetCC->getOperand(1)); - BuildMI(BB, U ? PPC::CMPLW : PPC::CMPW, 2, PPC::CR0).addReg(Tmp1) - .addReg(Tmp2); + BuildMI(BB, CompareOpc, 2, PPC::CR0).addReg(Tmp1).addReg(Tmp2); } } else { - Tmp1 = SelectExpr(N.getOperand(1)); + Tmp1 = SelectExpr(CC); BuildMI(BB, PPC::CMPLWI, 2, PPC::CR0).addReg(Tmp1).addImm(0); Opc = PPC::BNE; } + return Opc; +} +/// Check to see if the load is a constant offset from a base register +void ISel::SelectAddr(SDOperand N, unsigned& Reg, int& offset) +{ + unsigned imm = 0, opcode = N.getOpcode(); + if (N.getOpcode() == ISD::ADD) + if (1 == canUseAsImmediateForOpcode(N.getOperand(1), opcode, imm)) { + Reg = SelectExpr(N.getOperand(0)); + offset = imm; + return; + } + Reg = SelectExpr(N); + offset = 0; + return; +} + +void ISel::SelectBranchCC(SDOperand N) +{ + assert(N.getOpcode() == ISD::BRCOND && "Not a BranchCC???"); + MachineBasicBlock *Dest = + cast(N.getOperand(2))->getBasicBlock(); + + Select(N.getOperand(0)); //chain + unsigned Opc = SelectSetCR0(N.getOperand(1)); BuildMI(BB, Opc, 2).addReg(PPC::CR0).addMBB(Dest); return; } @@ -1201,32 +1208,7 @@ case ISD::SETCC: if (SetCCSDNode *SetCC = dyn_cast(Node)) { - bool U = false; - bool IsInteger = MVT::isInteger(SetCC->getOperand(0).getValueType()); - - // FIXME: Is there a situation in which we would ever need to emit fcmpo? - static const unsigned CompareOpcodes[] = - { PPC::FCMPU, PPC::FCMPU, PPC::CMPW, PPC::CMPLW }; - - // Set the branch opcode to use below - Opc = getBCCForSetCC(SetCC->getCondition(), U); - - // Try and use an integer compare with immediate, if applicable. - // Normal setcc uses the sign-extended immediate range, unsigned setcc - // uses the zero extended immediate range. - if (IsInteger && - 1 == canUseAsImmediateForOpcode(N.getOperand(1), opcode, Tmp2, U)) { - Tmp1 = SelectExpr(N.getOperand(0)); - if (U) - BuildMI(BB, PPC::CMPLWI, 2, PPC::CR0).addReg(Tmp1).addImm(Tmp2); - else - BuildMI(BB, PPC::CMPWI, 2, PPC::CR0).addReg(Tmp1).addSImm(Tmp2); - } else { - Tmp1 = SelectExpr(N.getOperand(0)); - Tmp2 = SelectExpr(N.getOperand(1)); - unsigned CompareOpc = CompareOpcodes[2 * IsInteger + U]; - BuildMI(BB, CompareOpc, 2, PPC::CR0).addReg(Tmp1).addReg(Tmp2); - } + Opc = SelectSetCR0(N); // Create an iterator with which to insert the MBB for copying the false // value and the MBB to hold the PHI instruction for this SetCC. @@ -1273,6 +1255,8 @@ return 0; case ISD::SELECT: { + Opc = SelectSetCR0(N.getOperand(0)); + // Create an iterator with which to insert the MBB for copying the false // value and the MBB to hold the PHI instruction for this SetCC. MachineBasicBlock *thisMBB = BB; @@ -1280,34 +1264,6 @@ ilist::iterator It = BB; ++It; - // If the first operand to the select is a SETCC node, then we can fold it - // into the branch that selects which value to return. - SetCCSDNode* SetCC = dyn_cast(N.getOperand(0).Val); - if (SetCC && N.getOperand(0).getOpcode() == ISD::SETCC && - MVT::isInteger(SetCC->getOperand(0).getValueType())) { - bool U; - Opc = getBCCForSetCC(SetCC->getCondition(), U); - Tmp1 = SelectExpr(SetCC->getOperand(0)); - - // Pass the optional argument U to canUseAsImmediateForOpcode for SETCC, - // so that it knows whether the SETCC immediate range is signed or not. - if (1 == canUseAsImmediateForOpcode(SetCC->getOperand(1), ISD::SETCC, - Tmp2, U)) { - if (U) - BuildMI(BB, PPC::CMPLWI, 2, PPC::CR0).addReg(Tmp1).addImm(Tmp2); - else - BuildMI(BB, PPC::CMPWI, 2, PPC::CR0).addReg(Tmp1).addSImm(Tmp2); - } else { - Tmp2 = SelectExpr(SetCC->getOperand(1)); - BuildMI(BB, U ? PPC::CMPLW : PPC::CMPW, 2, PPC::CR0).addReg(Tmp1) - .addReg(Tmp2); - } - } else { - Tmp1 = SelectExpr(N.getOperand(0)); //Cond - BuildMI(BB, PPC::CMPLWI, 2, PPC::CR0).addReg(Tmp1).addImm(0); - Opc = PPC::BNE; - } - // thisMBB: // ... // TrueVal = ... From natebegeman at mac.com Thu Mar 31 19:08:18 2005 From: natebegeman at mac.com (Nate Begeman) Date: Thu, 31 Mar 2005 19:08:18 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Message-ID: <200504010108.TAA29506@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPC32ISelPattern.cpp updated: 1.24 -> 1.25 --- Log message: Add support for adding 0.0 and -0.0 to the constant pool, since we lie and say that we support them, for the purposes of generating fsel instructions. --- Diffs of the changes: (+11 -3) PPC32ISelPattern.cpp | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-) Index: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp diff -u llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.24 llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.25 --- llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.24 Thu Mar 31 18:32:34 2005 +++ llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Thu Mar 31 19:08:07 2005 @@ -760,9 +760,17 @@ BuildMI(BB, PPC::FMR, 1, Result).addReg(Tmp1); return Result; - case ISD::ConstantFP: - assert(0 && "ISD::ConstantFP Unimplemented"); - abort(); + case ISD::ConstantFP: { + Tmp1 = MakeReg(MVT::i32); + ConstantFPSDNode *CN = cast(N); + MachineConstantPool *CP = BB->getParent()->getConstantPool(); + ConstantFP *CFP = ConstantFP::get(Type::DoubleTy, CN->getValue()); + unsigned CPI = CP->getConstantPoolIndex(CFP); + BuildMI(BB, PPC::LOADHiAddr, 2, Tmp1).addReg(getGlobalBaseReg()) + .addConstantPoolIndex(CPI); + BuildMI(BB, PPC::LFD, 2, Result).addConstantPoolIndex(CPI).addReg(Tmp1); + return Result; + } case ISD::MUL: case ISD::ADD: From alkis at cs.uiuc.edu Thu Mar 31 19:56:48 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu, 31 Mar 2005 19:56:48 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200504010156.TAA29820@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.272 -> 1.273 --- Log message: Instead of calling class initialization functions one by one, create an array of initialization functions to run before main. This also includes string constant initialization functions as well. --- Diffs of the changes: (+37 -21) Compiler.cpp | 58 +++++++++++++++++++++++++++++++++++++--------------------- 1 files changed, 37 insertions(+), 21 deletions(-) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.272 llvm-java/lib/Compiler/Compiler.cpp:1.273 --- llvm-java/lib/Compiler/Compiler.cpp:1.272 Thu Mar 31 13:33:37 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Thu Mar 31 19:56:36 2005 @@ -33,8 +33,6 @@ #include #include -#define LLVM_JAVA_STATIC_INIT "llvm_java_static_init" - using namespace llvm; using namespace llvm::Java; @@ -64,7 +62,8 @@ Locals locals_; OperandStack opStack_; Function *getVtable_, *setVtable_, *throw_, *isInstanceOf_, - *memcpy_, *memset_, *staticInit_; + *memcpy_, *memset_; + std::vector classInitializers_; SetVector toCompileMethods_; @@ -120,10 +119,6 @@ "llvm.memset", Type::VoidTy, PointerType::get(Type::SByteTy), Type::UByteTy, Type::ULongTy, Type::UIntTy, NULL); - staticInit_ = - module_->getOrInsertFunction(LLVM_JAVA_STATIC_INIT, Type::VoidTy, NULL); - BasicBlock* staticInitBB = new BasicBlock("entry", staticInit_); - new ReturnInst(NULL, staticInitBB); } private: @@ -184,7 +179,7 @@ // Get class information for java/lang/String. const VMClass* clazz = resolver_->getClass("java/lang/String"); - emitStaticInitializers(clazz); + emitClassInitializers(clazz); const VTableInfo* vi = getVTableInfoGeneric(clazz); @@ -964,7 +959,7 @@ } /// Emits static initializers for this class if not done already. - void emitStaticInitializers(const VMClass* clazz) { + void emitClassInitializers(const VMClass* clazz) { static SetVector toInitClasses; const ClassFile* classfile = clazz->getClassFile(); @@ -974,23 +969,26 @@ if (toInitClasses.insert(clazz)) { // If this class has a super class, initialize that first. if (const VMClass* superClass = clazz->getSuperClass()) - emitStaticInitializers(superClass); - - Instruction* I = staticInit_->front().getTerminator(); - assert(I && LLVM_JAVA_STATIC_INIT " should have a terminator!"); + emitClassInitializers(superClass); // Create constant strings for this class. + Function* stringConstructors = module_->getOrInsertFunction( + clazz->getName() + "", + FunctionType::get(Type::VoidTy, std::vector(), false)); + Instruction* I = + new ReturnInst(NULL, new BasicBlock("entry", stringConstructors)); for (unsigned i = 0, e = classfile->getNumConstants(); i != e; ++i) if (ConstantString* s = dynamic_cast(classfile->getConstant(i))) initializeString(clazz->getConstant(i), s->getValue()->str(), I); + // Insert string constructors method in class initializers array. + classInitializers_.push_back(stringConstructors); + // Call its class initialization method if it exists. if (const VMMethod* method = clazz->getMethod("()V")) { - // Insert a call to it right before the terminator of the only - // basic block in llvm_java_static_init. + classInitializers_.push_back(method->getFunction()); bool inserted = scheduleMethod(method); assert(inserted && "Class initialization method already called!"); - new CallInst(method->getFunction(), "", I); } } } @@ -1003,7 +1001,7 @@ const std::string& methodDesc) { // Load the class. const VMClass* clazz = resolver_->getClass(className); - emitStaticInitializers(clazz); + emitClassInitializers(clazz); // Find the method. const VMMethod* method = clazz->getMethod(methodDesc); @@ -1016,6 +1014,24 @@ << " functions compiled\n"); } + // Null terminate the static initializers array and add the + // global to the module. + Type* classInitializerType = PointerType::get( + FunctionType::get(Type::VoidTy, std::vector(), false)); + classInitializers_.push_back( + llvm::Constant::getNullValue(classInitializerType)); + + ArrayType* classInitializersType = + ArrayType::get(classInitializerType, classInitializers_.size()); + new GlobalVariable(classInitializersType, + true, + GlobalVariable::ExternalLinkage, + ConstantArray::get(classInitializersType, + classInitializers_), + "llvm_java_class_initializers", + module_); + + return method; } @@ -1403,7 +1419,7 @@ void do_getstatic(unsigned index) { const VMField* field = class_->getField(index); - emitStaticInitializers(field->getParent()); + emitClassInitializers(field->getParent()); Value* v = new LoadInst(field->getGlobal(), TMP, currentBB_); push(v); @@ -1411,7 +1427,7 @@ void do_putstatic(unsigned index) { const VMField* field = class_->getField(index); - emitStaticInitializers(field->getParent()); + emitClassInitializers(field->getParent()); Value* v = pop(field->getClass()->getType()); new StoreInst(v, field->getGlobal(), currentBB_); @@ -1515,7 +1531,7 @@ void do_invokestatic(unsigned index) { const VMMethod* method = class_->getMethod(index); - emitStaticInitializers(method->getParent()); + emitClassInitializers(method->getParent()); Function* function = method->getFunction(); // Intercept java/lang/System/loadLibrary() calls and add // library deps to the module @@ -1603,7 +1619,7 @@ void do_new(unsigned index) { const VMClass* clazz = class_->getClass(index); - emitStaticInitializers(clazz); + emitClassInitializers(clazz); const VTableInfo& vi = getVTableInfo(clazz); push(allocateObject(*clazz, vi, currentBB_)); From alkis at cs.uiuc.edu Thu Mar 31 19:56:48 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu, 31 Mar 2005 19:56:48 -0600 Subject: [llvm-commits] CVS: llvm-java/runtime/runtime.c Message-ID: <200504010156.TAA29816@zion.cs.uiuc.edu> Changes in directory llvm-java/runtime: runtime.c updated: 1.23 -> 1.24 --- Log message: Instead of calling class initialization functions one by one, create an array of initialization functions to run before main. This also includes string constant initialization functions as well. --- Diffs of the changes: (+8 -2) runtime.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) Index: llvm-java/runtime/runtime.c diff -u llvm-java/runtime/runtime.c:1.23 llvm-java/runtime/runtime.c:1.24 --- llvm-java/runtime/runtime.c:1.23 Mon Mar 28 13:19:27 2005 +++ llvm-java/runtime/runtime.c Thu Mar 31 19:56:36 2005 @@ -352,11 +352,17 @@ const JNIEnv llvm_java_JNIEnv = &llvm_java_JNINativeInterface; -extern void llvm_java_static_init(void); +typedef void (*ClassInitializerFunction)(void); + +extern const ClassInitializerFunction llvm_java_class_initializers; + extern void llvm_java_main(int, char**); int main(int argc, char** argv) { - llvm_java_static_init(); + const ClassInitializerFunction* classInit = &llvm_java_class_initializers; + while (*classInit) + (*classInit++)(); + llvm_java_main(argc, argv); return 0; } From natebegeman at mac.com Thu Mar 31 20:59:38 2005 From: natebegeman at mac.com (Nate Begeman) Date: Thu, 31 Mar 2005 20:59:38 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Message-ID: <200504010259.UAA30063@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPC32ISelPattern.cpp updated: 1.25 -> 1.26 --- Log message: Implement FP_TO_SINT and FP_TO_UINT --- Diffs of the changes: (+86 -11) PPC32ISelPattern.cpp | 97 +++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 86 insertions(+), 11 deletions(-) Index: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp diff -u llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.25 llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.26 --- llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.25 Thu Mar 31 19:08:07 2005 +++ llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Thu Mar 31 20:59:27 2005 @@ -463,6 +463,7 @@ } unsigned getGlobalBaseReg(); + unsigned getConstDouble(double floatVal, unsigned Result); unsigned SelectSetCR0(SDOperand CC); unsigned SelectExpr(SDOperand N); unsigned SelectExprFP(SDOperand N, unsigned Result); @@ -547,6 +548,20 @@ return GlobalBaseReg; } +/// getConstDouble - Loads a floating point value into a register, via the +/// Constant Pool. Optionally takes a register in which to load the value. +unsigned ISel::getConstDouble(double doubleVal, unsigned Result=0) { + unsigned Tmp1 = MakeReg(MVT::i32); + if (0 == Result) Result = MakeReg(MVT::f64); + MachineConstantPool *CP = BB->getParent()->getConstantPool(); + ConstantFP *CFP = ConstantFP::get(Type::DoubleTy, doubleVal); + unsigned CPI = CP->getConstantPoolIndex(CFP); + BuildMI(BB, PPC::LOADHiAddr, 2, Tmp1).addReg(getGlobalBaseReg()) + .addConstantPoolIndex(CPI); + BuildMI(BB, PPC::LFD, 2, Result).addConstantPoolIndex(CPI).addReg(Tmp1); + return Result; +} + unsigned ISel::SelectSetCR0(SDOperand CC) { unsigned Opc, Tmp1, Tmp2; static const unsigned CompareOpcodes[] = @@ -761,14 +776,8 @@ return Result; case ISD::ConstantFP: { - Tmp1 = MakeReg(MVT::i32); ConstantFPSDNode *CN = cast(N); - MachineConstantPool *CP = BB->getParent()->getConstantPool(); - ConstantFP *CFP = ConstantFP::get(Type::DoubleTy, CN->getValue()); - unsigned CPI = CP->getConstantPoolIndex(CFP); - BuildMI(BB, PPC::LOADHiAddr, 2, Tmp1).addReg(getGlobalBaseReg()) - .addConstantPoolIndex(CPI); - BuildMI(BB, PPC::LFD, 2, Result).addConstantPoolIndex(CPI).addReg(Tmp1); + Result = getConstDouble(CN->getValue(), Result); return Result; } @@ -838,7 +847,7 @@ return Result; } } - assert(0 && "should not get here"); + assert(0 && "Should never get here"); return 0; } @@ -1210,9 +1219,75 @@ } case ISD::FP_TO_UINT: - case ISD::FP_TO_SINT: - assert(0 && "FP_TO_S/UINT unimplemented"); - abort(); + case ISD::FP_TO_SINT: { + bool U = (ISD::FP_TO_UINT == opcode); + Tmp1 = SelectExpr(N.getOperand(0)); + if (!U) { + Tmp2 = MakeReg(MVT::f64); + BuildMI(BB, PPC::FCTIWZ, 1, Tmp2).addReg(Tmp1); + int FrameIdx = BB->getParent()->getFrameInfo()->CreateStackObject(8, 8); + addFrameReference(BuildMI(BB, PPC::STFD, 3).addReg(Tmp2), FrameIdx); + addFrameReference(BuildMI(BB, PPC::LWZ, 2, Result), FrameIdx, 4); + return Result; + } else { + unsigned Zero = getConstDouble(0.0); + unsigned MaxInt = getConstDouble((1LL << 32) - 1); + unsigned Border = getConstDouble(1LL << 31); + unsigned UseZero = MakeReg(MVT::f64); + unsigned UseMaxInt = MakeReg(MVT::f64); + unsigned UseChoice = MakeReg(MVT::f64); + unsigned TmpReg = MakeReg(MVT::f64); + unsigned TmpReg2 = MakeReg(MVT::f64); + unsigned ConvReg = MakeReg(MVT::f64); + unsigned IntTmp = MakeReg(MVT::i32); + unsigned XorReg = MakeReg(MVT::i32); + MachineFunction *F = BB->getParent(); + int FrameIdx = F->getFrameInfo()->CreateStackObject(8, 8); + // Update machine-CFG edges + MachineBasicBlock *XorMBB = new MachineBasicBlock(BB->getBasicBlock()); + MachineBasicBlock *PhiMBB = new MachineBasicBlock(BB->getBasicBlock()); + MachineBasicBlock *OldMBB = BB; + ilist::iterator It = BB; ++It; + F->getBasicBlockList().insert(It, XorMBB); + F->getBasicBlockList().insert(It, PhiMBB); + BB->addSuccessor(XorMBB); + BB->addSuccessor(PhiMBB); + // Convert from floating point to unsigned 32-bit value + // Use 0 if incoming value is < 0.0 + BuildMI(BB, PPC::FSEL, 3, UseZero).addReg(Tmp1).addReg(Tmp1).addReg(Zero); + // Use 2**32 - 1 if incoming value is >= 2**32 + BuildMI(BB, PPC::FSUB, 2, UseMaxInt).addReg(MaxInt).addReg(Tmp1); + BuildMI(BB, PPC::FSEL, 3, UseChoice).addReg(UseMaxInt).addReg(UseZero) + .addReg(MaxInt); + // Subtract 2**31 + BuildMI(BB, PPC::FSUB, 2, TmpReg).addReg(UseChoice).addReg(Border); + // Use difference if >= 2**31 + BuildMI(BB, PPC::FCMPU, 2, PPC::CR0).addReg(UseChoice).addReg(Border); + BuildMI(BB, PPC::FSEL, 3, TmpReg2).addReg(TmpReg).addReg(TmpReg) + .addReg(UseChoice); + // Convert to integer + BuildMI(BB, PPC::FCTIWZ, 1, ConvReg).addReg(TmpReg2); + addFrameReference(BuildMI(BB, PPC::STFD, 3).addReg(ConvReg), FrameIdx); + addFrameReference(BuildMI(BB, PPC::LWZ, 2, IntTmp), FrameIdx, 4); + BuildMI(BB, PPC::BLT, 2).addReg(PPC::CR0).addMBB(PhiMBB); + BuildMI(BB, PPC::B, 1).addMBB(XorMBB); + + // XorMBB: + // add 2**31 if input was >= 2**31 + BB = XorMBB; + BuildMI(BB, PPC::XORIS, 2, XorReg).addReg(IntTmp).addImm(0x8000); + XorMBB->addSuccessor(PhiMBB); + + // PhiMBB: + // DestReg = phi [ IntTmp, OldMBB ], [ XorReg, XorMBB ] + BB = PhiMBB; + BuildMI(BB, PPC::PHI, 4, Result).addReg(IntTmp).addMBB(OldMBB) + .addReg(XorReg).addMBB(XorMBB); + return Result; + } + assert(0 && "Should never get here"); + return 0; + } case ISD::SETCC: if (SetCCSDNode *SetCC = dyn_cast(Node)) { From natebegeman at mac.com Thu Mar 31 22:45:22 2005 From: natebegeman at mac.com (Nate Begeman) Date: Thu, 31 Mar 2005 22:45:22 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Message-ID: <200504010445.WAA30464@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPC32ISelPattern.cpp updated: 1.26 -> 1.27 --- Log message: Support indexed loads and stores. This drops Shootout/matrix time from 18.8 to 14.8 seconds. The Pattern ISel is now often faster than the Simple ISel, esp. on memory intensive code. --- Diffs of the changes: (+40 -11) PPC32ISelPattern.cpp | 51 ++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 40 insertions(+), 11 deletions(-) Index: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp diff -u llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.26 llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.27 --- llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.26 Thu Mar 31 20:59:27 2005 +++ llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Thu Mar 31 22:45:11 2005 @@ -469,7 +469,7 @@ unsigned SelectExprFP(SDOperand N, unsigned Result); void Select(SDOperand N); - void SelectAddr(SDOperand N, unsigned& Reg, int& offset); + bool SelectAddr(SDOperand N, unsigned& Reg, int& offset); void SelectBranchCC(SDOperand N); }; @@ -529,6 +529,22 @@ case ISD::SETUGE: U = true; case ISD::SETGE: return PPC::BGE; } + return 0; +} + +/// IndexedOpForOp - Return the indexed variant for each of the PowerPC load +/// and store immediate instructions. +static unsigned IndexedOpForOp(unsigned Opcode) { + switch(Opcode) { + default: assert(0 && "Unknown opcode!"); abort(); + case PPC::LBZ: return PPC::LBZX; case PPC::STB: return PPC::STBX; + case PPC::LHZ: return PPC::LHZX; case PPC::STH: return PPC::STHX; + case PPC::LHA: return PPC::LHAX; case PPC::STW: return PPC::STWX; + case PPC::LWZ: return PPC::LWZX; case PPC::STFS: return PPC::STFSX; + case PPC::LFS: return PPC::LFSX; case PPC::STFD: return PPC::STFDX; + case PPC::LFD: return PPC::LFDX; + } + return 0; } } @@ -598,18 +614,21 @@ } /// Check to see if the load is a constant offset from a base register -void ISel::SelectAddr(SDOperand N, unsigned& Reg, int& offset) +bool ISel::SelectAddr(SDOperand N, unsigned& Reg, int& offset) { unsigned imm = 0, opcode = N.getOpcode(); - if (N.getOpcode() == ISD::ADD) + if (N.getOpcode() == ISD::ADD) { + Reg = SelectExpr(N.getOperand(0)); if (1 == canUseAsImmediateForOpcode(N.getOperand(1), opcode, imm)) { - Reg = SelectExpr(N.getOperand(0)); offset = imm; - return; - } + return false; + } + offset = SelectExpr(N.getOperand(1)); + return true; + } Reg = SelectExpr(N); offset = 0; - return; + return false; } void ISel::SelectBranchCC(SDOperand N) @@ -988,8 +1007,13 @@ addFrameReference(BuildMI(BB, Opc, 2, Result), (int)Tmp1); } else { int offset; - SelectAddr(Address, Tmp1, offset); - BuildMI(BB, Opc, 2, Result).addSImm(offset).addReg(Tmp1); + bool idx = SelectAddr(Address, Tmp1, offset); + if (idx) { + Opc = IndexedOpForOp(Opc); + BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(offset); + } else { + BuildMI(BB, Opc, 2, Result).addSImm(offset).addReg(Tmp1); + } } return Result; } @@ -1534,8 +1558,13 @@ else { int offset; - SelectAddr(Address, Tmp2, offset); - BuildMI(BB, Opc, 3).addReg(Tmp1).addImm(offset).addReg(Tmp2); + bool idx = SelectAddr(Address, Tmp2, offset); + if (idx) { + Opc = IndexedOpForOp(Opc); + BuildMI(BB, Opc, 3).addReg(Tmp1).addReg(Tmp2).addReg(offset); + } else { + BuildMI(BB, Opc, 3).addReg(Tmp1).addImm(offset).addReg(Tmp2); + } } return; } From alkis at cs.uiuc.edu Thu Mar 31 23:00:17 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu, 31 Mar 2005 23:00:17 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMClass.cpp Message-ID: <200504010500.XAA30630@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMClass.cpp updated: 1.33 -> 1.34 --- Log message: Compute interface index for classes as well (it represents the max interface index of the interfaces it implements). --- Diffs of the changes: (+15 -6) VMClass.cpp | 21 +++++++++++++++------ 1 files changed, 15 insertions(+), 6 deletions(-) Index: llvm-java/lib/Compiler/VMClass.cpp diff -u llvm-java/lib/Compiler/VMClass.cpp:1.33 llvm-java/lib/Compiler/VMClass.cpp:1.34 --- llvm-java/lib/Compiler/VMClass.cpp:1.33 Thu Mar 31 12:12:19 2005 +++ llvm-java/lib/Compiler/VMClass.cpp Thu Mar 31 23:00:06 2005 @@ -201,12 +201,10 @@ // In a classfile an interface is as if it inherits // java/lang/Object, but java/lang/Class/getSuperClass() should - // return null on any interface class. Thus we do the same here. - if (classFile_->isInterface()) - interfaceIndex_ = resolver_->getNextInterfaceIndex(); - else { - // Build the super classes array. The first class is the - // direct super class of this class. + // return null on any interface class. So we only add + // superclasses to if this is not an interface. + if (!classFile_->isInterface()) { + // The first class is the direct super class of this class. superClasses_.reserve(superClass->getNumSuperClasses() + 1); superClasses_.push_back(superClass); for (unsigned i = 0, e = superClass->getNumSuperClasses(); i != e; ++i) @@ -229,6 +227,17 @@ interfaces_.end()); } + // The interface index for an interface is a unique number generated + // from the resolver. + if (isInterface()) + interfaceIndex_ = resolver_->getNextInterfaceIndex(); + // For a class it is the max index of all the interfaces it implements. + else { + for (unsigned i = 0, e = getNumInterfaces(); i != e; ++i) + interfaceIndex_ = + std::max(interfaceIndex_, getInterface(i)->getInterfaceIndex()); + } + computeLayout(); computeClassRecord(); From natebegeman at mac.com Thu Mar 31 23:57:28 2005 From: natebegeman at mac.com (Nate Begeman) Date: Thu, 31 Mar 2005 23:57:28 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Message-ID: <200504010557.XAA30809@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPC32ISelPattern.cpp updated: 1.27 -> 1.28 --- Log message: Fix stores to global addresses Fix calls with no arguments --- Diffs of the changes: (+3 -7) PPC32ISelPattern.cpp | 10 +++------- 1 files changed, 3 insertions(+), 7 deletions(-) Index: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp diff -u llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.27 llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.28 --- llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.27 Thu Mar 31 22:45:11 2005 +++ llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Thu Mar 31 23:57:17 2005 @@ -210,7 +210,8 @@ unsigned NumBytes = 24; if (Args.empty()) { - NumBytes = 0; // Save zero bytes. + Chain = DAG.getNode(ISD::ADJCALLSTACKDOWN, MVT::Other, Chain, + DAG.getConstant(NumBytes, getPointerTy())); } else { for (unsigned i = 0, e = Args.size(); i != e; ++i) switch (getValueType(Args[i].second)) { @@ -1545,12 +1546,7 @@ } } - if (Address.getOpcode() == ISD::GlobalAddress) - { - BuildMI(BB, Opc, 2).addReg(Tmp1) - .addGlobalAddress(cast(Address)->getGlobal()); - } - else if(Address.getOpcode() == ISD::FrameIndex) + if(Address.getOpcode() == ISD::FrameIndex) { Tmp2 = cast(Address)->getIndex(); addFrameReference(BuildMI(BB, Opc, 3).addReg(Tmp1), (int)Tmp2); From lattner at cs.uiuc.edu Fri Apr 1 00:48:54 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 1 Apr 2005 00:48:54 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/MachineBasicBlock.cpp Message-ID: <200504010648.j316msI6032675@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: MachineBasicBlock.cpp updated: 1.23 -> 1.24 --- Log message: print the machine CFG in the -print-machineinstrs dump --- Diffs of the changes: (+8 -0) MachineBasicBlock.cpp | 8 ++++++++ 1 files changed, 8 insertions(+) Index: llvm/lib/CodeGen/MachineBasicBlock.cpp diff -u llvm/lib/CodeGen/MachineBasicBlock.cpp:1.23 llvm/lib/CodeGen/MachineBasicBlock.cpp:1.24 --- llvm/lib/CodeGen/MachineBasicBlock.cpp:1.23 Sat Jan 29 18:09:23 2005 +++ llvm/lib/CodeGen/MachineBasicBlock.cpp Fri Apr 1 00:48:38 2005 @@ -100,6 +100,14 @@ OS << "\t"; I->print(OS, &getParent()->getTarget()); } + + // Print the successors of this block according to the CFG. + if (!succ_empty()) { + OS << " Successors according to CFG:"; + for (const_succ_iterator SI = succ_begin(), E = succ_end(); SI != E; ++SI) + OS << " " << *SI; + OS << "\n"; + } } void MachineBasicBlock::addSuccessor(MachineBasicBlock *succ) { From lattner at cs.uiuc.edu Fri Apr 1 01:10:19 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 1 Apr 2005 01:10:19 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Message-ID: <200504010710.j317AJlx000579@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPC32ISelPattern.cpp updated: 1.28 -> 1.29 --- Log message: Move the selection of the arms of the select operation up to the conditional part to make sure we get the side effects and to avoid confusing the CFG. --- Diffs of the changes: (+3 -2) PPC32ISelPattern.cpp | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) Index: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp diff -u llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.28 llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.29 --- llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.28 Thu Mar 31 23:57:17 2005 +++ llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Fri Apr 1 01:10:02 2005 @@ -1365,6 +1365,9 @@ case ISD::SELECT: { Opc = SelectSetCR0(N.getOperand(0)); + unsigned TrueValue = SelectExpr(N.getOperand(1)); //Use if TRUE + unsigned FalseValue = SelectExpr(N.getOperand(2)); //Use if FALSE + // Create an iterator with which to insert the MBB for copying the false // value and the MBB to hold the PHI instruction for this SetCC. MachineBasicBlock *thisMBB = BB; @@ -1380,7 +1383,6 @@ // fallthrough --> copy0MBB MachineBasicBlock *copy0MBB = new MachineBasicBlock(LLVM_BB); MachineBasicBlock *sinkMBB = new MachineBasicBlock(LLVM_BB); - unsigned TrueValue = SelectExpr(N.getOperand(1)); //Use if TRUE BuildMI(BB, Opc, 2).addReg(PPC::CR0).addMBB(sinkMBB); MachineFunction *F = BB->getParent(); F->getBasicBlockList().insert(It, copy0MBB); @@ -1393,7 +1395,6 @@ // %FalseValue = ... // # fallthrough to sinkMBB BB = copy0MBB; - unsigned FalseValue = SelectExpr(N.getOperand(2)); //Use if FALSE // Update machine-CFG edges BB->addSuccessor(sinkMBB); From lattner at cs.uiuc.edu Fri Apr 1 01:19:22 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 1 Apr 2005 01:19:22 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/CodeGen/Generic/nested-select.ll Message-ID: <200504010719.j317JMRr000626@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/CodeGen/Generic: nested-select.ll added (r1.1) --- Log message: new testcase --- Diffs of the changes: (+16 -0) nested-select.ll | 16 ++++++++++++++++ 1 files changed, 16 insertions(+) Index: llvm/test/Regression/CodeGen/Generic/nested-select.ll diff -c /dev/null llvm/test/Regression/CodeGen/Generic/nested-select.ll:1.1 *** /dev/null Fri Apr 1 01:19:16 2005 --- llvm/test/Regression/CodeGen/Generic/nested-select.ll Fri Apr 1 01:19:06 2005 *************** *** 0 **** --- 1,16 ---- + ; RUN: llvm-as < %s | llc -o /dev/null -f + + ; Test that select of a select works + + int %ic_test(double %p.0.2.0.val, double %p.0.2.1.val, double %p.0.2.2.val, %typedef.tree* %t) { + %result.1.0 = cast bool false to int ; [#uses=1] + %tmp.55 = setge double 0.000000e+00, 1.000000e+00 ; [#uses=1] + %tmp.66 = div double 0.000000e+00, 0.000000e+00 ; [#uses=1] + br label %N + N: + %result.1.1 = select bool %tmp.55, int 0, int %result.1.0 ; [#uses=1] + %tmp.75 = setge double %tmp.66, 1.000000e+00 ; [#uses=1] + %retval1 = select bool %tmp.75, int 0, int %result.1.1 ; [#uses=1] + ret int %retval1 + } + From natebegeman at mac.com Fri Apr 1 01:21:40 2005 From: natebegeman at mac.com (Nate Begeman) Date: Fri, 1 Apr 2005 01:21:40 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Message-ID: <200504010721.BAA31222@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPC32ISelPattern.cpp updated: 1.29 -> 1.30 --- Log message: Also apply Chris's fix to FP select and SETCC --- Diffs of the changes: (+8 -6) PPC32ISelPattern.cpp | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-) Index: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp diff -u llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.29 llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.30 --- llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.29 Fri Apr 1 01:10:02 2005 +++ llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Fri Apr 1 01:21:30 2005 @@ -729,6 +729,9 @@ return 0; } + unsigned TrueValue = SelectExpr(N.getOperand(1)); //Use if TRUE + unsigned FalseValue = SelectExpr(N.getOperand(2)); //Use if FALSE + // Create an iterator with which to insert the MBB for copying the false // value and the MBB to hold the PHI instruction for this SetCC. MachineBasicBlock *thisMBB = BB; @@ -746,7 +749,6 @@ BuildMI(BB, PPC::CMPLWI, 2, PPC::CR0).addReg(Tmp1).addImm(0); MachineBasicBlock *copy0MBB = new MachineBasicBlock(LLVM_BB); MachineBasicBlock *sinkMBB = new MachineBasicBlock(LLVM_BB); - unsigned TrueValue = SelectExpr(N.getOperand(1)); //Use if TRUE BuildMI(BB, PPC::BNE, 2).addReg(PPC::CR0).addMBB(sinkMBB); MachineFunction *F = BB->getParent(); F->getBasicBlockList().insert(It, copy0MBB); @@ -759,7 +761,6 @@ // %FalseValue = ... // # fallthrough to sinkMBB BB = copy0MBB; - unsigned FalseValue = SelectExpr(N.getOperand(2)); //Use if FALSE // Update machine-CFG edges BB->addSuccessor(sinkMBB); @@ -1318,6 +1319,11 @@ if (SetCCSDNode *SetCC = dyn_cast(Node)) { Opc = SelectSetCR0(N); + unsigned TrueValue = MakeReg(MVT::i32); + BuildMI(BB, PPC::LI, 1, TrueValue).addSImm(1); + unsigned FalseValue = MakeReg(MVT::i32); + BuildMI(BB, PPC::LI, 1, FalseValue).addSImm(0); + // Create an iterator with which to insert the MBB for copying the false // value and the MBB to hold the PHI instruction for this SetCC. MachineBasicBlock *thisMBB = BB; @@ -1330,8 +1336,6 @@ // cmpTY cr0, r1, r2 // %TrueValue = li 1 // bCC sinkMBB - unsigned TrueValue = MakeReg(MVT::i32); - BuildMI(BB, PPC::LI, 1, TrueValue).addSImm(1); MachineBasicBlock *copy0MBB = new MachineBasicBlock(LLVM_BB); MachineBasicBlock *sinkMBB = new MachineBasicBlock(LLVM_BB); BuildMI(BB, Opc, 2).addReg(PPC::CR0).addMBB(sinkMBB); @@ -1346,8 +1350,6 @@ // %FalseValue = li 0 // fallthrough BB = copy0MBB; - unsigned FalseValue = MakeReg(MVT::i32); - BuildMI(BB, PPC::LI, 1, FalseValue).addSImm(0); // Update machine-CFG edges BB->addSuccessor(sinkMBB); From alkis at cs.uiuc.edu Fri Apr 1 01:25:28 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 1 Apr 2005 01:25:28 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMClass.h Message-ID: <200504010725.BAA31260@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMClass.h updated: 1.25 -> 1.26 --- Log message: Make interfaceIndex an int. --- Diffs of the changes: (+3 -3) VMClass.h | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Index: llvm-java/lib/Compiler/VMClass.h diff -u llvm-java/lib/Compiler/VMClass.h:1.25 llvm-java/lib/Compiler/VMClass.h:1.26 --- llvm-java/lib/Compiler/VMClass.h:1.25 Thu Mar 31 12:12:19 2005 +++ llvm-java/lib/Compiler/VMClass.h Fri Apr 1 01:25:17 2005 @@ -30,7 +30,7 @@ class Resolver; class VMClass { - static const unsigned INVALID_INTERFACE_INDEX = 0xFFFFFFFF; + static const int INVALID_INTERFACE_INDEX = -1; const std::string name_; Resolver* resolver_; @@ -38,7 +38,7 @@ const VMClass* componentClass_; Type* layoutType_; const Type* type_; - unsigned interfaceIndex_; + int interfaceIndex_; typedef std::map FieldMap; FieldMap fieldMap_; typedef std::map MethodMap; @@ -90,7 +90,7 @@ bool isArray() const { return getComponentClass(); } bool isPrimitive() const { return getType() == getLayoutType(); } bool isInterface() const { return classFile_ && classFile_->isInterface(); } - unsigned getInterfaceIndex() const { return interfaceIndex_; } + int getInterfaceIndex() const { return interfaceIndex_; } llvm::Constant* getConstant(unsigned index) const; const VMClass* getClass(unsigned index) const; From natebegeman at mac.com Fri Apr 1 02:57:55 2005 From: natebegeman at mac.com (Nate Begeman) Date: Fri, 1 Apr 2005 02:57:55 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Message-ID: <200504010857.CAA31686@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPC32ISelPattern.cpp updated: 1.30 -> 1.31 --- Log message: Fix Olden/bh, CR0 was being set in the wrong order LowerCallTo and ISD::CALL are going to need to be modified, regs are being set in the wrong order. --- Diffs of the changes: (+3 -5) PPC32ISelPattern.cpp | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-) Index: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp diff -u llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.30 llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.31 --- llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.30 Fri Apr 1 01:21:30 2005 +++ llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Fri Apr 1 02:57:43 2005 @@ -731,6 +731,7 @@ unsigned TrueValue = SelectExpr(N.getOperand(1)); //Use if TRUE unsigned FalseValue = SelectExpr(N.getOperand(2)); //Use if FALSE + Opc = SelectSetCR0(N.getOperand(0)); // Create an iterator with which to insert the MBB for copying the false // value and the MBB to hold the PHI instruction for this SetCC. @@ -745,11 +746,9 @@ // cmpTY cr0, r1, r2 // bCC copy1MBB // fallthrough --> copy0MBB - Tmp1 = SelectExpr(N.getOperand(0)); //Cond - BuildMI(BB, PPC::CMPLWI, 2, PPC::CR0).addReg(Tmp1).addImm(0); MachineBasicBlock *copy0MBB = new MachineBasicBlock(LLVM_BB); MachineBasicBlock *sinkMBB = new MachineBasicBlock(LLVM_BB); - BuildMI(BB, PPC::BNE, 2).addReg(PPC::CR0).addMBB(sinkMBB); + BuildMI(BB, Opc, 2).addReg(PPC::CR0).addMBB(sinkMBB); MachineFunction *F = BB->getParent(); F->getBasicBlockList().insert(It, copy0MBB); F->getBasicBlockList().insert(It, sinkMBB); @@ -1365,10 +1364,9 @@ return 0; case ISD::SELECT: { - Opc = SelectSetCR0(N.getOperand(0)); - unsigned TrueValue = SelectExpr(N.getOperand(1)); //Use if TRUE unsigned FalseValue = SelectExpr(N.getOperand(2)); //Use if FALSE + Opc = SelectSetCR0(N.getOperand(0)); // Create an iterator with which to insert the MBB for copying the false // value and the MBB to hold the PHI instruction for this SetCC. From duraid at octopus.com.au Fri Apr 1 04:35:12 2005 From: duraid at octopus.com.au (Duraid Madina) Date: Fri, 1 Apr 2005 04:35:12 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/IA64/IA64ISelPattern.cpp Message-ID: <200504011035.EAA30472@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/IA64: IA64ISelPattern.cpp updated: 1.6 -> 1.7 --- Log message: repair mindless SELECT waste. --- Diffs of the changes: (+5 -15) IA64ISelPattern.cpp | 20 +++++--------------- 1 files changed, 5 insertions(+), 15 deletions(-) Index: llvm/lib/Target/IA64/IA64ISelPattern.cpp diff -u llvm/lib/Target/IA64/IA64ISelPattern.cpp:1.6 llvm/lib/Target/IA64/IA64ISelPattern.cpp:1.7 --- llvm/lib/Target/IA64/IA64ISelPattern.cpp:1.6 Thu Mar 31 06:31:11 2005 +++ llvm/lib/Target/IA64/IA64ISelPattern.cpp Fri Apr 1 04:35:00 2005 @@ -554,11 +554,6 @@ Tmp2 = SelectExpr(N.getOperand(1)); //Use if TRUE Tmp3 = SelectExpr(N.getOperand(2)); //Use if FALSE - // a temporary predicate register to hold the complement of the - // condition: - unsigned CondComplement=MakeReg(MVT::i1); - unsigned bogusTemp=MakeReg(MVT::i1); - unsigned bogoResult; switch (N.getOperand(1).getValueType()) { @@ -571,16 +566,11 @@ bogoResult=MakeReg(MVT::f64); break; } - // set up the complement predicate reg (CondComplement = NOT Tmp1) - BuildMI(BB, IA64::CMPEQ, 2, bogusTemp).addReg(IA64::r0).addReg(IA64::r0); - BuildMI(BB, IA64::TPCMPNE, 3, CondComplement).addReg(bogusTemp) - .addReg(IA64::r0).addReg(IA64::r0).addReg(Tmp1); - - // and do a 'conditional move' - BuildMI(BB, IA64::PMOV, 2, bogoResult).addReg(Tmp2).addReg(Tmp1); - BuildMI(BB, IA64::CMOV, 2, Result).addReg(bogoResult).addReg(Tmp3) - .addReg(CondComplement); - + + BuildMI(BB, IA64::MOV, 1, bogoResult).addReg(Tmp3); + BuildMI(BB, IA64::CMOV, 2, Result).addReg(bogoResult).addReg(Tmp2) + .addReg(Tmp1); // FIXME: should be FMOV/FCMOV sometimes, + // though this will work for now (no JIT) return Result; } From lattner at cs.uiuc.edu Fri Apr 1 09:41:46 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 1 Apr 2005 09:41:46 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/ModuloScheduling/DependenceAnalyzer.cpp Message-ID: <200504011541.j31FfkPF002195@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9/ModuloScheduling: DependenceAnalyzer.cpp updated: 1.1 -> 1.2 --- Log message: Fix another PATypeHolder error, contributed by Bill Wendling! --- Diffs of the changes: (+1 -0) DependenceAnalyzer.cpp | 1 + 1 files changed, 1 insertion(+) Index: llvm/lib/Target/SparcV9/ModuloScheduling/DependenceAnalyzer.cpp diff -u llvm/lib/Target/SparcV9/ModuloScheduling/DependenceAnalyzer.cpp:1.1 llvm/lib/Target/SparcV9/ModuloScheduling/DependenceAnalyzer.cpp:1.2 --- llvm/lib/Target/SparcV9/ModuloScheduling/DependenceAnalyzer.cpp:1.1 Tue Mar 29 14:33:42 2005 +++ llvm/lib/Target/SparcV9/ModuloScheduling/DependenceAnalyzer.cpp Fri Apr 1 09:41:30 2005 @@ -14,6 +14,7 @@ #define DEBUG_TYPE "ModuloSched" #include "DependenceAnalyzer.h" +#include "llvm/Type.h" #include "llvm/Support/Debug.h" namespace llvm { From alkis at cs.uiuc.edu Fri Apr 1 12:24:59 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 1 Apr 2005 12:24:59 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMMethod.h VMMethod.cpp Message-ID: <200504011824.MAA01701@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMMethod.h updated: 1.2 -> 1.3 VMMethod.cpp updated: 1.1 -> 1.2 --- Log message: Add another constructor for dynamically bound methods. --- Diffs of the changes: (+32 -3) VMMethod.cpp | 22 +++++++++++++++++++--- VMMethod.h | 13 +++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) Index: llvm-java/lib/Compiler/VMMethod.h diff -u llvm-java/lib/Compiler/VMMethod.h:1.2 llvm-java/lib/Compiler/VMMethod.h:1.3 --- llvm-java/lib/Compiler/VMMethod.h:1.2 Thu Mar 31 13:33:37 2005 +++ llvm-java/lib/Compiler/VMMethod.h Fri Apr 1 12:24:48 2005 @@ -32,6 +32,9 @@ const VMClass* parent_; const Method* method_; Function* function_; + int index_; + + void init(); friend class VMClass; // Interface for VMClass. @@ -39,12 +42,22 @@ // Create statically bound method reference. VMMethod(const VMClass* parent, const Method* method); + // Create dynamically bound method reference. + VMMethod(const VMClass* parent, const Method* method, int index); + public: const VMClass* getParent() const { return parent_; } const Method* getMethod() const { return method_; } Function* getFunction() const { return function_; } + int getMethodIndex() const { return index_; } + + bool isStaticallyBound() const { + return isStatic() || isPrivate() || getName()[0] == '<'; + } + bool isDynamicallyBound() const { return !isStaticallyBound(); } bool isAbstract() const { return method_->isAbstract(); } bool isNative() const { return method_->isNative(); } + bool isPrivate() const { return method_->isPrivate(); } bool isStatic() const { return method_->isStatic(); } // FIXME: remove when transition is complete. Index: llvm-java/lib/Compiler/VMMethod.cpp diff -u llvm-java/lib/Compiler/VMMethod.cpp:1.1 llvm-java/lib/Compiler/VMMethod.cpp:1.2 --- llvm-java/lib/Compiler/VMMethod.cpp:1.1 Wed Mar 30 23:10:29 2005 +++ llvm-java/lib/Compiler/VMMethod.cpp Fri Apr 1 12:24:48 2005 @@ -21,9 +21,7 @@ using namespace llvm; using namespace llvm::Java; -VMMethod::VMMethod(const VMClass* parent, const Method* method) - : parent_(parent), - method_(method) +void VMMethod::init() { const std::string& methodName = method_->getName()->str(); const std::string& methodDescriptor = method_->getDescriptor()->str(); @@ -37,3 +35,21 @@ Module* module = resolver->getModule(); function_ = module->getOrInsertFunction(functionName, functionType); } + +VMMethod::VMMethod(const VMClass* parent, const Method* method) + : parent_(parent), + method_(method), + index_(-1) +{ + assert(isStaticallyBound() && "This should be a statically bound method!"); + init(); +} + +VMMethod::VMMethod(const VMClass* parent, const Method* method, int index) + : parent_(parent), + method_(method), + index_(index) +{ + assert(isDynamicallyBound() && "This should be a dynamically bound method!"); + init(); +} From alkis at cs.uiuc.edu Fri Apr 1 12:31:36 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 1 Apr 2005 12:31:36 -0600 Subject: [llvm-commits] CVS: llvm-java/runtime/runtime.c Message-ID: <200504011831.MAA01752@zion.cs.uiuc.edu> Changes in directory llvm-java/runtime: runtime.c updated: 1.24 -> 1.25 --- Log message: Merge VTableInfo in VMClass and update the compiler to use it. Now all classes have a class record (what we previously called vtable). As a result a lot of code is greatly simplified in the compiler and the internals of building the class record are now in VMClass. --- Diffs of the changes: (+53 -31) runtime.c | 84 +++++++++++++++++++++++++++++++++++++++----------------------- 1 files changed, 53 insertions(+), 31 deletions(-) Index: llvm-java/runtime/runtime.c diff -u llvm-java/runtime/runtime.c:1.24 llvm-java/runtime/runtime.c:1.25 --- llvm-java/runtime/runtime.c:1.24 Thu Mar 31 19:56:36 2005 +++ llvm-java/runtime/runtime.c Fri Apr 1 12:31:25 2005 @@ -14,58 +14,80 @@ struct llvm_java_object_base { struct llvm_java_object_header header; - struct llvm_java_object_vtable* vtable; + struct llvm_java_object_class_record* classRecord; }; struct llvm_java_object_typeinfo { - jint depth; - struct llvm_java_object_vtable** vtables; - jint lastIface; - union { - jint interfaceFlag; - struct llvm_java_object_vtable** interfaces; - }; - jint elementSize; /* The element size - 0 for classes */ + jint depth; /* The number of super classes to java.lang.Object. */ + struct llvm_java_object_class_record** vtables; /* The super class + * records up to + * java.lang.Object. */ + jint interfaceIndex; /* If an interface its interface index, + * otherwise the last interface index + * implemented by this class. */ + struct llvm_java_object_class_record** interfaces; /* The interface + * class records + * this class + * implements */ + jint elementSize; /* If an array the size of its elements, otherwise + * 0 for classes, -1 for interfaces and -2 for + * primitive classes */ }; -struct llvm_java_object_vtable { +struct llvm_java_object_class_record { struct llvm_java_object_typeinfo typeinfo; }; -struct llvm_java_object_vtable* llvm_java_get_vtable(jobject obj) { - return obj->vtable; +jint llvm_java_is_primitive_class(struct llvm_java_object_class_record* cr) +{ + return cr->typeinfo.elementSize == -2; +} + +jint llvm_java_is_interface_class(struct llvm_java_object_class_record* cr) +{ + return cr->typeinfo.elementSize == -1; +} + +jint llvm_java_is_array_class(struct llvm_java_object_class_record* cr) +{ + return cr->typeinfo.elementSize >= 0; +} + +struct llvm_java_object_class_record* llvm_java_get_class_record(jobject obj) { + return obj->classRecord; } -void llvm_java_set_vtable(jobject obj, struct llvm_java_object_vtable* clazz) { - obj->vtable = clazz; +void llvm_java_set_class_record(jobject obj, + struct llvm_java_object_class_record* cr) { + obj->classRecord = cr; } jint llvm_java_is_instance_of(jobject obj, - struct llvm_java_object_vtable* clazz) { - struct llvm_java_object_vtable* objClazz; + struct llvm_java_object_class_record* clazz) { + struct llvm_java_object_class_record* objClazz; /* trivial case 1: a null object can be cast to any type */ if (!obj) return JNI_TRUE; - objClazz = obj->vtable; + objClazz = obj->classRecord; /* trivial case 2: this object is of class clazz */ if (objClazz == clazz) return JNI_TRUE; - /* we are checking against a class' typeinfo */ - if (clazz->typeinfo.interfaceFlag != -1) { + /* instanceof AnInterface. */ + if (llvm_java_is_interface_class(clazz)) { + /* this interface's vtable can only be found at this index */ + int index = clazz->typeinfo.interfaceIndex; + return objClazz->typeinfo.interfaceIndex >= index && + objClazz->typeinfo.interfaces[index]; + } + /* instanceof AClass */ + else { /* this class' vtable can only be found at this index */ int index = objClazz->typeinfo.depth - clazz->typeinfo.depth - 1; return index >= 0 && objClazz->typeinfo.vtables[index] == clazz; } - /* otherwise we are checking against an interface's typeinfo */ - else { - /* this interface's vtable can only be found at this index */ - int index = clazz->typeinfo.lastIface; - return objClazz->typeinfo.lastIface >= index && - objClazz->typeinfo.interfaces[index]; - } } jint llvm_java_throw(jobject obj) { @@ -373,18 +395,18 @@ jint length) { struct llvm_java_bytearray* srcArray = (struct llvm_java_bytearray*) srcObj; struct llvm_java_bytearray* dstArray = (struct llvm_java_bytearray*) dstObj; - unsigned nbytes = length * srcObj->vtable->typeinfo.elementSize; + unsigned nbytes = length * srcObj->classRecord->typeinfo.elementSize; jbyte* src = srcArray->data; jbyte* dst = dstArray->data; // FIXME: Need to perform a proper type check here. - if (srcObj->vtable->typeinfo.elementSize != - dstObj->vtable->typeinfo.elementSize) + if (srcObj->classRecord->typeinfo.elementSize != + dstObj->classRecord->typeinfo.elementSize) llvm_java_throw(NULL); - src += srcStart * srcObj->vtable->typeinfo.elementSize; - dst += dstStart * dstObj->vtable->typeinfo.elementSize; + src += srcStart * srcObj->classRecord->typeinfo.elementSize; + dst += dstStart * dstObj->classRecord->typeinfo.elementSize; memmove(dst, src, nbytes); } From alkis at cs.uiuc.edu Fri Apr 1 12:31:37 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 1 Apr 2005 12:31:37 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMClass.h VMClass.cpp Resolver.cpp Compiler.cpp Message-ID: <200504011831.MAA01762@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMClass.h updated: 1.26 -> 1.27 VMClass.cpp updated: 1.34 -> 1.35 Resolver.cpp updated: 1.11 -> 1.12 Compiler.cpp updated: 1.273 -> 1.274 --- Log message: Merge VTableInfo in VMClass and update the compiler to use it. Now all classes have a class record (what we previously called vtable). As a result a lot of code is greatly simplified in the compiler and the internals of building the class record are now in VMClass. --- Diffs of the changes: (+310 -642) Compiler.cpp | 718 +++++++---------------------------------------------------- Resolver.cpp | 8 VMClass.cpp | 211 ++++++++++++++++- VMClass.h | 15 + 4 files changed, 310 insertions(+), 642 deletions(-) Index: llvm-java/lib/Compiler/VMClass.h diff -u llvm-java/lib/Compiler/VMClass.h:1.26 llvm-java/lib/Compiler/VMClass.h:1.27 --- llvm-java/lib/Compiler/VMClass.h:1.26 Fri Apr 1 01:25:17 2005 +++ llvm-java/lib/Compiler/VMClass.h Fri Apr 1 12:31:25 2005 @@ -47,9 +47,17 @@ std::vector superClasses_; std::vector interfaces_; std::vector memberFields_; + std::vector dynamicallyBoundMethods_; + llvm::Constant* classRecord_; void computeLayout(); void computeClassRecord(); + + llvm::Constant* buildSuperClassRecords() const; + llvm::Constant* buildInterfaceClassRecord(const VMClass* interface) const; + llvm::Constant* buildInterfaceClassRecords() const; + llvm::Constant* buildClassTypeInfo() const; + const VMField* lookupField(const std::string& name) const; const VMMethod* lookupMethod(const std::string& nameAndType) const; @@ -91,6 +99,13 @@ bool isPrimitive() const { return getType() == getLayoutType(); } bool isInterface() const { return classFile_ && classFile_->isInterface(); } int getInterfaceIndex() const { return interfaceIndex_; } + unsigned getNumDynamicallyBoundMethods() const { + return dynamicallyBoundMethods_.size(); + } + const VMMethod* getDynamicallyBoundMethod(unsigned i) const { + return dynamicallyBoundMethods_[i]; + } + llvm::Constant* getClassRecord() const { return classRecord_; } llvm::Constant* getConstant(unsigned index) const; const VMClass* getClass(unsigned index) const; Index: llvm-java/lib/Compiler/VMClass.cpp diff -u llvm-java/lib/Compiler/VMClass.cpp:1.34 llvm-java/lib/Compiler/VMClass.cpp:1.35 --- llvm-java/lib/Compiler/VMClass.cpp:1.34 Thu Mar 31 23:00:06 2005 +++ llvm-java/lib/Compiler/VMClass.cpp Fri Apr 1 12:31:25 2005 @@ -34,7 +34,8 @@ layoutType_(OpaqueType::get()), type_(PointerType::get(layoutType_)), interfaceIndex_(INVALID_INTERFACE_INDEX), - resolvedConstantPool_(classFile_->getNumConstants()) + resolvedConstantPool_(classFile_->getNumConstants()), + classRecord_(NULL) { } @@ -46,7 +47,8 @@ componentClass_(componentClass), layoutType_(OpaqueType::get()), type_(PointerType::get(layoutType_)), - interfaceIndex_(INVALID_INTERFACE_INDEX) + interfaceIndex_(INVALID_INTERFACE_INDEX), + classRecord_(NULL) { } @@ -65,7 +67,8 @@ componentClass_(NULL), layoutType_(const_cast(type)), type_(type), - interfaceIndex_(INVALID_INTERFACE_INDEX) + interfaceIndex_(INVALID_INTERFACE_INDEX), + classRecord_(NULL) { } @@ -87,8 +90,7 @@ return field; } - assert(0 && "Field not found!"); - abort(); + return NULL; } const VMMethod* VMClass::lookupMethod(const std::string& nameAndType) const @@ -109,8 +111,7 @@ return method; } - assert(0 && "Method not found!"); - abort(); + return NULL; } void VMClass::computeLayout() @@ -162,17 +163,199 @@ type_ = PointerType::get(layoutType_); } +llvm::Constant* VMClass::buildSuperClassRecords() const +{ + std::vector init; + init.reserve(getNumSuperClasses()); + for (unsigned i = 0, e = getNumSuperClasses(); i != e; ++i) + init.push_back(ConstantExpr::getCast( + getSuperClass(i)->getClassRecord(), + resolver_->getClassRecordPtrType())); + + const ArrayType* superClassRecordsType = + ArrayType::get(resolver_->getClassRecordPtrType(), init.size()); + + return ConstantExpr::getPtrPtrFromArrayPtr( + new GlobalVariable( + superClassRecordsType, + true, + GlobalVariable::ExternalLinkage, + ConstantArray::get(superClassRecordsType, init), + getName() + "", + resolver_->getModule())); +} + +llvm::Constant* +VMClass::buildInterfaceClassRecord(const VMClass* interface) const +{ + assert(interface->isInterface() && "Must be passed an interface!"); + + std::vector init; + init.reserve(interface->dynamicallyBoundMethods_.size()+1); + // Insert a null type info for this interface. + init.push_back(llvm::Constant::getNullValue(resolver_->getTypeInfoType())); + // For each method this interface declares, find the corresponding + // method in this class and put it in its slot. + for (unsigned i = 0, e = interface->dynamicallyBoundMethods_.size(); + i != e; ++i) { + assert(init.size() == i+1 && "Interface method not found in class!"); + const VMMethod* interfaceMethod = interface->dynamicallyBoundMethods_[i]; + for (unsigned j = 0, f = dynamicallyBoundMethods_.size(); j != f; ++j) { + const VMMethod* method = dynamicallyBoundMethods_[j]; + if (method->getName() == interfaceMethod->getName() && + method->getDescriptor() == interfaceMethod->getDescriptor()) { + init.push_back(method->getFunction()); + break; + } + } + } + + llvm::Constant* classRecordInit = ConstantStruct::get(init); + + return ConstantExpr::getCast( + new GlobalVariable( + classRecordInit->getType(), + true, + GlobalVariable::ExternalLinkage, + classRecordInit, + getName() + '+' + interface->getName() + "", + resolver_->getModule()), + resolver_->getClassRecordPtrType()); +} + +llvm::Constant* VMClass::buildInterfaceClassRecords() const +{ + // This is an interface or primitive class record so it doesn't + // implement any interfaces. Thus the pointer to the array of + // implemented interfaces is null. + if (isInterface() || isPrimitive()) { + const Type* classRecordPtrPtrType = + PointerType::get(resolver_->getClassRecordPtrType()); + + return llvm::Constant::getNullValue(classRecordPtrPtrType); + } + + // Otherwise this is a class or array class record so we have to + // fill in the array of implemented interfaces up the max interface + // index and build each individual interface class record for this + // class. + llvm::Constant* nullClassRecord = + llvm::Constant::getNullValue(resolver_->getClassRecordPtrType()); + std::vector init(getInterfaceIndex()+1, nullClassRecord); + + for (unsigned i = 0, e = getNumInterfaces(); i != e; ++i) { + const VMClass* interface = getInterface(i); + init[interface->getInterfaceIndex()] = buildInterfaceClassRecord(interface); + } + + const ArrayType* interfaceClassRecordsType = + ArrayType::get(resolver_->getClassRecordPtrType(), init.size()); + + return ConstantExpr::getPtrPtrFromArrayPtr( + new GlobalVariable( + interfaceClassRecordsType, + true, + GlobalVariable::ExternalLinkage, + ConstantArray::get(interfaceClassRecordsType, init), + getName() + "", + resolver_->getModule())); +} + +llvm::Constant* VMClass::buildClassTypeInfo() const +{ + std::vector init; + init.reserve(5); + + init.push_back(ConstantSInt::get(Type::IntTy, getNumSuperClasses())); + init.push_back(buildSuperClassRecords()); + init.push_back(ConstantSInt::get(Type::IntTy, getInterfaceIndex())); + init.push_back(buildInterfaceClassRecords()); + if (isArray()) + init.push_back( + ConstantExpr::getCast( + ConstantExpr::getSizeOf(getComponentClass()->getType()), Type::IntTy)); + else if (isPrimitive()) + init.push_back(ConstantSInt::get(Type::IntTy, -2)); + else if (isInterface()) + init.push_back(ConstantSInt::get(Type::IntTy, -1)); + else // A class. + init.push_back(ConstantSInt::get(Type::IntTy, 0)); + + return ConstantStruct::get(init); +} + void VMClass::computeClassRecord() { - if (classFile_) { - const Methods& methods = classFile_->getMethods(); - for (unsigned i = 0, e = methods.size(); i != e; ++i) { - Method* method = methods[i]; - const std::string& name = - method->getName()->str() + method->getDescriptor()->str(); - methodMap_.insert(std::make_pair(name, VMMethod(this, method))); + // Find dynamically bound methods. + if (!isPrimitive()) { + if (const VMClass* superClass = getSuperClass()) + dynamicallyBoundMethods_ = superClass->dynamicallyBoundMethods_; + + if (getClassFile()) { + const Methods& methods = classFile_->getMethods(); + for (unsigned i = 0, e = methods.size(); i != e; ++i) { + Method* method = methods[i]; + const std::string& name = method->getName()->str(); + const std::string& descriptor = method->getDescriptor()->str(); + + // If method is statically bound just create it. + if (method->isPrivate() || method->isStatic() || name[0] == '<') + methodMap_.insert( + std::make_pair(name + descriptor, VMMethod(this, method))); + // Otherwise we need to assign an index for it and update the + // dynamicallyBoundMethods_ vector. + else { + const VMMethod* overridenMethod = NULL; + for (unsigned i = 0, e = getNumDynamicallyBoundMethods(); + i != e; ++i) { + const VMMethod* m = getDynamicallyBoundMethod(i); + if (m->getName() == name && m->getDescriptor() == descriptor) + overridenMethod = m; + } + + // If this is an overriden method reuse the method index + // with the overriding one. + if (overridenMethod) { + int index = overridenMethod->getMethodIndex(); + MethodMap::iterator i = methodMap_.insert( + std::make_pair(name + descriptor, + VMMethod(this, method, index))).first; + dynamicallyBoundMethods_[index] = &i->second; + } + // Otherwise assign it a new index. + else { + int index = dynamicallyBoundMethods_.size(); + MethodMap::iterator i = methodMap_.insert( + std::make_pair( + name + descriptor, VMMethod(this, method, index))).first; + dynamicallyBoundMethods_.push_back(&i->second); + } + } + } } } + + std::vector init; + init.reserve(1 + getNumDynamicallyBoundMethods()); + init.push_back(buildClassTypeInfo()); + for (unsigned i = 0, e = getNumDynamicallyBoundMethods(); i != e; ++i) { + const VMMethod* method = getDynamicallyBoundMethod(i); + init.push_back( + method->isAbstract() ? + llvm::Constant::getNullValue(method->getFunction()->getType()) : + method->getFunction()); + } + + llvm::Constant* classRecordInit = ConstantStruct::get(init); + resolver_->getModule()->addTypeName("classRecord." + getName(), + classRecordInit->getType()); + classRecord_ = new GlobalVariable( + classRecordInit->getType(), + true, + GlobalVariable::ExternalLinkage, + classRecordInit, + getName() + "", + resolver_->getModule()); } void VMClass::link() Index: llvm-java/lib/Compiler/Resolver.cpp diff -u llvm-java/lib/Compiler/Resolver.cpp:1.11 llvm-java/lib/Compiler/Resolver.cpp:1.12 --- llvm-java/lib/Compiler/Resolver.cpp:1.11 Thu Mar 31 01:56:28 2005 +++ llvm-java/lib/Compiler/Resolver.cpp Fri Apr 1 12:31:25 2005 @@ -66,7 +66,8 @@ StructType::get(std::vector(1, getTypeInfoType()))); classRecordType_ = holder.get(); - module_->addTypeName("struct.llvm_java_object_vtable", getClassRecordType()); + module_->addTypeName("struct.llvm_java_object_class_record", + getClassRecordType()); classRecordPtrType_ = PointerType::get(classRecordType_); } @@ -169,8 +170,9 @@ } it->second.link(); if (!it->second.isPrimitive() && !it->second.isInterface()) - module_->addTypeName(descriptor, it->second.getLayoutType()); - DEBUG(std::cerr << "Loaded class: " << descriptor << '\n'); + module_->addTypeName("struct." + descriptor, it->second.getLayoutType()); + DEBUG(std::cerr << "Loaded class: " << descriptor); + DEBUG(std::cerr << " (" << it->second.getInterfaceIndex() << ")\n"); } return &it->second; Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.273 llvm-java/lib/Compiler/Compiler.cpp:1.274 --- llvm-java/lib/Compiler/Compiler.cpp:1.273 Thu Mar 31 19:56:36 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Fri Apr 1 12:31:25 2005 @@ -61,28 +61,12 @@ BasicBlock* currentBB_; Locals locals_; OperandStack opStack_; - Function *getVtable_, *setVtable_, *throw_, *isInstanceOf_, + Function *getClassRecord_, *setClassRecord_, *throw_, *isInstanceOf_, *memcpy_, *memset_; std::vector classInitializers_; SetVector toCompileMethods_; - /// This class contains the vtable of a class, a vector with the - /// vtables of its super classes (with the class higher in the - /// hierarchy first). It also contains a map from methods to - /// struct indices for this class (used to index into the vtable). - struct VTableInfo { - VTableInfo() : vtable(NULL) { } - GlobalVariable* vtable; - std::vector superVtables; - typedef std::map Method2IndexMap; - typedef Method2IndexMap::iterator iterator; - typedef Method2IndexMap::const_iterator const_iterator; - Method2IndexMap m2iMap; - }; - typedef std::map Class2VTableInfoMap; - Class2VTableInfoMap c2viMap_; - public: Compiler(Module* m) : module_(m), @@ -97,19 +81,19 @@ NULL, "llvm_java_JNIEnv", module_); - const Type* vtablePtrType = resolver_->getClassRecordPtrType(); - getVtable_ = module_->getOrInsertFunction( - "llvm_java_get_vtable", vtablePtrType, + const Type* classRecordPtrType = resolver_->getClassRecordPtrType(); + getClassRecord_ = module_->getOrInsertFunction( + "llvm_java_get_class_record", classRecordPtrType, resolver_->getObjectBaseType(), NULL); - setVtable_ = module_->getOrInsertFunction( - "llvm_java_set_vtable", Type::VoidTy, - resolver_->getObjectBaseType(), vtablePtrType, NULL); + setClassRecord_ = module_->getOrInsertFunction( + "llvm_java_set_class_record", Type::VoidTy, + resolver_->getObjectBaseType(), classRecordPtrType, NULL); throw_ = module_->getOrInsertFunction( "llvm_java_throw", Type::IntTy, resolver_->getObjectBaseType(), NULL); isInstanceOf_ = module_->getOrInsertFunction( "llvm_java_is_instance_of", Type::IntTy, - resolver_->getObjectBaseType(), vtablePtrType, NULL); + resolver_->getObjectBaseType(), classRecordPtrType, NULL); memcpy_ = module_->getOrInsertFunction( "llvm.memcpy", Type::VoidTy, PointerType::get(Type::SByteTy), @@ -148,10 +132,7 @@ // Create a new byte[] object and initialize it with the // contents of this string constant. Value* count = ConstantUInt::get(Type::UIntTy, str.size()); - Value* arrayRef = allocateArray(resolver_->getClass("[B"), - &getPrimitiveArrayVTableInfo(BYTE), - count, - ip); + Value* arrayRef = allocateArray(resolver_->getClass("[B"), count, ip); // Copy string data. std::vector indices; indices.reserve(3); @@ -181,14 +162,13 @@ const VMClass* clazz = resolver_->getClass("java/lang/String"); emitClassInitializers(clazz); - const VTableInfo* vi = getVTableInfoGeneric(clazz); - - // Install the vtable pointer. + // Install the class record. Value* objBase = new CastInst(globalString, resolver_->getObjectBaseType(), TMP, ip); - const Type* vtablePtrType = resolver_->getClassRecordPtrType(); - Value* vtable = new CastInst(vi->vtable, vtablePtrType, TMP, ip); - new CallInst(setVtable_, objBase, vtable, "", ip); + const Type* classRecordPtrType = resolver_->getClassRecordPtrType(); + Value* classRecord = + new CastInst(clazz->getClassRecord(), classRecordPtrType, TMP, ip); + new CallInst(setClassRecord_, objBase, classRecord, "", ip); // Initialize it: call java/lang/String/(byte[],int) const VMMethod* method = clazz->getMethod("([BI)V"); @@ -197,7 +177,8 @@ params.reserve(3); params.clear(); params.push_back(objBase); - params.push_back(new CastInst(arrayRef, resolver_->getObjectBaseType(), TMP, ip)); + params.push_back( + new CastInst(arrayRef, resolver_->getObjectBaseType(), TMP, ip)); params.push_back(ConstantSInt::get(Type::IntTy, 0)); new CallInst(method->getFunction(), params, "", ip); } @@ -248,517 +229,6 @@ return 0; // not reached } - /// Initializes the VTableInfo map; in other words it adds the - /// VTableInfo for java.lang.Object. - bool initializeVTableInfoMap() { - DEBUG(std::cerr << "Building VTableInfo for: java/lang/Object\n"); - const VMClass* clazz = resolver_->getClass("java/lang/Object"); - VTableInfo& vi = c2viMap_[clazz]; - - assert(!vi.vtable && vi.m2iMap.empty() && - "java/lang/Object VTableInfo should not be initialized!"); - - Type* VTtype = OpaqueType::get(); - - std::vector init; - - // This is java/lang/Object so we must add a typeinfo struct - // first. - - const Type* vtablePtrPtrType = - PointerType::get(resolver_->getClassRecordPtrType()); - // depth - init.push_back(llvm::ConstantSInt::get(Type::IntTy, 0)); - // superclasses vtable pointers - init.push_back(llvm::Constant::getNullValue(vtablePtrPtrType)); - // last interface index - init.push_back(llvm::ConstantSInt::get(Type::IntTy, -1)); - // interfaces vtable pointers - init.push_back(llvm::Constant::getNullValue(vtablePtrPtrType)); - // the element size (0 for classes) - init.push_back(llvm::ConstantSInt::get(Type::IntTy, 0)); - - llvm::Constant* typeInfoInit = ConstantStruct::get(init); - assert(typeInfoInit->getType() == resolver_->getTypeInfoType() && - "TypeInfo types mismatch!"); - - // Now that we have both the type and initializer for the - // typeinfo struct we can start adding the function pointers. - std::vector elements; - init.clear(); - - /// First add the typeinfo struct itself. - elements.push_back(typeInfoInit->getType()); - // Add the typeinfo block for this class. - init.push_back(typeInfoInit); - - const Methods& methods = clazz->getClassFile()->getMethods(); - - // Add member functions to the vtable. - for (unsigned i = 0, e = methods.size(); i != e; ++i) { - Method* method = methods[i]; - // Static methods, private instance methods and the contructor - // are statically bound so we don't add them to the vtable. - if (!method->isStatic() && - !method->isPrivate() && - method->getName()->str()[0] != '<') { - const std::string& methodDescr = - method->getName()->str() + method->getDescriptor()->str(); - - const VMMethod* method = clazz->getMethod(methodDescr); - scheduleMethod(method); - - unsigned& index = vi.m2iMap[methodDescr]; - if (!index) { - index = elements.size(); - elements.resize(index + 1, NULL); - init.resize(index + 1, NULL); - } - elements[index] = method->getFunction()->getType(); - init[index] = method->getFunction(); - } - } - - PATypeHolder holder = VTtype; - cast(VTtype)->refineAbstractTypeTo(StructType::get(elements)); - - VTtype = holder.get(); - module_->addTypeName("java/lang/Object", VTtype); - - vi.vtable = new GlobalVariable(VTtype, - true, GlobalVariable::ExternalLinkage, - ConstantStruct::get(init), - "java/lang/Object", - module_); - DEBUG(std::cerr << "Built VTableInfo for: java/lang/Object\n"); - return true; - } - - /// Builds the super classes' vtable array for this classfile and - /// its corresponding VTable. The direct superclass goes first in - /// the array. - llvm::Constant* - buildSuperClassesVTables(const VMClass* clazz, 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], resolver_->getClassRecordPtrType()); - - llvm::Constant* init = ConstantArray::get( - ArrayType::get(resolver_->getClassRecordPtrType(), superVtables.size()), - superVtables); - - GlobalVariable* vtablesArray = new GlobalVariable( - init->getType(), - true, - GlobalVariable::ExternalLinkage, - init, - clazz->getClassFile()->getThisClass()->getName()->str() + - "", - module_); - - return ConstantExpr::getPtrPtrFromArrayPtr(vtablesArray); - } - - /// Builds an interface VTable for the specified - /// pair. - llvm::Constant* buildInterfaceVTable(const VMClass* clazz, - const VMClass* interface) { - DEBUG(std::cerr << "Building interface vtable: " - << interface->getName() << " for: " << clazz->getName() << '\n'); - - const VTableInfo& classVI = getVTableInfo(clazz); - const VTableInfo& interfaceVI = getVTableInfo(interface); - const Methods& methods = interface->getClassFile()->getMethods(); - - // The size of the initializer will be 1 greater than the number - // of methods for this interface (the first slot is the typeinfo - // struct. - std::vector init(interfaceVI.m2iMap.size()+1, NULL); - init[0] = llvm::Constant::getNullValue(resolver_->getTypeInfoType()); - - // For each method in this interface find the implementing - // method in the class' VTable and add it to the appropriate - // slot. - for (VTableInfo::Method2IndexMap::const_iterator - i = interfaceVI.m2iMap.begin(), e = interfaceVI.m2iMap.end(); - i != e; ++i) { - if (!clazz->getClassFile()->isAbstract()) { - assert(classVI.m2iMap.find(i->first) != classVI.m2iMap.end() && - "Interface method not found in class definition!"); - unsigned classMethodIdx = classVI.m2iMap.find(i->first)->second; - init[i->second] = cast( - classVI.vtable->getInitializer())->getOperand(classMethodIdx); - } - else - init[i->second] = - llvm::Constant::getNullValue(resolver_->getClassRecordPtrType()); - } - - llvm::Constant* vtable = ConstantStruct::get(init); - const std::string& globalName = - clazz->getName() + '+' + interface->getName() + ""; - module_->addTypeName(globalName, vtable->getType()); - - GlobalVariable* gv = new GlobalVariable( - vtable->getType(), - true, - GlobalVariable::ExternalLinkage, - vtable, - globalName, - module_); - - return ConstantExpr::getCast(gv, resolver_->getClassRecordPtrType()); - } - - void insertVtablesForInterface(std::vector& vtables, - const VMClass* clazz, - const VMClass* interface) { - static llvm::Constant* nullVTable = - llvm::Constant::getNullValue(resolver_->getClassRecordPtrType()); - - assert(interface->isInterface() && "Classfile must be an interface!"); - unsigned index = interface->getInterfaceIndex(); - if (index >= vtables.size()) - vtables.resize(index+1, nullVTable); - assert(vtables[index] == nullVTable && "Interface vtable already added!"); - vtables[index] = buildInterfaceVTable(clazz, interface); - } - - /// Builds the interfaces vtable array for this classfile and its - /// corresponding VTableInfo. If this classfile is an interface we - /// return a pointer to 0xFFFFFFFF. - std::pair - buildInterfacesVTables(const VMClass* clazz, 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 - // value. - if (clazz->isInterface()) - return std::make_pair( - clazz->getInterfaceIndex(), - ConstantExpr::getCast( - ConstantIntegral::getAllOnesValue(Type::LongTy), - PointerType::get(resolver_->getClassRecordPtrType()))); - - // Otherwise we must fill in the interfaces vtables array. For - // each implemented interface we insert a pointer to the - // vtable for this class. Note that we only - // fill in up to the highest index of the implemented - // interfaces. - std::vector vtables; - llvm::Constant* nullVTable = - llvm::Constant::getNullValue(resolver_->getClassRecordPtrType()); - - for (unsigned i = 0, e = clazz->getNumInterfaces(); i != e; ++i) - insertVtablesForInterface(vtables, clazz, clazz->getInterface(i)); - - const std::string& globalName = clazz->getName() + ""; - - llvm::Constant* init = ConstantArray::get( - ArrayType::get(resolver_->getClassRecordPtrType(), vtables.size()), - vtables); - module_->addTypeName(globalName, init->getType()); - - GlobalVariable* interfacesArray = new GlobalVariable( - init->getType(), - true, - GlobalVariable::ExternalLinkage, - init, - globalName, - module_); - - return std::make_pair( - int(vtables.size())-1, - ConstantExpr::getPtrPtrFromArrayPtr(interfacesArray)); - } - - /// Given the classfile and its corresponding VTableInfo, - /// construct the typeinfo constant for it. - llvm::Constant* buildClassTypeInfo(const VMClass* clazz, - const VTableInfo& vi) { - std::vector typeInfoInit; - - llvm::Constant* superClassesVTables = buildSuperClassesVTables(clazz, vi); - - // The depth (java/lang/Object has depth 0). - typeInfoInit.push_back( - ConstantSInt::get(Type::IntTy, clazz->getNumSuperClasses())); - // The super classes' vtables. - typeInfoInit.push_back(superClassesVTables); - - int lastInterface; - llvm::Constant* interfacesVTables; - tie(lastInterface, interfacesVTables) = buildInterfacesVTables(clazz, vi); - - // The last interface index or the interface index if this is an - // interface. - typeInfoInit.push_back(ConstantSInt::get(Type::IntTy, lastInterface)); - // The interfaces' vtables. - typeInfoInit.push_back(interfacesVTables); - // the element size (0 for classes) - typeInfoInit.push_back(llvm::ConstantSInt::get(Type::IntTy, 0)); - - return ConstantStruct::get(typeInfoInit); - } - - /// Returns the VTableInfo associated with this classfile. - const VTableInfo& getVTableInfo(const VMClass* clazz) { - static bool initialized = initializeVTableInfoMap(); - - Class2VTableInfoMap::iterator it = c2viMap_.lower_bound(clazz); - if (it != c2viMap_.end() && it->first == clazz) - return it->second; - - const std::string& className = - clazz->getClassFile()->getThisClass()->getName()->str(); - DEBUG(std::cerr << "Building VTableInfo for: " << className << '\n'); - VTableInfo& vi = c2viMap_[clazz]; - - assert(!vi.vtable && vi.m2iMap.empty() && - "got already initialized VTableInfo!"); - - std::vector init(1); - // Use a null typeinfo struct for now. - init[0] = llvm::Constant::getNullValue(resolver_->getTypeInfoType()); - - // If this is an interface, add all methods from each interface - // this inherits from. - if (clazz->isInterface()) { - for (unsigned i = 0, e = clazz->getNumInterfaces(); i != e; ++i) { - const VMClass* interface = clazz->getInterface(i); - const VTableInfo& ifaceVI = getVTableInfo(interface); - const ClassFile* ifaceCF = interface->getClassFile(); - ConstantStruct* ifaceInit = - cast(ifaceVI.vtable->getInitializer()); - for (VTableInfo::const_iterator MI = ifaceVI.m2iMap.begin(), - ME = ifaceVI.m2iMap.end(); MI != ME; ++MI) { - const std::string& methodDescr = MI->first; - unsigned slot = MI->second; - - unsigned& index = vi.m2iMap[methodDescr]; - if (!index) { - index = init.size(); - init.resize(index + 1); - } - init[index] = ifaceInit->getOperand(slot); - } - } - } - // Otherwise this is a class, so add all methods from its super - // class. - else { - const VMClass* superClass = clazz->getSuperClass(); - assert(superClass && "Class does not have superclass!"); - const VTableInfo& superVI = getVTableInfo(superClass); - - // Copy the super vtables array. - vi.superVtables.reserve(superVI.superVtables.size() + 1); - vi.superVtables.push_back(superVI.vtable); - std::copy(superVI.superVtables.begin(), superVI.superVtables.end(), - std::back_inserter(vi.superVtables)); - - assert(superVI.vtable && "No vtable found for super class!"); - ConstantStruct* superInit = - cast(superVI.vtable->getInitializer()); - // Fill in the function pointers as they are in the super - // class. Overriden methods will be replaced later. - init.resize(superInit->getNumOperands()); - for (unsigned i = 1, e = superInit->getNumOperands(); i != e; ++i) - init[i] = superInit->getOperand(i); - vi.m2iMap = superVI.m2iMap; - } - - // Add member functions to the vtable. - const Methods& methods = clazz->getClassFile()->getMethods(); - - for (unsigned i = 0, e = methods.size(); i != e; ++i) { - Method* method = methods[i]; - // Static methods, private instance methods and the contructor - // are statically bound so we don't add them to the vtable. - if (!method->isStatic() && - !method->isPrivate() && - method->getName()->str()[0] != '<') { - const std::string& methodDescr = - method->getName()->str() + method->getDescriptor()->str(); - - const VMMethod* method = clazz->getMethod(methodDescr); - llvm::Constant* vf = method->getFunction(); - if (clazz->isInterface() || method->isAbstract()) - vf = llvm::Constant::getNullValue(method->getFunction()->getType()); - else - scheduleMethod(method); - - unsigned& index = vi.m2iMap[methodDescr]; - if (!index) { - index = init.size(); - init.resize(index + 1); - } - init[index] = vf; - } - } - -#ifndef NDEBUG - for (unsigned i = 0, e = init.size(); i != e; ++i) - assert(init[i] && "No elements in the initializer should be NULL!"); -#endif - - const std::string& globalName = className + ""; - - llvm::Constant* vtable = ConstantStruct::get(init); - module_->addTypeName(globalName, vtable->getType()); - vi.vtable = new GlobalVariable(vtable->getType(), - true, - GlobalVariable::ExternalLinkage, - vtable, - globalName, - module_); - - // Now the vtable is complete, install the new typeinfo block - // for this class: we install it last because we need the vtable - // to exist in order to build it. - init[0] = buildClassTypeInfo(clazz, vi); - vi.vtable->setInitializer(ConstantStruct::get(init)); - - DEBUG(std::cerr << "Built VTableInfo for: " << className << '\n'); - return vi; - } - - VTableInfo buildArrayVTableInfo(const Type* elementTy) { - VTableInfo vi; - const VTableInfo& superVI = - getVTableInfo(resolver_->getClass("java/lang/Object")); - - // Add java/lang/Object as its superclass. - vi.superVtables.reserve(1); - vi.superVtables.push_back( - ConstantExpr::getCast( - superVI.vtable, resolver_->getClassRecordPtrType())); - - // Copy the constants from java/lang/Object vtable. - ConstantStruct* superInit = - cast(superVI.vtable->getInitializer()); - std::vector init(superInit->getNumOperands()); - // Use a null typeinfo struct for now. - init[0] = llvm::Constant::getNullValue(resolver_->getTypeInfoType()); - - // Fill in the function pointers as they are in - // java/lang/Object. There are no overriden methods. - for (unsigned i = 1, e = superInit->getNumOperands(); i != e; ++i) - init[i] = superInit->getOperand(i); - vi.m2iMap = superVI.m2iMap; - -#ifndef NDEBUG - for (unsigned i = 0, e = init.size(); i != e; ++i) - assert(init[i] && "No elements in the initializer should be NULL!"); -#endif - - const std::string& globalName = - elementTy->getDescription() + "[]"; - - llvm::Constant* vtable = ConstantStruct::get(init); - module_->addTypeName(globalName, vtable->getType()); - vi.vtable = new GlobalVariable(vtable->getType(), - true, - GlobalVariable::ExternalLinkage, - vtable, - globalName, - module_); - - // Construct the typeinfo now. - std::vector typeInfoInit; - typeInfoInit.push_back(ConstantSInt::get(Type::IntTy, 1)); - // Build the super classes' vtable array. - ArrayType* vtablesArrayTy = - ArrayType::get(resolver_->getClassRecordPtrType(), - vi.superVtables.size()); - - GlobalVariable* vtablesArray = new GlobalVariable( - vtablesArrayTy, - true, - GlobalVariable::ExternalLinkage, - ConstantArray::get(vtablesArrayTy, vi.superVtables), - elementTy->getDescription() + "[]", - module_); - - typeInfoInit.push_back(ConstantExpr::getPtrPtrFromArrayPtr(vtablesArray)); - typeInfoInit.push_back(ConstantSInt::get(Type::IntTy, 0)); - typeInfoInit.push_back( - llvm::Constant::getNullValue( - PointerType::get(resolver_->getClassRecordPtrType()))); - // the element size - typeInfoInit.push_back( - ConstantExpr::getCast( - ConstantExpr::getSizeOf(elementTy), Type::IntTy)); - - init[0] = ConstantStruct::get(typeInfoInit); - vi.vtable->setInitializer(ConstantStruct::get(init)); - - return vi; - } - - const VTableInfo& getPrimitiveArrayVTableInfo(const Type* type) { - if (Type::BoolTy == type) return getPrimitiveArrayVTableInfo(BOOLEAN); - else if (Type::UShortTy == type) return getPrimitiveArrayVTableInfo(CHAR); - else if (Type::FloatTy == type) return getPrimitiveArrayVTableInfo(FLOAT); - else if (Type::DoubleTy == type) return getPrimitiveArrayVTableInfo(DOUBLE); - else if (Type::SByteTy == type) return getPrimitiveArrayVTableInfo(BYTE); - else if (Type::ShortTy == type) return getPrimitiveArrayVTableInfo(SHORT); - else if (Type::IntTy == type) return getPrimitiveArrayVTableInfo(INT); - else if (Type::LongTy == type) return getPrimitiveArrayVTableInfo(LONG); - else abort(); - } - - // Returns the VTableInfo object for an array of the specified - // element type. - const VTableInfo& getPrimitiveArrayVTableInfo(JType type) { - switch (type) { - case BOOLEAN: { - // Because baload/bastore is used to load/store to both byte - // arrays and boolean arrays we use sbyte for java boolean - // arrays as well. - static VTableInfo arrayInfo = buildArrayVTableInfo(Type::SByteTy); - return arrayInfo; - } - case CHAR: { - static VTableInfo arrayInfo = buildArrayVTableInfo(Type::UShortTy); - return arrayInfo; - } - case FLOAT: { - static VTableInfo arrayInfo = buildArrayVTableInfo(Type::FloatTy); - return arrayInfo; - } - case DOUBLE: { - static VTableInfo arrayInfo = buildArrayVTableInfo(Type::DoubleTy); - return arrayInfo; - } - case BYTE: { - static VTableInfo arrayInfo = buildArrayVTableInfo(Type::SByteTy); - return arrayInfo; - } - case SHORT: { - static VTableInfo arrayInfo = buildArrayVTableInfo(Type::ShortTy); - return arrayInfo; - } - case INT: { - static VTableInfo arrayInfo = buildArrayVTableInfo(Type::IntTy); - return arrayInfo; - } - case LONG: { - static VTableInfo arrayInfo = buildArrayVTableInfo(Type::LongTy); - return arrayInfo; - } - } - abort(); - } - - const VTableInfo& getObjectArrayVTableInfo() { - static VTableInfo arrayInfo = - buildArrayVTableInfo(resolver_->getObjectBaseType()); - - return arrayInfo; - } - std::string getMangledString(const std::string& str) { std::string mangledStr; @@ -971,6 +441,15 @@ if (const VMClass* superClass = clazz->getSuperClass()) emitClassInitializers(superClass); + // Schedule all its dynamically bound non abstract methods for + // compilation. + for (unsigned i = 0, e = clazz->getNumDynamicallyBoundMethods(); + i != e; ++i) { + const VMMethod* method = clazz->getDynamicallyBoundMethod(i); + if (!method->isAbstract()) + scheduleMethod(method); + } + // Create constant strings for this class. Function* stringConstructors = module_->getOrInsertFunction( clazz->getName() + "", @@ -1481,24 +960,9 @@ return params; } - const VTableInfo* getVTableInfoGeneric(const VMClass* clazz) { - assert(!clazz->isPrimitive() && - "Cannot get VTableInfo for primitive class!"); - if (clazz->isArray()) { - const VMClass* componentClass = clazz->getComponentClass(); - if (componentClass->isPrimitive()) - return &getPrimitiveArrayVTableInfo(componentClass->getType()); - else - return &getObjectArrayVTableInfo(); - } - else - return &getVTableInfo(clazz); - } - void do_invokevirtual(unsigned index) { const VMMethod* method = class_->getMethod(index); const VMClass* clazz = method->getParent(); - const VTableInfo* vi = getVTableInfoGeneric(clazz); Function* function = method->getFunction(); std::vector params(getParams(function->getFunctionType())); @@ -1507,19 +971,21 @@ objRef = new CastInst(objRef, clazz->getType(), "this", currentBB_); Value* objBase = new CastInst(objRef, resolver_->getObjectBaseType(), TMP, currentBB_); - Value* vtable = new CallInst(getVtable_, objBase, TMP, currentBB_); - vtable = new CastInst(vtable, vi->vtable->getType(), - clazz->getName() + ".vtable", currentBB_); + Value* classRecord = + new CallInst(getClassRecord_, objBase, TMP, currentBB_); + classRecord = new CastInst(classRecord, + clazz->getClassRecord()->getType(), + clazz->getName() + ".classRecord", currentBB_); std::vector indices(1, ConstantUInt::get(Type::UIntTy, 0)); - assert(vi->m2iMap.find(method->getNameAndDescriptor()) != vi->m2iMap.end() && - "could not find slot for virtual function!"); - unsigned vSlot = vi->m2iMap.find(method->getNameAndDescriptor())->second; - indices.push_back(ConstantUInt::get(Type::UIntTy, vSlot)); - Value* vfunPtr = - new GetElementPtrInst(vtable, indices, TMP, currentBB_); - Value* vfun = new LoadInst(vfunPtr, function->getName(), currentBB_); + assert(method->getMethodIndex() != -1 && + "Method index not found for dynamically bound method!"); + indices.push_back( + ConstantUInt::get(Type::UIntTy, method->getMethodIndex()+1)); + Value* funPtr = + new GetElementPtrInst(classRecord, indices, TMP, currentBB_); + Value* fun = new LoadInst(funPtr, function->getName(), currentBB_); - makeCall(vfun, params); + makeCall(fun, params); } void do_invokespecial(unsigned index) { @@ -1552,7 +1018,7 @@ void do_invokeinterface(unsigned index) { const VMMethod* method = class_->getMethod(index); const VMClass* clazz = method->getParent(); - const VTableInfo* vi = getVTableInfoGeneric(clazz); + assert(clazz->isInterface() && "Class must be an interface!"); Function* function = method->getFunction(); std::vector params(getParams(function->getFunctionType())); @@ -1561,43 +1027,45 @@ objRef = new CastInst(objRef, clazz->getType(), "this", currentBB_); Value* objBase = new CastInst(objRef, resolver_->getObjectBaseType(), TMP, currentBB_); - Value* vtable = new CallInst(getVtable_, objBase, TMP, currentBB_); - vtable = new CastInst(vtable, resolver_->getClassRecordPtrType(), - TMP, currentBB_); - // get the interfaces array of vtables + Value* classRecord = + new CallInst(getClassRecord_, objBase, TMP, currentBB_); + classRecord = new CastInst(classRecord, + resolver_->getClassRecordPtrType(), + TMP, currentBB_); + // get the interfaces array of class records std::vector indices(2, ConstantUInt::get(Type::UIntTy, 0)); indices.push_back(ConstantUInt::get(Type::UIntTy, 3)); - Value* interfaceVTables = - new GetElementPtrInst(vtable, indices, TMP, currentBB_); - interfaceVTables = new LoadInst(interfaceVTables, TMP, currentBB_); - // Get the actual interface vtable. + Value* interfaceClassRecords = + new GetElementPtrInst(classRecord, indices, TMP, currentBB_); + interfaceClassRecords = + new LoadInst(interfaceClassRecords, TMP, currentBB_); + // Get the actual interface class record. indices.clear(); - indices.push_back(ConstantUInt::get(Type::UIntTy, - clazz->getInterfaceIndex())); - Value* interfaceVTable = - new GetElementPtrInst(interfaceVTables, indices, TMP, currentBB_); - interfaceVTable = - new LoadInst(interfaceVTable, clazz->getName() + ".vtable", currentBB_); - interfaceVTable = - new CastInst(interfaceVTable, vi->vtable->getType(), TMP, currentBB_); + indices.push_back( + ConstantUInt::get(Type::UIntTy, clazz->getInterfaceIndex())); + Value* interfaceClassRecord = + new GetElementPtrInst(interfaceClassRecords, indices, TMP, currentBB_); + interfaceClassRecord = + new LoadInst(interfaceClassRecord, + clazz->getName() + ".classRecord", currentBB_); + interfaceClassRecord = + new CastInst(interfaceClassRecord, + clazz->getClassRecord()->getType(), TMP, currentBB_); // Get the function pointer. - assert(vi->m2iMap.find(method->getNameAndDescriptor()) != vi->m2iMap.end() && - "could not find slot for virtual function!"); - unsigned vSlot = vi->m2iMap.find(method->getNameAndDescriptor())->second; + assert(method->getMethodIndex() != -1 && + "Method index not found for dynamically bound method!"); indices.resize(2); indices[0] = ConstantUInt::get(Type::UIntTy, 0); - indices[1] = ConstantUInt::get(Type::UIntTy, vSlot); - Value* vfunPtr = - new GetElementPtrInst(interfaceVTable, indices, TMP, currentBB_); - Value* vfun = new LoadInst(vfunPtr, function->getName(), currentBB_); + indices[1] = ConstantUInt::get(Type::UIntTy, method->getMethodIndex()+1); + Value* funPtr = + new GetElementPtrInst(interfaceClassRecord, indices, TMP, currentBB_); + Value* fun = new LoadInst(funPtr, function->getName(), currentBB_); - makeCall(vfun, params); + makeCall(fun, params); } template - Value* allocateObject(const VMClass& clazz, - const VTableInfo& vi, - InsertionPointTy* ip) { + Value* allocateObject(const VMClass& clazz, InsertionPointTy* ip) { static std::vector params(4); Value* objRef = new MallocInst(clazz.getLayoutType(), NULL, TMP, ip); @@ -1608,11 +1076,13 @@ params[3] = ConstantUInt::get(Type::UIntTy, 0); // alignment new CallInst(memset_, params, "", ip); - // Install the vtable pointer. - Value* objBase = new CastInst(objRef, resolver_->getObjectBaseType(), TMP, ip); - const Type* vtablePtrType = resolver_->getClassRecordPtrType(); - Value* vtable = new CastInst(vi.vtable, vtablePtrType, TMP, ip); - new CallInst(setVtable_, objBase, vtable, "", ip); + // Install the class record. + Value* objBase = + new CastInst(objRef, resolver_->getObjectBaseType(), TMP, ip); + const Type* classRecordPtrType = resolver_->getClassRecordPtrType(); + Value* classRecord = + new CastInst(clazz.getClassRecord(), classRecordPtrType, TMP, ip); + new CallInst(setClassRecord_, objBase, classRecord, "", ip); return objRef; } @@ -1620,9 +1090,7 @@ void do_new(unsigned index) { const VMClass* clazz = class_->getClass(index); emitClassInitializers(clazz); - const VTableInfo& vi = getVTableInfo(clazz); - - push(allocateObject(*clazz, vi, currentBB_)); + push(allocateObject(*clazz, currentBB_)); } template @@ -1647,7 +1115,6 @@ template Value* allocateArray(const VMClass* clazz, - const VTableInfo* vi, Value* count, InsertionPointTy* ip) { static std::vector params(4); @@ -1686,11 +1153,12 @@ Value* lengthPtr = getArrayLengthPtr(objRef, ip); new StoreInst(count, lengthPtr, ip); - // Install the vtable pointer. + // Install the class record. Value* objBase = new CastInst(objRef, resolver_->getObjectBaseType(), TMP, ip); - const Type* vtablePtrType = resolver_->getClassRecordPtrType(); - Value* vtable = new CastInst(vi->vtable, vtablePtrType, TMP, ip); - new CallInst(setVtable_, objBase, vtable, "", ip); + const Type* classRecordPtrType = resolver_->getClassRecordPtrType(); + Value* classRecord = + new CastInst(clazz->getClassRecord(), classRecordPtrType, TMP, ip); + new CallInst(setClassRecord_, objBase, classRecord, "", ip); return objRef; } @@ -1700,9 +1168,8 @@ const VMClass* clazz = resolver_->getClass(type); const VMClass* arrayClass = resolver_->getArrayClass(clazz); - const VTableInfo* vi = getVTableInfoGeneric(arrayClass); - push(allocateArray(arrayClass, vi, count, currentBB_)); + push(allocateArray(arrayClass, count, currentBB_)); } void do_anewarray(unsigned index) { @@ -1710,9 +1177,8 @@ const VMClass* clazz = class_->getClass(index); const VMClass* arrayClass = resolver_->getArrayClass(clazz); - const VTableInfo* vi = getVTableInfoGeneric(arrayClass); - push(allocateArray(arrayClass, vi, count, currentBB_)); + push(allocateArray(arrayClass, count, currentBB_)); } void do_arraylength() { @@ -1731,12 +1197,13 @@ void do_checkcast(unsigned index) { const VMClass* clazz = class_->getClass(index); - const VTableInfo* vi = getVTableInfoGeneric(clazz); Value* objRef = pop(resolver_->getObjectBaseType()); - const Type* vtablePtrType = resolver_->getClassRecordPtrType(); - Value* vtable = new CastInst(vi->vtable, vtablePtrType, TMP, currentBB_); - Value* r = new CallInst(isInstanceOf_, objRef, vtable, TMP, currentBB_); + const Type* classRecordPtrType = resolver_->getClassRecordPtrType(); + Value* classRecord = new CastInst(clazz->getClassRecord(), + classRecordPtrType, TMP, currentBB_); + Value* r = + new CallInst(isInstanceOf_, objRef, classRecord, TMP, currentBB_); Value* b = new SetCondInst(Instruction::SetEQ, r, ConstantSInt::get(Type::IntTy, 1), @@ -1747,12 +1214,13 @@ void do_instanceof(unsigned index) { const VMClass* clazz = class_->getClass(index); - const VTableInfo* vi = getVTableInfoGeneric(clazz); Value* objRef = pop(resolver_->getObjectBaseType()); - const Type* vtablePtrType = resolver_->getClassRecordPtrType(); - Value* vtable = new CastInst(vi->vtable, vtablePtrType, TMP, currentBB_); - Value* r = new CallInst(isInstanceOf_, objRef, vtable, TMP, currentBB_); + const Type* classRecordPtrType = resolver_->getClassRecordPtrType(); + Value* classRecord = new CastInst(clazz->getClassRecord(), + classRecordPtrType, TMP, currentBB_); + Value* r = + new CallInst(isInstanceOf_, objRef, classRecord, TMP, currentBB_); push(r); } From alkis at cs.uiuc.edu Fri Apr 1 12:42:50 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 1 Apr 2005 12:42:50 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/ClassFile/ClassFile.cpp Message-ID: <200504011842.MAA01827@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/ClassFile: ClassFile.cpp updated: 1.44 -> 1.45 --- Log message: Remove nameAndType->method map from ClassFile as this is not needed anymore since an equivalent data structure exists in VMClass. --- Diffs of the changes: (+0 -11) ClassFile.cpp | 11 ----------- 1 files changed, 11 deletions(-) Index: llvm-java/lib/ClassFile/ClassFile.cpp diff -u llvm-java/lib/ClassFile/ClassFile.cpp:1.44 llvm-java/lib/ClassFile/ClassFile.cpp:1.45 --- llvm-java/lib/ClassFile/ClassFile.cpp:1.44 Sat Mar 26 13:14:02 2005 +++ llvm-java/lib/ClassFile/ClassFile.cpp Fri Apr 1 12:42:38 2005 @@ -208,11 +208,6 @@ 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( - std::make_pair( - (*i)->getName()->str() + (*i)->getDescriptor()->str(), *i)); } ConstantClass* ClassFile::getConstantClass(unsigned index) const @@ -265,12 +260,6 @@ return static_cast(getConstant(index)); } -Method* ClassFile::getMethod(const std::string& nameAndDescr) const -{ - Name2MethodMap::const_iterator it = n2mMap_.find(nameAndDescr); - return it == n2mMap_.end() ? NULL : it->second; -} - bool ClassFile::isNativeMethodOverloaded(const Method& method) const { unsigned count = 0; From alkis at cs.uiuc.edu Fri Apr 1 12:42:50 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 1 Apr 2005 12:42:50 -0600 Subject: [llvm-commits] CVS: llvm-java/include/llvm/Java/ClassFile.h Message-ID: <200504011842.MAA01831@zion.cs.uiuc.edu> Changes in directory llvm-java/include/llvm/Java: ClassFile.h updated: 1.36 -> 1.37 --- Log message: Remove nameAndType->method map from ClassFile as this is not needed anymore since an equivalent data structure exists in VMClass. --- Diffs of the changes: (+0 -5) ClassFile.h | 5 ----- 1 files changed, 5 deletions(-) Index: llvm-java/include/llvm/Java/ClassFile.h diff -u llvm-java/include/llvm/Java/ClassFile.h:1.36 llvm-java/include/llvm/Java/ClassFile.h:1.37 --- llvm-java/include/llvm/Java/ClassFile.h:1.36 Mon Mar 28 19:01:16 2005 +++ llvm-java/include/llvm/Java/ClassFile.h Fri Apr 1 12:42:38 2005 @@ -18,7 +18,6 @@ #include #include -#include #include #include @@ -72,8 +71,6 @@ static std::vector getClassPath(); static sys::Path getFileForClass(const std::string& classname); - typedef std::map Name2MethodMap; - public: static const ClassFile* get(const std::string& classname); @@ -120,7 +117,6 @@ const Attributes& getAttributes() const { return attributes_; } - Method* getMethod(const std::string& nameAndDescr) const; bool isNativeMethodOverloaded(const Method& method) const; std::ostream& dump(std::ostream& os) const; @@ -136,7 +132,6 @@ Fields fields_; Methods methods_; Attributes attributes_; - Name2MethodMap n2mMap_; ClassFile(std::istream& is); }; From alkis at cs.uiuc.edu Fri Apr 1 14:21:07 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 1 Apr 2005 14:21:07 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMClass.cpp Message-ID: <200504012021.OAA02448@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMClass.cpp updated: 1.35 -> 1.36 --- Log message: Compute class records for primitive classes as well. --- Diffs of the changes: (+6 -3) VMClass.cpp | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) Index: llvm-java/lib/Compiler/VMClass.cpp diff -u llvm-java/lib/Compiler/VMClass.cpp:1.35 llvm-java/lib/Compiler/VMClass.cpp:1.36 --- llvm-java/lib/Compiler/VMClass.cpp:1.35 Fri Apr 1 12:31:25 2005 +++ llvm-java/lib/Compiler/VMClass.cpp Fri Apr 1 14:20:56 2005 @@ -116,6 +116,10 @@ void VMClass::computeLayout() { + // The layout of primitive classes is already computed. + if (isPrimitive()) + return; + // If this is an interface, then its layout and type are the same as // java/lang/Object. if (isInterface()) { @@ -362,9 +366,8 @@ { // Primitive classes require no linking. if (isPrimitive()) - return; - - if (isArray()) { + ; + else if (isArray()) { superClasses_.reserve(1); superClasses_.push_back(resolver_->getClass("java/lang/Object")); From natebegeman at mac.com Fri Apr 1 16:34:51 2005 From: natebegeman at mac.com (Nate Begeman) Date: Fri, 1 Apr 2005 16:34:51 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Message-ID: <200504012234.QAA07971@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPC32ISelPattern.cpp updated: 1.31 -> 1.32 --- Log message: Add ISD::UNDEF node Teach the SelectionDAG code how to expand and promote it Have PPC32 LowerCallTo generate ISD::UNDEF for int arg regs used up by fp arguments, but not shadowing their value. This allows us to do the right thing with both fixed and vararg floating point arguments. --- Diffs of the changes: (+67 -41) PPC32ISelPattern.cpp | 108 +++++++++++++++++++++++++++++++-------------------- 1 files changed, 67 insertions(+), 41 deletions(-) Index: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp diff -u llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.31 llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.32 --- llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.31 Fri Apr 1 02:57:43 2005 +++ llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Fri Apr 1 16:34:39 2005 @@ -53,7 +53,7 @@ // PowerPC has an i16 but no i8 (or i1) SEXTLOAD setOperationAction(ISD::SEXTLOAD, MVT::i1, Expand); setOperationAction(ISD::SEXTLOAD, MVT::i8, Expand); - + addLegalFPImmediate(+0.0); // Necessary for FSEL addLegalFPImmediate(-0.0); // @@ -251,15 +251,6 @@ unsigned ArgOffset = 24; unsigned GPR_remaining = 8; unsigned FPR_remaining = 13; - unsigned GPR_idx = 0, FPR_idx = 0; - static const unsigned GPR[] = { - PPC::R3, PPC::R4, PPC::R5, PPC::R6, - PPC::R7, PPC::R8, PPC::R9, PPC::R10, - }; - static const unsigned FPR[] = { - PPC::F1, PPC::F2, PPC::F3, PPC::F4, PPC::F5, PPC::F6, PPC::F7, - PPC::F8, PPC::F9, PPC::F10, PPC::F11, PPC::F12, PPC::F13 - }; std::vector MemOps; for (unsigned i = 0, e = Args.size(); i != e; ++i) { @@ -283,10 +274,8 @@ // FALL THROUGH case MVT::i32: if (GPR_remaining > 0) { - args_to_use.push_back(DAG.getCopyToReg(Chain, Args[i].first, - GPR[GPR_idx])); + args_to_use.push_back(Args[i].first); --GPR_remaining; - ++GPR_idx; } else { MemOps.push_back(DAG.getNode(ISD::STORE, MVT::Other, Chain, Args[i].first, PtrOff)); @@ -302,13 +291,11 @@ Args[i].first, DAG.getConstant(1, MVT::i32)); SDOperand Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, MVT::i32, Args[i].first, DAG.getConstant(0, MVT::i32)); - args_to_use.push_back(DAG.getCopyToReg(Chain, Hi, GPR[GPR_idx])); + args_to_use.push_back(Hi); --GPR_remaining; - ++GPR_idx; if (GPR_remaining > 0) { - args_to_use.push_back(DAG.getCopyToReg(Chain, Lo, GPR[GPR_idx])); + args_to_use.push_back(Lo); --GPR_remaining; - ++GPR_idx; } else { SDOperand ConstFour = DAG.getConstant(4, getPointerTy()); PtrOff = DAG.getNode(ISD::ADD, MVT::i32, PtrOff, ConstFour); @@ -324,6 +311,8 @@ case MVT::f32: case MVT::f64: if (FPR_remaining > 0) { + args_to_use.push_back(Args[i].first); + --FPR_remaining; if (isVarArg) { SDOperand Store = DAG.getNode(ISD::STORE, MVT::Other, Chain, Args[i].first, PtrOff); @@ -332,32 +321,29 @@ if (GPR_remaining > 0) { SDOperand Load = DAG.getLoad(MVT::i32, Store, PtrOff); MemOps.push_back(Load); - args_to_use.push_back(DAG.getCopyToReg(Load, Load, - GPR[GPR_idx])); + args_to_use.push_back(Load); + --GPR_remaining; } - if (GPR_remaining > 1 && MVT::f64 == ArgVT) { + if (GPR_remaining > 0 && MVT::f64 == ArgVT) { SDOperand ConstFour = DAG.getConstant(4, getPointerTy()); PtrOff = DAG.getNode(ISD::ADD, MVT::i32, PtrOff, ConstFour); SDOperand Load = DAG.getLoad(MVT::i32, Store, PtrOff); MemOps.push_back(Load); - args_to_use.push_back(DAG.getCopyToReg(Load, Load, - GPR[GPR_idx+1])); + args_to_use.push_back(Load); + --GPR_remaining; + } + } else { + // If we have any FPRs remaining, we may also have GPRs remaining. + // Args passed in FPRs consume either 1 (f32) or 2 (f64) available + // GPRs. + if (GPR_remaining > 0) { + args_to_use.push_back(DAG.getNode(ISD::UNDEF, MVT::i32)); + --GPR_remaining; + } + if (GPR_remaining > 0 && MVT::f64 == ArgVT) { + args_to_use.push_back(DAG.getNode(ISD::UNDEF, MVT::i32)); + --GPR_remaining; } - } - args_to_use.push_back(DAG.getCopyToReg(Chain, Args[i].first, - FPR[FPR_idx])); - --FPR_remaining; - ++FPR_idx; - // If we have any FPRs remaining, we may also have GPRs remaining. - // Args passed in FPRs consume either 1 (f32) or 2 (f64) available - // GPRs. - if (GPR_remaining > 0) { - --GPR_remaining; - ++GPR_idx; - } - if (GPR_remaining > 0 && MVT::f64 == ArgVT) { - --GPR_remaining; - ++GPR_idx; } } else { MemOps.push_back(DAG.getNode(ISD::STORE, MVT::Other, Chain, @@ -909,14 +895,20 @@ } if (DestType == MVT::f64 || DestType == MVT::f32) - if (ISD::LOAD != opcode && ISD::EXTLOAD != opcode) + if (ISD::LOAD != opcode && ISD::EXTLOAD != opcode && ISD::UNDEF != opcode) return SelectExprFP(N, Result); switch (opcode) { default: Node->dump(); assert(0 && "Node not handled!\n"); - + case ISD::UNDEF: + if (Result != 1) + ExprMap[N.getValue(1)] = 1; + else + Result = ExprMap[N.getValue(0)] = MakeReg(N.getValue(0).getValueType()); + BuildMI(BB, PPC::IMPLICIT_DEF, 0, Result); + return Result; case ISD::DYNAMIC_STACKALLOC: // Generate both result values. FIXME: Need a better commment here? if (Result != 1) @@ -1020,13 +1012,47 @@ } case ISD::CALL: { + unsigned GPR_idx = 0, FPR_idx = 0; + static const unsigned GPR[] = { + PPC::R3, PPC::R4, PPC::R5, PPC::R6, + PPC::R7, PPC::R8, PPC::R9, PPC::R10, + }; + static const unsigned FPR[] = { + PPC::F1, PPC::F2, PPC::F3, PPC::F4, PPC::F5, PPC::F6, PPC::F7, + PPC::F8, PPC::F9, PPC::F10, PPC::F11, PPC::F12, PPC::F13 + }; + // Lower the chain for this call. Select(N.getOperand(0)); ExprMap[N.getValue(Node->getNumValues()-1)] = 1; + // Load the register args to virtual regs + std::vector ArgVR; for(int i = 2, e = Node->getNumOperands(); i < e; ++i) - Select(N.getOperand(i)); - + ArgVR.push_back(SelectExpr(N.getOperand(i))); + + // Copy the virtual registers into the appropriate argument register + for(int i = 0, e = ArgVR.size(); i < e; ++i) { + switch(N.getOperand(i+2).getValueType()) { + default: Node->dump(); assert(0 && "Unknown value type for call"); + case MVT::i1: + case MVT::i8: + case MVT::i16: + case MVT::i32: + assert(GPR_idx < 8 && "Too many int args"); + if (N.getOperand(i+2).getOpcode() != ISD::UNDEF) + BuildMI(BB, PPC::OR,2,GPR[GPR_idx]).addReg(ArgVR[i]).addReg(ArgVR[i]); + ++GPR_idx; + break; + case MVT::f64: + case MVT::f32: + assert(FPR_idx < 13 && "Too many fp args"); + BuildMI(BB, PPC::FMR, 1, FPR[FPR_idx]).addReg(ArgVR[i]); + ++FPR_idx; + break; + } + } + // Emit the correct call instruction based on the type of symbol called. if (GlobalAddressSDNode *GASD = dyn_cast(N.getOperand(1))) { From natebegeman at mac.com Fri Apr 1 16:34:51 2005 From: natebegeman at mac.com (Nate Begeman) Date: Fri, 1 Apr 2005 16:34:51 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/SelectionDAGNodes.h Message-ID: <200504012234.QAA07975@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: SelectionDAGNodes.h updated: 1.23 -> 1.24 --- Log message: Add ISD::UNDEF node Teach the SelectionDAG code how to expand and promote it Have PPC32 LowerCallTo generate ISD::UNDEF for int arg regs used up by fp arguments, but not shadowing their value. This allows us to do the right thing with both fixed and vararg floating point arguments. --- Diffs of the changes: (+3 -0) SelectionDAGNodes.h | 3 +++ 1 files changed, 3 insertions(+) Index: llvm/include/llvm/CodeGen/SelectionDAGNodes.h diff -u llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.23 llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.24 --- llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.23 Thu Mar 31 15:30:35 2005 +++ llvm/include/llvm/CodeGen/SelectionDAGNodes.h Fri Apr 1 16:34:39 2005 @@ -74,6 +74,9 @@ // out. ImplicitDef, + // UNDEF - An undefined node + UNDEF, + // EXTRACT_ELEMENT - This is used to get the first or second (determined by // a Constant, which is required to be operand #1), element of the aggregate // value specified as operand #0. This is only for use before legalization, From natebegeman at mac.com Fri Apr 1 16:34:51 2005 From: natebegeman at mac.com (Nate Begeman) Date: Fri, 1 Apr 2005 16:34:51 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp SelectionDAG.cpp Message-ID: <200504012234.QAA07981@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: LegalizeDAG.cpp updated: 1.64 -> 1.65 SelectionDAG.cpp updated: 1.54 -> 1.55 --- Log message: Add ISD::UNDEF node Teach the SelectionDAG code how to expand and promote it Have PPC32 LowerCallTo generate ISD::UNDEF for int arg regs used up by fp arguments, but not shadowing their value. This allows us to do the right thing with both fixed and vararg floating point arguments. --- Diffs of the changes: (+25 -0) LegalizeDAG.cpp | 24 ++++++++++++++++++++++++ SelectionDAG.cpp | 1 + 2 files changed, 25 insertions(+) Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.64 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.65 --- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.64 Thu Mar 31 15:24:06 2005 +++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Fri Apr 1 16:34:39 2005 @@ -219,6 +219,23 @@ if (Tmp1 != Node->getOperand(0)) Result = DAG.getImplicitDef(Tmp1, cast(Node)->getReg()); break; + case ISD::UNDEF: { + MVT::ValueType VT = Op.getValueType(); + switch (TLI.getOperationAction(ISD::UNDEF, VT)) { + case Expand: + case Promote: + if (MVT::isInteger(VT)) + Result = DAG.getConstant(0, VT); + else if (MVT::isFloatingPoint(VT)) + Result = DAG.getConstantFP(0, VT); + else + assert(0 && "Unknown value type!"); + break; + case Legal: + break; + } + break; + } case ISD::Constant: // We know we don't need to expand constants here, constants only have one // value and we check that it is fine above. @@ -1018,6 +1035,9 @@ std::cerr << "NODE: "; Node->dump(); std::cerr << "\n"; assert(0 && "Do not know how to promote this operator!"); abort(); + case ISD::UNDEF: + Result = DAG.getNode(ISD::UNDEF, NVT); + break; case ISD::Constant: Result = DAG.getNode(ISD::ZERO_EXTEND, NVT, Op); assert(isa(Result) && "Didn't constant fold zext?"); @@ -1574,6 +1594,10 @@ std::cerr << "NODE: "; Node->dump(); std::cerr << "\n"; assert(0 && "Do not know how to expand this operator!"); abort(); + case ISD::UNDEF: + Lo = DAG.getNode(ISD::UNDEF, NVT); + Hi = DAG.getNode(ISD::UNDEF, NVT); + break; case ISD::Constant: { uint64_t Cst = cast(Node)->getValue(); Lo = DAG.getConstant(Cst, NVT); Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.54 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.55 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.54 Thu Mar 31 15:24:06 2005 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Fri Apr 1 16:34:39 2005 @@ -1112,6 +1112,7 @@ case ISD::CopyToReg: return "CopyToReg"; case ISD::CopyFromReg: return "CopyFromReg"; case ISD::ImplicitDef: return "ImplicitDef"; + case ISD::UNDEF: return "undef"; case ISD::ADD: return "add"; case ISD::SUB: return "sub"; From alkis at cs.uiuc.edu Fri Apr 1 16:43:55 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 1 Apr 2005 16:43:55 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200504012243.QAA08029@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.274 -> 1.275 --- Log message: Initialize array classes as well (and their component classes recursively). --- Diffs of the changes: (+31 -19) Compiler.cpp | 50 +++++++++++++++++++++++++++++++------------------- 1 files changed, 31 insertions(+), 19 deletions(-) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.274 llvm-java/lib/Compiler/Compiler.cpp:1.275 --- llvm-java/lib/Compiler/Compiler.cpp:1.274 Fri Apr 1 12:31:25 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Fri Apr 1 16:43:44 2005 @@ -432,28 +432,38 @@ void emitClassInitializers(const VMClass* clazz) { static SetVector toInitClasses; - const ClassFile* classfile = clazz->getClassFile(); - if (!classfile) + // If this is a primitive class we are done. + if (clazz->isPrimitive()) + return; + + // If this class is already initialized, we are done. + if (!toInitClasses.insert(clazz)) return; - - if (toInitClasses.insert(clazz)) { - // If this class has a super class, initialize that first. - if (const VMClass* superClass = clazz->getSuperClass()) - emitClassInitializers(superClass); - - // Schedule all its dynamically bound non abstract methods for - // compilation. - for (unsigned i = 0, e = clazz->getNumDynamicallyBoundMethods(); - i != e; ++i) { - const VMMethod* method = clazz->getDynamicallyBoundMethod(i); - if (!method->isAbstract()) - scheduleMethod(method); - } - // Create constant strings for this class. + // If this class has a super class, initialize that first. + if (const VMClass* superClass = clazz->getSuperClass()) + emitClassInitializers(superClass); + + // If this class is an array, initialize its component class now. + if (const VMClass* componentClass = clazz->getComponentClass()) + emitClassInitializers(componentClass); + + // Schedule all its dynamically bound non abstract methods for + // compilation. + for (unsigned i = 0, e = clazz->getNumDynamicallyBoundMethods(); + i != e; ++i) { + const VMMethod* method = clazz->getDynamicallyBoundMethod(i); + if (!method->isAbstract()) + scheduleMethod(method); + } + + + // If this class has a constant pool (was loaded from a + // classfile), create constant strings for it. + if (const ClassFile* classfile = clazz->getClassFile()) { Function* stringConstructors = module_->getOrInsertFunction( - clazz->getName() + "", - FunctionType::get(Type::VoidTy, std::vector(), false)); + clazz->getName() + "", + FunctionType::get(Type::VoidTy, std::vector(), false)); Instruction* I = new ReturnInst(NULL, new BasicBlock("entry", stringConstructors)); for (unsigned i = 0, e = classfile->getNumConstants(); i != e; ++i) @@ -1168,6 +1178,7 @@ const VMClass* clazz = resolver_->getClass(type); const VMClass* arrayClass = resolver_->getArrayClass(clazz); + emitClassInitializers(arrayClass); push(allocateArray(arrayClass, count, currentBB_)); } @@ -1177,6 +1188,7 @@ const VMClass* clazz = class_->getClass(index); const VMClass* arrayClass = resolver_->getArrayClass(clazz); + emitClassInitializers(arrayClass); push(allocateArray(arrayClass, count, currentBB_)); } From lattner at cs.uiuc.edu Fri Apr 1 16:47:02 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 1 Apr 2005 16:47:02 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ISelPattern.cpp Message-ID: <200504012247.j31Ml21P019493@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ISelPattern.cpp updated: 1.95 -> 1.96 --- Log message: Add support for ISD::UNDEF to the X86 be --- Diffs of the changes: (+8 -0) X86ISelPattern.cpp | 8 ++++++++ 1 files changed, 8 insertions(+) Index: llvm/lib/Target/X86/X86ISelPattern.cpp diff -u llvm/lib/Target/X86/X86ISelPattern.cpp:1.95 llvm/lib/Target/X86/X86ISelPattern.cpp:1.96 --- llvm/lib/Target/X86/X86ISelPattern.cpp:1.95 Tue Mar 29 19:10:00 2005 +++ llvm/lib/Target/X86/X86ISelPattern.cpp Fri Apr 1 16:46:45 2005 @@ -1384,6 +1384,14 @@ } BuildMI(BB, Opc, 1,Result).addImm(cast(N)->getValue()); return Result; + case ISD::UNDEF: + if (Node->getValueType(0) == MVT::f64) { + // FIXME: SHOULD TEACH STACKIFIER ABOUT UNDEF VALUES! + BuildMI(BB, X86::FLD0, 0, Result); + } else { + BuildMI(BB, X86::IMPLICIT_DEF, 0, Result); + } + return Result; case ISD::GlobalAddress: { GlobalValue *GV = cast(N)->getGlobal(); BuildMI(BB, X86::MOV32ri, 1, Result).addGlobalAddress(GV); From alkis at cs.uiuc.edu Fri Apr 1 16:56:31 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 1 Apr 2005 16:56:31 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMClass.cpp Message-ID: <200504012256.QAA08098@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMClass.cpp updated: 1.36 -> 1.37 --- Log message: Make any interface as if it inherits from java/lang/Object. --- Diffs of the changes: (+5 -20) VMClass.cpp | 25 +++++-------------------- 1 files changed, 5 insertions(+), 20 deletions(-) Index: llvm-java/lib/Compiler/VMClass.cpp diff -u llvm-java/lib/Compiler/VMClass.cpp:1.36 llvm-java/lib/Compiler/VMClass.cpp:1.37 --- llvm-java/lib/Compiler/VMClass.cpp:1.36 Fri Apr 1 14:20:56 2005 +++ llvm-java/lib/Compiler/VMClass.cpp Fri Apr 1 16:56:20 2005 @@ -120,15 +120,6 @@ if (isPrimitive()) return; - // If this is an interface, then its layout and type are the same as - // java/lang/Object. - if (isInterface()) { - const VMClass* object = resolver_->getClass("java/lang/Object"); - layoutType_ = const_cast(object->getLayoutType()); - type_ = object->getType(); - return; - } - std::vector layout; if (isArray()) { layout.reserve(3); @@ -385,17 +376,11 @@ for (unsigned i = 0, e = superClass->getNumInterfaces(); i != e; ++i) interfaces_.push_back(superClass->getInterface(i)); - // In a classfile an interface is as if it inherits - // java/lang/Object, but java/lang/Class/getSuperClass() should - // return null on any interface class. So we only add - // superclasses to if this is not an interface. - if (!classFile_->isInterface()) { - // The first class is the direct super class of this class. - superClasses_.reserve(superClass->getNumSuperClasses() + 1); - superClasses_.push_back(superClass); - for (unsigned i = 0, e = superClass->getNumSuperClasses(); i != e; ++i) - superClasses_.push_back(superClass->getSuperClass(i)); - } + // The first class is the direct super class of this class. + superClasses_.reserve(superClass->getNumSuperClasses() + 1); + superClasses_.push_back(superClass); + for (unsigned i = 0, e = superClass->getNumSuperClasses(); i != e; ++i) + superClasses_.push_back(superClass->getSuperClass(i)); } // For each of the interfaces we implement, load it and add that From alkis at cs.uiuc.edu Fri Apr 1 16:59:31 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 1 Apr 2005 16:59:31 -0600 Subject: [llvm-commits] CVS: llvm-java/runtime/runtime.c Message-ID: <200504012259.QAA08137@zion.cs.uiuc.edu> Changes in directory llvm-java/runtime: runtime.c updated: 1.25 -> 1.26 --- Log message: Implement instanceof for arrays. Now we pass ArrayInstanceOf.java. --- Diffs of the changes: (+60 -37) runtime.c | 97 ++++++++++++++++++++++++++++++++++++++------------------------ 1 files changed, 60 insertions(+), 37 deletions(-) Index: llvm-java/runtime/runtime.c diff -u llvm-java/runtime/runtime.c:1.25 llvm-java/runtime/runtime.c:1.26 --- llvm-java/runtime/runtime.c:1.25 Fri Apr 1 12:31:25 2005 +++ llvm-java/runtime/runtime.c Fri Apr 1 16:59:20 2005 @@ -18,20 +18,27 @@ }; struct llvm_java_object_typeinfo { - jint depth; /* The number of super classes to java.lang.Object. */ - struct llvm_java_object_class_record** vtables; /* The super class - * records up to - * java.lang.Object. */ - jint interfaceIndex; /* If an interface its interface index, - * otherwise the last interface index - * implemented by this class. */ - struct llvm_java_object_class_record** interfaces; /* The interface - * class records - * this class - * implements */ - jint elementSize; /* If an array the size of its elements, otherwise - * 0 for classes, -1 for interfaces and -2 for - * primitive classes */ + /* The number of super classes to java.lang.Object. */ + jint depth; + + /* The super class records up to java.lang.Object. */ + struct llvm_java_object_class_record** superclasses; + + /* If an interface its interface index, otherwise the last interface + * index implemented by this class. */ + jint interfaceIndex; + + + /* The interface class records this class implements. */ + struct llvm_java_object_class_record** interfaces; + + /* The component class record if this is an array class, null + * otherwise. */ + struct llvm_java_object_class_record* component; + + /* If an array the size of its elements, otherwise 0 for classes, -1 + * for interfaces and -2 for primitive classes. */ + jint elementSize; }; struct llvm_java_object_class_record { @@ -50,7 +57,7 @@ jint llvm_java_is_array_class(struct llvm_java_object_class_record* cr) { - return cr->typeinfo.elementSize >= 0; + return cr->typeinfo.elementSize > 0; } struct llvm_java_object_class_record* llvm_java_get_class_record(jobject obj) { @@ -62,32 +69,48 @@ obj->classRecord = cr; } -jint llvm_java_is_instance_of(jobject obj, - struct llvm_java_object_class_record* clazz) { - struct llvm_java_object_class_record* objClazz; - - /* trivial case 1: a null object can be cast to any type */ - if (!obj) +jint llvm_java_is_assignable_from(struct llvm_java_object_class_record* cr, + struct llvm_java_object_class_record* from) { + /* trivial case: class records are the same */ + if (cr == from) return JNI_TRUE; - objClazz = obj->classRecord; - /* trivial case 2: this object is of class clazz */ - if (objClazz == clazz) - return JNI_TRUE; - - /* instanceof AnInterface. */ - if (llvm_java_is_interface_class(clazz)) { - /* this interface's vtable can only be found at this index */ - int index = clazz->typeinfo.interfaceIndex; - return objClazz->typeinfo.interfaceIndex >= index && - objClazz->typeinfo.interfaces[index]; + /* if from is a primitive class then they must be of the same class */ + if (llvm_java_is_primitive_class(from)) + return cr == from; + + /* if from is an interface class then the current class must + * implement that interface */ + if (llvm_java_is_interface_class(from)) { + int index = from->typeinfo.interfaceIndex; + return (cr->typeinfo.interfaceIndex >= index && + cr->typeinfo.interfaces[index]); } - /* instanceof AClass */ - else { - /* this class' vtable can only be found at this index */ - int index = objClazz->typeinfo.depth - clazz->typeinfo.depth - 1; - return index >= 0 && objClazz->typeinfo.vtables[index] == clazz; + + /* if from is an array class then the component types of must be + * assignable from */ + if (llvm_java_is_array_class(from)) + return (cr->typeinfo.component && + llvm_java_is_assignable_from(cr->typeinfo.component, + from->typeinfo.component)); + + /* otherwise this is a class, check if from is a superclass of this + * class */ + if (cr->typeinfo.depth > from->typeinfo.depth) { + int index = cr->typeinfo.depth - from->typeinfo.depth - 1; + return cr->typeinfo.superclasses[index] == from; } + + return JNI_FALSE; +} + +jint llvm_java_is_instance_of(jobject obj, + struct llvm_java_object_class_record* cr) { + /* trivial case: a null object can be cast to any type */ + if (!obj) + return JNI_TRUE; + + return llvm_java_is_assignable_from(obj->classRecord, cr); } jint llvm_java_throw(jobject obj) { From alkis at cs.uiuc.edu Fri Apr 1 16:59:31 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 1 Apr 2005 16:59:31 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMClass.h VMClass.cpp Resolver.cpp Message-ID: <200504012259.QAA08145@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMClass.h updated: 1.27 -> 1.28 VMClass.cpp updated: 1.37 -> 1.38 Resolver.cpp updated: 1.12 -> 1.13 --- Log message: Implement instanceof for arrays. Now we pass ArrayInstanceOf.java. --- Diffs of the changes: (+52 -20) Resolver.cpp | 1 VMClass.cpp | 67 ++++++++++++++++++++++++++++++++++++++++++----------------- VMClass.h | 4 ++- 3 files changed, 52 insertions(+), 20 deletions(-) Index: llvm-java/lib/Compiler/VMClass.h diff -u llvm-java/lib/Compiler/VMClass.h:1.27 llvm-java/lib/Compiler/VMClass.h:1.28 --- llvm-java/lib/Compiler/VMClass.h:1.27 Fri Apr 1 12:31:25 2005 +++ llvm-java/lib/Compiler/VMClass.h Fri Apr 1 16:59:20 2005 @@ -48,7 +48,9 @@ std::vector interfaces_; std::vector memberFields_; std::vector dynamicallyBoundMethods_; - llvm::Constant* classRecord_; + GlobalVariable* classRecord_; + + void init(); void computeLayout(); void computeClassRecord(); Index: llvm-java/lib/Compiler/VMClass.cpp diff -u llvm-java/lib/Compiler/VMClass.cpp:1.37 llvm-java/lib/Compiler/VMClass.cpp:1.38 --- llvm-java/lib/Compiler/VMClass.cpp:1.37 Fri Apr 1 16:56:20 2005 +++ llvm-java/lib/Compiler/VMClass.cpp Fri Apr 1 16:59:20 2005 @@ -15,17 +15,32 @@ // //===----------------------------------------------------------------------===// +#define DEBUG_TYPE "javaclass" + #include "VMClass.h" #include "Resolver.h" #include #include #include - -#define LLVM_JAVA_OBJECT_BASE "struct.llvm_java_object_base" +#include using namespace llvm; using namespace llvm::Java; +// On initialization we create a placeholder global for the class +// record that will be patched later when the class record is +// computed. +void VMClass::init() +{ + classRecord_ = new GlobalVariable( + OpaqueType::get(), + false, + GlobalVariable::ExternalLinkage, + NULL, + getName() + "", + resolver_->getModule()); +} + VMClass::VMClass(Resolver* resolver, const std::string& className) : name_(Resolver::canonicalizeClassName(className)), resolver_(resolver), @@ -34,10 +49,9 @@ layoutType_(OpaqueType::get()), type_(PointerType::get(layoutType_)), interfaceIndex_(INVALID_INTERFACE_INDEX), - resolvedConstantPool_(classFile_->getNumConstants()), - classRecord_(NULL) + resolvedConstantPool_(classFile_->getNumConstants()) { - + init(); } VMClass::VMClass(Resolver* resolver, const VMClass* componentClass) @@ -47,10 +61,9 @@ componentClass_(componentClass), layoutType_(OpaqueType::get()), type_(PointerType::get(layoutType_)), - interfaceIndex_(INVALID_INTERFACE_INDEX), - classRecord_(NULL) + interfaceIndex_(INVALID_INTERFACE_INDEX) { - + init(); } VMClass::VMClass(Resolver* resolver, const Type* type) @@ -67,10 +80,9 @@ componentClass_(NULL), layoutType_(const_cast(type)), type_(type), - interfaceIndex_(INVALID_INTERFACE_INDEX), - classRecord_(NULL) + interfaceIndex_(INVALID_INTERFACE_INDEX) { - + init(); } const VMField* VMClass::lookupField(const std::string& name) const @@ -116,9 +128,12 @@ void VMClass::computeLayout() { + DEBUG(std::cerr << "Computing layout for: " << getName() << '\n'); // The layout of primitive classes is already computed. - if (isPrimitive()) + if (isPrimitive()) { + DEBUG(std::cerr << "Computed layout for: " << getName() << '\n'); return; + } std::vector layout; if (isArray()) { @@ -156,6 +171,8 @@ cast(layoutType_)->refineAbstractTypeTo(resolvedType); layoutType_ = holder.get(); type_ = PointerType::get(layoutType_); + + DEBUG(std::cerr << "Computed layout for: " << getName() << '\n'); } llvm::Constant* VMClass::buildSuperClassRecords() const @@ -266,6 +283,12 @@ init.push_back(ConstantSInt::get(Type::IntTy, getInterfaceIndex())); init.push_back(buildInterfaceClassRecords()); if (isArray()) + init.push_back(ConstantExpr::getCast(getComponentClass()->getClassRecord(), + resolver_->getClassRecordPtrType())); + else + init.push_back( + llvm::Constant::getNullValue(resolver_->getClassRecordPtrType())); + if (isArray()) init.push_back( ConstantExpr::getCast( ConstantExpr::getSizeOf(getComponentClass()->getType()), Type::IntTy)); @@ -281,6 +304,7 @@ void VMClass::computeClassRecord() { + DEBUG(std::cerr << "Computing class record for: " << getName() << '\n'); // Find dynamically bound methods. if (!isPrimitive()) { if (const VMClass* superClass = getSuperClass()) @@ -344,13 +368,18 @@ llvm::Constant* classRecordInit = ConstantStruct::get(init); resolver_->getModule()->addTypeName("classRecord." + getName(), classRecordInit->getType()); - classRecord_ = new GlobalVariable( - classRecordInit->getType(), - true, - GlobalVariable::ExternalLinkage, - classRecordInit, - getName() + "", - resolver_->getModule()); + + // Now resolve the opaque type of the placeholder class record. + const Type* classRecordType = + cast(classRecord_->getType())->getElementType(); + OpaqueType* opaqueType = cast(const_cast(classRecordType)); + opaqueType->refineAbstractTypeTo(classRecordInit->getType()); + // Set the initializer of the class record. + classRecord_->setInitializer(classRecordInit); + // Mark the class record as constant. + classRecord_->setConstant(true); + + DEBUG(std::cerr << "Computed class record for: " << getName() << '\n'); } void VMClass::link() Index: llvm-java/lib/Compiler/Resolver.cpp diff -u llvm-java/lib/Compiler/Resolver.cpp:1.12 llvm-java/lib/Compiler/Resolver.cpp:1.13 --- llvm-java/lib/Compiler/Resolver.cpp:1.12 Fri Apr 1 12:31:25 2005 +++ llvm-java/lib/Compiler/Resolver.cpp Fri Apr 1 16:59:20 2005 @@ -55,6 +55,7 @@ elements.push_back(PointerType::get(PointerType::get(classRecordType_))); elements.push_back(Type::IntTy); elements.push_back(PointerType::get(PointerType::get(classRecordType_))); + elements.push_back(PointerType::get(classRecordType_)); elements.push_back(Type::IntTy); typeInfoType_ = StructType::get(elements); From criswell at cs.uiuc.edu Fri Apr 1 17:16:44 2005 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri, 1 Apr 2005 17:16:44 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/CFrontend/2005-02-20-AggregateSAVEEXPR.c Message-ID: <200504012316.RAA15414@choi.cs.uiuc.edu> Changes in directory llvm/test/Regression/CFrontend: 2005-02-20-AggregateSAVEEXPR.c updated: 1.1 -> 1.2 --- Log message: For Sparc, this xfails. I don't think sparc has the C99 complex data type support. --- Diffs of the changes: (+8 -0) 2005-02-20-AggregateSAVEEXPR.c | 8 ++++++++ 1 files changed, 8 insertions(+) Index: llvm/test/Regression/CFrontend/2005-02-20-AggregateSAVEEXPR.c diff -u llvm/test/Regression/CFrontend/2005-02-20-AggregateSAVEEXPR.c:1.1 llvm/test/Regression/CFrontend/2005-02-20-AggregateSAVEEXPR.c:1.2 --- llvm/test/Regression/CFrontend/2005-02-20-AggregateSAVEEXPR.c:1.1 Sun Feb 20 17:29:23 2005 +++ llvm/test/Regression/CFrontend/2005-02-20-AggregateSAVEEXPR.c Fri Apr 1 17:16:23 2005 @@ -1,4 +1,12 @@ // RUN: %llvmgcc %s -o /dev/null -S +// Note: +// We fail this on SparcV9 because the C library seems to be missing complex.h +// and the corresponding C99 complex support. +// +// We could modify the test to use only GCC extensions, but I don't know if +// that would change the nature of the test. +// +// XFAIL: sparcv9 #include From natebegeman at mac.com Fri Apr 1 18:41:25 2005 From: natebegeman at mac.com (Nate Begeman) Date: Fri, 1 Apr 2005 18:41:25 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Message-ID: <200504020041.SAA08815@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: LegalizeDAG.cpp updated: 1.65 -> 1.66 --- Log message: Fix a warning about an unhandled switch case --- Diffs of the changes: (+4 -3) LegalizeDAG.cpp | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.65 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.66 --- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.65 Fri Apr 1 16:34:39 2005 +++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Fri Apr 1 18:41:14 2005 @@ -222,8 +222,9 @@ case ISD::UNDEF: { MVT::ValueType VT = Op.getValueType(); switch (TLI.getOperationAction(ISD::UNDEF, VT)) { - case Expand: - case Promote: + default: assert(0 && "This action is not supported yet!"); + case TargetLowering::Expand: + case TargetLowering::Promote: if (MVT::isInteger(VT)) Result = DAG.getConstant(0, VT); else if (MVT::isFloatingPoint(VT)) @@ -231,7 +232,7 @@ else assert(0 && "Unknown value type!"); break; - case Legal: + case TargetLowering::Legal: break; } break; From natebegeman at mac.com Fri Apr 1 18:42:27 2005 From: natebegeman at mac.com (Nate Begeman) Date: Fri, 1 Apr 2005 18:42:27 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Message-ID: <200504020042.SAA08830@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPC32ISelPattern.cpp updated: 1.32 -> 1.33 --- Log message: Fix i64 returns Generate PowerPC 'subfic' instruction when appropriate --- Diffs of the changes: (+9 -8) PPC32ISelPattern.cpp | 17 +++++++++-------- 1 files changed, 9 insertions(+), 8 deletions(-) Index: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp diff -u llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.32 llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.33 --- llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.32 Fri Apr 1 16:34:39 2005 +++ llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Fri Apr 1 18:42:16 2005 @@ -488,6 +488,7 @@ if ((v & 0x0000FFFF) == 0) { Imm = v >> 16; return 2; } break; case ISD::MUL: + case ISD::SUB: if (v <= 32767 && v >= -32768) { Imm = v & 0xFFFF; return 1; } break; case ISD::SETCC: @@ -903,10 +904,6 @@ Node->dump(); assert(0 && "Node not handled!\n"); case ISD::UNDEF: - if (Result != 1) - ExprMap[N.getValue(1)] = 1; - else - Result = ExprMap[N.getValue(0)] = MakeReg(N.getValue(0).getValueType()); BuildMI(BB, PPC::IMPLICIT_DEF, 0, Result); return Result; case ISD::DYNAMIC_STACKALLOC: @@ -1212,9 +1209,13 @@ case ISD::SUB: assert (DestType == MVT::i32 && "Only do arithmetic on i32s!"); - Tmp1 = SelectExpr(N.getOperand(0)); Tmp2 = SelectExpr(N.getOperand(1)); - BuildMI(BB, PPC::SUBF, 2, Result).addReg(Tmp2).addReg(Tmp1); + if (1 == canUseAsImmediateForOpcode(N.getOperand(0), opcode, Tmp1)) + BuildMI(BB, PPC::SUBFIC, 2, Result).addReg(Tmp2).addSImm(Tmp1); + else { + Tmp1 = SelectExpr(N.getOperand(0)); + BuildMI(BB, PPC::SUBF, 2, Result).addReg(Tmp2).addReg(Tmp1); + } return Result; case ISD::MUL: @@ -1524,8 +1525,8 @@ Select(N.getOperand(0)); Tmp1 = SelectExpr(N.getOperand(1)); Tmp2 = SelectExpr(N.getOperand(2)); - BuildMI(BB, PPC::OR, 2, PPC::R3).addReg(Tmp1).addReg(Tmp1); - BuildMI(BB, PPC::OR, 2, PPC::R4).addReg(Tmp2).addReg(Tmp2); + BuildMI(BB, PPC::OR, 2, PPC::R3).addReg(Tmp2).addReg(Tmp2); + BuildMI(BB, PPC::OR, 2, PPC::R4).addReg(Tmp1).addReg(Tmp1); break; case 2: Select(N.getOperand(0)); From lattner at cs.uiuc.edu Fri Apr 1 20:42:13 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 1 Apr 2005 20:42:13 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/CodeGen/Generic/shift-int64.ll Message-ID: <200504020242.j322gDoC024198@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/CodeGen/Generic: shift-int64.ll added (r1.1) --- Log message: new generic testcsae --- Diffs of the changes: (+11 -0) shift-int64.ll | 11 +++++++++++ 1 files changed, 11 insertions(+) Index: llvm/test/Regression/CodeGen/Generic/shift-int64.ll diff -c /dev/null llvm/test/Regression/CodeGen/Generic/shift-int64.ll:1.1 *** /dev/null Fri Apr 1 20:42:06 2005 --- llvm/test/Regression/CodeGen/Generic/shift-int64.ll Fri Apr 1 20:41:55 2005 *************** *** 0 **** --- 1,11 ---- + ; RUN: llvm-as < %s | llc + + long %test_imm(long %X) { + %Y = shr long %X, ubyte 17 + ret long %Y + } + + long %test_variable(long %X, ubyte %Amt) { + %Y = shr long %X, ubyte %Amt + ret long %Y + } From alkis at cs.uiuc.edu Fri Apr 1 20:47:44 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 1 Apr 2005 20:47:44 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Resolver.cpp Message-ID: <200504020247.UAA09418@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Resolver.cpp updated: 1.13 -> 1.14 --- Log message: Update comments. --- Diffs of the changes: (+3 -5) Resolver.cpp | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-) Index: llvm-java/lib/Compiler/Resolver.cpp diff -u llvm-java/lib/Compiler/Resolver.cpp:1.13 llvm-java/lib/Compiler/Resolver.cpp:1.14 --- llvm-java/lib/Compiler/Resolver.cpp:1.13 Fri Apr 1 16:59:20 2005 +++ llvm-java/lib/Compiler/Resolver.cpp Fri Apr 1 20:47:33 2005 @@ -40,12 +40,10 @@ // // struct type_info { // int depth; - // struct class_record** superClasses; + // struct class_record** superclasses; // int interfaceIndex; - // union { - // int interfaceFlag; - // struct class_record** interfaces; - // }; + // struct class_record** interfaces; + // struct class_record* component; // int elementSize; // }; From alkis at cs.uiuc.edu Fri Apr 1 21:06:46 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 1 Apr 2005 21:06:46 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMClass.h VMClass.cpp Resolver.cpp Compiler.cpp Message-ID: <200504020306.VAA09576@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMClass.h updated: 1.28 -> 1.29 VMClass.cpp updated: 1.38 -> 1.39 Resolver.cpp updated: 1.14 -> 1.15 Compiler.cpp updated: 1.275 -> 1.276 --- Log message: Add the name of the class in the typeinfo struct inside the class record. --- Diffs of the changes: (+19 -1) Compiler.cpp | 2 +- Resolver.cpp | 2 ++ VMClass.cpp | 15 +++++++++++++++ VMClass.h | 1 + 4 files changed, 19 insertions(+), 1 deletion(-) Index: llvm-java/lib/Compiler/VMClass.h diff -u llvm-java/lib/Compiler/VMClass.h:1.28 llvm-java/lib/Compiler/VMClass.h:1.29 --- llvm-java/lib/Compiler/VMClass.h:1.28 Fri Apr 1 16:59:20 2005 +++ llvm-java/lib/Compiler/VMClass.h Fri Apr 1 21:06:35 2005 @@ -55,6 +55,7 @@ void computeLayout(); void computeClassRecord(); + llvm::Constant* buildClassName() const; llvm::Constant* buildSuperClassRecords() const; llvm::Constant* buildInterfaceClassRecord(const VMClass* interface) const; llvm::Constant* buildInterfaceClassRecords() const; Index: llvm-java/lib/Compiler/VMClass.cpp diff -u llvm-java/lib/Compiler/VMClass.cpp:1.38 llvm-java/lib/Compiler/VMClass.cpp:1.39 --- llvm-java/lib/Compiler/VMClass.cpp:1.38 Fri Apr 1 16:59:20 2005 +++ llvm-java/lib/Compiler/VMClass.cpp Fri Apr 1 21:06:35 2005 @@ -273,11 +273,26 @@ resolver_->getModule())); } +llvm::Constant* VMClass::buildClassName() const +{ + llvm::Constant* name = ConstantArray::get(getName()); + + return ConstantExpr::getPtrPtrFromArrayPtr( + new GlobalVariable( + name->getType(), + true, + GlobalVariable::ExternalLinkage, + name, + getName() + "", + resolver_->getModule())); +} + llvm::Constant* VMClass::buildClassTypeInfo() const { std::vector init; init.reserve(5); + init.push_back(buildClassName()); init.push_back(ConstantSInt::get(Type::IntTy, getNumSuperClasses())); init.push_back(buildSuperClassRecords()); init.push_back(ConstantSInt::get(Type::IntTy, getInterfaceIndex())); Index: llvm-java/lib/Compiler/Resolver.cpp diff -u llvm-java/lib/Compiler/Resolver.cpp:1.14 llvm-java/lib/Compiler/Resolver.cpp:1.15 --- llvm-java/lib/Compiler/Resolver.cpp:1.14 Fri Apr 1 20:47:33 2005 +++ llvm-java/lib/Compiler/Resolver.cpp Fri Apr 1 21:06:35 2005 @@ -39,6 +39,7 @@ // }; // // struct type_info { + // char** name; // int depth; // struct class_record** superclasses; // int interfaceIndex; @@ -49,6 +50,7 @@ // Compute the type_info type. std::vector elements; + elements.push_back(PointerType::get(PointerType::get(Type::SByteTy))); elements.push_back(Type::IntTy); elements.push_back(PointerType::get(PointerType::get(classRecordType_))); elements.push_back(Type::IntTy); Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.275 llvm-java/lib/Compiler/Compiler.cpp:1.276 --- llvm-java/lib/Compiler/Compiler.cpp:1.275 Fri Apr 1 16:43:44 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Fri Apr 1 21:06:35 2005 @@ -1044,7 +1044,7 @@ TMP, currentBB_); // get the interfaces array of class records std::vector indices(2, ConstantUInt::get(Type::UIntTy, 0)); - indices.push_back(ConstantUInt::get(Type::UIntTy, 3)); + indices.push_back(ConstantUInt::get(Type::UIntTy, 4)); Value* interfaceClassRecords = new GetElementPtrInst(classRecord, indices, TMP, currentBB_); interfaceClassRecords = From alkis at cs.uiuc.edu Fri Apr 1 21:06:47 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 1 Apr 2005 21:06:47 -0600 Subject: [llvm-commits] CVS: llvm-java/runtime/runtime.c Message-ID: <200504020306.VAA09580@zion.cs.uiuc.edu> Changes in directory llvm-java/runtime: runtime.c updated: 1.26 -> 1.27 --- Log message: Add the name of the class in the typeinfo struct inside the class record. --- Diffs of the changes: (+3 -0) runtime.c | 3 +++ 1 files changed, 3 insertions(+) Index: llvm-java/runtime/runtime.c diff -u llvm-java/runtime/runtime.c:1.26 llvm-java/runtime/runtime.c:1.27 --- llvm-java/runtime/runtime.c:1.26 Fri Apr 1 16:59:20 2005 +++ llvm-java/runtime/runtime.c Fri Apr 1 21:06:35 2005 @@ -18,6 +18,9 @@ }; struct llvm_java_object_typeinfo { + /* The name of this class */ + const char** name; + /* The number of super classes to java.lang.Object. */ jint depth; From lattner at cs.uiuc.edu Fri Apr 1 21:22:56 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 1 Apr 2005 21:22:56 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Message-ID: <200504020322.j323MukF025469@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: LegalizeDAG.cpp updated: 1.66 -> 1.67 --- Log message: Fix a bug when inserting a libcall into a function with no other calls. --- Diffs of the changes: (+4 -2) LegalizeDAG.cpp | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.66 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.67 --- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.66 Fri Apr 1 18:41:14 2005 +++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Fri Apr 1 21:22:40 2005 @@ -1428,7 +1428,8 @@ static SDNode *FindAdjCallStackUp(SDNode *Node) { if (Node->getOpcode() == ISD::ADJCALLSTACKUP) return Node; - assert(!Node->use_empty() && "Could not find ADJCALLSTACKUP!"); + if (Node->use_empty()) + return 0; // No adjcallstackup if (Node->hasOneUse()) // Simple case, only has one user to check. return FindAdjCallStackUp(*Node->use_begin()); @@ -1484,7 +1485,8 @@ SDNode *OutChain; SDOperand InChain = FindInputOutputChains(Node, OutChain, DAG.getEntryNode()); - // TODO. Link in chains. + if (InChain.Val == 0) + InChain = DAG.getEntryNode(); TargetLowering::ArgListTy Args; for (unsigned i = 0, e = Node->getNumOperands(); i != e; ++i) { From lattner at cs.uiuc.edu Fri Apr 1 21:30:49 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 1 Apr 2005 21:30:49 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/SelectionDAGNodes.h Message-ID: <200504020330.j323UnEb025617@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: SelectionDAGNodes.h updated: 1.24 -> 1.25 --- Log message: add some new nodes. --- Diffs of the changes: (+6 -0) SelectionDAGNodes.h | 6 ++++++ 1 files changed, 6 insertions(+) Index: llvm/include/llvm/CodeGen/SelectionDAGNodes.h diff -u llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.24 llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.25 --- llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.24 Fri Apr 1 16:34:39 2005 +++ llvm/include/llvm/CodeGen/SelectionDAGNodes.h Fri Apr 1 21:30:33 2005 @@ -111,6 +111,12 @@ // [Lo,Hi] = op [LoLHS,HiLHS], [LoRHS,HiRHS] ADD_PARTS, SUB_PARTS, + // SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded + // integer shift operations, just like ADD/SUB_PARTS. The operation + // ordering is: + // [Lo,Hi] = op [LoLHS,HiLHS], [LoRHS,HiRHS] + SHL_PARTS, SRA_PARTS, SRL_PARTS, + // Conversion operators. These are all single input single output // operations. For all of these, the result type must be strictly // wider or narrower (depending on the operation) than the source From lattner at cs.uiuc.edu Fri Apr 1 21:30:55 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 1 Apr 2005 21:30:55 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Message-ID: <200504020330.j323UtMj025626@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: SelectionDAG.cpp updated: 1.55 -> 1.56 --- Log message: Print some new nodes --- Diffs of the changes: (+6 -1) SelectionDAG.cpp | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletion(-) Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.55 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.56 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.55 Fri Apr 1 16:34:39 2005 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Fri Apr 1 21:30:42 2005 @@ -924,7 +924,9 @@ default: // FIXME: MEMOIZE!! SDNode *N = new SDNode(Opcode, Children); - if (Opcode != ISD::ADD_PARTS && Opcode != ISD::SUB_PARTS) { + if (Opcode != ISD::ADD_PARTS && Opcode != ISD::SUB_PARTS && + Opcode != ISD::SRA_PARTS && Opcode != ISD::SRL_PARTS && + Opcode != ISD::SHL_PARTS) { N->setValueTypes(VT); } else { std::vector V(N->getNumOperands()/2, VT); @@ -1131,6 +1133,9 @@ case ISD::SELECT: return "select"; case ISD::ADD_PARTS: return "add_parts"; case ISD::SUB_PARTS: return "sub_parts"; + case ISD::SHL_PARTS: return "shl_parts"; + case ISD::SRA_PARTS: return "sra_parts"; + case ISD::SRL_PARTS: return "srl_parts"; // Conversion operators. case ISD::SIGN_EXTEND: return "sign_extend"; From lattner at cs.uiuc.edu Fri Apr 1 21:39:09 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 1 Apr 2005 21:39:09 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Message-ID: <200504020339.j323d9lC026591@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: LegalizeDAG.cpp updated: 1.67 -> 1.68 --- Log message: Turn expanded shift operations into (e.g.) SHL_PARTS if the target supports it. --- Diffs of the changes: (+39 -9) LegalizeDAG.cpp | 48 +++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 39 insertions(+), 9 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.67 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.68 --- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.67 Fri Apr 1 21:22:40 2005 +++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Fri Apr 1 21:38:53 2005 @@ -125,8 +125,8 @@ SDOperand Source); bool ExpandShift(unsigned Opc, SDOperand Op, SDOperand Amt, SDOperand &Lo, SDOperand &Hi); - void ExpandAddSub(bool isAdd, SDOperand Op, SDOperand Amt, - SDOperand &Lo, SDOperand &Hi); + void ExpandByParts(unsigned NodeOp, SDOperand Op, SDOperand Amt, + SDOperand &Lo, SDOperand &Hi); SDOperand getIntPtrConstant(uint64_t Val) { return DAG.getConstant(Val, TLI.getPointerTy()); @@ -1288,8 +1288,9 @@ /// ExpandAddSub - Find a clever way to expand this add operation into /// subcomponents. -void SelectionDAGLegalize::ExpandAddSub(bool isAdd, SDOperand LHS,SDOperand RHS, - SDOperand &Lo, SDOperand &Hi) { +void SelectionDAGLegalize:: +ExpandByParts(unsigned NodeOp, SDOperand LHS, SDOperand RHS, + SDOperand &Lo, SDOperand &Hi) { // Expand the subcomponents. SDOperand LHSL, LHSH, RHSL, RHSH; ExpandOp(LHS, LHSL, LHSH); @@ -1297,13 +1298,12 @@ // Convert this add to the appropriate ADDC pair. The low part has no carry // in. - unsigned Opc = isAdd ? ISD::ADD_PARTS : ISD::SUB_PARTS; std::vector Ops; Ops.push_back(LHSL); Ops.push_back(LHSH); Ops.push_back(RHSL); Ops.push_back(RHSH); - Lo = DAG.getNode(Opc, LHSL.getValueType(), Ops); + Lo = DAG.getNode(NodeOp, LHSL.getValueType(), Ops); Hi = Lo.getValue(1); } @@ -1313,6 +1313,10 @@ /// low-parts expanded into Lo and Hi. bool SelectionDAGLegalize::ExpandShift(unsigned Opc, SDOperand Op,SDOperand Amt, SDOperand &Lo, SDOperand &Hi) { + // FIXME: This code is buggy, disable it for now. Note that we should at + // least handle the case when Amt is an immediate here. + return false; + assert((Opc == ISD::SHL || Opc == ISD::SRA || Opc == ISD::SRL) && "This is not a shift!"); MVT::ValueType NVT = TLI.getTypeToTransformTo(Op.getValueType()); @@ -1746,6 +1750,14 @@ // If we can emit an efficient shift operation, do so now. if (ExpandShift(ISD::SHL, Node->getOperand(0), Node->getOperand(1), Lo, Hi)) break; + + // If this target supports SHL_PARTS, use it. + if (TLI.getOperationAction(ISD::SHL_PARTS, NVT) == TargetLowering::Legal) { + ExpandByParts(ISD::SHL_PARTS, Node->getOperand(0), Node->getOperand(1), + Lo, Hi); + break; + } + // Otherwise, emit a libcall. Lo = ExpandLibCall("__ashldi3", Node, Hi); break; @@ -1754,6 +1766,14 @@ // If we can emit an efficient shift operation, do so now. if (ExpandShift(ISD::SRA, Node->getOperand(0), Node->getOperand(1), Lo, Hi)) break; + + // If this target supports SRA_PARTS, use it. + if (TLI.getOperationAction(ISD::SRA_PARTS, NVT) == TargetLowering::Legal) { + ExpandByParts(ISD::SRA_PARTS, Node->getOperand(0), Node->getOperand(1), + Lo, Hi); + break; + } + // Otherwise, emit a libcall. Lo = ExpandLibCall("__ashrdi3", Node, Hi); break; @@ -1761,15 +1781,25 @@ // If we can emit an efficient shift operation, do so now. if (ExpandShift(ISD::SRL, Node->getOperand(0), Node->getOperand(1), Lo, Hi)) break; + + // If this target supports SRL_PARTS, use it. + if (TLI.getOperationAction(ISD::SRL_PARTS, NVT) == TargetLowering::Legal) { + ExpandByParts(ISD::SRL_PARTS, Node->getOperand(0), Node->getOperand(1), + Lo, Hi); + break; + } + // Otherwise, emit a libcall. Lo = ExpandLibCall("__lshrdi3", Node, Hi); break; - case ISD::ADD: - ExpandAddSub(true, Node->getOperand(0), Node->getOperand(1), Lo, Hi); + case ISD::ADD: + ExpandByParts(ISD::ADD_PARTS, Node->getOperand(0), Node->getOperand(1), + Lo, Hi); break; case ISD::SUB: - ExpandAddSub(false, Node->getOperand(0), Node->getOperand(1), Lo, Hi); + ExpandByParts(ISD::SUB_PARTS, Node->getOperand(0), Node->getOperand(1), + Lo, Hi); break; case ISD::MUL: Lo = ExpandLibCall("__muldi3" , Node, Hi); break; case ISD::SDIV: Lo = ExpandLibCall("__divdi3" , Node, Hi); break; From lattner at cs.uiuc.edu Fri Apr 1 22:00:01 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 1 Apr 2005 22:00:01 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/SelectionDAGNodes.h Message-ID: <200504020400.j324013t027873@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: SelectionDAGNodes.h updated: 1.25 -> 1.26 --- Log message: fix a comment --- Diffs of the changes: (+1 -1) SelectionDAGNodes.h | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/include/llvm/CodeGen/SelectionDAGNodes.h diff -u llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.25 llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.26 --- llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.25 Fri Apr 1 21:30:33 2005 +++ llvm/include/llvm/CodeGen/SelectionDAGNodes.h Fri Apr 1 21:59:45 2005 @@ -114,7 +114,7 @@ // SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded // integer shift operations, just like ADD/SUB_PARTS. The operation // ordering is: - // [Lo,Hi] = op [LoLHS,HiLHS], [LoRHS,HiRHS] + // [Lo,Hi] = op [LoLHS,HiLHS], Amt SHL_PARTS, SRA_PARTS, SRL_PARTS, // Conversion operators. These are all single input single output From lattner at cs.uiuc.edu Fri Apr 1 22:01:12 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 1 Apr 2005 22:01:12 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp SelectionDAG.cpp Message-ID: <200504020401.j3241Cub027914@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: LegalizeDAG.cpp updated: 1.68 -> 1.69 SelectionDAG.cpp updated: 1.56 -> 1.57 --- Log message: fix some bugs in the implementation of SHL_PARTS and friends. --- Diffs of the changes: (+38 -11) LegalizeDAG.cpp | 37 +++++++++++++++++++++++++++++-------- SelectionDAG.cpp | 12 +++++++++--- 2 files changed, 38 insertions(+), 11 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.68 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.69 --- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.68 Fri Apr 1 21:38:53 2005 +++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Fri Apr 1 22:00:59 2005 @@ -125,7 +125,9 @@ SDOperand Source); bool ExpandShift(unsigned Opc, SDOperand Op, SDOperand Amt, SDOperand &Lo, SDOperand &Hi); - void ExpandByParts(unsigned NodeOp, SDOperand Op, SDOperand Amt, + void ExpandShiftParts(unsigned NodeOp, SDOperand Op, SDOperand Amt, + SDOperand &Lo, SDOperand &Hi); + void ExpandByParts(unsigned NodeOp, SDOperand LHS, SDOperand RHS, SDOperand &Lo, SDOperand &Hi); SDOperand getIntPtrConstant(uint64_t Val) { @@ -825,7 +827,10 @@ break; } case ISD::ADD_PARTS: - case ISD::SUB_PARTS: { + case ISD::SUB_PARTS: + case ISD::SHL_PARTS: + case ISD::SRA_PARTS: + case ISD::SRL_PARTS: { std::vector Ops; bool Changed = false; for (unsigned i = 0, e = Node->getNumOperands(); i != e; ++i) { @@ -1307,6 +1312,22 @@ Hi = Lo.getValue(1); } +void SelectionDAGLegalize::ExpandShiftParts(unsigned NodeOp, + SDOperand Op, SDOperand Amt, + SDOperand &Lo, SDOperand &Hi) { + // Expand the subcomponents. + SDOperand LHSL, LHSH; + ExpandOp(Op, LHSL, LHSH); + + std::vector Ops; + Ops.push_back(LHSL); + Ops.push_back(LHSH); + Ops.push_back(Amt); + Lo = DAG.getNode(NodeOp, LHSL.getValueType(), Ops); + Hi = Lo.getValue(1); +} + + /// ExpandShift - Try to find a clever way to expand this shift operation out to /// smaller elements. If we can't find a way that is more efficient than a /// libcall on this target, return false. Otherwise, return true with the @@ -1753,8 +1774,8 @@ // If this target supports SHL_PARTS, use it. if (TLI.getOperationAction(ISD::SHL_PARTS, NVT) == TargetLowering::Legal) { - ExpandByParts(ISD::SHL_PARTS, Node->getOperand(0), Node->getOperand(1), - Lo, Hi); + ExpandShiftParts(ISD::SHL_PARTS, Node->getOperand(0), Node->getOperand(1), + Lo, Hi); break; } @@ -1769,8 +1790,8 @@ // If this target supports SRA_PARTS, use it. if (TLI.getOperationAction(ISD::SRA_PARTS, NVT) == TargetLowering::Legal) { - ExpandByParts(ISD::SRA_PARTS, Node->getOperand(0), Node->getOperand(1), - Lo, Hi); + ExpandShiftParts(ISD::SRA_PARTS, Node->getOperand(0), Node->getOperand(1), + Lo, Hi); break; } @@ -1784,8 +1805,8 @@ // If this target supports SRL_PARTS, use it. if (TLI.getOperationAction(ISD::SRL_PARTS, NVT) == TargetLowering::Legal) { - ExpandByParts(ISD::SRL_PARTS, Node->getOperand(0), Node->getOperand(1), - Lo, Hi); + ExpandShiftParts(ISD::SRL_PARTS, Node->getOperand(0), Node->getOperand(1), + Lo, Hi); break; } Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.56 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.57 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.56 Fri Apr 1 21:30:42 2005 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Fri Apr 1 22:00:59 2005 @@ -907,6 +907,14 @@ case ISD::DYNAMIC_STACKALLOC: // DYNAMIC_STACKALLOC produces pointer and chain N->setValueTypes(VT, MVT::Other); break; + + case ISD::SRA_PARTS: + case ISD::SRL_PARTS: + case ISD::SHL_PARTS: { + std::vector V(N->getNumOperands()-1, VT); + N->setValueTypes(V); + break; + } } // FIXME: memoize NODES @@ -924,9 +932,7 @@ default: // FIXME: MEMOIZE!! SDNode *N = new SDNode(Opcode, Children); - if (Opcode != ISD::ADD_PARTS && Opcode != ISD::SUB_PARTS && - Opcode != ISD::SRA_PARTS && Opcode != ISD::SRL_PARTS && - Opcode != ISD::SHL_PARTS) { + if (Opcode != ISD::ADD_PARTS && Opcode != ISD::SUB_PARTS) { N->setValueTypes(VT); } else { std::vector V(N->getNumOperands()/2, VT); From lattner at cs.uiuc.edu Fri Apr 1 22:01:27 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 1 Apr 2005 22:01:27 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ISelPattern.cpp Message-ID: <200504020401.j3241R1O027926@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ISelPattern.cpp updated: 1.96 -> 1.97 --- Log message: Add support for 64-bit shifts. --- Diffs of the changes: (+84 -16) X86ISelPattern.cpp | 100 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 84 insertions(+), 16 deletions(-) Index: llvm/lib/Target/X86/X86ISelPattern.cpp diff -u llvm/lib/Target/X86/X86ISelPattern.cpp:1.96 llvm/lib/Target/X86/X86ISelPattern.cpp:1.97 --- llvm/lib/Target/X86/X86ISelPattern.cpp:1.96 Fri Apr 1 16:46:45 2005 +++ llvm/lib/Target/X86/X86ISelPattern.cpp Fri Apr 1 22:01:14 2005 @@ -1319,29 +1319,34 @@ unsigned &Reg = ExprMap[N]; if (Reg) return Reg; - if (N.getOpcode() != ISD::CALL && N.getOpcode() != ISD::ADD_PARTS && - N.getOpcode() != ISD::SUB_PARTS) + switch (N.getOpcode()) { + default: Reg = Result = (N.getValueType() != MVT::Other) ? - MakeReg(N.getValueType()) : 1; - else { + MakeReg(N.getValueType()) : 1; + break; + case ISD::CALL: // If this is a call instruction, make sure to prepare ALL of the result // values as well as the chain. - if (N.getOpcode() == ISD::CALL) { - if (Node->getNumValues() == 1) - Reg = Result = 1; // Void call, just a chain. - else { - Result = MakeReg(Node->getValueType(0)); - ExprMap[N.getValue(0)] = Result; - for (unsigned i = 1, e = N.Val->getNumValues()-1; i != e; ++i) - ExprMap[N.getValue(i)] = MakeReg(Node->getValueType(i)); - ExprMap[SDOperand(Node, Node->getNumValues()-1)] = 1; - } - } else { + if (Node->getNumValues() == 1) + Reg = Result = 1; // Void call, just a chain. + else { Result = MakeReg(Node->getValueType(0)); ExprMap[N.getValue(0)] = Result; - for (unsigned i = 1, e = N.Val->getNumValues(); i != e; ++i) + for (unsigned i = 1, e = N.Val->getNumValues()-1; i != e; ++i) ExprMap[N.getValue(i)] = MakeReg(Node->getValueType(i)); + ExprMap[SDOperand(Node, Node->getNumValues()-1)] = 1; } + break; + case ISD::ADD_PARTS: + case ISD::SUB_PARTS: + case ISD::SHL_PARTS: + case ISD::SRL_PARTS: + case ISD::SRA_PARTS: + Result = MakeReg(Node->getValueType(0)); + ExprMap[N.getValue(0)] = Result; + for (unsigned i = 1, e = N.Val->getNumValues(); i != e; ++i) + ExprMap[N.getValue(i)] = MakeReg(Node->getValueType(i)); + break; } switch (N.getOpcode()) { @@ -2024,6 +2029,69 @@ return Result+N.ResNo; } + case ISD::SHL_PARTS: + case ISD::SRA_PARTS: + case ISD::SRL_PARTS: { + assert(N.getNumOperands() == 3 && N.getValueType() == MVT::i32 && + "Not an i64 shift!"); + unsigned ShiftOpLo = SelectExpr(N.getOperand(0)); + unsigned ShiftOpHi = SelectExpr(N.getOperand(1)); + unsigned TmpReg = MakeReg(MVT::i32); + if (N.getOpcode() == ISD::SRA_PARTS) { + // If this is a SHR of a Long, then we need to do funny sign extension + // stuff. TmpReg gets the value to use as the high-part if we are + // shifting more than 32 bits. + BuildMI(BB, X86::SAR32ri, 2, TmpReg).addReg(ShiftOpHi).addImm(31); + } else { + // Other shifts use a fixed zero value if the shift is more than 32 bits. + BuildMI(BB, X86::MOV32ri, 1, TmpReg).addImm(0); + } + + // Initialize CL with the shift amount. + unsigned ShiftAmountReg = SelectExpr(N.getOperand(2)); + BuildMI(BB, X86::MOV8rr, 1, X86::CL).addReg(ShiftAmountReg); + + unsigned TmpReg2 = MakeReg(MVT::i32); + unsigned TmpReg3 = MakeReg(MVT::i32); + if (N.getOpcode() == ISD::SHL_PARTS) { + // TmpReg2 = shld inHi, inLo + BuildMI(BB, X86::SHLD32rrCL, 2,TmpReg2).addReg(ShiftOpHi) + .addReg(ShiftOpLo); + // TmpReg3 = shl inLo, CL + BuildMI(BB, X86::SHL32rCL, 1, TmpReg3).addReg(ShiftOpLo); + + // Set the flags to indicate whether the shift was by more than 32 bits. + BuildMI(BB, X86::TEST8ri, 2).addReg(X86::CL).addImm(32); + + // DestHi = (>32) ? TmpReg3 : TmpReg2; + BuildMI(BB, X86::CMOVNE32rr, 2, + Result+1).addReg(TmpReg2).addReg(TmpReg3); + // DestLo = (>32) ? TmpReg : TmpReg3; + BuildMI(BB, X86::CMOVNE32rr, 2, + Result).addReg(TmpReg3).addReg(TmpReg); + } else { + // TmpReg2 = shrd inLo, inHi + BuildMI(BB, X86::SHRD32rrCL,2,TmpReg2).addReg(ShiftOpLo) + .addReg(ShiftOpHi); + // TmpReg3 = s[ah]r inHi, CL + BuildMI(BB, N.getOpcode() == ISD::SRA_PARTS ? X86::SAR32rCL + : X86::SHR32rCL, 1, TmpReg3) + .addReg(ShiftOpHi); + + // Set the flags to indicate whether the shift was by more than 32 bits. + BuildMI(BB, X86::TEST8ri, 2).addReg(X86::CL).addImm(32); + + // DestLo = (>32) ? TmpReg3 : TmpReg2; + BuildMI(BB, X86::CMOVNE32rr, 2, + Result).addReg(TmpReg2).addReg(TmpReg3); + + // DestHi = (>32) ? TmpReg : TmpReg3; + BuildMI(BB, X86::CMOVNE32rr, 2, + Result+1).addReg(TmpReg3).addReg(TmpReg); + } + return Result+N.ResNo; + } + case ISD::SELECT: if (getRegPressure(N.getOperand(1)) > getRegPressure(N.getOperand(2))) { Tmp2 = SelectExpr(N.getOperand(1)); From lattner at cs.uiuc.edu Fri Apr 1 22:32:12 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 1 Apr 2005 22:32:12 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86InstrInfo.td Message-ID: <200504020432.j324WCXp030380@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86InstrInfo.td updated: 1.119 -> 1.120 --- Log message: add an fabs instr --- Diffs of the changes: (+1 -0) X86InstrInfo.td | 1 + 1 files changed, 1 insertion(+) Index: llvm/lib/Target/X86/X86InstrInfo.td diff -u llvm/lib/Target/X86/X86InstrInfo.td:1.119 llvm/lib/Target/X86/X86InstrInfo.td:1.120 --- llvm/lib/Target/X86/X86InstrInfo.td:1.119 Sun Feb 27 00:16:27 2005 +++ llvm/lib/Target/X86/X86InstrInfo.td Fri Apr 1 22:31:56 2005 @@ -1523,6 +1523,7 @@ // Unary operations... def FCHS : FPI<0xE0, RawFrm, OneArgFPRW, (ops), "fchs">, D9; // f1 = fchs f2 +def FABS : FPI<0xE1, RawFrm, OneArgFPRW, (ops), "fabs">, D9; // f1 = fabs f2 def FTST : FPI<0xE4, RawFrm, OneArgFP, (ops), "ftst">, D9; // ftst ST(0) // Binary arithmetic operations... From lattner at cs.uiuc.edu Fri Apr 1 22:58:44 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 1 Apr 2005 22:58:44 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/SelectionDAGNodes.h Message-ID: <200504020458.j324wi7r031848@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: SelectionDAGNodes.h updated: 1.26 -> 1.27 --- Log message: Add two happy new nodes for FABS and FNEG --- Diffs of the changes: (+4 -0) SelectionDAGNodes.h | 4 ++++ 1 files changed, 4 insertions(+) Index: llvm/include/llvm/CodeGen/SelectionDAGNodes.h diff -u llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.26 llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.27 --- llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.26 Fri Apr 1 21:59:45 2005 +++ llvm/include/llvm/CodeGen/SelectionDAGNodes.h Fri Apr 1 22:58:28 2005 @@ -164,6 +164,10 @@ // FP_EXTEND - Extend a smaller FP type into a larger FP type. FP_EXTEND, + // FNEG, FABS - Perform unary floating point negation and absolute value + // operations. + FNEG, FABS, + // Other operators. LOAD and STORE have token chains as their first // operand, then the same operands as an LLVM load/store instruction. LOAD, STORE, From lattner at cs.uiuc.edu Fri Apr 1 22:58:55 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 1 Apr 2005 22:58:55 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Message-ID: <200504020458.j324wtg8031858@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: SelectionDAG.cpp updated: 1.57 -> 1.58 --- Log message: print fneg/fabs --- Diffs of the changes: (+5 -0) SelectionDAG.cpp | 5 +++++ 1 files changed, 5 insertions(+) Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.57 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.58 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.57 Fri Apr 1 22:00:59 2005 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Fri Apr 1 22:58:41 2005 @@ -1122,6 +1122,11 @@ case ISD::ImplicitDef: return "ImplicitDef"; case ISD::UNDEF: return "undef"; + // Unary operators + case ISD::FABS: return "fabs"; + case ISD::FNEG: return "fneg"; + + // Binary operators case ISD::ADD: return "add"; case ISD::SUB: return "sub"; case ISD::MUL: return "mul"; From lattner at cs.uiuc.edu Fri Apr 1 23:00:20 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 1 Apr 2005 23:00:20 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Message-ID: <200504020500.j3250KXD031881@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: LegalizeDAG.cpp updated: 1.69 -> 1.70 --- Log message: Several changes mixed up here. First when legalizing a DAG with pcmarker, dont' regen the whole dag if unneccesary. Second, fix and ugly bug with the _PARTS nodes that caused legalize to produce multiples of them. Finally, implement initial support for FABS and FNEG. Currently FNEG is the only one to be trusted though. --- Diffs of the changes: (+57 -12) LegalizeDAG.cpp | 69 ++++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 57 insertions(+), 12 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.69 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.70 --- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.69 Fri Apr 1 22:00:59 2005 +++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Fri Apr 1 23:00:07 2005 @@ -574,7 +574,8 @@ break; case ISD::PCMARKER: Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the chain. - Result = DAG.getNode(ISD::PCMARKER, MVT::Other, Tmp1, Node->getOperand(1)); + if (Tmp1 != Node->getOperand(0)) + Result = DAG.getNode(ISD::PCMARKER, MVT::Other, Tmp1,Node->getOperand(1)); break; case ISD::TRUNCSTORE: Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the chain. @@ -839,8 +840,15 @@ } if (Changed) Result = DAG.getNode(Node->getOpcode(), Node->getValueType(0), Ops); - break; + + // Since these produce multiple values, make sure to remember that we + // legalized all of them. + for (unsigned i = 0, e = Node->getNumValues(); i != e; ++i) + AddLegalizedOperand(SDOperand(Node, i), Result.getValue(i)); + return Result.getValue(Op.ResNo); } + + // Binary operators case ISD::ADD: case ISD::SUB: case ISD::MUL: @@ -860,6 +868,33 @@ Tmp2 != Node->getOperand(1)) Result = DAG.getNode(Node->getOpcode(), Node->getValueType(0), Tmp1,Tmp2); break; + + // Unary operators + case ISD::FABS: + case ISD::FNEG: + Tmp1 = LegalizeOp(Node->getOperand(0)); + switch (TLI.getOperationAction(Node->getOpcode(), Node->getValueType(0))) { + case TargetLowering::Legal: + if (Tmp1 != Node->getOperand(0)) + Result = DAG.getNode(Node->getOpcode(), Node->getValueType(0), Tmp1); + break; + case TargetLowering::Promote: + case TargetLowering::Custom: + assert(0 && "Cannot promote/custom handle this yet!"); + case TargetLowering::Expand: + if (Node->getOpcode() == ISD::FNEG) { + // Expand Y = FNEG(X) -> Y = SUB -0.0, X + Tmp2 = DAG.getConstantFP(-0.0, Node->getValueType(0)); + Result = LegalizeOp(DAG.getNode(ISD::SUB, Node->getValueType(0), + Tmp2, Tmp1)); + } else { + assert(0 && "Expand fneg not impl yet!"); + } + break; + } + break; + + // Conversion operators. The source and destination have different types. case ISD::ZERO_EXTEND: case ISD::SIGN_EXTEND: case ISD::TRUNCATE: @@ -882,17 +917,17 @@ Node->getValueType(0), Node->getOperand(0)); Result = LegalizeOp(Result); break; + } else if (Node->getOpcode() == ISD::TRUNCATE) { + // In the expand case, we must be dealing with a truncate, because + // otherwise the result would be larger than the source. + ExpandOp(Node->getOperand(0), Tmp1, Tmp2); + + // Since the result is legal, we should just be able to truncate the low + // part of the source. + Result = DAG.getNode(ISD::TRUNCATE, Node->getValueType(0), Tmp1); + break; } - // In the expand case, we must be dealing with a truncate, because - // otherwise the result would be larger than the source. - assert(Node->getOpcode() == ISD::TRUNCATE && - "Shouldn't need to expand other operators here!"); - ExpandOp(Node->getOperand(0), Tmp1, Tmp2); - - // Since the result is legal, we should just be able to truncate the low - // part of the source. - Result = DAG.getNode(ISD::TRUNCATE, Node->getValueType(0), Tmp1); - break; + assert(0 && "Shouldn't need to expand other operators here!"); case Promote: switch (Node->getOpcode()) { @@ -1172,6 +1207,16 @@ Result = DAG.getNode(Node->getOpcode(), NVT, Tmp1); break; + case ISD::FABS: + case ISD::FNEG: + Tmp1 = PromoteOp(Node->getOperand(0)); + assert(Tmp1.getValueType() == NVT); + Result = DAG.getNode(Node->getOpcode(), NVT, Tmp1); + // NOTE: we do not have to do any extra rounding here for + // NoExcessFPPrecision, because we know the input will have the appropriate + // precision, and these operations don't modify precision at all. + break; + case ISD::AND: case ISD::OR: case ISD::XOR: From lattner at cs.uiuc.edu Fri Apr 1 23:03:33 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 1 Apr 2005 23:03:33 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp Message-ID: <200504020503.j3253Xq9032474@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.72 -> 1.73 --- Log message: This target doesn't support fabs/fneg yet. --- Diffs of the changes: (+4 -0) AlphaISelPattern.cpp | 4 ++++ 1 files changed, 4 insertions(+) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.72 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.73 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.72 Thu Mar 31 16:02:25 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Fri Apr 1 23:03:19 2005 @@ -75,6 +75,10 @@ setOperationAction(ISD::MEMSET , MVT::Other, Expand); setOperationAction(ISD::MEMCPY , MVT::Other, Expand); + // We don't support these yet. + setOperationAction(ISD::FNEG , MVT::f64 , Expand); + setOperationAction(ISD::FABS , MVT::f64 , Expand); + //Doesn't work yet setOperationAction(ISD::SETCC , MVT::f32, Promote); From lattner at cs.uiuc.edu Fri Apr 1 23:03:36 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 1 Apr 2005 23:03:36 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/IA64/IA64ISelPattern.cpp Message-ID: <200504020503.j3253a7N032483@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/IA64: IA64ISelPattern.cpp updated: 1.7 -> 1.8 --- Log message: This target doesn't support fabs/fneg yet. --- Diffs of the changes: (+3 -0) IA64ISelPattern.cpp | 3 +++ 1 files changed, 3 insertions(+) Index: llvm/lib/Target/IA64/IA64ISelPattern.cpp diff -u llvm/lib/Target/IA64/IA64ISelPattern.cpp:1.7 llvm/lib/Target/IA64/IA64ISelPattern.cpp:1.8 --- llvm/lib/Target/IA64/IA64ISelPattern.cpp:1.7 Fri Apr 1 04:35:00 2005 +++ llvm/lib/Target/IA64/IA64ISelPattern.cpp Fri Apr 1 23:03:21 2005 @@ -80,6 +80,9 @@ setOperationAction(ISD::MEMSET , MVT::Other, Expand); setOperationAction(ISD::MEMCPY , MVT::Other, Expand); + // We don't support these yet. + setOperationAction(ISD::FNEG , MVT::f64 , Expand); + setOperationAction(ISD::FABS , MVT::f64 , Expand); computeRegisterProperties(); From lattner at cs.uiuc.edu Fri Apr 1 23:03:38 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 1 Apr 2005 23:03:38 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Message-ID: <200504020503.j3253cP6032489@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPC32ISelPattern.cpp updated: 1.33 -> 1.34 --- Log message: This target doesn't support fabs/fneg yet. --- Diffs of the changes: (+4 -0) PPC32ISelPattern.cpp | 4 ++++ 1 files changed, 4 insertions(+) Index: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp diff -u llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.33 llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.34 --- llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.33 Fri Apr 1 18:42:16 2005 +++ llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Fri Apr 1 23:03:23 2005 @@ -53,6 +53,10 @@ // PowerPC has an i16 but no i8 (or i1) SEXTLOAD setOperationAction(ISD::SEXTLOAD, MVT::i1, Expand); setOperationAction(ISD::SEXTLOAD, MVT::i8, Expand); + + // We don't support these yet. + setOperationAction(ISD::FNEG , MVT::f64 , Expand); + setOperationAction(ISD::FABS , MVT::f64 , Expand); addLegalFPImmediate(+0.0); // Necessary for FSEL addLegalFPImmediate(-0.0); // From lattner at cs.uiuc.edu Fri Apr 1 23:03:38 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 1 Apr 2005 23:03:38 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ISelPattern.cpp Message-ID: <200504020503.j3253cKv032492@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ISelPattern.cpp updated: 1.97 -> 1.98 --- Log message: This target doesn't support fabs/fneg yet. --- Diffs of the changes: (+4 -0) X86ISelPattern.cpp | 4 ++++ 1 files changed, 4 insertions(+) Index: llvm/lib/Target/X86/X86ISelPattern.cpp diff -u llvm/lib/Target/X86/X86ISelPattern.cpp:1.97 llvm/lib/Target/X86/X86ISelPattern.cpp:1.98 --- llvm/lib/Target/X86/X86ISelPattern.cpp:1.97 Fri Apr 1 22:01:14 2005 +++ llvm/lib/Target/X86/X86ISelPattern.cpp Fri Apr 1 23:03:24 2005 @@ -63,6 +63,10 @@ setOperationAction(ISD::FP_ROUND_INREG , MVT::f32 , Expand); setOperationAction(ISD::SEXTLOAD , MVT::i1 , Expand); setOperationAction(ISD::SREM , MVT::f64 , Expand); + + // We don't support these yet. + setOperationAction(ISD::FNEG , MVT::f64 , Expand); + setOperationAction(ISD::FABS , MVT::f64 , Expand); // These should be promoted to a larger select which is supported. /**/ setOperationAction(ISD::SELECT , MVT::i1 , Promote); From lattner at cs.uiuc.edu Fri Apr 1 23:05:04 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 1 Apr 2005 23:05:04 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <200504020505.j325540p032512@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: SelectionDAGISel.cpp updated: 1.37 -> 1.38 --- Log message: Turn -0.0 - X -> fneg --- Diffs of the changes: (+13 -1) SelectionDAGISel.cpp | 14 +++++++++++++- 1 files changed, 13 insertions(+), 1 deletion(-) Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.37 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.38 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.37 Thu Mar 31 15:24:06 2005 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Fri Apr 1 23:04:50 2005 @@ -314,7 +314,7 @@ // void visitBinary(User &I, unsigned Opcode); void visitAdd(User &I) { visitBinary(I, ISD::ADD); } - void visitSub(User &I) { visitBinary(I, ISD::SUB); } + void visitSub(User &I); void visitMul(User &I) { visitBinary(I, ISD::MUL); } void visitDiv(User &I) { visitBinary(I, I.getType()->isUnsigned() ? ISD::UDIV : ISD::SDIV); @@ -454,6 +454,18 @@ } } +void SelectionDAGLowering::visitSub(User &I) { + // -0.0 - X --> fneg + if (ConstantFP *CFP = dyn_cast(I.getOperand(0))) + if (CFP->isExactlyValue(-0.0)) { + SDOperand Op2 = getValue(I.getOperand(1)); + setValue(&I, DAG.getNode(ISD::FNEG, Op2.getValueType(), Op2)); + return; + } + + visitBinary(I, ISD::SUB); +} + void SelectionDAGLowering::visitBinary(User &I, unsigned Opcode) { SDOperand Op1 = getValue(I.getOperand(0)); SDOperand Op2 = getValue(I.getOperand(1)); From duraid at octopus.com.au Fri Apr 1 23:19:03 2005 From: duraid at octopus.com.au (Duraid Madina) Date: Fri, 1 Apr 2005 23:19:03 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/IA64/IA64ISelPattern.cpp IA64InstrInfo.td Message-ID: <200504020519.XAA10224@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/IA64: IA64ISelPattern.cpp updated: 1.8 -> 1.9 IA64InstrInfo.td updated: 1.2 -> 1.3 --- Log message: add support FNEG and FABS --- Diffs of the changes: (+19 -5) IA64ISelPattern.cpp | 20 +++++++++++++++----- IA64InstrInfo.td | 4 ++++ 2 files changed, 19 insertions(+), 5 deletions(-) Index: llvm/lib/Target/IA64/IA64ISelPattern.cpp diff -u llvm/lib/Target/IA64/IA64ISelPattern.cpp:1.8 llvm/lib/Target/IA64/IA64ISelPattern.cpp:1.9 --- llvm/lib/Target/IA64/IA64ISelPattern.cpp:1.8 Fri Apr 1 23:03:21 2005 +++ llvm/lib/Target/IA64/IA64ISelPattern.cpp Fri Apr 1 23:18:38 2005 @@ -80,10 +80,6 @@ setOperationAction(ISD::MEMSET , MVT::Other, Expand); setOperationAction(ISD::MEMCPY , MVT::Other, Expand); - // We don't support these yet. - setOperationAction(ISD::FNEG , MVT::f64 , Expand); - setOperationAction(ISD::FABS , MVT::f64 , Expand); - computeRegisterProperties(); addLegalFPImmediate(+0.0); @@ -794,7 +790,21 @@ BuildMI(BB, IA64::FSUB, 2, Result).addReg(Tmp1).addReg(Tmp2); return Result; } - + + case ISD::FABS: { + Tmp1 = SelectExpr(N.getOperand(0)); + assert(DestType == MVT::f64 && "trying to fabs something other than f64?"); + BuildMI(BB, IA64::FABS, 1, Result).addReg(Tmp1); + return Result; + } + + case ISD::FNEG: { + Tmp1 = SelectExpr(N.getOperand(0)); + assert(DestType == MVT::f64 && "trying to fneg something other than f64?"); + BuildMI(BB, IA64::FNEG, 1, Result).addReg(Tmp1); + return Result; + } + case ISD::AND: { switch (N.getValueType()) { default: assert(0 && "Cannot AND this type!"); Index: llvm/lib/Target/IA64/IA64InstrInfo.td diff -u llvm/lib/Target/IA64/IA64InstrInfo.td:1.2 llvm/lib/Target/IA64/IA64InstrInfo.td:1.3 --- llvm/lib/Target/IA64/IA64InstrInfo.td:1.2 Thu Mar 31 01:32:32 2005 +++ llvm/lib/Target/IA64/IA64InstrInfo.td Fri Apr 1 23:18:38 2005 @@ -227,6 +227,10 @@ "fma $dst = $src1, $src2, $src3;;">; def FNMA : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3), "fnma $dst = $src1, $src2, $src3;;">; +def FABS : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src), + "fabs $dst = $src;;">; +def FNEG : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src), + "fneg $dst = $src;;">; def CFMAS1 : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3, PR:$qp), From lattner at cs.uiuc.edu Fri Apr 1 23:27:10 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 1 Apr 2005 23:27:10 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <200504020527.j325RAZH001312@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: SelectionDAGISel.cpp updated: 1.38 -> 1.39 --- Log message: transform fabs/fabsf calls into FABS nodes. --- Diffs of the changes: (+39 -29) SelectionDAGISel.cpp | 68 +++++++++++++++++++++++++++++---------------------- 1 files changed, 39 insertions(+), 29 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.38 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.39 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.38 Fri Apr 1 23:04:50 2005 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Fri Apr 1 23:26:53 2005 @@ -652,35 +652,45 @@ void SelectionDAGLowering::visitCall(CallInst &I) { const char *RenameFn = 0; if (Function *F = I.getCalledFunction()) - switch (F->getIntrinsicID()) { - case 0: break; // Not an intrinsic. - case Intrinsic::vastart: visitVAStart(I); return; - case Intrinsic::vaend: visitVAEnd(I); return; - case Intrinsic::vacopy: visitVACopy(I); return; - case Intrinsic::returnaddress: visitFrameReturnAddress(I, false); return; - case Intrinsic::frameaddress: visitFrameReturnAddress(I, true); return; - default: - // FIXME: IMPLEMENT THESE. - // readport, writeport, readio, writeio - assert(0 && "This intrinsic is not implemented yet!"); - return; - case Intrinsic::setjmp: RenameFn = "setjmp"; break; - case Intrinsic::longjmp: RenameFn = "longjmp"; break; - case Intrinsic::memcpy: visitMemIntrinsic(I, ISD::MEMCPY); return; - case Intrinsic::memset: visitMemIntrinsic(I, ISD::MEMSET); return; - case Intrinsic::memmove: visitMemIntrinsic(I, ISD::MEMMOVE); return; - - case Intrinsic::isunordered: - setValue(&I, DAG.getSetCC(ISD::SETUO, MVT::i1, getValue(I.getOperand(1)), - getValue(I.getOperand(2)))); - return; - case Intrinsic::pcmarker: { - SDOperand Num = getValue(I.getOperand(1)); - DAG.setRoot(DAG.getNode(ISD::PCMARKER, MVT::Other, getRoot(), Num)); - return; - } - - } + if (F->isExternal()) + switch (F->getIntrinsicID()) { + case 0: // Not an LLVM intrinsic. + if (F->getName() == "fabs" || F->getName() == "fabsf") { + if (I.getNumOperands() == 2 && // Basic sanity checks. + I.getOperand(1)->getType()->isFloatingPoint() && + I.getType() == I.getOperand(1)->getType()) { + SDOperand Tmp = getValue(I.getOperand(1)); + setValue(&I, DAG.getNode(ISD::FABS, Tmp.getValueType(), Tmp)); + return; + } + } + break; + case Intrinsic::vastart: visitVAStart(I); return; + case Intrinsic::vaend: visitVAEnd(I); return; + case Intrinsic::vacopy: visitVACopy(I); return; + case Intrinsic::returnaddress: visitFrameReturnAddress(I, false); return; + case Intrinsic::frameaddress: visitFrameReturnAddress(I, true); return; + default: + // FIXME: IMPLEMENT THESE. + // readport, writeport, readio, writeio + assert(0 && "This intrinsic is not implemented yet!"); + return; + case Intrinsic::setjmp: RenameFn = "setjmp"; break; + case Intrinsic::longjmp: RenameFn = "longjmp"; break; + case Intrinsic::memcpy: visitMemIntrinsic(I, ISD::MEMCPY); return; + case Intrinsic::memset: visitMemIntrinsic(I, ISD::MEMSET); return; + case Intrinsic::memmove: visitMemIntrinsic(I, ISD::MEMMOVE); return; + + case Intrinsic::isunordered: + setValue(&I, DAG.getSetCC(ISD::SETUO, MVT::i1,getValue(I.getOperand(1)), + getValue(I.getOperand(2)))); + return; + case Intrinsic::pcmarker: { + SDOperand Num = getValue(I.getOperand(1)); + DAG.setRoot(DAG.getNode(ISD::PCMARKER, MVT::Other, getRoot(), Num)); + return; + } + } SDOperand Callee; if (!RenameFn) From lattner at cs.uiuc.edu Fri Apr 1 23:27:21 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 1 Apr 2005 23:27:21 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Message-ID: <200504020527.j325RLSN001319@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: LegalizeDAG.cpp updated: 1.70 -> 1.71 --- Log message: Expand fabs into fneg --- Diffs of the changes: (+9 -1) LegalizeDAG.cpp | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletion(-) Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.70 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.71 --- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.70 Fri Apr 1 23:00:07 2005 +++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Fri Apr 1 23:26:37 2005 @@ -887,8 +887,16 @@ Tmp2 = DAG.getConstantFP(-0.0, Node->getValueType(0)); Result = LegalizeOp(DAG.getNode(ISD::SUB, Node->getValueType(0), Tmp2, Tmp1)); + } else if (Node->getOpcode() == ISD::FABS) { + // Expand Y = FABS(X) -> Y = (X >u 0.0) ? X : fneg(X). + MVT::ValueType VT = Node->getValueType(0); + Tmp2 = DAG.getConstantFP(0.0, VT); + Tmp2 = DAG.getSetCC(ISD::SETUGT, TLI.getSetCCResultTy(), Tmp1, Tmp2); + Tmp3 = DAG.getNode(ISD::FNEG, VT, Tmp1); + Result = DAG.getNode(ISD::SELECT, VT, Tmp2, Tmp1, Tmp3); + Result = LegalizeOp(Result); } else { - assert(0 && "Expand fneg not impl yet!"); + assert(0 && "Unreachable!"); } break; } From lattner at cs.uiuc.edu Fri Apr 1 23:30:35 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 1 Apr 2005 23:30:35 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ISelPattern.cpp Message-ID: <200504020530.j325UZV6001650@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ISelPattern.cpp updated: 1.98 -> 1.99 --- Log message: add support for FABS and FNEG --- Diffs of the changes: (+10 -4) X86ISelPattern.cpp | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-) Index: llvm/lib/Target/X86/X86ISelPattern.cpp diff -u llvm/lib/Target/X86/X86ISelPattern.cpp:1.98 llvm/lib/Target/X86/X86ISelPattern.cpp:1.99 --- llvm/lib/Target/X86/X86ISelPattern.cpp:1.98 Fri Apr 1 23:03:24 2005 +++ llvm/lib/Target/X86/X86ISelPattern.cpp Fri Apr 1 23:30:17 2005 @@ -64,10 +64,6 @@ setOperationAction(ISD::SEXTLOAD , MVT::i1 , Expand); setOperationAction(ISD::SREM , MVT::f64 , Expand); - // We don't support these yet. - setOperationAction(ISD::FNEG , MVT::f64 , Expand); - setOperationAction(ISD::FABS , MVT::f64 , Expand); - // These should be promoted to a larger select which is supported. /**/ setOperationAction(ISD::SELECT , MVT::i1 , Promote); setOperationAction(ISD::SELECT , MVT::i8 , Promote); @@ -1812,6 +1808,16 @@ BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); return Result; + + case ISD::FABS: + Tmp1 = SelectExpr(Node->getOperand(0)); + BuildMI(BB, X86::FABS, 1, Result).addReg(Tmp1); + return Result; + case ISD::FNEG: + Tmp1 = SelectExpr(Node->getOperand(0)); + BuildMI(BB, X86::FCHS, 1, Result).addReg(Tmp1); + return Result; + case ISD::SUB: case ISD::MUL: case ISD::AND: From lattner at cs.uiuc.edu Fri Apr 1 23:33:27 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 1 Apr 2005 23:33:27 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/CodeGen/Generic/fneg-fabs.ll Message-ID: <200504020533.j325XR58001675@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/CodeGen/Generic: fneg-fabs.ll added (r1.1) --- Log message: new testcase --- Diffs of the changes: (+26 -0) fneg-fabs.ll | 26 ++++++++++++++++++++++++++ 1 files changed, 26 insertions(+) Index: llvm/test/Regression/CodeGen/Generic/fneg-fabs.ll diff -c /dev/null llvm/test/Regression/CodeGen/Generic/fneg-fabs.ll:1.1 *** /dev/null Fri Apr 1 23:33:20 2005 --- llvm/test/Regression/CodeGen/Generic/fneg-fabs.ll Fri Apr 1 23:33:10 2005 *************** *** 0 **** --- 1,26 ---- + ; RUN: llvm-as < %s | llc + + double %fneg(double %X) { + %Y = sub double -0.0, %X + ret double %Y + } + + float %fnegf(float %X) { + %Y = sub float -0.0, %X + ret float %Y + } + + declare double %fabs(double) + declare float %fabsf(float) + + + double %fabstest(double %X) { + %Y = call double %fabs(double %X) + ret double %Y + } + + float %fabsftest(float %X) { + %Y = call float %fabsf(float %X) + ret float %Y + } + From lattner at cs.uiuc.edu Fri Apr 1 23:35:13 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 1 Apr 2005 23:35:13 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/CodeGen/X86/fabs.ll Message-ID: <200504020535.j325ZDFv001704@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/CodeGen/X86: fabs.ll added (r1.1) --- Log message: new testcase --- Diffs of the changes: (+10 -0) fabs.ll | 10 ++++++++++ 1 files changed, 10 insertions(+) Index: llvm/test/Regression/CodeGen/X86/fabs.ll diff -c /dev/null llvm/test/Regression/CodeGen/X86/fabs.ll:1.1 *** /dev/null Fri Apr 1 23:35:10 2005 --- llvm/test/Regression/CodeGen/X86/fabs.ll Fri Apr 1 23:35:00 2005 *************** *** 0 **** --- 1,10 ---- + ; Make sure this testcase codegens to the fabs instruction, not a call to fabsf + ; RUN: llvm-as < %s | llc -disable-pattern-isel=0 | grep 'fabs$' + + declare float %fabsf(float) + + float %fabsftest(float %X) { + %Y = call float %fabsf(float %X) + ret float %Y + } + From lattner at cs.uiuc.edu Fri Apr 1 23:40:19 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 1 Apr 2005 23:40:19 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/CodeGen/X86/fabs.ll Message-ID: <200504020540.j325eJ48003308@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/CodeGen/X86: fabs.ll updated: 1.1 -> 1.2 --- Log message: don't forget to use the right code generator :) --- Diffs of the changes: (+1 -1) fabs.ll | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/test/Regression/CodeGen/X86/fabs.ll diff -u llvm/test/Regression/CodeGen/X86/fabs.ll:1.1 llvm/test/Regression/CodeGen/X86/fabs.ll:1.2 --- llvm/test/Regression/CodeGen/X86/fabs.ll:1.1 Fri Apr 1 23:35:00 2005 +++ llvm/test/Regression/CodeGen/X86/fabs.ll Fri Apr 1 23:40:03 2005 @@ -1,5 +1,5 @@ ; Make sure this testcase codegens to the fabs instruction, not a call to fabsf -; RUN: llvm-as < %s | llc -disable-pattern-isel=0 | grep 'fabs$' +; RUN: llvm-as < %s | llc -march=x86 -disable-pattern-isel=0 | grep 'fabs$' declare float %fabsf(float) From natebegeman at mac.com Fri Apr 1 23:59:48 2005 From: natebegeman at mac.com (Nate Begeman) Date: Fri, 1 Apr 2005 23:59:48 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp PowerPCInstrInfo.td Message-ID: <200504020559.XAA10417@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPC32ISelPattern.cpp updated: 1.34 -> 1.35 PowerPCInstrInfo.td updated: 1.52 -> 1.53 --- Log message: Set shift amount to Extend Implement ISD::FABS and ISD::FNEG nodes Implement SHL_PARTS, SRL_PARTS, and SRA_PARTS Generate PowerPC 'fneg', 'fabs', and 'fnabs' instructions --- Diffs of the changes: (+105 -24) PPC32ISelPattern.cpp | 125 +++++++++++++++++++++++++++++++++++++++++---------- PowerPCInstrInfo.td | 4 + 2 files changed, 105 insertions(+), 24 deletions(-) Index: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp diff -u llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.34 llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.35 --- llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.34 Fri Apr 1 23:03:23 2005 +++ llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Fri Apr 1 23:59:34 2005 @@ -54,10 +54,7 @@ setOperationAction(ISD::SEXTLOAD, MVT::i1, Expand); setOperationAction(ISD::SEXTLOAD, MVT::i8, Expand); - // We don't support these yet. - setOperationAction(ISD::FNEG , MVT::f64 , Expand); - setOperationAction(ISD::FABS , MVT::f64 , Expand); - + setShiftAmountFlavor(Extend); // shl X, 32 == 0 addLegalFPImmediate(+0.0); // Necessary for FSEL addLegalFPImmediate(-0.0); // @@ -762,7 +759,22 @@ .addMBB(copy0MBB).addReg(TrueValue).addMBB(thisMBB); return Result; } + + case ISD::FNEG: + if (ISD::FABS == N.getOperand(0).getOpcode()) { + Tmp1 = SelectExpr(N.getOperand(0).getOperand(0)); + BuildMI(BB, PPC::FNABS, 1, Result).addReg(Tmp1); + } else { + Tmp1 = SelectExpr(N.getOperand(0)); + BuildMI(BB, PPC::FNEG, 1, Result).addReg(Tmp1); + } + return Result; + case ISD::FABS: + Tmp1 = SelectExpr(N.getOperand(0)); + BuildMI(BB, PPC::FABS, 1, Result).addReg(Tmp1); + return Result; + case ISD::FP_ROUND: assert (DestType == MVT::f32 && N.getOperand(0).getValueType() == MVT::f64 && @@ -874,29 +886,34 @@ unsigned &Reg = ExprMap[N]; if (Reg) return Reg; - if (N.getOpcode() != ISD::CALL && N.getOpcode() != ISD::ADD_PARTS && - N.getOpcode() != ISD::SUB_PARTS) + switch (N.getOpcode()) { + default: Reg = Result = (N.getValueType() != MVT::Other) ? - MakeReg(N.getValueType()) : 1; - else { + MakeReg(N.getValueType()) : 1; + break; + case ISD::CALL: // If this is a call instruction, make sure to prepare ALL of the result // values as well as the chain. - if (N.getOpcode() == ISD::CALL) { - if (Node->getNumValues() == 1) - Reg = Result = 1; // Void call, just a chain. - else { - Result = MakeReg(Node->getValueType(0)); - ExprMap[N.getValue(0)] = Result; - for (unsigned i = 1, e = N.Val->getNumValues()-1; i != e; ++i) - ExprMap[N.getValue(i)] = MakeReg(Node->getValueType(i)); - ExprMap[SDOperand(Node, Node->getNumValues()-1)] = 1; - } - } else { + if (Node->getNumValues() == 1) + Reg = Result = 1; // Void call, just a chain. + else { Result = MakeReg(Node->getValueType(0)); ExprMap[N.getValue(0)] = Result; - for (unsigned i = 1, e = N.Val->getNumValues(); i != e; ++i) + for (unsigned i = 1, e = N.Val->getNumValues()-1; i != e; ++i) ExprMap[N.getValue(i)] = MakeReg(Node->getValueType(i)); + ExprMap[SDOperand(Node, Node->getNumValues()-1)] = 1; } + break; + case ISD::ADD_PARTS: + case ISD::SUB_PARTS: + case ISD::SHL_PARTS: + case ISD::SRL_PARTS: + case ISD::SRA_PARTS: + Result = MakeReg(Node->getValueType(0)); + ExprMap[N.getValue(0)] = Result; + for (unsigned i = 1, e = N.Val->getNumValues(); i != e; ++i) + ExprMap[N.getValue(i)] = MakeReg(Node->getValueType(i)); + break; } if (DestType == MVT::f64 || DestType == MVT::f32) @@ -1265,11 +1282,71 @@ for (unsigned i = 0, e = N.getNumOperands(); i != e; ++i) InVals.push_back(SelectExpr(N.getOperand(i))); if (N.getOpcode() == ISD::ADD_PARTS) { - BuildMI(BB, PPC::ADDC, 2, Result+1).addReg(InVals[0]).addReg(InVals[2]); - BuildMI(BB, PPC::ADDE, 2, Result).addReg(InVals[1]).addReg(InVals[3]); + BuildMI(BB, PPC::ADDC, 2, Result).addReg(InVals[0]).addReg(InVals[2]); + BuildMI(BB, PPC::ADDE, 2, Result+1).addReg(InVals[1]).addReg(InVals[3]); + } else { + BuildMI(BB, PPC::SUBFC, 2, Result).addReg(InVals[2]).addReg(InVals[0]); + BuildMI(BB, PPC::SUBFE, 2, Result+1).addReg(InVals[3]).addReg(InVals[1]); + } + return Result+N.ResNo; + } + + case ISD::SHL_PARTS: + case ISD::SRA_PARTS: + case ISD::SRL_PARTS: { + assert(N.getNumOperands() == 3 && N.getValueType() == MVT::i32 && + "Not an i64 shift!"); + unsigned ShiftOpLo = SelectExpr(N.getOperand(0)); + unsigned ShiftOpHi = SelectExpr(N.getOperand(1)); + unsigned SHReg = SelectExpr(N.getOperand(2)); + Tmp1 = MakeReg(MVT::i32); + Tmp2 = MakeReg(MVT::i32); + Tmp3 = MakeReg(MVT::i32); + unsigned Tmp4 = MakeReg(MVT::i32); + unsigned Tmp5 = MakeReg(MVT::i32); + unsigned Tmp6 = MakeReg(MVT::i32); + BuildMI(BB, PPC::SUBFIC, 2, Tmp1).addReg(SHReg).addSImm(32); + if (ISD::SHL_PARTS == opcode) { + BuildMI(BB, PPC::SLW, 2, Tmp2).addReg(ShiftOpHi).addReg(SHReg); + BuildMI(BB, PPC::SRW, 2, Tmp3).addReg(ShiftOpLo).addReg(Tmp1); + BuildMI(BB, PPC::OR, 2, Tmp4).addReg(Tmp2).addReg(Tmp3); + BuildMI(BB, PPC::ADDI, 2, Tmp5).addReg(SHReg).addSImm(-32); + BuildMI(BB, PPC::SLW, 2, Tmp6).addReg(ShiftOpHi).addReg(Tmp5); + BuildMI(BB, PPC::OR, 2, Result+1).addReg(Tmp4).addReg(Tmp6); + BuildMI(BB, PPC::SLW, 2, Result).addReg(ShiftOpLo).addReg(SHReg); + } else if (ISD::SRL_PARTS == opcode) { + BuildMI(BB, PPC::SRW, 2, Tmp2).addReg(ShiftOpLo).addReg(SHReg); + BuildMI(BB, PPC::SLW, 2, Tmp3).addReg(ShiftOpHi).addReg(Tmp1); + BuildMI(BB, PPC::OR, 2, Tmp4).addReg(Tmp2).addReg(Tmp3); + BuildMI(BB, PPC::ADDI, 2, Tmp5).addReg(SHReg).addSImm(-32); + BuildMI(BB, PPC::SRW, 2, Tmp6).addReg(ShiftOpHi).addReg(Tmp5); + BuildMI(BB, PPC::OR, 2, Result).addReg(Tmp4).addReg(Tmp6); + BuildMI(BB, PPC::SRW, 2, Result+1).addReg(ShiftOpHi).addReg(SHReg); } else { - BuildMI(BB, PPC::SUBFC, 2, Result+1).addReg(InVals[2]).addReg(InVals[0]); - BuildMI(BB, PPC::SUBFE, 2, Result).addReg(InVals[3]).addReg(InVals[1]); + MachineBasicBlock *TmpMBB = new MachineBasicBlock(BB->getBasicBlock()); + MachineBasicBlock *PhiMBB = new MachineBasicBlock(BB->getBasicBlock()); + MachineBasicBlock *OldMBB = BB; + MachineFunction *F = BB->getParent(); + ilist::iterator It = BB; ++It; + F->getBasicBlockList().insert(It, TmpMBB); + F->getBasicBlockList().insert(It, PhiMBB); + BB->addSuccessor(TmpMBB); + BB->addSuccessor(PhiMBB); + BuildMI(BB, PPC::SRW, 2, Tmp2).addReg(ShiftOpLo).addReg(SHReg); + BuildMI(BB, PPC::SLW, 2, Tmp3).addReg(ShiftOpHi).addReg(Tmp1); + BuildMI(BB, PPC::OR, 2, Tmp4).addReg(Tmp2).addReg(Tmp3); + BuildMI(BB, PPC::ADDICo, 2, Tmp5).addReg(SHReg).addSImm(-32); + BuildMI(BB, PPC::SRAW, 2, Tmp6).addReg(ShiftOpHi).addReg(Tmp5); + BuildMI(BB, PPC::SRAW, 2, Result+1).addReg(ShiftOpHi).addReg(SHReg); + BuildMI(BB, PPC::BLE, 2).addReg(PPC::CR0).addMBB(PhiMBB); + // Select correct least significant half if the shift amount > 32 + BB = TmpMBB; + unsigned Tmp7 = MakeReg(MVT::i32); + BuildMI(BB, PPC::OR, 2, Tmp7).addReg(Tmp6).addReg(Tmp6); + TmpMBB->addSuccessor(PhiMBB); + BB = PhiMBB; + BuildMI(BB, PPC::PHI, 4, Result).addReg(Tmp4).addMBB(OldMBB) + .addReg(Tmp7).addMBB(TmpMBB); } return Result+N.ResNo; } Index: llvm/lib/Target/PowerPC/PowerPCInstrInfo.td diff -u llvm/lib/Target/PowerPC/PowerPCInstrInfo.td:1.52 llvm/lib/Target/PowerPC/PowerPCInstrInfo.td:1.53 --- llvm/lib/Target/PowerPC/PowerPCInstrInfo.td:1.52 Tue Mar 29 15:54:38 2005 +++ llvm/lib/Target/PowerPC/PowerPCInstrInfo.td Fri Apr 1 23:59:34 2005 @@ -308,8 +308,12 @@ "fctidz $frD, $frB">; def FCTIWZ : XForm_26<63, 15, 0, 0, 0, (ops FPRC:$frD, FPRC:$frB), "fctiwz $frD, $frB">; +def FABS : XForm_26<63, 264, 0, 0, 0, (ops FPRC:$frD, FPRC:$frB), + "fabs $frD, $frB">; def FMR : XForm_26<63, 72, 0, 0, 0, (ops FPRC:$frD, FPRC:$frB), "fmr $frD, $frB">; +def FNABS : XForm_26<63, 136, 0, 0, 0, (ops FPRC:$frD, FPRC:$frB), + "fnabs $frD, $frB">; def FNEG : XForm_26<63, 40, 0, 0, 0, (ops FPRC:$frD, FPRC:$frB), "fneg $frD, $frB">; def FRSP : XForm_26<63, 12, 0, 0, 0, (ops FPRC:$frD, FPRC:$frB), From alkis at cs.uiuc.edu Sat Apr 2 02:18:31 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 2 Apr 2005 02:18:31 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMClass.h VMClass.cpp Resolver.h Resolver.cpp Compiler.cpp Message-ID: <200504020818.CAA11122@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMClass.h updated: 1.29 -> 1.30 VMClass.cpp updated: 1.39 -> 1.40 Resolver.h updated: 1.12 -> 1.13 Resolver.cpp updated: 1.15 -> 1.16 Compiler.cpp updated: 1.276 -> 1.277 --- Log message: Differentiate between the class name and the class descriptor. --- Diffs of the changes: (+26 -18) Compiler.cpp | 5 +---- Resolver.cpp | 3 +-- Resolver.h | 4 ++-- VMClass.cpp | 30 ++++++++++++++++++++---------- VMClass.h | 2 ++ 5 files changed, 26 insertions(+), 18 deletions(-) Index: llvm-java/lib/Compiler/VMClass.h diff -u llvm-java/lib/Compiler/VMClass.h:1.29 llvm-java/lib/Compiler/VMClass.h:1.30 --- llvm-java/lib/Compiler/VMClass.h:1.29 Fri Apr 1 21:06:35 2005 +++ llvm-java/lib/Compiler/VMClass.h Sat Apr 2 02:18:20 2005 @@ -33,6 +33,7 @@ static const int INVALID_INTERFACE_INDEX = -1; const std::string name_; + const std::string descriptor_; Resolver* resolver_; const ClassFile* classFile_; const VMClass* componentClass_; @@ -86,6 +87,7 @@ public: const std::string& getName() const { return name_; } + const std::string& getDescriptor() const { return descriptor_; } Resolver* getResolver() const { return resolver_; } const Type* getLayoutType() const { return layoutType_; } const Type* getType() const { return type_; } Index: llvm-java/lib/Compiler/VMClass.cpp diff -u llvm-java/lib/Compiler/VMClass.cpp:1.39 llvm-java/lib/Compiler/VMClass.cpp:1.40 --- llvm-java/lib/Compiler/VMClass.cpp:1.39 Fri Apr 1 21:06:35 2005 +++ llvm-java/lib/Compiler/VMClass.cpp Sat Apr 2 02:18:20 2005 @@ -42,7 +42,8 @@ } VMClass::VMClass(Resolver* resolver, const std::string& className) - : name_(Resolver::canonicalizeClassName(className)), + : name_(className), + descriptor_(Resolver::canonicalizeClassName(className)), resolver_(resolver), classFile_(ClassFile::get(className)), componentClass_(NULL), @@ -55,7 +56,8 @@ } VMClass::VMClass(Resolver* resolver, const VMClass* componentClass) - : name_('[' + componentClass->getName()), + : name_('[' + componentClass->getDescriptor()), + descriptor_(name_), resolver_(resolver), classFile_(NULL), componentClass_(componentClass), @@ -67,14 +69,22 @@ } VMClass::VMClass(Resolver* resolver, const Type* type) - : name_(type == Type::SByteTy ? "B" : - type == Type::UShortTy ? "C" : - type == Type::DoubleTy ? "D" : - type == Type::FloatTy ? "F" : - type == Type::IntTy ? "I" : - type == Type::LongTy ? "J" : - type == Type::ShortTy ? "S" : - type == Type::BoolTy ? "Z" : "V"), + : name_(type == Type::SByteTy ? "byte" : + type == Type::UShortTy ? "char" : + type == Type::DoubleTy ? "double" : + type == Type::FloatTy ? "float" : + type == Type::IntTy ? "int" : + type == Type::LongTy ? "long" : + type == Type::ShortTy ? "short" : + type == Type::BoolTy ? "boolean" : "void"), + descriptor_(type == Type::SByteTy ? "B" : + type == Type::UShortTy ? "C" : + type == Type::DoubleTy ? "D" : + type == Type::FloatTy ? "F" : + type == Type::IntTy ? "I" : + type == Type::LongTy ? "J" : + type == Type::ShortTy ? "S" : + type == Type::BoolTy ? "Z" : "V"), resolver_(resolver), classFile_(NULL), componentClass_(NULL), Index: llvm-java/lib/Compiler/Resolver.h diff -u llvm-java/lib/Compiler/Resolver.h:1.12 llvm-java/lib/Compiler/Resolver.h:1.13 --- llvm-java/lib/Compiler/Resolver.h:1.12 Thu Mar 31 01:56:28 2005 +++ llvm-java/lib/Compiler/Resolver.h Sat Apr 2 02:18:20 2005 @@ -42,7 +42,7 @@ bool memberMethod = false) const; ClassMap::iterator insertClass(ClassMap::iterator i, const VMClass& clazz) { - return classMap_.insert(i, std::make_pair(clazz.getName(), clazz)); + return classMap_.insert(i, std::make_pair(clazz.getDescriptor(), clazz)); } friend class VMClass; @@ -82,7 +82,7 @@ const VMClass* getClass(JType type); const VMClass* getArrayClass(const VMClass* clazz) { - return getClassForDesc('[' + clazz->getName()); + return getClassForDesc('[' + clazz->getDescriptor()); } unsigned getNextInterfaceIndex() { return nextInterfaceIndex_++; } Index: llvm-java/lib/Compiler/Resolver.cpp diff -u llvm-java/lib/Compiler/Resolver.cpp:1.15 llvm-java/lib/Compiler/Resolver.cpp:1.16 --- llvm-java/lib/Compiler/Resolver.cpp:1.15 Fri Apr 1 21:06:35 2005 +++ llvm-java/lib/Compiler/Resolver.cpp Sat Apr 2 02:18:20 2005 @@ -125,7 +125,6 @@ { ClassMap::iterator it = classMap_.lower_bound(descriptor); if (it == classMap_.end() || it->first != descriptor) { - DEBUG(std::cerr << "Loading class: " << descriptor << '\n'); switch (descriptor[0]) { case 'B': it = insertClass(it, VMClass(this, Type::SByteTy)); @@ -172,7 +171,7 @@ it->second.link(); if (!it->second.isPrimitive() && !it->second.isInterface()) module_->addTypeName("struct." + descriptor, it->second.getLayoutType()); - DEBUG(std::cerr << "Loaded class: " << descriptor); + DEBUG(std::cerr << "Loaded class: " << it->second.getName()); DEBUG(std::cerr << " (" << it->second.getInterfaceIndex() << ")\n"); } Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.276 llvm-java/lib/Compiler/Compiler.cpp:1.277 --- llvm-java/lib/Compiler/Compiler.cpp:1.276 Fri Apr 1 21:06:35 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Sat Apr 2 02:18:20 2005 @@ -259,9 +259,6 @@ return; } - const std::string& className = - class_->getClassFile()->getThisClass()->getName()->str(); - if (method->isNative()) { DEBUG(std::cerr << "Adding stub for natively implemented method: " << function->getName() << '\n'); @@ -270,7 +267,7 @@ std::string funcName = "Java_" + - getMangledString(className) + '_' + + getMangledString(class_->getName()) + '_' + getMangledString(method->getName()); if (class_->getClassFile()->isNativeMethodOverloaded(*method->getMethod())) { // We need to add two underscores and a mangled argument signature From alkis at cs.uiuc.edu Sat Apr 2 03:14:37 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 2 Apr 2005 03:14:37 -0600 Subject: [llvm-commits] CVS: llvm-java/runtime/runtime.c Message-ID: <200504020914.DAA12492@zion.cs.uiuc.edu> Changes in directory llvm-java/runtime: runtime.c updated: 1.27 -> 1.28 --- Log message: Add the name of the class in the typeinfo struct inside the class record. --- Diffs of the changes: (+14 -4) runtime.c | 18 ++++++++++++++---- 1 files changed, 14 insertions(+), 4 deletions(-) Index: llvm-java/runtime/runtime.c diff -u llvm-java/runtime/runtime.c:1.27 llvm-java/runtime/runtime.c:1.28 --- llvm-java/runtime/runtime.c:1.27 Fri Apr 1 21:06:35 2005 +++ llvm-java/runtime/runtime.c Sat Apr 2 03:14:24 2005 @@ -4,7 +4,7 @@ struct llvm_java_object_base; struct llvm_java_object_header; -struct llvm_java_object_vtable; +struct llvm_java_object_class_record; struct llvm_java_object_typeinfo; struct llvm_java_object_header { @@ -19,7 +19,7 @@ struct llvm_java_object_typeinfo { /* The name of this class */ - const char** name; + const char* name; /* The number of super classes to java.lang.Object. */ jint depth; @@ -31,7 +31,6 @@ * index implemented by this class. */ jint interfaceIndex; - /* The interface class records this class implements. */ struct llvm_java_object_class_record** interfaces; @@ -122,6 +121,17 @@ /* The implementation of JNI functions */ +extern const struct llvm_java_object_class_record* llvm_java_class_records; + +static jclass llvm_java_find_class(JNIEnv* env, const char* name) { + const struct llvm_java_object_class_record** clazz = &llvm_java_class_records; + while (*clazz) + if (strcmp((*clazz)->typeinfo.name, name) == 0) + return (jclass) clazz; + + return NULL; +} + #define HANDLE_TYPE(TYPE) \ struct llvm_java_##TYPE##array { \ struct llvm_java_object_base object_base; \ @@ -170,7 +180,7 @@ NULL, NULL, NULL, - NULL, + &llvm_java_find_class, NULL, NULL, NULL, From alkis at cs.uiuc.edu Sat Apr 2 03:14:37 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 2 Apr 2005 03:14:37 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Resolver.h Resolver.cpp Compiler.cpp Message-ID: <200504020914.DAA12518@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Resolver.h updated: 1.13 -> 1.14 Resolver.cpp updated: 1.16 -> 1.17 Compiler.cpp updated: 1.277 -> 1.278 --- Log message: Add the name of the class in the typeinfo struct inside the class record. --- Diffs of the changes: (+28 -1) Compiler.cpp | 2 ++ Resolver.cpp | 25 +++++++++++++++++++++++++ Resolver.h | 2 +- 3 files changed, 28 insertions(+), 1 deletion(-) Index: llvm-java/lib/Compiler/Resolver.h diff -u llvm-java/lib/Compiler/Resolver.h:1.13 llvm-java/lib/Compiler/Resolver.h:1.14 --- llvm-java/lib/Compiler/Resolver.h:1.13 Sat Apr 2 02:18:20 2005 +++ llvm-java/lib/Compiler/Resolver.h Sat Apr 2 03:14:25 2005 @@ -87,7 +87,7 @@ unsigned getNextInterfaceIndex() { return nextInterfaceIndex_++; } Module* getModule() { return module_; } - + void emitClassRecordsArray() const; }; } } // namespace llvm::Java Index: llvm-java/lib/Compiler/Resolver.cpp diff -u llvm-java/lib/Compiler/Resolver.cpp:1.16 llvm-java/lib/Compiler/Resolver.cpp:1.17 --- llvm-java/lib/Compiler/Resolver.cpp:1.16 Sat Apr 2 02:18:20 2005 +++ llvm-java/lib/Compiler/Resolver.cpp Sat Apr 2 03:14:25 2005 @@ -15,6 +15,7 @@ #include "Resolver.h" #include +#include #include #include @@ -209,3 +210,27 @@ else return type; } + +void Resolver::emitClassRecordsArray() const +{ + std::vector init; + init.reserve(classMap_.size() + 1); + + for (ClassMap::const_iterator i = classMap_.begin(), e = classMap_.end(); + i != e; ++i) + init.push_back(ConstantExpr::getCast(i->second.getClassRecord(), + classRecordPtrType_)); + + // Null terminate the array. + init.push_back(llvm::Constant::getNullValue(classRecordPtrType_)); + + const ArrayType* arrayType = ArrayType::get(classRecordPtrType_, init.size()); + + new GlobalVariable( + arrayType, + true, + GlobalVariable::ExternalLinkage, + ConstantArray::get(arrayType, init), + "llvm_java_class_records", + module_); +} Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.277 llvm-java/lib/Compiler/Compiler.cpp:1.278 --- llvm-java/lib/Compiler/Compiler.cpp:1.277 Sat Apr 2 02:18:20 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Sat Apr 2 03:14:25 2005 @@ -517,6 +517,8 @@ "llvm_java_class_initializers", module_); + // Emit the array of all class records. + resolver_->emitClassRecordsArray(); return method; } From alkis at cs.uiuc.edu Sat Apr 2 03:42:10 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 2 Apr 2005 03:42:10 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMMethod.cpp Message-ID: <200504020942.DAA30756@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMMethod.cpp updated: 1.2 -> 1.3 --- Log message: Use VMClass::getName() now that it returns the real class name. --- Diffs of the changes: (+3 -4) VMMethod.cpp | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) Index: llvm-java/lib/Compiler/VMMethod.cpp diff -u llvm-java/lib/Compiler/VMMethod.cpp:1.2 llvm-java/lib/Compiler/VMMethod.cpp:1.3 --- llvm-java/lib/Compiler/VMMethod.cpp:1.2 Fri Apr 1 12:24:48 2005 +++ llvm-java/lib/Compiler/VMMethod.cpp Sat Apr 2 03:41:59 2005 @@ -25,13 +25,12 @@ { const std::string& methodName = method_->getName()->str(); const std::string& methodDescriptor = method_->getDescriptor()->str(); + const std::string& functionName = + parent_->getName() + '/' + methodName + methodDescriptor; + Resolver* resolver = parent_->getResolver(); const FunctionType* functionType = cast( resolver->getType(methodDescriptor, !method_->isStatic())); - const std::string& className = - parent_->getClassFile()->getThisClass()->getName()->str(); - const std::string& functionName = - className + '/' + methodName + methodDescriptor; Module* module = resolver->getModule(); function_ = module->getOrInsertFunction(functionName, functionType); } From duraid at octopus.com.au Sat Apr 2 04:06:38 2005 From: duraid at octopus.com.au (Duraid Madina) Date: Sat, 2 Apr 2005 04:06:38 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/IA64/IA64InstrInfo.td Message-ID: <200504021006.EAA05201@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/IA64: IA64InstrInfo.td updated: 1.3 -> 1.4 --- Log message: add fnegabs op --- Diffs of the changes: (+2 -0) IA64InstrInfo.td | 2 ++ 1 files changed, 2 insertions(+) Index: llvm/lib/Target/IA64/IA64InstrInfo.td diff -u llvm/lib/Target/IA64/IA64InstrInfo.td:1.3 llvm/lib/Target/IA64/IA64InstrInfo.td:1.4 --- llvm/lib/Target/IA64/IA64InstrInfo.td:1.3 Fri Apr 1 23:18:38 2005 +++ llvm/lib/Target/IA64/IA64InstrInfo.td Sat Apr 2 04:06:27 2005 @@ -231,6 +231,8 @@ "fabs $dst = $src;;">; def FNEG : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src), "fneg $dst = $src;;">; +def FNEGABS : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src), + "fnegabs $dst = $src;;">; def CFMAS1 : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3, PR:$qp), From duraid at octopus.com.au Sat Apr 2 04:34:04 2005 From: duraid at octopus.com.au (Duraid Madina) Date: Sat, 2 Apr 2005 04:34:04 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/IA64/IA64ISelPattern.cpp Message-ID: <200504021034.EAA12646@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/IA64: IA64ISelPattern.cpp updated: 1.9 -> 1.10 --- Log message: support IDEF, fnegabs (thanks sampo) --- Diffs of the changes: (+14 -2) IA64ISelPattern.cpp | 16 ++++++++++++++-- 1 files changed, 14 insertions(+), 2 deletions(-) Index: llvm/lib/Target/IA64/IA64ISelPattern.cpp diff -u llvm/lib/Target/IA64/IA64ISelPattern.cpp:1.9 llvm/lib/Target/IA64/IA64ISelPattern.cpp:1.10 --- llvm/lib/Target/IA64/IA64ISelPattern.cpp:1.9 Fri Apr 1 23:18:38 2005 +++ llvm/lib/Target/IA64/IA64ISelPattern.cpp Sat Apr 2 04:33:53 2005 @@ -609,6 +609,11 @@ return Result; } + + case ISD::UNDEF: { + BuildMI(BB, IA64::IDEF, 0, Result); + return Result; + } case ISD::GlobalAddress: { GlobalValue *GV = cast(N)->getGlobal(); @@ -799,9 +804,16 @@ } case ISD::FNEG: { - Tmp1 = SelectExpr(N.getOperand(0)); assert(DestType == MVT::f64 && "trying to fneg something other than f64?"); - BuildMI(BB, IA64::FNEG, 1, Result).addReg(Tmp1); + + if (ISD::FABS == N.getOperand(0).getOpcode()) { // && hasOneUse()? + Tmp1 = SelectExpr(N.getOperand(0).getOperand(0)); + BuildMI(BB, IA64::FNEGABS, 1, Result).addReg(Tmp1); // fold in abs + } else { + Tmp1 = SelectExpr(N.getOperand(0)); + BuildMI(BB, IA64::FNEG, 1, Result).addReg(Tmp1); // plain old fneg + } + return Result; } From duraid at octopus.com.au Sat Apr 2 06:22:02 2005 From: duraid at octopus.com.au (Duraid Madina) Date: Sat, 2 Apr 2005 06:22:02 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/AsmPrinter.h Message-ID: <200504021222.GAA01212@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: AsmPrinter.h updated: 1.10 -> 1.11 --- Log message: add support for prefix/suffix strings to go around GlobalValue(s) (which may or be function pointers) in the asmprinter. For the moment, this changes nothing, except the IA64 backend which can use this to write: data8.ua @fptr(blah__blah__mangled_function_name) (by setting FunctionAddrPrefix/Suffix to "@fptr(" / ")") --- Diffs of the changes: (+19 -0) AsmPrinter.h | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+) Index: llvm/include/llvm/CodeGen/AsmPrinter.h diff -u llvm/include/llvm/CodeGen/AsmPrinter.h:1.10 llvm/include/llvm/CodeGen/AsmPrinter.h:1.11 --- llvm/include/llvm/CodeGen/AsmPrinter.h:1.10 Sat Jan 8 13:57:49 2005 +++ llvm/include/llvm/CodeGen/AsmPrinter.h Sat Apr 2 06:21:51 2005 @@ -54,6 +54,21 @@ /// onto all global symbols. This is often used for "_" or ".". const char *GlobalPrefix; // Defaults to "" + /// GlobalVarAddrPrefix/Suffix - If these are nonempty, these strings + /// will enclose any GlobalVariable (that isn't a function) + /// + const char *GlobalVarAddrPrefix; // Defaults to "" + const char *GlobalVarAddrSuffix; // Defaults to "" + + /// FunctionAddrPrefix/Suffix - If these are nonempty, these strings + /// will enclose any GlobalVariable that points to a function. + /// For example, this is used by the IA64 backend to materialize + /// function descriptors, by decorating the ".data8" object with the + /// @fptr( ) link-relocation operator. + /// + const char *FunctionAddrPrefix; // Defaults to "" + const char *FunctionAddrSuffix; // Defaults to "" + /// ZeroDirective - this should be set to the directive used to get some /// number of zero bytes emitted to the current section. Common cases are /// "\t.zero\t" and "\t.space\t". If this is set to null, the @@ -87,6 +102,10 @@ : O(o), TM(tm), CommentString("#"), GlobalPrefix(""), + GlobalVarAddrPrefix(""), + GlobalVarAddrSuffix(""), + FunctionAddrPrefix(""), + FunctionAddrSuffix(""), ZeroDirective("\t.zero\t"), AsciiDirective("\t.ascii\t"), Data8bitsDirective("\t.byte\t"), From duraid at octopus.com.au Sat Apr 2 06:22:02 2005 From: duraid at octopus.com.au (Duraid Madina) Date: Sat, 2 Apr 2005 06:22:02 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/AsmPrinter.cpp Message-ID: <200504021222.GAA01210@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: AsmPrinter.cpp updated: 1.15 -> 1.16 --- Log message: add support for prefix/suffix strings to go around GlobalValue(s) (which may or be function pointers) in the asmprinter. For the moment, this changes nothing, except the IA64 backend which can use this to write: data8.ua @fptr(blah__blah__mangled_function_name) (by setting FunctionAddrPrefix/Suffix to "@fptr(" / ")") --- Diffs of the changes: (+10 -5) AsmPrinter.cpp | 15 ++++++++++----- 1 files changed, 10 insertions(+), 5 deletions(-) Index: llvm/lib/CodeGen/AsmPrinter.cpp diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.15 llvm/lib/CodeGen/AsmPrinter.cpp:1.16 --- llvm/lib/CodeGen/AsmPrinter.cpp:1.15 Mon Feb 14 15:40:26 2005 +++ llvm/lib/CodeGen/AsmPrinter.cpp Sat Apr 2 06:21:50 2005 @@ -67,11 +67,16 @@ O << (unsigned long long)CI->getValue(); else if (const ConstantUInt *CI = dyn_cast(CV)) O << CI->getValue(); - else if (isa((Value*)CV)) - // This is a constant address for a global variable or function. Use the - // name of the variable or function as the address value. - O << Mang->getValueName(CV); - else if (const ConstantExpr *CE = dyn_cast(CV)) { + else if (isa((Value*)CV)) { + // This is a constant address for a global variable or function. Use the + // name of the variable or function as the address value, possibly + // decorating it with GlobalVarAddrPrefix/Suffix or + // FunctionAddrPrefix/Suffix (these all default to "" ) + if (isa((Value*)CV)) + O << FunctionAddrPrefix << Mang->getValueName(CV) << FunctionAddrSuffix; + else + O << GlobalVarAddrPrefix << Mang->getValueName(CV) << GlobalVarAddrSuffix; + } else if (const ConstantExpr *CE = dyn_cast(CV)) { const TargetData &TD = TM.getTargetData(); switch(CE->getOpcode()) { case Instruction::GetElementPtr: { From duraid at octopus.com.au Sat Apr 2 06:30:58 2005 From: duraid at octopus.com.au (Duraid Madina) Date: Sat, 2 Apr 2005 06:30:58 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/IA64/IA64AsmPrinter.cpp Message-ID: <200504021230.GAA02735@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/IA64: IA64AsmPrinter.cpp updated: 1.5 -> 1.6 --- Log message: ia64 asmprinter fixes: - turn off assembler's autoalignment - set FunctionAddrPrefix/Suffix so that .data8 entries pointing to functions have their value wrapped in @fptr(), so that a function descriptor will be materialized for that function. --- Diffs of the changes: (+11 -7) IA64AsmPrinter.cpp | 18 +++++++++++------- 1 files changed, 11 insertions(+), 7 deletions(-) Index: llvm/lib/Target/IA64/IA64AsmPrinter.cpp diff -u llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.5 llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.6 --- llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.5 Thu Mar 31 01:40:24 2005 +++ llvm/lib/Target/IA64/IA64AsmPrinter.cpp Sat Apr 2 06:30:47 2005 @@ -142,9 +142,8 @@ // FALL THROUGH case GlobalValue::InternalLinkage: if (C->isNullValue()) - SwitchSection(O, CurSection, ".data"); // FIXME: this was - // '.bss', but in ia64-land .bss means "nobits" (i.e. uninitialized) - // hmm. + SwitchSection(O, CurSection, ".bss"); + // FIXME? in ia64-land .bss means "nobits" (i.e. uninitialized) else SwitchSection(O, CurSection, ".data"); break; @@ -191,13 +190,18 @@ : IA64SharedAsmPrinter(O, TM) { CommentString = "//"; - Data8bitsDirective = "\tdata1\t"; - Data16bitsDirective = "\tdata2\t"; - Data32bitsDirective = "\tdata4\t"; - Data64bitsDirective = "\tdata8\t"; + Data8bitsDirective = "\tdata1\t"; // FIXME: check that we are + Data16bitsDirective = "\tdata2.ua\t"; // disabling auto-alignment + Data32bitsDirective = "\tdata4.ua\t"; // properly + Data64bitsDirective = "\tdata8.ua\t"; ZeroDirective = "\t.skip\t"; AsciiDirective = "\tstring\t"; + GlobalVarAddrPrefix=""; + GlobalVarAddrSuffix=""; + FunctionAddrPrefix="@fptr("; + FunctionAddrSuffix=")"; + } virtual const char *getPassName() const { From lattner at cs.uiuc.edu Sat Apr 2 10:18:13 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 2 Apr 2005 10:18:13 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/CodeGen/X86/shift-double.llx Message-ID: <200504021618.j32GIDAg005358@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/CodeGen/X86: shift-double.llx updated: 1.3 -> 1.4 --- Log message: this has now been fixed --- Diffs of the changes: (+0 -4) shift-double.llx | 4 ---- 1 files changed, 4 deletions(-) Index: llvm/test/Regression/CodeGen/X86/shift-double.llx diff -u llvm/test/Regression/CodeGen/X86/shift-double.llx:1.3 llvm/test/Regression/CodeGen/X86/shift-double.llx:1.4 --- llvm/test/Regression/CodeGen/X86/shift-double.llx:1.3 Wed Jan 26 01:09:44 2005 +++ llvm/test/Regression/CodeGen/X86/shift-double.llx Sat Apr 2 10:17:57 2005 @@ -1,9 +1,5 @@ ; RUN: llvm-as < %s | llc -march=x86 -x86-asm-syntax=intel -disable-pattern-isel=0 | grep sh[lr]d | wc -l | grep 5 -; This is currently xfailed, because the expander for long shifts needed to -; change and the X86 BE was not updated to match. FIXME. -; XFAIL: * - long %test1(long %X, ubyte %C) { %Y = shl long %X, ubyte %C ret long %Y From alkis at cs.uiuc.edu Sat Apr 2 12:56:08 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 2 Apr 2005 12:56:08 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Resolver.cpp Message-ID: <200504021856.MAA07458@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Resolver.cpp updated: 1.17 -> 1.18 --- Log message: Rename llvm_java_object_typeinfo to llvm_java_typeinfo and llvm_java_object_class_record to llvm_java_class_record. --- Diffs of the changes: (+2 -3) Resolver.cpp | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) Index: llvm-java/lib/Compiler/Resolver.cpp diff -u llvm-java/lib/Compiler/Resolver.cpp:1.17 llvm-java/lib/Compiler/Resolver.cpp:1.18 --- llvm-java/lib/Compiler/Resolver.cpp:1.17 Sat Apr 2 03:14:25 2005 +++ llvm-java/lib/Compiler/Resolver.cpp Sat Apr 2 12:55:56 2005 @@ -60,7 +60,7 @@ elements.push_back(Type::IntTy); typeInfoType_ = StructType::get(elements); - module_->addTypeName("struct.llvm_java_object_typeinfo", getTypeInfoType()); + module_->addTypeName("struct.llvm_java_typeinfo", getTypeInfoType()); // Compute the class_record type. PATypeHolder holder = classRecordType_; @@ -68,8 +68,7 @@ StructType::get(std::vector(1, getTypeInfoType()))); classRecordType_ = holder.get(); - module_->addTypeName("struct.llvm_java_object_class_record", - getClassRecordType()); + module_->addTypeName("struct.llvm_java_class_record", getClassRecordType()); classRecordPtrType_ = PointerType::get(classRecordType_); } From alkis at cs.uiuc.edu Sat Apr 2 12:56:08 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 2 Apr 2005 12:56:08 -0600 Subject: [llvm-commits] CVS: llvm-java/runtime/runtime.c Message-ID: <200504021856.MAA07456@zion.cs.uiuc.edu> Changes in directory llvm-java/runtime: runtime.c updated: 1.28 -> 1.29 --- Log message: Rename llvm_java_object_typeinfo to llvm_java_typeinfo and llvm_java_object_class_record to llvm_java_class_record. --- Diffs of the changes: (+19 -19) runtime.c | 38 +++++++++++++++++++------------------- 1 files changed, 19 insertions(+), 19 deletions(-) Index: llvm-java/runtime/runtime.c diff -u llvm-java/runtime/runtime.c:1.28 llvm-java/runtime/runtime.c:1.29 --- llvm-java/runtime/runtime.c:1.28 Sat Apr 2 03:14:24 2005 +++ llvm-java/runtime/runtime.c Sat Apr 2 12:55:56 2005 @@ -4,8 +4,8 @@ struct llvm_java_object_base; struct llvm_java_object_header; -struct llvm_java_object_class_record; -struct llvm_java_object_typeinfo; +struct llvm_java_class_record; +struct llvm_java_typeinfo; struct llvm_java_object_header { /* gc info, hash info, locking */ @@ -14,10 +14,10 @@ struct llvm_java_object_base { struct llvm_java_object_header header; - struct llvm_java_object_class_record* classRecord; + struct llvm_java_class_record* classRecord; }; -struct llvm_java_object_typeinfo { +struct llvm_java_typeinfo { /* The name of this class */ const char* name; @@ -25,54 +25,54 @@ jint depth; /* The super class records up to java.lang.Object. */ - struct llvm_java_object_class_record** superclasses; + struct llvm_java_class_record** superclasses; /* If an interface its interface index, otherwise the last interface * index implemented by this class. */ jint interfaceIndex; /* The interface class records this class implements. */ - struct llvm_java_object_class_record** interfaces; + struct llvm_java_class_record** interfaces; /* The component class record if this is an array class, null * otherwise. */ - struct llvm_java_object_class_record* component; + struct llvm_java_class_record* component; /* If an array the size of its elements, otherwise 0 for classes, -1 * for interfaces and -2 for primitive classes. */ jint elementSize; }; -struct llvm_java_object_class_record { - struct llvm_java_object_typeinfo typeinfo; +struct llvm_java_class_record { + struct llvm_java_typeinfo typeinfo; }; -jint llvm_java_is_primitive_class(struct llvm_java_object_class_record* cr) +jint llvm_java_is_primitive_class(struct llvm_java_class_record* cr) { return cr->typeinfo.elementSize == -2; } -jint llvm_java_is_interface_class(struct llvm_java_object_class_record* cr) +jint llvm_java_is_interface_class(struct llvm_java_class_record* cr) { return cr->typeinfo.elementSize == -1; } -jint llvm_java_is_array_class(struct llvm_java_object_class_record* cr) +jint llvm_java_is_array_class(struct llvm_java_class_record* cr) { return cr->typeinfo.elementSize > 0; } -struct llvm_java_object_class_record* llvm_java_get_class_record(jobject obj) { +struct llvm_java_class_record* llvm_java_get_class_record(jobject obj) { return obj->classRecord; } void llvm_java_set_class_record(jobject obj, - struct llvm_java_object_class_record* cr) { + struct llvm_java_class_record* cr) { obj->classRecord = cr; } -jint llvm_java_is_assignable_from(struct llvm_java_object_class_record* cr, - struct llvm_java_object_class_record* from) { +jint llvm_java_is_assignable_from(struct llvm_java_class_record* cr, + struct llvm_java_class_record* from) { /* trivial case: class records are the same */ if (cr == from) return JNI_TRUE; @@ -107,7 +107,7 @@ } jint llvm_java_is_instance_of(jobject obj, - struct llvm_java_object_class_record* cr) { + struct llvm_java_class_record* cr) { /* trivial case: a null object can be cast to any type */ if (!obj) return JNI_TRUE; @@ -121,10 +121,10 @@ /* The implementation of JNI functions */ -extern const struct llvm_java_object_class_record* llvm_java_class_records; +extern const struct llvm_java_class_record* llvm_java_class_records; static jclass llvm_java_find_class(JNIEnv* env, const char* name) { - const struct llvm_java_object_class_record** clazz = &llvm_java_class_records; + const struct llvm_java_class_record** clazz = &llvm_java_class_records; while (*clazz) if (strcmp((*clazz)->typeinfo.name, name) == 0) return (jclass) clazz; From alenhar2 at cs.uiuc.edu Sat Apr 2 13:05:15 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Sat, 2 Apr 2005 13:05:15 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp Message-ID: <200504021905.NAA32516@niobe.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.73 -> 1.74 --- Log message: FNEG/FABS --- Diffs of the changes: (+17 -4) AlphaISelPattern.cpp | 21 +++++++++++++++++---- 1 files changed, 17 insertions(+), 4 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.73 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.74 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.73 Fri Apr 1 23:03:19 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Sat Apr 2 13:04:58 2005 @@ -75,10 +75,6 @@ setOperationAction(ISD::MEMSET , MVT::Other, Expand); setOperationAction(ISD::MEMCPY , MVT::Other, Expand); - // We don't support these yet. - setOperationAction(ISD::FNEG , MVT::f64 , Expand); - setOperationAction(ISD::FABS , MVT::f64 , Expand); - //Doesn't work yet setOperationAction(ISD::SETCC , MVT::f32, Promote); @@ -541,6 +537,23 @@ Node->dump(); assert(0 && "Node not handled!\n"); + case ISD::FNEG: + if(ISD::FABS == N.getOperand(0).getOpcode()) + { + Tmp1 = SelectExpr(N.getOperand(0).getOperand(0)); + BuildMI(BB, Alpha::CPYSN, 2, Result).addReg(Tmp1).addReg(Tmp1); + } else { + Tmp1 = SelectExpr(N.getOperand(0)); + Opc = DestType == MVT::f64 ? Alpha::SUBT : Alpha::SUBS ; + BuildMI(BB, Opc, 2, Result).addReg(Alpha::F31).addReg(Tmp1); + } + return Result; + + case ISD::FABS: + Tmp1 = SelectExpr(N.getOperand(0)); + BuildMI(BB, Alpha::CPYS, 2, Result).addReg(Alpha::F31).addReg(Tmp1); + return Result; + case ISD::SELECT: { //Tmp1 = SelectExpr(N.getOperand(0)); //Cond From alenhar2 at cs.uiuc.edu Sat Apr 2 13:11:21 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Sat, 2 Apr 2005 13:11:21 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp Message-ID: <200504021911.NAA32561@niobe.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.74 -> 1.75 --- Log message: FNEG/FABS/UNDEF --- Diffs of the changes: (+13 -3) AlphaISelPattern.cpp | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.74 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.75 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.74 Sat Apr 2 13:04:58 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Sat Apr 2 13:11:07 2005 @@ -537,15 +537,19 @@ Node->dump(); assert(0 && "Node not handled!\n"); + case ISD::UNDEF: { + BuildMI(BB, Alpha::IDEF, 0, Result); + return Result; + } + case ISD::FNEG: if(ISD::FABS == N.getOperand(0).getOpcode()) { Tmp1 = SelectExpr(N.getOperand(0).getOperand(0)); - BuildMI(BB, Alpha::CPYSN, 2, Result).addReg(Tmp1).addReg(Tmp1); + BuildMI(BB, Alpha::CPYSN, 2, Result).addReg(Alpha::F31).addReg(Tmp1); } else { Tmp1 = SelectExpr(N.getOperand(0)); - Opc = DestType == MVT::f64 ? Alpha::SUBT : Alpha::SUBS ; - BuildMI(BB, Opc, 2, Result).addReg(Alpha::F31).addReg(Tmp1); + BuildMI(BB, Alpha::CPYSN, 2, Result).addReg(Tmp1).addReg(Tmp1); } return Result; @@ -850,6 +854,12 @@ Node->dump(); assert(0 && "Node not handled!\n"); + + case ISD::UNDEF: { + BuildMI(BB, Alpha::IDEF, 0, Result); + return Result; + } + case ISD::DYNAMIC_STACKALLOC: // Generate both result values. if (Result != notIn) From lattner at cs.uiuc.edu Sat Apr 2 13:15:32 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 2 Apr 2005 13:15:32 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/DataStructure/DataStructure.h EquivClassGraphs.h Message-ID: <200504021915.j32JFWvB011145@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis/DataStructure: DataStructure.h updated: 1.89 -> 1.90 EquivClassGraphs.h updated: 1.19 -> 1.20 --- Log message: Change the ActualCallees callgraph from hash_multimap to std::set> to avoid duplicate entries. --- Diffs of the changes: (+24 -6) DataStructure.h | 17 +++++++++++++---- EquivClassGraphs.h | 13 +++++++++++-- 2 files changed, 24 insertions(+), 6 deletions(-) Index: llvm/include/llvm/Analysis/DataStructure/DataStructure.h diff -u llvm/include/llvm/Analysis/DataStructure/DataStructure.h:1.89 llvm/include/llvm/Analysis/DataStructure/DataStructure.h:1.90 --- llvm/include/llvm/Analysis/DataStructure/DataStructure.h:1.89 Wed Mar 23 15:59:31 2005 +++ llvm/include/llvm/Analysis/DataStructure/DataStructure.h Sat Apr 2 13:15:15 2005 @@ -102,7 +102,7 @@ // DSInfo, one graph for each function hash_map DSInfo; DSGraph *GlobalsGraph; - hash_multimap ActualCallees; + std::set > ActualCallees; // This map is only maintained during construction of BU Graphs std::map, @@ -152,11 +152,20 @@ AU.addRequired(); } - typedef hash_multimap ActualCalleesTy; + typedef std::set > ActualCalleesTy; const ActualCalleesTy &getActualCallees() const { return ActualCallees; } + ActualCalleesTy::iterator callee_begin(Instruction *I) const { + return ActualCallees.lower_bound(std::pair(I, 0)); + } + + ActualCalleesTy::iterator callee_end(Instruction *I) const { + I = (Instruction*)((char*)I + 1); + return ActualCallees.lower_bound(std::pair(I, 0)); + } + private: void calculateGraph(DSGraph &G); @@ -177,6 +186,7 @@ hash_map DSInfo; hash_set ArgsRemainIncomplete; DSGraph *GlobalsGraph; + BUDataStructures *BUInfo; /// GlobalECs - The equivalence classes for each global value that is merged /// with other global values in the DSGraphs. @@ -257,8 +267,7 @@ void InlineCallersIntoGraph(DSGraph &G); DSGraph &getOrCreateDSGraph(Function &F); void ComputePostOrder(Function &F, hash_set &Visited, - std::vector &PostOrder, - const BUDataStructures::ActualCalleesTy &ActualCallees); + std::vector &PostOrder); }; Index: llvm/include/llvm/Analysis/DataStructure/EquivClassGraphs.h diff -u llvm/include/llvm/Analysis/DataStructure/EquivClassGraphs.h:1.19 llvm/include/llvm/Analysis/DataStructure/EquivClassGraphs.h:1.20 --- llvm/include/llvm/Analysis/DataStructure/EquivClassGraphs.h:1.19 Sat Mar 19 16:12:33 2005 +++ llvm/include/llvm/Analysis/DataStructure/EquivClassGraphs.h Sat Apr 2 13:15:15 2005 @@ -39,7 +39,7 @@ /// ActualCallees - The actual functions callable from indirect call sites. /// - hash_multimap ActualCallees; + std::set > ActualCallees; // Equivalence class where functions that can potentially be called via the // same function pointer are in the same class. @@ -96,10 +96,19 @@ return *GlobalsGraph; } - typedef hash_multimap ActualCalleesTy; + typedef std::set > ActualCalleesTy; const ActualCalleesTy &getActualCallees() const { return ActualCallees; } + + ActualCalleesTy::iterator callee_begin(Instruction *I) const { + return ActualCallees.lower_bound(std::pair(I, 0)); + } + + ActualCalleesTy::iterator callee_end(Instruction *I) const { + I = (Instruction*)((char*)I + 1); + return ActualCallees.lower_bound(std::pair(I, 0)); + } virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); From lattner at cs.uiuc.edu Sat Apr 2 13:17:31 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 2 Apr 2005 13:17:31 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp DataStructure.cpp EquivClassGraphs.cpp Steensgaard.cpp TopDownClosure.cpp Message-ID: <200504021917.j32JHVg9011166@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: CompleteBottomUp.cpp updated: 1.29 -> 1.30 DataStructure.cpp updated: 1.236 -> 1.237 EquivClassGraphs.cpp updated: 1.40 -> 1.41 Steensgaard.cpp updated: 1.59 -> 1.60 TopDownClosure.cpp updated: 1.85 -> 1.86 --- Log message: Change the ActualCallees callgraph from hash_multimap to std::set> to avoid duplicate entries. This speeds up the CompleteBU pass from 1.99s to .15s on povray and the eqgraph passes from 1.5s to .16s on the same. --- Diffs of the changes: (+41 -79) CompleteBottomUp.cpp | 45 ++++++++-------------------------------- DataStructure.cpp | 2 - EquivClassGraphs.cpp | 8 +++---- Steensgaard.cpp | 8 ++----- TopDownClosure.cpp | 57 +++++++++++++++++++++------------------------------ 5 files changed, 41 insertions(+), 79 deletions(-) Index: llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp diff -u llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp:1.29 llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp:1.30 --- llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp:1.29 Thu Mar 24 12:42:51 2005 +++ llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp Sat Apr 2 13:17:17 2005 @@ -13,6 +13,7 @@ // //===----------------------------------------------------------------------===// +#define DEBUG_TYPE "cbudatastructure" #include "llvm/Analysis/DataStructure/DataStructure.h" #include "llvm/Module.h" #include "llvm/Analysis/DataStructure/DSGraph.h" @@ -37,39 +38,8 @@ GlobalsGraph = new DSGraph(BU.getGlobalsGraph(), GlobalECs); GlobalsGraph->setPrintAuxCalls(); -#if 1 // REMOVE ME EVENTUALLY - // FIXME: TEMPORARY (remove once finalization of indirect call sites in the - // globals graph has been implemented in the BU pass) - TDDataStructures &TD = getAnalysis(); - - ActualCallees.clear(); - - // The call graph extractable from the TD pass is _much more complete_ and - // trustable than that generated by the BU pass so far. Until this is fixed, - // we hack it like this: - for (Module::iterator MI = M.begin(), ME = M.end(); MI != ME; ++MI) { - if (MI->isExternal()) continue; - const std::list &CSs = TD.getDSGraph(*MI).getFunctionCalls(); - - for (std::list::const_iterator CSI = CSs.begin(), E = CSs.end(); - CSI != E; ++CSI) { - Instruction *TheCall = CSI->getCallSite().getInstruction(); - - if (CSI->isIndirectCall()) { // indirect call: insert all callees - std::vector Callees; - CSI->getCalleeNode()->addFullFunctionList(Callees); - for (unsigned i = 0, e = Callees.size(); i != e; ++i) - ActualCallees.insert(std::make_pair(TheCall, Callees[i])); - } else { // direct call: insert the single callee directly - ActualCallees.insert(std::make_pair(TheCall, - CSI->getCalleeFunc())); - } - } - } -#else // Our call graph is the same as the BU data structures call graph ActualCallees = BU.getActualCallees(); -#endif std::vector Stack; hash_map ValMap; @@ -150,8 +120,9 @@ Instruction *Call = CI->getCallSite().getInstruction(); // Loop over all of the actually called functions... - ActualCalleesTy::iterator I, E; - for (tie(I, E) = ActualCallees.equal_range(Call); I != E; ++I) + ActualCalleesTy::iterator I = callee_begin(Call), E = callee_end(Call); + for (; I != E && I->first == Call; ++I) { + assert(I->first == Call && "Bad callee construction!"); if (!I->second->isExternal()) { DSGraph &Callee = getOrCreateGraph(*I->second); unsigned M; @@ -163,6 +134,7 @@ M = It->second; if (M < Min) Min = M; } + } } assert(ValMap[&FG] == MyID && "SCC construction assumption wrong!"); @@ -225,10 +197,11 @@ // Inline direct calls as well as indirect calls because the direct // callee may have indirect callees and so may have changed. // - ActualCalleesTy::iterator I, E; - tie(I, E) = ActualCallees.equal_range(TheCall); - unsigned TNum = 0, Num = std::distance(I, E); + ActualCalleesTy::iterator I = callee_begin(TheCall),E = callee_end(TheCall); + unsigned TNum = 0, Num = 0; + DEBUG(Num = std::distance(I, E)); for (; I != E; ++I, ++TNum) { + assert(I->first == TheCall && "Bad callee construction!"); Function *CalleeFunc = I->second; if (!CalleeFunc->isExternal()) { // Merge the callee's graph into this graph. This works for normal Index: llvm/lib/Analysis/DataStructure/DataStructure.cpp diff -u llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.236 llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.237 --- llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.236 Tue Mar 29 13:16:59 2005 +++ llvm/lib/Analysis/DataStructure/DataStructure.cpp Sat Apr 2 13:17:17 2005 @@ -2055,7 +2055,7 @@ GlobalNodes.push_back(std::make_pair(I->first, I->second.getNode())); // Make sure that all globals are cloned over as roots. - if (!(Flags & DSGraph::RemoveUnreachableGlobals)) { + if (!(Flags & DSGraph::RemoveUnreachableGlobals) && GlobalsGraph) { DSGraph::ScalarMapTy::iterator SMI = GlobalsGraph->getScalarMap().find(I->first); if (SMI != GlobalsGraph->getScalarMap().end()) Index: llvm/lib/Analysis/DataStructure/EquivClassGraphs.cpp diff -u llvm/lib/Analysis/DataStructure/EquivClassGraphs.cpp:1.40 llvm/lib/Analysis/DataStructure/EquivClassGraphs.cpp:1.41 --- llvm/lib/Analysis/DataStructure/EquivClassGraphs.cpp:1.40 Thu Mar 24 12:42:51 2005 +++ llvm/lib/Analysis/DataStructure/EquivClassGraphs.cpp Sat Apr 2 13:17:17 2005 @@ -339,8 +339,8 @@ Instruction *Call = CI->getCallSite().getInstruction(); // Loop over all of the actually called functions... - ActualCalleesTy::const_iterator I, E; - for (tie(I, E) = getActualCallees().equal_range(Call); I != E; ++I) + ActualCalleesTy::const_iterator I = callee_begin(Call),E = callee_end(Call); + for (; I != E; ++I) if (!I->second->isExternal()) { // Process the callee as necessary. unsigned M = processSCC(getOrCreateGraph(*I->second), @@ -414,8 +414,8 @@ // graph so we only need to do this once. // DSGraph* CalleeGraph = NULL; - ActualCalleesTy::const_iterator I, E; - tie(I, E) = getActualCallees().equal_range(TheCall); + ActualCalleesTy::const_iterator I = callee_begin(TheCall); + ActualCalleesTy::const_iterator E = callee_end(TheCall); unsigned TNum, Num; // Loop over all potential callees to find the first non-external callee. Index: llvm/lib/Analysis/DataStructure/Steensgaard.cpp diff -u llvm/lib/Analysis/DataStructure/Steensgaard.cpp:1.59 llvm/lib/Analysis/DataStructure/Steensgaard.cpp:1.60 --- llvm/lib/Analysis/DataStructure/Steensgaard.cpp:1.59 Tue Mar 29 13:16:59 2005 +++ llvm/lib/Analysis/DataStructure/Steensgaard.cpp Sat Apr 2 13:17:18 2005 @@ -25,11 +25,10 @@ namespace { class Steens : public ModulePass, public AliasAnalysis { DSGraph *ResultGraph; - DSGraph *GlobalsGraph; // FIXME: Eliminate globals graph stuff from DNE EquivalenceClasses GlobalECs; // Always empty public: - Steens() : ResultGraph(0), GlobalsGraph(0) {} + Steens() : ResultGraph(0) {} ~Steens() { releaseMyMemory(); assert(ResultGraph == 0 && "releaseMemory not called?"); @@ -116,8 +115,7 @@ // Create a new, empty, graph... ResultGraph = new DSGraph(GlobalECs, getTargetData()); - GlobalsGraph = new DSGraph(GlobalECs, getTargetData()); - ResultGraph->setGlobalsGraph(GlobalsGraph); + ResultGraph->spliceFrom(LDS.getGlobalsGraph()); // Loop over the rest of the module, merging graphs for non-external functions // into this graph. @@ -186,7 +184,7 @@ // Remove any nodes that are dead after all of the merging we have done... // FIXME: We should be able to disable the globals graph for steens! - ResultGraph->removeDeadNodes(DSGraph::KeepUnreachableGlobals); + //ResultGraph->removeDeadNodes(DSGraph::KeepUnreachableGlobals); DEBUG(print(std::cerr, &M)); return false; Index: llvm/lib/Analysis/DataStructure/TopDownClosure.cpp diff -u llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.85 llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.86 --- llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.85 Wed Mar 23 22:22:04 2005 +++ llvm/lib/Analysis/DataStructure/TopDownClosure.cpp Sat Apr 2 13:17:18 2005 @@ -58,9 +58,9 @@ // program. // bool TDDataStructures::runOnModule(Module &M) { - BUDataStructures &BU = getAnalysis(); - GlobalECs = BU.getGlobalECs(); - GlobalsGraph = new DSGraph(BU.getGlobalsGraph(), GlobalECs); + BUInfo = &getAnalysis(); + GlobalECs = BUInfo->getGlobalECs(); + GlobalsGraph = new DSGraph(BUInfo->getGlobalsGraph(), GlobalECs); GlobalsGraph->setPrintAuxCalls(); // Figure out which functions must not mark their arguments complete because @@ -95,8 +95,6 @@ // calculate a post-order traversal, then reverse it. hash_set VisitedGraph; std::vector PostOrder; - const BUDataStructures::ActualCalleesTy &ActualCallees = - getAnalysis().getActualCallees(); #if 0 {TIME_REGION(XXX, "td:Copy graphs"); @@ -114,11 +112,11 @@ // Calculate top-down from main... if (Function *F = M.getMainFunction()) - ComputePostOrder(*F, VisitedGraph, PostOrder, ActualCallees); + ComputePostOrder(*F, VisitedGraph, PostOrder); // Next calculate the graphs for each unreachable function... for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) - ComputePostOrder(*I, VisitedGraph, PostOrder, ActualCallees); + ComputePostOrder(*I, VisitedGraph, PostOrder); VisitedGraph.clear(); // Release memory! } @@ -167,8 +165,7 @@ void TDDataStructures::ComputePostOrder(Function &F,hash_set &Visited, - std::vector &PostOrder, - const BUDataStructures::ActualCalleesTy &ActualCallees) { + std::vector &PostOrder) { if (F.isExternal()) return; DSGraph &G = getOrCreateDSGraph(F); if (Visited.count(&G)) return; @@ -177,13 +174,11 @@ // Recursively traverse all of the callee graphs. for (DSGraph::fc_iterator CI = G.fc_begin(), E = G.fc_end(); CI != E; ++CI) { Instruction *CallI = CI->getCallSite().getInstruction(); - std::pair - IP = ActualCallees.equal_range(CallI); - - for (BUDataStructures::ActualCalleesTy::const_iterator I = IP.first; - I != IP.second; ++I) - ComputePostOrder(*I->second, Visited, PostOrder, ActualCallees); + BUDataStructures::ActualCalleesTy::const_iterator I = + BUInfo->callee_begin(CallI), E = BUInfo->callee_end(CallI); + + for (; I != E; ++I) + ComputePostOrder(*I->second, Visited, PostOrder); } PostOrder.push_back(&G); @@ -315,9 +310,6 @@ // callee graphs. if (DSG.fc_begin() == DSG.fc_end()) return; - const BUDataStructures::ActualCalleesTy &ActualCallees = - getAnalysis().getActualCallees(); - // Loop over all the call sites and all the callees at each call site, and add // edges to the CallerEdges structure for each callee. for (DSGraph::fc_iterator CI = DSG.fc_begin(), E = DSG.fc_end(); @@ -334,27 +326,26 @@ Instruction *CallI = CI->getCallSite().getInstruction(); // For each function in the invoked function list at this call site... - std::pair - IP = ActualCallees.equal_range(CallI); + BUDataStructures::ActualCalleesTy::const_iterator IPI = + BUInfo->callee_begin(CallI), IPE = BUInfo->callee_end(CallI); // Skip over all calls to this graph (SCC calls). - while (IP.first != IP.second && &getDSGraph(*IP.first->second) == &DSG) - ++IP.first; + while (IPI != IPE && &getDSGraph(*IPI->second) == &DSG) + ++IPI; // All SCC calls? - if (IP.first == IP.second) continue; + if (IPI == IPE) continue; - Function *FirstCallee = IP.first->second; - ++IP.first; + Function *FirstCallee = IPI->second; + ++IPI; // Skip over more SCC calls. - while (IP.first != IP.second && &getDSGraph(*IP.first->second) == &DSG) - ++IP.first; + while (IPI != IPE && &getDSGraph(*IPI->second) == &DSG) + ++IPI; // If there is exactly one callee from this call site, remember the edge in // CallerEdges. - if (IP.first == IP.second) { + if (IPI == IPE) { if (!FirstCallee->isExternal()) CallerEdges[&getDSGraph(*FirstCallee)] .push_back(CallerCallEdge(&DSG, &*CI, FirstCallee)); @@ -367,9 +358,9 @@ // so we build up a new, private, graph that represents the calls of all // calls to this set of functions. std::vector Callees; - IP = ActualCallees.equal_range(CallI); - for (BUDataStructures::ActualCalleesTy::const_iterator I = IP.first; - I != IP.second; ++I) + for (BUDataStructures::ActualCalleesTy::const_iterator I = + BUInfo->callee_begin(CallI), E = BUInfo->callee_end(CallI); + I != E; ++I) if (!I->second->isExternal()) Callees.push_back(I->second); std::sort(Callees.begin(), Callees.end()); From lattner at cs.uiuc.edu Sat Apr 2 13:54:08 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 2 Apr 2005 13:54:08 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/test/TEST.pacompiletime.Makefile TEST.pacompiletime.report Makefile Message-ID: <200504021954.j32Js8hj012373@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/test: TEST.pacompiletime.Makefile added (r1.1) TEST.pacompiletime.report added (r1.1) Makefile updated: 1.29 -> 1.30 --- Log message: add new pool allocation compile-time report --- Diffs of the changes: (+130 -0) Makefile | 6 ++++ TEST.pacompiletime.Makefile | 65 ++++++++++++++++++++++++++++++++++++++++++++ TEST.pacompiletime.report | 59 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 130 insertions(+) Index: llvm-poolalloc/test/TEST.pacompiletime.Makefile diff -c /dev/null llvm-poolalloc/test/TEST.pacompiletime.Makefile:1.1 *** /dev/null Sat Apr 2 13:54:02 2005 --- llvm-poolalloc/test/TEST.pacompiletime.Makefile Sat Apr 2 13:53:52 2005 *************** *** 0 **** --- 1,65 ---- + ##===- poolalloc/test/TEST.pacompiletime.Makefile ----------*- Makefile -*-===## + # + # This test figures out how much time we spend in DSA and the pool allocator + # compiling a program. + # + ##===----------------------------------------------------------------------===## + + CFLAGS = -O2 -fno-strict-aliasing + + EXTRA_PA_FLAGS := + + CURDIR := $(shell cd .; pwd) + PROGDIR := $(shell cd $(LLVM_SRC_ROOT)/projects/llvm-test; pwd)/ + RELDIR := $(subst $(PROGDIR),,$(CURDIR)) + + # Pool allocator pass shared object + PA_SO := $(PROJECT_DIR)/Debug/lib/libpoolalloc$(SHLIBEXT) + + # Command to run opt with the pool allocator pass loaded + OPT_PA := $(LOPT) -load $(PA_SO) + + # OPT_PA_STATS - Run opt with the -stats and -time-passes options, capturing the + # output to a file. + OPT_PA_STATS = $(OPT_PA) -info-output-file=$(CURDIR)/$@.info -time-passes + + + # This rule runs the pool allocator on the .llvm.bc file to produce a new .bc + # file + $(PROGRAMS_TO_TEST:%=Output/%.$(TEST).poolalloc.bc): \ + Output/%.$(TEST).poolalloc.bc: Output/%.llvm.bc $(PA_SO) $(LOPT) + - at rm -f $(CURDIR)/$@.info + -$(OPT_PA_STATS) -poolalloc $(EXTRA_PA_FLAGS) $< -o $@ -f 2>&1 > $@.out + + + # This rule wraps everything together to build the actual output the report is + # generated from. + $(PROGRAMS_TO_TEST:%=Output/%.$(TEST).report.txt): \ + Output/%.$(TEST).report.txt: Output/%.$(TEST).poolalloc.bc Output/%.LOC.txt + @echo > $@ + printf "LOC: " >> $@ + cat Output/$*.LOC.txt >> $@ + @echo >> $@ + @printf "LOCTIME: " >> $@ + @-grep "Local Data Structure" Output/$*.$(TEST).poolalloc.bc.info >>$@ + @printf "BUTIME: " >> $@ + @-grep " Bottom-up Data Struc" Output/$*.$(TEST).poolalloc.bc.info >>$@ + @printf "TDTIME: " >> $@ + @-grep "Top-down Data Structur" Output/$*.$(TEST).poolalloc.bc.info >>$@ + @printf "COMTIME: " >> $@ + @-grep "'Complete' Bottom-up D" Output/$*.$(TEST).poolalloc.bc.info >>$@ + @printf "EQTIME: " >> $@ + @-grep "Equivalence-class Bott" Output/$*.$(TEST).poolalloc.bc.info >>$@ + @printf "PATIME: " >> $@ + @-grep "Pool allocate disjoint" Output/$*.$(TEST).poolalloc.bc.info >>$@ + + + + $(PROGRAMS_TO_TEST:%=test.$(TEST).%): \ + test.$(TEST).%: Output/%.$(TEST).report.txt + @echo "---------------------------------------------------------------" + @echo ">>> ========= '$(RELDIR)/$*' Program" + @echo "---------------------------------------------------------------" + @cat $< + + REPORT_DEPENDENCIES := $(PA_RT_O) $(PA_SO) $(PROGRAMS_TO_TEST:%=Output/%.llvm.bc) $(LLC) $(LOPT) Index: llvm-poolalloc/test/TEST.pacompiletime.report diff -c /dev/null llvm-poolalloc/test/TEST.pacompiletime.report:1.1 *** /dev/null Sat Apr 2 13:54:08 2005 --- llvm-poolalloc/test/TEST.pacompiletime.report Sat Apr 2 13:53:52 2005 *************** *** 0 **** --- 1,59 ---- + ##=== TEST.pacompiletime.report - Report for PA Compile Time ---*- perl -*-===## + # + # This file defines a report to be generated for the pool allocator compile-time + # tests. + # + ##===----------------------------------------------------------------------===## + + # Sort by program name + $SortCol = 0; + $TrimRepeatedPrefix = 1; + + @LatexColumns = (1, 8, 10); + + my $FREEBENCH = 'MultiSource/Benchmarks/FreeBench'; + my $PTRDIST = 'MultiSource/Benchmarks/Ptrdist'; + + @LatexRowMapOrder = ( + "anagram/anagram" => 'anagram', + "bc/bc" => 'bc', + "ft/ft" => 'ft', + "ks/ks" => 'ks', + "yacr2/yacr2" => 'yacr2', + '-' => '-', + '164.gzip/164.gzip' => '164.gzip', + '175.vpr/175.vpr' => '175.vpr', + '181.mcf/181.mcf' => '181.mcf', + '186.crafty/186.crafty' => '186.crafty', + '197.parser/197.parser' => '197.parser', + '197.parser.hacked/197.parser.hacked' => '197.parser(b)', + '255.vortex/255.vortex' => '255.vortex', + '256.bzip2/256.bzip2' => '256.bzip2', + '300.twolf/300.twolf' => '300.twolf', + '-' => '-', + "analyzer" => 'analyzer', + "llu" => 'llu-bench', + ); + + + # These are the columns for the report. The first entry is the header for the + # column, the second is the regex to use to match the value. Empty list create + # seperators, and closures may be put in for custom processing. + my $USERSYSTTIME = '([0-9.]+)[ 0-9.]+\([^)]+\)[ 0-9.]+\([^)]+\) +'; + ( + # Name + ["Name:" , '\'([^\']+)\' Program'], + ["LOC" , 'LOC:\s*([0-9]+)'], + [], + # DSA Times + ["LOC", "${USERSYSTTIME}Local"], + ["BU", "${USERSYSTTIME}Bottom-up"], + ["TD", "${USERSYSTTIME}Top-down"], + ["COM", "${USERSYSTTIME}'Complete'"], + ["EQ", "${USERSYSTTIME}Equivalence"], + ["DSASUM", sub { return SumCols(@_, 5); }], + [], + ["PA Time", "${USERSYSTTIME}Pool allocate"], + [] + ); + Index: llvm-poolalloc/test/Makefile diff -u llvm-poolalloc/test/Makefile:1.29 llvm-poolalloc/test/Makefile:1.30 --- llvm-poolalloc/test/Makefile:1.29 Thu Mar 3 21:35:11 2005 +++ llvm-poolalloc/test/Makefile Sat Apr 2 13:53:52 2005 @@ -146,6 +146,12 @@ GET_STABLE_NUMBERS=1 report report.html) @printf "\a"; sleep 1; printf "\a"; sleep 1; printf "\a" +pacompiletime:: + (cd $(LLVM_OBJ_ROOT)/projects/llvm-test/$(SUBDIR); \ + PROJECT_DIR=$(PROJ_OBJ_ROOT) $(MAKE) -j1 TEST=pacompiletime \ + report report.html) + @printf "\a"; sleep 1; printf "\a"; sleep 1; printf "\a" + ptrcomp:: (cd $(LLVM_OBJ_ROOT)/projects/llvm-test/$(SUBDIR); \ PROJECT_DIR=$(PROJ_OBJ_ROOT) $(MAKE) -j1 TEST=ptrcomp \ From lattner at cs.uiuc.edu Sat Apr 2 13:55:45 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 2 Apr 2005 13:55:45 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp Message-ID: <200504021955.j32JtjY7013102@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/lib/PoolAllocate: TransformFunctionBody.cpp updated: 1.40 -> 1.41 --- Log message: adjust to api changes. --- Diffs of the changes: (+3 -4) TransformFunctionBody.cpp | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) Index: llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp diff -u llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.40 llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.41 --- llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.40 Mon Mar 14 22:46:30 2005 +++ llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp Sat Apr 2 13:55:29 2005 @@ -453,10 +453,9 @@ #ifndef NDEBUG // Verify that all potential callees at call site have the same DS graph. - const EquivClassGraphs::ActualCalleesTy& ActualCallees = - ECGraphs.getActualCallees(); - EquivClassGraphs::ActualCalleesTy::const_iterator I, E; - for (tie(I, E) = ActualCallees.equal_range(OrigInst); I != E; ++I) + EquivClassGraphs::ActualCalleesTy::const_iterator I = + ECGraphs.callee_begin(OrigInst), E = ECGraphs.callee_end(OrigInst); + for (; I != E; ++I) if (!I->second->isExternal()) assert(CalleeGraph == &ECGraphs.getDSGraph(*I->second) && "Callees at call site do not have a common graph!"); From alkis at cs.uiuc.edu Sat Apr 2 13:58:35 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 2 Apr 2005 13:58:35 -0600 Subject: [llvm-commits] CVS: llvm-java/runtime/runtime.h runtime.c Message-ID: <200504021958.NAA07725@zion.cs.uiuc.edu> Changes in directory llvm-java/runtime: runtime.h added (r1.1) runtime.c updated: 1.29 -> 1.30 --- Log message: Extract a header from runtime.h. --- Diffs of the changes: (+77 -58) runtime.c | 63 ++++-------------------------------------------------- runtime.h | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 58 deletions(-) Index: llvm-java/runtime/runtime.h diff -c /dev/null llvm-java/runtime/runtime.h:1.1 *** /dev/null Sat Apr 2 13:58:34 2005 --- llvm-java/runtime/runtime.h Sat Apr 2 13:58:24 2005 *************** *** 0 **** --- 1,72 ---- + #include + + /* For now we cast a java/lang/Class reference to a class record. When + * we get proper java/lang/Class representation this will be a field + * access. */ + #define GET_CLASS_RECORD(clazz) ((struct llvm_java_object_class_record*) clazz) + #define GET_CLASS(classRecord) ((jclass) classRecord) + + const JNIEnv llvm_java_JNIEnv; + + struct llvm_java_object_base; + struct llvm_java_object_header; + struct llvm_java_class_record; + struct llvm_java_typeinfo; + + struct llvm_java_object_header { + /* gc info, hash info, locking */ + int dummy; + }; + + struct llvm_java_object_base { + struct llvm_java_object_header header; + struct llvm_java_class_record* classRecord; + }; + + struct llvm_java_typeinfo { + /* The name of this class */ + const char* name; + + /* The number of super classes to java.lang.Object. */ + jint depth; + + /* The super class records up to java.lang.Object. */ + struct llvm_java_class_record** superclasses; + + /* If an interface its interface index, otherwise the last interface + * index implemented by this class. */ + jint interfaceIndex; + + /* The interface class records this class implements. */ + struct llvm_java_class_record** interfaces; + + /* The component class record if this is an array class, null + * otherwise. */ + struct llvm_java_class_record* component; + + /* If an array the size of its elements, otherwise 0 for classes, -1 + * for interfaces and -2 for primitive classes. */ + jint elementSize; + }; + + struct llvm_java_class_record { + struct llvm_java_typeinfo typeinfo; + }; + + #define HANDLE_TYPE(TYPE) \ + struct llvm_java_##TYPE##array { \ + struct llvm_java_object_base object_base; \ + jint length; \ + j##TYPE data[0]; \ + }; + #include "types.def" + + struct llvm_java_class_record* llvm_java_find_class_record(const char* name); + struct llvm_java_class_record* llvm_java_get_class_record(jobject obj); + void llvm_java_set_class_record(jobject obj, struct llvm_java_class_record* cr); + jboolean + llvm_java_is_instance_of(jobject obj, struct llvm_java_class_record* cr); + jboolean + llvm_java_is_assignable_from(struct llvm_java_class_record* cr, + struct llvm_java_class_record* from); + jint llvm_java_throw(jobject obj); Index: llvm-java/runtime/runtime.c diff -u llvm-java/runtime/runtime.c:1.29 llvm-java/runtime/runtime.c:1.30 --- llvm-java/runtime/runtime.c:1.29 Sat Apr 2 12:55:56 2005 +++ llvm-java/runtime/runtime.c Sat Apr 2 13:58:24 2005 @@ -1,51 +1,6 @@ +#include "runtime.h" #include #include -#include - -struct llvm_java_object_base; -struct llvm_java_object_header; -struct llvm_java_class_record; -struct llvm_java_typeinfo; - -struct llvm_java_object_header { - /* gc info, hash info, locking */ - int dummy; -}; - -struct llvm_java_object_base { - struct llvm_java_object_header header; - struct llvm_java_class_record* classRecord; -}; - -struct llvm_java_typeinfo { - /* The name of this class */ - const char* name; - - /* The number of super classes to java.lang.Object. */ - jint depth; - - /* The super class records up to java.lang.Object. */ - struct llvm_java_class_record** superclasses; - - /* If an interface its interface index, otherwise the last interface - * index implemented by this class. */ - jint interfaceIndex; - - /* The interface class records this class implements. */ - struct llvm_java_class_record** interfaces; - - /* The component class record if this is an array class, null - * otherwise. */ - struct llvm_java_class_record* component; - - /* If an array the size of its elements, otherwise 0 for classes, -1 - * for interfaces and -2 for primitive classes. */ - jint elementSize; -}; - -struct llvm_java_class_record { - struct llvm_java_typeinfo typeinfo; -}; jint llvm_java_is_primitive_class(struct llvm_java_class_record* cr) { @@ -71,8 +26,8 @@ obj->classRecord = cr; } -jint llvm_java_is_assignable_from(struct llvm_java_class_record* cr, - struct llvm_java_class_record* from) { +jboolean llvm_java_is_assignable_from(struct llvm_java_class_record* cr, + struct llvm_java_class_record* from) { /* trivial case: class records are the same */ if (cr == from) return JNI_TRUE; @@ -106,8 +61,8 @@ return JNI_FALSE; } -jint llvm_java_is_instance_of(jobject obj, - struct llvm_java_class_record* cr) { +jboolean llvm_java_is_instance_of(jobject obj, + struct llvm_java_class_record* cr) { /* trivial case: a null object can be cast to any type */ if (!obj) return JNI_TRUE; @@ -132,14 +87,6 @@ return NULL; } -#define HANDLE_TYPE(TYPE) \ - struct llvm_java_##TYPE##array { \ - struct llvm_java_object_base object_base; \ - jint length; \ - j##TYPE data[0]; \ - }; -#include "types.def" - static jint llvm_java_get_array_length(JNIEnv* env, jarray array) { return ((struct llvm_java_booleanarray*) array)->length; } From lattner at cs.uiuc.edu Sat Apr 2 14:00:32 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 2 Apr 2005 14:00:32 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp Message-ID: <200504022000.j32K0WpI014353@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/lib/PoolAllocate: TransformFunctionBody.cpp updated: 1.41 -> 1.42 --- Log message: adjust to api changes. --- Diffs of the changes: (+1 -1) TransformFunctionBody.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp diff -u llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.41 llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.42 --- llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.41 Sat Apr 2 13:55:29 2005 +++ llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp Sat Apr 2 14:00:16 2005 @@ -453,7 +453,7 @@ #ifndef NDEBUG // Verify that all potential callees at call site have the same DS graph. - EquivClassGraphs::ActualCalleesTy::const_iterator I = + EquivClassGraphs::callee_iterator I = ECGraphs.callee_begin(OrigInst), E = ECGraphs.callee_end(OrigInst); for (; I != E; ++I) if (!I->second->isExternal()) From alkis at cs.uiuc.edu Sat Apr 2 14:01:14 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 2 Apr 2005 14:01:14 -0600 Subject: [llvm-commits] CVS: llvm-java/include/llvm/Java/types.def Message-ID: <200504022001.OAA07785@zion.cs.uiuc.edu> Changes in directory llvm-java/include/llvm/Java: types.def updated: 1.1 -> 1.2 --- Log message: Provide two macros: one for the native types and one that includes jobject as well. --- Diffs of the changes: (+16 -0) types.def | 16 ++++++++++++++++ 1 files changed, 16 insertions(+) Index: llvm-java/include/llvm/Java/types.def diff -u llvm-java/include/llvm/Java/types.def:1.1 llvm-java/include/llvm/Java/types.def:1.2 --- llvm-java/include/llvm/Java/types.def:1.1 Fri Dec 17 01:39:07 2004 +++ llvm-java/include/llvm/Java/types.def Sat Apr 2 14:01:03 2005 @@ -17,6 +17,21 @@ // Provide definitions of macros so that users of this file do not have to // define everything to use it... +#ifdef HANDLE_NATIVE_TYPE +HANDLE_NATIVE_TYPE(boolean) +HANDLE_NATIVE_TYPE(byte) +HANDLE_NATIVE_TYPE(char) +HANDLE_NATIVE_TYPE(short) +HANDLE_NATIVE_TYPE(int) +HANDLE_NATIVE_TYPE(long) +HANDLE_NATIVE_TYPE(float) +HANDLE_NATIVE_TYPE(double) + +#undef HANDLE_NATIVE_TYPE +#endif + +#ifdef HANDLE_TYPE +HANDLE_TYPE(object) HANDLE_TYPE(boolean) HANDLE_TYPE(byte) HANDLE_TYPE(char) @@ -27,3 +42,4 @@ HANDLE_TYPE(double) #undef HANDLE_TYPE +#endif From lattner at cs.uiuc.edu Sat Apr 2 14:02:48 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 2 Apr 2005 14:02:48 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/DataStructure/DataStructure.h EquivClassGraphs.h Message-ID: <200504022002.j32K2m1u014531@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis/DataStructure: DataStructure.h updated: 1.90 -> 1.91 EquivClassGraphs.h updated: 1.20 -> 1.21 --- Log message: add and use a callee_iterator typedef --- Diffs of the changes: (+7 -5) DataStructure.h | 5 +++-- EquivClassGraphs.h | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) Index: llvm/include/llvm/Analysis/DataStructure/DataStructure.h diff -u llvm/include/llvm/Analysis/DataStructure/DataStructure.h:1.90 llvm/include/llvm/Analysis/DataStructure/DataStructure.h:1.91 --- llvm/include/llvm/Analysis/DataStructure/DataStructure.h:1.90 Sat Apr 2 13:15:15 2005 +++ llvm/include/llvm/Analysis/DataStructure/DataStructure.h Sat Apr 2 14:02:32 2005 @@ -157,11 +157,12 @@ return ActualCallees; } - ActualCalleesTy::iterator callee_begin(Instruction *I) const { + typedef ActualCalleesTy::const_iterator callee_iterator; + callee_iterator callee_begin(Instruction *I) const { return ActualCallees.lower_bound(std::pair(I, 0)); } - ActualCalleesTy::iterator callee_end(Instruction *I) const { + callee_iterator callee_end(Instruction *I) const { I = (Instruction*)((char*)I + 1); return ActualCallees.lower_bound(std::pair(I, 0)); } Index: llvm/include/llvm/Analysis/DataStructure/EquivClassGraphs.h diff -u llvm/include/llvm/Analysis/DataStructure/EquivClassGraphs.h:1.20 llvm/include/llvm/Analysis/DataStructure/EquivClassGraphs.h:1.21 --- llvm/include/llvm/Analysis/DataStructure/EquivClassGraphs.h:1.20 Sat Apr 2 13:15:15 2005 +++ llvm/include/llvm/Analysis/DataStructure/EquivClassGraphs.h Sat Apr 2 14:02:32 2005 @@ -100,12 +100,13 @@ const ActualCalleesTy &getActualCallees() const { return ActualCallees; } - - ActualCalleesTy::iterator callee_begin(Instruction *I) const { + + typedef ActualCalleesTy::const_iterator callee_iterator; + callee_iterator callee_begin(Instruction *I) const { return ActualCallees.lower_bound(std::pair(I, 0)); } - ActualCalleesTy::iterator callee_end(Instruction *I) const { + callee_iterator callee_end(Instruction *I) const { I = (Instruction*)((char*)I + 1); return ActualCallees.lower_bound(std::pair(I, 0)); } From lattner at cs.uiuc.edu Sat Apr 2 14:02:55 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 2 Apr 2005 14:02:55 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp EquivClassGraphs.cpp TopDownClosure.cpp Message-ID: <200504022002.j32K2tD5014544@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: CompleteBottomUp.cpp updated: 1.30 -> 1.31 EquivClassGraphs.cpp updated: 1.41 -> 1.42 TopDownClosure.cpp updated: 1.86 -> 1.87 --- Log message: use a callee_iterator typedef. --- Diffs of the changes: (+7 -9) CompleteBottomUp.cpp | 4 ++-- EquivClassGraphs.cpp | 7 +++---- TopDownClosure.cpp | 5 ++--- 3 files changed, 7 insertions(+), 9 deletions(-) Index: llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp diff -u llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp:1.30 llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp:1.31 --- llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp:1.30 Sat Apr 2 13:17:17 2005 +++ llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp Sat Apr 2 14:02:41 2005 @@ -120,7 +120,7 @@ Instruction *Call = CI->getCallSite().getInstruction(); // Loop over all of the actually called functions... - ActualCalleesTy::iterator I = callee_begin(Call), E = callee_end(Call); + callee_iterator I = callee_begin(Call), E = callee_end(Call); for (; I != E && I->first == Call; ++I) { assert(I->first == Call && "Bad callee construction!"); if (!I->second->isExternal()) { @@ -197,7 +197,7 @@ // Inline direct calls as well as indirect calls because the direct // callee may have indirect callees and so may have changed. // - ActualCalleesTy::iterator I = callee_begin(TheCall),E = callee_end(TheCall); + callee_iterator I = callee_begin(TheCall),E = callee_end(TheCall); unsigned TNum = 0, Num = 0; DEBUG(Num = std::distance(I, E)); for (; I != E; ++I, ++TNum) { Index: llvm/lib/Analysis/DataStructure/EquivClassGraphs.cpp diff -u llvm/lib/Analysis/DataStructure/EquivClassGraphs.cpp:1.41 llvm/lib/Analysis/DataStructure/EquivClassGraphs.cpp:1.42 --- llvm/lib/Analysis/DataStructure/EquivClassGraphs.cpp:1.41 Sat Apr 2 13:17:17 2005 +++ llvm/lib/Analysis/DataStructure/EquivClassGraphs.cpp Sat Apr 2 14:02:41 2005 @@ -339,8 +339,8 @@ Instruction *Call = CI->getCallSite().getInstruction(); // Loop over all of the actually called functions... - ActualCalleesTy::const_iterator I = callee_begin(Call),E = callee_end(Call); - for (; I != E; ++I) + for (callee_iterator I = callee_begin(Call), E = callee_end(Call); + I != E; ++I) if (!I->second->isExternal()) { // Process the callee as necessary. unsigned M = processSCC(getOrCreateGraph(*I->second), @@ -414,8 +414,7 @@ // graph so we only need to do this once. // DSGraph* CalleeGraph = NULL; - ActualCalleesTy::const_iterator I = callee_begin(TheCall); - ActualCalleesTy::const_iterator E = callee_end(TheCall); + callee_iterator I = callee_begin(TheCall), E = callee_end(TheCall); unsigned TNum, Num; // Loop over all potential callees to find the first non-external callee. Index: llvm/lib/Analysis/DataStructure/TopDownClosure.cpp diff -u llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.86 llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.87 --- llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.86 Sat Apr 2 13:17:18 2005 +++ llvm/lib/Analysis/DataStructure/TopDownClosure.cpp Sat Apr 2 14:02:41 2005 @@ -174,9 +174,8 @@ // Recursively traverse all of the callee graphs. for (DSGraph::fc_iterator CI = G.fc_begin(), E = G.fc_end(); CI != E; ++CI) { Instruction *CallI = CI->getCallSite().getInstruction(); - BUDataStructures::ActualCalleesTy::const_iterator I = + BUDataStructures::callee_iterator I = BUInfo->callee_begin(CallI), E = BUInfo->callee_end(CallI); - for (; I != E; ++I) ComputePostOrder(*I->second, Visited, PostOrder); } @@ -326,7 +325,7 @@ Instruction *CallI = CI->getCallSite().getInstruction(); // For each function in the invoked function list at this call site... - BUDataStructures::ActualCalleesTy::const_iterator IPI = + BUDataStructures::callee_iterator IPI = BUInfo->callee_begin(CallI), IPE = BUInfo->callee_end(CallI); // Skip over all calls to this graph (SCC calls). From alkis at cs.uiuc.edu Sat Apr 2 14:03:06 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 2 Apr 2005 14:03:06 -0600 Subject: [llvm-commits] CVS: llvm-java/runtime/runtime.h runtime.c Message-ID: <200504022003.OAA07820@zion.cs.uiuc.edu> Changes in directory llvm-java/runtime: runtime.h updated: 1.1 -> 1.2 runtime.c updated: 1.30 -> 1.31 --- Log message: Use new macro. --- Diffs of the changes: (+3 -3) runtime.c | 4 ++-- runtime.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) Index: llvm-java/runtime/runtime.h diff -u llvm-java/runtime/runtime.h:1.1 llvm-java/runtime/runtime.h:1.2 --- llvm-java/runtime/runtime.h:1.1 Sat Apr 2 13:58:24 2005 +++ llvm-java/runtime/runtime.h Sat Apr 2 14:02:55 2005 @@ -53,7 +53,7 @@ struct llvm_java_typeinfo typeinfo; }; -#define HANDLE_TYPE(TYPE) \ +#define HANDLE_NATIVE_TYPE(TYPE) \ struct llvm_java_##TYPE##array { \ struct llvm_java_object_base object_base; \ jint length; \ Index: llvm-java/runtime/runtime.c diff -u llvm-java/runtime/runtime.c:1.30 llvm-java/runtime/runtime.c:1.31 --- llvm-java/runtime/runtime.c:1.30 Sat Apr 2 13:58:24 2005 +++ llvm-java/runtime/runtime.c Sat Apr 2 14:02:55 2005 @@ -91,7 +91,7 @@ return ((struct llvm_java_booleanarray*) array)->length; } -#define HANDLE_TYPE(TYPE) \ +#define HANDLE_NATIVE_TYPE(TYPE) \ static j ## TYPE* llvm_java_get_##TYPE##_array_elements( \ JNIEnv* env, \ jarray array, \ @@ -102,7 +102,7 @@ } #include "types.def" -#define HANDLE_TYPE(TYPE) \ +#define HANDLE_NATIVE_TYPE(TYPE) \ static void llvm_java_release_ ##TYPE## _array_elements( \ JNIEnv* env, \ jarray array, \ From alkis at cs.uiuc.edu Sat Apr 2 14:05:22 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 2 Apr 2005 14:05:22 -0600 Subject: [llvm-commits] CVS: llvm-java/runtime/runtime.c Message-ID: <200504022005.OAA07851@zion.cs.uiuc.edu> Changes in directory llvm-java/runtime: runtime.c updated: 1.31 -> 1.32 --- Log message: Use no spaces between ## in macros. --- Diffs of the changes: (+3 -3) runtime.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Index: llvm-java/runtime/runtime.c diff -u llvm-java/runtime/runtime.c:1.31 llvm-java/runtime/runtime.c:1.32 --- llvm-java/runtime/runtime.c:1.31 Sat Apr 2 14:02:55 2005 +++ llvm-java/runtime/runtime.c Sat Apr 2 14:05:11 2005 @@ -92,18 +92,18 @@ } #define HANDLE_NATIVE_TYPE(TYPE) \ - static j ## TYPE* llvm_java_get_##TYPE##_array_elements( \ + static j##TYPE* llvm_java_get_##TYPE##_array_elements( \ JNIEnv* env, \ jarray array, \ jboolean* isCopy) { \ if (isCopy) \ *isCopy = JNI_FALSE; \ - return ((struct llvm_java_ ##TYPE## array*) array)->data; \ + return ((struct llvm_java_##TYPE##array*) array)->data; \ } #include "types.def" #define HANDLE_NATIVE_TYPE(TYPE) \ - static void llvm_java_release_ ##TYPE## _array_elements( \ + static void llvm_java_release_##TYPE##_array_elements( \ JNIEnv* env, \ jarray array, \ j##TYPE* elements, \ From lattner at cs.uiuc.edu Sat Apr 2 14:08:23 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 2 Apr 2005 14:08:23 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/DataStructure/DataStructure.h EquivClassGraphs.h Message-ID: <200504022008.j32K8NmG014780@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis/DataStructure: DataStructure.h updated: 1.91 -> 1.92 EquivClassGraphs.h (r1.21) removed --- Log message: merge EquivClassGraphs.h into DataStructure.h with the other DSA pass definitions. --- Diffs of the changes: (+105 -0) DataStructure.h | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 105 insertions(+) Index: llvm/include/llvm/Analysis/DataStructure/DataStructure.h diff -u llvm/include/llvm/Analysis/DataStructure/DataStructure.h:1.91 llvm/include/llvm/Analysis/DataStructure/DataStructure.h:1.92 --- llvm/include/llvm/Analysis/DataStructure/DataStructure.h:1.91 Sat Apr 2 14:02:32 2005 +++ llvm/include/llvm/Analysis/DataStructure/DataStructure.h Sat Apr 2 14:08:06 2005 @@ -25,6 +25,7 @@ class Type; class Instruction; class GlobalValue; +class CallSite; class DSGraph; class DSCallSite; class DSNode; @@ -314,6 +315,110 @@ void processGraph(DSGraph &G); }; + +/// EquivClassGraphs - This is the same as the complete bottom-up graphs, but +/// with functions partitioned into equivalence classes and a single merged +/// DS graph for all functions in an equivalence class. After this merging, +/// graphs are inlined bottom-up on the SCCs of the final (CBU) call graph. +/// +struct EquivClassGraphs : public ModulePass { + CompleteBUDataStructures *CBU; + + DSGraph *GlobalsGraph; + + // DSInfo - one graph for each function. + hash_map DSInfo; + + /// ActualCallees - The actual functions callable from indirect call sites. + /// + std::set > ActualCallees; + + // Equivalence class where functions that can potentially be called via the + // same function pointer are in the same class. + EquivalenceClasses FuncECs; + + /// OneCalledFunction - For each indirect call, we keep track of one + /// target of the call. This is used to find equivalence class called by + /// a call site. + std::map OneCalledFunction; + + /// GlobalECs - The equivalence classes for each global value that is merged + /// with other global values in the DSGraphs. + EquivalenceClasses GlobalECs; + +public: + /// EquivClassGraphs - Computes the equivalence classes and then the + /// folded DS graphs for each class. + /// + virtual bool runOnModule(Module &M); + + /// print - Print out the analysis results... + /// + void print(std::ostream &O, const Module *M) const; + + EquivalenceClasses &getGlobalECs() { return GlobalECs; } + + /// getDSGraph - Return the data structure graph for the specified function. + /// This returns the folded graph. The folded graph is the same as the CBU + /// graph iff the function is in a singleton equivalence class AND all its + /// callees also have the same folded graph as the CBU graph. + /// + DSGraph &getDSGraph(const Function &F) const { + hash_map::const_iterator I = DSInfo.find(&F); + assert(I != DSInfo.end() && "No graph computed for that function!"); + return *I->second; + } + + bool hasGraph(const Function &F) const { + return DSInfo.find(&F) != DSInfo.end(); + } + + /// ContainsDSGraphFor - Return true if we have a graph for the specified + /// function. + bool ContainsDSGraphFor(const Function &F) const { + return DSInfo.find(&F) != DSInfo.end(); + } + + /// getSomeCalleeForCallSite - Return any one callee function at + /// a call site. + /// + Function *getSomeCalleeForCallSite(const CallSite &CS) const; + + DSGraph &getGlobalsGraph() const { + return *GlobalsGraph; + } + + typedef std::set > ActualCalleesTy; + const ActualCalleesTy &getActualCallees() const { + return ActualCallees; + } + + typedef ActualCalleesTy::const_iterator callee_iterator; + callee_iterator callee_begin(Instruction *I) const { + return ActualCallees.lower_bound(std::pair(I, 0)); + } + + callee_iterator callee_end(Instruction *I) const { + I = (Instruction*)((char*)I + 1); + return ActualCallees.lower_bound(std::pair(I, 0)); + } + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesAll(); + AU.addRequired(); + } + +private: + void buildIndirectFunctionSets(Module &M); + + unsigned processSCC(DSGraph &FG, std::vector &Stack, + unsigned &NextID, + std::map &ValMap); + void processGraph(DSGraph &FG); + + DSGraph &getOrCreateGraph(Function &F); +}; + } // End llvm namespace #endif From lattner at cs.uiuc.edu Sat Apr 2 14:08:30 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 2 Apr 2005 14:08:30 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/EquivClassGraphs.cpp Printer.cpp Message-ID: <200504022008.j32K8U3P015008@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: EquivClassGraphs.cpp updated: 1.42 -> 1.43 Printer.cpp updated: 1.81 -> 1.82 --- Log message: EquivClassGraphs is now in DataStructure.h --- Diffs of the changes: (+1 -3) EquivClassGraphs.cpp | 3 +-- Printer.cpp | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) Index: llvm/lib/Analysis/DataStructure/EquivClassGraphs.cpp diff -u llvm/lib/Analysis/DataStructure/EquivClassGraphs.cpp:1.42 llvm/lib/Analysis/DataStructure/EquivClassGraphs.cpp:1.43 --- llvm/lib/Analysis/DataStructure/EquivClassGraphs.cpp:1.42 Sat Apr 2 14:02:41 2005 +++ llvm/lib/Analysis/DataStructure/EquivClassGraphs.cpp Sat Apr 2 14:08:17 2005 @@ -15,12 +15,11 @@ //===----------------------------------------------------------------------===// #define DEBUG_TYPE "ECGraphs" -#include "llvm/Analysis/DataStructure/EquivClassGraphs.h" +#include "llvm/Analysis/DataStructure/DataStructure.h" #include "llvm/DerivedTypes.h" #include "llvm/Module.h" #include "llvm/Pass.h" #include "llvm/Analysis/DataStructure/DSGraph.h" -#include "llvm/Analysis/DataStructure/DataStructure.h" #include "llvm/Support/CallSite.h" #include "llvm/Support/Debug.h" #include "llvm/ADT/SCCIterator.h" Index: llvm/lib/Analysis/DataStructure/Printer.cpp diff -u llvm/lib/Analysis/DataStructure/Printer.cpp:1.81 llvm/lib/Analysis/DataStructure/Printer.cpp:1.82 --- llvm/lib/Analysis/DataStructure/Printer.cpp:1.81 Fri Mar 25 14:54:45 2005 +++ llvm/lib/Analysis/DataStructure/Printer.cpp Sat Apr 2 14:08:17 2005 @@ -12,7 +12,6 @@ //===----------------------------------------------------------------------===// #include "llvm/Analysis/DataStructure/DataStructure.h" -#include "llvm/Analysis/DataStructure/EquivClassGraphs.h" #include "llvm/Analysis/DataStructure/DSGraph.h" #include "llvm/Analysis/DataStructure/DSGraphTraits.h" #include "llvm/Module.h" From lattner at cs.uiuc.edu Sat Apr 2 14:11:10 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 2 Apr 2005 14:11:10 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp PoolAllocate.cpp TransformFunctionBody.cpp Message-ID: <200504022011.j32KBAPs016305@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/lib/PoolAllocate: PointerCompress.cpp updated: 1.58 -> 1.59 PoolAllocate.cpp updated: 1.112 -> 1.113 TransformFunctionBody.cpp updated: 1.42 -> 1.43 --- Log message: equiv class graphs are now in DataStructure.h --- Diffs of the changes: (+3 -3) PointerCompress.cpp | 3 ++- PoolAllocate.cpp | 2 +- TransformFunctionBody.cpp | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) Index: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp diff -u llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.58 llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.59 --- llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.58 Wed Mar 16 16:46:45 2005 +++ llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Sat Apr 2 14:10:56 2005 @@ -17,7 +17,8 @@ #include "llvm/Constants.h" #include "llvm/Instructions.h" #include "llvm/Module.h" -#include "llvm/Analysis/DataStructure/EquivClassGraphs.h" +#include "llvm/Analysis/DataStructure/DataStructure.h" +#include "llvm/Analysis/DataStructure/DSGraph.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/CommandLine.h" Index: llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp diff -u llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.112 llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.113 --- llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.112 Wed Mar 16 16:46:45 2005 +++ llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp Sat Apr 2 14:10:56 2005 @@ -22,13 +22,13 @@ #include "llvm/Constants.h" #include "llvm/Analysis/DataStructure/DataStructure.h" #include "llvm/Analysis/DataStructure/DSGraph.h" -#include "llvm/Analysis/DataStructure/EquivClassGraphs.h" #include "llvm/Support/CFG.h" #include "llvm/Target/TargetData.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Transforms/Utils/Cloning.h" #include "llvm/ADT/DepthFirstIterator.h" #include "llvm/ADT/Statistic.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" using namespace llvm; Index: llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp diff -u llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.42 llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.43 --- llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.42 Sat Apr 2 14:00:16 2005 +++ llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp Sat Apr 2 14:10:57 2005 @@ -15,7 +15,6 @@ #include "PoolAllocate.h" #include "llvm/Analysis/DataStructure/DataStructure.h" #include "llvm/Analysis/DataStructure/DSGraph.h" -#include "llvm/Analysis/DataStructure/EquivClassGraphs.h" #include "llvm/Module.h" #include "llvm/DerivedTypes.h" #include "llvm/Constants.h" From lattner at cs.uiuc.edu Sat Apr 2 14:17:25 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 2 Apr 2005 14:17:25 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/TopDownClosure.cpp Message-ID: <200504022017.j32KHPm5019561@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: TopDownClosure.cpp updated: 1.87 -> 1.88 --- Log message: fix some VC compilation problems, thanks to Jeff C for pointing this out! --- Diffs of the changes: (+3 -4) TopDownClosure.cpp | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) Index: llvm/lib/Analysis/DataStructure/TopDownClosure.cpp diff -u llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.87 llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.88 --- llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.87 Sat Apr 2 14:02:41 2005 +++ llvm/lib/Analysis/DataStructure/TopDownClosure.cpp Sat Apr 2 14:17:09 2005 @@ -172,11 +172,10 @@ Visited.insert(&G); // Recursively traverse all of the callee graphs. - for (DSGraph::fc_iterator CI = G.fc_begin(), E = G.fc_end(); CI != E; ++CI) { + for (DSGraph::fc_iterator CI = G.fc_begin(), CE = G.fc_end(); CI != CE; ++CI){ Instruction *CallI = CI->getCallSite().getInstruction(); - BUDataStructures::callee_iterator I = - BUInfo->callee_begin(CallI), E = BUInfo->callee_end(CallI); - for (; I != E; ++I) + for (BUDataStructures::callee_iterator I = BUInfo->callee_begin(CallI), + E = BUInfo->callee_end(CallI); I != E; ++I) ComputePostOrder(*I->second, Visited, PostOrder); } From alkis at cs.uiuc.edu Sat Apr 2 14:17:33 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 2 Apr 2005 14:17:33 -0600 Subject: [llvm-commits] CVS: llvm-java/runtime/runtime.c Message-ID: <200504022017.OAA07924@zion.cs.uiuc.edu> Changes in directory llvm-java/runtime: runtime.c updated: 1.32 -> 1.33 --- Log message: Move jni implementation out of the runtime. --- Diffs of the changes: (+22 -293) runtime.c | 315 ++++---------------------------------------------------------- 1 files changed, 22 insertions(+), 293 deletions(-) Index: llvm-java/runtime/runtime.c diff -u llvm-java/runtime/runtime.c:1.32 llvm-java/runtime/runtime.c:1.33 --- llvm-java/runtime/runtime.c:1.32 Sat Apr 2 14:05:11 2005 +++ llvm-java/runtime/runtime.c Sat Apr 2 14:17:22 2005 @@ -74,304 +74,18 @@ abort(); } -/* The implementation of JNI functions */ +extern struct llvm_java_class_record* llvm_java_class_records; -extern const struct llvm_java_class_record* llvm_java_class_records; - -static jclass llvm_java_find_class(JNIEnv* env, const char* name) { - const struct llvm_java_class_record** clazz = &llvm_java_class_records; - while (*clazz) - if (strcmp((*clazz)->typeinfo.name, name) == 0) - return (jclass) clazz; +struct llvm_java_class_record* +llvm_java_find_class(JNIEnv* env, const char* name) { + struct llvm_java_class_record** cr = &llvm_java_class_records; + while (*cr) + if (strcmp((*cr)->typeinfo.name, name) == 0) + return *cr; return NULL; } -static jint llvm_java_get_array_length(JNIEnv* env, jarray array) { - return ((struct llvm_java_booleanarray*) array)->length; -} - -#define HANDLE_NATIVE_TYPE(TYPE) \ - static j##TYPE* llvm_java_get_##TYPE##_array_elements( \ - JNIEnv* env, \ - jarray array, \ - jboolean* isCopy) { \ - if (isCopy) \ - *isCopy = JNI_FALSE; \ - return ((struct llvm_java_##TYPE##array*) array)->data; \ - } -#include "types.def" - -#define HANDLE_NATIVE_TYPE(TYPE) \ - static void llvm_java_release_##TYPE##_array_elements( \ - JNIEnv* env, \ - jarray array, \ - j##TYPE* elements, \ - jint mode) { \ - switch (mode) { \ - case 0: \ - case JNI_COMMIT: \ - case JNI_ABORT: \ - return; \ - default: \ - abort(); \ - } \ - } -#include "types.def" - -/* The JNI interface definition */ -static const struct JNINativeInterface llvm_java_JNINativeInterface = { - NULL, /* 0 */ - NULL, - NULL, - NULL, - NULL, - NULL, - &llvm_java_find_class, - NULL, - NULL, - NULL, - NULL, /* 10 */ - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, /* 20 */ - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, /* 30 */ - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, /* 40 */ - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, /* 50 */ - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, /* 60 */ - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, /* 70 */ - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, /* 80 */ - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, /* 90 */ - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, /* 100 */ - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, /* 110 */ - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, /* 120 */ - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, /* 130 */ - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, /* 140 */ - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, /* 150 */ - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, /* 160 */ - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, /* 170 */ - &llvm_java_get_array_length, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, /* 180 */ - NULL, - NULL, - &llvm_java_get_boolean_array_elements, - &llvm_java_get_byte_array_elements, - &llvm_java_get_char_array_elements, - &llvm_java_get_short_array_elements, - &llvm_java_get_int_array_elements, - &llvm_java_get_long_array_elements, - &llvm_java_get_float_array_elements, - &llvm_java_get_double_array_elements, - &llvm_java_release_boolean_array_elements, - &llvm_java_release_byte_array_elements, - &llvm_java_release_char_array_elements, - &llvm_java_release_short_array_elements, - &llvm_java_release_int_array_elements, - &llvm_java_release_long_array_elements, - &llvm_java_release_float_array_elements, - &llvm_java_release_double_array_elements, - NULL, - NULL, /* 200 */ - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, /* 210 */ - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, /* 220 */ - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, /* 230 */ - NULL, -}; - -const JNIEnv llvm_java_JNIEnv = &llvm_java_JNINativeInterface; - -typedef void (*ClassInitializerFunction)(void); - -extern const ClassInitializerFunction llvm_java_class_initializers; - -extern void llvm_java_main(int, char**); - -int main(int argc, char** argv) { - const ClassInitializerFunction* classInit = &llvm_java_class_initializers; - while (*classInit) - (*classInit++)(); - - llvm_java_main(argc, argv); - return 0; -} - void Java_java_lang_VMSystem_arraycopy(JNIEnv *env, jobject clazz, jobject srcObj, jint srcStart, jobject dstObj, jint dstStart, @@ -398,3 +112,18 @@ jobject properties) { } + +typedef void (*ClassInitializerFunction)(void); + +extern const ClassInitializerFunction llvm_java_class_initializers; + +extern void llvm_java_main(int, char**); + +int main(int argc, char** argv) { + const ClassInitializerFunction* classInit = &llvm_java_class_initializers; + while (*classInit) + (*classInit++)(); + + llvm_java_main(argc, argv); + return 0; +} From alkis at cs.uiuc.edu Sat Apr 2 14:17:52 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 2 Apr 2005 14:17:52 -0600 Subject: [llvm-commits] CVS: llvm-java/runtime/jni.c Message-ID: <200504022017.OAA07948@zion.cs.uiuc.edu> Changes in directory llvm-java/runtime: jni.c added (r1.1) --- Log message: Move jni implementation out of the runtime. --- Diffs of the changes: (+296 -0) jni.c | 296 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 296 insertions(+) Index: llvm-java/runtime/jni.c diff -c /dev/null llvm-java/runtime/jni.c:1.1 *** /dev/null Sat Apr 2 14:17:51 2005 --- llvm-java/runtime/jni.c Sat Apr 2 14:17:41 2005 *************** *** 0 **** --- 1,296 ---- + #include "runtime.h" + #include + #include + + /* The implementation of JNI functions */ + + static jclass find_class(JNIEnv* env, const char* name) { + return GET_CLASS(llvm_java_find_class_record(name)); + } + + static jboolean is_assignable_from(JNIEnv* env, jclass c1, jclass c2) { + return llvm_java_is_assignable_from(GET_CLASS_RECORD(c1), + GET_CLASS_RECORD(c2)); + } + + static jboolean is_same_object(JNIEnv* env, jobject o1, jobject o2) { + return o1 == o2; + } + + static jclass get_object_class(JNIEnv* env, jobject obj) { + return GET_CLASS(llvm_java_get_class_record(obj)); + } + + static jboolean is_instance_of(JNIEnv* env, jobject obj, jclass c) { + return llvm_java_is_instance_of(obj, GET_CLASS_RECORD(c)); + } + + static jint get_array_length(JNIEnv* env, jarray array) { + return ((struct llvm_java_booleanarray*) array)->length; + } + + #define HANDLE_NATIVE_TYPE(TYPE) \ + static j ## TYPE* get_##TYPE##_array_elements( \ + JNIEnv* env, \ + jarray array, \ + jboolean* isCopy) { \ + if (isCopy) \ + *isCopy = JNI_FALSE; \ + return ((struct llvm_java_ ##TYPE## array*) array)->data; \ + } + #include "types.def" + + #define HANDLE_NATIVE_TYPE(TYPE) \ + static void release_ ##TYPE## _array_elements( \ + JNIEnv* env, \ + jarray array, \ + j##TYPE* elements, \ + jint mode) { \ + switch (mode) { \ + case 0: \ + case JNI_COMMIT: \ + case JNI_ABORT: \ + return; \ + default: \ + abort(); \ + } \ + } + #include "types.def" + + /* The JNI interface definition */ + static const struct JNINativeInterface llvm_java_JNINativeInterface = { + NULL, /* 0 */ + NULL, + NULL, + NULL, + NULL, + NULL, + &find_class, + NULL, + NULL, + NULL, + NULL, /* 10 */ + &is_assignable_from, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, /* 20 */ + NULL, + NULL, + NULL, + &is_same_object, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, /* 30 */ + &get_object_class, + &is_instance_of, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, /* 40 */ + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, /* 50 */ + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, /* 60 */ + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, /* 70 */ + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, /* 80 */ + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, /* 90 */ + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, /* 100 */ + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, /* 110 */ + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, /* 120 */ + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, /* 130 */ + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, /* 140 */ + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, /* 150 */ + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, /* 160 */ + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, /* 170 */ + &get_array_length, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, /* 180 */ + NULL, + NULL, + &get_boolean_array_elements, + &get_byte_array_elements, + &get_char_array_elements, + &get_short_array_elements, + &get_int_array_elements, + &get_long_array_elements, + &get_float_array_elements, + &get_double_array_elements, + &release_boolean_array_elements, + &release_byte_array_elements, + &release_char_array_elements, + &release_short_array_elements, + &release_int_array_elements, + &release_long_array_elements, + &release_float_array_elements, + &release_double_array_elements, + NULL, + NULL, /* 200 */ + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, /* 210 */ + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, /* 220 */ + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, /* 230 */ + NULL, + }; + + const JNIEnv llvm_java_JNIEnv = &llvm_java_JNINativeInterface; From alenhar2 at cs.uiuc.edu Sat Apr 2 15:07:07 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Sat, 2 Apr 2005 15:07:07 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp AlphaInstrInfo.td Message-ID: <200504022107.PAA02364@niobe.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.75 -> 1.76 AlphaInstrInfo.td updated: 1.36 -> 1.37 --- Log message: Try several things. 1) drop /i from FP ops 2) factor out FP to Int moves and provide 21264 support for those 3) match not 4) match ornot andnot xornot --- Diffs of the changes: (+120 -94) AlphaISelPattern.cpp | 189 ++++++++++++++++++++++++++++----------------------- AlphaInstrInfo.td | 25 ++++-- 2 files changed, 120 insertions(+), 94 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.75 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.76 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.75 Sat Apr 2 13:11:07 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Sat Apr 2 15:06:51 2005 @@ -36,7 +36,7 @@ cl::opt EnableAlphaIDIV("enable-alpha-intfpdiv", cl::desc("Use the FP div instruction for integer div when possible"), cl::Hidden); - cl::opt EnableAlpha("enable-alpha-ftoi", + cl::opt EnableAlphaFTOI("enable-alpha-ftoi", cl::desc("Enable use of ftoi* and itof* instructions (ev6 and higher)"), cl::Hidden); } @@ -333,6 +333,8 @@ void SelectAddr(SDOperand N, unsigned& Reg, long& offset); void SelectBranchCC(SDOperand N); + void MoveFP2Int(unsigned src, unsigned dst, bool isDouble); + void MoveInt2FP(unsigned src, unsigned dst, bool isDouble); }; } @@ -376,6 +378,46 @@ } } +void ISel::MoveFP2Int(unsigned src, unsigned dst, bool isDouble) +{ + unsigned Opc; + if (EnableAlphaFTOI) { + Opc = isDouble ? Alpha::FTOIT : Alpha::FTOIS; + BuildMI(BB, Opc, 1, dst).addReg(src); + } else { + //The hard way: + // Spill the integer to memory and reload it from there. + unsigned Size = MVT::getSizeInBits(MVT::f64)/8; + MachineFunction *F = BB->getParent(); + int FrameIdx = F->getFrameInfo()->CreateStackObject(Size, 8); + + Opc = isDouble ? Alpha::STT : Alpha::STS; + BuildMI(BB, Opc, 3).addReg(src).addFrameIndex(FrameIdx).addReg(Alpha::F31); + Opc = isDouble ? Alpha::LDQ : Alpha::LDL; + BuildMI(BB, Alpha::LDQ, 2, dst).addFrameIndex(FrameIdx).addReg(Alpha::F31); + } +} + +void ISel::MoveInt2FP(unsigned src, unsigned dst, bool isDouble) +{ + unsigned Opc; + if (EnableAlphaFTOI) { + Opc = isDouble?Alpha::ITOFT:Alpha::ITOFS; + BuildMI(BB, Opc, 1, dst).addReg(src); + } else { + //The hard way: + // Spill the integer to memory and reload it from there. + unsigned Size = MVT::getSizeInBits(MVT::f64)/8; + MachineFunction *F = BB->getParent(); + int FrameIdx = F->getFrameInfo()->CreateStackObject(Size, 8); + + Opc = isDouble ? Alpha::STQ : Alpha::STL; + BuildMI(BB, Opc, 3).addReg(src).addFrameIndex(FrameIdx).addReg(Alpha::F31); + Opc = isDouble ? Alpha::LDT : Alpha::LDS; + BuildMI(BB, Opc, 2, dst).addFrameIndex(FrameIdx).addReg(Alpha::F31); + } +} + //Check to see if the load is a constant offset from a base register void ISel::SelectAddr(SDOperand N, unsigned& Reg, long& offset) { @@ -615,16 +657,13 @@ else { Tmp1 = SelectExpr(N.getOperand(0)); //Cond - // Spill the cond to memory and reload it from there. - unsigned Size = MVT::getSizeInBits(MVT::f64)/8; - MachineFunction *F = BB->getParent(); - int FrameIdx = F->getFrameInfo()->CreateStackObject(Size, 8); - unsigned Tmp4 = MakeReg(MVT::f64); - BuildMI(BB, Alpha::STQ, 3).addReg(Tmp1).addFrameIndex(FrameIdx).addReg(Alpha::F31); - BuildMI(BB, Alpha::LDT, 2, Tmp4).addFrameIndex(FrameIdx).addReg(Alpha::F31); - //now ideally, we don't have to do anything to the flag... - // Get the condition into the zero flag. - BuildMI(BB, Alpha::FCMOVEQ, 3, Result).addReg(TV).addReg(FV).addReg(Tmp4); + BuildMI(BB, Alpha::FCMOVEQ_INT, 3, Result).addReg(TV).addReg(FV).addReg(Tmp1); +// // Spill the cond to memory and reload it from there. +// unsigned Tmp4 = MakeReg(MVT::f64); +// MoveIntFP(Tmp1, Tmp4, true); +// //now ideally, we don't have to do anything to the flag... +// // Get the condition into the zero flag. +// BuildMI(BB, Alpha::FCMOVEQ, 3, Result).addReg(TV).addReg(FV).addReg(Tmp4); return Result; } } @@ -784,25 +823,9 @@ && "only quads can be loaded from"); Tmp1 = SelectExpr(N.getOperand(0)); // Get the operand register Tmp2 = MakeReg(MVT::f64); - - //The hard way: - // Spill the integer to memory and reload it from there. - unsigned Size = MVT::getSizeInBits(MVT::i64)/8; - MachineFunction *F = BB->getParent(); - int FrameIdx = F->getFrameInfo()->CreateStackObject(Size, Size); - - BuildMI(BB, Alpha::STQ, 3).addReg(Tmp1).addFrameIndex(FrameIdx).addReg(Alpha::F31); - BuildMI(BB, Alpha::LDT, 2, Tmp2).addFrameIndex(FrameIdx).addReg(Alpha::F31); + MoveInt2FP(Tmp1, Tmp2, true); Opc = DestType == MVT::f64 ? Alpha::CVTQT : Alpha::CVTQS; 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); - return Result; } } @@ -1082,38 +1105,27 @@ return Result+N.ResNo; } - case ISD::SIGN_EXTEND: - abort(); - case ISD::SIGN_EXTEND_INREG: { //do SDIV opt for all levels of ints if (EnableAlphaIDIV && N.getOperand(0).getOpcode() == ISD::SDIV) { - Tmp1 = SelectExpr(N.getOperand(0).getOperand(0)); - Tmp2 = SelectExpr(N.getOperand(0).getOperand(1)); - unsigned Size = MVT::getSizeInBits(MVT::f64)/8; - MachineFunction *F = BB->getParent(); - int FrameIdxL = F->getFrameInfo()->CreateStackObject(Size, 8); - int FrameIdxR = F->getFrameInfo()->CreateStackObject(Size, 8); - int FrameIdxF = F->getFrameInfo()->CreateStackObject(Size, 8); unsigned Tmp4 = MakeReg(MVT::f64); unsigned Tmp5 = MakeReg(MVT::f64); unsigned Tmp6 = MakeReg(MVT::f64); unsigned Tmp7 = MakeReg(MVT::f64); unsigned Tmp8 = MakeReg(MVT::f64); unsigned Tmp9 = MakeReg(MVT::f64); - - BuildMI(BB, Alpha::STQ, 3).addReg(Tmp1).addFrameIndex(FrameIdxL).addReg(Alpha::F31); - BuildMI(BB, Alpha::STQ, 3).addReg(Tmp2).addFrameIndex(FrameIdxR).addReg(Alpha::F31); - BuildMI(BB, Alpha::LDT, 2, Tmp4).addFrameIndex(FrameIdxL).addReg(Alpha::F31); - BuildMI(BB, Alpha::LDT, 2, Tmp5).addFrameIndex(FrameIdxR).addReg(Alpha::F31); + + Tmp1 = SelectExpr(N.getOperand(0).getOperand(0)); + Tmp2 = SelectExpr(N.getOperand(0).getOperand(1)); + MoveInt2FP(Tmp1, Tmp4, true); + MoveInt2FP(Tmp2, Tmp5, true); BuildMI(BB, Alpha::CVTQT, 1, Tmp6).addReg(Tmp4); BuildMI(BB, Alpha::CVTQT, 1, Tmp7).addReg(Tmp5); BuildMI(BB, Alpha::DIVT, 2, Tmp8).addReg(Tmp6).addReg(Tmp7); BuildMI(BB, Alpha::CVTTQ, 1, Tmp9).addReg(Tmp8); - BuildMI(BB, Alpha::STT, 3).addReg(Tmp9).addFrameIndex(FrameIdxF).addReg(Alpha::F31); - BuildMI(BB, Alpha::LDQ, 2, Result).addFrameIndex(FrameIdxF).addReg(Alpha::F31); + MoveFP2Int(Tmp9, Result, true); return Result; } @@ -1362,30 +1374,7 @@ BuildMI(BB, Alpha::ADDQi, 2, Tmp4).addReg(Alpha::R31).addImm(1); Opc = inv?Alpha::CMOVNEi_FP:Alpha::CMOVEQi_FP; BuildMI(BB, Opc, 3, Result).addReg(Tmp4).addImm(0).addReg(Tmp3); - -// // Spill the FP to memory and reload it from there. -// unsigned Size = MVT::getSizeInBits(MVT::f64)/8; -// MachineFunction *F = BB->getParent(); -// int FrameIdx = F->getFrameInfo()->CreateStackObject(Size, 8); -// unsigned Tmp4 = MakeReg(MVT::f64); -// BuildMI(BB, Alpha::CVTTQ, 1, Tmp4).addReg(Tmp3); -// BuildMI(BB, Alpha::STT, 3).addReg(Tmp4).addFrameIndex(FrameIdx).addReg(Alpha::F31); -// unsigned Tmp5 = MakeReg(MVT::i64); -// BuildMI(BB, Alpha::LDQ, 2, Tmp5).addFrameIndex(FrameIdx).addReg(Alpha::F31); - -// //now, set result based on Tmp5 -// //Set Tmp6 if fp cmp was false -// unsigned Tmp6 = MakeReg(MVT::i64); -// BuildMI(BB, Alpha::CMPEQ, 2, Tmp6).addReg(Tmp5).addReg(Alpha::R31); -// //and invert -// BuildMI(BB, Alpha::CMPEQ, 2, Result).addReg(Tmp6).addReg(Alpha::R31); - } - // else - // { - // Node->dump(); - // assert(0 && "Not a setcc in setcc"); - // } } return Result; } @@ -1409,9 +1398,49 @@ //Most of the plain arithmetic and logic share the same form, and the same //constant immediate test - case ISD::AND: case ISD::OR: + //Match Not + if (N.getOperand(1).getOpcode() == ISD::Constant && + cast(N.getOperand(1))->isAllOnesValue()) + { + Tmp1 = SelectExpr(N.getOperand(0)); + BuildMI(BB, Alpha::ORNOT, 2, Result).addReg(Alpha::R31).addReg(Tmp1); + return Result; + } + //Fall through + case ISD::AND: case ISD::XOR: + //Check operand(0) == Not + if (N.getOperand(0).getOpcode() == ISD::OR && + N.getOperand(0).getOperand(1).getOpcode() == ISD::Constant && + cast(N.getOperand(0).getOperand(1))->isAllOnesValue()) + { + switch(opcode) { + case ISD::AND: Opc = Alpha::BIC; break; + case ISD::OR: Opc = Alpha::ORNOT; break; + case ISD::XOR: Opc = Alpha::EQV; break; + } + Tmp1 = SelectExpr(N.getOperand(1)); + Tmp2 = SelectExpr(N.getOperand(0).getOperand(0)); + BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); + return Result; + } + //Check operand(1) == Not + if (N.getOperand(1).getOpcode() == ISD::OR && + N.getOperand(1).getOperand(1).getOpcode() == ISD::Constant && + cast(N.getOperand(1).getOperand(1))->isAllOnesValue()) + { + switch(opcode) { + case ISD::AND: Opc = Alpha::BIC; break; + case ISD::OR: Opc = Alpha::ORNOT; break; + case ISD::XOR: Opc = Alpha::EQV; break; + } + Tmp1 = SelectExpr(N.getOperand(0)); + Tmp2 = SelectExpr(N.getOperand(1).getOperand(0)); + BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); + return Result; + } + //Fall through case ISD::SHL: case ISD::SRL: case ISD::SRA: @@ -1512,25 +1541,15 @@ MVT::ValueType SrcType = N.getOperand(0).getValueType(); assert (SrcType == MVT::f32 || SrcType == MVT::f64); Tmp1 = SelectExpr(N.getOperand(0)); // Get the operand register - - //The hard way: - // Spill the integer to memory and reload it from there. - unsigned Size = MVT::getSizeInBits(MVT::f64)/8; - MachineFunction *F = BB->getParent(); - int FrameIdx = F->getFrameInfo()->CreateStackObject(Size, 8); - - //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); + MoveFP2Int(Tmp2, Result, true); return Result; } Index: llvm/lib/Target/Alpha/AlphaInstrInfo.td diff -u llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.36 llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.37 --- llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.36 Thu Mar 31 15:24:05 2005 +++ llvm/lib/Target/Alpha/AlphaInstrInfo.td Sat Apr 2 15:06:51 2005 @@ -96,7 +96,10 @@ // "lda $RES,1($$31)\n\tfbne $COND, 42f\n\tbis $$31,$$31,$RES\n42:\n">; //An even better improvement on the Int = SetCC(FP): SelectCC! +//These are evil because they hide control flow in a MBB +//really the ISel should emit multiple MBB let isTwoAddress = 1 in { +//Conditional move of an int based on a FP CC def CMOVEQ_FP : PseudoInstAlpha<(ops GPRC:$RDEST, GPRC:$RSRC_F, GPRC:$RSRC_T, FPRC:$RCOND), "fbne $RCOND, 42f\n\tbis $RSRC_T,$RSRC_T,$RDEST\n42:\n">; def CMOVEQi_FP : PseudoInstAlpha<(ops GPRC:$RDEST, GPRC:$RSRC_F, u8imm:$L, FPRC:$RCOND), @@ -106,7 +109,11 @@ "fbeq $RCOND, 42f\n\tbis $RSRC_T,$RSRC_T,$RDEST\n42:\n">; def CMOVNEi_FP : PseudoInstAlpha<(ops GPRC:$RDEST, GPRC:$RSRC_F, u8imm:$L, FPRC:$RCOND), "fbeq $RCOND, 42f\n\taddq $$31,$L,$RDEST\n42:\n">; - +//Conditional move of an FP based on a Int CC + def FCMOVEQ_INT : PseudoInstAlpha<(ops GPRC:$RDEST, GPRC:$RSRC_F, GPRC:$RSRC_T, FPRC:$RCOND), + "bne $RCOND, 42f\n\tcpys $RSRC_T,$RSRC_T,$RDEST\n42:\n">; + def FCMOVNE_INT : PseudoInstAlpha<(ops GPRC:$RDEST, GPRC:$RSRC_F, GPRC:$RSRC_T, FPRC:$RCOND), + "beq $RCOND, 42f\n\tcpys $RSRC_T,$RSRC_T,$RDEST\n42:\n">; } //*********************** @@ -380,14 +387,14 @@ def CPYSN : FPForm<0x17, 0x021, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "cpysn $RA,$RB,$RC">; //Copy sign negate //Basic Floating point ops -def ADDS : FPForm<0x16, 0x080, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "adds/sui $RA,$RB,$RC">; //Add S_floating -def ADDT : FPForm<0x16, 0x0A0, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "addt/sui $RA,$RB,$RC">; //Add T_floating -def SUBS : FPForm<0x16, 0x081, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "subs/sui $RA,$RB,$RC">; //Subtract S_floating -def SUBT : FPForm<0x16, 0x0A1, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "subt/sui $RA,$RB,$RC">; //Subtract T_floating -def DIVS : FPForm<0x16, 0x083, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "divs/sui $RA,$RB,$RC">; //Divide S_floating -def DIVT : FPForm<0x16, 0x0A3, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "divt/sui $RA,$RB,$RC">; //Divide T_floating -def MULS : FPForm<0x16, 0x082, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "muls/sui $RA,$RB,$RC">; //Multiply S_floating -def MULT : FPForm<0x16, 0x0A2, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "mult/sui $RA,$RB,$RC">; //Multiply T_floating +def ADDS : FPForm<0x16, 0x080, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "adds/su $RA,$RB,$RC">; //Add S_floating +def ADDT : FPForm<0x16, 0x0A0, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "addt/su $RA,$RB,$RC">; //Add T_floating +def SUBS : FPForm<0x16, 0x081, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "subs/su $RA,$RB,$RC">; //Subtract S_floating +def SUBT : FPForm<0x16, 0x0A1, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "subt/su $RA,$RB,$RC">; //Subtract T_floating +def DIVS : FPForm<0x16, 0x083, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "divs/su $RA,$RB,$RC">; //Divide S_floating +def DIVT : FPForm<0x16, 0x0A3, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "divt/su $RA,$RB,$RC">; //Divide T_floating +def MULS : FPForm<0x16, 0x082, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "muls/su $RA,$RB,$RC">; //Multiply S_floating +def MULT : FPForm<0x16, 0x0A2, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "mult/su $RA,$RB,$RC">; //Multiply T_floating def SQRTS : FPForm<0x14, 0x08B, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "sqrts $RA,$RB,$RC">; //Square root S_floating def SQRTT : FPForm<0x14, 0x0AB, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "sqrtt $RA,$RB,$RC">; //Square root T_floating From lattner at cs.uiuc.edu Sat Apr 2 15:18:35 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 2 Apr 2005 15:18:35 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp Message-ID: <200504022118.j32LIZNW028346@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/lib/PoolAllocate: PoolAllocate.cpp updated: 1.113 -> 1.114 --- Log message: add a bunch of timers. --- Diffs of the changes: (+21 -5) PoolAllocate.cpp | 26 +++++++++++++++++++++----- 1 files changed, 21 insertions(+), 5 deletions(-) Index: llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp diff -u llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.113 llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.114 --- llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.113 Sat Apr 2 14:10:56 2005 +++ llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp Sat Apr 2 15:18:18 2005 @@ -31,11 +31,19 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/Timer.h" using namespace llvm; using namespace PA; const Type *PoolAllocate::PoolDescPtrTy = 0; +#if 0 +#define TIME_REGION(VARNAME, DESC) \ + NamedRegionTimer VARNAME(DESC) +#else +#define TIME_REGION(VARNAME, DESC) +#endif + namespace { RegisterOpt X("poolalloc", "Pool allocate disjoint data structures"); @@ -84,12 +92,13 @@ if (SetupGlobalPools(M)) return true; +{TIME_REGION(X, "FindFunctionPoolArgs"); // Loop over the functions in the original program finding the pool desc. // arguments necessary for each function that is indirectly callable. for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) if (!I->isExternal() && ECGraphs->ContainsDSGraphFor(*I)) FindFunctionPoolArgs(*I); - +} std::map FuncMap; // Now clone a function using the pool arg list obtained in the previous pass @@ -97,6 +106,7 @@ // don't traverse newly added ones. If the function needs new arguments, make // its clone. std::set ClonedFunctions; +{TIME_REGION(X, "MakeFunctionClone"); for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) if (!I->isExternal() && !ClonedFunctions.count(I) && ECGraphs->ContainsDSGraphFor(*I)) @@ -104,16 +114,18 @@ FuncMap[I] = Clone; ClonedFunctions.insert(Clone); } +} // Now that all call targets are available, rewrite the function bodies of the // clones. +{TIME_REGION(X, "ProcessFunctionBody"); for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) if (!I->isExternal() && !ClonedFunctions.count(I) && ECGraphs->ContainsDSGraphFor(*I)) { std::map::iterator FI = FuncMap.find(I); ProcessFunctionBody(*I, FI != FuncMap.end() ? *FI->second : *I); } - +} // Replace all uses of original functions with the transformed function. for (std::map::iterator I = FuncMap.begin(), E = FuncMap.end(); I != E; ++I) { @@ -340,22 +352,26 @@ // Populate the value map with all of the globals in the program. // FIXME: This should be unnecessary! Module &M = *F.getParent(); +{TIME_REGION(X, "ValueMap Construct"); for (Module::iterator I = M.begin(), E=M.end(); I!=E; ++I) ValueMap[I] = I; for (Module::global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I) ValueMap[I] = I; - +} // Perform the cloning. std::vector Returns; +{TIME_REGION(X, "CFI"); CloneFunctionInto(New, &F, ValueMap, Returns); - +} // Invert the ValueMap into the NewToOldValueMap std::map &NewToOldValueMap = FI.NewToOldValueMap; + +{TIME_REGION(X, "N2O Map Construct"); for (std::map::iterator I = ValueMap.begin(), E = ValueMap.end(); I != E; ++I) NewToOldValueMap.insert(std::make_pair(I->second, I->first)); - +} return FI.Clone = New; } From lattner at cs.uiuc.edu Sat Apr 2 15:20:08 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 2 Apr 2005 15:20:08 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp Message-ID: <200504022120.j32LK8E5028750@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/lib/PoolAllocate: PoolAllocate.cpp updated: 1.114 -> 1.115 --- Log message: Don't initialize the valuemap for cloning with all of the globals in the program. This is really slow for programs with lots of globals, and the valuemapper assumes that globals have an identity mapping unless otherwise specified anyway. This speeds up the PA on povray from .89s -> .64s. --- Diffs of the changes: (+1 -7) PoolAllocate.cpp | 8 +------- 1 files changed, 1 insertion(+), 7 deletions(-) Index: llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp diff -u llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.114 llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.115 --- llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.114 Sat Apr 2 15:18:18 2005 +++ llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp Sat Apr 2 15:19:54 2005 @@ -352,13 +352,7 @@ // Populate the value map with all of the globals in the program. // FIXME: This should be unnecessary! Module &M = *F.getParent(); -{TIME_REGION(X, "ValueMap Construct"); - for (Module::iterator I = M.begin(), E=M.end(); I!=E; ++I) - ValueMap[I] = I; - for (Module::global_iterator I = M.global_begin(), E = M.global_end(); - I != E; ++I) - ValueMap[I] = I; -} + // Perform the cloning. std::vector Returns; {TIME_REGION(X, "CFI"); From lattner at cs.uiuc.edu Sat Apr 2 15:21:58 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 2 Apr 2005 15:21:58 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp Message-ID: <200504022121.j32LLwBX029311@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/lib/PoolAllocate: PoolAllocate.cpp updated: 1.115 -> 1.116 --- Log message: remove the fixme and var defn now too :) --- Diffs of the changes: (+0 -4) PoolAllocate.cpp | 4 ---- 1 files changed, 4 deletions(-) Index: llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp diff -u llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.115 llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.116 --- llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.115 Sat Apr 2 15:19:54 2005 +++ llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp Sat Apr 2 15:21:44 2005 @@ -349,10 +349,6 @@ NI->setName(I->getName()); } - // Populate the value map with all of the globals in the program. - // FIXME: This should be unnecessary! - Module &M = *F.getParent(); - // Perform the cloning. std::vector Returns; {TIME_REGION(X, "CFI"); From lattner at cs.uiuc.edu Sat Apr 2 15:41:06 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 2 Apr 2005 15:41:06 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp Message-ID: <200504022141.j32Lf63h031849@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/lib/PoolAllocate: PoolAllocate.cpp updated: 1.116 -> 1.117 --- Log message: remove some timers add some new ones. --- Diffs of the changes: (+3 -5) PoolAllocate.cpp | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-) Index: llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp diff -u llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.116 llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.117 --- llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.116 Sat Apr 2 15:21:44 2005 +++ llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp Sat Apr 2 15:40:49 2005 @@ -92,13 +92,12 @@ if (SetupGlobalPools(M)) return true; -{TIME_REGION(X, "FindFunctionPoolArgs"); // Loop over the functions in the original program finding the pool desc. // arguments necessary for each function that is indirectly callable. for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) if (!I->isExternal() && ECGraphs->ContainsDSGraphFor(*I)) FindFunctionPoolArgs(*I); -} + std::map FuncMap; // Now clone a function using the pool arg list obtained in the previous pass @@ -351,17 +350,15 @@ // Perform the cloning. std::vector Returns; -{TIME_REGION(X, "CFI"); +{TIME_REGION(X, "CloneFunctionInto"); CloneFunctionInto(New, &F, ValueMap, Returns); } // Invert the ValueMap into the NewToOldValueMap std::map &NewToOldValueMap = FI.NewToOldValueMap; -{TIME_REGION(X, "N2O Map Construct"); for (std::map::iterator I = ValueMap.begin(), E = ValueMap.end(); I != E; ++I) NewToOldValueMap.insert(std::make_pair(I->second, I->first)); -} return FI.Clone = New; } @@ -482,6 +479,7 @@ std::map &PoolDescriptors) { if (NodesToPA.empty()) return; + TIME_REGION(X, "CreatePools"); std::vector ResultPools; CurHeuristic->AssignToPools(NodesToPA, &F, *NodesToPA[0]->getParentGraph(), From alenhar2 at cs.uiuc.edu Sat Apr 2 16:32:55 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Sat, 2 Apr 2005 16:32:55 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp AlphaInstrInfo.td Message-ID: <200504022232.QAA02461@niobe.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.76 -> 1.77 AlphaInstrInfo.td updated: 1.37 -> 1.38 --- Log message: Select optimization --- Diffs of the changes: (+143 -56) AlphaISelPattern.cpp | 197 ++++++++++++++++++++++++++++++++++++--------------- AlphaInstrInfo.td | 2 2 files changed, 143 insertions(+), 56 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.76 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.77 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.76 Sat Apr 2 15:06:51 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Sat Apr 2 16:32:39 2005 @@ -335,6 +335,8 @@ void SelectBranchCC(SDOperand N); void MoveFP2Int(unsigned src, unsigned dst, bool isDouble); void MoveInt2FP(unsigned src, unsigned dst, bool isDouble); + //returns whether the sense of the comparison was inverted + bool SelectFPSetCC(SDOperand N, unsigned dst); }; } @@ -418,6 +420,64 @@ } } +bool ISel::SelectFPSetCC(SDOperand N, unsigned dst) +{ + SDNode *Node = N.Val; + unsigned Opc, Tmp1, Tmp2, Tmp3; + SetCCSDNode *SetCC = dyn_cast(Node); + + //assert(SetCC->getOperand(0).getValueType() != MVT::f32 && "SetCC f32 should have been promoted"); + bool rev = false; + bool inv = false; + + switch (SetCC->getCondition()) { + default: Node->dump(); assert(0 && "Unknown FP comparison!"); + case ISD::SETEQ: Opc = Alpha::CMPTEQ; break; + case ISD::SETLT: Opc = Alpha::CMPTLT; break; + case ISD::SETLE: Opc = Alpha::CMPTLE; break; + case ISD::SETGT: Opc = Alpha::CMPTLT; rev = true; break; + case ISD::SETGE: Opc = Alpha::CMPTLE; rev = true; break; + case ISD::SETNE: Opc = Alpha::CMPTEQ; inv = true; break; + } + + //FIXME: check for constant 0.0 + ConstantFPSDNode *CN; + if ((CN = dyn_cast(SetCC->getOperand(0))) + && (CN->isExactlyValue(+0.0) || CN->isExactlyValue(-0.0))) + Tmp1 = Alpha::F31; + else + Tmp1 = SelectExpr(N.getOperand(0)); + + if ((CN = dyn_cast(SetCC->getOperand(1))) + && (CN->isExactlyValue(+0.0) || CN->isExactlyValue(-0.0))) + Tmp2 = Alpha::F31; + else + Tmp2 = SelectExpr(N.getOperand(1)); + + //Can only compare doubles, and dag won't promote for me + if (SetCC->getOperand(0).getValueType() == MVT::f32) + { + //assert(0 && "Setcc On float?\n"); + 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) + { + //assert (0 && "Setcc On float?\n"); + std::cerr << "Setcc on float!\n"; + Tmp3 = MakeReg(MVT::f64); + BuildMI(BB, Alpha::CVTST, 1, Tmp3).addReg(Tmp2); + Tmp2 = Tmp3; + } + + if (rev) std::swap(Tmp1, Tmp2); + //do the comparison + BuildMI(BB, Opc, 2, dst).addReg(Tmp1).addReg(Tmp2); + return inv; +} + //Check to see if the load is a constant offset from a base register void ISel::SelectAddr(SDOperand N, unsigned& Reg, long& offset) { @@ -1318,62 +1378,15 @@ } } } else { - //assert(SetCC->getOperand(0).getValueType() != MVT::f32 && "SetCC f32 should have been promoted"); - bool rev = false; - bool inv = false; - - switch (SetCC->getCondition()) { - default: Node->dump(); assert(0 && "Unknown FP comparison!"); - case ISD::SETEQ: Opc = Alpha::CMPTEQ; break; - case ISD::SETLT: Opc = Alpha::CMPTLT; break; - case ISD::SETLE: Opc = Alpha::CMPTLE; break; - case ISD::SETGT: Opc = Alpha::CMPTLT; rev = true; break; - case ISD::SETGE: Opc = Alpha::CMPTLE; rev = true; break; - case ISD::SETNE: Opc = Alpha::CMPTEQ; inv = true; break; - } - - //FIXME: check for constant 0.0 - ConstantFPSDNode *CN; - if ((CN = dyn_cast(SetCC->getOperand(0))) - && (CN->isExactlyValue(+0.0) || CN->isExactlyValue(-0.0))) - Tmp1 = Alpha::F31; - else - Tmp1 = SelectExpr(N.getOperand(0)); - - if ((CN = dyn_cast(SetCC->getOperand(1))) - && (CN->isExactlyValue(+0.0) || CN->isExactlyValue(-0.0))) - Tmp2 = Alpha::F31; - else - Tmp2 = SelectExpr(N.getOperand(1)); - - //Can only compare doubles, and dag won't promote for me - if (SetCC->getOperand(0).getValueType() == MVT::f32) - { - //assert(0 && "Setcc On float?\n"); - 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) - { - //assert (0 && "Setcc On float?\n"); - std::cerr << "Setcc on float!\n"; - Tmp3 = MakeReg(MVT::f64); - BuildMI(BB, Alpha::CVTST, 1, Tmp3).addReg(Tmp2); - Tmp2 = Tmp3; - } - - if (rev) std::swap(Tmp1, Tmp2); - Tmp3 = MakeReg(MVT::f64); //do the comparison - BuildMI(BB, Opc, 2, Tmp3).addReg(Tmp1).addReg(Tmp2); - + Tmp1 = MakeReg(MVT::f64); + bool inv = SelectFPSetCC(N, Tmp1); + //now arrange for Result (int) to have a 1 or 0 - unsigned Tmp4 = MakeReg(MVT::i64); - BuildMI(BB, Alpha::ADDQi, 2, Tmp4).addReg(Alpha::R31).addImm(1); + Tmp2 = MakeReg(MVT::i64); + BuildMI(BB, Alpha::ADDQi, 2, Tmp2).addReg(Alpha::R31).addImm(1); Opc = inv?Alpha::CMOVNEi_FP:Alpha::CMOVEQi_FP; - BuildMI(BB, Opc, 3, Result).addReg(Tmp4).addImm(0).addReg(Tmp3); + BuildMI(BB, Opc, 3, Result).addReg(Tmp2).addImm(0).addReg(Tmp1); } } return Result; @@ -1554,16 +1567,88 @@ return Result; } - // // case ISD::FP_TO_UINT: - case ISD::SELECT: { //FIXME: look at parent to decide if intCC can be folded, or if setCC(FP) and can save stack use - Tmp1 = SelectExpr(N.getOperand(0)); //Cond + //Tmp1 = SelectExpr(N.getOperand(0)); //Cond Tmp2 = SelectExpr(N.getOperand(1)); //Use if TRUE Tmp3 = SelectExpr(N.getOperand(2)); //Use if FALSE // Get the condition into the zero flag. + //BuildMI(BB, Alpha::CMOVEQ, 2, Result).addReg(Tmp2).addReg(Tmp3).addReg(Tmp1); + SDOperand CC = N.getOperand(0); + SetCCSDNode* SetCC = dyn_cast(CC.Val); + + if (CC.getOpcode() == ISD::SETCC && + !MVT::isInteger(SetCC->getOperand(0).getValueType())) + { //FP Setcc -> Int Select + Tmp1 = MakeReg(MVT::f64); + bool inv = SelectFPSetCC(CC, Tmp1); + BuildMI(BB, inv?Alpha::CMOVNE_FP:Alpha::CMOVEQ_FP, 2, Result) + .addReg(Tmp2).addReg(Tmp3).addReg(Tmp1); + return Result; + } + if (CC.getOpcode() == ISD::SETCC) { + //Int SetCC -> Select + //Dropping the CC is only useful if we are comparing to 0 + if(SetCC->getOperand(1).getOpcode() == ISD::Constant && + cast(SetCC->getOperand(0))->getValue() == 0) + { + bool useI = (SetCC->getOperand(1).getOpcode() == ISD::Constant && + cast(SetCC->getOperand(1))->getValue() <= 255); + + switch (SetCC->getCondition()) { + default: CC.Val->dump(); assert(0 && "Unknown integer comparison!"); + case ISD::SETEQ: Opc = useI?Alpha::CMOVEQi:Alpha::CMOVEQ; break; + case ISD::SETLT: Opc = useI?Alpha::CMOVGTi:Alpha::CMOVGT; break; + case ISD::SETLE: Opc = useI?Alpha::CMOVGEi:Alpha::CMOVGE; break; + case ISD::SETGT: Opc = useI?Alpha::CMOVLTi:Alpha::CMOVLT; break; + case ISD::SETGE: Opc = useI?Alpha::CMOVLEi:Alpha::CMOVLE; break; + case ISD::SETULT: Opc = useI?Alpha::CMOVNEi:Alpha::CMOVNE; 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 = useI?Alpha::CMOVEQi:Alpha::CMOVEQ; break; //Technically you could have this CC + case ISD::SETNE: Opc = useI?Alpha::CMOVNEi:Alpha::CMOVNE; break; + } + if (useI) + BuildMI(BB, Opc, 2, Result).addReg(Tmp2).addReg(Tmp3) + .addImm(cast(SetCC->getOperand(1))->getValue()); + else + BuildMI(BB, Opc, 2, Result).addReg(Tmp2).addReg(Tmp3) + .addReg(SelectExpr(SetCC->getOperand(1))); + return Result; + } + if(SetCC->getOperand(1).getOpcode() == ISD::Constant && + cast(SetCC->getOperand(1))->getValue() == 0) + { + bool useI = (SetCC->getOperand(0).getOpcode() == ISD::Constant && + cast(SetCC->getOperand(0))->getValue() <= 255); + + switch (SetCC->getCondition()) { + default: CC.Val->dump(); assert(0 && "Unknown integer comparison!"); + case ISD::SETEQ: Opc = useI?Alpha::CMOVEQi:Alpha::CMOVEQ; break; + case ISD::SETLT: Opc = useI?Alpha::CMOVLTi:Alpha::CMOVLT; break; + case ISD::SETLE: Opc = useI?Alpha::CMOVLEi:Alpha::CMOVLE; break; + case ISD::SETGT: Opc = useI?Alpha::CMOVGTi:Alpha::CMOVGT; break; + case ISD::SETGE: Opc = useI?Alpha::CMOVGEi:Alpha::CMOVGE; break; + case ISD::SETULT: assert(0 && "x (unsigned) < 0 is never true"); break; + case ISD::SETUGT: Opc = useI?Alpha::CMOVNEi:Alpha::CMOVNE; break; + case ISD::SETULE: Opc = useI?Alpha::CMOVEQi:Alpha::CMOVEQ; break; //Technically you could have this CC + case ISD::SETUGE: assert(0 && "x (unsgined >= 0 is always true"); break; + case ISD::SETNE: Opc = useI?Alpha::CMOVNEi:Alpha::CMOVNE; break; + } + if (useI) + BuildMI(BB, Opc, 2, Result).addReg(Tmp2).addReg(Tmp3) + .addImm(cast(SetCC->getOperand(0))->getValue()); + else + BuildMI(BB, Opc, 2, Result).addReg(Tmp2).addReg(Tmp3) + .addReg(SelectExpr(SetCC->getOperand(0))); + return Result; + } + //Otherwise, fall though + } + Tmp1 = SelectExpr(N.getOperand(0)); //Cond BuildMI(BB, Alpha::CMOVEQ, 2, Result).addReg(Tmp2).addReg(Tmp3).addReg(Tmp1); + return Result; } Index: llvm/lib/Target/Alpha/AlphaInstrInfo.td diff -u llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.37 llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.38 --- llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.37 Sat Apr 2 15:06:51 2005 +++ llvm/lib/Target/Alpha/AlphaInstrInfo.td Sat Apr 2 16:32:39 2005 @@ -55,6 +55,7 @@ let isReturn = 1, isTerminator = 1 in def RETURN : PseudoInstAlpha<(ops ), "ret $$31,($$26),1">; //Return from subroutine +//These are evil as they get expanded into multiple instructions to take care of reallocation let Uses = [R29], Defs = [R28] in { def LOAD_ADDR : PseudoInstAlpha<(ops GPRC:$RA, s64imm:$DISP), "lda $RA,$DISP">; //Load address def LDQ_SYM : PseudoInstAlpha<(ops GPRC:$RA, s64imm:$DISP), "ldq $RA,$DISP">; //Load quadword @@ -80,6 +81,7 @@ //RESULTS of these go to R27 +//These are also evil as the assembler expands them into calls let Uses = [R29], Defs = [R28, R23, R24, R25, R27] in { From alkis at cs.uiuc.edu Sat Apr 2 18:22:55 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 2 Apr 2005 18:22:55 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Resolver.cpp Message-ID: <200504030022.SAA09053@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Resolver.cpp updated: 1.18 -> 1.19 --- Log message: Match types of runtime functions and structs. This allows again the inlining of functions in the runtime. --- Diffs of the changes: (+2 -2) Resolver.cpp | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm-java/lib/Compiler/Resolver.cpp diff -u llvm-java/lib/Compiler/Resolver.cpp:1.18 llvm-java/lib/Compiler/Resolver.cpp:1.19 --- llvm-java/lib/Compiler/Resolver.cpp:1.18 Sat Apr 2 12:55:56 2005 +++ llvm-java/lib/Compiler/Resolver.cpp Sat Apr 2 18:22:44 2005 @@ -40,7 +40,7 @@ // }; // // struct type_info { - // char** name; + // char* name; // int depth; // struct class_record** superclasses; // int interfaceIndex; @@ -51,7 +51,7 @@ // Compute the type_info type. std::vector elements; - elements.push_back(PointerType::get(PointerType::get(Type::SByteTy))); + elements.push_back(PointerType::get(Type::SByteTy)); elements.push_back(Type::IntTy); elements.push_back(PointerType::get(PointerType::get(classRecordType_))); elements.push_back(Type::IntTy); From alkis at cs.uiuc.edu Sat Apr 2 18:23:06 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 2 Apr 2005 18:23:06 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200504030023.SAA09065@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.278 -> 1.279 --- Log message: Match types of runtime functions and structs. This allows again the inlining of functions in the runtime. --- Diffs of the changes: (+6 -4) Compiler.cpp | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.278 llvm-java/lib/Compiler/Compiler.cpp:1.279 --- llvm-java/lib/Compiler/Compiler.cpp:1.278 Sat Apr 2 03:14:25 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Sat Apr 2 18:22:55 2005 @@ -82,18 +82,20 @@ "llvm_java_JNIEnv", module_); const Type* classRecordPtrType = resolver_->getClassRecordPtrType(); + const Type* objectBaseType = resolver_->getObjectBaseType(); + getClassRecord_ = module_->getOrInsertFunction( "llvm_java_get_class_record", classRecordPtrType, - resolver_->getObjectBaseType(), NULL); + objectBaseType, NULL); setClassRecord_ = module_->getOrInsertFunction( "llvm_java_set_class_record", Type::VoidTy, - resolver_->getObjectBaseType(), classRecordPtrType, NULL); + objectBaseType, classRecordPtrType, NULL); throw_ = module_->getOrInsertFunction( "llvm_java_throw", Type::IntTy, - resolver_->getObjectBaseType(), NULL); + objectBaseType, NULL); isInstanceOf_ = module_->getOrInsertFunction( "llvm_java_is_instance_of", Type::IntTy, - resolver_->getObjectBaseType(), classRecordPtrType, NULL); + objectBaseType, classRecordPtrType, NULL); memcpy_ = module_->getOrInsertFunction( "llvm.memcpy", Type::VoidTy, PointerType::get(Type::SByteTy), From alkis at cs.uiuc.edu Sat Apr 2 18:32:03 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 2 Apr 2005 18:32:03 -0600 Subject: [llvm-commits] CVS: llvm-java/runtime/runtime.c Message-ID: <200504030032.SAA09127@zion.cs.uiuc.edu> Changes in directory llvm-java/runtime: runtime.c updated: 1.33 -> 1.34 --- Log message: Give proper name to function. --- Diffs of the changes: (+1 -1) runtime.c | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm-java/runtime/runtime.c diff -u llvm-java/runtime/runtime.c:1.33 llvm-java/runtime/runtime.c:1.34 --- llvm-java/runtime/runtime.c:1.33 Sat Apr 2 14:17:22 2005 +++ llvm-java/runtime/runtime.c Sat Apr 2 18:31:52 2005 @@ -77,7 +77,7 @@ extern struct llvm_java_class_record* llvm_java_class_records; struct llvm_java_class_record* -llvm_java_find_class(JNIEnv* env, const char* name) { +llvm_java_find_class_record(const char* name) { struct llvm_java_class_record** cr = &llvm_java_class_records; while (*cr) if (strcmp((*cr)->typeinfo.name, name) == 0) From alkis at cs.uiuc.edu Sat Apr 2 18:37:19 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 2 Apr 2005 18:37:19 -0600 Subject: [llvm-commits] CVS: llvm-java/runtime/runtime.c Message-ID: <200504030037.SAA09158@zion.cs.uiuc.edu> Changes in directory llvm-java/runtime: runtime.c updated: 1.34 -> 1.35 --- Log message: Really loop through class records! --- Diffs of the changes: (+3 -3) runtime.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Index: llvm-java/runtime/runtime.c diff -u llvm-java/runtime/runtime.c:1.34 llvm-java/runtime/runtime.c:1.35 --- llvm-java/runtime/runtime.c:1.34 Sat Apr 2 18:31:52 2005 +++ llvm-java/runtime/runtime.c Sat Apr 2 18:37:08 2005 @@ -79,7 +79,7 @@ struct llvm_java_class_record* llvm_java_find_class_record(const char* name) { struct llvm_java_class_record** cr = &llvm_java_class_records; - while (*cr) + for (; *cr; ++cr) if (strcmp((*cr)->typeinfo.name, name) == 0) return *cr; @@ -121,8 +121,8 @@ int main(int argc, char** argv) { const ClassInitializerFunction* classInit = &llvm_java_class_initializers; - while (*classInit) - (*classInit++)(); + for (; *classInit; ++classInit) + (*classInit)(); llvm_java_main(argc, argv); return 0; From alkis at cs.uiuc.edu Sat Apr 2 19:10:26 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 2 Apr 2005 19:10:26 -0600 Subject: [llvm-commits] CVS: llvm-java/test/Programs/SingleSource/UnitTests/test.c Test.java Message-ID: <200504030110.TAA09323@zion.cs.uiuc.edu> Changes in directory llvm-java/test/Programs/SingleSource/UnitTests: test.c updated: 1.4 -> 1.5 Test.java updated: 1.7 -> 1.8 --- Log message: Add tests for getfield. --- Diffs of the changes: (+64 -0) Test.java | 12 ++++++++++++ test.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) Index: llvm-java/test/Programs/SingleSource/UnitTests/test.c diff -u llvm-java/test/Programs/SingleSource/UnitTests/test.c:1.4 llvm-java/test/Programs/SingleSource/UnitTests/test.c:1.5 --- llvm-java/test/Programs/SingleSource/UnitTests/test.c:1.4 Sat Dec 11 21:13:59 2004 +++ llvm-java/test/Programs/SingleSource/UnitTests/test.c Sat Apr 2 19:10:15 2005 @@ -38,3 +38,55 @@ // Since we didn't modify the array there is no point in copying it back (*env)->ReleaseByteArrayElements(env, array, elements, JNI_ABORT); } + +void Java_Test_printFields(JNIEnv *env, jobject obj) +{ + jclass classTest; + jclass objClass; + jfieldID id; + jboolean z; + jint i; + jlong l; + jfloat f; + jdouble d; + jshort s; + jbyte b; + + classTest = (*env)->FindClass(env, "Test"); + if (!classTest) + printf("ERROR: Class Test not found!\n"); + + if (!(*env)->IsInstanceOf(env, obj, classTest)) + printf("ERROR: IsInstanceOf\n"); + objClass = (*env)->GetObjectClass(env, obj); + if (!(*env)->IsAssignableFrom(env, objClass, classTest)) + printf("ERROR: IsAssignableFrom\n"); + + id = (*env)->GetFieldID(env, objClass, "z", "Z"); + z = (*env)->GetBooleanField(env, obj, id); + Java_Test_println__Z(env, objClass, z); + + id = (*env)->GetFieldID(env, objClass, "i", "I"); + i = (*env)->GetIntField(env, obj, id); + Java_Test_println__I(env, objClass, i); + + id = (*env)->GetFieldID(env, objClass, "l", "J"); + l = (*env)->GetLongField(env, obj, id); + Java_Test_println__J(env, objClass, l); + + id = (*env)->GetFieldID(env, objClass, "f", "F"); + f = (*env)->GetFloatField(env, obj, id); + Java_Test_println__F(env, objClass, f); + + id = (*env)->GetFieldID(env, objClass, "d", "D"); + d = (*env)->GetDoubleField(env, obj, id); + Java_Test_println__D(env, objClass, d); + + id = (*env)->GetFieldID(env, objClass, "s", "S"); + s = (*env)->GetShortField(env, obj, id); + Java_Test_println__I(env, objClass, s); + + id = (*env)->GetFieldID(env, objClass, "b", "B"); + b = (*env)->GetByteField(env, obj, id); + Java_Test_println__I(env, objClass, b); +} Index: llvm-java/test/Programs/SingleSource/UnitTests/Test.java diff -u llvm-java/test/Programs/SingleSource/UnitTests/Test.java:1.7 llvm-java/test/Programs/SingleSource/UnitTests/Test.java:1.8 --- llvm-java/test/Programs/SingleSource/UnitTests/Test.java:1.7 Mon Feb 7 19:38:02 2005 +++ llvm-java/test/Programs/SingleSource/UnitTests/Test.java Sat Apr 2 19:10:15 2005 @@ -1,5 +1,13 @@ public class Test { + public boolean z = false; + public int i = 123; + public long l = 1234567890123456789L; + public float f = 753.46F; + public double d = -46.75346; + public short s = 456; + public byte b = 78; + static { System.loadLibrary("test"); } @@ -19,6 +27,8 @@ } private static native void println(byte[] a); + public native void printFields(); + public static void main(String[] args) { println(true); println(false); @@ -32,5 +42,7 @@ println(-753.46); println(new byte[] { 'H', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd' }); println("Hello world"); + + new Test().printFields(); } } From alkis at cs.uiuc.edu Sat Apr 2 19:12:17 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 2 Apr 2005 19:12:17 -0600 Subject: [llvm-commits] CVS: llvm-java/runtime/runtime.h jni.c Message-ID: <200504030112.TAA09376@zion.cs.uiuc.edu> Changes in directory llvm-java/runtime: runtime.h updated: 1.2 -> 1.3 jni.c updated: 1.1 -> 1.2 --- Log message: Implement GetFieldId, GetField, SetField JNI functions. --- Diffs of the changes: (+66 -19) jni.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++---------------- runtime.h | 9 +++++++ 2 files changed, 66 insertions(+), 19 deletions(-) Index: llvm-java/runtime/runtime.h diff -u llvm-java/runtime/runtime.h:1.2 llvm-java/runtime/runtime.h:1.3 --- llvm-java/runtime/runtime.h:1.2 Sat Apr 2 14:02:55 2005 +++ llvm-java/runtime/runtime.h Sat Apr 2 19:12:05 2005 @@ -47,6 +47,15 @@ /* If an array the size of its elements, otherwise 0 for classes, -1 * for interfaces and -2 for primitive classes. */ jint elementSize; + + /* A null terminated array of strings describing the fields of this + * class. A field description is the concatenation of its name with + * its descriptor. */ + const char** fieldDescriptors; + + /* An array of offsets to fields. This is indexed the same way as + * the field descriptor array. */ + jfieldID* fieldOffsets; }; struct llvm_java_class_record { Index: llvm-java/runtime/jni.c diff -u llvm-java/runtime/jni.c:1.1 llvm-java/runtime/jni.c:1.2 --- llvm-java/runtime/jni.c:1.1 Sat Apr 2 14:17:41 2005 +++ llvm-java/runtime/jni.c Sat Apr 2 19:12:05 2005 @@ -25,6 +25,44 @@ return llvm_java_is_instance_of(obj, GET_CLASS_RECORD(c)); } +static jfieldID get_fieldid(JNIEnv *env, + jclass clazz, + const char *name, + const char *sig) { + int nameLength; + int i; + const char* fieldDescriptor; + struct llvm_java_class_record* cr = GET_CLASS_RECORD(clazz); + + /* lookup the name+sig in the fieldDescriptors array and retrieve + * the offset of the field */ + nameLength = strlen(name); + for (i = 0; (fieldDescriptor = cr->typeinfo.fieldDescriptors[i]); ++i) + if (strncmp(name, fieldDescriptor, nameLength) == 0 && + strcmp(sig, fieldDescriptor+nameLength) == 0) + return cr->typeinfo.fieldOffsets[i]; + + return 0; +} + +#define HANDLE_TYPE(TYPE) \ + static j##TYPE get_##TYPE##_field(JNIEnv* env, \ + jobject obj, \ + jfieldID fid) { \ + return *(j##TYPE*) (((char*)obj) + fid); \ + } +#include "types.def" + +#define HANDLE_TYPE(TYPE) \ + static void set_##TYPE##_field(JNIEnv* env, \ + jobject obj, \ + jfieldID fid, \ + j##TYPE value) { \ + *(j##TYPE*) (((char*)obj) + fid) = value; \ + } +#include "types.def" + + static jint get_array_length(JNIEnv* env, jarray array) { return ((struct llvm_java_booleanarray*) array)->length; } @@ -153,25 +191,25 @@ NULL, NULL, NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, /* 100 */ - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, /* 110 */ - NULL, - NULL, + &get_fieldid, + &get_object_field, + &get_boolean_field, + &get_byte_field, + &get_char_field, + &get_short_field, + &get_int_field, + &get_long_field, + &get_float_field, + &get_double_field, + &set_object_field, + &set_boolean_field, + &set_byte_field, + &set_char_field, + &set_short_field, + &set_int_field, + &set_long_field, + &set_float_field, + &set_double_field, NULL, NULL, NULL, From alkis at cs.uiuc.edu Sat Apr 2 19:12:17 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 2 Apr 2005 19:12:17 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMField.h VMField.cpp VMClass.h VMClass.cpp Resolver.cpp Message-ID: <200504030112.TAA09384@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMField.h updated: 1.4 -> 1.5 VMField.cpp updated: 1.5 -> 1.6 VMClass.h updated: 1.30 -> 1.31 VMClass.cpp updated: 1.40 -> 1.41 Resolver.cpp updated: 1.19 -> 1.20 --- Log message: Implement GetFieldId, GetField, SetField JNI functions. --- Diffs of the changes: (+95 -0) Resolver.cpp | 4 ++++ VMClass.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ VMClass.h | 2 ++ VMField.cpp | 32 ++++++++++++++++++++++++++++++++ VMField.h | 7 +++++++ 5 files changed, 95 insertions(+) Index: llvm-java/lib/Compiler/VMField.h diff -u llvm-java/lib/Compiler/VMField.h:1.4 llvm-java/lib/Compiler/VMField.h:1.5 --- llvm-java/lib/Compiler/VMField.h:1.4 Wed Mar 30 21:15:08 2005 +++ llvm-java/lib/Compiler/VMField.h Sat Apr 2 19:12:05 2005 @@ -19,6 +19,7 @@ namespace llvm { + class Constant; class GlobalVariable; } @@ -47,6 +48,9 @@ public: const std::string& getName() const { return field_->getName()->str(); } + const std::string& getDescriptor() const { + return field_->getDescriptor()->str(); + } bool isStatic() const { return field_->isStatic(); } const VMClass* getParent() const { return parent_; } @@ -59,6 +63,9 @@ assert(isStatic() && "Field should be static!"); return data_.global; } + + llvm::Constant* buildFieldDescriptor() const; + llvm::Constant* buildFieldOffset() const; }; } } // namespace llvm::Java Index: llvm-java/lib/Compiler/VMField.cpp diff -u llvm-java/lib/Compiler/VMField.cpp:1.5 llvm-java/lib/Compiler/VMField.cpp:1.6 --- llvm-java/lib/Compiler/VMField.cpp:1.5 Wed Mar 30 21:15:08 2005 +++ llvm-java/lib/Compiler/VMField.cpp Sat Apr 2 19:12:05 2005 @@ -16,6 +16,7 @@ #include "Resolver.h" #include "VMClass.h" #include +#include using namespace llvm; using namespace llvm::Java; @@ -56,3 +57,34 @@ assert(!isStatic() && "This should be a member field!"); data_.index = index; } + +llvm::Constant* VMField::buildFieldDescriptor() const +{ + llvm::Constant* fd = ConstantArray::get(getName() + getDescriptor()); + + return ConstantExpr::getPtrPtrFromArrayPtr( + new GlobalVariable( + fd->getType(), + true, + GlobalVariable::ExternalLinkage, + fd, + getName() + getDescriptor(), + parent_->getResolver()->getModule())); +} + +llvm::Constant* VMField::buildFieldOffset() const +{ + assert(!isStatic() && "This should be a member field!"); + + assert(!isa(getParent()->getType()) && + "Should not be called before its owning class layout is computed!"); + llvm::Constant* nullRef = + llvm::Constant::getNullValue(getParent()->getType()); + std::vector indices; + indices.reserve(2); + indices.push_back(ConstantInt::get(Type::UIntTy, 0)); + indices.push_back(ConstantInt::get(Type::UIntTy, getMemberIndex())); + + return ConstantExpr::getCast( + ConstantExpr::getGetElementPtr(nullRef, indices), Type::UIntTy); +} Index: llvm-java/lib/Compiler/VMClass.h diff -u llvm-java/lib/Compiler/VMClass.h:1.30 llvm-java/lib/Compiler/VMClass.h:1.31 --- llvm-java/lib/Compiler/VMClass.h:1.30 Sat Apr 2 02:18:20 2005 +++ llvm-java/lib/Compiler/VMClass.h Sat Apr 2 19:12:05 2005 @@ -60,6 +60,8 @@ llvm::Constant* buildSuperClassRecords() const; llvm::Constant* buildInterfaceClassRecord(const VMClass* interface) const; llvm::Constant* buildInterfaceClassRecords() const; + llvm::Constant* buildFieldDescriptors() const; + llvm::Constant* buildFieldOffsets() const; llvm::Constant* buildClassTypeInfo() const; const VMField* lookupField(const std::string& name) const; Index: llvm-java/lib/Compiler/VMClass.cpp diff -u llvm-java/lib/Compiler/VMClass.cpp:1.40 llvm-java/lib/Compiler/VMClass.cpp:1.41 --- llvm-java/lib/Compiler/VMClass.cpp:1.40 Sat Apr 2 02:18:20 2005 +++ llvm-java/lib/Compiler/VMClass.cpp Sat Apr 2 19:12:05 2005 @@ -297,6 +297,53 @@ resolver_->getModule())); } +llvm::Constant* VMClass::buildFieldDescriptors() const +{ + std::vector init; + init.reserve(memberFields_.size()+1); + + for (unsigned i = 0, e = memberFields_.size(); i != e; ++i) { + const VMField* field = memberFields_[i]; + init.push_back(field->buildFieldDescriptor()); + } + // Null terminate. + init.push_back(llvm::Constant::getNullValue(PointerType::get(Type::SByteTy))); + + const ArrayType* arrayType = + ArrayType::get(init.back()->getType(), init.size()); + + return ConstantExpr::getPtrPtrFromArrayPtr( + new GlobalVariable( + arrayType, + true, + GlobalVariable::ExternalLinkage, + ConstantArray::get(arrayType, init), + getName() + "", + resolver_->getModule())); +} + +llvm::Constant* VMClass::buildFieldOffsets() const +{ + std::vector init; + init.reserve(memberFields_.size()); + + for (unsigned i = 0, e = memberFields_.size(); i != e; ++i) { + const VMField* field = memberFields_[i]; + init.push_back(field->buildFieldOffset()); + } + + const ArrayType* arrayType = ArrayType::get(Type::UIntTy, init.size()); + + return ConstantExpr::getPtrPtrFromArrayPtr( + new GlobalVariable( + arrayType, + true, + GlobalVariable::ExternalLinkage, + ConstantArray::get(arrayType, init), + getName() + "", + resolver_->getModule())); +} + llvm::Constant* VMClass::buildClassTypeInfo() const { std::vector init; @@ -324,6 +371,9 @@ else // A class. init.push_back(ConstantSInt::get(Type::IntTy, 0)); + init.push_back(buildFieldDescriptors()); + init.push_back(buildFieldOffsets()); + return ConstantStruct::get(init); } Index: llvm-java/lib/Compiler/Resolver.cpp diff -u llvm-java/lib/Compiler/Resolver.cpp:1.19 llvm-java/lib/Compiler/Resolver.cpp:1.20 --- llvm-java/lib/Compiler/Resolver.cpp:1.19 Sat Apr 2 18:22:44 2005 +++ llvm-java/lib/Compiler/Resolver.cpp Sat Apr 2 19:12:05 2005 @@ -47,6 +47,8 @@ // struct class_record** interfaces; // struct class_record* component; // int elementSize; + // char** fieldDescriptors; + // unsigned* fieldOffsets; // }; // Compute the type_info type. @@ -58,6 +60,8 @@ elements.push_back(PointerType::get(PointerType::get(classRecordType_))); elements.push_back(PointerType::get(classRecordType_)); elements.push_back(Type::IntTy); + elements.push_back(PointerType::get(PointerType::get(Type::SByteTy))); + elements.push_back(PointerType::get(Type::UIntTy)); typeInfoType_ = StructType::get(elements); module_->addTypeName("struct.llvm_java_typeinfo", getTypeInfoType()); From alkis at cs.uiuc.edu Sat Apr 2 20:05:44 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 2 Apr 2005 20:05:44 -0600 Subject: [llvm-commits] CVS: llvm-java/test/Programs/SingleSource/UnitTests/test.c Test.java Message-ID: <200504030205.UAA09665@zion.cs.uiuc.edu> Changes in directory llvm-java/test/Programs/SingleSource/UnitTests: test.c updated: 1.5 -> 1.6 Test.java updated: 1.8 -> 1.9 --- Log message: Add tests for static field access through JNI. --- Diffs of the changes: (+58 -0) Test.java | 10 ++++++++++ test.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) Index: llvm-java/test/Programs/SingleSource/UnitTests/test.c diff -u llvm-java/test/Programs/SingleSource/UnitTests/test.c:1.5 llvm-java/test/Programs/SingleSource/UnitTests/test.c:1.6 --- llvm-java/test/Programs/SingleSource/UnitTests/test.c:1.5 Sat Apr 2 19:10:15 2005 +++ llvm-java/test/Programs/SingleSource/UnitTests/test.c Sat Apr 2 20:05:33 2005 @@ -90,3 +90,51 @@ b = (*env)->GetByteField(env, obj, id); Java_Test_println__I(env, objClass, b); } + +void Java_Test_printStaticFields(JNIEnv *env, jclass clazz) +{ + jclass classTest; + jfieldID id; + jboolean z; + jint i; + jlong l; + jfloat f; + jdouble d; + jshort s; + jbyte b; + + classTest = (*env)->FindClass(env, "Test"); + if (!classTest) + printf("ERROR: Class Test not found!\n"); + + if (!(*env)->IsAssignableFrom(env, clazz, classTest)) + printf("ERROR: IsAssignableFrom\n"); + + id = (*env)->GetStaticFieldID(env, clazz, "Z", "Z"); + z = (*env)->GetStaticBooleanField(env, clazz, id); + Java_Test_println__Z(env, clazz, z); + + id = (*env)->GetStaticFieldID(env, clazz, "I", "I"); + i = (*env)->GetStaticIntField(env, clazz, id); + Java_Test_println__I(env, clazz, i); + + id = (*env)->GetStaticFieldID(env, clazz, "L", "J"); + l = (*env)->GetStaticLongField(env, clazz, id); + Java_Test_println__J(env, clazz, l); + + id = (*env)->GetStaticFieldID(env, clazz, "F", "F"); + f = (*env)->GetStaticFloatField(env, clazz, id); + Java_Test_println__F(env, clazz, f); + + id = (*env)->GetStaticFieldID(env, clazz, "D", "D"); + d = (*env)->GetStaticDoubleField(env, clazz, id); + Java_Test_println__D(env, clazz, d); + + id = (*env)->GetStaticFieldID(env, clazz, "S", "S"); + s = (*env)->GetStaticShortField(env, clazz, id); + Java_Test_println__I(env, clazz, s); + + id = (*env)->GetStaticFieldID(env, clazz, "B", "B"); + b = (*env)->GetStaticByteField(env, clazz, id); + Java_Test_println__I(env, clazz, b); +} Index: llvm-java/test/Programs/SingleSource/UnitTests/Test.java diff -u llvm-java/test/Programs/SingleSource/UnitTests/Test.java:1.8 llvm-java/test/Programs/SingleSource/UnitTests/Test.java:1.9 --- llvm-java/test/Programs/SingleSource/UnitTests/Test.java:1.8 Sat Apr 2 19:10:15 2005 +++ llvm-java/test/Programs/SingleSource/UnitTests/Test.java Sat Apr 2 20:05:33 2005 @@ -8,6 +8,14 @@ public short s = 456; public byte b = 78; + public static boolean Z = true; + public static int I = 321; + public static long L = 1234567890987654321L; + public static float F = 46.753F; + public static double D = -75346.46; + public static short S = 654; + public static byte B = 87; + static { System.loadLibrary("test"); } @@ -28,6 +36,7 @@ private static native void println(byte[] a); public native void printFields(); + public static native void printStaticFields(); public static void main(String[] args) { println(true); @@ -43,6 +52,7 @@ println(new byte[] { 'H', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd' }); println("Hello world"); + printStaticFields(); new Test().printFields(); } } From alkis at cs.uiuc.edu Sat Apr 2 20:43:20 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 2 Apr 2005 20:43:20 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200504030243.UAA09927@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.279 -> 1.280 --- Log message: Pass the class record as a second argument in a JNI call to a static method. --- Diffs of the changes: (+3 -1) Compiler.cpp | 4 +++- 1 files changed, 3 insertions(+), 1 deletion(-) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.279 llvm-java/lib/Compiler/Compiler.cpp:1.280 --- llvm-java/lib/Compiler/Compiler.cpp:1.279 Sat Apr 2 18:22:55 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Sat Apr 2 20:43:09 2005 @@ -287,7 +287,9 @@ std::vector params; params.push_back(JNIEnvPtr_); if (method->isStatic()) - params.push_back(llvm::Constant::getNullValue(resolver_->getObjectBaseType())); + params.push_back( + new CastInst(method->getParent()->getClassRecord(), + resolver_->getObjectBaseType(), TMP, bb)); for (Function::arg_iterator A = function->arg_begin(), E = function->arg_end(); A != E; ++A) { params.push_back( From alkis at cs.uiuc.edu Sat Apr 2 20:49:55 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 2 Apr 2005 20:49:55 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/VMClass.h VMClass.cpp Resolver.cpp Message-ID: <200504030249.UAA10005@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: VMClass.h updated: 1.31 -> 1.32 VMClass.cpp updated: 1.41 -> 1.42 Resolver.cpp updated: 1.20 -> 1.21 --- Log message: Implement get/set static field for JNI. --- Diffs of the changes: (+60 -1) Resolver.cpp | 4 ++++ VMClass.cpp | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++- VMClass.h | 3 +++ 3 files changed, 60 insertions(+), 1 deletion(-) Index: llvm-java/lib/Compiler/VMClass.h diff -u llvm-java/lib/Compiler/VMClass.h:1.31 llvm-java/lib/Compiler/VMClass.h:1.32 --- llvm-java/lib/Compiler/VMClass.h:1.31 Sat Apr 2 19:12:05 2005 +++ llvm-java/lib/Compiler/VMClass.h Sat Apr 2 20:49:44 2005 @@ -48,6 +48,7 @@ std::vector superClasses_; std::vector interfaces_; std::vector memberFields_; + std::vector staticFields_; std::vector dynamicallyBoundMethods_; GlobalVariable* classRecord_; @@ -62,6 +63,8 @@ llvm::Constant* buildInterfaceClassRecords() const; llvm::Constant* buildFieldDescriptors() const; llvm::Constant* buildFieldOffsets() const; + llvm::Constant* buildStaticFieldDescriptors() const; + llvm::Constant* buildStaticFieldPointers() const; llvm::Constant* buildClassTypeInfo() const; const VMField* lookupField(const std::string& name) const; Index: llvm-java/lib/Compiler/VMClass.cpp diff -u llvm-java/lib/Compiler/VMClass.cpp:1.41 llvm-java/lib/Compiler/VMClass.cpp:1.42 --- llvm-java/lib/Compiler/VMClass.cpp:1.41 Sat Apr 2 19:12:05 2005 +++ llvm-java/lib/Compiler/VMClass.cpp Sat Apr 2 20:49:44 2005 @@ -163,7 +163,9 @@ Field* field = fields[i]; const std::string& name = field->getName()->str(); if (field->isStatic()) { - fieldMap_.insert(std::make_pair(name, VMField(this, field))); + FieldMap::iterator i = fieldMap_.insert( + std::make_pair(name, VMField(this, field))).first; + staticFields_.push_back(&i->second); } else { unsigned index = memberFields_.size() + 1; @@ -344,6 +346,54 @@ resolver_->getModule())); } +llvm::Constant* VMClass::buildStaticFieldDescriptors() const +{ + std::vector init; + init.reserve(staticFields_.size()+1); + + for (unsigned i = 0, e = staticFields_.size(); i != e; ++i) { + const VMField* field = staticFields_[i]; + init.push_back(field->buildFieldDescriptor()); + } + // Null terminate. + init.push_back(llvm::Constant::getNullValue(PointerType::get(Type::SByteTy))); + + const ArrayType* arrayType = + ArrayType::get(init.back()->getType(), init.size()); + + return ConstantExpr::getPtrPtrFromArrayPtr( + new GlobalVariable( + arrayType, + true, + GlobalVariable::ExternalLinkage, + ConstantArray::get(arrayType, init), + getName() + "", + resolver_->getModule())); +} + +llvm::Constant* VMClass::buildStaticFieldPointers() const +{ + std::vector init; + init.reserve(staticFields_.size()); + + const Type* pointerType = PointerType::get(Type::SByteTy); + for (unsigned i = 0, e = staticFields_.size(); i != e; ++i) { + const VMField* field = staticFields_[i]; + init.push_back(ConstantExpr::getCast(field->getGlobal(), pointerType)); + } + + const ArrayType* arrayType = ArrayType::get(pointerType, init.size()); + + return ConstantExpr::getPtrPtrFromArrayPtr( + new GlobalVariable( + arrayType, + true, + GlobalVariable::ExternalLinkage, + ConstantArray::get(arrayType, init), + getName() + "", + resolver_->getModule())); +} + llvm::Constant* VMClass::buildClassTypeInfo() const { std::vector init; @@ -373,6 +423,8 @@ init.push_back(buildFieldDescriptors()); init.push_back(buildFieldOffsets()); + init.push_back(buildStaticFieldDescriptors()); + init.push_back(buildStaticFieldPointers()); return ConstantStruct::get(init); } Index: llvm-java/lib/Compiler/Resolver.cpp diff -u llvm-java/lib/Compiler/Resolver.cpp:1.20 llvm-java/lib/Compiler/Resolver.cpp:1.21 --- llvm-java/lib/Compiler/Resolver.cpp:1.20 Sat Apr 2 19:12:05 2005 +++ llvm-java/lib/Compiler/Resolver.cpp Sat Apr 2 20:49:44 2005 @@ -49,6 +49,8 @@ // int elementSize; // char** fieldDescriptors; // unsigned* fieldOffsets; + // char** staticFieldDescriptors; + // void** staticFields; // }; // Compute the type_info type. @@ -62,6 +64,8 @@ elements.push_back(Type::IntTy); elements.push_back(PointerType::get(PointerType::get(Type::SByteTy))); elements.push_back(PointerType::get(Type::UIntTy)); + elements.push_back(PointerType::get(PointerType::get(Type::SByteTy))); + elements.push_back(PointerType::get(PointerType::get(Type::SByteTy))); typeInfoType_ = StructType::get(elements); module_->addTypeName("struct.llvm_java_typeinfo", getTypeInfoType()); From alkis at cs.uiuc.edu Sat Apr 2 20:49:56 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sat, 2 Apr 2005 20:49:56 -0600 Subject: [llvm-commits] CVS: llvm-java/runtime/runtime.h jni.c Message-ID: <200504030249.UAA10011@zion.cs.uiuc.edu> Changes in directory llvm-java/runtime: runtime.h updated: 1.3 -> 1.4 jni.c updated: 1.2 -> 1.3 --- Log message: Implement get/set static field for JNI. --- Diffs of the changes: (+70 -22) jni.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++---------------- runtime.h | 15 +++++++++--- 2 files changed, 70 insertions(+), 22 deletions(-) Index: llvm-java/runtime/runtime.h diff -u llvm-java/runtime/runtime.h:1.3 llvm-java/runtime/runtime.h:1.4 --- llvm-java/runtime/runtime.h:1.3 Sat Apr 2 19:12:05 2005 +++ llvm-java/runtime/runtime.h Sat Apr 2 20:49:44 2005 @@ -48,14 +48,23 @@ * for interfaces and -2 for primitive classes. */ jint elementSize; - /* A null terminated array of strings describing the fields of this - * class. A field description is the concatenation of its name with - * its descriptor. */ + /* A null terminated array of strings describing the member fields + * of this class. A field description is the concatenation of its + * name with its descriptor. */ const char** fieldDescriptors; /* An array of offsets to fields. This is indexed the same way as * the field descriptor array. */ jfieldID* fieldOffsets; + + /* A null terminated array of strings describing the static fields + * of this class. A field description is the concatenation of its + * name with its descriptor. */ + const char** staticFieldDescriptors; + + /* An array of pointers to static fields. This is the indexed the + * same way as the static field descriptor array. */ + void** staticFields; }; struct llvm_java_class_record { Index: llvm-java/runtime/jni.c diff -u llvm-java/runtime/jni.c:1.2 llvm-java/runtime/jni.c:1.3 --- llvm-java/runtime/jni.c:1.2 Sat Apr 2 19:12:05 2005 +++ llvm-java/runtime/jni.c Sat Apr 2 20:49:44 2005 @@ -45,6 +45,45 @@ return 0; } +static jfieldID get_static_fieldid(JNIEnv *env, + jclass clazz, + const char *name, + const char *sig) { + int nameLength; + int i; + const char* fieldDescriptor; + struct llvm_java_class_record* cr = GET_CLASS_RECORD(clazz); + + /* lookup the name+sig in the staticFieldDescriptors array and + * retrieve the index of the field */ + nameLength = strlen(name); + for (i = 0; (fieldDescriptor = cr->typeinfo.staticFieldDescriptors[i]); ++i) + if (strncmp(name, fieldDescriptor, nameLength) == 0 && + strcmp(sig, fieldDescriptor+nameLength) == 0) + return i; + + return 0; +} + +#define HANDLE_TYPE(TYPE) \ + static j##TYPE get_static_##TYPE##_field(JNIEnv* env, \ + jclass clazz, \ + jfieldID fid) { \ + struct llvm_java_class_record* cr = GET_CLASS_RECORD(clazz); \ + return *(j##TYPE*) cr->typeinfo.staticFields[fid]; \ + } +#include "types.def" + +#define HANDLE_TYPE(TYPE) \ + static void set_static_##TYPE##_field(JNIEnv* env, \ + jclass clazz, \ + jfieldID fid, \ + j##TYPE value) { \ + struct llvm_java_class_record* cr = GET_CLASS_RECORD(clazz); \ + *(j##TYPE*) cr->typeinfo.staticFields[fid] = value; \ + } +#include "types.def" + #define HANDLE_TYPE(TYPE) \ static j##TYPE get_##TYPE##_field(JNIEnv* env, \ jobject obj, \ @@ -241,25 +280,25 @@ NULL, NULL, NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, /* 150 */ - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, /* 160 */ - NULL, - NULL, + &get_static_fieldid, + &get_static_object_field, + &get_static_boolean_field, + &get_static_byte_field, + &get_static_char_field, + &get_static_short_field, + &get_static_int_field, + &get_static_long_field, + &get_static_float_field, + &get_static_double_field, + &set_static_object_field, + &set_static_boolean_field, + &set_static_byte_field, + &set_static_char_field, + &set_static_short_field, + &set_static_int_field, + &set_static_long_field, + &set_static_float_field, + &set_static_double_field, NULL, NULL, NULL, From natebegeman at mac.com Sun Apr 3 06:20:31 2005 From: natebegeman at mac.com (Nate Begeman) Date: Sun, 3 Apr 2005 06:20:31 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Message-ID: <200504031120.GAA06624@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPC32ISelPattern.cpp updated: 1.35 -> 1.36 --- Log message: Keeping up with the Joneses. Implement not, nor, nand, and eqv --- Diffs of the changes: (+51 -10) PPC32ISelPattern.cpp | 61 ++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 51 insertions(+), 10 deletions(-) Index: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp diff -u llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.35 llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.36 --- llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.35 Fri Apr 1 23:59:34 2005 +++ llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Sun Apr 3 06:20:20 2005 @@ -409,7 +409,7 @@ } namespace { - +Statistic<>NotLogic("ppc-codegen", "Number of inverted logical ops"); //===--------------------------------------------------------------------===// /// ISel - PPC32 specific code to select PPC32 machine instructions for /// SelectionDAG operations. @@ -1195,8 +1195,6 @@ case ISD::AND: case ISD::OR: - case ISD::XOR: - assert (DestType == MVT::i32 && "Only do arithmetic on i32s!"); Tmp1 = SelectExpr(N.getOperand(0)); switch(canUseAsImmediateForOpcode(N.getOperand(1), opcode, Tmp2)) { default: assert(0 && "unhandled result code"); @@ -1205,7 +1203,6 @@ switch (opcode) { case ISD::AND: Opc = PPC::AND; break; case ISD::OR: Opc = PPC::OR; break; - case ISD::XOR: Opc = PPC::XOR; break; } BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); break; @@ -1213,7 +1210,6 @@ switch (opcode) { case ISD::AND: Opc = PPC::ANDIo; break; case ISD::OR: Opc = PPC::ORI; break; - case ISD::XOR: Opc = PPC::XORI; break; } BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addImm(Tmp2); break; @@ -1221,15 +1217,63 @@ switch (opcode) { case ISD::AND: Opc = PPC::ANDISo; break; case ISD::OR: Opc = PPC::ORIS; break; - case ISD::XOR: Opc = PPC::XORIS; break; } BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addImm(Tmp2); break; } return Result; + case ISD::XOR: { + // Check for EQV: xor, (xor a, -1), b + if (N.getOperand(0).getOpcode() == ISD::XOR && + N.getOperand(0).getOperand(1).getOpcode() == ISD::Constant && + cast(N.getOperand(0).getOperand(1))->isAllOnesValue()) { + ++NotLogic; + Tmp1 = SelectExpr(N.getOperand(0).getOperand(0)); + Tmp2 = SelectExpr(N.getOperand(1)); + BuildMI(BB, PPC::EQV, 2, Result).addReg(Tmp1).addReg(Tmp2); + return Result; + } + // Check for NOT, NOR, and NAND: xor (copy, or, and), -1 + if (N.getOperand(1).getOpcode() == ISD::Constant && + cast(N.getOperand(1))->isAllOnesValue()) { + ++NotLogic; + switch(N.getOperand(0).getOpcode()) { + case ISD::OR: + Tmp1 = SelectExpr(N.getOperand(0).getOperand(0)); + Tmp2 = SelectExpr(N.getOperand(0).getOperand(1)); + BuildMI(BB, PPC::NOR, 2, Result).addReg(Tmp1).addReg(Tmp2); + break; + case ISD::AND: + Tmp1 = SelectExpr(N.getOperand(0).getOperand(0)); + Tmp2 = SelectExpr(N.getOperand(0).getOperand(1)); + BuildMI(BB, PPC::NAND, 2, Result).addReg(Tmp1).addReg(Tmp2); + break; + default: + Tmp1 = SelectExpr(N.getOperand(0)); + BuildMI(BB, PPC::NOR, 2, Result).addReg(Tmp1).addReg(Tmp1); + break; + } + return Result; + } + Tmp1 = SelectExpr(N.getOperand(0)); + switch(canUseAsImmediateForOpcode(N.getOperand(1), opcode, Tmp2)) { + default: assert(0 && "unhandled result code"); + case 0: // No immediate + Tmp2 = SelectExpr(N.getOperand(1)); + BuildMI(BB, PPC::XOR, 2, Result).addReg(Tmp1).addReg(Tmp2); + break; + case 1: // Low immediate + BuildMI(BB, PPC::XORI, 2, Result).addReg(Tmp1).addImm(Tmp2); + break; + case 2: // Shifted immediate + BuildMI(BB, PPC::XORIS, 2, Result).addReg(Tmp1).addImm(Tmp2); + break; + } + return Result; + } + case ISD::SUB: - assert (DestType == MVT::i32 && "Only do arithmetic on i32s!"); Tmp2 = SelectExpr(N.getOperand(1)); if (1 == canUseAsImmediateForOpcode(N.getOperand(0), opcode, Tmp1)) BuildMI(BB, PPC::SUBFIC, 2, Result).addReg(Tmp2).addSImm(Tmp1); @@ -1240,7 +1284,6 @@ return Result; case ISD::MUL: - assert (DestType == MVT::i32 && "Only do arithmetic on i32s!"); Tmp1 = SelectExpr(N.getOperand(0)); if (1 == canUseAsImmediateForOpcode(N.getOperand(1), opcode, Tmp2)) BuildMI(BB, PPC::MULLI, 2, Result).addReg(Tmp1).addSImm(Tmp2); @@ -1252,7 +1295,6 @@ case ISD::SDIV: case ISD::UDIV: - assert (DestType == MVT::i32 && "Only do arithmetic on i32s!"); Tmp1 = SelectExpr(N.getOperand(0)); Tmp2 = SelectExpr(N.getOperand(1)); Opc = (ISD::UDIV == opcode) ? PPC::DIVWU : PPC::DIVW; @@ -1261,7 +1303,6 @@ case ISD::UREM: case ISD::SREM: { - assert (DestType == MVT::i32 && "Only do arithmetic on i32s!"); Tmp1 = SelectExpr(N.getOperand(0)); Tmp2 = SelectExpr(N.getOperand(1)); Tmp3 = MakeReg(MVT::i32); From duraid at octopus.com.au Sun Apr 3 09:52:12 2005 From: duraid at octopus.com.au (Duraid Madina) Date: Sun, 3 Apr 2005 09:52:12 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/IA64/IA64AsmPrinter.cpp Message-ID: <200504031452.JAA13637@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/IA64: IA64AsmPrinter.cpp updated: 1.6 -> 1.7 --- Log message: .bss is no problem here. --- Diffs of the changes: (+0 -1) IA64AsmPrinter.cpp | 1 - 1 files changed, 1 deletion(-) Index: llvm/lib/Target/IA64/IA64AsmPrinter.cpp diff -u llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.6 llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.7 --- llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.6 Sat Apr 2 06:30:47 2005 +++ llvm/lib/Target/IA64/IA64AsmPrinter.cpp Sun Apr 3 09:52:01 2005 @@ -143,7 +143,6 @@ case GlobalValue::InternalLinkage: if (C->isNullValue()) SwitchSection(O, CurSection, ".bss"); - // FIXME? in ia64-land .bss means "nobits" (i.e. uninitialized) else SwitchSection(O, CurSection, ".data"); break; From duraid at octopus.com.au Sun Apr 3 09:57:46 2005 From: duraid at octopus.com.au (Duraid Madina) Date: Sun, 3 Apr 2005 09:57:46 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/AsmPrinter.h Message-ID: <200504031457.JAA13665@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: AsmPrinter.h updated: 1.11 -> 1.12 --- Log message: a wise man once said: "!!!!!!!! IF YOU CHANGE SPACES TO TABS, YOU WILL BE KILLED!!!!!!" --- Diffs of the changes: (+4 -4) AsmPrinter.h | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) Index: llvm/include/llvm/CodeGen/AsmPrinter.h diff -u llvm/include/llvm/CodeGen/AsmPrinter.h:1.11 llvm/include/llvm/CodeGen/AsmPrinter.h:1.12 --- llvm/include/llvm/CodeGen/AsmPrinter.h:1.11 Sat Apr 2 06:21:51 2005 +++ llvm/include/llvm/CodeGen/AsmPrinter.h Sun Apr 3 09:57:35 2005 @@ -102,10 +102,10 @@ : O(o), TM(tm), CommentString("#"), GlobalPrefix(""), - GlobalVarAddrPrefix(""), - GlobalVarAddrSuffix(""), - FunctionAddrPrefix(""), - FunctionAddrSuffix(""), + GlobalVarAddrPrefix(""), + GlobalVarAddrSuffix(""), + FunctionAddrPrefix(""), + FunctionAddrSuffix(""), ZeroDirective("\t.zero\t"), AsciiDirective("\t.ascii\t"), Data8bitsDirective("\t.byte\t"), From alenhar2 at cs.uiuc.edu Sun Apr 3 13:25:07 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Sun, 3 Apr 2005 13:25:07 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp Message-ID: <200504031825.j33IP79d011178@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.77 -> 1.78 --- Log message: fix 101 regressions --- Diffs of the changes: (+3 -3) AlphaISelPattern.cpp | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.77 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.78 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.77 Sat Apr 2 16:32:39 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Sun Apr 3 13:24:50 2005 @@ -1591,7 +1591,7 @@ //Int SetCC -> Select //Dropping the CC is only useful if we are comparing to 0 if(SetCC->getOperand(1).getOpcode() == ISD::Constant && - cast(SetCC->getOperand(0))->getValue() == 0) + cast(SetCC->getOperand(1))->getValue() == 0) { bool useI = (SetCC->getOperand(1).getOpcode() == ISD::Constant && cast(SetCC->getOperand(1))->getValue() <= 255); @@ -1617,8 +1617,8 @@ .addReg(SelectExpr(SetCC->getOperand(1))); return Result; } - if(SetCC->getOperand(1).getOpcode() == ISD::Constant && - cast(SetCC->getOperand(1))->getValue() == 0) + if(SetCC->getOperand(0).getOpcode() == ISD::Constant && + cast(SetCC->getOperand(0))->getValue() == 0) { bool useI = (SetCC->getOperand(0).getOpcode() == ISD::Constant && cast(SetCC->getOperand(0))->getValue() <= 255); From alenhar2 at cs.uiuc.edu Sun Apr 3 15:35:39 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Sun, 3 Apr 2005 15:35:39 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp Message-ID: <200504032035.j33KZd6r012294@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.78 -> 1.79 --- Log message: is this simpler? I think it is simpler. --- Diffs of the changes: (+83 -85) AlphaISelPattern.cpp | 168 +++++++++++++++++++++++++-------------------------- 1 files changed, 83 insertions(+), 85 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.78 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.79 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.78 Sun Apr 3 13:24:50 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Sun Apr 3 15:35:21 2005 @@ -518,37 +518,21 @@ 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 LeftZero = SetCC->getOperand(0).getOpcode() == ISD::Constant && + cast(SetCC->getOperand(0))->getValue() == 0; + bool RightZero = SetCC->getOperand(0).getOpcode() == ISD::Constant && + cast(SetCC->getOperand(0))->getValue() == 0; 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) + + //Fix up CC + ISD::CondCode cCode= SetCC->getCondition(); + if (LeftZero && !RightZero) //Swap Operands + cCode = ISD::getSetCCSwappedOperands(cCode); + + if(cCode == 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) { + if (LeftZero || RightZero) { switch (SetCC->getCondition()) { default: CC.Val->dump(); assert(0 && "Unknown integer comparison!"); case ISD::SETEQ: Opc = Alpha::BEQ; break; @@ -562,7 +546,11 @@ 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)); + unsigned Tmp1; + if(LeftZero && !RightZero) //swap Operands + Tmp1 = SelectExpr(SetCC->getOperand(1)); //Cond + else + Tmp1 = SelectExpr(SetCC->getOperand(0)); //Cond BuildMI(BB, Opc, 2).addReg(Tmp1).addMBB(Dest); return; } else { @@ -1571,10 +1559,11 @@ { //FIXME: look at parent to decide if intCC can be folded, or if setCC(FP) and can save stack use //Tmp1 = SelectExpr(N.getOperand(0)); //Cond - Tmp2 = SelectExpr(N.getOperand(1)); //Use if TRUE - Tmp3 = SelectExpr(N.getOperand(2)); //Use if FALSE + //Tmp2 = SelectExpr(N.getOperand(1)); //Use if TRUE + //Tmp3 = SelectExpr(N.getOperand(2)); //Use if FALSE // Get the condition into the zero flag. //BuildMI(BB, Alpha::CMOVEQ, 2, Result).addReg(Tmp2).addReg(Tmp3).addReg(Tmp1); + SDOperand CC = N.getOperand(0); SetCCSDNode* SetCC = dyn_cast(CC.Val); @@ -1582,6 +1571,8 @@ !MVT::isInteger(SetCC->getOperand(0).getValueType())) { //FP Setcc -> Int Select Tmp1 = MakeReg(MVT::f64); + Tmp2 = SelectExpr(N.getOperand(1)); //Use if TRUE + Tmp3 = SelectExpr(N.getOperand(2)); //Use if FALSE bool inv = SelectFPSetCC(CC, Tmp1); BuildMI(BB, inv?Alpha::CMOVNE_FP:Alpha::CMOVEQ_FP, 2, Result) .addReg(Tmp2).addReg(Tmp3).addReg(Tmp1); @@ -1590,63 +1581,70 @@ if (CC.getOpcode() == ISD::SETCC) { //Int SetCC -> Select //Dropping the CC is only useful if we are comparing to 0 - if(SetCC->getOperand(1).getOpcode() == ISD::Constant && - cast(SetCC->getOperand(1))->getValue() == 0) - { - bool useI = (SetCC->getOperand(1).getOpcode() == ISD::Constant && - cast(SetCC->getOperand(1))->getValue() <= 255); - - switch (SetCC->getCondition()) { - default: CC.Val->dump(); assert(0 && "Unknown integer comparison!"); - case ISD::SETEQ: Opc = useI?Alpha::CMOVEQi:Alpha::CMOVEQ; break; - case ISD::SETLT: Opc = useI?Alpha::CMOVGTi:Alpha::CMOVGT; break; - case ISD::SETLE: Opc = useI?Alpha::CMOVGEi:Alpha::CMOVGE; break; - case ISD::SETGT: Opc = useI?Alpha::CMOVLTi:Alpha::CMOVLT; break; - case ISD::SETGE: Opc = useI?Alpha::CMOVLEi:Alpha::CMOVLE; break; - case ISD::SETULT: Opc = useI?Alpha::CMOVNEi:Alpha::CMOVNE; 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 = useI?Alpha::CMOVEQi:Alpha::CMOVEQ; break; //Technically you could have this CC - case ISD::SETNE: Opc = useI?Alpha::CMOVNEi:Alpha::CMOVNE; break; - } - if (useI) - BuildMI(BB, Opc, 2, Result).addReg(Tmp2).addReg(Tmp3) - .addImm(cast(SetCC->getOperand(1))->getValue()); - else - BuildMI(BB, Opc, 2, Result).addReg(Tmp2).addReg(Tmp3) - .addReg(SelectExpr(SetCC->getOperand(1))); - return Result; - } - if(SetCC->getOperand(0).getOpcode() == ISD::Constant && - cast(SetCC->getOperand(0))->getValue() == 0) - { - bool useI = (SetCC->getOperand(0).getOpcode() == ISD::Constant && - cast(SetCC->getOperand(0))->getValue() <= 255); - - switch (SetCC->getCondition()) { - default: CC.Val->dump(); assert(0 && "Unknown integer comparison!"); - case ISD::SETEQ: Opc = useI?Alpha::CMOVEQi:Alpha::CMOVEQ; break; - case ISD::SETLT: Opc = useI?Alpha::CMOVLTi:Alpha::CMOVLT; break; - case ISD::SETLE: Opc = useI?Alpha::CMOVLEi:Alpha::CMOVLE; break; - case ISD::SETGT: Opc = useI?Alpha::CMOVGTi:Alpha::CMOVGT; break; - case ISD::SETGE: Opc = useI?Alpha::CMOVGEi:Alpha::CMOVGE; break; - case ISD::SETULT: assert(0 && "x (unsigned) < 0 is never true"); break; - case ISD::SETUGT: Opc = useI?Alpha::CMOVNEi:Alpha::CMOVNE; break; - case ISD::SETULE: Opc = useI?Alpha::CMOVEQi:Alpha::CMOVEQ; break; //Technically you could have this CC - case ISD::SETUGE: assert(0 && "x (unsgined >= 0 is always true"); break; - case ISD::SETNE: Opc = useI?Alpha::CMOVNEi:Alpha::CMOVNE; break; - } - if (useI) - BuildMI(BB, Opc, 2, Result).addReg(Tmp2).addReg(Tmp3) - .addImm(cast(SetCC->getOperand(0))->getValue()); - else - BuildMI(BB, Opc, 2, Result).addReg(Tmp2).addReg(Tmp3) - .addReg(SelectExpr(SetCC->getOperand(0))); - return Result; - } + if((SetCC->getOperand(1).getOpcode() == ISD::Constant && + cast(SetCC->getOperand(1))->getValue() == 0) || + (SetCC->getOperand(0).getOpcode() == ISD::Constant && + cast(SetCC->getOperand(0))->getValue() == 0)) + { + //figure out a few things + bool LeftZero = SetCC->getOperand(0).getOpcode() == ISD::Constant && + cast(SetCC->getOperand(0))->getValue() == 0; + bool RightZero = SetCC->getOperand(0).getOpcode() == ISD::Constant && + cast(SetCC->getOperand(0))->getValue() == 0; + bool LeftConst = N.getOperand(1).getOpcode() == ISD::Constant && + cast(N.getOperand(1))->getValue() <= 255; + bool RightConst = N.getOperand(2).getOpcode() == ISD::Constant && + cast(N.getOperand(2))->getValue() <= 255; + bool useImm = LeftConst || RightConst; + + //Fix up CC + ISD::CondCode cCode= SetCC->getCondition(); + if (RightConst && !LeftConst) //Invert sense to get Imm field right + cCode = ISD::getSetCCInverse(cCode, true); + if (LeftZero && !RightZero) //Swap Operands + cCode = ISD::getSetCCSwappedOperands(cCode); + + //Choose the CMOV + switch (cCode) { + default: CC.Val->dump(); assert(0 && "Unknown integer comparison!"); + case ISD::SETEQ: Opc = useImm?Alpha::CMOVEQi:Alpha::CMOVEQ; break; + case ISD::SETLT: Opc = useImm?Alpha::CMOVLTi:Alpha::CMOVLT; break; + case ISD::SETLE: Opc = useImm?Alpha::CMOVLEi:Alpha::CMOVLE; break; + case ISD::SETGT: Opc = useImm?Alpha::CMOVGTi:Alpha::CMOVGT; break; + case ISD::SETGE: Opc = useImm?Alpha::CMOVGEi:Alpha::CMOVGE; break; + case ISD::SETULT: assert(0 && "x (unsigned) < 0 is never true"); break; + case ISD::SETUGT: Opc = useImm?Alpha::CMOVNEi:Alpha::CMOVNE; break; + case ISD::SETULE: Opc = useImm?Alpha::CMOVEQi:Alpha::CMOVEQ; break; //Technically you could have this CC + case ISD::SETUGE: assert(0 && "x (unsgined >= 0 is always true"); break; + case ISD::SETNE: Opc = useImm?Alpha::CMOVNEi:Alpha::CMOVNE; break; + } + if(LeftZero && !RightZero) //swap Operands + Tmp1 = SelectExpr(SetCC->getOperand(1)); //Cond + else + Tmp1 = SelectExpr(SetCC->getOperand(0)); //Cond + + if (LeftConst) { + Tmp3 = SelectExpr(N.getOperand(2)); //Use if FALSE + BuildMI(BB, Opc, 2, Result).addReg(Tmp3) + .addImm(cast(N.getOperand(1))->getValue()) + .addReg(Tmp1); + } else if (RightConst) { + Tmp3 = SelectExpr(N.getOperand(1)); //Use if FALSE + BuildMI(BB, Opc, 2, Result).addReg(Tmp3) + .addImm(cast(N.getOperand(2))->getValue()) + .addReg(Tmp1); + } else { + Tmp2 = SelectExpr(N.getOperand(1)); //Use if TRUE + Tmp3 = SelectExpr(N.getOperand(2)); //Use if FALSE + BuildMI(BB, Opc, 2, Result).addReg(Tmp3).addReg(Tmp2).addReg(Tmp1); + } + return Result; + } //Otherwise, fall though } Tmp1 = SelectExpr(N.getOperand(0)); //Cond + Tmp2 = SelectExpr(N.getOperand(1)); //Use if TRUE + Tmp3 = SelectExpr(N.getOperand(2)); //Use if FALSE BuildMI(BB, Alpha::CMOVEQ, 2, Result).addReg(Tmp2).addReg(Tmp3).addReg(Tmp1); return Result; From natebegeman at mac.com Sun Apr 3 17:13:40 2005 From: natebegeman at mac.com (Nate Begeman) Date: Sun, 3 Apr 2005 17:13:40 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Message-ID: <200504032213.RAA15508@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPC32ISelPattern.cpp updated: 1.36 -> 1.37 --- Log message: Fix SHL_PARTS Start implementation of integer varargs --- Diffs of the changes: (+10 -2) PPC32ISelPattern.cpp | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-) Index: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp diff -u llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.36 llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.37 --- llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.36 Sun Apr 3 06:20:20 2005 +++ llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Sun Apr 3 17:13:27 2005 @@ -192,8 +192,16 @@ // If the function takes variable number of arguments, make a frame index for // the start of the first vararg value... for expansion of llvm.va_start. - if (F.isVarArg()) + if (F.isVarArg()) { VarArgsFrameIndex = MFI->CreateFixedObject(4, ArgOffset); + // If this function is vararg, store r4-r10 to their spots on the stack so + // that they may be loaded by dereferencing va_next + SDOperand FIN = DAG.getFrameIndex(VarArgsFrameIndex, MVT::i32); + SDOperand Val = DAG.getCopyFromReg(PPC::R4, MVT::i32, DAG.getRoot()); + SDOperand Store = DAG.getNode(ISD::STORE, MVT::Other, Val, Val, FIN); + DAG.setRoot(Val.getValue(1)); + ArgValues.push_back(Store); + } return ArgValues; } @@ -1352,7 +1360,7 @@ BuildMI(BB, PPC::SRW, 2, Tmp3).addReg(ShiftOpLo).addReg(Tmp1); BuildMI(BB, PPC::OR, 2, Tmp4).addReg(Tmp2).addReg(Tmp3); BuildMI(BB, PPC::ADDI, 2, Tmp5).addReg(SHReg).addSImm(-32); - BuildMI(BB, PPC::SLW, 2, Tmp6).addReg(ShiftOpHi).addReg(Tmp5); + BuildMI(BB, PPC::SLW, 2, Tmp6).addReg(ShiftOpLo).addReg(Tmp5); BuildMI(BB, PPC::OR, 2, Result+1).addReg(Tmp4).addReg(Tmp6); BuildMI(BB, PPC::SLW, 2, Result).addReg(ShiftOpLo).addReg(SHReg); } else if (ISD::SRL_PARTS == opcode) { From natebegeman at mac.com Sun Apr 3 17:23:07 2005 From: natebegeman at mac.com (Nate Begeman) Date: Sun, 3 Apr 2005 17:23:07 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Message-ID: <200504032223.RAA15547@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPC32ISelPattern.cpp updated: 1.37 -> 1.38 --- Log message: Pass the correct value for the chain to the store --- Diffs of the changes: (+2 -3) PPC32ISelPattern.cpp | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) Index: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp diff -u llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.37 llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.38 --- llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.37 Sun Apr 3 17:13:27 2005 +++ llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Sun Apr 3 17:22:56 2005 @@ -198,9 +198,8 @@ // that they may be loaded by dereferencing va_next SDOperand FIN = DAG.getFrameIndex(VarArgsFrameIndex, MVT::i32); SDOperand Val = DAG.getCopyFromReg(PPC::R4, MVT::i32, DAG.getRoot()); - SDOperand Store = DAG.getNode(ISD::STORE, MVT::Other, Val, Val, FIN); - DAG.setRoot(Val.getValue(1)); - ArgValues.push_back(Store); + SDOperand Store = DAG.getNode(ISD::STORE, MVT::Other, Val.getValue(1), Val, FIN); + DAG.setRoot(Store); } return ArgValues; From alkis at cs.uiuc.edu Sun Apr 3 18:05:18 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sun, 3 Apr 2005 18:05:18 -0500 Subject: [llvm-commits] CVS: llvm-java/runtime/runtime.h runtime.c Message-ID: <200504032305.SAA15747@zion.cs.uiuc.edu> Changes in directory llvm-java/runtime: runtime.h updated: 1.4 -> 1.5 runtime.c updated: 1.35 -> 1.36 --- Log message: Implement get superclass in the runtime. --- Diffs of the changes: (+17 -7) runtime.c | 11 ++++++++++- runtime.h | 13 +++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) Index: llvm-java/runtime/runtime.h diff -u llvm-java/runtime/runtime.h:1.4 llvm-java/runtime/runtime.h:1.5 --- llvm-java/runtime/runtime.h:1.4 Sat Apr 2 20:49:44 2005 +++ llvm-java/runtime/runtime.h Sun Apr 3 18:05:07 2005 @@ -82,9 +82,10 @@ struct llvm_java_class_record* llvm_java_find_class_record(const char* name); struct llvm_java_class_record* llvm_java_get_class_record(jobject obj); void llvm_java_set_class_record(jobject obj, struct llvm_java_class_record* cr); -jboolean -llvm_java_is_instance_of(jobject obj, struct llvm_java_class_record* cr); -jboolean -llvm_java_is_assignable_from(struct llvm_java_class_record* cr, - struct llvm_java_class_record* from); -jint llvm_java_throw(jobject obj); +jboolean llvm_java_is_instance_of(jobject obj, + struct llvm_java_class_record* cr); +struct llvm_java_class_record* llvm_java_get_superclass_record( + struct llvm_java_class_record* cr); +jboolean llvm_java_is_assignable_from(struct llvm_java_class_record* cr, + struct llvm_java_class_record* from); +jint llvm_java_throw(jthrowable obj); Index: llvm-java/runtime/runtime.c diff -u llvm-java/runtime/runtime.c:1.35 llvm-java/runtime/runtime.c:1.36 --- llvm-java/runtime/runtime.c:1.35 Sat Apr 2 18:37:08 2005 +++ llvm-java/runtime/runtime.c Sun Apr 3 18:05:07 2005 @@ -26,6 +26,15 @@ obj->classRecord = cr; } +struct llvm_java_class_record* +llvm_java_get_superclass_record(struct llvm_java_class_record* cr) { + /* If this is an interface or java/lang/Object return NULL. */ + if (llvm_java_is_interface_class(cr) || cr->typeinfo.depth == 0) + return NULL; + + return cr->typeinfo.superclasses[0]; +} + jboolean llvm_java_is_assignable_from(struct llvm_java_class_record* cr, struct llvm_java_class_record* from) { /* trivial case: class records are the same */ @@ -70,7 +79,7 @@ return llvm_java_is_assignable_from(obj->classRecord, cr); } -jint llvm_java_throw(jobject obj) { +jint llvm_java_throw(jthrowable obj) { abort(); } From alkis at cs.uiuc.edu Sun Apr 3 18:06:13 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sun, 3 Apr 2005 18:06:13 -0500 Subject: [llvm-commits] CVS: llvm-java/runtime/jni.c Message-ID: <200504032306.SAA15770@zion.cs.uiuc.edu> Changes in directory llvm-java/runtime: jni.c updated: 1.3 -> 1.4 --- Log message: Group method implemenations in sections as they are described in the JNI specification. Add implementation of Throw and GetSuperclass. --- Diffs of the changes: (+56 -17) jni.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 56 insertions(+), 17 deletions(-) Index: llvm-java/runtime/jni.c diff -u llvm-java/runtime/jni.c:1.3 llvm-java/runtime/jni.c:1.4 --- llvm-java/runtime/jni.c:1.3 Sat Apr 2 20:49:44 2005 +++ llvm-java/runtime/jni.c Sun Apr 3 18:06:02 2005 @@ -4,15 +4,33 @@ /* The implementation of JNI functions */ +/* Class operations */ + static jclass find_class(JNIEnv* env, const char* name) { return GET_CLASS(llvm_java_find_class_record(name)); } +static jclass get_superclass(JNIEnv* env, jclass clazz) { + return GET_CLASS(llvm_java_get_superclass_record(GET_CLASS_RECORD(clazz))); +} + static jboolean is_assignable_from(JNIEnv* env, jclass c1, jclass c2) { return llvm_java_is_assignable_from(GET_CLASS_RECORD(c1), GET_CLASS_RECORD(c2)); } +/* Exceptions */ + +static jint throw(JNIEnv* env, jthrowable obj) { + return llvm_java_throw(obj); +} + +/* Global and local references */ + +/* Weak global references */ + +/* Object operations */ + static jboolean is_same_object(JNIEnv* env, jobject o1, jobject o2) { return o1 == o2; } @@ -25,6 +43,8 @@ return llvm_java_is_instance_of(obj, GET_CLASS_RECORD(c)); } +/* Accessing fields of objects */ + static jfieldID get_fieldid(JNIEnv *env, jclass clazz, const char *name, @@ -45,6 +65,27 @@ return 0; } +#define HANDLE_TYPE(TYPE) \ + static j##TYPE get_##TYPE##_field(JNIEnv* env, \ + jobject obj, \ + jfieldID fid) { \ + return *(j##TYPE*) (((char*)obj) + fid); \ + } +#include "types.def" + +#define HANDLE_TYPE(TYPE) \ + static void set_##TYPE##_field(JNIEnv* env, \ + jobject obj, \ + jfieldID fid, \ + j##TYPE value) { \ + *(j##TYPE*) (((char*)obj) + fid) = value; \ + } +#include "types.def" + +/* Calling instance methods */ + +/* Accessing static fields */ + static jfieldID get_static_fieldid(JNIEnv *env, jclass clazz, const char *name, @@ -84,23 +125,11 @@ } #include "types.def" -#define HANDLE_TYPE(TYPE) \ - static j##TYPE get_##TYPE##_field(JNIEnv* env, \ - jobject obj, \ - jfieldID fid) { \ - return *(j##TYPE*) (((char*)obj) + fid); \ - } -#include "types.def" +/* Calling static methods */ -#define HANDLE_TYPE(TYPE) \ - static void set_##TYPE##_field(JNIEnv* env, \ - jobject obj, \ - jfieldID fid, \ - j##TYPE value) { \ - *(j##TYPE*) (((char*)obj) + fid) = value; \ - } -#include "types.def" +/* String operations */ +/* Array operations */ static jint get_array_length(JNIEnv* env, jarray array) { return ((struct llvm_java_booleanarray*) array)->length; @@ -134,6 +163,16 @@ } #include "types.def" +/* Register native methods */ + +/* Monitor operations */ + +/* NIO support */ + +/* Reflection support */ + +/* Java VM interface */ + /* The JNI interface definition */ static const struct JNINativeInterface llvm_java_JNINativeInterface = { NULL, /* 0 */ @@ -146,10 +185,10 @@ NULL, NULL, NULL, - NULL, /* 10 */ + &get_superclass, &is_assignable_from, NULL, - NULL, + &throw, NULL, NULL, NULL, From alkis at cs.uiuc.edu Sun Apr 3 18:10:55 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sun, 3 Apr 2005 18:10:55 -0500 Subject: [llvm-commits] CVS: llvm-java/runtime/runtime.h jni.c Message-ID: <200504032310.SAA15800@zion.cs.uiuc.edu> Changes in directory llvm-java/runtime: runtime.h updated: 1.5 -> 1.6 jni.c updated: 1.4 -> 1.5 --- Log message: Implement GetObjectArrayElement and SetObjectArrayElement. --- Diffs of the changes: (+12 -1) jni.c | 11 +++++++++++ runtime.h | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) Index: llvm-java/runtime/runtime.h diff -u llvm-java/runtime/runtime.h:1.5 llvm-java/runtime/runtime.h:1.6 --- llvm-java/runtime/runtime.h:1.5 Sun Apr 3 18:05:07 2005 +++ llvm-java/runtime/runtime.h Sun Apr 3 18:10:44 2005 @@ -71,7 +71,7 @@ struct llvm_java_typeinfo typeinfo; }; -#define HANDLE_NATIVE_TYPE(TYPE) \ +#define HANDLE_TYPE(TYPE) \ struct llvm_java_##TYPE##array { \ struct llvm_java_object_base object_base; \ jint length; \ Index: llvm-java/runtime/jni.c diff -u llvm-java/runtime/jni.c:1.4 llvm-java/runtime/jni.c:1.5 --- llvm-java/runtime/jni.c:1.4 Sun Apr 3 18:06:02 2005 +++ llvm-java/runtime/jni.c Sun Apr 3 18:10:44 2005 @@ -135,6 +135,17 @@ return ((struct llvm_java_booleanarray*) array)->length; } +static jobject get_object_array_element(JNIEnv* env, jarray array, jsize i) { + return ((struct llvm_java_objectarray*) array)->data[i]; +} + +static void set_object_array_element(JNIEnv* env, + jarray array, + jsize i, + jobject value) { + ((struct llvm_java_objectarray*) array)->data[i] = value; +} + #define HANDLE_NATIVE_TYPE(TYPE) \ static j ## TYPE* get_##TYPE##_array_elements( \ JNIEnv* env, \ From natebegeman at mac.com Sun Apr 3 18:11:28 2005 From: natebegeman at mac.com (Nate Begeman) Date: Sun, 3 Apr 2005 18:11:28 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Message-ID: <200504032311.SAA15812@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPC32ISelPattern.cpp updated: 1.38 -> 1.39 --- Log message: Full varargs support. All of UnitTests now passes --- Diffs of the changes: (+15 -5) PPC32ISelPattern.cpp | 20 +++++++++++++++----- 1 files changed, 15 insertions(+), 5 deletions(-) Index: llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp diff -u llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.38 llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.39 --- llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp:1.38 Sun Apr 3 17:22:56 2005 +++ llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp Sun Apr 3 18:11:17 2005 @@ -194,12 +194,22 @@ // the start of the first vararg value... for expansion of llvm.va_start. if (F.isVarArg()) { VarArgsFrameIndex = MFI->CreateFixedObject(4, ArgOffset); - // If this function is vararg, store r4-r10 to their spots on the stack so - // that they may be loaded by dereferencing va_next SDOperand FIN = DAG.getFrameIndex(VarArgsFrameIndex, MVT::i32); - SDOperand Val = DAG.getCopyFromReg(PPC::R4, MVT::i32, DAG.getRoot()); - SDOperand Store = DAG.getNode(ISD::STORE, MVT::Other, Val.getValue(1), Val, FIN); - DAG.setRoot(Store); + // If this function is vararg, store any remaining integer argument regs + // to their spots on the stack so that they may be loaded by deferencing the + // result of va_next. + std::vector MemOps; + for (; GPR_remaining > 0; --GPR_remaining, ++GPR_idx) { + BuildMI(&BB, PPC::IMPLICIT_DEF, 0, GPR[GPR_idx]); + SDOperand Val = DAG.getCopyFromReg(GPR[GPR_idx], MVT::i32, DAG.getRoot()); + SDOperand Store = DAG.getNode(ISD::STORE, MVT::Other, Val.getValue(1), + Val, FIN); + MemOps.push_back(Store); + // Increment the address by four for the next argument to store + SDOperand PtrOff = DAG.getConstant(4, getPointerTy()); + FIN = DAG.getNode(ISD::ADD, MVT::i32, FIN, PtrOff); + } + DAG.setRoot(DAG.getNode(ISD::TokenFactor, MVT::Other, MemOps)); } return ArgValues; From alkis at cs.uiuc.edu Sun Apr 3 18:12:54 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sun, 3 Apr 2005 18:12:54 -0500 Subject: [llvm-commits] CVS: llvm-java/runtime/jni.c Message-ID: <200504032312.SAA15834@zion.cs.uiuc.edu> Changes in directory llvm-java/runtime: jni.c updated: 1.5 -> 1.6 --- Log message: Actually stick the function pointers in the JNIEnv struct. --- Diffs of the changes: (+2 -2) jni.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm-java/runtime/jni.c diff -u llvm-java/runtime/jni.c:1.5 llvm-java/runtime/jni.c:1.6 --- llvm-java/runtime/jni.c:1.5 Sun Apr 3 18:10:44 2005 +++ llvm-java/runtime/jni.c Sun Apr 3 18:12:43 2005 @@ -359,8 +359,8 @@ NULL, /* 170 */ &get_array_length, NULL, - NULL, - NULL, + &get_object_array_element, + &set_object_array_element, NULL, NULL, NULL, From lattner at cs.uiuc.edu Sun Apr 3 18:42:09 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 3 Apr 2005 18:42:09 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Message-ID: <200504032342.j33Ng98m013679@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: LegalizeDAG.cpp updated: 1.71 -> 1.72 --- Log message: Fix sign_extend and zero_extend of promoted value types to expanded value types. This occurs when casting short to long on PPC for example. --- Diffs of the changes: (+27 -3) LegalizeDAG.cpp | 30 +++++++++++++++++++++++++++--- 1 files changed, 27 insertions(+), 3 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.71 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.72 --- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.71 Fri Apr 1 23:26:37 2005 +++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Sun Apr 3 18:41:52 2005 @@ -1785,9 +1785,21 @@ break; } case ISD::SIGN_EXTEND: { + SDOperand In; + switch (getTypeAction(Node->getOperand(0).getValueType())) { + case Expand: assert(0 && "expand-expand not implemented yet!"); + case Legal: In = LegalizeOp(Node->getOperand(0)); break; + case Promote: + In = PromoteOp(Node->getOperand(0)); + // Emit the appropriate sign_extend_inreg to get the value we want. + In = DAG.getNode(ISD::SIGN_EXTEND_INREG, In.getValueType(), In, + Node->getOperand(0).getValueType()); + break; + } + // The low part is just a sign extension of the input (which degenerates to // a copy). - Lo = DAG.getNode(ISD::SIGN_EXTEND, NVT, LegalizeOp(Node->getOperand(0))); + Lo = DAG.getNode(ISD::SIGN_EXTEND, NVT, In); // The high part is obtained by SRA'ing all but one of the bits of the lo // part. @@ -1796,7 +1808,19 @@ TLI.getShiftAmountTy())); break; } - case ISD::ZERO_EXTEND: + case ISD::ZERO_EXTEND: { + SDOperand In; + switch (getTypeAction(Node->getOperand(0).getValueType())) { + case Expand: assert(0 && "expand-expand not implemented yet!"); + case Legal: In = LegalizeOp(Node->getOperand(0)); break; + case Promote: + In = PromoteOp(Node->getOperand(0)); + // Emit the appropriate zero_extend_inreg to get the value we want. + In = DAG.getNode(ISD::ZERO_EXTEND_INREG, In.getValueType(), In, + Node->getOperand(0).getValueType()); + break; + } + // The low part is just a zero extension of the input (which degenerates to // a copy). Lo = DAG.getNode(ISD::ZERO_EXTEND, NVT, LegalizeOp(Node->getOperand(0))); @@ -1804,7 +1828,7 @@ // The high part is just a zero. Hi = DAG.getConstant(0, NVT); break; - + } // These operators cannot be expanded directly, emit them as calls to // library functions. case ISD::FP_TO_SINT: From natebegeman at mac.com Sun Apr 3 19:57:19 2005 From: natebegeman at mac.com (Nate Begeman) Date: Sun, 3 Apr 2005 19:57:19 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Message-ID: <200504040057.TAA16180@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: LegalizeDAG.cpp updated: 1.72 -> 1.73 --- Log message: Handle expanding arguments to ISD::TRUNCATE. This happens on PowerPC when you have something like i16 = truncate i64. This fixes Regression/C/casts --- Diffs of the changes: (+3 -1) LegalizeDAG.cpp | 4 +++- 1 files changed, 3 insertions(+), 1 deletion(-) Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.72 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.73 --- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.72 Sun Apr 3 18:41:52 2005 +++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Sun Apr 3 19:57:08 2005 @@ -1126,7 +1126,9 @@ Result = PromoteOp(Node->getOperand(0)); break; case Expand: - assert(0 && "Cannot handle expand yet"); + ExpandOp(Node->getOperand(0), Tmp1, Tmp2); + // Truncate the low part of the expanded value to the result type + Result = DAG.getNode(ISD::TRUNCATE, VT, Tmp1); } break; case ISD::SIGN_EXTEND: From duraid at octopus.com.au Sun Apr 3 23:51:09 2005 From: duraid at octopus.com.au (Duraid Madina) Date: Sun, 3 Apr 2005 23:51:09 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/IA64/IA64InstrInfo.td Message-ID: <200504040451.XAA16985@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/IA64: IA64InstrInfo.td updated: 1.4 -> 1.5 --- Log message: add implicit use op --- Diffs of the changes: (+1 -0) IA64InstrInfo.td | 1 + 1 files changed, 1 insertion(+) Index: llvm/lib/Target/IA64/IA64InstrInfo.td diff -u llvm/lib/Target/IA64/IA64InstrInfo.td:1.4 llvm/lib/Target/IA64/IA64InstrInfo.td:1.5 --- llvm/lib/Target/IA64/IA64InstrInfo.td:1.4 Sat Apr 2 04:06:27 2005 +++ llvm/lib/Target/IA64/IA64InstrInfo.td Sun Apr 3 23:50:57 2005 @@ -36,6 +36,7 @@ def PHI : PseudoInstIA64<(ops), "PHI">; def IDEF : PseudoInstIA64<(ops), "// IDEF">; +def IUSE : PseudoInstIA64<(ops), "// IUSE">; def WTF : PseudoInstIA64<(ops), "que??">; def ADJUSTCALLSTACKUP : PseudoInstIA64<(ops), "// ADJUSTCALLSTACKUP">; def ADJUSTCALLSTACKDOWN : PseudoInstIA64<(ops), "// ADJUSTCALLSTACKDOWN">;