From alkis at cs.uiuc.edu Mon Jan 24 07:33:37 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon, 24 Jan 2005 07:33:37 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200501241333.HAA19539@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.189 -> 1.190 --- Log message: For each interface recursively add all methods from the interfaces it inherits from. --- Diffs of the changes: (+40 -10) Compiler.cpp | 50 ++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 40 insertions(+), 10 deletions(-) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.189 llvm-java/lib/Compiler/Compiler.cpp:1.190 --- llvm-java/lib/Compiler/Compiler.cpp:1.189 Sun Jan 23 08:40:25 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Mon Jan 24 07:33:26 2005 @@ -107,6 +107,8 @@ GlobalVariable* vtable; std::vector superVtables; typedef std::map Method2IndexMap; + typedef Method2IndexMap::iterator iterator; + typedef Method2IndexMap::const_iterator const_iterator; Method2IndexMap m2iMap; static Type* VTableBaseTy; @@ -746,18 +748,46 @@ std::copy(superVI.superVtables.begin(), superVI.superVtables.end(), std::back_inserter(vi.superVtables)); - // Copy all the constants from the super class' vtable. - assert(superVI.vtable && "No vtable found for super class!"); - ConstantStruct* superInit = - cast(superVI.vtable->getInitializer()); - std::vector init(superInit->getNumOperands()); + std::vector init(1); // Use a null typeinfo struct for now. init[0] = llvm::Constant::getNullValue(VTableInfo::TypeInfoTy); - // Fill in the function pointers as they are in the super - // class. Overriden methods will be replaced later. - for (unsigned i = 1, e = superInit->getNumOperands(); i != e; ++i) - init[i] = superInit->getOperand(i); - vi.m2iMap = superVI.m2iMap; + + // If this is an interface, add all methods from each interface + // this inherits from. + if (cf->isInterface()) { + const Classes& ifaces = cf->getInterfaces(); + for (unsigned i = 0, e = ifaces.size(); i != e; ++i) { + ClassFile* ifaceCF = ClassFile::get(ifaces[i]->getName()->str()); + const VTableInfo& ifaceVI = getVTableInfo(ifaceCF); + 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 { + 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 = cf->getMethods(); From alkis at cs.uiuc.edu Mon Jan 24 07:42:12 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon, 24 Jan 2005 07:42:12 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200501241342.HAA19635@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.190 -> 1.191 --- Log message: For each interface a class implements, add an interface vtable for that interface and all the interfaces that interface inherits from (recursively). This fixes MultipleInterfaces.java. --- Diffs of the changes: (+20 -9) Compiler.cpp | 29 ++++++++++++++++++++--------- 1 files changed, 20 insertions(+), 9 deletions(-) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.190 llvm-java/lib/Compiler/Compiler.cpp:1.191 --- llvm-java/lib/Compiler/Compiler.cpp:1.190 Mon Jan 24 07:33:26 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Mon Jan 24 07:42:01 2005 @@ -628,6 +628,24 @@ return ConstantExpr::getCast(gv, PointerType::get(VTableInfo::VTableTy)); } + void insertVtablesForInterface(std::vector& vtables, + ClassFile* cf, + ClassFile* ifaceCf) { + static llvm::Constant* nullVTable = + llvm::Constant::getNullValue(PointerType::get(VTableInfo::VTableTy)); + + assert(ifaceCf->isInterface() && "Classfile must be an interface!"); + const ClassInfo& ifaceCi = getClassInfo(ifaceCf); + if (ifaceCi.interfaceIdx >= vtables.size()) + vtables.resize(ifaceCi.interfaceIdx+1, nullVTable); + vtables[ifaceCi.interfaceIdx] = buildInterfaceVTable(cf, ifaceCf); + const Classes& interfaces = ifaceCf->getInterfaces(); + for (unsigned i = 0, e = interfaces.size(); i != e; ++i) { + ClassFile* otherCf = ClassFile::get(interfaces[i]->getName()->str()); + insertVtablesForInterface(vtables, cf, otherCf); + } + } + /// Builds the interfaces vtable array for this classfile and its /// corresponding VTableInfo. If this classfile is an interface we /// return a pointer to 0xFFFFFFFF. @@ -657,15 +675,8 @@ while (true) { const Classes& interfaces = curCf->getInterfaces(); for (unsigned i = 0, e = interfaces.size(); i != e; ++i) { - ClassFile* interface = - ClassFile::get(interfaces[i]->getName()->str()); - assert(interface->isInterface() && - "Class in interfaces list is not an interface!"); - const ClassInfo& interfaceCI = getClassInfo(interface); - if (interfaceCI.interfaceIdx >= vtables.size()) - vtables.resize(interfaceCI.interfaceIdx+1, nullVTable); - vtables[interfaceCI.interfaceIdx] = - buildInterfaceVTable(cf, interface); + ClassFile* ifaceCf = ClassFile::get(interfaces[i]->getName()->str()); + insertVtablesForInterface(vtables, cf, ifaceCf); } if (!curCf->getSuperClass()) break; From alkis at cs.uiuc.edu Mon Jan 24 07:44:38 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon, 24 Jan 2005 07:44:38 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200501241344.HAA19695@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.191 -> 1.192 --- Log message: Create a null function pointer only when we really need to. --- Diffs of the changes: (+4 -3) Compiler.cpp | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.191 llvm-java/lib/Compiler/Compiler.cpp:1.192 --- llvm-java/lib/Compiler/Compiler.cpp:1.191 Mon Jan 24 07:42:01 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Mon Jan 24 07:44:28 2005 @@ -815,9 +815,10 @@ const FunctionType* funcTy = cast( getType(method->getDescriptor(), ObjectBaseTy)); - llvm::Constant* vfun = - llvm::Constant::getNullValue(PointerType::get(funcTy)); - if (!cf->isInterface() && !method->isAbstract()) { + llvm::Constant* vfun = NULL; + if (cf->isInterface() || method->isAbstract()) + vfun = llvm::Constant::getNullValue(PointerType::get(funcTy)); + else { vfun = module_.getOrInsertFunction(funcName, funcTy); scheduleFunction(cast(vfun)); } From alkis at cs.uiuc.edu Mon Jan 24 07:47:28 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon, 24 Jan 2005 07:47:28 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200501241347.HAA19763@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.192 -> 1.193 --- Log message: Add java/util/ConcurrentModificationException so that list iterators can work. --- Diffs of the changes: (+1 -0) Compiler.cpp | 1 + 1 files changed, 1 insertion(+) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.192 llvm-java/lib/Compiler/Compiler.cpp:1.193 --- llvm-java/lib/Compiler/Compiler.cpp:1.192 Mon Jan 24 07:44:28 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Mon Jan 24 07:47:17 2005 @@ -1303,6 +1303,7 @@ classMethodDesc.find("java/lang/Long") != 0 && classMethodDesc.find("java/lang/Short") != 0 && classMethodDesc.find("java/lang/StringBuffer") != 0 && + classMethodDesc.find("java/util/ConcurrentModificationException") != 0 && classMethodDesc.find("java/util/IndexOutOfBoundsException") != 0 && classMethodDesc.find("java/util/NoSuchElementException") != 0 && classMethodDesc.find("java/util/AbstractCollection") != 0 && From lattner at cs.uiuc.edu Mon Jan 24 10:01:10 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 24 Jan 2005 10:01:10 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Type.h Message-ID: <200501241601.j0OG1AEv006172@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: Type.h updated: 1.69 -> 1.70 --- Log message: Do not return true from isSized for things without a size (like functions and labels) even though they are concrete. This fixes the DSA regressions from last night. --- Diffs of the changes: (+10 -1) Type.h | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletion(-) Index: llvm/include/llvm/Type.h diff -u llvm/include/llvm/Type.h:1.69 llvm/include/llvm/Type.h:1.70 --- llvm/include/llvm/Type.h:1.69 Sun Jan 23 20:08:34 2005 +++ llvm/include/llvm/Type.h Mon Jan 24 10:00:52 2005 @@ -201,7 +201,16 @@ /// TargetData subsystem to do this. /// bool isSized() const { - return !isAbstract() || ID == PointerTyID || isSizedDerivedType(); + // If it's a primative, it is always sized. + if (ID >= BoolTyID && ID <= DoubleTyID || ID == PointerTyID) + return true; + // If it is not something that can have a size (e.g. a function or label), + // it doesn't have a size. + if (ID != StructTyID && ID != ArrayTyID && ID != PackedTyID) + return false; + // If it is something that can have a size and it's concrete, it definitely + // has a size, otherwise we have to try harder to decide. + return !isAbstract() || isSizedDerivedType(); } /// getPrimitiveSize - Return the basic size of this type if it is a primitive From brukman at cs.uiuc.edu Mon Jan 24 10:28:14 2005 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Mon, 24 Jan 2005 10:28:14 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Type.h Message-ID: <200501241628.KAA21084@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: Type.h updated: 1.70 -> 1.71 --- Log message: `primitive' has no `a' --- Diffs of the changes: (+1 -1) Type.h | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/include/llvm/Type.h diff -u llvm/include/llvm/Type.h:1.70 llvm/include/llvm/Type.h:1.71 --- llvm/include/llvm/Type.h:1.70 Mon Jan 24 10:00:52 2005 +++ llvm/include/llvm/Type.h Mon Jan 24 10:28:03 2005 @@ -201,7 +201,7 @@ /// TargetData subsystem to do this. /// bool isSized() const { - // If it's a primative, it is always sized. + // If it's a primitive, it is always sized. if (ID >= BoolTyID && ID <= DoubleTyID || ID == PointerTyID) return true; // If it is not something that can have a size (e.g. a function or label), From brukman at cs.uiuc.edu Mon Jan 24 10:29:35 2005 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Mon, 24 Jan 2005 10:29:35 -0600 Subject: [llvm-commits] CVS: llvm/autoconf/configure.ac Message-ID: <200501241629.KAA21124@zion.cs.uiuc.edu> Changes in directory llvm/autoconf: configure.ac updated: 1.165 -> 1.166 --- Log message: Mark CVS versions different from releases --- Diffs of the changes: (+1 -1) configure.ac | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/autoconf/configure.ac diff -u llvm/autoconf/configure.ac:1.165 llvm/autoconf/configure.ac:1.166 --- llvm/autoconf/configure.ac:1.165 Sat Jan 22 15:29:42 2005 +++ llvm/autoconf/configure.ac Mon Jan 24 10:29:24 2005 @@ -31,7 +31,7 @@ dnl===-----------------------------------------------------------------------=== dnl Initialize autoconf and define the package name, version number and dnl email address for reporting bugs. -AC_INIT([[llvm]],[[1.5]],[llvmbugs at cs.uiuc.edu]) +AC_INIT([[llvm]],[[1.5cvs]],[llvmbugs at cs.uiuc.edu]) dnl Provide a copyright substitution and ensure the copyright notice is included dnl in the output of --version option of the generated configure script. From alenhar2 at cs.uiuc.edu Mon Jan 24 11:25:57 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Mon, 24 Jan 2005 11:25:57 -0600 Subject: [llvm-commits] CVS: llvm/configure Message-ID: <200501241725.LAA01844@niobe.cs.uiuc.edu> Changes in directory llvm: configure updated: 1.172 -> 1.173 --- Log message: let configure recognize Alphas --- Diffs of the changes: (+1 -0) configure | 1 + 1 files changed, 1 insertion(+) Index: llvm/configure diff -u llvm/configure:1.172 llvm/configure:1.173 --- llvm/configure:1.172 Sun Jan 16 03:44:58 2005 +++ llvm/configure Mon Jan 24 11:25:41 2005 @@ -1790,6 +1790,7 @@ amd64-* | x86_64-*) llvm_cv_target_arch="x86_64" ;; sparc*-*) llvm_cv_target_arch="Sparc" ;; powerpc*-*) llvm_cv_target_arch="PowerPC" ;; + alpha*-*) llvm_cv_target_arch="Alpha" ;; *) llvm_cv_target_arch="Unknown" ;; esac fi From alenhar2 at cs.uiuc.edu Mon Jan 24 11:34:05 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Mon, 24 Jan 2005 11:34:05 -0600 Subject: [llvm-commits] CVS: llvm/autoconf/configure.ac Message-ID: <200501241734.LAA01862@niobe.cs.uiuc.edu> Changes in directory llvm/autoconf: configure.ac updated: 1.166 -> 1.167 --- Log message: let configure recognize Alphas --- Diffs of the changes: (+1 -0) configure.ac | 1 + 1 files changed, 1 insertion(+) Index: llvm/autoconf/configure.ac diff -u llvm/autoconf/configure.ac:1.166 llvm/autoconf/configure.ac:1.167 --- llvm/autoconf/configure.ac:1.166 Mon Jan 24 10:29:24 2005 +++ llvm/autoconf/configure.ac Mon Jan 24 11:33:52 2005 @@ -174,6 +174,7 @@ amd64-* | x86_64-*) llvm_cv_target_arch="x86_64" ;; sparc*-*) llvm_cv_target_arch="Sparc" ;; powerpc*-*) llvm_cv_target_arch="PowerPC" ;; + alpha*-*) llvm_cv_target_arch="Alpha" ;; *) llvm_cv_target_arch="Unknown" ;; esac]) From alkis at cs.uiuc.edu Mon Jan 24 11:37:27 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon, 24 Jan 2005 11:37:27 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/ClassFile/ClassFile.cpp Message-ID: <200501241737.LAA21973@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/ClassFile: ClassFile.cpp updated: 1.33 -> 1.34 --- Log message: Remove 'x' from debugging output. --- Diffs of the changes: (+1 -1) ClassFile.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm-java/lib/ClassFile/ClassFile.cpp diff -u llvm-java/lib/ClassFile/ClassFile.cpp:1.33 llvm-java/lib/ClassFile/ClassFile.cpp:1.34 --- llvm-java/lib/ClassFile/ClassFile.cpp:1.33 Mon Dec 13 01:43:46 2004 +++ llvm-java/lib/ClassFile/ClassFile.cpp Mon Jan 24 11:37:16 2005 @@ -184,7 +184,7 @@ e = ClassPath.find(':', b); if (path.setDirectory(ClassPath.substr(b, e - b))) { result.push_back(path); - DEBUG(std::cerr << "Adding: " << path.toString() << " to CLASSPATH\nx"); + DEBUG(std::cerr << "Adding: " << path.toString() << " to CLASSPATH\n"); } b = e + 1; } while (e != std::string::npos); From alenhar2 at cs.uiuc.edu Mon Jan 24 12:38:05 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Mon, 24 Jan 2005 12:38:05 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp Message-ID: <200501241838.MAA28073@cypher.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaAsmPrinter.cpp updated: 1.1 -> 1.2 --- Log message: Pruned includes --- Diffs of the changes: (+5 -15) AlphaAsmPrinter.cpp | 20 +++++--------------- 1 files changed, 5 insertions(+), 15 deletions(-) Index: llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp diff -u llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp:1.1 llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp:1.2 --- llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp:1.1 Sat Jan 22 17:41:55 2005 +++ llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp Mon Jan 24 12:37:48 2005 @@ -1,4 +1,4 @@ -//===-- AlphaAsmPrinter.cpp - Alpha LLVM assembly writer --------------===// +//===-- AlphaAsmPrinter.cpp - Alpha LLVM assembly writer ------------------===// // // The LLVM Compiler Infrastructure // @@ -14,25 +14,17 @@ #include "Alpha.h" #include "AlphaInstrInfo.h" -#include "llvm/Constants.h" -#include "llvm/DerivedTypes.h" #include "llvm/Module.h" #include "llvm/Assembly/Writer.h" -#include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineConstantPool.h" -#include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/ValueTypes.h" #include "llvm/CodeGen/AsmPrinter.h" #include "llvm/Target/TargetMachine.h" -#include "llvm/Target/MRegisterInfo.h" -#include "llvm/Target/TargetInstrInfo.h" #include "llvm/Support/Mangler.h" #include "llvm/ADT/Statistic.h" -#include "llvm/ADT/StringExtras.h" -#include "llvm/Support/CommandLine.h" -#include + using namespace llvm; namespace { @@ -87,7 +79,7 @@ const MachineOperand &MO = MI->getOperand(opNum); if (MO.getType() == MachineOperand::MO_MachineRegister) { assert(MRegisterInfo::isPhysicalRegister(MO.getReg())&&"Not physreg??"); - O << LowercaseString(TM.getRegisterInfo()->get(MO.getReg()).Name); + O << TM.getRegisterInfo()->get(MO.getReg()).Name; } else if (MO.isImmediate()) { O << MO.getImmedValue(); } else { @@ -109,7 +101,7 @@ // FALLTHROUGH case MachineOperand::MO_MachineRegister: case MachineOperand::MO_CCRegister: - O << LowercaseString(RI.get(MO.getReg()).Name); + O << RI.get(MO.getReg()).Name; return; case MachineOperand::MO_SignExtendedImmed: @@ -119,7 +111,7 @@ return; case MachineOperand::MO_PCRelativeDisp: - std::cerr << "Shouldn't use addPCDisp() when building PPC MachineInstrs"; + std::cerr << "Shouldn't use addPCDisp() when building Alpha MachineInstrs"; abort(); return; @@ -140,8 +132,6 @@ return; case MachineOperand::MO_GlobalAddress: - //std::cerr << "Global Addresses? Are you kidding?\n" - //abort(); O << Mang->getValueName(MO.getGlobal()); return; From alenhar2 at cs.uiuc.edu Mon Jan 24 12:46:00 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Mon, 24 Jan 2005 12:46:00 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaTargetMachine.cpp Message-ID: <200501241846.MAA28086@cypher.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaTargetMachine.cpp updated: 1.1 -> 1.2 --- Log message: include prune and JIT prune --- Diffs of the changes: (+1 -35) AlphaTargetMachine.cpp | 36 +----------------------------------- 1 files changed, 1 insertion(+), 35 deletions(-) Index: llvm/lib/Target/Alpha/AlphaTargetMachine.cpp diff -u llvm/lib/Target/Alpha/AlphaTargetMachine.cpp:1.1 llvm/lib/Target/Alpha/AlphaTargetMachine.cpp:1.2 --- llvm/lib/Target/Alpha/AlphaTargetMachine.cpp:1.1 Sat Jan 22 17:41:55 2005 +++ llvm/lib/Target/Alpha/AlphaTargetMachine.cpp Mon Jan 24 12:45:41 2005 @@ -1,4 +1,4 @@ -//===-- AlphaTargetMachine.cpp - Define TargetMachine for Alpha -------===// +//===-- AlphaTargetMachine.cpp - Define TargetMachine for Alpha -----------===// // // The LLVM Compiler Infrastructure // @@ -12,14 +12,10 @@ #include "Alpha.h" #include "AlphaTargetMachine.h" -#include "llvm/Module.h" -#include "llvm/CodeGen/IntrinsicLowering.h" -#include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/Passes.h" #include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetMachineRegistry.h" #include "llvm/Transforms/Scalar.h" -#include "llvm/Support/CommandLine.h" #include using namespace llvm; @@ -31,7 +27,6 @@ AlphaTargetMachine::AlphaTargetMachine( const Module &M, IntrinsicLowering *IL) : TargetMachine("alpha", IL, true), FrameInfo(TargetFrameInfo::StackGrowsDown, 8, 0) //TODO: check these - //JITInfo(*this) {} bool AlphaTargetMachine::addPassesToEmitMachineCode(FunctionPassManager &PM, @@ -57,8 +52,6 @@ // FIXME: Implement the switch instruction in the instruction selector! PM.add(createLowerSwitchPass()); - PM.add(createLowerConstantExpressionsPass()); - // Make sure that no unreachable blocks are instruction selected. PM.add(createUnreachableBlockEliminationPass()); @@ -82,30 +75,3 @@ PM.add(createMachineCodeDeleter()); return false; } - -//void AlphaJITInfo::addPassesToJITCompile(FunctionPassManager &PM) { -// // FIXME: Implement efficient support for garbage collection intrinsics. -// PM.add(createLowerGCPass()); - -// // FIXME: Implement the invoke/unwind instructions! -// PM.add(createLowerInvokePass()); - -// // FIXME: Implement the switch instruction in the instruction selector! -// PM.add(createLowerSwitchPass()); - -// PM.add(createLowerConstantExpressionsPass()); - -// // Make sure that no unreachable blocks are instruction selected. -// PM.add(createUnreachableBlockEliminationPass()); - -// PM.add(createPPC32ISelSimple(TM)); -// PM.add(createRegisterAllocator()); -// PM.add(createPrologEpilogCodeInserter()); - -// // Must run branch selection immediately preceding the asm printer -// PM.add(createPPCBranchSelectionPass()); - -// if (PrintMachineCode) -// PM.add(createMachineFunctionPrinterPass(&std::cerr)); -//} - From alenhar2 at cs.uiuc.edu Mon Jan 24 12:48:39 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Mon, 24 Jan 2005 12:48:39 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaTargetMachine.cpp AlphaTargetMachine.h Message-ID: <200501241848.MAA28099@cypher.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaTargetMachine.cpp updated: 1.2 -> 1.3 AlphaTargetMachine.h updated: 1.1 -> 1.2 --- Log message: Alpha JIT prune --- Diffs of the changes: (+0 -16) AlphaTargetMachine.cpp | 8 -------- AlphaTargetMachine.h | 8 -------- 2 files changed, 16 deletions(-) Index: llvm/lib/Target/Alpha/AlphaTargetMachine.cpp diff -u llvm/lib/Target/Alpha/AlphaTargetMachine.cpp:1.2 llvm/lib/Target/Alpha/AlphaTargetMachine.cpp:1.3 --- llvm/lib/Target/Alpha/AlphaTargetMachine.cpp:1.2 Mon Jan 24 12:45:41 2005 +++ llvm/lib/Target/Alpha/AlphaTargetMachine.cpp Mon Jan 24 12:48:22 2005 @@ -29,14 +29,6 @@ FrameInfo(TargetFrameInfo::StackGrowsDown, 8, 0) //TODO: check these {} -bool AlphaTargetMachine::addPassesToEmitMachineCode(FunctionPassManager &PM, - MachineCodeEmitter &MCE) -{ - assert(0 && "TODO"); - return false; -} - - /// addPassesToEmitAssembly - Add passes to the specified pass manager /// to implement a static compiler for this target. /// Index: llvm/lib/Target/Alpha/AlphaTargetMachine.h diff -u llvm/lib/Target/Alpha/AlphaTargetMachine.h:1.1 llvm/lib/Target/Alpha/AlphaTargetMachine.h:1.2 --- llvm/lib/Target/Alpha/AlphaTargetMachine.h:1.1 Sat Jan 22 17:41:55 2005 +++ llvm/lib/Target/Alpha/AlphaTargetMachine.h Mon Jan 24 12:48:22 2005 @@ -18,7 +18,6 @@ #include "llvm/Target/TargetFrameInfo.h" #include "llvm/PassManager.h" #include "AlphaInstrInfo.h" -//#include "AlphaJITInfo.h" namespace llvm { @@ -28,7 +27,6 @@ class AlphaTargetMachine : public TargetMachine { AlphaInstrInfo InstrInfo; TargetFrameInfo FrameInfo; - // AlphaJITInfo JITInfo; public: AlphaTargetMachine(const Module &M, IntrinsicLowering *IL); @@ -38,13 +36,7 @@ virtual const MRegisterInfo *getRegisterInfo() const { return &InstrInfo.getRegisterInfo(); } - // virtual TargetJITInfo *getJITInfo() { - // return &JITInfo; - // } - virtual bool addPassesToEmitMachineCode(FunctionPassManager &PM, - MachineCodeEmitter &MCE); - virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out); }; From alenhar2 at cs.uiuc.edu Mon Jan 24 13:44:23 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Mon, 24 Jan 2005 13:44:23 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp AlphaInstrFormats.td AlphaInstrInfo.cpp AlphaInstrInfo.td AlphaRegisterInfo.cpp AlphaTargetMachine.h Message-ID: <200501241944.NAA28144@cypher.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.1 -> 1.2 AlphaInstrFormats.td updated: 1.1 -> 1.2 AlphaInstrInfo.cpp updated: 1.1 -> 1.2 AlphaInstrInfo.td updated: 1.1 -> 1.2 AlphaRegisterInfo.cpp updated: 1.1 -> 1.2 AlphaTargetMachine.h updated: 1.2 -> 1.3 --- Log message: Clean ups, and taught the instruction selector about immediate forms --- Diffs of the changes: (+192 -132) AlphaISelPattern.cpp | 88 +++++++++---------- AlphaInstrFormats.td | 5 - AlphaInstrInfo.cpp | 3 AlphaInstrInfo.td | 222 ++++++++++++++++++++++++++++++++------------------ AlphaRegisterInfo.cpp | 4 AlphaTargetMachine.h | 2 6 files changed, 192 insertions(+), 132 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.1 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.2 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.1 Sat Jan 22 17:41:55 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Mon Jan 24 13:44:05 2005 @@ -1,4 +1,4 @@ -//===-- AlphaISelPattern.cpp - A pattern matching inst selector for Alpha -----===// +//===- AlphaISelPattern.cpp - A pattern matching inst selector for Alpha -===// // // The LLVM Compiler Infrastructure // @@ -12,7 +12,6 @@ //===----------------------------------------------------------------------===// #include "Alpha.h" -//#include "X86InstrBuilder.h" #include "AlphaRegisterInfo.h" #include "llvm/Constants.h" // FIXME: REMOVE #include "llvm/Function.h" @@ -55,10 +54,6 @@ computeRegisterProperties(); - // setOperationUnsupported(ISD::MUL, MVT::i8); - // setOperationUnsupported(ISD::SELECT, MVT::i1); - // setOperationUnsupported(ISD::SELECT, MVT::i8); - // addLegalFPImmediate(+0.0); // FLD0 // addLegalFPImmediate(+1.0); // FLD1 // addLegalFPImmediate(-0.0); // FLD0/FCHS @@ -538,6 +533,48 @@ return Result; } + //Most of the plain arithmetic and logic share the same form, and the same + //constant immediate test + case ISD::AND: + case ISD::OR: + case ISD::XOR: + case ISD::SHL: + case ISD::SRL: + case ISD::MUL: + if(N.getOperand(1).getOpcode() == ISD::Constant && + cast(N.getOperand(1))->getValue() >= 0 && + cast(N.getOperand(1))->getValue() <= 255) + { + switch(N.getOpcode()) { + case ISD::AND: Opc = Alpha::ANDi; break; + case ISD::OR: Opc = Alpha::BISi; break; + case ISD::XOR: Opc = Alpha::XORi; break; + case ISD::SHL: Opc = Alpha::SLi; break; + case ISD::SRL: Opc = Alpha::SRLi; break; + case ISD::SRA: Opc = Alpha::SRAi; break; + case ISD::MUL: Opc = Alpha::MULQi; break; + }; + Tmp1 = SelectExpr(N.getOperand(0)); + Tmp2 = cast(N.getOperand(1))->getValue(); + BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addImm(Tmp2); + } + else + { + switch(N.getOpcode()) { + case ISD::AND: Opc = Alpha::AND; break; + case ISD::OR: Opc = Alpha::BIS; break; + case ISD::XOR: Opc = Alpha::XOR; break; + case ISD::SHL: Opc = Alpha::SL; break; + case ISD::SRL: Opc = Alpha::SRL; break; + case ISD::SRA: Opc = Alpha::SRA; break; + case ISD::MUL: Opc = Alpha::MULQ; break; + }; + Tmp1 = SelectExpr(N.getOperand(0)); + Tmp2 = SelectExpr(N.getOperand(1)); + BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); + } + return Result; + case ISD::ADD: Tmp1 = SelectExpr(N.getOperand(0)); Tmp2 = SelectExpr(N.getOperand(1)); @@ -549,27 +586,6 @@ BuildMI(BB, Alpha::SUBQ, 2, Result).addReg(Tmp1).addReg(Tmp2); return Result; - case ISD::AND: - Tmp1 = SelectExpr(N.getOperand(0)); - Tmp2 = SelectExpr(N.getOperand(1)); - BuildMI(BB, Alpha::AND, 2, Result).addReg(Tmp1).addReg(Tmp2); - return Result; - case ISD::OR: - Tmp1 = SelectExpr(N.getOperand(0)); - Tmp2 = SelectExpr(N.getOperand(1)); - BuildMI(BB, Alpha::BIS, 2, Result).addReg(Tmp1).addReg(Tmp2); - return Result; - case ISD::XOR: - Tmp1 = SelectExpr(N.getOperand(0)); - Tmp2 = SelectExpr(N.getOperand(1)); - BuildMI(BB, Alpha::XOR, 2, Result).addReg(Tmp1).addReg(Tmp2); - return Result; - - case ISD::MUL: - Tmp1 = SelectExpr(N.getOperand(0)); - Tmp2 = SelectExpr(N.getOperand(1)); - BuildMI(BB, Alpha::MULQ, 2, Result).addReg(Tmp1).addReg(Tmp2); - return Result; case ISD::UREM: Tmp1 = SelectExpr(N.getOperand(0)); Tmp2 = SelectExpr(N.getOperand(1)); @@ -588,22 +604,6 @@ return Result; } - case ISD::SHL: - Tmp1 = SelectExpr(N.getOperand(0)); - Tmp2 = SelectExpr(N.getOperand(1)); - BuildMI(BB, Alpha::SL, 2, Result).addReg(Tmp1).addReg(Tmp2); - return Result; - case ISD::SRL: - Tmp1 = SelectExpr(N.getOperand(0)); - Tmp2 = SelectExpr(N.getOperand(1)); - BuildMI(BB, Alpha::SRL, 1, Result).addReg(Tmp1).addReg(Tmp2); - return Result; - case ISD::SRA: - Tmp1 = SelectExpr(N.getOperand(0)); - Tmp2 = SelectExpr(N.getOperand(1)); - BuildMI(BB, Alpha::SRA, 2, Result).addReg(Tmp1).addReg(Tmp2); - return Result; - case ISD::Constant: { long val = cast(N)->getValue(); @@ -611,8 +611,6 @@ return Result; } - - case ISD::LOAD: { // Make sure we generate both values. Index: llvm/lib/Target/Alpha/AlphaInstrFormats.td diff -u llvm/lib/Target/Alpha/AlphaInstrFormats.td:1.1 llvm/lib/Target/Alpha/AlphaInstrFormats.td:1.2 --- llvm/lib/Target/Alpha/AlphaInstrFormats.td:1.1 Sat Jan 22 17:41:55 2005 +++ llvm/lib/Target/Alpha/AlphaInstrFormats.td Mon Jan 24 13:44:06 2005 @@ -23,7 +23,6 @@ class InstAlpha op, dag OL, string asmstr> : Instruction { // Alpha instruction baseline field bits<32> Inst; -// let Name = asmstr; let Namespace = "Alpha"; let OperandList = OL; let AsmString = asmstr; @@ -70,10 +69,10 @@ } -class OFormL opcode, dag OL, string asmstr> : InstAlpha { +class OFormL opcode, bits<7> fun, dag OL, string asmstr> : InstAlpha { bits<5> Ra; bits<8> LIT; - bits<7> Function; + bits<7> Function = fun; bits<5> Rc; let Inst{25-21} = Ra; Index: llvm/lib/Target/Alpha/AlphaInstrInfo.cpp diff -u llvm/lib/Target/Alpha/AlphaInstrInfo.cpp:1.1 llvm/lib/Target/Alpha/AlphaInstrInfo.cpp:1.2 --- llvm/lib/Target/Alpha/AlphaInstrInfo.cpp:1.1 Sat Jan 22 17:41:55 2005 +++ llvm/lib/Target/Alpha/AlphaInstrInfo.cpp Mon Jan 24 13:44:06 2005 @@ -1,4 +1,4 @@ -//===- AlphaInstrInfo.cpp - Alpha Instruction Information ---*- C++ -*-===// +//===- AlphaInstrInfo.cpp - Alpha Instruction Information ---*- C++ -*-----===// // // The LLVM Compiler Infrastructure // @@ -25,7 +25,6 @@ bool AlphaInstrInfo::isMoveInstr(const MachineInstr& MI, unsigned& sourceReg, unsigned& destReg) const { - //assert(0 && "TODO"); MachineOpCode oc = MI.getOpcode(); if (oc == Alpha::BIS) { // or r1, r2, r2 assert(MI.getNumOperands() == 3 && Index: llvm/lib/Target/Alpha/AlphaInstrInfo.td diff -u llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.1 llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.2 --- llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.1 Sat Jan 22 17:41:55 2005 +++ llvm/lib/Target/Alpha/AlphaInstrInfo.td Mon Jan 24 13:44:07 2005 @@ -18,6 +18,7 @@ // //#define GP $29 // //#define SP $30 +def u8imm : Operand; def s14imm : Operand; def s16imm : Operand; def s21imm : Operand; @@ -41,7 +42,8 @@ def LDGP : PseudoInstAlpha<(ops), "ldgp $$29, 0($$27)">; let isCall = 1, - Defs = [R0, R1, R2, R3, R4, R5, R6, R7, R8, R16, R17, R18, R19, R20, R21, R22, R23, R24, R25, R26, R27, R29], + Defs = [R0, R1, R2, R3, R4, R5, R6, R7, R8, R16, R17, R18, R19, + R20, R21, R22, R23, R24, R25, R26, R27, R29], Uses = [R27, R29] in def CALL : PseudoInstAlpha< (ops s64imm:$TARGET), "jsr $TARGET">; //Jump to subroutine @@ -70,55 +72,148 @@ //*********************** //Operation Form: -def ADDL : OForm<0x10, 0x00, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "addl $RA,$RB,$RC">; //Add longword -def ADDL_V : OForm< 0x10, 0x40, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "ADDL/V $RA,$RB,$RC">; -def ADDQ : OForm< 0x10, 0x20, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "addq $RA,$RB,$RC">; //Add quadword -def ADDQ_V : OForm< 0x10, 0x60, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "ADDQ/V $RA,$RB,$RC">; -def AMASK : OForm< 0x11, 0x61, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "AMASK $RA,$RB,$RC">; //Architecture mask -def AND : OForm< 0x11, 0x00, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "AND $RA,$RB,$RC">; //Logical product -def BIC : OForm< 0x11, 0x08, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "BIC $RA,$RB,$RC">; //Bit clear -def BIS : OForm<0x11, 0x20, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "bis $RA,$RB,$RC">; //Logical sum //let isTwoAddress = 1 in { - def CMOVEQ : OForm< 0x11, 0x24, - (ops GPRC:$RDEST, GPRC:$RSRC, GPRC:$RCOND), - "cmoveq $RCOND,$RSRC,$RDEST">; //CMOVE if RCOND = zero - def CMOVGE : OForm< 0x11, 0x46, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CMOVGE $RA,$RB,$RC">; //CMOVE if ? zero - def CMOVGT : OForm<0x11, 0x66, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CMOVGT $RA,$RB,$RC">; //CMOVE if > zero - def CMOVLBC : OForm< 0x11, 0x16, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CMOVLBC $RA,$RB,$RC">; //CMOVE if low bit clear - def CMOVLBS : OForm< 0x11, 0x14, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CMOVLBS $RA,$RB,$RC">; //CMOVE if low bit set - def CMOVLE : OForm<0x11, 0x64, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CMOVLE $RA,$RB,$RC">; //CMOVE if ? zero - def CMOVLT : OForm< 0x11, 0x44, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CMOVLT $RA,$RB,$RC">; //CMOVE if < zero - def CMOVNE : OForm< 0x11, 0x26, - (ops GPRC:$RC, GPRC:$DUMMY, GPRC:$RA, GPRC:$RB), - "cmovne $RA,$RB,$RC">; //CMOVE if ? zero + def CMOVEQ : OForm< 0x11, 0x24, (ops GPRC:$RDEST, GPRC:$RSRC, GPRC:$RCOND), "cmoveq $RCOND,$RSRC,$RDEST">; //CMOVE if RCOND = zero + def CMOVEQi : OFormL< 0x11, 0x24, (ops GPRC:$RDEST, u8imm:$L, GPRC:$RCOND), "cmoveq $RCOND,$L,$RDEST">; //CMOVE if RCOND = zero + def CMOVGE : OForm< 0x11, 0x46, (ops GPRC:$RDEST, GPRC:$RSRC, GPRC:$RCOND), "CMOVGE $RCOND,$RSRC,$RDEST">; //CMOVE if RCOND >= zero + def CMOVGEi : OFormL< 0x11, 0x46, (ops GPRC:$RDEST, u8imm:$L, GPRC:$RCOND), "CMOVGE $RCOND,$L,$RDEST">; //CMOVE if RCOND >= zero + def CMOVGT : OForm< 0x11, 0x66, (ops GPRC:$RDEST, GPRC:$RSRC, GPRC:$RCOND), "CMOVGT $RCOND,$RSRC,$RDEST">; //CMOVE if RCOND > zero + def CMOVGTi : OFormL< 0x11, 0x66, (ops GPRC:$RDEST, u8imm:$L, GPRC:$RCOND), "CMOVGT $RCOND,$L,$RDEST">; //CMOVE if RCOND > zero + def CMOVLBC : OForm< 0x11, 0x16, (ops GPRC:$RDEST, GPRC:$RSRC, GPRC:$RCOND), "CMOVLBC $RCOND,$RSRC,$RDEST">; //CMOVE if RCOND low bit clear + def CMOVLBCi : OFormL< 0x11, 0x16, (ops GPRC:$RDEST, u8imm:$L, GPRC:$RCOND), "CMOVLBC $RCOND,$L,$RDEST">; //CMOVE if RCOND low bit clear + def CMOVLBS : OForm< 0x11, 0x14, (ops GPRC:$RDEST, GPRC:$RSRC, GPRC:$RCOND), "CMOVLBS $RCOND,$RSRC,$RDEST">; //CMOVE if RCOND low bit set + def CMOVLBSi : OFormL< 0x11, 0x14, (ops GPRC:$RDEST, u8imm:$L, GPRC:$RCOND), "CMOVLBS $RCOND,$L,$RDEST">; //CMOVE if RCOND low bit set + def CMOVLE : OForm< 0x11, 0x64, (ops GPRC:$RDEST, GPRC:$RSRC, GPRC:$RCOND), "CMOVLE $RCOND,$RSRC,$RDEST">; //CMOVE if RCOND <= zero + def CMOVLEi : OFormL< 0x11, 0x64, (ops GPRC:$RDEST, u8imm:$L, GPRC:$RCOND), "CMOVLE $RCOND,$L,$RDEST">; //CMOVE if RCOND <= zero + def CMOVLT : OForm< 0x11, 0x44, (ops GPRC:$RDEST, GPRC:$RSRC, GPRC:$RCOND), "CMOVLT $RCOND,$RSRC,$RDEST">; //CMOVE if RCOND < zero + def CMOVLTi : OFormL< 0x11, 0x44, (ops GPRC:$RDEST, u8imm:$L, GPRC:$RCOND), "CMOVLT $RCOND,$L,$RDEST">; //CMOVE if RCOND < zero + def CMOVNE : OForm< 0x11, 0x26, (ops GPRC:$RDEST, GPRC:$RSRC, GPRC:$RCOND), "cmovne $RCOND,$RSRC,$RDEST">; //CMOVE if RCOND != zero + def CMOVNEi : OFormL< 0x11, 0x26, (ops GPRC:$RDEST, u8imm:$L, GPRC:$RCOND), "cmovne $RCOND,$L,$RDEST">; //CMOVE if RCOND != zero //} -def CMPBGE : OForm< 0x10, 0x0F, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CMPBGE $RA,$RB,$RC">; //Compare byte -def CMPEQ : OForm< 0x10, 0x2D, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CMPEQ $RA,$RB,$RC">; //Compare signed quadword equal -def CMPLE : OForm< 0x10, 0x6D, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CMPLE $RA,$RB,$RC">; //Compare signed quadword less than or equal -def CMPLT : OForm< 0x10, 0x4D, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CMPLT $RA,$RB,$RC">; //Compare signed quadword less than -def CMPULE : OForm< 0x10, 0x3D, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CMPULE $RA,$RB,$RC">; //Compare unsigned quadword less than or equal -def CMPULT : OForm< 0x10, 0x1D, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CMPULT $RA,$RB,$RC">; //Compare unsigned quadword less than -def CTLZ : OForm< 0x1C, 0x32, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CTLZ $RA,$RB,$RC">; //Count leading zero -def CTPOP : OForm< 0x1C, 0x30, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CTPOP $RA,$RB,$RC">; //Count population -def CTTZ : OForm<0x1C, 0x33, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CTTZ $RA,$RB,$RC">; //Count trailing zero -def EQV : OForm< 0x11, 0x48, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "EQV $RA,$RB,$RC">; //Logical equivalence -def EXTBL : OForm< 0x12, 0x06, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "EXTBL $RA,$RB,$RC">; //Extract byte low -def EXTLH : OForm< 0x12, 0x6A, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "EXTLH $RA,$RB,$RC">; //Extract longword high -def EXTLL : OForm< 0x12, 0x26, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "EXTLL $RA,$RB,$RC">; //Extract longword low -def EXTQH : OForm< 0x12, 0x7A, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "EXTQH $RA,$RB,$RC">; //Extract quadword high -def EXTQ : OForm< 0x12, 0x36, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "EXTQ $RA,$RB,$RC">; //Extract quadword low -def EXTWH : OForm< 0x12, 0x5A, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "EXTWH $RA,$RB,$RC">; //Extract word high -def EXTWL : OForm< 0x12, 0x16, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "EXTWL $RA,$RB,$RC">; //Extract word low -def IMPLVER : OForm< 0x11, 0x6C, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "IMPLVER $RA,$RB,$RC">; //Implementation version -def INSBL : OForm< 0x12, 0x0B, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "INSBL $RA,$RB,$RC">; //Insert byte low -def INSLH : OForm< 0x12, 0x67, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "INSLH $RA,$RB,$RC">; //Insert longword high -def INSLL : OForm< 0x12, 0x2B, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "INSLL $RA,$RB,$RC">; //Insert longword low -def INSQH : OForm< 0x12, 0x77, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "INSQH $RA,$RB,$RC">; //Insert quadword high -def INSQL : OForm< 0x12, 0x3B, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "INSQL $RA,$RB,$RC">; //Insert quadword low -def INSWH : OForm< 0x12, 0x57, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "INSWH $RA,$RB,$RC">; //Insert word high -def INSWL : OForm< 0x12, 0x1B, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "INSWL $RA,$RB,$RC">; //Insert word low +def ADDL : OForm< 0x10, 0x00, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "addl $RA,$RB,$RC">; //Add longword +def ADDLi : OFormL<0x10, 0x00, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "addl $RA,$L,$RC">; //Add longword +def ADDQ : OForm< 0x10, 0x20, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "addq $RA,$RB,$RC">; //Add quadword +def ADDQi : OFormL<0x10, 0x20, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "addq $RA,$L,$RC">; //Add quadword +def AMASK : OForm< 0x11, 0x61, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "AMASK $RA,$RB,$RC">; //Architecture mask +def AMASKi : OFormL<0x11, 0x61, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "AMASK $RA,$L,$RC">; //Architecture mask +def AND : OForm< 0x11, 0x00, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "AND $RA,$RB,$RC">; //Logical product +def ANDi : OFormL<0x11, 0x00, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "AND $RA,$L,$RC">; //Logical product +def BIC : OForm< 0x11, 0x08, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "BIC $RA,$RB,$RC">; //Bit clear +def BICi : OFormL<0x11, 0x08, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "BIC $RA,$L,$RC">; //Bit clear +def BIS : OForm< 0x11, 0x20, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "bis $RA,$RB,$RC">; //Logical sum +def BISi : OFormL<0x11, 0x20, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "bis $RA,$L,$RC">; //Logical sum +def CMPBGE : OForm< 0x10, 0x0F, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CMPBGE $RA,$RB,$RC">; //Compare byte +def CMPBGEi : OFormL<0x10, 0x0F, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "CMPBGE $RA,$L,$RC">; //Compare byte +def CMPEQ : OForm< 0x10, 0x2D, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CMPEQ $RA,$RB,$RC">; //Compare signed quadword equal +def CMPEQi : OFormL<0x10, 0x2D, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "CMPEQ $RA,$L,$RC">; //Compare signed quadword equal +def CMPLE : OForm< 0x10, 0x6D, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CMPLE $RA,$RB,$RC">; //Compare signed quadword less than or equal +def CMPLEi : OFormL<0x10, 0x6D, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "CMPLE $RA,$L,$RC">; //Compare signed quadword less than or equal +def CMPLT : OForm< 0x10, 0x4D, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CMPLT $RA,$RB,$RC">; //Compare signed quadword less than +def CMPLTi : OFormL<0x10, 0x4D, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "CMPLT $RA,$L,$RC">; //Compare signed quadword less than +def CMPULE : OForm< 0x10, 0x3D, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CMPULE $RA,$RB,$RC">; //Compare unsigned quadword less than or equal +def CMPULEi : OFormL<0x10, 0x3D, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "CMPULE $RA,$L,$RC">; //Compare unsigned quadword less than or equal +def CMPULT : OForm< 0x10, 0x1D, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CMPULT $RA,$RB,$RC">; //Compare unsigned quadword less than +def CMPULTi : OFormL<0x10, 0x1D, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "CMPULT $RA,$L,$RC">; //Compare unsigned quadword less than +def CTLZ : OForm< 0x1C, 0x32, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CTLZ $RA,$RB,$RC">; //Count leading zero +def CTLZi : OFormL<0x1C, 0x32, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "CTLZ $RA,$L,$RC">; //Count leading zero +def CTPOP : OForm< 0x1C, 0x30, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CTPOP $RA,$RB,$RC">; //Count population +def CTPOPi : OFormL<0x1C, 0x30, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "CTPOP $RA,$L,$RC">; //Count population +def CTTZ : OForm< 0x1C, 0x33, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CTTZ $RA,$RB,$RC">; //Count trailing zero +def CTTZi : OFormL<0x1C, 0x33, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "CTTZ $RA,$L,$RC">; //Count trailing zero +def EQV : OForm< 0x11, 0x48, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "EQV $RA,$RB,$RC">; //Logical equivalence +def EQVi : OFormL<0x11, 0x48, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "EQV $RA,$L,$RC">; //Logical equivalence +def EXTBL : OForm< 0x12, 0x06, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "EXTBL $RA,$RB,$RC">; //Extract byte low +def EXTBLi : OFormL<0x12, 0x06, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "EXTBL $RA,$L,$RC">; //Extract byte low +def EXTLH : OForm< 0x12, 0x6A, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "EXTLH $RA,$RB,$RC">; //Extract longword high +def EXTLHi : OFormL<0x12, 0x6A, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "EXTLH $RA,$L,$RC">; //Extract longword high +def EXTLL : OForm< 0x12, 0x26, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "EXTLL $RA,$RB,$RC">; //Extract longword low +def EXTLLi : OFormL<0x12, 0x26, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "EXTLL $RA,$L,$RC">; //Extract longword low +def EXTQH : OForm< 0x12, 0x7A, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "EXTQH $RA,$RB,$RC">; //Extract quadword high +def EXTQHi : OFormL<0x12, 0x7A, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "EXTQH $RA,$L,$RC">; //Extract quadword high +def EXTQ : OForm< 0x12, 0x36, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "EXTQ $RA,$RB,$RC">; //Extract quadword low +def EXTQi : OFormL<0x12, 0x36, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "EXTQ $RA,$L,$RC">; //Extract quadword low +def EXTWH : OForm< 0x12, 0x5A, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "EXTWH $RA,$RB,$RC">; //Extract word high +def EXTWHi : OFormL<0x12, 0x5A, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "EXTWH $RA,$L,$RC">; //Extract word high +def EXTWL : OForm< 0x12, 0x16, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "EXTWL $RA,$RB,$RC">; //Extract word low +def EXTWLi : OFormL<0x12, 0x16, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "EXTWL $RA,$L,$RC">; //Extract word low +def IMPLVER : OForm< 0x11, 0x6C, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "IMPLVER $RA,$RB,$RC">; //Implementation version +def IMPLVERi : OFormL<0x11, 0x6C, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "IMPLVER $RA,$L,$RC">; //Implementation version +def INSBL : OForm< 0x12, 0x0B, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "INSBL $RA,$RB,$RC">; //Insert byte low +def INSBLi : OFormL<0x12, 0x0B, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "INSBL $RA,$L,$RC">; //Insert byte low +def INSLH : OForm< 0x12, 0x67, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "INSLH $RA,$RB,$RC">; //Insert longword high +def INSLHi : OFormL<0x12, 0x67, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "INSLH $RA,$L,$RC">; //Insert longword high +def INSLL : OForm< 0x12, 0x2B, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "INSLL $RA,$RB,$RC">; //Insert longword low +def INSLLi : OFormL<0x12, 0x2B, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "INSLL $RA,$L,$RC">; //Insert longword low +def INSQH : OForm< 0x12, 0x77, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "INSQH $RA,$RB,$RC">; //Insert quadword high +def INSQHi : OFormL<0x12, 0x77, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "INSQH $RA,$L,$RC">; //Insert quadword high +def INSQL : OForm< 0x12, 0x3B, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "INSQL $RA,$RB,$RC">; //Insert quadword low +def INSQLi : OFormL<0x12, 0x3B, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "INSQL $RA,$L,$RC">; //Insert quadword low +def INSWH : OForm< 0x12, 0x57, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "INSWH $RA,$RB,$RC">; //Insert word high +def INSWHi : OFormL<0x12, 0x57, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "INSWH $RA,$L,$RC">; //Insert word high +def INSWL : OForm< 0x12, 0x1B, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "INSWL $RA,$RB,$RC">; //Insert word low +def INSWLi : OFormL<0x12, 0x1B, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "INSWL $RA,$L,$RC">; //Insert word low +def MSKBL : OForm< 0x12, 0x02, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "MSKBL $RA,$RB,$RC">; //Mask byte low +def MSKBLi : OFormL<0x12, 0x02, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "MSKBL $RA,$L,$RC">; //Mask byte low +def MSKLH : OForm< 0x12, 0x62, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "MSKLH $RA,$RB,$RC">; //Mask longword high +def MSKLHi : OFormL<0x12, 0x62, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "MSKLH $RA,$L,$RC">; //Mask longword high +def MSKLL : OForm< 0x12, 0x22, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "MSKLL $RA,$RB,$RC">; //Mask longword low +def MSKLLi : OFormL<0x12, 0x22, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "MSKLL $RA,$L,$RC">; //Mask longword low +def MSKQH : OForm< 0x12, 0x72, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "MSKQH $RA,$RB,$RC">; //Mask quadword high +def MSKQHi : OFormL<0x12, 0x72, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "MSKQH $RA,$L,$RC">; //Mask quadword high +def MSKQL : OForm< 0x12, 0x32, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "MSKQL $RA,$RB,$RC">; //Mask quadword low +def MSKQLi : OFormL<0x12, 0x32, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "MSKQL $RA,$L,$RC">; //Mask quadword low +def MSKWH : OForm< 0x12, 0x52, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "MSKWH $RA,$RB,$RC">; //Mask word high +def MSKWHi : OFormL<0x12, 0x52, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "MSKWH $RA,$L,$RC">; //Mask word high +def MSKWL : OForm< 0x12, 0x12, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "MSKWL $RA,$RB,$RC">; //Mask word low +def MSKWLi : OFormL<0x12, 0x12, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "MSKWL $RA,$L,$RC">; //Mask word low +def MULL : OForm< 0x13, 0x00, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "MULL $RA,$RB,$RC">; //Multiply longword +def MULLi : OFormL<0x13, 0x00, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "MULL $RA,$L,$RC">; //Multiply longword +def MULQ : OForm< 0x13, 0x20, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "MULQ $RA,$RB,$RC">; //Multiply quadword +def MULQi : OFormL<0x13, 0x20, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "MULQ $RA,$L,$RC">; //Multiply quadword +def ORNOT : OForm< 0x11, 0x28, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "ORNOT $RA,$RB,$RC">; //Logical sum with complement +def ORNOTi : OFormL<0x11, 0x28, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "ORNOT $RA,$L,$RC">; //Logical sum with complement +def S4ADDL : OForm< 0x10, 0x02, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "S4ADDL $RA,$RB,$RC">; //Scaled add longword by 4 +def S4ADDLi : OFormL<0x10, 0x02, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "S4ADDL $RA,$L,$RC">; //Scaled add longword by 4 +def S4ADDQ : OForm< 0x10, 0x22, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "S4ADDQ $RA,$RB,$RC">; //Scaled add quadword by 4 +def S4ADDQi : OFormL<0x10, 0x22, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "S4ADDQ $RA,$L,$RC">; //Scaled add quadword by 4 +def S4SUBL : OForm< 0x10, 0x0B, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "S4SUBL $RA,$RB,$RC">; //Scaled subtract longword by 4 +def S4SUBLi : OFormL<0x10, 0x0B, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "S4SUBL $RA,$L,$RC">; //Scaled subtract longword by 4 +def S4SUBQ : OForm< 0x10, 0x2B, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "S4SUBQ $RA,$RB,$RC">; //Scaled subtract quadword by 4 +def S4SUBQi : OFormL<0x10, 0x2B, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "S4SUBQ $RA,$L,$RC">; //Scaled subtract quadword by 4 +def S8ADDL : OForm< 0x10, 0x12, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "S8ADDL $RA,$RB,$RC">; //Scaled add longword by 8 +def S8ADDLi : OFormL<0x10, 0x12, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "S8ADDL $RA,$L,$RC">; //Scaled add longword by 8 +def S8ADDQ : OForm< 0x10, 0x32, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "S8ADDQ $RA,$RB,$RC">; //Scaled add quadword by 8 +def S8ADDQi : OFormL<0x10, 0x32, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "S8ADDQ $RA,$L,$RC">; //Scaled add quadword by 8 +def S8SUBL : OForm< 0x10, 0x1B, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "S8SUBL $RA,$RB,$RC">; //Scaled subtract longword by 8 +def S8SUBLi : OFormL<0x10, 0x1B, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "S8SUBL $RA,$L,$RC">; //Scaled subtract longword by 8 +def S8SUBQ : OForm< 0x10, 0x3B, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "S8SUBQ $RA,$RB,$RC">; //Scaled subtract quadword by 8 +def S8SUBQi : OFormL<0x10, 0x3B, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "S8SUBQ $RA,$L,$RC">; //Scaled subtract quadword by 8 +def SEXTB : OForm< 0x1C, 0x00, (ops GPRC:$RC, GPRC:$RB), "sextb $RB,$RC">; //Sign extend byte +def SEXTBi : OFormL<0x1C, 0x00, (ops GPRC:$RC, u8imm:$L), "sextb $L,$RC">; //Sign extend byte +def SEXTW : OForm< 0x1C, 0x01, (ops GPRC:$RC, GPRC:$RB), "sextw $RB,$RC">; //Sign extend word +def SEXTWi : OFormL<0x1C, 0x01, (ops GPRC:$RC, u8imm:$L), "sextw $L,$RC">; //Sign extend word +def SL : OForm< 0x12, 0x39, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "SLL $RA,$RB,$RC">; //Shift left logical +def SLi : OFormL<0x12, 0x39, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "SLL $RA,$L,$RC">; //Shift left logical +def SRA : OForm< 0x12, 0x3C, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "SRA $RA,$RB,$RC">; //Shift right arithmetic +def SRAi : OFormL<0x12, 0x3C, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "SRA $RA,$L,$RC">; //Shift right arithmetic +def SRL : OForm< 0x12, 0x34, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "SRL $RA,$RB,$RC">; //Shift right logical +def SRLi : OFormL<0x12, 0x34, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "SRL $RA,$L,$RC">; //Shift right logical +def SUBL : OForm< 0x10, 0x09, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "SUBL $RA,$RB,$RC">; //Subtract longword +def SUBLi : OFormL<0x10, 0x09, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "SUBL $RA,$L,$RC">; //Subtract longword +def SUBQ : OForm< 0x10, 0x29, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "SUBQ $RA,$RB,$RC">; //Subtract quadword +def SUBQi : OFormL<0x10, 0x29, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "SUBQ $RA,$L,$RC">; //Subtract quadword +def UMULH : OForm< 0x13, 0x30, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "UMULH $RA,$RB,$RC">; //Unsigned multiply quadword high +def UMULHi : OFormL<0x13, 0x30, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "UMULH $RA,$L,$RC">; //Unsigned multiply quadword high +def XOR : OForm< 0x11, 0x40, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "XOR $RA,$RB,$RC">; //Logical difference +def XORi : OFormL<0x11, 0x40, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "XOR $RA,$L,$RC">; //Logical difference +def ZAP : OForm< 0x12, 0x30, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "ZAP $RA,$RB,$RC">; //Zero bytes +def ZAPi : OFormL<0x12, 0x30, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "ZAP $RA,$L,$RC">; //Zero bytes +def ZAPNOT : OForm< 0x12, 0x31, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "ZAPNOT $RA,$RB,$RC">; //Zero bytes not +def ZAPNOTi : OFormL<0x12, 0x31, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "ZAPNOT $RA,$L,$RC">; //Zero bytes not + +//There are in the Multimedia extentions, so let's not use them yet def MAXSB8 : OForm<0x1C, 0x3E, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "MAXSB8 $RA,$RB,$RC">; //Vector signed byte maximum def MAXSW4 : OForm< 0x1C, 0x3F, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "MAXSW4 $RA,$RB,$RC">; //Vector signed word maximum def MAXUB8 : OForm<0x1C, 0x3C, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "MAXUB8 $RA,$RB,$RC">; //Vector unsigned byte maximum @@ -127,44 +222,13 @@ def MINSW4 : OForm< 0x1C, 0x39, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "MINSW4 $RA,$RB,$RC">; //Vector signed word minimum def MINUB8 : OForm< 0x1C, 0x3A, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "MINUB8 $RA,$RB,$RC">; //Vector unsigned byte minimum def MINUW4 : OForm< 0x1C, 0x3B, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "MINUW4 $RA,$RB,$RC">; //Vector unsigned word minimum -def MSKBL : OForm< 0x12, 0x02, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "MSKBL $RA,$RB,$RC">; //Mask byte low -def MSKLH : OForm< 0x12, 0x62, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "MSKLH $RA,$RB,$RC">; //Mask longword high -def MSKLL : OForm< 0x12, 0x22, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "MSKLL $RA,$RB,$RC">; //Mask longword low -def MSKQH : OForm< 0x12, 0x72, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "MSKQH $RA,$RB,$RC">; //Mask quadword high -def MSKQL : OForm< 0x12, 0x32, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "MSKQL $RA,$RB,$RC">; //Mask quadword low -def MSKWH : OForm< 0x12, 0x52, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "MSKWH $RA,$RB,$RC">; //Mask word high -def MSKWL : OForm< 0x12, 0x12, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "MSKWL $RA,$RB,$RC">; //Mask word low -def MULL : OForm< 0x13, 0x00, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "MULL $RA,$RB,$RC">; //Multiply longword -def MULL_V : OForm< 0x13, 0x40, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "MULL/V $RA,$RB,$RC">; -def MULQ : OForm< 0x13, 0x20, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "MULQ $RA,$RB,$RC">; //Multiply quadword -def MULQ_V : OForm< 0x13, 0x60, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "MULQ/V $RA,$RB,$RC">; -def ORNOT : OForm< 0x11, 0x28, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "ORNOT $RA,$RB,$RC">; //Logical sum with complement def PERR : OForm< 0x1C, 0x31, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "PERR $RA,$RB,$RC">; //Pixel error def PKLB : OForm< 0x1C, 0x37, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "PKLB $RA,$RB,$RC">; //Pack longwords to bytes def PKWB : OForm<0x1C, 0x36, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "PKWB $RA,$RB,$RC">; //Pack words to bytes -def S4ADDL : OForm< 0x10, 0x02, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "S4ADDL $RA,$RB,$RC">; //Scaled add longword by 4 -def S4ADDQ : OForm< 0x10, 0x22, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "S4ADDQ $RA,$RB,$RC">; //Scaled add quadword by 4 -def S4SUBL : OForm< 0x10, 0x0B, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "S4SUBL $RA,$RB,$RC">; //Scaled subtract longword by 4 -def S4SUBQ : OForm< 0x10, 0x2B, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "S4SUBQ $RA,$RB,$RC">; //Scaled subtract quadword by 4 -def S8ADDL : OForm< 0x10, 0x12, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "S8ADDL $RA,$RB,$RC">; //Scaled add longword by 8 -def S8ADDQ : OForm< 0x10, 0x32, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "S8ADDQ $RA,$RB,$RC">; //Scaled add quadword by 8 -def S8SUBL : OForm< 0x10, 0x1B, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "S8SUBL $RA,$RB,$RC">; //Scaled subtract longword by 8 -def S8SUBQ : OForm< 0x10, 0x3B, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "S8SUBQ $RA,$RB,$RC">; //Scaled subtract quadword by 8 -def SEXTB : OForm< 0x1C, 0x00, (ops GPRC:$RC, GPRC:$RB), "sextb $RB,$RC">; //Sign extend byte -def SEXTW : OForm< 0x1C, 0x01, (ops GPRC:$RC, GPRC:$RB), "sextw $RB,$RC">; //Sign extend word -def SL : OForm< 0x12, 0x39, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "SLL $RA,$RB,$RC">; //Shift left logical -def SRA : OForm< 0x12, 0x3C, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "SRA $RA,$RB,$RC">; //Shift right arithmetic -def SRL : OForm< 0x12, 0x34, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "SRL $RA,$RB,$RC">; //Shift right logical -def SUBL : OForm< 0x10, 0x09, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "SUBL $RA,$RB,$RC">; //Subtract longword -def SUBL_V : OForm< 0x10, 0x49, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "SUBL/V $RA,$RB,$RC">; -def SUBQ : OForm< 0x10, 0x29, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "SUBQ $RA,$RB,$RC">; //Subtract quadword -def SUBQ_V : OForm< 0x10, 0x69, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "SUBQ/V $RA,$RB,$RC">; -def UMULH : OForm< 0x13, 0x30, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "UMULH $RA,$RB,$RC">; //Unsigned multiply quadword high def UNPKBL : OForm< 0x1C, 0x35, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "UNPKBL $RA,$RB,$RC">; //Unpack bytes to longwords def UNPKBW : OForm< 0x1C, 0x34, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "UNPKBW $RA,$RB,$RC">; //Unpack bytes to words -def XOR : OForm< 0x11, 0x40, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "XOR $RA,$RB,$RC">; //Logical difference -def ZAP : OForm< 0x12, 0x30, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "ZAP $RA,$RB,$RC">; //Zero bytes -def ZAPNOT : OForm< 0x12, 0x31, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "ZAPNOT $RA,$RB,$RC">; //Zero bytes not + +//End operate let isReturn = 1, isTerminator = 1 in def RET : MForm< 0x1A, (ops GPRC:$RD, GPRC:$RS), "ret $RD,($RS),1">; //Return from subroutine Index: llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp diff -u llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.1 llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.2 --- llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.1 Sat Jan 22 17:41:55 2005 +++ llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp Mon Jan 24 13:44:07 2005 @@ -1,4 +1,4 @@ -//===- PPC64RegisterInfo.cpp - PowerPC64 Register Information ---*- C++ -*-===// +//===- AlphaRegisterInfo.cpp - Alpha Register Information ---*- C++ -*-----===// // // The LLVM Compiler Infrastructure // @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// This file contains the PowerPC64 implementation of the MRegisterInfo class. +// This file contains the Alpha implementation of the MRegisterInfo class. // //===----------------------------------------------------------------------===// Index: llvm/lib/Target/Alpha/AlphaTargetMachine.h diff -u llvm/lib/Target/Alpha/AlphaTargetMachine.h:1.2 llvm/lib/Target/Alpha/AlphaTargetMachine.h:1.3 --- llvm/lib/Target/Alpha/AlphaTargetMachine.h:1.2 Mon Jan 24 12:48:22 2005 +++ llvm/lib/Target/Alpha/AlphaTargetMachine.h Mon Jan 24 13:44:07 2005 @@ -1,4 +1,4 @@ -//===-- AlphaTargetMachine.h - Define TargetMachine for PowerPC -*- C++ -*-=// +//===-- AlphaTargetMachine.h - Define TargetMachine for Alpha -*- C++ -*-----=// // // The LLVM Compiler Infrastructure // From lattner at cs.uiuc.edu Mon Jan 24 13:55:49 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 24 Jan 2005 13:55:49 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/DataStructure/DSGraph.h DataStructure.h Message-ID: <200501241955.j0OJtnIU012759@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis/DataStructure: DSGraph.h updated: 1.83 -> 1.84 DataStructure.h updated: 1.81 -> 1.82 --- Log message: Add some methods. --- Diffs of the changes: (+23 -0) DSGraph.h | 13 +++++++++++++ DataStructure.h | 10 ++++++++++ 2 files changed, 23 insertions(+) Index: llvm/include/llvm/Analysis/DataStructure/DSGraph.h diff -u llvm/include/llvm/Analysis/DataStructure/DSGraph.h:1.83 llvm/include/llvm/Analysis/DataStructure/DSGraph.h:1.84 --- llvm/include/llvm/Analysis/DataStructure/DSGraph.h:1.83 Sat Jan 8 22:18:28 2005 +++ llvm/include/llvm/Analysis/DataStructure/DSGraph.h Mon Jan 24 13:55:34 2005 @@ -55,6 +55,11 @@ void erase(Value *V) { erase(find(V)); } + void eraseIfExists(Value *V) { + iterator I = find(V); + if (I != end()) erase(I); + } + /// replaceScalar - When an instruction needs to be modified, this method can /// be used to update the scalar map to remove the old and insert the new. /// @@ -65,6 +70,14 @@ erase(I); } + /// copyScalarIfExists - If Old exists in the scalar map, make New point to + /// whatever Old did. + void copyScalarIfExists(Value *Old, Value *New) { + iterator I = find(Old); + if (I != end()) + ValueMap.insert(std::make_pair(New, I->second)); + } + DSNodeHandle &operator[](Value *V) { std::pair IP = ValueMap.insert(std::make_pair(V, DSNodeHandle())); Index: llvm/include/llvm/Analysis/DataStructure/DataStructure.h diff -u llvm/include/llvm/Analysis/DataStructure/DataStructure.h:1.81 llvm/include/llvm/Analysis/DataStructure/DataStructure.h:1.82 --- llvm/include/llvm/Analysis/DataStructure/DataStructure.h:1.81 Sat Jan 8 22:18:28 2005 +++ llvm/include/llvm/Analysis/DataStructure/DataStructure.h Mon Jan 24 13:55:34 2005 @@ -113,6 +113,11 @@ DSGraph &getGlobalsGraph() const { return *GlobalsGraph; } + /// deleteValue/copyValue - Interfaces to update the DSGraphs in the program. + /// These correspond to the interfaces defined in the AliasAnalysis class. + void deleteValue(Value *V); + void copyValue(Value *From, Value *To); + /// print - Print out the analysis results... /// void print(std::ostream &O, const Module *M) const; @@ -175,6 +180,11 @@ DSGraph &getGlobalsGraph() const { return *GlobalsGraph; } + /// deleteValue/copyValue - Interfaces to update the DSGraphs in the program. + /// These correspond to the interfaces defined in the AliasAnalysis class. + void deleteValue(Value *V); + void copyValue(Value *From, Value *To); + /// print - Print out the analysis results... /// void print(std::ostream &O, const Module *M) const; From lattner at cs.uiuc.edu Mon Jan 24 14:00:29 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 24 Jan 2005 14:00:29 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp DataStructureAA.cpp TopDownClosure.cpp Message-ID: <200501242000.j0OK0T2Y013308@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: BottomUpClosure.cpp updated: 1.84 -> 1.85 DataStructureAA.cpp updated: 1.22 -> 1.23 TopDownClosure.cpp updated: 1.70 -> 1.71 --- Log message: Make -ds-aa more useful, allowing it to be updated as xforms hack on the program. --- Diffs of the changes: (+119 -0) BottomUpClosure.cpp | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++ DataStructureAA.cpp | 11 ++++++++++ TopDownClosure.cpp | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 119 insertions(+) Index: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp diff -u llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.84 llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.85 --- llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.84 Mon Nov 8 15:08:46 2004 +++ llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp Mon Jan 24 14:00:14 2005 @@ -331,3 +331,58 @@ //Graph.writeGraphToFile(std::cerr, "bu_" + F.getName()); } + +static const Function *getFnForValue(const Value *V) { + if (const Instruction *I = dyn_cast(V)) + return I->getParent()->getParent(); + else if (const Argument *A = dyn_cast(V)) + return A->getParent(); + else if (const BasicBlock *BB = dyn_cast(V)) + return BB->getParent(); + return 0; +} + +/// deleteValue/copyValue - Interfaces to update the DSGraphs in the program. +/// These correspond to the interfaces defined in the AliasAnalysis class. +void BUDataStructures::deleteValue(Value *V) { + if (const Function *F = getFnForValue(V)) { // Function local value? + // If this is a function local value, just delete it from the scalar map! + getDSGraph(*F).getScalarMap().eraseIfExists(V); + return; + } + + if (Function *F = dyn_cast(F)) { + assert(getDSGraph(*F).getReturnNodes().size() == 1 && + "cannot handle scc's"); + delete DSInfo[F]; + DSInfo.erase(F); + return; + } + + assert(!isa(V) && "Do not know how to delete GV's yet!"); +} + +void BUDataStructures::copyValue(Value *From, Value *To) { + if (From == To) return; + if (const Function *F = getFnForValue(From)) { // Function local value? + // If this is a function local value, just delete it from the scalar map! + getDSGraph(*F).getScalarMap().copyScalarIfExists(From, To); + return; + } + + if (Function *FromF = dyn_cast(From)) { + Function *ToF = cast(To); + assert(!DSInfo.count(ToF) && "New Function already exists!"); + DSGraph *NG = new DSGraph(getDSGraph(*FromF)); + DSInfo[ToF] = NG; + assert(NG->getReturnNodes().size() == 1 && "Cannot copy SCC's yet!"); + + // Change the Function* is the returnnodes map to the ToF. + DSNodeHandle Ret = NG->getReturnNodes().begin()->second; + NG->getReturnNodes().clear(); + NG->getReturnNodes()[ToF] = Ret; + return; + } + + assert(!isa(From) && "Do not know how to copy GV's yet!"); +} Index: llvm/lib/Analysis/DataStructure/DataStructureAA.cpp diff -u llvm/lib/Analysis/DataStructure/DataStructureAA.cpp:1.22 llvm/lib/Analysis/DataStructure/DataStructureAA.cpp:1.23 --- llvm/lib/Analysis/DataStructure/DataStructureAA.cpp:1.22 Sun Jan 9 14:42:52 2005 +++ llvm/lib/Analysis/DataStructure/DataStructureAA.cpp Mon Jan 24 14:00:14 2005 @@ -61,6 +61,17 @@ return AliasAnalysis::getModRefInfo(CS1,CS2); } + virtual void deleteValue(Value *V) { + BU->deleteValue(V); + TD->deleteValue(V); + } + + virtual void copyValue(Value *From, Value *To) { + if (From == To) return; + BU->copyValue(From, To); + TD->copyValue(From, To); + } + private: DSGraph *getGraphForValue(const Value *V); }; Index: llvm/lib/Analysis/DataStructure/TopDownClosure.cpp diff -u llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.70 llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.71 --- llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.70 Sun Sep 19 23:45:25 2004 +++ llvm/lib/Analysis/DataStructure/TopDownClosure.cpp Mon Jan 24 14:00:14 2005 @@ -290,3 +290,56 @@ << Graph.getFunctionNames() << " [" << Graph.getGraphSize() << "+" << Graph.getFunctionCalls().size() << "]\n"); } + +static const Function *getFnForValue(const Value *V) { + if (const Instruction *I = dyn_cast(V)) + return I->getParent()->getParent(); + else if (const Argument *A = dyn_cast(V)) + return A->getParent(); + else if (const BasicBlock *BB = dyn_cast(V)) + return BB->getParent(); + return 0; +} + +void TDDataStructures::deleteValue(Value *V) { + if (const Function *F = getFnForValue(V)) { // Function local value? + // If this is a function local value, just delete it from the scalar map! + getDSGraph(*F).getScalarMap().eraseIfExists(V); + return; + } + + if (Function *F = dyn_cast(F)) { + assert(getDSGraph(*F).getReturnNodes().size() == 1 && + "cannot handle scc's"); + delete DSInfo[F]; + DSInfo.erase(F); + return; + } + + assert(!isa(V) && "Do not know how to delete GV's yet!"); +} + +void TDDataStructures::copyValue(Value *From, Value *To) { + if (From == To) return; + if (const Function *F = getFnForValue(From)) { // Function local value? + // If this is a function local value, just delete it from the scalar map! + getDSGraph(*F).getScalarMap().copyScalarIfExists(From, To); + return; + } + + if (Function *FromF = dyn_cast(From)) { + Function *ToF = cast(To); + assert(!DSInfo.count(ToF) && "New Function already exists!"); + DSGraph *NG = new DSGraph(getDSGraph(*FromF)); + DSInfo[ToF] = NG; + assert(NG->getReturnNodes().size() == 1 && "Cannot copy SCC's yet!"); + + // Change the Function* is the returnnodes map to the ToF. + DSNodeHandle Ret = NG->getReturnNodes().begin()->second; + NG->getReturnNodes().clear(); + NG->getReturnNodes()[ToF] = Ret; + return; + } + + assert(!isa(From) && "Do not know how to copy GV's yet!"); +} From lattner at cs.uiuc.edu Mon Jan 24 15:11:22 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 24 Jan 2005 15:11:22 -0600 Subject: [llvm-commits] CVS: llvm-test/Makefile.dummylib Message-ID: <200501242111.j0OLBMZ3017316@apoc.cs.uiuc.edu> Changes in directory llvm-test: Makefile.dummylib updated: 1.6 -> 1.7 --- Log message: Get this to work with recent changes. --- Diffs of the changes: (+2 -2) Makefile.dummylib | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm-test/Makefile.dummylib diff -u llvm-test/Makefile.dummylib:1.6 llvm-test/Makefile.dummylib:1.7 --- llvm-test/Makefile.dummylib:1.6 Mon Sep 20 13:39:32 2004 +++ llvm-test/Makefile.dummylib Mon Jan 24 15:11:06 2005 @@ -9,7 +9,7 @@ # DUMMYLIB - The path to the library of stub functions which is used to resolve # external functions for dsanalysis. # -DUMMYLIB := $(DESTLIBBYTECODE)/libdummy.bc +DUMMYLIB := $(LLVMLIBDEBUGSOURCE)/libdummy.bca DUMMYSRC := $(LLVM_SRC_ROOT)/runtime/libdummy # Rebuild dummylib if necessary... @@ -20,4 +20,4 @@ LINKED_PROGS := $(PROGRAMS_TO_TEST:%=Output/%.lib.bc) $(LINKED_PROGS): Output/%.lib.bc: Output/%.llvm.bc $(DUMMYLIB) - $(LLINK) $< $(DUMMYLIB) | $(LOPT) -funcresolve -internalize -globaldce > $@ + $(LGCCLDPROG) --link-as-library $< $(DUMMYLIB) -o $@ From lattner at cs.uiuc.edu Mon Jan 24 15:21:30 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 24 Jan 2005 15:21:30 -0600 Subject: [llvm-commits] CVS: llvm-test/TEST.dsgraph.Makefile Message-ID: <200501242121.j0OLLUPg019967@apoc.cs.uiuc.edu> Changes in directory llvm-test: TEST.dsgraph.Makefile updated: 1.13 -> 1.14 --- Log message: Get this to work. --- Diffs of the changes: (+1 -3) TEST.dsgraph.Makefile | 4 +--- 1 files changed, 1 insertion(+), 3 deletions(-) Index: llvm-test/TEST.dsgraph.Makefile diff -u llvm-test/TEST.dsgraph.Makefile:1.13 llvm-test/TEST.dsgraph.Makefile:1.14 --- llvm-test/TEST.dsgraph.Makefile:1.13 Sat Jan 15 21:16:09 2005 +++ llvm-test/TEST.dsgraph.Makefile Mon Jan 24 15:21:14 2005 @@ -5,9 +5,7 @@ # ##===----------------------------------------------------------------------===## -CURDIR := $(shell cd .; pwd) -PROGDIR := $(PROJ_SRC_ROOT) -RELDIR := $(subst $(PROGDIR),,$(CURDIR)) +RELDIR := $(subst $(PROJ_OBJ_ROOT),,$(PROJ_OBJ_DIR)) # We require the programs to be linked with libdummy include $(LEVEL)/Makefile.dummylib From alenhar2 at cs.uiuc.edu Mon Jan 24 18:35:52 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Mon, 24 Jan 2005 18:35:52 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp AlphaInstrInfo.td Message-ID: <200501250035.SAA28362@cypher.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.2 -> 1.3 AlphaInstrInfo.td updated: 1.2 -> 1.3 --- Log message: more load choices, better add with imm --- Diffs of the changes: (+103 -41) AlphaISelPattern.cpp | 141 ++++++++++++++++++++++++++++++++++++--------------- AlphaInstrInfo.td | 3 + 2 files changed, 103 insertions(+), 41 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.2 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.3 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.2 Mon Jan 24 13:44:05 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Mon Jan 24 18:35:34 2005 @@ -44,10 +44,10 @@ setOperationAction(ISD::EXTLOAD , MVT::i1 , Expand); setOperationAction(ISD::EXTLOAD , MVT::i8 , Expand); setOperationAction(ISD::EXTLOAD , MVT::i16 , Expand); + setOperationAction(ISD::ZEXTLOAD , MVT::i1 , Expand); - setOperationAction(ISD::ZEXTLOAD , MVT::i8 , Expand); - setOperationAction(ISD::ZEXTLOAD , MVT::i16 , Expand); setOperationAction(ISD::ZEXTLOAD , MVT::i32 , Expand); + setOperationAction(ISD::SEXTLOAD , MVT::i1 , Expand); setOperationAction(ISD::SEXTLOAD , MVT::i8 , Expand); setOperationAction(ISD::SEXTLOAD , MVT::i16 , Expand); @@ -305,6 +305,35 @@ return Result; case ISD::EXTLOAD: + // 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()); + + Select(Node->getOperand(0)); // chain + Tmp1 = SelectExpr(Node->getOperand(1)); + + switch(Node->getValueType(0)) { + default: assert(0 && "Unknown type to sign extend to."); + case MVT::i64: + switch (cast(Node)->getExtraValueType()) { + default: + assert(0 && "Bad sign extend!"); + case MVT::i32: + BuildMI(BB, Alpha::LDL, 2, Result).addImm(0).addReg(Tmp1); + break; + case MVT::i16: + BuildMI(BB, Alpha::LDWU, 2, Result).addImm(0).addReg(Tmp1); + break; + case MVT::i8: + BuildMI(BB, Alpha::LDBU, 2, Result).addImm(0).addReg(Tmp1); + break; + } + break; + } + return Result; + case ISD::SEXTLOAD: // Make sure we generate both values. if (Result != 1) @@ -323,17 +352,44 @@ case MVT::i32: BuildMI(BB, Alpha::LDL, 2, Result).addImm(0).addReg(Tmp1); break; +// case MVT::i16: +// BuildMI(BB, Alpha::LDW, 2, Result).addImm(0).addReg(Tmp1); +// break; +// case MVT::i8: +// BuildMI(BB, Alpha::LDB, 2, Result).addImm(0).addReg(Tmp1); +// break; + } + break; + } + return Result; + + case ISD::ZEXTLOAD: + // 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()); + + Select(Node->getOperand(0)); // chain + Tmp1 = SelectExpr(Node->getOperand(1)); + switch(Node->getValueType(0)) { + default: assert(0 && "Unknown type to zero extend to."); + case MVT::i64: + switch (cast(Node)->getExtraValueType()) { + default: + assert(0 && "Bad sign extend!"); case MVT::i16: - BuildMI(BB, Alpha::LDW, 2, Result).addImm(0).addReg(Tmp1); + BuildMI(BB, Alpha::LDWU, 2, Result).addImm(0).addReg(Tmp1); break; case MVT::i8: - BuildMI(BB, Alpha::LDB, 2, Result).addImm(0).addReg(Tmp1); + BuildMI(BB, Alpha::LDBU, 2, Result).addImm(0).addReg(Tmp1); break; } break; } return Result; + case ISD::GlobalAddress: AlphaLowering.restoreGP(BB); BuildMI(BB, Alpha::LOAD_ADDR, 1, Result) @@ -403,12 +459,6 @@ } case ISD::SIGN_EXTEND: - { - std::cerr << "DestT: " << N.getValueType() << "\n"; - std::cerr << "SrcT: " << N.getOperand(0).getValueType() << "\n"; - assert(0 && "Sign Extend not there yet"); - return Result; - } case ISD::SIGN_EXTEND_INREG: { Tmp1 = SelectExpr(N.getOperand(0)); @@ -421,11 +471,7 @@ break; case MVT::i32: { - Tmp2 = MakeReg(MVT::i64); - unsigned Tmp3 = MakeReg(MVT::i64); - BuildMI(BB, Alpha::LOAD_IMM, 1, Tmp2).addImm(16); - BuildMI(BB, Alpha::SL, 2, Tmp3).addReg(Tmp1).addReg(Tmp2); - BuildMI(BB, Alpha::SRA, 2, Result).addReg(Tmp3).addReg(Tmp2); + BuildMI(BB, Alpha::ADDLi, 2, Result).addReg(Tmp1).addImm(0); break; } case MVT::i16: @@ -447,25 +493,12 @@ default: assert(0 && "Zero Extend InReg not there yet"); break; - case MVT::i32: - { - Tmp2 = MakeReg(MVT::i64); - BuildMI(BB, Alpha::LOAD_IMM, 1, Tmp2).addImm(0xf0); - BuildMI(BB, Alpha::ZAP, 2, Result).addReg(Tmp1).addReg(Tmp2); - break; - } - case MVT::i16: - Tmp2 = MakeReg(MVT::i64); - BuildMI(BB, Alpha::LOAD_IMM, 1, Tmp2).addImm(0xfc); - BuildMI(BB, Alpha::ZAP, 2, Result).addReg(Tmp1).addReg(Tmp2); - break; - case MVT::i8: - Tmp2 = MakeReg(MVT::i64); - BuildMI(BB, Alpha::LOAD_IMM, 1, Tmp2).addImm(0xfe); - BuildMI(BB, Alpha::ZAP, 2, Result).addReg(Tmp1).addReg(Tmp2); - break; + case MVT::i32: Tmp2 = 0xf0; break; + case MVT::i16: Tmp2 = 0xfc; break; + case MVT::i8: Tmp2 = 0xfe; break; } - return Result; + BuildMI(BB, Alpha::ZAPi, 2, Result).addReg(Tmp1).addImm(Tmp2); + return Result; } case ISD::SETCC: @@ -576,15 +609,40 @@ return Result; case ISD::ADD: - Tmp1 = SelectExpr(N.getOperand(0)); - Tmp2 = SelectExpr(N.getOperand(1)); - BuildMI(BB, Alpha::ADDQ, 2, Result).addReg(Tmp1).addReg(Tmp2); - return Result; case ISD::SUB: - Tmp1 = SelectExpr(N.getOperand(0)); - Tmp2 = SelectExpr(N.getOperand(1)); - BuildMI(BB, Alpha::SUBQ, 2, Result).addReg(Tmp1).addReg(Tmp2); - return Result; + { + bool isAdd = N.getOpcode() == ISD::ADD; + + //FIXME: first check for Scaled Adds and Subs! + if(N.getOperand(1).getOpcode() == ISD::Constant && + cast(N.getOperand(1))->getValue() >= 0 && + cast(N.getOperand(1))->getValue() <= 255) + { //Normal imm add/sub + Opc = isAdd ? Alpha::ADDQi : Alpha::SUBQi; + Tmp1 = SelectExpr(N.getOperand(0)); + Tmp2 = cast(N.getOperand(1))->getValue(); + BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addImm(Tmp2); + } + else if(N.getOperand(1).getOpcode() == ISD::Constant && + cast(N.getOperand(1))->getValue() >= 0 && + cast(N.getOperand(1))->getValue() <= 32767) + { //LDA //FIXME: expand the above condition a bit + Tmp1 = SelectExpr(N.getOperand(0)); + Tmp2 = cast(N.getOperand(1))->getValue(); + if (!isAdd) + Tmp2 = -Tmp2; + BuildMI(BB, Alpha::LDA, 2, Result).addImm(Tmp2).addReg(Tmp1); + } + else + { //Normal add/sub + Opc = isAdd ? Alpha::ADDQ : Alpha::SUBQ; + Tmp1 = SelectExpr(N.getOperand(0)); + Tmp2 = SelectExpr(N.getOperand(1)); + BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); + + } + return Result; + } case ISD::UREM: Tmp1 = SelectExpr(N.getOperand(0)); @@ -713,6 +771,7 @@ Tmp1 = SelectExpr(N.getOperand(1)); switch (N.getOperand(1).getValueType()) { default: assert(0 && "All other types should have been promoted!!"); + case MVT::i32: case MVT::i64: BuildMI(BB, Alpha::BIS, 2, Alpha::R0).addReg(Tmp1).addReg(Tmp1); break; Index: llvm/lib/Target/Alpha/AlphaInstrInfo.td diff -u llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.2 llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.3 --- llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.2 Mon Jan 24 13:44:07 2005 +++ llvm/lib/Target/Alpha/AlphaInstrInfo.td Mon Jan 24 18:35:34 2005 @@ -253,6 +253,9 @@ def LDL : MForm<0x28, (ops GPRC:$RA, s16imm:$DISP, GPRC:$RB), "ldq $RA,$DISP($RB)">; // Load sign-extended longword def LDQ : MForm<0x29, (ops GPRC:$RA, s16imm:$DISP, GPRC:$RB), "ldq $RA,$DISP($RB)">; //Load quadword +def LDBU : MForm<0x0A, (ops GPRC:$RA, s16imm:$DISP, GPRC:$RB), "ldbu $RA,$DISP($RB)">; //Load zero-extended byte +def LDWU : MForm<0x0C, (ops GPRC:$RA, s16imm:$DISP, GPRC:$RB), "ldwu $RA,$DISP($RB)">; //Load zero-extended word + def BEQ : BForm<0x39, (ops GPRC:$RA, s21imm:$DISP), "beq $RA,$DISP">; //Branch if = zero def BGE : BForm<0x3E, (ops GPRC:$RA, s21imm:$DISP), "bge $RA,$DISP">; //Branch if >= zero From reid at x10sys.com Mon Jan 24 23:05:00 2005 From: reid at x10sys.com (Reid Spencer) Date: Mon, 24 Jan 2005 23:05:00 -0600 Subject: [llvm-commits] CVS: llvm/docs/CommandGuide/llc.pod Message-ID: <200501250505.XAA27802@zion.cs.uiuc.edu> Changes in directory llvm/docs/CommandGuide: llc.pod updated: 1.7 -> 1.8 --- Log message: Document the --load option. --- Diffs of the changes: (+6 -0) llc.pod | 6 ++++++ 1 files changed, 6 insertions(+) Index: llvm/docs/CommandGuide/llc.pod diff -u llvm/docs/CommandGuide/llc.pod:1.7 llvm/docs/CommandGuide/llc.pod:1.8 --- llvm/docs/CommandGuide/llc.pod:1.7 Thu Dec 9 15:16:40 2004 +++ llvm/docs/CommandGuide/llc.pod Mon Jan 24 23:04:49 2005 @@ -134,6 +134,12 @@ =back +=item B<--load>=F + +Dynamically load F (a path to a dynamically shared object) that +implements an LLVM target. This will permit the target name to be used with the +B<-march> option so that code can be generated for that target. + =back =head2 Intel IA-32-specific Options From alkis at cs.uiuc.edu Tue Jan 25 02:29:31 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue, 25 Jan 2005 02:29:31 -0600 Subject: [llvm-commits] CVS: llvm-java/test/Programs/SingleSource/UnitTests/Collections.java Collections1.java Collections2.java Message-ID: <200501250829.CAA29740@zion.cs.uiuc.edu> Changes in directory llvm-java/test/Programs/SingleSource/UnitTests: Collections.java added (r1.1) Collections1.java added (r1.1) Collections2.java added (r1.1) --- Log message: Add more tests --- Diffs of the changes: (+52 -0) Collections.java | 22 ++++++++++++++++++++++ Collections1.java | 15 +++++++++++++++ Collections2.java | 15 +++++++++++++++ 3 files changed, 52 insertions(+) Index: llvm-java/test/Programs/SingleSource/UnitTests/Collections.java diff -c /dev/null llvm-java/test/Programs/SingleSource/UnitTests/Collections.java:1.1 *** /dev/null Tue Jan 25 02:29:30 2005 --- llvm-java/test/Programs/SingleSource/UnitTests/Collections.java Tue Jan 25 02:29:20 2005 *************** *** 0 **** --- 1,22 ---- + import java.util.*; + + public class Collections + { + public static void main(String[] args) { + Collection c1 = new LinkedList(); + for (int i = 0; i < 100; ++i) { + c1.add(new Integer(i)); + } + Collection c2 = new TreeSet(c1); + + Test.println(c1.remove(new Integer(5))); + Test.println(c1.equals(c2)); + Test.println(c2.remove(new Integer(5))); + Test.println(c1.equals(c2)); + + Test.println(c1.remove(new Integer(5))); + Test.println(c1.equals(c2)); + Test.println(c2.remove(new Integer(5))); + Test.println(c1.equals(c2)); + } + } Index: llvm-java/test/Programs/SingleSource/UnitTests/Collections1.java diff -c /dev/null llvm-java/test/Programs/SingleSource/UnitTests/Collections1.java:1.1 *** /dev/null Tue Jan 25 02:29:31 2005 --- llvm-java/test/Programs/SingleSource/UnitTests/Collections1.java Tue Jan 25 02:29:20 2005 *************** *** 0 **** --- 1,15 ---- + import java.util.*; + + public class Collections1 + { + public static void main(String[] args) { + Collection c1 = new LinkedList(); + for (int i = 0; i < 100; ++i) { + c1.add(new Integer(i)); + } + + for (Iterator i = c1.iterator(); i.hasNext(); ) { + Test.println(((Integer) i.next()).intValue()); + } + } + } Index: llvm-java/test/Programs/SingleSource/UnitTests/Collections2.java diff -c /dev/null llvm-java/test/Programs/SingleSource/UnitTests/Collections2.java:1.1 *** /dev/null Tue Jan 25 02:29:31 2005 --- llvm-java/test/Programs/SingleSource/UnitTests/Collections2.java Tue Jan 25 02:29:20 2005 *************** *** 0 **** --- 1,15 ---- + import java.util.*; + + public class Collections2 + { + public static void main(String[] args) { + Collection c1 = new TreeSet(); + for (int i = 0; i < 100; ++i) { + c1.add(new Integer(i)); + } + + for (Iterator i = c1.iterator(); i.hasNext(); ) { + Test.println(((Integer) i.next()).intValue()); + } + } + } From alkis at cs.uiuc.edu Tue Jan 25 02:40:39 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue, 25 Jan 2005 02:40:39 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200501250840.CAA29914@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.193 -> 1.194 --- Log message: Do not emit interface vtables more than once. This fixes Collection1.java. Also add some more classes to compile so that Collections.java and Collection2.java do not fail with missing functions. --- Diffs of the changes: (+16 -6) Compiler.cpp | 22 ++++++++++++++++------ 1 files changed, 16 insertions(+), 6 deletions(-) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.193 llvm-java/lib/Compiler/Compiler.cpp:1.194 --- llvm-java/lib/Compiler/Compiler.cpp:1.193 Mon Jan 24 07:47:17 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Tue Jan 25 02:40:28 2005 @@ -587,6 +587,9 @@ /// Builds an interface VTable for the specified /// pair. llvm::Constant* buildInterfaceVTable(ClassFile* cf, ClassFile* interface) { + DEBUG(std::cerr << "Building interface vtable: " + << interface->getThisClass()->getName()->str() << " for: " + << cf->getThisClass()->getName()->str() << '\n'); const VTableInfo& classVI = getVTableInfo(cf); const VTableInfo& interfaceVI = getVTableInfo(interface); @@ -638,11 +641,14 @@ const ClassInfo& ifaceCi = getClassInfo(ifaceCf); if (ifaceCi.interfaceIdx >= vtables.size()) vtables.resize(ifaceCi.interfaceIdx+1, nullVTable); - vtables[ifaceCi.interfaceIdx] = buildInterfaceVTable(cf, ifaceCf); - const Classes& interfaces = ifaceCf->getInterfaces(); - for (unsigned i = 0, e = interfaces.size(); i != e; ++i) { - ClassFile* otherCf = ClassFile::get(interfaces[i]->getName()->str()); - insertVtablesForInterface(vtables, cf, otherCf); + // Add this interface's vtable if it was not added before. + if (vtables[ifaceCi.interfaceIdx] == nullVTable) { + vtables[ifaceCi.interfaceIdx] = buildInterfaceVTable(cf, ifaceCf); + const Classes& interfaces = ifaceCf->getInterfaces(); + for (unsigned i = 0, e = interfaces.size(); i != e; ++i) { + ClassFile* otherCf = ClassFile::get(interfaces[i]->getName()->str()); + insertVtablesForInterface(vtables, cf, otherCf); + } } } @@ -1308,8 +1314,12 @@ classMethodDesc.find("java/util/NoSuchElementException") != 0 && classMethodDesc.find("java/util/AbstractCollection") != 0 && classMethodDesc.find("java/util/AbstractList") != 0 && + classMethodDesc.find("java/util/AbstractSet") != 0 && + classMethodDesc.find("java/util/AbstractMap") != 0 && classMethodDesc.find("java/util/AbstractSequentialList") != 0 && - classMethodDesc.find("java/util/LinkedList") != 0) { + classMethodDesc.find("java/util/LinkedList") != 0 && + classMethodDesc.find("java/util/TreeMap") != 0 && + classMethodDesc.find("java/util/TreeSet") != 0) { DEBUG(std::cerr << "Skipping compilation of method: " << classMethodDesc << '\n'); return function; From alkis at cs.uiuc.edu Tue Jan 25 08:23:57 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue, 25 Jan 2005 08:23:57 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200501251423.IAA26200@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.194 -> 1.195 --- Log message: Indent to 2 spaces and untabify. --- Diffs of the changes: (+7 -7) Compiler.cpp | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.194 llvm-java/lib/Compiler/Compiler.cpp:1.195 --- llvm-java/lib/Compiler/Compiler.cpp:1.194 Tue Jan 25 02:40:28 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Tue Jan 25 08:23:46 2005 @@ -311,7 +311,7 @@ PATypeHolder holder = ci.type; cast(ci.type)-> - refineAbstractTypeTo(StructType::get(elements)); + refineAbstractTypeTo(StructType::get(elements)); ci.type = holder.get(); DEBUG(std::cerr << "Adding java/lang/Object = " @@ -587,9 +587,9 @@ /// Builds an interface VTable for the specified /// pair. llvm::Constant* buildInterfaceVTable(ClassFile* cf, ClassFile* interface) { - DEBUG(std::cerr << "Building interface vtable: " - << interface->getThisClass()->getName()->str() << " for: " - << cf->getThisClass()->getName()->str() << '\n'); + DEBUG(std::cerr << "Building interface vtable: " + << interface->getThisClass()->getName()->str() << " for: " + << cf->getThisClass()->getName()->str() << '\n'); const VTableInfo& classVI = getVTableInfo(cf); const VTableInfo& interfaceVI = getVTableInfo(interface); @@ -1259,7 +1259,7 @@ DEBUG(std::cerr << "Adding stub for natively implemented method: " << classMethodDesc << '\n'); FunctionType* jniFuncTy = - cast(getJNIType(method->getDescriptor())); + cast(getJNIType(method->getDescriptor())); std::string funcName = "Java_" + @@ -1288,7 +1288,7 @@ } Value* result = new CallInst(jniFunction, params, "", bb); if (result->getType() != Type::VoidTy) - result = new CastInst(result, function->getReturnType(), TMP,bb); + result = new CastInst(result, function->getReturnType(), TMP,bb); new ReturnInst(result, bb); return function; @@ -1592,7 +1592,7 @@ void do_aload_common(Type* arrayTy) { Value* index = pop(Type::IntTy); - Value* arrayRef = pop(PointerType::get(arrayTy)); + Value* arrayRef = pop(PointerType::get(arrayTy)); std::vector indices; indices.reserve(3); From alkis at cs.uiuc.edu Tue Jan 25 09:52:59 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue, 25 Jan 2005 09:52:59 -0600 Subject: [llvm-commits] CVS: llvm-java/test/Programs/SingleSource/UnitTests/Collections.java Message-ID: <200501251552.JAA26842@zion.cs.uiuc.edu> Changes in directory llvm-java/test/Programs/SingleSource/UnitTests: Collections.java updated: 1.1 -> 1.2 --- Log message: Make test a bit more interesting --- Diffs of the changes: (+1 -1) Collections.java | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm-java/test/Programs/SingleSource/UnitTests/Collections.java diff -u llvm-java/test/Programs/SingleSource/UnitTests/Collections.java:1.1 llvm-java/test/Programs/SingleSource/UnitTests/Collections.java:1.2 --- llvm-java/test/Programs/SingleSource/UnitTests/Collections.java:1.1 Tue Jan 25 02:29:20 2005 +++ llvm-java/test/Programs/SingleSource/UnitTests/Collections.java Tue Jan 25 09:52:48 2005 @@ -3,7 +3,7 @@ public class Collections { public static void main(String[] args) { - Collection c1 = new LinkedList(); + Collection c1 = new TreeSet(); for (int i = 0; i < 100; ++i) { c1.add(new Integer(i)); } From alkis at cs.uiuc.edu Tue Jan 25 10:02:03 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue, 25 Jan 2005 10:02:03 -0600 Subject: [llvm-commits] CVS: llvm-java/test/Makefile.test Message-ID: <200501251602.KAA27115@zion.cs.uiuc.edu> Changes in directory llvm-java/test: Makefile.test updated: 1.35 -> 1.36 --- Log message: Move common rules out of the ifdef. --- Diffs of the changes: (+10 -10) Makefile.test | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-) Index: llvm-java/test/Makefile.test diff -u llvm-java/test/Makefile.test:1.35 llvm-java/test/Makefile.test:1.36 --- llvm-java/test/Makefile.test:1.35 Mon Jan 17 11:33:59 2005 +++ llvm-java/test/Makefile.test Tue Jan 25 10:01:52 2005 @@ -17,6 +17,16 @@ # intermediate results .PRECIOUS: %.linked.bc %.raw.bc %.ll %.llvm.bc +# rule to link bytecode with runtime +%.llvm %.llvm.bc: %.linked.bc $(LibDir)/libjrt.bca $(EXTRA_OBJS) $(LOPT) + $(Echo) Linking $< with the Java runtime + -$(Verb)$(GCCLD) -o=$*.llvm $< -L $(CFERuntimeLibDir) -L $(LibDir) $(EXTRA_OBJS) + +# rule to make assembly from bytecode +%.dis-ll: %.bc + $(Echo) Disassembling $< + $(Verb)$(LDIS) -f -o=$@ $< + # rule to compile java sources ifdef BUILD_JAVA_SOURCES JAVA_SOURCES := $(wildcard *.java) @@ -58,16 +68,6 @@ && echo "PASS: $(notdir $*)" \ || echo "FAIL: $(notdir $*)" -# rule to link bytecode with runtime -%.llvm %.llvm.bc: %.linked.bc $(LibDir)/libjrt.bca $(EXTRA_OBJS) $(LOPT) - $(Echo) Linking $< with the Java runtime - -$(Verb)$(GCCLD) -o=$*.llvm $< -L $(CFERuntimeLibDir) -L $(LibDir) $(EXTRA_OBJS) - -# rule to make assembly from bytecode -%.dis-ll: %.bc - $(Echo) Disassembling $< - $(Verb)$(LDIS) -f -o=$@ $< - all-local:: $(DIFFS) endif From alkis at cs.uiuc.edu Tue Jan 25 10:24:08 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue, 25 Jan 2005 10:24:08 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Instrumentation/TraceValues.cpp Message-ID: <200501251624.KAA27397@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Instrumentation: TraceValues.cpp updated: 1.70 -> 1.71 --- Log message: Add a dependency to the trace library so that it gets pulled in automatically. --- Diffs of the changes: (+3 -1) TraceValues.cpp | 4 +++- 1 files changed, 3 insertions(+), 1 deletion(-) Index: llvm/lib/Transforms/Instrumentation/TraceValues.cpp diff -u llvm/lib/Transforms/Instrumentation/TraceValues.cpp:1.70 llvm/lib/Transforms/Instrumentation/TraceValues.cpp:1.71 --- llvm/lib/Transforms/Instrumentation/TraceValues.cpp:1.70 Thu Sep 30 15:14:18 2004 +++ llvm/lib/Transforms/Instrumentation/TraceValues.cpp Tue Jan 25 10:23:57 2005 @@ -118,9 +118,11 @@ return new BasicBlockTracer(); } -// Add a prototype for external functions used by the tracing code. +// Add a prototype for external functions used by the tracing code and require +// the trace library for this module. // void ExternalFuncs::doInitialization(Module &M) { + M.addLibrary("trace"); const Type *SBP = PointerType::get(Type::SByteTy); const FunctionType *MTy = FunctionType::get(Type::IntTy, std::vector(1, SBP), true); From alkis at cs.uiuc.edu Tue Jan 25 10:24:54 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue, 25 Jan 2005 10:24:54 -0600 Subject: [llvm-commits] CVS: llvm-java/test/Programs/SingleSource/Makefile.singlesrc Message-ID: <200501251624.KAA27410@zion.cs.uiuc.edu> Changes in directory llvm-java/test/Programs/SingleSource: Makefile.singlesrc updated: 1.15 -> 1.16 --- Log message: Add rule to create traced executables. --- Diffs of the changes: (+5 -0) Makefile.singlesrc | 5 +++++ 1 files changed, 5 insertions(+) Index: llvm-java/test/Programs/SingleSource/Makefile.singlesrc diff -u llvm-java/test/Programs/SingleSource/Makefile.singlesrc:1.15 llvm-java/test/Programs/SingleSource/Makefile.singlesrc:1.16 --- llvm-java/test/Programs/SingleSource/Makefile.singlesrc:1.15 Mon Dec 13 20:59:35 2004 +++ llvm-java/test/Programs/SingleSource/Makefile.singlesrc Tue Jan 25 10:24:43 2005 @@ -25,4 +25,9 @@ $(Echo) Optimizing $< -$(Verb)$(LOPT) $(OPT_PASSES) -f -o=$@ $< +# add function trace code +%.tracef.linked.bc: %.linked.bc $(LOPT) + $(Echo) Adding function trace code to $< + $(Verb)$(LOPT) -tracem -f -o=$@ $< + include $(LEVEL)/test/Makefile.test From alkis at cs.uiuc.edu Tue Jan 25 10:26:35 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue, 25 Jan 2005 10:26:35 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200501251626.KAA27450@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.195 -> 1.196 --- Log message: Remove tracing code since we use tracelib now. --- Diffs of the changes: (+0 -15) Compiler.cpp | 15 --------------- 1 files changed, 15 deletions(-) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.195 llvm-java/lib/Compiler/Compiler.cpp:1.196 --- llvm-java/lib/Compiler/Compiler.cpp:1.195 Tue Jan 25 08:23:46 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Tue Jan 25 10:26:24 2005 @@ -1958,21 +1958,6 @@ const FunctionType* funTy = cast(funPtrTy->getElementType()); - // Trace function calls. -// llvm::Constant* functionNameArray = ConstantArray::get(fun->getName()); -// GlobalVariable* functionName = -// new GlobalVariable(functionNameArray->getType(), -// true, -// GlobalVariable::ExternalLinkage, -// functionNameArray, -// fun->getName() + "name", -// &module_); -// Function* puts = -// module_.getOrInsertFunction("puts", -// Type::VoidTy, -// functionName->getType(), NULL); -// new CallInst(puts, std::vector(1, functionName), "", currentBB_); - if (funTy->getReturnType() == Type::VoidTy) new CallInst(fun, params, "", currentBB_); else { From alkis at cs.uiuc.edu Tue Jan 25 10:45:22 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue, 25 Jan 2005 10:45:22 -0600 Subject: [llvm-commits] CVS: llvm-java/test/Programs/SingleSource/UnitTests/Collections.java Collections1.java Collections2.java Message-ID: <200501251645.KAA28484@zion.cs.uiuc.edu> Changes in directory llvm-java/test/Programs/SingleSource/UnitTests: Collections.java updated: 1.2 -> 1.3 Collections1.java updated: 1.1 -> 1.2 Collections2.java updated: 1.1 -> 1.2 --- Log message: Share some code and make sure we are calling methods through the Collection interface --- Diffs of the changes: (+15 -17) Collections.java | 14 +++++++++++--- Collections1.java | 9 ++------- Collections2.java | 9 ++------- 3 files changed, 15 insertions(+), 17 deletions(-) Index: llvm-java/test/Programs/SingleSource/UnitTests/Collections.java diff -u llvm-java/test/Programs/SingleSource/UnitTests/Collections.java:1.2 llvm-java/test/Programs/SingleSource/UnitTests/Collections.java:1.3 --- llvm-java/test/Programs/SingleSource/UnitTests/Collections.java:1.2 Tue Jan 25 09:52:48 2005 +++ llvm-java/test/Programs/SingleSource/UnitTests/Collections.java Tue Jan 25 10:45:11 2005 @@ -2,11 +2,19 @@ public class Collections { + public static void fillCollectionWithInts(Collection c) { + for (int i = 0; i < 10; ++i) + c.add(new Integer(i)); + } + + public static void printIntCollection(Collection c) { + for (Iterator i = c.iterator(); i.hasNext(); ) + Test.println(((Integer)i.next()).intValue()); + } + public static void main(String[] args) { Collection c1 = new TreeSet(); - for (int i = 0; i < 100; ++i) { - c1.add(new Integer(i)); - } + fillCollectionWithInts(c1); Collection c2 = new TreeSet(c1); Test.println(c1.remove(new Integer(5))); Index: llvm-java/test/Programs/SingleSource/UnitTests/Collections1.java diff -u llvm-java/test/Programs/SingleSource/UnitTests/Collections1.java:1.1 llvm-java/test/Programs/SingleSource/UnitTests/Collections1.java:1.2 --- llvm-java/test/Programs/SingleSource/UnitTests/Collections1.java:1.1 Tue Jan 25 02:29:20 2005 +++ llvm-java/test/Programs/SingleSource/UnitTests/Collections1.java Tue Jan 25 10:45:11 2005 @@ -4,12 +4,7 @@ { public static void main(String[] args) { Collection c1 = new LinkedList(); - for (int i = 0; i < 100; ++i) { - c1.add(new Integer(i)); - } - - for (Iterator i = c1.iterator(); i.hasNext(); ) { - Test.println(((Integer) i.next()).intValue()); - } + Collections.fillCollectionWithInts(c1); + Collections.printIntCollection(c1); } } Index: llvm-java/test/Programs/SingleSource/UnitTests/Collections2.java diff -u llvm-java/test/Programs/SingleSource/UnitTests/Collections2.java:1.1 llvm-java/test/Programs/SingleSource/UnitTests/Collections2.java:1.2 --- llvm-java/test/Programs/SingleSource/UnitTests/Collections2.java:1.1 Tue Jan 25 02:29:20 2005 +++ llvm-java/test/Programs/SingleSource/UnitTests/Collections2.java Tue Jan 25 10:45:11 2005 @@ -4,12 +4,7 @@ { public static void main(String[] args) { Collection c1 = new TreeSet(); - for (int i = 0; i < 100; ++i) { - c1.add(new Integer(i)); - } - - for (Iterator i = c1.iterator(); i.hasNext(); ) { - Test.println(((Integer) i.next()).intValue()); - } + Collections.fillCollectionWithInts(c1); + Collections.printIntCollection(c1); } } From alkis at cs.uiuc.edu Tue Jan 25 10:55:56 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue, 25 Jan 2005 10:55:56 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200501251655.KAA28574@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.196 -> 1.197 --- Log message: Java finals are not LLVM constants. This fixes Collection1.java and Collection2.java. --- Diffs of the changes: (+1 -1) Compiler.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.196 llvm-java/lib/Compiler/Compiler.cpp:1.197 --- llvm-java/lib/Compiler/Compiler.cpp:1.196 Tue Jan 25 10:26:24 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Tue Jan 25 10:55:45 2005 @@ -1435,7 +1435,7 @@ field->getName()->str(); DEBUG(std::cerr << "Adding global: " << globalName << '\n'); new GlobalVariable(globalTy, - field->isFinal(), + false, GlobalVariable::ExternalLinkage, init, globalName, From alenhar2 at cs.uiuc.edu Tue Jan 25 13:58:53 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Tue, 25 Jan 2005 13:58:53 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp AlphaISelPattern.cpp Message-ID: <200501251958.NAA12570@niobe.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaAsmPrinter.cpp updated: 1.2 -> 1.3 AlphaISelPattern.cpp updated: 1.3 -> 1.4 --- Log message: problems with bools, and their work arounds --- Diffs of the changes: (+14 -4) AlphaAsmPrinter.cpp | 2 +- AlphaISelPattern.cpp | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) Index: llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp diff -u llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp:1.2 llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp:1.3 --- llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp:1.2 Mon Jan 24 12:37:48 2005 +++ llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp Tue Jan 25 13:58:40 2005 @@ -164,7 +164,7 @@ if (CurrentFnName.compare("main") == 0) { - O << "\n\n#HACK\n\t.text\n\t.ent __main\n__main:\n\tret $31,($26),1\n\t.end __main\n#ENDHACK\n\n"; + // O << "\n\n#HACK\n\t.text\n\t.ent __main\n__main:\n\tret $31,($26),1\n\t.end __main\n#ENDHACK\n\n"; } // Print out constants referenced by the function Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.3 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.4 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.3 Mon Jan 24 18:35:34 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Tue Jan 25 13:58:40 2005 @@ -42,8 +42,6 @@ addRegisterClass(MVT::f64, Alpha::FPRCRegisterClass); setOperationAction(ISD::EXTLOAD , MVT::i1 , Expand); - setOperationAction(ISD::EXTLOAD , MVT::i8 , Expand); - setOperationAction(ISD::EXTLOAD , MVT::i16 , Expand); setOperationAction(ISD::ZEXTLOAD , MVT::i1 , Expand); setOperationAction(ISD::ZEXTLOAD , MVT::i32 , Expand); @@ -319,7 +317,17 @@ case MVT::i64: switch (cast(Node)->getExtraValueType()) { default: - assert(0 && "Bad sign extend!"); + std::cerr << cast(Node)->getExtraValueType() + << "(i1 is " << MVT::i1 + << " i8 is " << MVT::i8 + << " i16 is " << MVT::i16 + << " i32 is " << MVT::i32 + << " i64 is " << MVT::i64 + << ")\n"; + assert(0 && "Bad extend load!"); + case MVT::i64: + BuildMI(BB, Alpha::LDQ, 2, Result).addImm(0).addReg(Tmp1); + break; case MVT::i32: BuildMI(BB, Alpha::LDL, 2, Result).addImm(0).addReg(Tmp1); break; @@ -327,6 +335,7 @@ BuildMI(BB, Alpha::LDWU, 2, Result).addImm(0).addReg(Tmp1); break; case MVT::i8: + case MVT::i1: //FIXME: DAG does not expand i8?? BuildMI(BB, Alpha::LDBU, 2, Result).addImm(0).addReg(Tmp1); break; } @@ -822,6 +831,7 @@ switch (StoredTy) { default: assert(0 && "Unhandled Type"); break; + case MVT::i1: //FIXME: DAG does not promote this load case MVT::i8: Opc = Alpha::STB; break; case MVT::i16: Opc = Alpha::STW; break; case MVT::i32: Opc = Alpha::STL; break; From lattner at cs.uiuc.edu Tue Jan 25 14:03:26 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 25 Jan 2005 14:03:26 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ISelPattern.cpp Message-ID: <200501252003.j0PK3Qjd001470@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ISelPattern.cpp updated: 1.87 -> 1.88 --- Log message: Fold promoted loads into binary ops for FP, allowing us to generate m32 forms of FP ops. --- Diffs of the changes: (+31 -20) X86ISelPattern.cpp | 51 +++++++++++++++++++++++++++++++-------------------- 1 files changed, 31 insertions(+), 20 deletions(-) Index: llvm/lib/Target/X86/X86ISelPattern.cpp diff -u llvm/lib/Target/X86/X86ISelPattern.cpp:1.87 llvm/lib/Target/X86/X86ISelPattern.cpp:1.88 --- llvm/lib/Target/X86/X86ISelPattern.cpp:1.87 Sun Jan 23 17:20:06 2005 +++ llvm/lib/Target/X86/X86ISelPattern.cpp Tue Jan 25 14:03:11 2005 @@ -371,7 +371,8 @@ /// SelectionDAGISel when it has created a SelectionDAG for us to codegen. virtual void InstructionSelectBasicBlock(SelectionDAG &DAG); - bool isFoldableLoad(SDOperand Op, SDOperand OtherOp); + bool isFoldableLoad(SDOperand Op, SDOperand OtherOp, + bool FloatPromoteOk = false); void EmitFoldedLoad(SDOperand Op, X86AddressMode &AM); bool TryToFoldLoadOpStore(SDNode *Node); @@ -1119,11 +1120,19 @@ /// isFoldableLoad - Return true if this is a load instruction that can safely /// be folded into an operation that uses it. -bool ISel::isFoldableLoad(SDOperand Op, SDOperand OtherOp) { - if (Op.getOpcode() != ISD::LOAD || - // FIXME: currently can't fold constant pool indexes. - isa(Op.getOperand(1))) +bool ISel::isFoldableLoad(SDOperand Op, SDOperand OtherOp, bool FloatPromoteOk){ + if (Op.getOpcode() == ISD::LOAD) { + // FIXME: currently can't fold constant pool indexes. + if (isa(Op.getOperand(1))) + return false; + } else if (FloatPromoteOk && Op.getOpcode() == ISD::EXTLOAD && + cast(Op)->getExtraValueType() == MVT::f32) { + // FIXME: currently can't fold constant pool indexes. + if (isa(Op.getOperand(1))) + return false; + } else { return false; + } // If this load has already been emitted, we clearly can't fold it. assert(Op.ResNo == 0 && "Not a use of the value of the load?"); @@ -1686,12 +1695,12 @@ Op0 = N.getOperand(0); Op1 = N.getOperand(1); - if (isFoldableLoad(Op0, Op1)) { + if (isFoldableLoad(Op0, Op1, true)) { std::swap(Op0, Op1); goto FoldAdd; } - if (isFoldableLoad(Op1, Op0)) { + if (isFoldableLoad(Op1, Op0, true)) { FoldAdd: switch (N.getValueType()) { default: assert(0 && "Cannot add this type!"); @@ -1699,8 +1708,10 @@ case MVT::i8: Opc = X86::ADD8rm; break; case MVT::i16: Opc = X86::ADD16rm; break; case MVT::i32: Opc = X86::ADD32rm; break; - case MVT::f32: Opc = X86::FADD32m; break; - case MVT::f64: Opc = X86::FADD64m; break; + case MVT::f64: + // For F64, handle promoted load operations (from F32) as well! + Opc = Op1.getOpcode() == ISD::LOAD ? X86::FADD64m : X86::FADD32m; + break; } X86AddressMode AM; EmitFoldedLoad(Op1, AM); @@ -1893,18 +1904,18 @@ } } - if (isFoldableLoad(Op0, Op1)) + if (isFoldableLoad(Op0, Op1, true)) if (Node->getOpcode() != ISD::SUB) { std::swap(Op0, Op1); goto FoldOps; } else { - // Emit 'reverse' subract, with a memory operand. - switch (N.getValueType()) { - default: Opc = 0; break; - case MVT::f32: Opc = X86::FSUBR32m; break; - case MVT::f64: Opc = X86::FSUBR64m; break; - } - if (Opc) { + // For FP, emit 'reverse' subract, with a memory operand. + if (N.getValueType() == MVT::f64) { + if (Op0.getOpcode() == ISD::EXTLOAD) + Opc = X86::FSUBR32m; + else + Opc = X86::FSUBR64m; + X86AddressMode AM; EmitFoldedLoad(Op0, AM); Tmp1 = SelectExpr(Op1); @@ -1913,7 +1924,7 @@ } } - if (isFoldableLoad(Op1, Op0)) { + if (isFoldableLoad(Op1, Op0, true)) { FoldOps: switch (N.getValueType()) { default: assert(0 && "Cannot operate on this type!"); @@ -1921,8 +1932,8 @@ case MVT::i8: Opc = 5; break; case MVT::i16: Opc = 6; break; case MVT::i32: Opc = 7; break; - case MVT::f32: Opc = 8; break; - case MVT::f64: Opc = 9; break; + // For F64, handle promoted load operations (from F32) as well! + case MVT::f64: Opc = Op1.getOpcode() == ISD::LOAD ? 9 : 8; break; } switch (Node->getOpcode()) { default: assert(0 && "Unreachable!"); From lattner at cs.uiuc.edu Tue Jan 25 14:35:26 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 25 Jan 2005 14:35:26 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ISelPattern.cpp Message-ID: <200501252035.j0PKZQ0x004404@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ISelPattern.cpp updated: 1.88 -> 1.89 --- Log message: We can fold promoted and non-promoted loads into divs also! --- Diffs of the changes: (+28 -0) X86ISelPattern.cpp | 28 ++++++++++++++++++++++++++++ 1 files changed, 28 insertions(+) Index: llvm/lib/Target/X86/X86ISelPattern.cpp diff -u llvm/lib/Target/X86/X86ISelPattern.cpp:1.88 llvm/lib/Target/X86/X86ISelPattern.cpp:1.89 --- llvm/lib/Target/X86/X86ISelPattern.cpp:1.88 Tue Jan 25 14:03:11 2005 +++ llvm/lib/Target/X86/X86ISelPattern.cpp Tue Jan 25 14:35:10 2005 @@ -2034,6 +2034,34 @@ "We don't support this operator!"); if (N.getOpcode() == ISD::SDIV) + + // We can fold loads into FpDIVs, but not really into any others. + if (N.getValueType() == MVT::f64) { + // Check for reversed and unreversed DIV. + if (isFoldableLoad(N.getOperand(0), N.getOperand(1), true)) { + if (N.getOperand(0).getOpcode() == ISD::EXTLOAD) + Opc = X86::FDIVR32m; + else + Opc = X86::FDIVR64m; + X86AddressMode AM; + EmitFoldedLoad(N.getOperand(0), AM); + Tmp1 = SelectExpr(N.getOperand(1)); + addFullAddress(BuildMI(BB, Opc, 5, Result).addReg(Tmp1), AM); + return Result; + } else if (isFoldableLoad(N.getOperand(1), N.getOperand(0), true) && + N.getOperand(1).getOpcode() == ISD::LOAD) { + if (N.getOperand(1).getOpcode() == ISD::EXTLOAD) + Opc = X86::FDIV32m; + else + Opc = X86::FDIV64m; + X86AddressMode AM; + EmitFoldedLoad(N.getOperand(1), AM); + Tmp1 = SelectExpr(N.getOperand(0)); + addFullAddress(BuildMI(BB, Opc, 5, Result).addReg(Tmp1), AM); + return Result; + } + } + if (ConstantSDNode *CN = dyn_cast(N.getOperand(1))) { // FIXME: These special cases should be handled by the lowering impl! unsigned RHS = CN->getValue(); From alkis at cs.uiuc.edu Tue Jan 25 14:56:17 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue, 25 Jan 2005 14:56:17 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200501252056.OAA30268@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.197 -> 1.198 --- Log message: Bring in anything from java/util. --- Diffs of the changes: (+1 -11) Compiler.cpp | 12 +----------- 1 files changed, 1 insertion(+), 11 deletions(-) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.197 llvm-java/lib/Compiler/Compiler.cpp:1.198 --- llvm-java/lib/Compiler/Compiler.cpp:1.197 Tue Jan 25 10:55:45 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Tue Jan 25 14:56:06 2005 @@ -1309,17 +1309,7 @@ classMethodDesc.find("java/lang/Long") != 0 && classMethodDesc.find("java/lang/Short") != 0 && classMethodDesc.find("java/lang/StringBuffer") != 0 && - classMethodDesc.find("java/util/ConcurrentModificationException") != 0 && - classMethodDesc.find("java/util/IndexOutOfBoundsException") != 0 && - classMethodDesc.find("java/util/NoSuchElementException") != 0 && - classMethodDesc.find("java/util/AbstractCollection") != 0 && - classMethodDesc.find("java/util/AbstractList") != 0 && - classMethodDesc.find("java/util/AbstractSet") != 0 && - classMethodDesc.find("java/util/AbstractMap") != 0 && - classMethodDesc.find("java/util/AbstractSequentialList") != 0 && - classMethodDesc.find("java/util/LinkedList") != 0 && - classMethodDesc.find("java/util/TreeMap") != 0 && - classMethodDesc.find("java/util/TreeSet") != 0) { + classMethodDesc.find("java/util/") != 0) { DEBUG(std::cerr << "Skipping compilation of method: " << classMethodDesc << '\n'); return function; From alkis at cs.uiuc.edu Tue Jan 25 15:33:38 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue, 25 Jan 2005 15:33:38 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200501252133.PAA30665@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.198 -> 1.199 --- Log message: Add java/lang/IllegalArgumentException. --- Diffs of the changes: (+1 -0) Compiler.cpp | 1 + 1 files changed, 1 insertion(+) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.198 llvm-java/lib/Compiler/Compiler.cpp:1.199 --- llvm-java/lib/Compiler/Compiler.cpp:1.198 Tue Jan 25 14:56:06 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Tue Jan 25 15:33:28 2005 @@ -1302,6 +1302,7 @@ (classMethodDesc.find("java/lang/Throwable") != 0 || classMethodDesc.find("java/lang/Throwable$StaticData/ Changes in directory llvm-java/test/Programs/SingleSource: Makefile.singlesrc updated: 1.16 -> 1.17 --- Log message: Disable value hashing. --- Diffs of the changes: (+1 -1) Makefile.singlesrc | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm-java/test/Programs/SingleSource/Makefile.singlesrc diff -u llvm-java/test/Programs/SingleSource/Makefile.singlesrc:1.16 llvm-java/test/Programs/SingleSource/Makefile.singlesrc:1.17 --- llvm-java/test/Programs/SingleSource/Makefile.singlesrc:1.16 Tue Jan 25 10:24:43 2005 +++ llvm-java/test/Programs/SingleSource/Makefile.singlesrc Tue Jan 25 15:40:12 2005 @@ -28,6 +28,6 @@ # add function trace code %.tracef.linked.bc: %.linked.bc $(LOPT) $(Echo) Adding function trace code to $< - $(Verb)$(LOPT) -tracem -f -o=$@ $< + $(Verb)$(LOPT) -tracem -tracedisablehashdisable -f -o=$@ $< include $(LEVEL)/test/Makefile.test From alkis at cs.uiuc.edu Tue Jan 25 16:13:44 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue, 25 Jan 2005 16:13:44 -0600 Subject: [llvm-commits] CVS: llvm-java/test/Programs/SingleSource/UnitTests/RandomTest.java Message-ID: <200501252213.QAA31004@zion.cs.uiuc.edu> Changes in directory llvm-java/test/Programs/SingleSource/UnitTests: RandomTest.java added (r1.1) --- Log message: Add test for java.util.Random --- Diffs of the changes: (+11 -0) RandomTest.java | 11 +++++++++++ 1 files changed, 11 insertions(+) Index: llvm-java/test/Programs/SingleSource/UnitTests/RandomTest.java diff -c /dev/null llvm-java/test/Programs/SingleSource/UnitTests/RandomTest.java:1.1 *** /dev/null Tue Jan 25 16:13:43 2005 --- llvm-java/test/Programs/SingleSource/UnitTests/RandomTest.java Tue Jan 25 16:13:33 2005 *************** *** 0 **** --- 1,11 ---- + import java.util.*; + + public class RandomTest + { + public static Random rand = new Random(0); + + public static void main(String[] args) { + for (int i = 0; i < 1000; ++i) + Test.println(rand.nextInt()); + } + } From alkis at cs.uiuc.edu Tue Jan 25 16:28:18 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue, 25 Jan 2005 16:28:18 -0600 Subject: [llvm-commits] CVS: llvm-java/test/Programs/SingleSource/UnitTests/Maps.java Message-ID: <200501252228.QAA31138@zion.cs.uiuc.edu> Changes in directory llvm-java/test/Programs/SingleSource/UnitTests: Maps.java added (r1.1) --- Log message: Simple map test --- Diffs of the changes: (+14 -0) Maps.java | 14 ++++++++++++++ 1 files changed, 14 insertions(+) Index: llvm-java/test/Programs/SingleSource/UnitTests/Maps.java diff -c /dev/null llvm-java/test/Programs/SingleSource/UnitTests/Maps.java:1.1 *** /dev/null Tue Jan 25 16:28:18 2005 --- llvm-java/test/Programs/SingleSource/UnitTests/Maps.java Tue Jan 25 16:28:08 2005 *************** *** 0 **** --- 1,14 ---- + import java.util.*; + + public class Maps + { + public static Random rand = new Random(0); + + public static void main(String[] args) { + TreeMap tmap = new TreeMap(); + for (int i = 0; i < 1000; ++i) + tmap.put(new Integer(i), new Integer(rand.nextInt())); + for (int i = 0; i < 1000; ++i) + Test.println(((Integer)tmap.get(new Integer(i))).intValue()); + } + } From alkis at cs.uiuc.edu Tue Jan 25 16:31:51 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue, 25 Jan 2005 16:31:51 -0600 Subject: [llvm-commits] CVS: llvm-java/test/Programs/SingleSource/UnitTests/Maps1.java Message-ID: <200501252231.QAA31199@zion.cs.uiuc.edu> Changes in directory llvm-java/test/Programs/SingleSource/UnitTests: Maps1.java added (r1.1) --- Log message: Test HashMap. We don't pass this becayse Syste.arrayCopy is not implemented --- Diffs of the changes: (+14 -0) Maps1.java | 14 ++++++++++++++ 1 files changed, 14 insertions(+) Index: llvm-java/test/Programs/SingleSource/UnitTests/Maps1.java diff -c /dev/null llvm-java/test/Programs/SingleSource/UnitTests/Maps1.java:1.1 *** /dev/null Tue Jan 25 16:31:50 2005 --- llvm-java/test/Programs/SingleSource/UnitTests/Maps1.java Tue Jan 25 16:31:40 2005 *************** *** 0 **** --- 1,14 ---- + import java.util.*; + + public class Maps1 + { + public static Random rand = new Random(0); + + public static void main(String[] args) { + HashMap tmap = new HashMap(); + for (int i = 0; i < 1000; ++i) + tmap.put(new Integer(i), new Integer(rand.nextInt())); + for (int i = 0; i < 1000; ++i) + Test.println(((Integer)tmap.get(new Integer(i))).intValue()); + } + } From alkis at cs.uiuc.edu Tue Jan 25 17:46:45 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue, 25 Jan 2005 17:46:45 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200501252346.RAA31598@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.199 -> 1.200 --- Log message: Simplify code a bit by declaring frequently used functions up front. --- Diffs of the changes: (+29 -44) Compiler.cpp | 73 +++++++++++++++++++++++------------------------------------ 1 files changed, 29 insertions(+), 44 deletions(-) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.199 llvm-java/lib/Compiler/Compiler.cpp:1.200 --- llvm-java/lib/Compiler/Compiler.cpp:1.199 Tue Jan 25 15:33:28 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Tue Jan 25 17:46:34 2005 @@ -41,16 +41,13 @@ #define LLVM_JAVA_STATIC_INIT "llvm_java_static_init" -#define LLVM_JAVA_ISINSTANCEOF "llvm_java_IsInstanceOf" -#define LLVM_JAVA_GETOBJECTCLASS "llvm_java_GetObjectClass" -#define LLVM_JAVA_SETOBJECTCLASS "llvm_java_SetObjectClass" -#define LLVM_JAVA_THROW "llvm_java_Throw" - using namespace llvm; using namespace llvm::Java; Type* llvm::Java::ObjectBaseTy = OpaqueType::get(); Type* llvm::Java::ObjectBaseRefTy = PointerType::get(ObjectBaseTy); +Type* llvm::Java::VTableBaseTy = OpaqueType::get(); +Type* llvm::Java::VTableBaseRefTy = PointerType::get(ObjectBaseTy); namespace llvm { namespace Java { namespace { @@ -75,6 +72,7 @@ BasicBlock* currentBB_; Locals locals_; OperandStack opStack_; + Function *getObjectClass_, *setObjectClass_, *throw_, *isInstanceOf_; typedef SetVector FunctionSet; FunctionSet toCompileFunctions_; @@ -111,7 +109,6 @@ typedef Method2IndexMap::const_iterator const_iterator; Method2IndexMap m2iMap; - static Type* VTableBaseTy; static StructType* VTableTy; static StructType* TypeInfoTy; }; @@ -130,6 +127,20 @@ NULL, "llvm_java_JNIEnv", &module_); + module_.addTypeName("llvm_java_object_base", ObjectBaseTy); + module_.addTypeName("llvm_java_object_vtable", VTableBaseTy); + getObjectClass_ = module_.getOrInsertFunction( + "llvm_java_GetObjectClass", VTableBaseRefTy, + ObjectBaseRefTy, NULL); + setObjectClass_ = module_.getOrInsertFunction( + "llvm_java_SetObjectClass", Type::VoidTy, + ObjectBaseRefTy, VTableBaseRefTy, NULL); + throw_ = module_.getOrInsertFunction( + "llvm_java_Throw", Type::IntTy, + ObjectBaseRefTy, NULL); + isInstanceOf_ = module_.getOrInsertFunction( + "llvm_java_IsInstanceOf", Type::IntTy, + ObjectBaseRefTy, VTableBaseRefTy, NULL); } private: @@ -407,8 +418,6 @@ PATypeHolder holder = VTtype; cast(VTtype)->refineAbstractTypeTo(StructType::get(elements)); - VTableInfo::VTableBaseTy = OpaqueType::get(); - module_.addTypeName(LLVM_JAVA_OBJECT_VTABLE, VTableInfo::VTableBaseTy); VTableInfo::VTableTy = cast(holder.get()); module_.addTypeName("java/lang/Object", VTableInfo::VTableTy); @@ -1303,6 +1312,7 @@ classMethodDesc.find("java/lang/Throwable$StaticData/getType(), NULL); - Value* vtable = new CallInst(f, objBase, TMP, currentBB_); + Value* vtable = new CallInst(getObjectClass_, objBase, TMP, currentBB_); vtable = new CastInst(vtable, vi->vtable->getType(), className + "", currentBB_); std::vector indices(1, ConstantUInt::get(Type::UIntTy, 0)); @@ -2128,10 +2135,7 @@ "this", currentBB_); Value* objBase = new CastInst(objRef, ObjectBaseRefTy, TMP, currentBB_); - Function* f = module_.getOrInsertFunction( - LLVM_JAVA_GETOBJECTCLASS, PointerType::get(VTableInfo::VTableBaseTy), - objBase->getType(), NULL); - Value* vtable = new CallInst(f, objBase, TMP, currentBB_); + Value* vtable = new CallInst(getObjectClass_, objBase, TMP, currentBB_); vtable = new CastInst(vtable, PointerType::get(VTableInfo::VTableTy), TMP, currentBB_); // get the interfaces array of vtables @@ -2173,13 +2177,9 @@ Value* objRef = new MallocInst(ci.type, NULL, TMP, currentBB_); Value* objBase = new CastInst(objRef, ObjectBaseRefTy, TMP, currentBB_); Value* vtable = new CastInst(vi.vtable, - PointerType::get(VTableInfo::VTableBaseTy), + VTableBaseRefTy, TMP, currentBB_); - Function* f = module_.getOrInsertFunction( - LLVM_JAVA_SETOBJECTCLASS, Type::VoidTy, - ObjectBaseRefTy, - PointerType::get(VTableInfo::VTableBaseTy), NULL); - new CallInst(f, objBase, vtable, "", currentBB_); + new CallInst(setObjectClass_, objBase, vtable, "", currentBB_); push(objRef); } @@ -2251,13 +2251,9 @@ Value* objBase = new CastInst(objRef, ObjectBaseRefTy, TMP, currentBB_); Value* vtable = new CastInst(vi.vtable, - PointerType::get(VTableInfo::VTableBaseTy), + VTableBaseRefTy, TMP, currentBB_); - Function* f = module_.getOrInsertFunction( - LLVM_JAVA_SETOBJECTCLASS, Type::VoidTy, - ObjectBaseRefTy, - PointerType::get(VTableInfo::VTableBaseTy), NULL); - new CallInst(f, objBase, vtable, "", currentBB_); + new CallInst(setObjectClass_, objBase, vtable, "", currentBB_); push(objRef); } @@ -2271,10 +2267,7 @@ void do_athrow() { Value* objRef = pop(ObjectBaseRefTy); - Function* f = module_.getOrInsertFunction( - LLVM_JAVA_THROW, Type::IntTy, - ObjectBaseRefTy, NULL); - new CallInst(f, objRef, TMP, currentBB_); + new CallInst(throw_, objRef, TMP, currentBB_); new UnreachableInst(currentBB_); } @@ -2286,13 +2279,10 @@ tie(ci, vi) = getInfo(classRef->getName()->str()); Value* objRef = pop(ObjectBaseRefTy); - Function* f = module_.getOrInsertFunction( - LLVM_JAVA_ISINSTANCEOF, Type::IntTy, - ObjectBaseRefTy, PointerType::get(VTableInfo::VTableBaseTy), NULL); Value* vtable = new CastInst(vi->vtable, - PointerType::get(VTableInfo::VTableBaseTy), + VTableBaseRefTy, TMP, currentBB_); - Value* r = new CallInst(f, objRef, vtable, TMP, currentBB_); + Value* r = new CallInst(isInstanceOf_, objRef, vtable, TMP, currentBB_); Value* b = new SetCondInst(Instruction::SetEQ, r, ConstantSInt::get(Type::IntTy, 1), @@ -2309,13 +2299,9 @@ tie(ci, vi) = getInfo(classRef->getName()->str()); Value* objRef = pop(ObjectBaseRefTy); - Function* f = module_.getOrInsertFunction( - LLVM_JAVA_ISINSTANCEOF, Type::IntTy, - ObjectBaseRefTy, PointerType::get(VTableInfo::VTableBaseTy), NULL); - Value* vtable = new CastInst(vi->vtable, - PointerType::get(VTableInfo::VTableBaseTy), + Value* vtable = new CastInst(vi->vtable, VTableBaseRefTy, TMP, currentBB_); - Value* r = new CallInst(f, objRef, vtable, TMP, currentBB_); + Value* r = new CallInst(isInstanceOf_, objRef, vtable, TMP, currentBB_); push(r); } @@ -2333,7 +2319,6 @@ }; unsigned Compiler::ClassInfo::InterfaceCount = 0; - Type* Compiler::VTableInfo::VTableBaseTy; StructType* Compiler::VTableInfo::VTableTy; StructType* Compiler::VTableInfo::TypeInfoTy; From alkis at cs.uiuc.edu Tue Jan 25 17:46:45 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue, 25 Jan 2005 17:46:45 -0600 Subject: [llvm-commits] CVS: llvm-java/include/llvm/Java/Compiler.h Message-ID: <200501252346.RAA31602@zion.cs.uiuc.edu> Changes in directory llvm-java/include/llvm/Java: Compiler.h updated: 1.12 -> 1.13 --- Log message: Simplify code a bit by declaring frequently used functions up front. --- Diffs of the changes: (+2 -0) Compiler.h | 2 ++ 1 files changed, 2 insertions(+) Index: llvm-java/include/llvm/Java/Compiler.h diff -u llvm-java/include/llvm/Java/Compiler.h:1.12 llvm-java/include/llvm/Java/Compiler.h:1.13 --- llvm-java/include/llvm/Java/Compiler.h:1.12 Mon Jan 17 12:21:03 2005 +++ llvm-java/include/llvm/Java/Compiler.h Tue Jan 25 17:46:34 2005 @@ -23,6 +23,8 @@ extern Type* ObjectBaseTy; extern Type* ObjectBaseRefTy; + extern Type* VTableBaseTy; + extern Type* VTableBaseRefTy; } } // namespace llvm::Java From alenhar2 at cs.uiuc.edu Tue Jan 25 19:24:53 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Tue, 25 Jan 2005 19:24:53 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp AlphaInstrInfo.td Message-ID: <200501260124.TAA28447@niobe.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.4 -> 1.5 AlphaInstrInfo.td updated: 1.3 -> 1.4 --- Log message: add some operations, fix others. should compile several more tests now --- Diffs of the changes: (+26 -5) AlphaISelPattern.cpp | 17 ++++++++++++++++- AlphaInstrInfo.td | 14 ++++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.4 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.5 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.4 Tue Jan 25 13:58:40 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Tue Jan 25 19:24:38 2005 @@ -50,6 +50,10 @@ setOperationAction(ISD::SEXTLOAD , MVT::i8 , Expand); setOperationAction(ISD::SEXTLOAD , MVT::i16 , Expand); + setOperationAction(ISD::ZERO_EXTEND_INREG, MVT::i1, Expand); + setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i1, Expand); + + computeRegisterProperties(); // addLegalFPImmediate(+0.0); // FLD0 @@ -654,9 +658,20 @@ } case ISD::UREM: + case ISD::SREM: + case ISD::SDIV: + case ISD::UDIV: + //FIXME: alpha really doesn't support any of these operations, + // the ops are expanded into special library calls with + // special calling conventions + switch(N.getOpcode()) { + case UREM: Opc = Alpha::REMQU; break; + case SREM: Opc = Alpha::REMQ; break; + case UDIV: Opc = Alpha::DIVQU; break; + case SDIV: Opc = Alpha::DIVQ; break; Tmp1 = SelectExpr(N.getOperand(0)); Tmp2 = SelectExpr(N.getOperand(1)); - BuildMI(BB, Alpha::REMQU, 2, Result).addReg(Tmp1).addReg(Tmp2); + BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); return Result; case ISD::SELECT: Index: llvm/lib/Target/Alpha/AlphaInstrInfo.td diff -u llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.3 llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.4 --- llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.3 Mon Jan 24 18:35:34 2005 +++ llvm/lib/Target/Alpha/AlphaInstrInfo.td Tue Jan 25 19:24:38 2005 @@ -50,22 +50,28 @@ let isReturn = 1, isTerminator = 1 in def RETURN : PseudoInstAlpha<(ops ), "ret $$31,($$26),1">; //Return from subroutine -def LOAD_IMM : PseudoInstAlpha<(ops GPRC:$RC, s64imm:$IMM), "ldiq $RC,$IMM">; //Load Immediate Quadword +let Uses = [R28] in + def LOAD_IMM : PseudoInstAlpha<(ops GPRC:$RC, s64imm:$IMM), "ldiq $RC,$IMM">; //Load Immediate Quadword -let Uses = [R29] in +let Uses = [R29, R28] in def STORE : PseudoInstAlpha<(ops GPRC:$RA, s64imm:$DISP), "stq $RA,$DISP">; //Store quadword -let Uses = [R29] in +let Uses = [R29, R28] in def LOAD_ADDR : PseudoInstAlpha<(ops GPRC:$RA, s64imm:$DISP), "lda $RA,$DISP">; //Load address -let Uses = [R29] in +let Uses = [R29, R28] in def LOAD : PseudoInstAlpha<(ops GPRC:$RA, s64imm:$DISP), "ldq $RA,$DISP">; //Load quadword def LDW : PseudoInstAlpha<(ops GPRC:$RA, s16imm:$DISP, GPRC:$RB), "ldw $RA,$DISP($RB)">; // Load sign-extended word def LDB : PseudoInstAlpha<(ops GPRC:$RA, s16imm:$DISP, GPRC:$RB), "ldb $RA,$DISP($RB)">; //Load byte let Uses = [R28, R23, R24, R25, R26] in +{ def REMQU : PseudoInstAlpha<(ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "remqu $RA,$RB,$RC">; //unsigned remander + def REMQ : PseudoInstAlpha<(ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "remq $RA,$RB,$RC">; //unsigned remander + def DIVQU : PseudoInstAlpha<(ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "divqu $RA,$RB,$RC">; //unsigned remander + def DIVQ : PseudoInstAlpha<(ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "divq $RA,$RB,$RC">; //unsigned remander +} //*********************** //Real instructions From alenhar2 at cs.uiuc.edu Tue Jan 25 20:54:11 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Tue, 25 Jan 2005 20:54:11 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp Message-ID: <200501260254.UAA28524@niobe.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.5 -> 1.6 --- Log message: hum, writing on one machine, testing on another... --- Diffs of the changes: (+5 -4) AlphaISelPattern.cpp | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.5 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.6 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.5 Tue Jan 25 19:24:38 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Tue Jan 25 20:53:56 2005 @@ -665,10 +665,11 @@ // the ops are expanded into special library calls with // special calling conventions switch(N.getOpcode()) { - case UREM: Opc = Alpha::REMQU; break; - case SREM: Opc = Alpha::REMQ; break; - case UDIV: Opc = Alpha::DIVQU; break; - case SDIV: Opc = Alpha::DIVQ; break; + case ISD::UREM: Opc = Alpha::REMQU; break; + case ISD::SREM: Opc = Alpha::REMQ; break; + case ISD::UDIV: Opc = Alpha::DIVQU; break; + case ISD::SDIV: Opc = Alpha::DIVQ; break; + }; Tmp1 = SelectExpr(N.getOperand(0)); Tmp2 = SelectExpr(N.getOperand(1)); BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); From lattner at cs.uiuc.edu Wed Jan 26 01:08:57 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 26 Jan 2005 01:08:57 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/InstCombine/2004-11-27-SetCCForCastLargerAndConstant.ll Message-ID: <200501260708.j0Q78vUo017705@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/InstCombine: 2004-11-27-SetCCForCastLargerAndConstant.ll updated: 1.3 -> 1.4 --- Log message: XFAIL this for now. --- Diffs of the changes: (+5 -0) 2004-11-27-SetCCForCastLargerAndConstant.ll | 5 +++++ 1 files changed, 5 insertions(+) Index: llvm/test/Regression/Transforms/InstCombine/2004-11-27-SetCCForCastLargerAndConstant.ll diff -u llvm/test/Regression/Transforms/InstCombine/2004-11-27-SetCCForCastLargerAndConstant.ll:1.3 llvm/test/Regression/Transforms/InstCombine/2004-11-27-SetCCForCastLargerAndConstant.ll:1.4 --- llvm/test/Regression/Transforms/InstCombine/2004-11-27-SetCCForCastLargerAndConstant.ll:1.3 Sun Nov 28 15:36:52 2004 +++ llvm/test/Regression/Transforms/InstCombine/2004-11-27-SetCCForCastLargerAndConstant.ll Wed Jan 26 01:08:42 2005 @@ -11,6 +11,11 @@ ; ; RUN: llvm-as %s -o - | opt -instcombine | llvm-dis | not grep 'cast.*int' + +; Some of these cases were miscompiling programs so they were disabled, see +; bugzilla for details. +; XFAIL: * + implementation ; Functions: ; From lattner at cs.uiuc.edu Wed Jan 26 01:09:57 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 26 Jan 2005 01:09:57 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/CodeGen/X86/shift-double.llx Message-ID: <200501260709.j0Q79vMO017719@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/CodeGen/X86: shift-double.llx updated: 1.2 -> 1.3 --- Log message: xfail this. --- Diffs of the changes: (+4 -0) shift-double.llx | 4 ++++ 1 files changed, 4 insertions(+) Index: llvm/test/Regression/CodeGen/X86/shift-double.llx diff -u llvm/test/Regression/CodeGen/X86/shift-double.llx:1.2 llvm/test/Regression/CodeGen/X86/shift-double.llx:1.3 --- llvm/test/Regression/CodeGen/X86/shift-double.llx:1.2 Wed Jan 19 01:37:01 2005 +++ llvm/test/Regression/CodeGen/X86/shift-double.llx Wed Jan 26 01:09:44 2005 @@ -1,5 +1,9 @@ ; 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 alenhar2 at cs.uiuc.edu Wed Jan 26 15:54:26 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Wed, 26 Jan 2005 15:54:26 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp AlphaInstrFormats.td AlphaInstrInfo.cpp AlphaInstrInfo.td AlphaRegisterInfo.cpp Message-ID: <200501262154.PAA30100@cypher.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.6 -> 1.7 AlphaInstrFormats.td updated: 1.2 -> 1.3 AlphaInstrInfo.cpp updated: 1.2 -> 1.3 AlphaInstrInfo.td updated: 1.4 -> 1.5 AlphaRegisterInfo.cpp updated: 1.2 -> 1.3 --- Log message: initial fp support --- Diffs of the changes: (+358 -226) AlphaISelPattern.cpp | 436 ++++++++++++++++++++++++++++++++------------------ AlphaInstrFormats.td | 4 AlphaInstrInfo.cpp | 2 AlphaInstrInfo.td | 111 ++++++------ AlphaRegisterInfo.cpp | 31 ++- 5 files changed, 358 insertions(+), 226 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.6 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.7 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.6 Tue Jan 25 20:53:56 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Wed Jan 26 15:54:08 2005 @@ -53,6 +53,14 @@ setOperationAction(ISD::ZERO_EXTEND_INREG, MVT::i1, Expand); setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i1, Expand); + // setOperationAction(ISD::UINT_TO_FP , MVT::i64 , Expand); + // setOperationAction(ISD::UINT_TO_FP , MVT::i64 , Expand); + setOperationAction(ISD::SINT_TO_FP , MVT::i1 , Promote); + setOperationAction(ISD::SINT_TO_FP , MVT::i8 , Promote); + setOperationAction(ISD::SINT_TO_FP , MVT::i16 , Promote); + setOperationAction(ISD::SINT_TO_FP , MVT::i32 , Promote); + + setOperationAction(ISD::FP_TO_SINT , MVT::f32 , Promote); computeRegisterProperties(); @@ -124,18 +132,35 @@ //Handle the return address //BuildMI(&BB, Alpha::IDEF, 0, Alpha::R26); - unsigned args[] = {Alpha::R16, Alpha::R17, Alpha::R18, - Alpha::R19, Alpha::R20, Alpha::R21}; + unsigned args_int[] = {Alpha::R16, Alpha::R17, Alpha::R18, + Alpha::R19, Alpha::R20, Alpha::R21}; + unsigned args_float[] = {Alpha::F16, Alpha::F17, Alpha::F18, + Alpha::F19, Alpha::F20, Alpha::F21}; std::vector argVreg; - + std::vector argPreg; int count = 0; for (Function::aiterator I = F.abegin(), E = F.aend(); I != E; ++I) { ++count; assert(count <= 6 && "More than 6 args not supported"); - assert(getValueType(I->getType()) != MVT::f64 && "No floats yet"); - BuildMI(&BB, Alpha::IDEF, 0, args[count - 1]); - argVreg.push_back(MF.getSSARegMap()->createVirtualRegister(getRegClassFor(MVT::i64))); + switch (getValueType(I->getType())) { + default: std::cerr << "Unknown Type " << getValueType(I->getType()) << "\n"; abort(); + case MVT::f64: + case MVT::f32: + BuildMI(&BB, Alpha::IDEF, 0, args_float[count - 1]); + argVreg.push_back(MF.getSSARegMap()->createVirtualRegister(getRegClassFor(getValueType(I->getType())))); + argPreg.push_back(args_float[count - 1]); + break; + case MVT::i1: + case MVT::i8: + case MVT::i16: + case MVT::i32: + case MVT::i64: + BuildMI(&BB, Alpha::IDEF, 0, args_int[count - 1]); + argVreg.push_back(MF.getSSARegMap()->createVirtualRegister(getRegClassFor(getValueType(I->getType())))); + argPreg.push_back(args_int[count - 1]); + break; + } } BuildMI(&BB, Alpha::IDEF, 0, Alpha::R29); @@ -143,25 +168,30 @@ count = 0; for (Function::aiterator I = F.abegin(), E = F.aend(); I != E; ++I) { - BuildMI(&BB, Alpha::BIS, 2, argVreg[count]).addReg(args[count]).addReg(args[count]); - - SDOperand argt, newroot; + SDOperand newroot; + unsigned Opc; switch (getValueType(I->getType())) { + default: assert(0 && "Unhandled type"); case MVT::i64: - argt = newroot = DAG.getCopyFromReg(argVreg[count], MVT::i64, DAG.getRoot()); - break; case MVT::i32: - argt = newroot = DAG.getCopyFromReg(argVreg[count], MVT::i32, DAG.getRoot()); + case MVT::i16: + case MVT::i8: + case MVT::i1: + Opc = Alpha::BIS; + break; + case MVT::f32: + case MVT::f64: + Opc = Alpha::CPYS; break; - default: - newroot = DAG.getCopyFromReg(argVreg[count], MVT::i64, DAG.getRoot()); - argt = DAG.getNode(ISD::TRUNCATE, getValueType(I->getType()), newroot); } + BuildMI(&BB, Opc, 2, argVreg[count]).addReg(argPreg[count]).addReg(argPreg[count]); + newroot = DAG.getCopyFromReg(argVreg[count], getValueType(I->getType()), DAG.getRoot()); DAG.setRoot(newroot.getValue(1)); - ArgValues.push_back(argt); + ArgValues.push_back(newroot); ++count; } + return ArgValues; } @@ -184,9 +214,9 @@ // Promote the integer to 64 bits. If the input type is signed use a // sign extend, otherwise use a zero extend. if (Args[i].second->isSigned()) - Args[i].first = DAG.getNode(ISD::SIGN_EXTEND, MVT::i64, Args[i].first); + Args[i].first = DAG.getNode(ISD::SIGN_EXTEND_INREG, MVT::i64, Args[i].first); else - Args[i].first = DAG.getNode(ISD::ZERO_EXTEND, MVT::i64, Args[i].first); + Args[i].first = DAG.getNode(ISD::ZERO_EXTEND_INREG, MVT::i64, Args[i].first); break; case MVT::i64: break; @@ -317,18 +347,12 @@ Tmp1 = SelectExpr(Node->getOperand(1)); switch(Node->getValueType(0)) { - default: assert(0 && "Unknown type to sign extend to."); + default: Node->dump(); assert(0 && "Unknown type to sign extend to."); case MVT::i64: switch (cast(Node)->getExtraValueType()) { default: - std::cerr << cast(Node)->getExtraValueType() - << "(i1 is " << MVT::i1 - << " i8 is " << MVT::i8 - << " i16 is " << MVT::i16 - << " i32 is " << MVT::i32 - << " i64 is " << MVT::i64 - << ")\n"; - assert(0 && "Bad extend load!"); + Node->dump(); + assert(0 && "Bad extend load!"); case MVT::i64: BuildMI(BB, Alpha::LDQ, 2, Result).addImm(0).addReg(Tmp1); break; @@ -357,11 +381,12 @@ Select(Node->getOperand(0)); // chain Tmp1 = SelectExpr(Node->getOperand(1)); switch(Node->getValueType(0)) { - default: assert(0 && "Unknown type to sign extend to."); + default: Node->dump(); assert(0 && "Unknown type to sign extend to."); case MVT::i64: switch (cast(Node)->getExtraValueType()) { default: - assert(0 && "Bad sign extend!"); + Node->dump(); + assert(0 && "Bad sign extend!"); case MVT::i32: BuildMI(BB, Alpha::LDL, 2, Result).addImm(0).addReg(Tmp1); break; @@ -386,11 +411,12 @@ Select(Node->getOperand(0)); // chain Tmp1 = SelectExpr(Node->getOperand(1)); switch(Node->getValueType(0)) { - default: assert(0 && "Unknown type to zero extend to."); + default: Node->dump(); assert(0 && "Unknown type to zero extend to."); case MVT::i64: switch (cast(Node)->getExtraValueType()) { default: - assert(0 && "Bad sign extend!"); + Node->dump(); + assert(0 && "Bad sign extend!"); case MVT::i16: BuildMI(BB, Alpha::LDWU, 2, Result).addImm(0).addReg(Tmp1); break; @@ -412,7 +438,7 @@ case ISD::CALL: { Select(N.getOperand(0)); - + // The chain for this call is now lowered. ExprMap.insert(std::make_pair(N.getValue(Node->getNumValues()-1), 1)); @@ -420,67 +446,86 @@ std::vector argvregs; assert(Node->getNumOperands() < 8 && "Only 6 args supported"); for(int i = 2, e = Node->getNumOperands(); i < e; ++i) - { - argvregs.push_back(SelectExpr(N.getOperand(i))); - } + argvregs.push_back(SelectExpr(N.getOperand(i))); + for(int i = 0, e = argvregs.size(); i < e; ++i) - { - unsigned args[] = {Alpha::R16, Alpha::R17, Alpha::R18, - Alpha::R19, Alpha::R20, Alpha::R21}; - - BuildMI(BB, Alpha::BIS, 2, args[i]).addReg(argvregs[i]).addReg(argvregs[i]); - } - - //build the right kind of call - if (GlobalAddressSDNode *GASD = - dyn_cast(N.getOperand(1))) - { - Select(N.getOperand(0)); - AlphaLowering.restoreGP(BB); - BuildMI(BB, Alpha::CALL, 1).addGlobalAddress(GASD->getGlobal(),true); + { + unsigned args_int[] = {Alpha::R16, Alpha::R17, Alpha::R18, + Alpha::R19, Alpha::R20, Alpha::R21}; + unsigned args_float[] = {Alpha::F16, Alpha::F17, Alpha::F18, + Alpha::F19, Alpha::F20, Alpha::F21}; + switch(N.getOperand(i).getValueType()) { + default: Node->dump(); assert(0 && "Unknown value type for call"); + case MVT::i1: + case MVT::i8: + case MVT::i16: + case MVT::i32: + case MVT::i64: + BuildMI(BB, Alpha::BIS, 2, args_int[i]).addReg(argvregs[i]).addReg(argvregs[i]); + break; + case MVT::f32: + case MVT::f64: + BuildMI(BB, Alpha::CPYS, 2, args_float[i]).addReg(argvregs[i]).addReg(argvregs[i]); + break; + } + + } + //build the right kind of call + if (GlobalAddressSDNode *GASD = + dyn_cast(N.getOperand(1))) + { + Select(N.getOperand(0)); + AlphaLowering.restoreGP(BB); + BuildMI(BB, Alpha::CALL, 1).addGlobalAddress(GASD->getGlobal(),true); + } + else if (ExternalSymbolSDNode *ESSDN = + dyn_cast(N.getOperand(1))) + { + Select(N.getOperand(0)); + AlphaLowering.restoreGP(BB); + BuildMI(BB, Alpha::CALL, 0).addExternalSymbol(ESSDN->getSymbol(), true); + } + else + { + Select(N.getOperand(0)); + Tmp1 = SelectExpr(N.getOperand(1)); + BuildMI(BB, Alpha::CALL, 1).addReg(Tmp1); + AlphaLowering.restoreGP(BB); + } + + //push the result into a virtual register + // if (Result != 1) + // BuildMI(BB, Alpha::BIS, 2, Result).addReg(Alpha::R0).addReg(Alpha::R0); + + switch (Node->getValueType(0)) { + default: Node->dump(); assert(0 && "Unknown value type for call result!"); + case MVT::Other: return 1; + case MVT::i1: + case MVT::i8: + case MVT::i16: + case MVT::i32: + case MVT::i64: + BuildMI(BB, Alpha::BIS, 2, Result).addReg(Alpha::R0).addReg(Alpha::R0); + break; + case MVT::f32: + case MVT::f64: + BuildMI(BB, Alpha::CPYS, 2, Result).addReg(Alpha::F0).addReg(Alpha::F0); + break; } - else if (ExternalSymbolSDNode *ESSDN = - dyn_cast(N.getOperand(1))) - { - Select(N.getOperand(0)); - AlphaLowering.restoreGP(BB); - BuildMI(BB, Alpha::CALL, 0).addExternalSymbol(ESSDN->getSymbol(), true); - } - else { - Select(N.getOperand(0)); - Tmp1 = SelectExpr(N.getOperand(1)); - BuildMI(BB, Alpha::CALL, 1).addReg(Tmp1); - AlphaLowering.restoreGP(BB); - } - - //push the result into a virtual register - // if (Result != 1) - // BuildMI(BB, Alpha::BIS, 2, Result).addReg(Alpha::R0).addReg(Alpha::R0); - - switch (Node->getValueType(0)) { - default: assert(0 && "Unknown value type for call result!"); - case MVT::Other: return 1; - case MVT::i1: - case MVT::i8: - case MVT::i16: - case MVT::i32: - case MVT::i64: - BuildMI(BB, Alpha::BIS, 2, Result).addReg(Alpha::R0).addReg(Alpha::R0); - break; - } - return Result+N.ResNo; + return Result+N.ResNo; } - + case ISD::SIGN_EXTEND: case ISD::SIGN_EXTEND_INREG: { Tmp1 = SelectExpr(N.getOperand(0)); MVTSDNode* MVN = dyn_cast(Node); - std::cerr << "SrcT: " << MVN->getExtraValueType() << "\n"; + //std::cerr << "SrcT: " << MVN->getExtraValueType() << "\n"; switch(MVN->getExtraValueType()) { default: - assert(0 && "Sign Extend InReg not there yet"); + Node->dump(); + assert(0 && "Sign Extend InReg not there yet"); break; case MVT::i32: { @@ -500,11 +545,12 @@ { Tmp1 = SelectExpr(N.getOperand(0)); MVTSDNode* MVN = dyn_cast(Node); - std::cerr << "SrcT: " << MVN->getExtraValueType() << "\n"; + //std::cerr << "SrcT: " << MVN->getExtraValueType() << "\n"; switch(MVN->getExtraValueType()) { default: - assert(0 && "Zero Extend InReg not there yet"); + Node->dump(); + assert(0 && "Zero Extend InReg not there yet"); break; case MVT::i32: Tmp2 = 0xf0; break; case MVT::i16: Tmp2 = 0xfc; break; @@ -520,7 +566,7 @@ if (SetCCSDNode *SetCC = dyn_cast(Node)) { if (MVT::isInteger(SetCC->getOperand(0).getValueType())) { switch (SetCC->getCondition()) { - default: assert(0 && "Unknown integer comparison!"); + default: Node->dump(); assert(0 && "Unknown integer comparison!"); case ISD::SETEQ: BuildMI(BB, Alpha::CMPEQ, 2, Result).addReg(Tmp1).addReg(Tmp2); break; @@ -558,11 +604,16 @@ } } else - assert(0 && "only integer"); + { + Node->dump(); + assert(0 && "only integer"); + } } else - assert(0 && "Not a setcc in setcc"); - + { + Node->dump(); + assert(0 && "Not a setcc in setcc"); + } return Result; case ISD::CopyFromReg: @@ -587,94 +638,159 @@ case ISD::SHL: case ISD::SRL: case ISD::MUL: - if(N.getOperand(1).getOpcode() == ISD::Constant && - cast(N.getOperand(1))->getValue() >= 0 && - cast(N.getOperand(1))->getValue() <= 255) - { - switch(N.getOpcode()) { - case ISD::AND: Opc = Alpha::ANDi; break; - case ISD::OR: Opc = Alpha::BISi; break; - case ISD::XOR: Opc = Alpha::XORi; break; - case ISD::SHL: Opc = Alpha::SLi; break; - case ISD::SRL: Opc = Alpha::SRLi; break; - case ISD::SRA: Opc = Alpha::SRAi; break; - case ISD::MUL: Opc = Alpha::MULQi; break; - }; - Tmp1 = SelectExpr(N.getOperand(0)); - Tmp2 = cast(N.getOperand(1))->getValue(); - BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addImm(Tmp2); - } - else - { - switch(N.getOpcode()) { - case ISD::AND: Opc = Alpha::AND; break; - case ISD::OR: Opc = Alpha::BIS; break; - case ISD::XOR: Opc = Alpha::XOR; break; - case ISD::SHL: Opc = Alpha::SL; break; - case ISD::SRL: Opc = Alpha::SRL; break; - case ISD::SRA: Opc = Alpha::SRA; break; - case ISD::MUL: Opc = Alpha::MULQ; break; - }; - Tmp1 = SelectExpr(N.getOperand(0)); - Tmp2 = SelectExpr(N.getOperand(1)); - BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); - } - return Result; - - case ISD::ADD: - case ISD::SUB: - { - bool isAdd = N.getOpcode() == ISD::ADD; - - //FIXME: first check for Scaled Adds and Subs! + switch (N.getValueType()) { + default: Node->dump(); assert (0 && "unhandled type"); + case MVT::f64: + assert(N.getOpcode() == ISD::MUL && "only mul here please"); + Tmp1 = SelectExpr(N.getOperand(0)); + Tmp2 = SelectExpr(N.getOperand(1)); + BuildMI(BB, Alpha::MULT, 2, Result).addReg(Tmp1).addReg(Tmp2); + break; + case MVT::f32: + assert(N.getOpcode() == ISD::MUL && "only mul here please"); + Tmp1 = SelectExpr(N.getOperand(0)); + Tmp2 = SelectExpr(N.getOperand(1)); + BuildMI(BB, Alpha::MULS, 2, Result).addReg(Tmp1).addReg(Tmp2); + break; + case MVT::i64: if(N.getOperand(1).getOpcode() == ISD::Constant && cast(N.getOperand(1))->getValue() >= 0 && cast(N.getOperand(1))->getValue() <= 255) - { //Normal imm add/sub - Opc = isAdd ? Alpha::ADDQi : Alpha::SUBQi; + { + switch(N.getOpcode()) { + case ISD::AND: Opc = Alpha::ANDi; break; + case ISD::OR: Opc = Alpha::BISi; break; + case ISD::XOR: Opc = Alpha::XORi; break; + case ISD::SHL: Opc = Alpha::SLi; break; + case ISD::SRL: Opc = Alpha::SRLi; break; + case ISD::SRA: Opc = Alpha::SRAi; break; + case ISD::MUL: Opc = Alpha::MULQi; break; + }; Tmp1 = SelectExpr(N.getOperand(0)); Tmp2 = cast(N.getOperand(1))->getValue(); BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addImm(Tmp2); } - else if(N.getOperand(1).getOpcode() == ISD::Constant && - cast(N.getOperand(1))->getValue() >= 0 && - cast(N.getOperand(1))->getValue() <= 32767) - { //LDA //FIXME: expand the above condition a bit - Tmp1 = SelectExpr(N.getOperand(0)); - Tmp2 = cast(N.getOperand(1))->getValue(); - if (!isAdd) - Tmp2 = -Tmp2; - BuildMI(BB, Alpha::LDA, 2, Result).addImm(Tmp2).addReg(Tmp1); - } else - { //Normal add/sub - Opc = isAdd ? Alpha::ADDQ : Alpha::SUBQ; + { + switch(N.getOpcode()) { + case ISD::AND: Opc = Alpha::AND; break; + case ISD::OR: Opc = Alpha::BIS; break; + case ISD::XOR: Opc = Alpha::XOR; break; + case ISD::SHL: Opc = Alpha::SL; break; + case ISD::SRL: Opc = Alpha::SRL; break; + case ISD::SRA: Opc = Alpha::SRA; break; + case ISD::MUL: Opc = Alpha::MULQ; break; + }; Tmp1 = SelectExpr(N.getOperand(0)); Tmp2 = SelectExpr(N.getOperand(1)); BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); - } - return Result; + break; + } + return Result; + + case ISD::ADD: + case ISD::SUB: + { + bool isAdd = N.getOpcode() == ISD::ADD; + + switch (N.getValueType()) { + default: Node->dump(); assert(0 && "Unhandled type"); + case MVT::i64: { + //FIXME: first check for Scaled Adds and Subs! + if(N.getOperand(1).getOpcode() == ISD::Constant && + cast(N.getOperand(1))->getValue() >= 0 && + cast(N.getOperand(1))->getValue() <= 255) + { //Normal imm add/sub + Opc = isAdd ? Alpha::ADDQi : Alpha::SUBQi; + Tmp1 = SelectExpr(N.getOperand(0)); + Tmp2 = cast(N.getOperand(1))->getValue(); + BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addImm(Tmp2); + } + else if(N.getOperand(1).getOpcode() == ISD::Constant && + cast(N.getOperand(1))->getValue() >= 0 && + cast(N.getOperand(1))->getValue() <= 32767) + { //LDA //FIXME: expand the above condition a bit + Tmp1 = SelectExpr(N.getOperand(0)); + Tmp2 = cast(N.getOperand(1))->getValue(); + if (!isAdd) + Tmp2 = -Tmp2; + BuildMI(BB, Alpha::LDA, 2, Result).addImm(Tmp2).addReg(Tmp1); + } + else + { //Normal add/sub + Opc = isAdd ? Alpha::ADDQ : Alpha::SUBQ; + Tmp1 = SelectExpr(N.getOperand(0)); + Tmp2 = SelectExpr(N.getOperand(1)); + BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); + } + } break; + case MVT::f64: + case MVT::f32: + if (N.getValueType() == MVT::f64) + Opc = isAdd ? Alpha::ADDT : Alpha::SUBT; + else + Opc = isAdd ? Alpha::ADDS : Alpha::SUBS; + // + Tmp1 = SelectExpr(N.getOperand(0)); + Tmp2 = SelectExpr(N.getOperand(1)); + BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); + break; } + return Result; + } case ISD::UREM: case ISD::SREM: case ISD::SDIV: case ISD::UDIV: - //FIXME: alpha really doesn't support any of these operations, - // the ops are expanded into special library calls with - // special calling conventions - switch(N.getOpcode()) { - case ISD::UREM: Opc = Alpha::REMQU; break; - case ISD::SREM: Opc = Alpha::REMQ; break; - case ISD::UDIV: Opc = Alpha::DIVQU; break; - case ISD::SDIV: Opc = Alpha::DIVQ; break; - }; + switch (N.getValueType()) { + default: Node->dump(); assert (0 && "unhandled type"); + case MVT::f64: + assert(N.getOpcode() == ISD::SDIV && "only div here please"); + Opc = Alpha::DIVT; + break; + case MVT::f32: + assert(N.getOpcode() == ISD::SDIV && "only div here please"); + Opc = Alpha::DIVS; + break; + case MVT::i64: + //FIXME: alpha really doesn't support any of these operations, + // the ops are expanded into special library calls with + // special calling conventions + switch(N.getOpcode()) { + case ISD::UREM: Opc = Alpha::REMQU; break; + case ISD::SREM: Opc = Alpha::REMQ; break; + case ISD::UDIV: Opc = Alpha::DIVQU; break; + case ISD::SDIV: Opc = Alpha::DIVQ; break; + } + break; + } Tmp1 = SelectExpr(N.getOperand(0)); Tmp2 = SelectExpr(N.getOperand(1)); BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); return Result; +// case ISD::SINT_TO_FP: +// MVT::ValueType DestTy = N.getValueType(); +// Tmp1 = SelectExpr(N.getOperand(0)); // Get the operand register +// Tmp2 = MakeReg(DestTy); +// Opc = DestTy == MVT::f64 ? ITOFT : ITOFS; +// BuildMI(BB, Opc, 1, Tmp2).addReg(Tmp1); +// Opc = DestTy == MVT::f64 ? CVTQT : CVTQS; +// BuildMI(BB, Opc, 1, Result).addReg(Tmp1); +// // case ISD::UINT_TO_FP: + +// case ISD::FP_TO_SINT: +// assert (N.getValueType() == MVT::f64 && "Only can convert for doubles"); +// Tmp1 = SelectExpr(N.getOperand(0)); // Get the operand register +// Tmp2 = MakeReg(SrcTy); +// BuildMI(BB, CVTTQ, 1, Tmp2).addReg(Tmp1); +// BuildMI(BB, FTOIT, 1, Result).addReg(Tmp2); +// return result; + +// // case ISD::FP_TO_UINT: + case ISD::SELECT: { Tmp2 = SelectExpr(N.getOperand(1)); //Use if TRUE @@ -790,12 +906,17 @@ std::cerr << N.getNumOperands() << "\n"; for (unsigned i = 0; i < N.getNumOperands(); ++i) std::cerr << N.getOperand(i).getValueType() << "\n"; + Node->dump(); assert(0 && "Unknown return instruction!"); case 2: Select(N.getOperand(0)); Tmp1 = SelectExpr(N.getOperand(1)); switch (N.getOperand(1).getValueType()) { - default: assert(0 && "All other types should have been promoted!!"); + default: Node->dump(); assert(0 && "All other types should have been promoted!!"); + case MVT::f64: + case MVT::f32: + BuildMI(BB, Alpha::CPYS, 2, Alpha::F0).addReg(Tmp1).addReg(Tmp1); + break; case MVT::i32: case MVT::i64: BuildMI(BB, Alpha::BIS, 2, Alpha::R0).addReg(Tmp1).addReg(Tmp1); @@ -839,14 +960,17 @@ case ISD::TRUNCSTORE: { // truncstore chain, val, ptr :storety MVT::ValueType StoredTy = cast(Node)->getExtraValueType(); - assert(StoredTy != MVT::i64 && "Unsupported TRUNCSTORE for this target!"); + if (StoredTy == MVT::i64) { + Node->dump(); + assert(StoredTy != MVT::i64 && "Unsupported TRUNCSTORE for this target!"); + } Select(N.getOperand(0)); Tmp1 = SelectExpr(N.getOperand(1)); Tmp2 = SelectExpr(N.getOperand(2)); switch (StoredTy) { - default: assert(0 && "Unhandled Type"); break; + default: Node->dump(); assert(0 && "Unhandled Type"); break; case MVT::i1: //FIXME: DAG does not promote this load case MVT::i8: Opc = Alpha::STB; break; case MVT::i16: Opc = Alpha::STW; break; Index: llvm/lib/Target/Alpha/AlphaInstrFormats.td diff -u llvm/lib/Target/Alpha/AlphaInstrFormats.td:1.2 llvm/lib/Target/Alpha/AlphaInstrFormats.td:1.3 --- llvm/lib/Target/Alpha/AlphaInstrFormats.td:1.2 Mon Jan 24 13:44:06 2005 +++ llvm/lib/Target/Alpha/AlphaInstrFormats.td Wed Jan 26 15:54:08 2005 @@ -83,10 +83,10 @@ } //3.3.4 -class FPForm opcode, dag OL, string asmstr> : InstAlpha { +class FPForm opcode, bits<11> fun, dag OL, string asmstr> : InstAlpha { bits<5> Fa; bits<5> Fb; - bits<11> Function; + bits<11> Function = fun; bits<5> Fc; let Inst{25-21} = Fa; Index: llvm/lib/Target/Alpha/AlphaInstrInfo.cpp diff -u llvm/lib/Target/Alpha/AlphaInstrInfo.cpp:1.2 llvm/lib/Target/Alpha/AlphaInstrInfo.cpp:1.3 --- llvm/lib/Target/Alpha/AlphaInstrInfo.cpp:1.2 Mon Jan 24 13:44:06 2005 +++ llvm/lib/Target/Alpha/AlphaInstrInfo.cpp Wed Jan 26 15:54:09 2005 @@ -26,7 +26,7 @@ unsigned& sourceReg, unsigned& destReg) const { MachineOpCode oc = MI.getOpcode(); - if (oc == Alpha::BIS) { // or r1, r2, r2 + if (oc == Alpha::BIS || oc == Alpha::CPYS) { // or r1, r2, r2 // cpys r1 r2 r2 assert(MI.getNumOperands() == 3 && MI.getOperand(0).isRegister() && MI.getOperand(1).isRegister() && Index: llvm/lib/Target/Alpha/AlphaInstrInfo.td diff -u llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.4 llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.5 --- llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.4 Tue Jan 25 19:24:38 2005 +++ llvm/lib/Target/Alpha/AlphaInstrInfo.td Wed Jan 26 15:54:09 2005 @@ -43,7 +43,10 @@ let isCall = 1, Defs = [R0, R1, R2, R3, R4, R5, R6, R7, R8, R16, R17, R18, R19, - R20, R21, R22, R23, R24, R25, R26, R27, R29], + R20, R21, R22, R23, R24, R25, R26, R27, R29, + F0, F1, + F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, + F20, F21, F22, F23, F24, F25, F26, F27, F28, F29, F30], Uses = [R27, R29] in def CALL : PseudoInstAlpha< (ops s64imm:$TARGET), "jsr $TARGET">; //Jump to subroutine @@ -250,19 +253,32 @@ let Defs = [R0, R1, R2, R3, R4, R5, R6, R7, R8, R16, R17, R18, R19, R20, R21, R22, R23, R24, R25, R27, R29] in def BSR : BForm<0x34, (ops GPRC:$RD, s21imm:$DISP), "bsr $RD,$DISP">; //Branch to subroutine +//Stores, int def STB : MForm<0x0E, (ops GPRC:$RA, s16imm:$DISP, GPRC:$RB), "stb $RA,$DISP($RB)">; // Store byte def STW : MForm<0x0D, (ops GPRC:$RA, s16imm:$DISP, GPRC:$RB), "stw $RA,$DISP($RB)">; // Store word def STL : MForm<0x2C, (ops GPRC:$RA, s16imm:$DISP, GPRC:$RB), "stl $RA,$DISP($RB)">; // Store longword def STQ : MForm<0x2D, (ops GPRC:$RA, s16imm:$DISP, GPRC:$RB), "stq $RA,$DISP($RB)">; //Store quadword +//Load address def LDA : MForm<0x08, (ops GPRC:$RA, s16imm:$DISP, GPRC:$RB), "lda $RA,$DISP($RB)">; //Load address +def LDAH : MForm<0x08, (ops GPRC:$RA, s16imm:$DISP, GPRC:$RB), "ldah $RA,$DISP($RB)">; //Load address high +//Loads, int def LDL : MForm<0x28, (ops GPRC:$RA, s16imm:$DISP, GPRC:$RB), "ldq $RA,$DISP($RB)">; // Load sign-extended longword def LDQ : MForm<0x29, (ops GPRC:$RA, s16imm:$DISP, GPRC:$RB), "ldq $RA,$DISP($RB)">; //Load quadword def LDBU : MForm<0x0A, (ops GPRC:$RA, s16imm:$DISP, GPRC:$RB), "ldbu $RA,$DISP($RB)">; //Load zero-extended byte def LDWU : MForm<0x0C, (ops GPRC:$RA, s16imm:$DISP, GPRC:$RB), "ldwu $RA,$DISP($RB)">; //Load zero-extended word +//Stores, float +def STS : MForm<0x26, (ops FPRC:$RA, s16imm:$DISP, GPRC:$RB), "sts $RA,$DISP($RB)">; //Store S_floating +def STT : MForm<0x27, (ops FPRC:$RA, s16imm:$DISP, GPRC:$RB), "stt $RA,$DISP($RB)">; //Store T_floating +//Loads, float +def LDS : MForm<0x22, (ops FPRC:$RA, s16imm:$DISP, GPRC:$RB), "lds $RA,$DISP($RB)">; //Load S_floating +def LDT : MForm<0x23, (ops FPRC:$RA, s16imm:$DISP, GPRC:$RB), "ldt $RA,$DISP($RB)">; //Load T_floating + + +//Branches, int def BEQ : BForm<0x39, (ops GPRC:$RA, s21imm:$DISP), "beq $RA,$DISP">; //Branch if = zero def BGE : BForm<0x3E, (ops GPRC:$RA, s21imm:$DISP), "bge $RA,$DISP">; //Branch if >= zero def BGT : BForm<0x3F, (ops GPRC:$RA, s21imm:$DISP), "bgt $RA,$DISP">; //Branch if > zero @@ -272,19 +288,42 @@ def BLT : BForm<0x3A, (ops GPRC:$RA, s21imm:$DISP), "blt $RA,$DISP">; //Branch if < zero def BNE : BForm<0x3D, (ops GPRC:$RA, s21imm:$DISP), "bne $RA,$DISP">; //Branch if != zero +//Branches, float +def FBEQ : BForm<0x31, (ops FPRC:$RA, s21imm:$DISP), "beq $RA,$DISP">; //Floating branch if = zero +def FBGE : BForm<0x36, (ops FPRC:$RA, s21imm:$DISP), "beq $RA,$DISP">; //Floating branch if >= zero +def FBGT : BForm<0x37, (ops FPRC:$RA, s21imm:$DISP), "beq $RA,$DISP">; //Floating branch if > zero +def FBLE : BForm<0x33, (ops FPRC:$RA, s21imm:$DISP), "beq $RA,$DISP">; //Floating branch if <= zero +def FBLT : BForm<0x32, (ops FPRC:$RA, s21imm:$DISP), "beq $RA,$DISP">; //Floating branch if < zero +def FBNE : BForm<0x35, (ops FPRC:$RA, s21imm:$DISP), "beq $RA,$DISP">; //Floating branch if != zero + +//Funky Floating point ops +def CPYS : FPForm<0x17, 0x020, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "cpys $RA,$RB,$RC">; //Copy sign +def CPYSE : FPForm<0x17, 0x022, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "cpyse $RA,$RB,$RC">; //Copy sign and exponent +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 $RA,$RB,$RC">; //Add S_floating +def ADDT : FPForm<0x16, 0x0A0, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "addt $RA,$RB,$RC">; //Add T_floating +def SUBS : FPForm<0x16, 0x081, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "subs $RA,$RB,$RC">; //Subtract S_floating +def SUBT : FPForm<0x16, 0x0A1, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "subt $RA,$RB,$RC">; //Subtract T_floating +def DIVS : FPForm<0x16, 0x083, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "divs $RA,$RB,$RC">; //Divide S_floating +def DIVT : FPForm<0x16, 0x0A3, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "divt $RA,$RB,$RC">; //Divide T_floating +def MULS : FPForm<0x16, 0x082, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "muls $RA,$RB,$RC">; //Multiply S_floating +def MULT : FPForm<0x16, 0x0A2, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "mult $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 + +//S_floating : IEEE Single +//T_floating : IEEE Double + //Mnemonic Format Opcode Description -//ADDF F-P 15.080 Add F_floating -//ADDG F-P 15.0A0 Add G_floating -//ADDS F-P 16.080 Add S_floating -//ADDT F-P 16.0A0 Add T_floating + //CALL_PAL Pcd 00 Trap to PALcode //ECB Mfc 18.E800 Evict cache block //EXCB Mfc 18.0400 Exception barrier //FETCH Mfc 18.8000 Prefetch data //FETCH_M Mfc 18.A000 Prefetch data, modify intent -//LDAH Mem 09 Load address high -//LDBU Mem 0A Load zero-extended byte -//LDWU Mem 0C Load zero-extended word + //LDL_L Mem 2A Load sign-extended longword locked //LDQ_L Mem 2B Load quadword locked //LDQ_U Mem 0B Load unaligned quadword @@ -292,77 +331,39 @@ //RC Mfc 18.E000 Read and clear //RPCC Mfc 18.C000 Read process cycle counter //RS Mfc 18.F000 Read and set + //STL_C Mem 2E Store longword conditional //STQ_C Mem 2F Store quadword conditional //STQ_U Mem 0F Store unaligned quadword + //TRAPB Mfc 18.0000 Trap barrier //WH64 Mfc 18.F800 Write hint  64 bytes //WMB Mfc 18.4400 Write memory barrier - -//CMPGEQ F-P 15.0A5 Compare G_floating equal -//CMPGLE F-P 15.0A7 Compare G_floating less than or equal -//CMPGLT F-P 15.0A6 Compare G_floating less than //CMPTEQ F-P 16.0A5 Compare T_floating equal //CMPTLE F-P 16.0A7 Compare T_floating less than or equal //CMPTLT F-P 16.0A6 Compare T_floating less than //CMPTUN F-P 16.0A4 Compare T_floating unordered -//CPYS F-P 17.020 Copy sign -//CPYSE F-P 17.022 Copy sign and exponent -//CPYSN F-P 17.021 Copy sign negate -//CVTDG F-P 15.09E Convert D_floating to G_floating -//CVTGD F-P 15.0AD Convert G_floating to D_floating -//CVTGF F-P 15.0AC Convert G_floating to F_floating -//CVTGQ F-P 15.0AF Convert G_floating to quadword + //CVTLQ F-P 17.010 Convert longword to quadword -//CVTQF F-P 15.0BC Convert quadword to F_floating -//CVTQG F-P 15.0BE Convert quadword to G_floating //CVTQL F-P 17.030 Convert quadword to longword //CVTQS F-P 16.0BC Convert quadword to S_floating //CVTQT F-P 16.0BE Convert quadword to T_floating //CVTST F-P 16.2AC Convert S_floating to T_floating //CVTTQ F-P 16.0AF Convert T_floating to quadword //CVTTS F-P 16.0AC Convert T_floating to S_floating -//DIVF F-P 15.083 Divide F_floating -//DIVG F-P 15.0A3 Divide G_floating -//DIVS F-P 16.083 Divide S_floating -//DIVT F-P 16.0A3 Divide T_floating -//FBEQ Bra 31 Floating branch if = zero -//FBGE Bra 36 Floating branch if ? zero -//FBGT Bra 37 Floating branch if > zero -//FBLE Bra 33 Floating branch if ? zero -//FBLT Bra 32 Floating branch if < zero -//FBNE Bra 35 Floating branch if ? zero + //FCMOVEQ F-P 17.02A FCMOVE if = zero -//FCMOVGE F-P 17.02D FCMOVE if ? zero +//FCMOVGE F-P 17.02D FCMOVE if >= zero //FCMOVGT F-P 17.02F FCMOVE if > zero -//FCMOVLE F-P 17.02E FCMOVE if ? zero +//FCMOVLE F-P 17.02E FCMOVE if <= zero //FCMOVLT F-P 17.02C FCMOVE if < zero -//FCMOVNE F-P 17.02B FCMOVE if ? zero +//FCMOVNE F-P 17.02B FCMOVE if != zero + //FTOIS F-P 1C.78 Floating to integer move, S_floating //FTOIT F-P 1C.70 Floating to integer move, T_floating -//ITOFF F-P 14.014 Integer to floating move, F_floating //ITOFS F-P 14.004 Integer to floating move, S_floating //ITOFT F-P 14.024 Integer to floating move, T_floating -//LDF Mem 20 Load F_floating -//LDG Mem 21 Load G_floating -//LDS Mem 22 Load S_floating -//LDT Mem 23 Load T_floating + //MF_FPCR F-P 17.025 Move from FPCR //MT_FPCR F-P 17.024 Move to FPCR -//MULF F-P 15.082 Multiply F_floating -//MULG F-P 15.0A2 Multiply G_floating -//MULS F-P 16.082 Multiply S_floating -//MULT F-P 16.0A2 Multiply T_floating -//SQRTF F-P 14.08A Square root F_floating -//SQRTG F-P 14.0AA Square root G_floating -//SQRTS F-P 14.08B Square root S_floating -//SQRTT F-P 14.0AB Square root T_floating -//STF Mem 24 Store F_floating -//STG Mem 25 Store G_floating -//STS Mem 26 Store S_floating -//STT Mem 27 Store T_floating -//SUBF F-P 15.081 Subtract F_floating -//SUBG F-P 15.0A1 Subtract G_floating -//SUBS F-P 16.081 Subtract S_floating -//SUBT F-P 16.0A1 Subtract T_floating Index: llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp diff -u llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.2 llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.3 --- llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.2 Mon Jan 24 13:44:07 2005 +++ llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp Wed Jan 26 15:54:09 2005 @@ -48,7 +48,7 @@ AlphaRegisterInfo::storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned SrcReg, int FrameIdx) const { - std::cerr << "Trying to store " << getPrettyName(SrcReg) << " to " << FrameIdx << "\n"; + //std::cerr << "Trying to store " << getPrettyName(SrcReg) << " to " << FrameIdx << "\n"; //BuildMI(MBB, MI, Alpha::WTF, 0).addReg(SrcReg); BuildMI(MBB, MI, Alpha::STQ, 3).addReg(SrcReg).addImm(FrameIdx * 8).addReg(Alpha::R30); // assert(0 && "TODO"); @@ -58,7 +58,7 @@ AlphaRegisterInfo::loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned DestReg, int FrameIdx) const{ - std::cerr << "Trying to load " << getPrettyName(DestReg) << " to " << FrameIdx << "\n"; + //std::cerr << "Trying to load " << getPrettyName(DestReg) << " to " << FrameIdx << "\n"; //BuildMI(MBB, MI, Alpha::WTF, 0, DestReg); BuildMI(MBB, MI, Alpha::LDQ, 2, DestReg).addImm(FrameIdx * 8).addReg(Alpha::R30); // assert(0 && "TODO"); @@ -71,8 +71,8 @@ // std::cerr << "copyRegToReg " << DestReg << " <- " << SrcReg << "\n"; if (RC == Alpha::GPRCRegisterClass) { BuildMI(MBB, MI, Alpha::BIS, 2, DestReg).addReg(SrcReg).addReg(SrcReg); -// } else if (RC == Alpha::FPRCRegisterClass) { -// BuildMI(MBB, MI, PPC::FMR, 1, DestReg).addReg(SrcReg); + } else if (RC == Alpha::FPRCRegisterClass) { + BuildMI(MBB, MI, Alpha::CPYS, 2, DestReg).addReg(SrcReg).addReg(SrcReg); } else { std::cerr << "Attempt to copy register that is not GPR or FPR"; abort(); @@ -205,14 +205,21 @@ // adjust stack pointer: r30 -= numbytes - if (NumBytes <= 32000) //FIXME: do this better - { - MI=BuildMI(Alpha::LDA, 2, Alpha::R30).addImm(-NumBytes).addReg(Alpha::R30); - MBB.insert(MBBI, MI); - } else { - std::cerr << "Too big a stack frame\n"; - abort(); - } + if (NumBytes <= 32767) { + MI=BuildMI(Alpha::LDA, 2, Alpha::R30).addImm(-NumBytes).addReg(Alpha::R30); + MBB.insert(MBBI, MI); + } else if (NumBytes <= 32767 * 65536) { + long y = NumBytes / 65536; + if (NumBytes % 65536 > 32767) + ++y; + MI=BuildMI(Alpha::LDAH, 2, Alpha::R30).addImm(-y).addReg(Alpha::R30); + MBB.insert(MBBI, MI); + MI=BuildMI(Alpha::LDA, 2, Alpha::R30).addImm(-(NumBytes - y * 65536)).addReg(Alpha::R30); + MBB.insert(MBBI, MI); + } else { + std::cerr << "Too big a stack frame\n"; + abort(); + } } void AlphaRegisterInfo::emitEpilogue(MachineFunction &MF, From alenhar2 at cs.uiuc.edu Wed Jan 26 17:57:05 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Wed, 26 Jan 2005 17:57:05 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaInstrInfo.td Message-ID: <200501262357.RAA30151@cypher.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaInstrInfo.td updated: 1.5 -> 1.6 --- Log message: added instructions for fp to int to fp moves --- Diffs of the changes: (+6 -5) AlphaInstrInfo.td | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-) Index: llvm/lib/Target/Alpha/AlphaInstrInfo.td diff -u llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.5 llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.6 --- llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.5 Wed Jan 26 15:54:09 2005 +++ llvm/lib/Target/Alpha/AlphaInstrInfo.td Wed Jan 26 17:56:48 2005 @@ -313,6 +313,12 @@ 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 +//INT reg to FP reg and back again +def FTOIS : FPForm<0x1C, 0x078, (ops FPRC:$RC, GPRC:$RA), "ftois $RA,$RC">; //Floating to integer move, S_floating +def FTOIT : FPForm<0x1C, 0x070, (ops FPRC:$RC, GPRC:$RA), "ftoit $RA,$RC">; //Floating to integer move, T_floating +def ITOFS : FPForm<0x14, 0x004, (ops FPRC:$RC, GPRC:$RA), "itofs $RA,$RC">; //Integer to floating move, S_floating +def ITOFT : FPForm<0x14, 0x024, (ops FPRC:$RC, GPRC:$RA), "itoft $RA,$RC">; //Integer to floating move, T_floating + //S_floating : IEEE Single //T_floating : IEEE Double @@ -360,10 +366,5 @@ //FCMOVLT F-P 17.02C FCMOVE if < zero //FCMOVNE F-P 17.02B FCMOVE if != zero -//FTOIS F-P 1C.78 Floating to integer move, S_floating -//FTOIT F-P 1C.70 Floating to integer move, T_floating -//ITOFS F-P 14.004 Integer to floating move, S_floating -//ITOFT F-P 14.024 Integer to floating move, T_floating - //MF_FPCR F-P 17.025 Move from FPCR //MT_FPCR F-P 17.024 Move to FPCR From alenhar2 at cs.uiuc.edu Wed Jan 26 18:51:22 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Wed, 26 Jan 2005 18:51:22 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp Message-ID: <200501270051.SAA30185@cypher.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.7 -> 1.8 --- Log message: minor bug fix --- 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.7 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.8 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.7 Wed Jan 26 15:54:08 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Wed Jan 26 18:51:05 2005 @@ -157,7 +157,7 @@ case MVT::i32: case MVT::i64: BuildMI(&BB, Alpha::IDEF, 0, args_int[count - 1]); - argVreg.push_back(MF.getSSARegMap()->createVirtualRegister(getRegClassFor(getValueType(I->getType())))); + argVreg.push_back(MF.getSSARegMap()->createVirtualRegister(getRegClassFor(MVT::i64)))); argPreg.push_back(args_int[count - 1]); break; } From alenhar2 at cs.uiuc.edu Wed Jan 26 18:52:43 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Wed, 26 Jan 2005 18:52:43 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp Message-ID: <200501270052.SAA30195@cypher.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.8 -> 1.9 --- Log message: minor bug fix --- 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.8 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.9 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.8 Wed Jan 26 18:51:05 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Wed Jan 26 18:52:26 2005 @@ -157,7 +157,7 @@ case MVT::i32: case MVT::i64: BuildMI(&BB, Alpha::IDEF, 0, args_int[count - 1]); - argVreg.push_back(MF.getSSARegMap()->createVirtualRegister(getRegClassFor(MVT::i64)))); + argVreg.push_back(MF.getSSARegMap()->createVirtualRegister(getRegClassFor(MVT::i64))); argPreg.push_back(args_int[count - 1]); break; } From alenhar2 at cs.uiuc.edu Wed Jan 26 19:23:05 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Wed, 26 Jan 2005 19:23:05 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp Message-ID: <200501270123.TAA30249@cypher.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.9 -> 1.10 --- Log message: perhaps this will let me have calls again --- Diffs of the changes: (+9 -5) AlphaISelPattern.cpp | 14 +++++++++----- 1 files changed, 9 insertions(+), 5 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.9 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.10 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.9 Wed Jan 26 18:52:26 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Wed Jan 26 19:22:48 2005 @@ -220,6 +220,9 @@ break; case MVT::i64: break; + case MVT::f64: + case MVT::f32: + break; } args_to_use.push_back(Args[i].first); } @@ -454,8 +457,12 @@ Alpha::R19, Alpha::R20, Alpha::R21}; unsigned args_float[] = {Alpha::F16, Alpha::F17, Alpha::F18, Alpha::F19, Alpha::F20, Alpha::F21}; - switch(N.getOperand(i).getValueType()) { - default: Node->dump(); assert(0 && "Unknown value type for call"); + switch(N.getOperand(i+2).getValueType()) { + default: + Node->dump(); + N.getOperand(i).Val->dump(); + std::cerr << "Type for " << i << " is: " << N.getOperand(i+2).getValueType() << "\n"; + assert(0 && "Unknown value type for call"); case MVT::i1: case MVT::i8: case MVT::i16: @@ -474,20 +481,17 @@ if (GlobalAddressSDNode *GASD = dyn_cast(N.getOperand(1))) { - Select(N.getOperand(0)); AlphaLowering.restoreGP(BB); BuildMI(BB, Alpha::CALL, 1).addGlobalAddress(GASD->getGlobal(),true); } else if (ExternalSymbolSDNode *ESSDN = dyn_cast(N.getOperand(1))) { - Select(N.getOperand(0)); AlphaLowering.restoreGP(BB); BuildMI(BB, Alpha::CALL, 0).addExternalSymbol(ESSDN->getSymbol(), true); } else { - Select(N.getOperand(0)); Tmp1 = SelectExpr(N.getOperand(1)); BuildMI(BB, Alpha::CALL, 1).addReg(Tmp1); AlphaLowering.restoreGP(BB); From jeffc at jolt-lang.org Wed Jan 26 21:49:14 2005 From: jeffc at jolt-lang.org (Jeff Cohen) Date: Wed, 26 Jan 2005 21:49:14 -0600 Subject: [llvm-commits] CVS: llvm/lib/System/Win32/Path.inc Message-ID: <200501270349.VAA05418@zion.cs.uiuc.edu> Changes in directory llvm/lib/System/Win32: Path.inc updated: 1.29 -> 1.30 --- Log message: Fix some Path bugs --- Diffs of the changes: (+24 -11) Path.inc | 35 ++++++++++++++++++++++++----------- 1 files changed, 24 insertions(+), 11 deletions(-) Index: llvm/lib/System/Win32/Path.inc diff -u llvm/lib/System/Win32/Path.inc:1.29 llvm/lib/System/Win32/Path.inc:1.30 --- llvm/lib/System/Win32/Path.inc:1.29 Sat Jan 22 10:28:33 2005 +++ llvm/lib/System/Win32/Path.inc Wed Jan 26 21:49:03 2005 @@ -347,9 +347,10 @@ result.clear(); WIN32_FIND_DATA fd; - HANDLE h = FindFirstFile(path.c_str(), &fd); + std::string searchpath = path + "*"; + HANDLE h = FindFirstFile(searchpath.c_str(), &fd); if (h == INVALID_HANDLE_VALUE) { - if (GetLastError() == ERROR_NO_MORE_FILES) + if (GetLastError() == ERROR_FILE_NOT_FOUND) return true; // not really an error, now is it? ThrowError(path + ": Can't read directory: "); } @@ -607,7 +608,7 @@ aPath.destroyFile(); } } else { - if (GetLastError() != ERROR_NO_MORE_FILES) + if (GetLastError() != ERROR_FILE_NOT_FOUND) ThrowError(path + ": Can't read directory: "); } } @@ -742,15 +743,19 @@ if (reuse_current && !exists()) return; // File doesn't exist already, just use it! - Path dir (*this); - dir.elideFile(); - std::string fname = this->getLast(); - - char newName[MAX_PATH + 1]; - if (!GetTempFileName(dir.c_str(), fname.c_str(), 0, newName)) - ThrowError("Cannot make unique filename for '" + path + "': "); + // Reserve space for -XXXXXX at the end. + char *FNBuffer = (char*) alloca(path.size()+8); + unsigned offset = path.size(); + path.copy(FNBuffer, offset); - path = newName; + // Find a numeric suffix that isn't used by an existing file. + static unsigned FCounter = 0; + do { + sprintf(FNBuffer+offset, "-%06u", FCounter); + if (++FCounter > 999999) + FCounter = 0; + path = FNBuffer; + } while (exists()); } bool @@ -761,6 +766,14 @@ // Make this into a unique file name makeUnique( reuse_current ); + + // Now go and create it + HANDLE h = CreateFile(path.c_str(), GENERIC_WRITE, 0, NULL, CREATE_NEW, + FILE_ATTRIBUTE_NORMAL, NULL); + if (h == INVALID_HANDLE_VALUE) + return false; + + CloseHandle(h); return true; } From alenhar2 at cs.uiuc.edu Wed Jan 26 21:50:00 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Wed, 26 Jan 2005 21:50:00 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp AlphaInstrInfo.td Message-ID: <200501270350.VAA00451@niobe.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.10 -> 1.11 AlphaInstrInfo.td updated: 1.6 -> 1.7 --- Log message: teach isel about comparison with constants and zero extending bits --- Diffs of the changes: (+136 -112) AlphaISelPattern.cpp | 221 +++++++++++++++++++++++++++------------------------ AlphaInstrInfo.td | 27 +++--- 2 files changed, 136 insertions(+), 112 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.10 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.11 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.10 Wed Jan 26 19:22:48 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Wed Jan 26 21:49:45 2005 @@ -38,31 +38,29 @@ public: AlphaTargetLowering(TargetMachine &TM) : TargetLowering(TM) { // Set up the TargetLowering object. + //I am having problems with shr n ubyte 1 + setShiftAmountType(MVT::i64); //are these needed? + setSetCCResultType(MVT::i64); //are these needed? + addRegisterClass(MVT::i64, Alpha::GPRCRegisterClass); addRegisterClass(MVT::f64, Alpha::FPRCRegisterClass); + addRegisterClass(MVT::f32, Alpha::FPRCRegisterClass); - setOperationAction(ISD::EXTLOAD , MVT::i1 , Expand); + setOperationAction(ISD::EXTLOAD , MVT::i1 , Expand); //Should this be Promote? Chris? - setOperationAction(ISD::ZEXTLOAD , MVT::i1 , Expand); + setOperationAction(ISD::ZEXTLOAD , MVT::i1 , Expand); //Should this be Promote? Chris? setOperationAction(ISD::ZEXTLOAD , MVT::i32 , Expand); - setOperationAction(ISD::SEXTLOAD , MVT::i1 , Expand); + setOperationAction(ISD::SEXTLOAD , MVT::i1 , Expand); //Should this be Promote? Chris? setOperationAction(ISD::SEXTLOAD , MVT::i8 , Expand); setOperationAction(ISD::SEXTLOAD , MVT::i16 , Expand); - setOperationAction(ISD::ZERO_EXTEND_INREG, MVT::i1, Expand); - setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i1, Expand); - - // setOperationAction(ISD::UINT_TO_FP , MVT::i64 , Expand); - // setOperationAction(ISD::UINT_TO_FP , MVT::i64 , Expand); - setOperationAction(ISD::SINT_TO_FP , MVT::i1 , Promote); - setOperationAction(ISD::SINT_TO_FP , MVT::i8 , Promote); - setOperationAction(ISD::SINT_TO_FP , MVT::i16 , Promote); - setOperationAction(ISD::SINT_TO_FP , MVT::i32 , Promote); + setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i1, Expand); //what is the sign expansion of 1? 1 or -1? - setOperationAction(ISD::FP_TO_SINT , MVT::f32 , Promote); + setOperationAction(ISD::SREM, MVT::f32, Expand); + setOperationAction(ISD::SREM, MVT::f64, Expand); - computeRegisterProperties(); + computeRegisterProperties(); // addLegalFPImmediate(+0.0); // FLD0 // addLegalFPImmediate(+1.0); // FLD1 @@ -366,7 +364,6 @@ BuildMI(BB, Alpha::LDWU, 2, Result).addImm(0).addReg(Tmp1); break; case MVT::i8: - case MVT::i1: //FIXME: DAG does not expand i8?? BuildMI(BB, Alpha::LDBU, 2, Result).addImm(0).addReg(Tmp1); break; } @@ -393,12 +390,6 @@ case MVT::i32: BuildMI(BB, Alpha::LDL, 2, Result).addImm(0).addReg(Tmp1); break; -// case MVT::i16: -// BuildMI(BB, Alpha::LDW, 2, Result).addImm(0).addReg(Tmp1); -// break; -// case MVT::i8: -// BuildMI(BB, Alpha::LDB, 2, Result).addImm(0).addReg(Tmp1); -// break; } break; } @@ -520,29 +511,31 @@ } case ISD::SIGN_EXTEND: + abort(); + case ISD::SIGN_EXTEND_INREG: { Tmp1 = SelectExpr(N.getOperand(0)); MVTSDNode* MVN = dyn_cast(Node); //std::cerr << "SrcT: " << MVN->getExtraValueType() << "\n"; switch(MVN->getExtraValueType()) - { - default: - Node->dump(); - assert(0 && "Sign Extend InReg not there yet"); - break; - case MVT::i32: - { - BuildMI(BB, Alpha::ADDLi, 2, Result).addReg(Tmp1).addImm(0); - break; - } - case MVT::i16: - BuildMI(BB, Alpha::SEXTW, 1, Result).addReg(Tmp1); - break; - case MVT::i8: - BuildMI(BB, Alpha::SEXTB, 1, Result).addReg(Tmp1); - break; - } + { + default: + Node->dump(); + assert(0 && "Sign Extend InReg not there yet"); + break; + case MVT::i32: + { + BuildMI(BB, Alpha::ADDLi, 2, Result).addReg(Tmp1).addImm(0); + break; + } + case MVT::i16: + BuildMI(BB, Alpha::SEXTW, 1, Result).addReg(Tmp1); + break; + case MVT::i8: + BuildMI(BB, Alpha::SEXTB, 1, Result).addReg(Tmp1); + break; + } return Result; } case ISD::ZERO_EXTEND_INREG: @@ -551,75 +544,103 @@ MVTSDNode* MVN = dyn_cast(Node); //std::cerr << "SrcT: " << MVN->getExtraValueType() << "\n"; switch(MVN->getExtraValueType()) - { - default: - Node->dump(); - assert(0 && "Zero Extend InReg not there yet"); - break; - case MVT::i32: Tmp2 = 0xf0; break; - case MVT::i16: Tmp2 = 0xfc; break; - case MVT::i8: Tmp2 = 0xfe; break; - } + { + default: + Node->dump(); + assert(0 && "Zero Extend InReg not there yet"); + break; + case MVT::i32: Tmp2 = 0xf0; break; + case MVT::i16: Tmp2 = 0xfc; break; + case MVT::i8: Tmp2 = 0xfe; break; + case MVT::i1: //handle this one special + BuildMI(BB, Alpha::ANDi, 2, Result).addReg(Tmp1).addImm(1); + return Result; + } BuildMI(BB, Alpha::ZAPi, 2, Result).addReg(Tmp1).addImm(Tmp2); - return Result; + return Result; } case ISD::SETCC: - Tmp1 = SelectExpr(N.getOperand(0)); - Tmp2 = SelectExpr(N.getOperand(1)); - if (SetCCSDNode *SetCC = dyn_cast(Node)) { - if (MVT::isInteger(SetCC->getOperand(0).getValueType())) { - switch (SetCC->getCondition()) { - default: Node->dump(); assert(0 && "Unknown integer comparison!"); - case ISD::SETEQ: - BuildMI(BB, Alpha::CMPEQ, 2, Result).addReg(Tmp1).addReg(Tmp2); - break; - case ISD::SETGT: - BuildMI(BB, Alpha::CMPLT, 2, Result).addReg(Tmp2).addReg(Tmp1); - break; - case ISD::SETGE: - BuildMI(BB, Alpha::CMPLE, 2, Result).addReg(Tmp2).addReg(Tmp1); - break; - case ISD::SETLT: - BuildMI(BB, Alpha::CMPLT, 2, Result).addReg(Tmp1).addReg(Tmp2); - break; - case ISD::SETLE: - BuildMI(BB, Alpha::CMPLE, 2, Result).addReg(Tmp1).addReg(Tmp2); - break; - case ISD::SETNE: - { - unsigned Tmp3 = MakeReg(MVT::i64); - BuildMI(BB, Alpha::CMPEQ, 2, Tmp3).addReg(Tmp1).addReg(Tmp2); - BuildMI(BB, Alpha::CMPEQ, 2, Result).addReg(Tmp3).addReg(Alpha::R31); - break; - } - case ISD::SETULT: - BuildMI(BB, Alpha::CMPULT, 2, Result).addReg(Tmp1).addReg(Tmp2); - break; - case ISD::SETUGT: - BuildMI(BB, Alpha::CMPULT, 2, Result).addReg(Tmp2).addReg(Tmp1); - break; - case ISD::SETULE: - BuildMI(BB, Alpha::CMPULE, 2, Result).addReg(Tmp1).addReg(Tmp2); - break; - case ISD::SETUGE: - BuildMI(BB, Alpha::CMPULE, 2, Result).addReg(Tmp2).addReg(Tmp1); - break; - } + { + if (SetCCSDNode *SetCC = dyn_cast(Node)) { + if (MVT::isInteger(SetCC->getOperand(0).getValueType())) { + bool isConst1 = false; + bool isConst2 = false; + int dir; + + //Tmp1 = SelectExpr(N.getOperand(0)); + if(N.getOperand(0).getOpcode() == ISD::Constant && + cast(N.getOperand(0))->getValue() >= 0 && + cast(N.getOperand(0))->getValue() <= 255) + isConst1 = true; + if(N.getOperand(1).getOpcode() == ISD::Constant && + cast(N.getOperand(1))->getValue() >= 0 && + cast(N.getOperand(1))->getValue() <= 255) + isConst2 = true; + + switch (SetCC->getCondition()) { + default: Node->dump(); assert(0 && "Unknown integer comparison!"); + case ISD::SETEQ: Opc = Alpha::CMPEQ; dir=0; break; + case ISD::SETLT: Opc = isConst2 ? Alpha::CMPLTi : Alpha::CMPLT; dir = 1; break; + case ISD::SETLE: Opc = isConst2 ? Alpha::CMPLEi : Alpha::CMPLE; dir = 1; break; + case ISD::SETGT: Opc = isConst1 ? Alpha::CMPLTi : Alpha::CMPLT; dir = 2; break; + case ISD::SETGE: Opc = isConst1 ? Alpha::CMPLEi : Alpha::CMPLE; dir = 2; break; + case ISD::SETULT: Opc = isConst2 ? Alpha::CMPULTi : Alpha::CMPULT; dir = 1; break; + case ISD::SETUGT: Opc = isConst1 ? Alpha::CMPULTi : Alpha::CMPULT; dir = 2; break; + case ISD::SETULE: Opc = isConst2 ? Alpha::CMPULEi : Alpha::CMPULE; dir = 1; break; + case ISD::SETUGE: Opc = isConst1 ? Alpha::CMPULEi : Alpha::CMPULE; dir = 2; break; + case ISD::SETNE: + std::cerr << "Alpha does not have a setne.\n"; + abort(); + } + if (dir == 1) { + Tmp1 = SelectExpr(N.getOperand(0)); + if (isConst2) { + Tmp2 = cast(N.getOperand(1))->getValue(); + BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addImm(Tmp2); + } else { + Tmp2 = SelectExpr(N.getOperand(1)); + BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); + } + } else if (dir == 2) { + Tmp1 = SelectExpr(N.getOperand(1)); + if (isConst2) { + Tmp2 = cast(N.getOperand(0))->getValue(); + BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addImm(Tmp2); + } else { + Tmp2 = SelectExpr(N.getOperand(0)); + BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); + } + } else { //dir == 0 + if (isConst1) { + Tmp1 = cast(N.getOperand(0))->getValue(); + Tmp2 = SelectExpr(N.getOperand(1)); + BuildMI(BB, Alpha::CMPEQi, 2, Result).addReg(Tmp2).addImm(Tmp1); + } else if (isConst2) { + Tmp1 = SelectExpr(N.getOperand(0)); + Tmp2 = cast(N.getOperand(1))->getValue(); + BuildMI(BB, Alpha::CMPEQi, 2, Result).addReg(Tmp1).addImm(Tmp2); + } else { + Tmp1 = SelectExpr(N.getOperand(0)); + Tmp2 = SelectExpr(N.getOperand(1)); + BuildMI(BB, Alpha::CMPEQ, 2, Result).addReg(Tmp1).addReg(Tmp2); + } + } + } + else + { + Node->dump(); + assert(0 && "only integer"); + } } else - { - Node->dump(); - assert(0 && "only integer"); - } + { + Node->dump(); + assert(0 && "Not a setcc in setcc"); + } + return Result; } - else - { - Node->dump(); - assert(0 && "Not a setcc in setcc"); - } - return Result; - + case ISD::CopyFromReg: { if (Result == 1) Index: llvm/lib/Target/Alpha/AlphaInstrInfo.td diff -u llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.6 llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.7 --- llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.6 Wed Jan 26 17:56:48 2005 +++ llvm/lib/Target/Alpha/AlphaInstrInfo.td Wed Jan 26 21:49:45 2005 @@ -113,18 +113,6 @@ def BICi : OFormL<0x11, 0x08, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "BIC $RA,$L,$RC">; //Bit clear def BIS : OForm< 0x11, 0x20, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "bis $RA,$RB,$RC">; //Logical sum def BISi : OFormL<0x11, 0x20, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "bis $RA,$L,$RC">; //Logical sum -def CMPBGE : OForm< 0x10, 0x0F, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CMPBGE $RA,$RB,$RC">; //Compare byte -def CMPBGEi : OFormL<0x10, 0x0F, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "CMPBGE $RA,$L,$RC">; //Compare byte -def CMPEQ : OForm< 0x10, 0x2D, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CMPEQ $RA,$RB,$RC">; //Compare signed quadword equal -def CMPEQi : OFormL<0x10, 0x2D, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "CMPEQ $RA,$L,$RC">; //Compare signed quadword equal -def CMPLE : OForm< 0x10, 0x6D, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CMPLE $RA,$RB,$RC">; //Compare signed quadword less than or equal -def CMPLEi : OFormL<0x10, 0x6D, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "CMPLE $RA,$L,$RC">; //Compare signed quadword less than or equal -def CMPLT : OForm< 0x10, 0x4D, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CMPLT $RA,$RB,$RC">; //Compare signed quadword less than -def CMPLTi : OFormL<0x10, 0x4D, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "CMPLT $RA,$L,$RC">; //Compare signed quadword less than -def CMPULE : OForm< 0x10, 0x3D, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CMPULE $RA,$RB,$RC">; //Compare unsigned quadword less than or equal -def CMPULEi : OFormL<0x10, 0x3D, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "CMPULE $RA,$L,$RC">; //Compare unsigned quadword less than or equal -def CMPULT : OForm< 0x10, 0x1D, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CMPULT $RA,$RB,$RC">; //Compare unsigned quadword less than -def CMPULTi : OFormL<0x10, 0x1D, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "CMPULT $RA,$L,$RC">; //Compare unsigned quadword less than def CTLZ : OForm< 0x1C, 0x32, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CTLZ $RA,$RB,$RC">; //Count leading zero def CTLZi : OFormL<0x1C, 0x32, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "CTLZ $RA,$L,$RC">; //Count leading zero def CTPOP : OForm< 0x1C, 0x30, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CTPOP $RA,$RB,$RC">; //Count population @@ -222,6 +210,21 @@ def ZAPNOT : OForm< 0x12, 0x31, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "ZAPNOT $RA,$RB,$RC">; //Zero bytes not def ZAPNOTi : OFormL<0x12, 0x31, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "ZAPNOT $RA,$L,$RC">; //Zero bytes not +//Comparison, int +def CMPBGE : OForm< 0x10, 0x0F, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CMPBGE $RA,$RB,$RC">; //Compare byte +def CMPBGEi : OFormL<0x10, 0x0F, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "CMPBGE $RA,$L,$RC">; //Compare byte +def CMPEQ : OForm< 0x10, 0x2D, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CMPEQ $RA,$RB,$RC">; //Compare signed quadword equal +def CMPEQi : OFormL<0x10, 0x2D, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "CMPEQ $RA,$L,$RC">; //Compare signed quadword equal +def CMPLE : OForm< 0x10, 0x6D, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CMPLE $RA,$RB,$RC">; //Compare signed quadword less than or equal +def CMPLEi : OFormL<0x10, 0x6D, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "CMPLE $RA,$L,$RC">; //Compare signed quadword less than or equal +def CMPLT : OForm< 0x10, 0x4D, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CMPLT $RA,$RB,$RC">; //Compare signed quadword less than +def CMPLTi : OFormL<0x10, 0x4D, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "CMPLT $RA,$L,$RC">; //Compare signed quadword less than +def CMPULE : OForm< 0x10, 0x3D, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CMPULE $RA,$RB,$RC">; //Compare unsigned quadword less than or equal +def CMPULEi : OFormL<0x10, 0x3D, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "CMPULE $RA,$L,$RC">; //Compare unsigned quadword less than or equal +def CMPULT : OForm< 0x10, 0x1D, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "CMPULT $RA,$RB,$RC">; //Compare unsigned quadword less than +def CMPULTi : OFormL<0x10, 0x1D, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "CMPULT $RA,$L,$RC">; //Compare unsigned quadword less than + + //There are in the Multimedia extentions, so let's not use them yet def MAXSB8 : OForm<0x1C, 0x3E, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "MAXSB8 $RA,$RB,$RC">; //Vector signed byte maximum def MAXSW4 : OForm< 0x1C, 0x3F, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "MAXSW4 $RA,$RB,$RC">; //Vector signed word maximum From brukman at cs.uiuc.edu Thu Jan 27 00:46:49 2005 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Thu, 27 Jan 2005 00:46:49 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp Instructions.cpp Message-ID: <200501270646.AAA07126@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Constants.cpp updated: 1.119 -> 1.120 Instructions.cpp updated: 1.7 -> 1.8 --- Log message: Fix grammar --- Diffs of the changes: (+2 -2) Constants.cpp | 2 +- Instructions.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/lib/VMCore/Constants.cpp diff -u llvm/lib/VMCore/Constants.cpp:1.119 llvm/lib/VMCore/Constants.cpp:1.120 --- llvm/lib/VMCore/Constants.cpp:1.119 Sat Jan 1 09:59:57 2005 +++ llvm/lib/VMCore/Constants.cpp Thu Jan 27 00:46:38 2005 @@ -1306,7 +1306,7 @@ case Instruction::Xor: assert(C1->getType() == C2->getType() && "Op types should be identical!"); assert(C1->getType()->isIntegral() && - "Tried to create an logical operation on a non-integral type!"); + "Tried to create a logical operation on a non-integral type!"); break; case Instruction::SetLT: case Instruction::SetGT: case Instruction::SetLE: case Instruction::SetGE: case Instruction::SetEQ: case Instruction::SetNE: Index: llvm/lib/VMCore/Instructions.cpp diff -u llvm/lib/VMCore/Instructions.cpp:1.7 llvm/lib/VMCore/Instructions.cpp:1.8 --- llvm/lib/VMCore/Instructions.cpp:1.7 Thu Nov 18 11:47:13 2004 +++ llvm/lib/VMCore/Instructions.cpp Thu Jan 27 00:46:38 2005 @@ -561,7 +561,7 @@ assert(getType() == S1->getType() && "Logical operation should return same type as operands!"); assert(getType()->isIntegral() && - "Tried to create an logical operation on a non-integral type!"); + "Tried to create a logical operation on a non-integral type!"); break; case SetLT: case SetGT: case SetLE: case SetGE: case SetEQ: case SetNE: From alenhar2 at cs.uiuc.edu Thu Jan 27 01:50:49 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Thu, 27 Jan 2005 01:50:49 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp AlphaInstrInfo.td Message-ID: <200501270750.BAA00687@niobe.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.11 -> 1.12 AlphaInstrInfo.td updated: 1.7 -> 1.8 --- Log message: int to float conversion and another setcc --- Diffs of the changes: (+54 -32) AlphaISelPattern.cpp | 70 +++++++++++++++++++++++++++++++++------------------ AlphaInstrInfo.td | 16 +++++------ 2 files changed, 54 insertions(+), 32 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.11 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.12 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.11 Wed Jan 26 21:49:45 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Thu Jan 27 01:50:35 2005 @@ -46,7 +46,7 @@ addRegisterClass(MVT::f64, Alpha::FPRCRegisterClass); addRegisterClass(MVT::f32, Alpha::FPRCRegisterClass); - setOperationAction(ISD::EXTLOAD , MVT::i1 , Expand); //Should this be Promote? Chris? + setOperationAction(ISD::EXTLOAD , MVT::i1 , Promote); setOperationAction(ISD::ZEXTLOAD , MVT::i1 , Expand); //Should this be Promote? Chris? setOperationAction(ISD::ZEXTLOAD , MVT::i32 , Expand); @@ -62,10 +62,7 @@ computeRegisterProperties(); - // addLegalFPImmediate(+0.0); // FLD0 - // addLegalFPImmediate(+1.0); // FLD1 - // addLegalFPImmediate(-0.0); // FLD0/FCHS - // addLegalFPImmediate(-1.0); // FLD1/FCHS + addLegalFPImmediate(+0.0); //F31 } /// LowerArguments - This hook must be implemented to indicate how we should @@ -209,13 +206,13 @@ case MVT::i8: case MVT::i16: case MVT::i32: - // Promote the integer to 64 bits. If the input type is signed use a - // sign extend, otherwise use a zero extend. - if (Args[i].second->isSigned()) - Args[i].first = DAG.getNode(ISD::SIGN_EXTEND_INREG, MVT::i64, Args[i].first); - else - Args[i].first = DAG.getNode(ISD::ZERO_EXTEND_INREG, MVT::i64, Args[i].first); - break; + // Promote the integer to 64 bits. If the input type is signed use a + // sign extend, otherwise use a zero extend. + if (Args[i].second->isSigned()) + Args[i].first = DAG.getNode(ISD::SIGN_EXTEND_INREG, MVT::i64, Args[i].first); + else + Args[i].first = DAG.getNode(ISD::ZERO_EXTEND_INREG, MVT::i64, Args[i].first); + break; case MVT::i64: break; case MVT::f64: @@ -332,6 +329,17 @@ Node->dump(); assert(0 && "Node not handled!\n"); + case ISD::ConstantFP: + if (ConstantFPSDNode *CN = dyn_cast(N)) { + if (CN->isExactlyValue(+0.0) || + CN->isExactlyValue(-0.0)) { + BuildMI(BB, Alpha::CPYS, 2, Result).addReg(R31).addReg(R31); + } else { + abort(); + } + } + return Result; + case ISD::FrameIndex: Tmp1 = cast(N)->getIndex(); BuildMI(BB, Alpha::LDA, 2, Result).addImm(Tmp1 * 8).addReg(Alpha::R30); @@ -363,6 +371,7 @@ case MVT::i16: BuildMI(BB, Alpha::LDWU, 2, Result).addImm(0).addReg(Tmp1); break; + case MVT::i1: //Treat i1 as i8 since there are problems otherwise case MVT::i8: BuildMI(BB, Alpha::LDBU, 2, Result).addImm(0).addReg(Tmp1); break; @@ -589,10 +598,18 @@ case ISD::SETUGT: Opc = isConst1 ? Alpha::CMPULTi : Alpha::CMPULT; dir = 2; break; case ISD::SETULE: Opc = isConst2 ? Alpha::CMPULEi : Alpha::CMPULE; dir = 1; break; case ISD::SETUGE: Opc = isConst1 ? Alpha::CMPULEi : Alpha::CMPULE; dir = 2; break; - case ISD::SETNE: - std::cerr << "Alpha does not have a setne.\n"; - abort(); - } + case ISD::SETNE: {//Handle this one special + //std::cerr << "Alpha does not have a setne.\n"; + //abort(); + Tmp1 = SelectExpr(N.getOperand(0)); + Tmp2 = SelectExpr(N.getOperand(1)); + Tmp3 = MakeReg(MVT::i64); + BuildMI(BB, Alpha::CMPEQ, 2, Tmp3).addReg(Tmp1).addReg(Tmp2); + //and invert + BuildMI(BB,Alpha::ORNOT, 2, Result).addReg(Alpha::R31).addReg(Tmp3); + return Result; + } + } if (dir == 1) { Tmp1 = SelectExpr(N.getOperand(0)); if (isConst2) { @@ -796,14 +813,19 @@ BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); return Result; -// case ISD::SINT_TO_FP: -// MVT::ValueType DestTy = N.getValueType(); -// Tmp1 = SelectExpr(N.getOperand(0)); // Get the operand register -// Tmp2 = MakeReg(DestTy); -// Opc = DestTy == MVT::f64 ? ITOFT : ITOFS; -// BuildMI(BB, Opc, 1, Tmp2).addReg(Tmp1); -// Opc = DestTy == MVT::f64 ? CVTQT : CVTQS; -// BuildMI(BB, Opc, 1, Result).addReg(Tmp1); + case ISD::SINT_TO_FP: + { + MVT::ValueType DestTy = N.getValueType(); + assert (N.getOperand(0).getValueType() == MVT::i64 && "only quads can be loaded from"); + Tmp1 = SelectExpr(N.getOperand(0)); // Get the operand register + Tmp2 = MakeReg(DestTy); + Opc = DestTy == MVT::f64 ? Alpha::ITOFT : Alpha::ITOFS; + BuildMI(BB, Opc, 1, Tmp2).addReg(Tmp1); + Opc = DestTy == MVT::f64 ? Alpha::CVTQT : Alpha::CVTQS; + BuildMI(BB, Opc, 1, Result).addReg(Tmp1); + return Result; + } + // // case ISD::UINT_TO_FP: // case ISD::FP_TO_SINT: Index: llvm/lib/Target/Alpha/AlphaInstrInfo.td diff -u llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.7 llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.8 --- llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.7 Wed Jan 26 21:49:45 2005 +++ llvm/lib/Target/Alpha/AlphaInstrInfo.td Thu Jan 27 01:50:35 2005 @@ -322,6 +322,14 @@ def ITOFS : FPForm<0x14, 0x004, (ops FPRC:$RC, GPRC:$RA), "itofs $RA,$RC">; //Integer to floating move, S_floating def ITOFT : FPForm<0x14, 0x024, (ops FPRC:$RC, GPRC:$RA), "itoft $RA,$RC">; //Integer to floating move, T_floating +//CVTLQ F-P 17.010 Convert longword to quadword +//CVTQL F-P 17.030 Convert quadword to longword +def CVTQS : FPForm<0x16, 0x0BC, (ops FPRC:$RC, FPRC:$RA), "cvtqs $RA,$RC">; //Convert quadword to S_floating +def CVTQT : FPForm<0x16, 0x0BE, (ops FPRC:$RC, FPRC:$RA), "cvtqt $RA,$RC">; //Convert quadword to T_floating +//CVTST F-P 16.2AC Convert S_floating to T_floating +//CVTTQ F-P 16.0AF Convert T_floating to quadword +//CVTTS F-P 16.0AC Convert T_floating to S_floating + //S_floating : IEEE Single //T_floating : IEEE Double @@ -354,14 +362,6 @@ //CMPTLT F-P 16.0A6 Compare T_floating less than //CMPTUN F-P 16.0A4 Compare T_floating unordered -//CVTLQ F-P 17.010 Convert longword to quadword -//CVTQL F-P 17.030 Convert quadword to longword -//CVTQS F-P 16.0BC Convert quadword to S_floating -//CVTQT F-P 16.0BE Convert quadword to T_floating -//CVTST F-P 16.2AC Convert S_floating to T_floating -//CVTTQ F-P 16.0AF Convert T_floating to quadword -//CVTTS F-P 16.0AC Convert T_floating to S_floating - //FCMOVEQ F-P 17.02A FCMOVE if = zero //FCMOVGE F-P 17.02D FCMOVE if >= zero //FCMOVGT F-P 17.02F FCMOVE if > zero From alenhar2 at cs.uiuc.edu Thu Jan 27 01:58:27 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Thu, 27 Jan 2005 01:58:27 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp Message-ID: <200501270758.BAA00722@niobe.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.12 -> 1.13 --- Log message: Floating point instructions like Floating point registers --- 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.12 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.13 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.12 Thu Jan 27 01:50:35 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Thu Jan 27 01:58:15 2005 @@ -333,7 +333,7 @@ if (ConstantFPSDNode *CN = dyn_cast(N)) { if (CN->isExactlyValue(+0.0) || CN->isExactlyValue(-0.0)) { - BuildMI(BB, Alpha::CPYS, 2, Result).addReg(R31).addReg(R31); + BuildMI(BB, Alpha::CPYS, 2, Result).addReg(Alpha::F31).addReg(Alpha::F31); } else { abort(); } From alenhar2 at cs.uiuc.edu Thu Jan 27 02:31:32 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Thu, 27 Jan 2005 02:31:32 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp AlphaRegisterInfo.td Message-ID: <200501270831.CAA00790@niobe.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaRegisterInfo.cpp updated: 1.3 -> 1.4 AlphaRegisterInfo.td updated: 1.1 -> 1.2 --- Log message: stack frame fix and zero FP reg fix --- Diffs of the changes: (+19 -12) AlphaRegisterInfo.cpp | 27 +++++++++++++++++---------- AlphaRegisterInfo.td | 4 ++-- 2 files changed, 19 insertions(+), 12 deletions(-) Index: llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp diff -u llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.3 llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.4 --- llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.3 Wed Jan 26 15:54:09 2005 +++ llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp Thu Jan 27 02:31:19 2005 @@ -208,7 +208,7 @@ if (NumBytes <= 32767) { MI=BuildMI(Alpha::LDA, 2, Alpha::R30).addImm(-NumBytes).addReg(Alpha::R30); MBB.insert(MBBI, MI); - } else if (NumBytes <= 32767 * 65536) { + } else if ((unsigned long)NumBytes <= (unsigned long)32767 * (unsigned long)65536) { long y = NumBytes / 65536; if (NumBytes % 65536 > 32767) ++y; @@ -217,7 +217,7 @@ MI=BuildMI(Alpha::LDA, 2, Alpha::R30).addImm(-(NumBytes - y * 65536)).addReg(Alpha::R30); MBB.insert(MBBI, MI); } else { - std::cerr << "Too big a stack frame\n"; + std::cerr << "Too big a stack frame at " << NumBytes << "\n"; abort(); } } @@ -235,14 +235,21 @@ if (NumBytes != 0) { - if (NumBytes <= 32000) //FIXME: do this better - { - MI=BuildMI(Alpha::LDA, 2, Alpha::R30).addImm(NumBytes).addReg(Alpha::R30); - MBB.insert(MBBI, MI); - } else { - std::cerr << "Too big a stack frame\n"; - abort(); - } + if (NumBytes <= 32767) { + MI=BuildMI(Alpha::LDA, 2, Alpha::R30).addImm(NumBytes).addReg(Alpha::R30); + MBB.insert(MBBI, MI); + } else if ((unsigned long)NumBytes <= (unsigned long)32767 * (unsigned long)65536) { + long y = NumBytes / 65536; + if (NumBytes % 65536 > 32767) + ++y; + MI=BuildMI(Alpha::LDAH, 2, Alpha::R30).addImm(y).addReg(Alpha::R30); + MBB.insert(MBBI, MI); + MI=BuildMI(Alpha::LDA, 2, Alpha::R30).addImm(NumBytes - y * 65536).addReg(Alpha::R30); + MBB.insert(MBBI, MI); + } else { + std::cerr << "Too big a stack frame at " << NumBytes << "\n"; + abort(); + } } } Index: llvm/lib/Target/Alpha/AlphaRegisterInfo.td diff -u llvm/lib/Target/Alpha/AlphaRegisterInfo.td:1.1 llvm/lib/Target/Alpha/AlphaRegisterInfo.td:1.2 --- llvm/lib/Target/Alpha/AlphaRegisterInfo.td:1.1 Sat Jan 22 17:41:55 2005 +++ llvm/lib/Target/Alpha/AlphaRegisterInfo.td Thu Jan 27 02:31:19 2005 @@ -81,13 +81,13 @@ //Volitle [R0, R1, R2, R3, R4, R5, R6, R7, R8, R16, R17, R18, R19, R20, R21, R22, R23, R24, R25, R27, //Non-Volitile - R9, R10, R11, R12, R13, R14, R15, R26, /*R28,*/ R29, R30, R31]>; + R9, R10, R11, R12, R13, R14, R15, R26, /*R28,*/ R29, R30 /*, R31*/ ]>; //R28 is reserved for the assembler //Don't allocate 15, 29, 30, 31 //Allocation volatiles only for now def FPRC : RegisterClass; + F20, F21, F22, F23, F24, F25, F26, F27, F28, F29, F30]>; From brukman at cs.uiuc.edu Thu Jan 27 12:00:02 2005 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Thu, 27 Jan 2005 12:00:02 -0600 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200501271800.MAA07253@zion.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.288 -> 1.289 --- Log message: Mark -parallel pass as `experimental' --- Diffs of the changes: (+2 -2) ReleaseNotes.html | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.288 llvm/docs/ReleaseNotes.html:1.289 --- llvm/docs/ReleaseNotes.html:1.288 Sat Jan 22 12:45:35 2005 +++ llvm/docs/ReleaseNotes.html Thu Jan 27 11:59:51 2005 @@ -208,7 +208,7 @@
  • The following passes are incomplete or buggy, and may be removed in future releases: -pgmdep, -memdep, -ipmodref, -cee, -branch-combine, - -instloops, -paths, -pre
  • + -instloops, -parallel, -paths, -pre
  • The llvm-db tool is in a very early stage of development, but can be used to step through programs and inspect the stack.
  • The "iterative scan" register allocator (enabled with -regalloc=iterativescan) @@ -566,7 +566,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2005/01/22 18:45:35 $ + Last modified: $Date: 2005/01/27 17:59:51 $ From alkis at cs.uiuc.edu Thu Jan 27 13:18:05 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu, 27 Jan 2005 13:18:05 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200501271918.NAA03215@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.200 -> 1.201 --- Log message: Make ClassInfo a class and its members private. --- Diffs of the changes: (+74 -63) Compiler.cpp | 137 +++++++++++++++++++++++++++++++---------------------------- 1 files changed, 74 insertions(+), 63 deletions(-) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.200 llvm-java/lib/Compiler/Compiler.cpp:1.201 --- llvm-java/lib/Compiler/Compiler.cpp:1.200 Tue Jan 25 17:46:34 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Thu Jan 27 13:17:54 2005 @@ -83,15 +83,29 @@ /// represents an interface. It also contains a map from fields to /// struct indices for this class (used to index into the class /// object). - struct ClassInfo { - ClassInfo() : type(NULL), interfaceIdx(0) { } - - Type* type; - unsigned interfaceIdx; - typedef std::map Field2IndexMap; - Field2IndexMap f2iMap; + class ClassInfo { + Type* type_; + unsigned interfaceIdx_; + typedef std::map Field2IndexMap; + Field2IndexMap f2iMap_; + public: static unsigned InterfaceCount; + + public: + ClassInfo() : type_(NULL), interfaceIdx_(0) { } + void setType(Type* type) { type_ = type; } + Type* getType() { return type_; } + const Type* getType() const { return type_; } + void addField(const std::string& name, int slot) { + f2iMap_.insert(std::make_pair(name, slot)); + } + int getFieldIndex(const std::string& name) const { + Field2IndexMap::const_iterator it = f2iMap_.find(name); + return it == f2iMap_.end() ? -1 : it->second; + } + unsigned getInterfaceIndex() const { return interfaceIdx_; } + void setInterfaceIndex(unsigned index) { interfaceIdx_ = index; } }; typedef std::map Class2ClassInfoMap; Class2ClassInfoMap c2ciMap_; @@ -169,7 +183,7 @@ // FIXME: should return a String object represeting this ConstantString return ConstantPointerNull::get( PointerType::get( - getClassInfo(ClassFile::get("java/lang/String")).type)); + getClassInfo(ClassFile::get("java/lang/String")).getType())); else if (ConstantInteger* i = dynamic_cast(c)) return ConstantSInt::get(Type::IntTy, i->getValue()); else if (ConstantFloat* f = dynamic_cast(c)) @@ -298,38 +312,37 @@ module_.addTypeName(LLVM_JAVA_OBJECT_BASE, ObjectBaseTy); - assert(!ci.type && ci.f2iMap.empty() && + assert(!ci.getType() && "java/lang/Object ClassInfo should not be initialized!"); - ci.type = OpaqueType::get(); + ci.setType(OpaqueType::get()); std::vector elements; // Because this is java/lang/Object, we add the opaque // llvm_java_object_base type first. - ci.f2iMap.insert(std::make_pair(LLVM_JAVA_OBJECT_BASE, elements.size())); + ci.addField(LLVM_JAVA_OBJECT_BASE, elements.size()); elements.push_back(ObjectBaseTy); const Fields& fields = cf->getFields(); for (unsigned i = 0, e = fields.size(); i != e; ++i) { Field* field = fields[i]; if (!field->isStatic()) { - ci.f2iMap.insert( - std::make_pair(field->getName()->str(), elements.size())); + ci.addField(field->getName()->str(), elements.size()); elements.push_back(getType(field->getDescriptor())); } } - PATypeHolder holder = ci.type; - cast(ci.type)-> + PATypeHolder holder = ci.getType(); + cast(ci.getType())-> refineAbstractTypeTo(StructType::get(elements)); - ci.type = holder.get(); + ci.setType(holder.get()); DEBUG(std::cerr << "Adding java/lang/Object = " - << *ci.type << " to type map\n"); - module_.addTypeName("java/lang/Object", ci.type); + << *ci.getType() << " to type map\n"); + module_.addTypeName("java/lang/Object", ci.getType()); - assert(ci.type && "ClassInfo not initialized properly!"); + assert(ci.getType() && "ClassInfo not initialized properly!"); emitStaticInitializers(cf); DEBUG(std::cerr << "Built ClassInfo for: java/lang/Object\n"); return true; @@ -442,39 +455,38 @@ DEBUG(std::cerr << "Building ClassInfo for: " << className << '\n'); ClassInfo& ci = c2ciMap_[cf]; - assert(!ci.type && ci.f2iMap.empty() && - "got already initialized ClassInfo!"); + assert(!ci.getType() && "got already initialized ClassInfo!"); // Get the interface id. if (cf->isInterface()) - ci.interfaceIdx = ClassInfo::InterfaceCount++; + ci.setInterfaceIndex(ClassInfo::InterfaceCount++); - ci.type = OpaqueType::get(); + ci.setType(OpaqueType::get()); std::vector elements; ConstantClass* super = cf->getSuperClass(); assert(super && "Class does not have superclass!"); const ClassInfo& superCI = getClassInfo(ClassFile::get(super->getName()->str())); - elements.push_back(superCI.type); + elements.push_back(superCI.getType()); const Fields& fields = cf->getFields(); for (unsigned i = 0, e = fields.size(); i != e; ++i) { Field* field = fields[i]; if (!field->isStatic()) { - ci.f2iMap.insert( - std::make_pair(field->getName()->str(), elements.size())); + ci.addField(field->getName()->str(), elements.size()); elements.push_back(getType(field->getDescriptor())); } } - PATypeHolder holder = ci.type; - cast(ci.type)->refineAbstractTypeTo(StructType::get(elements)); - ci.type = holder.get(); + PATypeHolder holder = ci.getType(); + cast(ci.getType())-> + refineAbstractTypeTo(StructType::get(elements)); + ci.setType(holder.get()); - assert(ci.type && "ClassInfo not initialized properly!"); + assert(ci.getType() && "ClassInfo not initialized properly!"); DEBUG(std::cerr << "Adding " << className << " = " - << *ci.type << " to type map\n"); - module_.addTypeName(className, ci.type); + << *ci.getType() << " to type map\n"); + module_.addTypeName(className, ci.getType()); emitStaticInitializers(cf); DEBUG(std::cerr << "Built ClassInfo for: " << className << '\n'); return ci; @@ -489,11 +501,11 @@ elements.reserve(3); elements.push_back(ObjectBaseTy); elements.push_back(Type::UIntTy); - arrayInfo.f2iMap.insert(std::make_pair("", elements.size())); + arrayInfo.addField("", elements.size()); elements.push_back(ArrayType::get(elementTy, 0)); - arrayInfo.f2iMap.insert(std::make_pair("", elements.size())); + arrayInfo.addField("", elements.size()); - arrayInfo.type = StructType::get(elements); + arrayInfo.setType(StructType::get(elements)); return arrayInfo; } @@ -648,11 +660,11 @@ assert(ifaceCf->isInterface() && "Classfile must be an interface!"); const ClassInfo& ifaceCi = getClassInfo(ifaceCf); - if (ifaceCi.interfaceIdx >= vtables.size()) - vtables.resize(ifaceCi.interfaceIdx+1, nullVTable); + if (ifaceCi.getInterfaceIndex() >= vtables.size()) + vtables.resize(ifaceCi.getInterfaceIndex()+1, nullVTable); // Add this interface's vtable if it was not added before. - if (vtables[ifaceCi.interfaceIdx] == nullVTable) { - vtables[ifaceCi.interfaceIdx] = buildInterfaceVTable(cf, ifaceCf); + if (vtables[ifaceCi.getInterfaceIndex()] == nullVTable) { + vtables[ifaceCi.getInterfaceIndex()] = buildInterfaceVTable(cf, ifaceCf); const Classes& interfaces = ifaceCf->getInterfaces(); for (unsigned i = 0, e = interfaces.size(); i != e; ++i) { ClassFile* otherCf = ClassFile::get(interfaces[i]->getName()->str()); @@ -672,7 +684,7 @@ // value. if (cf->isInterface()) return std::make_pair( - getClassInfo(cf).interfaceIdx, + getClassInfo(cf).getInterfaceIndex(), ConstantExpr::getCast( ConstantIntegral::getAllOnesValue(Type::LongTy), PointerType::get(PointerType::get(VTableInfo::VTableTy)))); @@ -1212,21 +1224,20 @@ /// pointer to an object. Value* getField(ClassFile* cf, const std::string& fieldName, Value* ptr) { // Cast ptr to correct type. - ptr = new CastInst(ptr, PointerType::get(getClassInfo(cf).type), + ptr = new CastInst(ptr, PointerType::get(getClassInfo(cf).getType()), TMP, currentBB_); // Deref pointer. std::vector indices(1, ConstantUInt::get(Type::UIntTy, 0)); while (true) { const ClassInfo& info = getClassInfo(cf); - ClassInfo::Field2IndexMap::const_iterator it = - info.f2iMap.find(fieldName); - if (it == info.f2iMap.end()) { + int slot = info.getFieldIndex(fieldName); + if (slot == -1) { cf = ClassFile::get(cf->getSuperClass()->getName()->str()); indices.push_back(ConstantUInt::get(Type::UIntTy, 0)); } else { - indices.push_back(ConstantUInt::get(Type::UIntTy, it->second)); + indices.push_back(ConstantUInt::get(Type::UIntTy, slot)); break; } } @@ -1582,16 +1593,16 @@ push(val); } - void do_iaload() { do_aload_common(getPrimitiveArrayInfo(INT).type); } - void do_laload() { do_aload_common(getPrimitiveArrayInfo(LONG).type); } - void do_faload() { do_aload_common(getPrimitiveArrayInfo(FLOAT).type); } - void do_daload() { do_aload_common(getPrimitiveArrayInfo(DOUBLE).type); } - void do_aaload() { do_aload_common(getObjectArrayInfo().type); } - void do_baload() { do_aload_common(getPrimitiveArrayInfo(BYTE).type); } - void do_caload() { do_aload_common(getPrimitiveArrayInfo(CHAR).type); } - void do_saload() { do_aload_common(getPrimitiveArrayInfo(SHORT).type); } + void do_iaload() { do_aload_common(getPrimitiveArrayInfo(INT).getType()); } + void do_laload() { do_aload_common(getPrimitiveArrayInfo(LONG).getType()); } + void do_faload() { do_aload_common(getPrimitiveArrayInfo(FLOAT).getType()); } + void do_daload() { do_aload_common(getPrimitiveArrayInfo(DOUBLE).getType()); } + void do_aaload() { do_aload_common(getObjectArrayInfo().getType()); } + void do_baload() { do_aload_common(getPrimitiveArrayInfo(BYTE).getType()); } + void do_caload() { do_aload_common(getPrimitiveArrayInfo(CHAR).getType()); } + void do_saload() { do_aload_common(getPrimitiveArrayInfo(SHORT).getType()); } - void do_aload_common(Type* arrayTy) { + void do_aload_common(const Type* arrayTy) { Value* index = pop(Type::IntTy); Value* arrayRef = pop(PointerType::get(arrayTy)); @@ -1629,7 +1640,7 @@ void do_astore_common(const Type* elementTy) { Value* value = pop(elementTy); Value* index = pop(Type::IntTy); - const Type* arrayRefTy = PointerType::get(getArrayInfo(elementTy).type); + const Type* arrayRefTy = PointerType::get(getArrayInfo(elementTy).getType()); Value* arrayRef = pop(arrayRefTy); std::vector indices; @@ -2051,7 +2062,7 @@ std::vector params(getParams(funTy)); Value* objRef = params.front(); - objRef = new CastInst(objRef, PointerType::get(ci->type), + objRef = new CastInst(objRef, PointerType::get(ci->getType()), "this", currentBB_); Value* objBase = new CastInst(objRef, ObjectBaseRefTy, TMP, currentBB_); @@ -2131,7 +2142,7 @@ std::vector params(getParams(funTy)); Value* objRef = params.front(); - objRef = new CastInst(objRef, PointerType::get(ci->type), + objRef = new CastInst(objRef, PointerType::get(ci->getType()), "this", currentBB_); Value* objBase = new CastInst(objRef, ObjectBaseRefTy, TMP, currentBB_); @@ -2146,7 +2157,7 @@ interfaceVTables = new LoadInst(interfaceVTables, TMP, currentBB_); // Get the actual interface vtable. indices.clear(); - indices.push_back(ConstantUInt::get(Type::UIntTy, ci->interfaceIdx)); + indices.push_back(ConstantUInt::get(Type::UIntTy, ci->getInterfaceIndex())); Value* interfaceVTable = new GetElementPtrInst(interfaceVTables, indices, TMP, currentBB_); interfaceVTable = @@ -2174,7 +2185,7 @@ const ClassInfo& ci = getClassInfo(cf); const VTableInfo& vi = getVTableInfo(cf); - Value* objRef = new MallocInst(ci.type, NULL, TMP, currentBB_); + Value* objRef = new MallocInst(ci.getType(), NULL, TMP, currentBB_); Value* objBase = new CastInst(objRef, ObjectBaseRefTy, TMP, currentBB_); Value* vtable = new CastInst(vi.vtable, VTableBaseRefTy, @@ -2219,7 +2230,7 @@ const ClassInfo& ei = getClassInfo(cf); const VTableInfo& vi = getObjectArrayVTableInfo(cf); - do_newarray_common(ci, PointerType::get(ei.type), vi, count); + do_newarray_common(ci, PointerType::get(ei.getType()), vi, count); } void do_newarray_common(const ClassInfo& ci, @@ -2235,14 +2246,14 @@ Instruction::Mul, count, elementSize, TMP, currentBB_); // The size of the rest of the array object. llvm::Constant* arrayObjectSize = - ConstantExpr::getCast(ConstantExpr::getSizeOf(ci.type), Type::UIntTy); + ConstantExpr::getCast(ConstantExpr::getSizeOf(ci.getType()), Type::UIntTy); // Add the array part plus the object part together. size = BinaryOperator::create( Instruction::Add, size, arrayObjectSize, TMP, currentBB_); // Allocate memory for the object. Value* objRef = new MallocInst(Type::SByteTy, size, TMP, currentBB_); - objRef = new CastInst(objRef, PointerType::get(ci.type), TMP, currentBB_); + objRef = new CastInst(objRef, PointerType::get(ci.getType()), TMP, currentBB_); // Store the size. Value* lengthPtr = getArrayLengthPtr(objRef); @@ -2259,7 +2270,7 @@ void do_arraylength() { const ClassInfo& ci = getObjectArrayInfo(); - Value* arrayRef = pop(PointerType::get(ci.type)); + Value* arrayRef = pop(PointerType::get(ci.getType())); Value* lengthPtr = getArrayLengthPtr(arrayRef); Value* length = new LoadInst(lengthPtr, TMP, currentBB_); push(length); From alkis at cs.uiuc.edu Thu Jan 27 13:56:22 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu, 27 Jan 2005 13:56:22 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200501271956.NAA03708@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.201 -> 1.202 --- Log message: Teach ClassInfo how to resolve to its real type and keep track of its elements. This removes a bit of code from initializeClassInfo(), getClassInfo() and buildArrayClassInfo(). --- Diffs of the changes: (+32 -42) Compiler.cpp | 74 +++++++++++++++++++++++++---------------------------------- 1 files changed, 32 insertions(+), 42 deletions(-) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.201 llvm-java/lib/Compiler/Compiler.cpp:1.202 --- llvm-java/lib/Compiler/Compiler.cpp:1.201 Thu Jan 27 13:17:54 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Thu Jan 27 13:56:11 2005 @@ -88,22 +88,30 @@ unsigned interfaceIdx_; typedef std::map Field2IndexMap; Field2IndexMap f2iMap_; + typedef std::vector ElementTypes; + ElementTypes elementTypes; public: static unsigned InterfaceCount; public: - ClassInfo() : type_(NULL), interfaceIdx_(0) { } - void setType(Type* type) { type_ = type; } + ClassInfo() : type_(OpaqueType::get()), interfaceIdx_(0) { } Type* getType() { return type_; } const Type* getType() const { return type_; } - void addField(const std::string& name, int slot) { - f2iMap_.insert(std::make_pair(name, slot)); + void addField(const std::string& name, const Type* type) { + f2iMap_.insert(std::make_pair(name, elementTypes.size())); + elementTypes.push_back(type); } int getFieldIndex(const std::string& name) const { Field2IndexMap::const_iterator it = f2iMap_.find(name); return it == f2iMap_.end() ? -1 : it->second; } + void resolveType() { + PATypeHolder holder = type_; + Type* resolvedType = StructType::get(elementTypes); + cast(type_)->refineAbstractTypeTo(resolvedType); + type_ = holder.get(); + } unsigned getInterfaceIndex() const { return interfaceIdx_; } void setInterfaceIndex(unsigned index) { interfaceIdx_ = index; } }; @@ -312,37 +320,28 @@ module_.addTypeName(LLVM_JAVA_OBJECT_BASE, ObjectBaseTy); - assert(!ci.getType() && + assert(isa(ci.getType()) && "java/lang/Object ClassInfo should not be initialized!"); - ci.setType(OpaqueType::get()); - - std::vector elements; - // Because this is java/lang/Object, we add the opaque // llvm_java_object_base type first. - ci.addField(LLVM_JAVA_OBJECT_BASE, elements.size()); - elements.push_back(ObjectBaseTy); + ci.addField(LLVM_JAVA_OBJECT_BASE, ObjectBaseTy); const Fields& fields = cf->getFields(); for (unsigned i = 0, e = fields.size(); i != e; ++i) { Field* field = fields[i]; - if (!field->isStatic()) { - ci.addField(field->getName()->str(), elements.size()); - elements.push_back(getType(field->getDescriptor())); - } + if (!field->isStatic()) + ci.addField(field->getName()->str(), getType(field->getDescriptor())); } - PATypeHolder holder = ci.getType(); - cast(ci.getType())-> - refineAbstractTypeTo(StructType::get(elements)); - ci.setType(holder.get()); + ci.resolveType(); DEBUG(std::cerr << "Adding java/lang/Object = " << *ci.getType() << " to type map\n"); module_.addTypeName("java/lang/Object", ci.getType()); - assert(ci.getType() && "ClassInfo not initialized properly!"); + assert(!isa(ci.getType()) && + "ClassInfo not initialized properly!"); emitStaticInitializers(cf); DEBUG(std::cerr << "Built ClassInfo for: java/lang/Object\n"); return true; @@ -455,35 +454,30 @@ DEBUG(std::cerr << "Building ClassInfo for: " << className << '\n'); ClassInfo& ci = c2ciMap_[cf]; - assert(!ci.getType() && "got already initialized ClassInfo!"); + assert(isa(ci.getType()) && + "got already initialized ClassInfo!"); // Get the interface id. if (cf->isInterface()) ci.setInterfaceIndex(ClassInfo::InterfaceCount++); - ci.setType(OpaqueType::get()); - - std::vector elements; ConstantClass* super = cf->getSuperClass(); assert(super && "Class does not have superclass!"); const ClassInfo& superCI = getClassInfo(ClassFile::get(super->getName()->str())); - elements.push_back(superCI.getType()); + ci.addField("super", superCI.getType()); const Fields& fields = cf->getFields(); for (unsigned i = 0, e = fields.size(); i != e; ++i) { Field* field = fields[i]; - if (!field->isStatic()) { - ci.addField(field->getName()->str(), elements.size()); - elements.push_back(getType(field->getDescriptor())); - } + if (!field->isStatic()) + ci.addField(field->getName()->str(), getType(field->getDescriptor())); } - PATypeHolder holder = ci.getType(); - cast(ci.getType())-> - refineAbstractTypeTo(StructType::get(elements)); - ci.setType(holder.get()); - assert(ci.getType() && "ClassInfo not initialized properly!"); + ci.resolveType(); + + assert(!isa(ci.getType()) && + "ClassInfo not initialized properly!"); DEBUG(std::cerr << "Adding " << className << " = " << *ci.getType() << " to type map\n"); module_.addTypeName(className, ci.getType()); @@ -497,15 +491,11 @@ ClassInfo buildArrayClassInfo(Type* elementTy) { ClassInfo arrayInfo; - std::vector elements; - elements.reserve(3); - elements.push_back(ObjectBaseTy); - elements.push_back(Type::UIntTy); - arrayInfo.addField("", elements.size()); - elements.push_back(ArrayType::get(elementTy, 0)); - arrayInfo.addField("", elements.size()); + arrayInfo.addField("super", ObjectBaseTy); + arrayInfo.addField("", Type::UIntTy); + arrayInfo.addField("", ArrayType::get(elementTy, 0)); - arrayInfo.setType(StructType::get(elements)); + arrayInfo.resolveType(); return arrayInfo; } From alkis at cs.uiuc.edu Thu Jan 27 14:03:52 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu, 27 Jan 2005 14:03:52 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200501272003.OAA03980@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.202 -> 1.203 --- Log message: Make InterfaceCount private as well. --- Diffs of the changes: (+2 -3) Compiler.cpp | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.202 llvm-java/lib/Compiler/Compiler.cpp:1.203 --- llvm-java/lib/Compiler/Compiler.cpp:1.202 Thu Jan 27 13:56:11 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Thu Jan 27 14:03:41 2005 @@ -91,7 +91,6 @@ typedef std::vector ElementTypes; ElementTypes elementTypes; - public: static unsigned InterfaceCount; public: @@ -113,7 +112,7 @@ type_ = holder.get(); } unsigned getInterfaceIndex() const { return interfaceIdx_; } - void setInterfaceIndex(unsigned index) { interfaceIdx_ = index; } + void setNextInterfaceIndex() { interfaceIdx_ = InterfaceCount++; } }; typedef std::map Class2ClassInfoMap; Class2ClassInfoMap c2ciMap_; @@ -459,7 +458,7 @@ // Get the interface id. if (cf->isInterface()) - ci.setInterfaceIndex(ClassInfo::InterfaceCount++); + ci.setNextInterfaceIndex(); ConstantClass* super = cf->getSuperClass(); assert(super && "Class does not have superclass!"); From alkis at cs.uiuc.edu Thu Jan 27 14:04:52 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu, 27 Jan 2005 14:04:52 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200501272004.OAA04008@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.203 -> 1.204 --- Log message: Make field access a bit more readable. --- Diffs of the changes: (+4 -2) Compiler.cpp | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.203 llvm-java/lib/Compiler/Compiler.cpp:1.204 --- llvm-java/lib/Compiler/Compiler.cpp:1.203 Thu Jan 27 14:03:41 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Thu Jan 27 14:04:42 2005 @@ -1231,7 +1231,7 @@ } } - return new GetElementPtrInst(ptr, indices, fieldName, currentBB_); + return new GetElementPtrInst(ptr, indices, fieldName + '*', currentBB_); } std::string getMangledString(const std::string& str) { @@ -1938,8 +1938,10 @@ } void do_getfield(unsigned index) { + ConstantFieldRef* fieldRef = cf_->getConstantFieldRef(index); + const std::string& name = fieldRef->getNameAndType()->getName()->str(); Value* p = pop(ObjectBaseRefTy); - Value* v = new LoadInst(getField(index, p), TMP, currentBB_); + Value* v = new LoadInst(getField(index, p), name, currentBB_); push(v); } From jeffc at jolt-lang.org Thu Jan 27 19:17:18 2005 From: jeffc at jolt-lang.org (Jeff Cohen) Date: Thu, 27 Jan 2005 19:17:18 -0600 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Archive/Archive.cpp ArchiveWriter.cpp Message-ID: <200501280117.TAA27001@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Archive: Archive.cpp updated: 1.5 -> 1.6 ArchiveWriter.cpp updated: 1.14 -> 1.15 --- Log message: Properly close mapped files. --- Diffs of the changes: (+3 -3) Archive.cpp | 2 +- ArchiveWriter.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) Index: llvm/lib/Bytecode/Archive/Archive.cpp diff -u llvm/lib/Bytecode/Archive/Archive.cpp:1.5 llvm/lib/Bytecode/Archive/Archive.cpp:1.6 --- llvm/lib/Bytecode/Archive/Archive.cpp:1.5 Fri Dec 10 18:14:15 2004 +++ llvm/lib/Bytecode/Archive/Archive.cpp Thu Jan 27 19:17:07 2005 @@ -143,7 +143,7 @@ Archive::~Archive() { // Shutdown the file mapping if (mapfile) { - mapfile->unmap(); + mapfile->close(); delete mapfile; } // Delete any ModuleProviders and ArchiveMember's we've allocated as a result Index: llvm/lib/Bytecode/Archive/ArchiveWriter.cpp diff -u llvm/lib/Bytecode/Archive/ArchiveWriter.cpp:1.14 llvm/lib/Bytecode/Archive/ArchiveWriter.cpp:1.15 --- llvm/lib/Bytecode/Archive/ArchiveWriter.cpp:1.14 Sat Jan 22 11:36:16 2005 +++ llvm/lib/Bytecode/Archive/ArchiveWriter.cpp Thu Jan 27 19:17:07 2005 @@ -303,7 +303,7 @@ // Close the mapped file if it was opened if (mFile != 0) { - mFile->unmap(); + mFile->close(); delete mFile; } } @@ -442,7 +442,7 @@ // Close up shop FinalFile.close(); - arch.unmap(); + arch.close(); TmpArchive.destroyFile(); } else { From lattner at cs.uiuc.edu Fri Jan 28 00:13:23 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 00:13:23 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/DependenceGraph.cpp DependenceGraph.h IPModRef.cpp IPModRef.h MemoryDepAnalysis.cpp MemoryDepAnalysis.h Parallelize.cpp PgmDependenceGraph.cpp PgmDependenceGraph.h Message-ID: <200501280613.j0S6DM0n009022@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: DependenceGraph.cpp (r1.1) removed DependenceGraph.h (r1.2) removed IPModRef.cpp (r1.28) removed IPModRef.h (r1.4) removed MemoryDepAnalysis.cpp (r1.22) removed MemoryDepAnalysis.h (r1.5) removed Parallelize.cpp (r1.19) removed PgmDependenceGraph.cpp (r1.9) removed PgmDependenceGraph.h (r1.6) removed --- Log message: Remove this code as it is currently completely broken and unmaintained. If needed, this can be resurrected from CVS. Note that several of the interfaces (e.g. the IPModRef ones) are supersumed by generic AliasAnalysis interfaces that have been written since this code was developed (and they are not DSA specific). --- Diffs of the changes: (+0 -0) 0 files changed From lattner at cs.uiuc.edu Fri Jan 28 00:14:04 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 00:14:04 -0600 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200501280614.j0S6E4T5009044@apoc.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.289 -> 1.290 --- Log message: These passes are no more. --- Diffs of the changes: (+2 -3) ReleaseNotes.html | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.289 llvm/docs/ReleaseNotes.html:1.290 --- llvm/docs/ReleaseNotes.html:1.289 Thu Jan 27 11:59:51 2005 +++ llvm/docs/ReleaseNotes.html Fri Jan 28 00:13:52 2005 @@ -207,8 +207,7 @@
    • The following passes are incomplete or buggy, and may be removed in future - releases: -pgmdep, -memdep, -ipmodref, -cee, -branch-combine, - -instloops, -parallel, -paths, -pre
    • + releases: -cee, -branch-combine, -instloops, -paths, -pre
    • The llvm-db tool is in a very early stage of development, but can be used to step through programs and inspect the stack.
    • The "iterative scan" register allocator (enabled with -regalloc=iterativescan) @@ -566,7 +565,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
      - Last modified: $Date: 2005/01/27 17:59:51 $ + Last modified: $Date: 2005/01/28 06:13:52 $ From lattner at cs.uiuc.edu Fri Jan 28 00:27:53 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 00:27:53 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Message-ID: <200501280627.j0S6RrEP015360@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: LegalizeDAG.cpp updated: 1.53 -> 1.54 --- Log message: CopyFromReg produces two values. Make sure that we remember that both are legalized, and actually return the correct result when we legalize the chain first. --- Diffs of the changes: (+8 -1) LegalizeDAG.cpp | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletion(-) Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.53 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.54 --- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.53 Sun Jan 23 17:19:44 2005 +++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Fri Jan 28 00:27:38 2005 @@ -206,7 +206,14 @@ if (Tmp1 != Node->getOperand(0)) Result = DAG.getCopyFromReg(cast(Node)->getReg(), Node->getValueType(0), Tmp1); - break; + else + Result = Op.getValue(0); + + // Since CopyFromReg produces two values, make sure to remember that we + // legalized both of them. + AddLegalizedOperand(Op.getValue(0), Result); + AddLegalizedOperand(Op.getValue(1), Result.getValue(1)); + return Result.getValue(Op.ResNo); case ISD::ImplicitDef: Tmp1 = LegalizeOp(Node->getOperand(0)); if (Tmp1 != Node->getOperand(0)) From alenhar2 at cs.uiuc.edu Fri Jan 28 00:57:33 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Fri, 28 Jan 2005 00:57:33 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp Message-ID: <200501280657.AAA00708@niobe.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.13 -> 1.14 --- Log message: move FP into it's own select --- Diffs of the changes: (+167 -191) AlphaISelPattern.cpp | 358 +++++++++++++++++++++++---------------------------- 1 files changed, 167 insertions(+), 191 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.13 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.14 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.13 Thu Jan 27 01:58:15 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Fri Jan 28 00:57:18 2005 @@ -133,60 +133,47 @@ Alpha::F19, Alpha::F20, Alpha::F21}; std::vector argVreg; std::vector argPreg; + std::vector argOpc; int count = 0; for (Function::aiterator I = F.abegin(), E = F.aend(); I != E; ++I) { + SDOperand newroot, argt; ++count; assert(count <= 6 && "More than 6 args not supported"); switch (getValueType(I->getType())) { default: std::cerr << "Unknown Type " << getValueType(I->getType()) << "\n"; abort(); case MVT::f64: case MVT::f32: - BuildMI(&BB, Alpha::IDEF, 0, args_float[count - 1]); - argVreg.push_back(MF.getSSARegMap()->createVirtualRegister(getRegClassFor(getValueType(I->getType())))); - argPreg.push_back(args_float[count - 1]); - break; + BuildMI(&BB, Alpha::IDEF, 0, args_float[count - 1]); + argVreg.push_back(MF.getSSARegMap()->createVirtualRegister(getRegClassFor(getValueType(I->getType())))); + argPreg.push_back(args_float[count - 1]); + argOpc.push_back(Alpha::CPYS); + newroot = DAG.getCopyFromReg(argVreg[count], getValueType(I->getType()), DAG.getRoot()); + break; case MVT::i1: case MVT::i8: case MVT::i16: case MVT::i32: case MVT::i64: - BuildMI(&BB, Alpha::IDEF, 0, args_int[count - 1]); - argVreg.push_back(MF.getSSARegMap()->createVirtualRegister(getRegClassFor(MVT::i64))); - argPreg.push_back(args_int[count - 1]); - break; - } + BuildMI(&BB, Alpha::IDEF, 0, args_int[count - 1]); + argVreg.push_back(MF.getSSARegMap()->createVirtualRegister(getRegClassFor(MVT::i64))); + argPreg.push_back(args_int[count - 1]); + argOpc.push_back(Alpha::BIS); + argt = newroot = DAG.getCopyFromReg(argVreg[count], MVT::i64, DAG.getRoot()); + if (getValueType(I->getType()) != MVT::i64) + argt = DAG.getNode(ISD::TRUNCATE, getValueType(I->getType()), newroot); + break; + } + DAG.setRoot(newroot.getValue(1)); + ArgValues.push_back(argt); } BuildMI(&BB, Alpha::IDEF, 0, Alpha::R29); BuildMI(&BB, Alpha::BIS, 2, GP).addReg(Alpha::R29).addReg(Alpha::R29); count = 0; - for (Function::aiterator I = F.abegin(), E = F.aend(); I != E; ++I) - { - SDOperand newroot; - unsigned Opc; - switch (getValueType(I->getType())) - { - default: assert(0 && "Unhandled type"); - case MVT::i64: - case MVT::i32: - case MVT::i16: - case MVT::i8: - case MVT::i1: - Opc = Alpha::BIS; - break; - case MVT::f32: - case MVT::f64: - Opc = Alpha::CPYS; - break; - } - BuildMI(&BB, Opc, 2, argVreg[count]).addReg(argPreg[count]).addReg(argPreg[count]); - newroot = DAG.getCopyFromReg(argVreg[count], getValueType(I->getType()), DAG.getRoot()); - DAG.setRoot(newroot.getValue(1)); - ArgValues.push_back(newroot); - ++count; - } - + for (int i = 0; i < count; ++i) + BuildMI(&BB, argOpc[i], 2, argVreg[i]).addReg(argPreg[i]).addReg(argPreg[i]); + return ArgValues; } @@ -209,19 +196,16 @@ // Promote the integer to 64 bits. If the input type is signed use a // sign extend, otherwise use a zero extend. if (Args[i].second->isSigned()) - Args[i].first = DAG.getNode(ISD::SIGN_EXTEND_INREG, MVT::i64, Args[i].first); + Args[i].first = DAG.getNode(ISD::SIGN_EXTEND, MVT::i64, Args[i].first); else - Args[i].first = DAG.getNode(ISD::ZERO_EXTEND_INREG, MVT::i64, Args[i].first); + Args[i].first = DAG.getNode(ISD::ZERO_EXTEND, MVT::i64, Args[i].first); break; case MVT::i64: - break; - case MVT::f64: - case MVT::f32: - break; + break; } args_to_use.push_back(Args[i].first); } - + std::vector RetVals; MVT::ValueType RetTyVT = getValueType(RetTy); if (RetTyVT != MVT::isVoid) @@ -275,7 +259,6 @@ /// vreg the value is produced in, so we only emit one copy of each compiled /// tree. std::map ExprMap; - std::set LoweredTokens; public: ISel(TargetMachine &TM) : SelectionDAGISel(AlphaLowering), AlphaLowering(TM) { @@ -289,20 +272,77 @@ // Clear state used for selection. ExprMap.clear(); - LoweredTokens.clear(); } unsigned SelectExpr(SDOperand N); + unsigned SelectExprFP(SDOperand N, unsigned Result); void Select(SDOperand N); }; } +unsigned ISel::SelectExprFP(SDOperand N, unsigned Result) +{ + unsigned Tmp1, Tmp2, Tmp3; + unsigned Opc = 0; + SDNode *Node = N.Val; + MVT::ValueType DestType = N.getValueType(); + unsigned opcode = N.getOpcode(); + + switch (opcode) { + default: + Node->dump(); + assert(0 && "Node not handled!\n"); + + case ISD::ConstantFP: + if (ConstantFPSDNode *CN = dyn_cast(N)) { + if (CN->isExactlyValue(+0.0)) { + BuildMI(BB, Alpha::CPYS, 2, Result).addReg(Alpha::F31).addReg(Alpha::F31); + } else { + abort(); + } + } + return Result; + + case ISD::MUL: + case ISD::ADD: + case ISD::SUB: + case ISD::SDIV: + switch( opcode ) { + case ISD::MUL: Opc = DestType == MVT::f64 ? Alpha::MULT : Alpha::MULS; break; + case ISD::ADD: Opc = DestType == MVT::f64 ? Alpha::ADDT : Alpha::ADDS; break; + case ISD::SUB: Opc = DestType == MVT::f64 ? Alpha::SUBT : Alpha::SUBS; break; + case ISD::SDIV: Opc = DestType == MVT::f64 ? Alpha::DIVT : Alpha::DIVS; break; + }; + Tmp1 = SelectExpr(N.getOperand(0)); + Tmp2 = SelectExpr(N.getOperand(1)); + BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); + return Result; + + case ISD::SINT_TO_FP: + { + assert (N.getOperand(0).getValueType() == MVT::i64 && "only quads can be loaded from"); + Tmp1 = SelectExpr(N.getOperand(0)); // Get the operand register + Tmp2 = MakeReg(DestType); + //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; + } + } + assert(0 && "should not get here"); + return 0; +} + unsigned ISel::SelectExpr(SDOperand N) { unsigned Result; unsigned Tmp1, Tmp2, Tmp3; unsigned Opc = 0; + unsigned opcode = N.getOpcode(); SDNode *Node = N.Val; + MVT::ValueType DestType = N.getValueType(); unsigned &Reg = ExprMap[N]; if (Reg) return Reg; @@ -324,22 +364,14 @@ } } - switch (N.getOpcode()) { + if (DestType == MVT::f64 || DestType == MVT::f32) + return SelectExprFP(N, Result); + + switch (opcode) { default: Node->dump(); assert(0 && "Node not handled!\n"); - case ISD::ConstantFP: - if (ConstantFPSDNode *CN = dyn_cast(N)) { - if (CN->isExactlyValue(+0.0) || - CN->isExactlyValue(-0.0)) { - BuildMI(BB, Alpha::CPYS, 2, Result).addReg(Alpha::F31).addReg(Alpha::F31); - } else { - abort(); - } - } - return Result; - case ISD::FrameIndex: Tmp1 = cast(N)->getIndex(); BuildMI(BB, Alpha::LDA, 2, Result).addImm(Tmp1 * 8).addReg(Alpha::R30); @@ -660,9 +692,12 @@ case ISD::CopyFromReg: { - if (Result == 1) + // 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); Select(Chain); @@ -680,105 +715,73 @@ case ISD::SHL: case ISD::SRL: case ISD::MUL: - switch (N.getValueType()) { - default: Node->dump(); assert (0 && "unhandled type"); - case MVT::f64: - assert(N.getOpcode() == ISD::MUL && "only mul here please"); - Tmp1 = SelectExpr(N.getOperand(0)); - Tmp2 = SelectExpr(N.getOperand(1)); - BuildMI(BB, Alpha::MULT, 2, Result).addReg(Tmp1).addReg(Tmp2); - break; - case MVT::f32: - assert(N.getOpcode() == ISD::MUL && "only mul here please"); - Tmp1 = SelectExpr(N.getOperand(0)); - Tmp2 = SelectExpr(N.getOperand(1)); - BuildMI(BB, Alpha::MULS, 2, Result).addReg(Tmp1).addReg(Tmp2); - break; - case MVT::i64: - if(N.getOperand(1).getOpcode() == ISD::Constant && - cast(N.getOperand(1))->getValue() >= 0 && - cast(N.getOperand(1))->getValue() <= 255) - { - switch(N.getOpcode()) { - case ISD::AND: Opc = Alpha::ANDi; break; - case ISD::OR: Opc = Alpha::BISi; break; - case ISD::XOR: Opc = Alpha::XORi; break; - case ISD::SHL: Opc = Alpha::SLi; break; - case ISD::SRL: Opc = Alpha::SRLi; break; - case ISD::SRA: Opc = Alpha::SRAi; break; - case ISD::MUL: Opc = Alpha::MULQi; break; - }; - Tmp1 = SelectExpr(N.getOperand(0)); - Tmp2 = cast(N.getOperand(1))->getValue(); - BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addImm(Tmp2); - } - else - { - switch(N.getOpcode()) { - case ISD::AND: Opc = Alpha::AND; break; - case ISD::OR: Opc = Alpha::BIS; break; - case ISD::XOR: Opc = Alpha::XOR; break; - case ISD::SHL: Opc = Alpha::SL; break; - case ISD::SRL: Opc = Alpha::SRL; break; - case ISD::SRA: Opc = Alpha::SRA; break; - case ISD::MUL: Opc = Alpha::MULQ; break; - }; - Tmp1 = SelectExpr(N.getOperand(0)); - Tmp2 = SelectExpr(N.getOperand(1)); - BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); - } - break; - } + assert (DestType == MVT::i64 && "Only do arithmetic on i64s!"); + if(N.getOperand(1).getOpcode() == ISD::Constant && + cast(N.getOperand(1))->getValue() >= 0 && + cast(N.getOperand(1))->getValue() <= 255) + { + switch(opcode) { + case ISD::AND: Opc = Alpha::ANDi; break; + case ISD::OR: Opc = Alpha::BISi; break; + case ISD::XOR: Opc = Alpha::XORi; break; + case ISD::SHL: Opc = Alpha::SLi; break; + case ISD::SRL: Opc = Alpha::SRLi; break; + case ISD::SRA: Opc = Alpha::SRAi; break; + case ISD::MUL: Opc = Alpha::MULQi; break; + }; + Tmp1 = SelectExpr(N.getOperand(0)); + Tmp2 = cast(N.getOperand(1))->getValue(); + BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addImm(Tmp2); + } + else + { + switch(opcode) { + case ISD::AND: Opc = Alpha::AND; break; + case ISD::OR: Opc = Alpha::BIS; break; + case ISD::XOR: Opc = Alpha::XOR; break; + case ISD::SHL: Opc = Alpha::SL; break; + case ISD::SRL: Opc = Alpha::SRL; break; + case ISD::SRA: Opc = Alpha::SRA; break; + case ISD::MUL: Opc = Alpha::MULQ; break; + }; + Tmp1 = SelectExpr(N.getOperand(0)); + Tmp2 = SelectExpr(N.getOperand(1)); + BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); + } return Result; - + case ISD::ADD: case ISD::SUB: { - bool isAdd = N.getOpcode() == ISD::ADD; - - switch (N.getValueType()) { - default: Node->dump(); assert(0 && "Unhandled type"); - case MVT::i64: { - //FIXME: first check for Scaled Adds and Subs! - if(N.getOperand(1).getOpcode() == ISD::Constant && - cast(N.getOperand(1))->getValue() >= 0 && - cast(N.getOperand(1))->getValue() <= 255) - { //Normal imm add/sub - Opc = isAdd ? Alpha::ADDQi : Alpha::SUBQi; - Tmp1 = SelectExpr(N.getOperand(0)); - Tmp2 = cast(N.getOperand(1))->getValue(); - BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addImm(Tmp2); - } - else if(N.getOperand(1).getOpcode() == ISD::Constant && - cast(N.getOperand(1))->getValue() >= 0 && - cast(N.getOperand(1))->getValue() <= 32767) - { //LDA //FIXME: expand the above condition a bit - Tmp1 = SelectExpr(N.getOperand(0)); - Tmp2 = cast(N.getOperand(1))->getValue(); - if (!isAdd) - Tmp2 = -Tmp2; - BuildMI(BB, Alpha::LDA, 2, Result).addImm(Tmp2).addReg(Tmp1); - } - else - { //Normal add/sub - Opc = isAdd ? Alpha::ADDQ : Alpha::SUBQ; - Tmp1 = SelectExpr(N.getOperand(0)); - Tmp2 = SelectExpr(N.getOperand(1)); - BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); - } - } break; - case MVT::f64: - case MVT::f32: - if (N.getValueType() == MVT::f64) - Opc = isAdd ? Alpha::ADDT : Alpha::SUBT; - else - Opc = isAdd ? Alpha::ADDS : Alpha::SUBS; - // - Tmp1 = SelectExpr(N.getOperand(0)); - Tmp2 = SelectExpr(N.getOperand(1)); - BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); - break; - } + bool isAdd = opcode == ISD::ADD; + + //FIXME: first check for Scaled Adds and Subs! + if(N.getOperand(1).getOpcode() == ISD::Constant && + cast(N.getOperand(1))->getValue() >= 0 && + cast(N.getOperand(1))->getValue() <= 255) + { //Normal imm add/sub + Opc = isAdd ? Alpha::ADDQi : Alpha::SUBQi; + Tmp1 = SelectExpr(N.getOperand(0)); + Tmp2 = cast(N.getOperand(1))->getValue(); + BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addImm(Tmp2); + } + else if(N.getOperand(1).getOpcode() == ISD::Constant && + cast(N.getOperand(1))->getValue() >= 0 && + cast(N.getOperand(1))->getValue() <= 32767) + { //LDA //FIXME: expand the above condition a bit + Tmp1 = SelectExpr(N.getOperand(0)); + Tmp2 = cast(N.getOperand(1))->getValue(); + if (!isAdd) + Tmp2 = -Tmp2; + BuildMI(BB, Alpha::LDA, 2, Result).addImm(Tmp2).addReg(Tmp1); + } + else + { //Normal add/sub + Opc = isAdd ? Alpha::ADDQ : Alpha::SUBQ; + Tmp1 = SelectExpr(N.getOperand(0)); + Tmp2 = SelectExpr(N.getOperand(1)); + BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); + } return Result; } @@ -786,46 +789,19 @@ case ISD::SREM: case ISD::SDIV: case ISD::UDIV: - switch (N.getValueType()) { - default: Node->dump(); assert (0 && "unhandled type"); - case MVT::f64: - assert(N.getOpcode() == ISD::SDIV && "only div here please"); - Opc = Alpha::DIVT; - break; - case MVT::f32: - assert(N.getOpcode() == ISD::SDIV && "only div here please"); - Opc = Alpha::DIVS; - break; - case MVT::i64: - //FIXME: alpha really doesn't support any of these operations, - // the ops are expanded into special library calls with - // special calling conventions - switch(N.getOpcode()) { - case ISD::UREM: Opc = Alpha::REMQU; break; - case ISD::SREM: Opc = Alpha::REMQ; break; - case ISD::UDIV: Opc = Alpha::DIVQU; break; - case ISD::SDIV: Opc = Alpha::DIVQ; break; - } - break; + //FIXME: alpha really doesn't support any of these operations, + // the ops are expanded into special library calls with + // special calling conventions + switch(opcode) { + case ISD::UREM: Opc = Alpha::REMQU; break; + case ISD::SREM: Opc = Alpha::REMQ; break; + case ISD::UDIV: Opc = Alpha::DIVQU; break; + case ISD::SDIV: Opc = Alpha::DIVQ; break; } Tmp1 = SelectExpr(N.getOperand(0)); Tmp2 = SelectExpr(N.getOperand(1)); BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); return Result; - - case ISD::SINT_TO_FP: - { - MVT::ValueType DestTy = N.getValueType(); - assert (N.getOperand(0).getValueType() == MVT::i64 && "only quads can be loaded from"); - Tmp1 = SelectExpr(N.getOperand(0)); // Get the operand register - Tmp2 = MakeReg(DestTy); - Opc = DestTy == MVT::f64 ? Alpha::ITOFT : Alpha::ITOFS; - BuildMI(BB, Opc, 1, Tmp2).addReg(Tmp1); - Opc = DestTy == MVT::f64 ? Alpha::CVTQT : Alpha::CVTQS; - BuildMI(BB, Opc, 1, Result).addReg(Tmp1); - return Result; - } - // // case ISD::UINT_TO_FP: // case ISD::FP_TO_SINT: @@ -890,9 +866,9 @@ void ISel::Select(SDOperand N) { unsigned Tmp1, Tmp2, Opc; - // FIXME: Disable for our current expansion model! - if (/*!N->hasOneUse() &&*/ !LoweredTokens.insert(N).second) - return; // Already selected. + if(ExprMap[N]) + return; //alread selected + ExprMap[N] = 1; SDNode *Node = N.Val; From reid at x10sys.com Fri Jan 28 01:22:31 2005 From: reid at x10sys.com (Reid Spencer) Date: Fri, 28 Jan 2005 01:22:31 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/ADT/StringExtras.h Message-ID: <200501280722.BAA30011@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/ADT: StringExtras.h updated: 1.24 -> 1.25 --- Log message: Convert some old C-style casts to C++ style. --- Diffs of the changes: (+2 -2) StringExtras.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/include/llvm/ADT/StringExtras.h diff -u llvm/include/llvm/ADT/StringExtras.h:1.24 llvm/include/llvm/ADT/StringExtras.h:1.25 --- llvm/include/llvm/ADT/StringExtras.h:1.24 Mon Jan 3 19:56:28 2005 +++ llvm/include/llvm/ADT/StringExtras.h Fri Jan 28 01:22:20 2005 @@ -29,7 +29,7 @@ if (X == 0) *--BufPtr = '0'; // Handle special case... while (X) { - unsigned char Mod = (unsigned char)X & 15; + unsigned char Mod = static_cast(X) & 15; if (Mod < 10) *--BufPtr = '0' + Mod; else @@ -109,7 +109,7 @@ std::string result(S); for (unsigned i = 0; i < S.length(); ++i) if (isupper(result[i])) - result[i] = (char)tolower(result[i]); + result[i] = char(tolower(result[i])); return result; } From jeffc at jolt-lang.org Fri Jan 28 01:29:25 2005 From: jeffc at jolt-lang.org (Jeff Cohen) Date: Fri, 28 Jan 2005 01:29:25 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Transforms/LinkAllPasses.h Message-ID: <200501280729.BAA30068@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Transforms: LinkAllPasses.h updated: 1.14 -> 1.15 --- Log message: Get VC++ compiling again --- Diffs of the changes: (+0 -1) LinkAllPasses.h | 1 - 1 files changed, 1 deletion(-) Index: llvm/include/llvm/Transforms/LinkAllPasses.h diff -u llvm/include/llvm/Transforms/LinkAllPasses.h:1.14 llvm/include/llvm/Transforms/LinkAllPasses.h:1.15 --- llvm/include/llvm/Transforms/LinkAllPasses.h:1.14 Sun Jan 9 21:56:27 2005 +++ llvm/include/llvm/Transforms/LinkAllPasses.h Fri Jan 28 01:29:15 2005 @@ -96,7 +96,6 @@ (void) llvm::createNoAAPass(); (void) llvm::createNoProfileInfoPass(); (void) llvm::createPREPass(); - (void) llvm::createParallelizePass(); (void) llvm::createProfileLoaderPass(); (void) llvm::createProfilePathsPass(); (void) llvm::createPromoteMemoryToRegister(); From jeffc at jolt-lang.org Fri Jan 28 01:29:26 2005 From: jeffc at jolt-lang.org (Jeff Cohen) Date: Fri, 28 Jan 2005 01:29:26 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/Passes.h Message-ID: <200501280729.BAA30072@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: Passes.h updated: 1.4 -> 1.5 --- Log message: Get VC++ compiling again --- Diffs of the changes: (+0 -7) Passes.h | 7 ------- 1 files changed, 7 deletions(-) Index: llvm/include/llvm/Analysis/Passes.h diff -u llvm/include/llvm/Analysis/Passes.h:1.4 llvm/include/llvm/Analysis/Passes.h:1.5 --- llvm/include/llvm/Analysis/Passes.h:1.4 Sun Jan 9 21:56:27 2005 +++ llvm/include/llvm/Analysis/Passes.h Fri Jan 28 01:29:15 2005 @@ -98,13 +98,6 @@ //===--------------------------------------------------------------------===// // - // createParallelizePass - This pass parallelizes a program using the cilk - // multi-threaded runtime system. - // - ModulePass *createParallelizePass(); - - //===--------------------------------------------------------------------===// - // // createSteensgaardPass - This pass uses the data structure graphs to do a // simple context insensitive alias analysis. // From jeffc at jolt-lang.org Fri Jan 28 01:29:43 2005 From: jeffc at jolt-lang.org (Jeff Cohen) Date: Fri, 28 Jan 2005 01:29:43 -0600 Subject: [llvm-commits] CVS: llvm/win32/analyze/analyze.vcproj Message-ID: <200501280729.BAA30089@zion.cs.uiuc.edu> Changes in directory llvm/win32/analyze: analyze.vcproj updated: 1.2 -> 1.3 --- Log message: Get VC++ compiling again --- Diffs of the changes: (+2 -2) analyze.vcproj | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/win32/analyze/analyze.vcproj diff -u llvm/win32/analyze/analyze.vcproj:1.2 llvm/win32/analyze/analyze.vcproj:1.3 --- llvm/win32/analyze/analyze.vcproj:1.2 Wed Jan 19 23:19:40 2005 +++ llvm/win32/analyze/analyze.vcproj Fri Jan 28 01:29:32 2005 @@ -36,7 +36,7 @@ Name="VCCustomBuildTool"/> Changes in directory llvm/win32/Analysis: Analysis.vcproj updated: 1.8 -> 1.9 --- Log message: Get VC++ compiling again --- Diffs of the changes: (+0 -27) Analysis.vcproj | 27 --------------------------- 1 files changed, 27 deletions(-) Index: llvm/win32/Analysis/Analysis.vcproj diff -u llvm/win32/Analysis/Analysis.vcproj:1.8 llvm/win32/Analysis/Analysis.vcproj:1.9 --- llvm/win32/Analysis/Analysis.vcproj:1.8 Sat Jan 8 22:18:28 2005 +++ llvm/win32/Analysis/Analysis.vcproj Fri Jan 28 01:29:32 2005 @@ -210,42 +210,15 @@ RelativePath="..\..\lib\Analysis\DataStructure\DataStructureStats.cpp"> - - - - - - - - - - - - - - - - - - Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.14 -> 1.15 --- Log message: fix ExprMap and constant check in setcc --- Diffs of the changes: (+5 -4) AlphaISelPattern.cpp | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.14 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.15 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.14 Fri Jan 28 00:57:18 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Fri Jan 28 08:06:46 2005 @@ -653,7 +653,7 @@ } } else if (dir == 2) { Tmp1 = SelectExpr(N.getOperand(1)); - if (isConst2) { + if (isConst1) { Tmp2 = cast(N.getOperand(0))->getValue(); BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addImm(Tmp2); } else { @@ -866,9 +866,9 @@ void ISel::Select(SDOperand N) { unsigned Tmp1, Tmp2, Opc; - if(ExprMap[N]) - return; //alread selected - ExprMap[N] = 1; + // FIXME: Disable for our current expansion model! + if (/*!N->hasOneUse() &&*/ !ExprMap.insert(std::make_pair(N, 1)).second) + return; // Already selected. SDNode *Node = N.Val; @@ -977,6 +977,7 @@ case ISD::CopyFromReg: case ISD::CALL: // case ISD::DYNAMIC_STACKALLOC: + ExprMap.erase(N); SelectExpr(N); return; From lattner at cs.uiuc.edu Fri Jan 28 10:08:40 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 10:08:40 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/System/MappedFile.h Message-ID: <200501281608.j0SG8dXR028502@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/System: MappedFile.h updated: 1.5 -> 1.6 --- Log message: Do not clean up if the MappedFile was never used or if the client already closed the file. This unbreaks the build. --- Diffs of the changes: (+1 -1) MappedFile.h | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/include/llvm/System/MappedFile.h diff -u llvm/include/llvm/System/MappedFile.h:1.5 llvm/include/llvm/System/MappedFile.h:1.6 --- llvm/include/llvm/System/MappedFile.h:1.5 Sun Dec 12 20:58:51 2004 +++ llvm/include/llvm/System/MappedFile.h Fri Jan 28 10:08:23 2005 @@ -52,7 +52,7 @@ /// Destruct a MappedFile and release all memory associated with it. /// @throws std::string if an error occurs - ~MappedFile() { terminate(); } + ~MappedFile() { if (info_) terminate(); } /// @} /// @name Accessors From lattner at cs.uiuc.edu Fri Jan 28 11:23:09 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 11:23:09 -0600 Subject: [llvm-commits] CVS: llvm/docs/CodeGenerator.html Message-ID: <200501281723.j0SHN9K9028726@apoc.cs.uiuc.edu> Changes in directory llvm/docs: CodeGenerator.html updated: 1.9 -> 1.10 --- Log message: Add some initial documentation for the SelectionDAG based instruction selectors --- Diffs of the changes: (+332 -15) CodeGenerator.html | 347 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 332 insertions(+), 15 deletions(-) Index: llvm/docs/CodeGenerator.html diff -u llvm/docs/CodeGenerator.html:1.9 llvm/docs/CodeGenerator.html:1.10 --- llvm/docs/CodeGenerator.html:1.9 Fri Dec 3 09:59:26 2004 +++ llvm/docs/CodeGenerator.html Fri Jan 28 11:22:53 2005 @@ -23,6 +23,7 @@
      • The TargetMachine class
      • The TargetData class
      • +
      • The TargetLowering class
      • The MRegisterInfo class
      • The TargetInstrInfo class
      • The TargetFrameInfo class
      • @@ -31,14 +32,30 @@
      • Machine code description classes
      • Target-independent code generation algorithms +
      • Target description implementations
      • @@ -159,16 +176,17 @@
        -

        The LLVM target-indendent code generator is designed to support efficient and +

        The LLVM target-independent code generator is designed to support efficient and quality code generation for standard register-based microprocessors. Code generation in this model is divided into the following stages:

          -
        1. Instruction Selection - Determining an efficient implementation of the -input LLVM code in the target instruction set. This stage produces the initial -code for the program in the target instruction set, then makes use of virtual -registers in SSA form and physical registers that represent any required -register assignments due to target constraints or calling conventions.
        2. +
        3. Instruction Selection - Determining an +efficient implementation of the input LLVM code in the target instruction set. +This stage produces the initial code for the program in the target instruction +set, then makes use of virtual registers in SSA form and physical registers that +represent any required register assignments due to target constraints or calling +conventions.
        4. SSA-based Machine Code Optimizations - This (optional) stage consists of a series of machine-code optimizations that operate on the SSA-form produced @@ -205,7 +223,7 @@ aggressive iterative peephole optimization are much slower. This design permits efficient compilation (important for JIT environments) and aggressive optimization (used when generating code offline) by allowing -components of varying levels of sophisication to be used for any step of +components of varying levels of sophistication to be used for any step of compilation.

          @@ -296,6 +314,25 @@

        + + + +
        + +

        The TargetLowering class is used by SelectionDAG based instruction +selectors primarily to describe how LLVM code should be lowered to SelectionDAG +operations. Among other things, this class indicates an initial register class +to use for various ValueTypes, which operations are natively supported by the +target machine, and some other miscellaneous properties (such as the return type +of setcc operations, the type to use for shift amounts, etc).

        + +
        + + + +
        @@ -384,8 +421,8 @@

        The opcode number is an simple unsigned number that only has meaning to a specific backend. All of the instructions for a target should be defined in the *InstrInfo.td file for the target, and the opcode enum values -are autogenerated from this description. The MachineInstr class does -not have any information about how to intepret the instruction (i.e., what the +are auto-generated from this description. The MachineInstr class does +not have any information about how to interpret the instruction (i.e., what the semantics of the instruction are): for that you must refer to the TargetInstrInfo class.

        @@ -396,7 +433,7 @@

        By convention, the LLVM code generator orders instruction operands so that all register definitions come before the register uses, even on architectures -that are normally printed in other orders. For example, the sparc add +that are normally printed in other orders. For example, the SPARC add instruction: "add %i1, %i2, %i3" adds the "%i1", and "%i2" registers and stores the result into the "%i3" register. In the LLVM code generator, the operands should be stored as "%i3, %i1, %i2": with the destination @@ -503,7 +540,7 @@ ret -

        By the end of code generation, the register allocator has coallesced +

        By the end of code generation, the register allocator has coalesced the registers and deleted the resultant identity moves, producing the following code:

        @@ -546,6 +583,286 @@ + + +
        + +

        This section documents the phases described in the high-level design of the code generator. It +explains how they work and some of the rationale behind their design.

        + +
        + + + + +
        +

        +Instruction Selection is the process of translating the LLVM code input to the +code generator into target-specific machine instructions. There are several +well-known ways to do this in the literature. In LLVM there are two main forms: +the old-style 'simple' instruction selector (which effectively peephole selects +each LLVM instruction into a series of machine instructions), and the new +SelectionDAG based instruction selector. +

        + +

        The 'simple' instruction selectors are tedious to write, require a lot of +boiler plate code, and are difficult to get correct. Additionally, any +optimizations written for a simple instruction selector cannot be used by other +targets. For this reason, LLVM is moving to a new SelectionDAG based +instruction selector, which is described in this section. If you are starting a +new port, we recommend that you write the instruction selector using the +SelectionDAG infrastructure.

        + +

        In time, most of the target-specific code for instruction selection will be +auto-generated from the target .td files. For now, however, the Select Phase must still be written by hand.

        +
        + + + + +
        + +

        +The SelectionDAG provides an abstraction for representing code in a way that is +amenable to instruction selection using automatic techniques +(e.g. dynamic-programming based optimal pattern matching selectors), as well as +an abstraction that is useful for other phases of code generation (in +particular, instruction scheduling). Additionally, the SelectionDAG provides a +host representation where a large variety of very-low-level (but +target-independent) optimizations may be +performed: ones which require extensive information about the instructions +efficiently supported by the target. +

        + +

        +The SelectionDAG is a Directed-Acyclic-Graph whose nodes are instances of the +SDNode class. The primary payload of the Node is its operation code +(Opcode) that indicates what the operation the node performs. The various +operation node types are described at the top of the +include/llvm/CodeGen/SelectionDAGNodes.h file. Depending on the operation, nodes may contain additional information (e.g. the condition code +for a SETCC node) contained in a derived class.

        + +

        Each node in the graph may define multiple values +(e.g. for a combined div/rem operation and many other situations), though most +operations define a single value. Each node also has some number of operands, +which are edges to the node defining the used value. Because nodes may define +multiple values, edges are represented by instances of the SDOperand +class, which is a <SDNode, unsigned> pair, indicating the node and result +value being used. Each value produced by a SDNode has an associated +MVT::ValueType, indicating what type the value is. +

        + +

        +SelectionDAGs contain two different kinds of value: those that represent data +flow and those that represent control flow dependencies. Data values are simple +edges with a integer or floating point value type. Control edges are +represented as "chain" edges which are of type MVT::Other. These edges provide +an ordering between nodes that have side effects (such as +loads/stores/calls/return/etc). All nodes that have side effects should take a +token chain as input and produce a new one as output. By convention, token +chain inputs are always operand #0, and chain results are always the last +value produced by an operation.

        + +

        +A SelectionDAG has designated "Entry" and "Root" nodes. The Entry node is +always a marker node with Opcode of ISD::TokenFactor. The Root node is the +final side effecting node in the token chain (for example, in a single basic +block function, this would be the return node). +

        + +

        +One important concept for SelectionDAGs is the notion of a "legal" vs "illegal" +DAG. A legal DAG for a target is one that only uses supported operations and +supported types. On PowerPC, for example, a DAG with any values of i1, i8, i16, +or i64 type would be illegal. The legalize +phase is the one responsible for turning an illegal DAG into a legal DAG. +

        +
        + + + + +
        + +

        +SelectionDAG-based instruction selection consists of the following steps: +

        + +
          +
        1. Build initial DAG - This stage performs + a simple translation from the input LLVM code to an illegal SelectionDAG. +
        2. +
        3. Optimize SelectionDAG - This stage + performs simple optimizations on the SelectionDAG to simplify it and + recognize meta instructions (like rotates and div/rem pairs) for + targets that support these meta operations. This makes the resultant code + more efficient and the 'select' phase more simple. +
        4. +
        5. Legalize SelectionDAG - This stage + converts the illegal SelectionDAG to a legal SelectionDAG, by eliminating + unsupported operations and data types.
        6. +
        7. Optimize SelectionDAG (#2) - This + second run of the SelectionDAG optimized the newly legalized DAG, to + eliminate inefficiencies introduced by legalization.
        8. +
        9. Select instructions from DAG - Finally, + the target instruction selector matches the DAG operations to target + instructions, emitting them and building the MachineFunction being + compiled.
        10. +
        + +

        After all of these steps are complete, the SelectionDAG is destroyed and the +rest of the code generation passes are run.

        + +
        + + + + +
        + +

        +The initial SelectionDAG is naively peephole expanded from the LLVM input by +the SelectionDAGLowering class in the SelectionDAGISel.cpp file. The idea of +doing this pass is to expose as much low-level target-specific details to the +SelectionDAG as possible. This pass is mostly hard-coded (e.g. an LLVM add +turns into a SDNode add, a geteelementptr is expanded into the obvious +arithmetic, etc) but does require target-specific hooks to lower calls and +returns, varargs, etc. For these features, the TargetLowering interface is +used. +

        + +
        + + + + +
        + +

        The Legalize phase is in charge of converting a DAG to only use the types and +operations that are natively supported by the target. This involves two major +tasks:

        + +
          +
        1. Convert values of unsupported types to values of supported types.

          +

          There are two main ways of doing this: promoting a small type to a larger + type (e.g. f32 -> f64, or i16 -> i32), and expanding larger integer types + to smaller ones (e.g. implementing i64 with i32 operations where + possible). Promotion insert sign and zero extensions as needed to make + sure that the final code has the same behavior as the input.

          +
        2. + +
        3. Eliminate operations that are not supported by the target in a supported + type.

          +

          Targets often have wierd constraints, such as not supporting every + operation on every supported datatype (e.g. X86 does not support byte + conditional moves). Legalize takes care of either open-coding another + sequence of operations to emulate the operation (this is known as + expansion), promoting to a larger type that supports the operation + (promotion), or can use a target-specific hook to implement the + legalization.

          +
        4. +
        + +

        +Instead of using a Legalize pass, we could require that every target-specific +selector support and expand every operator +and type even if they are not supported and may require many instructions to +implement (in fact, this is the approach taken by the "simple" selectors). +However, using a Legalize pass allows all of the cannonicalization patterns to +be shared across targets, and makes it very easy to optimize the cannonicalized +code (because it is still in the form of a DAG). +

        + +
        + + + + +
        + +

        +The SelectionDAG optimization phase is run twice for code generation: once +immediately after the DAG is built and once after legalization. The first pass +allows the initial code to be cleaned up, (for example) performing optimizations +that depend on knowing that the operators have restricted type inputs. The second +pass cleans up the messy code generated by the Legalize pass, allowing Legalize to +be very simple (not having to take into account many special cases. +

        + +

        +One important class of optimizations that this pass will do in the future is +optimizing inserted sign and zero extension instructions. Here are some good +papers on the subject:

        + +

        +"Widening +integer arithmetic"
        +Kevin Redwine and Norman Ramsey
        +International Conference on Compiler Construction (CC) 2004 +

        + + +

        + "Effective + sign extension elimination"
        + Motohiro Kawahito, Hideaki Komatsu, and Toshio Nakatani
        + Proceedings of the ACM SIGPLAN 2002 Conference on Programming Language Design + and Implementation. +

        + +
        + + + + +
        + +

        The Select phase is the bulk of the target-specific code for instruction +selection. This phase takes a legal SelectionDAG as input, and does simple +pattern matching on the DAG to generate code. In time, the Select phase will +be automatically generated from the targets InstrInfo.td file, which is why we +want to make the Select phase a simple and mechanical as possible.

        + +
        + + + + +
        + +
          +
        1. Optional whole-function selection.
        2. +
        3. Select is a graph translation phase.
        4. +
        5. Place the machine instrs resulting from Select according to register pressure or a schedule.
        6. +
        7. DAG Scheduling.
        8. +
        9. Auto-generate the Select phase from the target .td files.
        10. +
        + +
        + + + + @@ -570,7 +887,7 @@ code generator currently targets a generic P6-like processor. As such, it produces a few P6-and-above instructions (like conditional moves), but it does not make use of newer features like MMX or SSE. In the future, the X86 backend -will have subtarget support added for specific processor families and +will have sub-target support added for specific processor families and implementations.

        @@ -637,7 +954,7 @@ Chris Lattner
        The LLVM Compiler Infrastructure
        - Last modified: $Date: 2004/12/03 15:59:26 $ + Last modified: $Date: 2005/01/28 17:22:53 $ From lattner at cs.uiuc.edu Fri Jan 28 13:08:47 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 13:08:47 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/ConstProp/2005-01-28-SetCCGEP.ll Message-ID: <200501281908.j0SJ8lx2001787@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/ConstProp: 2005-01-28-SetCCGEP.ll added (r1.1) --- Log message: New testcase. --- Diffs of the changes: (+12 -0) 2005-01-28-SetCCGEP.ll | 12 ++++++++++++ 1 files changed, 12 insertions(+) Index: llvm/test/Regression/Transforms/ConstProp/2005-01-28-SetCCGEP.ll diff -c /dev/null llvm/test/Regression/Transforms/ConstProp/2005-01-28-SetCCGEP.ll:1.1 *** /dev/null Fri Jan 28 13:08:42 2005 --- llvm/test/Regression/Transforms/ConstProp/2005-01-28-SetCCGEP.ll Fri Jan 28 13:08:32 2005 *************** *** 0 **** --- 1,12 ---- + ; RUN: llvm-as < %s | opt -constprop | llvm-dis | not grep 'ret bool false' + + %b = external global [2 x { }] + + implementation + + bool %f() { + ; tmp.2 -> true, not false. + %tmp.2 = seteq { }* getelementptr ([2 x { }]* %b, int 0, int 0), + getelementptr ([2 x { }]* %b, int 0, int 1) + ret bool %tmp.2 + } From lattner at cs.uiuc.edu Fri Jan 28 13:10:04 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 13:10:04 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/ConstantFolding.cpp Message-ID: <200501281910.j0SJA4j9001816@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: ConstantFolding.cpp updated: 1.70 -> 1.71 --- Log message: Fix ConstProp/2005-01-28-SetCCGEP.ll: indexing over zero sized elements does not change the address. --- Diffs of the changes: (+36 -5) ConstantFolding.cpp | 41 ++++++++++++++++++++++++++++++++++++----- 1 files changed, 36 insertions(+), 5 deletions(-) Index: llvm/lib/VMCore/ConstantFolding.cpp diff -u llvm/lib/VMCore/ConstantFolding.cpp:1.70 llvm/lib/VMCore/ConstantFolding.cpp:1.71 --- llvm/lib/VMCore/ConstantFolding.cpp:1.70 Thu Jan 6 10:26:38 2005 +++ llvm/lib/VMCore/ConstantFolding.cpp Fri Jan 28 13:09:51 2005 @@ -623,6 +623,22 @@ return 0; } +/// isZeroSizedType - This type is zero sized if its an array or structure of +/// zero sized types. The only leaf zero sized type is an empty structure. +static bool isMaybeZeroSizedType(const Type *Ty) { + if (isa(Ty)) return true; // Can't say. + if (const StructType *STy = dyn_cast(Ty)) { + + // If all of elements have zero size, this does too. + for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) + if (!isMaybeZeroSizedType(Ty)) return false; + return true; + + } else if (const ArrayType *ATy = dyn_cast(Ty)) { + return isMaybeZeroSizedType(ATy->getElementType()); + } + return false; +} /// IdxCompare - Compare the two constants as though they were getelementptr /// indices. This allows coersion of the types to be the same thing. @@ -631,7 +647,7 @@ /// first is less than the second, return -1, if the second is less than the /// first, return 1. If the constants are not integral, return -2. /// -static int IdxCompare(Constant *C1, Constant *C2) { +static int IdxCompare(Constant *C1, Constant *C2, const Type *ElTy) { if (C1 == C2) return 0; // Ok, we found a different index. Are either of the operands @@ -645,6 +661,11 @@ C2 = ConstantExpr::getSignExtend(C2, Type::LongTy); if (C1 == C2) return 0; // Are they just differing types? + // If the type being indexed over is really just a zero sized type, there is + // no pointer difference being made here. + if (isMaybeZeroSizedType(ElTy)) + return -2; // dunno. + // If they are really different, now that they are the same type, then we // found a difference! if (cast(C1)->getValue() < cast(C2)->getValue()) @@ -779,8 +800,11 @@ unsigned i = 1; // Compare all of the operands the GEP's have in common. - for (;i != CE1->getNumOperands() && i != CE2->getNumOperands(); ++i) - switch (IdxCompare(CE1->getOperand(i), CE2->getOperand(i))) { + gep_type_iterator GTI = gep_type_begin(CE1); + for (;i != CE1->getNumOperands() && i != CE2->getNumOperands(); + ++i, ++GTI) + switch (IdxCompare(CE1->getOperand(i), CE2->getOperand(i), + GTI.getIndexedType())) { case -1: return Instruction::SetLT; case 1: return Instruction::SetGT; case -2: return Instruction::BinaryOpsEnd; @@ -790,10 +814,17 @@ // are non-zero then we have a difference, otherwise we are equal. for (; i < CE1->getNumOperands(); ++i) if (!CE1->getOperand(i)->isNullValue()) - return Instruction::SetGT; + if (isa(CE1->getOperand(i))) + return Instruction::SetGT; + else + return Instruction::BinaryOpsEnd; // Might be equal. + for (; i < CE2->getNumOperands(); ++i) if (!CE2->getOperand(i)->isNullValue()) - return Instruction::SetLT; + if (isa(CE2->getOperand(i))) + return Instruction::SetLT; + else + return Instruction::BinaryOpsEnd; // Might be equal. return Instruction::SetEQ; } } From lattner at cs.uiuc.edu Fri Jan 28 13:32:16 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 13:32:16 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200501281932.j0SJWGZH002372@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.310 -> 1.311 --- Log message: * add some DEBUG statements * Properly compile this: struct a {}; int test() { struct a b[2]; if (&b[0] != &b[1]) abort (); return 0; } to 'return 0', not abort(). --- Diffs of the changes: (+10 -3) InstructionCombining.cpp | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.310 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.311 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.310 Sun Jan 23 14:26:55 2005 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Fri Jan 28 13:32:01 2005 @@ -2198,14 +2198,17 @@ // index is zero or not. if (Cond == Instruction::SetEQ || Cond == Instruction::SetNE) { Instruction *InVal = 0; - for (unsigned i = 1, e = GEPLHS->getNumOperands(); i != e; ++i) { + gep_type_iterator GTI = gep_type_begin(GEPLHS); + for (unsigned i = 1, e = GEPLHS->getNumOperands(); i != e; ++i, ++GTI) { bool EmitIt = true; if (Constant *C = dyn_cast(GEPLHS->getOperand(i))) { if (isa(C)) // undef index -> undef. return ReplaceInstUsesWith(I, UndefValue::get(I.getType())); if (C->isNullValue()) EmitIt = false; - else if (isa(C)) + else if (TD->getTypeSize(GTI.getIndexedType()) == 0) { + EmitIt = false; // This is indexing into a zero sized array? + } else if (isa(C)) return ReplaceInstUsesWith(I, // No comparison is needed here. ConstantBool::get(Cond == Instruction::SetNE)); } @@ -4902,7 +4905,9 @@ AddUsesToWorkList(*I); ++NumDeadInst; - I->getParent()->getInstList().erase(I); + DEBUG(std::cerr << "IC: DCE: " << *I); + + I->eraseFromParent(); removeFromWorkList(I); continue; } @@ -4929,6 +4934,8 @@ } } + DEBUG(std::cerr << "IC: ConstFold to: " << *C << " from: " << *I); + // Add operands to the worklist... AddUsesToWorkList(*I); ReplaceInstUsesWith(*I, C); From lattner at cs.uiuc.edu Fri Jan 28 13:37:48 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 13:37:48 -0600 Subject: [llvm-commits] CVS: llvm/runtime/libtrace/tracelib.c Message-ID: <200501281937.j0SJbmT5002397@apoc.cs.uiuc.edu> Changes in directory llvm/runtime/libtrace: tracelib.c updated: 1.11 -> 1.12 --- Log message: Hrm, who knows what 'uint' is, but it seems to work sometimes? Wierd. --- Diffs of the changes: (+4 -4) tracelib.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) Index: llvm/runtime/libtrace/tracelib.c diff -u llvm/runtime/libtrace/tracelib.c:1.11 llvm/runtime/libtrace/tracelib.c:1.12 --- llvm/runtime/libtrace/tracelib.c:1.11 Wed Sep 1 17:55:37 2004 +++ llvm/runtime/libtrace/tracelib.c Fri Jan 28 13:37:35 2005 @@ -51,12 +51,12 @@ // Use these as the successive sizes of the hash table. #define NUMPRIMES 11 #define FIRSTENTRY 2 -const uint PRIMES[NUMPRIMES] = { (1<<20)-3, (1<<21)-9, (1<<22)-3, (1<<23)-15, +const unsigned PRIMES[NUMPRIMES] = { (1<<20)-3, (1<<21)-9, (1<<22)-3, (1<<23)-15, (1<<24)-3, (1<<25)-39, (1<<26)-5, (1<<27)-39, (1<<28)-57, (1<<29)-3, (1<<30)-35 }; -uint CurrentSizeEntry = FIRSTENTRY; +unsigned CurrentSizeEntry = FIRSTENTRY; -const uint MAX_NUM_PROBES = 4; +const unsigned MAX_NUM_PROBES = 4; typedef struct PtrValueHashEntry_struct { void* key; @@ -170,7 +170,7 @@ Index FindIndex(PtrValueHashTable* ptrTable, void* ptr) { - uint numProbes = 1; + unsigned numProbes = 1; Index index = PointerHashFunc(ptr, ptrTable->capacity); if (ptrTable->fullEmptyFlags[index] == FULL) { From reid at x10sys.com Fri Jan 28 13:52:43 2005 From: reid at x10sys.com (Reid Spencer) Date: Fri, 28 Jan 2005 13:52:43 -0600 Subject: [llvm-commits] CVS: llvm/Makefile.rules Message-ID: <200501281952.NAA20530@zion.cs.uiuc.edu> Changes in directory llvm: Makefile.rules updated: 1.291 -> 1.292 --- Log message: Fix some typos in the Makefile.rules. Patch contributed by Vladimer Merzliakov. --- Diffs of the changes: (+3 -3) Makefile.rules | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Index: llvm/Makefile.rules diff -u llvm/Makefile.rules:1.291 llvm/Makefile.rules:1.292 --- llvm/Makefile.rules:1.291 Sat Jan 15 20:20:54 2005 +++ llvm/Makefile.rules Fri Jan 28 13:52:32 2005 @@ -329,7 +329,7 @@ CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused -LD.Flags += -L$(LibDir) -L$(LLVMLibDir) +LD.Flags += -L$(LibDir) -L$(LLVMLibDir) $(LIBS) CPP.Flags += -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \ -I$(PROJ_OBJ_ROOT)/include \ -I$(PROJ_SRC_ROOT)/include \ @@ -550,7 +550,7 @@ LinkModule := $(LLVMGCCWITHPATH) -shared -nostdlib ifdef EXPORTED_SYMBOL_FILE -LinkMOdule += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE) +LinkModule += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE) endif $(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD) @@ -1280,7 +1280,7 @@ dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL ===== -DistCheckDir := $(LLVM_OBJ_ROOT)/_distcheckdir +DistCheckDir := $(PROJ_OBJ_ROOT)/_distcheckdir dist-check:: $(DistTarGZip) $(Echo) Checking distribution tar file. From lattner at cs.uiuc.edu Fri Jan 28 16:29:35 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 16:29:35 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Message-ID: <200501282229.j0SMTYcr030143@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: LegalizeDAG.cpp updated: 1.54 -> 1.55 --- Log message: Get alpha working with memset/memcpy/memmove --- Diffs of the changes: (+29 -5) LegalizeDAG.cpp | 34 +++++++++++++++++++++++++++++----- 1 files changed, 29 insertions(+), 5 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.54 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.55 --- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.54 Fri Jan 28 00:27:38 2005 +++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Fri Jan 28 16:29:18 2005 @@ -706,11 +706,35 @@ case ISD::MEMSET: case ISD::MEMCPY: case ISD::MEMMOVE: { - Tmp1 = LegalizeOp(Node->getOperand(0)); - Tmp2 = LegalizeOp(Node->getOperand(1)); - Tmp3 = LegalizeOp(Node->getOperand(2)); - SDOperand Tmp4 = LegalizeOp(Node->getOperand(3)); - SDOperand Tmp5 = LegalizeOp(Node->getOperand(4)); + Tmp1 = LegalizeOp(Node->getOperand(0)); // Function + Tmp2 = LegalizeOp(Node->getOperand(1)); // Pointer + + if (Node->getOpcode() == ISD::MEMSET) { // memset = ubyte + switch (getTypeAction(Node->getOperand(2).getValueType())) { + case Expand: assert(0 && "Cannot expand a byte!"); + case Legal: + Tmp3 = LegalizeOp(Node->getOperand(1)); + break; + case Promote: + Tmp3 = PromoteOp(Node->getOperand(1)); + break; + } + } else { + Tmp3 = LegalizeOp(Node->getOperand(2)); // memcpy/move = pointer, + } + SDOperand Tmp4, Tmp5; + + switch (getTypeAction(Node->getOperand(3).getValueType())) { // uint + case Expand: assert(0 && "Cannot expand this yet!"); + case Legal: + Tmp4 = LegalizeOp(Node->getOperand(3)); + Tmp5 = LegalizeOp(Node->getOperand(4)); + break; + case Promote: + Tmp4 = PromoteOp(Node->getOperand(3)); + Tmp5 = PromoteOp(Node->getOperand(4)); + break; + } switch (TLI.getOperationAction(Node->getOpcode(), MVT::Other)) { default: assert(0 && "This action not implemented for this operation!"); From lattner at cs.uiuc.edu Fri Jan 28 16:53:06 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 16:53:06 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Message-ID: <200501282253.j0SMr6Gk007189@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: LegalizeDAG.cpp updated: 1.55 -> 1.56 --- Log message: implement legalization of truncates whose results and sources need to be truncated, e.g. (truncate:i8 something:i16) on a 32 or 64-bit RISC. --- Diffs of the changes: (+5 -2) LegalizeDAG.cpp | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.55 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.56 --- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.55 Fri Jan 28 16:29:18 2005 +++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Fri Jan 28 16:52:50 2005 @@ -1035,10 +1035,13 @@ if (Result.getValueType() > NVT) // Truncate to NVT instead of VT Result = DAG.getNode(ISD::TRUNCATE, NVT, Result); break; + case Promote: + // The truncation is not required, because we don't guarantee anything + // about high bits anyway. + Result = PromoteOp(Node->getOperand(0)); + break; case Expand: assert(0 && "Cannot handle expand yet"); - case Promote: - assert(0 && "Cannot handle promote-promote yet"); } break; case ISD::SIGN_EXTEND: From lattner at cs.uiuc.edu Fri Jan 28 16:58:38 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 16:58:38 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Message-ID: <200501282258.j0SMwcYh007293@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: LegalizeDAG.cpp updated: 1.56 -> 1.57 --- Log message: Alpha doesn't have a native f32 extload instruction. --- Diffs of the changes: (+5 -1) LegalizeDAG.cpp | 6 +++++- 1 files changed, 5 insertions(+), 1 deletion(-) Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.56 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.57 --- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.56 Fri Jan 28 16:52:50 2005 +++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Fri Jan 28 16:58:25 2005 @@ -256,7 +256,11 @@ bool isDouble = VT == MVT::f64; ConstantFP *LLVMC = ConstantFP::get(isDouble ? Type::DoubleTy : Type::FloatTy, CFP->getValue()); - if (isDouble && CFP->isExactlyValue((float)CFP->getValue())) { + if (isDouble && CFP->isExactlyValue((float)CFP->getValue()) && + // Only do this if the target has a native EXTLOAD instruction from + // f32. + TLI.getOperationAction(ISD::EXTLOAD, + MVT::f32) == TargetLowering::Legal) { LLVMC = cast(ConstantExpr::getCast(LLVMC, Type::FloatTy)); VT = MVT::f32; Extend = true; From lattner at cs.uiuc.edu Fri Jan 28 17:17:42 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 17:17:42 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/ConstantFolding.cpp Message-ID: <200501282317.j0SNHgk5011684@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: ConstantFolding.cpp updated: 1.71 -> 1.72 --- Log message: Fix a nasty thinko in my previous commit. --- Diffs of the changes: (+1 -1) ConstantFolding.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/VMCore/ConstantFolding.cpp diff -u llvm/lib/VMCore/ConstantFolding.cpp:1.71 llvm/lib/VMCore/ConstantFolding.cpp:1.72 --- llvm/lib/VMCore/ConstantFolding.cpp:1.71 Fri Jan 28 13:09:51 2005 +++ llvm/lib/VMCore/ConstantFolding.cpp Fri Jan 28 17:17:27 2005 @@ -631,7 +631,7 @@ // If all of elements have zero size, this does too. for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) - if (!isMaybeZeroSizedType(Ty)) return false; + if (!isMaybeZeroSizedType(STy->getElementType(i))) return false; return true; } else if (const ArrayType *ATy = dyn_cast(Ty)) { From alenhar2 at cs.uiuc.edu Fri Jan 28 17:18:10 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Fri, 28 Jan 2005 17:18:10 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp Message-ID: <200501282318.RAA03944@niobe.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.15 -> 1.16 --- Log message: fix ExprMap, partially teach about add long --- Diffs of the changes: (+85 -32) AlphaISelPattern.cpp | 117 +++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 85 insertions(+), 32 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.15 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.16 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.15 Fri Jan 28 08:06:46 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Fri Jan 28 17:17:54 2005 @@ -48,10 +48,10 @@ setOperationAction(ISD::EXTLOAD , MVT::i1 , Promote); - setOperationAction(ISD::ZEXTLOAD , MVT::i1 , Expand); //Should this be Promote? Chris? + setOperationAction(ISD::ZEXTLOAD , MVT::i1 , Expand); setOperationAction(ISD::ZEXTLOAD , MVT::i32 , Expand); - setOperationAction(ISD::SEXTLOAD , MVT::i1 , Expand); //Should this be Promote? Chris? + setOperationAction(ISD::SEXTLOAD , MVT::i1 , Expand); setOperationAction(ISD::SEXTLOAD , MVT::i8 , Expand); setOperationAction(ISD::SEXTLOAD , MVT::i16 , Expand); @@ -148,7 +148,7 @@ argVreg.push_back(MF.getSSARegMap()->createVirtualRegister(getRegClassFor(getValueType(I->getType())))); argPreg.push_back(args_float[count - 1]); argOpc.push_back(Alpha::CPYS); - newroot = DAG.getCopyFromReg(argVreg[count], getValueType(I->getType()), DAG.getRoot()); + newroot = DAG.getCopyFromReg(argVreg[count-1], getValueType(I->getType()), DAG.getRoot()); break; case MVT::i1: case MVT::i8: @@ -159,7 +159,7 @@ argVreg.push_back(MF.getSSARegMap()->createVirtualRegister(getRegClassFor(MVT::i64))); argPreg.push_back(args_int[count - 1]); argOpc.push_back(Alpha::BIS); - argt = newroot = DAG.getCopyFromReg(argVreg[count], MVT::i64, DAG.getRoot()); + argt = newroot = DAG.getCopyFromReg(argVreg[count-1], MVT::i64, DAG.getRoot()); if (getValueType(I->getType()) != MVT::i64) argt = DAG.getNode(ISD::TRUNCATE, getValueType(I->getType()), newroot); break; @@ -170,7 +170,6 @@ BuildMI(&BB, Alpha::IDEF, 0, Alpha::R29); BuildMI(&BB, Alpha::BIS, 2, GP).addReg(Alpha::R29).addReg(Alpha::R29); - count = 0; for (int i = 0; i < count; ++i) BuildMI(&BB, argOpc[i], 2, argVreg[i]).addReg(argPreg[i]).addReg(argPreg[i]); @@ -201,6 +200,8 @@ Args[i].first = DAG.getNode(ISD::ZERO_EXTEND, MVT::i64, Args[i].first); break; case MVT::i64: + case MVT::f64: + case MVT::f32: break; } args_to_use.push_back(Args[i].first); @@ -258,6 +259,7 @@ /// ExprMap - As shared expressions are codegen'd, we keep track of which /// vreg the value is produced in, so we only emit one copy of each compiled /// tree. + static const unsigned notIn = (unsigned)(-1); std::map ExprMap; public: @@ -292,7 +294,33 @@ default: Node->dump(); assert(0 && "Node not handled!\n"); - + case ISD::LOAD: + { + // Make sure we generate both values. + if (Result != notIn) + ExprMap[N.getValue(1)] = notIn; // Generate the token + else + Result = ExprMap[N.getValue(0)] = MakeReg(N.getValue(0).getValueType()); + + SDOperand Chain = N.getOperand(0); + SDOperand Address = N.getOperand(1); + + if (Address.getOpcode() == ISD::GlobalAddress) + { + Select(Chain); + AlphaLowering.restoreGP(BB); + Opc = DestType == MVT::f64 ? Alpha::LDS : Alpha::LDT; + BuildMI(BB, Opc, 1, Result).addGlobalAddress(cast(Address)->getGlobal()); + } + else + { + Select(Chain); + Tmp2 = SelectExpr(Address); + Opc = DestType == MVT::f64 ? Alpha::LDS : Alpha::LDT; + BuildMI(BB, Opc, 2, Result).addImm(0).addReg(Tmp2); + } + return Result; + } case ISD::ConstantFP: if (ConstantFPSDNode *CN = dyn_cast(N)) { if (CN->isExactlyValue(+0.0)) { @@ -349,18 +377,18 @@ if (N.getOpcode() != ISD::CALL) Reg = Result = (N.getValueType() != MVT::Other) ? - MakeReg(N.getValueType()) : 1; + MakeReg(N.getValueType()) : notIn; else { // If this is a call instruction, make sure to prepare ALL of the result // values as well as the chain. if (Node->getNumValues() == 1) - Reg = Result = 1; // Void call, just a chain. + Reg = Result = notIn; // 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; + ExprMap[SDOperand(Node, Node->getNumValues()-1)] = notIn; } } @@ -379,8 +407,8 @@ case ISD::EXTLOAD: // Make sure we generate both values. - if (Result != 1) - ExprMap[N.getValue(1)] = 1; // Generate the token + if (Result != notIn) + ExprMap[N.getValue(1)] = notIn; // Generate the token else Result = ExprMap[N.getValue(0)] = MakeReg(N.getValue(0).getValueType()); @@ -403,7 +431,7 @@ case MVT::i16: BuildMI(BB, Alpha::LDWU, 2, Result).addImm(0).addReg(Tmp1); break; - case MVT::i1: //Treat i1 as i8 since there are problems otherwise + case MVT::i1: //FIXME: Treat i1 as i8 since there are problems otherwise case MVT::i8: BuildMI(BB, Alpha::LDBU, 2, Result).addImm(0).addReg(Tmp1); break; @@ -414,8 +442,8 @@ case ISD::SEXTLOAD: // Make sure we generate both values. - if (Result != 1) - ExprMap[N.getValue(1)] = 1; // Generate the token + if (Result != notIn) + ExprMap[N.getValue(1)] = notIn; // Generate the token else Result = ExprMap[N.getValue(0)] = MakeReg(N.getValue(0).getValueType()); @@ -438,8 +466,8 @@ case ISD::ZEXTLOAD: // Make sure we generate both values. - if (Result != 1) - ExprMap[N.getValue(1)] = 1; // Generate the token + if (Result != notIn) + ExprMap[N.getValue(1)] = notIn; // Generate the token else Result = ExprMap[N.getValue(0)] = MakeReg(N.getValue(0).getValueType()); @@ -475,7 +503,7 @@ Select(N.getOperand(0)); // The chain for this call is now lowered. - ExprMap.insert(std::make_pair(N.getValue(Node->getNumValues()-1), 1)); + ExprMap.insert(std::make_pair(N.getValue(Node->getNumValues()-1), notIn)); //grab the arguments std::vector argvregs; @@ -525,17 +553,15 @@ else { Tmp1 = SelectExpr(N.getOperand(1)); - BuildMI(BB, Alpha::CALL, 1).addReg(Tmp1); AlphaLowering.restoreGP(BB); + BuildMI(BB, Alpha::CALL, 1).addReg(Tmp1); } //push the result into a virtual register - // if (Result != 1) - // BuildMI(BB, Alpha::BIS, 2, Result).addReg(Alpha::R0).addReg(Alpha::R0); switch (Node->getValueType(0)) { default: Node->dump(); assert(0 && "Unknown value type for call result!"); - case MVT::Other: return 1; + case MVT::Other: return notIn; case MVT::i1: case MVT::i8: case MVT::i16: @@ -556,6 +582,37 @@ case ISD::SIGN_EXTEND_INREG: { + //Alpha has instructions for a bunch of signed 32 bit stuff + if( dyn_cast(Node)->getExtraValueType() == MVT::i32) + { + switch (N.getOperand(0).getOpcode()) { + case ISD::ADD: + case ISD::SUB: + case ISD::MUL: + { + bool isAdd = N.getOperand(0).getOpcode() == ISD::ADD; + bool isMul = N.getOperand(0).getOpcode() == ISD::MUL; + //FIXME: first check for Scaled Adds and Subs! + if(N.getOperand(0).getOperand(1).getOpcode() == ISD::Constant && + cast(N.getOperand(0).getOperand(1))->getValue() <= 255) + { //Normal imm add/sub + Opc = isAdd ? Alpha::ADDLi : (isMul ? Alpha::MULLi : Alpha::SUBLi); + Tmp1 = SelectExpr(N.getOperand(0).getOperand(0)); + Tmp2 = cast(N.getOperand(0).getOperand(1))->getValue(); + BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addImm(Tmp2); + } + else + { //Normal add/sub + Opc = isAdd ? Alpha::ADDL : (isMul ? Alpha::MULLi : Alpha::SUBL); + Tmp1 = SelectExpr(N.getOperand(0).getOperand(0)); + Tmp2 = SelectExpr(N.getOperand(0).getOperand(1)); + BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); + } + return Result; + } + default: break; //Fall Though; + } + } //Every thing else fall though too, including unhandled opcodes above Tmp1 = SelectExpr(N.getOperand(0)); MVTSDNode* MVN = dyn_cast(Node); //std::cerr << "SrcT: " << MVN->getExtraValueType() << "\n"; @@ -611,11 +668,9 @@ //Tmp1 = SelectExpr(N.getOperand(0)); if(N.getOperand(0).getOpcode() == ISD::Constant && - cast(N.getOperand(0))->getValue() >= 0 && cast(N.getOperand(0))->getValue() <= 255) isConst1 = true; if(N.getOperand(1).getOpcode() == ISD::Constant && - cast(N.getOperand(1))->getValue() >= 0 && cast(N.getOperand(1))->getValue() <= 255) isConst2 = true; @@ -638,7 +693,8 @@ Tmp3 = MakeReg(MVT::i64); BuildMI(BB, Alpha::CMPEQ, 2, Tmp3).addReg(Tmp1).addReg(Tmp2); //and invert - BuildMI(BB,Alpha::ORNOT, 2, Result).addReg(Alpha::R31).addReg(Tmp3); + BuildMI(BB, Alpha::CMPEQ, 2, Result).addReg(Alpha::R31).addReg(Tmp3); + //BuildMI(BB,Alpha::ORNOT, 2, Result).addReg(Alpha::R31).addReg(Tmp3); return Result; } } @@ -693,8 +749,8 @@ case ISD::CopyFromReg: { // Make sure we generate both values. - if (Result != 1) - ExprMap[N.getValue(1)] = 1; // Generate the token + if (Result != notIn) + ExprMap[N.getValue(1)] = notIn; // Generate the token else Result = ExprMap[N.getValue(0)] = MakeReg(N.getValue(0).getValueType()); @@ -717,7 +773,6 @@ case ISD::MUL: assert (DestType == MVT::i64 && "Only do arithmetic on i64s!"); if(N.getOperand(1).getOpcode() == ISD::Constant && - cast(N.getOperand(1))->getValue() >= 0 && cast(N.getOperand(1))->getValue() <= 255) { switch(opcode) { @@ -757,7 +812,6 @@ //FIXME: first check for Scaled Adds and Subs! if(N.getOperand(1).getOpcode() == ISD::Constant && - cast(N.getOperand(1))->getValue() >= 0 && cast(N.getOperand(1))->getValue() <= 255) { //Normal imm add/sub Opc = isAdd ? Alpha::ADDQi : Alpha::SUBQi; @@ -766,7 +820,6 @@ BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addImm(Tmp2); } else if(N.getOperand(1).getOpcode() == ISD::Constant && - cast(N.getOperand(1))->getValue() >= 0 && cast(N.getOperand(1))->getValue() <= 32767) { //LDA //FIXME: expand the above condition a bit Tmp1 = SelectExpr(N.getOperand(0)); @@ -836,8 +889,8 @@ case ISD::LOAD: { // Make sure we generate both values. - if (Result != 1) - ExprMap[N.getValue(1)] = 1; // Generate the token + if (Result != notIn) + ExprMap[N.getValue(1)] = notIn; // Generate the token else Result = ExprMap[N.getValue(0)] = MakeReg(N.getValue(0).getValueType()); @@ -867,7 +920,7 @@ unsigned Tmp1, Tmp2, Opc; // FIXME: Disable for our current expansion model! - if (/*!N->hasOneUse() &&*/ !ExprMap.insert(std::make_pair(N, 1)).second) + if (/*!N->hasOneUse() &&*/ !ExprMap.insert(std::make_pair(N, notIn)).second) return; // Already selected. SDNode *Node = N.Val; From lattner at cs.uiuc.edu Fri Jan 28 18:29:55 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 18:29:55 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/User.h Message-ID: <200501290029.j0T0TtCB006220@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: User.h updated: 1.32 -> 1.33 --- Log message: Instead of storing operands as std::vector, just maintain a pointer and num operands in the User class. this allows us to embed the operands directly in the subclasses if possible. For example, for binary operators we store the two operands in the derived class. The has several effects: 1. it improves locality because the operands and instruction are together 2. it makes accesses to operands faster (one less load) if you access them through the derived class pointer. For example this: Value *GetBinaryOperatorOp(BinaryOperator *I, int i) { return I->getOperand(i); } Was compiled to: _Z19GetBinaryOperatorOpPN4llvm14BinaryOperatorEi: movl 4(%esp), %edx movl 8(%esp), %eax sall $4, %eax movl 24(%edx), %ecx addl %ecx, %eax movl (%eax), %eax ret and is now compiled to: _Z19GetBinaryOperatorOpPN4llvm14BinaryOperatorEi: movl 8(%esp), %eax movl 4(%esp), %edx sall $4, %eax addl %edx, %eax movl 44(%eax), %eax ret Accesses through "Instruction*" are unmodified. 3. This reduces memory consumption (by about 3%) by eliminating 1 word of vector overhead and a malloc header on a seperate object. 4. This speeds up gccas about 10% (both debug and release builds) on large things (such as 176.gcc). For example, it takes a debug build from 172.9 -> 155.6s and a release gccas from 67.7 -> 61.8s --- Diffs of the changes: (+33 -34) User.h | 67 ++++++++++++++++++++++++++++++++--------------------------------- 1 files changed, 33 insertions(+), 34 deletions(-) Index: llvm/include/llvm/User.h diff -u llvm/include/llvm/User.h:1.32 llvm/include/llvm/User.h:1.33 --- llvm/include/llvm/User.h:1.32 Mon Nov 15 13:02:35 2004 +++ llvm/include/llvm/User.h Fri Jan 28 18:29:39 2005 @@ -27,45 +27,42 @@ class User : public Value { User(const User &); // Do not implement protected: - std::vector Operands; -public: - User(const Type *Ty, unsigned vty, const std::string &name = "") - : Value(Ty, vty, name) {} + /// OperandList - This is a pointer to the array of Users for this operand. + /// For nodes of fixed arity (e.g. a binary operator) this array will live + /// embedded into the derived class. For nodes of variable arity + /// (e.g. ConstantArrays, CallInst, PHINodes, etc), this memory will be + /// dynamically allocated and should be destroyed by the classes virtual dtor. + Use *OperandList; + + /// NumOperands - The number of values used by this User. + /// + unsigned NumOperands; - inline Value *getOperand(unsigned i) { - assert(i < Operands.size() && "getOperand() out of range!"); - return Operands[i]; - } - inline const Value *getOperand(unsigned i) const { - assert(i < Operands.size() && "getOperand() const out of range!"); - return Operands[i]; - } - inline void setOperand(unsigned i, Value *Val) { - assert(i < Operands.size() && "setOperand() out of range!"); - Operands[i] = Val; +public: + User(const Type *Ty, unsigned vty, Use *OpList, unsigned NumOps, + const std::string &name = "") + : Value(Ty, vty, name), OperandList(OpList), NumOperands(NumOps) {} + + Value *getOperand(unsigned i) const { + assert(i < NumOperands && "getOperand() out of range!"); + return OperandList[i]; + } + void setOperand(unsigned i, Value *Val) { + assert(i < NumOperands && "setOperand() out of range!"); + OperandList[i] = Val; } - inline unsigned getNumOperands() const { return (unsigned)Operands.size(); } + unsigned getNumOperands() const { return NumOperands; } // --------------------------------------------------------------------------- // Operand Iterator interface... // - typedef std::vector::iterator op_iterator; - typedef std::vector::const_iterator const_op_iterator; + typedef Use* op_iterator; + typedef const Use* const_op_iterator; - void op_reserve(unsigned NumElements) { Operands.reserve(NumElements); } - - inline op_iterator op_begin() { return Operands.begin(); } - inline const_op_iterator op_begin() const { return Operands.begin(); } - inline op_iterator op_end() { return Operands.end(); } - inline const_op_iterator op_end() const { return Operands.end(); } - - /// op_erase - This method is used to remove one of the arguments from the - /// operands list. Only use this if you know what you are doing. - /// - op_iterator op_erase(op_iterator I) { return Operands.erase(I); } - op_iterator op_erase(op_iterator I, op_iterator E) { - return Operands.erase(I, E); - } + inline op_iterator op_begin() { return OperandList; } + inline const_op_iterator op_begin() const { return OperandList; } + inline op_iterator op_end() { return OperandList+NumOperands; } + inline const_op_iterator op_end() const { return OperandList+NumOperands; } // dropAllReferences() - This function is in charge of "letting go" of all // objects that this User refers to. This allows one to @@ -75,8 +72,10 @@ // valid on an object that has "dropped all references", except operator // delete. // - inline void dropAllReferences() { - Operands.clear(); + void dropAllReferences() { + Use *OL = OperandList; + for (unsigned i = 0, e = NumOperands; i != e; ++i) + OL[i].set(0); } /// replaceUsesOfWith - Replaces all references to the "From" definition with From lattner at cs.uiuc.edu Fri Jan 28 18:30:55 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 18:30:55 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Value.h Message-ID: <200501290030.j0T0Utuu006248@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: Value.h updated: 1.67 -> 1.68 --- Log message: Adjust to User.h changes. --- Diffs of the changes: (+3 -6) Value.h | 9 +++------ 1 files changed, 3 insertions(+), 6 deletions(-) Index: llvm/include/llvm/Value.h diff -u llvm/include/llvm/Value.h:1.67 llvm/include/llvm/Value.h:1.68 --- llvm/include/llvm/Value.h:1.67 Mon Dec 13 10:28:53 2004 +++ llvm/include/llvm/Value.h Fri Jan 28 18:30:42 2005 @@ -41,7 +41,6 @@ /// as operands to other values. /// class Value { -private: unsigned SubclassID; // Subclass identifier (for isa/dyn_cast) PATypeHolder Ty; iplist Uses; @@ -168,11 +167,9 @@ } -Use::Use(Value *v, User *user) : Val(v), U(user) { - if (Val) Val->addUse(*this); -} - -Use::Use(const Use &u) : Val(u.Val), U(u.U) { +void Use::init(Value *v, User *user) { + Val = v; + U = user; if (Val) Val->addUse(*this); } From lattner at cs.uiuc.edu Fri Jan 28 18:31:04 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 18:31:04 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Use.h Message-ID: <200501290031.j0T0V4hS006257@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: Use.h updated: 1.7 -> 1.8 --- Log message: Adjust to User.h changes. --- Diffs of the changes: (+9 -2) Use.h | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) Index: llvm/include/llvm/Use.h diff -u llvm/include/llvm/Use.h:1.7 llvm/include/llvm/Use.h:1.8 --- llvm/include/llvm/Use.h:1.7 Wed Oct 27 11:14:47 2004 +++ llvm/include/llvm/Use.h Fri Jan 28 18:30:52 2005 @@ -37,10 +37,17 @@ Use *Prev, *Next; friend struct ilist_traits; public: - inline Use(Value *v, User *user); - inline Use(const Use &u); + inline void init(Value *V, User *U); + + Use(Value *V, User *U) { init(V, U); } + Use(const Use &U) { init(U.Val, U.U); } inline ~Use(); + /// Default ctor - This leaves the Use completely unitialized. The only thing + /// that is valid to do with this use is to call the "init" method. + inline Use() : Val(0) {} + + operator Value*() const { return Val; } Value *get() const { return Val; } User *getUser() const { return U; } From lattner at cs.uiuc.edu Fri Jan 28 18:31:49 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 18:31:49 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Instructions.h Message-ID: <200501290031.j0T0Vn8d006273@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: Instructions.h updated: 1.11 -> 1.12 --- Log message: Many changes to cope with the User.h changes. Instructions now generally directly embed their operands. --- Diffs of the changes: (+306 -234) Instructions.h | 540 ++++++++++++++++++++++++++++++++------------------------- 1 files changed, 306 insertions(+), 234 deletions(-) Index: llvm/include/llvm/Instructions.h diff -u llvm/include/llvm/Instructions.h:1.11 llvm/include/llvm/Instructions.h:1.12 --- llvm/include/llvm/Instructions.h:1.11 Fri Dec 10 14:35:47 2004 +++ llvm/include/llvm/Instructions.h Fri Jan 28 18:31:36 2005 @@ -31,9 +31,8 @@ /// AllocationInst - This class is the common base class of MallocInst and /// AllocaInst. /// -class AllocationInst : public Instruction { +class AllocationInst : public UnaryInstruction { protected: - void init(const Type *Ty, Value *ArraySize, unsigned iTy); AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, const std::string &Name = "", Instruction *InsertBefore = 0); AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, @@ -49,8 +48,8 @@ /// getArraySize - Get the number of element allocated, for a simple /// allocation of a single element, this will return a constant 1 value. /// - inline const Value *getArraySize() const { return Operands[0]; } - inline Value *getArraySize() { return Operands[0]; } + inline const Value *getArraySize() const { return getOperand(0); } + inline Value *getArraySize() { return getOperand(0); } /// getType - Overload to return most specific pointer type /// @@ -143,9 +142,8 @@ /// FreeInst - an instruction to deallocate memory /// -class FreeInst : public Instruction { - void init(Value *Ptr); - +class FreeInst : public UnaryInstruction { + void AssertOK(); public: explicit FreeInst(Value *Ptr, Instruction *InsertBefore = 0); FreeInst(Value *Ptr, BasicBlock *InsertAfter); @@ -171,13 +169,17 @@ /// LoadInst - an instruction for reading from memory /// -class LoadInst : public Instruction { - LoadInst(const LoadInst &LI) : Instruction(LI.getType(), Load) { - Volatile = LI.isVolatile(); - init(LI.Operands[0]); - } +class LoadInst : public UnaryInstruction { bool Volatile; // True if this is a volatile load - void init(Value *Ptr); + + LoadInst(const LoadInst &LI) + : UnaryInstruction(LI.getType(), Load, LI.getOperand(0)), + Volatile(LI.isVolatile()) { +#ifndef NDEBUG + AssertOK(); +#endif + } + void AssertOK(); public: LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBefore); LoadInst(Value *Ptr, const std::string &Name, BasicBlock *InsertAtEnd); @@ -221,12 +223,17 @@ /// StoreInst - an instruction for storing to memory /// class StoreInst : public Instruction { - StoreInst(const StoreInst &SI) : Instruction(SI.getType(), Store) { - Volatile = SI.isVolatile(); - init(SI.Operands[0], SI.Operands[1]); - } + Use Ops[2]; bool Volatile; // True if this is a volatile store - void init(Value *Val, Value *Ptr); + StoreInst(const StoreInst &SI) : Instruction(SI.getType(), Store, Ops, 2), + Volatile(SI.isVolatile()) { + Ops[0].init(SI.Ops[0], this); + Ops[1].init(SI.Ops[1], this); +#ifndef NDEBUG + AssertOK(); +#endif + } + void AssertOK(); public: StoreInst(Value *Val, Value *Ptr, Instruction *InsertBefore); StoreInst(Value *Val, Value *Ptr, BasicBlock *InsertAtEnd); @@ -244,6 +251,18 @@ /// void setVolatile(bool V) { Volatile = V; } + /// Transparently provide more efficient getOperand methods. + Value *getOperand(unsigned i) const { + assert(i < 2 && "getOperand() out of range!"); + return Ops[i]; + } + void setOperand(unsigned i, Value *Val) { + assert(i < 2 && "setOperand() out of range!"); + Ops[i] = Val; + } + unsigned getNumOperands() const { return 2; } + + virtual StoreInst *clone() const; virtual bool mayWriteToMemory() const { return true; } @@ -271,12 +290,13 @@ /// access elements of arrays and structs /// class GetElementPtrInst : public Instruction { - GetElementPtrInst(const GetElementPtrInst &EPI) - : Instruction((static_cast(&EPI)->getType()), - GetElementPtr) { - Operands.reserve(EPI.Operands.size()); - for (unsigned i = 0, E = (unsigned)EPI.Operands.size(); i != E; ++i) - Operands.push_back(Use(EPI.Operands[i], this)); + GetElementPtrInst(const GetElementPtrInst &GEPI) + : Instruction(reinterpret_cast(GEPI.getType()), GetElementPtr, + 0, GEPI.getNumOperands()) { + Use *OL = OperandList = new Use[NumOperands]; + Use *GEPIOL = GEPI.OperandList; + for (unsigned i = 0, E = NumOperands; i != E; ++i) + OL[i].init(GEPIOL[i], this); } void init(Value *Ptr, const std::vector &Idx); void init(Value *Ptr, Value *Idx0, Value *Idx1); @@ -296,6 +316,7 @@ const std::string &Name = "", Instruction *InsertBefore =0); GetElementPtrInst(Value *Ptr, Value *Idx0, Value *Idx1, const std::string &Name, BasicBlock *InsertAtEnd); + ~GetElementPtrInst(); virtual GetElementPtrInst *clone() const; @@ -408,25 +429,18 @@ /// CastInst - This class represents a cast from Operand[0] to the type of /// the instruction (i->getType()). /// -class CastInst : public Instruction { - CastInst(const CastInst &CI) : Instruction(CI.getType(), Cast) { - Operands.reserve(1); - Operands.push_back(Use(CI.Operands[0], this)); - } - void init(Value *S) { - Operands.reserve(1); - Operands.push_back(Use(S, this)); +class CastInst : public UnaryInstruction { + CastInst(const CastInst &CI) + : UnaryInstruction(CI.getType(), Cast, CI.getOperand(0)) { } public: CastInst(Value *S, const Type *Ty, const std::string &Name = "", Instruction *InsertBefore = 0) - : Instruction(Ty, Cast, Name, InsertBefore) { - init(S); + : UnaryInstruction(Ty, Cast, S, Name, InsertBefore) { } CastInst(Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd) - : Instruction(Ty, Cast, Name, InsertAtEnd) { - init(S); + : UnaryInstruction(Ty, Cast, S, Name, InsertAtEnd) { } virtual CastInst *clone() const; @@ -476,6 +490,7 @@ Instruction *InsertBefore = 0); explicit CallInst(Value *F, const std::string &Name, BasicBlock *InsertAtEnd); + ~CallInst(); virtual CallInst *clone() const; bool mayWriteToMemory() const { return true; } @@ -484,12 +499,12 @@ /// if it is a direct call. If it is a call through a function pointer, /// return null. Function *getCalledFunction() const { - return dyn_cast(Operands[0]); + return (Function*)dyn_cast(getOperand(0)); } // getCalledValue - Get a pointer to a method that is invoked by this inst. - inline const Value *getCalledValue() const { return Operands[0]; } - inline Value *getCalledValue() { return Operands[0]; } + inline const Value *getCalledValue() const { return getOperand(0); } + inline Value *getCalledValue() { return getOperand(0); } // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const CallInst *) { return true; } @@ -509,27 +524,27 @@ /// ShiftInst - This class represents left and right shift instructions. /// class ShiftInst : public Instruction { - ShiftInst(const ShiftInst &SI) : Instruction(SI.getType(), SI.getOpcode()) { - Operands.reserve(2); - Operands.push_back(Use(SI.Operands[0], this)); - Operands.push_back(Use(SI.Operands[1], this)); + Use Ops[2]; + ShiftInst(const ShiftInst &SI) + : Instruction(SI.getType(), SI.getOpcode(), Ops, 2) { + Ops[0].init(SI.Ops[0], this); + Ops[1].init(SI.Ops[1], this); } void init(OtherOps Opcode, Value *S, Value *SA) { assert((Opcode == Shl || Opcode == Shr) && "ShiftInst Opcode invalid!"); - Operands.reserve(2); - Operands.push_back(Use(S, this)); - Operands.push_back(Use(SA, this)); + Ops[0].init(S, this); + Ops[1].init(SA, this); } public: ShiftInst(OtherOps Opcode, Value *S, Value *SA, const std::string &Name = "", Instruction *InsertBefore = 0) - : Instruction(S->getType(), Opcode, Name, InsertBefore) { + : Instruction(S->getType(), Opcode, Ops, 2, Name, InsertBefore) { init(Opcode, S, SA); } ShiftInst(OtherOps Opcode, Value *S, Value *SA, const std::string &Name, BasicBlock *InsertAtEnd) - : Instruction(S->getType(), Opcode, Name, InsertAtEnd) { + : Instruction(S->getType(), Opcode, Ops, 2, Name, InsertAtEnd) { init(Opcode, S, SA); } @@ -537,6 +552,17 @@ return static_cast(Instruction::getOpcode()); } + /// Transparently provide more efficient getOperand methods. + Value *getOperand(unsigned i) const { + assert(i < 2 && "getOperand() out of range!"); + return Ops[i]; + } + void setOperand(unsigned i, Value *Val) { + assert(i < 2 && "setOperand() out of range!"); + Ops[i] = Val; + } + unsigned getNumOperands() const { return 2; } + virtual ShiftInst *clone() const; // Methods for support type inquiry through isa, cast, and dyn_cast: @@ -557,34 +583,46 @@ /// SelectInst - This class represents the LLVM 'select' instruction. /// class SelectInst : public Instruction { - SelectInst(const SelectInst &SI) : Instruction(SI.getType(), SI.getOpcode()) { - Operands.reserve(3); - Operands.push_back(Use(SI.Operands[0], this)); - Operands.push_back(Use(SI.Operands[1], this)); - Operands.push_back(Use(SI.Operands[2], this)); - } + Use Ops[3]; + void init(Value *C, Value *S1, Value *S2) { - Operands.reserve(3); - Operands.push_back(Use(C, this)); - Operands.push_back(Use(S1, this)); - Operands.push_back(Use(S2, this)); + Ops[0].init(C, this); + Ops[1].init(S1, this); + Ops[2].init(S2, this); } + SelectInst(const SelectInst &SI) + : Instruction(SI.getType(), SI.getOpcode(), Ops, 3) { + init(SI.Ops[0], SI.Ops[1], SI.Ops[2]); + } public: SelectInst(Value *C, Value *S1, Value *S2, const std::string &Name = "", Instruction *InsertBefore = 0) - : Instruction(S1->getType(), Instruction::Select, Name, InsertBefore) { + : Instruction(S1->getType(), Instruction::Select, Ops, 3, + Name, InsertBefore) { init(C, S1, S2); } SelectInst(Value *C, Value *S1, Value *S2, const std::string &Name, BasicBlock *InsertAtEnd) - : Instruction(S1->getType(), Instruction::Select, Name, InsertAtEnd) { + : Instruction(S1->getType(), Instruction::Select, Ops, 3, + Name, InsertAtEnd) { init(C, S1, S2); } - Value *getCondition() const { return Operands[0]; } - Value *getTrueValue() const { return Operands[1]; } - Value *getFalseValue() const { return Operands[2]; } + Value *getCondition() const { return Ops[0]; } + Value *getTrueValue() const { return Ops[1]; } + Value *getFalseValue() const { return Ops[2]; } + + /// Transparently provide more efficient getOperand methods. + Value *getOperand(unsigned i) const { + assert(i < 3 && "getOperand() out of range!"); + return Ops[i]; + } + void setOperand(unsigned i, Value *Val) { + assert(i < 3 && "setOperand() out of range!"); + Ops[i] = Val; + } + unsigned getNumOperands() const { return 3; } OtherOps getOpcode() const { return static_cast(Instruction::getOpcode()); @@ -611,27 +649,23 @@ /// advances a vararg list passed an argument of the specified type, returning /// the resultant list. /// -class VANextInst : public Instruction { +class VANextInst : public UnaryInstruction { PATypeHolder ArgTy; - void init(Value *List) { - Operands.reserve(1); - Operands.push_back(Use(List, this)); - } VANextInst(const VANextInst &VAN) - : Instruction(VAN.getType(), VANext), ArgTy(VAN.getArgType()) { - init(VAN.Operands[0]); + : UnaryInstruction(VAN.getType(), VANext, VAN.getOperand(0)), + ArgTy(VAN.getArgType()) { } public: VANextInst(Value *List, const Type *Ty, const std::string &Name = "", Instruction *InsertBefore = 0) - : Instruction(List->getType(), VANext, Name, InsertBefore), ArgTy(Ty) { - init(List); + : UnaryInstruction(List->getType(), VANext, List, Name, InsertBefore), + ArgTy(Ty) { } VANextInst(Value *List, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd) - : Instruction(List->getType(), VANext, Name, InsertAtEnd), ArgTy(Ty) { - init(List); + : UnaryInstruction(List->getType(), VANext, List, Name, InsertAtEnd), + ArgTy(Ty) { } const Type *getArgType() const { return ArgTy; } @@ -656,25 +690,17 @@ /// VAArgInst - This class represents the va_arg llvm instruction, which returns /// an argument of the specified type given a va_list. /// -class VAArgInst : public Instruction { - void init(Value* List) { - Operands.reserve(1); - Operands.push_back(Use(List, this)); - } +class VAArgInst : public UnaryInstruction { VAArgInst(const VAArgInst &VAA) - : Instruction(VAA.getType(), VAArg) { - init(VAA.Operands[0]); - } + : UnaryInstruction(VAA.getType(), VAArg, VAA.getOperand(0)) {} public: VAArgInst(Value *List, const Type *Ty, const std::string &Name = "", Instruction *InsertBefore = 0) - : Instruction(Ty, VAArg, Name, InsertBefore) { - init(List); + : UnaryInstruction(Ty, VAArg, List, Name, InsertBefore) { } VAArgInst(Value *List, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd) - : Instruction(Ty, VAArg, Name, InsertAtEnd) { - init(List); + : UnaryInstruction(Ty, VAArg, List, Name, InsertAtEnd) { } virtual VAArgInst *clone() const; @@ -698,46 +724,59 @@ // scientist's overactive imagination. // class PHINode : public Instruction { + /// ReservedSpace - The number of operands actually allocated. NumOperands is + /// the number actually in use. + unsigned ReservedSpace; PHINode(const PHINode &PN); public: PHINode(const Type *Ty, const std::string &Name = "", Instruction *InsertBefore = 0) - : Instruction(Ty, Instruction::PHI, Name, InsertBefore) { + : Instruction(Ty, Instruction::PHI, 0, 0, Name, InsertBefore), + ReservedSpace(0) { } PHINode(const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd) - : Instruction(Ty, Instruction::PHI, Name, InsertAtEnd) { + : Instruction(Ty, Instruction::PHI, 0, 0, Name, InsertAtEnd), + ReservedSpace(0) { + } + + ~PHINode(); + + /// reserveOperandSpace - This method can be used to avoid repeated + /// reallocation of PHI operand lists by reserving space for the correct + /// number of operands before adding them. Unlike normal vector reserves, + /// this method can also be used to trim the operand space. + void reserveOperandSpace(unsigned NumValues) { + resizeOperands(NumValues*2); } virtual PHINode *clone() const; /// getNumIncomingValues - Return the number of incoming edges /// - unsigned getNumIncomingValues() const { return (unsigned)Operands.size()/2; } + unsigned getNumIncomingValues() const { return getNumOperands()/2; } /// getIncomingValue - Return incoming value #x /// Value *getIncomingValue(unsigned i) const { - assert(i*2 < Operands.size() && "Invalid value number!"); - return Operands[i*2]; + assert(i*2 < getNumOperands() && "Invalid value number!"); + return getOperand(i*2); } void setIncomingValue(unsigned i, Value *V) { - assert(i*2 < Operands.size() && "Invalid value number!"); - Operands[i*2] = V; + assert(i*2 < getNumOperands() && "Invalid value number!"); + setOperand(i*2, V); } - inline unsigned getOperandNumForIncomingValue(unsigned i) { + unsigned getOperandNumForIncomingValue(unsigned i) { return i*2; } /// getIncomingBlock - Return incoming basic block #x /// BasicBlock *getIncomingBlock(unsigned i) const { - assert(i*2+1 < Operands.size() && "Invalid value number!"); - return reinterpret_cast(Operands[i*2+1].get()); + return reinterpret_cast(getOperand(i*2+1)); } void setIncomingBlock(unsigned i, BasicBlock *BB) { - assert(i*2+1 < Operands.size() && "Invalid value number!"); - Operands[i*2+1] = reinterpret_cast(BB); + setOperand(i*2+1, reinterpret_cast(BB)); } unsigned getOperandNumForIncomingBlock(unsigned i) { return i*2+1; @@ -748,8 +787,13 @@ void addIncoming(Value *V, BasicBlock *BB) { assert(getType() == V->getType() && "All operands to PHI node must be the same type as the PHI node!"); - Operands.push_back(Use(V, this)); - Operands.push_back(Use(reinterpret_cast(BB), this)); + unsigned OpNo = NumOperands; + if (OpNo+2 > ReservedSpace) + resizeOperands(0); // Get more space! + // Initialize some new operands. + NumOperands = OpNo+2; + OperandList[OpNo].init(V, this); + OperandList[OpNo+1].init(reinterpret_cast(BB), this); } /// removeIncomingValue - Remove an incoming value. This is useful if a @@ -772,8 +816,9 @@ /// block in the value list for this PHI. Returns -1 if no instance. /// int getBasicBlockIndex(const BasicBlock *BB) const { - for (unsigned i = 0; i < Operands.size()/2; ++i) - if (getIncomingBlock(i) == BB) return i; + Use *OL = OperandList; + for (unsigned i = 0, e = getNumOperands(); i != e; i += 2) + if (OL[i+1] == reinterpret_cast(BB)) return i/2; return -1; } @@ -789,6 +834,8 @@ static inline bool classof(const Value *V) { return isa(V) && classof(cast(V)); } + private: + void resizeOperands(unsigned NumOperands); }; //===----------------------------------------------------------------------===// @@ -800,12 +847,11 @@ /// does not continue in this function any longer. /// class ReturnInst : public TerminatorInst { - ReturnInst(const ReturnInst &RI) : TerminatorInst(Instruction::Ret) { - if (RI.Operands.size()) { - assert(RI.Operands.size() == 1 && "Return insn can only have 1 operand!"); - Operands.reserve(1); - Operands.push_back(Use(RI.Operands[0], this)); - } + Use RetVal; // Possibly null retval. + ReturnInst(const ReturnInst &RI) : TerminatorInst(Instruction::Ret, &RetVal, + RI.getNumOperands()) { + if (RI.getNumOperands()) + RetVal.init(RI.RetVal, this); } void init(Value *RetVal); @@ -822,34 +868,33 @@ // // NOTE: If the Value* passed is of type void then the constructor behaves as // if it was passed NULL. - ReturnInst(Value *RetVal = 0, Instruction *InsertBefore = 0) - : TerminatorInst(Instruction::Ret, InsertBefore) { - init(RetVal); - } - ReturnInst(Value *RetVal, BasicBlock *InsertAtEnd) - : TerminatorInst(Instruction::Ret, InsertAtEnd) { - init(RetVal); + ReturnInst(Value *retVal = 0, Instruction *InsertBefore = 0) + : TerminatorInst(Instruction::Ret, &RetVal, 0, InsertBefore) { + init(retVal); + } + ReturnInst(Value *retVal, BasicBlock *InsertAtEnd) + : TerminatorInst(Instruction::Ret, &RetVal, 0, InsertAtEnd) { + init(retVal); } ReturnInst(BasicBlock *InsertAtEnd) - : TerminatorInst(Instruction::Ret, InsertAtEnd) { + : TerminatorInst(Instruction::Ret, &RetVal, 0, InsertAtEnd) { } virtual ReturnInst *clone() const; - inline const Value *getReturnValue() const { - return Operands.size() ? Operands[0].get() : 0; + // Transparently provide more efficient getOperand methods. + Value *getOperand(unsigned i) const { + assert(i < getNumOperands() && "getOperand() out of range!"); + return RetVal; } - inline Value *getReturnValue() { - return Operands.size() ? Operands[0].get() : 0; + void setOperand(unsigned i, Value *Val) { + assert(i < getNumOperands() && "setOperand() out of range!"); + RetVal = Val; } - virtual const BasicBlock *getSuccessor(unsigned idx) const { - assert(0 && "ReturnInst has no successors!"); - abort(); - return 0; - } - virtual void setSuccessor(unsigned idx, BasicBlock *NewSucc); - virtual unsigned getNumSuccessors() const { return 0; } + Value *getReturnValue() const { return RetVal; } + + unsigned getNumSuccessors() const { return 0; } // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const ReturnInst *) { return true; } @@ -859,6 +904,10 @@ static inline bool classof(const Value *V) { return isa(V) && classof(cast(V)); } + private: + virtual BasicBlock *getSuccessorV(unsigned idx) const; + virtual unsigned getNumSuccessorsV() const; + virtual void setSuccessorV(unsigned idx, BasicBlock *B); }; //===----------------------------------------------------------------------===// @@ -869,9 +918,12 @@ /// BranchInst - Conditional or Unconditional Branch instruction. /// class BranchInst : public TerminatorInst { + /// Ops list - Branches are strange. The operands are ordered: + /// TrueDest, FalseDest, Cond. This makes some accessors faster because + /// they don't have to check for cond/uncond branchness. + Use Ops[3]; BranchInst(const BranchInst &BI); - void init(BasicBlock *IfTrue); - void init(BasicBlock *True, BasicBlock *False, Value *Cond); + void AssertOK(); public: // BranchInst constructors (where {B, T, F} are blocks, and C is a condition): // BranchInst(BB *B) - 'br B' @@ -881,34 +933,57 @@ // BranchInst(BB* B, BB *I) - 'br B' insert at end // BranchInst(BB* T, BB *F, Value *C, BB *I) - 'br C, T, F', insert at end BranchInst(BasicBlock *IfTrue, Instruction *InsertBefore = 0) - : TerminatorInst(Instruction::Br, InsertBefore) { - init(IfTrue); + : TerminatorInst(Instruction::Br, Ops, 1, InsertBefore) { + assert(IfTrue != 0 && "Branch destination may not be null!"); + Ops[0].init(reinterpret_cast(IfTrue), this); } BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond, Instruction *InsertBefore = 0) - : TerminatorInst(Instruction::Br, InsertBefore) { - init(IfTrue, IfFalse, Cond); + : TerminatorInst(Instruction::Br, Ops, 3, InsertBefore) { + Ops[0].init(reinterpret_cast(IfTrue), this); + Ops[1].init(reinterpret_cast(IfFalse), this); + Ops[2].init(Cond, this); +#ifndef NDEBUG + AssertOK(); +#endif } BranchInst(BasicBlock *IfTrue, BasicBlock *InsertAtEnd) - : TerminatorInst(Instruction::Br, InsertAtEnd) { - init(IfTrue); + : TerminatorInst(Instruction::Br, Ops, 1, InsertAtEnd) { + assert(IfTrue != 0 && "Branch destination may not be null!"); + Ops[0].init(reinterpret_cast(IfTrue), this); } BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond, BasicBlock *InsertAtEnd) - : TerminatorInst(Instruction::Br, InsertAtEnd) { - init(IfTrue, IfFalse, Cond); + : TerminatorInst(Instruction::Br, Ops, 3, InsertAtEnd) { + Ops[0].init(reinterpret_cast(IfTrue), this); + Ops[1].init(reinterpret_cast(IfFalse), this); + Ops[2].init(Cond, this); +#ifndef NDEBUG + AssertOK(); +#endif + } + + + /// Transparently provide more efficient getOperand methods. + Value *getOperand(unsigned i) const { + assert(i < getNumOperands() && "getOperand() out of range!"); + return Ops[i]; + } + void setOperand(unsigned i, Value *Val) { + assert(i < getNumOperands() && "setOperand() out of range!"); + Ops[i] = Val; } virtual BranchInst *clone() const; - inline bool isUnconditional() const { return Operands.size() == 1; } - inline bool isConditional() const { return Operands.size() == 3; } + inline bool isUnconditional() const { return getNumOperands() == 1; } + inline bool isConditional() const { return getNumOperands() == 3; } inline Value *getCondition() const { assert(isConditional() && "Cannot get condition of an uncond branch!"); - return Operands[2].get(); + return getOperand(2); } void setCondition(Value *V) { @@ -918,29 +993,29 @@ // setUnconditionalDest - Change the current branch to an unconditional branch // targeting the specified block. - // + // FIXME: Eliminate this ugly method. void setUnconditionalDest(BasicBlock *Dest) { - if (isConditional()) Operands.erase(Operands.begin()+1, Operands.end()); - Operands[0] = reinterpret_cast(Dest); + if (isConditional()) { // Convert this to an uncond branch. + NumOperands = 1; + Ops[1].set(0); + Ops[2].set(0); + } + setOperand(0, reinterpret_cast(Dest)); } - virtual const BasicBlock *getSuccessor(unsigned i) const { + unsigned getNumSuccessors() const { return 1+isConditional(); } + + BasicBlock *getSuccessor(unsigned i) const { assert(i < getNumSuccessors() && "Successor # out of range for Branch!"); - return (i == 0) ? cast(Operands[0].get()) : - cast(Operands[1].get()); - } - inline BasicBlock *getSuccessor(unsigned idx) { - const BranchInst *BI = this; - return const_cast(BI->getSuccessor(idx)); + return (i == 0) ? cast(getOperand(0)) : + cast(getOperand(1)); } - virtual void setSuccessor(unsigned idx, BasicBlock *NewSucc) { + void setSuccessor(unsigned idx, BasicBlock *NewSucc) { assert(idx < getNumSuccessors() && "Successor # out of range for Branch!"); - Operands[idx] = reinterpret_cast(NewSucc); + setOperand(idx, reinterpret_cast(NewSucc)); } - virtual unsigned getNumSuccessors() const { return 1+isConditional(); } - // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const BranchInst *) { return true; } static inline bool classof(const Instruction *I) { @@ -949,6 +1024,10 @@ static inline bool classof(const Value *V) { return isa(V) && classof(cast(V)); } +private: + virtual BasicBlock *getSuccessorV(unsigned idx) const; + virtual unsigned getNumSuccessorsV() const; + virtual void setSuccessorV(unsigned idx, BasicBlock *B); }; //===----------------------------------------------------------------------===// @@ -959,42 +1038,49 @@ /// SwitchInst - Multiway switch /// class SwitchInst : public TerminatorInst { + unsigned ReservedSpace; // Operand[0] = Value to switch on // Operand[1] = Default basic block destination // Operand[2n ] = Value to match // Operand[2n+1] = BasicBlock to go to on match SwitchInst(const SwitchInst &RI); - void init(Value *Value, BasicBlock *Default); - + void init(Value *Value, BasicBlock *Default, unsigned NumCases); + void resizeOperands(unsigned No); public: - SwitchInst(Value *Value, BasicBlock *Default, Instruction *InsertBefore = 0) - : TerminatorInst(Instruction::Switch, InsertBefore) { - init(Value, Default); - } - SwitchInst(Value *Value, BasicBlock *Default, BasicBlock *InsertAtEnd) - : TerminatorInst(Instruction::Switch, InsertAtEnd) { - init(Value, Default); + /// SwitchInst ctor - Create a new switch instruction, specifying a value to + /// switch on and a default destination. The number of additional cases can + /// be specified here to make memory allocation more efficient. This + /// constructor can also autoinsert before another instruction. + SwitchInst(Value *Value, BasicBlock *Default, unsigned NumCases, + Instruction *InsertBefore = 0) + : TerminatorInst(Instruction::Switch, 0, 0, InsertBefore) { + init(Value, Default, NumCases); + } + + /// SwitchInst ctor - Create a new switch instruction, specifying a value to + /// switch on and a default destination. The number of additional cases can + /// be specified here to make memory allocation more efficient. This + /// constructor also autoinserts at the end of the specified BasicBlock. + SwitchInst(Value *Value, BasicBlock *Default, unsigned NumCases, + BasicBlock *InsertAtEnd) + : TerminatorInst(Instruction::Switch, 0, 0, InsertAtEnd) { + init(Value, Default, NumCases); } + ~SwitchInst(); - virtual SwitchInst *clone() const; // Accessor Methods for Switch stmt - // - inline const Value *getCondition() const { return Operands[0]; } - inline Value *getCondition() { return Operands[0]; } - void setCondition(Value *V) { Operands[0] = V; } + inline Value *getCondition() const { return getOperand(0); } + void setCondition(Value *V) { setOperand(0, V); } - inline const BasicBlock *getDefaultDest() const { - return cast(Operands[1].get()); - } - inline BasicBlock *getDefaultDest() { - return cast(Operands[1].get()); + inline BasicBlock *getDefaultDest() const { + return cast(getOperand(1)); } /// getNumCases - return the number of 'cases' in this switch instruction. /// Note that case #0 is always the default case. unsigned getNumCases() const { - return (unsigned)Operands.size()/2; + return getNumOperands()/2; } /// getCaseValue - Return the specified case value. Note that case #0, the @@ -1031,31 +1117,24 @@ /// void removeCase(unsigned idx); - virtual const BasicBlock *getSuccessor(unsigned idx) const { - assert(idx < getNumSuccessors() &&"Successor idx out of range for switch!"); - return cast(Operands[idx*2+1].get()); - } - inline BasicBlock *getSuccessor(unsigned idx) { + virtual SwitchInst *clone() const; + + unsigned getNumSuccessors() const { return getNumOperands()/2; } + BasicBlock *getSuccessor(unsigned idx) const { assert(idx < getNumSuccessors() &&"Successor idx out of range for switch!"); - return cast(Operands[idx*2+1].get()); + return cast(getOperand(idx*2+1)); } - - virtual void setSuccessor(unsigned idx, BasicBlock *NewSucc) { + void setSuccessor(unsigned idx, BasicBlock *NewSucc) { assert(idx < getNumSuccessors() && "Successor # out of range for switch!"); - Operands[idx*2+1] = reinterpret_cast(NewSucc); + setOperand(idx*2+1, reinterpret_cast(NewSucc)); } // getSuccessorValue - Return the value associated with the specified // successor. - inline const Constant *getSuccessorValue(unsigned idx) const { - assert(idx < getNumSuccessors() && "Successor # out of range!"); - return cast(Operands[idx*2].get()); - } - inline Constant *getSuccessorValue(unsigned idx) { + inline Constant *getSuccessorValue(unsigned idx) const { assert(idx < getNumSuccessors() && "Successor # out of range!"); - return cast(Operands[idx*2].get()); + return cast(getOperand(idx*2)); } - virtual unsigned getNumSuccessors() const { return (unsigned)Operands.size()/2; } // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const SwitchInst *) { return true; } @@ -1065,6 +1144,10 @@ static inline bool classof(const Value *V) { return isa(V) && classof(cast(V)); } +private: + virtual BasicBlock *getSuccessorV(unsigned idx) const; + virtual unsigned getNumSuccessorsV() const; + virtual void setSuccessorV(unsigned idx, BasicBlock *B); }; //===----------------------------------------------------------------------===// @@ -1085,6 +1168,7 @@ InvokeInst(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException, const std::vector &Params, const std::string &Name, BasicBlock *InsertAtEnd); + ~InvokeInst(); virtual InvokeInst *clone() const; @@ -1094,50 +1178,38 @@ /// indirect function invocation. /// Function *getCalledFunction() const { - return dyn_cast(Operands[0]); + return dyn_cast(getOperand(0)); } // getCalledValue - Get a pointer to a function that is invoked by this inst. - inline const Value *getCalledValue() const { return Operands[0]; } - inline Value *getCalledValue() { return Operands[0]; } + inline Value *getCalledValue() const { return getOperand(0); } // get*Dest - Return the destination basic blocks... - inline const BasicBlock *getNormalDest() const { - return cast(Operands[1].get()); + BasicBlock *getNormalDest() const { + return cast(getOperand(1)); } - inline BasicBlock *getNormalDest() { - return cast(Operands[1].get()); + BasicBlock *getUnwindDest() const { + return cast(getOperand(2)); } - inline const BasicBlock *getUnwindDest() const { - return cast(Operands[2].get()); - } - inline BasicBlock *getUnwindDest() { - return cast(Operands[2].get()); - } - - inline void setNormalDest(BasicBlock *B){ - Operands[1] = reinterpret_cast(B); + void setNormalDest(BasicBlock *B) { + setOperand(1, reinterpret_cast(B)); } - inline void setUnwindDest(BasicBlock *B){ - Operands[2] = reinterpret_cast(B); + void setUnwindDest(BasicBlock *B) { + setOperand(2, reinterpret_cast(B)); } - virtual const BasicBlock *getSuccessor(unsigned i) const { - assert(i < 2 && "Successor # out of range for invoke!"); - return i == 0 ? getNormalDest() : getUnwindDest(); - } - inline BasicBlock *getSuccessor(unsigned i) { + inline BasicBlock *getSuccessor(unsigned i) const { assert(i < 2 && "Successor # out of range for invoke!"); return i == 0 ? getNormalDest() : getUnwindDest(); } - virtual void setSuccessor(unsigned idx, BasicBlock *NewSucc) { + void setSuccessor(unsigned idx, BasicBlock *NewSucc) { assert(idx < 2 && "Successor # out of range for invoke!"); - Operands[idx+1] = reinterpret_cast(NewSucc); + setOperand(idx+1, reinterpret_cast(NewSucc)); } - virtual unsigned getNumSuccessors() const { return 2; } + unsigned getNumSuccessors() const { return 2; } // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const InvokeInst *) { return true; } @@ -1147,6 +1219,10 @@ static inline bool classof(const Value *V) { return isa(V) && classof(cast(V)); } +private: + virtual BasicBlock *getSuccessorV(unsigned idx) const; + virtual unsigned getNumSuccessorsV() const; + virtual void setSuccessorV(unsigned idx, BasicBlock *B); }; @@ -1161,21 +1237,15 @@ class UnwindInst : public TerminatorInst { public: UnwindInst(Instruction *InsertBefore = 0) - : TerminatorInst(Instruction::Unwind, InsertBefore) { + : TerminatorInst(Instruction::Unwind, 0, 0, InsertBefore) { } UnwindInst(BasicBlock *InsertAtEnd) - : TerminatorInst(Instruction::Unwind, InsertAtEnd) { + : TerminatorInst(Instruction::Unwind, 0, 0, InsertAtEnd) { } virtual UnwindInst *clone() const; - virtual const BasicBlock *getSuccessor(unsigned idx) const { - assert(0 && "UnwindInst has no successors!"); - abort(); - return 0; - } - virtual void setSuccessor(unsigned idx, BasicBlock *NewSucc); - virtual unsigned getNumSuccessors() const { return 0; } + unsigned getNumSuccessors() const { return 0; } // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const UnwindInst *) { return true; } @@ -1185,6 +1255,10 @@ static inline bool classof(const Value *V) { return isa(V) && classof(cast(V)); } +private: + virtual BasicBlock *getSuccessorV(unsigned idx) const; + virtual unsigned getNumSuccessorsV() const; + virtual void setSuccessorV(unsigned idx, BasicBlock *B); }; //===----------------------------------------------------------------------===// @@ -1199,21 +1273,15 @@ class UnreachableInst : public TerminatorInst { public: UnreachableInst(Instruction *InsertBefore = 0) - : TerminatorInst(Instruction::Unreachable, InsertBefore) { + : TerminatorInst(Instruction::Unreachable, 0, 0, InsertBefore) { } UnreachableInst(BasicBlock *InsertAtEnd) - : TerminatorInst(Instruction::Unreachable, InsertAtEnd) { + : TerminatorInst(Instruction::Unreachable, 0, 0, InsertAtEnd) { } virtual UnreachableInst *clone() const; - virtual const BasicBlock *getSuccessor(unsigned idx) const { - assert(0 && "UnreachableInst has no successors!"); - abort(); - return 0; - } - virtual void setSuccessor(unsigned idx, BasicBlock *NewSucc); - virtual unsigned getNumSuccessors() const { return 0; } + unsigned getNumSuccessors() const { return 0; } // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const UnreachableInst *) { return true; } @@ -1223,6 +1291,10 @@ static inline bool classof(const Value *V) { return isa(V) && classof(cast(V)); } +private: + virtual BasicBlock *getSuccessorV(unsigned idx) const; + virtual unsigned getNumSuccessorsV() const; + virtual void setSuccessorV(unsigned idx, BasicBlock *B); }; } // End llvm namespace From lattner at cs.uiuc.edu Fri Jan 28 18:32:13 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 18:32:13 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Constant.h Message-ID: <200501290032.j0T0WDs7006288@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: Constant.h updated: 1.19 -> 1.20 --- Log message: Adjust to user changes. --- Diffs of the changes: (+3 -4) Constant.h | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) Index: llvm/include/llvm/Constant.h diff -u llvm/include/llvm/Constant.h:1.19 llvm/include/llvm/Constant.h:1.20 --- llvm/include/llvm/Constant.h:1.19 Fri Nov 19 10:39:04 2004 +++ llvm/include/llvm/Constant.h Fri Jan 28 18:32:00 2005 @@ -20,10 +20,9 @@ class Constant : public User { protected: - inline Constant(const Type *Ty, ValueTy vty = Value::SimpleConstantVal, - const std::string& Name = "") - : User(Ty, vty, Name) {} - ~Constant() {} + Constant(const Type *Ty, ValueTy vty, Use *Ops, unsigned NumOps, + const std::string& Name = "") + : User(Ty, vty, Ops, NumOps, Name) {} void destroyConstantImpl(); public: From lattner at cs.uiuc.edu Fri Jan 28 18:33:04 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 18:33:04 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/InstrTypes.h Message-ID: <200501290033.j0T0X4YT006313@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: InstrTypes.h updated: 1.41 -> 1.42 --- Log message: Adjust to changes in the User class. Introduce a new UnaryInstruction class. --- Diffs of the changes: (+78 -23) InstrTypes.h | 101 +++++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 78 insertions(+), 23 deletions(-) Index: llvm/include/llvm/InstrTypes.h diff -u llvm/include/llvm/InstrTypes.h:1.41 llvm/include/llvm/InstrTypes.h:1.42 --- llvm/include/llvm/InstrTypes.h:1.41 Fri Oct 15 18:52:05 2004 +++ llvm/include/llvm/InstrTypes.h Fri Jan 28 18:32:51 2005 @@ -29,34 +29,45 @@ /// class TerminatorInst : public Instruction { protected: - TerminatorInst(Instruction::TermOps iType, Instruction *InsertBefore = 0); + TerminatorInst(Instruction::TermOps iType, Use *Ops, unsigned NumOps, + Instruction *InsertBefore = 0); TerminatorInst(const Type *Ty, Instruction::TermOps iType, + Use *Ops, unsigned NumOps, const std::string &Name = "", Instruction *InsertBefore = 0) - : Instruction(Ty, iType, Name, InsertBefore) {} + : Instruction(Ty, iType, Ops, NumOps, Name, InsertBefore) {} - TerminatorInst(Instruction::TermOps iType, BasicBlock *InsertAtEnd); + TerminatorInst(Instruction::TermOps iType, Use *Ops, unsigned NumOps, + BasicBlock *InsertAtEnd); TerminatorInst(const Type *Ty, Instruction::TermOps iType, + Use *Ops, unsigned NumOps, const std::string &Name, BasicBlock *InsertAtEnd) - : Instruction(Ty, iType, Name, InsertAtEnd) {} + : Instruction(Ty, iType, Ops, NumOps, Name, InsertAtEnd) {} + /// Virtual methods - Terminators should overload these and provide inline + /// overrides of non-V methods. + virtual BasicBlock *getSuccessorV(unsigned idx) const = 0; + virtual unsigned getNumSuccessorsV() const = 0; + virtual void setSuccessorV(unsigned idx, BasicBlock *B) = 0; public: - /// Terminators must implement the methods required by Instruction... virtual Instruction *clone() const = 0; - /// Additionally, they must provide a method to get at the successors of this - /// terminator instruction. 'idx' may not be >= the number of successors - /// returned by getNumSuccessors()! - /// - virtual const BasicBlock *getSuccessor(unsigned idx) const = 0; - virtual unsigned getNumSuccessors() const = 0; - - /// Set a successor at a given index - virtual void setSuccessor(unsigned idx, BasicBlock *B) = 0; - - inline BasicBlock *getSuccessor(unsigned idx) { - const TerminatorInst *TI = this; - return const_cast(TI->getSuccessor(idx)); + /// getNumSuccessors - Return the number of successors that this terminator + /// has. + unsigned getNumSuccessors() const { + return getNumSuccessorsV(); + } + + /// getSuccessor - Return the specified successor. + /// + BasicBlock *getSuccessor(unsigned idx) const { + return getSuccessorV(idx); + } + + /// setSuccessor - Update the specified successor to point at the provided + /// block. + void setSuccessor(unsigned idx, BasicBlock *B) { + setSuccessorV(idx, B); } // Methods for support type inquiry through isa, cast, and dyn_cast: @@ -69,27 +80,71 @@ } }; +//===----------------------------------------------------------------------===// +// UnaryInstruction Class +//===----------------------------------------------------------------------===// + +class UnaryInstruction : public Instruction { + Use Op; +protected: + UnaryInstruction(const Type *Ty, unsigned iType, Value *V, + const std::string &Name = "", Instruction *IB = 0) + : Instruction(Ty, iType, &Op, 1, Name, IB), Op(V, this) { + } + UnaryInstruction(const Type *Ty, unsigned iType, Value *V, + const std::string &Name, BasicBlock *IAE) + : Instruction(Ty, iType, &Op, 1, Name, IAE), Op(V, this) { + } +public: + + // Transparently provide more efficient getOperand methods. + Value *getOperand(unsigned i) const { + assert(i == 0 && "getOperand() out of range!"); + return Op; + } + void setOperand(unsigned i, Value *Val) { + assert(i == 0 && "setOperand() out of range!"); + Op = Val; + } + unsigned getNumOperands() const { return 1; } +}; //===----------------------------------------------------------------------===// // BinaryOperator Class //===----------------------------------------------------------------------===// class BinaryOperator : public Instruction { + Use Ops[2]; protected: - void init(BinaryOps iType, Value *S1, Value *S2); + void init(BinaryOps iType); BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty, const std::string &Name, Instruction *InsertBefore) - : Instruction(Ty, iType, Name, InsertBefore) { - init(iType, S1, S2); + : Instruction(Ty, iType, Ops, 2, Name, InsertBefore) { + Ops[0].init(S1, this); + Ops[1].init(S2, this); + init(iType); } BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd) - : Instruction(Ty, iType, Name, InsertAtEnd) { - init(iType, S1, S2); + : Instruction(Ty, iType, Ops, 2, Name, InsertAtEnd) { + Ops[0].init(S1, this); + Ops[1].init(S2, this); + init(iType); } public: + /// Transparently provide more efficient getOperand methods. + Value *getOperand(unsigned i) const { + assert(i < 2 && "getOperand() out of range!"); + return Ops[i]; + } + void setOperand(unsigned i, Value *Val) { + assert(i < 2 && "setOperand() out of range!"); + Ops[i] = Val; + } + unsigned getNumOperands() const { return 2; } + /// create() - Construct a binary instruction, given the opcode and the two /// operands. Optionally (if InstBefore is specified) insert the instruction /// into a BasicBlock right before the specified instruction. The specified From lattner at cs.uiuc.edu Fri Jan 28 18:33:13 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 18:33:13 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Instruction.h Message-ID: <200501290033.j0T0XDSf006335@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: Instruction.h updated: 1.62 -> 1.63 --- Log message: Adjust to changes in the User class. --- Diffs of the changes: (+4 -4) Instruction.h | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) Index: llvm/include/llvm/Instruction.h diff -u llvm/include/llvm/Instruction.h:1.62 llvm/include/llvm/Instruction.h:1.63 --- llvm/include/llvm/Instruction.h:1.62 Mon Nov 29 20:51:41 2004 +++ llvm/include/llvm/Instruction.h Fri Jan 28 18:33:00 2005 @@ -36,7 +36,6 @@ friend class SymbolTableListTraits >; void setParent(BasicBlock *P); - void init(); private: // FIXME: This is a dirty hack. Setcc instructions shouldn't encode the CC @@ -44,10 +43,11 @@ void setOpcode(unsigned NewOpcode); friend class BinaryOperator; protected: - Instruction(const Type *Ty, unsigned iType, const std::string &Name = "", + Instruction(const Type *Ty, unsigned iType, Use *Ops, unsigned NumOps, + const std::string &Name = "", Instruction *InsertBefore = 0); - Instruction(const Type *Ty, unsigned iType, const std::string &Name, - BasicBlock *InsertAtEnd); + Instruction(const Type *Ty, unsigned iType, Use *Ops, unsigned NumOps, + const std::string &Name, BasicBlock *InsertAtEnd); public: ~Instruction() { From lattner at cs.uiuc.edu Fri Jan 28 18:33:13 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 18:33:13 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Constants.h GlobalValue.h GlobalVariable.h Message-ID: <200501290033.j0T0XDGw006329@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: Constants.h updated: 1.66 -> 1.67 GlobalValue.h updated: 1.20 -> 1.21 GlobalVariable.h updated: 1.29 -> 1.30 --- Log message: Adjust to changes in the User class. --- Diffs of the changes: (+26 -17) Constants.h | 17 ++++++++++------- GlobalValue.h | 6 +++--- GlobalVariable.h | 20 +++++++++++++------- 3 files changed, 26 insertions(+), 17 deletions(-) Index: llvm/include/llvm/Constants.h diff -u llvm/include/llvm/Constants.h:1.66 llvm/include/llvm/Constants.h:1.67 --- llvm/include/llvm/Constants.h:1.66 Mon Dec 13 13:48:47 2004 +++ llvm/include/llvm/Constants.h Fri Jan 28 18:32:29 2005 @@ -319,7 +319,7 @@ ConstantAggregateZero(const ConstantAggregateZero &); // DO NOT IMPLEMENT protected: ConstantAggregateZero(const Type *Ty) - : Constant(Ty, ConstantAggregateZeroVal) {} + : Constant(Ty, ConstantAggregateZeroVal, 0, 0) {} public: /// get() - static factory method for creating a null aggregate. It is /// illegal to call this method with a non-aggregate type. @@ -351,6 +351,7 @@ ConstantArray(const ConstantArray &); // DO NOT IMPLEMENT protected: ConstantArray(const ArrayType *T, const std::vector &Val); + ~ConstantArray(); public: /// get() - Static factory methods - Return objects of the specified value static Constant *get(const ArrayType *T, const std::vector &); @@ -399,6 +400,7 @@ ConstantStruct(const ConstantStruct &); // DO NOT IMPLEMENT protected: ConstantStruct(const StructType *T, const std::vector &Val); + ~ConstantStruct(); public: /// get() - Static factory methods - Return objects of the specified value /// @@ -439,6 +441,7 @@ ConstantPacked(const ConstantPacked &); // DO NOT IMPLEMENT protected: ConstantPacked(const PackedType *T, const std::vector &Val); + ~ConstantPacked(); public: /// get() - Static factory methods - Return objects of the specified value static Constant *get(const PackedType *T, const std::vector &); @@ -476,7 +479,8 @@ ConstantPointerNull(const ConstantPointerNull &); // DO NOT IMPLEMENT protected: ConstantPointerNull(const PointerType *T) - : Constant(reinterpret_cast(T)) {} + : Constant(reinterpret_cast(T), + Value::SimpleConstantVal, 0, 0) {} public: @@ -518,10 +522,9 @@ friend struct ConvertConstantType; protected: - // Cast creation ctor - ConstantExpr(unsigned Opcode, Constant *C, const Type *Ty); - // Binary/Shift instruction creation ctor - ConstantExpr(unsigned Opcode, Constant *C1, Constant *C2); + ConstantExpr(const Type *Ty, unsigned Opcode, Use *Ops, unsigned NumOps) + : Constant(Ty, ConstantExprVal, Ops, NumOps), iType(Opcode) {} + // Select instruction creation ctor ConstantExpr(Constant *C, Constant *V1, Constant *V2); // GEP instruction creation ctor @@ -642,7 +645,7 @@ friend struct ConstantCreator; UndefValue(const UndefValue &); // DO NOT IMPLEMENT protected: - UndefValue(const Type *T) : Constant(T, UndefValueVal) {} + UndefValue(const Type *T) : Constant(T, UndefValueVal, 0, 0) {} public: /// get() - Static factory methods - Return an 'undef' object of the specified /// type. Index: llvm/include/llvm/GlobalValue.h diff -u llvm/include/llvm/GlobalValue.h:1.20 llvm/include/llvm/GlobalValue.h:1.21 --- llvm/include/llvm/GlobalValue.h:1.20 Mon Nov 15 17:20:19 2004 +++ llvm/include/llvm/GlobalValue.h Fri Jan 28 18:32:30 2005 @@ -36,9 +36,9 @@ GhostLinkage // Stand-in functions for streaming fns from BC files }; protected: - GlobalValue(const Type *Ty, ValueTy vty, LinkageTypes linkage, - const std::string &name = "") - : Constant(Ty, vty, name), Linkage(linkage), Parent(0) { } + GlobalValue(const Type *Ty, ValueTy vty, Use *Ops, unsigned NumOps, + LinkageTypes linkage, const std::string &name = "") + : Constant(Ty, vty, Ops, NumOps, name), Linkage(linkage), Parent(0) { } LinkageTypes Linkage; // The linkage of this global Module *Parent; Index: llvm/include/llvm/GlobalVariable.h diff -u llvm/include/llvm/GlobalVariable.h:1.29 llvm/include/llvm/GlobalVariable.h:1.30 --- llvm/include/llvm/GlobalVariable.h:1.29 Mon Oct 11 17:21:13 2004 +++ llvm/include/llvm/GlobalVariable.h Fri Jan 28 18:32:30 2005 @@ -41,6 +41,8 @@ void setPrev(GlobalVariable *N) { Prev = N; } bool isConstantGlobal; // Is this a global constant? + Use Initializer; + public: /// GlobalVariable ctor - If a parent module is specified, the global is /// automatically inserted into the end of the specified modules global list. @@ -56,11 +58,11 @@ /// global variable is defined in some other translation unit, and is thus /// externally defined here. /// - virtual bool isExternal() const { return Operands.empty(); } + virtual bool isExternal() const { return getNumOperands() == 0; } /// hasInitializer - Unless a global variable isExternal(), it has an /// initializer. The initializer for the global variable/constant is held by - /// Operands[0] if an initializer is specified. + /// Initializer if an initializer is specified. /// inline bool hasInitializer() const { return !isExternal(); } @@ -70,18 +72,22 @@ /// inline Constant *getInitializer() const { assert(hasInitializer() && "GV doesn't have initializer!"); - return reinterpret_cast(Operands[0].get()); + return reinterpret_cast(Initializer.get()); } inline Constant *getInitializer() { assert(hasInitializer() && "GV doesn't have initializer!"); - return reinterpret_cast(Operands[0].get()); + return reinterpret_cast(Initializer.get()); } inline void setInitializer(Constant *CPV) { if (CPV == 0) { - if (hasInitializer()) Operands.pop_back(); + if (hasInitializer()) { + Initializer.set(0); + NumOperands = 0; + } } else { - if (!hasInitializer()) Operands.push_back(Use(0, this)); - Operands[0] = reinterpret_cast(CPV); + if (!hasInitializer()) + NumOperands = 1; + Initializer.set(CPV); } } From lattner at cs.uiuc.edu Fri Jan 28 18:33:44 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 18:33:44 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/InstrTypes.cpp Message-ID: <200501290033.j0T0Xiog006353@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: InstrTypes.cpp (r1.26) removed --- Log message: This file is now merged into Instructions.cpp --- Diffs of the changes: (+0 -0) 0 files changed From lattner at cs.uiuc.edu Fri Jan 28 18:34:11 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 18:34:11 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/BasicBlock.cpp Message-ID: <200501290034.j0T0YBKb006372@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: BasicBlock.cpp updated: 1.51 -> 1.52 --- Log message: Adjust to changes in User class. --- Diffs of the changes: (+1 -1) BasicBlock.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/VMCore/BasicBlock.cpp diff -u llvm/lib/VMCore/BasicBlock.cpp:1.51 llvm/lib/VMCore/BasicBlock.cpp:1.52 --- llvm/lib/VMCore/BasicBlock.cpp:1.51 Sat Dec 11 16:10:29 2004 +++ llvm/lib/VMCore/BasicBlock.cpp Fri Jan 28 18:33:59 2005 @@ -26,7 +26,7 @@ /// DummyInst - An instance of this class is used to mark the end of the /// instruction list. This is not a real instruction. struct DummyInst : public Instruction { - DummyInst() : Instruction(Type::VoidTy, OtherOpsEnd) { + DummyInst() : Instruction(Type::VoidTy, OtherOpsEnd, 0, 0) { // This should not be garbage monitored. LeakDetector::removeGarbageObject(this); } From lattner at cs.uiuc.edu Fri Jan 28 18:34:55 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 18:34:55 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp Message-ID: <200501290034.j0T0Yt7x006391@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Constants.cpp updated: 1.120 -> 1.121 --- Log message: Adjust to changes in User class. Aggregate constants now must explicitly manage their operands. --- Diffs of the changes: (+81 -46) Constants.cpp | 127 ++++++++++++++++++++++++++++++++++++---------------------- 1 files changed, 81 insertions(+), 46 deletions(-) Index: llvm/lib/VMCore/Constants.cpp diff -u llvm/lib/VMCore/Constants.cpp:1.120 llvm/lib/VMCore/Constants.cpp:1.121 --- llvm/lib/VMCore/Constants.cpp:1.120 Thu Jan 27 00:46:38 2005 +++ llvm/lib/VMCore/Constants.cpp Fri Jan 28 18:34:39 2005 @@ -216,7 +216,7 @@ // Normal Constructors ConstantIntegral::ConstantIntegral(const Type *Ty, uint64_t V) - : Constant(Ty) { + : Constant(Ty, SimpleConstantVal, 0, 0) { Val.Unsigned = V; } @@ -238,67 +238,77 @@ assert(isValueValidForType(Ty, V) && "Value too large for type!"); } -ConstantFP::ConstantFP(const Type *Ty, double V) : Constant(Ty) { +ConstantFP::ConstantFP(const Type *Ty, double V) + : Constant(Ty, SimpleConstantVal, 0, 0) { assert(isValueValidForType(Ty, V) && "Value too large for type!"); Val = V; } ConstantArray::ConstantArray(const ArrayType *T, - const std::vector &V) : Constant(T) { + const std::vector &V) + : Constant(T, SimpleConstantVal, new Use[V.size()], V.size()) { assert(V.size() == T->getNumElements() && "Invalid initializer vector for constant array"); - Operands.reserve(V.size()); + Use *OL = OperandList; for (unsigned i = 0, e = V.size(); i != e; ++i) { assert((V[i]->getType() == T->getElementType() || (T->isAbstract() && - V[i]->getType()->getTypeID() == T->getElementType()->getTypeID())) && + V[i]->getType()->getTypeID()==T->getElementType()->getTypeID())) && "Initializer for array element doesn't match array element type!"); - Operands.push_back(Use(V[i], this)); + OL[i].init(V[i], this); } } +ConstantArray::~ConstantArray() { + delete [] OperandList; +} + ConstantStruct::ConstantStruct(const StructType *T, - const std::vector &V) : Constant(T) { + const std::vector &V) + : Constant(T, SimpleConstantVal, new Use[V.size()], V.size()) { assert(V.size() == T->getNumElements() && "Invalid initializer vector for constant structure"); - Operands.reserve(V.size()); + Use *OL = OperandList; for (unsigned i = 0, e = V.size(); i != e; ++i) { assert((V[i]->getType() == T->getElementType(i) || ((T->getElementType(i)->isAbstract() || V[i]->getType()->isAbstract()) && - T->getElementType(i)->getTypeID() == V[i]->getType()->getTypeID())) && + T->getElementType(i)->getTypeID()==V[i]->getType()->getTypeID()))&& "Initializer for struct element doesn't match struct element type!"); - Operands.push_back(Use(V[i], this)); + OL[i].init(V[i], this); } } +ConstantStruct::~ConstantStruct() { + delete [] OperandList; +} + + ConstantPacked::ConstantPacked(const PackedType *T, - const std::vector &V) : Constant(T) { - Operands.reserve(V.size()); + const std::vector &V) + : Constant(T, SimpleConstantVal, new Use[V.size()], V.size()) { + Use *OL = OperandList; for (unsigned i = 0, e = V.size(); i != e; ++i) { assert((V[i]->getType() == T->getElementType() || (T->isAbstract() && - V[i]->getType()->getTypeID() == T->getElementType()->getTypeID())) && + V[i]->getType()->getTypeID()==T->getElementType()->getTypeID())) && "Initializer for packed element doesn't match packed element type!"); - Operands.push_back(Use(V[i], this)); + OL[i].init(V[i], this); } } -ConstantExpr::ConstantExpr(unsigned Opcode, Constant *C, const Type *Ty) - : Constant(Ty, ConstantExprVal), iType(Opcode) { - Operands.reserve(1); - Operands.push_back(Use(C, this)); -} - -// Select instruction creation ctor -ConstantExpr::ConstantExpr(Constant *C, Constant *V1, Constant *V2) - : Constant(V1->getType(), ConstantExprVal), iType(Instruction::Select) { - Operands.reserve(3); - Operands.push_back(Use(C, this)); - Operands.push_back(Use(V1, this)); - Operands.push_back(Use(V2, this)); +ConstantPacked::~ConstantPacked() { + delete [] OperandList; } +/// UnaryConstantExpr - This class is private to Constants.cpp, and is used +/// behind the scenes to implement unary constant exprs. +class UnaryConstantExpr : public ConstantExpr { + Use Op; +public: + UnaryConstantExpr(unsigned Opcode, Constant *C, const Type *Ty) + : ConstantExpr(Ty, Opcode, &Op, 1), Op(C, this) {} +}; static bool isSetCC(unsigned Opcode) { return Opcode == Instruction::SetEQ || Opcode == Instruction::SetNE || @@ -306,22 +316,47 @@ Opcode == Instruction::SetLE || Opcode == Instruction::SetGE; } -ConstantExpr::ConstantExpr(unsigned Opcode, Constant *C1, Constant *C2) - : Constant(isSetCC(Opcode) ? Type::BoolTy : C1->getType(), ConstantExprVal), - iType(Opcode) { - Operands.reserve(2); - Operands.push_back(Use(C1, this)); - Operands.push_back(Use(C2, this)); -} +/// BinaryConstantExpr - This class is private to Constants.cpp, and is used +/// behind the scenes to implement binary constant exprs. +class BinaryConstantExpr : public ConstantExpr { + Use Ops[2]; +public: + BinaryConstantExpr(unsigned Opcode, Constant *C1, Constant *C2) + : ConstantExpr(isSetCC(Opcode) ? Type::BoolTy : C1->getType(), + Opcode, Ops, 2) { + Ops[0].init(C1, this); + Ops[1].init(C2, this); + } +}; -ConstantExpr::ConstantExpr(Constant *C, const std::vector &IdxList, - const Type *DestTy) - : Constant(DestTy, ConstantExprVal), iType(Instruction::GetElementPtr) { - Operands.reserve(1+IdxList.size()); - Operands.push_back(Use(C, this)); - for (unsigned i = 0, E = IdxList.size(); i != E; ++i) - Operands.push_back(Use(IdxList[i], this)); -} +/// SelectConstantExpr - This class is private to Constants.cpp, and is used +/// behind the scenes to implement select constant exprs. +class SelectConstantExpr : public ConstantExpr { + Use Ops[3]; +public: + SelectConstantExpr(Constant *C1, Constant *C2, Constant *C3) + : ConstantExpr(C2->getType(), Instruction::Select, Ops, 3) { + Ops[0].init(C1, this); + Ops[1].init(C2, this); + Ops[2].init(C3, this); + } +}; + +/// GetElementPtrConstantExpr - This class is private to Constants.cpp, and is +/// used behind the scenes to implement getelementpr constant exprs. +struct GetElementPtrConstantExpr : public ConstantExpr { + GetElementPtrConstantExpr(Constant *C, const std::vector &IdxList, + const Type *DestTy) + : ConstantExpr(DestTy, Instruction::GetElementPtr, + new Use[IdxList.size()+1], IdxList.size()+1) { + OperandList[0].init(C, this); + for (unsigned i = 0, E = IdxList.size(); i != E; ++i) + OperandList[i+1].init(IdxList[i], this); + } + ~GetElementPtrConstantExpr() { + delete [] OperandList; + } +}; /// ConstantExpr::get* - Return some common constants without having to /// specify the full Instruction::OPCODE identifier. @@ -1162,18 +1197,18 @@ struct ConstantCreator { static ConstantExpr *create(const Type *Ty, const ExprMapKeyType &V) { if (V.first == Instruction::Cast) - return new ConstantExpr(Instruction::Cast, V.second[0], Ty); + return new UnaryConstantExpr(Instruction::Cast, V.second[0], Ty); if ((V.first >= Instruction::BinaryOpsBegin && V.first < Instruction::BinaryOpsEnd) || V.first == Instruction::Shl || V.first == Instruction::Shr) - return new ConstantExpr(V.first, V.second[0], V.second[1]); + return new BinaryConstantExpr(V.first, V.second[0], V.second[1]); if (V.first == Instruction::Select) - return new ConstantExpr(V.second[0], V.second[1], V.second[2]); + return new SelectConstantExpr(V.second[0], V.second[1], V.second[2]); assert(V.first == Instruction::GetElementPtr && "Invalid ConstantExpr!"); std::vector IdxList(V.second.begin()+1, V.second.end()); - return new ConstantExpr(V.second[0], IdxList, Ty); + return new GetElementPtrConstantExpr(V.second[0], IdxList, Ty); } }; From lattner at cs.uiuc.edu Fri Jan 28 18:35:31 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 18:35:31 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Instructions.cpp Message-ID: <200501290035.j0T0ZVKc006406@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Instructions.cpp updated: 1.8 -> 1.9 --- Log message: Merge InstrTypes.cpp into this file Adjust to changes in the User class, operand handling is very different. PHI node and switch statements must handle explicit resizing of operand lists. --- Diffs of the changes: (+424 -193) Instructions.cpp | 617 +++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 424 insertions(+), 193 deletions(-) Index: llvm/lib/VMCore/Instructions.cpp diff -u llvm/lib/VMCore/Instructions.cpp:1.8 llvm/lib/VMCore/Instructions.cpp:1.9 --- llvm/lib/VMCore/Instructions.cpp:1.8 Thu Jan 27 00:46:38 2005 +++ llvm/lib/VMCore/Instructions.cpp Fri Jan 28 18:35:16 2005 @@ -7,7 +7,8 @@ // //===----------------------------------------------------------------------===// // -// This file implements the LLVM instructions... +// This file implements all of the non-inline methods for the LLVM instruction +// classes. // //===----------------------------------------------------------------------===// @@ -20,13 +21,116 @@ using namespace llvm; //===----------------------------------------------------------------------===// +// TerminatorInst Class +//===----------------------------------------------------------------------===// + +TerminatorInst::TerminatorInst(Instruction::TermOps iType, + Use *Ops, unsigned NumOps, Instruction *IB) + : Instruction(Type::VoidTy, iType, Ops, NumOps, "", IB) { +} + +TerminatorInst::TerminatorInst(Instruction::TermOps iType, + Use *Ops, unsigned NumOps, BasicBlock *IAE) + : Instruction(Type::VoidTy, iType, Ops, NumOps, "", IAE) { +} + + + +//===----------------------------------------------------------------------===// +// PHINode Class +//===----------------------------------------------------------------------===// + +PHINode::PHINode(const PHINode &PN) + : Instruction(PN.getType(), Instruction::PHI, + new Use[PN.getNumOperands()], PN.getNumOperands()), + ReservedSpace(PN.getNumOperands()) { + Use *OL = OperandList; + for (unsigned i = 0, e = PN.getNumOperands(); i != e; i+=2) { + OL[i].init(PN.getOperand(i), this); + OL[i+1].init(PN.getOperand(i+1), this); + } +} + +PHINode::~PHINode() { + delete [] OperandList; +} + +// removeIncomingValue - Remove an incoming value. This is useful if a +// predecessor basic block is deleted. +Value *PHINode::removeIncomingValue(unsigned Idx, bool DeletePHIIfEmpty) { + unsigned NumOps = getNumOperands(); + Use *OL = OperandList; + assert(Idx*2 < NumOps && "BB not in PHI node!"); + Value *Removed = OL[Idx*2]; + + // Move everything after this operand down. + // + // FIXME: we could just swap with the end of the list, then erase. However, + // client might not expect this to happen. The code as it is thrashes the + // use/def lists, which is kinda lame. + for (unsigned i = (Idx+1)*2; i != NumOps; i += 2) { + OL[i-2] = OL[i]; + OL[i-2+1] = OL[i+1]; + } + + // Nuke the last value. + OL[NumOps-2].set(0); + OL[NumOps-2+1].set(0); + NumOperands = NumOps-2; + + // If the PHI node is dead, because it has zero entries, nuke it now. + if (NumOps == 2 && DeletePHIIfEmpty) { + // If anyone is using this PHI, make them use a dummy value instead... + replaceAllUsesWith(UndefValue::get(getType())); + eraseFromParent(); + } + return Removed; +} + +/// resizeOperands - resize operands - This adjusts the length of the operands +/// list according to the following behavior: +/// 1. If NumOps == 0, grow the operand list in response to a push_back style +/// of operation. This grows the number of ops by 1.5 times. +/// 2. If NumOps > NumOperands, reserve space for NumOps operands. +/// 3. If NumOps == NumOperands, trim the reserved space. +/// +void PHINode::resizeOperands(unsigned NumOps) { + if (NumOps == 0) { + NumOps = (getNumOperands())*3/2; + if (NumOps < 4) NumOps = 4; // 4 op PHI nodes are VERY common. + } else if (NumOps*2 > NumOperands) { + // No resize needed. + if (ReservedSpace >= NumOps) return; + } else if (NumOps == NumOperands) { + if (ReservedSpace == NumOps) return; + } else { + return; + } + + ReservedSpace = NumOps; + Use *NewOps = new Use[NumOps]; + Use *OldOps = OperandList; + for (unsigned i = 0, e = getNumOperands(); i != e; ++i) { + NewOps[i].init(OldOps[i], this); + OldOps[i].set(0); + } + delete [] OldOps; + OperandList = NewOps; +} + + +//===----------------------------------------------------------------------===// // CallInst Implementation //===----------------------------------------------------------------------===// -void CallInst::init(Value *Func, const std::vector &Params) -{ - Operands.reserve(1+Params.size()); - Operands.push_back(Use(Func, this)); +CallInst::~CallInst() { + delete [] OperandList; +} + +void CallInst::init(Value *Func, const std::vector &Params) { + NumOperands = Params.size()+1; + Use *OL = OperandList = new Use[Params.size()+1]; + OL[0].init(Func, this); const FunctionType *FTy = cast(cast(Func->getType())->getElementType()); @@ -34,43 +138,43 @@ assert((Params.size() == FTy->getNumParams() || (FTy->isVarArg() && Params.size() > FTy->getNumParams())) && "Calling a function with bad signature"); - for (unsigned i = 0; i != Params.size(); i++) - Operands.push_back(Use(Params[i], this)); + for (unsigned i = 0, e = Params.size(); i != e; ++i) + OL[i+1].init(Params[i], this); } -void CallInst::init(Value *Func, Value *Actual1, Value *Actual2) -{ - Operands.reserve(3); - Operands.push_back(Use(Func, this)); +void CallInst::init(Value *Func, Value *Actual1, Value *Actual2) { + NumOperands = 3; + Use *OL = OperandList = new Use[3]; + OL[0].init(Func, this); + OL[1].init(Actual1, this); + OL[2].init(Actual2, this); - const FunctionType *MTy = + const FunctionType *FTy = cast(cast(Func->getType())->getElementType()); - assert((MTy->getNumParams() == 2 || - (MTy->isVarArg() && MTy->getNumParams() == 0)) && + assert((FTy->getNumParams() == 2 || + (FTy->isVarArg() && FTy->getNumParams() == 0)) && "Calling a function with bad signature"); - Operands.push_back(Use(Actual1, this)); - Operands.push_back(Use(Actual2, this)); } -void CallInst::init(Value *Func, Value *Actual) -{ - Operands.reserve(2); - Operands.push_back(Use(Func, this)); +void CallInst::init(Value *Func, Value *Actual) { + NumOperands = 2; + Use *OL = OperandList = new Use[2]; + OL[0].init(Func, this); + OL[1].init(Actual, this); - const FunctionType *MTy = + const FunctionType *FTy = cast(cast(Func->getType())->getElementType()); - assert((MTy->getNumParams() == 1 || - (MTy->isVarArg() && MTy->getNumParams() == 0)) && + assert((FTy->getNumParams() == 1 || + (FTy->isVarArg() && FTy->getNumParams() == 0)) && "Calling a function with bad signature"); - Operands.push_back(Use(Actual, this)); } -void CallInst::init(Value *Func) -{ - Operands.reserve(1); - Operands.push_back(Use(Func, this)); +void CallInst::init(Value *Func) { + NumOperands = 1; + Use *OL = OperandList = new Use[1]; + OL[0].init(Func, this); const FunctionType *MTy = cast(cast(Func->getType())->getElementType()); @@ -82,7 +186,7 @@ const std::string &Name, Instruction *InsertBefore) : Instruction(cast(cast(Func->getType()) ->getElementType())->getReturnType(), - Instruction::Call, Name, InsertBefore) { + Instruction::Call, 0, 0, Name, InsertBefore) { init(Func, Params); } @@ -90,7 +194,7 @@ const std::string &Name, BasicBlock *InsertAtEnd) : Instruction(cast(cast(Func->getType()) ->getElementType())->getReturnType(), - Instruction::Call, Name, InsertAtEnd) { + Instruction::Call, 0, 0, Name, InsertAtEnd) { init(Func, Params); } @@ -98,7 +202,7 @@ const std::string &Name, Instruction *InsertBefore) : Instruction(cast(cast(Func->getType()) ->getElementType())->getReturnType(), - Instruction::Call, Name, InsertBefore) { + Instruction::Call, 0, 0, Name, InsertBefore) { init(Func, Actual1, Actual2); } @@ -106,7 +210,7 @@ const std::string &Name, BasicBlock *InsertAtEnd) : Instruction(cast(cast(Func->getType()) ->getElementType())->getReturnType(), - Instruction::Call, Name, InsertAtEnd) { + Instruction::Call, 0, 0, Name, InsertAtEnd) { init(Func, Actual1, Actual2); } @@ -114,7 +218,7 @@ Instruction *InsertBefore) : Instruction(cast(cast(Func->getType()) ->getElementType())->getReturnType(), - Instruction::Call, Name, InsertBefore) { + Instruction::Call, 0, 0, Name, InsertBefore) { init(Func, Actual); } @@ -122,7 +226,7 @@ BasicBlock *InsertAtEnd) : Instruction(cast(cast(Func->getType()) ->getElementType())->getReturnType(), - Instruction::Call, Name, InsertAtEnd) { + Instruction::Call, 0, 0, Name, InsertAtEnd) { init(Func, Actual); } @@ -130,7 +234,7 @@ Instruction *InsertBefore) : Instruction(cast(cast(Func->getType()) ->getElementType())->getReturnType(), - Instruction::Call, Name, InsertBefore) { + Instruction::Call, 0, 0, Name, InsertBefore) { init(Func); } @@ -138,15 +242,17 @@ BasicBlock *InsertAtEnd) : Instruction(cast(cast(Func->getType()) ->getElementType())->getReturnType(), - Instruction::Call, Name, InsertAtEnd) { + Instruction::Call, 0, 0, Name, InsertAtEnd) { init(Func); } CallInst::CallInst(const CallInst &CI) - : Instruction(CI.getType(), Instruction::Call) { - Operands.reserve(CI.Operands.size()); - for (unsigned i = 0; i < CI.Operands.size(); ++i) - Operands.push_back(Use(CI.Operands[i], this)); + : Instruction(CI.getType(), Instruction::Call, new Use[CI.getNumOperands()], + CI.getNumOperands()) { + Use *OL = OperandList; + Use *InOL = CI.OperandList; + for (unsigned i = 0, e = CI.getNumOperands(); i != e; ++i) + OL[i].init(InOL[i], this); } @@ -154,22 +260,26 @@ // InvokeInst Implementation //===----------------------------------------------------------------------===// +InvokeInst::~InvokeInst() { + delete [] OperandList; +} + void InvokeInst::init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException, - const std::vector &Params) -{ - Operands.reserve(3+Params.size()); - Operands.push_back(Use(Fn, this)); - Operands.push_back(Use((Value*)IfNormal, this)); - Operands.push_back(Use((Value*)IfException, this)); - const FunctionType *MTy = + const std::vector &Params) { + NumOperands = 3+Params.size(); + Use *OL = OperandList = new Use[3+Params.size()]; + OL[0].init(Fn, this); + OL[1].init(IfNormal, this); + OL[2].init(IfException, this); + const FunctionType *FTy = cast(cast(Fn->getType())->getElementType()); - assert((Params.size() == MTy->getNumParams()) || - (MTy->isVarArg() && Params.size() > MTy->getNumParams()) && + assert((Params.size() == FTy->getNumParams()) || + (FTy->isVarArg() && Params.size() > FTy->getNumParams()) && "Calling a function with bad signature"); - for (unsigned i = 0; i < Params.size(); i++) - Operands.push_back(Use(Params[i], this)); + for (unsigned i = 0, e = Params.size(); i != e; i++) + OL[i+3].init(Params[i], this); } InvokeInst::InvokeInst(Value *Fn, BasicBlock *IfNormal, @@ -178,7 +288,7 @@ const std::string &Name, Instruction *InsertBefore) : TerminatorInst(cast(cast(Fn->getType()) ->getElementType())->getReturnType(), - Instruction::Invoke, Name, InsertBefore) { + Instruction::Invoke, 0, 0, Name, InsertBefore) { init(Fn, IfNormal, IfException, Params); } @@ -188,118 +298,159 @@ const std::string &Name, BasicBlock *InsertAtEnd) : TerminatorInst(cast(cast(Fn->getType()) ->getElementType())->getReturnType(), - Instruction::Invoke, Name, InsertAtEnd) { + Instruction::Invoke, 0, 0, Name, InsertAtEnd) { init(Fn, IfNormal, IfException, Params); } -InvokeInst::InvokeInst(const InvokeInst &CI) - : TerminatorInst(CI.getType(), Instruction::Invoke) { - Operands.reserve(CI.Operands.size()); - for (unsigned i = 0; i < CI.Operands.size(); ++i) - Operands.push_back(Use(CI.Operands[i], this)); +InvokeInst::InvokeInst(const InvokeInst &II) + : TerminatorInst(II.getType(), Instruction::Invoke, + new Use[II.getNumOperands()], II.getNumOperands()) { + Use *OL = OperandList, *InOL = II.OperandList; + for (unsigned i = 0, e = II.getNumOperands(); i != e; ++i) + OL[i].init(InOL[i], this); +} + +BasicBlock *InvokeInst::getSuccessorV(unsigned idx) const { + return getSuccessor(idx); } +unsigned InvokeInst::getNumSuccessorsV() const { + return getNumSuccessors(); +} +void InvokeInst::setSuccessorV(unsigned idx, BasicBlock *B) { + return setSuccessor(idx, B); +} + //===----------------------------------------------------------------------===// // ReturnInst Implementation //===----------------------------------------------------------------------===// -void ReturnInst::init(Value* RetVal) { - if (RetVal && RetVal->getType() != Type::VoidTy) { - assert(!isa(RetVal) && +void ReturnInst::init(Value *retVal) { + if (retVal && retVal->getType() != Type::VoidTy) { + assert(!isa(retVal) && "Cannot return basic block. Probably using the incorrect ctor"); - Operands.reserve(1); - Operands.push_back(Use(RetVal, this)); + NumOperands = 1; + RetVal.init(retVal, this); } } +unsigned ReturnInst::getNumSuccessorsV() const { + return getNumSuccessors(); +} + // Out-of-line ReturnInst method, put here so the C++ compiler can choose to // emit the vtable for the class in this translation unit. -void ReturnInst::setSuccessor(unsigned idx, BasicBlock *NewSucc) { +void ReturnInst::setSuccessorV(unsigned idx, BasicBlock *NewSucc) { + assert(0 && "ReturnInst has no successors!"); +} + +BasicBlock *ReturnInst::getSuccessorV(unsigned idx) const { assert(0 && "ReturnInst has no successors!"); + abort(); + return 0; } + //===----------------------------------------------------------------------===// // UnwindInst Implementation //===----------------------------------------------------------------------===// -// Likewise for UnwindInst -void UnwindInst::setSuccessor(unsigned idx, BasicBlock *NewSucc) { +unsigned UnwindInst::getNumSuccessorsV() const { + return getNumSuccessors(); +} + +void UnwindInst::setSuccessorV(unsigned idx, BasicBlock *NewSucc) { assert(0 && "UnwindInst has no successors!"); } +BasicBlock *UnwindInst::getSuccessorV(unsigned idx) const { + assert(0 && "UnwindInst has no successors!"); + abort(); + return 0; +} + //===----------------------------------------------------------------------===// // UnreachableInst Implementation //===----------------------------------------------------------------------===// -void UnreachableInst::setSuccessor(unsigned idx, BasicBlock *NewSucc) { - assert(0 && "UnreachableInst has no successors!"); +unsigned UnreachableInst::getNumSuccessorsV() const { + return getNumSuccessors(); +} + +void UnreachableInst::setSuccessorV(unsigned idx, BasicBlock *NewSucc) { + assert(0 && "UnwindInst has no successors!"); +} + +BasicBlock *UnreachableInst::getSuccessorV(unsigned idx) const { + assert(0 && "UnwindInst has no successors!"); + abort(); + return 0; } //===----------------------------------------------------------------------===// // BranchInst Implementation //===----------------------------------------------------------------------===// -void BranchInst::init(BasicBlock *IfTrue) -{ - assert(IfTrue != 0 && "Branch destination may not be null!"); - Operands.reserve(1); - Operands.push_back(Use(IfTrue, this)); +void BranchInst::AssertOK() { + if (isConditional()) + assert(getCondition()->getType() == Type::BoolTy && + "May only branch on boolean predicates!"); } -void BranchInst::init(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond) -{ - assert(IfTrue && IfFalse && Cond && - "Branch destinations and condition may not be null!"); - assert(Cond && Cond->getType() == Type::BoolTy && - "May only branch on boolean predicates!"); - Operands.reserve(3); - Operands.push_back(Use(IfTrue, this)); - Operands.push_back(Use(IfFalse, this)); - Operands.push_back(Use(Cond, this)); -} - -BranchInst::BranchInst(const BranchInst &BI) : TerminatorInst(Instruction::Br) { - Operands.reserve(BI.Operands.size()); - Operands.push_back(Use(BI.Operands[0], this)); - if (BI.Operands.size() != 1) { - assert(BI.Operands.size() == 3 && "BR can have 1 or 3 operands!"); - Operands.push_back(Use(BI.Operands[1], this)); - Operands.push_back(Use(BI.Operands[2], this)); +BranchInst::BranchInst(const BranchInst &BI) : + TerminatorInst(Instruction::Br, Ops, BI.getNumOperands()) { + OperandList[0].init(BI.getOperand(0), this); + if (BI.getNumOperands() != 1) { + assert(BI.getNumOperands() == 3 && "BR can have 1 or 3 operands!"); + OperandList[1].init(BI.getOperand(1), this); + OperandList[2].init(BI.getOperand(2), this); } } +BasicBlock *BranchInst::getSuccessorV(unsigned idx) const { + return getSuccessor(idx); +} +unsigned BranchInst::getNumSuccessorsV() const { + return getNumSuccessors(); +} +void BranchInst::setSuccessorV(unsigned idx, BasicBlock *B) { + setSuccessor(idx, B); +} + + //===----------------------------------------------------------------------===// // AllocationInst Implementation //===----------------------------------------------------------------------===// -void AllocationInst::init(const Type *Ty, Value *ArraySize, unsigned iTy) { - assert(Ty != Type::VoidTy && "Cannot allocate void elements!"); - // ArraySize defaults to 1. - if (!ArraySize) ArraySize = ConstantUInt::get(Type::UIntTy, 1); - - Operands.reserve(1); - assert(ArraySize->getType() == Type::UIntTy && - "Malloc/Allocation array size != UIntTy!"); - - Operands.push_back(Use(ArraySize, this)); +static Value *getAISize(Value *Amt) { + if (!Amt) + Amt = ConstantUInt::get(Type::UIntTy, 1); + else + assert(Amt->getType() == Type::UIntTy && + "Malloc/Allocation array size != UIntTy!"); + return Amt; } AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, const std::string &Name, Instruction *InsertBefore) - : Instruction(PointerType::get(Ty), iTy, Name, InsertBefore) { - init(Ty, ArraySize, iTy); + : UnaryInstruction(PointerType::get(Ty), iTy, getAISize(ArraySize), + Name, InsertBefore) { + assert(Ty != Type::VoidTy && "Cannot allocate void!"); } AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, const std::string &Name, BasicBlock *InsertAtEnd) - : Instruction(PointerType::get(Ty), iTy, Name, InsertAtEnd) { - init(Ty, ArraySize, iTy); + : UnaryInstruction(PointerType::get(Ty), iTy, getAISize(ArraySize), + Name, InsertAtEnd) { + assert(Ty != Type::VoidTy && "Cannot allocate void!"); } bool AllocationInst::isArrayAllocation() const { - return getOperand(0) != ConstantUInt::get(Type::UIntTy, 1); + if (ConstantUInt *CUI = dyn_cast(getOperand(0))) + return CUI->getValue() != 1; + return true; } const Type *AllocationInst::getAllocatedType() const { @@ -320,21 +471,19 @@ // FreeInst Implementation //===----------------------------------------------------------------------===// -void FreeInst::init(Value *Ptr) -{ - assert(Ptr && isa(Ptr->getType()) && "Can't free nonpointer!"); - Operands.reserve(1); - Operands.push_back(Use(Ptr, this)); +void FreeInst::AssertOK() { + assert(isa(getOperand(0)->getType()) && + "Can not free something of nonpointer type!"); } FreeInst::FreeInst(Value *Ptr, Instruction *InsertBefore) - : Instruction(Type::VoidTy, Free, "", InsertBefore) { - init(Ptr); + : UnaryInstruction(Type::VoidTy, Free, Ptr, "", InsertBefore) { + AssertOK(); } FreeInst::FreeInst(Value *Ptr, BasicBlock *InsertAtEnd) - : Instruction(Type::VoidTy, Free, "", InsertAtEnd) { - init(Ptr); + : UnaryInstruction(Type::VoidTy, Free, Ptr, "", InsertAtEnd) { + AssertOK(); } @@ -342,37 +491,35 @@ // LoadInst Implementation //===----------------------------------------------------------------------===// -void LoadInst::init(Value *Ptr) { - assert(Ptr && isa(Ptr->getType()) && +void LoadInst::AssertOK() { + assert(isa(getOperand(0)->getType()) && "Ptr must have pointer type."); - Operands.reserve(1); - Operands.push_back(Use(Ptr, this)); } LoadInst::LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBef) - : Instruction(cast(Ptr->getType())->getElementType(), - Load, Name, InsertBef), Volatile(false) { - init(Ptr); + : UnaryInstruction(cast(Ptr->getType())->getElementType(), + Load, Ptr, Name, InsertBef), Volatile(false) { + AssertOK(); } LoadInst::LoadInst(Value *Ptr, const std::string &Name, BasicBlock *InsertAE) - : Instruction(cast(Ptr->getType())->getElementType(), - Load, Name, InsertAE), Volatile(false) { - init(Ptr); + : UnaryInstruction(cast(Ptr->getType())->getElementType(), + Load, Ptr, Name, InsertAE), Volatile(false) { + AssertOK(); } LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile, Instruction *InsertBef) - : Instruction(cast(Ptr->getType())->getElementType(), - Load, Name, InsertBef), Volatile(isVolatile) { - init(Ptr); + : UnaryInstruction(cast(Ptr->getType())->getElementType(), + Load, Ptr, Name, InsertBef), Volatile(isVolatile) { + AssertOK(); } LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile, BasicBlock *InsertAE) - : Instruction(cast(Ptr->getType())->getElementType(), - Load, Name, InsertAE), Volatile(isVolatile) { - init(Ptr); + : UnaryInstruction(cast(Ptr->getType())->getElementType(), + Load, Ptr, Name, InsertAE), Volatile(isVolatile) { + AssertOK(); } @@ -380,36 +527,46 @@ // StoreInst Implementation //===----------------------------------------------------------------------===// -StoreInst::StoreInst(Value *Val, Value *Ptr, Instruction *InsertBefore) - : Instruction(Type::VoidTy, Store, "", InsertBefore), Volatile(false) { - init(Val, Ptr); +void StoreInst::AssertOK() { + assert(isa(getOperand(1)->getType()) && + "Ptr must have pointer type!"); + assert(getOperand(0)->getType() == + cast(getOperand(1)->getType())->getElementType() + && "Ptr must be a pointer to Val type!"); } -StoreInst::StoreInst(Value *Val, Value *Ptr, BasicBlock *InsertAtEnd) - : Instruction(Type::VoidTy, Store, "", InsertAtEnd), Volatile(false) { - init(Val, Ptr); + +StoreInst::StoreInst(Value *val, Value *addr, Instruction *InsertBefore) + : Instruction(Type::VoidTy, Store, Ops, 2, "", InsertBefore), + Volatile(false) { + Ops[0].init(val, this); + Ops[1].init(addr, this); + AssertOK(); +} + +StoreInst::StoreInst(Value *val, Value *addr, BasicBlock *InsertAtEnd) + : Instruction(Type::VoidTy, Store, Ops, 2, "", InsertAtEnd), Volatile(false) { + Ops[0].init(val, this); + Ops[1].init(addr, this); + AssertOK(); } -StoreInst::StoreInst(Value *Val, Value *Ptr, bool isVolatile, +StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, Instruction *InsertBefore) - : Instruction(Type::VoidTy, Store, "", InsertBefore), Volatile(isVolatile) { - init(Val, Ptr); + : Instruction(Type::VoidTy, Store, Ops, 2, "", InsertBefore), + Volatile(isVolatile) { + Ops[0].init(val, this); + Ops[1].init(addr, this); + AssertOK(); } -StoreInst::StoreInst(Value *Val, Value *Ptr, bool isVolatile, +StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, BasicBlock *InsertAtEnd) - : Instruction(Type::VoidTy, Store, "", InsertAtEnd), Volatile(isVolatile) { - init(Val, Ptr); -} - -void StoreInst::init(Value *Val, Value *Ptr) { - assert(isa(Ptr->getType()) && "Ptr must have pointer type!"); - assert(Val->getType() == cast(Ptr->getType())->getElementType() - && "Ptr must be a pointer to Val type!"); - - Operands.reserve(2); - Operands.push_back(Use(Val, this)); - Operands.push_back(Use(Ptr, this)); + : Instruction(Type::VoidTy, Store, Ops, 2, "", InsertAtEnd), + Volatile(isVolatile) { + Ops[0].init(val, this); + Ops[1].init(addr, this); + AssertOK(); } //===----------------------------------------------------------------------===// @@ -424,27 +581,28 @@ return Ty; } -void GetElementPtrInst::init(Value *Ptr, const std::vector &Idx) -{ - Operands.reserve(1+Idx.size()); - Operands.push_back(Use(Ptr, this)); +void GetElementPtrInst::init(Value *Ptr, const std::vector &Idx) { + NumOperands = 1+Idx.size(); + Use *OL = OperandList = new Use[NumOperands]; + OL[0].init(Ptr, this); - for (unsigned i = 0, E = Idx.size(); i != E; ++i) - Operands.push_back(Use(Idx[i], this)); + for (unsigned i = 0, e = Idx.size(); i != e; ++i) + OL[i+1].init(Idx[i], this); } void GetElementPtrInst::init(Value *Ptr, Value *Idx0, Value *Idx1) { - Operands.reserve(3); - Operands.push_back(Use(Ptr, this)); - Operands.push_back(Use(Idx0, this)); - Operands.push_back(Use(Idx1, this)); + NumOperands = 3; + Use *OL = OperandList = new Use[3]; + OL[0].init(Ptr, this); + OL[1].init(Idx0, this); + OL[2].init(Idx1, this); } GetElementPtrInst::GetElementPtrInst(Value *Ptr, const std::vector &Idx, const std::string &Name, Instruction *InBe) : Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(), Idx, true))), - GetElementPtr, Name, InBe) { + GetElementPtr, 0, 0, Name, InBe) { init(Ptr, Idx); } @@ -452,7 +610,7 @@ const std::string &Name, BasicBlock *IAE) : Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(), Idx, true))), - GetElementPtr, Name, IAE) { + GetElementPtr, 0, 0, Name, IAE) { init(Ptr, Idx); } @@ -460,7 +618,7 @@ const std::string &Name, Instruction *InBe) : Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(), Idx0, Idx1, true))), - GetElementPtr, Name, InBe) { + GetElementPtr, 0, 0, Name, InBe) { init(Ptr, Idx0, Idx1); } @@ -468,10 +626,14 @@ const std::string &Name, BasicBlock *IAE) : Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(), Idx0, Idx1, true))), - GetElementPtr, Name, IAE) { + GetElementPtr, 0, 0, Name, IAE) { init(Ptr, Idx0, Idx1); } +GetElementPtrInst::~GetElementPtrInst() { + delete[] OperandList; +} + // getIndexedType - Returns the type of the element that would be loaded with // a load instruction with the specified parameters. // @@ -537,19 +699,17 @@ // BinaryOperator Class //===----------------------------------------------------------------------===// -void BinaryOperator::init(BinaryOps iType, Value *S1, Value *S2) +void BinaryOperator::init(BinaryOps iType) { - Operands.reserve(2); - Operands.push_back(Use(S1, this)); - Operands.push_back(Use(S2, this)); - assert(S1 && S2 && S1->getType() == S2->getType()); - + Value *LHS = getOperand(0), *RHS = getOperand(1); + assert(LHS->getType() == RHS->getType() && + "Binary operator operand types must match!"); #ifndef NDEBUG switch (iType) { case Add: case Sub: case Mul: case Div: case Rem: - assert(getType() == S1->getType() && + assert(getType() == LHS->getType() && "Arithmetic operation should return same type as operands!"); assert((getType()->isInteger() || getType()->isFloatingPoint() || @@ -558,7 +718,7 @@ break; case And: case Or: case Xor: - assert(getType() == S1->getType() && + assert(getType() == LHS->getType() && "Logical operation should return same type as operands!"); assert(getType()->isIntegral() && "Tried to create a logical operation on a non-integral type!"); @@ -696,7 +856,7 @@ else return true; // Can't commute operands - std::swap(Operands[0], Operands[1]); + std::swap(Ops[0], Ops[1]); return false; } @@ -756,28 +916,41 @@ // SwitchInst Implementation //===----------------------------------------------------------------------===// -void SwitchInst::init(Value *Value, BasicBlock *Default) -{ +void SwitchInst::init(Value *Value, BasicBlock *Default, unsigned NumCases) { assert(Value && Default); - Operands.push_back(Use(Value, this)); - Operands.push_back(Use(Default, this)); + ReservedSpace = 2+NumCases*2; + NumOperands = 2; + OperandList = new Use[ReservedSpace]; + + OperandList[0].init(Value, this); + OperandList[1].init(Default, this); } SwitchInst::SwitchInst(const SwitchInst &SI) - : TerminatorInst(Instruction::Switch) { - Operands.reserve(SI.Operands.size()); - - for (unsigned i = 0, E = SI.Operands.size(); i != E; i+=2) { - Operands.push_back(Use(SI.Operands[i], this)); - Operands.push_back(Use(SI.Operands[i+1], this)); + : TerminatorInst(Instruction::Switch, new Use[SI.getNumOperands()], + SI.getNumOperands()) { + Use *OL = OperandList, *InOL = SI.OperandList; + for (unsigned i = 0, E = SI.getNumOperands(); i != E; i+=2) { + OL[i].init(InOL[i], this); + OL[i+1].init(InOL[i+1], this); } } +SwitchInst::~SwitchInst() { + delete [] OperandList; +} + + /// addCase - Add an entry to the switch instruction... /// void SwitchInst::addCase(Constant *OnVal, BasicBlock *Dest) { - Operands.push_back(Use((Value*)OnVal, this)); - Operands.push_back(Use((Value*)Dest, this)); + unsigned OpNo = NumOperands; + if (OpNo+2 > ReservedSpace) + resizeOperands(0); // Get more space! + // Initialize some new operands. + NumOperands = OpNo+2; + OperandList[OpNo].init(OnVal, this); + OperandList[OpNo+1].init(Dest, this); } /// removeCase - This method removes the specified successor from the switch @@ -786,8 +959,66 @@ /// void SwitchInst::removeCase(unsigned idx) { assert(idx != 0 && "Cannot remove the default case!"); - assert(idx*2 < Operands.size() && "Successor index out of range!!!"); - Operands.erase(Operands.begin()+idx*2, Operands.begin()+(idx+1)*2); + assert(idx*2 < getNumOperands() && "Successor index out of range!!!"); + + unsigned NumOps = getNumOperands(); + Use *OL = OperandList; + + // Move everything after this operand down. + // + // FIXME: we could just swap with the end of the list, then erase. However, + // client might not expect this to happen. The code as it is thrashes the + // use/def lists, which is kinda lame. + for (unsigned i = (idx+1)*2; i != NumOps; i += 2) { + OL[i-2] = OL[i]; + OL[i-2+1] = OL[i+1]; + } + + // Nuke the last value. + OL[NumOps-2].set(0); + OL[NumOps-2+1].set(0); + NumOperands = NumOps-2; +} + +/// resizeOperands - resize operands - This adjusts the length of the operands +/// list according to the following behavior: +/// 1. If NumOps == 0, grow the operand list in response to a push_back style +/// of operation. This grows the number of ops by 1.5 times. +/// 2. If NumOps > NumOperands, reserve space for NumOps operands. +/// 3. If NumOps == NumOperands, trim the reserved space. +/// +void SwitchInst::resizeOperands(unsigned NumOps) { + if (NumOps == 0) { + NumOps = (getNumOperands())*3/2; + } else if (NumOps*2 > NumOperands) { + // No resize needed. + if (ReservedSpace >= NumOps) return; + } else if (NumOps == NumOperands) { + if (ReservedSpace == NumOps) return; + } else { + return; + } + + ReservedSpace = NumOps; + Use *NewOps = new Use[NumOps]; + Use *OldOps = OperandList; + for (unsigned i = 0, e = getNumOperands(); i != e; ++i) { + NewOps[i].init(OldOps[i], this); + OldOps[i].set(0); + } + delete [] OldOps; + OperandList = NewOps; +} + + +BasicBlock *SwitchInst::getSuccessorV(unsigned idx) const { + return getSuccessor(idx); +} +unsigned SwitchInst::getNumSuccessorsV() const { + return getNumSuccessors(); +} +void SwitchInst::setSuccessorV(unsigned idx, BasicBlock *B) { + setSuccessor(idx, B); } @@ -799,12 +1030,12 @@ } BinaryOperator *BinaryOperator::clone() const { - return create(getOpcode(), Operands[0], Operands[1]); + return create(getOpcode(), Ops[0], Ops[1]); } MallocInst *MallocInst::clone() const { return new MallocInst(*this); } AllocaInst *AllocaInst::clone() const { return new AllocaInst(*this); } -FreeInst *FreeInst::clone() const { return new FreeInst(Operands[0]); } +FreeInst *FreeInst::clone() const { return new FreeInst(getOperand(0)); } LoadInst *LoadInst::clone() const { return new LoadInst(*this); } StoreInst *StoreInst::clone() const { return new StoreInst(*this); } CastInst *CastInst::clone() const { return new CastInst(*this); } From lattner at cs.uiuc.edu Fri Jan 28 18:35:46 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 18:35:46 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Function.cpp Globals.cpp Instruction.cpp Message-ID: <200501290035.j0T0ZkaP006425@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Function.cpp updated: 1.84 -> 1.85 Globals.cpp updated: 1.7 -> 1.8 Instruction.cpp updated: 1.41 -> 1.42 --- Log message: Adjust to changes in User class. --- Diffs of the changes: (+17 -17) Function.cpp | 2 +- Globals.cpp | 13 ++++++++----- Instruction.cpp | 19 ++++++++----------- 3 files changed, 17 insertions(+), 17 deletions(-) Index: llvm/lib/VMCore/Function.cpp diff -u llvm/lib/VMCore/Function.cpp:1.84 llvm/lib/VMCore/Function.cpp:1.85 --- llvm/lib/VMCore/Function.cpp:1.84 Fri Jan 7 01:40:32 2005 +++ llvm/lib/VMCore/Function.cpp Fri Jan 28 18:35:33 2005 @@ -87,7 +87,7 @@ Function::Function(const FunctionType *Ty, LinkageTypes Linkage, const std::string &name, Module *ParentModule) - : GlobalValue(PointerType::get(Ty), Value::FunctionVal, Linkage, name) { + : GlobalValue(PointerType::get(Ty), Value::FunctionVal, 0, 0, Linkage, name) { BasicBlocks.setItemParent(this); BasicBlocks.setParent(this); ArgumentList.setItemParent(this); Index: llvm/lib/VMCore/Globals.cpp diff -u llvm/lib/VMCore/Globals.cpp:1.7 llvm/lib/VMCore/Globals.cpp:1.8 --- llvm/lib/VMCore/Globals.cpp:1.7 Mon Oct 11 17:21:39 2004 +++ llvm/lib/VMCore/Globals.cpp Fri Jan 28 18:35:33 2005 @@ -72,14 +72,17 @@ //===----------------------------------------------------------------------===// GlobalVariable::GlobalVariable(const Type *Ty, bool constant, LinkageTypes Link, - Constant *Initializer, + Constant *InitVal, const std::string &Name, Module *ParentModule) - : GlobalValue(PointerType::get(Ty), Value::GlobalVariableVal, Link, Name), + : GlobalValue(PointerType::get(Ty), Value::GlobalVariableVal, + &Initializer, InitVal != 0, Link, Name), isConstantGlobal(constant) { - if (Initializer) { - assert(Initializer->getType() == Ty && + if (InitVal) { + assert(InitVal->getType() == Ty && "Initializer should be the same type as the GlobalVariable!"); - Operands.push_back(Use((Value*)Initializer, this)); + Initializer.init(InitVal, this); + } else { + Initializer.init(0, this); } LeakDetector::addGarbageObject(this); Index: llvm/lib/VMCore/Instruction.cpp diff -u llvm/lib/VMCore/Instruction.cpp:1.41 llvm/lib/VMCore/Instruction.cpp:1.42 --- llvm/lib/VMCore/Instruction.cpp:1.41 Mon Nov 29 20:51:53 2004 +++ llvm/lib/VMCore/Instruction.cpp Fri Jan 28 18:35:33 2005 @@ -18,15 +18,11 @@ #include "llvm/Support/LeakDetector.h" using namespace llvm; -void Instruction::init() { +Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps, + const std::string &Name, Instruction *InsertBefore) + : User(ty, Value::InstructionVal + it, Ops, NumOps, Name), Parent(0) { // Make sure that we get added to a basicblock LeakDetector::addGarbageObject(this); -} - -Instruction::Instruction(const Type *ty, unsigned it, const std::string &Name, - Instruction *InsertBefore) - : User(ty, Value::InstructionVal + it, Name), Parent(0) { - init(); // If requested, insert this instruction into a basic block... if (InsertBefore) { @@ -36,10 +32,11 @@ } } -Instruction::Instruction(const Type *ty, unsigned it, const std::string &Name, - BasicBlock *InsertAtEnd) - : User(ty, Value::InstructionVal + it, Name), Parent(0) { - init(); +Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps, + const std::string &Name, BasicBlock *InsertAtEnd) + : User(ty, Value::InstructionVal + it, Ops, NumOps, Name), Parent(0) { + // Make sure that we get added to a basicblock + LeakDetector::addGarbageObject(this); // append this instruction into the basic block assert(InsertAtEnd && "Basic block to append to may not be NULL!"); From lattner at cs.uiuc.edu Fri Jan 28 18:36:07 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 18:36:07 -0600 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200501290036.j0T0a7ts006440@apoc.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.209 -> 1.210 --- Log message: Adjust to slight changes in instruction interfaces. --- Diffs of the changes: (+3 -3) llvmAsmParser.y | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.209 llvm/lib/AsmParser/llvmAsmParser.y:1.210 --- llvm/lib/AsmParser/llvmAsmParser.y:1.209 Wed Dec 8 10:13:53 2004 +++ llvm/lib/AsmParser/llvmAsmParser.y Fri Jan 28 18:35:55 2005 @@ -1808,7 +1808,7 @@ $$ = new BranchInst(getBBVal($6), getBBVal($9), getVal(Type::BoolTy, $3)); } | SWITCH IntType ValueRef ',' LABEL ValueRef '[' JumpTable ']' { - SwitchInst *S = new SwitchInst(getVal($2, $3), getBBVal($6)); + SwitchInst *S = new SwitchInst(getVal($2, $3), getBBVal($6), $8->size()); $$ = S; std::vector >::iterator I = $8->begin(), @@ -1818,7 +1818,7 @@ delete $8; } | SWITCH IntType ValueRef ',' LABEL ValueRef '[' ']' { - SwitchInst *S = new SwitchInst(getVal($2, $3), getBBVal($6)); + SwitchInst *S = new SwitchInst(getVal($2, $3), getBBVal($6), 0); $$ = S; } | INVOKE TypesV ValueRef '(' ValueRefListE ')' TO LABEL ValueRef @@ -2031,7 +2031,7 @@ if (!Ty->isFirstClassType()) ThrowException("PHI node operands must be of first class type!"); $$ = new PHINode(Ty); - $$->op_reserve($2->size()*2); + ((PHINode*)$$)->reserveOperandSpace($2->size()); while ($2->begin() != $2->end()) { if ($2->front().first->getType() != Ty) ThrowException("All elements of a PHI node must be of the same type!"); From lattner at cs.uiuc.edu Fri Jan 28 18:36:32 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 18:36:32 -0600 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.cpp Reader.h Message-ID: <200501290036.j0T0aWet006457@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: Reader.cpp updated: 1.150 -> 1.151 Reader.h updated: 1.20 -> 1.21 --- Log message: Adjust to changes in User class and minor changes in instruction ctors. --- Diffs of the changes: (+25 -21) Reader.cpp | 25 ++++++++++++------------- Reader.h | 21 +++++++++++++-------- 2 files changed, 25 insertions(+), 21 deletions(-) Index: llvm/lib/Bytecode/Reader/Reader.cpp diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.150 llvm/lib/Bytecode/Reader/Reader.cpp:1.151 --- llvm/lib/Bytecode/Reader/Reader.cpp:1.150 Sun Dec 19 21:23:46 2004 +++ llvm/lib/Bytecode/Reader/Reader.cpp Fri Jan 28 18:36:19 2005 @@ -32,17 +32,15 @@ using namespace llvm; namespace { - -/// @brief A class for maintaining the slot number definition -/// as a placeholder for the actual definition for forward constants defs. -class ConstantPlaceHolder : public ConstantExpr { - ConstantPlaceHolder(); // DO NOT IMPLEMENT - void operator=(const ConstantPlaceHolder &); // DO NOT IMPLEMENT -public: - ConstantPlaceHolder(const Type *Ty) - : ConstantExpr(Instruction::UserOp1, Constant::getNullValue(Ty), Ty) {} -}; - + /// @brief A class for maintaining the slot number definition + /// as a placeholder for the actual definition for forward constants defs. + class ConstantPlaceHolder : public ConstantExpr { + ConstantPlaceHolder(); // DO NOT IMPLEMENT + void operator=(const ConstantPlaceHolder &); // DO NOT IMPLEMENT + public: + ConstantPlaceHolder(const Type *Ty) + : ConstantExpr(Ty, Instruction::UserOp1, 0, 0) {} + }; } // Provide some details on error @@ -671,7 +669,7 @@ error("Invalid phi node encountered!"); PHINode *PN = new PHINode(InstTy); - PN->op_reserve(Oprnds.size()); + PN->reserveOperandSpace(Oprnds.size()); for (unsigned i = 0, e = Oprnds.size(); i != e; i += 2) PN->addIncoming(getValue(iType, Oprnds[i]), getBasicBlock(Oprnds[i+1])); Result = PN; @@ -707,7 +705,8 @@ error("Switch statement with odd number of arguments!"); SwitchInst *I = new SwitchInst(getValue(iType, Oprnds[0]), - getBasicBlock(Oprnds[1])); + getBasicBlock(Oprnds[1]), + Oprnds.size()/2-1); for (unsigned i = 2, e = Oprnds.size(); i != e; i += 2) I->addCase(cast(getValue(iType, Oprnds[i])), getBasicBlock(Oprnds[i+1])); Index: llvm/lib/Bytecode/Reader/Reader.h diff -u llvm/lib/Bytecode/Reader/Reader.h:1.20 llvm/lib/Bytecode/Reader/Reader.h:1.21 --- llvm/lib/Bytecode/Reader/Reader.h:1.20 Thu Dec 9 00:19:44 2004 +++ llvm/lib/Bytecode/Reader/Reader.h Fri Jan 28 18:36:19 2005 @@ -77,18 +77,23 @@ /// constants with global variables at the end of reading the /// globals section. /// @brief A list of values as a User of those Values. - struct ValueList : public User { - ValueList() : User(Type::VoidTy, Value::ValueListVal) {} + class ValueList : public User { + std::vector Uses; + public: + ValueList() : User(Type::VoidTy, Value::ValueListVal, 0, 0) {} // vector compatibility methods unsigned size() const { return getNumOperands(); } - void push_back(Value *V) { Operands.push_back(Use(V, this)); } - Value *back() const { return Operands.back(); } - void pop_back() { Operands.pop_back(); } - bool empty() const { return Operands.empty(); } - // must override this + void push_back(Value *V) { + Uses.push_back(Use(V, this)); + OperandList = &Uses[0]; + ++NumOperands; + } + Value *back() const { return Uses.back(); } + void pop_back() { Uses.pop_back(); --NumOperands; } + bool empty() const { return NumOperands == 0; } virtual void print(std::ostream& os) const { - for ( unsigned i = 0; i < size(); i++ ) { + for (unsigned i = 0; i < size(); ++i) { os << i << " "; getOperand(i)->print(os); os << "\n"; From lattner at cs.uiuc.edu Fri Jan 28 18:37:14 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 18:37:14 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/SparcV9TmpInstr.cpp SparcV9TmpInstr.h Message-ID: <200501290037.j0T0bEvR006482@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9: SparcV9TmpInstr.cpp updated: 1.2 -> 1.3 SparcV9TmpInstr.h updated: 1.2 -> 1.3 --- Log message: Finegrainify namespacification. Adjust TmpInstruction to work with the new User model. --- Diffs of the changes: (+27 -24) SparcV9TmpInstr.cpp | 39 +++++++++++++++++++++++++-------------- SparcV9TmpInstr.h | 12 ++---------- 2 files changed, 27 insertions(+), 24 deletions(-) Index: llvm/lib/Target/SparcV9/SparcV9TmpInstr.cpp diff -u llvm/lib/Target/SparcV9/SparcV9TmpInstr.cpp:1.2 llvm/lib/Target/SparcV9/SparcV9TmpInstr.cpp:1.3 --- llvm/lib/Target/SparcV9/SparcV9TmpInstr.cpp:1.2 Wed Sep 1 17:55:36 2004 +++ llvm/lib/Target/SparcV9/SparcV9TmpInstr.cpp Fri Jan 28 18:36:59 2005 @@ -14,14 +14,24 @@ #include "SparcV9TmpInstr.h" #include "llvm/Support/LeakDetector.h" +using namespace llvm; -namespace llvm { +TmpInstruction::TmpInstruction(const TmpInstruction &TI) + : Instruction(TI.getType(), TI.getOpcode(), Ops, TI.getNumOperands()) { + if (TI.getNumOperands()) { + Ops[0].init(TI.Ops[0], this); + if (TI.getNumOperands() == 2) + Ops[1].init(TI.Ops[1], this); + else + assert(0 && "Bad # operands to TmpInstruction!"); + } +} TmpInstruction::TmpInstruction(Value *s1, Value *s2, const std::string &name) - : Instruction(s1->getType(), Instruction::UserOp1, name) { - Operands.push_back(Use(s1, this)); // s1 must be non-null + : Instruction(s1->getType(), Instruction::UserOp1, Ops, 1+(s2 != 0), name) { + Ops[0].init(s1, this); // s1 must be non-null if (s2) - Operands.push_back(Use(s2, this)); + Ops[1].init(s2, this); // TmpInstructions should not be garbage checked. LeakDetector::removeGarbageObject(this); @@ -29,12 +39,12 @@ TmpInstruction::TmpInstruction(MachineCodeForInstruction& mcfi, Value *s1, Value *s2, const std::string &name) - : Instruction(s1->getType(), Instruction::UserOp1, name) { + : Instruction(s1->getType(), Instruction::UserOp1, Ops, 1+(s2 != 0), name) { mcfi.addTemp(this); - Operands.push_back(Use(s1, this)); // s1 must be non-null + Ops[0].init(s1, this); // s1 must be non-null if (s2) - Operands.push_back(Use(s2, this)); + Ops[1].init(s2, this); // TmpInstructions should not be garbage checked. LeakDetector::removeGarbageObject(this); @@ -45,16 +55,17 @@ TmpInstruction::TmpInstruction(MachineCodeForInstruction& mcfi, const Type *Ty, Value *s1, Value* s2, const std::string &name) - : Instruction(Ty, Instruction::UserOp1, name) { + : Instruction(Ty, Instruction::UserOp1, Ops, (s1 != 0)+(s2 != 0), name) { mcfi.addTemp(this); - if (s1) - Operands.push_back(Use(s1, this)); - if (s2) - Operands.push_back(Use(s2, this)); + assert((s1 != 0 || s2 == 0) && + "s2 cannot be non-null if s1 is non-null!"); + if (s1) { + Ops[0].init(s1, this); + if (s2) + Ops[1].init(s2, this); + } // TmpInstructions should not be garbage checked. LeakDetector::removeGarbageObject(this); } - -} // end namespace llvm Index: llvm/lib/Target/SparcV9/SparcV9TmpInstr.h diff -u llvm/lib/Target/SparcV9/SparcV9TmpInstr.h:1.2 llvm/lib/Target/SparcV9/SparcV9TmpInstr.h:1.3 --- llvm/lib/Target/SparcV9/SparcV9TmpInstr.h:1.2 Mon Aug 16 16:54:30 2004 +++ llvm/lib/Target/SparcV9/SparcV9TmpInstr.h Fri Jan 28 18:36:59 2005 @@ -24,16 +24,8 @@ /// values used within the SparcV9 machine code for an LLVM instruction. /// class TmpInstruction : public Instruction { - TmpInstruction(const TmpInstruction &TI) - : Instruction(TI.getType(), TI.getOpcode()) { - if (!TI.Operands.empty()) { - Operands.push_back(Use(TI.Operands[0], this)); - if (TI.Operands.size() == 2) - Operands.push_back(Use(TI.Operands[1], this)); - else - assert(0 && "Bad # operands to TmpInstruction!"); - } - } + Use Ops[2]; + TmpInstruction(const TmpInstruction &TI); public: // Constructor that uses the type of S1 as the type of the temporary. // s1 must be a valid value. s2 may be NULL. From lattner at cs.uiuc.edu Fri Jan 28 18:37:21 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 18:37:21 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp Message-ID: <200501290037.j0T0bLGV006490@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9: SparcV9PreSelection.cpp updated: 1.41 -> 1.42 --- Log message: add namespace qualifier --- Diffs of the changes: (+2 -1) SparcV9PreSelection.cpp | 3 ++- 1 files changed, 2 insertions(+), 1 deletion(-) Index: llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp diff -u llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp:1.41 llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp:1.42 --- llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp:1.41 Sat Oct 16 13:14:10 2004 +++ llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp Fri Jan 28 18:36:38 2005 @@ -120,7 +120,8 @@ return new CastInst(getArg1, CE->getType(), "constantCast",&insertBefore); case Instruction::GetElementPtr: - assert(find_if(CE->op_begin()+1, CE->op_end(),nonConstant) == CE->op_end() + assert(std::find_if(CE->op_begin()+1, CE->op_end(), + nonConstant) == CE->op_end() && "All indices in ConstantExpr getelementptr must be constant!"); getArg1 = CE->getOperand(0); if (ConstantExpr* CEarg = dyn_cast(getArg1)) From lattner at cs.uiuc.edu Fri Jan 28 18:37:52 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 18:37:52 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/ExprTypeConvert.cpp TransformInternals.h Message-ID: <200501290037.j0T0bqb9006510@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms: ExprTypeConvert.cpp updated: 1.100 -> 1.101 TransformInternals.h updated: 1.24 -> 1.25 --- Log message: Adjust Valuehandle to hold its operand directly in it. --- Diffs of the changes: (+7 -7) ExprTypeConvert.cpp | 13 ++++++------- TransformInternals.h | 1 + 2 files changed, 7 insertions(+), 7 deletions(-) Index: llvm/lib/Transforms/ExprTypeConvert.cpp diff -u llvm/lib/Transforms/ExprTypeConvert.cpp:1.100 llvm/lib/Transforms/ExprTypeConvert.cpp:1.101 --- llvm/lib/Transforms/ExprTypeConvert.cpp:1.100 Sat Jan 8 13:48:40 2005 +++ llvm/lib/Transforms/ExprTypeConvert.cpp Fri Jan 28 18:37:36 2005 @@ -1258,15 +1258,14 @@ ValueHandle::ValueHandle(ValueMapCache &VMC, Value *V) - : Instruction(Type::VoidTy, UserOp1, ""), Cache(VMC) { + : Instruction(Type::VoidTy, UserOp1, &Op, 1, ""), Op(V, this), Cache(VMC) { //DEBUG(std::cerr << "VH AQUIRING: " << (void*)V << " " << V); - Operands.push_back(Use(V, this)); } ValueHandle::ValueHandle(const ValueHandle &VH) - : Instruction(Type::VoidTy, UserOp1, ""), Cache(VH.Cache) { + : Instruction(Type::VoidTy, UserOp1, &Op, 1, ""), + Op(VH.Op, this), Cache(VH.Cache) { //DEBUG(std::cerr << "VH AQUIRING: " << (void*)V << " " << V); - Operands.push_back(Use((Value*)VH.getOperand(0), this)); } static void RecursiveDelete(ValueMapCache &Cache, Instruction *I) { @@ -1291,9 +1290,9 @@ } ValueHandle::~ValueHandle() { - if (Operands[0]->hasOneUse()) { - Value *V = Operands[0]; - Operands[0] = 0; // Drop use! + if (Op->hasOneUse()) { + Value *V = Op; + Op.set(0); // Drop use! // Now we just need to remove the old instruction so we don't get infinite // loops. Note that we cannot use DCE because DCE won't remove a store Index: llvm/lib/Transforms/TransformInternals.h diff -u llvm/lib/Transforms/TransformInternals.h:1.24 llvm/lib/Transforms/TransformInternals.h:1.25 --- llvm/lib/Transforms/TransformInternals.h:1.24 Wed Oct 27 11:12:24 2004 +++ llvm/lib/Transforms/TransformInternals.h Fri Jan 28 18:37:36 2005 @@ -59,6 +59,7 @@ // class ValueMapCache; class ValueHandle : public Instruction { + Use Op; ValueMapCache &Cache; public: ValueHandle(ValueMapCache &VMC, Value *V); From lattner at cs.uiuc.edu Fri Jan 28 18:38:39 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 18:38:39 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/CodeExtractor.cpp SimplifyCFG.cpp Message-ID: <200501290038.j0T0cdtN006530@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: CodeExtractor.cpp updated: 1.35 -> 1.36 SimplifyCFG.cpp updated: 1.62 -> 1.63 --- Log message: switchinst ctor now takes a hint for the number of cases that it will have. --- Diffs of the changes: (+3 -3) CodeExtractor.cpp | 2 +- SimplifyCFG.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp diff -u llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.35 llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.36 --- llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.35 Fri Nov 19 20:20:27 2004 +++ llvm/lib/Transforms/Utils/CodeExtractor.cpp Fri Jan 28 18:38:26 2005 @@ -439,7 +439,7 @@ // Now we can emit a switch statement using the call as a value. SwitchInst *TheSwitch = new SwitchInst(ConstantUInt::getNullValue(Type::UShortTy), - codeReplacer, codeReplacer); + codeReplacer, 0, codeReplacer); // Since there may be multiple exits from the original region, make the new // function return an unsigned, switch on that number. This loop iterates Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp diff -u llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.62 llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.63 --- llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.62 Sat Jan 1 10:02:12 2005 +++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp Fri Jan 28 18:38:26 2005 @@ -518,7 +518,7 @@ AddPredecessorToBlock(NewSuccessors[i], Pred, BB); // Now that the successors are updated, create the new Switch instruction. - SwitchInst *NewSI = new SwitchInst(CV, PredDefault, PTI); + SwitchInst *NewSI = new SwitchInst(CV, PredDefault, PredCases.size(),PTI); for (unsigned i = 0, e = PredCases.size(); i != e; ++i) NewSI->addCase(PredCases[i].first, PredCases[i].second); @@ -1209,7 +1209,7 @@ if (!TrueWhenEqual) std::swap(DefaultBB, EdgeBB); // Create the new switch instruction now. - SwitchInst *New = new SwitchInst(CompVal, DefaultBB, BI); + SwitchInst *New = new SwitchInst(CompVal, DefaultBB,Values.size(),BI); // Add all of the 'cases' to the switch instruction. for (unsigned i = 0, e = Values.size(); i != e; ++i) From lattner at cs.uiuc.edu Fri Jan 28 18:38:58 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 18:38:58 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/LowerSetJmp.cpp Message-ID: <200501290038.j0T0cwpx006543@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: LowerSetJmp.cpp updated: 1.21 -> 1.22 --- Log message: Switchinst takes a hint for the number of cases it will have. --- Diffs of the changes: (+1 -1) LowerSetJmp.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/Transforms/IPO/LowerSetJmp.cpp diff -u llvm/lib/Transforms/IPO/LowerSetJmp.cpp:1.21 llvm/lib/Transforms/IPO/LowerSetJmp.cpp:1.22 --- llvm/lib/Transforms/IPO/LowerSetJmp.cpp:1.21 Thu Oct 7 01:00:24 2004 +++ llvm/lib/Transforms/IPO/LowerSetJmp.cpp Fri Jan 28 18:38:45 2005 @@ -352,7 +352,7 @@ CallInst(TryCatchLJ, make_vector(GetSetJmpMap(Func), 0), "SJNum"); DecisionBBIL.push_back(SJNum); - SwitchInst* SI = new SwitchInst(SJNum, Rethrow, DecisionBB); + SwitchInst* SI = new SwitchInst(SJNum, Rethrow, 0, DecisionBB); return SwitchValMap[Func] = SwitchValuePair(SI, LJVal); } From lattner at cs.uiuc.edu Fri Jan 28 18:39:21 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 18:39:21 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp InstructionCombining.cpp LoopSimplify.cpp Message-ID: <200501290039.j0T0dLne006572@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: DeadStoreElimination.cpp updated: 1.10 -> 1.11 InstructionCombining.cpp updated: 1.311 -> 1.312 LoopSimplify.cpp updated: 1.52 -> 1.53 --- Log message: Adjust to changes in instruction interfaces. --- Diffs of the changes: (+11 -10) DeadStoreElimination.cpp | 11 +++++------ InstructionCombining.cpp | 4 ++-- LoopSimplify.cpp | 6 ++++-- 3 files changed, 11 insertions(+), 10 deletions(-) Index: llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp diff -u llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp:1.10 llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp:1.11 --- llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp:1.10 Sat Jan 8 13:42:22 2005 +++ llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp Fri Jan 28 18:39:08 2005 @@ -156,13 +156,12 @@ // See if this made any operands dead. We do it this way in case the // instruction uses the same operand twice. We don't want to delete a // value then reference it. - while (unsigned NumOps = I->getNumOperands()) { - Instruction *Op = dyn_cast(I->getOperand(NumOps-1)); - I->op_erase(I->op_end()-1); // Drop from the operand list. - - if (Op) DeadInsts.insert(Op); // Attempt to nuke it later. + for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) { + if (Instruction *Op = dyn_cast(I->getOperand(i))) + DeadInsts.insert(Op); // Attempt to nuke it later. + I->setOperand(i, 0); // Drop from the operand list. } - I->getParent()->getInstList().erase(I); + I->eraseFromParent(); ++NumOther; } Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.311 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.312 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.311 Fri Jan 28 13:32:01 2005 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Fri Jan 28 18:39:08 2005 @@ -575,7 +575,7 @@ // Okay, we can do the transformation: create the new PHI node. PHINode *NewPN = new PHINode(I.getType(), I.getName()); I.setName(""); - NewPN->op_reserve(PN->getNumOperands()); + NewPN->reserveOperandSpace(PN->getNumOperands()/2); InsertNewInstBefore(NewPN, *PN); // Next, add all of the operands to the PHI. @@ -4142,7 +4142,7 @@ // correct type, and PHI together all of the LHS's of the instructions. PHINode *NewPN = new PHINode(FirstInst->getOperand(0)->getType(), PN.getName()+".in"); - NewPN->op_reserve(PN.getNumOperands()); + NewPN->reserveOperandSpace(PN.getNumOperands()/2); Value *InVal = FirstInst->getOperand(0); NewPN->addIncoming(InVal, PN.getIncomingBlock(0)); Index: llvm/lib/Transforms/Scalar/LoopSimplify.cpp diff -u llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.52 llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.53 --- llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.52 Sun Oct 17 16:22:29 2004 +++ llvm/lib/Transforms/Scalar/LoopSimplify.cpp Fri Jan 28 18:39:08 2005 @@ -575,7 +575,7 @@ PHINode *PN = cast(I); PHINode *NewPN = new PHINode(PN->getType(), PN->getName()+".be", BETerminator); - NewPN->op_reserve(2*BackedgeBlocks.size()); + NewPN->reserveOperandSpace(BackedgeBlocks.size()); // Loop over the PHI node, moving all entries except the one for the // preheader over to the new PHI node. @@ -604,7 +604,9 @@ PN->setIncomingValue(0, PN->getIncomingValue(PreheaderIdx)); PN->setIncomingBlock(0, PN->getIncomingBlock(PreheaderIdx)); } - PN->op_erase(PN->op_begin()+2, PN->op_end()); + // Nuke all entries except the zero'th. + for (unsigned i = 0, e = PN->getNumIncomingValues()-1; i != e; ++i) + PN->removeIncomingValue(e-i, false); // Finally, add the newly constructed PHI node as the entry for the BEBlock. PN->addIncoming(NewPN, BEBlock); From lattner at cs.uiuc.edu Fri Jan 28 18:44:36 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 18:44:36 -0600 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200501290044.j0T0iaTZ008040@apoc.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.290 -> 1.291 --- Log message: noteworthy. --- Diffs of the changes: (+3 -1) ReleaseNotes.html | 4 +++- 1 files changed, 3 insertions(+), 1 deletion(-) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.290 llvm/docs/ReleaseNotes.html:1.291 --- llvm/docs/ReleaseNotes.html:1.290 Fri Jan 28 00:13:52 2005 +++ llvm/docs/ReleaseNotes.html Fri Jan 28 18:44:22 2005 @@ -78,6 +78,8 @@
      • LLVM now includes an Interprocedural Sparse Conditional Constant Propagation pass, named -ipsccp, which is run by default at link-time.
      • +
      • LLVM is now about 10% faster than before due to its core data structures + using less memory.
      • @@ -565,7 +567,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
        - Last modified: $Date: 2005/01/28 06:13:52 $ + Last modified: $Date: 2005/01/29 00:44:22 $ From lattner at cs.uiuc.edu Fri Jan 28 19:05:28 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 19:05:28 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Instructions.cpp Message-ID: <200501290105.j0T15Sor018124@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Instructions.cpp updated: 1.9 -> 1.10 --- Log message: Make sure that we always grow a multiple of 2 operands. --- Diffs of the changes: (+3 -2) Instructions.cpp | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) Index: llvm/lib/VMCore/Instructions.cpp diff -u llvm/lib/VMCore/Instructions.cpp:1.9 llvm/lib/VMCore/Instructions.cpp:1.10 --- llvm/lib/VMCore/Instructions.cpp:1.9 Fri Jan 28 18:35:16 2005 +++ llvm/lib/VMCore/Instructions.cpp Fri Jan 28 19:05:12 2005 @@ -948,6 +948,7 @@ if (OpNo+2 > ReservedSpace) resizeOperands(0); // Get more space! // Initialize some new operands. + assert(OpNo+1 < ReservedSpace && "Growing didn't work!"); NumOperands = OpNo+2; OperandList[OpNo].init(OnVal, this); OperandList[OpNo+1].init(Dest, this); @@ -989,14 +990,14 @@ /// void SwitchInst::resizeOperands(unsigned NumOps) { if (NumOps == 0) { - NumOps = (getNumOperands())*3/2; + NumOps = getNumOperands()/2*6; } else if (NumOps*2 > NumOperands) { // No resize needed. if (ReservedSpace >= NumOps) return; } else if (NumOps == NumOperands) { if (ReservedSpace == NumOps) return; } else { - return; + return; } ReservedSpace = NumOps; From jeffc at jolt-lang.org Fri Jan 28 21:33:00 2005 From: jeffc at jolt-lang.org (Jeff Cohen) Date: Fri, 28 Jan 2005 21:33:00 -0600 Subject: [llvm-commits] CVS: llvm/win32/VMCore/VMCore.vcproj Message-ID: <200501290333.VAA28510@zion.cs.uiuc.edu> Changes in directory llvm/win32/VMCore: VMCore.vcproj updated: 1.8 -> 1.9 --- Log message: Unbreak VC++ build --- Diffs of the changes: (+0 -3) VMCore.vcproj | 3 --- 1 files changed, 3 deletions(-) Index: llvm/win32/VMCore/VMCore.vcproj diff -u llvm/win32/VMCore/VMCore.vcproj:1.8 llvm/win32/VMCore/VMCore.vcproj:1.9 --- llvm/win32/VMCore/VMCore.vcproj:1.8 Sat Jan 1 16:30:19 2005 +++ llvm/win32/VMCore/VMCore.vcproj Fri Jan 28 21:32:49 2005 @@ -131,9 +131,6 @@ RelativePath="..\..\lib\VMCore\Globals.cpp"> - - Changes in directory llvm/include/llvm/Support: Timer.h updated: 1.14 -> 1.15 --- Log message: Memory used is a delta between memuse at the start of the time and the memuse at the end, thus it is signed. --- Diffs of the changes: (+2 -2) Timer.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/include/llvm/Support/Timer.h diff -u llvm/include/llvm/Support/Timer.h:1.14 llvm/include/llvm/Support/Timer.h:1.15 --- llvm/include/llvm/Support/Timer.h:1.14 Sat Jan 8 14:15:57 2005 +++ llvm/include/llvm/Support/Timer.h Fri Jan 28 23:21:00 2005 @@ -36,7 +36,7 @@ double Elapsed; // Wall clock time elapsed in seconds double UserTime; // User time elapsed double SystemTime; // System time elapsed - size_t MemUsed; // Memory allocated (in bytes) + ssize_t MemUsed; // Memory allocated (in bytes) size_t PeakMem; // Peak memory used size_t PeakMemBase; // Temporary for peak calculation... std::string Name; // The name of this time variable @@ -50,7 +50,7 @@ double getProcessTime() const { return UserTime+SystemTime; } double getWallTime() const { return Elapsed; } - size_t getMemUsed() const { return MemUsed; } + ssize_t getMemUsed() const { return MemUsed; } size_t getPeakMem() const { return PeakMem; } std::string getName() const { return Name; } From lattner at cs.uiuc.edu Fri Jan 28 23:21:29 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 23:21:29 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/Timer.cpp Message-ID: <200501290521.j0T5LT08028156@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Support: Timer.cpp updated: 1.41 -> 1.42 --- Log message: Memory used is a delta between memuse at the start of the time and the memuse at the end, thus it is signed. --- Diffs of the changes: (+2 -3) Timer.cpp | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) Index: llvm/lib/Support/Timer.cpp diff -u llvm/lib/Support/Timer.cpp:1.41 llvm/lib/Support/Timer.cpp:1.42 --- llvm/lib/Support/Timer.cpp:1.41 Sat Jan 8 14:15:57 2005 +++ llvm/lib/Support/Timer.cpp Fri Jan 28 23:21:16 2005 @@ -19,7 +19,6 @@ #include #include #include - using namespace llvm; // GetLibSupportInfoOutputFile - Return a file stream to print our output on. @@ -101,7 +100,7 @@ struct TimeRecord { double Elapsed, UserTime, SystemTime; - size_t MemUsed; + ssize_t MemUsed; }; static TimeRecord getTimeRecord(bool Start) { @@ -111,7 +110,7 @@ sys::TimeValue user(0,0); sys::TimeValue sys(0,0); - size_t MemUsed = 0; + ssize_t MemUsed = 0; if (Start) { sys::Process::GetTimeUsage(now,user,sys); MemUsed = getMemUsage(); From lattner at cs.uiuc.edu Fri Jan 28 23:57:16 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 28 Jan 2005 23:57:16 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/LoadValueNumbering.cpp Message-ID: <200501290557.j0T5vGVf029542@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: LoadValueNumbering.cpp updated: 1.23 -> 1.24 --- Log message: If we see: %A = alloca int %V = load int* %A value number %V to undef, not 0. --- Diffs of the changes: (+3 -4) LoadValueNumbering.cpp | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) Index: llvm/lib/Analysis/LoadValueNumbering.cpp diff -u llvm/lib/Analysis/LoadValueNumbering.cpp:1.23 llvm/lib/Analysis/LoadValueNumbering.cpp:1.24 --- llvm/lib/Analysis/LoadValueNumbering.cpp:1.23 Wed Dec 15 12:14:04 2004 +++ llvm/lib/Analysis/LoadValueNumbering.cpp Fri Jan 28 23:57:01 2005 @@ -22,7 +22,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Analysis/LoadValueNumbering.h" -#include "llvm/Constant.h" +#include "llvm/Constants.h" #include "llvm/Function.h" #include "llvm/Instructions.h" #include "llvm/Pass.h" @@ -357,11 +357,10 @@ Instrs.erase(I); } else if (AllocationInst *AI = dyn_cast(I)) { // If we run into an allocation of the value being loaded, then the - // contenxt are not initialized. We can return any value, so we will - // return a zero. + // contents are not initialized. if (Allocations.count(AI)) { LoadInvalidatedInBBBefore = true; - RetVals.push_back(Constant::getNullValue(LI->getType())); + RetVals.push_back(UndefValue::get(LI->getType())); break; } } From lattner at cs.uiuc.edu Sat Jan 29 00:11:31 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 29 Jan 2005 00:11:31 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/LoadValueNumbering.cpp Message-ID: <200501290611.j0T6BVIq029873@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: LoadValueNumbering.cpp updated: 1.24 -> 1.25 --- Log message: Eliminate generality that is not buying us anything. In particular, this will cause us to miss cases where the input pointer to a load could be value numbered to another load. Something like this: %X = load int* %P1 %Y = load int* %P2 Those are obviously the same if P1/P2 are the same. The code this patch removes attempts to handle that. However, since GCSE iterates, this doesn't actually buy us anything: GCSE will first replace P1 or P2 with the other one, then the load can be value numbered as equal. Removing this code speeds up gcse a lot. On 176.gcc in debug mode, this speeds up gcse from 29.08s -> 25.73s, a 13% savings. --- Diffs of the changes: (+13 -32) LoadValueNumbering.cpp | 45 +++++++++++++-------------------------------- 1 files changed, 13 insertions(+), 32 deletions(-) Index: llvm/lib/Analysis/LoadValueNumbering.cpp diff -u llvm/lib/Analysis/LoadValueNumbering.cpp:1.24 llvm/lib/Analysis/LoadValueNumbering.cpp:1.25 --- llvm/lib/Analysis/LoadValueNumbering.cpp:1.24 Fri Jan 28 23:57:01 2005 +++ llvm/lib/Analysis/LoadValueNumbering.cpp Sat Jan 29 00:11:16 2005 @@ -284,17 +284,7 @@ if (LI->isVolatile()) return getAnalysis().getEqualNumberNodes(V, RetVals); - // If we have a load instruction, find all of the load and store instructions - // that use the same source operand. We implement this recursively, because - // there could be a load of a load of a load that are all identical. We are - // guaranteed that this cannot be an infinite recursion because load - // instructions would have to pass through a PHI node in order for there to be - // a cycle. The PHI node would be handled by the else case here, breaking the - // infinite recursion. - // - std::vector PointerSources; - getEqualNumberNodes(LI->getOperand(0), PointerSources); - PointerSources.push_back(LI->getOperand(0)); + Value *PointerSource = LI->getOperand(0); BasicBlock *LoadBB = LI->getParent(); Function *F = LoadBB->getParent(); @@ -305,27 +295,18 @@ // std::map > CandidateLoads; std::map > CandidateStores; - std::set Allocations; - - while (!PointerSources.empty()) { - Value *Source = PointerSources.back(); - PointerSources.pop_back(); // Get a source pointer... - - if (AllocationInst *AI = dyn_cast(Source)) - Allocations.insert(AI); - for (Value::use_iterator UI = Source->use_begin(), UE = Source->use_end(); - UI != UE; ++UI) - if (LoadInst *Cand = dyn_cast(*UI)) {// Is a load of source? - if (Cand->getParent()->getParent() == F && // In the same function? - Cand != LI && !Cand->isVolatile()) // Not LI itself? - CandidateLoads[Cand->getParent()].push_back(Cand); // Got one... - } else if (StoreInst *Cand = dyn_cast(*UI)) { - if (Cand->getParent()->getParent() == F && !Cand->isVolatile() && - Cand->getOperand(1) == Source) // It's a store THROUGH the ptr... - CandidateStores[Cand->getParent()].push_back(Cand); - } - } + for (Value::use_iterator UI = PointerSource->use_begin(), + UE = PointerSource->use_end(); UI != UE; ++UI) + if (LoadInst *Cand = dyn_cast(*UI)) {// Is a load of source? + if (Cand->getParent()->getParent() == F && // In the same function? + Cand != LI && !Cand->isVolatile()) // Not LI itself? + CandidateLoads[Cand->getParent()].push_back(Cand); // Got one... + } else if (StoreInst *Cand = dyn_cast(*UI)) { + if (Cand->getParent()->getParent() == F && !Cand->isVolatile() && + Cand->getOperand(1) == PointerSource) // It's a store THROUGH the ptr. + CandidateStores[Cand->getParent()].push_back(Cand); + } // Get alias analysis & dominators. AliasAnalysis &AA = getAnalysis(); @@ -358,7 +339,7 @@ } else if (AllocationInst *AI = dyn_cast(I)) { // If we run into an allocation of the value being loaded, then the // contents are not initialized. - if (Allocations.count(AI)) { + if ((Value*)AI == PointerSource) { LoadInvalidatedInBBBefore = true; RetVals.push_back(UndefValue::get(LI->getType())); break; From lattner at cs.uiuc.edu Sat Jan 29 00:21:10 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 29 Jan 2005 00:21:10 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/LoadValueNumbering.cpp Message-ID: <200501290621.j0T6LAYr030690@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: LoadValueNumbering.cpp updated: 1.25 -> 1.26 --- Log message: Minor simplification/speedup. Replaces a set lookup with a pointer comparison. This speeds up 176.gcc from 25.73s to 23.48s, which is 9.5% --- Diffs of the changes: (+3 -4) LoadValueNumbering.cpp | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) Index: llvm/lib/Analysis/LoadValueNumbering.cpp diff -u llvm/lib/Analysis/LoadValueNumbering.cpp:1.25 llvm/lib/Analysis/LoadValueNumbering.cpp:1.26 --- llvm/lib/Analysis/LoadValueNumbering.cpp:1.25 Sat Jan 29 00:11:16 2005 +++ llvm/lib/Analysis/LoadValueNumbering.cpp Sat Jan 29 00:20:55 2005 @@ -285,7 +285,6 @@ return getAnalysis().getEqualNumberNodes(V, RetVals); Value *PointerSource = LI->getOperand(0); - BasicBlock *LoadBB = LI->getParent(); Function *F = LoadBB->getParent(); @@ -333,7 +332,7 @@ // If this instruction is a candidate load before LI, we know there are no // invalidating instructions between it and LI, so they have the same value // number. - if (isa(I) && Instrs.count(I)) { + if (isa(I) && cast(I)->getOperand(0) == PointerSource) { RetVals.push_back(I); Instrs.erase(I); } else if (AllocationInst *AI = dyn_cast(I)) { @@ -350,7 +349,7 @@ // If the invalidating instruction is a store, and its in our candidate // set, then we can do store-load forwarding: the load has the same value // # as the stored value. - if (isa(I) && Instrs.count(I)) { + if (isa(I) && I->getOperand(1) == PointerSource) { Instrs.erase(I); RetVals.push_back(I->getOperand(0)); } @@ -368,7 +367,7 @@ for (BasicBlock::iterator I = LI->getNext(); I != LoadBB->end(); ++I) { // If this instruction is a load, then this instruction returns the same // value as LI. - if (isa(I) && Instrs.count(I)) { + if (isa(I) && cast(I)->getOperand(0) == PointerSource) { RetVals.push_back(I); Instrs.erase(I); } From jeffc at jolt-lang.org Sat Jan 29 00:27:27 2005 From: jeffc at jolt-lang.org (Jeff Cohen) Date: Sat, 29 Jan 2005 00:27:27 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Support/Timer.h Message-ID: <200501290627.AAA29676@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Support: Timer.h updated: 1.15 -> 1.16 --- Log message: Unbreak VC++ build --- Diffs of the changes: (+1 -0) Timer.h | 1 + 1 files changed, 1 insertion(+) Index: llvm/include/llvm/Support/Timer.h diff -u llvm/include/llvm/Support/Timer.h:1.15 llvm/include/llvm/Support/Timer.h:1.16 --- llvm/include/llvm/Support/Timer.h:1.15 Fri Jan 28 23:21:00 2005 +++ llvm/include/llvm/Support/Timer.h Sat Jan 29 00:27:16 2005 @@ -15,6 +15,7 @@ #ifndef LLVM_SUPPORT_TIMER_H #define LLVM_SUPPORT_TIMER_H +#include #include #include #include From lattner at cs.uiuc.edu Sat Jan 29 00:30:00 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 29 Jan 2005 00:30:00 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Support/Timer.h Message-ID: <200501290630.j0T6U0Li031355@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Support: Timer.h updated: 1.16 -> 1.17 --- Log message: Fix quotes. --- Diffs of the changes: (+1 -1) Timer.h | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/include/llvm/Support/Timer.h diff -u llvm/include/llvm/Support/Timer.h:1.16 llvm/include/llvm/Support/Timer.h:1.17 --- llvm/include/llvm/Support/Timer.h:1.16 Sat Jan 29 00:27:16 2005 +++ llvm/include/llvm/Support/Timer.h Sat Jan 29 00:29:45 2005 @@ -15,7 +15,7 @@ #ifndef LLVM_SUPPORT_TIMER_H #define LLVM_SUPPORT_TIMER_H -#include +#include "llvm/Support/DataTypes.h" #include #include #include From lattner at cs.uiuc.edu Sat Jan 29 00:32:06 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 29 Jan 2005 00:32:06 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/LoadValueNumbering.cpp Message-ID: <200501290632.j0T6W6rP031372@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: LoadValueNumbering.cpp updated: 1.26 -> 1.27 --- Log message: Before doing expensive global analysis, check to make sure the pointer is not invalidated on entry and on exit of the block. This fixes some N^2 behavior in common cases, and speeds up gcc another 5% to 22.35s. --- Diffs of the changes: (+50 -46) LoadValueNumbering.cpp | 96 +++++++++++++++++++++++++------------------------ 1 files changed, 50 insertions(+), 46 deletions(-) Index: llvm/lib/Analysis/LoadValueNumbering.cpp diff -u llvm/lib/Analysis/LoadValueNumbering.cpp:1.26 llvm/lib/Analysis/LoadValueNumbering.cpp:1.27 --- llvm/lib/Analysis/LoadValueNumbering.cpp:1.26 Sat Jan 29 00:20:55 2005 +++ llvm/lib/Analysis/LoadValueNumbering.cpp Sat Jan 29 00:31:53 2005 @@ -284,43 +284,13 @@ if (LI->isVolatile()) return getAnalysis().getEqualNumberNodes(V, RetVals); - Value *PointerSource = LI->getOperand(0); + Value *LoadPtr = LI->getOperand(0); BasicBlock *LoadBB = LI->getParent(); Function *F = LoadBB->getParent(); - - // Now that we know the set of equivalent source pointers for the load - // instruction, look to see if there are any load or store candidates that are - // identical. - // - std::map > CandidateLoads; - std::map > CandidateStores; - - for (Value::use_iterator UI = PointerSource->use_begin(), - UE = PointerSource->use_end(); UI != UE; ++UI) - if (LoadInst *Cand = dyn_cast(*UI)) {// Is a load of source? - if (Cand->getParent()->getParent() == F && // In the same function? - Cand != LI && !Cand->isVolatile()) // Not LI itself? - CandidateLoads[Cand->getParent()].push_back(Cand); // Got one... - } else if (StoreInst *Cand = dyn_cast(*UI)) { - if (Cand->getParent()->getParent() == F && !Cand->isVolatile() && - Cand->getOperand(1) == PointerSource) // It's a store THROUGH the ptr. - CandidateStores[Cand->getParent()].push_back(Cand); - } - - // Get alias analysis & dominators. - AliasAnalysis &AA = getAnalysis(); - DominatorSet &DomSetInfo = getAnalysis(); - Value *LoadPtr = LI->getOperand(0); + // Find out how many bytes of memory are loaded by the load instruction... unsigned LoadSize = getAnalysis().getTypeSize(LI->getType()); - - // Find all of the candidate loads and stores that are in the same block as - // the defining instruction. - std::set Instrs; - Instrs.insert(CandidateLoads[LoadBB].begin(), CandidateLoads[LoadBB].end()); - CandidateLoads.erase(LoadBB); - Instrs.insert(CandidateStores[LoadBB].begin(), CandidateStores[LoadBB].end()); - CandidateStores.erase(LoadBB); + AliasAnalysis &AA = getAnalysis(); // Figure out if the load is invalidated from the entry of the block it is in // until the actual instruction. This scans the block backwards from LI. If @@ -332,27 +302,26 @@ // If this instruction is a candidate load before LI, we know there are no // invalidating instructions between it and LI, so they have the same value // number. - if (isa(I) && cast(I)->getOperand(0) == PointerSource) { + if (isa(I) && cast(I)->getOperand(0) == LoadPtr) { RetVals.push_back(I); - Instrs.erase(I); - } else if (AllocationInst *AI = dyn_cast(I)) { + } else if (I == LoadPtr) { // If we run into an allocation of the value being loaded, then the // contents are not initialized. - if ((Value*)AI == PointerSource) { - LoadInvalidatedInBBBefore = true; + if (isa(I)) RetVals.push_back(UndefValue::get(LI->getType())); - break; - } + + // Otherwise, since this is the definition of what we are loading, this + // loaded value cannot occur before this block. + LoadInvalidatedInBBBefore = true; + break; } if (AA.getModRefInfo(I, LoadPtr, LoadSize) & AliasAnalysis::Mod) { // If the invalidating instruction is a store, and its in our candidate // set, then we can do store-load forwarding: the load has the same value // # as the stored value. - if (isa(I) && I->getOperand(1) == PointerSource) { - Instrs.erase(I); + if (isa(I) && I->getOperand(1) == LoadPtr) RetVals.push_back(I->getOperand(0)); - } LoadInvalidatedInBBBefore = true; break; @@ -367,10 +336,8 @@ for (BasicBlock::iterator I = LI->getNext(); I != LoadBB->end(); ++I) { // If this instruction is a load, then this instruction returns the same // value as LI. - if (isa(I) && cast(I)->getOperand(0) == PointerSource) { + if (isa(I) && cast(I)->getOperand(0) == LoadPtr) RetVals.push_back(I); - Instrs.erase(I); - } if (AA.getModRefInfo(I, LoadPtr, LoadSize) & AliasAnalysis::Mod) { LoadInvalidatedInBBAfter = true; @@ -378,6 +345,43 @@ } } + // If the pointer is clobbered on entry and on exit to the function, there is + // no need to do any global analysis at all. + if (LoadInvalidatedInBBBefore && LoadInvalidatedInBBAfter) + return; + + // Now that we know the set of equivalent source pointers for the load + // instruction, look to see if there are any load or store candidates that are + // identical. + // + std::map > CandidateLoads; + std::map > CandidateStores; + + for (Value::use_iterator UI = LoadPtr->use_begin(), UE = LoadPtr->use_end(); + UI != UE; ++UI) + if (LoadInst *Cand = dyn_cast(*UI)) {// Is a load of source? + if (Cand->getParent()->getParent() == F && // In the same function? + // Not in LI's block? + Cand->getParent() != LoadBB && !Cand->isVolatile()) + CandidateLoads[Cand->getParent()].push_back(Cand); // Got one... + } else if (StoreInst *Cand = dyn_cast(*UI)) { + if (Cand->getParent()->getParent() == F && !Cand->isVolatile() && + Cand->getParent() != LoadBB && + Cand->getOperand(1) == LoadPtr) // It's a store THROUGH the ptr. + CandidateStores[Cand->getParent()].push_back(Cand); + } + + // Get dominators. + DominatorSet &DomSetInfo = getAnalysis(); + + // Find all of the candidate loads and stores that are in the same block as + // the defining instruction. + std::set Instrs; + Instrs.insert(CandidateLoads[LoadBB].begin(), CandidateLoads[LoadBB].end()); + CandidateLoads.erase(LoadBB); + Instrs.insert(CandidateStores[LoadBB].begin(), CandidateStores[LoadBB].end()); + CandidateStores.erase(LoadBB); + // If there is anything left in the Instrs set, it could not possibly equal // LI. Instrs.clear(); From lattner at cs.uiuc.edu Sat Jan 29 00:39:40 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 29 Jan 2005 00:39:40 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/LoadValueNumbering.cpp Message-ID: <200501290639.j0T6dePC031945@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: LoadValueNumbering.cpp updated: 1.27 -> 1.28 --- Log message: Remove some useless map operations. Loads/stores that are in the same BB as the load are not included in the Cand* sets at all. --- Diffs of the changes: (+0 -10) LoadValueNumbering.cpp | 10 ---------- 1 files changed, 10 deletions(-) Index: llvm/lib/Analysis/LoadValueNumbering.cpp diff -u llvm/lib/Analysis/LoadValueNumbering.cpp:1.27 llvm/lib/Analysis/LoadValueNumbering.cpp:1.28 --- llvm/lib/Analysis/LoadValueNumbering.cpp:1.27 Sat Jan 29 00:31:53 2005 +++ llvm/lib/Analysis/LoadValueNumbering.cpp Sat Jan 29 00:39:25 2005 @@ -374,17 +374,7 @@ // Get dominators. DominatorSet &DomSetInfo = getAnalysis(); - // Find all of the candidate loads and stores that are in the same block as - // the defining instruction. std::set Instrs; - Instrs.insert(CandidateLoads[LoadBB].begin(), CandidateLoads[LoadBB].end()); - CandidateLoads.erase(LoadBB); - Instrs.insert(CandidateStores[LoadBB].begin(), CandidateStores[LoadBB].end()); - CandidateStores.erase(LoadBB); - - // If there is anything left in the Instrs set, it could not possibly equal - // LI. - Instrs.clear(); // TransparentBlocks - For each basic block the load/store is alive across, // figure out if the pointer is invalidated or not. If it is invalidated, the From lattner at cs.uiuc.edu Sat Jan 29 00:42:49 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 29 Jan 2005 00:42:49 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/LoadValueNumbering.cpp Message-ID: <200501290642.j0T6gnIb032231@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: LoadValueNumbering.cpp updated: 1.28 -> 1.29 --- Log message: Properly handle volatile. --- Diffs of the changes: (+11 -9) LoadValueNumbering.cpp | 20 +++++++++++--------- 1 files changed, 11 insertions(+), 9 deletions(-) Index: llvm/lib/Analysis/LoadValueNumbering.cpp diff -u llvm/lib/Analysis/LoadValueNumbering.cpp:1.28 llvm/lib/Analysis/LoadValueNumbering.cpp:1.29 --- llvm/lib/Analysis/LoadValueNumbering.cpp:1.28 Sat Jan 29 00:39:25 2005 +++ llvm/lib/Analysis/LoadValueNumbering.cpp Sat Jan 29 00:42:34 2005 @@ -299,12 +299,7 @@ bool LoadInvalidatedInBBBefore = false; for (BasicBlock::iterator I = LI; I != LoadBB->begin(); ) { --I; - // If this instruction is a candidate load before LI, we know there are no - // invalidating instructions between it and LI, so they have the same value - // number. - if (isa(I) && cast(I)->getOperand(0) == LoadPtr) { - RetVals.push_back(I); - } else if (I == LoadPtr) { + if (I == LoadPtr) { // If we run into an allocation of the value being loaded, then the // contents are not initialized. if (isa(I)) @@ -314,14 +309,21 @@ // loaded value cannot occur before this block. LoadInvalidatedInBBBefore = true; break; + } else if (LoadInst *LI = dyn_cast(I)) { + // If this instruction is a candidate load before LI, we know there are no + // invalidating instructions between it and LI, so they have the same + // value number. + if (LI->getOperand(0) == LoadPtr && !LI->isVolatile()) + RetVals.push_back(I); } - + if (AA.getModRefInfo(I, LoadPtr, LoadSize) & AliasAnalysis::Mod) { // If the invalidating instruction is a store, and its in our candidate // set, then we can do store-load forwarding: the load has the same value // # as the stored value. - if (isa(I) && I->getOperand(1) == LoadPtr) - RetVals.push_back(I->getOperand(0)); + if (StoreInst *SI = dyn_cast(I)) + if (SI->getOperand(1) == LoadPtr) + RetVals.push_back(I->getOperand(0)); LoadInvalidatedInBBBefore = true; break; From lattner at cs.uiuc.edu Sat Jan 29 01:04:25 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 29 Jan 2005 01:04:25 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/LoadValueNumbering.cpp Message-ID: <200501290704.j0T74PAP000910@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: LoadValueNumbering.cpp updated: 1.29 -> 1.30 --- Log message: Due to previous simplifications, we can simplify the data structures being used here. --- Diffs of the changes: (+36 -35) LoadValueNumbering.cpp | 71 ++++++++++++++++++++++++------------------------- 1 files changed, 36 insertions(+), 35 deletions(-) Index: llvm/lib/Analysis/LoadValueNumbering.cpp diff -u llvm/lib/Analysis/LoadValueNumbering.cpp:1.29 llvm/lib/Analysis/LoadValueNumbering.cpp:1.30 --- llvm/lib/Analysis/LoadValueNumbering.cpp:1.29 Sat Jan 29 00:42:34 2005 +++ llvm/lib/Analysis/LoadValueNumbering.cpp Sat Jan 29 01:04:10 2005 @@ -316,7 +316,7 @@ if (LI->getOperand(0) == LoadPtr && !LI->isVolatile()) RetVals.push_back(I); } - + if (AA.getModRefInfo(I, LoadPtr, LoadSize) & AliasAnalysis::Mod) { // If the invalidating instruction is a store, and its in our candidate // set, then we can do store-load forwarding: the load has the same value @@ -352,12 +352,12 @@ if (LoadInvalidatedInBBBefore && LoadInvalidatedInBBAfter) return; - // Now that we know the set of equivalent source pointers for the load - // instruction, look to see if there are any load or store candidates that are - // identical. + // Now that we know the value is not neccesarily killed on entry or exit to + // the BB, find out how many load and store instructions (to this location) + // live in each BB in the function. // - std::map > CandidateLoads; - std::map > CandidateStores; + std::map CandidateLoads; + std::set CandidateStores; for (Value::use_iterator UI = LoadPtr->use_begin(), UE = LoadPtr->use_end(); UI != UE; ++UI) @@ -365,19 +365,16 @@ if (Cand->getParent()->getParent() == F && // In the same function? // Not in LI's block? Cand->getParent() != LoadBB && !Cand->isVolatile()) - CandidateLoads[Cand->getParent()].push_back(Cand); // Got one... + ++CandidateLoads[Cand->getParent()]; // Got one. } else if (StoreInst *Cand = dyn_cast(*UI)) { if (Cand->getParent()->getParent() == F && !Cand->isVolatile() && - Cand->getParent() != LoadBB && Cand->getOperand(1) == LoadPtr) // It's a store THROUGH the ptr. - CandidateStores[Cand->getParent()].push_back(Cand); + CandidateStores.insert(Cand->getParent()); } - + // Get dominators. DominatorSet &DomSetInfo = getAnalysis(); - std::set Instrs; - // TransparentBlocks - For each basic block the load/store is alive across, // figure out if the pointer is invalidated or not. If it is invalidated, the // boolean is set to false, if it's not it is set to true. If we don't know @@ -388,7 +385,7 @@ // is live across the CFG from the source to destination blocks, and if the // value is not invalidated in either the source or destination blocks, add it // to the equivalence sets. - for (std::map >::iterator + for (std::map::iterator I = CandidateLoads.begin(), E = CandidateLoads.end(); I != E; ++I) { bool CantEqual = false; @@ -430,18 +427,19 @@ // For any loads that are not invalidated, add them to the equivalence // set! if (!CantEqual) { - Instrs.insert(I->second.begin(), I->second.end()); + unsigned NumLoads = I->second; if (BB1 == LoadBB) { // If LI dominates the block in question, check to see if any of the // loads in this block are invalidated before they are reached. for (BasicBlock::iterator BBI = I->first->begin(); ; ++BBI) { - if (isa(BBI) && Instrs.count(BBI)) { - // The load is in the set! - RetVals.push_back(BBI); - Instrs.erase(BBI); - if (Instrs.empty()) break; + if (LoadInst *LI = dyn_cast(BBI)) { + if (LI->getOperand(0) == LoadPtr && !LI->isVolatile()) { + // The load is in the set! + RetVals.push_back(BBI); + if (--NumLoads == 0) break; // Found last load to check. + } } else if (AA.getModRefInfo(BBI, LoadPtr, LoadSize) - & AliasAnalysis::Mod) { + & AliasAnalysis::Mod) { // If there is a modifying instruction, nothing below it will value // # the same. break; @@ -453,11 +451,12 @@ BasicBlock::iterator BBI = I->first->end(); while (1) { --BBI; - if (isa(BBI) && Instrs.count(BBI)) { - // The load is in the set! - RetVals.push_back(BBI); - Instrs.erase(BBI); - if (Instrs.empty()) break; + if (LoadInst *LI = dyn_cast(BBI)) { + if (LI->getOperand(0) == LoadPtr && !LI->isVolatile()) { + // The load is the same as this load! + RetVals.push_back(BBI); + if (--NumLoads == 0) break; // Found all of the laods. + } } else if (AA.getModRefInfo(BBI, LoadPtr, LoadSize) & AliasAnalysis::Mod) { // If there is a modifying instruction, nothing above it will value @@ -466,8 +465,6 @@ } } } - - Instrs.clear(); } } @@ -477,16 +474,21 @@ if (LoadInvalidatedInBBBefore) return; - for (std::map >::iterator - I = CandidateStores.begin(), E = CandidateStores.end(); I != E; ++I) - if (DomSetInfo.dominates(I->first, LoadBB)) { + // Stores in the load-bb are handled above. + CandidateStores.erase(LoadBB); + + for (std::set::iterator I = CandidateStores.begin(), + E = CandidateStores.end(); I != E; ++I) + if (DomSetInfo.dominates(*I, LoadBB)) { + BasicBlock *StoreBB = *I; + // Check to see if the path from the store to the load is transparent // w.r.t. the memory location. bool CantEqual = false; std::set Visited; for (pred_iterator PI = pred_begin(LoadBB), E = pred_end(LoadBB); PI != E; ++PI) - if (!isPathTransparentTo(*PI, I->first, LoadPtr, LoadSize, AA, + if (!isPathTransparentTo(*PI, StoreBB, LoadPtr, LoadSize, AA, Visited, TransparentBlocks)) { // None of these stores can VN the same. CantEqual = true; @@ -499,9 +501,9 @@ // of the load block to the load itself. Now we just scan the store // block. - BasicBlock::iterator BBI = I->first->end(); + BasicBlock::iterator BBI = StoreBB->end(); while (1) { - assert(BBI != I->first->begin() && + assert(BBI != StoreBB->begin() && "There is a store in this block of the pointer, but the store" " doesn't mod the address being stored to?? Must be a bug in" " the alias analysis implementation!"); @@ -510,8 +512,7 @@ // If the invalidating instruction is one of the candidates, // then it provides the value the load loads. if (StoreInst *SI = dyn_cast(BBI)) - if (std::find(I->second.begin(), I->second.end(), SI) != - I->second.end()) + if (SI->getOperand(1) == LoadPtr) RetVals.push_back(SI->getOperand(0)); break; } From alenhar2 at cs.uiuc.edu Sat Jan 29 09:42:22 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Sat, 29 Jan 2005 09:42:22 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp AlphaInstrInfo.td AlphaRegisterInfo.cpp AlphaInstrBuilder.h Message-ID: <200501291542.JAA28331@niobe.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.16 -> 1.17 AlphaInstrInfo.td updated: 1.8 -> 1.9 AlphaRegisterInfo.cpp updated: 1.4 -> 1.5 AlphaInstrBuilder.h (r1.1) removed --- Log message: first step towards a correct and complete stack. also add some forms for things that were getting stuck in the nightly tester. --- Diffs of the changes: (+78 -12) AlphaISelPattern.cpp | 82 +++++++++++++++++++++++++++++++++++++++++++++----- AlphaInstrInfo.td | 4 +- AlphaRegisterInfo.cpp | 4 +- 3 files changed, 78 insertions(+), 12 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.16 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.17 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.16 Fri Jan 28 17:17:54 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Sat Jan 29 09:42:07 2005 @@ -294,6 +294,24 @@ default: Node->dump(); assert(0 && "Node not handled!\n"); + + case ISD::CopyFromReg: + { + // Make sure we generate both values. + if (Result != notIn) + ExprMap[N.getValue(1)] = notIn; // Generate the token + else + Result = ExprMap[N.getValue(0)] = MakeReg(N.getValue(0).getValueType()); + + SDOperand Chain = N.getOperand(0); + + Select(Chain); + unsigned r = dyn_cast(Node)->getReg(); + //std::cerr << "CopyFromReg " << Result << " = " << r << "\n"; + BuildMI(BB, Alpha::CPYS, 2, Result).addReg(r).addReg(r); + return Result; + } + case ISD::LOAD: { // Make sure we generate both values. @@ -346,16 +364,57 @@ BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); return Result; - case ISD::SINT_TO_FP: + case ISD::EXTLOAD: + //include a conversion sequence for float loads to double + if (Result != notIn) + ExprMap[N.getValue(1)] = notIn; // Generate the token + else + Result = ExprMap[N.getValue(0)] = MakeReg(N.getValue(0).getValueType()); + + Tmp2 = MakeReg(MVT::f32); + + if (ConstantPoolSDNode *CP = dyn_cast(N.getOperand(1))) + if (Node->getValueType(0) == MVT::f64) { + assert(cast(Node)->getExtraValueType() == MVT::f32 && + "Bad EXTLOAD!"); + BuildMI(BB, Alpha::LDS, 1, Tmp2).addConstantPoolIndex(CP->getIndex()); + BuildMI(BB, Alpha::CVTST, 1, Result).addReg(Tmp2); + return Result; + } + Select(Node->getOperand(0)); // chain + Tmp1 = SelectExpr(Node->getOperand(1)); + BuildMI(BB, Alpha::LDS, 1, Tmp2).addReg(Tmp1); + BuildMI(BB, Alpha::CVTST, 1, Result).addReg(Tmp2); + return Result; + + + //case ISD::UINT_TO_FP: + + case ISD::SINT_TO_FP: { assert (N.getOperand(0).getValueType() == MVT::i64 && "only quads can be loaded from"); Tmp1 = SelectExpr(N.getOperand(0)); // Get the operand register - Tmp2 = MakeReg(DestType); - //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); + + //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); + + //STL LDS + //STQ LDT + Opc = DestType == MVT::f64 ? Alpha::STQ : Alpha::STL; + BuildMI(BB, Opc, 2).addReg(Tmp1).addFrameIndex(FrameIdx); + Opc = DestType == MVT::f64 ? Alpha::LDT : Alpha::LDS; + BuildMI(BB, Opc, 1, Result).addFrameIndex(FrameIdx); + + //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; } } @@ -400,9 +459,15 @@ Node->dump(); assert(0 && "Node not handled!\n"); + case ISD::ConstantPool: + Tmp1 = cast(N)->getIndex(); + AlphaLowering.restoreGP(BB); + BuildMI(BB, Alpha::LOAD, 1, Result).addConstantPoolIndex(Tmp1); + return Result; + case ISD::FrameIndex: Tmp1 = cast(N)->getIndex(); - BuildMI(BB, Alpha::LDA, 2, Result).addImm(Tmp1 * 8).addReg(Alpha::R30); + BuildMI(BB, Alpha::LDA, 2, Result).addFrameIndex(Tmp1); return Result; case ISD::EXTLOAD: @@ -770,6 +835,7 @@ case ISD::XOR: case ISD::SHL: case ISD::SRL: + case ISD::SRA: case ISD::MUL: assert (DestType == MVT::i64 && "Only do arithmetic on i64s!"); if(N.getOperand(1).getOpcode() == ISD::Constant && Index: llvm/lib/Target/Alpha/AlphaInstrInfo.td diff -u llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.8 llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.9 --- llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.8 Thu Jan 27 01:50:35 2005 +++ llvm/lib/Target/Alpha/AlphaInstrInfo.td Sat Jan 29 09:42:07 2005 @@ -326,9 +326,9 @@ //CVTQL F-P 17.030 Convert quadword to longword def CVTQS : FPForm<0x16, 0x0BC, (ops FPRC:$RC, FPRC:$RA), "cvtqs $RA,$RC">; //Convert quadword to S_floating def CVTQT : FPForm<0x16, 0x0BE, (ops FPRC:$RC, FPRC:$RA), "cvtqt $RA,$RC">; //Convert quadword to T_floating -//CVTST F-P 16.2AC Convert S_floating to T_floating +def CVTST : FPForm<0x16, 0x2AC, (ops FPRC:$RC, FPRC:$RA), "cvtst $RA,$RC">; //Convert S_floating to T_floating //CVTTQ F-P 16.0AF Convert T_floating to quadword -//CVTTS F-P 16.0AC Convert T_floating to S_floating +def CVTTS : FPForm<0x16, 0x2AC, (ops FPRC:$RC, FPRC:$RA), "cvtts $RA,$RC">; //Convert T_floating to S_floating //S_floating : IEEE Single //T_floating : IEEE Double Index: llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp diff -u llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.4 llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.5 --- llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.4 Thu Jan 27 02:31:19 2005 +++ llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp Sat Jan 29 09:42:07 2005 @@ -50,7 +50,7 @@ unsigned SrcReg, int FrameIdx) const { //std::cerr << "Trying to store " << getPrettyName(SrcReg) << " to " << FrameIdx << "\n"; //BuildMI(MBB, MI, Alpha::WTF, 0).addReg(SrcReg); - BuildMI(MBB, MI, Alpha::STQ, 3).addReg(SrcReg).addImm(FrameIdx * 8).addReg(Alpha::R30); + BuildMI(MBB, MI, Alpha::STQ, 3).addReg(SrcReg).addFrameIndex(FrameIdx); // assert(0 && "TODO"); } @@ -60,7 +60,7 @@ unsigned DestReg, int FrameIdx) const{ //std::cerr << "Trying to load " << getPrettyName(DestReg) << " to " << FrameIdx << "\n"; //BuildMI(MBB, MI, Alpha::WTF, 0, DestReg); - BuildMI(MBB, MI, Alpha::LDQ, 2, DestReg).addImm(FrameIdx * 8).addReg(Alpha::R30); + BuildMI(MBB, MI, Alpha::LDQ, 2, DestReg).addFrameIndex(FrameIdx); // assert(0 && "TODO"); } From lattner at cs.uiuc.edu Sat Jan 29 10:53:17 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 29 Jan 2005 10:53:17 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/Compressor.cpp Message-ID: <200501291653.j0TGrHYi001799@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Support: Compressor.cpp updated: 1.10 -> 1.11 --- Log message: Finegrainify namespacification --- Diffs of the changes: (+14 -12) Compressor.cpp | 26 ++++++++++++++------------ 1 files changed, 14 insertions(+), 12 deletions(-) Index: llvm/lib/Support/Compressor.cpp diff -u llvm/lib/Support/Compressor.cpp:1.10 llvm/lib/Support/Compressor.cpp:1.11 --- llvm/lib/Support/Compressor.cpp:1.10 Sat Jan 8 13:32:59 2005 +++ llvm/lib/Support/Compressor.cpp Sat Jan 29 10:53:02 2005 @@ -18,15 +18,14 @@ #include #include #include "bzip2/bzlib.h" - -namespace { +using namespace llvm; enum CompressionTypes { COMP_TYPE_NONE = '0', COMP_TYPE_BZIP2 = '2', }; -inline int getdata(char*& buffer, unsigned& size, +static int getdata(char*& buffer, unsigned& size, llvm::Compressor::OutputDataCallback* cb, void* context) { buffer = 0; size = 0; @@ -54,11 +53,11 @@ uint64_t output_count; // Total count of output bytes }; -void NULLCOMP_init(NULLCOMP_stream* s) { +static void NULLCOMP_init(NULLCOMP_stream* s) { s->output_count = 0; } -bool NULLCOMP_compress(NULLCOMP_stream* s) { +static bool NULLCOMP_compress(NULLCOMP_stream* s) { assert(s && "Invalid NULLCOMP_stream"); assert(s->next_in != 0); assert(s->next_out != 0); @@ -82,7 +81,7 @@ } } -bool NULLCOMP_decompress(NULLCOMP_stream* s) { +static bool NULLCOMP_decompress(NULLCOMP_stream* s) { assert(s && "Invalid NULLCOMP_stream"); assert(s->next_in != 0); assert(s->next_out != 0); @@ -106,9 +105,11 @@ } } -void NULLCOMP_end(NULLCOMP_stream* strm) { +static void NULLCOMP_end(NULLCOMP_stream* strm) { } +namespace { + /// This structure is only used when a bytecode file is compressed. /// As bytecode is being decompressed, the memory buffer might need /// to be reallocated. The buffer allocation is handled in a callback @@ -170,6 +171,11 @@ } }; +} // end anonymous namespace + + +namespace { + // This structure retains the context when compressing the bytecode file. The // WriteCompressedData function below uses it to keep track of the previously // filled chunk of memory (which it writes) and how many bytes have been @@ -233,9 +239,7 @@ std::ostream* Out; // The stream we write the data to. }; -} - -namespace llvm { +} // end anonymous namespace // Compress in one of three ways uint64_t Compressor::compress(const char* in, unsigned size, @@ -460,6 +464,4 @@ return zipSize; } -} - // vim: sw=2 ai From lattner at cs.uiuc.edu Sat Jan 29 11:06:11 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 29 Jan 2005 11:06:11 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/Compressor.cpp Message-ID: <200501291706.j0TH6Bsf002342@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Support: Compressor.cpp updated: 1.11 -> 1.12 --- Log message: After reading in a bc file, trim the resultant buffer down to what we really need. This reduces 4M of memory consumption reading 176.gcc. --- Diffs of the changes: (+12 -2) Compressor.cpp | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-) Index: llvm/lib/Support/Compressor.cpp diff -u llvm/lib/Support/Compressor.cpp:1.11 llvm/lib/Support/Compressor.cpp:1.12 --- llvm/lib/Support/Compressor.cpp:1.11 Sat Jan 29 10:53:02 2005 +++ llvm/lib/Support/Compressor.cpp Sat Jan 29 11:05:56 2005 @@ -119,7 +119,7 @@ struct BufferContext { char* buff; unsigned size; - BufferContext(unsigned compressedSize ) { + BufferContext(unsigned compressedSize) { // Null to indicate malloc of a new block buff = 0; @@ -128,12 +128,21 @@ // in the callback for an initial allocation of 4x compressedSize. This // calculation is based on the typical compression ratio of bzip2 on LLVM // bytecode files which typically ranges in the 50%-75% range. Since we - // tyipcally get at least 50%, doubling is insufficient. By using a 4x + // typically get at least 50%, doubling is insufficient. By using a 4x // multiplier on the first allocation, we minimize the impact of having to // copy the buffer on reallocation. size = compressedSize*2; } + /// trimTo - Reduce the size of the buffer down to the specified amount. This + /// is useful after have read in the bytecode file to discard extra unused + /// memory. + /// + void trimTo(size_t NewSize) { + buff = (char*)::realloc(buff, NewSize); + size = NewSize; + } + /// This function handles allocation of the buffer used for decompression of /// compressed bytecode files. It is called by Compressor::decompress which is /// called by BytecodeReader::ParseBytecode. @@ -333,6 +342,7 @@ Compressor::compressToNewBuffer(const char* in, unsigned size, char*&out) { BufferContext bc(size); uint64_t result = compress(in,size,BufferContext::callback,(void*)&bc); + bc.trimTo(result); out = bc.buff; return result; } From lattner at cs.uiuc.edu Sat Jan 29 11:16:24 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 29 Jan 2005 11:16:24 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Support/Compressor.h Message-ID: <200501291716.j0THGOiT014532@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Support: Compressor.h updated: 1.4 -> 1.5 --- Log message: There is no reason to include ostream here, include iosfwd instead. This file was schizophrenic when it came to representing sizes. In some cases it represented them as 'unsigneds', which are not enough for 64-bit hosts. In other cases, it represented them as uint64_t's, which are inefficient for 32-bit hosts. This patch unifies all of the sizes to use size_t instead. --- Diffs of the changes: (+14 -14) Compressor.h | 28 ++++++++++++++-------------- 1 files changed, 14 insertions(+), 14 deletions(-) Index: llvm/include/llvm/Support/Compressor.h diff -u llvm/include/llvm/Support/Compressor.h:1.4 llvm/include/llvm/Support/Compressor.h:1.5 --- llvm/include/llvm/Support/Compressor.h:1.4 Thu Nov 25 13:37:42 2004 +++ llvm/include/llvm/Support/Compressor.h Sat Jan 29 11:16:07 2005 @@ -15,7 +15,7 @@ #define LLVM_SUPPORT_COMPRESSOR_H #include "llvm/Support/DataTypes.h" -#include +#include namespace llvm { @@ -46,9 +46,9 @@ /// @throws std::string explaining error if a compression error occurs /// @returns The size of the output buffer \p out. /// @brief Compress memory to a new memory buffer. - static uint64_t compressToNewBuffer( + static size_t compressToNewBuffer( const char* in, ///< The buffer to be compressed - unsigned size, ///< The size of the buffer to be compressed + size_t size, ///< The size of the buffer to be compressed char*&out ///< The returned output buffer ); @@ -59,9 +59,9 @@ /// compression the caller would *prefer*. /// @returns The amount of data written to \p out. /// @brief Compress memory to a file. - static uint64_t compressToStream( + static size_t compressToStream( const char*in, ///< The buffer to be compressed - unsigned size, ///< The size of the buffer to be compressed + size_t size, ///< The size of the buffer to be compressed std::ostream& out ///< The output stream to write data on ); @@ -70,9 +70,9 @@ /// by malloc. It is the caller's responsibility to free \p out. /// @returns The size of the output buffer \p out. /// @brief Decompress memory to a new memory buffer. - static uint64_t decompressToNewBuffer( + static size_t decompressToNewBuffer( const char *in, ///< The buffer to be decompressed - unsigned size, ///< Size of the buffer to be decompressed + size_t size, ///< Size of the buffer to be decompressed char*&out ///< The returned output buffer ); @@ -82,9 +82,9 @@ /// this method. /// @returns The amount of data written to \p out. /// @brief Decompress memory to a stream. - static uint64_t decompressToStream( + static size_t decompressToStream( const char *in, ///< The buffer to be decompressed - unsigned size, ///< Size of the buffer to be decompressed + size_t size, ///< Size of the buffer to be decompressed std::ostream& out ///< The stream to write write data on ); @@ -105,7 +105,7 @@ /// @returns 0 for success, 1 for failure /// @throws nothing /// @brief Output callback function type - typedef unsigned (OutputDataCallback)(char*& buffer, unsigned& size, + typedef size_t (OutputDataCallback)(char*& buffer, size_t& size, void* context); /// This function does the compression work. The block of memory starting @@ -123,9 +123,9 @@ /// @throws std::string if an error occurs /// @returns the total size of the compressed data /// @brief Compress a block of memory. - static uint64_t compress( + static size_t compress( const char* in, ///< The buffer to be compressed - unsigned size, ///< The size of the buffer to be compressed + size_t size, ///< The size of the buffer to be compressed OutputDataCallback* cb, ///< Call back for memory allocation void* context = 0 ///< Context for callback ); @@ -143,9 +143,9 @@ /// @throws std::string if an error occurs /// @returns the total size of the decompressed data /// @brief Decompress a block of memory. - static uint64_t decompress( + static size_t decompress( const char *in, ///< The buffer to be decompressed - unsigned size, ///< Size of the buffer to be decompressed + size_t size, ///< Size of the buffer to be decompressed OutputDataCallback* cb, ///< Call back for memory allocation void* context = 0 ///< Context for callback ); From lattner at cs.uiuc.edu Sat Jan 29 11:17:30 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 29 Jan 2005 11:17:30 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/Compressor.cpp Message-ID: <200501291717.j0THHURR014546@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Support: Compressor.cpp updated: 1.12 -> 1.13 --- Log message: This file was schizophrenic when it came to representing sizes. In some cases it represented them as 'unsigned's, which are not enough for 64-bit hosts. In other cases, it represented them as uint64_t's, which are inefficient for 32-bit hosts. This patch unifies all of the sizes to use size_t instead. --- Diffs of the changes: (+45 -44) Compressor.cpp | 89 ++++++++++++++++++++++++++++----------------------------- 1 files changed, 45 insertions(+), 44 deletions(-) Index: llvm/lib/Support/Compressor.cpp diff -u llvm/lib/Support/Compressor.cpp:1.12 llvm/lib/Support/Compressor.cpp:1.13 --- llvm/lib/Support/Compressor.cpp:1.12 Sat Jan 29 11:05:56 2005 +++ llvm/lib/Support/Compressor.cpp Sat Jan 29 11:17:18 2005 @@ -17,6 +17,7 @@ #include "llvm/ADT/StringExtras.h" #include #include +#include #include "bzip2/bzlib.h" using namespace llvm; @@ -25,7 +26,7 @@ COMP_TYPE_BZIP2 = '2', }; -static int getdata(char*& buffer, unsigned& size, +static int getdata(char*& buffer, size_t &size, llvm::Compressor::OutputDataCallback* cb, void* context) { buffer = 0; size = 0; @@ -44,13 +45,13 @@ struct NULLCOMP_stream { // User provided fields - char* next_in; - unsigned avail_in; - char* next_out; - unsigned avail_out; + char* next_in; + size_t avail_in; + char* next_out; + size_t avail_out; // Information fields - uint64_t output_count; // Total count of output bytes + size_t output_count; // Total count of output bytes }; static void NULLCOMP_init(NULLCOMP_stream* s) { @@ -118,8 +119,8 @@ /// @brief An internal buffer object used for handling decompression struct BufferContext { char* buff; - unsigned size; - BufferContext(unsigned compressedSize) { + size_t size; + BufferContext(size_t compressedSize) { // Null to indicate malloc of a new block buff = 0; @@ -146,12 +147,12 @@ /// This function handles allocation of the buffer used for decompression of /// compressed bytecode files. It is called by Compressor::decompress which is /// called by BytecodeReader::ParseBytecode. - static unsigned callback(char*&buff, unsigned& sz, void* ctxt){ + static size_t callback(char*&buff, size_t &sz, void* ctxt){ // Case the context variable to our BufferContext BufferContext* bc = reinterpret_cast(ctxt); // Compute the new, doubled, size of the block - unsigned new_size = bc->size * 2; + size_t new_size = bc->size * 2; // Extend or allocate the block (realloc(0,n) == malloc(n)) char* new_buff = (char*) ::realloc(bc->buff, new_size); @@ -191,7 +192,7 @@ // written. struct WriterContext { // Initialize the context - WriterContext(std::ostream*OS, unsigned CS) + WriterContext(std::ostream*OS, size_t CS) : chunk(0), sz(0), written(0), compSize(CS), Out(OS) {} // Make sure we clean up memory @@ -201,8 +202,8 @@ } // Write the chunk - void write(unsigned size = 0) { - unsigned write_size = (size == 0 ? sz : size); + void write(size_t size = 0) { + size_t write_size = (size == 0 ? sz : size); Out->write(chunk,write_size); written += write_size; delete [] chunk; @@ -214,10 +215,9 @@ // allocate memory for the compression buffer. This function fulfills that // responsibility but also writes the previous (now filled) buffer out to the // stream. - static unsigned callback(char*& buffer, unsigned& size, void* context) { + static size_t callback(char*& buffer, size_t &size, void* context) { // Cast the context to the structure it must point to. - WriterContext* ctxt = - reinterpret_cast(context); + WriterContext* ctxt = reinterpret_cast(context); // If there's a previously allocated chunk, it must now be filled with // compressed data, so we write it out and deallocate it. @@ -242,22 +242,22 @@ } char* chunk; // pointer to the chunk of memory filled by compression - unsigned sz; // size of chunk - unsigned written; // aggregate total of bytes written in all chunks - unsigned compSize; // size of the uncompressed buffer + size_t sz; // size of chunk + size_t written; // aggregate total of bytes written in all chunks + size_t compSize; // size of the uncompressed buffer std::ostream* Out; // The stream we write the data to. }; } // end anonymous namespace // Compress in one of three ways -uint64_t Compressor::compress(const char* in, unsigned size, - OutputDataCallback* cb, void* context ) { +size_t Compressor::compress(const char* in, size_t size, + OutputDataCallback* cb, void* context) { assert(in && "Can't compress null buffer"); assert(size && "Can't compress empty buffer"); assert(cb && "Can't compress without a callback function"); - uint64_t result = 0; + size_t result = 0; // For small files, we just don't bother compressing. bzip2 isn't very good // with tiny files and can actually make the file larger, so we just avoid @@ -308,8 +308,9 @@ } // Finish - result = (static_cast(bzdata.total_out_hi32) << 32) | - bzdata.total_out_lo32 + 1; + result = bzdata.total_out_lo32 + 1; + if (sizeof(size_t) == sizeof(uint64_t)) + result |= static_cast(bzdata.total_out_hi32) << 32; BZ2_bzCompressEnd(&bzdata); } else { @@ -338,22 +339,21 @@ return result; } -uint64_t -Compressor::compressToNewBuffer(const char* in, unsigned size, char*&out) { +size_t Compressor::compressToNewBuffer(const char* in, size_t size, char*&out) { BufferContext bc(size); - uint64_t result = compress(in,size,BufferContext::callback,(void*)&bc); + size_t result = compress(in,size,BufferContext::callback,(void*)&bc); bc.trimTo(result); out = bc.buff; return result; } -uint64_t -Compressor::compressToStream(const char*in, unsigned size, std::ostream& out) { +size_t +Compressor::compressToStream(const char*in, size_t size, std::ostream& out) { // Set up the context and writer - WriterContext ctxt(&out,size / 2); + WriterContext ctxt(&out, size / 2); - // Compress everything after the magic number (which we'll alter) - uint64_t zipSize = Compressor::compress(in,size, + // Compress everything after the magic number (which we'll alter). + size_t zipSize = Compressor::compress(in,size, WriterContext::callback, (void*)&ctxt); if (ctxt.chunk) { @@ -363,13 +363,13 @@ } // Decompress in one of three ways -uint64_t Compressor::decompress(const char *in, unsigned size, - OutputDataCallback* cb, void* context) { +size_t Compressor::decompress(const char *in, size_t size, + OutputDataCallback* cb, void* context) { assert(in && "Can't decompress null buffer"); assert(size > 1 && "Can't decompress empty buffer"); assert(cb && "Can't decompress without a callback function"); - uint64_t result = 0; + size_t result = 0; switch (*in++) { case COMP_TYPE_BZIP2: { @@ -417,8 +417,9 @@ } // Finish - result = (static_cast(bzdata.total_out_hi32) << 32) | - bzdata.total_out_lo32; + result = bzdata.total_out_lo32; + if (sizeof(size_t) == sizeof(uint64_t)) + result |= (static_cast(bzdata.total_out_hi32) << 32); BZ2_bzDecompressEnd(&bzdata); break; } @@ -451,21 +452,21 @@ return result; } -uint64_t -Compressor::decompressToNewBuffer(const char* in, unsigned size, char*&out) { +size_t +Compressor::decompressToNewBuffer(const char* in, size_t size, char*&out) { BufferContext bc(size); - unsigned result = decompress(in,size,BufferContext::callback,(void*)&bc); + size_t result = decompress(in,size,BufferContext::callback,(void*)&bc); out = bc.buff; return result; } - -uint64_t -Compressor::decompressToStream(const char*in, unsigned size, std::ostream& out){ + +size_t +Compressor::decompressToStream(const char*in, size_t size, std::ostream& out){ // Set up the context and writer WriterContext ctxt(&out,size / 2); // Compress everything after the magic number (which we'll alter) - uint64_t zipSize = Compressor::decompress(in,size, + size_t zipSize = Compressor::decompress(in,size, WriterContext::callback, (void*)&ctxt); if (ctxt.chunk) { From lattner at cs.uiuc.edu Sat Jan 29 11:27:42 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 29 Jan 2005 11:27:42 -0600 Subject: [llvm-commits] CVS: llvm/tools/llvm-dis/llvm-dis.cpp Message-ID: <200501291727.j0THRgkw014759@apoc.cs.uiuc.edu> Changes in directory llvm/tools/llvm-dis: llvm-dis.cpp updated: 1.48 -> 1.49 --- Log message: This has been deprecated for long enough, nuke it. --- Diffs of the changes: (+0 -9) llvm-dis.cpp | 9 --------- 1 files changed, 9 deletions(-) Index: llvm/tools/llvm-dis/llvm-dis.cpp diff -u llvm/tools/llvm-dis/llvm-dis.cpp:1.48 llvm/tools/llvm-dis/llvm-dis.cpp:1.49 --- llvm/tools/llvm-dis/llvm-dis.cpp:1.48 Wed Dec 29 23:36:07 2004 +++ llvm/tools/llvm-dis/llvm-dis.cpp Sat Jan 29 11:27:26 2005 @@ -37,9 +37,6 @@ static cl::opt Force("f", cl::desc("Overwrite output files")); -static cl::opt -CWriteMode("c", cl::desc("Obsolete option, do not use"), cl::ReallyHidden); - int main(int argc, char **argv) { try { cl::ParseCommandLineOptions(argc, argv, " llvm .bc -> .ll disassembler\n"); @@ -48,12 +45,6 @@ std::ostream *Out = &std::cout; // Default to printing to stdout... std::string ErrorMessage; - if (CWriteMode) { - std::cerr << "ERROR: llvm-dis no longer contains the C backend. " - << "Use 'llc -march=c' instead!\n"; - exit(1); - } - std::auto_ptr M(ParseBytecodeFile(InputFilename, &ErrorMessage)); if (M.get() == 0) { std::cerr << argv[0] << ": "; From lattner at cs.uiuc.edu Sat Jan 29 11:29:18 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 29 Jan 2005 11:29:18 -0600 Subject: [llvm-commits] CVS: llvm/tools/llvm-dis/llvm-dis.cpp Message-ID: <200501291729.j0THTIl0014929@apoc.cs.uiuc.edu> Changes in directory llvm/tools/llvm-dis: llvm-dis.cpp updated: 1.49 -> 1.50 --- Log message: clean up comments --- Diffs of the changes: (+2 -3) llvm-dis.cpp | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) Index: llvm/tools/llvm-dis/llvm-dis.cpp diff -u llvm/tools/llvm-dis/llvm-dis.cpp:1.49 llvm/tools/llvm-dis/llvm-dis.cpp:1.50 --- llvm/tools/llvm-dis/llvm-dis.cpp:1.49 Sat Jan 29 11:27:26 2005 +++ llvm/tools/llvm-dis/llvm-dis.cpp Sat Jan 29 11:29:05 2005 @@ -42,7 +42,7 @@ cl::ParseCommandLineOptions(argc, argv, " llvm .bc -> .ll disassembler\n"); sys::PrintStackTraceOnErrorSignal(); - std::ostream *Out = &std::cout; // Default to printing to stdout... + std::ostream *Out = &std::cout; // Default to printing to stdout. std::string ErrorMessage; std::auto_ptr M(ParseBytecodeFile(InputFilename, &ErrorMessage)); @@ -98,8 +98,7 @@ Out = &std::cout; } - // All that dis does is write the assembly or C out to a file... - // + // All that llvm-dis does is write the assembly to a file. PassManager Passes; Passes.add(new PrintModulePass(Out)); Passes.run(*M.get()); From lattner at cs.uiuc.edu Sat Jan 29 12:40:35 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 29 Jan 2005 12:40:35 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/ADT/ilist Message-ID: <200501291840.j0TIeZ3s001722@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/ADT: ilist updated: 1.22 -> 1.23 --- Log message: Rename createNode -> createSentinal. Add a new method, destroySentinal, that is used to delete it (instead of requiring use of delete. --- Diffs of the changes: (+4 -3) ilist | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) Index: llvm/include/llvm/ADT/ilist diff -u llvm/include/llvm/ADT/ilist:1.22 llvm/include/llvm/ADT/ilist:1.23 --- llvm/include/llvm/ADT/ilist:1.22 Mon Oct 4 13:10:14 2004 +++ llvm/include/llvm/ADT/ilist Sat Jan 29 12:40:19 2005 @@ -58,9 +58,10 @@ static void setPrev(NodeTy *N, NodeTy *Prev) { N->setPrev(Prev); } static void setNext(NodeTy *N, NodeTy *Next) { N->setNext(Next); } - static NodeTy *createNode() { return new NodeTy(); } static NodeTy *createNode(const NodeTy &V) { return new NodeTy(V); } + static NodeTy *createSentinal() { return new NodeTy(); } + static void destroySentinal(NodeTy *N) { delete N; } void addNodeToList(NodeTy *NTy) {} void removeNodeFromList(NodeTy *NTy) {} @@ -301,11 +302,11 @@ typedef std::reverse_iterator const_reverse_iterator; typedef std::reverse_iterator reverse_iterator; - iplist() : Head(Traits::createNode()), Tail(Head) { + iplist() : Head(Traits::createSentinal()), Tail(Head) { setNext(Head, 0); setPrev(Head, 0); } - ~iplist() { clear(); delete Tail; } + ~iplist() { clear(); Traits::destroySentinal(Tail); } // Iterator creation methods. iterator begin() { return iterator(Head); } From lattner at cs.uiuc.edu Sat Jan 29 12:40:54 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 29 Jan 2005 12:40:54 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineBasicBlock.h MachineFunction.h Message-ID: <200501291840.j0TIesi2001744@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineBasicBlock.h updated: 1.41 -> 1.42 MachineFunction.h updated: 1.47 -> 1.48 --- Log message: Adjust to ilist changes. --- Diffs of the changes: (+4 -2) MachineBasicBlock.h | 3 ++- MachineFunction.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) Index: llvm/include/llvm/CodeGen/MachineBasicBlock.h diff -u llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.41 llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.42 --- llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.41 Wed Oct 27 11:14:51 2004 +++ llvm/include/llvm/CodeGen/MachineBasicBlock.h Sat Jan 29 12:40:42 2005 @@ -45,7 +45,8 @@ static void setPrev(MachineInstr* N, MachineInstr* prev) { N->prev = prev; } static void setNext(MachineInstr* N, MachineInstr* next) { N->next = next; } - static MachineInstr* createNode(); + static MachineInstr* createSentinal(); + static void destroySentinal(MachineInstr *MI) { delete MI; } void addNodeToList(MachineInstr* N); void removeNodeFromList(MachineInstr* N); void transferNodesFromList( Index: llvm/include/llvm/CodeGen/MachineFunction.h diff -u llvm/include/llvm/CodeGen/MachineFunction.h:1.47 llvm/include/llvm/CodeGen/MachineFunction.h:1.48 --- llvm/include/llvm/CodeGen/MachineFunction.h:1.47 Sun Jan 23 16:57:27 2005 +++ llvm/include/llvm/CodeGen/MachineFunction.h Sat Jan 29 12:40:42 2005 @@ -55,7 +55,8 @@ N->Next = next; } - static MachineBasicBlock* createNode(); + static MachineBasicBlock* createSentinal(); + static void destroySentinal(MachineBasicBlock *MBB) { delete MBB; } void addNodeToList(MachineBasicBlock* N); void removeNodeFromList(MachineBasicBlock* N); void transferNodesFromList(iplist Changes in directory llvm/include/llvm/Analysis/DataStructure: DSNode.h updated: 1.46 -> 1.47 --- Log message: Adjust to ilist changes. --- Diffs of the changes: (+2 -1) DSNode.h | 3 ++- 1 files changed, 2 insertions(+), 1 deletion(-) Index: llvm/include/llvm/Analysis/DataStructure/DSNode.h diff -u llvm/include/llvm/Analysis/DataStructure/DSNode.h:1.46 llvm/include/llvm/Analysis/DataStructure/DSNode.h:1.47 --- llvm/include/llvm/Analysis/DataStructure/DSNode.h:1.46 Sat Jan 8 22:18:28 2005 +++ llvm/include/llvm/Analysis/DataStructure/DSNode.h Sat Jan 29 12:40:43 2005 @@ -369,7 +369,8 @@ static void setPrev(DSNode *N, DSNode *Prev) { N->Prev = Prev; } static void setNext(DSNode *N, DSNode *Next) { N->Next = Next; } - static DSNode *createNode() { return new DSNode(0,0); } + static DSNode *createSentinal() { return new DSNode(0,0); } + static void destroySentinal(DSNode *N) { delete N; } //static DSNode *createNode(const DSNode &V) { return new DSNode(V); } From lattner at cs.uiuc.edu Sat Jan 29 12:41:13 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 29 Jan 2005 12:41:13 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/BasicBlock.h Function.h Module.h Message-ID: <200501291841.j0TIfDgd001772@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: BasicBlock.h updated: 1.45 -> 1.46 Function.h updated: 1.57 -> 1.58 Module.h updated: 1.55 -> 1.56 --- Log message: Adjust to changes in ilist --- Diffs of the changes: (+15 -11) BasicBlock.h | 5 +++-- Function.h | 11 ++++++----- Module.h | 10 ++++++---- 3 files changed, 15 insertions(+), 11 deletions(-) Index: llvm/include/llvm/BasicBlock.h diff -u llvm/include/llvm/BasicBlock.h:1.45 llvm/include/llvm/BasicBlock.h:1.46 --- llvm/include/llvm/BasicBlock.h:1.45 Mon Nov 15 13:02:35 2004 +++ llvm/include/llvm/BasicBlock.h Sat Jan 29 12:41:00 2005 @@ -40,8 +40,9 @@ template<> struct ilist_traits : public SymbolTableListTraits { - // createNode is used to create a node that marks the end of the list... - static Instruction *createNode(); + // createSentinal is used to create a node that marks the end of the list... + static Instruction *createSentinal(); + static void destroySentinal(Instruction *I) { delete I; } static iplist &getList(BasicBlock *BB); }; Index: llvm/include/llvm/Function.h diff -u llvm/include/llvm/Function.h:1.57 llvm/include/llvm/Function.h:1.58 --- llvm/include/llvm/Function.h:1.57 Fri Jan 7 01:40:20 2005 +++ llvm/include/llvm/Function.h Sat Jan 29 12:41:00 2005 @@ -31,17 +31,18 @@ template<> struct ilist_traits : public SymbolTableListTraits { - // createNode is used to create a node that marks the end of the list... - static BasicBlock *createNode(); - + // createSentinal is used to create a node that marks the end of the list... + static BasicBlock *createSentinal(); + static void destroySentinal(BasicBlock *BB) { delete BB; } static iplist &getList(Function *F); }; template<> struct ilist_traits : public SymbolTableListTraits { - // createNode is used to create a node that marks the end of the list... - static Argument *createNode(); + // createSentinal is used to create a node that marks the end of the list... + static Argument *createSentinal(); + static void destroySentinal(Argument *A) { delete A; } static iplist &getList(Function *F); }; Index: llvm/include/llvm/Module.h diff -u llvm/include/llvm/Module.h:1.55 llvm/include/llvm/Module.h:1.56 --- llvm/include/llvm/Module.h:1.55 Fri Nov 19 10:25:42 2004 +++ llvm/include/llvm/Module.h Sat Jan 29 12:41:00 2005 @@ -32,14 +32,16 @@ template<> struct ilist_traits : public SymbolTableListTraits { - // createNode is used to create a node that marks the end of the list... - static Function *createNode(); + // createSentinal is used to create a node that marks the end of the list. + static Function *createSentinal(); + static void destroySentinal(Function *F) { delete F; } static iplist &getList(Module *M); }; template<> struct ilist_traits : public SymbolTableListTraits { - // createNode is used to create a node that marks the end of the list... - static GlobalVariable *createNode(); + // createSentinal is used to create a node that marks the end of the list. + static GlobalVariable *createSentinal(); + static void destroySentinal(GlobalVariable *GV) { delete GV; } static iplist &getList(Module *M); }; From lattner at cs.uiuc.edu Sat Jan 29 12:41:25 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 29 Jan 2005 12:41:25 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/BasicBlock.cpp Function.cpp Module.cpp Message-ID: <200501291841.j0TIfPlk001790@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: BasicBlock.cpp updated: 1.52 -> 1.53 Function.cpp updated: 1.85 -> 1.86 Module.cpp updated: 1.57 -> 1.58 --- Log message: Adjust to ilist changes. --- Diffs of the changes: (+5 -5) BasicBlock.cpp | 2 +- Function.cpp | 4 ++-- Module.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) Index: llvm/lib/VMCore/BasicBlock.cpp diff -u llvm/lib/VMCore/BasicBlock.cpp:1.52 llvm/lib/VMCore/BasicBlock.cpp:1.53 --- llvm/lib/VMCore/BasicBlock.cpp:1.52 Fri Jan 28 18:33:59 2005 +++ llvm/lib/VMCore/BasicBlock.cpp Sat Jan 29 12:41:12 2005 @@ -48,7 +48,7 @@ }; } -Instruction *ilist_traits::createNode() { +Instruction *ilist_traits::createSentinal() { return new DummyInst(); } iplist &ilist_traits::getList(BasicBlock *BB) { Index: llvm/lib/VMCore/Function.cpp diff -u llvm/lib/VMCore/Function.cpp:1.85 llvm/lib/VMCore/Function.cpp:1.86 --- llvm/lib/VMCore/Function.cpp:1.85 Fri Jan 28 18:35:33 2005 +++ llvm/lib/VMCore/Function.cpp Sat Jan 29 12:41:12 2005 @@ -20,7 +20,7 @@ #include "llvm/ADT/StringExtras.h" using namespace llvm; -BasicBlock *ilist_traits::createNode() { +BasicBlock *ilist_traits::createSentinal() { BasicBlock *Ret = new BasicBlock(); // This should not be garbage monitored. LeakDetector::removeGarbageObject(Ret); @@ -31,7 +31,7 @@ return F->getBasicBlockList(); } -Argument *ilist_traits::createNode() { +Argument *ilist_traits::createSentinal() { Argument *Ret = new Argument(Type::IntTy); // This should not be garbage monitored. LeakDetector::removeGarbageObject(Ret); Index: llvm/lib/VMCore/Module.cpp diff -u llvm/lib/VMCore/Module.cpp:1.57 llvm/lib/VMCore/Module.cpp:1.58 --- llvm/lib/VMCore/Module.cpp:1.57 Tue Sep 14 00:43:23 2004 +++ llvm/lib/VMCore/Module.cpp Sat Jan 29 12:41:12 2005 @@ -28,7 +28,7 @@ // Methods to implement the globals and functions lists. // -Function *ilist_traits::createNode() { +Function *ilist_traits::createSentinal() { FunctionType *FTy = FunctionType::get(Type::VoidTy, std::vector(), false); Function *Ret = new Function(FTy, GlobalValue::ExternalLinkage); @@ -36,7 +36,7 @@ LeakDetector::removeGarbageObject(Ret); return Ret; } -GlobalVariable *ilist_traits::createNode() { +GlobalVariable *ilist_traits::createSentinal() { GlobalVariable *Ret = new GlobalVariable(Type::IntTy, false, GlobalValue::ExternalLinkage); // This should not be garbage monitored. From lattner at cs.uiuc.edu Sat Jan 29 12:41:37 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 29 Jan 2005 12:41:37 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/MachineFunction.cpp MachineBasicBlock.cpp Message-ID: <200501291841.j0TIfba5001804@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: MachineFunction.cpp updated: 1.75 -> 1.76 MachineBasicBlock.cpp updated: 1.21 -> 1.22 --- Log message: adjust to ilist changes. --- Diffs of the changes: (+4 -5) MachineBasicBlock.cpp | 2 +- MachineFunction.cpp | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) Index: llvm/lib/CodeGen/MachineFunction.cpp diff -u llvm/lib/CodeGen/MachineFunction.cpp:1.75 llvm/lib/CodeGen/MachineFunction.cpp:1.76 --- llvm/lib/CodeGen/MachineFunction.cpp:1.75 Sun Jan 23 16:13:58 2005 +++ llvm/lib/CodeGen/MachineFunction.cpp Sat Jan 29 12:41:24 2005 @@ -89,8 +89,8 @@ //===---------------------------------------------------------------------===// // MachineFunction implementation //===---------------------------------------------------------------------===// -MachineBasicBlock* ilist_traits::createNode() -{ + +MachineBasicBlock* ilist_traits::createSentinal() { MachineBasicBlock* dummy = new MachineBasicBlock(); LeakDetector::removeGarbageObject(dummy); return dummy; @@ -99,8 +99,7 @@ void ilist_traits::transferNodesFromList( iplist >& toList, ilist_iterator first, - ilist_iterator last) -{ + ilist_iterator last) { if (Parent != toList.Parent) for (; first != last; ++first) first->Parent = toList.Parent; Index: llvm/lib/CodeGen/MachineBasicBlock.cpp diff -u llvm/lib/CodeGen/MachineBasicBlock.cpp:1.21 llvm/lib/CodeGen/MachineBasicBlock.cpp:1.22 --- llvm/lib/CodeGen/MachineBasicBlock.cpp:1.21 Tue Oct 26 10:43:42 2004 +++ llvm/lib/CodeGen/MachineBasicBlock.cpp Sat Jan 29 12:41:25 2005 @@ -46,7 +46,7 @@ } -MachineInstr* ilist_traits::createNode() { +MachineInstr* ilist_traits::createSentinal() { MachineInstr* dummy = new MachineInstr(0, 0); LeakDetector::removeGarbageObject(dummy); return dummy; From lattner at cs.uiuc.edu Sat Jan 29 12:43:43 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 29 Jan 2005 12:43:43 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Use.h Message-ID: <200501291843.j0TIhhAq001826@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: Use.h updated: 1.8 -> 1.9 --- Log message: Adjust to ilist changes. Based on the ilist changes avoid allocating an entire Use object for the end of the Use chain. This saves 8 bytes of memory for each Value allocated in the program. For 176.gcc, this reduces us from 69.5M -> 66.0M, a 5.3% memory savings. --- Diffs of the changes: (+25 -13) Use.h | 38 +++++++++++++++++++++++++------------- 1 files changed, 25 insertions(+), 13 deletions(-) Index: llvm/include/llvm/Use.h diff -u llvm/include/llvm/Use.h:1.8 llvm/include/llvm/Use.h:1.9 --- llvm/include/llvm/Use.h:1.8 Fri Jan 28 18:30:52 2005 +++ llvm/include/llvm/Use.h Sat Jan 29 12:43:28 2005 @@ -32,10 +32,6 @@ // Use is here to make keeping the "use" list of a Value up-to-date really easy. // class Use { - Value *Val; - User *U; - Use *Prev, *Next; - friend struct ilist_traits; public: inline void init(Value *V, User *U); @@ -65,19 +61,35 @@ Value *operator->() { return Val; } const Value *operator->() const { return Val; } + +private: + // NOTE!! The Next/Prev fields MUST stay at the start of this structure. The + // end-token for the ilist is allocated as JUST the next/prev pair to reduce + // memory usage instead of allocating an entire Use. + struct NextPrevPtrs { + Use *Next, *Prev; + } UseLinks; + + Value *Val; + User *U; + friend struct ilist_traits; }; template<> struct ilist_traits { - static Use *getPrev(Use *N) { return N->Prev; } - static Use *getNext(Use *N) { return N->Next; } - static const Use *getPrev(const Use *N) { return N->Prev; } - static const Use *getNext(const Use *N) { return N->Next; } - static void setPrev(Use *N, Use *Prev) { N->Prev = Prev; } - static void setNext(Use *N, Use *Next) { N->Next = Next; } - - // createNode - this is used to create the end marker for the use list - static Use *createNode() { return new Use(0,0); } + static Use *getPrev(Use *N) { return N->UseLinks.Prev; } + static Use *getNext(Use *N) { return N->UseLinks.Next; } + static const Use *getPrev(const Use *N) { return N->UseLinks.Prev; } + static const Use *getNext(const Use *N) { return N->UseLinks.Next; } + static void setPrev(Use *N, Use *Prev) { N->UseLinks.Prev = Prev; } + static void setNext(Use *N, Use *Next) { N->UseLinks.Next = Next; } + + /// createSentinal - this is used to create the end marker for the use list. + /// Note that we only allocate a UseLinks structure, which is just enough to + /// hold the next/prev pointers. This saves us 8 bytes of memory for every + /// Value allocated. + static Use *createSentinal() { return (Use*)new Use::NextPrevPtrs(); } + static void destroySentinal(Use *S) { delete (Use::NextPrevPtrs*)S; } void addNodeToList(Use *NTy) {} void removeNodeFromList(Use *NTy) {} From lattner at cs.uiuc.edu Sat Jan 29 13:27:43 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 29 Jan 2005 13:27:43 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp Message-ID: <200501291927.j0TJRh0s016850@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaRegisterInfo.cpp updated: 1.5 -> 1.6 --- Log message: Unbreak the build :( --- Diffs of the changes: (+0 -1) AlphaRegisterInfo.cpp | 1 - 1 files changed, 1 deletion(-) Index: llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp diff -u llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.5 llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.6 --- llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.5 Sat Jan 29 09:42:07 2005 +++ llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp Sat Jan 29 13:27:28 2005 @@ -13,7 +13,6 @@ #define DEBUG_TYPE "reginfo" #include "Alpha.h" -#include "AlphaInstrBuilder.h" #include "AlphaRegisterInfo.h" #include "llvm/Constants.h" #include "llvm/Type.h" From reid at x10sys.com Sat Jan 29 16:30:04 2005 From: reid at x10sys.com (Reid Spencer) Date: Sat, 29 Jan 2005 16:30:04 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200501292230.QAA31108@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.204 -> 1.205 --- Log message: Fix the use of the constructor for SwitchInst which now has a "NumCases" parameter. --- Diffs of the changes: (+2 -1) Compiler.cpp | 3 ++- 1 files changed, 2 insertions(+), 1 deletion(-) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.204 llvm-java/lib/Compiler/Compiler.cpp:1.205 --- llvm-java/lib/Compiler/Compiler.cpp:1.204 Thu Jan 27 14:04:42 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Sat Jan 29 16:29:53 2005 @@ -1919,7 +1919,8 @@ void do_switch(unsigned defTarget, const SwitchCases& sw) { Value* v = pop(Type::IntTy); SwitchInst* in = - new SwitchInst(v, bbBuilder_->getBasicBlock(defTarget), currentBB_); + new SwitchInst(v, bbBuilder_->getBasicBlock(defTarget), sw.size(), + currentBB_); for (unsigned i = 0, e = sw.size(); i != e; ++i) in->addCase(ConstantSInt::get(Type::IntTy, sw[i].first), bbBuilder_->getBasicBlock(sw[i].second)); From tbrethou at cs.uiuc.edu Sat Jan 29 17:08:16 2005 From: tbrethou at cs.uiuc.edu (Tanya Brethour) Date: Sat, 29 Jan 2005 17:08:16 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/Compressor.cpp Message-ID: <200501292308.RAA28619@niobe.cs.uiuc.edu> Changes in directory llvm/lib/Support: Compressor.cpp updated: 1.13 -> 1.14 --- Log message: Make this work on systems where size_t is not the same as unsigned. --- Diffs of the changes: (+8 -0) Compressor.cpp | 8 ++++++++ 1 files changed, 8 insertions(+) Index: llvm/lib/Support/Compressor.cpp diff -u llvm/lib/Support/Compressor.cpp:1.13 llvm/lib/Support/Compressor.cpp:1.14 --- llvm/lib/Support/Compressor.cpp:1.13 Sat Jan 29 11:17:18 2005 +++ llvm/lib/Support/Compressor.cpp Sat Jan 29 17:08:01 2005 @@ -36,6 +36,14 @@ return result; } +static int getdata(char*& buffer, unsigned &size, + llvm::Compressor::OutputDataCallback* cb, void* context) { + size_t SizeOut; + int Res = getdata(buffer, SizeOut, cb, context); + size = SizeOut; + return Res; +} + //===----------------------------------------------------------------------===// //=== NULLCOMP - a compression like set of routines that just copies data //=== without doing any compression. This is provided so that if the From tbrethou at cs.uiuc.edu Sat Jan 29 17:30:11 2005 From: tbrethou at cs.uiuc.edu (Tanya Brethour) Date: Sat, 29 Jan 2005 17:30:11 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/Compressor.cpp Message-ID: <200501292330.RAA28648@niobe.cs.uiuc.edu> Changes in directory llvm/lib/Support: Compressor.cpp updated: 1.14 -> 1.15 --- Log message: Make this work on systems where size_t == unsigned and where they are not the same. --- Diffs of the changes: (+6 -6) Compressor.cpp | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) Index: llvm/lib/Support/Compressor.cpp diff -u llvm/lib/Support/Compressor.cpp:1.14 llvm/lib/Support/Compressor.cpp:1.15 --- llvm/lib/Support/Compressor.cpp:1.14 Sat Jan 29 17:08:01 2005 +++ llvm/lib/Support/Compressor.cpp Sat Jan 29 17:29:55 2005 @@ -36,8 +36,8 @@ return result; } -static int getdata(char*& buffer, unsigned &size, - llvm::Compressor::OutputDataCallback* cb, void* context) { +static int getdata_uns(char*& buffer, unsigned &size, + llvm::Compressor::OutputDataCallback* cb, void* context) { size_t SizeOut; int Res = getdata(buffer, SizeOut, cb, context); size = SizeOut; @@ -290,7 +290,7 @@ } // Get a block of memory - if (0 != getdata(bzdata.next_out, bzdata.avail_out,cb,context)) { + if (0 != getdata_uns(bzdata.next_out, bzdata.avail_out,cb,context)) { BZ2_bzCompressEnd(&bzdata); throw std::string("Can't allocate output buffer"); } @@ -302,7 +302,7 @@ // Compress it int bzerr = BZ_FINISH_OK; while (BZ_FINISH_OK == (bzerr = BZ2_bzCompress(&bzdata, BZ_FINISH))) { - if (0 != getdata(bzdata.next_out, bzdata.avail_out,cb,context)) { + if (0 != getdata_uns(bzdata.next_out, bzdata.avail_out,cb,context)) { BZ2_bzCompressEnd(&bzdata); throw std::string("Can't allocate output buffer"); } @@ -400,7 +400,7 @@ } // Get a block of memory - if (0 != getdata(bzdata.next_out, bzdata.avail_out,cb,context)) { + if (0 != getdata_uns(bzdata.next_out, bzdata.avail_out,cb,context)) { BZ2_bzDecompressEnd(&bzdata); throw std::string("Can't allocate output buffer"); } @@ -408,7 +408,7 @@ // Decompress it int bzerr = BZ_OK; while (BZ_OK == (bzerr = BZ2_bzDecompress(&bzdata))) { - if (0 != getdata(bzdata.next_out, bzdata.avail_out,cb,context)) { + if (0 != getdata_uns(bzdata.next_out, bzdata.avail_out,cb,context)) { BZ2_bzDecompressEnd(&bzdata); throw std::string("Can't allocate output buffer"); } From lattner at cs.uiuc.edu Sat Jan 29 18:08:42 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 29 Jan 2005 18:08:42 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/BasicBlock.h Function.h Module.h Use.h Message-ID: <200501300008.j0U08giH018506@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: BasicBlock.h updated: 1.46 -> 1.47 Function.h updated: 1.58 -> 1.59 Module.h updated: 1.56 -> 1.57 Use.h updated: 1.9 -> 1.10 --- Log message: Improve conformance with the Misha spelling benchmark suite --- Diffs of the changes: (+18 -18) BasicBlock.h | 6 +++--- Function.h | 12 ++++++------ Module.h | 12 ++++++------ Use.h | 6 +++--- 4 files changed, 18 insertions(+), 18 deletions(-) Index: llvm/include/llvm/BasicBlock.h diff -u llvm/include/llvm/BasicBlock.h:1.46 llvm/include/llvm/BasicBlock.h:1.47 --- llvm/include/llvm/BasicBlock.h:1.46 Sat Jan 29 12:41:00 2005 +++ llvm/include/llvm/BasicBlock.h Sat Jan 29 18:08:26 2005 @@ -40,9 +40,9 @@ template<> struct ilist_traits : public SymbolTableListTraits { - // createSentinal is used to create a node that marks the end of the list... - static Instruction *createSentinal(); - static void destroySentinal(Instruction *I) { delete I; } + // createSentinel is used to create a node that marks the end of the list... + static Instruction *createSentinel(); + static void destroySentinel(Instruction *I) { delete I; } static iplist &getList(BasicBlock *BB); }; Index: llvm/include/llvm/Function.h diff -u llvm/include/llvm/Function.h:1.58 llvm/include/llvm/Function.h:1.59 --- llvm/include/llvm/Function.h:1.58 Sat Jan 29 12:41:00 2005 +++ llvm/include/llvm/Function.h Sat Jan 29 18:08:26 2005 @@ -31,18 +31,18 @@ template<> struct ilist_traits : public SymbolTableListTraits { - // createSentinal is used to create a node that marks the end of the list... - static BasicBlock *createSentinal(); - static void destroySentinal(BasicBlock *BB) { delete BB; } + // createSentinel is used to create a node that marks the end of the list... + static BasicBlock *createSentinel(); + static void destroySentinel(BasicBlock *BB) { delete BB; } static iplist &getList(Function *F); }; template<> struct ilist_traits : public SymbolTableListTraits { - // createSentinal is used to create a node that marks the end of the list... - static Argument *createSentinal(); - static void destroySentinal(Argument *A) { delete A; } + // createSentinel is used to create a node that marks the end of the list... + static Argument *createSentinel(); + static void destroySentinel(Argument *A) { delete A; } static iplist &getList(Function *F); }; Index: llvm/include/llvm/Module.h diff -u llvm/include/llvm/Module.h:1.56 llvm/include/llvm/Module.h:1.57 --- llvm/include/llvm/Module.h:1.56 Sat Jan 29 12:41:00 2005 +++ llvm/include/llvm/Module.h Sat Jan 29 18:08:26 2005 @@ -32,16 +32,16 @@ template<> struct ilist_traits : public SymbolTableListTraits { - // createSentinal is used to create a node that marks the end of the list. - static Function *createSentinal(); - static void destroySentinal(Function *F) { delete F; } + // createSentinel is used to create a node that marks the end of the list. + static Function *createSentinel(); + static void destroySentinel(Function *F) { delete F; } static iplist &getList(Module *M); }; template<> struct ilist_traits : public SymbolTableListTraits { - // createSentinal is used to create a node that marks the end of the list. - static GlobalVariable *createSentinal(); - static void destroySentinal(GlobalVariable *GV) { delete GV; } + // createSentinel is used to create a node that marks the end of the list. + static GlobalVariable *createSentinel(); + static void destroySentinel(GlobalVariable *GV) { delete GV; } static iplist &getList(Module *M); }; Index: llvm/include/llvm/Use.h diff -u llvm/include/llvm/Use.h:1.9 llvm/include/llvm/Use.h:1.10 --- llvm/include/llvm/Use.h:1.9 Sat Jan 29 12:43:28 2005 +++ llvm/include/llvm/Use.h Sat Jan 29 18:08:26 2005 @@ -84,12 +84,12 @@ static void setPrev(Use *N, Use *Prev) { N->UseLinks.Prev = Prev; } static void setNext(Use *N, Use *Next) { N->UseLinks.Next = Next; } - /// createSentinal - this is used to create the end marker for the use list. + /// createSentinel - this is used to create the end marker for the use list. /// Note that we only allocate a UseLinks structure, which is just enough to /// hold the next/prev pointers. This saves us 8 bytes of memory for every /// Value allocated. - static Use *createSentinal() { return (Use*)new Use::NextPrevPtrs(); } - static void destroySentinal(Use *S) { delete (Use::NextPrevPtrs*)S; } + static Use *createSentinel() { return (Use*)new Use::NextPrevPtrs(); } + static void destroySentinel(Use *S) { delete (Use::NextPrevPtrs*)S; } void addNodeToList(Use *NTy) {} void removeNodeFromList(Use *NTy) {} From lattner at cs.uiuc.edu Sat Jan 29 18:08:45 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 29 Jan 2005 18:08:45 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/ADT/ilist Message-ID: <200501300008.j0U08jnJ018524@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/ADT: ilist updated: 1.23 -> 1.24 --- Log message: Improve conformance with the Misha spelling benchmark suite --- Diffs of the changes: (+4 -4) ilist | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) Index: llvm/include/llvm/ADT/ilist diff -u llvm/include/llvm/ADT/ilist:1.23 llvm/include/llvm/ADT/ilist:1.24 --- llvm/include/llvm/ADT/ilist:1.23 Sat Jan 29 12:40:19 2005 +++ llvm/include/llvm/ADT/ilist Sat Jan 29 18:08:31 2005 @@ -60,8 +60,8 @@ static NodeTy *createNode(const NodeTy &V) { return new NodeTy(V); } - static NodeTy *createSentinal() { return new NodeTy(); } - static void destroySentinal(NodeTy *N) { delete N; } + static NodeTy *createSentinel() { return new NodeTy(); } + static void destroySentinel(NodeTy *N) { delete N; } void addNodeToList(NodeTy *NTy) {} void removeNodeFromList(NodeTy *NTy) {} @@ -302,11 +302,11 @@ typedef std::reverse_iterator const_reverse_iterator; typedef std::reverse_iterator reverse_iterator; - iplist() : Head(Traits::createSentinal()), Tail(Head) { + iplist() : Head(Traits::createSentinel()), Tail(Head) { setNext(Head, 0); setPrev(Head, 0); } - ~iplist() { clear(); Traits::destroySentinal(Tail); } + ~iplist() { clear(); Traits::destroySentinel(Tail); } // Iterator creation methods. iterator begin() { return iterator(Head); } From lattner at cs.uiuc.edu Sat Jan 29 18:09:03 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 29 Jan 2005 18:09:03 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/BasicBlock.cpp Function.cpp Module.cpp Message-ID: <200501300009.j0U0935M018746@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: BasicBlock.cpp updated: 1.53 -> 1.54 Function.cpp updated: 1.86 -> 1.87 Module.cpp updated: 1.58 -> 1.59 --- Log message: Improve conformance with the Misha spelling benchmark suite --- Diffs of the changes: (+5 -5) BasicBlock.cpp | 2 +- Function.cpp | 4 ++-- Module.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) Index: llvm/lib/VMCore/BasicBlock.cpp diff -u llvm/lib/VMCore/BasicBlock.cpp:1.53 llvm/lib/VMCore/BasicBlock.cpp:1.54 --- llvm/lib/VMCore/BasicBlock.cpp:1.53 Sat Jan 29 12:41:12 2005 +++ llvm/lib/VMCore/BasicBlock.cpp Sat Jan 29 18:08:49 2005 @@ -48,7 +48,7 @@ }; } -Instruction *ilist_traits::createSentinal() { +Instruction *ilist_traits::createSentinel() { return new DummyInst(); } iplist &ilist_traits::getList(BasicBlock *BB) { Index: llvm/lib/VMCore/Function.cpp diff -u llvm/lib/VMCore/Function.cpp:1.86 llvm/lib/VMCore/Function.cpp:1.87 --- llvm/lib/VMCore/Function.cpp:1.86 Sat Jan 29 12:41:12 2005 +++ llvm/lib/VMCore/Function.cpp Sat Jan 29 18:08:49 2005 @@ -20,7 +20,7 @@ #include "llvm/ADT/StringExtras.h" using namespace llvm; -BasicBlock *ilist_traits::createSentinal() { +BasicBlock *ilist_traits::createSentinel() { BasicBlock *Ret = new BasicBlock(); // This should not be garbage monitored. LeakDetector::removeGarbageObject(Ret); @@ -31,7 +31,7 @@ return F->getBasicBlockList(); } -Argument *ilist_traits::createSentinal() { +Argument *ilist_traits::createSentinel() { Argument *Ret = new Argument(Type::IntTy); // This should not be garbage monitored. LeakDetector::removeGarbageObject(Ret); Index: llvm/lib/VMCore/Module.cpp diff -u llvm/lib/VMCore/Module.cpp:1.58 llvm/lib/VMCore/Module.cpp:1.59 --- llvm/lib/VMCore/Module.cpp:1.58 Sat Jan 29 12:41:12 2005 +++ llvm/lib/VMCore/Module.cpp Sat Jan 29 18:08:49 2005 @@ -28,7 +28,7 @@ // Methods to implement the globals and functions lists. // -Function *ilist_traits::createSentinal() { +Function *ilist_traits::createSentinel() { FunctionType *FTy = FunctionType::get(Type::VoidTy, std::vector(), false); Function *Ret = new Function(FTy, GlobalValue::ExternalLinkage); @@ -36,7 +36,7 @@ LeakDetector::removeGarbageObject(Ret); return Ret; } -GlobalVariable *ilist_traits::createSentinal() { +GlobalVariable *ilist_traits::createSentinel() { GlobalVariable *Ret = new GlobalVariable(Type::IntTy, false, GlobalValue::ExternalLinkage); // This should not be garbage monitored. From lattner at cs.uiuc.edu Sat Jan 29 18:08:49 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 29 Jan 2005 18:08:49 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/DataStructure/DSNode.h Message-ID: <200501300008.j0U08n0W018548@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis/DataStructure: DSNode.h updated: 1.47 -> 1.48 --- Log message: Improve conformance with the Misha spelling benchmark suite --- Diffs of the changes: (+2 -2) DSNode.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/include/llvm/Analysis/DataStructure/DSNode.h diff -u llvm/include/llvm/Analysis/DataStructure/DSNode.h:1.47 llvm/include/llvm/Analysis/DataStructure/DSNode.h:1.48 --- llvm/include/llvm/Analysis/DataStructure/DSNode.h:1.47 Sat Jan 29 12:40:43 2005 +++ llvm/include/llvm/Analysis/DataStructure/DSNode.h Sat Jan 29 18:08:36 2005 @@ -369,8 +369,8 @@ static void setPrev(DSNode *N, DSNode *Prev) { N->Prev = Prev; } static void setNext(DSNode *N, DSNode *Next) { N->Next = Next; } - static DSNode *createSentinal() { return new DSNode(0,0); } - static void destroySentinal(DSNode *N) { delete N; } + static DSNode *createSentinel() { return new DSNode(0,0); } + static void destroySentinel(DSNode *N) { delete N; } //static DSNode *createNode(const DSNode &V) { return new DSNode(V); } From lattner at cs.uiuc.edu Sat Jan 29 18:09:37 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 29 Jan 2005 18:09:37 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/MachineBasicBlock.cpp MachineFunction.cpp Message-ID: <200501300009.j0U09bJq018820@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: MachineBasicBlock.cpp updated: 1.22 -> 1.23 MachineFunction.cpp updated: 1.76 -> 1.77 --- Log message: Improve conformance with the Misha spelling benchmark suite --- Diffs of the changes: (+2 -2) MachineBasicBlock.cpp | 2 +- MachineFunction.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/lib/CodeGen/MachineBasicBlock.cpp diff -u llvm/lib/CodeGen/MachineBasicBlock.cpp:1.22 llvm/lib/CodeGen/MachineBasicBlock.cpp:1.23 --- llvm/lib/CodeGen/MachineBasicBlock.cpp:1.22 Sat Jan 29 12:41:25 2005 +++ llvm/lib/CodeGen/MachineBasicBlock.cpp Sat Jan 29 18:09:23 2005 @@ -46,7 +46,7 @@ } -MachineInstr* ilist_traits::createSentinal() { +MachineInstr* ilist_traits::createSentinel() { MachineInstr* dummy = new MachineInstr(0, 0); LeakDetector::removeGarbageObject(dummy); return dummy; Index: llvm/lib/CodeGen/MachineFunction.cpp diff -u llvm/lib/CodeGen/MachineFunction.cpp:1.76 llvm/lib/CodeGen/MachineFunction.cpp:1.77 --- llvm/lib/CodeGen/MachineFunction.cpp:1.76 Sat Jan 29 12:41:24 2005 +++ llvm/lib/CodeGen/MachineFunction.cpp Sat Jan 29 18:09:23 2005 @@ -90,7 +90,7 @@ // MachineFunction implementation //===---------------------------------------------------------------------===// -MachineBasicBlock* ilist_traits::createSentinal() { +MachineBasicBlock* ilist_traits::createSentinel() { MachineBasicBlock* dummy = new MachineBasicBlock(); LeakDetector::removeGarbageObject(dummy); return dummy; From lattner at cs.uiuc.edu Sat Jan 29 18:13:48 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 29 Jan 2005 18:13:48 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineBasicBlock.h MachineFunction.h Message-ID: <200501300013.j0U0DmOF020657@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineBasicBlock.h updated: 1.42 -> 1.43 MachineFunction.h updated: 1.48 -> 1.49 --- Log message: Improve spelling --- Diffs of the changes: (+4 -4) MachineBasicBlock.h | 4 ++-- MachineFunction.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) Index: llvm/include/llvm/CodeGen/MachineBasicBlock.h diff -u llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.42 llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.43 --- llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.42 Sat Jan 29 12:40:42 2005 +++ llvm/include/llvm/CodeGen/MachineBasicBlock.h Sat Jan 29 18:13:34 2005 @@ -45,8 +45,8 @@ static void setPrev(MachineInstr* N, MachineInstr* prev) { N->prev = prev; } static void setNext(MachineInstr* N, MachineInstr* next) { N->next = next; } - static MachineInstr* createSentinal(); - static void destroySentinal(MachineInstr *MI) { delete MI; } + static MachineInstr* createSentinel(); + static void destroySentinel(MachineInstr *MI) { delete MI; } void addNodeToList(MachineInstr* N); void removeNodeFromList(MachineInstr* N); void transferNodesFromList( Index: llvm/include/llvm/CodeGen/MachineFunction.h diff -u llvm/include/llvm/CodeGen/MachineFunction.h:1.48 llvm/include/llvm/CodeGen/MachineFunction.h:1.49 --- llvm/include/llvm/CodeGen/MachineFunction.h:1.48 Sat Jan 29 12:40:42 2005 +++ llvm/include/llvm/CodeGen/MachineFunction.h Sat Jan 29 18:13:34 2005 @@ -55,8 +55,8 @@ N->Next = next; } - static MachineBasicBlock* createSentinal(); - static void destroySentinal(MachineBasicBlock *MBB) { delete MBB; } + static MachineBasicBlock* createSentinel(); + static void destroySentinel(MachineBasicBlock *MBB) { delete MBB; } void addNodeToList(MachineBasicBlock* N); void removeNodeFromList(MachineBasicBlock* N); void transferNodesFromList(iplist Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.17 -> 1.18 AlphaRegisterInfo.cpp updated: 1.6 -> 1.7 --- Log message: support for larger calls --- Diffs of the changes: (+129 -103) AlphaISelPattern.cpp | 144 +++++++++++++++++++++++++++++++------------------- AlphaRegisterInfo.cpp | 88 +++++++++++++----------------- 2 files changed, 129 insertions(+), 103 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.17 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.18 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.17 Sat Jan 29 09:42:07 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Sat Jan 29 18:35:26 2005 @@ -27,6 +27,7 @@ #include "llvm/Support/MathExtras.h" #include "llvm/ADT/Statistic.h" #include +#include using namespace llvm; //===----------------------------------------------------------------------===// @@ -138,34 +139,42 @@ for (Function::aiterator I = F.abegin(), E = F.aend(); I != E; ++I) { SDOperand newroot, argt; - ++count; - assert(count <= 6 && "More than 6 args not supported"); - switch (getValueType(I->getType())) { - default: std::cerr << "Unknown Type " << getValueType(I->getType()) << "\n"; abort(); - case MVT::f64: - case MVT::f32: - BuildMI(&BB, Alpha::IDEF, 0, args_float[count - 1]); - argVreg.push_back(MF.getSSARegMap()->createVirtualRegister(getRegClassFor(getValueType(I->getType())))); - argPreg.push_back(args_float[count - 1]); - argOpc.push_back(Alpha::CPYS); - newroot = DAG.getCopyFromReg(argVreg[count-1], getValueType(I->getType()), DAG.getRoot()); - break; - case MVT::i1: - case MVT::i8: - case MVT::i16: - case MVT::i32: - case MVT::i64: - BuildMI(&BB, Alpha::IDEF, 0, args_int[count - 1]); - argVreg.push_back(MF.getSSARegMap()->createVirtualRegister(getRegClassFor(MVT::i64))); - argPreg.push_back(args_int[count - 1]); - argOpc.push_back(Alpha::BIS); - argt = newroot = DAG.getCopyFromReg(argVreg[count-1], MVT::i64, DAG.getRoot()); - if (getValueType(I->getType()) != MVT::i64) - argt = DAG.getNode(ISD::TRUNCATE, getValueType(I->getType()), newroot); - break; + if (count < 6) { + switch (getValueType(I->getType())) { + default: std::cerr << "Unknown Type " << getValueType(I->getType()) << "\n"; abort(); + case MVT::f64: + case MVT::f32: + BuildMI(&BB, Alpha::IDEF, 0, args_float[count]); + argVreg.push_back(MF.getSSARegMap()->createVirtualRegister(getRegClassFor(getValueType(I->getType())))); + argPreg.push_back(args_float[count]); + argOpc.push_back(Alpha::CPYS); + newroot = DAG.getCopyFromReg(argVreg[count], getValueType(I->getType()), DAG.getRoot()); + break; + case MVT::i1: + case MVT::i8: + case MVT::i16: + case MVT::i32: + case MVT::i64: + BuildMI(&BB, Alpha::IDEF, 0, args_int[count]); + argVreg.push_back(MF.getSSARegMap()->createVirtualRegister(getRegClassFor(MVT::i64))); + argPreg.push_back(args_int[count]); + argOpc.push_back(Alpha::BIS); + argt = newroot = DAG.getCopyFromReg(argVreg[count], MVT::i64, DAG.getRoot()); + if (getValueType(I->getType()) != MVT::i64) + argt = DAG.getNode(ISD::TRUNCATE, getValueType(I->getType()), newroot); + break; + } + } else { //more args + // Create the frame index object for this incoming parameter... + int FI = MFI->CreateFixedObject(8, 8 * (count - 6)); + + // Create the SelectionDAG nodes corresponding to a load from this parameter + SDOperand FIN = DAG.getFrameIndex(FI, MVT::i64); + argt = newroot = DAG.getLoad(getValueType(I->getType()), DAG.getEntryNode(), FIN); } DAG.setRoot(newroot.getValue(1)); ArgValues.push_back(argt); + ++count; } BuildMI(&BB, Alpha::IDEF, 0, Alpha::R29); @@ -181,6 +190,9 @@ const Type *RetTy, SDOperand Callee, ArgListTy &Args, SelectionDAG &DAG) { int NumBytes = 0; + if (Args.size() > 6) + NumBytes = (Args.size() - 6) * 8; + Chain = DAG.getNode(ISD::ADJCALLSTACKDOWN, MVT::Other, Chain, DAG.getConstant(NumBytes, getPointerTy())); std::vector args_to_use; @@ -404,9 +416,9 @@ //STL LDS //STQ LDT Opc = DestType == MVT::f64 ? Alpha::STQ : Alpha::STL; - BuildMI(BB, Opc, 2).addReg(Tmp1).addFrameIndex(FrameIdx); + BuildMI(BB, Opc, 2).addReg(Tmp1).addFrameIndex(FrameIdx).addReg(Alpha::F31); Opc = DestType == MVT::f64 ? Alpha::LDT : Alpha::LDS; - BuildMI(BB, Opc, 1, Result).addFrameIndex(FrameIdx); + BuildMI(BB, Opc, 1, Result).addFrameIndex(FrameIdx).addReg(Alpha::F31); //The easy way: doesn't work // //so these instructions are not supported on ev56 @@ -467,7 +479,7 @@ case ISD::FrameIndex: Tmp1 = cast(N)->getIndex(); - BuildMI(BB, Alpha::LDA, 2, Result).addFrameIndex(Tmp1); + BuildMI(BB, Alpha::LDA, 2, Result).addFrameIndex(Tmp1).addReg(Alpha::F31); return Result; case ISD::EXTLOAD: @@ -576,32 +588,56 @@ for(int i = 2, e = Node->getNumOperands(); i < e; ++i) argvregs.push_back(SelectExpr(N.getOperand(i))); - for(int i = 0, e = argvregs.size(); i < e; ++i) - { - unsigned args_int[] = {Alpha::R16, Alpha::R17, Alpha::R18, - Alpha::R19, Alpha::R20, Alpha::R21}; - unsigned args_float[] = {Alpha::F16, Alpha::F17, Alpha::F18, - Alpha::F19, Alpha::F20, Alpha::F21}; - switch(N.getOperand(i+2).getValueType()) { - default: - Node->dump(); - N.getOperand(i).Val->dump(); - std::cerr << "Type for " << i << " is: " << N.getOperand(i+2).getValueType() << "\n"; - assert(0 && "Unknown value type for call"); - case MVT::i1: - case MVT::i8: - case MVT::i16: - case MVT::i32: - case MVT::i64: - BuildMI(BB, Alpha::BIS, 2, args_int[i]).addReg(argvregs[i]).addReg(argvregs[i]); - break; - case MVT::f32: - case MVT::f64: - BuildMI(BB, Alpha::CPYS, 2, args_float[i]).addReg(argvregs[i]).addReg(argvregs[i]); - break; - } - - } + //in reg args + for(int i = 0, e = std::min(6, (int)argvregs.size()); i < e; ++i) + { + unsigned args_int[] = {Alpha::R16, Alpha::R17, Alpha::R18, + Alpha::R19, Alpha::R20, Alpha::R21}; + unsigned args_float[] = {Alpha::F16, Alpha::F17, Alpha::F18, + Alpha::F19, Alpha::F20, Alpha::F21}; + switch(N.getOperand(i+2).getValueType()) { + default: + Node->dump(); + N.getOperand(i).Val->dump(); + std::cerr << "Type for " << i << " is: " << N.getOperand(i+2).getValueType() << "\n"; + assert(0 && "Unknown value type for call"); + case MVT::i1: + case MVT::i8: + case MVT::i16: + case MVT::i32: + case MVT::i64: + BuildMI(BB, Alpha::BIS, 2, args_int[i]).addReg(argvregs[i]).addReg(argvregs[i]); + break; + case MVT::f32: + case MVT::f64: + BuildMI(BB, Alpha::CPYS, 2, args_float[i]).addReg(argvregs[i]).addReg(argvregs[i]); + break; + } + } + //in mem args + for (int i = 6, e = argvregs.size(); i < e; ++i) + { + switch(N.getOperand(i+2).getValueType()) { + default: + Node->dump(); + N.getOperand(i).Val->dump(); + std::cerr << "Type for " << i << " is: " << N.getOperand(i+2).getValueType() << "\n"; + assert(0 && "Unknown value type for call"); + case MVT::i1: + case MVT::i8: + case MVT::i16: + case MVT::i32: + case MVT::i64: + BuildMI(BB, Alpha::STQ, 3).addReg(argvregs[i]).addImm((i - 6) * 8).addReg(Alpha::R30); + break; + case MVT::f32: + BuildMI(BB, Alpha::STS, 3).addReg(argvregs[i]).addImm((i - 6) * 8).addReg(Alpha::R30); + break; + case MVT::f64: + BuildMI(BB, Alpha::STT, 3).addReg(argvregs[i]).addImm((i - 6) * 8).addReg(Alpha::R30); + break; + } + } //build the right kind of call if (GlobalAddressSDNode *GASD = dyn_cast(N.getOperand(1))) Index: llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp diff -u llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.6 llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.7 --- llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.6 Sat Jan 29 13:27:28 2005 +++ llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp Sat Jan 29 18:35:27 2005 @@ -49,7 +49,7 @@ unsigned SrcReg, int FrameIdx) const { //std::cerr << "Trying to store " << getPrettyName(SrcReg) << " to " << FrameIdx << "\n"; //BuildMI(MBB, MI, Alpha::WTF, 0).addReg(SrcReg); - BuildMI(MBB, MI, Alpha::STQ, 3).addReg(SrcReg).addFrameIndex(FrameIdx); + BuildMI(MBB, MI, Alpha::STQ, 3).addReg(SrcReg).addFrameIndex(FrameIdx).addReg(Alpha::F31); // assert(0 && "TODO"); } @@ -59,7 +59,7 @@ unsigned DestReg, int FrameIdx) const{ //std::cerr << "Trying to load " << getPrettyName(DestReg) << " to " << FrameIdx << "\n"; //BuildMI(MBB, MI, Alpha::WTF, 0, DestReg); - BuildMI(MBB, MI, Alpha::LDQ, 2, DestReg).addFrameIndex(FrameIdx); + BuildMI(MBB, MI, Alpha::LDQ, 2, DestReg).addFrameIndex(FrameIdx).addReg(Alpha::F31); // assert(0 && "TODO"); } @@ -128,53 +128,35 @@ void AlphaRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II) const { - assert(0 && "TODO"); -// unsigned i = 0; -// MachineInstr &MI = *II; -// MachineBasicBlock &MBB = *MI.getParent(); -// MachineFunction &MF = *MBB.getParent(); - -// while (!MI.getOperand(i).isFrameIndex()) { -// ++i; -// assert(i < MI.getNumOperands() && "Instr doesn't have FrameIndex operand!"); -// } - -// int FrameIndex = MI.getOperand(i).getFrameIndex(); - -// // Replace the FrameIndex with base register with GPR1 (SP) or GPR31 (FP). -// MI.SetMachineOperandReg(i, hasFP(MF) ? PPC::R31 : PPC::R1); - -// // Take into account whether it's an add or mem instruction -// unsigned OffIdx = (i == 2) ? 1 : 2; - -// // Now add the frame object offset to the offset from r1. -// int Offset = MF.getFrameInfo()->getObjectOffset(FrameIndex) + -// MI.getOperand(OffIdx).getImmedValue(); - -// // If we're not using a Frame Pointer that has been set to the value of the -// // SP before having the stack size subtracted from it, then add the stack size -// // to Offset to get the correct offset. -// Offset += MF.getFrameInfo()->getStackSize(); - -// if (Offset > 32767 || Offset < -32768) { -// // Insert a set of r0 with the full offset value before the ld, st, or add -// MachineBasicBlock *MBB = MI.getParent(); -// MBB->insert(II, BuildMI(PPC::LIS, 1, PPC::R0).addSImm(Offset >> 16)); -// MBB->insert(II, BuildMI(PPC::ORI, 2, PPC::R0).addReg(PPC::R0) -// .addImm(Offset)); -// // convert into indexed form of the instruction -// // sth 0:rA, 1:imm 2:(rB) ==> sthx 0:rA, 2:rB, 1:r0 -// // addi 0:rA 1:rB, 2, imm ==> add 0:rA, 1:rB, 2:r0 -// unsigned NewOpcode = -// const_cast& >(ImmToIdxMap)[MI.getOpcode()]; -// assert(NewOpcode && "No indexed form of load or store available!"); -// MI.setOpcode(NewOpcode); -// MI.SetMachineOperandReg(1, MI.getOperand(i).getReg()); -// MI.SetMachineOperandReg(2, PPC::R0); -// } else { -// MI.SetMachineOperandConst(OffIdx, MachineOperand::MO_SignExtendedImmed, -// Offset); -// } + unsigned i = 0; + MachineInstr &MI = *II; + MachineBasicBlock &MBB = *MI.getParent(); + MachineFunction &MF = *MBB.getParent(); + + while (!MI.getOperand(i).isFrameIndex()) { + ++i; + assert(i < MI.getNumOperands() && "Instr doesn't have FrameIndex operand!"); + } + + int FrameIndex = MI.getOperand(i).getFrameIndex(); + + // Add the base register of R30 (SP) or R15 (FP). + MI.SetMachineOperandReg(i + 1, hasFP(MF) ? Alpha::R15 : Alpha::R30); + + // Now add the frame object offset to the offset from r1. + int Offset = MF.getFrameInfo()->getObjectOffset(FrameIndex); + + // If we're not using a Frame Pointer that has been set to the value of the + // SP before having the stack size subtracted from it, then add the stack size + // to Offset to get the correct offset. + Offset += MF.getFrameInfo()->getStackSize(); + + if (Offset > 32767 || Offset < -32768) { + std::cerr << "Offset needs to be " << Offset << "\n"; + assert(0 && "stack too big"); + } else { + MI.SetMachineOperandConst(i, MachineOperand::MO_SignExtendedImmed, Offset); + } } @@ -191,6 +173,14 @@ // Get the number of bytes to allocate from the FrameInfo unsigned NumBytes = MFI->getStackSize(); + if (MFI->hasCalls()) { + // We reserve argument space for call sites in the function immediately on + // entry to the current function. This eliminates the need for add/sub + // brackets around call sites. + NumBytes += MFI->getMaxCallFrameSize(); + std::cerr << "Added " << MFI->getMaxCallFrameSize() << " to the stack due to calls\n"; + } + // Do we need to allocate space on the stack? if (NumBytes == 0) return; From lattner at cs.uiuc.edu Sun Jan 30 10:33:03 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 30 Jan 2005 10:33:03 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp AlphaRegisterInfo.cpp Message-ID: <200501301633.j0UGX38I011461@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.18 -> 1.19 AlphaRegisterInfo.cpp updated: 1.7 -> 1.8 --- Log message: Fix warnings. --- Diffs of the changes: (+2 -2) AlphaISelPattern.cpp | 2 +- AlphaRegisterInfo.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.18 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.19 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.18 Sat Jan 29 18:35:26 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Sun Jan 30 10:32:48 2005 @@ -1149,7 +1149,7 @@ Tmp2 = SelectExpr(N.getOperand(2)); switch (StoredTy) { - default: Node->dump(); assert(0 && "Unhandled Type"); break; + default: Node->dump(); assert(0 && "Unhandled Type"); case MVT::i1: //FIXME: DAG does not promote this load case MVT::i8: Opc = Alpha::STB; break; case MVT::i16: Opc = Alpha::STW; break; Index: llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp diff -u llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.7 llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.8 --- llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.7 Sat Jan 29 18:35:27 2005 +++ llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp Sun Jan 30 10:32:48 2005 @@ -108,7 +108,7 @@ unsigned Align = MF.getTarget().getFrameInfo()->getStackAlignment(); Amount = (Amount+Align-1)/Align*Align; - MachineInstr *New; +// MachineInstr *New; // if (Old->getOpcode() == X86::ADJCALLSTACKDOWN) { // New=BuildMI(X86::SUB32ri, 1, X86::ESP, MachineOperand::UseAndDef) // .addZImm(Amount); From lattner at cs.uiuc.edu Sun Jan 30 10:34:03 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 30 Jan 2005 10:34:03 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp Message-ID: <200501301634.j0UGY3hk012168@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaRegisterInfo.cpp updated: 1.8 -> 1.9 --- Log message: This code is really unreachable. --- Diffs of the changes: (+2 -1) AlphaRegisterInfo.cpp | 3 ++- 1 files changed, 2 insertions(+), 1 deletion(-) Index: llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp diff -u llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.8 llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.9 --- llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.8 Sun Jan 30 10:32:48 2005 +++ llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp Sun Jan 30 10:33:46 2005 @@ -119,7 +119,8 @@ // } // Replace the pseudo instruction with a new instruction... - MBB.insert(I, New); + //MBB.insert(I, New); + abort(); } } From lattner at cs.uiuc.edu Sun Jan 30 10:37:46 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 30 Jan 2005 10:37:46 -0600 Subject: [llvm-commits] CVS: poolalloc/runtime/PoolAllocator/PageManager.cpp Message-ID: <200501301637.j0UGbk0r018271@apoc.cs.uiuc.edu> Changes in directory poolalloc/runtime/PoolAllocator: PageManager.cpp updated: 1.10 -> 1.11 --- Log message: These headers are no longer here. --- Diffs of the changes: (+2 -2) Index: poolalloc/runtime/PoolAllocator/PageManager.cpp diff -u poolalloc/runtime/PoolAllocator/PageManager.cpp:1.10 poolalloc/runtime/PoolAllocator/PageManager.cpp:1.11 --- poolalloc/runtime/PoolAllocator/PageManager.cpp:1.10 Mon Nov 22 10:55:33 2004 +++ poolalloc/runtime/PoolAllocator/PageManager.cpp Sun Jan 30 10:37:36 2005 @@ -15,8 +15,8 @@ #ifndef _POSIX_MAPPED_FILES #define _POSIX_MAPPED_FILES #endif -#include "llvm/Config/unistd.h" -#include "llvm/Config/sys/mman.h" +#include +#include #include "poolalloc/Support/MallocAllocator.h" #include #include From lattner at cs.uiuc.edu Sun Jan 30 10:38:17 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 30 Jan 2005 10:38:17 -0600 Subject: [llvm-commits] CVS: poolalloc/runtime/FreeListAllocator/PageManager.cpp Message-ID: <200501301638.j0UGcH2r019206@apoc.cs.uiuc.edu> Changes in directory poolalloc/runtime/FreeListAllocator: PageManager.cpp updated: 1.9 -> 1.10 --- Log message: Adjust to changes --- Diffs of the changes: (+2 -2) Index: poolalloc/runtime/FreeListAllocator/PageManager.cpp diff -u poolalloc/runtime/FreeListAllocator/PageManager.cpp:1.9 poolalloc/runtime/FreeListAllocator/PageManager.cpp:1.10 --- poolalloc/runtime/FreeListAllocator/PageManager.cpp:1.9 Mon Nov 22 10:55:30 2004 +++ poolalloc/runtime/FreeListAllocator/PageManager.cpp Sun Jan 30 10:38:07 2005 @@ -15,8 +15,8 @@ #ifndef _POSIX_MAPPED_FILES #define _POSIX_MAPPED_FILES #endif -#include "llvm/Config/unistd.h" -#include "llvm/Config/sys/mman.h" +#include +#include #include "poolalloc/Support/MallocAllocator.h" #include #include From jeffc at jolt-lang.org Sun Jan 30 11:54:31 2005 From: jeffc at jolt-lang.org (Jeff Cohen) Date: Sun, 30 Jan 2005 11:54:31 -0600 Subject: [llvm-commits] CVS: llvm/win32/AsmParser/AsmParser.vcproj Message-ID: <200501301754.LAA28419@zion.cs.uiuc.edu> Changes in directory llvm/win32/AsmParser: AsmParser.vcproj updated: 1.3 -> 1.4 --- Log message: Silence VC++ warnings about using 'this' in base member initializations. --- Diffs of the changes: (+2 -2) AsmParser.vcproj | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/win32/AsmParser/AsmParser.vcproj diff -u llvm/win32/AsmParser/AsmParser.vcproj:1.3 llvm/win32/AsmParser/AsmParser.vcproj:1.4 --- llvm/win32/AsmParser/AsmParser.vcproj:1.3 Tue Jan 4 00:18:10 2005 +++ llvm/win32/AsmParser/AsmParser.vcproj Sun Jan 30 11:54:11 2005 @@ -32,7 +32,7 @@ WarningLevel="3" Detect64BitPortabilityProblems="FALSE" DebugInformationFormat="4" - DisableSpecificWarnings="4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> Changes in directory llvm/win32/llvm-dis: llvm-dis.vcproj updated: 1.2 -> 1.3 --- Log message: Silence VC++ warnings about using 'this' in base member initializations. --- Diffs of the changes: (+2 -2) llvm-dis.vcproj | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/win32/llvm-dis/llvm-dis.vcproj diff -u llvm/win32/llvm-dis/llvm-dis.vcproj:1.2 llvm/win32/llvm-dis/llvm-dis.vcproj:1.3 --- llvm/win32/llvm-dis/llvm-dis.vcproj:1.2 Sat Jan 1 14:51:41 2005 +++ llvm/win32/llvm-dis/llvm-dis.vcproj Sun Jan 30 11:54:12 2005 @@ -31,7 +31,7 @@ WarningLevel="3" Detect64BitPortabilityProblems="FALSE" DebugInformationFormat="4" - DisableSpecificWarnings="4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> Changes in directory llvm/win32/Analysis: Analysis.vcproj updated: 1.9 -> 1.10 --- Log message: Silence VC++ warnings about using 'this' in base member initializations. --- Diffs of the changes: (+2 -2) Analysis.vcproj | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/win32/Analysis/Analysis.vcproj diff -u llvm/win32/Analysis/Analysis.vcproj:1.9 llvm/win32/Analysis/Analysis.vcproj:1.10 --- llvm/win32/Analysis/Analysis.vcproj:1.9 Fri Jan 28 01:29:32 2005 +++ llvm/win32/Analysis/Analysis.vcproj Sun Jan 30 11:54:11 2005 @@ -31,7 +31,7 @@ WarningLevel="3" Detect64BitPortabilityProblems="FALSE" DebugInformationFormat="4" - DisableSpecificWarnings="4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> Changes in directory llvm/win32/Support: Support.vcproj updated: 1.10 -> 1.11 --- Log message: Silence VC++ warnings about using 'this' in base member initializations. --- Diffs of the changes: (+2 -2) Support.vcproj | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/win32/Support/Support.vcproj diff -u llvm/win32/Support/Support.vcproj:1.10 llvm/win32/Support/Support.vcproj:1.11 --- llvm/win32/Support/Support.vcproj:1.10 Sat Jan 22 10:32:47 2005 +++ llvm/win32/Support/Support.vcproj Sun Jan 30 11:54:11 2005 @@ -32,7 +32,7 @@ WarningLevel="3" Detect64BitPortabilityProblems="FALSE" DebugInformationFormat="4" - DisableSpecificWarnings="4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> Changes in directory llvm/win32/llvm-ld: llvm-ld.vcproj updated: 1.1 -> 1.2 --- Log message: Silence VC++ warnings about using 'this' in base member initializations. --- Diffs of the changes: (+2 -2) llvm-ld.vcproj | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/win32/llvm-ld/llvm-ld.vcproj diff -u llvm/win32/llvm-ld/llvm-ld.vcproj:1.1 llvm/win32/llvm-ld/llvm-ld.vcproj:1.2 --- llvm/win32/llvm-ld/llvm-ld.vcproj:1.1 Mon Jan 17 23:44:50 2005 +++ llvm/win32/llvm-ld/llvm-ld.vcproj Sun Jan 30 11:54:12 2005 @@ -31,7 +31,7 @@ WarningLevel="3" Detect64BitPortabilityProblems="FALSE" DebugInformationFormat="4" - DisableSpecificWarnings="4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> Changes in directory llvm/win32/TableGen: TableGen.vcproj updated: 1.11 -> 1.12 --- Log message: Silence VC++ warnings about using 'this' in base member initializations. --- Diffs of the changes: (+2 -2) TableGen.vcproj | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/win32/TableGen/TableGen.vcproj diff -u llvm/win32/TableGen/TableGen.vcproj:1.11 llvm/win32/TableGen/TableGen.vcproj:1.12 --- llvm/win32/TableGen/TableGen.vcproj:1.11 Tue Jan 4 00:18:10 2005 +++ llvm/win32/TableGen/TableGen.vcproj Sun Jan 30 11:54:11 2005 @@ -31,7 +31,7 @@ WarningLevel="3" Detect64BitPortabilityProblems="FALSE" DebugInformationFormat="4" - DisableSpecificWarnings="4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> Changes in directory llvm/win32/Transforms: Transforms.vcproj updated: 1.10 -> 1.11 --- Log message: Silence VC++ warnings about using 'this' in base member initializations. --- Diffs of the changes: (+2 -2) Transforms.vcproj | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/win32/Transforms/Transforms.vcproj diff -u llvm/win32/Transforms/Transforms.vcproj:1.10 llvm/win32/Transforms/Transforms.vcproj:1.11 --- llvm/win32/Transforms/Transforms.vcproj:1.10 Fri Jan 7 00:54:58 2005 +++ llvm/win32/Transforms/Transforms.vcproj Sun Jan 30 11:54:11 2005 @@ -31,7 +31,7 @@ WarningLevel="3" Detect64BitPortabilityProblems="FALSE" DebugInformationFormat="4" - DisableSpecificWarnings="4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> Changes in directory llvm/win32/Linker: Linker.vcproj updated: 1.1 -> 1.2 --- Log message: Silence VC++ warnings about using 'this' in base member initializations. --- Diffs of the changes: (+2 -2) Linker.vcproj | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/win32/Linker/Linker.vcproj diff -u llvm/win32/Linker/Linker.vcproj:1.1 llvm/win32/Linker/Linker.vcproj:1.2 --- llvm/win32/Linker/Linker.vcproj:1.1 Sat Jan 1 16:32:26 2005 +++ llvm/win32/Linker/Linker.vcproj Sun Jan 30 11:54:11 2005 @@ -31,7 +31,7 @@ WarningLevel="3" Detect64BitPortabilityProblems="FALSE" DebugInformationFormat="4" - DisableSpecificWarnings="4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> Changes in directory llvm/win32/VMCore: VMCore.vcproj updated: 1.9 -> 1.10 --- Log message: Silence VC++ warnings about using 'this' in base member initializations. --- Diffs of the changes: (+2 -2) VMCore.vcproj | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/win32/VMCore/VMCore.vcproj diff -u llvm/win32/VMCore/VMCore.vcproj:1.9 llvm/win32/VMCore/VMCore.vcproj:1.10 --- llvm/win32/VMCore/VMCore.vcproj:1.9 Fri Jan 28 21:32:49 2005 +++ llvm/win32/VMCore/VMCore.vcproj Sun Jan 30 11:54:11 2005 @@ -31,7 +31,7 @@ WarningLevel="3" Detect64BitPortabilityProblems="FALSE" DebugInformationFormat="4" - DisableSpecificWarnings="4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> Changes in directory llvm/win32/lli: lli.vcproj updated: 1.5 -> 1.6 --- Log message: Silence VC++ warnings about using 'this' in base member initializations. --- Diffs of the changes: (+2 -2) lli.vcproj | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/win32/lli/lli.vcproj diff -u llvm/win32/lli/lli.vcproj:1.5 llvm/win32/lli/lli.vcproj:1.6 --- llvm/win32/lli/lli.vcproj:1.5 Sat Jan 1 22:23:12 2005 +++ llvm/win32/lli/lli.vcproj Sun Jan 30 11:54:12 2005 @@ -31,7 +31,7 @@ WarningLevel="3" Detect64BitPortabilityProblems="FALSE" DebugInformationFormat="4" - DisableSpecificWarnings="4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> Changes in directory llvm/win32/llvm-ranlib: llvm-ranlib.vcproj updated: 1.1 -> 1.2 --- Log message: Silence VC++ warnings about using 'this' in base member initializations. --- Diffs of the changes: (+2 -2) llvm-ranlib.vcproj | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/win32/llvm-ranlib/llvm-ranlib.vcproj diff -u llvm/win32/llvm-ranlib/llvm-ranlib.vcproj:1.1 llvm/win32/llvm-ranlib/llvm-ranlib.vcproj:1.2 --- llvm/win32/llvm-ranlib/llvm-ranlib.vcproj:1.1 Sat Jan 1 16:05:56 2005 +++ llvm/win32/llvm-ranlib/llvm-ranlib.vcproj Sun Jan 30 11:54:12 2005 @@ -31,7 +31,7 @@ WarningLevel="3" Detect64BitPortabilityProblems="FALSE" DebugInformationFormat="4" - DisableSpecificWarnings="4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> Changes in directory llvm/win32/llvm-nm: llvm-nm.vcproj updated: 1.1 -> 1.2 --- Log message: Silence VC++ warnings about using 'this' in base member initializations. --- Diffs of the changes: (+2 -2) llvm-nm.vcproj | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/win32/llvm-nm/llvm-nm.vcproj diff -u llvm/win32/llvm-nm/llvm-nm.vcproj:1.1 llvm/win32/llvm-nm/llvm-nm.vcproj:1.2 --- llvm/win32/llvm-nm/llvm-nm.vcproj:1.1 Mon Jan 17 23:44:25 2005 +++ llvm/win32/llvm-nm/llvm-nm.vcproj Sun Jan 30 11:54:12 2005 @@ -31,7 +31,7 @@ WarningLevel="3" Detect64BitPortabilityProblems="FALSE" DebugInformationFormat="4" - DisableSpecificWarnings="4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> Changes in directory llvm/win32/analyze: analyze.vcproj updated: 1.3 -> 1.4 --- Log message: Silence VC++ warnings about using 'this' in base member initializations. --- Diffs of the changes: (+2 -2) analyze.vcproj | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/win32/analyze/analyze.vcproj diff -u llvm/win32/analyze/analyze.vcproj:1.3 llvm/win32/analyze/analyze.vcproj:1.4 --- llvm/win32/analyze/analyze.vcproj:1.3 Fri Jan 28 01:29:32 2005 +++ llvm/win32/analyze/analyze.vcproj Sun Jan 30 11:54:12 2005 @@ -31,7 +31,7 @@ WarningLevel="3" Detect64BitPortabilityProblems="FALSE" DebugInformationFormat="4" - DisableSpecificWarnings="4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> Changes in directory llvm/win32/ExecutionEngine: ExecutionEngine.vcproj updated: 1.6 -> 1.7 --- Log message: Silence VC++ warnings about using 'this' in base member initializations. --- Diffs of the changes: (+2 -2) ExecutionEngine.vcproj | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/win32/ExecutionEngine/ExecutionEngine.vcproj diff -u llvm/win32/ExecutionEngine/ExecutionEngine.vcproj:1.6 llvm/win32/ExecutionEngine/ExecutionEngine.vcproj:1.7 --- llvm/win32/ExecutionEngine/ExecutionEngine.vcproj:1.6 Sat Dec 18 20:29:00 2004 +++ llvm/win32/ExecutionEngine/ExecutionEngine.vcproj Sun Jan 30 11:54:11 2005 @@ -31,7 +31,7 @@ WarningLevel="3" Detect64BitPortabilityProblems="FALSE" DebugInformationFormat="4" - DisableSpecificWarnings="4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> Changes in directory llvm/win32/llvm-prof: llvm-prof.vcproj updated: 1.1 -> 1.2 --- Log message: Silence VC++ warnings about using 'this' in base member initializations. --- Diffs of the changes: (+2 -2) llvm-prof.vcproj | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/win32/llvm-prof/llvm-prof.vcproj diff -u llvm/win32/llvm-prof/llvm-prof.vcproj:1.1 llvm/win32/llvm-prof/llvm-prof.vcproj:1.2 --- llvm/win32/llvm-prof/llvm-prof.vcproj:1.1 Wed Jan 19 22:41:35 2005 +++ llvm/win32/llvm-prof/llvm-prof.vcproj Sun Jan 30 11:54:12 2005 @@ -31,7 +31,7 @@ WarningLevel="3" Detect64BitPortabilityProblems="FALSE" DebugInformationFormat="4" - DisableSpecificWarnings="4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> Changes in directory llvm/win32/bugpoint: bugpoint.vcproj updated: 1.1 -> 1.2 --- Log message: Silence VC++ warnings about using 'this' in base member initializations. --- Diffs of the changes: (+2 -2) bugpoint.vcproj | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/win32/bugpoint/bugpoint.vcproj diff -u llvm/win32/bugpoint/bugpoint.vcproj:1.1 llvm/win32/bugpoint/bugpoint.vcproj:1.2 --- llvm/win32/bugpoint/bugpoint.vcproj:1.1 Sat Jan 22 11:35:30 2005 +++ llvm/win32/bugpoint/bugpoint.vcproj Sun Jan 30 11:54:12 2005 @@ -31,7 +31,7 @@ WarningLevel="3" Detect64BitPortabilityProblems="FALSE" DebugInformationFormat="4" - DisableSpecificWarnings="4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> Changes in directory llvm/win32/Fibonacci: Fibonacci.vcproj updated: 1.8 -> 1.9 --- Log message: Silence VC++ warnings about using 'this' in base member initializations. --- Diffs of the changes: (+2 -2) Fibonacci.vcproj | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/win32/Fibonacci/Fibonacci.vcproj diff -u llvm/win32/Fibonacci/Fibonacci.vcproj:1.8 llvm/win32/Fibonacci/Fibonacci.vcproj:1.9 --- llvm/win32/Fibonacci/Fibonacci.vcproj:1.8 Sat Jan 1 22:23:12 2005 +++ llvm/win32/Fibonacci/Fibonacci.vcproj Sun Jan 30 11:54:11 2005 @@ -32,7 +32,7 @@ WarningLevel="3" Detect64BitPortabilityProblems="FALSE" DebugInformationFormat="4" - DisableSpecificWarnings="4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> Changes in directory llvm/win32/llvm-ar: llvm-ar.vcproj updated: 1.1 -> 1.2 --- Log message: Silence VC++ warnings about using 'this' in base member initializations. --- Diffs of the changes: (+2 -2) llvm-ar.vcproj | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/win32/llvm-ar/llvm-ar.vcproj diff -u llvm/win32/llvm-ar/llvm-ar.vcproj:1.1 llvm/win32/llvm-ar/llvm-ar.vcproj:1.2 --- llvm/win32/llvm-ar/llvm-ar.vcproj:1.1 Sat Jan 1 16:00:28 2005 +++ llvm/win32/llvm-ar/llvm-ar.vcproj Sun Jan 30 11:54:12 2005 @@ -31,7 +31,7 @@ WarningLevel="3" Detect64BitPortabilityProblems="FALSE" DebugInformationFormat="4" - DisableSpecificWarnings="4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> Changes in directory llvm/win32/llvm-bcanalyzer: llvm-bcanalyzer.vcproj updated: 1.1 -> 1.2 --- Log message: Silence VC++ warnings about using 'this' in base member initializations. --- Diffs of the changes: (+2 -2) llvm-bcanalyzer.vcproj | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/win32/llvm-bcanalyzer/llvm-bcanalyzer.vcproj diff -u llvm/win32/llvm-bcanalyzer/llvm-bcanalyzer.vcproj:1.1 llvm/win32/llvm-bcanalyzer/llvm-bcanalyzer.vcproj:1.2 --- llvm/win32/llvm-bcanalyzer/llvm-bcanalyzer.vcproj:1.1 Mon Jan 17 23:31:15 2005 +++ llvm/win32/llvm-bcanalyzer/llvm-bcanalyzer.vcproj Sun Jan 30 11:54:12 2005 @@ -31,7 +31,7 @@ WarningLevel="3" Detect64BitPortabilityProblems="FALSE" DebugInformationFormat="4" - DisableSpecificWarnings="4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> Changes in directory llvm/win32/llvm-as: llvm-as.vcproj updated: 1.1 -> 1.2 --- Log message: Silence VC++ warnings about using 'this' in base member initializations. --- Diffs of the changes: (+2 -2) llvm-as.vcproj | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/win32/llvm-as/llvm-as.vcproj diff -u llvm/win32/llvm-as/llvm-as.vcproj:1.1 llvm/win32/llvm-as/llvm-as.vcproj:1.2 --- llvm/win32/llvm-as/llvm-as.vcproj:1.1 Sat Jan 1 14:51:41 2005 +++ llvm/win32/llvm-as/llvm-as.vcproj Sun Jan 30 11:54:12 2005 @@ -31,7 +31,7 @@ WarningLevel="3" Detect64BitPortabilityProblems="FALSE" DebugInformationFormat="4" - DisableSpecificWarnings="4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> Changes in directory llvm/win32/CodeGen: CodeGen.vcproj updated: 1.10 -> 1.11 --- Log message: Silence VC++ warnings about using 'this' in base member initializations. --- Diffs of the changes: (+2 -2) CodeGen.vcproj | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/win32/CodeGen/CodeGen.vcproj diff -u llvm/win32/CodeGen/CodeGen.vcproj:1.10 llvm/win32/CodeGen/CodeGen.vcproj:1.11 --- llvm/win32/CodeGen/CodeGen.vcproj:1.10 Sat Jan 15 01:33:52 2005 +++ llvm/win32/CodeGen/CodeGen.vcproj Sun Jan 30 11:54:11 2005 @@ -31,7 +31,7 @@ WarningLevel="3" Detect64BitPortabilityProblems="FALSE" DebugInformationFormat="4" - DisableSpecificWarnings="4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> Changes in directory llvm/win32/System: System.vcproj updated: 1.13 -> 1.14 --- Log message: Silence VC++ warnings about using 'this' in base member initializations. --- Diffs of the changes: (+2 -2) System.vcproj | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/win32/System/System.vcproj diff -u llvm/win32/System/System.vcproj:1.13 llvm/win32/System/System.vcproj:1.14 --- llvm/win32/System/System.vcproj:1.13 Sun Jan 9 18:50:11 2005 +++ llvm/win32/System/System.vcproj Sun Jan 30 11:54:11 2005 @@ -32,7 +32,7 @@ WarningLevel="3" Detect64BitPortabilityProblems="FALSE" DebugInformationFormat="4" - DisableSpecificWarnings="4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> Changes in directory llvm/win32/llvm-link: llvm-link.vcproj updated: 1.1 -> 1.2 --- Log message: Silence VC++ warnings about using 'this' in base member initializations. --- Diffs of the changes: (+2 -2) llvm-link.vcproj | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/win32/llvm-link/llvm-link.vcproj diff -u llvm/win32/llvm-link/llvm-link.vcproj:1.1 llvm/win32/llvm-link/llvm-link.vcproj:1.2 --- llvm/win32/llvm-link/llvm-link.vcproj:1.1 Sat Jan 1 16:32:26 2005 +++ llvm/win32/llvm-link/llvm-link.vcproj Sun Jan 30 11:54:12 2005 @@ -31,7 +31,7 @@ WarningLevel="3" Detect64BitPortabilityProblems="FALSE" DebugInformationFormat="4" - DisableSpecificWarnings="4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> Changes in directory llvm/win32/opt: opt.vcproj updated: 1.1 -> 1.2 --- Log message: Silence VC++ warnings about using 'this' in base member initializations. --- Diffs of the changes: (+2 -2) opt.vcproj | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/win32/opt/opt.vcproj diff -u llvm/win32/opt/opt.vcproj:1.1 llvm/win32/opt/opt.vcproj:1.2 --- llvm/win32/opt/opt.vcproj:1.1 Thu Jan 6 00:02:53 2005 +++ llvm/win32/opt/opt.vcproj Sun Jan 30 11:54:12 2005 @@ -31,7 +31,7 @@ WarningLevel="3" Detect64BitPortabilityProblems="FALSE" DebugInformationFormat="4" - DisableSpecificWarnings="4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> Changes in directory llvm/win32/llc: llc.vcproj updated: 1.6 -> 1.7 --- Log message: Silence VC++ warnings about using 'this' in base member initializations. --- Diffs of the changes: (+2 -2) llc.vcproj | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/win32/llc/llc.vcproj diff -u llvm/win32/llc/llc.vcproj:1.6 llvm/win32/llc/llc.vcproj:1.7 --- llvm/win32/llc/llc.vcproj:1.6 Tue Jan 4 00:01:55 2005 +++ llvm/win32/llc/llc.vcproj Sun Jan 30 11:54:12 2005 @@ -31,7 +31,7 @@ WarningLevel="3" Detect64BitPortabilityProblems="FALSE" DebugInformationFormat="4" - DisableSpecificWarnings="4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> Changes in directory llvm/win32/CBackend: CBackend.vcproj updated: 1.1 -> 1.2 --- Log message: Silence VC++ warnings about using 'this' in base member initializations. --- Diffs of the changes: (+2 -2) CBackend.vcproj | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/win32/CBackend/CBackend.vcproj diff -u llvm/win32/CBackend/CBackend.vcproj:1.1 llvm/win32/CBackend/CBackend.vcproj:1.2 --- llvm/win32/CBackend/CBackend.vcproj:1.1 Tue Jan 4 00:01:54 2005 +++ llvm/win32/CBackend/CBackend.vcproj Sun Jan 30 11:54:11 2005 @@ -31,7 +31,7 @@ WarningLevel="3" Detect64BitPortabilityProblems="FALSE" DebugInformationFormat="4" - DisableSpecificWarnings="4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> Changes in directory llvm/win32/x86: x86.vcproj updated: 1.8 -> 1.9 --- Log message: Silence VC++ warnings about using 'this' in base member initializations. --- Diffs of the changes: (+2 -2) x86.vcproj | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/win32/x86/x86.vcproj diff -u llvm/win32/x86/x86.vcproj:1.8 llvm/win32/x86/x86.vcproj:1.9 --- llvm/win32/x86/x86.vcproj:1.8 Sat Jan 1 12:17:40 2005 +++ llvm/win32/x86/x86.vcproj Sun Jan 30 11:54:12 2005 @@ -32,7 +32,7 @@ WarningLevel="3" Detect64BitPortabilityProblems="FALSE" DebugInformationFormat="4" - DisableSpecificWarnings="4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> Changes in directory llvm/win32/Bytecode: Bytecode.vcproj updated: 1.2 -> 1.3 --- Log message: Silence VC++ warnings about using 'this' in base member initializations. --- Diffs of the changes: (+2 -2) Bytecode.vcproj | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/win32/Bytecode/Bytecode.vcproj diff -u llvm/win32/Bytecode/Bytecode.vcproj:1.2 llvm/win32/Bytecode/Bytecode.vcproj:1.3 --- llvm/win32/Bytecode/Bytecode.vcproj:1.2 Sat Jan 1 14:51:41 2005 +++ llvm/win32/Bytecode/Bytecode.vcproj Sun Jan 30 11:54:11 2005 @@ -31,7 +31,7 @@ WarningLevel="3" Detect64BitPortabilityProblems="FALSE" DebugInformationFormat="4" - DisableSpecificWarnings="4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> Changes in directory llvm/win32/Target: Target.vcproj updated: 1.7 -> 1.8 --- Log message: Silence VC++ warnings about using 'this' in base member initializations. --- Diffs of the changes: (+2 -2) Target.vcproj | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/win32/Target/Target.vcproj diff -u llvm/win32/Target/Target.vcproj:1.7 llvm/win32/Target/Target.vcproj:1.8 --- llvm/win32/Target/Target.vcproj:1.7 Fri Jan 7 09:52:36 2005 +++ llvm/win32/Target/Target.vcproj Sun Jan 30 11:54:11 2005 @@ -31,7 +31,7 @@ WarningLevel="3" Detect64BitPortabilityProblems="FALSE" DebugInformationFormat="4" - DisableSpecificWarnings="4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> + DisableSpecificWarnings="4355,4146,4800"/> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.19 -> 1.20 AlphaInstrInfo.td updated: 1.9 -> 1.10 --- Log message: added fp extend and removed a forgotten assert in more than 6 arg support (should break somewhere else now :) ) and fix an incorrect asm sequence for indirect calls --- Diffs of the changes: (+32 -22) AlphaISelPattern.cpp | 38 ++++++++++++++++++++++---------------- AlphaInstrInfo.td | 16 ++++++++++------ 2 files changed, 32 insertions(+), 22 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.19 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.20 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.19 Sun Jan 30 10:32:48 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Sun Jan 30 14:42:36 2005 @@ -307,6 +307,12 @@ Node->dump(); assert(0 && "Node not handled!\n"); + case ISD::FP_EXTEND: + assert (DestType == MVT::f64 && N.getOperand(0).getValueType() == MVT::f32 && "only f32 to f64 conversion supported here"); + Tmp1 = SelectExpr(N.getOperand(0)); + BuildMI(BB, Alpha::CVTST, 1, Result).addReg(Tmp1); + return Result; + case ISD::CopyFromReg: { // Make sure we generate both values. @@ -584,7 +590,7 @@ //grab the arguments std::vector argvregs; - assert(Node->getNumOperands() < 8 && "Only 6 args supported"); + //assert(Node->getNumOperands() < 8 && "Only 6 args supported"); for(int i = 2, e = Node->getNumOperands(); i < e; ++i) argvregs.push_back(SelectExpr(N.getOperand(i))); @@ -640,23 +646,23 @@ } //build the right kind of call if (GlobalAddressSDNode *GASD = - dyn_cast(N.getOperand(1))) - { - AlphaLowering.restoreGP(BB); - BuildMI(BB, Alpha::CALL, 1).addGlobalAddress(GASD->getGlobal(),true); - } + dyn_cast(N.getOperand(1))) + { + AlphaLowering.restoreGP(BB); + BuildMI(BB, Alpha::CALL, 1).addGlobalAddress(GASD->getGlobal(),true); + } else if (ExternalSymbolSDNode *ESSDN = - dyn_cast(N.getOperand(1))) - { - AlphaLowering.restoreGP(BB); - BuildMI(BB, Alpha::CALL, 0).addExternalSymbol(ESSDN->getSymbol(), true); - } + dyn_cast(N.getOperand(1))) + { + AlphaLowering.restoreGP(BB); + BuildMI(BB, Alpha::CALL, 0).addExternalSymbol(ESSDN->getSymbol(), true); + } else - { - Tmp1 = SelectExpr(N.getOperand(1)); - AlphaLowering.restoreGP(BB); - BuildMI(BB, Alpha::CALL, 1).addReg(Tmp1); - } + { + //no need to restore GP as we are doing an indirect call + Tmp1 = SelectExpr(N.getOperand(1)); + BuildMI(BB, Alpha::JSR, 2, Alpha::R26).addReg(Tmp1).addImm(1); + } //push the result into a virtual register Index: llvm/lib/Target/Alpha/AlphaInstrInfo.td diff -u llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.9 llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.10 --- llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.9 Sat Jan 29 09:42:07 2005 +++ llvm/lib/Target/Alpha/AlphaInstrInfo.td Sun Jan 30 14:42:36 2005 @@ -246,15 +246,19 @@ def RET : MForm< 0x1A, (ops GPRC:$RD, GPRC:$RS), "ret $RD,($RS),1">; //Return from subroutine def JMP : MForm< 0x1A, (ops GPRC:$RD, GPRC:$RS), "jmp $RD,($RS),0">; //Jump -let isCall = 1 in - let Defs = [R0, R1, R2, R3, R4, R5, R6, R7, R8, R16, R17, R18, R19, R20, R21, R22, R23, R24, R25, R27, R29] in +let isCall = 1, + Defs = [R0, R1, R2, R3, R4, R5, R6, R7, R8, R16, R17, R18, R19, + R20, R21, R22, R23, R24, R25, R26, R27, R29, + F0, F1, + F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, + F20, F21, F22, F23, F24, F25, F26, F27, F28, F29, F30], + Uses = [R27, R29] in { def JSR : MForm< 0x1A, (ops GPRC:$RD, GPRC:$RS, s14imm:$DISP), "jsr $RD,($RS),$DISP">; //Jump to subroutine -def JSR_COROUTINE : MForm< 0x1A, (ops GPRC:$RD, GPRC:$RS), "jsr_coroutine $RD,($RS),1">; //Jump to subroutine return + def BSR : BForm<0x34, (ops GPRC:$RD, s21imm:$DISP), "bsr $RD,$DISP">; //Branch to subroutine +} +def JSR_COROUTINE : MForm< 0x1A, (ops GPRC:$RD, GPRC:$RS), "jsr_coroutine $RD,($RS),1">; //Jump to subroutine return def BR : BForm<0x30, (ops GPRC:$RD, s21imm:$DISP), "br $RD,$DISP">; //Branch -let isCall = 1 in - let Defs = [R0, R1, R2, R3, R4, R5, R6, R7, R8, R16, R17, R18, R19, R20, R21, R22, R23, R24, R25, R27, R29] in - def BSR : BForm<0x34, (ops GPRC:$RD, s21imm:$DISP), "bsr $RD,$DISP">; //Branch to subroutine //Stores, int def STB : MForm<0x0E, (ops GPRC:$RA, s16imm:$DISP, GPRC:$RB), "stb $RA,$DISP($RB)">; // Store byte From lattner at cs.uiuc.edu Sun Jan 30 17:51:04 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 30 Jan 2005 17:51:04 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/DataStructure/DSGraph.h DSNode.h DSSupport.h Message-ID: <200501302351.j0UNp4a0007715@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis/DataStructure: DSGraph.h updated: 1.84 -> 1.85 DSNode.h updated: 1.48 -> 1.49 DSSupport.h updated: 1.35 -> 1.36 --- Log message: * Make some methods more const correct. * Change the FunctionCalls and AuxFunctionCalls vectors into std::lists. This makes many operations on these lists much more natural, and avoids *exteremely* expensive copying of DSCallSites (e.g. moving nodes around between lists, erasing a node from not the end of the vector, etc). With a profile build of analyze, this speeds up BU DS from 25.14s to 12.59s on 176.gcc. I expect that it would help TD even more, but I don't have data for it. This effectively eliminates removeIdenticalCalls and children from the profile, going from 6.53 to 0.27s. --- Diffs of the changes: (+23 -12) DSGraph.h | 31 +++++++++++++++++++++---------- DSNode.h | 2 +- DSSupport.h | 2 +- 3 files changed, 23 insertions(+), 12 deletions(-) Index: llvm/include/llvm/Analysis/DataStructure/DSGraph.h diff -u llvm/include/llvm/Analysis/DataStructure/DSGraph.h:1.84 llvm/include/llvm/Analysis/DataStructure/DSGraph.h:1.85 --- llvm/include/llvm/Analysis/DataStructure/DSGraph.h:1.84 Mon Jan 24 13:55:34 2005 +++ llvm/include/llvm/Analysis/DataStructure/DSGraph.h Sun Jan 30 17:50:48 2005 @@ -17,6 +17,7 @@ #include "llvm/Analysis/DataStructure/DSNode.h" #include "llvm/ADT/hash_map" +#include namespace llvm { @@ -136,19 +137,19 @@ // ReturnNodesTy ReturnNodes; - // FunctionCalls - This vector maintains a single entry for each call + // FunctionCalls - This list maintains a single entry for each call // instruction in the current graph. The first entry in the vector is the // scalar that holds the return value for the call, the second is the function // scalar being invoked, and the rest are pointer arguments to the function. // This vector is built by the Local graph and is never modified after that. // - std::vector FunctionCalls; + std::list FunctionCalls; // AuxFunctionCalls - This vector contains call sites that have been processed // by some mechanism. In pratice, the BU Analysis uses this vector to hold // the _unresolved_ call sites, because it cannot modify FunctionCalls. // - std::vector AuxFunctionCalls; + std::list AuxFunctionCalls; // InlinedGlobals - This set records which globals have been inlined from // other graphs (callers or callees, depending on the pass) into this one. @@ -222,20 +223,30 @@ /// getFunctionCalls - Return the list of call sites in the original local /// graph... /// - const std::vector &getFunctionCalls() const { - return FunctionCalls; - } + const std::list &getFunctionCalls() const { return FunctionCalls;} + std::list &getFunctionCalls() { return FunctionCalls;} /// getAuxFunctionCalls - Get the call sites as modified by whatever passes /// have been run. /// - std::vector &getAuxFunctionCalls() { - return AuxFunctionCalls; - } - const std::vector &getAuxFunctionCalls() const { + std::list &getAuxFunctionCalls() { return AuxFunctionCalls; } + const std::list &getAuxFunctionCalls() const { return AuxFunctionCalls; } + // Function Call iteration + typedef std::list::const_iterator fc_iterator; + fc_iterator fc_begin() const { return FunctionCalls.begin(); } + fc_iterator fc_end() const { return FunctionCalls.end(); } + + + // Aux Function Call iteration + typedef std::list::const_iterator afc_iterator; + afc_iterator afc_begin() const { return AuxFunctionCalls.begin(); } + afc_iterator afc_end() const { return AuxFunctionCalls.end(); } + + + /// getInlinedGlobals - Get the set of globals that are have been inlined /// (from callees in BU or from callers in TD) into the current graph. /// Index: llvm/include/llvm/Analysis/DataStructure/DSNode.h diff -u llvm/include/llvm/Analysis/DataStructure/DSNode.h:1.48 llvm/include/llvm/Analysis/DataStructure/DSNode.h:1.49 --- llvm/include/llvm/Analysis/DataStructure/DSNode.h:1.48 Sat Jan 29 18:08:36 2005 +++ llvm/include/llvm/Analysis/DataStructure/DSNode.h Sun Jan 30 17:50:48 2005 @@ -349,7 +349,7 @@ /// DSNodes, marking any nodes which are reachable. All reachable nodes it /// adds to the set, which allows it to only traverse visited nodes once. /// - void markReachableNodes(hash_set &ReachableNodes); + void markReachableNodes(hash_set &ReachableNodes) const; private: friend class DSNodeHandle; Index: llvm/include/llvm/Analysis/DataStructure/DSSupport.h diff -u llvm/include/llvm/Analysis/DataStructure/DSSupport.h:1.35 llvm/include/llvm/Analysis/DataStructure/DSSupport.h:1.36 --- llvm/include/llvm/Analysis/DataStructure/DSSupport.h:1.35 Sat Jan 8 22:18:28 2005 +++ llvm/include/llvm/Analysis/DataStructure/DSSupport.h Sun Jan 30 17:50:48 2005 @@ -289,7 +289,7 @@ /// DSNodes, marking any nodes which are reachable. All reachable nodes it /// adds to the set, which allows it to only traverse visited nodes once. /// - void markReachableNodes(hash_set &Nodes); + void markReachableNodes(hash_set &Nodes) const; bool operator<(const DSCallSite &CS) const { if (isDirectCall()) { // This must sort by callee first! From lattner at cs.uiuc.edu Sun Jan 30 17:51:16 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 30 Jan 2005 17:51:16 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp CompleteBottomUp.cpp DSCallSiteIterator.h DataStructure.cpp DataStructureStats.cpp Local.cpp Printer.cpp Steensgaard.cpp TopDownClosure.cpp Message-ID: <200501302351.j0UNpGWv007745@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: BottomUpClosure.cpp updated: 1.85 -> 1.86 CompleteBottomUp.cpp updated: 1.15 -> 1.16 DSCallSiteIterator.h updated: 1.9 -> 1.10 DataStructure.cpp updated: 1.186 -> 1.187 DataStructureStats.cpp updated: 1.15 -> 1.16 Local.cpp updated: 1.120 -> 1.121 Printer.cpp updated: 1.73 -> 1.74 Steensgaard.cpp updated: 1.44 -> 1.45 TopDownClosure.cpp updated: 1.71 -> 1.72 --- Log message: * Make some methods more const correct. * Change the FunctionCalls and AuxFunctionCalls vectors into std::lists. This makes many operations on these lists much more natural, and avoids *exteremely* expensive copying of DSCallSites (e.g. moving nodes around between lists, erasing a node from not the end of the vector, etc). With a profile build of analyze, this speeds up BU DS from 25.14s to 12.59s on 176.gcc. I expect that it would help TD even more, but I don't have data for it. This effectively eliminates removeIdenticalCalls and children from the profile, going from 6.53 to 0.27s. --- Diffs of the changes: (+243 -218) BottomUpClosure.cpp | 42 ++++--- CompleteBottomUp.cpp | 26 ++-- DSCallSiteIterator.h | 36 +++--- DataStructure.cpp | 287 +++++++++++++++++++++++++------------------------ DataStructureStats.cpp | 10 - Local.cpp | 4 Printer.cpp | 7 - Steensgaard.cpp | 17 +- TopDownClosure.cpp | 32 ++--- 9 files changed, 243 insertions(+), 218 deletions(-) Index: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp diff -u llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.85 llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.86 --- llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.85 Mon Jan 24 14:00:14 2005 +++ llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp Sun Jan 30 17:51:00 2005 @@ -247,23 +247,23 @@ void BUDataStructures::calculateGraph(DSGraph &Graph) { // Move our call site list into TempFCs so that inline call sites go into the // new call site list and doesn't invalidate our iterators! - std::vector TempFCs; - std::vector &AuxCallsList = Graph.getAuxFunctionCalls(); + std::list TempFCs; + std::list &AuxCallsList = Graph.getAuxFunctionCalls(); TempFCs.swap(AuxCallsList); DSGraph::ReturnNodesTy &ReturnNodes = Graph.getReturnNodes(); // Loop over all of the resolvable call sites - unsigned LastCallSiteIdx = ~0U; - for (DSCallSiteIterator I = DSCallSiteIterator::begin(TempFCs), - E = DSCallSiteIterator::end(TempFCs); I != E; ++I) { - // If we skipped over any call sites, they must be unresolvable, copy them - // to the real call site list. - LastCallSiteIdx++; - for (; LastCallSiteIdx < I.getCallSiteIdx(); ++LastCallSiteIdx) - AuxCallsList.push_back(TempFCs[LastCallSiteIdx]); - LastCallSiteIdx = I.getCallSiteIdx(); + DSCallSiteIterator I = DSCallSiteIterator::begin(TempFCs); + DSCallSiteIterator E = DSCallSiteIterator::end(TempFCs); + + // If DSCallSiteIterator skipped over any call sites, they are unresolvable: + // move them back to the AuxCallsList. + std::list::iterator LastCallSiteIdx = TempFCs.begin(); + while (LastCallSiteIdx != I.getCallSiteIdx()) + AuxCallsList.splice(AuxCallsList.end(), TempFCs, LastCallSiteIdx++); + while (I != E) { // Resolve the current call... Function *Callee = *I; DSCallSite CS = I.getCallSite(); @@ -301,11 +301,23 @@ Callee->getName()); #endif } - } - // Make sure to catch any leftover unresolvable calls... - for (++LastCallSiteIdx; LastCallSiteIdx < TempFCs.size(); ++LastCallSiteIdx) - AuxCallsList.push_back(TempFCs[LastCallSiteIdx]); + LastCallSiteIdx = I.getCallSiteIdx(); + ++I; // Move to the next call site. + + if (I.getCallSiteIdx() != LastCallSiteIdx) { + ++LastCallSiteIdx; // Skip over the site we already processed. + + // If there are call sites that get skipped over, move them to the aux + // calls list: they are not resolvable. + if (I != E) + while (LastCallSiteIdx != I.getCallSiteIdx()) + AuxCallsList.splice(AuxCallsList.end(), TempFCs, LastCallSiteIdx++); + else + while (LastCallSiteIdx != TempFCs.end()) + AuxCallsList.splice(AuxCallsList.end(), TempFCs, LastCallSiteIdx++); + } + } TempFCs.clear(); Index: llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp diff -u llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp:1.15 llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp:1.16 --- llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp:1.15 Thu Oct 7 15:01:31 2004 +++ llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp Sun Jan 30 17:51:00 2005 @@ -49,20 +49,21 @@ // we hack it like this: for (Module::iterator MI = M.begin(), ME = M.end(); MI != ME; ++MI) { if (MI->isExternal()) continue; - const std::vector &CSs = TD.getDSGraph(*MI).getFunctionCalls(); + const std::list &CSs = TD.getDSGraph(*MI).getFunctionCalls(); - for (unsigned CSi = 0, e = CSs.size(); CSi != e; ++CSi) { - Instruction *TheCall = CSs[CSi].getCallSite().getInstruction(); + for (std::list::const_iterator CSI = CSs.begin(), E = CSs.end(); + CSI != E; ++CSI) { + Instruction *TheCall = CSI->getCallSite().getInstruction(); - if (CSs[CSi].isIndirectCall()) { // indirect call: insert all callees + if (CSI->isIndirectCall()) { // indirect call: insert all callees const std::vector &Callees = - CSs[CSi].getCalleeNode()->getGlobals(); + CSI->getCalleeNode()->getGlobals(); for (unsigned i = 0, e = Callees.size(); i != e; ++i) if (Function *F = dyn_cast(Callees[i])) ActualCallees.insert(std::make_pair(TheCall, F)); } else { // direct call: insert the single callee directly ActualCallees.insert(std::make_pair(TheCall, - CSs[CSi].getCalleeFunc())); + CSI->getCalleeFunc())); } } } @@ -121,8 +122,8 @@ Stack.push_back(&FG); // The edges out of the current node are the call site targets... - for (unsigned i = 0, e = FG.getFunctionCalls().size(); i != e; ++i) { - Instruction *Call = FG.getFunctionCalls()[i].getCallSite().getInstruction(); + for (DSGraph::fc_iterator CI = FG.fc_begin(), E = FG.fc_end(); CI != E; ++CI){ + Instruction *Call = CI->getCallSite().getInstruction(); // Loop over all of the actually called functions... ActualCalleesTy::iterator I, E; @@ -183,8 +184,10 @@ hash_set calls; // The edges out of the current node are the call site targets... - for (unsigned i = 0, e = G.getFunctionCalls().size(); i != e; ++i) { - const DSCallSite &CS = G.getFunctionCalls()[i]; + unsigned i = 0; + for (DSGraph::fc_iterator CI = G.fc_begin(), E = G.fc_end(); CI != E; + ++CI, ++i) { + const DSCallSite &CS = *CI; Instruction *TheCall = CS.getCallSite().getInstruction(); assert(calls.insert(TheCall).second && @@ -208,7 +211,8 @@ G.mergeInGraph(CS, *CalleeFunc, GI, DSGraph::KeepModRefBits | DSGraph::StripAllocaBit | DSGraph::DontCloneCallNodes | DSGraph::DontCloneAuxCallNodes); - DEBUG(std::cerr << " Inlining graph [" << i << "/" << e-1 + DEBUG(std::cerr << " Inlining graph [" << i << "/" + << G.getFunctionCalls().size()-1 << ":" << TNum << "/" << Num-1 << "] for " << CalleeFunc->getName() << "[" << GI.getGraphSize() << "+" << GI.getAuxFunctionCalls().size() Index: llvm/lib/Analysis/DataStructure/DSCallSiteIterator.h diff -u llvm/lib/Analysis/DataStructure/DSCallSiteIterator.h:1.9 llvm/lib/Analysis/DataStructure/DSCallSiteIterator.h:1.10 --- llvm/lib/Analysis/DataStructure/DSCallSiteIterator.h:1.9 Wed Jul 7 01:32:21 2004 +++ llvm/lib/Analysis/DataStructure/DSCallSiteIterator.h Sun Jan 30 17:51:01 2005 @@ -23,18 +23,18 @@ struct DSCallSiteIterator { // FCs are the edges out of the current node are the call site targets... - const std::vector *FCs; - unsigned CallSite; + std::list *FCs; + std::list::iterator CallSite; unsigned CallSiteEntry; - DSCallSiteIterator(const std::vector &CS) : FCs(&CS) { - CallSite = 0; CallSiteEntry = 0; + DSCallSiteIterator(std::list &CS) : FCs(&CS) { + CallSite = CS.begin(); CallSiteEntry = 0; advanceToValidCallee(); } - // End iterator ctor... - DSCallSiteIterator(const std::vector &CS, bool) : FCs(&CS) { - CallSite = FCs->size(); CallSiteEntry = 0; + // End iterator ctor. + DSCallSiteIterator(std::list &CS, bool) : FCs(&CS) { + CallSite = CS.end(); CallSiteEntry = 0; } static bool isVAHackFn(const Function *F) { @@ -52,13 +52,13 @@ } void advanceToValidCallee() { - while (CallSite < FCs->size()) { - if ((*FCs)[CallSite].isDirectCall()) { + while (CallSite != FCs->end()) { + if (CallSite->isDirectCall()) { if (CallSiteEntry == 0 && // direct call only has one target... - ! isUnresolvableFunc((*FCs)[CallSite].getCalleeFunc())) + ! isUnresolvableFunc(CallSite->getCalleeFunc())) return; // and not an unresolvable external func } else { - DSNode *CalleeNode = (*FCs)[CallSite].getCalleeNode(); + DSNode *CalleeNode = CallSite->getCalleeNode(); if (CallSiteEntry || isCompleteNode(CalleeNode)) { const std::vector &Callees = CalleeNode->getGlobals(); while (CallSiteEntry < Callees.size()) { @@ -98,8 +98,8 @@ static DSCallSiteIterator end_std(DSGraph &G) { return DSCallSiteIterator(G.getFunctionCalls(), true); } - static DSCallSiteIterator begin(std::vector &CSs) { return CSs; } - static DSCallSiteIterator end(std::vector &CSs) { + static DSCallSiteIterator begin(std::list &CSs) { return CSs; } + static DSCallSiteIterator end(std::list &CSs) { return DSCallSiteIterator(CSs, true); } bool operator==(const DSCallSiteIterator &CSI) const { @@ -109,14 +109,14 @@ return !operator==(CSI); } - unsigned getCallSiteIdx() const { return CallSite; } - const DSCallSite &getCallSite() const { return (*FCs)[CallSite]; } + std::list::iterator getCallSiteIdx() const { return CallSite; } + const DSCallSite &getCallSite() const { return *CallSite; } Function *operator*() const { - if ((*FCs)[CallSite].isDirectCall()) { - return (*FCs)[CallSite].getCalleeFunc(); + if (CallSite->isDirectCall()) { + return CallSite->getCalleeFunc(); } else { - DSNode *Node = (*FCs)[CallSite].getCalleeNode(); + DSNode *Node = CallSite->getCalleeNode(); return cast(Node->getGlobals()[CallSiteEntry]); } } Index: llvm/lib/Analysis/DataStructure/DataStructure.cpp diff -u llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.186 llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.187 --- llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.186 Tue Jan 11 22:51:37 2005 +++ llvm/lib/Analysis/DataStructure/DataStructure.cpp Sun Jan 30 17:51:01 2005 @@ -1201,19 +1201,15 @@ } if (!(CloneFlags & DontCloneCallNodes)) { - // Copy the function calls list... - unsigned FC = FunctionCalls.size(); // FirstCall - FunctionCalls.reserve(FC+G.FunctionCalls.size()); - for (unsigned i = 0, ei = G.FunctionCalls.size(); i != ei; ++i) - FunctionCalls.push_back(DSCallSite(G.FunctionCalls[i], OldNodeMap)); + // Copy the function calls list. + for (fc_iterator I = G.fc_begin(), E = G.fc_end(); I != E; ++I) + FunctionCalls.push_back(DSCallSite(*I, OldNodeMap)); } if (!(CloneFlags & DontCloneAuxCallNodes)) { - // Copy the auxiliary function calls list... - unsigned FC = AuxFunctionCalls.size(); // FirstCall - AuxFunctionCalls.reserve(FC+G.AuxFunctionCalls.size()); - for (unsigned i = 0, ei = G.AuxFunctionCalls.size(); i != ei; ++i) - AuxFunctionCalls.push_back(DSCallSite(G.AuxFunctionCalls[i], OldNodeMap)); + // Copy the auxiliary function calls list. + for (afc_iterator I = G.afc_begin(), E = G.afc_end(); I != E; ++I) + AuxFunctionCalls.push_back(DSCallSite(*I, OldNodeMap)); } // Map the return node pointers over... @@ -1289,20 +1285,14 @@ // If requested, copy all of the calls. if (!(CloneFlags & DontCloneCallNodes)) { - // Copy the function calls list... - FunctionCalls.reserve(FunctionCalls.size()+Graph.FunctionCalls.size()); - for (unsigned i = 0, ei = Graph.FunctionCalls.size(); i != ei; ++i) - FunctionCalls.push_back(DSCallSite(Graph.FunctionCalls[i], RC)); + // Copy the function calls list. + for (fc_iterator I = Graph.fc_begin(), E = Graph.fc_end(); I != E; ++I) + FunctionCalls.push_back(DSCallSite(*I, RC)); } // If the user has us copying aux calls (the normal case), set up a data // structure to keep track of which ones we've copied over. - std::vector CopiedAuxCall; - if (!(CloneFlags & DontCloneAuxCallNodes)) { - AuxFunctionCalls.reserve(AuxFunctionCalls.size()+ - Graph.AuxFunctionCalls.size()); - CopiedAuxCall.resize(Graph.AuxFunctionCalls.size()); - } + std::set CopiedAuxCall; // Clone over all globals that appear in the caller and callee graphs. hash_set NonCopiedGlobals; @@ -1341,17 +1331,15 @@ // If requested, copy any aux calls that can reach copied nodes. if (!(CloneFlags & DontCloneAuxCallNodes)) { - for (unsigned i = 0, ei = Graph.AuxFunctionCalls.size(); i != ei; ++i) - if (!CopiedAuxCall[i] && - PathExistsToClonedNode(Graph.AuxFunctionCalls[i], RC)) { - AuxFunctionCalls.push_back(DSCallSite(Graph.AuxFunctionCalls[i], - RC)); - CopiedAuxCall[i] = true; + for (afc_iterator I = Graph.afc_begin(), E = Graph.afc_end(); I!=E; ++I) + if (CopiedAuxCall.insert(&*I).second && + PathExistsToClonedNode(*I, RC)) { + AuxFunctionCalls.push_back(DSCallSite(*I, RC)); MadeChange = true; } } } - + } else { DSNodeHandle RetVal = getReturnNodeFor(F); @@ -1458,7 +1446,7 @@ // added to the NodeType. // void DSGraph::markIncompleteNodes(unsigned Flags) { - // Mark any incoming arguments as incomplete... + // Mark any incoming arguments as incomplete. if (Flags & DSGraph::MarkFormalArgs) for (ReturnNodesTy::iterator FI = ReturnNodes.begin(), E =ReturnNodes.end(); FI != E; ++FI) { @@ -1469,14 +1457,15 @@ markIncompleteNode(getNodeForValue(I).getNode()); } - // Mark stuff passed into functions calls as being incomplete... + // Mark stuff passed into functions calls as being incomplete. if (!shouldPrintAuxCalls()) - for (unsigned i = 0, e = FunctionCalls.size(); i != e; ++i) - markIncomplete(FunctionCalls[i]); + for (std::list::iterator I = FunctionCalls.begin(), + E = FunctionCalls.end(); I != E; ++I) + markIncomplete(*I); else - for (unsigned i = 0, e = AuxFunctionCalls.size(); i != e; ++i) - markIncomplete(AuxFunctionCalls[i]); - + for (std::list::iterator I = AuxFunctionCalls.begin(), + E = AuxFunctionCalls.end(); I != E; ++I) + markIncomplete(*I); // Mark all global nodes as incomplete... if ((Flags & DSGraph::IgnoreGlobals) == 0) @@ -1504,22 +1493,21 @@ return false; } -static void removeIdenticalCalls(std::vector &Calls) { +static void removeIdenticalCalls(std::list &Calls) { // Remove trivially identical function calls - unsigned NumFns = Calls.size(); - std::sort(Calls.begin(), Calls.end()); // Sort by callee as primary key! + Calls.sort(); // Sort by callee as primary key! -#if 1 // Scan the call list cleaning it up as necessary... DSNode *LastCalleeNode = 0; Function *LastCalleeFunc = 0; unsigned NumDuplicateCalls = 0; bool LastCalleeContainsExternalFunction = false; - std::vector CallsToDelete; - - for (unsigned i = 0; i != Calls.size(); ++i) { - DSCallSite &CS = Calls[i]; + unsigned NumDeleted = 0; + for (std::list::iterator I = Calls.begin(), E = Calls.end(); + I != E;) { + DSCallSite &CS = *I; + std::list::iterator OldIt = I++; // If the Callee is a useless edge, this must be an unreachable call site, // eliminate it. @@ -1529,78 +1517,106 @@ #ifndef NDEBUG std::cerr << "WARNING: Useless call site found.\n"; #endif - CallsToDelete.push_back(i); - } else { - // If the return value or any arguments point to a void node with no - // information at all in it, and the call node is the only node to point - // to it, remove the edge to the node (killing the node). - // - killIfUselessEdge(CS.getRetVal()); - for (unsigned a = 0, e = CS.getNumPtrArgs(); a != e; ++a) - killIfUselessEdge(CS.getPtrArg(a)); + Calls.erase(OldIt); + ++NumDeleted; + continue; + } + + // If the return value or any arguments point to a void node with no + // information at all in it, and the call node is the only node to point + // to it, remove the edge to the node (killing the node). + // + killIfUselessEdge(CS.getRetVal()); + for (unsigned a = 0, e = CS.getNumPtrArgs(); a != e; ++a) + killIfUselessEdge(CS.getPtrArg(a)); + +#if 0 + // If this call site calls the same function as the last call site, and if + // the function pointer contains an external function, this node will + // never be resolved. Merge the arguments of the call node because no + // information will be lost. + // + if ((CS.isDirectCall() && CS.getCalleeFunc() == LastCalleeFunc) || + (CS.isIndirectCall() && CS.getCalleeNode() == LastCalleeNode)) { + ++NumDuplicateCalls; + if (NumDuplicateCalls == 1) { + if (LastCalleeNode) + LastCalleeContainsExternalFunction = + nodeContainsExternalFunction(LastCalleeNode); + else + LastCalleeContainsExternalFunction = LastCalleeFunc->isExternal(); + } - // If this call site calls the same function as the last call site, and if - // the function pointer contains an external function, this node will - // never be resolved. Merge the arguments of the call node because no - // information will be lost. - // - if ((CS.isDirectCall() && CS.getCalleeFunc() == LastCalleeFunc) || - (CS.isIndirectCall() && CS.getCalleeNode() == LastCalleeNode)) { - ++NumDuplicateCalls; - if (NumDuplicateCalls == 1) { - if (LastCalleeNode) - LastCalleeContainsExternalFunction = - nodeContainsExternalFunction(LastCalleeNode); - else - LastCalleeContainsExternalFunction = LastCalleeFunc->isExternal(); - } - - // It is not clear why, but enabling this code makes DSA really - // sensitive to node forwarding. Basically, with this enabled, DSA - // performs different number of inlinings based on which nodes are - // forwarding or not. This is clearly a problem, so this code is - // disabled until this can be resolved. + // It is not clear why, but enabling this code makes DSA really + // sensitive to node forwarding. Basically, with this enabled, DSA + // performs different number of inlinings based on which nodes are + // forwarding or not. This is clearly a problem, so this code is + // disabled until this can be resolved. #if 1 - if (LastCalleeContainsExternalFunction + if (LastCalleeContainsExternalFunction #if 0 - || - // This should be more than enough context sensitivity! - // FIXME: Evaluate how many times this is tripped! - NumDuplicateCalls > 20 + || + // This should be more than enough context sensitivity! + // FIXME: Evaluate how many times this is tripped! + NumDuplicateCalls > 20 #endif - ) { - DSCallSite &OCS = Calls[i-1]; - OCS.mergeWith(CS); - - // No need to keep this call anymore. - CallsToDelete.push_back(i); - } + ) { + + std::list::iterator PrevIt = OldIt; + --PrevIt; + PrevIt->mergeWith(CS); + + // No need to keep this call anymore. + Calls.erase(OldIt); + ++NumDeleted; + continue; + } #endif + } else { + if (CS.isDirectCall()) { + LastCalleeFunc = CS.getCalleeFunc(); + LastCalleeNode = 0; } else { - if (CS.isDirectCall()) { - LastCalleeFunc = CS.getCalleeFunc(); - LastCalleeNode = 0; - } else { - LastCalleeNode = CS.getCalleeNode(); - LastCalleeFunc = 0; - } - NumDuplicateCalls = 0; + LastCalleeNode = CS.getCalleeNode(); + LastCalleeFunc = 0; } + NumDuplicateCalls = 0; } - } #endif - unsigned NumDeleted = 0; - for (unsigned i = 0, e = CallsToDelete.size(); i != e; ++i) - Calls.erase(Calls.begin()+CallsToDelete[i]-NumDeleted++); + if (I != Calls.end() && CS == *I) { + Calls.erase(OldIt); + ++NumDeleted; + continue; + } + } - Calls.erase(std::unique(Calls.begin(), Calls.end()), Calls.end()); + // Resort now that we simplified things. + Calls.sort(); + + // Now that we are in sorted order, eliminate duplicates. + std::list::iterator I = Calls.begin(), E = Calls.end(); + if (I != E) + while (1) { + std::list::iterator OldIt = I++; + if (I == E) break; + + // If this call site is now the same as the previous one, we can delete it + // as a duplicate. + if (*OldIt == *I) { + Calls.erase(I); + I = OldIt; + ++NumDeleted; + } + } + + //Calls.erase(std::unique(Calls.begin(), Calls.end()), Calls.end()); // Track the number of call nodes merged away... - NumCallNodesMerged += NumFns-Calls.size(); + NumCallNodesMerged += NumDeleted; - DEBUG(if (NumFns != Calls.size()) - std::cerr << "Merged " << (NumFns-Calls.size()) << " call nodes.\n";); + DEBUG(if (NumDeleted) + std::cerr << "Merged " << NumDeleted << " call nodes.\n";); } @@ -1698,7 +1714,7 @@ /// DSNodes, marking any nodes which are reachable. All reachable nodes it adds /// to the set, which allows it to only traverse visited nodes once. /// -void DSNode::markReachableNodes(hash_set &ReachableNodes) { +void DSNode::markReachableNodes(hash_set &ReachableNodes) const { if (this == 0) return; assert(getForwardNode() == 0 && "Cannot mark a forwarded node!"); if (ReachableNodes.insert(this).second) // Is newly reachable? @@ -1706,7 +1722,7 @@ getLink(i).getNode()->markReachableNodes(ReachableNodes); } -void DSCallSite::markReachableNodes(hash_set &Nodes) { +void DSCallSite::markReachableNodes(hash_set &Nodes) const { getRetVal().getNode()->markReachableNodes(Nodes); if (isIndirectCall()) getCalleeNode()->markReachableNodes(Nodes); @@ -1719,8 +1735,8 @@ // true, otherwise return false. If an alive node is reachable, this node is // marked as alive... // -static bool CanReachAliveNodes(DSNode *N, hash_set &Alive, - hash_set &Visited, +static bool CanReachAliveNodes(DSNode *N, hash_set &Alive, + hash_set &Visited, bool IgnoreGlobals) { if (N == 0) return false; assert(N->getForwardNode() == 0 && "Cannot mark a forwarded node!"); @@ -1749,8 +1765,9 @@ // CallSiteUsesAliveArgs - Return true if the specified call site can reach any // alive nodes. // -static bool CallSiteUsesAliveArgs(DSCallSite &CS, hash_set &Alive, - hash_set &Visited, +static bool CallSiteUsesAliveArgs(const DSCallSite &CS, + hash_set &Alive, + hash_set &Visited, bool IgnoreGlobals) { if (CanReachAliveNodes(CS.getRetVal().getNode(), Alive, Visited, IgnoreGlobals)) @@ -1783,7 +1800,7 @@ // FIXME: Merge non-trivially identical call nodes... // Alive - a set that holds all nodes found to be reachable/alive. - hash_set Alive; + hash_set Alive; std::vector > GlobalNodes; // Copy and merge all information about globals to the GlobalsGraph if this is @@ -1843,16 +1860,16 @@ I->second.getNode()->markReachableNodes(Alive); // Mark any nodes reachable by primary calls as alive... - for (unsigned i = 0, e = FunctionCalls.size(); i != e; ++i) - FunctionCalls[i].markReachableNodes(Alive); + for (fc_iterator I = fc_begin(), E = fc_end(); I != E; ++I) + I->markReachableNodes(Alive); // Now find globals and aux call nodes that are already live or reach a live // value (which makes them live in turn), and continue till no more are found. // bool Iterate; - hash_set Visited; - std::vector AuxFCallsAlive(AuxFunctionCalls.size()); + hash_set Visited; + hash_set AuxFCallsAlive; do { Visited.clear(); // If any global node points to a non-global that is "alive", the global is @@ -1873,36 +1890,32 @@ // call nodes that get resolved will be difficult to remove from that graph. // The final unresolved call nodes must be handled specially at the end of // the BU pass (i.e., in main or other roots of the call graph). - for (unsigned i = 0, e = AuxFunctionCalls.size(); i != e; ++i) - if (!AuxFCallsAlive[i] && - (AuxFunctionCalls[i].isIndirectCall() - || CallSiteUsesAliveArgs(AuxFunctionCalls[i], Alive, Visited, + for (afc_iterator CI = afc_begin(), E = afc_end(); CI != E; ++CI) + if (AuxFCallsAlive.insert(&*CI).second && + (CI->isIndirectCall() + || CallSiteUsesAliveArgs(*CI, Alive, Visited, Flags & DSGraph::RemoveUnreachableGlobals))) { - AuxFunctionCalls[i].markReachableNodes(Alive); - AuxFCallsAlive[i] = true; + CI->markReachableNodes(Alive); Iterate = true; } } while (Iterate); // Move dead aux function calls to the end of the list unsigned CurIdx = 0; - for (unsigned i = 0, e = AuxFunctionCalls.size(); i != e; ++i) - if (AuxFCallsAlive[i]) - AuxFunctionCalls[CurIdx++].swap(AuxFunctionCalls[i]); + for (std::list::iterator CI = AuxFunctionCalls.begin(), + E = AuxFunctionCalls.end(); CI != E; ) + if (AuxFCallsAlive.count(&*CI)) + ++CI; + else { + // Copy and merge global nodes and dead aux call nodes into the + // GlobalsGraph, and all nodes reachable from those nodes. Update their + // target pointers using the GGCloner. + // + if (!(Flags & DSGraph::RemoveUnreachableGlobals)) + GlobalsGraph->AuxFunctionCalls.push_back(DSCallSite(*CI, GGCloner)); - // Copy and merge all global nodes and dead aux call nodes into the - // GlobalsGraph, and all nodes reachable from those nodes - // - if (!(Flags & DSGraph::RemoveUnreachableGlobals)) { - // Copy the unreachable call nodes to the globals graph, updating their - // target pointers using the GGCloner - for (unsigned i = CurIdx, e = AuxFunctionCalls.size(); i != e; ++i) - GlobalsGraph->AuxFunctionCalls.push_back(DSCallSite(AuxFunctionCalls[i], - GGCloner)); - } - // Crop all the useless ones out... - AuxFunctionCalls.erase(AuxFunctionCalls.begin()+CurIdx, - AuxFunctionCalls.end()); + AuxFunctionCalls.erase(CI++); + } // We are finally done with the GGCloner so we can destroy it. GGCloner.destroy(); @@ -1962,12 +1975,12 @@ } void DSGraph::AssertCallNodesInGraph() const { - for (unsigned i = 0, e = FunctionCalls.size(); i != e; ++i) - AssertCallSiteInGraph(FunctionCalls[i]); + for (fc_iterator I = fc_begin(), E = fc_end(); I != E; ++I) + AssertCallSiteInGraph(*I); } void DSGraph::AssertAuxCallNodesInGraph() const { - for (unsigned i = 0, e = AuxFunctionCalls.size(); i != e; ++i) - AssertCallSiteInGraph(AuxFunctionCalls[i]); + for (afc_iterator I = afc_begin(), E = afc_end(); I != E; ++I) + AssertCallSiteInGraph(*I); } void DSGraph::AssertGraphOK() const { Index: llvm/lib/Analysis/DataStructure/DataStructureStats.cpp diff -u llvm/lib/Analysis/DataStructure/DataStructureStats.cpp:1.15 llvm/lib/Analysis/DataStructure/DataStructureStats.cpp:1.16 --- llvm/lib/Analysis/DataStructure/DataStructureStats.cpp:1.15 Mon Dec 6 22:03:45 2004 +++ llvm/lib/Analysis/DataStructure/DataStructureStats.cpp Sun Jan 30 17:51:01 2005 @@ -75,19 +75,19 @@ void DSGraphStats::countCallees(const Function& F) { unsigned numIndirectCalls = 0, totalNumCallees = 0; - const std::vector &callSites = TDGraph->getFunctionCalls(); - for (unsigned i = 0, N = callSites.size(); i != N; ++i) - if (isIndirectCallee(callSites[i].getCallSite().getCalledValue())) { + for (DSGraph::fc_iterator I = TDGraph->fc_begin(), E = TDGraph->fc_end(); + I != E; ++I) + if (isIndirectCallee(I->getCallSite().getCalledValue())) { // This is an indirect function call const std::vector &Callees = - callSites[i].getCalleeNode()->getGlobals(); + I->getCalleeNode()->getGlobals(); if (Callees.size() > 0) { totalNumCallees += Callees.size(); ++numIndirectCalls; } else std::cerr << "WARNING: No callee in Function '" << F.getName() << "' at call: \n" - << *callSites[i].getCallSite().getInstruction(); + << *I->getCallSite().getInstruction(); } TotalNumCallees += totalNumCallees; Index: llvm/lib/Analysis/DataStructure/Local.cpp diff -u llvm/lib/Analysis/DataStructure/Local.cpp:1.120 llvm/lib/Analysis/DataStructure/Local.cpp:1.121 --- llvm/lib/Analysis/DataStructure/Local.cpp:1.120 Tue Jan 11 22:51:37 2005 +++ llvm/lib/Analysis/DataStructure/Local.cpp Sun Jan 30 17:51:02 2005 @@ -73,11 +73,11 @@ DSGraph &G; DSNodeHandle *RetNode; // Node that gets returned... DSScalarMap &ScalarMap; - std::vector *FunctionCalls; + std::list *FunctionCalls; public: GraphBuilder(Function &f, DSGraph &g, DSNodeHandle &retNode, - std::vector &fc) + std::list &fc) : G(g), RetNode(&retNode), ScalarMap(G.getScalarMap()), FunctionCalls(&fc) { Index: llvm/lib/Analysis/DataStructure/Printer.cpp diff -u llvm/lib/Analysis/DataStructure/Printer.cpp:1.73 llvm/lib/Analysis/DataStructure/Printer.cpp:1.74 --- llvm/lib/Analysis/DataStructure/Printer.cpp:1.73 Sat Oct 30 02:21:19 2004 +++ llvm/lib/Analysis/DataStructure/Printer.cpp Sun Jan 30 17:51:02 2005 @@ -174,11 +174,12 @@ } // Output all of the call nodes... - const std::vector &FCs = + const std::list &FCs = G->shouldPrintAuxCalls() ? G->getAuxFunctionCalls() : G->getFunctionCalls(); - for (unsigned i = 0, e = FCs.size(); i != e; ++i) { - const DSCallSite &Call = FCs[i]; + for (std::list::const_iterator I = FCs.begin(), E = FCs.end(); + I != E; ++I) { + const DSCallSite &Call = *I; std::vector EdgeSourceCaptions(Call.getNumPtrArgs()+2); EdgeSourceCaptions[0] = "r"; if (Call.isDirectCall()) Index: llvm/lib/Analysis/DataStructure/Steensgaard.cpp diff -u llvm/lib/Analysis/DataStructure/Steensgaard.cpp:1.44 llvm/lib/Analysis/DataStructure/Steensgaard.cpp:1.45 --- llvm/lib/Analysis/DataStructure/Steensgaard.cpp:1.44 Sun Jan 9 14:42:52 2005 +++ llvm/lib/Analysis/DataStructure/Steensgaard.cpp Sun Jan 30 17:51:02 2005 @@ -152,15 +152,15 @@ // Now that we have all of the graphs inlined, we can go about eliminating // call nodes... // - std::vector &Calls = - ResultGraph->getAuxFunctionCalls(); + std::list &Calls = ResultGraph->getAuxFunctionCalls(); assert(Calls.empty() && "Aux call list is already in use??"); - // Start with a copy of the original call sites... + // Start with a copy of the original call sites. Calls = ResultGraph->getFunctionCalls(); - for (unsigned i = 0; i != Calls.size(); ) { - DSCallSite &CurCall = Calls[i]; + for (std::list::iterator CI = Calls.begin(), E = Calls.end(); + CI != E;) { + DSCallSite &CurCall = *CI++; // Loop over the called functions, eliminating as many as possible... std::vector CallTargets; @@ -185,10 +185,9 @@ } if (CallTargets.empty()) { // Eliminated all calls? - CurCall = Calls.back(); // Remove entry - Calls.pop_back(); - } else - ++i; // Skip this call site... + std::list::iterator I = CI; + Calls.erase(--I); // Remove entry + } } RetValMap.clear(); Index: llvm/lib/Analysis/DataStructure/TopDownClosure.cpp diff -u llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.71 llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.72 --- llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.71 Mon Jan 24 14:00:14 2005 +++ llvm/lib/Analysis/DataStructure/TopDownClosure.cpp Sun Jan 30 17:51:02 2005 @@ -70,13 +70,11 @@ // Loop over unresolved call nodes. Any functions passed into (but not // returned!) from unresolvable call nodes may be invoked outside of the // current module. - const std::vector &Calls = GlobalsGraph->getAuxFunctionCalls(); - for (unsigned i = 0, e = Calls.size(); i != e; ++i) { - const DSCallSite &CS = Calls[i]; - for (unsigned arg = 0, e = CS.getNumPtrArgs(); arg != e; ++arg) - markReachableFunctionsExternallyAccessible(CS.getPtrArg(arg).getNode(), + for (DSGraph::afc_iterator I = GlobalsGraph->afc_begin(), + E = GlobalsGraph->afc_end(); I != E; ++I) + for (unsigned arg = 0, e = I->getNumPtrArgs(); arg != e; ++arg) + markReachableFunctionsExternallyAccessible(I->getPtrArg(arg).getNode(), Visited); - } Visited.clear(); // Functions without internal linkage also have unknown incoming arguments! @@ -135,10 +133,8 @@ Visited.insert(&G); // Recursively traverse all of the callee graphs. - const std::vector &FunctionCalls = G.getFunctionCalls(); - - for (unsigned i = 0, e = FunctionCalls.size(); i != e; ++i) { - Instruction *CallI = FunctionCalls[i].getCallSite().getInstruction(); + 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); @@ -211,8 +207,7 @@ // We are done with computing the current TD Graph! Now move on to // inlining the current graph into the graphs for its callees, if any. // - const std::vector &FunctionCalls = Graph.getFunctionCalls(); - if (FunctionCalls.empty()) { + if (Graph.fc_begin() == Graph.fc_end()) { DEBUG(std::cerr << " [TD] No callees for: " << Graph.getFunctionNames() << "\n"); return; @@ -224,7 +219,7 @@ // would be cloned only once, this should still be better on average). // DEBUG(std::cerr << " [TD] Inlining '" << Graph.getFunctionNames() <<"' into " - << FunctionCalls.size() << " call nodes.\n"); + << Graph.getFunctionCalls().size() << " call nodes.\n"); const BUDataStructures::ActualCalleesTy &ActualCallees = getAnalysis().getActualCallees(); @@ -235,12 +230,13 @@ // multiple call sites to the callees in the graph from this caller. std::multimap > CallSites; - for (unsigned i = 0, e = FunctionCalls.size(); i != e; ++i) { - Instruction *CallI = FunctionCalls[i].getCallSite().getInstruction(); + for (DSGraph::fc_iterator CI = Graph.fc_begin(), E = Graph.fc_end(); + CI != E; ++CI) { + 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> + IP = ActualCallees.equal_range(CallI); // Loop over each actual callee at this call site for (BUDataStructures::ActualCalleesTy::const_iterator I = IP.first; I != IP.second; ++I) { @@ -248,7 +244,7 @@ assert(&CalleeGraph != &Graph && "TD need not inline graph into self!"); CallSites.insert(std::make_pair(&CalleeGraph, - std::make_pair(I->second, &FunctionCalls[i]))); + std::make_pair(I->second, &*CI))); } } From lattner at cs.uiuc.edu Sun Jan 30 17:51:35 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 30 Jan 2005 17:51:35 -0600 Subject: [llvm-commits] CVS: poolalloc/lib/PoolAllocate/EquivClassGraphs.cpp Heuristic.cpp Heuristic.h PoolAllocate.cpp PoolAllocate.h TransformFunctionBody.cpp Message-ID: <200501302351.j0UNpZKT007768@apoc.cs.uiuc.edu> Changes in directory poolalloc/lib/PoolAllocate: EquivClassGraphs.cpp updated: 1.18 -> 1.19 Heuristic.cpp updated: 1.4 -> 1.5 Heuristic.h updated: 1.2 -> 1.3 PoolAllocate.cpp updated: 1.97 -> 1.98 PoolAllocate.h updated: 1.33 -> 1.34 TransformFunctionBody.cpp updated: 1.34 -> 1.35 --- Log message: Make things more const-correct, adjust to changes in DSA interfaces. --- Diffs of the changes: (+70 -62) Index: poolalloc/lib/PoolAllocate/EquivClassGraphs.cpp diff -u poolalloc/lib/PoolAllocate/EquivClassGraphs.cpp:1.18 poolalloc/lib/PoolAllocate/EquivClassGraphs.cpp:1.19 --- poolalloc/lib/PoolAllocate/EquivClassGraphs.cpp:1.18 Thu Nov 11 16:11:17 2004 +++ poolalloc/lib/PoolAllocate/EquivClassGraphs.cpp Sun Jan 30 17:51:25 2005 @@ -292,8 +292,8 @@ Stack.push_back(&FG); // The edges out of the current node are the call site targets... - for (unsigned i = 0, e = FG.getFunctionCalls().size(); i != e; ++i) { - Instruction *Call = FG.getFunctionCalls()[i].getCallSite().getInstruction(); + for (DSGraph::fc_iterator CI = FG.fc_begin(), E = FG.fc_end(); CI != E; ++CI){ + Instruction *Call = CI->getCallSite().getInstruction(); // Loop over all of the actually called functions... ActualCalleesTy::const_iterator I, E; @@ -355,8 +355,10 @@ // Else we need to inline some callee graph. Visit all call sites. // The edges out of the current node are the call site targets... - for (unsigned i=0, e = G.getFunctionCalls().size(); i != e; ++i) { - const DSCallSite &CS = G.getFunctionCalls()[i]; + unsigned i = 0; + for (DSGraph::fc_iterator CI = G.fc_begin(), E = G.fc_end(); CI != E; + ++CI, ++i) { + const DSCallSite &CS = *CI; Instruction *TheCall = CS.getCallSite().getInstruction(); assert(calls.insert(TheCall).second && @@ -392,7 +394,8 @@ DSGraph::KeepModRefBits | DSGraph::StripAllocaBit | DSGraph::DontCloneCallNodes | DSGraph::DontCloneAuxCallNodes); - DEBUG(std::cerr << " Inlining graph [" << i << "/" << e-1 + DEBUG(std::cerr << " Inlining graph [" << i << "/" + << G.getFunctionCalls().size()-1 << ":" << TNum << "/" << Num-1 << "] for " << CalleeFunc->getName() << "[" << CalleeGraph->getGraphSize() << "+" Index: poolalloc/lib/PoolAllocate/Heuristic.cpp diff -u poolalloc/lib/PoolAllocate/Heuristic.cpp:1.4 poolalloc/lib/PoolAllocate/Heuristic.cpp:1.5 --- poolalloc/lib/PoolAllocate/Heuristic.cpp:1.4 Wed Nov 10 15:13:47 2004 +++ poolalloc/lib/PoolAllocate/Heuristic.cpp Sun Jan 30 17:51:25 2005 @@ -49,7 +49,7 @@ Heuristic::~Heuristic() {} -unsigned Heuristic::getRecommendedSize(DSNode *N) { +unsigned Heuristic::getRecommendedSize(const DSNode *N) { unsigned PoolSize = 0; if (!N->isArray() && N->getType()->isSized()) { PoolSize = N->getParentGraph()->getTargetData().getTypeSize(N->getType()); @@ -87,7 +87,7 @@ /// getRecommendedAlignment - Return the recommended object alignment for this /// DSNode. /// -unsigned Heuristic::getRecommendedAlignment(DSNode *N) { +unsigned Heuristic::getRecommendedAlignment(const DSNode *N) { if (N->getType() == Type::VoidTy) // Is this void or collapsed? return 0; // No known alignment, let runtime decide. @@ -105,7 +105,7 @@ // struct AllNodesHeuristic : public Heuristic { - void AssignToPools(const std::vector &NodesToPA, + void AssignToPools(const std::vector &NodesToPA, Function *F, DSGraph &G, std::vector &ResultPools) { for (unsigned i = 0, e = NodesToPA.size(); i != e; ++i) @@ -123,7 +123,7 @@ // struct AllButUnreachableFromMemoryHeuristic : public Heuristic { - void AssignToPools(const std::vector &NodesToPA, + void AssignToPools(const std::vector &NodesToPA, Function *F, DSGraph &G, std::vector &ResultPools) { // Build a set of all nodes that are reachable from another node in the @@ -161,19 +161,20 @@ // struct CyclicNodesHeuristic : public Heuristic { - void AssignToPools(const std::vector &NodesToPA, + void AssignToPools(const std::vector &NodesToPA, Function *F, DSGraph &G, std::vector &ResultPools); }; -static bool NodeExistsInCycle(DSNode *N) { - for (DSNode::iterator I = N->begin(), E = N->end(); I != E; ++I) +static bool NodeExistsInCycle(const DSNode *N) { + for (DSNode::const_iterator I = N->begin(), E = N->end(); I != E; ++I) if (*I && std::find(df_begin(*I), df_end(*I), N) != df_end(*I)) return true; return false; } -void CyclicNodesHeuristic::AssignToPools(const std::vector &NodesToPA, +void CyclicNodesHeuristic::AssignToPools(const std::vector &NodesToPA, Function *F, DSGraph &G, std::vector &ResultPools) { for (unsigned i = 0, e = NodesToPA.size(); i != e; ++i) @@ -189,14 +190,14 @@ // struct SmartCoallesceNodesHeuristic : public Heuristic { - void AssignToPools(const std::vector &NodesToPA, + void AssignToPools(const std::vector &NodesToPA, Function *F, DSGraph &G, std::vector &ResultPools) { // For globals, do not pool allocate unless the node is cyclic and not an // array (unless it's collapsed). if (F == 0) { for (unsigned i = 0, e = NodesToPA.size(); i != e; ++i) { - DSNode *Node = NodesToPA[i]; + const DSNode *Node = NodesToPA[i]; if ((Node->isNodeCompletelyFolded() || !Node->isArray()) && NodeExistsInCycle(Node)) ResultPools.push_back(OnePool(Node)); @@ -374,7 +375,7 @@ virtual bool IsRealHeuristic() { return false; } - void AssignToPools(const std::vector &NodesToPA, + void AssignToPools(const std::vector &NodesToPA, Function *F, DSGraph &G, std::vector &ResultPools) { if (TheGlobalPD == 0) @@ -398,7 +399,7 @@ struct OnlyOverheadHeuristic : public Heuristic { virtual bool IsRealHeuristic() { return false; } - void AssignToPools(const std::vector &NodesToPA, + void AssignToPools(const std::vector &NodesToPA, Function *F, DSGraph &G, std::vector &ResultPools) { // For this heuristic, we assign everything possible to its own pool. @@ -461,7 +462,7 @@ struct NoNodesHeuristic : public Heuristic { virtual bool IsRealHeuristic() { return false; } - void AssignToPools(const std::vector &NodesToPA, + void AssignToPools(const std::vector &NodesToPA, Function *F, DSGraph &G, std::vector &ResultPools) { // Nothing to pool allocate here. Index: poolalloc/lib/PoolAllocate/Heuristic.h diff -u poolalloc/lib/PoolAllocate/Heuristic.h:1.2 poolalloc/lib/PoolAllocate/Heuristic.h:1.3 --- poolalloc/lib/PoolAllocate/Heuristic.h:1.2 Wed Nov 10 15:13:47 2004 +++ poolalloc/lib/PoolAllocate/Heuristic.h Sun Jan 30 17:51:25 2005 @@ -48,7 +48,7 @@ struct OnePool { // NodesInPool - The DS nodes to be allocated to this pool. There may be // multiple here if they are being coallesced into the same pool. - std::vector NodesInPool; + std::vector NodesInPool; // PoolDesc - If the heuristic wants the nodes allocated to a specific // pool descriptor, it can specify it here, otherwise a new pool is @@ -62,12 +62,12 @@ OnePool() : PoolDesc(0), PoolSize(0), PoolAlignment(0) {} - OnePool(DSNode *N) : PoolDesc(0), PoolSize(getRecommendedSize(N)), - PoolAlignment(getRecommendedAlignment(N)) { + OnePool(const DSNode *N) : PoolDesc(0), PoolSize(getRecommendedSize(N)), + PoolAlignment(getRecommendedAlignment(N)) { NodesInPool.push_back(N); } - OnePool(DSNode *N, Value *PD) : PoolDesc(PD), PoolSize(0), - PoolAlignment(0) { + OnePool(const DSNode *N, Value *PD) : PoolDesc(PD), PoolSize(0), + PoolAlignment(0) { NodesInPool.push_back(N); } }; @@ -75,21 +75,22 @@ /// AssignToPools - Partition NodesToPA into a set of disjoint pools, /// returning the result in ResultPools. If this is a function being pool /// allocated, F will not be null. - virtual void AssignToPools(const std::vector &NodesToPA, + virtual void AssignToPools(const std::vector &NodesToPA, Function *F, DSGraph &G, std::vector &ResultPools) = 0; // Hacks for the OnlyOverhead heuristic. - virtual void HackFunctionBody(Function &F, std::map &PDs){} + virtual void HackFunctionBody(Function &F, + std::map &PDs) {} /// getRecommendedSize - Return the recommended pool size for this DSNode. /// - static unsigned getRecommendedSize(DSNode *N); + static unsigned getRecommendedSize(const DSNode *N); /// getRecommendedAlignment - Return the recommended object alignment for /// this DSNode. /// - static unsigned getRecommendedAlignment(DSNode *N); + static unsigned getRecommendedAlignment(const DSNode *N); /// create - This static ctor creates the heuristic, based on the command /// line argument to choose the heuristic. Index: poolalloc/lib/PoolAllocate/PoolAllocate.cpp diff -u poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.97 poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.98 --- poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.97 Thu Jan 20 13:12:14 2005 +++ poolalloc/lib/PoolAllocate/PoolAllocate.cpp Sun Jan 30 17:51:25 2005 @@ -224,13 +224,13 @@ static void GetNodesReachableFromGlobals(DSGraph &G, - hash_set &NodesFromGlobals) { + hash_set &NodesFromGlobals) { for (DSScalarMap::global_iterator I = G.getScalarMap().global_begin(), E = G.getScalarMap().global_end(); I != E; ++I) G.getNodeForValue(*I).getNode()->markReachableNodes(NodesFromGlobals); } -static void MarkNodesWhichMustBePassedIn(hash_set &MarkedNodes, +static void MarkNodesWhichMustBePassedIn(hash_set &MarkedNodes, Function &F, DSGraph &G) { // Mark globals and incomplete nodes as live... (this handles arguments) if (F.getName() != "main") { @@ -250,16 +250,16 @@ // Calculate which DSNodes are reachable from globals. If a node is reachable // from a global, we will create a global pool for it, so no argument passage // is required. - hash_set NodesFromGlobals; + hash_set NodesFromGlobals; GetNodesReachableFromGlobals(G, NodesFromGlobals); // Remove any nodes reachable from a global. These nodes will be put into // global pools, which do not require arguments to be passed in. Also, erase // any marked node that is not a heap node. Since no allocations or frees // will be done with it, it needs no argument. - for (hash_set::iterator I = MarkedNodes.begin(), + for (hash_set::iterator I = MarkedNodes.begin(), E = MarkedNodes.end(); I != E; ) { - DSNode *N = *I++; + const DSNode *N = *I++; if ((!N->isHeapNode() && !PASS_ALL_ARGUMENTS) || NodesFromGlobals.count(N)) MarkedNodes.erase(N); } @@ -270,7 +270,7 @@ DSGraph &G = ECGraphs->getDSGraph(F); FuncInfo &FI = FunctionInfo[&F]; // Create a new entry for F - hash_set &MarkedNodes = FI.MarkedNodes; + hash_set &MarkedNodes = FI.MarkedNodes; if (G.node_begin() == G.node_end()) return; // No memory activity, nothing is required @@ -316,7 +316,7 @@ // Set the rest of the new arguments names to be PDa and add entries to the // pool descriptors map - std::map &PoolDescriptors = FI.PoolDescriptors; + std::map &PoolDescriptors = FI.PoolDescriptors; Function::aiterator NI = New->abegin(); for (unsigned i = 0, e = FI.ArgNodes.size(); i != e; ++i, ++NI) { @@ -367,13 +367,13 @@ DSGraph &GG = ECGraphs->getGlobalsGraph(); // Get all of the nodes reachable from globals. - hash_set GlobalHeapNodes; + hash_set GlobalHeapNodes; GetNodesReachableFromGlobals(GG, GlobalHeapNodes); // Filter out all nodes which have no heap allocations merged into them. - for (hash_set::iterator I = GlobalHeapNodes.begin(), + for (hash_set::iterator I = GlobalHeapNodes.begin(), E = GlobalHeapNodes.end(); I != E; ) { - hash_set::iterator Last = I++; + hash_set::iterator Last = I++; if (!(*Last)->isHeapNode()) GlobalHeapNodes.erase(Last); } @@ -390,7 +390,8 @@ << " global nodes!\n"; - std::vector NodesToPA(GlobalHeapNodes.begin(),GlobalHeapNodes.end()); + std::vector NodesToPA(GlobalHeapNodes.begin(), + GlobalHeapNodes.end()); std::vector ResultPools; CurHeuristic->AssignToPools(NodesToPA, 0, GG, ResultPools); @@ -415,7 +416,7 @@ } // Any unallocated DSNodes get null pool descriptor pointers. - for (hash_set::iterator I = GlobalHeapNodes.begin(), + for (hash_set::iterator I = GlobalHeapNodes.begin(), E = GlobalHeapNodes.end(); I != E; ++I) { GlobalNodes[*I] = Constant::getNullValue(PointerType::get(PoolDescType)); ++NumNonprofit; @@ -456,15 +457,16 @@ // PoolDescriptors map for each DSNode. // void PoolAllocate::CreatePools(Function &F, - const std::vector &NodesToPA, - std::map &PoolDescriptors) { + const std::vector &NodesToPA, + std::map &PoolDescriptors) { if (NodesToPA.empty()) return; std::vector ResultPools; CurHeuristic->AssignToPools(NodesToPA, &F, *NodesToPA[0]->getParentGraph(), ResultPools); - std::set UnallocatedNodes(NodesToPA.begin(), NodesToPA.end()); + std::set UnallocatedNodes(NodesToPA.begin(), NodesToPA.end()); BasicBlock::iterator InsertPoint = F.front().begin(); while (isa(InsertPoint)) ++InsertPoint; @@ -497,7 +499,7 @@ } // Any unallocated DSNodes get null pool descriptor pointers. - for (std::set::iterator I = UnallocatedNodes.begin(), + for (std::set::iterator I = UnallocatedNodes.begin(), E = UnallocatedNodes.end(); I != E; ++I) { PoolDescriptors[*I] =Constant::getNullValue(PointerType::get(PoolDescType)); ++NumNonprofit; @@ -513,7 +515,7 @@ if (G.node_begin() == G.node_end()) return; // Quick exit if nothing to do. FuncInfo &FI = FunctionInfo[&F]; // Get FuncInfo for F - hash_set &MarkedNodes = FI.MarkedNodes; + hash_set &MarkedNodes = FI.MarkedNodes; // Calculate which DSNodes are reachable from globals. If a node is reachable // from a global, we will create a global pool for it, so no argument passage @@ -531,7 +533,7 @@ // Loop over all of the nodes which are non-escaping, adding pool-allocatable // ones to the NodesToPA vector. - std::vector NodesToPA; + std::vector NodesToPA; for (DSGraph::node_iterator I = G.node_begin(), E = G.node_end(); I != E;++I){ // We only need to make a pool if there is a heap object in it... DSNode *N = *I; @@ -616,8 +618,8 @@ /// InitializeAndDestroyPools- This inserts calls to poolinit and pooldestroy /// into the function to initialize and destroy one pool. /// -void PoolAllocate::InitializeAndDestroyPool(Function &F, DSNode *Node, - std::map &PoolDescriptors, +void PoolAllocate::InitializeAndDestroyPool(Function &F, const DSNode *Node, + std::map &PoolDescriptors, std::multimap &PoolUses, std::multimap &PoolFrees) { AllocaInst *PD = cast(PoolDescriptors[Node]); @@ -812,15 +814,15 @@ /// into the function to initialize and destroy the pools in the NodesToPA list. /// void PoolAllocate::InitializeAndDestroyPools(Function &F, - const std::vector &NodesToPA, - std::map &PoolDescriptors, + const std::vector &NodesToPA, + std::map &PoolDescriptors, std::multimap &PoolUses, std::multimap &PoolFrees) { std::set AllocasHandled; // Insert all of the poolinit/destroy calls into the function. for (unsigned i = 0, e = NodesToPA.size(); i != e; ++i) { - DSNode *Node = NodesToPA[i]; + const DSNode *Node = NodesToPA[i]; if (isa(PoolDescriptors[Node]) || isa(PoolDescriptors[Node])) Index: poolalloc/lib/PoolAllocate/PoolAllocate.h diff -u poolalloc/lib/PoolAllocate/PoolAllocate.h:1.33 poolalloc/lib/PoolAllocate/PoolAllocate.h:1.34 --- poolalloc/lib/PoolAllocate/PoolAllocate.h:1.33 Tue Dec 14 14:16:24 2004 +++ poolalloc/lib/PoolAllocate/PoolAllocate.h Sun Jan 30 17:51:25 2005 @@ -49,14 +49,14 @@ /// MarkedNodes - The set of nodes which are not locally pool allocatable in /// the current function. /// - hash_set MarkedNodes; + hash_set MarkedNodes; /// Clone - The cloned version of the function, if applicable. Function *Clone; /// ArgNodes - The list of DSNodes which have pools passed in as arguments. /// - std::vector ArgNodes; + std::vector ArgNodes; /// PoolDescriptors - The Value* (either an argument or an alloca) which /// defines the pool descriptor for this DSNode. Pools are mapped one to @@ -68,7 +68,7 @@ /// not. /// Note: Does not include pool arguments that are passed in because of /// indirect function calls that are not used in the function. - std::map PoolDescriptors; + std::map PoolDescriptors; //This is a map from Old to New Value Map reverse of the one above //Useful in SAFECode for check insertion @@ -104,7 +104,7 @@ /// GlobalNodes - For each node (with an H marker) in the globals graph, this /// map contains the global variable that holds the pool descriptor for the /// node. - std::map GlobalNodes; + std::map GlobalNodes; public: bool runOnModule(Module &M); @@ -183,8 +183,8 @@ /// pools specified in the NodesToPA list. This adds an entry to the /// PoolDescriptors map for each DSNode. /// - void CreatePools(Function &F, const std::vector &NodesToPA, - std::map &PoolDescriptors); + void CreatePools(Function &F, const std::vector &NodesToPA, + std::map &PoolDescriptors); void TransformBody(DSGraph &g, PA::FuncInfo &fi, std::multimap &poolUses, @@ -195,13 +195,13 @@ /// into the function to initialize and destroy the pools in the NodesToPA /// list. void InitializeAndDestroyPools(Function &F, - const std::vector &NodesToPA, - std::map &PoolDescriptors, + const std::vector &NodesToPA, + std::map &PoolDescriptors, std::multimap &PoolUses, std::multimap &PoolFrees); - void InitializeAndDestroyPool(Function &F, DSNode *Pool, - std::map &PoolDescriptors, + void InitializeAndDestroyPool(Function &F, const DSNode *Pool, + std::map &PoolDescriptors, std::multimap &PoolUses, std::multimap &PoolFrees); Index: poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp diff -u poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.34 poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.35 --- poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.34 Tue Dec 14 14:16:24 2004 +++ poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp Sun Jan 30 17:51:25 2005 @@ -102,7 +102,8 @@ Value *getPoolHandle(Value *V) { DSNode *Node = getDSNodeHFor(V).getNode(); // Get the pool handle for this DSNode... - std::map::iterator I = FI.PoolDescriptors.find(Node); + std::map::iterator I = + FI.PoolDescriptors.find(Node); return I != FI.PoolDescriptors.end() ? I->second : 0; } @@ -422,7 +423,7 @@ DSGraph::NodeMapTy NodeMapping; Instruction *NewCall; Value *NewCallee; - std::vector ArgNodes; + std::vector ArgNodes; DSGraph *CalleeGraph; // The callee graph // For indirect callees find any callee since all DS graphs have been merged. From lattner at cs.uiuc.edu Sun Jan 30 18:11:14 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 30 Jan 2005 18:11:14 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp DataStructure.cpp Message-ID: <200501310011.j0V0BECw008036@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: CompleteBottomUp.cpp updated: 1.16 -> 1.17 DataStructure.cpp updated: 1.187 -> 1.188 --- Log message: Rename variables to work with VC++'s hokey scoping rules. --- Diffs of the changes: (+10 -9) CompleteBottomUp.cpp | 5 +++-- DataStructure.cpp | 14 +++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) Index: llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp diff -u llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp:1.16 llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp:1.17 --- llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp:1.16 Sun Jan 30 17:51:00 2005 +++ llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp Sun Jan 30 18:10:58 2005 @@ -122,7 +122,8 @@ Stack.push_back(&FG); // The edges out of the current node are the call site targets... - for (DSGraph::fc_iterator CI = FG.fc_begin(), E = FG.fc_end(); CI != E; ++CI){ + for (DSGraph::fc_iterator CI = FG.fc_begin(), CE = FG.fc_end(); + CI != CE; ++CI) { Instruction *Call = CI->getCallSite().getInstruction(); // Loop over all of the actually called functions... @@ -185,7 +186,7 @@ // The edges out of the current node are the call site targets... unsigned i = 0; - for (DSGraph::fc_iterator CI = G.fc_begin(), E = G.fc_end(); CI != E; + for (DSGraph::fc_iterator CI = G.fc_begin(), CE = G.fc_end(); CI != CE; ++CI, ++i) { const DSCallSite &CS = *CI; Instruction *TheCall = CS.getCallSite().getInstruction(); Index: llvm/lib/Analysis/DataStructure/DataStructure.cpp diff -u llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.187 llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.188 --- llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.187 Sun Jan 30 17:51:01 2005 +++ llvm/lib/Analysis/DataStructure/DataStructure.cpp Sun Jan 30 18:10:58 2005 @@ -1595,17 +1595,17 @@ Calls.sort(); // Now that we are in sorted order, eliminate duplicates. - std::list::iterator I = Calls.begin(), E = Calls.end(); - if (I != E) + std::list::iterator CI = Calls.begin(), CE = Calls.end(); + if (CI != CE) while (1) { - std::list::iterator OldIt = I++; - if (I == E) break; + std::list::iterator OldIt = CI++; + if (CI == CE) break; // If this call site is now the same as the previous one, we can delete it // as a duplicate. - if (*OldIt == *I) { - Calls.erase(I); - I = OldIt; + if (*OldIt == *CI) { + Calls.erase(CI); + CI = OldIt; ++NumDeleted; } } From lattner at cs.uiuc.edu Sun Jan 30 18:11:28 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 30 Jan 2005 18:11:28 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/TopDownClosure.cpp BottomUpClosure.cpp Message-ID: <200501310011.j0V0BSYF008045@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: TopDownClosure.cpp updated: 1.72 -> 1.73 BottomUpClosure.cpp updated: 1.86 -> 1.87 --- Log message: Fix some scary bugs that VC++ detected. --- Diffs of the changes: (+2 -2) BottomUpClosure.cpp | 2 +- TopDownClosure.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/lib/Analysis/DataStructure/TopDownClosure.cpp diff -u llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.72 llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.73 --- llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.72 Sun Jan 30 17:51:02 2005 +++ llvm/lib/Analysis/DataStructure/TopDownClosure.cpp Sun Jan 30 18:10:45 2005 @@ -304,7 +304,7 @@ return; } - if (Function *F = dyn_cast(F)) { + if (Function *F = dyn_cast(V)) { assert(getDSGraph(*F).getReturnNodes().size() == 1 && "cannot handle scc's"); delete DSInfo[F]; Index: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp diff -u llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.86 llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.87 --- llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.86 Sun Jan 30 17:51:00 2005 +++ llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp Sun Jan 30 18:10:45 2005 @@ -363,7 +363,7 @@ return; } - if (Function *F = dyn_cast(F)) { + if (Function *F = dyn_cast(V)) { assert(getDSGraph(*F).getReturnNodes().size() == 1 && "cannot handle scc's"); delete DSInfo[F]; From lattner at cs.uiuc.edu Sun Jan 30 19:11:29 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 30 Jan 2005 19:11:29 -0600 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.cpp Message-ID: <200501310111.j0V1BTgH011989@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: Reader.cpp updated: 1.151 -> 1.152 --- Log message: Fix the regressions my User changes introduced. Apparently some parts of LLVM make the very reasonable assumption that constant expressions will have at least one operand! :) --- Diffs of the changes: (+4 -1) Reader.cpp | 5 ++++- 1 files changed, 4 insertions(+), 1 deletion(-) Index: llvm/lib/Bytecode/Reader/Reader.cpp diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.151 llvm/lib/Bytecode/Reader/Reader.cpp:1.152 --- llvm/lib/Bytecode/Reader/Reader.cpp:1.151 Fri Jan 28 18:36:19 2005 +++ llvm/lib/Bytecode/Reader/Reader.cpp Sun Jan 30 19:11:13 2005 @@ -38,8 +38,11 @@ ConstantPlaceHolder(); // DO NOT IMPLEMENT void operator=(const ConstantPlaceHolder &); // DO NOT IMPLEMENT public: + Use Op; ConstantPlaceHolder(const Type *Ty) - : ConstantExpr(Ty, Instruction::UserOp1, 0, 0) {} + : ConstantExpr(Ty, Instruction::UserOp1, &Op, 1), + Op(UndefValue::get(Type::IntTy), this) { + } }; } From alenhar2 at cs.uiuc.edu Sun Jan 30 19:44:41 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Sun, 30 Jan 2005 19:44:41 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp AlphaInstrInfo.td Message-ID: <200501310144.TAA26473@niobe.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.20 -> 1.21 AlphaInstrInfo.td updated: 1.10 -> 1.11 --- Log message: fp to int and back conversion sequences --- Diffs of the changes: (+34 -14) AlphaISelPattern.cpp | 46 +++++++++++++++++++++++++++++++++------------- AlphaInstrInfo.td | 2 +- 2 files changed, 34 insertions(+), 14 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.20 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.21 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.20 Sun Jan 30 14:42:36 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Sun Jan 30 19:44:26 2005 @@ -412,6 +412,7 @@ { assert (N.getOperand(0).getValueType() == MVT::i64 && "only quads can be loaded from"); Tmp1 = SelectExpr(N.getOperand(0)); // Get the operand register + Tmp2 = MakeReg(MVT::f64); //The hard way: // Spill the integer to memory and reload it from there. @@ -419,12 +420,10 @@ MachineFunction *F = BB->getParent(); int FrameIdx = F->getFrameInfo()->CreateStackObject(Size, Size); - //STL LDS - //STQ LDT - Opc = DestType == MVT::f64 ? Alpha::STQ : Alpha::STL; - BuildMI(BB, Opc, 2).addReg(Tmp1).addFrameIndex(FrameIdx).addReg(Alpha::F31); - Opc = DestType == MVT::f64 ? Alpha::LDT : Alpha::LDS; - BuildMI(BB, Opc, 1, Result).addFrameIndex(FrameIdx).addReg(Alpha::F31); + BuildMI(BB, Alpha::STQ, 3).addReg(Tmp1).addFrameIndex(FrameIdx).addReg(Alpha::F31); + BuildMI(BB, Alpha::LDT, 2, Tmp2).addFrameIndex(FrameIdx).addReg(Alpha::F31); + 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 @@ -965,13 +964,34 @@ return Result; // // case ISD::UINT_TO_FP: -// case ISD::FP_TO_SINT: -// assert (N.getValueType() == MVT::f64 && "Only can convert for doubles"); -// Tmp1 = SelectExpr(N.getOperand(0)); // Get the operand register -// Tmp2 = MakeReg(SrcTy); -// BuildMI(BB, CVTTQ, 1, Tmp2).addReg(Tmp1); -// BuildMI(BB, FTOIT, 1, Result).addReg(Tmp2); -// return result; + + case ISD::FP_TO_SINT: + { + assert (DestType == MVT::i64 && "only quads can be loaded to"); + MVT::ValueType SrcType = N.getOperand(0).getValueType(); + 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::CVTTQ, 1, Tmp2).addReg(Tmp1); + BuildMI(BB, Alpha::STT, 3).addReg(Tmp2).addFrameIndex(FrameIdx).addReg(Alpha::F31); + BuildMI(BB, Alpha::LDQ, 2, Result).addFrameIndex(FrameIdx).addReg(Alpha::F31); + + return Result; + } // // case ISD::FP_TO_UINT: Index: llvm/lib/Target/Alpha/AlphaInstrInfo.td diff -u llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.10 llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.11 --- llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.10 Sun Jan 30 14:42:36 2005 +++ llvm/lib/Target/Alpha/AlphaInstrInfo.td Sun Jan 30 19:44:26 2005 @@ -331,7 +331,7 @@ def CVTQS : FPForm<0x16, 0x0BC, (ops FPRC:$RC, FPRC:$RA), "cvtqs $RA,$RC">; //Convert quadword to S_floating def CVTQT : FPForm<0x16, 0x0BE, (ops FPRC:$RC, FPRC:$RA), "cvtqt $RA,$RC">; //Convert quadword to T_floating def CVTST : FPForm<0x16, 0x2AC, (ops FPRC:$RC, FPRC:$RA), "cvtst $RA,$RC">; //Convert S_floating to T_floating -//CVTTQ F-P 16.0AF Convert T_floating to quadword +def CVTTQ : FPForm<0x16, 0x0AF, (ops FPRC:$RC, FPRC:$RA), "cvttq $RA,$RC">; //Convert T_floating to quadword def CVTTS : FPForm<0x16, 0x2AC, (ops FPRC:$RC, FPRC:$RA), "cvtts $RA,$RC">; //Convert T_floating to S_floating //S_floating : IEEE Single From alenhar2 at cs.uiuc.edu Sun Jan 30 21:19:46 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Sun, 30 Jan 2005 21:19:46 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaInstrInfo.td Message-ID: <200501310319.VAA26527@niobe.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaInstrInfo.td updated: 1.11 -> 1.12 --- Log message: indirect call fix --- Diffs of the changes: (+1 -1) AlphaInstrInfo.td | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/Target/Alpha/AlphaInstrInfo.td diff -u llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.11 llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.12 --- llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.11 Sun Jan 30 19:44:26 2005 +++ llvm/lib/Target/Alpha/AlphaInstrInfo.td Sun Jan 30 21:19:31 2005 @@ -248,7 +248,7 @@ def JMP : MForm< 0x1A, (ops GPRC:$RD, GPRC:$RS), "jmp $RD,($RS),0">; //Jump let isCall = 1, Defs = [R0, R1, R2, R3, R4, R5, R6, R7, R8, R16, R17, R18, R19, - R20, R21, R22, R23, R24, R25, R26, R27, R29, + R20, R21, R22, R23, R24, R25, R27, R29, F0, F1, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, F25, F26, F27, F28, F29, F30], From lattner at cs.uiuc.edu Sun Jan 30 22:49:38 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 30 Jan 2005 22:49:38 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/InstCombine/cast-load-gep.ll Message-ID: <200501310449.j0V4nbLs015059@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/InstCombine: cast-load-gep.ll added (r1.1) --- Log message: New testcase --- Diffs of the changes: (+22 -0) cast-load-gep.ll | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+) Index: llvm/test/Regression/Transforms/InstCombine/cast-load-gep.ll diff -c /dev/null llvm/test/Regression/Transforms/InstCombine/cast-load-gep.ll:1.1 *** /dev/null Sun Jan 30 22:49:32 2005 --- llvm/test/Regression/Transforms/InstCombine/cast-load-gep.ll Sun Jan 30 22:49:22 2005 *************** *** 0 **** --- 1,22 ---- + ; RUN: llvm-as < %s | opt -instcombine -globaldce | llvm-dis | not grep Array + + ; Pulling the cast out of the load allows us to eliminate the load, and then + ; the whole array. + + %unop = type {int } + %op = type {float} + + %Array = internal constant [1 x %op* (%op*)*] [ %op* (%op*)* %foo ] + + implementation + + %op* %foo(%op* %X) { + ret %op* %X + } + + %unop* %caller(%op* %O) { + %tmp = load %unop* (%op*)** cast ([1 x %op* (%op*)*]* %Array to %unop* (%op*)**) + %tmp.2 = call %unop* (%op*)* %tmp(%op* %O) + ret %unop* %tmp.2 + } + From lattner at cs.uiuc.edu Sun Jan 30 22:50:59 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 30 Jan 2005 22:50:59 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200501310450.j0V4oxne015258@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.312 -> 1.313 --- Log message: Implement Transforms/InstCombine/cast-load-gep.ll, which allows us to devirtualize 11 indirect calls in perlbmk. --- Diffs of the changes: (+29 -15) InstructionCombining.cpp | 44 +++++++++++++++++++++++++++++--------------- 1 files changed, 29 insertions(+), 15 deletions(-) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.312 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.313 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.312 Fri Jan 28 18:39:08 2005 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Sun Jan 30 22:50:46 2005 @@ -4623,24 +4623,38 @@ static Instruction *InstCombineLoadCast(InstCombiner &IC, LoadInst &LI) { User *CI = cast(LI.getOperand(0)); + Value *CastOp = CI->getOperand(0); const Type *DestPTy = cast(CI->getType())->getElementType(); - if (const PointerType *SrcTy = - dyn_cast(CI->getOperand(0)->getType())) { + if (const PointerType *SrcTy = dyn_cast(CastOp->getType())) { const Type *SrcPTy = SrcTy->getElementType(); - if (SrcPTy->isSized() && DestPTy->isSized() && - IC.getTargetData().getTypeSize(SrcPTy) == - IC.getTargetData().getTypeSize(DestPTy) && - (SrcPTy->isInteger() || isa(SrcPTy)) && - (DestPTy->isInteger() || isa(DestPTy))) { - // Okay, we are casting from one integer or pointer type to another of - // the same size. Instead of casting the pointer before the load, cast - // the result of the loaded value. - Value *NewLoad = IC.InsertNewInstBefore(new LoadInst(CI->getOperand(0), - CI->getName(), - LI.isVolatile()),LI); - // Now cast the result of the load. - return new CastInst(NewLoad, LI.getType()); + + if (DestPTy->isInteger() || isa(DestPTy)) { + // If the source is an array, the code below will not succeed. Check to + // see if a trivial 'gep P, 0, 0' will help matters. Only do this for + // constants. + if (const ArrayType *ASrcTy = dyn_cast(SrcPTy)) + if (Constant *CSrc = dyn_cast(CastOp)) + if (ASrcTy->getNumElements() != 0) { + std::vector Idxs(2, Constant::getNullValue(Type::IntTy)); + CastOp = ConstantExpr::getGetElementPtr(CSrc, Idxs); + SrcTy = cast(CastOp->getType()); + SrcPTy = SrcTy->getElementType(); + } + + if ((SrcPTy->isInteger() || isa(SrcPTy)) && + IC.getTargetData().getTypeSize(SrcPTy) == + IC.getTargetData().getTypeSize(DestPTy)) { + + // Okay, we are casting from one integer or pointer type to another of + // the same size. Instead of casting the pointer before the load, cast + // the result of the loaded value. + Value *NewLoad = IC.InsertNewInstBefore(new LoadInst(CastOp, + CI->getName(), + LI.isVolatile()),LI); + // Now cast the result of the load. + return new CastInst(NewLoad, LI.getType()); + } } } return 0; From lattner at cs.uiuc.edu Sun Jan 30 23:17:46 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 30 Jan 2005 23:17:46 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/InstCombine/cast.ll Message-ID: <200501310517.j0V5HkpD015899@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/InstCombine: cast.ll updated: 1.23 -> 1.24 --- Log message: Rename these to start with %c, as they are the only ones that are checked. No change to the tests themselves. --- Diffs of the changes: (+15 -15) cast.ll | 30 +++++++++++++++--------------- 1 files changed, 15 insertions(+), 15 deletions(-) Index: llvm/test/Regression/Transforms/InstCombine/cast.ll diff -u llvm/test/Regression/Transforms/InstCombine/cast.ll:1.23 llvm/test/Regression/Transforms/InstCombine/cast.ll:1.24 --- llvm/test/Regression/Transforms/InstCombine/cast.ll:1.23 Sat Jan 1 10:13:43 2005 +++ llvm/test/Regression/Transforms/InstCombine/cast.ll Sun Jan 30 23:17:31 2005 @@ -118,40 +118,40 @@ } bool %test19(int %X) { - %Y = cast int %X to long - %Z = setlt long %Y, 12345 + %c = cast int %X to long + %Z = setlt long %c, 12345 ret bool %Z } bool %test20(bool %B) { - %C = cast bool %B to int - %D = setlt int %C, -1 + %c = cast bool %B to int + %D = setlt int %c, -1 ret bool %D ;; false } uint %test21(uint %X) { - %Y = cast uint %X to sbyte - %Z = cast sbyte %Y to uint ;; sext -> zext -> and -> nop - %RV = and uint %Z, 255 + %c1 = cast uint %X to sbyte + %c2 = cast sbyte %c1 to uint ;; sext -> zext -> and -> nop + %RV = and uint %c2, 255 ret uint %RV } uint %test22(uint %X) { - %Y = cast uint %X to sbyte - %Z = cast sbyte %Y to uint ;; sext -> zext -> and -> nop - %RV = shl uint %Z, ubyte 24 + %c1 = cast uint %X to sbyte + %c2 = cast sbyte %c1 to uint ;; sext -> zext -> and -> nop + %RV = shl uint %c2, ubyte 24 ret uint %RV } int %test23(int %X) { - %Y = cast int %X to ushort ;; Turn into an AND even though X - %Z = cast ushort %Y to int ;; and Z are signed. - ret int %Z + %c1 = cast int %X to ushort ;; Turn into an AND even though X + %c2 = cast ushort %c1 to int ;; and Z are signed. + ret int %c2 } bool %test24(bool %C) { %X = select bool %C, uint 14, uint 1234 - %Y = cast uint %X to bool ;; Fold cast into select - ret bool %Y + %c = cast uint %X to bool ;; Fold cast into select + ret bool %c } From lattner at cs.uiuc.edu Sun Jan 30 23:36:34 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 30 Jan 2005 23:36:34 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/InstCombine/store.ll Message-ID: <200501310536.j0V5aYjh016680@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/InstCombine: store.ll added (r1.1) --- Log message: New testcase --- Diffs of the changes: (+9 -0) store.ll | 9 +++++++++ 1 files changed, 9 insertions(+) Index: llvm/test/Regression/Transforms/InstCombine/store.ll diff -c /dev/null llvm/test/Regression/Transforms/InstCombine/store.ll:1.1 *** /dev/null Sun Jan 30 23:36:30 2005 --- llvm/test/Regression/Transforms/InstCombine/store.ll Sun Jan 30 23:36:19 2005 *************** *** 0 **** --- 1,9 ---- + ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep -v 'store.*,.*null' | not grep store + + + void %test1(int* %P) { + store int undef, int* %P + store int 123, int* undef + store int 124, int* null + ret void + } From lattner at cs.uiuc.edu Sun Jan 30 23:36:56 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 30 Jan 2005 23:36:56 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200501310536.j0V5aucu016695@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.313 -> 1.314 --- Log message: Implement the trivial cases in InstCombine/store.ll --- Diffs of the changes: (+38 -1) InstructionCombining.cpp | 39 ++++++++++++++++++++++++++++++++++++++- 1 files changed, 38 insertions(+), 1 deletion(-) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.313 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.314 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.313 Sun Jan 30 22:50:46 2005 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Sun Jan 30 23:36:43 2005 @@ -130,6 +130,7 @@ Instruction *visitAllocationInst(AllocationInst &AI); Instruction *visitFreeInst(FreeInst &FI); Instruction *visitLoadInst(LoadInst &LI); + Instruction *visitStoreInst(StoreInst &SI); Instruction *visitBranchInst(BranchInst &BI); Instruction *visitSwitchInst(SwitchInst &SI); @@ -4804,6 +4805,42 @@ return 0; } +Instruction *InstCombiner::visitStoreInst(StoreInst &SI) { + Value *Val = SI.getOperand(0); + Value *Ptr = SI.getOperand(1); + + if (isa(Ptr)) { // store X, undef -> noop (even if volatile) + removeFromWorkList(&SI); + SI.eraseFromParent(); + ++NumCombined; + return 0; + } + + if (SI.isVolatile()) return 0; // Don't hack volatile loads. + + // store X, null -> turns into 'unreachable' in SimplifyCFG + if (isa(Ptr)) { + if (!isa(Val)) { + SI.setOperand(0, UndefValue::get(Val->getType())); + if (Instruction *U = dyn_cast(Val)) + WorkList.push_back(U); // Dropped a use. + ++NumCombined; + } + return 0; // Do not modify these! + } + + // store undef, Ptr -> noop + if (isa(Val)) { + removeFromWorkList(&SI); + SI.eraseFromParent(); + ++NumCombined; + return 0; + } + + return 0; +} + + Instruction *InstCombiner::visitBranchInst(BranchInst &BI) { // Change br (not X), label True, label False to: br X, label False, True Value *X; @@ -5039,7 +5076,7 @@ // Instructions may end up in the worklist more than once. Erase all // occurrances of this instruction. removeFromWorkList(I); - I->getParent()->getInstList().erase(I); + I->eraseFromParent(); } else { WorkList.push_back(Result); AddUsersToWorkList(*Result); From jeffc at jolt-lang.org Sun Jan 30 23:42:20 2005 From: jeffc at jolt-lang.org (Jeff Cohen) Date: Sun, 30 Jan 2005 23:42:20 -0600 Subject: [llvm-commits] CVS: llvm/docs/GettingStartedVS.html Message-ID: <200501310542.XAA30196@zion.cs.uiuc.edu> Changes in directory llvm/docs: GettingStartedVS.html added (r1.1) --- Log message: Add LLVM with Visual Studio overview --- Diffs of the changes: (+433 -0) GettingStartedVS.html | 433 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 433 insertions(+) Index: llvm/docs/GettingStartedVS.html diff -c /dev/null llvm/docs/GettingStartedVS.html:1.1 *** /dev/null Sun Jan 30 23:42:20 2005 --- llvm/docs/GettingStartedVS.html Sun Jan 30 23:42:10 2005 *************** *** 0 **** --- 1,433 ---- + + + + + Getting Started with LLVM System for Microsoft Visual Studio + + + + +
        + Getting Started with the LLVM System using Microsoft Visual Studio +
        + + + +
        +

        Written by: + Jeff Cohen, +

        +
        + + + +
        + Overview +
        + + +
        + +

        The Visual Studio port at this time is experimental. It is suitable for + use only if you are writing your own compiler front end or otherwise have a + need to dynamically generate machine code. The JIT and interpreter are + functional, but it is currently not possible to directly generate an + executable file. You can do so indirectly by using the C back end.

        + +

        To emphasize, there is no C/C++ front end currently available. llvm-gcc + is based on GCC, which cannot be bootstrapped using VC++. Eventually there + should be a llvm-gcc based on Cygwin or Mingw that is usable. There is also + the option of generating bytecode files on Unix and copying them over to + Windows. But be aware the odds of linking C++ code compiled with llvm-gcc + with code compiled with VC++ is essentially zero.

        + +

        The LLVM test suite cannot be run on the Visual Studio port at this + time.

        + +

        Most of the tools build and work. llvm-db does not build at this + time. bugpoint does build, but does not work. + +

        Additional information about the LLVM directory structure and tool chain + can be found on the main Getting Started + page.

        + +
        + + + + + +
        + +

        Here's the short story for getting up and running quickly with LLVM:

        + +
          +
        1. Read the documentation.
        2. +
        3. Read the documentation.
        4. +
        5. Remember that you were warned twice about reading the documentation.
        6. + +
        7. Get the Source Code +
            +
          • With the distributed files: +
              +
            1. cd where-you-want-llvm-to-live +
            2. gunzip --stdout llvm-version.tar.gz | tar -xvf - + or use WinZip +
            3. cd llvm
            4. +
          • + +
          • With anonymous CVS access (or use a mirror): +
              +
            1. cd where-you-want-llvm-to-live
            2. +
            3. cvs -d + :pserver:anon at llvm-cvs.cs.uiuc.edu:/var/cvs/llvm login
            4. +
            5. Hit the return key when prompted for the password. +
            6. cvs -z3 -d :pserver:anon at llvm-cvs.cs.uiuc.edu:/var/cvs/llvm + co llvm
            7. +
            8. cd llvm
            9. +
            10. cvs up -P -d
            11. +
          • +
        8. + +
        9. Start Visual Studio +
            +
          1. Simply double click on the solution file llvm/win32/llvm.sln. +
          2. +
        10. + +
        11. Build the LLVM Suite: +
            +
          1. Simply build the solution.
          2. +
          3. The Fibonacci project is a sample program that uses the JIT. Modify + the project's debugging properties to provide a numeric command line + argument. The program will print the corresponding fibonacci value.
          4. +
        12. + +
        + +
        + + + + + +
        + +

        Before you begin to use the LLVM system, review the requirements given + below. This may save you some trouble by knowing ahead of time what hardware + and software you will need.

        + +
        + + +
        + Hardware +
        + +
        + +

        Any system that can adequately run Visual Studio .NET 2003 is fine. The + LLVM source tree and object files, libraries and executables will consume + approximately 3GB.

        + +
        + + + +
        + +

        You will need Visual Studio .NET 2003. Earlier versions cannot open the + solution/project files. The VS 2005 beta can, but will migrate these files + to its own format in the process. While it should work with the VS 2005 + beta, there are no guarantees and there is no support for it at this time.

        + +

        You will also need several open source packages: bison, flex, and sed. + These must be installed in llvm/win32/tools. These can be found at + http://gnuwin32.sourceforge.net/ + . Bison prefers that m4 be in the path. You must add it to the Visual + Studio configuration under the menu Options -> Projects -> VC++ + Directories. Alternatively, you can set the environment variable M4 + to point to m4 executable.

        + +
        + + + + + +
        + +

        The remainder of this guide is meant to get you up and running with + LLVM using Visual Studio and to give you some basic information about the LLVM + environment.

        + +
        + + + + +
        + +

        Throughout this manual, the following names are used to denote paths + specific to the local system and working environment. These are not + environment variables you need to set but just strings used in the rest + of this document below. In any of the examples below, simply replace + each of these names with the appropriate pathname on your local system. + All these paths are absolute:

        + +
        +
        SRC_ROOT +
        + This is the top level directory of the LLVM source tree. +

        + +

        OBJ_ROOT +
        + This is the top level directory of the LLVM object tree (i.e. the + tree where object files and compiled programs will be placed. It + is fixed at SRC_ROOT/win32). +

        +

        + +
        + + + + +
        + +

        + If you have the LLVM distribution, you will need to unpack it before you + can begin to compile it. LLVM is distributed as a set of two files: the LLVM + suite and the LLVM GCC front end compiled for your platform. There is an + additional test suite that is optional. Each file is a TAR archive that is + compressed with the gzip program. The WinZip program can also unpack this + archive. Only the LLVM suite is usable with Visual Studio. +

        + +

        The files are as follows: +

        +
        llvm-1.4.tar.gz
        +
        This is the source code for the LLVM libraries and tools.
        +
        + +
        + + + + +
        + +

        If you have access to our CVS repository, you can get a fresh copy of + the entire source code. Note that significant progress has been made on the + Visual Studio port since 1.4 was released. All you need to do is check it out + from CVS as follows:

        + +
          +
        • cd where-you-want-llvm-to-live +
        • cvs -d :pserver:anon at llvm-cvs.cs.uiuc.edu:/var/cvs/llvm login +
        • Hit the return key when prompted for the password. +
        • cvs -z3 -d :pserver:anon at llvm-cvs.cs.uiuc.edu:/var/cvs/llvm co + llvm +
        + +

        This will create an 'llvm' directory in the current + directory and fully populate it with the LLVM source code, Makefiles, + test directories, and local copies of documentation files.

        + +

        If you want to get a specific release (as opposed to the most recent + revision), you can specify a label. The following releases have the following + label:

        + +
          +
        • Release 1.4: RELEASE_14
        • +
        • Release 1.3: RELEASE_13
        • +
        • Release 1.2: RELEASE_12
        • +
        • Release 1.1: RELEASE_11
        • +
        • Release 1.0: RELEASE_1
        • +
        + +
        + + + + +
        + +

        If the main CVS server is overloaded or inaccessible, you can try one of + these user-hosted mirrors:

        + + +
        + + + + +
        + +

        The object files are placed under OBJ_ROOT/Debug for debug builds + and OBJ_ROOT/Release for release (optimized) builds. These include + both executables and libararies that your application can link against. + +

        The files that configure would create when building on Unix are + created by the Configure project and placed in + OBJ_ROOT/llvm. You application must have OBJ_ROOT in its include + search path just before SRC_ROOT/include. + +

        + + + + + +
        + +
          +
        1. First, create a simple C file, name it 'hello.c': +
          +    #include <stdio.h>
          +    int main() {
          +      printf("hello world\n");
          +      return 0;
          +    }
          +        
        2. + +
        3. Next, compile the C file into a LLVM bytecode file:

          +

          % llvm-gcc hello.c -o hello

          + +

          Note that you should have already built the tools and they have to be + in your path, at least gccas and gccld.

          + +

          This will create two result files: hello and + hello.bc. The hello.bc is the LLVM bytecode that + corresponds the the compiled program and the library facilities that it + required. hello is a simple shell script that runs the bytecode + file with lli, making the result directly executable. Note that + all LLVM optimizations are enabled by default, so there is no need for a + "-O3" switch.

          + +

          Note: while you cannot do this step on Windows, you can do it on a + Unix system and transfer hello.bc to Windows.

        4. + +
        5. Run the program. To make sure the program ran, execute the + following command:

          + +

          % lli hello.bc

        6. + +
        7. Use the llvm-dis utility to take a look at the LLVM assembly + code:

          + +

          % llvm-dis < hello.bc | less

        8. + +
        9. Compile the program to native assembly using the LLC code + generator:

          + +

          % llc hello.bc -o hello.s

          + +
        10. Assemble the native assembly language file into a program:

          + +

          Not currently possible, but eventually will use NASMW.

          + +
        11. Execute the native code program:

          + +

          % ./hello.native

        12. + +
        + +
        + + + + + +
        + +

        If you are having problems building or using LLVM, or if you have any other + general questions about LLVM, please consult the Frequently + Asked Questions page.

        + +
        + + +
        + Links +
        + + +
        + +

        This document is just an introduction to how to use LLVM to do + some simple things... there are many more interesting and complicated things + that you can do that aren't documented here (but we'll gladly accept a patch + if you want to write something up!). For more information about LLVM, check + out:

        + + + +
        + + + +
        +
        + Valid CSS! + Valid HTML 4.01! + + Chris Lattner
        + Reid Spencer
        + The LLVM Compiler Infrastructure
        + Last modified: $Date: 2005/01/31 05:42:10 $ +
        + + From lattner at cs.uiuc.edu Sun Jan 30 23:51:33 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 30 Jan 2005 23:51:33 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/InstCombine/cast.ll Message-ID: <200501310551.j0V5pXlY017323@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/InstCombine: cast.ll updated: 1.24 -> 1.25 --- Log message: New testcase --- Diffs of the changes: (+6 -0) cast.ll | 6 ++++++ 1 files changed, 6 insertions(+) Index: llvm/test/Regression/Transforms/InstCombine/cast.ll diff -u llvm/test/Regression/Transforms/InstCombine/cast.ll:1.24 llvm/test/Regression/Transforms/InstCombine/cast.ll:1.25 --- llvm/test/Regression/Transforms/InstCombine/cast.ll:1.24 Sun Jan 30 23:17:31 2005 +++ llvm/test/Regression/Transforms/InstCombine/cast.ll Sun Jan 30 23:51:18 2005 @@ -155,3 +155,9 @@ ret bool %c } +void %test25(int** %P) { + %c = cast int** %P to float** + store float* null, float** %c ;; Fold cast into null + ret void +} + From lattner at cs.uiuc.edu Sun Jan 30 23:51:58 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 30 Jan 2005 23:51:58 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200501310551.j0V5pw8T017334@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.314 -> 1.315 --- Log message: Implement InstCombine/cast.ll:test25, a case that occurs many times in spec --- Diffs of the changes: (+56 -0) InstructionCombining.cpp | 56 +++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 56 insertions(+) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.314 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.315 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.314 Sun Jan 30 23:36:43 2005 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Sun Jan 30 23:51:45 2005 @@ -4622,6 +4622,7 @@ return C; } +/// InstCombineLoadCast - Fold 'load (cast P)' -> cast (load P)' when possible. static Instruction *InstCombineLoadCast(InstCombiner &IC, LoadInst &LI) { User *CI = cast(LI.getOperand(0)); Value *CastOp = CI->getOperand(0); @@ -4805,6 +4806,51 @@ return 0; } +/// InstCombineStoreToCast - Fold 'store V, (cast P)' -> store (cast V), P' +/// when possible. +static Instruction *InstCombineStoreToCast(InstCombiner &IC, StoreInst &SI) { + User *CI = cast(SI.getOperand(1)); + Value *CastOp = CI->getOperand(0); + + const Type *DestPTy = cast(CI->getType())->getElementType(); + if (const PointerType *SrcTy = dyn_cast(CastOp->getType())) { + const Type *SrcPTy = SrcTy->getElementType(); + + if (DestPTy->isInteger() || isa(DestPTy)) { + // If the source is an array, the code below will not succeed. Check to + // see if a trivial 'gep P, 0, 0' will help matters. Only do this for + // constants. + if (const ArrayType *ASrcTy = dyn_cast(SrcPTy)) + if (Constant *CSrc = dyn_cast(CastOp)) + if (ASrcTy->getNumElements() != 0) { + std::vector Idxs(2, Constant::getNullValue(Type::IntTy)); + CastOp = ConstantExpr::getGetElementPtr(CSrc, Idxs); + SrcTy = cast(CastOp->getType()); + SrcPTy = SrcTy->getElementType(); + } + + if ((SrcPTy->isInteger() || isa(SrcPTy)) && + IC.getTargetData().getTypeSize(SrcPTy) == + IC.getTargetData().getTypeSize(DestPTy)) { + + // Okay, we are casting from one integer or pointer type to another of + // the same size. Instead of casting the pointer before the store, cast + // the value to be stored. + Value *NewCast; + if (Constant *C = dyn_cast(SI.getOperand(0))) + NewCast = ConstantExpr::getCast(C, SrcPTy); + else + NewCast = IC.InsertNewInstBefore(new CastInst(SI.getOperand(0), + SrcPTy, + SI.getOperand(0)->getName()+".c"), SI); + + return new StoreInst(NewCast, CastOp); + } + } + } + return 0; +} + Instruction *InstCombiner::visitStoreInst(StoreInst &SI) { Value *Val = SI.getOperand(0); Value *Ptr = SI.getOperand(1); @@ -4837,6 +4883,16 @@ return 0; } + // If the pointer destination is a cast, see if we can fold the cast into the + // source instead. + if (CastInst *CI = dyn_cast(Ptr)) + if (Instruction *Res = InstCombineStoreToCast(*this, SI)) + return Res; + if (ConstantExpr *CE = dyn_cast(Ptr)) + if (CE->getOpcode() == Instruction::Cast) + if (Instruction *Res = InstCombineStoreToCast(*this, SI)) + return Res; + return 0; }